@kolkrabbi/design-editor 0.2.0 → 0.3.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/README.md +41 -26
- package/dist/{BufferResource-CKQMSOM4.js → BufferResource-BfLgK37S.js} +42 -34
- package/dist/{CanvasPool-ilDNHrRx.js → CanvasPool-YNSF8hsR.js} +9 -9
- package/dist/CanvasRenderer-Bl0rlqNq.js +2 -0
- package/dist/{browserAll-CJ593myQ.js → FederatedEventTarget-BJgROaRQ.js} +119 -127
- package/dist/FilterSystem-BUrPNXx-.js +1323 -0
- package/dist/{Geometry-D3fkwmax.js → Geometry-C5s5KpWq.js} +492 -411
- package/dist/{OrbitControls-CE3qSrHQ.js → OrbitControls-Cql8Rn2i.js} +1944 -1914
- package/dist/{RenderTargetSystem-umK0aqrs.js → RenderTargetSystem-oFwWv5IW.js} +1107 -612
- package/dist/WebGLRenderer-CXxpVIx3.js +2 -0
- package/dist/WebGPURenderer-BwLEUYBa.js +2 -0
- package/dist/browserAll-CAzdTUbR.js +6 -0
- package/dist/canvasUtils-BoNfkAod.js +168 -0
- package/dist/{rolldown-runtime-B0aSnxlc.js → chunk-3b4jIN3o.js} +4 -11
- package/dist/design-editor.css +2 -2
- package/dist/design-editor.js +7675 -8478
- package/dist/{getTextureBatchBindGroup-ChWkOJ3t.js → getTextureBatchBindGroup-CNWhZRbV.js} +5 -5
- package/dist/{host-6EhdLf5-.js → host-CVR9RL_W.js} +8 -6
- package/dist/{host-DPFYZP9I.js → host-be1CWhN1.js} +4 -2
- package/dist/init-jApIMi04.js +4 -0
- package/dist/{phase-D3rwI6OO.js → phase-t_DhU5Nm.js} +2 -2
- package/dist/pipeline-CMpuPUaX.js +11995 -0
- package/dist/{src-zDOFeQWX.js → src-QwKcYKfv.js} +747 -746
- package/dist/webworkerAll-DEZhpG90.js +2 -0
- package/package.json +33 -27
- package/LICENSE +0 -21
- package/dist/CanvasRenderer-CDbc3nH9.js +0 -3396
- package/dist/WebGLRenderer-DVKPZbKc.js +0 -2145
- package/dist/WebGPURenderer-DHSBocAL.js +0 -1656
- package/dist/canvasUtils-CXoNqK7T.js +0 -168
- package/dist/defaultFilter.vert-C9efGgir.js +0 -888
- package/dist/init-4Y6mtayI.js +0 -441
- package/dist/pipeline-DfTD40M-.js +0 -4825
- package/dist/webworkerAll-wTH3MKcZ.js +0 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { C as e, ot as t } from "./Geometry-C5s5KpWq.js";
|
|
2
|
+
import { a as n, i as r, n as i, r as a, t as o } from "./FederatedEventTarget-BJgROaRQ.js";
|
|
3
|
+
import "./FilterSystem-BUrPNXx-.js";
|
|
4
|
+
import "./init-jApIMi04.js";
|
|
5
|
+
t.add(n), t.mixin(e, r), t.add(a), t.add(i), t.mixin(e, o);
|
|
6
|
+
//#endregion
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { A as e, at as t, k as n, rt as r, y as i } from "./Geometry-C5s5KpWq.js";
|
|
2
|
+
//#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/rendering/renderers/shared/texture/sources/ImageSource.mjs
|
|
3
|
+
var a = class extends e {
|
|
4
|
+
constructor(e) {
|
|
5
|
+
super(e), this.uploadMethodId = "image", this.autoGarbageCollect = !0;
|
|
6
|
+
}
|
|
7
|
+
static test(e) {
|
|
8
|
+
return globalThis.HTMLImageElement && e instanceof HTMLImageElement || typeof ImageBitmap < "u" && e instanceof ImageBitmap || globalThis.VideoFrame && e instanceof VideoFrame;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
a.extension = t.TextureSource;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/rendering/renderers/canvas/utils/canUseNewCanvasBlendModes.mjs
|
|
14
|
+
var o;
|
|
15
|
+
function s(e) {
|
|
16
|
+
let t = i.get().createCanvas(6, 1), n = t.getContext("2d");
|
|
17
|
+
return n.fillStyle = e, n.fillRect(0, 0, 6, 1), t;
|
|
18
|
+
}
|
|
19
|
+
function c() {
|
|
20
|
+
if (o !== void 0) return o;
|
|
21
|
+
try {
|
|
22
|
+
let e = s("#ff00ff"), t = s("#ffff00"), n = i.get().createCanvas(6, 1).getContext("2d");
|
|
23
|
+
n.globalCompositeOperation = "multiply", n.drawImage(e, 0, 0), n.drawImage(t, 2, 0);
|
|
24
|
+
let r = n.getImageData(2, 0, 1, 1);
|
|
25
|
+
if (!r) o = !1;
|
|
26
|
+
else {
|
|
27
|
+
let e = r.data;
|
|
28
|
+
o = e[0] === 255 && e[1] === 0 && e[2] === 0;
|
|
29
|
+
}
|
|
30
|
+
} catch {
|
|
31
|
+
o = !1;
|
|
32
|
+
}
|
|
33
|
+
return o;
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region ../../node_modules/.pnpm/pixi.js@8.20.1/node_modules/pixi.js/lib/rendering/renderers/canvas/utils/canvasUtils.mjs
|
|
37
|
+
var l = {
|
|
38
|
+
canvas: null,
|
|
39
|
+
convertTintToImage: !1,
|
|
40
|
+
cacheStepsPerColorChannel: 8,
|
|
41
|
+
canUseMultiply: c(),
|
|
42
|
+
tintMethod: null,
|
|
43
|
+
_canvasSourceCache: /* @__PURE__ */ new WeakMap(),
|
|
44
|
+
_unpremultipliedCache: /* @__PURE__ */ new WeakMap(),
|
|
45
|
+
getCanvasSource: (e) => {
|
|
46
|
+
let t = e.source, n = t?.resource;
|
|
47
|
+
if (!n) return null;
|
|
48
|
+
let r = t.alphaMode === "premultiplied-alpha", a = t.resourceWidth ?? t.pixelWidth, o = t.resourceHeight ?? t.pixelHeight, s = a !== t.pixelWidth || o !== t.pixelHeight;
|
|
49
|
+
if (r) {
|
|
50
|
+
if ((n instanceof HTMLCanvasElement || typeof OffscreenCanvas < "u" && n instanceof OffscreenCanvas) && !s) return n;
|
|
51
|
+
let e = l._unpremultipliedCache.get(t);
|
|
52
|
+
if (e?.resourceId === t._resourceId) return e.canvas;
|
|
53
|
+
}
|
|
54
|
+
if (n instanceof Uint8Array || n instanceof Uint8ClampedArray || n instanceof Int8Array || n instanceof Uint16Array || n instanceof Int16Array || n instanceof Uint32Array || n instanceof Int32Array || n instanceof Float32Array || n instanceof ArrayBuffer) {
|
|
55
|
+
let e = l._canvasSourceCache.get(t);
|
|
56
|
+
if (e?.resourceId === t._resourceId) return e.canvas;
|
|
57
|
+
let r = i.get().createCanvas(t.pixelWidth, t.pixelHeight), a = r.getContext("2d"), o = a.createImageData(t.pixelWidth, t.pixelHeight), s = o.data, c = n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
|
|
58
|
+
if (t.format === "bgra8unorm") for (let e = 0; e < s.length && e + 3 < c.length; e += 4) s[e] = c[e + 2], s[e + 1] = c[e + 1], s[e + 2] = c[e], s[e + 3] = c[e + 3];
|
|
59
|
+
else s.set(c.subarray(0, s.length));
|
|
60
|
+
return a.putImageData(o, 0, 0), l._canvasSourceCache.set(t, {
|
|
61
|
+
canvas: r,
|
|
62
|
+
resourceId: t._resourceId
|
|
63
|
+
}), r;
|
|
64
|
+
}
|
|
65
|
+
if (r) {
|
|
66
|
+
let e = i.get().createCanvas(t.pixelWidth, t.pixelHeight), r = e.getContext("2d", { willReadFrequently: !0 });
|
|
67
|
+
e.width = t.pixelWidth, e.height = t.pixelHeight, r.drawImage(n, 0, 0);
|
|
68
|
+
let a = r.getImageData(0, 0, e.width, e.height), o = a.data;
|
|
69
|
+
for (let e = 0; e < o.length; e += 4) {
|
|
70
|
+
let t = o[e + 3];
|
|
71
|
+
if (t > 0) {
|
|
72
|
+
let n = 255 / t;
|
|
73
|
+
o[e] = Math.min(255, o[e] * n + .5), o[e + 1] = Math.min(255, o[e + 1] * n + .5), o[e + 2] = Math.min(255, o[e + 2] * n + .5);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return r.putImageData(a, 0, 0), l._unpremultipliedCache.set(t, {
|
|
77
|
+
canvas: e,
|
|
78
|
+
resourceId: t._resourceId
|
|
79
|
+
}), e;
|
|
80
|
+
}
|
|
81
|
+
if (s) {
|
|
82
|
+
let e = l._canvasSourceCache.get(t);
|
|
83
|
+
if (e?.resourceId === t._resourceId) return e.canvas;
|
|
84
|
+
let r = i.get().createCanvas(t.pixelWidth, t.pixelHeight), a = r.getContext("2d");
|
|
85
|
+
return r.width = t.pixelWidth, r.height = t.pixelHeight, a.drawImage(n, 0, 0), l._canvasSourceCache.set(t, {
|
|
86
|
+
canvas: r,
|
|
87
|
+
resourceId: t._resourceId
|
|
88
|
+
}), r;
|
|
89
|
+
}
|
|
90
|
+
return n;
|
|
91
|
+
},
|
|
92
|
+
getTintedCanvas: (e, t) => {
|
|
93
|
+
let n = e.texture, a = r.shared.setValue(t).toHex(), o = n.tintCache ||= {}, s = o[a], c = n.source._resourceId;
|
|
94
|
+
if (s?.tintId === c) return s;
|
|
95
|
+
let u = s && "getContext" in s ? s : i.get().createCanvas();
|
|
96
|
+
if (l.tintMethod(n, t, u), u.tintId = c, l.convertTintToImage && u.toDataURL !== void 0) {
|
|
97
|
+
let e = i.get().createImage();
|
|
98
|
+
e.src = u.toDataURL(), e.tintId = c, o[a] = e;
|
|
99
|
+
} else o[a] = u;
|
|
100
|
+
return o[a];
|
|
101
|
+
},
|
|
102
|
+
getTintedPattern: (e, t) => {
|
|
103
|
+
let n = r.shared.setValue(t).toHex(), a = e.patternCache ||= {}, o = e.source._resourceId, s = a[n];
|
|
104
|
+
return s?.tintId === o ? s : (l.canvas ||= i.get().createCanvas(), l.tintMethod(e, t, l.canvas), s = l.canvas.getContext("2d").createPattern(l.canvas, "repeat"), s.tintId = o, a[n] = s, s);
|
|
105
|
+
},
|
|
106
|
+
applyPatternTransform: (e, t, n = !0) => {
|
|
107
|
+
if (!t) return;
|
|
108
|
+
let r = e;
|
|
109
|
+
if (!r.setTransform) return;
|
|
110
|
+
let i = globalThis.DOMMatrix;
|
|
111
|
+
if (!i) return;
|
|
112
|
+
let a = new i([
|
|
113
|
+
t.a,
|
|
114
|
+
t.b,
|
|
115
|
+
t.c,
|
|
116
|
+
t.d,
|
|
117
|
+
t.tx,
|
|
118
|
+
t.ty
|
|
119
|
+
]);
|
|
120
|
+
r.setTransform(n ? a.inverse() : a);
|
|
121
|
+
},
|
|
122
|
+
tintWithMultiply: (e, t, i) => {
|
|
123
|
+
let a = i.getContext("2d"), o = e.frame.clone(), s = e.source._resolution ?? e.source.resolution ?? 1, c = e.rotate;
|
|
124
|
+
o.x *= s, o.y *= s, o.width *= s, o.height *= s;
|
|
125
|
+
let u = n.isVertical(c), d = u ? o.height : o.width, f = u ? o.width : o.height;
|
|
126
|
+
i.width = Math.ceil(d), i.height = Math.ceil(f), a.save(), a.fillStyle = r.shared.setValue(t).toHex(), a.fillRect(0, 0, d, f), a.globalCompositeOperation = "multiply";
|
|
127
|
+
let p = l.getCanvasSource(e);
|
|
128
|
+
if (!p) {
|
|
129
|
+
a.restore();
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
c && l._applyInverseRotation(a, c, o.width, o.height), a.drawImage(p, o.x, o.y, o.width, o.height, 0, 0, o.width, o.height), a.globalCompositeOperation = "destination-atop", a.drawImage(p, o.x, o.y, o.width, o.height, 0, 0, o.width, o.height), a.restore();
|
|
133
|
+
},
|
|
134
|
+
tintWithOverlay: (e, t, i) => {
|
|
135
|
+
let a = i.getContext("2d"), o = e.frame.clone(), s = e.source._resolution ?? e.source.resolution ?? 1, c = e.rotate;
|
|
136
|
+
o.x *= s, o.y *= s, o.width *= s, o.height *= s;
|
|
137
|
+
let u = n.isVertical(c), d = u ? o.height : o.width, f = u ? o.width : o.height;
|
|
138
|
+
i.width = Math.ceil(d), i.height = Math.ceil(f), a.save(), a.globalCompositeOperation = "copy", a.fillStyle = r.shared.setValue(t).toHex(), a.fillRect(0, 0, d, f), a.globalCompositeOperation = "destination-atop";
|
|
139
|
+
let p = l.getCanvasSource(e);
|
|
140
|
+
if (!p) {
|
|
141
|
+
a.restore();
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
c && l._applyInverseRotation(a, c, o.width, o.height), a.drawImage(p, o.x, o.y, o.width, o.height, 0, 0, o.width, o.height), a.restore();
|
|
145
|
+
},
|
|
146
|
+
tintWithPerPixel: (e, t, r) => {
|
|
147
|
+
let i = r.getContext("2d"), a = e.frame.clone(), o = e.source._resolution ?? e.source.resolution ?? 1, s = e.rotate;
|
|
148
|
+
a.x *= o, a.y *= o, a.width *= o, a.height *= o;
|
|
149
|
+
let c = n.isVertical(s), u = c ? a.height : a.width, d = c ? a.width : a.height;
|
|
150
|
+
r.width = Math.ceil(u), r.height = Math.ceil(d), i.save(), i.globalCompositeOperation = "copy";
|
|
151
|
+
let f = l.getCanvasSource(e);
|
|
152
|
+
if (!f) {
|
|
153
|
+
i.restore();
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
s && l._applyInverseRotation(i, s, a.width, a.height), i.drawImage(f, a.x, a.y, a.width, a.height, 0, 0, a.width, a.height), i.restore();
|
|
157
|
+
let p = t >> 16 & 255, m = t >> 8 & 255, h = t & 255, g = i.getImageData(0, 0, u, d), _ = g.data;
|
|
158
|
+
for (let e = 0; e < _.length; e += 4) _[e] = _[e] * p / 255, _[e + 1] = _[e + 1] * m / 255, _[e + 2] = _[e + 2] * h / 255;
|
|
159
|
+
i.putImageData(g, 0, 0);
|
|
160
|
+
},
|
|
161
|
+
_applyInverseRotation: (e, t, r, i) => {
|
|
162
|
+
let a = n.inv(t), o = n.uX(a), s = n.uY(a), c = n.vX(a), l = n.vY(a), u = -Math.min(0, o * r, c * i, o * r + c * i), d = -Math.min(0, s * r, l * i, s * r + l * i);
|
|
163
|
+
e.transform(o, s, c, l, u, d);
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
l.tintMethod = l.canUseMultiply ? l.tintWithMultiply : l.tintWithPerPixel;
|
|
167
|
+
//#endregion
|
|
168
|
+
export { c as n, a as r, l as t };
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
//#region \0rolldown/runtime.js
|
|
2
|
-
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e,
|
|
3
|
-
let r = {};
|
|
4
|
-
for (var i in e) t(r, i, {
|
|
5
|
-
get: e[i],
|
|
6
|
-
enumerable: !0
|
|
7
|
-
});
|
|
8
|
-
return n || t(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
9
|
-
}, c = (e, i, o, s) => {
|
|
2
|
+
var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
|
|
10
3
|
if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
|
|
11
4
|
get: ((e) => i[e]).bind(null, d),
|
|
12
5
|
enumerable: !(s = n(i, d)) || s.enumerable
|
|
13
6
|
});
|
|
14
7
|
return e;
|
|
15
|
-
},
|
|
8
|
+
}, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
|
|
16
9
|
value: n,
|
|
17
10
|
enumerable: !0
|
|
18
|
-
}) :
|
|
11
|
+
}) : a, n));
|
|
19
12
|
//#endregion
|
|
20
|
-
export {
|
|
13
|
+
export { c as n, o as t };
|