@jieyin/editor-sdk-test 1.1.187 → 1.1.191
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/deform.worker.js +367 -1111
- package/dist/editor-sdk.es.js +59292 -16236
- package/dist/maskWorker.js +28 -28
- package/dist/prefetch.worker.js +16 -0
- package/dist/render.worker.js +27629 -0
- package/dist/renderWorker.js +6597 -6566
- package/dist/style.css +1 -1
- package/package.json +4 -2
- package/README.md +0 -397
- package/dist/encodeWorker.js +0 -20
package/dist/deform.worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
2
|
-
const
|
|
1
|
+
var te = Object.defineProperty, re = (s, t, e) => t in s ? te(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, z = (s, t, e) => re(s, typeof t != "symbol" ? t + "" : t, e);
|
|
2
|
+
const Z = class P {
|
|
3
3
|
constructor() {
|
|
4
|
-
|
|
4
|
+
z(this, "wasmReady", !1), z(this, "go", null), z(this, "wasmModule", null);
|
|
5
5
|
}
|
|
6
6
|
isDebugEnabled() {
|
|
7
7
|
try {
|
|
@@ -10,61 +10,61 @@ const Gt = class ct {
|
|
|
10
10
|
}
|
|
11
11
|
return !1;
|
|
12
12
|
}
|
|
13
|
-
debugLog(...
|
|
13
|
+
debugLog(...t) {
|
|
14
14
|
this.isDebugEnabled();
|
|
15
15
|
}
|
|
16
|
-
debugWarn(...
|
|
16
|
+
debugWarn(...t) {
|
|
17
17
|
this.isDebugEnabled();
|
|
18
18
|
}
|
|
19
19
|
static getInstance() {
|
|
20
|
-
return
|
|
20
|
+
return P.instance || (P.instance = new P()), P.instance;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
23
|
* 在 Worker 环境中加载 WASM 模块
|
|
24
24
|
* @param wasmUrl WASM 文件路径
|
|
25
25
|
* @param wasmExecUrl wasm_exec.js 路径
|
|
26
26
|
*/
|
|
27
|
-
async load(
|
|
27
|
+
async load(t, e) {
|
|
28
28
|
if (this.wasmReady) {
|
|
29
29
|
this.debugLog("✅ WASM 已加载,跳过重复加载");
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
try {
|
|
33
33
|
this.debugLog("🚀 Worker: 加载透视变换 WASM...");
|
|
34
|
-
const r = (
|
|
35
|
-
if (e &&
|
|
34
|
+
const r = (i) => {
|
|
35
|
+
if (e && i === "wasm_exec.js")
|
|
36
36
|
return e;
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
37
|
+
if (t && i === "perspective.wasm")
|
|
38
|
+
return t;
|
|
39
39
|
try {
|
|
40
40
|
let h = null;
|
|
41
41
|
if (typeof import.meta < "u" && import.meta.url ? h = import.meta.url : typeof self < "u" && self.location && (h = self.location.href), h) {
|
|
42
|
-
const
|
|
43
|
-
if (
|
|
44
|
-
const
|
|
45
|
-
return this.debugLog(`🔍 [WASM] 计算路径: ${
|
|
46
|
-
} else if (
|
|
47
|
-
const
|
|
48
|
-
return this.debugLog(`🔍 [WASM] 计算路径: ${
|
|
42
|
+
const f = new URL(h), d = f.pathname;
|
|
43
|
+
if (d.includes("/js/")) {
|
|
44
|
+
const y = "../assets/" + i, m = new URL(y, f);
|
|
45
|
+
return this.debugLog(`🔍 [WASM] 计算路径: ${i} -> ${m.pathname} (Worker: ${d})`), m.pathname;
|
|
46
|
+
} else if (d.includes("/assets/")) {
|
|
47
|
+
const y = "./" + i, m = new URL(y, f);
|
|
48
|
+
return this.debugLog(`🔍 [WASM] 计算路径: ${i} -> ${m.pathname} (Worker: ${d})`), m.pathname;
|
|
49
49
|
} else
|
|
50
|
-
return this.debugLog(`🔍 [WASM] 使用默认绝对路径: /assets/${
|
|
50
|
+
return this.debugLog(`🔍 [WASM] 使用默认绝对路径: /assets/${i}`), "/assets/" + i;
|
|
51
51
|
}
|
|
52
52
|
} catch (h) {
|
|
53
53
|
this.debugWarn("⚠️ 无法计算 WASM 相对路径,使用默认路径:", h);
|
|
54
54
|
}
|
|
55
|
-
return "/assets/" +
|
|
56
|
-
},
|
|
57
|
-
this.debugLog("🔍 [WASM] 最终使用的路径:", { execUrl:
|
|
58
|
-
const
|
|
59
|
-
this.go = new
|
|
60
|
-
const
|
|
61
|
-
if (!
|
|
62
|
-
throw new Error(`无法加载 WASM 文件: ${
|
|
63
|
-
const
|
|
64
|
-
this.wasmModule =
|
|
65
|
-
const
|
|
66
|
-
if (
|
|
67
|
-
this.debugLog("✅ Worker WASM 加载成功:",
|
|
55
|
+
return "/assets/" + i;
|
|
56
|
+
}, n = e || r("wasm_exec.js"), u = t || r("perspective.wasm");
|
|
57
|
+
this.debugLog("🔍 [WASM] 最终使用的路径:", { execUrl: n, moduleUrl: u }), await this.loadWasmExec(n);
|
|
58
|
+
const o = typeof self < "u" ? self : globalThis;
|
|
59
|
+
this.go = new o.Go();
|
|
60
|
+
const c = await fetch(u);
|
|
61
|
+
if (!c.ok)
|
|
62
|
+
throw new Error(`无法加载 WASM 文件: ${c.status}`);
|
|
63
|
+
const w = await c.arrayBuffer(), a = await WebAssembly.instantiate(w, this.go.importObject);
|
|
64
|
+
this.wasmModule = a.instance, this.go.run(this.wasmModule), this.wasmReady = !0;
|
|
65
|
+
const l = this.call("wasmInit");
|
|
66
|
+
if (l && l.success)
|
|
67
|
+
this.debugLog("✅ Worker WASM 加载成功:", l);
|
|
68
68
|
else
|
|
69
69
|
throw new Error("WASM 初始化失败");
|
|
70
70
|
} catch (r) {
|
|
@@ -75,59 +75,59 @@ const Gt = class ct {
|
|
|
75
75
|
* 在 Worker 中加载 wasm_exec.js
|
|
76
76
|
* Module Worker 不支持 importScripts(),仅 Classic Worker 可尝试 importScripts,否则用 fetch + eval
|
|
77
77
|
*/
|
|
78
|
-
async loadWasmExec(
|
|
78
|
+
async loadWasmExec(t) {
|
|
79
79
|
return new Promise((e, r) => {
|
|
80
80
|
if (!(typeof import.meta < "u" && import.meta.url) && typeof self.importScripts == "function")
|
|
81
81
|
try {
|
|
82
|
-
self.importScripts(
|
|
82
|
+
self.importScripts(t), e();
|
|
83
83
|
return;
|
|
84
|
-
} catch (
|
|
85
|
-
this.debugWarn("⚠️ importScripts 失败,使用 fetch:",
|
|
84
|
+
} catch (u) {
|
|
85
|
+
this.debugWarn("⚠️ importScripts 失败,使用 fetch:", u);
|
|
86
86
|
}
|
|
87
|
-
fetch(
|
|
88
|
-
if (!
|
|
89
|
-
throw new Error(`HTTP ${
|
|
90
|
-
const
|
|
91
|
-
return !
|
|
92
|
-
}).then((
|
|
93
|
-
if (
|
|
94
|
-
throw new Error(`返回的是 HTML 而不是 JavaScript,可能是 404 错误。URL: ${
|
|
87
|
+
fetch(t).then((u) => {
|
|
88
|
+
if (!u.ok)
|
|
89
|
+
throw new Error(`HTTP ${u.status}: ${u.statusText} - URL: ${t}`);
|
|
90
|
+
const o = u.headers.get("content-type") || "";
|
|
91
|
+
return !o.includes("javascript") && !o.includes("text/plain") && this.debugWarn("⚠️ [WASM] 响应 Content-Type 不是 JavaScript:", o), u.text();
|
|
92
|
+
}).then((u) => {
|
|
93
|
+
if (u.trim().startsWith("<!DOCTYPE") || u.trim().startsWith("<html"))
|
|
94
|
+
throw new Error(`返回的是 HTML 而不是 JavaScript,可能是 404 错误。URL: ${t}`);
|
|
95
95
|
try {
|
|
96
|
-
const
|
|
97
|
-
new Function("self",
|
|
98
|
-
} catch (
|
|
99
|
-
r(new Error(`执行 wasm_exec.js 失败: ${
|
|
96
|
+
const o = typeof self < "u" ? self : globalThis;
|
|
97
|
+
new Function("self", u)(o), e();
|
|
98
|
+
} catch (o) {
|
|
99
|
+
r(new Error(`执行 wasm_exec.js 失败: ${o}`));
|
|
100
100
|
}
|
|
101
|
-
}).catch((
|
|
102
|
-
r(
|
|
101
|
+
}).catch((u) => {
|
|
102
|
+
r(u);
|
|
103
103
|
});
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
107
|
* 验证授权(通过 API)
|
|
108
108
|
*/
|
|
109
|
-
async verifyLicense(
|
|
109
|
+
async verifyLicense(t, e) {
|
|
110
110
|
if (!this.wasmReady)
|
|
111
111
|
return !1;
|
|
112
112
|
if (e)
|
|
113
113
|
try {
|
|
114
|
-
const r = this.getDeviceID(),
|
|
114
|
+
const r = this.getDeviceID(), n = this.getDomain(), o = await (await fetch(`${e}/jet_license/interface/license/verify`, {
|
|
115
115
|
method: "POST",
|
|
116
116
|
headers: {
|
|
117
117
|
"Content-Type": "application/json"
|
|
118
118
|
},
|
|
119
119
|
body: JSON.stringify({
|
|
120
|
-
token:
|
|
120
|
+
token: t,
|
|
121
121
|
deviceId: r,
|
|
122
|
-
domain:
|
|
122
|
+
domain: n
|
|
123
123
|
})
|
|
124
124
|
})).json();
|
|
125
|
-
if (!
|
|
126
|
-
const
|
|
127
|
-
throw new Error(
|
|
125
|
+
if (!o.success || !o.valid) {
|
|
126
|
+
const w = o.error || "License 验证失败";
|
|
127
|
+
throw new Error(w);
|
|
128
128
|
}
|
|
129
|
-
const
|
|
130
|
-
if (!
|
|
129
|
+
const c = this.call("wasmVerifyLicense", t);
|
|
130
|
+
if (!c.success || c.valid !== !0)
|
|
131
131
|
throw new Error("WASM 验证失败");
|
|
132
132
|
return !0;
|
|
133
133
|
} catch (r) {
|
|
@@ -135,7 +135,7 @@ const Gt = class ct {
|
|
|
135
135
|
}
|
|
136
136
|
else
|
|
137
137
|
try {
|
|
138
|
-
const r = this.call("wasmVerifyLicense",
|
|
138
|
+
const r = this.call("wasmVerifyLicense", t);
|
|
139
139
|
return r.success && r.valid === !0;
|
|
140
140
|
} catch {
|
|
141
141
|
return !1;
|
|
@@ -156,13 +156,13 @@ const Gt = class ct {
|
|
|
156
156
|
/**
|
|
157
157
|
* 计算透视变换矩阵
|
|
158
158
|
*/
|
|
159
|
-
calcPerspectiveMatrix(
|
|
159
|
+
calcPerspectiveMatrix(t) {
|
|
160
160
|
if (!this.wasmReady)
|
|
161
161
|
throw new Error("WASM 未加载");
|
|
162
|
-
if (
|
|
162
|
+
if (t.length !== 4)
|
|
163
163
|
throw new Error("需要恰好 4 个点");
|
|
164
164
|
try {
|
|
165
|
-
const e = this.call("wasmCalcPerspectiveMatrix", JSON.stringify(
|
|
165
|
+
const e = this.call("wasmCalcPerspectiveMatrix", JSON.stringify(t));
|
|
166
166
|
if (!e.success)
|
|
167
167
|
throw new Error(e.error || "计算失败");
|
|
168
168
|
return e.matrix;
|
|
@@ -173,11 +173,11 @@ const Gt = class ct {
|
|
|
173
173
|
/**
|
|
174
174
|
* 矩阵求逆
|
|
175
175
|
*/
|
|
176
|
-
invertMatrix(
|
|
176
|
+
invertMatrix(t) {
|
|
177
177
|
if (!this.wasmReady)
|
|
178
178
|
throw new Error("WASM 未加载");
|
|
179
179
|
try {
|
|
180
|
-
const e = this.call("wasmInvertMatrix", JSON.stringify(
|
|
180
|
+
const e = this.call("wasmInvertMatrix", JSON.stringify(t));
|
|
181
181
|
if (!e.success)
|
|
182
182
|
throw new Error(e.error || "矩阵求逆失败");
|
|
183
183
|
return e.matrix;
|
|
@@ -188,51 +188,51 @@ const Gt = class ct {
|
|
|
188
188
|
/**
|
|
189
189
|
* 应用透视变换到单个点
|
|
190
190
|
*/
|
|
191
|
-
applyPerspective(
|
|
191
|
+
applyPerspective(t, e, r) {
|
|
192
192
|
if (!this.wasmReady)
|
|
193
193
|
throw new Error("WASM 未加载");
|
|
194
194
|
try {
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
197
|
-
throw new Error(
|
|
198
|
-
return { x:
|
|
199
|
-
} catch (
|
|
200
|
-
throw
|
|
195
|
+
const n = this.call("wasmApplyPerspective", t, e, JSON.stringify(r));
|
|
196
|
+
if (!n.success)
|
|
197
|
+
throw new Error(n.error || "变换失败");
|
|
198
|
+
return { x: n.x, y: n.y };
|
|
199
|
+
} catch (n) {
|
|
200
|
+
throw n;
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
203
|
/**
|
|
204
204
|
* 应用逆透视变换到单个点
|
|
205
205
|
*/
|
|
206
|
-
applyInversePerspective(
|
|
206
|
+
applyInversePerspective(t, e, r) {
|
|
207
207
|
if (!this.wasmReady)
|
|
208
208
|
throw new Error("WASM 未加载");
|
|
209
209
|
try {
|
|
210
|
-
const
|
|
211
|
-
if (!
|
|
212
|
-
throw new Error(
|
|
213
|
-
return { x:
|
|
214
|
-
} catch (
|
|
215
|
-
throw
|
|
210
|
+
const n = this.call("wasmApplyInversePerspective", t, e, JSON.stringify(r));
|
|
211
|
+
if (!n.success)
|
|
212
|
+
throw new Error(n.error || "逆变换失败");
|
|
213
|
+
return { x: n.x, y: n.y };
|
|
214
|
+
} catch (n) {
|
|
215
|
+
throw n;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
/**
|
|
219
219
|
* 批量变换点(高性能)
|
|
220
220
|
*/
|
|
221
|
-
transformPoints(
|
|
221
|
+
transformPoints(t, e, r = !1) {
|
|
222
222
|
if (!this.wasmReady)
|
|
223
223
|
throw new Error("WASM 未加载");
|
|
224
224
|
try {
|
|
225
|
-
const
|
|
225
|
+
const n = this.call(
|
|
226
226
|
"wasmTransformPoints",
|
|
227
|
-
JSON.stringify(
|
|
227
|
+
JSON.stringify(t),
|
|
228
228
|
JSON.stringify(e),
|
|
229
229
|
r
|
|
230
230
|
);
|
|
231
|
-
if (!
|
|
232
|
-
throw new Error(
|
|
233
|
-
return JSON.parse(
|
|
234
|
-
} catch (
|
|
235
|
-
throw
|
|
231
|
+
if (!n.success)
|
|
232
|
+
throw new Error(n.error || "批量变换失败");
|
|
233
|
+
return JSON.parse(n.points);
|
|
234
|
+
} catch (n) {
|
|
235
|
+
throw n;
|
|
236
236
|
}
|
|
237
237
|
}
|
|
238
238
|
/**
|
|
@@ -244,57 +244,57 @@ const Gt = class ct {
|
|
|
244
244
|
/**
|
|
245
245
|
* 双三次插值点计算
|
|
246
246
|
*/
|
|
247
|
-
getBicubicPoint(
|
|
247
|
+
getBicubicPoint(t, e, r) {
|
|
248
248
|
if (!this.wasmReady)
|
|
249
249
|
throw new Error("WASM 未加载");
|
|
250
250
|
if (r.length !== 16)
|
|
251
251
|
throw new Error("需要恰好 16 个点");
|
|
252
252
|
try {
|
|
253
|
-
const
|
|
254
|
-
if (!
|
|
255
|
-
throw new Error(
|
|
256
|
-
return { x:
|
|
257
|
-
} catch (
|
|
258
|
-
throw
|
|
253
|
+
const n = this.call("wasmGetBicubicPoint", t, e, JSON.stringify(r));
|
|
254
|
+
if (!n.success)
|
|
255
|
+
throw new Error(n.error || "计算失败");
|
|
256
|
+
return { x: n.x, y: n.y };
|
|
257
|
+
} catch (n) {
|
|
258
|
+
throw n;
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
/**
|
|
262
262
|
* 双线性插值点计算
|
|
263
263
|
*/
|
|
264
|
-
getBilinearPoint(
|
|
264
|
+
getBilinearPoint(t, e, r) {
|
|
265
265
|
if (!this.wasmReady)
|
|
266
266
|
throw new Error("WASM 未加载");
|
|
267
267
|
if (r.length !== 4)
|
|
268
268
|
throw new Error("需要恰好 4 个点");
|
|
269
269
|
try {
|
|
270
|
-
const
|
|
271
|
-
if (!
|
|
272
|
-
throw new Error(
|
|
273
|
-
return { x:
|
|
274
|
-
} catch (
|
|
275
|
-
throw
|
|
270
|
+
const n = this.call("wasmGetBilinearPoint", t, e, JSON.stringify(r));
|
|
271
|
+
if (!n.success)
|
|
272
|
+
throw new Error(n.error || "计算失败");
|
|
273
|
+
return { x: n.x, y: n.y };
|
|
274
|
+
} catch (n) {
|
|
275
|
+
throw n;
|
|
276
276
|
}
|
|
277
277
|
}
|
|
278
278
|
/**
|
|
279
279
|
* 任意网格点插值计算
|
|
280
280
|
*/
|
|
281
|
-
getArbitraryMeshPoint(
|
|
281
|
+
getArbitraryMeshPoint(t, e, r, n) {
|
|
282
282
|
if (!this.wasmReady)
|
|
283
283
|
throw new Error("WASM 未加载");
|
|
284
284
|
try {
|
|
285
|
-
const
|
|
286
|
-
if (!
|
|
287
|
-
throw new Error(
|
|
288
|
-
return { x:
|
|
289
|
-
} catch (
|
|
290
|
-
throw
|
|
285
|
+
const u = this.call("wasmGetArbitraryMeshPoint", t, e, JSON.stringify(r), n);
|
|
286
|
+
if (!u.success)
|
|
287
|
+
throw new Error(u.error || "计算失败");
|
|
288
|
+
return { x: u.x, y: u.y };
|
|
289
|
+
} catch (u) {
|
|
290
|
+
throw u;
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
293
|
/**
|
|
294
294
|
* 批量双三次插值(高性能优化)
|
|
295
295
|
* 一次性处理多个坐标,避免频繁的 JS/WASM 边界调用
|
|
296
296
|
*/
|
|
297
|
-
batchBicubicInterpolation(
|
|
297
|
+
batchBicubicInterpolation(t, e) {
|
|
298
298
|
if (!this.wasmReady)
|
|
299
299
|
throw new Error("WASM 未加载");
|
|
300
300
|
if (e.length !== 16)
|
|
@@ -302,7 +302,7 @@ const Gt = class ct {
|
|
|
302
302
|
try {
|
|
303
303
|
const r = this.call(
|
|
304
304
|
"wasmBatchBicubicInterpolation",
|
|
305
|
-
JSON.stringify(
|
|
305
|
+
JSON.stringify(t),
|
|
306
306
|
JSON.stringify(e)
|
|
307
307
|
);
|
|
308
308
|
if (!r.success)
|
|
@@ -315,7 +315,7 @@ const Gt = class ct {
|
|
|
315
315
|
/**
|
|
316
316
|
* 批量双线性插值(高性能优化)
|
|
317
317
|
*/
|
|
318
|
-
batchBilinearInterpolation(
|
|
318
|
+
batchBilinearInterpolation(t, e) {
|
|
319
319
|
if (!this.wasmReady)
|
|
320
320
|
throw new Error("WASM 未加载");
|
|
321
321
|
if (e.length !== 4)
|
|
@@ -323,7 +323,7 @@ const Gt = class ct {
|
|
|
323
323
|
try {
|
|
324
324
|
const r = this.call(
|
|
325
325
|
"wasmBatchBilinearInterpolation",
|
|
326
|
-
JSON.stringify(
|
|
326
|
+
JSON.stringify(t),
|
|
327
327
|
JSON.stringify(e)
|
|
328
328
|
);
|
|
329
329
|
if (!r.success)
|
|
@@ -336,1055 +336,313 @@ const Gt = class ct {
|
|
|
336
336
|
/**
|
|
337
337
|
* 批量任意网格插值(高性能优化)
|
|
338
338
|
*/
|
|
339
|
-
batchArbitraryMeshInterpolation(
|
|
339
|
+
batchArbitraryMeshInterpolation(t, e, r) {
|
|
340
340
|
if (!this.wasmReady)
|
|
341
341
|
throw new Error("WASM 未加载");
|
|
342
342
|
try {
|
|
343
|
-
const
|
|
343
|
+
const n = this.call(
|
|
344
344
|
"wasmBatchArbitraryMeshInterpolation",
|
|
345
|
-
JSON.stringify(
|
|
345
|
+
JSON.stringify(t),
|
|
346
346
|
JSON.stringify(e),
|
|
347
347
|
r
|
|
348
348
|
);
|
|
349
|
-
if (!
|
|
350
|
-
throw new Error(
|
|
351
|
-
return
|
|
352
|
-
} catch (
|
|
353
|
-
throw
|
|
349
|
+
if (!n.success)
|
|
350
|
+
throw new Error(n.error || "批量网格插值失败");
|
|
351
|
+
return n.points;
|
|
352
|
+
} catch (n) {
|
|
353
|
+
throw n;
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
/**
|
|
357
357
|
* 调用 WASM 函数
|
|
358
358
|
*/
|
|
359
|
-
call(
|
|
359
|
+
call(t, ...e) {
|
|
360
360
|
if (!this.wasmReady)
|
|
361
361
|
throw new Error("WASM 未加载");
|
|
362
|
-
const
|
|
363
|
-
if (!
|
|
364
|
-
throw new Error(`函数不存在: ${
|
|
362
|
+
const n = (typeof self < "u" ? self : globalThis)[t];
|
|
363
|
+
if (!n)
|
|
364
|
+
throw new Error(`函数不存在: ${t}`);
|
|
365
365
|
try {
|
|
366
|
-
return
|
|
367
|
-
} catch (
|
|
368
|
-
throw
|
|
366
|
+
return n(...e);
|
|
367
|
+
} catch (u) {
|
|
368
|
+
throw u;
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
|
-
|
|
373
|
-
let
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
377
|
-
_t.prototype.C = function() {
|
|
378
|
-
return this.r * this.B;
|
|
379
|
-
};
|
|
380
|
-
_t.prototype.P = function() {
|
|
381
|
-
return new _t(this.x, this.y, this.r, this.B);
|
|
382
|
-
};
|
|
383
|
-
function $(t, n, e, r, s, o) {
|
|
384
|
-
typeof t > "u" && (t = 1, n = 0, e = 0, r = 1, s = 0, o = 0), this.zh = t, this.X = n, this.Fm = e, this.Yd = r, this.uV = s, this.QJ = o;
|
|
385
|
-
}
|
|
386
|
-
$.prototype.TX = function(t) {
|
|
387
|
-
return { x: t.x * this.zh + t.y * this.Fm + this.uV, y: t.x * this.X + t.y * this.Yd + this.QJ };
|
|
388
|
-
};
|
|
389
|
-
$.prototype.translate = function(t, n) {
|
|
390
|
-
this.uV += t, this.QJ += n;
|
|
391
|
-
};
|
|
392
|
-
$.prototype.rotate = function(t) {
|
|
393
|
-
const n = new $(Math.cos(t), -Math.sin(t), Math.sin(t), Math.cos(t), 0, 0);
|
|
394
|
-
this.concat(n);
|
|
395
|
-
};
|
|
396
|
-
$.prototype.scale = function(t, n) {
|
|
397
|
-
const e = new $(t, 0, 0, n, 0, 0);
|
|
398
|
-
this.concat(e);
|
|
399
|
-
};
|
|
400
|
-
$.prototype.concat = function(t) {
|
|
401
|
-
this.yd(new $(
|
|
402
|
-
this.zh * t.zh + this.X * t.Fm,
|
|
403
|
-
this.zh * t.X + this.X * t.Yd,
|
|
404
|
-
this.Fm * t.zh + this.Yd * t.Fm,
|
|
405
|
-
this.Fm * t.X + this.Yd * t.Yd,
|
|
406
|
-
this.uV * t.zh + this.QJ * t.Fm + t.uV,
|
|
407
|
-
this.uV * t.X + this.QJ * t.Yd + t.QJ
|
|
408
|
-
));
|
|
409
|
-
};
|
|
410
|
-
$.prototype.Ql = function() {
|
|
411
|
-
const t = this.zh * this.Yd - this.X * this.Fm;
|
|
412
|
-
this.yd(new $(
|
|
413
|
-
this.Yd / t,
|
|
414
|
-
-this.X / t,
|
|
415
|
-
-this.Fm / t,
|
|
416
|
-
this.zh / t,
|
|
417
|
-
(this.Fm * this.QJ - this.Yd * this.uV) / t,
|
|
418
|
-
(this.X * this.uV - this.zh * this.QJ) / t
|
|
419
|
-
));
|
|
420
|
-
};
|
|
421
|
-
$.prototype.P = function() {
|
|
422
|
-
return new $(this.zh, this.X, this.Fm, this.Yd, this.uV, this.QJ);
|
|
423
|
-
};
|
|
424
|
-
$.prototype.yd = function(t) {
|
|
425
|
-
this.zh = t.zh, this.X = t.X, this.Fm = t.Fm, this.Yd = t.Yd, this.uV = t.uV, this.QJ = t.QJ;
|
|
426
|
-
};
|
|
427
|
-
const U = { b: {}, ml: {}, n3: {} };
|
|
428
|
-
U.b.u = function(t, n, e) {
|
|
429
|
-
for (let r = 0; r < t.length; r += 2) {
|
|
430
|
-
const s = t[r], o = t[r + 1];
|
|
431
|
-
e[r] = s * n.zh + o * n.Fm + n.uV, e[r + 1] = s * n.X + o * n.Yd + n.QJ;
|
|
432
|
-
}
|
|
433
|
-
};
|
|
434
|
-
U.b.aGX = function(t, n, e, r) {
|
|
435
|
-
for (let s = 0; s < t.length; s += 2) {
|
|
436
|
-
const o = t[s], i = t[s + 1], u = n[s], c = n[s + 1];
|
|
437
|
-
e[s] = o + (u - o) * r, e[s + 1] = i + (c - i) * r;
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
U.ml.J = function(t, n, e, r) {
|
|
441
|
-
const s = [];
|
|
442
|
-
for (let o = 0; o < 4; o++) for (let i = 0; i < 4; i++) s.push(t + e * i / 3, n + r * o / 3);
|
|
443
|
-
return s;
|
|
444
|
-
};
|
|
445
|
-
U.n3.abG = function(t) {
|
|
446
|
-
return (4 - t) * (1 / 3);
|
|
447
|
-
};
|
|
448
|
-
U.n3.azW = function(t, n) {
|
|
449
|
-
return (1 - t) * (3 - t) / (3 * n);
|
|
450
|
-
};
|
|
451
|
-
U.n3.aK6 = function(t) {
|
|
452
|
-
const n = Math.sin(t * Math.PI / 2), e = Math.pow(t, 1 / 3.5);
|
|
453
|
-
let r = (1 - t) * n + t * e;
|
|
454
|
-
r = Math.pow(r, 1.045);
|
|
455
|
-
const s = 0.1725 + 0.0573 * r;
|
|
456
|
-
let o = 1 - (0.96 * n + 0.04 * e);
|
|
457
|
-
o = Math.pow(o, 1.27);
|
|
458
|
-
const i = 1 / 129 + (0.167684 - 1 / 129) * o;
|
|
459
|
-
return [s, i];
|
|
460
|
-
};
|
|
461
|
-
U.n3.atL = function(t, n) {
|
|
462
|
-
for (let e = 0; e < t.length; e += 2)
|
|
463
|
-
t[e] = n.x + t[e] * n.r, t[e + 1] = n.y + t[e + 1] * n.B;
|
|
464
|
-
};
|
|
465
|
-
U.n3.ac5 = function(t, n, e) {
|
|
466
|
-
for (let r = 0; r < t.length; r += 2) {
|
|
467
|
-
let s = t[r], o = t[r + 1];
|
|
468
|
-
const i = (1 - n) / 2, u = 1 - i, c = i + s * (u - i);
|
|
469
|
-
o = 0.5 + (o - 0.5) * c * 2;
|
|
470
|
-
const l = (1 - e) / 2, f = 1 - l, d = l + o * (f - l);
|
|
471
|
-
s = 0.5 + (s - 0.5) * d * 2, t[r] = s, t[r + 1] = o;
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
U.n3.n3 = function(t, n, e, r, s, o) {
|
|
475
|
-
if (t === "warpCylinder") {
|
|
476
|
-
const u = n, c = u[0], l = u[1], f = u[2], d = u[3], h = u[4], p = u[5], A = u[6], g = [];
|
|
477
|
-
for (let F = 0; F < 4; F++) for (let S = 0; S < 13; S++) g.push(S / 12, F / 3);
|
|
478
|
-
const a = f - c, y = l - d, m = h * 0.5 * (a / y), x = p * 0.5 * (a / y), E = U.n3.aK6(A), w = [0, 0, 0, 0, 0, E[0], 0.5], M = [0, 0, 0, 0, m * 0.42, m, m], D = [0, 0, 0, 0, x * 0.42, x, x];
|
|
479
|
-
for (let F = 0; F < 4; F++) for (let S = 0; S < 7; S++) {
|
|
480
|
-
const I = F * 13 + S;
|
|
481
|
-
g[I * 2] = w[S];
|
|
482
|
-
const v = M[S], T = 1 + D[S], W = F / 3;
|
|
483
|
-
g[I * 2 + 1] = v * (1 - W) + T * W;
|
|
484
|
-
}
|
|
485
|
-
for (let F = 0; F < 4; F++) for (let S = 0; S < 6; S++) {
|
|
486
|
-
const I = F * 13 + S, v = F * 13 + 12 - S;
|
|
487
|
-
g[v * 2] = 1 - g[I * 2], g[v * 2 + 1] = g[I * 2 + 1];
|
|
488
|
-
}
|
|
489
|
-
const C = E[1];
|
|
490
|
-
return [13, 4, [[0, C, 0.5, 1 - C, 1], [0, 1]], g];
|
|
491
|
-
}
|
|
492
|
-
const i = U.ml.J(0, 0, 1, 1);
|
|
493
|
-
if (t !== "warpNone") {
|
|
494
|
-
e || (o = 1 / o), U.n3.asq(i, t, n, r, s, o);
|
|
495
|
-
const u = i.slice(0);
|
|
496
|
-
if (!e) for (let c = 0; c < 4; c++) for (let l = 0; l < 4; l++)
|
|
497
|
-
i[(c * 4 + l) * 2] = u[(l * 4 + c) * 2 + 1], i[(c * 4 + l) * 2 + 1] = u[(l * 4 + c) * 2];
|
|
498
|
-
if (n === 0)
|
|
499
|
-
U.n3.ac5(i, r, s);
|
|
500
|
-
else {
|
|
501
|
-
const c = new $(void 0, void 0, void 0, void 0, void 0, void 0);
|
|
502
|
-
c.translate(-0.5, -0.5), U.b.u(i, c, i), U.n3.aLy(i, s, r), c.Ql(), U.b.u(i, c, i);
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
return [4, 4, [[0, 1], [0, 1]], i];
|
|
372
|
+
z(Z, "instance");
|
|
373
|
+
let ne = Z, H = !1;
|
|
374
|
+
const L = (...s) => {
|
|
375
|
+
}, se = (...s) => {
|
|
506
376
|
};
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
for (let c = 0; c < 4; c++) {
|
|
512
|
-
const l = 2 * (4 * u + c);
|
|
513
|
-
let f = t[l] - i.x, d = t[l + 1] - i.y, h = f, p = d;
|
|
514
|
-
if (e !== 0) {
|
|
515
|
-
const A = i.r / 2, g = i.B / 2;
|
|
516
|
-
h -= A, p -= g;
|
|
517
|
-
let a = h, y = h, m = -g, x = g;
|
|
518
|
-
const E = Math.abs(e), w = Math.tan((1 - E) * Math.PI / 2), M = Math.sqrt(w * w + 1), D = Math.atan2(1, w), C = h / A * D, F = A * M, S = A * M + i.B, I = Math.cos(D), v = Math.sin(D), T = U.n3.abG(I, v), W = U.n3.azW(I, v), L = -w * A + T * F;
|
|
519
|
-
if (n === "warpArc" && (a = Math.sin(C) * S, m = w * A - Math.cos(D) * S + g, y = Math.sin(C) * F, x = w * A - Math.cos(D) * F + g, (c === 1 || c === 2) && (a = c === 1 ? -W * S : W * S, y = c === 1 ? -W * F : W * F, m = w * A + g - T * S, x = w * A + g - T * F), e < 0)) {
|
|
520
|
-
const b = a;
|
|
521
|
-
a = y, y = b;
|
|
522
|
-
const P = m;
|
|
523
|
-
m = -x, x = -P;
|
|
524
|
-
}
|
|
525
|
-
if (n === "warpArcLower" && (c === 1 || c === 2) && (y = c === 1 ? -W * F : W * F, x = e < 0 ? g - L : g + L), (n === "warpArcUpper" || n === "warpArch" || n === "warpBulge") && ((c === 1 || c === 2) && (a = c === 1 ? -W * F : W * F, m = e < 0 ? -g + L : -g - L), n === "warpArch" && (y = a, x = m + 2 * g), n === "warpBulge" && (y = a, x = -m)), n === "warpFish" || n === "warpFlag" || n === "warpWave") {
|
|
526
|
-
let b = c;
|
|
527
|
-
n === "warpFlag" && (b = 3 - c), b === 1 && (m -= e * 4 * g, x += e * 4 * g), b === 2 && (m += e * 4 * g, x -= e * 4 * g), (n === "warpFlag" || n === "warpWave") && (m = x - 2 * g);
|
|
528
|
-
}
|
|
529
|
-
n === "warpRise" && (c < 2 && (m = -g + e * g * 4), x = m + 2 * g);
|
|
530
|
-
const B = (p + g) / i.B;
|
|
531
|
-
if (h = a + B * (y - a), p = m + B * (x - m), n === "warpWave" && (u === 0 && (p = -g), u === 3 && (p = g), (u === 1 || u === 2) && (p = 2 * g * (u / 3 - 0.5) * (1 / 3) + p * (2 / 3))), n === "warpFisheye" && (u === 1 || u === 2) && (c === 1 || c === 2) && (h = h + 4 * h * e, p = p + 4 * p * e), n === "warpInflate") {
|
|
532
|
-
const b = 0.6666666666666666;
|
|
533
|
-
(u === 1 || u === 2) && (c === 1 || c === 2) ? (h = h + 0.5 * h * e, p = p + 0.5 * p * e) : u === 1 || u === 2 ? h = h + b * h * e : (c === 1 || c === 2) && (p = p + b * p * e);
|
|
534
|
-
}
|
|
535
|
-
if (n === "warpSqueeze") {
|
|
536
|
-
const b = 0.6666666666666666;
|
|
537
|
-
(u === 1 || u === 2) && (c === 1 || c === 2) ? e > 0 ? h = h - b * h * e : p = p + b * p * e : u === 1 || u === 2 ? h = h - b * h * e : (c === 1 || c === 2) && (p = p + b * p * e);
|
|
538
|
-
}
|
|
539
|
-
if (n === "warpTwist" && (u === 1 || u === 2) && (c === 1 || c === 2)) {
|
|
540
|
-
const b = e * Math.PI / 2, P = 1 + Math.abs(e) * 2, X = h * Math.cos(b) - p * Math.sin(b), O = h * Math.sin(b) + p * Math.cos(b);
|
|
541
|
-
h = X * P, p = O * P;
|
|
542
|
-
}
|
|
543
|
-
if (n === "warpShellLower" || n === "warpShellUpper") {
|
|
544
|
-
let b = u;
|
|
545
|
-
if (n === "warpShellUpper" && (b = 3 - b, p = -p), b > 2 || b === 2 && (c === 0 || c === 3))
|
|
546
|
-
if (e > 0) {
|
|
547
|
-
const P = F + b / 3 * 2 * g;
|
|
548
|
-
h = Math.sin(C) * P, p = -w * A - g + Math.cos(C) * P, (c === 1 || c === 2) && (h = c === 1 ? -W * P : W * P, p = -w * A - g + T * P);
|
|
549
|
-
} else
|
|
550
|
-
(c === 1 || c === 2) && b === 3 ? (h = c === 1 ? -W * F : W * F, p = w * A - T * F + g) : b === 2 && (p = g - g * (2 / 3) * Math.cos(C), h = h + g * (2 / 3) * Math.sin(C));
|
|
551
|
-
n === "warpShellUpper" && (b = 3 - b, p = -p);
|
|
552
|
-
}
|
|
553
|
-
h += A, p += g;
|
|
554
|
-
}
|
|
555
|
-
f = h, d = p, t[l] = f + i.x, t[l + 1] = d + i.y;
|
|
556
|
-
}
|
|
557
|
-
for (let u = 0; u < t.length; u += 2) t[u] /= o;
|
|
558
|
-
};
|
|
559
|
-
U.n3.aLy = function(t, n, e) {
|
|
560
|
-
const r = [];
|
|
561
|
-
for (let x = 0; x < 4; x++) r.push(1 - e + x / 3 * 2 * e);
|
|
562
|
-
const s = [0, 0, 0, 0], o = [0, 0, 0, 0];
|
|
563
|
-
for (let x = 0; x < 4; x++) for (let E = 0; E < 4; E++) {
|
|
564
|
-
const w = 2 * (4 * x + E);
|
|
565
|
-
s[E] += t[w] / 4, o[E] += t[w + 1] / 4;
|
|
566
|
-
}
|
|
567
|
-
for (let x = 0; x < 4; x++) for (let E = 0; E < 4; E++) {
|
|
568
|
-
const w = r[E], M = 2 * (4 * x + E), D = s[E], C = o[E];
|
|
569
|
-
t[M] = D + w * (t[M] - D), t[M + 1] = C + w * (t[M + 1] - C);
|
|
570
|
-
}
|
|
571
|
-
const i = t.slice(0);
|
|
572
|
-
for (let x = 0; x < 4; x++) for (let E = 1; E < 3; E++) {
|
|
573
|
-
const w = 2 * (4 * x + E), M = w + (E === 1 ? -2 : 2);
|
|
574
|
-
t[w] = t[w] - t[M], t[w + 1] = t[w + 1] - t[M + 1];
|
|
575
|
-
}
|
|
576
|
-
const u = t[0], c = t[1], l = t[6], f = t[7], d = t[24], h = t[25], p = t[30], A = t[31], g = l - u, a = f - c, y = p - d, m = A - h;
|
|
577
|
-
for (let x = 0; x < 4; x++) {
|
|
578
|
-
const E = 2 * x * 4;
|
|
579
|
-
let w = 0, M = 0;
|
|
580
|
-
const D = x === 1 ? 0.33 : 0.66, C = 1 - D;
|
|
581
|
-
x === 0 && (w = g, M = a), x === 1 && (w = C * g + D * -y, M = C * a + D * -m), x === 2 && (w = C * g + D * -y, M = C * a + D * -m), x === 3 && (w = -y, M = -m), t[E] = t[E] + w / 2, t[E + 1] = t[E + 1] + M / 2, t[E + 6] = t[E + 6] - w / 2, t[E + 7] = t[E + 7] - M / 2;
|
|
582
|
-
}
|
|
583
|
-
for (let x = 0; x < 4; x++) for (let E = 1; E < 3; E++) {
|
|
584
|
-
const w = 2 * (4 * x + E), M = w + (E === 1 ? -2 : 2), D = 2 * x / 3;
|
|
585
|
-
t[w] = t[M] + D * t[w], t[w + 1] = t[M + 1] + D * t[w + 1];
|
|
586
|
-
}
|
|
587
|
-
for (let x = 1; x < 3; x++) for (let E = 1; E < 3; E++) {
|
|
588
|
-
const w = 2 * (4 * x + E), M = x === 1 ? -8 : -16, D = x === 1 ? 16 : 8, C = t[w + M], F = t[w + M + 1], S = t[w + D], I = t[w + D + 1], v = x / 3;
|
|
589
|
-
t[w] = (1 - v) * C + v * S, t[w + 1] = (1 - v) * F + v * I;
|
|
590
|
-
}
|
|
591
|
-
U.b.aGX(i, t, t, n);
|
|
592
|
-
};
|
|
593
|
-
function ee(t) {
|
|
594
|
-
const [n, e, r, s] = U.n3.n3(
|
|
595
|
-
t.preset,
|
|
596
|
-
t.value,
|
|
597
|
-
t.rotateHorizontal,
|
|
598
|
-
t.perspective,
|
|
599
|
-
t.perspectiveOther,
|
|
600
|
-
t.aspect
|
|
601
|
-
);
|
|
602
|
-
return { cols: n, rows: e, slices: r, points: s };
|
|
603
|
-
}
|
|
604
|
-
function ne(t, n) {
|
|
605
|
-
U.n3.atL(t, { x: n.x, y: n.y, r: n.width, B: n.height });
|
|
606
|
-
}
|
|
607
|
-
const re = (function() {
|
|
608
|
-
function t(r, s) {
|
|
609
|
-
this.data = new Array(r.length);
|
|
610
|
-
for (let o = 0, i = r[0].length; o < r.length; o++) {
|
|
611
|
-
this.data[o] = new Array(i);
|
|
612
|
-
for (let u = 0; u < i; u++)
|
|
613
|
-
this.data[o][u] = r[o][u];
|
|
614
|
-
}
|
|
615
|
-
if (s) {
|
|
616
|
-
if (typeof s[0] != "object")
|
|
617
|
-
for (let o = 0; o < s.length; o++)
|
|
618
|
-
s[o] = [s[o]];
|
|
619
|
-
this.mirror = new t(s);
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
t.prototype.swap = function(r, s) {
|
|
623
|
-
this.mirror && this.mirror.swap(r, s);
|
|
624
|
-
const o = this.data[r];
|
|
625
|
-
this.data[r] = this.data[s], this.data[s] = o;
|
|
626
|
-
}, t.prototype.multline = function(r, s) {
|
|
627
|
-
this.mirror && this.mirror.multline(r, s);
|
|
628
|
-
const o = this.data[r];
|
|
629
|
-
for (let i = o.length - 1; i >= 0; i--)
|
|
630
|
-
o[i] *= s;
|
|
631
|
-
}, t.prototype.addmul = function(r, s, o) {
|
|
632
|
-
this.mirror && this.mirror.addmul(r, s, o);
|
|
633
|
-
const i = this.data[r], u = this.data[s];
|
|
634
|
-
for (let c = i.length - 1; c >= 0; c--)
|
|
635
|
-
i[c] = i[c] + o * u[c];
|
|
636
|
-
}, t.prototype.hasNullLine = function(r) {
|
|
637
|
-
for (let s = 0; s < this.data[r].length; s++)
|
|
638
|
-
if (this.data[r][s] !== 0) return !1;
|
|
639
|
-
return !0;
|
|
640
|
-
}, t.prototype.gauss = function() {
|
|
641
|
-
let r = 0;
|
|
642
|
-
const s = this.data.length, o = this.data[0].length, i = [];
|
|
643
|
-
for (let u = 0; u < o; u++) {
|
|
644
|
-
let c = 0, l = 0;
|
|
645
|
-
for (let f = r; f < s; f++) {
|
|
646
|
-
const d = this.data[f][u];
|
|
647
|
-
Math.abs(d) > Math.abs(c) && (l = f, c = d);
|
|
648
|
-
}
|
|
649
|
-
if (c === 0)
|
|
650
|
-
i.push(r);
|
|
651
|
-
else {
|
|
652
|
-
this.multline(l, 1 / c), this.swap(l, r);
|
|
653
|
-
for (let f = 0; f < s; f++)
|
|
654
|
-
f !== r && this.addmul(f, r, -this.data[f][u]);
|
|
655
|
-
}
|
|
656
|
-
r++;
|
|
657
|
-
}
|
|
658
|
-
for (let u = 0; u < i.length; u++)
|
|
659
|
-
if (!this.mirror.hasNullLine(i[u]))
|
|
660
|
-
throw new Error("singular matrix");
|
|
661
|
-
return this.mirror.data;
|
|
662
|
-
};
|
|
663
|
-
const n = {};
|
|
664
|
-
n.solve = function(r, s) {
|
|
665
|
-
const o = new t(r, s).gauss();
|
|
666
|
-
if (o.length > 0 && o[0].length === 1)
|
|
667
|
-
for (let i = 0; i < o.length; i++) o[i] = o[i][0];
|
|
668
|
-
return o;
|
|
669
|
-
};
|
|
670
|
-
function e(r) {
|
|
671
|
-
const s = new Array(r);
|
|
672
|
-
for (let o = 0; o < r; o++) {
|
|
673
|
-
s[o] = new Array(r);
|
|
674
|
-
for (let i = 0; i < r; i++)
|
|
675
|
-
s[o][i] = o === i ? 1 : 0;
|
|
676
|
-
}
|
|
677
|
-
return s;
|
|
678
|
-
}
|
|
679
|
-
return n.invert = function(r) {
|
|
680
|
-
return new t(r, e(r.length)).gauss();
|
|
681
|
-
}, n;
|
|
682
|
-
})(), _ = { avu: {}, es: {}, XF: {}, uZ: {} };
|
|
683
|
-
_.avu.GE = function(t, n) {
|
|
684
|
-
t.push(n);
|
|
685
|
-
let e = t.length - 1, r = e >>> 1;
|
|
686
|
-
for (; r !== 0 && t[e][0] < t[r][0]; ) {
|
|
687
|
-
const s = t[e];
|
|
688
|
-
t[e] = t[r], t[r] = s, e = r, r = e >>> 1;
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
_.avu.Ng = function(t) {
|
|
692
|
-
if (t.length === 2) return t.pop();
|
|
693
|
-
const n = t[1];
|
|
694
|
-
let e = 1;
|
|
695
|
-
t[1] = t.pop();
|
|
696
|
-
const r = t.length;
|
|
697
|
-
for (; ; ) {
|
|
698
|
-
const s = e << 1, o = s + 1;
|
|
699
|
-
let i = e;
|
|
700
|
-
if (s < r && t[s][0] < t[i][0] && (i = s), o < r && t[o][0] < t[i][0] && (i = o), i === e) break;
|
|
701
|
-
const u = t[e];
|
|
702
|
-
t[e] = t[i], t[i] = u, e = i;
|
|
703
|
-
}
|
|
704
|
-
return n;
|
|
705
|
-
};
|
|
706
|
-
_.es.MG = function(t) {
|
|
707
|
-
const n = t.length, e = t[0].length, r = new Array(e);
|
|
708
|
-
for (let s = 0; s < e; s++) r[s] = new Array(n);
|
|
709
|
-
for (let s = 0; s < e; s++) for (let o = 0; o < n; o++) r[s][o] = t[o][s];
|
|
710
|
-
return r;
|
|
711
|
-
};
|
|
712
|
-
_.es.y8 = function(t, n) {
|
|
713
|
-
const e = t.length, r = t[0].length, s = new Array(e);
|
|
714
|
-
for (let o = 0; o < e; o++) s[o] = new Array(r);
|
|
715
|
-
for (let o = 0; o < e; o++) for (let i = 0; i < r; i++) s[o][i] = t[o][i] - n[o][i];
|
|
716
|
-
return s;
|
|
717
|
-
};
|
|
718
|
-
_.es.multiply = function(t, n) {
|
|
719
|
-
const e = t.length, r = t[0].length, s = n[0].length;
|
|
720
|
-
if (r !== n.length) throw new Error("es.multiply dim mismatch");
|
|
721
|
-
const o = new Array(e);
|
|
722
|
-
for (let i = 0; i < e; i++) o[i] = new Array(s);
|
|
723
|
-
for (let i = 0; i < e; i++) {
|
|
724
|
-
const u = t[i], c = o[i];
|
|
725
|
-
for (let l = 0; l < s; l++) {
|
|
726
|
-
let f = 0;
|
|
727
|
-
for (let d = 0; d < r; d++) f += u[d] * n[d][l];
|
|
728
|
-
c[l] = f;
|
|
729
|
-
}
|
|
730
|
-
}
|
|
731
|
-
return o;
|
|
732
|
-
};
|
|
733
|
-
_.es.Jj = function(t, n) {
|
|
734
|
-
const e = t.length, r = t[0].length, s = new Array(e);
|
|
735
|
-
for (let o = 0; o < e; o++) {
|
|
736
|
-
let i = 0;
|
|
737
|
-
for (let u = 0; u < r; u++) i += t[o][u] * n[u];
|
|
738
|
-
s[o] = i;
|
|
739
|
-
}
|
|
740
|
-
return s;
|
|
741
|
-
};
|
|
742
|
-
_.W9 = function(t, n) {
|
|
743
|
-
this.Y = [], this.ia = [0], this.Am = [], this.yr = [], this.qq = [0], this.t8 = [], this.oN = [], this.rows = t, this.cols = n;
|
|
744
|
-
};
|
|
745
|
-
_.W9.prototype.Hk = function(t, n, e) {
|
|
746
|
-
const r = this.ia.length - 1;
|
|
747
|
-
for (let s = 0; s < e; s++) {
|
|
748
|
-
const o = t[s], i = n[s];
|
|
749
|
-
this.Y.push(o), this.Am.push(i), i === r ? this.oN.push(o === 0 ? 0 : 1 / o) : (this.yr.push(o), this.t8.push(i));
|
|
750
|
-
}
|
|
751
|
-
this.ia.push(this.Y.length), this.qq.push(this.yr.length);
|
|
752
|
-
};
|
|
753
|
-
_.W9.prototype.Jj = function(t, n) {
|
|
754
|
-
const e = this, r = e.rows, s = e.Y, o = e.Am;
|
|
755
|
-
n == null && (n = new Array(r));
|
|
756
|
-
for (let i = 0; i < r; i++) {
|
|
757
|
-
let u = e.ia[i];
|
|
758
|
-
const c = e.ia[i + 1];
|
|
759
|
-
let l = 0;
|
|
760
|
-
for (; (c - u & 3) !== 0; )
|
|
761
|
-
l += s[u] * t[o[u]], u++;
|
|
762
|
-
for (let f = u; f < c; f += 4)
|
|
763
|
-
l += s[f] * t[o[f]] + s[f + 1] * t[o[f + 1]] + s[f + 2] * t[o[f + 2]] + s[f + 3] * t[o[f + 3]];
|
|
764
|
-
n[i] = l;
|
|
765
|
-
}
|
|
766
|
-
return n;
|
|
767
|
-
};
|
|
768
|
-
_.W9.prototype.multiply = function(t) {
|
|
769
|
-
return this._g(t.MG());
|
|
770
|
-
};
|
|
771
|
-
_.W9.prototype._g = function(t) {
|
|
772
|
-
const n = this, e = n.rows, r = t.rows, s = new _.W9(e, r), o = n.Am, i = t.Am;
|
|
773
|
-
for (let u = 0; u < e; u++) {
|
|
774
|
-
const c = [], l = [], f = n.ia[u], d = n.ia[u + 1];
|
|
775
|
-
for (let h = 0; h < r; h++) {
|
|
776
|
-
const p = t.ia[h], A = t.ia[h + 1];
|
|
777
|
-
let g = 0, a = f, y = p;
|
|
778
|
-
for (; a < d && y < A; ) {
|
|
779
|
-
const m = Math.max(o[a], i[y]);
|
|
780
|
-
for (; a < d && o[a] < m; ) a++;
|
|
781
|
-
for (; y < A && i[y] < m; ) y++;
|
|
782
|
-
a < d && y < A && o[a] === i[y] && (g += n.Y[a++] * t.Y[y++]);
|
|
783
|
-
}
|
|
784
|
-
g !== 0 && (c.push(g), l.push(h));
|
|
785
|
-
}
|
|
786
|
-
s.Hk(c, l, c.length);
|
|
787
|
-
}
|
|
788
|
-
return s;
|
|
789
|
-
};
|
|
790
|
-
_.W9.prototype.MG = function() {
|
|
791
|
-
const t = this.rows, n = this.cols, e = [];
|
|
792
|
-
for (let u = 0; u < n; u++) e.push([[], []]);
|
|
793
|
-
const r = this.Y, s = this.ia, o = this.Am;
|
|
794
|
-
for (let u = 0; u < t; u++) {
|
|
795
|
-
const c = s[u], l = s[u + 1];
|
|
796
|
-
for (let f = c; f < l; f++) {
|
|
797
|
-
const d = e[o[f]];
|
|
798
|
-
d[0].push(r[f]), d[1].push(u);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
const i = new _.W9(n, t);
|
|
802
|
-
for (let u = 0; u < n; u++) i.Hk(e[u][0], e[u][1], e[u][1].length);
|
|
803
|
-
return i;
|
|
804
|
-
};
|
|
805
|
-
_.W9.prototype.e0 = function(t, n, e) {
|
|
806
|
-
function r(g, a, y, m) {
|
|
807
|
-
const x = g.length;
|
|
808
|
-
for (let E = 0; E < x; E++) m[E] = g[E] - a[E] * y;
|
|
809
|
-
}
|
|
810
|
-
function s(g, a, y, m) {
|
|
811
|
-
const x = g.length;
|
|
812
|
-
let E = 0;
|
|
813
|
-
for (; (x - E & 3) !== 0; )
|
|
814
|
-
m[E] = g[E] + a[E] * y, E++;
|
|
815
|
-
for (let w = E; w < x; w += 4)
|
|
816
|
-
m[w] = g[w] + a[w] * y, m[w + 1] = g[w + 1] + a[w + 1] * y, m[w + 2] = g[w + 2] + a[w + 2] * y, m[w + 3] = g[w + 3] + a[w + 3] * y;
|
|
817
|
-
}
|
|
818
|
-
function o(g, a, y) {
|
|
819
|
-
const m = g.length;
|
|
820
|
-
for (let x = 0; x < m; x++) y[x] = g[x] * a[x];
|
|
821
|
-
}
|
|
822
|
-
function i(g, a) {
|
|
823
|
-
const y = g.length;
|
|
824
|
-
let m = 0, x = 0;
|
|
825
|
-
for (; (y - m & 3) !== 0; )
|
|
826
|
-
x += g[m] * a[m], m++;
|
|
827
|
-
for (let E = m; E < y; E += 4)
|
|
828
|
-
x += g[E] * a[E] + g[E + 1] * a[E + 1] + g[E + 2] * a[E + 2] + g[E + 3] * a[E + 3];
|
|
829
|
-
return x;
|
|
830
|
-
}
|
|
831
|
-
let u = 0;
|
|
832
|
-
const c = this, l = t.slice(0), f = t.slice(0);
|
|
833
|
-
c.Jj(t, f), r(n, f, 1, l);
|
|
834
|
-
const d = this.oN, h = l.slice(0);
|
|
835
|
-
o(d, l, h);
|
|
836
|
-
const p = h.slice(0);
|
|
837
|
-
let A = i(l, h);
|
|
838
|
-
for (; ; ) {
|
|
839
|
-
c.Jj(p, f);
|
|
840
|
-
const g = A / i(p, f);
|
|
841
|
-
if (s(t, p, g, t), r(l, f, g, l), (u & 7) === 0 && Math.sqrt(i(l, l)) < e) break;
|
|
842
|
-
o(d, l, h);
|
|
843
|
-
const a = i(l, h), y = a / A;
|
|
844
|
-
if (s(h, p, y, p), A = a, u++, u > 1e4) break;
|
|
845
|
-
}
|
|
846
|
-
};
|
|
847
|
-
_.XF.h6 = function(t, n, e, r) {
|
|
848
|
-
const s = t[n * 2], o = t[n * 2 + 1], i = t[e * 2], u = t[e * 2 + 1], c = t[r * 2], l = t[r * 2 + 1];
|
|
849
|
-
return s * u + i * l + c * o - c * u - i * o - s * l;
|
|
850
|
-
};
|
|
851
|
-
_.XF.a9o = function(t, n) {
|
|
852
|
-
const e = [], r = [], s = [], o = {};
|
|
853
|
-
for (let i = 0; i < n.length; i += 3) {
|
|
854
|
-
const u = ~~(i * 0.3333333333333333);
|
|
855
|
-
let c = n[i + 0], l = n[i + 1], f = n[i + 2];
|
|
856
|
-
if (_.XF.h6(t, c, l, f) > 0) {
|
|
857
|
-
const m = l;
|
|
858
|
-
l = f, f = m;
|
|
859
|
-
}
|
|
860
|
-
const h = o[f + "-" + l], p = o[l + "-" + c], A = o[c + "-" + f], g = [f, h, u, null], a = [l, p, u, g], y = [c, A, u, a];
|
|
861
|
-
g[3] = y, h && (h[1] = g), p && (p[1] = a), A && (A[1] = y), o[f + "-" + c] = y, o[c + "-" + l] = a, o[l + "-" + f] = g, e[c] = a, s[i] = a, e[l] = g, s[i + 1] = g, e[f] = y, s[i + 2] = y, r[u] = a;
|
|
862
|
-
}
|
|
863
|
-
return { fD: e, EE: r, pK: s };
|
|
864
|
-
};
|
|
865
|
-
_.uZ.aI9 = function(t) {
|
|
866
|
-
const n = t.UC, e = t.B_, r = t.w$, s = _.es.multiply, o = _.XF.a9o(n, e), i = n.length >>> 1;
|
|
867
|
-
let u = 0;
|
|
868
|
-
const c = 1e3;
|
|
869
|
-
for (let E = 0; E < o.pK.length; E++) u += o.pK[E][1] ? 0.5 : 1;
|
|
870
|
-
const l = u + r.length, f = new _.W9(l * 2, i * 2), d = new _.W9(l, i), h = [[[-1, 0, 1, 0, 0, 0], [0, -1, 0, 1, 0, 0]], [[-1, 0, 1, 0, 0, 0, 0, 0], [0, -1, 0, 1, 0, 0, 0, 0]]], p = [], A = [], g = [];
|
|
871
|
-
for (let E = 0; E < o.pK.length; E++) {
|
|
872
|
-
const w = o.pK[E], M = w[3][3][0], D = w[0], C = w[3][0], F = w[1] ? w[1][3][0] : C;
|
|
873
|
-
if (w[1] && M > D) continue;
|
|
874
|
-
const S = n[M * 2], I = n[M * 2 + 1], v = n[D * 2], T = n[D * 2 + 1], W = n[C * 2], L = n[C * 2 + 1], B = n[F * 2], b = n[F * 2 + 1], P = [[S, I, 1, 0], [I, -S, 0, 1], [v, T, 1, 0], [T, -v, 0, 1], [W, L, 1, 0], [L, -W, 0, 1]];
|
|
875
|
-
w[1] && P.push([B, b, 1, 0], [b, -B, 0, 1]);
|
|
876
|
-
const X = _.es.MG(P), O = s(re.invert(s(X, P)), X);
|
|
877
|
-
O.pop(), O.pop(), p.push(O);
|
|
878
|
-
const k = v - S, j = T - I;
|
|
879
|
-
let Y = h[w[1] ? 1 : 0];
|
|
880
|
-
Y = _.es.y8(Y, s([[k, j], [j, -k]], O));
|
|
881
|
-
const J = [M * 2, M * 2 + 1, D * 2, D * 2 + 1, C * 2, C * 2 + 1, F * 2, F * 2 + 1], z = w[1] ? 8 : 6, K = [];
|
|
882
|
-
for (let N = 0; N < z; N++) K.push([J[N], Y[0][N], Y[1][N]]);
|
|
883
|
-
K.sort(function(N, V) {
|
|
884
|
-
return N[0] - V[0];
|
|
885
|
-
});
|
|
886
|
-
for (let N = 0; N < 2; N++) {
|
|
887
|
-
for (let V = 0; V < z; V++)
|
|
888
|
-
A[V] = K[V][0], g[V] = K[V][1 + N];
|
|
889
|
-
f.Hk(g, A, z);
|
|
890
|
-
}
|
|
891
|
-
M < D ? d.Hk([-1, 1], [M, D], 2) : d.Hk([1, -1], [D, M], 2);
|
|
892
|
-
}
|
|
893
|
-
for (let E = 0; E < r.length; E++) {
|
|
894
|
-
const w = r[E];
|
|
895
|
-
f.Hk([c], [w * 2], 1), f.Hk([c], [w * 2 + 1], 1), d.Hk([c], [w], 1);
|
|
896
|
-
}
|
|
897
|
-
const a = f.MG(), y = a._g(a), m = d.MG(), x = m._g(m);
|
|
898
|
-
return { aI8: u, ah: l, abf: a, aCL: y, aug: m, ahD: x, azO: o, afj: p, mE: c };
|
|
899
|
-
};
|
|
900
|
-
_.uZ.aH0 = function(t) {
|
|
901
|
-
const n = t.nt, e = t.UC, r = t.iE, s = t.M3, o = t.oP, i = t.k3, u = _.es.Jj;
|
|
902
|
-
let c = 0;
|
|
903
|
-
function l(a) {
|
|
904
|
-
const y = new Array(a);
|
|
905
|
-
for (let m = 0; m < a; m++) y[m] = 0;
|
|
906
|
-
return y;
|
|
907
|
-
}
|
|
908
|
-
const f = e.length >>> 1, d = l(n.ah * 2), h = l(n.ah), p = l(n.ah);
|
|
909
|
-
for (let a = 0; a < t.w$.length; a++) {
|
|
910
|
-
const y = n.aI8 + a, m = n.mE * (o[a * 2] + i[a * 2]), x = n.mE * (o[a * 2 + 1] + i[a * 2 + 1]);
|
|
911
|
-
d[y * 2] = m, d[y * 2 + 1] = x, h[y] = m, p[y] = x;
|
|
912
|
-
}
|
|
913
|
-
n.aCL.e0(r, n.abf.Jj(d), 0.01);
|
|
914
|
-
for (let a = 0; a < n.azO.pK.length; a++) {
|
|
915
|
-
const y = n.azO.pK[a], m = y[3][3][0], x = y[0], E = y[3][0], w = y[1] ? y[1][3][0] : E;
|
|
916
|
-
if (y[1] && m > x) continue;
|
|
917
|
-
const M = e[m * 2], D = e[m * 2 + 1], C = e[x * 2], F = e[x * 2 + 1], S = r[m * 2], I = r[m * 2 + 1], v = r[x * 2], T = r[x * 2 + 1], W = r[E * 2], L = r[E * 2 + 1], B = r[w * 2], b = r[w * 2 + 1], P = [S, I, v, T, W, L];
|
|
918
|
-
y[1] && P.push(B, b);
|
|
919
|
-
const X = u(n.afj[c], P);
|
|
920
|
-
let O = X[0], k = X[1];
|
|
921
|
-
const j = 1 / Math.sqrt(O * O + k * k);
|
|
922
|
-
O *= j, k *= j;
|
|
923
|
-
const Y = C - M, J = F - D;
|
|
924
|
-
h[c] = O * Y + k * J, p[c] = -k * Y + O * J, c++;
|
|
925
|
-
}
|
|
926
|
-
const A = new Array(f), g = new Array(f);
|
|
927
|
-
for (let a = 0; a < f; a++)
|
|
928
|
-
A[a] = s[a * 2], g[a] = s[a * 2 + 1];
|
|
929
|
-
n.ahD.e0(A, n.aug.Jj(h), 0.5), n.ahD.e0(g, n.aug.Jj(p), 0.5);
|
|
930
|
-
for (let a = 0; a < f; a++)
|
|
931
|
-
s[a * 2] = A[a], s[a * 2 + 1] = g[a];
|
|
932
|
-
};
|
|
933
|
-
const it = /* @__PURE__ */ new Map(), se = 32;
|
|
934
|
-
function oe(t) {
|
|
935
|
-
const n = t.UC, e = t.B_, r = t.w$, s = n.length, o = [], i = [0, 1, 2, 3, s >> 2 | 0, s >> 1 | 0, 3 * s >> 2 | 0, s - 2, s - 1];
|
|
936
|
-
for (const u of i)
|
|
937
|
-
u >= 0 && u < s && o.push(Math.round(n[u] * 1e3));
|
|
938
|
-
return `${n.length}|${e.length}|${r.length}|${r.join(",")}|${o.join(",")}`;
|
|
939
|
-
}
|
|
940
|
-
function Qt(t) {
|
|
941
|
-
const n = oe(t), e = it.get(n);
|
|
942
|
-
if (e)
|
|
943
|
-
return e.lastUsed = Date.now(), t.nt = e.nt, t.nt;
|
|
944
|
-
if (it.size >= se) {
|
|
945
|
-
let s = null, o = 1 / 0;
|
|
946
|
-
for (const [i, u] of it)
|
|
947
|
-
u.lastUsed < o && (o = u.lastUsed, s = i);
|
|
948
|
-
s !== null && it.delete(s);
|
|
949
|
-
}
|
|
950
|
-
const r = _.uZ.aI9(t);
|
|
951
|
-
return t.nt = r, it.set(n, { nt: r, lastUsed: Date.now() }), r;
|
|
952
|
-
}
|
|
953
|
-
function ie(t) {
|
|
954
|
-
t.nt || Qt(t), _.uZ.aH0(t);
|
|
955
|
-
}
|
|
956
|
-
function ue(t) {
|
|
957
|
-
const n = [];
|
|
958
|
-
for (const i of t.originalVertices)
|
|
959
|
-
n.push(i.x, i.y);
|
|
960
|
-
const e = n.slice(), r = n.slice(), s = [];
|
|
961
|
-
for (const i of t.pinTargets)
|
|
962
|
-
s.push(i.x, i.y);
|
|
963
|
-
const o = [];
|
|
964
|
-
if (t.pinOffsets)
|
|
965
|
-
for (const i of t.pinOffsets)
|
|
966
|
-
o.push(i.x, i.y);
|
|
967
|
-
else
|
|
968
|
-
for (let i = 0; i < t.pinIndices.length; i++) o.push(0, 0);
|
|
969
|
-
return {
|
|
970
|
-
UC: n,
|
|
971
|
-
B_: t.triangles.slice(),
|
|
972
|
-
w$: t.pinIndices.slice(),
|
|
973
|
-
iE: e,
|
|
974
|
-
M3: r,
|
|
975
|
-
oP: s,
|
|
976
|
-
k3: o
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
let Bt = !1;
|
|
980
|
-
const rt = (...t) => {
|
|
981
|
-
}, ce = (...t) => {
|
|
982
|
-
};
|
|
983
|
-
let R = null, st = !1, H = null, q = null, lt = null, ht = null, ft = null, Tt = null, jt = 0, Kt = 0, Pt = null, ut = null, Rt = 0, Xt = 0, Z = [], Ot = null, nt = null, G = null, Ct = null, bt = null, vt = null;
|
|
984
|
-
function ae(t) {
|
|
985
|
-
q = t.licenseToken, lt = t.licenseApiUrl, ht = t.deviceId, ft = t.domain, self.LICENSE_TOKEN = q, self.LICENSE_API_URL = lt, self.DEVICE_ID = ht, self.DOMAIN = ft, R || (H && !st && (H = null), Nt().then(() => {
|
|
986
|
-
}).catch((n) => {
|
|
377
|
+
let E = null, R = !1, M = null, b = null, O = null, $ = null, U = null;
|
|
378
|
+
function ue(s) {
|
|
379
|
+
b = s.licenseToken, O = s.licenseApiUrl, $ = s.deviceId, U = s.domain, self.LICENSE_TOKEN = b, self.LICENSE_API_URL = O, self.DEVICE_ID = $, self.DOMAIN = U, E || (M && !R && (M = null), G().then(() => {
|
|
380
|
+
}).catch((t) => {
|
|
987
381
|
}));
|
|
988
382
|
}
|
|
989
|
-
async function
|
|
990
|
-
return
|
|
383
|
+
async function G() {
|
|
384
|
+
return E ? void 0 : R ? M || Promise.resolve() : b || self.LICENSE_TOKEN ? (R = !0, M = (async () => {
|
|
991
385
|
try {
|
|
992
|
-
|
|
993
|
-
const
|
|
994
|
-
const
|
|
995
|
-
if (
|
|
996
|
-
return
|
|
997
|
-
if (
|
|
998
|
-
return
|
|
386
|
+
E = ne.getInstance();
|
|
387
|
+
const t = (a) => {
|
|
388
|
+
const l = self.WASM_URL, i = self.WASM_EXEC_URL;
|
|
389
|
+
if (a === "perspective.wasm" && l)
|
|
390
|
+
return l;
|
|
391
|
+
if (a === "wasm_exec.js" && i)
|
|
392
|
+
return i;
|
|
999
393
|
try {
|
|
1000
394
|
let h = null;
|
|
1001
395
|
if (typeof import.meta < "u" && import.meta.url ? h = import.meta.url : typeof self < "u" && self.location && (h = self.location.href), h) {
|
|
1002
|
-
const
|
|
1003
|
-
if (
|
|
1004
|
-
const
|
|
1005
|
-
return
|
|
1006
|
-
} else if (
|
|
1007
|
-
const
|
|
1008
|
-
return
|
|
396
|
+
const f = new URL(h), d = f.pathname;
|
|
397
|
+
if (d.includes("/js/")) {
|
|
398
|
+
const y = "../assets/" + a, m = new URL(y, f);
|
|
399
|
+
return L(`🔍 [deform.worker] 计算路径: ${a} -> ${m.pathname} (Worker: ${d})`), m.pathname;
|
|
400
|
+
} else if (d.includes("/assets/")) {
|
|
401
|
+
const y = "./" + a, m = new URL(y, f);
|
|
402
|
+
return L(`🔍 [deform.worker] 计算路径: ${a} -> ${m.pathname} (Worker: ${d})`), m.pathname;
|
|
1009
403
|
} else
|
|
1010
|
-
return
|
|
404
|
+
return L(`🔍 [deform.worker] 使用默认绝对路径: /assets/${a}`), "/assets/" + a;
|
|
1011
405
|
}
|
|
1012
406
|
} catch (h) {
|
|
1013
|
-
|
|
407
|
+
se("⚠️ [deform.worker] 无法计算 WASM 相对路径,使用默认路径:", h);
|
|
1014
408
|
}
|
|
1015
|
-
return "/assets/" +
|
|
1016
|
-
}, e = self.WASM_URL ||
|
|
1017
|
-
|
|
1018
|
-
const
|
|
1019
|
-
if (!
|
|
409
|
+
return "/assets/" + a;
|
|
410
|
+
}, e = self.WASM_URL || t("perspective.wasm"), r = self.WASM_EXEC_URL || t("wasm_exec.js");
|
|
411
|
+
L("🔍 [deform.worker] 最终使用的 WASM 路径:", { wasmUrl: e, wasmExecUrl: r }), await E.load(e, r);
|
|
412
|
+
const n = b || self.LICENSE_TOKEN, u = O || self.LICENSE_API_URL, o = $ || self.DEVICE_ID, c = U || self.DOMAIN;
|
|
413
|
+
if (!n)
|
|
1020
414
|
throw new Error("LICENSE_TOKEN 未设置,无法使用 WASM 功能");
|
|
1021
|
-
if (!await
|
|
415
|
+
if (!await E.verifyLicense(n, u))
|
|
1022
416
|
throw new Error("WASM License 验证失败,无法使用 WASM 功能");
|
|
1023
|
-
} catch (
|
|
1024
|
-
throw
|
|
417
|
+
} catch (t) {
|
|
418
|
+
throw E = null, M = null, t;
|
|
1025
419
|
} finally {
|
|
1026
|
-
|
|
420
|
+
R = !1;
|
|
1027
421
|
}
|
|
1028
|
-
})(),
|
|
422
|
+
})(), M) : Promise.resolve();
|
|
1029
423
|
}
|
|
1030
|
-
function
|
|
1031
|
-
return "naturalWidth" in
|
|
424
|
+
function Y(s) {
|
|
425
|
+
return "naturalWidth" in s && s.naturalWidth ? { width: s.naturalWidth, height: s.naturalHeight } : "width" in s ? { width: s.width, height: s.height } : { width: 0, height: 0 };
|
|
1032
426
|
}
|
|
1033
|
-
function
|
|
1034
|
-
if (!
|
|
427
|
+
function oe(s, t) {
|
|
428
|
+
if (!s || !s.bounds)
|
|
1035
429
|
throw new Error("Invalid layer data: missing bounds");
|
|
1036
|
-
const e =
|
|
1037
|
-
if (
|
|
1038
|
-
return { ...
|
|
1039
|
-
const r =
|
|
430
|
+
const e = s.bounds;
|
|
431
|
+
if (t && t.width > 0 && t.height > 0)
|
|
432
|
+
return { ...s };
|
|
433
|
+
const r = s.size || s.placedLayer || {
|
|
1040
434
|
width: e.width,
|
|
1041
435
|
height: e.height
|
|
1042
|
-
},
|
|
1043
|
-
return
|
|
1044
|
-
(
|
|
1045
|
-
(
|
|
1046
|
-
(
|
|
1047
|
-
(
|
|
1048
|
-
(
|
|
1049
|
-
(
|
|
1050
|
-
(
|
|
1051
|
-
(
|
|
1052
|
-
]),
|
|
1053
|
-
}
|
|
1054
|
-
function
|
|
1055
|
-
return
|
|
1056
|
-
}
|
|
1057
|
-
function
|
|
1058
|
-
if (!
|
|
436
|
+
}, n = r.width / e.width, u = r.height / e.height, o = { ...s };
|
|
437
|
+
return s.transform && s.transform.length === 8 && (o.transform = [
|
|
438
|
+
(s.transform[0] - e.left) * n,
|
|
439
|
+
(s.transform[1] - e.top) * u,
|
|
440
|
+
(s.transform[2] - e.left) * n,
|
|
441
|
+
(s.transform[3] - e.top) * u,
|
|
442
|
+
(s.transform[4] - e.left) * n,
|
|
443
|
+
(s.transform[5] - e.top) * u,
|
|
444
|
+
(s.transform[6] - e.left) * n,
|
|
445
|
+
(s.transform[7] - e.top) * u
|
|
446
|
+
]), o;
|
|
447
|
+
}
|
|
448
|
+
function ie(s) {
|
|
449
|
+
return s.error, s;
|
|
450
|
+
}
|
|
451
|
+
function ce(s, t, e) {
|
|
452
|
+
if (!s || !t || !e)
|
|
1059
453
|
return "Invalid Parameters";
|
|
1060
|
-
const r = "naturalWidth" in
|
|
1061
|
-
if (!r || !
|
|
454
|
+
const r = "naturalWidth" in t ? t.naturalWidth : "width" in t ? t.width : 0, n = "naturalHeight" in t ? t.naturalHeight : "height" in t ? t.height : 0;
|
|
455
|
+
if (!r || !n)
|
|
1062
456
|
return "Image Not Loaded";
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
{ x:
|
|
1070
|
-
{ x:
|
|
1071
|
-
{ x:
|
|
1072
|
-
{ x: a[6], y: a[7] }
|
|
457
|
+
s.imageSmoothingEnabled = !0, s.imageSmoothingQuality = "high";
|
|
458
|
+
let u = null, o = null, c = null, w = null, a = 0, l = 0, i = null, h = "Unknown";
|
|
459
|
+
if (e.size && e.size.width ? (a = e.size.width, l = e.size.height) : e.placedLayer && e.placedLayer.width ? (a = e.placedLayer.width, l = e.placedLayer.height) : e.originalWidth && (a = e.originalWidth, l = e.originalHeight), e.meshPoints && e.meshPoints.length > 0 && (u = e.meshPoints), e.transform && e.transform.length === 8) {
|
|
460
|
+
const f = e.transform;
|
|
461
|
+
o = [
|
|
462
|
+
{ x: f[0], y: f[1] },
|
|
463
|
+
{ x: f[2], y: f[3] },
|
|
464
|
+
{ x: f[4], y: f[5] },
|
|
465
|
+
{ x: f[6], y: f[7] }
|
|
1073
466
|
];
|
|
1074
467
|
}
|
|
1075
|
-
|
|
1076
|
-
try {
|
|
1077
|
-
const a = e.presetPuppet, y = (D) => {
|
|
1078
|
-
if (!D) return [];
|
|
1079
|
-
if (D.length > 0 && typeof D[0] == "number") {
|
|
1080
|
-
const C = [], F = D;
|
|
1081
|
-
for (let S = 0; S < F.length; S += 2) C.push({ x: F[S], y: F[S + 1] });
|
|
1082
|
-
return C;
|
|
1083
|
-
}
|
|
1084
|
-
return D;
|
|
1085
|
-
}, m = y(a.originalVertices), x = y(a.pinTargets), E = a.pinOffsets ? y(a.pinOffsets) : void 0, w = ue({
|
|
1086
|
-
originalVertices: m,
|
|
1087
|
-
triangles: a.triangles,
|
|
1088
|
-
pinIndices: a.pinIndices,
|
|
1089
|
-
pinTargets: x,
|
|
1090
|
-
pinOffsets: E
|
|
1091
|
-
});
|
|
1092
|
-
Qt(w), ie(w);
|
|
1093
|
-
const M = Ut(n);
|
|
1094
|
-
for (let D = 0; D < a.triangles.length; D += 3) {
|
|
1095
|
-
const C = a.triangles[D], F = a.triangles[D + 1], S = a.triangles[D + 2], I = { x: w.UC[C * 2], y: w.UC[C * 2 + 1] }, v = { x: w.UC[F * 2], y: w.UC[F * 2 + 1] }, T = { x: w.UC[S * 2], y: w.UC[S * 2 + 1] }, W = { x: w.M3[C * 2], y: w.M3[C * 2 + 1] }, L = { x: w.M3[F * 2], y: w.M3[F * 2 + 1] }, B = { x: w.M3[S * 2], y: w.M3[S * 2 + 1] };
|
|
1096
|
-
let b = I, P = v, X = T;
|
|
1097
|
-
m.length > 0 && Math.max(
|
|
1098
|
-
...m.map((k) => Math.max(k.x, k.y))
|
|
1099
|
-
) <= 1.5 && (b = { x: I.x * M.width, y: I.y * M.height }, P = { x: v.x * M.width, y: v.y * M.height }, X = { x: T.x * M.width, y: T.y * M.height }), ot(t, n, b, P, X, W, L, B);
|
|
1100
|
-
}
|
|
1101
|
-
A = "Photopea ARAP Puppet";
|
|
1102
|
-
} catch {
|
|
1103
|
-
}
|
|
1104
|
-
if (A === "Unknown" && e.presetWarp && e.presetWarp.preset)
|
|
1105
|
-
try {
|
|
1106
|
-
const a = e.presetWarp, y = d / h, m = ee({
|
|
1107
|
-
preset: a.preset,
|
|
1108
|
-
value: a.value,
|
|
1109
|
-
rotateHorizontal: a.horizontal !== !1,
|
|
1110
|
-
perspective: a.perspective ?? 0,
|
|
1111
|
-
perspectiveOther: a.perspectiveOther ?? 0,
|
|
1112
|
-
aspect: y
|
|
1113
|
-
});
|
|
1114
|
-
ne(m.points, {
|
|
1115
|
-
x: e.bounds.left,
|
|
1116
|
-
y: e.bounds.top,
|
|
1117
|
-
width: e.bounds.width,
|
|
1118
|
-
height: e.bounds.height
|
|
1119
|
-
});
|
|
1120
|
-
const x = [];
|
|
1121
|
-
for (let E = 0; E < m.points.length; E += 2)
|
|
1122
|
-
x.push({ x: m.points[E], y: m.points[E + 1] });
|
|
1123
|
-
m.cols === 4 && m.rows === 4 ? Jt(t, n, x) : yt(t, n, x, "grid", m.cols, 20), A = `Preset:${a.preset}`;
|
|
1124
|
-
} catch {
|
|
1125
|
-
}
|
|
1126
|
-
A === "Unknown" && p && p.filter && p.filter.puppetShapeList && p.filter.puppetShapeList.length > 0 && c ? (ye(t, n, c, p.filter.puppetShapeList[0]), A = "Puppet Warp") : A === "Unknown" && u && c ? l && f ? (we(t, n, c, u, l, f, d, h), A = "Quilt Mesh") : u.length === 16 ? (de(t, n, c, u), A = "Std Mesh (16pt)") : (pe(t, n, c, u), A = "Auto-Fit Mesh") : A === "Unknown" && u ? (Jt(t, n, u), A = "Direct Mesh") : A === "Unknown" && c && ($t(t, n, c), A = "Transform Only");
|
|
1127
|
-
const g = Ee(n, o, i);
|
|
1128
|
-
if (g)
|
|
1129
|
-
Ot = g;
|
|
1130
|
-
else if (Z.length > 0) {
|
|
1131
|
-
const y = new OffscreenCanvas(r, s).getContext("2d");
|
|
1132
|
-
y.drawImage(n, 0, 0), Tt = y.getImageData(0, 0, r, s).data, jt = r, Kt = s, Rt = o, Xt = i, ut = new ImageData(Rt, Xt), Pt = ut.data;
|
|
1133
|
-
for (const m of Z)
|
|
1134
|
-
xe(
|
|
1135
|
-
{ x: m.t0x, y: m.t0y },
|
|
1136
|
-
{ x: m.t1x, y: m.t1y },
|
|
1137
|
-
{ x: m.t2x, y: m.t2y },
|
|
1138
|
-
{ x: m.p0x, y: m.p0y },
|
|
1139
|
-
{ x: m.p1x, y: m.p1y },
|
|
1140
|
-
{ x: m.p2x, y: m.p2y }
|
|
1141
|
-
);
|
|
1142
|
-
ut && t.putImageData(ut, 0, 0), Tt = null, Pt = null, ut = null;
|
|
1143
|
-
}
|
|
1144
|
-
return A;
|
|
468
|
+
return e.quiltSliceX && (c = e.quiltSliceX), e.quiltSliceY && (w = e.quiltSliceY), e.filterList && (i = e.filterList.find((f) => f.type === "puppet" && f.enabled)), a === 0 && c && c.length > 0 && (a = c[c.length - 1]), a === 0 && (a = 1e3), l === 0 && (l = 1e3), i && i.filter && i.filter.puppetShapeList && i.filter.puppetShapeList.length > 0 && o ? (ae(s, t, o, i.filter.puppetShapeList[0]), h = "Puppet Warp") : u && o ? c && w ? (he(s, t, o, u, c, w, a, l), h = "Quilt Mesh") : u.length === 16 ? (le(s, t, o, u), h = "Std Mesh (16pt)") : (fe(s, t, o, u), h = "Auto-Fit Mesh") : u ? (de(s, t, u), h = "Direct Mesh") : o && (K(s, t, o), h = "Transform Only"), h;
|
|
1145
469
|
}
|
|
1146
|
-
function
|
|
470
|
+
function ae(s, t, e, r, n, u) {
|
|
1147
471
|
if (!r.originalVertexArray || !r.deformedVertexArray || !r.indexArray)
|
|
1148
472
|
return;
|
|
1149
|
-
const
|
|
1150
|
-
if (!
|
|
1151
|
-
|
|
473
|
+
const o = q(e), c = ye(o);
|
|
474
|
+
if (!c) {
|
|
475
|
+
K(s, t, e);
|
|
1152
476
|
return;
|
|
1153
477
|
}
|
|
1154
|
-
const
|
|
1155
|
-
for (let
|
|
1156
|
-
const h =
|
|
1157
|
-
if (!
|
|
1158
|
-
const
|
|
1159
|
-
|
|
478
|
+
const w = r.originalVertexArray, a = r.deformedVertexArray, l = r.indexArray;
|
|
479
|
+
for (let i = 0; i < l.length; i += 3) {
|
|
480
|
+
const h = l[i], f = l[i + 1], d = l[i + 2];
|
|
481
|
+
if (!w[h] || !w[f] || !w[d]) continue;
|
|
482
|
+
const y = w[h], m = w[f], F = w[d], g = X(y.x, y.y, c), p = X(m.x, m.y, c), x = X(F.x, F.y, c), A = Y(t), D = { x: g.x * A.width, y: g.y * A.height }, W = { x: p.x * A.width, y: p.y * A.height }, B = { x: x.x * A.width, y: x.y * A.height }, _ = a[h], I = a[f], v = a[d];
|
|
483
|
+
k(s, t, D, W, B, _, I, v);
|
|
1160
484
|
}
|
|
1161
485
|
}
|
|
1162
|
-
function
|
|
1163
|
-
let
|
|
1164
|
-
r.forEach((
|
|
1165
|
-
|
|
486
|
+
function le(s, t, e, r) {
|
|
487
|
+
let n = 1 / 0, u = -1 / 0, o = 1 / 0, c = -1 / 0;
|
|
488
|
+
r.forEach((i) => {
|
|
489
|
+
n = Math.min(n, i.x), u = Math.max(u, i.x), o = Math.min(o, i.y), c = Math.max(c, i.y);
|
|
1166
490
|
});
|
|
1167
|
-
const
|
|
1168
|
-
if (
|
|
1169
|
-
|
|
491
|
+
const w = u - n, a = c - o;
|
|
492
|
+
if (w < 1 || a < 1) {
|
|
493
|
+
K(s, t, e);
|
|
1170
494
|
return;
|
|
1171
495
|
}
|
|
1172
|
-
const
|
|
1173
|
-
const h = (
|
|
1174
|
-
return
|
|
496
|
+
const l = r.map((i) => {
|
|
497
|
+
const h = (i.x - n) / w, f = (i.y - o) / a;
|
|
498
|
+
return N(h, f, e);
|
|
1175
499
|
});
|
|
1176
|
-
|
|
500
|
+
V(s, t, l, "bicubic", 4, 40);
|
|
1177
501
|
}
|
|
1178
|
-
function
|
|
1179
|
-
const
|
|
1180
|
-
let
|
|
1181
|
-
r.forEach((
|
|
1182
|
-
|
|
502
|
+
function he(s, t, e, r, n, u, o, c) {
|
|
503
|
+
const w = q(e);
|
|
504
|
+
let a = 1 / 0, l = -1 / 0, i = 1 / 0, h = -1 / 0;
|
|
505
|
+
r.forEach((F) => {
|
|
506
|
+
a = Math.min(a, F.x), l = Math.max(l, F.x), i = Math.min(i, F.y), h = Math.max(h, F.y);
|
|
1183
507
|
});
|
|
1184
|
-
const
|
|
1185
|
-
for (let
|
|
1186
|
-
for (let
|
|
1187
|
-
const
|
|
508
|
+
const f = l - a || 1, d = h - i || 1, y = n.length - 1, m = u.length - 1;
|
|
509
|
+
for (let F = 0; F < m; F++)
|
|
510
|
+
for (let g = 0; g < y; g++) {
|
|
511
|
+
const p = F * 3, x = g * 3, A = [], D = y * 3 + 1;
|
|
1188
512
|
try {
|
|
1189
|
-
for (let
|
|
513
|
+
for (let S = 0; S < 4; S++)
|
|
1190
514
|
for (let T = 0; T < 4; T++) {
|
|
1191
|
-
const
|
|
1192
|
-
r[
|
|
515
|
+
const J = (p + S) * D + (x + T);
|
|
516
|
+
r[J] && A.push(r[J]);
|
|
1193
517
|
}
|
|
1194
518
|
} catch {
|
|
1195
519
|
continue;
|
|
1196
520
|
}
|
|
1197
|
-
if (
|
|
1198
|
-
const
|
|
1199
|
-
const T = (
|
|
1200
|
-
return
|
|
1201
|
-
}),
|
|
1202
|
-
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
function
|
|
1206
|
-
const
|
|
1207
|
-
let
|
|
1208
|
-
r.forEach((
|
|
1209
|
-
|
|
521
|
+
if (A.length < 16) continue;
|
|
522
|
+
const W = A.map((S) => {
|
|
523
|
+
const T = (S.x - a) / f, J = (S.y - i) / d;
|
|
524
|
+
return ee(T, J, w);
|
|
525
|
+
}), B = n[g] / o, _ = n[g + 1] / o, I = u[F] / c, v = u[F + 1] / c;
|
|
526
|
+
we(s, t, W, B, _, I, v);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
function fe(s, t, e, r) {
|
|
530
|
+
const n = q(e);
|
|
531
|
+
let u = 1 / 0, o = -1 / 0, c = 1 / 0, w = -1 / 0;
|
|
532
|
+
r.forEach((f) => {
|
|
533
|
+
u = Math.min(u, f.x), o = Math.max(o, f.x), c = Math.min(c, f.y), w = Math.max(w, f.y);
|
|
1210
534
|
});
|
|
1211
|
-
const
|
|
1212
|
-
const
|
|
1213
|
-
return
|
|
535
|
+
const a = o - u || 1, l = w - c || 1, i = r.map((f) => {
|
|
536
|
+
const d = (f.x - u) / a, y = (f.y - c) / l;
|
|
537
|
+
return ee(d, y, n);
|
|
1214
538
|
}), h = Math.floor(Math.sqrt(r.length)) || 4;
|
|
1215
|
-
|
|
539
|
+
V(s, t, i, "grid", h, 40);
|
|
1216
540
|
}
|
|
1217
|
-
function
|
|
1218
|
-
const
|
|
1219
|
-
for (let
|
|
541
|
+
function we(s, t, e, r, n, u, o) {
|
|
542
|
+
const w = Y(t), a = w.width, l = w.height;
|
|
543
|
+
for (let i = 0; i < 20; i++)
|
|
1220
544
|
for (let h = 0; h < 20; h++) {
|
|
1221
|
-
const
|
|
1222
|
-
|
|
545
|
+
const f = h / 20, d = i / 20, y = (h + 1) / 20, m = (i + 1) / 20, F = r + f * (n - r), g = r + y * (n - r), p = u + d * (o - u), x = u + m * (o - u), A = { x: F * a, y: p * l }, D = { x: g * a, y: p * l }, W = { x: F * a, y: x * l }, B = { x: g * a, y: x * l }, _ = C(f, d, e), I = C(y, d, e), v = C(f, m, e), S = C(y, m, e);
|
|
546
|
+
k(s, t, A, D, W, _, I, v), k(s, t, D, B, W, I, S, v);
|
|
1223
547
|
}
|
|
1224
548
|
}
|
|
1225
|
-
function
|
|
1226
|
-
|
|
549
|
+
function K(s, t, e) {
|
|
550
|
+
V(s, t, e, "bilinear", 0, 10);
|
|
1227
551
|
}
|
|
1228
|
-
function
|
|
1229
|
-
|
|
552
|
+
function de(s, t, e) {
|
|
553
|
+
V(s, t, e, "bicubic", 4, 40);
|
|
1230
554
|
}
|
|
1231
|
-
function
|
|
1232
|
-
const
|
|
1233
|
-
for (let
|
|
1234
|
-
for (let
|
|
1235
|
-
const
|
|
1236
|
-
let
|
|
1237
|
-
r === "bicubic" ? (
|
|
555
|
+
function V(s, t, e, r, n, u) {
|
|
556
|
+
const o = Y(t), c = o.width, w = o.height;
|
|
557
|
+
for (let a = 0; a < u; a++)
|
|
558
|
+
for (let l = 0; l < u; l++) {
|
|
559
|
+
const i = l / u, h = a / u, f = (l + 1) / u, d = (a + 1) / u, y = { x: i * c, y: h * w }, m = { x: f * c, y: h * w }, F = { x: i * c, y: d * w }, g = { x: f * c, y: d * w };
|
|
560
|
+
let p, x, A, D;
|
|
561
|
+
r === "bicubic" ? (p = C(i, h, e), x = C(f, h, e), A = C(i, d, e), D = C(f, d, e)) : r === "grid" ? (p = j(i, h, e, n), x = j(f, h, e, n), A = j(i, d, e, n), D = j(f, d, e, n)) : (p = N(i, h, e), x = N(f, h, e), A = N(i, d, e), D = N(f, d, e)), k(s, t, y, m, F, p, x, A), k(s, t, m, g, F, x, D, A);
|
|
1238
562
|
}
|
|
1239
563
|
}
|
|
1240
|
-
function
|
|
1241
|
-
const e = 1 -
|
|
1242
|
-
return
|
|
564
|
+
function Q(s, t) {
|
|
565
|
+
const e = 1 - t;
|
|
566
|
+
return s === 0 ? e * e * e : s === 1 ? 3 * e * e * t : s === 2 ? 3 * e * t * t : t * t * t;
|
|
1243
567
|
}
|
|
1244
|
-
function
|
|
1245
|
-
let r = 0,
|
|
1246
|
-
for (let
|
|
1247
|
-
for (let
|
|
1248
|
-
const
|
|
1249
|
-
r += e[
|
|
568
|
+
function C(s, t, e) {
|
|
569
|
+
let r = 0, n = 0;
|
|
570
|
+
for (let u = 0; u < 4; u++)
|
|
571
|
+
for (let o = 0; o < 4; o++) {
|
|
572
|
+
const c = Q(u, t) * Q(o, s);
|
|
573
|
+
r += e[u * 4 + o].x * c, n += e[u * 4 + o].y * c;
|
|
1250
574
|
}
|
|
1251
|
-
return { x: r, y:
|
|
575
|
+
return { x: r, y: n };
|
|
1252
576
|
}
|
|
1253
|
-
function
|
|
1254
|
-
const r = (1 -
|
|
1255
|
-
return { x: r, y:
|
|
577
|
+
function N(s, t, e) {
|
|
578
|
+
const r = (1 - s) * (1 - t) * e[0].x + s * (1 - t) * e[1].x + s * t * e[2].x + (1 - s) * t * e[3].x, n = (1 - s) * (1 - t) * e[0].y + s * (1 - t) * e[1].y + s * t * e[2].y + (1 - s) * t * e[3].y;
|
|
579
|
+
return { x: r, y: n };
|
|
1256
580
|
}
|
|
1257
|
-
function
|
|
1258
|
-
const
|
|
1259
|
-
let
|
|
1260
|
-
|
|
1261
|
-
const
|
|
1262
|
-
return { x:
|
|
581
|
+
function j(s, t, e, r) {
|
|
582
|
+
const n = r - 1, u = s * n, o = t * n;
|
|
583
|
+
let c = Math.floor(u), w = Math.floor(o);
|
|
584
|
+
c >= n && (c = n - 1), w >= n && (w = n - 1), c < 0 && (c = 0), w < 0 && (w = 0);
|
|
585
|
+
const a = u - c, l = o - w, i = e[w * r + c], h = e[w * r + (c + 1)], f = e[(w + 1) * r + c], d = e[(w + 1) * r + (c + 1)], y = (1 - a) * (1 - l) * i.x + a * (1 - l) * h.x + a * l * d.x + (1 - a) * l * f.x, m = (1 - a) * (1 - l) * i.y + a * (1 - l) * h.y + a * l * d.y + (1 - a) * l * f.y;
|
|
586
|
+
return { x: y, y: m };
|
|
1263
587
|
}
|
|
1264
|
-
function
|
|
1265
|
-
if (!
|
|
588
|
+
function q(s) {
|
|
589
|
+
if (!E || !E.isReady())
|
|
1266
590
|
throw new Error("WASM 模块未加载,无法计算透视变换矩阵");
|
|
1267
591
|
try {
|
|
1268
|
-
return
|
|
1269
|
-
} catch (
|
|
1270
|
-
throw new Error(`WASM 计算透视矩阵失败: ${
|
|
592
|
+
return E.calcPerspectiveMatrix(s);
|
|
593
|
+
} catch (t) {
|
|
594
|
+
throw new Error(`WASM 计算透视矩阵失败: ${t}`);
|
|
1271
595
|
}
|
|
1272
596
|
}
|
|
1273
|
-
function
|
|
1274
|
-
if (!
|
|
597
|
+
function ye(s) {
|
|
598
|
+
if (!E || !E.isReady())
|
|
1275
599
|
throw new Error("WASM 模块未加载,无法求逆矩阵");
|
|
1276
600
|
try {
|
|
1277
|
-
return
|
|
1278
|
-
} catch (
|
|
1279
|
-
throw new Error(`WASM 求逆矩阵失败: ${
|
|
601
|
+
return E.invertMatrix(s);
|
|
602
|
+
} catch (t) {
|
|
603
|
+
throw new Error(`WASM 求逆矩阵失败: ${t}`);
|
|
1280
604
|
}
|
|
1281
605
|
}
|
|
1282
|
-
function
|
|
1283
|
-
if (!
|
|
606
|
+
function X(s, t, e) {
|
|
607
|
+
if (!E || !E.isReady())
|
|
1284
608
|
throw new Error("WASM 模块未加载,无法应用逆透视变换");
|
|
1285
609
|
try {
|
|
1286
|
-
return
|
|
610
|
+
return E.applyInversePerspective(s, t, e);
|
|
1287
611
|
} catch (r) {
|
|
1288
612
|
throw new Error(`WASM 应用逆透视变换失败: ${r}`);
|
|
1289
613
|
}
|
|
1290
614
|
}
|
|
1291
|
-
function
|
|
1292
|
-
if (!
|
|
615
|
+
function ee(s, t, e) {
|
|
616
|
+
if (!E || !E.isReady())
|
|
1293
617
|
throw new Error("WASM 模块未加载,无法应用透视变换");
|
|
1294
618
|
try {
|
|
1295
|
-
return
|
|
619
|
+
return E.applyPerspective(s, t, e);
|
|
1296
620
|
} catch (r) {
|
|
1297
621
|
throw new Error(`WASM 应用透视变换失败: ${r}`);
|
|
1298
622
|
}
|
|
1299
623
|
}
|
|
1300
|
-
function
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
p0x: o.x,
|
|
1309
|
-
p0y: o.y,
|
|
1310
|
-
p1x: i.x,
|
|
1311
|
-
p1y: i.y,
|
|
1312
|
-
p2x: u.x,
|
|
1313
|
-
p2y: u.y
|
|
1314
|
-
});
|
|
1315
|
-
}
|
|
1316
|
-
function xe(t, n, e, r, s, o) {
|
|
1317
|
-
if (!Tt || !Pt) return;
|
|
1318
|
-
const i = t.x * (e.y - n.y) - n.x * e.y + e.x * n.y + (n.x - e.x) * t.y;
|
|
1319
|
-
if (Math.abs(i) < 1e-3) return;
|
|
1320
|
-
const u = -(t.y * (o.x - s.x) - n.y * o.x + e.y * s.x + (n.y - e.y) * r.x) / i, c = (n.y * o.y + t.y * (s.y - o.y) - e.y * s.y + (e.y - n.y) * r.y) / i, l = (t.x * (o.x - s.x) - n.x * o.x + e.x * s.x + (n.x - e.x) * r.x) / i, f = -(n.x * o.y + t.x * (s.y - o.y) - e.x * s.y + (e.x - n.x) * r.y) / i, d = (t.x * (e.y * s.x - n.y * o.x) + t.y * (n.x * o.x - e.x * s.x) + (e.x * n.y - n.x * e.y) * r.x) / i, h = (t.x * (e.y * s.y - n.y * o.y) + t.y * (n.x * o.y - e.x * s.y) + (e.x * n.y - n.x * e.y) * r.y) / i, p = u * f - c * l;
|
|
1321
|
-
if (Math.abs(p) < 1e-9) return;
|
|
1322
|
-
const A = f / p, g = -c / p, a = -l / p, y = u / p, m = (-f * d + l * h) / p, x = (c * d - u * h) / p, E = Math.max(0, Math.floor(Math.min(r.x, s.x, o.x))), w = Math.min(Rt - 1, Math.ceil(Math.max(r.x, s.x, o.x))), M = Math.max(0, Math.floor(Math.min(r.y, s.y, o.y))), D = Math.min(Xt - 1, Math.ceil(Math.max(r.y, s.y, o.y))), C = s.x - r.x, F = s.y - r.y, S = o.x - s.x, I = o.y - s.y, v = r.x - o.x, T = r.y - o.y, W = jt, L = Kt, B = Tt, b = Pt;
|
|
1323
|
-
for (let P = M; P <= D; P++) {
|
|
1324
|
-
const X = P + 0.5, O = C * (X - r.y), k = S * (X - s.y), j = v * (X - o.y);
|
|
1325
|
-
for (let Y = E; Y <= w; Y++) {
|
|
1326
|
-
const J = Y + 0.5, z = O - F * (J - r.x), K = k - I * (J - s.x), N = j - T * (J - o.x);
|
|
1327
|
-
if (!(z >= 0 && K >= 0 && N >= 0 || z <= 0 && K <= 0 && N <= 0)) continue;
|
|
1328
|
-
const V = A * J + a * X + m, dt = g * J + y * X + x;
|
|
1329
|
-
if (V < 0 || V >= W || dt < 0 || dt >= L) continue;
|
|
1330
|
-
const tt = V | 0, et = dt | 0, Vt = tt < W - 1 ? tt + 1 : tt, Yt = et < L - 1 ? et + 1 : et, wt = V - tt, pt = dt - et, gt = (1 - wt) * (1 - pt), mt = wt * (1 - pt), xt = (1 - wt) * pt, Et = wt * pt, At = (et * W + tt) * 4, Mt = (et * W + Vt) * 4, Ft = (Yt * W + tt) * 4, Dt = (Yt * W + Vt) * 4, St = (P * Rt + Y) * 4;
|
|
1331
|
-
b[St] = gt * B[At] + mt * B[Mt] + xt * B[Ft] + Et * B[Dt], b[St + 1] = gt * B[At + 1] + mt * B[Mt + 1] + xt * B[Ft + 1] + Et * B[Dt + 1], b[St + 2] = gt * B[At + 2] + mt * B[Mt + 2] + xt * B[Ft + 2] + Et * B[Dt + 2], b[St + 3] = gt * B[At + 3] + mt * B[Mt + 3] + xt * B[Ft + 3] + Et * B[Dt + 3];
|
|
1332
|
-
}
|
|
1333
|
-
}
|
|
1334
|
-
}
|
|
1335
|
-
function Ee(t, n, e) {
|
|
1336
|
-
if (Z.length === 0) return null;
|
|
1337
|
-
try {
|
|
1338
|
-
if ((!nt || nt.width !== n || nt.height !== e) && (nt = new OffscreenCanvas(n, e), G = null, Ct = null, bt = null, vt = null), !G) {
|
|
1339
|
-
if (G = nt.getContext("webgl", {
|
|
1340
|
-
alpha: !0,
|
|
1341
|
-
premultipliedAlpha: !1,
|
|
1342
|
-
// 启用 MSAA:硬件抗锯齿,对三角形边缘、硬边图案(如网格/文字)显著改善
|
|
1343
|
-
// 现代 GPU 上开销可忽略;OffscreenCanvas + WebGL 1 默认 4x MSAA
|
|
1344
|
-
antialias: !0
|
|
1345
|
-
}), !G) return null;
|
|
1346
|
-
const a = G, y = "attribute vec2 aPos;attribute vec2 aUV;varying vec2 vUV;void main(){gl_Position=vec4(aPos,0.0,1.0);vUV=aUV;}", m = "precision highp float;uniform sampler2D uTex;varying vec2 vUV;void main(){if(vUV.x<0.0||vUV.x>1.0||vUV.y<0.0||vUV.y>1.0){gl_FragColor=vec4(0.0);return;}gl_FragColor=texture2D(uTex,vUV);}", x = (D, C) => {
|
|
1347
|
-
const F = a.createShader(D);
|
|
1348
|
-
return F ? (a.shaderSource(F, C), a.compileShader(F), a.getShaderParameter(F, a.COMPILE_STATUS) ? F : null) : null;
|
|
1349
|
-
}, E = x(a.VERTEX_SHADER, y), w = x(a.FRAGMENT_SHADER, m);
|
|
1350
|
-
if (!E || !w)
|
|
1351
|
-
return G = null, null;
|
|
1352
|
-
const M = a.createProgram();
|
|
1353
|
-
if (a.attachShader(M, E), a.attachShader(M, w), a.linkProgram(M), !a.getProgramParameter(M, a.LINK_STATUS))
|
|
1354
|
-
return G = null, null;
|
|
1355
|
-
Ct = M, bt = a.createBuffer(), vt = a.createTexture();
|
|
1356
|
-
}
|
|
1357
|
-
const r = G, s = Ct, o = "naturalWidth" in t ? t.naturalWidth : t.width, i = "naturalWidth" in t ? t.naturalHeight : t.height, u = r.getParameter(r.MAX_TEXTURE_SIZE), c = Math.min(u, Math.max(n * 2, e * 2));
|
|
1358
|
-
let l = t;
|
|
1359
|
-
if (o > c || i > c) {
|
|
1360
|
-
const a = Math.min(c / o, c / i), y = Math.max(1, Math.floor(o * a)), m = Math.max(1, Math.floor(i * a)), x = new OffscreenCanvas(y, m);
|
|
1361
|
-
x.getContext("2d").drawImage(t, 0, 0, y, m), l = x;
|
|
1362
|
-
}
|
|
1363
|
-
r.bindTexture(r.TEXTURE_2D, vt), r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MIN_FILTER, r.LINEAR), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MAG_FILTER, r.LINEAR), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE), r.texImage2D(r.TEXTURE_2D, 0, r.RGBA, r.RGBA, r.UNSIGNED_BYTE, l);
|
|
1364
|
-
const f = Z.length, d = new Float32Array(f * 12), h = 1.65;
|
|
1365
|
-
for (let a = 0; a < f; a++) {
|
|
1366
|
-
const y = Z[a], m = a * 12, x = (y.p0x + y.p1x + y.p2x) / 3, E = (y.p0y + y.p1y + y.p2y) / 3, w = (y.t0x + y.t1x + y.t2x) / 3, M = (y.t0y + y.t1y + y.t2y) / 3, D = x + (y.p0x - x) * h, C = E + (y.p0y - E) * h, F = x + (y.p1x - x) * h, S = E + (y.p1y - E) * h, I = x + (y.p2x - x) * h, v = E + (y.p2y - E) * h, T = w + (y.t0x - w) * h, W = M + (y.t0y - M) * h, L = w + (y.t1x - w) * h, B = M + (y.t1y - M) * h, b = w + (y.t2x - w) * h, P = M + (y.t2y - M) * h;
|
|
1367
|
-
d[m] = D / n * 2 - 1, d[m + 1] = -(C / e * 2 - 1), d[m + 2] = T / o, d[m + 3] = W / i, d[m + 4] = F / n * 2 - 1, d[m + 5] = -(S / e * 2 - 1), d[m + 6] = L / o, d[m + 7] = B / i, d[m + 8] = I / n * 2 - 1, d[m + 9] = -(v / e * 2 - 1), d[m + 10] = b / o, d[m + 11] = P / i;
|
|
1368
|
-
}
|
|
1369
|
-
r.useProgram(s), r.bindBuffer(r.ARRAY_BUFFER, bt), r.bufferData(r.ARRAY_BUFFER, d, r.DYNAMIC_DRAW);
|
|
1370
|
-
const p = 16, A = r.getAttribLocation(s, "aPos");
|
|
1371
|
-
r.enableVertexAttribArray(A), r.vertexAttribPointer(A, 2, r.FLOAT, !1, p, 0);
|
|
1372
|
-
const g = r.getAttribLocation(s, "aUV");
|
|
1373
|
-
return r.enableVertexAttribArray(g), r.vertexAttribPointer(g, 2, r.FLOAT, !1, p, 8), r.viewport(0, 0, n, e), r.clearColor(0, 0, 0, 0), r.clear(r.COLOR_BUFFER_BIT), r.enable(r.BLEND), r.blendFuncSeparate(r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA, r.ONE, r.ONE_MINUS_SRC_ALPHA), r.drawArrays(r.TRIANGLES, 0, f * 3), r.flush(), nt.transferToImageBitmap();
|
|
1374
|
-
} catch {
|
|
1375
|
-
return G = null, Ct = null, bt = null, vt = null, null;
|
|
624
|
+
function k(s, t, e, r, n, u, o, c) {
|
|
625
|
+
if (!t || "complete" in t && !t.complete || !("naturalWidth" in t ? t.naturalWidth : t.width)) return;
|
|
626
|
+
const a = (u.x + o.x + c.x) / 3, l = (u.y + o.y + c.y) / 3, i = 1.65, h = a + (u.x - a) * i, f = l + (u.y - l) * i, d = a + (o.x - a) * i, y = l + (o.y - l) * i, m = a + (c.x - a) * i, F = l + (c.y - l) * i;
|
|
627
|
+
s.save(), s.beginPath(), s.moveTo(h, f), s.lineTo(d, y), s.lineTo(m, F), s.closePath(), s.clip();
|
|
628
|
+
const g = e.x * (n.y - r.y) - r.x * n.y + n.x * r.y + (r.x - n.x) * e.y;
|
|
629
|
+
if (Math.abs(g) < 1e-3) {
|
|
630
|
+
s.restore();
|
|
631
|
+
return;
|
|
1376
632
|
}
|
|
633
|
+
const p = -(e.y * (c.x - o.x) - r.y * c.x + n.y * o.x + (r.y - n.y) * u.x) / g, x = (r.y * c.y + e.y * (o.y - c.y) - n.y * o.y + (n.y - r.y) * u.y) / g, A = (e.x * (c.x - o.x) - r.x * c.x + n.x * o.x + (r.x - n.x) * u.x) / g, D = -(r.x * c.y + e.x * (o.y - c.y) - n.x * o.y + (n.x - r.x) * u.y) / g, W = (e.x * (n.y * o.x - r.y * c.x) + e.y * (r.x * c.x - n.x * o.x) + (n.x * r.y - r.x * n.y) * u.x) / g, B = (e.x * (n.y * o.y - r.y * c.y) + e.y * (r.x * c.y - n.x * o.y) + (n.x * r.y - r.x * n.y) * u.y) / g;
|
|
634
|
+
s.transform(p, x, A, D, W, B), s.drawImage(t, 0, 0), s.restore();
|
|
1377
635
|
}
|
|
1378
|
-
self.onmessage = async (
|
|
1379
|
-
if (
|
|
1380
|
-
|
|
636
|
+
self.onmessage = async (s) => {
|
|
637
|
+
if (s.data?.type === "SET_DEBUG") {
|
|
638
|
+
H = !!s.data?.debugRender, self.__DEBUG_RENDER__ = H;
|
|
1381
639
|
return;
|
|
1382
640
|
}
|
|
1383
|
-
if (
|
|
1384
|
-
|
|
641
|
+
if (s.data?.type === "SET_LICENSE") {
|
|
642
|
+
ue(s.data);
|
|
1385
643
|
return;
|
|
1386
644
|
}
|
|
1387
|
-
const
|
|
645
|
+
const t = s.data, { id: e, designBitmap: r, layerData: n, canvasSize: u } = t;
|
|
1388
646
|
if (!r) {
|
|
1389
647
|
self.postMessage({
|
|
1390
648
|
id: e,
|
|
@@ -1394,7 +652,7 @@ self.onmessage = async (t) => {
|
|
|
1394
652
|
});
|
|
1395
653
|
return;
|
|
1396
654
|
}
|
|
1397
|
-
if (!
|
|
655
|
+
if (!n) {
|
|
1398
656
|
self.postMessage({
|
|
1399
657
|
id: e,
|
|
1400
658
|
imageBitmap: null,
|
|
@@ -1403,58 +661,58 @@ self.onmessage = async (t) => {
|
|
|
1403
661
|
});
|
|
1404
662
|
return;
|
|
1405
663
|
}
|
|
1406
|
-
const
|
|
1407
|
-
if (
|
|
664
|
+
const o = performance.now(), c = (/* @__PURE__ */ new Date()).toISOString();
|
|
665
|
+
if (L(`[deform worker] ⏰ 开始 id=${e} 时间=${c}`, {
|
|
1408
666
|
designBitmap: { width: r.width, height: r.height },
|
|
1409
|
-
size:
|
|
1410
|
-
bounds:
|
|
1411
|
-
canvasSize:
|
|
1412
|
-
}), !
|
|
1413
|
-
if (
|
|
667
|
+
size: n.size,
|
|
668
|
+
bounds: n.bounds,
|
|
669
|
+
canvasSize: u
|
|
670
|
+
}), !E || !E.isReady())
|
|
671
|
+
if (b || self.LICENSE_TOKEN)
|
|
1414
672
|
try {
|
|
1415
|
-
if (
|
|
673
|
+
if (R && M && await M, (!E || !E.isReady()) && await G(), !E || !E.isReady())
|
|
1416
674
|
throw new Error("WASM 模块仍未就绪");
|
|
1417
|
-
} catch (
|
|
1418
|
-
const
|
|
675
|
+
} catch (a) {
|
|
676
|
+
const i = performance.now() - o;
|
|
1419
677
|
self.postMessage({
|
|
1420
678
|
id: e,
|
|
1421
|
-
error: `WASM 初始化失败: ${
|
|
1422
|
-
duration:
|
|
679
|
+
error: `WASM 初始化失败: ${a.message}`,
|
|
680
|
+
duration: i
|
|
1423
681
|
});
|
|
1424
682
|
return;
|
|
1425
683
|
}
|
|
1426
684
|
else {
|
|
1427
|
-
let
|
|
1428
|
-
const
|
|
685
|
+
let a = 0;
|
|
686
|
+
const l = 500, i = 50;
|
|
1429
687
|
let h = null;
|
|
1430
|
-
for (;
|
|
1431
|
-
await new Promise((
|
|
688
|
+
for (; a < l && !h; )
|
|
689
|
+
await new Promise((f) => setTimeout(f, i)), a += i, h = b || self.LICENSE_TOKEN;
|
|
1432
690
|
if (h)
|
|
1433
691
|
try {
|
|
1434
|
-
if (
|
|
692
|
+
if (b = h, O = O || self.LICENSE_API_URL, $ = $ || self.DEVICE_ID, U = U || self.DOMAIN, R && M ? await M : E || await G(), !E || !E.isReady())
|
|
1435
693
|
throw new Error("WASM 模块未就绪");
|
|
1436
|
-
} catch (
|
|
1437
|
-
const
|
|
694
|
+
} catch (f) {
|
|
695
|
+
const y = performance.now() - o;
|
|
1438
696
|
self.postMessage({
|
|
1439
697
|
id: e,
|
|
1440
|
-
error: `WASM 初始化失败: ${
|
|
1441
|
-
duration:
|
|
698
|
+
error: `WASM 初始化失败: ${f.message}`,
|
|
699
|
+
duration: y
|
|
1442
700
|
});
|
|
1443
701
|
return;
|
|
1444
702
|
}
|
|
1445
703
|
else if (!h) {
|
|
1446
|
-
const
|
|
704
|
+
const d = performance.now() - o;
|
|
1447
705
|
self.postMessage({
|
|
1448
706
|
id: e,
|
|
1449
707
|
error: "LICENSE_TOKEN 未设置,无法使用 WASM 功能",
|
|
1450
|
-
duration:
|
|
708
|
+
duration: d
|
|
1451
709
|
});
|
|
1452
710
|
return;
|
|
1453
711
|
}
|
|
1454
712
|
}
|
|
1455
713
|
try {
|
|
1456
|
-
const
|
|
1457
|
-
if (!
|
|
714
|
+
const w = n.bounds;
|
|
715
|
+
if (!w || !w.width || !w.height) {
|
|
1458
716
|
self.postMessage({
|
|
1459
717
|
id: e,
|
|
1460
718
|
imageBitmap: null,
|
|
@@ -1463,42 +721,40 @@ self.onmessage = async (t) => {
|
|
|
1463
721
|
});
|
|
1464
722
|
return;
|
|
1465
723
|
}
|
|
1466
|
-
const
|
|
1467
|
-
let
|
|
1468
|
-
if (
|
|
1469
|
-
|
|
724
|
+
const a = oe(n, u);
|
|
725
|
+
let l, i;
|
|
726
|
+
if (u && u.width > 0 && u.height > 0)
|
|
727
|
+
l = u.width, i = u.height;
|
|
1470
728
|
else {
|
|
1471
|
-
const
|
|
1472
|
-
width:
|
|
1473
|
-
height:
|
|
729
|
+
const x = n.size || n.placedLayer || {
|
|
730
|
+
width: w.width,
|
|
731
|
+
height: w.height
|
|
1474
732
|
};
|
|
1475
|
-
|
|
733
|
+
l = x.width, i = x.height;
|
|
1476
734
|
}
|
|
1477
|
-
const h = new OffscreenCanvas(
|
|
1478
|
-
if (!
|
|
1479
|
-
const
|
|
1480
|
-
self.postMessage({ id: e, error: "Canvas context unavailable", duration:
|
|
735
|
+
const h = new OffscreenCanvas(l, i), f = h.getContext("2d");
|
|
736
|
+
if (!f) {
|
|
737
|
+
const A = performance.now() - o;
|
|
738
|
+
self.postMessage({ id: e, error: "Canvas context unavailable", duration: A });
|
|
1481
739
|
return;
|
|
1482
740
|
}
|
|
1483
|
-
const
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
rt(
|
|
1487
|
-
`[deform worker] ✅ 结束 id=${e} 时间=${m} 耗时=${Math.round(y)}ms 变形方法=${A}`,
|
|
741
|
+
const d = ce(f, r, a), y = h.transferToImageBitmap(), F = performance.now() - o, g = (/* @__PURE__ */ new Date()).toISOString();
|
|
742
|
+
L(
|
|
743
|
+
`[deform worker] ✅ 结束 id=${e} 时间=${g} 耗时=${Math.round(F)}ms 变形方法=${d}`,
|
|
1488
744
|
{
|
|
1489
|
-
width:
|
|
1490
|
-
height:
|
|
745
|
+
width: y.width,
|
|
746
|
+
height: y.height
|
|
1491
747
|
}
|
|
1492
748
|
), r.close();
|
|
1493
|
-
const
|
|
1494
|
-
{ id: e, imageBitmap:
|
|
749
|
+
const p = ie(
|
|
750
|
+
{ id: e, imageBitmap: y, duration: F }
|
|
1495
751
|
);
|
|
1496
752
|
self.postMessage(
|
|
1497
|
-
|
|
1498
|
-
|
|
753
|
+
p,
|
|
754
|
+
p.imageBitmap ? [p.imageBitmap] : []
|
|
1499
755
|
);
|
|
1500
|
-
} catch (
|
|
1501
|
-
const
|
|
1502
|
-
(/* @__PURE__ */ new Date()).toISOString(), self.postMessage({ id: e, error:
|
|
756
|
+
} catch (w) {
|
|
757
|
+
const l = performance.now() - o, i = w instanceof Error ? w.message : String(w);
|
|
758
|
+
(/* @__PURE__ */ new Date()).toISOString(), self.postMessage({ id: e, error: i, duration: l });
|
|
1503
759
|
}
|
|
1504
760
|
};
|