@zinejs/core 0.2.0 → 0.3.0
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 +3 -1
- package/dist/geometry/curls/cone.d.ts +17 -0
- package/dist/geometry/curls/flick.d.ts +20 -0
- package/dist/geometry/curls/leaf.d.ts +19 -0
- package/dist/geometry/curls/simple.d.ts +0 -8
- package/dist/geometry/curls/types.d.ts +7 -4
- package/dist/index.js +172 -150
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +13 -7
- package/dist/index.umd.cjs.map +1 -1
- package/dist/{types-Bz64qLvE.js → types-D-rEO00p.js} +6 -5
- package/dist/types-D-rEO00p.js.map +1 -0
- package/dist/{webglRenderer-m-lr412M.js → webglRenderer-Bg6VF4CW.js} +158 -93
- package/dist/webglRenderer-Bg6VF4CW.js.map +1 -0
- package/dist/zine.d.ts +1 -1
- package/options.schema.json +4 -4
- package/package.json +1 -1
- package/dist/geometry/curls/fold.d.ts +0 -9
- package/dist/geometry/curls/peel.d.ts +0 -9
- package/dist/types-Bz64qLvE.js.map +0 -1
- package/dist/webglRenderer-m-lr412M.js.map +0 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
//#region src/geometry/curls/types.ts
|
|
2
2
|
var e = [
|
|
3
3
|
"roll",
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
4
|
+
"cone",
|
|
5
|
+
"leaf",
|
|
6
|
+
"flick",
|
|
7
|
+
"simple"
|
|
8
|
+
], t = "cone";
|
|
8
9
|
//#endregion
|
|
9
10
|
export { t as n, e as t };
|
|
10
11
|
|
|
11
|
-
//# sourceMappingURL=types-
|
|
12
|
+
//# sourceMappingURL=types-D-rEO00p.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-D-rEO00p.js","names":[],"sources":["../src/geometry/curls/types.ts"],"sourcesContent":["/**\n * Curl type identifiers and the deform contract. Kept free of the deform\n * implementations so the engine (and CSS-only builds) can reference the union and the\n * validation list without pulling the WebGL-only curl math into the eager bundle.\n */\nimport type { PageMesh } from './mesh';\n\n/** Where a corner-anchored curl folds from: y in [0,1], 0 = top edge, 1 = bottom edge. */\nexport interface CurlAnchor {\n y: number;\n /**\n * Full-width lone page (single-page mode). The leaf hinges at the container edge and\n * has no facing half to land on — deforms may soften and delay the flop so the curl\n * reads naturally before the renderer dissolves the sheet.\n */\n fill?: boolean;\n}\n\nexport type CurlDeform = (mesh: PageMesh, W: number, H: number, t: number, anchor: CurlAnchor) => void;\n\nexport interface CurlModel {\n readonly deform: CurlDeform;\n /** True when the fold originates at a corner (`anchor.y`) rather than the whole edge. */\n readonly anchored: boolean;\n}\n\nexport type CurlType = 'roll' | 'cone' | 'leaf' | 'flick' | 'simple';\n\nexport const CURL_TYPES: CurlType[] = ['roll', 'cone', 'leaf', 'flick', 'simple'];\n\nexport const DEFAULT_CURL: CurlType = 'cone';\n"],"mappings":";AA4BA,IAAa,IAAyB;CAAC;CAAQ;CAAQ;CAAQ;CAAS;AAAQ,GAEnE,IAAyB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as e } from "./types-
|
|
1
|
+
import { n as e } from "./types-D-rEO00p.js";
|
|
2
2
|
//#region src/geometry/curls/mesh.ts
|
|
3
3
|
function t(e, t) {
|
|
4
4
|
let n = e + 1, r = t + 1, i = n * r, a = new Float32Array(i * 2);
|
|
@@ -37,95 +37,152 @@ function r(e, t, r, i) {
|
|
|
37
37
|
n(e);
|
|
38
38
|
}
|
|
39
39
|
//#endregion
|
|
40
|
-
//#region src/geometry/curls/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
for (let
|
|
46
|
-
let i =
|
|
47
|
-
|
|
40
|
+
//#region src/geometry/curls/cone.ts
|
|
41
|
+
var i = 30 * Math.PI / 180, a = 44 * Math.PI / 180, o = 1.35, s = .7, c = 1.85, l = 1.15, u = .42, d = 1.08;
|
|
42
|
+
function f(e, t, r, f, p) {
|
|
43
|
+
let m = e.cols + 1, h = e.rows + 1, g = e.positions, _ = !!p.fill, v = Math.sin(Math.PI * f) ** .85, y = _ ? a : i, b = Math.PI / 2 - v * (Math.PI / 2 - y), x = Math.sin(b), S = Math.cos(b), C = 1 / Math.max(x, 1e-6), w = _ ? c : o, T = r * (w + ((_ ? l : s) - w) * v), E = (p.y - .5) * 2, D = E >= 0, O = Math.min(1, Math.abs(E) / u), k = 1 - O, A = D ? r + T : -T, j = Math.hypot(t, .5 * r - A), M = Math.max(j * x, t / Math.PI), N = _ ? f ** +d : f, P = -Math.PI * N, F = Math.cos(P), I = Math.sin(P);
|
|
44
|
+
if (v < 1e-4) {
|
|
45
|
+
for (let n = 0; n < h; n++) {
|
|
46
|
+
let i = n / e.rows * r;
|
|
47
|
+
for (let r = 0; r < m; r++) {
|
|
48
|
+
let a = r / e.cols * t, o = (n * m + r) * 3;
|
|
49
|
+
g[o] = a * F, g[o + 1] = i, g[o + 2] = -a * I;
|
|
50
|
+
}
|
|
48
51
|
}
|
|
52
|
+
n(e);
|
|
53
|
+
return;
|
|
49
54
|
}
|
|
50
|
-
n
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
for (let n = 0; n < h; n++) {
|
|
56
|
+
let i = n / e.rows * r;
|
|
57
|
+
for (let a = 0; a < m; a++) {
|
|
58
|
+
let o = a / e.cols * t, s = o, c = i, l = 0;
|
|
59
|
+
if (O > 1e-5) {
|
|
60
|
+
let e = D ? r - i : i, t = -T, n = Math.hypot(o, e - t);
|
|
61
|
+
if (n > 1e-8) {
|
|
62
|
+
let e = n * x, i = Math.asin(Math.min(1, Math.max(0, o / n))) * C, a = 1 - Math.cos(i), u = n + t - e * a * x;
|
|
63
|
+
s = e * Math.sin(i), c = D ? r - u : u, l = e * a * S;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
let u = s, d = c, f = l;
|
|
67
|
+
if (k > 1e-5) {
|
|
68
|
+
let e = o / M, t = M * Math.sin(e), n = M * (1 - Math.cos(e));
|
|
69
|
+
u = O * s + k * t, d = O * c + k * i, f = O * l + k * n;
|
|
70
|
+
}
|
|
71
|
+
let p = (n * m + a) * 3;
|
|
72
|
+
g[p] = u * F + f * I, g[p + 1] = d, g[p + 2] = -u * I + f * F;
|
|
59
73
|
}
|
|
60
74
|
}
|
|
61
75
|
n(e);
|
|
62
76
|
}
|
|
63
77
|
//#endregion
|
|
64
|
-
//#region src/geometry/curls/
|
|
65
|
-
var
|
|
66
|
-
function
|
|
67
|
-
let
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
//#region src/geometry/curls/leaf.ts
|
|
79
|
+
var p = .34, m = 11 * Math.PI / 180, h = 128;
|
|
80
|
+
function g() {
|
|
81
|
+
let e = /* @__PURE__ */ new Float64Array(129), t = /* @__PURE__ */ new Float64Array(129), n = 1 / h, r = (e) => Math.PI * e - .5 * Math.sin(2 * Math.PI * e);
|
|
82
|
+
for (let i = 1; i <= h; i++) {
|
|
83
|
+
let a = r((i - 1) * n), o = r(i * n);
|
|
84
|
+
e[i] = e[i - 1] + .5 * (Math.cos(a) + Math.cos(o)) * n, t[i] = t[i - 1] + .5 * (Math.sin(a) + Math.sin(o)) * n;
|
|
85
|
+
}
|
|
86
|
+
return e[h] = 0, {
|
|
87
|
+
x: e,
|
|
88
|
+
z: t
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
var _ = g(), v = _.z[h];
|
|
92
|
+
function y(e) {
|
|
93
|
+
let t = Math.max(0, Math.min(1, e)) * h, n = Math.min(h - 1, Math.floor(t)), r = t - n;
|
|
94
|
+
return [_.x[n] + (_.x[n + 1] - _.x[n]) * r, _.z[n] + (_.z[n + 1] - _.z[n]) * r];
|
|
95
|
+
}
|
|
96
|
+
function b(e, t, r, i, a) {
|
|
97
|
+
let o = e.cols + 1, s = e.rows + 1, c = e.positions;
|
|
98
|
+
if (i <= 1e-7 || i >= .9999999) {
|
|
99
|
+
let a = i < .5 ? 1 : -1;
|
|
100
|
+
for (let n = 0; n < s; n++) {
|
|
101
|
+
let i = n / e.rows * r;
|
|
102
|
+
for (let r = 0; r < o; r++) {
|
|
103
|
+
let s = (n * o + r) * 3;
|
|
104
|
+
c[s] = a * (r / e.cols) * t, c[s + 1] = i, c[s + 2] = 0;
|
|
105
|
+
}
|
|
72
106
|
}
|
|
73
107
|
n(e);
|
|
74
108
|
return;
|
|
75
109
|
}
|
|
76
|
-
let
|
|
77
|
-
for (let n = 0; n <
|
|
110
|
+
let l = Math.sin(Math.PI * i) ** .72, u = Math.max(1e-6, t * p * l), d = Math.max(-1, Math.min(1, (a.y - .5) * 2)) * m * Math.sin(Math.PI * i) ** 1.15, f = Math.cos(d), h = Math.sin(d), g = -h, _ = f, b = Math.abs(h) * r * .5, x = t + b / f, S = x + (-(u + b) / f - x) * i, C = r * .5;
|
|
111
|
+
for (let n = 0; n < s; n++) {
|
|
78
112
|
let i = n / e.rows * r;
|
|
79
|
-
for (let r = 0; r <
|
|
80
|
-
let a = r / e.cols * t,
|
|
81
|
-
if (
|
|
82
|
-
|
|
113
|
+
for (let r = 0; r < o; r++) {
|
|
114
|
+
let a = r / e.cols * t, s = a - S, l = i - C, d = s * f + l * h, p = s * g + l * _, m = (n * o + r) * 3;
|
|
115
|
+
if (d <= 0) {
|
|
116
|
+
c[m] = a, c[m + 1] = i, c[m + 2] = 0;
|
|
83
117
|
continue;
|
|
84
118
|
}
|
|
85
|
-
let
|
|
86
|
-
|
|
119
|
+
let b, x;
|
|
120
|
+
if (d < u) {
|
|
121
|
+
let [e, t] = y(d / u);
|
|
122
|
+
b = u * e, x = u * t;
|
|
123
|
+
} else b = -(d - u), x = u * v;
|
|
124
|
+
c[m] = S + g * p + f * b, c[m + 1] = C + _ * p + h * b, c[m + 2] = x;
|
|
87
125
|
}
|
|
88
126
|
}
|
|
89
127
|
n(e);
|
|
90
128
|
}
|
|
91
129
|
//#endregion
|
|
92
|
-
//#region src/geometry/curls/
|
|
93
|
-
var
|
|
94
|
-
function
|
|
95
|
-
let o = e.cols + 1, s = e.rows + 1, c = e.positions;
|
|
96
|
-
for (let
|
|
97
|
-
let
|
|
130
|
+
//#region src/geometry/curls/flick.ts
|
|
131
|
+
var x = .45;
|
|
132
|
+
function S(e, t, r, i, a) {
|
|
133
|
+
let o = e.cols + 1, s = e.rows + 1, c = e.cols, l = e.positions, u = t / c, d = Math.PI * i, f = -.52 * Math.sin(2 * Math.PI * i);
|
|
134
|
+
for (let t = 0; t < s; t++) {
|
|
135
|
+
let n = t / e.rows, i = f * (1 + x * Math.abs(n - a.y)), s = n * r, p = 0, m = 0, h = Math.cos(d), g = Math.sin(d);
|
|
136
|
+
l[t * o * 3] = 0, l[t * o * 3 + 1] = s, l[t * o * 3 + 2] = 0;
|
|
137
|
+
for (let e = 1; e < o; e++) {
|
|
138
|
+
let n = e / c, r = d + i * n * n, a = Math.cos(r), f = Math.sin(r);
|
|
139
|
+
p += .5 * (h + a) * u, m += .5 * (g + f) * u, h = a, g = f;
|
|
140
|
+
let _ = (t * o + e) * 3;
|
|
141
|
+
l[_] = p, l[_ + 1] = s, l[_ + 2] = m;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
n(e);
|
|
145
|
+
}
|
|
146
|
+
//#endregion
|
|
147
|
+
//#region src/geometry/curls/simple.ts
|
|
148
|
+
function C(e, t, r, i) {
|
|
149
|
+
let a = e.cols + 1, o = e.rows + 1, s = e.positions, c = i * Math.PI, l = Math.cos(c), u = Math.sin(c);
|
|
150
|
+
for (let n = 0; n < a; n++) {
|
|
151
|
+
let i = n / e.cols * t, c = i * l, d = i * u;
|
|
98
152
|
for (let t = 0; t < o; t++) {
|
|
99
|
-
let
|
|
100
|
-
|
|
153
|
+
let i = (t * a + n) * 3;
|
|
154
|
+
s[i] = c, s[i + 1] = t / e.rows * r, s[i + 2] = d;
|
|
101
155
|
}
|
|
102
156
|
}
|
|
103
157
|
n(e);
|
|
104
158
|
}
|
|
105
159
|
//#endregion
|
|
106
160
|
//#region src/geometry/curls/index.ts
|
|
107
|
-
var
|
|
161
|
+
var w = {
|
|
108
162
|
roll: {
|
|
109
163
|
deform: r,
|
|
110
|
-
deformFill: a,
|
|
111
164
|
anchored: !1
|
|
112
165
|
},
|
|
113
|
-
|
|
114
|
-
deform:
|
|
115
|
-
anchored: !
|
|
166
|
+
cone: {
|
|
167
|
+
deform: f,
|
|
168
|
+
anchored: !0
|
|
116
169
|
},
|
|
117
|
-
|
|
118
|
-
deform:
|
|
170
|
+
leaf: {
|
|
171
|
+
deform: b,
|
|
119
172
|
anchored: !0
|
|
120
173
|
},
|
|
121
|
-
|
|
122
|
-
deform:
|
|
174
|
+
flick: {
|
|
175
|
+
deform: S,
|
|
123
176
|
anchored: !0
|
|
177
|
+
},
|
|
178
|
+
simple: {
|
|
179
|
+
deform: C,
|
|
180
|
+
anchored: !1
|
|
124
181
|
}
|
|
125
182
|
};
|
|
126
183
|
//#endregion
|
|
127
184
|
//#region src/renderer/gl/context.ts
|
|
128
|
-
function
|
|
185
|
+
function T(e) {
|
|
129
186
|
let t = e.getContext("webgl2", {
|
|
130
187
|
alpha: !0,
|
|
131
188
|
premultipliedAlpha: !0,
|
|
@@ -139,17 +196,17 @@ function f(e) {
|
|
|
139
196
|
}
|
|
140
197
|
//#endregion
|
|
141
198
|
//#region src/renderer/gl/program.ts
|
|
142
|
-
function
|
|
199
|
+
function E(e, t, n) {
|
|
143
200
|
let r = e.createProgram();
|
|
144
201
|
if (r === null) throw Error("WebglRenderer: could not create a program.");
|
|
145
|
-
let i =
|
|
202
|
+
let i = D(e, e.VERTEX_SHADER, t), a = D(e, e.FRAGMENT_SHADER, n);
|
|
146
203
|
if (e.attachShader(r, i), e.attachShader(r, a), e.linkProgram(r), e.deleteShader(i), e.deleteShader(a), !e.getProgramParameter(r, e.LINK_STATUS)) {
|
|
147
204
|
let t = e.getProgramInfoLog(r);
|
|
148
205
|
throw e.deleteProgram(r), Error(`WebglRenderer: program link failed: ${t ?? "unknown error"}`);
|
|
149
206
|
}
|
|
150
207
|
return r;
|
|
151
208
|
}
|
|
152
|
-
function
|
|
209
|
+
function D(e, t, n) {
|
|
153
210
|
let r = e.createShader(t);
|
|
154
211
|
if (r === null) throw Error("WebglRenderer: could not create a shader.");
|
|
155
212
|
if (e.shaderSource(r, n), e.compileShader(r), !e.getShaderParameter(r, e.COMPILE_STATUS)) {
|
|
@@ -160,21 +217,21 @@ function m(e, t, n) {
|
|
|
160
217
|
}
|
|
161
218
|
//#endregion
|
|
162
219
|
//#region src/renderer/gl/texture.ts
|
|
163
|
-
function
|
|
220
|
+
function O(e) {
|
|
164
221
|
let t = e.createTexture();
|
|
165
222
|
if (t === null) throw Error("WebglRenderer: could not create a texture.");
|
|
166
223
|
return e.bindTexture(e.TEXTURE_2D, t), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), t;
|
|
167
224
|
}
|
|
168
|
-
function
|
|
225
|
+
function k(e, t, n) {
|
|
169
226
|
e.bindTexture(e.TEXTURE_2D, t), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !0), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, n);
|
|
170
227
|
}
|
|
171
228
|
//#endregion
|
|
172
229
|
//#region src/renderer/webglRenderer.ts
|
|
173
|
-
var
|
|
174
|
-
function
|
|
230
|
+
var A = "#version 300 es\nin vec2 aUnit;\nuniform vec2 uViewport;\nuniform vec4 uRect;\nuniform vec3 uView;\nout vec2 vUv;\nvoid main() {\n vec2 px = uRect.xy + aUnit * uRect.zw;\n px = px * uView.x + uView.yz;\n vec2 clip = px / uViewport * 2.0 - 1.0;\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\n vUv = aUnit;\n}", j = "#version 300 es\nprecision mediump float;\nin vec2 vUv;\nuniform sampler2D uTex;\nuniform float uGutterSide; // +1 = spine at right edge, -1 = at left edge, 0 = none\nout vec4 outColor;\nvoid main() {\n vec4 c = texture(uTex, vUv);\n if (uGutterSide != 0.0) {\n float d = uGutterSide > 0.0 ? (1.0 - vUv.x) : vUv.x;\n c.rgb *= mix(0.72, 1.0, smoothstep(0.0, 0.10, d));\n }\n outColor = c;\n}", M = "#version 300 es\nin vec3 aPos; // leaf-local device px: x = bent offset from spine, y 0..H, z depth\nin vec3 aNormal;\nin vec2 aUv;\nuniform vec2 uViewport;\nuniform vec3 uView; // scale, tx, ty\nuniform float uOriginX; // spine x in device px\nuniform float uDir; // +1 leaf to the right of spine, -1 to the left\nuniform float uLeafW; // leaf width in device px (perspective scale)\nout vec2 vUv;\nout float vFacing;\nout float vU;\nvoid main() {\n float bookX = uOriginX + uDir * aPos.x;\n float bookY = aPos.y;\n float Z = aPos.z;\n // Eye distance, in leaf widths. Keeps the perspective resolution-independent. 5.3 puts the\n // roll's deepest point ~14% larger than flat; stronger than that (a nearer eye) balloons the\n // turning sheet and reads more like a fisheye than a page lifting.\n float D = uLeafW * 5.3;\n float persp = D / max(D - Z, 1.0);\n float cx = uViewport.x * 0.5;\n float cy = uViewport.y * 0.5;\n float px = cx + (bookX - cx) * persp;\n float py = cy + (bookY - cy) * min(persp, 1.0); // Y only shrinks (top-safe)\n vec2 p = vec2(px, py) * uView.x + uView.yz;\n vec2 clip = p / uViewport * 2.0 - 1.0;\n gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);\n vUv = aUv;\n vFacing = aNormal.z;\n vU = aUv.x;\n}", N = "#version 300 es\nprecision mediump float;\nin vec2 vUv;\nin float vFacing;\nin float vU;\nuniform sampler2D uFront;\nuniform sampler2D uBack;\nuniform highp float uDir;\nuniform float uGloss; // 0 disables the specular highlight (e.g. the flat 'simple' curl)\nuniform float uAlpha; // leaf opacity; a lone page dissolves into the page landing beneath it\nout vec4 outColor;\nvoid main() {\n // The turn mesh carries its own facing in the normal; the front points at the viewer\n // (normal.z > 0) until the leaf passes vertical, for both flip directions. u->x still\n // flips with uDir so a left-hand leaf reads spine-inward.\n bool showFront = vFacing > 0.0;\n float fx = uDir > 0.0 ? vUv.x : 1.0 - vUv.x;\n vec4 c = showFront ? texture(uFront, vec2(fx, vUv.y)) : texture(uBack, vec2(1.0 - fx, vUv.y));\n\n // Fold shading: the sheet darkens sharply where it curves away from the viewer, so the\n // rolled edge reads as a deep crease with a soft highlight riding the ridge.\n float diff = clamp(abs(vFacing), 0.0, 1.0);\n float lit = mix(0.42, 1.0, diff);\n lit *= mix(0.7, 1.0, smoothstep(0.0, 0.12, vU)); // spine crease matches the gutter shadow\n\n // Glossy specular: brightest where the surface tilts ~30 deg from facing the viewer,\n // so a thin glossy highlight rides across the sheet as it rolls.\n float spec = pow(max(cos(acos(diff) - 0.52), 0.0), 220.0) * 0.22 * uGloss;\n\n c.rgb = clamp(c.rgb * lit + spec, 0.0, 1.0);\n // Premultiplied alpha (blendFunc ONE, ONE_MINUS_SRC_ALPHA): scale colour as well as alpha,\n // or fading would brighten the sheet additively instead of dissolving it.\n outColor = vec4(c.rgb * uAlpha, c.a * uAlpha);\n}", P = 28, F = 36, I = .7, L = .8, R = 4e3, z = 256 * 1024 * 1024;
|
|
231
|
+
function B(e) {
|
|
175
232
|
return e.left === null == (e.right === null) ? 0 : e.right === null ? 1 : -1;
|
|
176
233
|
}
|
|
177
|
-
var
|
|
234
|
+
var V = class {
|
|
178
235
|
#e = null;
|
|
179
236
|
#t = null;
|
|
180
237
|
#n = null;
|
|
@@ -185,7 +242,7 @@ var E = class {
|
|
|
185
242
|
#s = null;
|
|
186
243
|
#c = null;
|
|
187
244
|
#l = 0;
|
|
188
|
-
#u = t(
|
|
245
|
+
#u = t(P, F);
|
|
189
246
|
#d = /* @__PURE__ */ new Map();
|
|
190
247
|
#f = 0;
|
|
191
248
|
#p = null;
|
|
@@ -216,7 +273,7 @@ var E = class {
|
|
|
216
273
|
mount(e) {
|
|
217
274
|
this.#e = e;
|
|
218
275
|
let t = e.ownerDocument, n = t.createElement("canvas");
|
|
219
|
-
return n.style.cssText = "display:block;width:100%;height:100%;", e.append(n), this.#t = n, n.addEventListener("webglcontextlost", this.#L), n.addEventListener("webglcontextrestored", this.#R), t.addEventListener("visibilitychange", this.#z), this.#n =
|
|
276
|
+
return n.style.cssText = "display:block;width:100%;height:100%;", e.append(n), this.#t = n, n.addEventListener("webglcontextlost", this.#L), n.addEventListener("webglcontextrestored", this.#R), t.addEventListener("visibilitychange", this.#z), this.#n = T(n), this.#H(), Promise.resolve();
|
|
220
277
|
}
|
|
221
278
|
destroy() {
|
|
222
279
|
this.#V();
|
|
@@ -241,7 +298,7 @@ var E = class {
|
|
|
241
298
|
}
|
|
242
299
|
beginFlip(e, t, n, r) {
|
|
243
300
|
let i = r?.fill ?? !1;
|
|
244
|
-
this.#x = 0, r?.curl && (this.#S = r.curl), r?.anchor && (this.#C = r.anchor), this.#T = i ? 0 :
|
|
301
|
+
this.#x = 0, r?.curl && (this.#S = r.curl), r?.anchor && (this.#C = r.anchor), this.#T = i ? 0 : B(e), this.#E = i ? 0 : B(t), this.#P(t), i ? this.#b = {
|
|
245
302
|
underLeft: null,
|
|
246
303
|
underRight: null,
|
|
247
304
|
underFull: t.right ?? t.left,
|
|
@@ -306,7 +363,7 @@ var E = class {
|
|
|
306
363
|
}
|
|
307
364
|
#I() {
|
|
308
365
|
let e = this.#F();
|
|
309
|
-
return !this.#y && this.#v !== null &&
|
|
366
|
+
return !this.#y && this.#v !== null && B(this.#v) !== 0 ? {
|
|
310
367
|
x: e.x + e.width / 4,
|
|
311
368
|
y: e.y,
|
|
312
369
|
width: e.width / 2,
|
|
@@ -314,7 +371,7 @@ var E = class {
|
|
|
314
371
|
} : e;
|
|
315
372
|
}
|
|
316
373
|
#L = (e) => {
|
|
317
|
-
e.preventDefault(), this.#A = !0, this.#M === null && (this.#M = setTimeout(() => this.#B(),
|
|
374
|
+
e.preventDefault(), this.#A = !0, this.#M === null && (this.#M = setTimeout(() => this.#B(), R));
|
|
318
375
|
};
|
|
319
376
|
#R = () => {
|
|
320
377
|
this.#V(), this.#A = !1, this.#H(), this.#G();
|
|
@@ -331,7 +388,7 @@ var E = class {
|
|
|
331
388
|
#H() {
|
|
332
389
|
let e = this.#n;
|
|
333
390
|
if (e !== null) {
|
|
334
|
-
this.#r =
|
|
391
|
+
this.#r = E(e, A, j), this.#i = E(e, M, N);
|
|
335
392
|
for (let t of [
|
|
336
393
|
"uViewport",
|
|
337
394
|
"uRect",
|
|
@@ -347,9 +404,10 @@ var E = class {
|
|
|
347
404
|
"uLeafW",
|
|
348
405
|
"uFront",
|
|
349
406
|
"uBack",
|
|
350
|
-
"uGloss"
|
|
407
|
+
"uGloss",
|
|
408
|
+
"uAlpha"
|
|
351
409
|
]) this.#h[t] = e.getUniformLocation(this.#i, t);
|
|
352
|
-
this.#a = this.#U(e, this.#r), this.#W(e, this.#i), this.#d.clear(), this.#f = 0, this.#p = this.#
|
|
410
|
+
this.#a = this.#U(e, this.#r), this.#W(e, this.#i), this.#d.clear(), this.#f = 0, this.#p = this.#te(e), e.useProgram(this.#r), e.uniform1i(this.#m.uTex ?? null, 0), e.useProgram(this.#i), e.uniform1i(this.#h.uFront ?? null, 0), e.uniform1i(this.#h.uBack ?? null, 1), e.clearColor(0, 0, 0, 0), e.enable(e.BLEND), e.blendFunc(e.ONE, e.ONE_MINUS_SRC_ALPHA);
|
|
353
411
|
}
|
|
354
412
|
}
|
|
355
413
|
#U(e, t) {
|
|
@@ -370,7 +428,7 @@ var E = class {
|
|
|
370
428
|
}
|
|
371
429
|
#W(e, t) {
|
|
372
430
|
let n = [];
|
|
373
|
-
for (let e = 0; e <
|
|
431
|
+
for (let e = 0; e < F; e++) for (let t = 0; t < P; t++) {
|
|
374
432
|
let r = e * 29 + t, i = r + 1, a = r + 29, o = a + 1;
|
|
375
433
|
n.push(r, a, i, i, a, o);
|
|
376
434
|
}
|
|
@@ -389,7 +447,7 @@ var E = class {
|
|
|
389
447
|
}
|
|
390
448
|
#G() {
|
|
391
449
|
let e = this.#n, t = this.#t;
|
|
392
|
-
e === null || t === null || this.#A || e.isContextLost() || (this.#
|
|
450
|
+
e === null || t === null || this.#A || e.isContextLost() || (this.#ne(), e.clear(e.COLOR_BUFFER_BIT), this.#K(), this.#b === null ? this.#v !== null && this.#q() : this.#J());
|
|
393
451
|
}
|
|
394
452
|
#K() {
|
|
395
453
|
let e = this.#n, t = this.#t, n = t.width, r = t.height;
|
|
@@ -402,17 +460,17 @@ var E = class {
|
|
|
402
460
|
}
|
|
403
461
|
#q() {
|
|
404
462
|
let e = this.#O, t = this.#k, n = this.#v;
|
|
405
|
-
this.#w = this.#y ? 0 :
|
|
463
|
+
this.#w = this.#y ? 0 : B(n) * (e / 4), this.#X(), this.#y ? this.#Z({
|
|
406
464
|
x: 0,
|
|
407
465
|
y: 0,
|
|
408
466
|
w: e,
|
|
409
467
|
h: t
|
|
410
|
-
}, n.right ?? n.left) : (this.#
|
|
468
|
+
}, n.right ?? n.left) : (this.#Z({
|
|
411
469
|
x: 0,
|
|
412
470
|
y: 0,
|
|
413
471
|
w: e / 2,
|
|
414
472
|
h: t
|
|
415
|
-
}, n.left, +!!n.right), this.#
|
|
473
|
+
}, n.left, +!!n.right), this.#Z({
|
|
416
474
|
x: e / 2,
|
|
417
475
|
y: 0,
|
|
418
476
|
w: e / 2,
|
|
@@ -421,57 +479,64 @@ var E = class {
|
|
|
421
479
|
}
|
|
422
480
|
#J() {
|
|
423
481
|
let e = this.#n, t = this.#O, n = this.#k, r = this.#b;
|
|
424
|
-
if (this.#w = r.fill ? 0 : (this.#T + (this.#E - this.#T) * this.#x) * (t / 4), this.#
|
|
482
|
+
if (this.#w = r.fill ? 0 : (this.#T + (this.#E - this.#T) * this.#x) * (t / 4), this.#X(), r.fill ? this.#Z({
|
|
425
483
|
x: 0,
|
|
426
484
|
y: 0,
|
|
427
485
|
w: t,
|
|
428
486
|
h: n
|
|
429
|
-
}, r.underFull) : (this.#
|
|
487
|
+
}, r.underFull) : (this.#Z({
|
|
430
488
|
x: 0,
|
|
431
489
|
y: 0,
|
|
432
490
|
w: t / 2,
|
|
433
491
|
h: n
|
|
434
|
-
}, r.underLeft, 1), this.#
|
|
492
|
+
}, r.underLeft, 1), this.#Z({
|
|
435
493
|
x: t / 2,
|
|
436
494
|
y: 0,
|
|
437
495
|
w: t / 2,
|
|
438
496
|
h: n
|
|
439
497
|
}, r.underRight, -1)), r.front === null && r.back === null) return;
|
|
440
|
-
let i = r.fill ? t : t / 2, a = r.fill ? r.dir > 0 ? 0 : t : t / 2
|
|
441
|
-
|
|
498
|
+
let i = r.fill ? t : t / 2, a = r.fill ? r.dir > 0 ? 0 : t : t / 2;
|
|
499
|
+
w[this.#S].deform(this.#u, i, n, this.#x, {
|
|
500
|
+
y: this.#C.y,
|
|
501
|
+
fill: r.fill
|
|
502
|
+
}), e.bindBuffer(e.ARRAY_BUFFER, this.#s), e.bufferSubData(e.ARRAY_BUFFER, 0, this.#u.positions), e.bindBuffer(e.ARRAY_BUFFER, this.#c), e.bufferSubData(e.ARRAY_BUFFER, 0, this.#u.normals), this.#Q(e.TEXTURE0, r.front), this.#Q(e.TEXTURE1, r.back), e.activeTexture(e.TEXTURE0), e.useProgram(this.#i), e.bindVertexArray(this.#o), e.uniform2f(this.#h.uViewport ?? null, t, n), e.uniform3f(this.#h.uView ?? null, this.#g.scale, this.#g.tx * this.#_ + this.#w, this.#g.ty * this.#_), e.uniform1f(this.#h.uOriginX ?? null, a), e.uniform1f(this.#h.uDir ?? null, r.dir), e.uniform1f(this.#h.uLeafW ?? null, i), e.uniform1f(this.#h.uGloss ?? null, this.#S === "simple" ? 0 : 1), e.uniform1f(this.#h.uAlpha ?? null, r.fill ? this.#Y() : 1), e.drawElements(e.TRIANGLES, this.#l, e.UNSIGNED_SHORT, 0);
|
|
442
503
|
}
|
|
443
504
|
#Y() {
|
|
505
|
+
let e = this.#S === "roll" || this.#S === "simple" ? I : L, t = (this.#x - e) / (1 - e);
|
|
506
|
+
return t <= 0 ? 1 : t >= 1 ? 0 : (1 - t) ** 1.5;
|
|
507
|
+
}
|
|
508
|
+
#X() {
|
|
444
509
|
let e = this.#n;
|
|
445
510
|
e.useProgram(this.#r), e.bindVertexArray(this.#a), e.activeTexture(e.TEXTURE0), e.uniform2f(this.#m.uViewport ?? null, this.#O, this.#k), e.uniform3f(this.#m.uView ?? null, this.#g.scale, this.#g.tx * this.#_ + this.#w, this.#g.ty * this.#_);
|
|
446
511
|
}
|
|
447
|
-
#
|
|
512
|
+
#Z(e, t, n = 0) {
|
|
448
513
|
let r = this.#n;
|
|
449
|
-
t !== null && (this.#
|
|
514
|
+
t !== null && (this.#Q(r.TEXTURE0, t), r.uniform4f(this.#m.uRect ?? null, e.x, e.y, e.w, e.h), r.uniform1f(this.#m.uGutterSide ?? null, n), r.drawArrays(r.TRIANGLE_STRIP, 0, 4));
|
|
450
515
|
}
|
|
451
|
-
#
|
|
516
|
+
#Q(e, t) {
|
|
452
517
|
let n = this.#n;
|
|
453
|
-
n.activeTexture(e), n.bindTexture(n.TEXTURE_2D, t === null ? this.#p : this
|
|
518
|
+
n.activeTexture(e), n.bindTexture(n.TEXTURE_2D, t === null ? this.#p : this.#$(t));
|
|
454
519
|
}
|
|
455
|
-
|
|
520
|
+
#$(e) {
|
|
456
521
|
let t = this.#n, n = this.#d.get(e);
|
|
457
522
|
if (n !== void 0) return this.#d.delete(e), this.#d.set(e, n), n.tex;
|
|
458
|
-
let r =
|
|
459
|
-
|
|
523
|
+
let r = O(t);
|
|
524
|
+
k(t, r, e);
|
|
460
525
|
let i = e, a = i.width * i.height * 4;
|
|
461
526
|
return this.#d.set(e, {
|
|
462
527
|
tex: r,
|
|
463
528
|
bytes: a
|
|
464
|
-
}), this.#f += a, this
|
|
529
|
+
}), this.#f += a, this.#ee(), r;
|
|
465
530
|
}
|
|
466
|
-
|
|
531
|
+
#ee() {
|
|
467
532
|
let e = this.#n;
|
|
468
533
|
for (let [t, n] of this.#d) {
|
|
469
|
-
if (this.#f <=
|
|
534
|
+
if (this.#f <= z || this.#d.size <= 4) break;
|
|
470
535
|
this.#d.delete(t), this.#f -= n.bytes, e.deleteTexture(n.tex);
|
|
471
536
|
}
|
|
472
537
|
}
|
|
473
|
-
#
|
|
474
|
-
let t =
|
|
538
|
+
#te(e) {
|
|
539
|
+
let t = O(e);
|
|
475
540
|
return e.bindTexture(e.TEXTURE_2D, t), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, 1, 1, 0, e.RGBA, e.UNSIGNED_BYTE, new Uint8Array([
|
|
476
541
|
0,
|
|
477
542
|
0,
|
|
@@ -479,7 +544,7 @@ var E = class {
|
|
|
479
544
|
0
|
|
480
545
|
])), t;
|
|
481
546
|
}
|
|
482
|
-
#
|
|
547
|
+
#ne() {
|
|
483
548
|
let e = this.#n, t = this.#t, n = this.#e;
|
|
484
549
|
if (e === null || t === null || n === null) return;
|
|
485
550
|
this.#_ = typeof devicePixelRatio == "number" ? devicePixelRatio : 1;
|
|
@@ -488,6 +553,6 @@ var E = class {
|
|
|
488
553
|
}
|
|
489
554
|
};
|
|
490
555
|
//#endregion
|
|
491
|
-
export {
|
|
556
|
+
export { V as WebglRenderer };
|
|
492
557
|
|
|
493
|
-
//# sourceMappingURL=webglRenderer-
|
|
558
|
+
//# sourceMappingURL=webglRenderer-Bg6VF4CW.js.map
|