@plupin/character 0.4.0 → 0.5.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/blob.d.ts +15 -2
- package/dist/blob.js +3 -1
- package/dist/body-presets.d.ts +9 -8
- package/dist/canvas.js +2 -2
- package/dist/{chunk-ew73g2v7.js → chunk-phwn2cn7.js} +6 -4
- package/dist/{chunk-rqenm9tn.js → chunk-s083mv4f.js} +9 -8
- package/dist/{chunk-7ry0n8cw.js → chunk-wryfx2sg.js} +377 -233
- package/dist/{chunk-vy9w8as2.js → chunk-x8f5p1qg.js} +42 -12
- package/dist/index.js +3 -3
- package/dist/listing.js +2 -2
- package/dist/pose.js +1 -1
- package/dist/skin-native.d.ts +11 -5
- package/dist/three.js +248 -40
- package/package.json +1 -1
|
@@ -2,7 +2,15 @@
|
|
|
2
2
|
import { SphereGeometry } from "three";
|
|
3
3
|
var BLOB_RADIUS = { x: 0.6, y: 0.56, z: 0.58 };
|
|
4
4
|
var BLOB_HEIGHT = BLOB_RADIUS.y * (1 + 0.62 + (1 - 0.62) * 0.3);
|
|
5
|
-
var ROUND = {
|
|
5
|
+
var ROUND = {
|
|
6
|
+
shoulders: 1,
|
|
7
|
+
waist: 1,
|
|
8
|
+
hips: 1,
|
|
9
|
+
bust: 0,
|
|
10
|
+
muscle: 1,
|
|
11
|
+
torsoHeight: 1,
|
|
12
|
+
figure: 0
|
|
13
|
+
};
|
|
6
14
|
var bump = (at, centre, spread) => Math.exp(-(((at - centre) / spread) ** 2));
|
|
7
15
|
var clamp01 = (v) => Math.max(0, Math.min(1, v));
|
|
8
16
|
var smoothstep = (e0, e1, x) => {
|
|
@@ -57,9 +65,28 @@ var FIGURE_HEAD_BASE_SCALE = 0.46;
|
|
|
57
65
|
var FIGURE_NECK_TOP_Y = 0.8;
|
|
58
66
|
var FIGURE_SHOULDER_Y = 0.64;
|
|
59
67
|
var FIGURE_HIP_Y = 0.17;
|
|
60
|
-
function
|
|
68
|
+
function figureTorsoSpan(torsoHeight = 1) {
|
|
69
|
+
const h = Math.max(0.45, Math.min(1.15, torsoHeight));
|
|
70
|
+
const minY = FIGURE_TORSO_MIN_Y;
|
|
71
|
+
const maxY = minY + (FIGURE_TORSO_MAX_Y - FIGURE_TORSO_MIN_Y) * h;
|
|
72
|
+
const centerY = (minY + maxY) / 2;
|
|
73
|
+
const halfH = (maxY - minY) / 2;
|
|
74
|
+
return {
|
|
75
|
+
minY,
|
|
76
|
+
maxY,
|
|
77
|
+
centerY,
|
|
78
|
+
halfH,
|
|
79
|
+
neckTopY: minY + (FIGURE_NECK_TOP_Y - minY) * h,
|
|
80
|
+
shoulderY: minY + (FIGURE_SHOULDER_Y - minY) * h,
|
|
81
|
+
hipY: minY + (FIGURE_HIP_Y - minY) * h,
|
|
82
|
+
waistY: minY + (0.41 - minY) * h,
|
|
83
|
+
bustY: minY + (0.56 - minY) * h
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function figureHeadMetrics(headSize = 0.78, torsoHeight = 1) {
|
|
87
|
+
const span = figureTorsoSpan(torsoHeight);
|
|
61
88
|
const scale = FIGURE_HEAD_BASE_SCALE * headSize;
|
|
62
|
-
const originY =
|
|
89
|
+
const originY = span.neckTopY - 0.03 * scale;
|
|
63
90
|
return { scale, originY, centerY: originY + BLOB_SEAT * scale };
|
|
64
91
|
}
|
|
65
92
|
var smin = (a, b, k) => {
|
|
@@ -67,7 +94,9 @@ var smin = (a, b, k) => {
|
|
|
67
94
|
return b * (1 - h) + a * h - k * h * (1 - h);
|
|
68
95
|
};
|
|
69
96
|
function figureTorsoPoint(y, phi, silhouette = ROUND) {
|
|
70
|
-
const
|
|
97
|
+
const span = figureTorsoSpan(silhouette.torsoHeight ?? 1);
|
|
98
|
+
const u = Math.max(-0.985, Math.min(0.985, (y - span.centerY) / span.halfH));
|
|
99
|
+
const compact = Math.min(1, 0.58 + 0.42 * (silhouette.torsoHeight ?? 1));
|
|
71
100
|
const ux = Math.sin(phi);
|
|
72
101
|
const uz = Math.cos(phi);
|
|
73
102
|
const sh = silhouette.shoulders ?? 1;
|
|
@@ -99,13 +128,13 @@ function figureTorsoPoint(y, phi, silhouette = ROUND) {
|
|
|
99
128
|
let rz = (shoulderW * shoulderRz + ribW * ribRz + waistW * waistRz + hipW * hipRz + 0.08 * 0.12) / wSum;
|
|
100
129
|
rz = rz * (1 - neckT) + neckRz * neckT;
|
|
101
130
|
rz *= pelvisRound;
|
|
102
|
-
let x = ux * rx;
|
|
103
|
-
let z = uz * rz;
|
|
131
|
+
let x = ux * rx * compact;
|
|
132
|
+
let z = uz * rz * compact;
|
|
104
133
|
if (bust > 0.01 && uz > -0.1) {
|
|
105
|
-
const domeR = 0.095 + Math.min(1.4, bust) * 0.038;
|
|
106
|
-
const cx = 0.082 + Math.min(1.4, bust) * 0.01;
|
|
107
|
-
const cy =
|
|
108
|
-
const cz = 0.075 + Math.min(1.4, bust) * 0.024;
|
|
134
|
+
const domeR = (0.095 + Math.min(1.4, bust) * 0.038) * compact;
|
|
135
|
+
const cx = (0.082 + Math.min(1.4, bust) * 0.01) * compact;
|
|
136
|
+
const cy = span.centerY + 0.34 * span.halfH;
|
|
137
|
+
const cz = (0.075 + Math.min(1.4, bust) * 0.024) * compact;
|
|
109
138
|
const bx = Math.abs(x) - cx;
|
|
110
139
|
const by = (y - cy) * 1.05;
|
|
111
140
|
const d2 = bx * bx + by * by;
|
|
@@ -177,13 +206,14 @@ function figureHeadRadiusAt(y) {
|
|
|
177
206
|
return Math.sqrt(Math.max(0.001, 1 - unit * unit)) * cheek * chinTaper * 0.54;
|
|
178
207
|
}
|
|
179
208
|
function buildFigureTorsoGeometry(silhouette = ROUND) {
|
|
209
|
+
const span = figureTorsoSpan(silhouette.torsoHeight ?? 1);
|
|
180
210
|
const geometry = new SphereGeometry(1, 56, 44);
|
|
181
211
|
const position = geometry.attributes.position;
|
|
182
212
|
for (let i = 0;i < position.count; i += 1) {
|
|
183
213
|
const ux = position.getX(i);
|
|
184
214
|
const uy = position.getY(i);
|
|
185
215
|
const uz = position.getZ(i);
|
|
186
|
-
const y =
|
|
216
|
+
const y = span.centerY + uy * span.halfH;
|
|
187
217
|
const phi = Math.atan2(ux, uz);
|
|
188
218
|
const pt = figureTorsoPoint(y, phi, silhouette);
|
|
189
219
|
position.setXYZ(i, pt.x, y, pt.z);
|
|
@@ -193,4 +223,4 @@ function buildFigureTorsoGeometry(silhouette = ROUND) {
|
|
|
193
223
|
return geometry;
|
|
194
224
|
}
|
|
195
225
|
|
|
196
|
-
export { BLOB_RADIUS, BLOB_HEIGHT, ROUND, silhouetteAt, BLOB_SEAT, blobRadiusAt, buildBlobGeometry, FIGURE_TORSO_MIN_Y, FIGURE_TORSO_MAX_Y, FIGURE_TORSO_CENTER_Y, FIGURE_TORSO_HALF_H, FIGURE_HEAD_BASE_SCALE, FIGURE_NECK_TOP_Y, FIGURE_SHOULDER_Y, FIGURE_HIP_Y, figureHeadMetrics, figureTorsoPoint, figureTorsoRadiusAt, buildFigureHeadGeometry, figureHeadRadiusAt, buildFigureTorsoGeometry };
|
|
226
|
+
export { BLOB_RADIUS, BLOB_HEIGHT, ROUND, silhouetteAt, BLOB_SEAT, blobRadiusAt, buildBlobGeometry, FIGURE_TORSO_MIN_Y, FIGURE_TORSO_MAX_Y, FIGURE_TORSO_CENTER_Y, FIGURE_TORSO_HALF_H, FIGURE_HEAD_BASE_SCALE, FIGURE_NECK_TOP_Y, FIGURE_SHOULDER_Y, FIGURE_HIP_Y, figureTorsoSpan, figureHeadMetrics, figureTorsoPoint, figureTorsoRadiusAt, buildFigureHeadGeometry, figureHeadRadiusAt, buildFigureTorsoGeometry };
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
RAGDOLL_JOINTS,
|
|
5
5
|
createRagdoll,
|
|
6
6
|
emoteOf
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-s083mv4f.js";
|
|
8
8
|
import {
|
|
9
9
|
WEARABLES,
|
|
10
10
|
WEAR_KEYS,
|
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
validateClassicTemplate,
|
|
51
51
|
validateVariantSheet,
|
|
52
52
|
visualEnvelope
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-phwn2cn7.js";
|
|
54
54
|
import {
|
|
55
55
|
AUTHORED_BONES,
|
|
56
56
|
AUTHORED_CLIPS,
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
mergePoses,
|
|
65
65
|
resolvePose,
|
|
66
66
|
sampleClip
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-wryfx2sg.js";
|
|
68
68
|
import {
|
|
69
69
|
FACE_STAMP_PALETTE,
|
|
70
70
|
NAMED_FACES,
|
package/dist/listing.js
CHANGED
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
NATIVE_SHEET_CAPS,
|
|
8
8
|
NATIVE_TORSO,
|
|
9
9
|
clampBodyScale
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-phwn2cn7.js";
|
|
11
11
|
import {
|
|
12
12
|
CLIPS
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-wryfx2sg.js";
|
|
14
14
|
import {
|
|
15
15
|
FACE_STAMP_PALETTE,
|
|
16
16
|
NAMED_FACES,
|
package/dist/pose.js
CHANGED
package/dist/skin-native.d.ts
CHANGED
|
@@ -123,13 +123,13 @@ export declare const PLUP_BODY_LIMITS: {
|
|
|
123
123
|
readonly min: 0;
|
|
124
124
|
readonly max: 1.4;
|
|
125
125
|
};
|
|
126
|
-
/** Leg length: 1 is Plup's stubs, 3 is a long-legged runway walker. */
|
|
126
|
+
/** Leg length: 0.65 is tiny chibi, 1 is Plup's stubs, 3 is a long-legged runway walker. */
|
|
127
127
|
readonly legLength: {
|
|
128
|
-
readonly min:
|
|
128
|
+
readonly min: 0.65;
|
|
129
129
|
readonly max: 3;
|
|
130
130
|
};
|
|
131
131
|
readonly armLength: {
|
|
132
|
-
readonly min: 0.
|
|
132
|
+
readonly min: 0.55;
|
|
133
133
|
readonly max: 1.8;
|
|
134
134
|
};
|
|
135
135
|
/** Arm, shoulder, chest and leg bulk (muscular / kekar build). */
|
|
@@ -142,10 +142,15 @@ export declare const PLUP_BODY_LIMITS: {
|
|
|
142
142
|
readonly min: 0.2;
|
|
143
143
|
readonly max: 0.55;
|
|
144
144
|
};
|
|
145
|
-
/** Head size multiplier: lower (0.55–0.8) makes the sculpted body stand out like anime/Roblox; 1
|
|
145
|
+
/** Head size multiplier: lower (0.55–0.8) makes the sculpted body stand out like anime/Roblox; 1.25–1.45 is chibi. */
|
|
146
146
|
readonly headSize: {
|
|
147
147
|
readonly min: 0.55;
|
|
148
|
-
readonly max: 1.
|
|
148
|
+
readonly max: 1.45;
|
|
149
|
+
};
|
|
150
|
+
/** Torso height multiplier on stylized figure mode (0.45 = compact cute chibi body, 1.0 = full runway anime). */
|
|
151
|
+
readonly torsoHeight: {
|
|
152
|
+
readonly min: 0.45;
|
|
153
|
+
readonly max: 1.15;
|
|
149
154
|
};
|
|
150
155
|
/** 0 = classic round Plup blob, 1 = stylized anime/chibi figure (round head + neck + sculpted torso). */
|
|
151
156
|
readonly figure: {
|
|
@@ -163,6 +168,7 @@ export interface PlupBody {
|
|
|
163
168
|
muscle: number;
|
|
164
169
|
shoulderHeight: number;
|
|
165
170
|
headSize: number;
|
|
171
|
+
torsoHeight: number;
|
|
166
172
|
figure: number;
|
|
167
173
|
}
|
|
168
174
|
export declare const CANONICAL_PLUP_BODY: PlupBody;
|
package/dist/three.js
CHANGED
|
@@ -2,10 +2,6 @@ import {
|
|
|
2
2
|
BLOB_HEIGHT,
|
|
3
3
|
BLOB_RADIUS,
|
|
4
4
|
BLOB_SEAT,
|
|
5
|
-
FIGURE_HIP_Y,
|
|
6
|
-
FIGURE_SHOULDER_Y,
|
|
7
|
-
FIGURE_TORSO_MAX_Y,
|
|
8
|
-
FIGURE_TORSO_MIN_Y,
|
|
9
5
|
blobRadiusAt,
|
|
10
6
|
buildBlobGeometry,
|
|
11
7
|
buildFigureHeadGeometry,
|
|
@@ -13,8 +9,9 @@ import {
|
|
|
13
9
|
figureHeadMetrics,
|
|
14
10
|
figureHeadRadiusAt,
|
|
15
11
|
figureTorsoPoint,
|
|
16
|
-
figureTorsoRadiusAt
|
|
17
|
-
|
|
12
|
+
figureTorsoRadiusAt,
|
|
13
|
+
figureTorsoSpan
|
|
14
|
+
} from "./chunk-x8f5p1qg.js";
|
|
18
15
|
import {
|
|
19
16
|
ANIME_FACE_SIZE,
|
|
20
17
|
ANIME_FACE_UV,
|
|
@@ -26,7 +23,7 @@ import {
|
|
|
26
23
|
RAGDOLL_JOINTS,
|
|
27
24
|
createRagdoll,
|
|
28
25
|
emoteOf
|
|
29
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-s083mv4f.js";
|
|
30
27
|
import {
|
|
31
28
|
WEARABLES,
|
|
32
29
|
hairVolume,
|
|
@@ -40,7 +37,7 @@ import {
|
|
|
40
37
|
clampPlupBody,
|
|
41
38
|
nativePartOf,
|
|
42
39
|
scaleBone
|
|
43
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-phwn2cn7.js";
|
|
44
41
|
import {
|
|
45
42
|
AUTHORED_CLIPS,
|
|
46
43
|
RIGS,
|
|
@@ -48,7 +45,7 @@ import {
|
|
|
48
45
|
mergePoses,
|
|
49
46
|
resolvePose,
|
|
50
47
|
sampleClip
|
|
51
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-wryfx2sg.js";
|
|
52
49
|
import {
|
|
53
50
|
BODY_HEIGHT,
|
|
54
51
|
BODY_SHAPES,
|
|
@@ -79,6 +76,7 @@ import {
|
|
|
79
76
|
CanvasTexture as CanvasTexture2,
|
|
80
77
|
CapsuleGeometry,
|
|
81
78
|
Color as Color2,
|
|
79
|
+
CylinderGeometry as CylinderGeometry2,
|
|
82
80
|
DoubleSide,
|
|
83
81
|
Group as Group2,
|
|
84
82
|
Mesh as Mesh2,
|
|
@@ -2631,9 +2629,11 @@ function createPlup(options = {}) {
|
|
|
2631
2629
|
hips: build.hips,
|
|
2632
2630
|
bust: build.bust,
|
|
2633
2631
|
muscle: build.muscle,
|
|
2632
|
+
torsoHeight: build.torsoHeight,
|
|
2634
2633
|
figure: build.figure
|
|
2635
2634
|
};
|
|
2636
|
-
const
|
|
2635
|
+
const span = figureTorsoSpan(build.torsoHeight);
|
|
2636
|
+
const legRaise = isFigure ? Math.max(0.14, 0.28 + 0.16 * (build.legLength - 1)) : Math.max(0, 0.16 * (build.legLength - 1));
|
|
2637
2637
|
const canvas = document.createElement("canvas");
|
|
2638
2638
|
canvas.width = BODY_WIDTH * 4;
|
|
2639
2639
|
canvas.height = BODY_HEIGHT * 4;
|
|
@@ -2653,7 +2653,7 @@ function createPlup(options = {}) {
|
|
|
2653
2653
|
const root = new Group2;
|
|
2654
2654
|
const lifted = new Group2;
|
|
2655
2655
|
root.add(lifted);
|
|
2656
|
-
const headMetrics = figureHeadMetrics(build.headSize);
|
|
2656
|
+
const headMetrics = figureHeadMetrics(build.headSize, build.torsoHeight);
|
|
2657
2657
|
const geometry = isFigure ? buildFigureHeadGeometry() : buildBlobGeometry(silhouette);
|
|
2658
2658
|
const torsoGeometry = isFigure ? buildFigureTorsoGeometry(silhouette) : null;
|
|
2659
2659
|
const headGroup = new Group2;
|
|
@@ -2693,13 +2693,13 @@ function createPlup(options = {}) {
|
|
|
2693
2693
|
const headWearRoot = new Group2;
|
|
2694
2694
|
const bodyWearRoot = new Group2;
|
|
2695
2695
|
if (isFigure) {
|
|
2696
|
-
|
|
2697
|
-
|
|
2696
|
+
headGroup.add(headWearRoot);
|
|
2697
|
+
lifted.add(bodyWearRoot);
|
|
2698
2698
|
} else {
|
|
2699
2699
|
headWearRoot.scale.set(fit.girth / shape.x, clampBodyScale(options.bodyScale).head, fit.girth / shape.x);
|
|
2700
2700
|
bodyWearRoot.scale.copy(headWearRoot.scale);
|
|
2701
|
+
lifted.add(headWearRoot, bodyWearRoot);
|
|
2701
2702
|
}
|
|
2702
|
-
lifted.add(headWearRoot, bodyWearRoot);
|
|
2703
2703
|
const worn = new Map;
|
|
2704
2704
|
const headKit = {
|
|
2705
2705
|
radiusAt: (y) => isFigure ? figureHeadRadiusAt(y) : blobRadiusAt(y, silhouette),
|
|
@@ -2725,12 +2725,12 @@ function createPlup(options = {}) {
|
|
|
2725
2725
|
hairColor: options.hairColor,
|
|
2726
2726
|
isFigure,
|
|
2727
2727
|
zones: isFigure ? {
|
|
2728
|
-
bottomY:
|
|
2729
|
-
hipY: 0.
|
|
2730
|
-
waistY:
|
|
2731
|
-
bustY:
|
|
2732
|
-
shoulderY:
|
|
2733
|
-
neckY:
|
|
2728
|
+
bottomY: span.minY,
|
|
2729
|
+
hipY: span.hipY + 0.05 * build.torsoHeight,
|
|
2730
|
+
waistY: span.waistY,
|
|
2731
|
+
bustY: span.bustY,
|
|
2732
|
+
shoulderY: span.shoulderY,
|
|
2733
|
+
neckY: span.maxY - 0.08 * build.torsoHeight
|
|
2734
2734
|
} : {
|
|
2735
2735
|
bottomY: 0.04,
|
|
2736
2736
|
hipY: 0.14,
|
|
@@ -2814,6 +2814,81 @@ function createPlup(options = {}) {
|
|
|
2814
2814
|
mesh.raycast = () => {};
|
|
2815
2815
|
lifted.add(pivot);
|
|
2816
2816
|
};
|
|
2817
|
+
const subPivots = { elbowL: null, elbowR: null, kneeL: null, kneeR: null };
|
|
2818
|
+
let figureLegLen = 0.44;
|
|
2819
|
+
const articulatedArm = (name, elbowKey, x, y, length) => {
|
|
2820
|
+
const pivot = pivots[name];
|
|
2821
|
+
pivot.position.set(x, y, 0);
|
|
2822
|
+
const upperLen = length * 0.5;
|
|
2823
|
+
const lowerLen = length * 0.5;
|
|
2824
|
+
const mScale = build.muscle > 1 ? 1 + (build.muscle - 1) * 0.42 : 0.84 + build.muscle * 0.16;
|
|
2825
|
+
const rTop = 0.046 * mScale;
|
|
2826
|
+
const rMid = 0.04 * mScale;
|
|
2827
|
+
const rWrist = 0.03 * mScale;
|
|
2828
|
+
const upperGeo = new CylinderGeometry2(rTop, rMid, upperLen, 12, 1);
|
|
2829
|
+
upperGeo.translate(0, -upperLen / 2, 0);
|
|
2830
|
+
const jointGeo = new SphereGeometry3(rMid * 1.04, 10, 8);
|
|
2831
|
+
const lowerGeo = new CylinderGeometry2(rMid, rWrist, lowerLen, 12, 1);
|
|
2832
|
+
lowerGeo.translate(0, -lowerLen / 2, 0);
|
|
2833
|
+
armGeometries.push(upperGeo, jointGeo, lowerGeo);
|
|
2834
|
+
const upperMesh = new Mesh2(upperGeo, limbMaterial);
|
|
2835
|
+
const upperInk = new Mesh2(upperGeo, figureInk);
|
|
2836
|
+
const jointMesh = new Mesh2(jointGeo, limbMaterial);
|
|
2837
|
+
jointMesh.position.y = -upperLen;
|
|
2838
|
+
const elbow = new Group2;
|
|
2839
|
+
elbow.position.set(0, -upperLen, 0);
|
|
2840
|
+
const lowerMesh = new Mesh2(lowerGeo, limbMaterial);
|
|
2841
|
+
const lowerInk = new Mesh2(lowerGeo, figureInk);
|
|
2842
|
+
const hand = new Mesh2(handGeometry, tipMaterial);
|
|
2843
|
+
hand.position.y = -lowerLen;
|
|
2844
|
+
hand.scale.setScalar(0.92 + Math.max(0, build.muscle - 1) * 0.22);
|
|
2845
|
+
const handInk = new Mesh2(handGeometry, figureInk);
|
|
2846
|
+
handInk.position.copy(hand.position);
|
|
2847
|
+
handInk.scale.copy(hand.scale);
|
|
2848
|
+
elbow.add(lowerMesh, lowerInk, hand, handInk);
|
|
2849
|
+
pivot.add(upperMesh, upperInk, jointMesh, elbow);
|
|
2850
|
+
for (const m of [...pivot.children, ...elbow.children])
|
|
2851
|
+
m.raycast = () => {};
|
|
2852
|
+
subPivots[elbowKey] = elbow;
|
|
2853
|
+
lifted.add(pivot);
|
|
2854
|
+
};
|
|
2855
|
+
const articulatedLeg = (name, kneeKey, x, y, length) => {
|
|
2856
|
+
const pivot = pivots[name];
|
|
2857
|
+
pivot.position.set(x, y, 0);
|
|
2858
|
+
const upperLen = length * 0.52;
|
|
2859
|
+
const lowerLen = length * 0.48;
|
|
2860
|
+
const thighBoost = 1 + Math.max(0, build.hips - 1) * 0.36 + Math.max(0, build.muscle - 1) * 0.22;
|
|
2861
|
+
const compact = Math.min(1, 0.65 + 0.35 * build.torsoHeight);
|
|
2862
|
+
const rHip = 0.072 * thighBoost * compact;
|
|
2863
|
+
const rKnee = 0.048 * (0.85 + 0.15 * thighBoost) * compact;
|
|
2864
|
+
const rAnkle = 0.036 * compact;
|
|
2865
|
+
const thighGeo = new CylinderGeometry2(rHip, rKnee, upperLen, 12, 1);
|
|
2866
|
+
thighGeo.translate(0, -upperLen / 2, 0);
|
|
2867
|
+
const jointGeo = new SphereGeometry3(rKnee * 1.03, 10, 8);
|
|
2868
|
+
const shinGeo = new CylinderGeometry2(rKnee, rAnkle, lowerLen, 12, 1);
|
|
2869
|
+
shinGeo.translate(0, -lowerLen / 2, 0);
|
|
2870
|
+
armGeometries.push(thighGeo, jointGeo, shinGeo);
|
|
2871
|
+
const thighMesh = new Mesh2(thighGeo, legMaterial);
|
|
2872
|
+
const thighInk = new Mesh2(thighGeo, figureInk);
|
|
2873
|
+
const jointMesh = new Mesh2(jointGeo, legMaterial);
|
|
2874
|
+
jointMesh.position.y = -upperLen;
|
|
2875
|
+
const knee = new Group2;
|
|
2876
|
+
knee.position.set(0, -upperLen, 0);
|
|
2877
|
+
const shinMesh = new Mesh2(shinGeo, legMaterial);
|
|
2878
|
+
const shinInk = new Mesh2(shinGeo, figureInk);
|
|
2879
|
+
const shoe = new Mesh2(footGeometry, shoeMaterial);
|
|
2880
|
+
shoe.position.set(0, -lowerLen, 0.025 * compact);
|
|
2881
|
+
shoe.scale.set(1.02 * compact, 0.62 * compact, 1.58 * compact);
|
|
2882
|
+
const shoeInk = new Mesh2(footGeometry, figureInk);
|
|
2883
|
+
shoeInk.position.copy(shoe.position);
|
|
2884
|
+
shoeInk.scale.copy(shoe.scale);
|
|
2885
|
+
knee.add(shinMesh, shinInk, shoe, shoeInk);
|
|
2886
|
+
pivot.add(thighMesh, thighInk, jointMesh, knee);
|
|
2887
|
+
for (const m of [...pivot.children, ...knee.children])
|
|
2888
|
+
m.raycast = () => {};
|
|
2889
|
+
subPivots[kneeKey] = knee;
|
|
2890
|
+
lifted.add(pivot);
|
|
2891
|
+
};
|
|
2817
2892
|
if (options.model) {
|
|
2818
2893
|
lifted.add(options.model);
|
|
2819
2894
|
for (const name of Object.keys(pivots)) {
|
|
@@ -2822,20 +2897,20 @@ function createPlup(options = {}) {
|
|
|
2822
2897
|
pivots[name] = found;
|
|
2823
2898
|
}
|
|
2824
2899
|
} else if (isFigure) {
|
|
2825
|
-
const shPt = figureTorsoPoint(
|
|
2826
|
-
const shoulderX = Math.max(0.
|
|
2827
|
-
const arm = 0.34 * build.armLength;
|
|
2828
|
-
const hipAnchorY =
|
|
2900
|
+
const shPt = figureTorsoPoint(span.shoulderY, Math.PI / 2, silhouette);
|
|
2901
|
+
const shoulderX = Math.max(0.11, shPt.x * 0.92);
|
|
2902
|
+
const arm = 0.34 * build.armLength * (0.72 + 0.28 * build.torsoHeight);
|
|
2903
|
+
const hipAnchorY = span.hipY + 0.05 * build.torsoHeight;
|
|
2829
2904
|
const hipPt = figureTorsoPoint(hipAnchorY, Math.PI / 2, silhouette);
|
|
2830
|
-
const hipX = Math.max(0.
|
|
2831
|
-
const leg = Math.max(0.
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
pivots.armL.scale.set(fit.armWidth[0]
|
|
2838
|
-
pivots.armR.scale.set(fit.armWidth[1]
|
|
2905
|
+
const hipX = Math.max(0.065, hipPt.x * 0.46);
|
|
2906
|
+
const leg = Math.max(0.24, legRaise + hipAnchorY - 0.02);
|
|
2907
|
+
figureLegLen = leg;
|
|
2908
|
+
articulatedArm("armL", "elbowL", -shoulderX, span.shoulderY, arm);
|
|
2909
|
+
articulatedArm("armR", "elbowR", shoulderX, span.shoulderY, arm);
|
|
2910
|
+
articulatedLeg("legL", "kneeL", -hipX, hipAnchorY, leg);
|
|
2911
|
+
articulatedLeg("legR", "kneeR", hipX, hipAnchorY, leg);
|
|
2912
|
+
pivots.armL.scale.set(fit.armWidth[0], 1, fit.armWidth[0]);
|
|
2913
|
+
pivots.armR.scale.set(fit.armWidth[1], 1, fit.armWidth[1]);
|
|
2839
2914
|
pivots.legL.scale.set(fit.legWidth[0], 1, fit.legWidth[0]);
|
|
2840
2915
|
pivots.legR.scale.set(fit.legWidth[1], 1, fit.legWidth[1]);
|
|
2841
2916
|
} else {
|
|
@@ -2886,8 +2961,124 @@ function createPlup(options = {}) {
|
|
|
2886
2961
|
let seconds = 0;
|
|
2887
2962
|
let clock = 0;
|
|
2888
2963
|
let lastDelta = 0;
|
|
2964
|
+
const danceKinematics = (active, t) => {
|
|
2965
|
+
const out = {
|
|
2966
|
+
elbowLx: -0.14,
|
|
2967
|
+
elbowLz: 0,
|
|
2968
|
+
elbowRx: -0.14,
|
|
2969
|
+
elbowRz: 0,
|
|
2970
|
+
kneeL: 0,
|
|
2971
|
+
kneeR: 0,
|
|
2972
|
+
hipX: 0,
|
|
2973
|
+
crouch: 0,
|
|
2974
|
+
squash: 0
|
|
2975
|
+
};
|
|
2976
|
+
if (typeof active !== "string")
|
|
2977
|
+
return out;
|
|
2978
|
+
const TAU = Math.PI * 2;
|
|
2979
|
+
const smooth01 = (v) => {
|
|
2980
|
+
const c = Math.max(0, Math.min(1, v));
|
|
2981
|
+
return c * c * (3 - 2 * c);
|
|
2982
|
+
};
|
|
2983
|
+
if (active === "brazil-funk") {
|
|
2984
|
+
const p = t % 1.6 / 1.6;
|
|
2985
|
+
const beat = 0.5 - 0.5 * Math.cos(p * TAU * 4);
|
|
2986
|
+
const sway = Math.sin(p * TAU * 2);
|
|
2987
|
+
out.elbowLx = -1.45 - 0.3 * Math.max(0, sway);
|
|
2988
|
+
out.elbowLz = 0.42 + 0.18 * sway;
|
|
2989
|
+
out.elbowRx = -1.45 - 0.3 * Math.max(0, -sway);
|
|
2990
|
+
out.elbowRz = -0.42 + 0.18 * sway;
|
|
2991
|
+
out.kneeL = 0.52 * beat + 0.18 * Math.max(0, sway);
|
|
2992
|
+
out.kneeR = 0.52 * beat + 0.18 * Math.max(0, -sway);
|
|
2993
|
+
out.hipX = sway * 0.11;
|
|
2994
|
+
out.crouch = 0.085 * beat;
|
|
2995
|
+
out.squash = -0.042 * beat + 0.018;
|
|
2996
|
+
} else if (active === "pacu-jalur") {
|
|
2997
|
+
const p = t % 2.4 / 2.4;
|
|
2998
|
+
const wave = Math.sin(p * TAU);
|
|
2999
|
+
const bounce = 0.5 - 0.5 * Math.cos(p * TAU * 2);
|
|
3000
|
+
out.elbowLx = -1.15 - 0.38 * wave;
|
|
3001
|
+
out.elbowLz = 0.35 + 0.38 * wave;
|
|
3002
|
+
out.elbowRx = -1.15 + 0.38 * wave;
|
|
3003
|
+
out.elbowRz = -0.35 + 0.38 * wave;
|
|
3004
|
+
out.kneeL = 0.52 + 0.22 * bounce + 0.12 * Math.max(0, wave);
|
|
3005
|
+
out.kneeR = 0.52 + 0.22 * bounce + 0.12 * Math.max(0, -wave);
|
|
3006
|
+
out.hipX = wave * 0.1;
|
|
3007
|
+
out.crouch = 0.095 + 0.055 * bounce;
|
|
3008
|
+
out.squash = -0.032 * bounce + 0.014;
|
|
3009
|
+
} else if (active === "velocity") {
|
|
3010
|
+
const p = t % 2 / 2;
|
|
3011
|
+
const hit1 = smooth01((p - 0.2) / 0.07) * (1 - smooth01((p - 0.46) / 0.12));
|
|
3012
|
+
const hit2 = smooth01((p - 0.63) / 0.07) * (1 - smooth01((p - 0.88) / 0.1));
|
|
3013
|
+
out.elbowLx = -0.55 - 1.15 * hit1 + 0.35 * hit2;
|
|
3014
|
+
out.elbowLz = 0.72 * hit1 - 0.15 * hit2;
|
|
3015
|
+
out.elbowRx = -0.55 - 1.15 * hit1 - 1.05 * hit2;
|
|
3016
|
+
out.elbowRz = -0.72 * hit1 - 0.55 * hit2;
|
|
3017
|
+
out.kneeL = 0.16 + 0.58 * hit1 + 0.22 * hit2;
|
|
3018
|
+
out.kneeR = 0.16 + 0.58 * hit1 + 0.34 * hit2;
|
|
3019
|
+
out.hipX = -0.08 * hit1 + 0.1 * hit2;
|
|
3020
|
+
out.crouch = 0.02 + 0.11 * hit1 + 0.04 * hit2;
|
|
3021
|
+
out.squash = -0.055 * hit1 + 0.028 * hit2;
|
|
3022
|
+
} else if (active === "griddy") {
|
|
3023
|
+
const p = t % 1.6 / 1.6;
|
|
3024
|
+
const goggles = 0.5 - 0.5 * Math.cos(p * TAU * 2);
|
|
3025
|
+
const step = Math.sin(p * TAU * 2);
|
|
3026
|
+
out.elbowLx = -0.25 - 1.85 * goggles;
|
|
3027
|
+
out.elbowLz = 0.46 * goggles;
|
|
3028
|
+
out.elbowRx = -0.25 - 1.85 * goggles;
|
|
3029
|
+
out.elbowRz = -0.46 * goggles;
|
|
3030
|
+
out.kneeL = 0.15 + 0.62 * Math.max(0, -step) + 0.18 * goggles;
|
|
3031
|
+
out.kneeR = 0.15 + 0.62 * Math.max(0, step) + 0.18 * goggles;
|
|
3032
|
+
out.hipX = step * 0.05;
|
|
3033
|
+
out.crouch = 0.045 + 0.055 * goggles;
|
|
3034
|
+
out.squash = -0.036 * goggles + 0.015;
|
|
3035
|
+
} else if (active === "floss") {
|
|
3036
|
+
const p = t % 1.6 / 1.6;
|
|
3037
|
+
const swing = Math.cos(p * TAU * 2);
|
|
3038
|
+
const beat = Math.abs(swing);
|
|
3039
|
+
out.elbowLx = -0.08;
|
|
3040
|
+
out.elbowRx = -0.08;
|
|
3041
|
+
out.kneeL = 0.2 + 0.16 * beat;
|
|
3042
|
+
out.kneeR = 0.2 + 0.16 * beat;
|
|
3043
|
+
out.hipX = -swing * 0.17;
|
|
3044
|
+
out.crouch = 0.035 * beat;
|
|
3045
|
+
out.squash = -0.026 * beat + 0.01;
|
|
3046
|
+
} else if (active === "caramel") {
|
|
3047
|
+
const p = t % 1.6 / 1.6;
|
|
3048
|
+
const sway = Math.cos(p * TAU);
|
|
3049
|
+
const beat = 0.5 - 0.5 * Math.cos(p * TAU * 2);
|
|
3050
|
+
const flap = Math.sin(p * TAU * 4) * 0.26;
|
|
3051
|
+
out.elbowLx = -0.35;
|
|
3052
|
+
out.elbowLz = -1.2 + flap;
|
|
3053
|
+
out.elbowRx = -0.35;
|
|
3054
|
+
out.elbowRz = 1.2 - flap;
|
|
3055
|
+
out.kneeL = 0.45 * (1 - beat) + 0.15 * Math.max(0, sway);
|
|
3056
|
+
out.kneeR = 0.45 * (1 - beat) + 0.15 * Math.max(0, -sway);
|
|
3057
|
+
out.hipX = -sway * 0.14;
|
|
3058
|
+
out.crouch = 0.075 * (1 - beat);
|
|
3059
|
+
out.squash = -0.042 * (1 - beat) + 0.024 * beat;
|
|
3060
|
+
} else if (active === "walk" || active === "run") {
|
|
3061
|
+
const rate = active === "run" ? 2.4 : 1.4;
|
|
3062
|
+
const stride = Math.sin(t * rate * TAU);
|
|
3063
|
+
const bend = active === "run" ? 0.95 : 0.42;
|
|
3064
|
+
out.elbowLx = -0.25 - Math.max(0, -stride) * bend;
|
|
3065
|
+
out.elbowRx = -0.25 - Math.max(0, stride) * bend;
|
|
3066
|
+
out.kneeL = Math.max(0, stride) * (active === "run" ? 0.95 : 0.55);
|
|
3067
|
+
out.kneeR = Math.max(0, -stride) * (active === "run" ? 0.95 : 0.55);
|
|
3068
|
+
} else if (active === "dance") {
|
|
3069
|
+
const beat = 0.5 - 0.5 * Math.cos(t * 2 * TAU);
|
|
3070
|
+
out.elbowLx = -0.65 - 0.35 * beat;
|
|
3071
|
+
out.elbowRx = -0.65 - 0.35 * beat;
|
|
3072
|
+
out.kneeL = 0.38 * beat;
|
|
3073
|
+
out.kneeR = 0.38 * beat;
|
|
3074
|
+
out.hipX = Math.sin(t * TAU) * 0.08;
|
|
3075
|
+
out.crouch = 0.05 * beat;
|
|
3076
|
+
}
|
|
3077
|
+
return out;
|
|
3078
|
+
};
|
|
2889
3079
|
const apply = () => {
|
|
2890
3080
|
const pose = resolvePose("plup", mergePoses(sampleClip(clip2, seconds), held));
|
|
3081
|
+
const kin = danceKinematics(clip2, seconds);
|
|
2891
3082
|
const byAlias = {
|
|
2892
3083
|
armL: "LeftArm",
|
|
2893
3084
|
armR: "RightArm",
|
|
@@ -2900,17 +3091,34 @@ function createPlup(options = {}) {
|
|
|
2900
3091
|
const clearance = name === "armL" ? fit.armClear[0] : name === "armR" ? -fit.armClear[1] : 0;
|
|
2901
3092
|
const z = rotation?.z ?? 0;
|
|
2902
3093
|
const side = name === "armL" ? -1 : name === "armR" ? 1 : 0;
|
|
2903
|
-
const restAngle = isFigure ? 0.
|
|
3094
|
+
const restAngle = isFigure ? 0.14 : 0.42;
|
|
2904
3095
|
const rest = options.model ? 0 : side * restAngle * Math.max(0, 1 - Math.abs(z) / 1.4);
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
3096
|
+
const kneeComp = isFigure && name === "legL" ? -kin.kneeL * 0.45 : isFigure && name === "legR" ? -kin.kneeR * 0.45 : 0;
|
|
3097
|
+
const rx = (rotation?.x ?? 0) + kneeComp;
|
|
3098
|
+
pivots[name].rotation.set(rx, rotation?.y ?? 0, z + clearance + rest);
|
|
3099
|
+
targets[name] = { x: rx, z: z + clearance + rest };
|
|
3100
|
+
}
|
|
3101
|
+
if (subPivots.elbowL)
|
|
3102
|
+
subPivots.elbowL.rotation.set(kin.elbowLx, 0, kin.elbowLz);
|
|
3103
|
+
if (subPivots.elbowR)
|
|
3104
|
+
subPivots.elbowR.rotation.set(kin.elbowRx, 0, kin.elbowRz);
|
|
3105
|
+
if (subPivots.kneeL)
|
|
3106
|
+
subPivots.kneeL.rotation.set(kin.kneeL, 0, 0);
|
|
3107
|
+
if (subPivots.kneeR)
|
|
3108
|
+
subPivots.kneeR.rotation.set(kin.kneeR, 0, 0);
|
|
2908
3109
|
const body = pose.get("Body");
|
|
3110
|
+
const head = pose.get("Head");
|
|
2909
3111
|
lifted.rotation.set(body?.x ?? 0, body?.y ?? 0, body?.z ?? 0);
|
|
2910
|
-
|
|
3112
|
+
if (isFigure) {
|
|
3113
|
+
headGroup.rotation.set(head?.x ?? 0, head?.y ?? 0, head?.z ?? 0);
|
|
3114
|
+
}
|
|
3115
|
+
const crouchDrop = isFigure ? kin.crouch * (figureLegLen / 0.44) : kin.crouch * 0.4;
|
|
3116
|
+
const clipLiftY = Math.max(0, legRaise + clipLift(clip2, seconds) * 0.32 * fit.lift - crouchDrop);
|
|
2911
3117
|
const breath = Math.sin(clock * 3.2) * (isFigure ? 0.01 : 0.018) * fit.squash;
|
|
2912
|
-
|
|
2913
|
-
|
|
3118
|
+
const sy = 1 + breath + kin.squash;
|
|
3119
|
+
const sxz = 1 / Math.sqrt(Math.max(0.75, sy));
|
|
3120
|
+
lifted.scale.set((isFigure ? 1 : shape.x) * fit.stature * sxz, (isFigure ? 1 : shape.y) * fit.stature * sy, (isFigure ? 1 : shape.x) * fit.stature * sxz);
|
|
3121
|
+
lifted.position.set(kin.hipX, clipLiftY, 0);
|
|
2914
3122
|
if (ragdoll) {
|
|
2915
3123
|
root.getWorldPosition(here);
|
|
2916
3124
|
const step2 = Math.max(0.001, lastDelta);
|
package/package.json
CHANGED