@plupin/character 0.2.0 → 0.4.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/dist/anime-face.d.ts +42 -0
- package/dist/anime-face.js +14 -0
- package/dist/blob.d.ts +70 -0
- package/dist/blob.js +46 -0
- package/dist/body-presets.d.ts +153 -0
- package/dist/canvas.js +27 -8
- package/dist/chunk-7ry0n8cw.js +1209 -0
- package/dist/{chunk-k5gwaq6t.js → chunk-ew73g2v7.js} +36 -3
- package/dist/chunk-ewkkvpte.js +448 -0
- package/dist/chunk-kf7f1tdx.js +207 -0
- package/dist/chunk-nx2wbkfn.js +421 -0
- package/dist/chunk-rqenm9tn.js +487 -0
- package/dist/chunk-vy9w8as2.js +196 -0
- package/dist/clips.d.ts +40 -0
- package/dist/dress.d.ts +4 -0
- package/dist/emote.d.ts +5 -3
- package/dist/gaze.d.ts +81 -0
- package/dist/gaze.js +113 -0
- package/dist/hair3d.d.ts +3 -0
- package/dist/index.d.ts +9 -2
- package/dist/index.js +46 -10
- package/dist/listing.d.ts +1 -1
- package/dist/listing.js +52 -16
- package/dist/platform-body-data.d.ts +9 -0
- package/dist/platform-body.d.ts +91 -0
- package/dist/plup3d.d.ts +43 -44
- package/dist/png.d.ts +23 -5
- package/dist/pose.d.ts +7 -1
- package/dist/pose.js +1 -1
- package/dist/proportions.d.ts +31 -0
- package/dist/ragdoll.d.ts +51 -0
- package/dist/resolution.d.ts +21 -0
- package/dist/skin-map.d.ts +156 -0
- package/dist/skin-map.js +57 -0
- package/dist/skin-native.d.ts +73 -6
- package/dist/texture.d.ts +8 -0
- package/dist/three.d.ts +11 -1
- package/dist/three.js +2820 -205
- package/dist/wear3d.d.ts +118 -0
- package/dist/wearables.d.ts +307 -0
- package/dist/wearables.js +26 -0
- package/package.json +21 -1
- package/dist/chunk-ae7gp5cc.js +0 -101
- package/dist/chunk-wpbgtn0y.js +0 -179
package/dist/chunk-wpbgtn0y.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
// src/rig.ts
|
|
2
|
-
var box = (name, parent, joint, size, center = [0, 0, 0]) => ({ name, parent, joint, size, center });
|
|
3
|
-
var R6 = {
|
|
4
|
-
id: "r6",
|
|
5
|
-
height: 5,
|
|
6
|
-
bones: [
|
|
7
|
-
box("Torso", null, [0, 3, 0], [2, 2, 1]),
|
|
8
|
-
box("Head", "Torso", [0, 1, 0], [2, 1, 1], [0, 0.5, 0]),
|
|
9
|
-
box("LeftArm", "Torso", [-1, 1, 0], [1, 2, 1], [-0.5, -1, 0]),
|
|
10
|
-
box("RightArm", "Torso", [1, 1, 0], [1, 2, 1], [0.5, -1, 0]),
|
|
11
|
-
box("LeftLeg", "Torso", [-0.5, -1, 0], [1, 2, 1], [0, -1, 0]),
|
|
12
|
-
box("RightLeg", "Torso", [0.5, -1, 0], [1, 2, 1], [0, -1, 0])
|
|
13
|
-
],
|
|
14
|
-
aliases: {
|
|
15
|
-
head: "Head",
|
|
16
|
-
torso: "Torso",
|
|
17
|
-
armL: "LeftArm",
|
|
18
|
-
armR: "RightArm",
|
|
19
|
-
legL: "LeftLeg",
|
|
20
|
-
legR: "RightLeg"
|
|
21
|
-
},
|
|
22
|
-
lower: {}
|
|
23
|
-
};
|
|
24
|
-
var R15 = {
|
|
25
|
-
id: "r15",
|
|
26
|
-
height: 5,
|
|
27
|
-
bones: [
|
|
28
|
-
box("LowerTorso", null, [0, 2.4, 0], [2, 0.4, 1], [0, -0.2, 0]),
|
|
29
|
-
box("UpperTorso", "LowerTorso", [0, -0, 0], [2, 1.6, 1], [0, 0.8, 0]),
|
|
30
|
-
box("Head", "UpperTorso", [0, 1.6, 0], [2, 1, 1], [0, 0.5, 0]),
|
|
31
|
-
box("LeftUpperArm", "UpperTorso", [-1, 1.6, 0], [1, 1, 1], [-0.5, -0.5, 0]),
|
|
32
|
-
box("LeftLowerArm", "LeftUpperArm", [-0.5, -1, 0], [1, 0.8, 1], [0, -0.4, 0]),
|
|
33
|
-
box("LeftHand", "LeftLowerArm", [0, -0.8, 0], [1, 0.2, 1], [0, -0.1, 0]),
|
|
34
|
-
box("RightUpperArm", "UpperTorso", [1, 1.6, 0], [1, 1, 1], [0.5, -0.5, 0]),
|
|
35
|
-
box("RightLowerArm", "RightUpperArm", [0.5, -1, 0], [1, 0.8, 1], [0, -0.4, 0]),
|
|
36
|
-
box("RightHand", "RightLowerArm", [0, -0.8, 0], [1, 0.2, 1], [0, -0.1, 0]),
|
|
37
|
-
box("LeftUpperLeg", "LowerTorso", [-0.5, -0.4, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
38
|
-
box("LeftLowerLeg", "LeftUpperLeg", [0, -0.9, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
39
|
-
box("LeftFoot", "LeftLowerLeg", [0, -0.9, 0], [1, 0.2, 1], [0, -0.1, 0]),
|
|
40
|
-
box("RightUpperLeg", "LowerTorso", [0.5, -0.4, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
41
|
-
box("RightLowerLeg", "RightUpperLeg", [0, -0.9, 0], [1, 0.9, 1], [0, -0.45, 0]),
|
|
42
|
-
box("RightFoot", "RightLowerLeg", [0, -0.9, 0], [1, 0.2, 1], [0, -0.1, 0])
|
|
43
|
-
],
|
|
44
|
-
aliases: {
|
|
45
|
-
head: "Head",
|
|
46
|
-
torso: "UpperTorso",
|
|
47
|
-
armL: "LeftUpperArm",
|
|
48
|
-
armR: "RightUpperArm",
|
|
49
|
-
legL: "LeftUpperLeg",
|
|
50
|
-
legR: "RightUpperLeg"
|
|
51
|
-
},
|
|
52
|
-
lower: {
|
|
53
|
-
armL: "LeftLowerArm",
|
|
54
|
-
armR: "RightLowerArm",
|
|
55
|
-
legL: "LeftLowerLeg",
|
|
56
|
-
legR: "RightLowerLeg"
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
var PLUP = {
|
|
60
|
-
id: "plup",
|
|
61
|
-
height: 3.4,
|
|
62
|
-
bones: [
|
|
63
|
-
box("Body", null, [0, 1.1, 0], [2.6, 2.3, 2], [0, 1, 0]),
|
|
64
|
-
box("LeftArm", "Body", [-1.3, 1, 0], [0.5, 0.9, 0.5], [-0.2, -0.45, 0]),
|
|
65
|
-
box("RightArm", "Body", [1.3, 1, 0], [0.5, 0.9, 0.5], [0.2, -0.45, 0]),
|
|
66
|
-
box("LeftLeg", "Body", [-0.6, 0, 0], [0.7, 1.1, 0.8], [0, -0.55, 0]),
|
|
67
|
-
box("RightLeg", "Body", [0.6, 0, 0], [0.7, 1.1, 0.8], [0, -0.55, 0])
|
|
68
|
-
],
|
|
69
|
-
aliases: {
|
|
70
|
-
head: "Body",
|
|
71
|
-
torso: "Body",
|
|
72
|
-
armL: "LeftArm",
|
|
73
|
-
armR: "RightArm",
|
|
74
|
-
legL: "LeftLeg",
|
|
75
|
-
legR: "RightLeg"
|
|
76
|
-
},
|
|
77
|
-
lower: {}
|
|
78
|
-
};
|
|
79
|
-
var RIGS = { plup: PLUP, r6: R6, r15: R15 };
|
|
80
|
-
function boneOf(rig, name) {
|
|
81
|
-
const resolved = rig.aliases[name] ?? name;
|
|
82
|
-
return rig.bones.find((bone) => bone.name === resolved);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// src/pose.ts
|
|
86
|
-
var sin = (t, rate, phase = 0) => Math.sin(t * rate * Math.PI * 2 + phase);
|
|
87
|
-
var stride = (t, rate, swing) => ({
|
|
88
|
-
armL: { x: sin(t, rate) * swing * 0.9 },
|
|
89
|
-
armR: { x: -sin(t, rate) * swing * 0.9 },
|
|
90
|
-
legL: { x: -sin(t, rate) * swing },
|
|
91
|
-
legR: { x: sin(t, rate) * swing },
|
|
92
|
-
lift: Math.abs(sin(t, rate)) * 0.08
|
|
93
|
-
});
|
|
94
|
-
var CLIPS = {
|
|
95
|
-
idle: (t) => ({
|
|
96
|
-
armL: { z: -0.06 + sin(t, 0.4) * 0.03 },
|
|
97
|
-
armR: { z: 0.06 - sin(t, 0.4) * 0.03 },
|
|
98
|
-
head: { y: sin(t, 0.15) * 0.12 },
|
|
99
|
-
lift: sin(t, 0.4) * 0.02
|
|
100
|
-
}),
|
|
101
|
-
walk: (t) => stride(t, 1.4, 0.65),
|
|
102
|
-
run: (t) => ({ ...stride(t, 2.4, 1.05), torso: { x: 0.12 } }),
|
|
103
|
-
jump: (t) => {
|
|
104
|
-
const air = Math.max(0, Math.sin(Math.min(t, 1) * Math.PI));
|
|
105
|
-
return {
|
|
106
|
-
armL: { z: -0.5 - air * 1.8 },
|
|
107
|
-
armR: { z: 0.5 + air * 1.8 },
|
|
108
|
-
legL: { x: air * 0.5 },
|
|
109
|
-
legR: { x: -air * 0.3 },
|
|
110
|
-
lift: air * 1.6
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
wave: (t) => ({ armR: { z: 2.6 + sin(t, 2) * 0.35 }, head: { y: 0.15 } }),
|
|
114
|
-
dance: (t) => ({
|
|
115
|
-
armL: { z: -1.6 + sin(t, 2) * 0.7 },
|
|
116
|
-
armR: { z: 1.6 + sin(t, 2) * 0.7 },
|
|
117
|
-
legL: { x: Math.max(0, sin(t, 2)) * 0.5 },
|
|
118
|
-
legR: { x: Math.max(0, -sin(t, 2)) * 0.5 },
|
|
119
|
-
torso: { z: sin(t, 1) * 0.12 },
|
|
120
|
-
lift: Math.abs(sin(t, 2)) * 0.25
|
|
121
|
-
})
|
|
122
|
-
};
|
|
123
|
-
var isCustomClip = (clip) => typeof clip !== "string";
|
|
124
|
-
var customDuration = (clip) => clip.frames.length / clip.fps;
|
|
125
|
-
function customFrame(clip, seconds) {
|
|
126
|
-
const count = clip.frames.length;
|
|
127
|
-
const position = Math.max(0, seconds) * clip.fps;
|
|
128
|
-
const wrapped = clip.loop ? position % count : Math.min(position, count - 1);
|
|
129
|
-
const index = Math.floor(wrapped);
|
|
130
|
-
const here = clip.frames[index] ?? clip.frames[count - 1] ?? [];
|
|
131
|
-
const next = clip.frames[clip.loop ? (index + 1) % count : Math.min(index + 1, count - 1)] ?? here;
|
|
132
|
-
const blend = wrapped - index;
|
|
133
|
-
return here.map((value, slot) => value + ((next[slot] ?? value) - value) * blend);
|
|
134
|
-
}
|
|
135
|
-
function sampleCustom(clip, seconds) {
|
|
136
|
-
const frame = customFrame(clip, seconds);
|
|
137
|
-
const out = {};
|
|
138
|
-
clip.bones.forEach((bone, index) => {
|
|
139
|
-
out[bone] = {
|
|
140
|
-
x: frame[index * 3] ?? 0,
|
|
141
|
-
y: frame[index * 3 + 1] ?? 0,
|
|
142
|
-
z: frame[index * 3 + 2] ?? 0
|
|
143
|
-
};
|
|
144
|
-
});
|
|
145
|
-
out.lift = frame[clip.bones.length * 3] ?? 0;
|
|
146
|
-
return out;
|
|
147
|
-
}
|
|
148
|
-
function evaluate(clip, seconds) {
|
|
149
|
-
return isCustomClip(clip) ? sampleCustom(clip, seconds) : CLIPS[clip](seconds);
|
|
150
|
-
}
|
|
151
|
-
function sampleClip(clip, seconds) {
|
|
152
|
-
const { lift: _lift, ...pose } = evaluate(clip, seconds);
|
|
153
|
-
return pose;
|
|
154
|
-
}
|
|
155
|
-
function clipLift(clip, seconds) {
|
|
156
|
-
return evaluate(clip, seconds).lift ?? 0;
|
|
157
|
-
}
|
|
158
|
-
function mergePoses(...poses) {
|
|
159
|
-
const merged = {};
|
|
160
|
-
for (const pose of poses) {
|
|
161
|
-
for (const [name, rotation] of Object.entries(pose)) {
|
|
162
|
-
merged[name] = { ...merged[name], ...rotation };
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
return merged;
|
|
166
|
-
}
|
|
167
|
-
function resolvePose(rigId, pose) {
|
|
168
|
-
const rig = RIGS[rigId];
|
|
169
|
-
const resolved = new Map;
|
|
170
|
-
for (const [name, rotation] of Object.entries(pose)) {
|
|
171
|
-
const bone = rig.aliases[name] ?? name;
|
|
172
|
-
if (rig.bones.some((candidate) => candidate.name === bone)) {
|
|
173
|
-
resolved.set(bone, { ...resolved.get(bone), ...rotation });
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
return resolved;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
export { RIGS, boneOf, CLIPS, isCustomClip, customDuration, sampleClip, clipLift, mergePoses, resolvePose };
|