dsh-quay-bot 1.0.2 → 1.0.4
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 +28 -105
- package/botscreen/requirements.txt +1 -1
- package/client.js +3 -2
- package/cordis.patch.yml +1 -1
- package/host/api.js +4 -0
- package/host/remote.js +285 -8
- package/host/screen.js +22 -86
- package/package.json +35 -32
- package/remote/bin/dsh-remote.mjs +435 -0
- package/remote/package.json +27 -0
- package/remote/src/config.mjs +183 -0
- package/remote/src/crypto.mjs +220 -0
- package/remote/src/keys.mjs +226 -0
- package/remote/src/proxy.mjs +1028 -0
- package/remote/src/sessions.mjs +163 -0
- package/remote/src/shim.js +838 -0
- package/remote/src/supervisor.mjs +207 -0
- package/remote/src/tunnel.mjs +533 -0
- package/remote/src/upstream.mjs +403 -0
- package/remote/src/util.mjs +149 -0
- package/remote/src/ws.mjs +313 -0
- package/LICENSE +0 -21
- package/avatar/build.mjs +0 -81
- package/avatar/gallery/droid.json +0 -14
- package/avatar/gallery/ghost.json +0 -14
- package/avatar/gallery/grok-pod.json +0 -14
- package/avatar/gallery/guardian.json +0 -14
- package/avatar/gallery/mecha.json +0 -14
- package/avatar/gallery/mochi.json +0 -14
- package/avatar/gallery/neko.json +0 -14
- package/avatar/gallery/orbiter.json +0 -14
- package/avatar/gallery/relay.json +0 -14
- package/avatar/gallery/spark.json +0 -14
- package/avatar/src/bot/clay.ts +0 -135
- package/avatar/src/bot/effects.ts +0 -100
- package/avatar/src/bot/grok-bot.ts +0 -626
- package/avatar/src/bot/index.ts +0 -15
- package/avatar/src/bot/palettes.ts +0 -62
- package/avatar/src/bot/ring.ts +0 -219
- package/avatar/src/bot/scheduler.ts +0 -239
- package/avatar/src/bot/shapes.ts +0 -277
- package/avatar/src/bot/spring.ts +0 -196
- package/avatar/src/core/color.ts +0 -92
- package/avatar/src/core/eyes.ts +0 -297
- package/avatar/src/core/field.ts +0 -482
- package/avatar/src/core/frame.ts +0 -655
- package/avatar/src/core/fx.ts +0 -375
- package/avatar/src/core/index.ts +0 -49
- package/avatar/src/core/paint.ts +0 -331
- package/avatar/src/core/path.ts +0 -495
- package/avatar/src/core/pose.ts +0 -581
- package/avatar/src/core/svg.ts +0 -98
- package/avatar/src/core/types.ts +0 -153
- package/avatar/src/core/validate.ts +0 -296
- package/avatar/src/core/volume.ts +0 -681
- package/avatar/src/entry.ts +0 -260
- package/bin/doctor.mjs +0 -148
- package/botscreen/requirements-offline.txt +0 -11
- package/market/index.json +0 -41
package/avatar/src/core/fx.ts
DELETED
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 状态在身体之外还画什么:工作时环绕身体的彩带,以及思考/阻塞时身体让位给的标记
|
|
3
|
-
* (三个圆点、一个感叹号)。全部是 viewBox 单位下的纯几何,输入是身体包围盒、
|
|
4
|
-
* seed、动画时钟与轮廓的内部判定。
|
|
5
|
-
*/
|
|
6
|
-
import { noise } from './pose.ts';
|
|
7
|
-
import type { Bounds, Point } from './path.ts';
|
|
8
|
-
|
|
9
|
-
const TAU = Math.PI * 2;
|
|
10
|
-
const clamp = (v: number, lo: number, hi: number) => Math.min(hi, Math.max(lo, v));
|
|
11
|
-
const smooth = (u: number) => {
|
|
12
|
-
const x = clamp(u, 0, 1);
|
|
13
|
-
return x * x * (3 - 2 * x);
|
|
14
|
-
};
|
|
15
|
-
const f = (n: number): string => {
|
|
16
|
-
const r = Math.round(n * 100) / 100;
|
|
17
|
-
return (Object.is(r, -0) ? 0 : r).toString();
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export interface Box {
|
|
21
|
-
x: number;
|
|
22
|
-
y: number;
|
|
23
|
-
w: number;
|
|
24
|
-
h: number;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// ---------------------------------------------------------------------------
|
|
28
|
-
// 彩带
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* 身体在每个方向上离 (cx, cy) 有多远。彩带的环挂在这之外一点,
|
|
32
|
-
* 于是身体的任何姿态都不会穿过“彩带从背后绕过”的那条线。
|
|
33
|
-
*/
|
|
34
|
-
export interface Rim {
|
|
35
|
-
cx: number;
|
|
36
|
-
cy: number;
|
|
37
|
-
at: (angle: number) => number;
|
|
38
|
-
max: number;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export function rimOf(polys: Point[][], cx: number, cy: number): Rim {
|
|
42
|
-
const at = (angle: number) => {
|
|
43
|
-
const ux = Math.cos(angle);
|
|
44
|
-
const uy = Math.sin(angle);
|
|
45
|
-
let far = 0;
|
|
46
|
-
for (const poly of polys) {
|
|
47
|
-
for (const [x, y] of poly) {
|
|
48
|
-
const d = Math.abs((x - cx) * ux + (y - cy) * uy);
|
|
49
|
-
if (d > far) far = d;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return far;
|
|
53
|
-
};
|
|
54
|
-
let max = 0;
|
|
55
|
-
for (let k = 0; k < 72; k++) max = Math.max(max, at((k * Math.PI) / 72));
|
|
56
|
-
return { cx, cy, at, max };
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** 环的倾角与画面内滚转角。 */
|
|
60
|
-
const HOOP_TILT = 0.386;
|
|
61
|
-
const HOOP_ROLL = 0.157;
|
|
62
|
-
const HOOP_JITTER = 0.24;
|
|
63
|
-
/** 每圈挂几条彩带。 */
|
|
64
|
-
const LANES = 3;
|
|
65
|
-
/** 环上相邻色带的半径差,viewBox 单位。 */
|
|
66
|
-
const LADDER = 4.2;
|
|
67
|
-
const BAND_ARC = 0.95;
|
|
68
|
-
const BAND_WIDTH = 2.4;
|
|
69
|
-
|
|
70
|
-
export interface RibbonPiece {
|
|
71
|
-
d: string;
|
|
72
|
-
front: boolean;
|
|
73
|
-
box: Box;
|
|
74
|
-
/** 属于哪一条彩带:cage 时为 hoop * LANES + lane。 */
|
|
75
|
-
ribbon: number;
|
|
76
|
-
/** 这条彩带的渐变,坐标与 `d` 相同:从尾 (x1,y1) 到头 (x2,y2)。 */
|
|
77
|
-
gradient: { x1: number; y1: number; x2: number; y2: number; stops: string[] };
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const rollOf = (seed: number, hoop: number, hoops: number) =>
|
|
81
|
-
HOOP_ROLL + (hoop * Math.PI) / hoops + (noise(seed, 450 + hoop) - 0.5) * HOOP_JITTER;
|
|
82
|
-
|
|
83
|
-
/** 环上角度 θ 的 3D 点、屏幕点与朝向观察者的符号。 */
|
|
84
|
-
function hoopPoint(ring: number, tilt: number, roll: number, theta: number): { x: number; y: number; front: boolean } {
|
|
85
|
-
const x3 = ring * Math.cos(theta);
|
|
86
|
-
const y3 = ring * Math.sin(theta) * Math.cos(tilt);
|
|
87
|
-
const z3 = ring * Math.sin(theta) * Math.sin(tilt);
|
|
88
|
-
const cos = Math.cos(roll);
|
|
89
|
-
const sin = Math.sin(roll);
|
|
90
|
-
return { x: x3 * cos - y3 * sin, y: y3 * cos + x3 * sin, front: z3 > 0 };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* 这一刻所有可见的彩带片段。
|
|
95
|
-
* `presence` 0..1 让彩带长出来又收回去;`sweep` 是身体转身带它们走过的角度。
|
|
96
|
-
* `inside` 判断一点是否在身体剪影内,用来把“在身体背后”的片段剪掉。
|
|
97
|
-
*/
|
|
98
|
-
export function ribbonPieces(
|
|
99
|
-
rim: Rim,
|
|
100
|
-
presence: number,
|
|
101
|
-
seed: number,
|
|
102
|
-
time: number,
|
|
103
|
-
sweep: number,
|
|
104
|
-
cage: number,
|
|
105
|
-
inside: (x: number, y: number) => boolean,
|
|
106
|
-
runOf: (ribbon: number) => string[],
|
|
107
|
-
): RibbonPiece[] {
|
|
108
|
-
if (presence <= 0.01) return [];
|
|
109
|
-
const hoops = cage >= 0.5 ? 3 : 1;
|
|
110
|
-
const pieces: RibbonPiece[] = [];
|
|
111
|
-
const tilt = HOOP_TILT + (noise(seed, 480) - 0.5) * 0.08;
|
|
112
|
-
for (let h = 0; h < hoops; h++) {
|
|
113
|
-
const roll = rollOf(seed, h, hoops);
|
|
114
|
-
const ring = rim.at(roll) + 2 + (h - (hoops - 1) / 2) * 1.4;
|
|
115
|
-
for (let lane = 0; lane < LANES; lane++) {
|
|
116
|
-
const r = ring + (lane - (LANES - 1) / 2) * LADDER;
|
|
117
|
-
// 每条彩带自己的相位、自己的速度份额,于是一圈上的彩带会散开。
|
|
118
|
-
const share = 0.74 + 0.2 * noise(seed, 500 + lane);
|
|
119
|
-
const drift = (0.5 + 0.6 * noise(seed, 520 + lane * 7 + h)) * time;
|
|
120
|
-
const head = sweep * share + drift + (lane / LANES) * TAU * 0.16 + h * 0.9;
|
|
121
|
-
const samples: { x: number; y: number; front: boolean; s: number }[] = [];
|
|
122
|
-
const N = 14;
|
|
123
|
-
for (let k = 0; k <= N; k++) {
|
|
124
|
-
const s = k / N;
|
|
125
|
-
const theta = head - BAND_ARC * (1 - s);
|
|
126
|
-
const p = hoopPoint(r, tilt, roll, theta);
|
|
127
|
-
samples.push({ x: rim.cx + p.x, y: rim.cy + p.y, front: p.front, s });
|
|
128
|
-
}
|
|
129
|
-
// 屏幕空间法线,用来给色带一点宽度(尾细头宽,圆头)。
|
|
130
|
-
const widths = samples.map((p) => BAND_WIDTH * presence * (0.45 + 0.55 * p.s));
|
|
131
|
-
const left: Point[] = [];
|
|
132
|
-
const right: Point[] = [];
|
|
133
|
-
for (let k = 0; k <= N; k++) {
|
|
134
|
-
const a = samples[Math.max(0, k - 1)];
|
|
135
|
-
const b = samples[Math.min(N, k + 1)];
|
|
136
|
-
const tx = b.x - a.x;
|
|
137
|
-
const ty = b.y - a.y;
|
|
138
|
-
const len = Math.hypot(tx, ty) || 1;
|
|
139
|
-
const nx = -ty / len;
|
|
140
|
-
const ny = tx / len;
|
|
141
|
-
const w = widths[k] / 2;
|
|
142
|
-
left.push([samples[k].x + nx * w, samples[k].y + ny * w]);
|
|
143
|
-
right.push([samples[k].x - nx * w, samples[k].y - ny * w]);
|
|
144
|
-
}
|
|
145
|
-
const visible = (k: number) => samples[k].front || !inside(samples[k].x, samples[k].y);
|
|
146
|
-
const headPoint = samples[N];
|
|
147
|
-
const tailPoint = samples[0];
|
|
148
|
-
const gradient = {
|
|
149
|
-
x1: tailPoint.x,
|
|
150
|
-
y1: tailPoint.y,
|
|
151
|
-
x2: headPoint.x,
|
|
152
|
-
y2: headPoint.y,
|
|
153
|
-
stops: runOf(h * LANES + lane),
|
|
154
|
-
};
|
|
155
|
-
let k = 0;
|
|
156
|
-
while (k <= N) {
|
|
157
|
-
if (!visible(k)) {
|
|
158
|
-
k++;
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
161
|
-
const from = k;
|
|
162
|
-
while (k <= N && visible(k)) k++;
|
|
163
|
-
const to = k - 1;
|
|
164
|
-
if (to - from < 1) continue;
|
|
165
|
-
const pts: Point[] = [];
|
|
166
|
-
for (let q = from; q <= to; q++) pts.push(left[q]);
|
|
167
|
-
for (let q = to; q >= from; q--) pts.push(right[q]);
|
|
168
|
-
const xs = pts.map((p) => p[0]);
|
|
169
|
-
const ys = pts.map((p) => p[1]);
|
|
170
|
-
const x = Math.min(...xs);
|
|
171
|
-
const y = Math.min(...ys);
|
|
172
|
-
pieces.push({
|
|
173
|
-
d: `M${pts.map((p) => `${f(p[0])} ${f(p[1])}`).join('L')}Z`,
|
|
174
|
-
front: samples[from].front,
|
|
175
|
-
box: { x, y, w: Math.max(...xs) - x, h: Math.max(...ys) - y },
|
|
176
|
-
ribbon: h * LANES + lane,
|
|
177
|
-
gradient,
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
return pieces;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// ---------------------------------------------------------------------------
|
|
186
|
-
// 完成态的粒子绽放
|
|
187
|
-
|
|
188
|
-
/** 一粒:圆点路径、画在哪个矩阵、什么颜色、在身体前还是后。 */
|
|
189
|
-
export interface BloomPiece {
|
|
190
|
-
d: string;
|
|
191
|
-
box: Box;
|
|
192
|
-
matrix: [number, number, number, number, number, number];
|
|
193
|
-
fill: string;
|
|
194
|
-
front: boolean;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/** 粒子半径的几档(同一档共用一条路径,省 Path2D)。 */
|
|
198
|
-
const RADII = [1, 1.5, 2.1, 2.9] as const;
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* 完成时的粒子绽放:从一个点向外炸开,然后慢慢飘散、缩没。
|
|
202
|
-
*
|
|
203
|
-
* 纯函数:同一 (seed, age) 永远得到同一组粒子。每个粒子的角度、速度、延迟、
|
|
204
|
-
* 大小、寿命、旋向都由 seed 与序号散列出来,所以每个头像的花形都不同,
|
|
205
|
-
* 但同一头像每次都一样。
|
|
206
|
-
*/
|
|
207
|
-
export function bloomPieces(
|
|
208
|
-
b: Bounds,
|
|
209
|
-
seed: number,
|
|
210
|
-
age: number,
|
|
211
|
-
energy: number,
|
|
212
|
-
palette: string[],
|
|
213
|
-
): BloomPiece[] {
|
|
214
|
-
if (energy <= 0.01 || !Number.isFinite(age)) return [];
|
|
215
|
-
const cx = (b.minX + b.maxX) / 2;
|
|
216
|
-
const cy = (b.minY + b.maxY) / 2;
|
|
217
|
-
const scale = clamp(Math.min(b.maxX - b.minX, b.maxY - b.minY), 40, 84) / 70;
|
|
218
|
-
const pieces: BloomPiece[] = [];
|
|
219
|
-
const GOLDEN = 2.399963;
|
|
220
|
-
const COUNT = 34;
|
|
221
|
-
|
|
222
|
-
for (let i = 0; i < COUNT; i++) {
|
|
223
|
-
const r1 = noise(seed, 7000 + i * 7);
|
|
224
|
-
const r2 = noise(seed, 7001 + i * 7);
|
|
225
|
-
const r3 = noise(seed, 7002 + i * 7);
|
|
226
|
-
const r4 = noise(seed, 7003 + i * 7);
|
|
227
|
-
const r5 = noise(seed, 7004 + i * 7);
|
|
228
|
-
|
|
229
|
-
const delay = r1 * 0.42;
|
|
230
|
-
const life = 1.5 + r2 * 2.1;
|
|
231
|
-
const t = (age - delay) / life;
|
|
232
|
-
if (t <= 0 || t >= 1) continue;
|
|
233
|
-
|
|
234
|
-
// 开头快、后面慢:位移是“炸开”的曲线,不是匀速飞散。
|
|
235
|
-
const reach = (10 + r3 * 46) * scale * (1 - Math.exp(-age * 2.6));
|
|
236
|
-
const angle = i * GOLDEN + r4 * 0.9 + age * (0.25 + r5 * 0.5) * (r5 > 0.5 ? 1 : -1);
|
|
237
|
-
const x = cx + Math.cos(angle) * reach;
|
|
238
|
-
const y = cy + Math.sin(angle) * reach * 0.92;
|
|
239
|
-
|
|
240
|
-
// 大小:先涨后缩,缩到 0 就等于淡出(配色是不透明填充)。
|
|
241
|
-
const envelope = Math.sin(Math.PI * clamp(t, 0, 1));
|
|
242
|
-
const r0 = RADII[i % RADII.length];
|
|
243
|
-
const grow = envelope * (0.55 + r2 * 0.9) * scale;
|
|
244
|
-
if (grow < 0.06) continue;
|
|
245
|
-
|
|
246
|
-
const spin = r4 * TAU;
|
|
247
|
-
const cos = Math.cos(spin) * grow;
|
|
248
|
-
const sin2 = Math.sin(spin) * grow;
|
|
249
|
-
const fill = palette[i % palette.length];
|
|
250
|
-
pieces.push({
|
|
251
|
-
d: circlePath(r0),
|
|
252
|
-
box: { x: -r0, y: -r0, w: 2 * r0, h: 2 * r0 },
|
|
253
|
-
matrix: [cos, sin2, -sin2, cos, x, y],
|
|
254
|
-
fill,
|
|
255
|
-
// 往下(朝向观察者这边)的粒子在身体前面,往上的在后面。
|
|
256
|
-
front: Math.sin(angle) > 0.12,
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
return pieces;
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
/** 以原点为圆心、半径 r 的圆路径(绝对坐标,供 Path2D 与 SVG 共用)。 */
|
|
263
|
-
function circlePath(r: number): string {
|
|
264
|
-
const f = (n: number) => Math.round(n * 100) / 100;
|
|
265
|
-
return `M${f(-r)} 0A${f(r)} ${f(r)} 0 1 1 ${f(r)} 0A${f(r)} ${f(r)} 0 1 1 ${f(-r)} 0Z`;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* 一条“粗线”:沿折线两侧按宽度偏移出轮廓,用于触须、蛇身、飘带这类
|
|
270
|
-
* 需要厚度又不想手写贝塞尔的部件(触须、蛇身、飘带之类)。
|
|
271
|
-
*/
|
|
272
|
-
export function tube(points: Point[], width: number, closed = false): string {
|
|
273
|
-
const pts = closed ? [...points, points[0]] : points;
|
|
274
|
-
if (pts.length < 2) return '';
|
|
275
|
-
const left: Point[] = [];
|
|
276
|
-
const right: Point[] = [];
|
|
277
|
-
for (let i = 0; i < pts.length; i++) {
|
|
278
|
-
const p = pts[i];
|
|
279
|
-
const a = pts[Math.max(0, i - 1)];
|
|
280
|
-
const c = pts[Math.min(pts.length - 1, i + 1)];
|
|
281
|
-
const dx = c[0] - a[0];
|
|
282
|
-
const dy = c[1] - a[1];
|
|
283
|
-
const len = Math.hypot(dx, dy) || 1;
|
|
284
|
-
const nx = (-dy / len) * (width / 2);
|
|
285
|
-
const ny = (dx / len) * (width / 2);
|
|
286
|
-
left.push([p[0] + nx, p[1] + ny]);
|
|
287
|
-
right.push([p[0] - nx, p[1] - ny]);
|
|
288
|
-
}
|
|
289
|
-
const f = (n: number) => Math.round(n * 100) / 100;
|
|
290
|
-
const fmt = (q: Point[]) => q.map(([x, y]) => `${f(x)} ${f(y)}`).join('L');
|
|
291
|
-
return `M${fmt(left)}L${fmt(right.reverse())}Z`;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// ---------------------------------------------------------------------------
|
|
295
|
-
// 标记
|
|
296
|
-
|
|
297
|
-
export interface MarkPart {
|
|
298
|
-
shape: string;
|
|
299
|
-
d: string;
|
|
300
|
-
box: Box;
|
|
301
|
-
x: number;
|
|
302
|
-
y: number;
|
|
303
|
-
turn: number;
|
|
304
|
-
scale: number;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
const circle = (r: number) => `M${f(r)} 0A${f(r)} ${f(r)} 0 1 1 ${f(-r)} 0A${f(r)} ${f(r)} 0 1 1 ${f(r)} 0Z`;
|
|
308
|
-
const capsule = (w: number, h: number) => {
|
|
309
|
-
const r = w / 2;
|
|
310
|
-
const y = h / 2 - r;
|
|
311
|
-
return `M${f(-r)} ${f(-y)}A${f(r)} ${f(r)} 0 0 1 ${f(r)} ${f(-y)}L${f(r)} ${f(y)}A${f(r)} ${f(r)} 0 0 1 ${f(-r)} ${f(y)}Z`;
|
|
312
|
-
};
|
|
313
|
-
|
|
314
|
-
/** 标记的尺寸单位:身体较窄边的比例,限定在读得清的范围内。 */
|
|
315
|
-
function markUnit(b: Bounds): number {
|
|
316
|
-
return clamp(Math.min(b.maxX - b.minX, b.maxY - b.minY), 34, 78);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/**
|
|
320
|
-
* 某一刻标记的各个部件。`bang` / `dots` 0..1 表示身体让位给各自的程度:
|
|
321
|
-
* 标记从身体中心长出来。圆点轮流跳;感叹号每隔 2.6 s 跳一下并抖一抖。
|
|
322
|
-
*/
|
|
323
|
-
export function markParts(b: Bounds, bang: number, dots: number, seed: number, time: number, still: boolean): MarkPart[] {
|
|
324
|
-
const cx = (b.minX + b.maxX) / 2;
|
|
325
|
-
const cy = (b.minY + b.maxY) / 2;
|
|
326
|
-
const u = markUnit(b);
|
|
327
|
-
const t = still ? 0 : time + noise(seed, 9) * 10;
|
|
328
|
-
const parts: MarkPart[] = [];
|
|
329
|
-
const grown = (weight: number) => smooth((clamp(weight, 0, 1) - 0.45) / 0.55);
|
|
330
|
-
|
|
331
|
-
const gb = grown(bang);
|
|
332
|
-
if (gb > 0) {
|
|
333
|
-
const barW = 0.21 * u;
|
|
334
|
-
const barH = 0.5 * u;
|
|
335
|
-
const dot = 0.115 * u;
|
|
336
|
-
const gap = 0.1 * u;
|
|
337
|
-
const total = barH + gap + 2 * dot;
|
|
338
|
-
const p = still ? 1 : (((t % 2.6) + 2.6) % 2.6) / 2.6;
|
|
339
|
-
const alarm = p < 0.3 ? p / 0.3 : 1;
|
|
340
|
-
const jump = still ? 0 : Math.sin(Math.PI * alarm);
|
|
341
|
-
const turn = still ? 0 : 0.2 * Math.sin(TAU * 3 * alarm) * (1 - alarm);
|
|
342
|
-
const lift = -0.09 * u * jump;
|
|
343
|
-
const barY = -total / 2 + barH / 2;
|
|
344
|
-
const dotY = total / 2 - dot;
|
|
345
|
-
parts.push(
|
|
346
|
-
{ shape: 'bar', d: capsule(barW, barH), box: { x: -barW / 2, y: -barH / 2, w: barW, h: barH }, x: cx, y: cy + (barY + lift) * gb, turn, scale: gb },
|
|
347
|
-
{ shape: 'dot', d: circle(dot), box: { x: -dot, y: -dot, w: 2 * dot, h: 2 * dot }, x: cx, y: cy + (dotY + lift * 0.45) * gb, turn, scale: gb },
|
|
348
|
-
);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
const gd = grown(dots);
|
|
352
|
-
if (gd > 0) {
|
|
353
|
-
const r = 0.1 * u;
|
|
354
|
-
const step = 0.31 * u;
|
|
355
|
-
for (let i = 0; i < 3; i++) {
|
|
356
|
-
const p = still ? 0 : (((t - i * 0.17) % 1.25) + 1.25) % 1.25 / 1.25;
|
|
357
|
-
const hop = p < 0.4 ? Math.sin(Math.PI * (p / 0.4)) : 0;
|
|
358
|
-
parts.push({
|
|
359
|
-
shape: 'dot3',
|
|
360
|
-
d: circle(r),
|
|
361
|
-
box: { x: -r, y: -r, w: 2 * r, h: 2 * r },
|
|
362
|
-
x: cx + (i - 1) * step * gd,
|
|
363
|
-
y: cy - 0.16 * u * hop * gd,
|
|
364
|
-
turn: 0,
|
|
365
|
-
scale: gd * (1 + 0.12 * hop),
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
return parts;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/** 身体让位给标记时保留多少尺寸:过半一点就完全消失。 */
|
|
373
|
-
export function bodyScale(bang: number, dots: number): number {
|
|
374
|
-
return 1 - smooth(clamp(bang + dots, 0, 1) / 0.55);
|
|
375
|
-
}
|
package/avatar/src/core/index.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/** 公共入口:定义契约、校验、体积推断、帧数据与两个渲染器。 */
|
|
2
|
-
export type { AvatarDefinition, AvatarEyes, AvatarMood, AvatarState, RenderOptions, ValidationResult } from './types.ts';
|
|
3
|
-
export { validateAvatar, analyzeBody, eyeClearance, gazeRange, EYE_W, EYE_H, GAZE_X, GAZE_Y, HAPPY_ARC } from './validate.ts';
|
|
4
|
-
export type { BodyAnalysis, BodySubpath, BodyHole, GazeRange } from './validate.ts';
|
|
5
|
-
export { buildVolume, boostedEyeScale, faceRoom, MAX_PART_DEPTH, EYE_BOOST, EYE_BOOST_PAD, FACE_ROOM_TARGET } from './volume.ts';
|
|
6
|
-
export type { Volume, VolumePart, VolumeSlice, EyePlane, FaceRoom } from './volume.ts';
|
|
7
|
-
export {
|
|
8
|
-
computeFrame,
|
|
9
|
-
prepare,
|
|
10
|
-
avatarExtent,
|
|
11
|
-
viewBasis,
|
|
12
|
-
planeMatrix,
|
|
13
|
-
sidePlaneMatrix,
|
|
14
|
-
projectPoint,
|
|
15
|
-
activeStack,
|
|
16
|
-
pivotOf,
|
|
17
|
-
DEFAULT_COLOR,
|
|
18
|
-
DEFAULT_DEPTH,
|
|
19
|
-
DEFAULT_EYE_COLOR,
|
|
20
|
-
} from './frame.ts';
|
|
21
|
-
export type { Frame, FramePath, FrameShape, EyeMark, Matrix, ViewBasis, Prepared } from './frame.ts';
|
|
22
|
-
export { renderSvg, placeholderSvg } from './svg.ts';
|
|
23
|
-
export { mountCanvas, paintFrame, fitSquare } from './paint.ts';
|
|
24
|
-
export type { Surface, Square } from './paint.ts';
|
|
25
|
-
export {
|
|
26
|
-
computePose,
|
|
27
|
-
blendPoses,
|
|
28
|
-
blinkAt,
|
|
29
|
-
wanderAt,
|
|
30
|
-
hashString,
|
|
31
|
-
noise,
|
|
32
|
-
STATES,
|
|
33
|
-
MOODS,
|
|
34
|
-
BASE_YAW,
|
|
35
|
-
BASE_PITCH,
|
|
36
|
-
DONE_CYCLE_S,
|
|
37
|
-
DONE_TURN_S,
|
|
38
|
-
} from './pose.ts';
|
|
39
|
-
export type { Pose, EyeLook, PoseInput } from './pose.ts';
|
|
40
|
-
export { eyePath, eyeOutline, plainLook } from './eyes.ts';
|
|
41
|
-
export type { EyeSpot } from './eyes.ts';
|
|
42
|
-
export { autoEyeColor, contrast, oklch, parseHex, toHex, toOklch } from './color.ts';
|
|
43
|
-
export type { Rgb } from './color.ts';
|
|
44
|
-
export { bodyScale, markParts, rimOf, ribbonPieces } from './fx.ts';
|
|
45
|
-
export type { Box, MarkPart, RibbonPiece, Rim } from './fx.ts';
|
|
46
|
-
export { parsePath, serializePath, flattenPath, winding, insideRow, bounds, filledArea, edgeBands, PathError, PATH_LIMITS } from './path.ts';
|
|
47
|
-
export type { Segment, Point, Bounds } from './path.ts';
|
|
48
|
-
export { contourLoops, loopsToPath, simplifyLoop, segDist2 } from './field.ts';
|
|
49
|
-
export type { Field, Grid } from './field.ts';
|