@lemoncat7/dsh-theme-xiaohei 0.4.6 → 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/README.md +15 -9
- package/THIRD_PARTY_NOTICES.md +13 -1
- package/docs/dsh-021-compatibility.md +23 -0
- package/docs/releases/0.5.0.md +24 -0
- package/docs/rift-interaction.md +35 -0
- package/docs/rift-preview.md +39 -0
- package/lib/client.companion.js +3 -4
- package/lib/client.decorations.js +224 -51
- package/lib/client.js +532 -2405
- package/lib/index.d.ts +1 -2
- package/lib/index.js +393 -11
- package/lib/rift/boot.d.ts +6 -0
- package/package.json +29 -19
- package/lib/appearance.d.ts +0 -12
- package/lib/appearance.js +0 -42
- package/lib/blink.d.ts +0 -4
- package/lib/blink.js +0 -110
- package/lib/bloub-heixiu/ambient.d.ts +0 -3
- package/lib/bloub-heixiu/ambient.js +0 -12
- package/lib/bloub-heixiu/character.d.ts +0 -33
- package/lib/bloub-heixiu/character.js +0 -124
- package/lib/bloub-heixiu/effects.d.ts +0 -4
- package/lib/bloub-heixiu/effects.js +0 -91
- package/lib/bloub-heixiu/flight.d.ts +0 -15
- package/lib/bloub-heixiu/flight.js +0 -66
- package/lib/bloub-heixiu/follow.d.ts +0 -13
- package/lib/bloub-heixiu/follow.js +0 -23
- package/lib/bloub-heixiu/layout.d.ts +0 -34
- package/lib/bloub-heixiu/layout.js +0 -26
- package/lib/bloub-heixiu/renderer.d.ts +0 -16
- package/lib/bloub-heixiu/renderer.js +0 -94
- package/lib/bloub-heixiu/runtime.d.ts +0 -6
- package/lib/bloub-heixiu/runtime.js +0 -440
- package/lib/bloub-heixiu/signals.d.ts +0 -17
- package/lib/bloub-heixiu/signals.js +0 -55
- package/lib/bloub-heixiu/styles.d.ts +0 -2
- package/lib/bloub-heixiu/styles.js +0 -98
- package/lib/boot-appearance.d.ts +0 -10
- package/lib/boot-appearance.js +0 -47
- package/lib/boot-loader.d.ts +0 -5
- package/lib/boot-loader.js +0 -158
- package/lib/chrome/accessibility.d.ts +0 -3
- package/lib/chrome/accessibility.js +0 -69
- package/lib/chrome/blink.d.ts +0 -3
- package/lib/chrome/blink.js +0 -15
- package/lib/chrome/composer-avatar.d.ts +0 -10
- package/lib/chrome/composer-avatar.js +0 -599
- package/lib/chrome/composer-send-heixiu.d.ts +0 -3
- package/lib/chrome/composer-send-heixiu.js +0 -143
- package/lib/chrome/composer.d.ts +0 -3
- package/lib/chrome/composer.js +0 -135
- package/lib/chrome/controls.d.ts +0 -8
- package/lib/chrome/controls.js +0 -348
- package/lib/chrome/conversation-messages.d.ts +0 -3
- package/lib/chrome/conversation-messages.js +0 -329
- package/lib/chrome/conversation-submissions.d.ts +0 -3
- package/lib/chrome/conversation-submissions.js +0 -68
- package/lib/chrome/conversation.d.ts +0 -3
- package/lib/chrome/conversation.js +0 -67
- package/lib/chrome/frames.d.ts +0 -6
- package/lib/chrome/frames.js +0 -134
- package/lib/chrome/gaze.d.ts +0 -3
- package/lib/chrome/gaze.js +0 -103
- package/lib/chrome/identity.d.ts +0 -6
- package/lib/chrome/identity.js +0 -47
- package/lib/chrome/overlays.d.ts +0 -3
- package/lib/chrome/overlays.js +0 -104
- package/lib/chrome/portal.d.ts +0 -6
- package/lib/chrome/portal.js +0 -169
- package/lib/chrome/reactions.d.ts +0 -3
- package/lib/chrome/reactions.js +0 -85
- package/lib/chrome/sidebar.d.ts +0 -3
- package/lib/chrome/sidebar.js +0 -313
- package/lib/chrome/tokens.d.ts +0 -3
- package/lib/chrome/tokens.js +0 -224
- package/lib/chrome/workspace.d.ts +0 -3
- package/lib/chrome/workspace.js +0 -94
- package/lib/chrome.d.ts +0 -10
- package/lib/chrome.js +0 -46
- package/lib/client-entry.d.ts +0 -3
- package/lib/client-entry.js +0 -3
- package/lib/client.d.ts +0 -10
- package/lib/client.pose-chin-dark.js +0 -4
- package/lib/client.pose-chin-light.js +0 -4
- package/lib/client.pose-doze-dark.js +0 -4
- package/lib/client.pose-doze-light.js +0 -4
- package/lib/client.pose-halfpeek-dark.js +0 -4
- package/lib/client.pose-halfpeek-light.js +0 -4
- package/lib/client.pose-peek-dark.js +0 -4
- package/lib/client.pose-peek-light.js +0 -4
- package/lib/client.pose-seated-dark.js +0 -4
- package/lib/client.pose-seated-light.js +0 -4
- package/lib/client.rig-chin-dark.js +0 -4
- package/lib/client.rig-chin-light.js +0 -4
- package/lib/client.rig-halfpeek-dark.js +0 -4
- package/lib/client.rig-halfpeek-light.js +0 -4
- package/lib/client.rig-peek-dark.js +0 -4
- package/lib/client.rig-peek-light.js +0 -4
- package/lib/client.rig-seated-dark.js +0 -4
- package/lib/client.rig-seated-light.js +0 -4
- package/lib/companion-entry.d.ts +0 -3
- package/lib/companion-entry.js +0 -3
- package/lib/composer-avatar.d.ts +0 -18
- package/lib/composer-avatar.js +0 -441
- package/lib/composer-draft-preview.d.ts +0 -4
- package/lib/composer-draft-preview.js +0 -8
- package/lib/composer-send-heixiu.d.ts +0 -8
- package/lib/composer-send-heixiu.js +0 -133
- package/lib/current-session.d.ts +0 -6
- package/lib/current-session.js +0 -5
- package/lib/decorations-entry.d.ts +0 -3
- package/lib/decorations-entry.js +0 -18
- package/lib/deferred-companion.d.ts +0 -5
- package/lib/deferred-companion.js +0 -9
- package/lib/deferred-decorations.d.ts +0 -3
- package/lib/deferred-decorations.js +0 -51
- package/lib/gaze.d.ts +0 -4
- package/lib/gaze.js +0 -230
- package/lib/generated-backgrounds.d.ts +0 -14
- package/lib/generated-backgrounds.js +0 -14
- package/lib/generated-character-motion.d.ts +0 -4
- package/lib/generated-character-motion.js +0 -2
- package/lib/generated-identity.d.ts +0 -6
- package/lib/generated-identity.js +0 -6
- package/lib/generated-keyart.d.ts +0 -34
- package/lib/generated-keyart.js +0 -34
- package/lib/generated-loading-assets.d.ts +0 -4
- package/lib/generated-loading-assets.js +0 -4
- package/lib/heixiu-interactions.d.ts +0 -10
- package/lib/heixiu-interactions.js +0 -161
- package/lib/host-contract.d.ts +0 -9
- package/lib/host-contract.js +0 -13
- package/lib/host-dom.d.ts +0 -11
- package/lib/host-dom.js +0 -72
- package/lib/loading-heixiu.d.ts +0 -8
- package/lib/loading-heixiu.js +0 -287
- package/lib/metallic-brand-mark.d.ts +0 -10
- package/lib/metallic-brand-mark.js +0 -296
- package/lib/plugin.d.ts +0 -6
- package/lib/plugin.js +0 -60
- package/lib/portal.d.ts +0 -40
- package/lib/portal.js +0 -225
- package/lib/reactions.d.ts +0 -20
- package/lib/reactions.js +0 -380
- package/lib/scene/avatar-model.d.ts +0 -6
- package/lib/scene/avatar-model.js +0 -646
- package/lib/scene/avatar-motion.d.ts +0 -3
- package/lib/scene/avatar-motion.js +0 -799
- package/lib/scene/character-assets.d.ts +0 -13
- package/lib/scene/character-assets.js +0 -26
- package/lib/scene/character-expression.d.ts +0 -4
- package/lib/scene/character-expression.js +0 -15
- package/lib/scene/character-eye-material.d.ts +0 -13
- package/lib/scene/character-eye-material.js +0 -88
- package/lib/scene/character-eye-renderer.d.ts +0 -5
- package/lib/scene/character-eye-renderer.js +0 -80
- package/lib/scene/character-eye-rig.d.ts +0 -20
- package/lib/scene/character-eye-rig.js +0 -35
- package/lib/scene/character-gaze.d.ts +0 -16
- package/lib/scene/character-gaze.js +0 -36
- package/lib/scene/character-idle.d.ts +0 -17
- package/lib/scene/character-idle.js +0 -65
- package/lib/scene/character-layout.d.ts +0 -24
- package/lib/scene/character-layout.js +0 -51
- package/lib/scene/character-motion-clock.d.ts +0 -18
- package/lib/scene/character-motion-clock.js +0 -70
- package/lib/scene/character-motion-types.d.ts +0 -12
- package/lib/scene/character-motion-types.js +0 -2
- package/lib/scene/character-motion.d.ts +0 -6
- package/lib/scene/character-motion.js +0 -187
- package/lib/scene/character-poses.d.ts +0 -26
- package/lib/scene/character-poses.js +0 -11
- package/lib/scene/character-rig-renderer.d.ts +0 -5
- package/lib/scene/character-rig-renderer.js +0 -95
- package/lib/scene/character-rig.d.ts +0 -22
- package/lib/scene/character-rig.js +0 -61
- package/lib/scene/heixiu-feedback.d.ts +0 -3
- package/lib/scene/heixiu-feedback.js +0 -64
- package/lib/scene/heixiu-interactions.d.ts +0 -3
- package/lib/scene/heixiu-interactions.js +0 -92
- package/lib/scene/ids.d.ts +0 -5
- package/lib/scene/ids.js +0 -5
- package/lib/scene/pointer-bridge.d.ts +0 -21
- package/lib/scene/pointer-bridge.js +0 -155
- package/lib/scene/runtime.d.ts +0 -12
- package/lib/scene/runtime.js +0 -74
- package/lib/scene/state-transitions.d.ts +0 -3
- package/lib/scene/state-transitions.js +0 -37
- package/lib/scene/styles.d.ts +0 -5
- package/lib/scene/styles.js +0 -69
- package/lib/scene/sylva-performance.d.ts +0 -11
- package/lib/scene/sylva-performance.js +0 -58
- package/lib/scene/wallpaper-character-styles.d.ts +0 -3
- package/lib/scene/wallpaper-character-styles.js +0 -49
- package/lib/scene/wallpaper-character.d.ts +0 -5
- package/lib/scene/wallpaper-character.js +0 -222
- package/lib/scene.d.ts +0 -8
- package/lib/scene.js +0 -8
- package/lib/sidebar-glass.d.ts +0 -16
- package/lib/sidebar-glass.js +0 -168
- package/lib/sidebar-heixiu-escape.d.ts +0 -44
- package/lib/sidebar-heixiu-escape.js +0 -340
- package/lib/sidebar-heixiu-roaming.d.ts +0 -27
- package/lib/sidebar-heixiu-roaming.js +0 -310
- package/lib/sidebar-reveal.d.ts +0 -8
- package/lib/sidebar-reveal.js +0 -59
- package/lib/state.d.ts +0 -21
- package/lib/state.js +0 -123
- package/lib/theme.d.ts +0 -19
- package/lib/theme.js +0 -188
- package/lib/vendor/bloub/decor.d.ts +0 -114
- package/lib/vendor/bloub/decor.js +0 -198
- package/lib/vendor/bloub/engine.d.ts +0 -213
- package/lib/vendor/bloub/engine.js +0 -452
- package/lib/vendor/bloub/expressions.d.ts +0 -35
- package/lib/vendor/bloub/expressions.js +0 -143
- package/lib/vendor/bloub/eyefit.d.ts +0 -75
- package/lib/vendor/bloub/eyefit.js +0 -393
- package/lib/vendor/bloub/face.d.ts +0 -63
- package/lib/vendor/bloub/face.js +0 -106
- package/lib/vendor/bloub/math.d.ts +0 -22
- package/lib/vendor/bloub/math.js +0 -36
- package/lib/vendor/bloub/profiles.d.ts +0 -8
- package/lib/vendor/bloub/profiles.js +0 -20
- package/lib/vendor/bloub/repere.d.ts +0 -30
- package/lib/vendor/bloub/repere.js +0 -32
- package/lib/vendor/bloub/shape.d.ts +0 -80
- package/lib/vendor/bloub/shape.js +0 -268
- package/lib/vendor/bloub/skins.d.ts +0 -36
- package/lib/vendor/bloub/skins.js +0 -74
- package/lib/vendor/bloub/states.d.ts +0 -87
- package/lib/vendor/bloub/states.js +0 -468
|
@@ -1,799 +0,0 @@
|
|
|
1
|
-
/** Runtime helpers inserted beside the Xiaohei model in ThreeUI's own r149 scene. */
|
|
2
|
-
export const XIAOHEI_AVATAR_MOTION_RUNTIME = `
|
|
3
|
-
var xiaoheiMotionEuler = new THREE.Euler();
|
|
4
|
-
var xiaoheiMotionDeltaQ = new THREE.Quaternion();
|
|
5
|
-
var xiaoheiMotionPoseQ = new THREE.Quaternion();
|
|
6
|
-
var xiaoheiMotionArmDown = {
|
|
7
|
-
leftUpper: new THREE.Quaternion(0.54427280, 0.01192567, 0.03342154, 0.83815747),
|
|
8
|
-
rightUpper: new THREE.Quaternion(0.54406160, -0.01540707, -0.03727146, 0.83807547),
|
|
9
|
-
leftLower: new THREE.Quaternion(0, 0, 0, 1),
|
|
10
|
-
rightLower: new THREE.Quaternion(0, 0, 0, 1)
|
|
11
|
-
};
|
|
12
|
-
var xiaoheiMotionSitArms = {
|
|
13
|
-
leftUpper: new THREE.Quaternion(0.42277680, 0.04837124, 0.43673194, 0.79258139),
|
|
14
|
-
rightUpper: new THREE.Quaternion(0.58108784, 0.00464093, 0.18044704, 0.79357061),
|
|
15
|
-
leftLower: new THREE.Quaternion(0.00485389, -0.02619754, 0.18480416, 0.98241418),
|
|
16
|
-
rightLower: new THREE.Quaternion(0.12449678, 0.00258430, -0.01948060, 0.99202538)
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
function xiaoheiMotionSmoothstep(a, b, value) {
|
|
20
|
-
var t = Math.max(0, Math.min(1, (value - a) / (b - a)));
|
|
21
|
-
return t * t * (3 - 2 * t);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function xiaoheiAvatarFindLegRegions(geometry, height) {
|
|
25
|
-
var position = geometry.getAttribute('position');
|
|
26
|
-
var index = geometry.getIndex();
|
|
27
|
-
var parent = new Int32Array(position.count);
|
|
28
|
-
for (var vertex = 0; vertex < position.count; vertex += 1) parent[vertex] = vertex;
|
|
29
|
-
|
|
30
|
-
function find(vertexIndex) {
|
|
31
|
-
var root = vertexIndex;
|
|
32
|
-
while (parent[root] !== root) root = parent[root];
|
|
33
|
-
while (parent[vertexIndex] !== vertexIndex) {
|
|
34
|
-
var next = parent[vertexIndex];
|
|
35
|
-
parent[vertexIndex] = root;
|
|
36
|
-
vertexIndex = next;
|
|
37
|
-
}
|
|
38
|
-
return root;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function join(first, second) {
|
|
42
|
-
var firstRoot = find(first);
|
|
43
|
-
var secondRoot = find(second);
|
|
44
|
-
if (firstRoot !== secondRoot) parent[secondRoot] = firstRoot;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (index) {
|
|
48
|
-
for (var offset = 0; offset < index.count; offset += 3) {
|
|
49
|
-
var first = index.getX(offset);
|
|
50
|
-
join(first, index.getX(offset + 1));
|
|
51
|
-
join(first, index.getX(offset + 2));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
var regions = Object.create(null);
|
|
56
|
-
for (vertex = 0; vertex < position.count; vertex += 1) {
|
|
57
|
-
var root = find(vertex);
|
|
58
|
-
var x = position.getX(vertex) / height;
|
|
59
|
-
var y = position.getY(vertex) / height;
|
|
60
|
-
var region = regions[root];
|
|
61
|
-
if (!region) {
|
|
62
|
-
region = regions[root] = { minX: x, maxX: x, minY: y, maxY: y };
|
|
63
|
-
} else {
|
|
64
|
-
region.minX = Math.min(region.minX, x);
|
|
65
|
-
region.maxX = Math.max(region.maxX, x);
|
|
66
|
-
region.minY = Math.min(region.minY, y);
|
|
67
|
-
region.maxY = Math.max(region.maxY, y);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
var legSide = new Int8Array(position.count);
|
|
72
|
-
for (vertex = 0; vertex < position.count; vertex += 1) {
|
|
73
|
-
root = find(vertex);
|
|
74
|
-
region = regions[root];
|
|
75
|
-
/* The shorts are built from separate side panels too. Keep every island
|
|
76
|
-
that rises into the garment on the pelvis, otherwise the two panels
|
|
77
|
-
rotate like rigid armour plates when a thigh swings. */
|
|
78
|
-
if (region.minY >= 0.36 || region.maxY >= 0.44) continue;
|
|
79
|
-
if (region.maxX < 0.012 && region.minX > -0.19) legSide[vertex] = -1;
|
|
80
|
-
else if (region.minX > -0.012 && region.maxX < 0.19) legSide[vertex] = 1;
|
|
81
|
-
}
|
|
82
|
-
return legSide;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function xiaoheiAvatarBuildRig(geometry, height) {
|
|
86
|
-
var bones = {
|
|
87
|
-
root: new THREE.Bone(),
|
|
88
|
-
pelvis: new THREE.Bone(),
|
|
89
|
-
spine: new THREE.Bone(),
|
|
90
|
-
chest: new THREE.Bone(),
|
|
91
|
-
neck: new THREE.Bone(),
|
|
92
|
-
head: new THREE.Bone(),
|
|
93
|
-
upperArmL: new THREE.Bone(),
|
|
94
|
-
lowerArmL: new THREE.Bone(),
|
|
95
|
-
handL: new THREE.Bone(),
|
|
96
|
-
upperArmR: new THREE.Bone(),
|
|
97
|
-
lowerArmR: new THREE.Bone(),
|
|
98
|
-
handR: new THREE.Bone(),
|
|
99
|
-
upperLegL: new THREE.Bone(),
|
|
100
|
-
lowerLegL: new THREE.Bone(),
|
|
101
|
-
footL: new THREE.Bone(),
|
|
102
|
-
upperLegR: new THREE.Bone(),
|
|
103
|
-
lowerLegR: new THREE.Bone(),
|
|
104
|
-
footR: new THREE.Bone()
|
|
105
|
-
};
|
|
106
|
-
var boneNames = {
|
|
107
|
-
root: 'root',
|
|
108
|
-
pelvis: 'pelvis',
|
|
109
|
-
spine: 'spine',
|
|
110
|
-
chest: 'chest',
|
|
111
|
-
neck: 'neck',
|
|
112
|
-
head: 'head',
|
|
113
|
-
upperArmL: 'upper-arm-left',
|
|
114
|
-
lowerArmL: 'lower-arm-left',
|
|
115
|
-
handL: 'hand-left',
|
|
116
|
-
upperArmR: 'upper-arm-right',
|
|
117
|
-
lowerArmR: 'lower-arm-right',
|
|
118
|
-
handR: 'hand-right',
|
|
119
|
-
upperLegL: 'upper-leg-left',
|
|
120
|
-
lowerLegL: 'lower-leg-left',
|
|
121
|
-
footL: 'foot-left',
|
|
122
|
-
upperLegR: 'upper-leg-right',
|
|
123
|
-
lowerLegR: 'lower-leg-right',
|
|
124
|
-
footR: 'foot-right'
|
|
125
|
-
};
|
|
126
|
-
Object.keys(boneNames).forEach(function (key) {
|
|
127
|
-
bones[key].name = 'xiaohei-rig-' + boneNames[key];
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
bones.root.add(bones.pelvis);
|
|
131
|
-
bones.pelvis.position.set(0, height * 0.285, 0);
|
|
132
|
-
bones.pelvis.add(bones.spine, bones.upperLegL, bones.upperLegR);
|
|
133
|
-
bones.spine.position.set(0, height * 0.105, 0);
|
|
134
|
-
bones.spine.add(bones.chest);
|
|
135
|
-
bones.chest.position.set(0, height * 0.135, 0);
|
|
136
|
-
bones.chest.add(bones.neck, bones.upperArmL, bones.upperArmR);
|
|
137
|
-
bones.neck.position.set(0, height * 0.080, 0);
|
|
138
|
-
bones.neck.add(bones.head);
|
|
139
|
-
bones.head.position.set(0, height * 0.055, 0);
|
|
140
|
-
|
|
141
|
-
bones.upperArmL.position.set(-height * 0.095, height * 0.035, 0);
|
|
142
|
-
bones.upperArmL.add(bones.lowerArmL);
|
|
143
|
-
bones.lowerArmL.position.set(-height * 0.125, 0, 0);
|
|
144
|
-
bones.lowerArmL.add(bones.handL);
|
|
145
|
-
bones.handL.position.set(-height * 0.085, 0, 0);
|
|
146
|
-
bones.upperArmR.position.set(height * 0.095, height * 0.035, 0);
|
|
147
|
-
bones.upperArmR.add(bones.lowerArmR);
|
|
148
|
-
bones.lowerArmR.position.set(height * 0.125, 0, 0);
|
|
149
|
-
bones.lowerArmR.add(bones.handR);
|
|
150
|
-
bones.handR.position.set(height * 0.085, 0, 0);
|
|
151
|
-
|
|
152
|
-
bones.upperLegL.position.set(-height * 0.055, height * 0.065, 0);
|
|
153
|
-
bones.upperLegL.add(bones.lowerLegL);
|
|
154
|
-
bones.lowerLegL.position.set(0, -height * 0.140, 0);
|
|
155
|
-
bones.lowerLegL.add(bones.footL);
|
|
156
|
-
bones.footL.position.set(0, -height * 0.120, height * 0.008);
|
|
157
|
-
bones.upperLegR.position.set(height * 0.055, height * 0.065, 0);
|
|
158
|
-
bones.upperLegR.add(bones.lowerLegR);
|
|
159
|
-
bones.lowerLegR.position.set(0, -height * 0.140, 0);
|
|
160
|
-
bones.lowerLegR.add(bones.footR);
|
|
161
|
-
bones.footR.position.set(0, -height * 0.120, height * 0.008);
|
|
162
|
-
|
|
163
|
-
var ordered = [
|
|
164
|
-
bones.root,
|
|
165
|
-
bones.pelvis,
|
|
166
|
-
bones.spine,
|
|
167
|
-
bones.chest,
|
|
168
|
-
bones.neck,
|
|
169
|
-
bones.head,
|
|
170
|
-
bones.upperArmL,
|
|
171
|
-
bones.lowerArmL,
|
|
172
|
-
bones.handL,
|
|
173
|
-
bones.upperArmR,
|
|
174
|
-
bones.lowerArmR,
|
|
175
|
-
bones.handR,
|
|
176
|
-
bones.upperLegL,
|
|
177
|
-
bones.lowerLegL,
|
|
178
|
-
bones.footL,
|
|
179
|
-
bones.upperLegR,
|
|
180
|
-
bones.lowerLegR,
|
|
181
|
-
bones.footR
|
|
182
|
-
];
|
|
183
|
-
var position = geometry.getAttribute('position');
|
|
184
|
-
var legSide = xiaoheiAvatarFindLegRegions(geometry, height);
|
|
185
|
-
var skinIndex = new Uint16Array(position.count * 4);
|
|
186
|
-
var skinWeight = new Float32Array(position.count * 4);
|
|
187
|
-
|
|
188
|
-
function weightPair(vertex, firstIndex, firstWeight, secondIndex) {
|
|
189
|
-
var offset = vertex * 4;
|
|
190
|
-
var clamped = Math.max(0, Math.min(1, firstWeight));
|
|
191
|
-
skinIndex[offset] = firstIndex;
|
|
192
|
-
skinIndex[offset + 1] = secondIndex;
|
|
193
|
-
skinWeight[offset] = clamped;
|
|
194
|
-
skinWeight[offset + 1] = 1 - clamped;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
for (var vertex = 0; vertex < position.count; vertex += 1) {
|
|
198
|
-
var x = position.getX(vertex) / height;
|
|
199
|
-
var y = position.getY(vertex) / height;
|
|
200
|
-
var ax = Math.abs(x);
|
|
201
|
-
var left = x < 0;
|
|
202
|
-
|
|
203
|
-
var armMask = xiaoheiMotionSmoothstep(0.105, 0.155, ax)
|
|
204
|
-
* xiaoheiMotionSmoothstep(0.515, 0.545, y)
|
|
205
|
-
* (1 - xiaoheiMotionSmoothstep(0.615, 0.645, y));
|
|
206
|
-
if (armMask > 0.06) {
|
|
207
|
-
var upperArm = left ? 6 : 9;
|
|
208
|
-
var lowerArm = left ? 7 : 10;
|
|
209
|
-
var hand = left ? 8 : 11;
|
|
210
|
-
if (ax < 0.190) {
|
|
211
|
-
weightPair(vertex, upperArm, armMask, 3);
|
|
212
|
-
} else if (ax < 0.270) {
|
|
213
|
-
weightPair(vertex, lowerArm, xiaoheiMotionSmoothstep(0.205, 0.265, ax), upperArm);
|
|
214
|
-
} else if (ax < 0.335) {
|
|
215
|
-
weightPair(vertex, hand, xiaoheiMotionSmoothstep(0.292, 0.332, ax), lowerArm);
|
|
216
|
-
} else {
|
|
217
|
-
weightPair(vertex, hand, 1, lowerArm);
|
|
218
|
-
}
|
|
219
|
-
continue;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
if (y >= 0.585) {
|
|
223
|
-
var headWeight = xiaoheiMotionSmoothstep(0.595, 0.650, y);
|
|
224
|
-
weightPair(vertex, 5, headWeight, 4);
|
|
225
|
-
continue;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
if (legSide[vertex]) {
|
|
229
|
-
var legIsLeft = legSide[vertex] < 0;
|
|
230
|
-
var upperLeg = legIsLeft ? 12 : 15;
|
|
231
|
-
var lowerLeg = legIsLeft ? 13 : 16;
|
|
232
|
-
var foot = legIsLeft ? 14 : 17;
|
|
233
|
-
if (y < 0.135) {
|
|
234
|
-
weightPair(vertex, foot, xiaoheiMotionSmoothstep(0.135, 0.075, y), lowerLeg);
|
|
235
|
-
} else if (y < 0.270) {
|
|
236
|
-
weightPair(vertex, lowerLeg, 1 - xiaoheiMotionSmoothstep(0.210, 0.270, y), upperLeg);
|
|
237
|
-
} else {
|
|
238
|
-
weightPair(vertex, upperLeg, 1 - xiaoheiMotionSmoothstep(0.340, 0.405, y), 1);
|
|
239
|
-
}
|
|
240
|
-
continue;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if (y >= 0.535) {
|
|
244
|
-
weightPair(vertex, 4, xiaoheiMotionSmoothstep(0.545, 0.605, y), 3);
|
|
245
|
-
} else if (y >= 0.420) {
|
|
246
|
-
weightPair(vertex, 3, xiaoheiMotionSmoothstep(0.430, 0.515, y), 2);
|
|
247
|
-
} else if (y >= 0.285) {
|
|
248
|
-
weightPair(vertex, 2, xiaoheiMotionSmoothstep(0.300, 0.410, y), 1);
|
|
249
|
-
} else {
|
|
250
|
-
weightPair(vertex, 1, 1, 0);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
geometry.setAttribute('skinIndex', new THREE.Uint16BufferAttribute(skinIndex, 4));
|
|
255
|
-
geometry.setAttribute('skinWeight', new THREE.Float32BufferAttribute(skinWeight, 4));
|
|
256
|
-
return {
|
|
257
|
-
rootBone: bones.root,
|
|
258
|
-
skeleton: new THREE.Skeleton(ordered),
|
|
259
|
-
bones: bones,
|
|
260
|
-
rest: {
|
|
261
|
-
pelvisY: bones.pelvis.position.y,
|
|
262
|
-
spineY: bones.spine.position.y,
|
|
263
|
-
chestY: bones.chest.position.y,
|
|
264
|
-
neckY: bones.neck.position.y,
|
|
265
|
-
headY: bones.head.position.y,
|
|
266
|
-
upperArmLX: bones.upperArmL.position.x,
|
|
267
|
-
upperArmRX: bones.upperArmR.position.x
|
|
268
|
-
}
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
function xiaoheiAvatarPrepareMotion(avatar) {
|
|
273
|
-
avatar.motion = {
|
|
274
|
-
action: 'settle',
|
|
275
|
-
anchorLimb: 0,
|
|
276
|
-
anchorT: 0.38,
|
|
277
|
-
walkMinT: 0.30,
|
|
278
|
-
walkMaxT: 0.48,
|
|
279
|
-
walkSpeed: 0.021,
|
|
280
|
-
walkDirection: 1,
|
|
281
|
-
walkPhase: 0,
|
|
282
|
-
walkBlend: 0,
|
|
283
|
-
runBlend: 0,
|
|
284
|
-
queuedAction: '',
|
|
285
|
-
lastAction: '',
|
|
286
|
-
travelTargetT: 0.38,
|
|
287
|
-
poseReview: 'sit',
|
|
288
|
-
reviewStarted: 0,
|
|
289
|
-
reviewProgress: 0,
|
|
290
|
-
reviewStartT: 0.38,
|
|
291
|
-
reviewSeatT: 0.38,
|
|
292
|
-
reviewSeatReady: false,
|
|
293
|
-
phase: 'settle',
|
|
294
|
-
phaseStarted: 0,
|
|
295
|
-
phaseUntil: 0,
|
|
296
|
-
lastNow: 0,
|
|
297
|
-
reportedAction: ''
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function xiaoheiAvatarSetMotionPhase(motion, phase, now, duration) {
|
|
302
|
-
motion.phase = phase;
|
|
303
|
-
motion.phaseStarted = now;
|
|
304
|
-
motion.phaseUntil = duration ? now + duration : 0;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
function xiaoheiAvatarMotionProgress(motion, now) {
|
|
308
|
-
var duration = motion.phaseUntil - motion.phaseStarted;
|
|
309
|
-
if (duration <= 0) return 0;
|
|
310
|
-
return xiaoheiMotionSmoothstep(
|
|
311
|
-
0,
|
|
312
|
-
1,
|
|
313
|
-
(now - motion.phaseStarted) / duration
|
|
314
|
-
);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function xiaoheiAvatarBeginIndependentAction(motion, now) {
|
|
318
|
-
var roll = Math.random();
|
|
319
|
-
var action = roll < 0.30
|
|
320
|
-
? 'walk'
|
|
321
|
-
: roll < 0.48
|
|
322
|
-
? 'jump'
|
|
323
|
-
: roll < 0.66
|
|
324
|
-
? 'sit'
|
|
325
|
-
: roll < 0.82
|
|
326
|
-
? 'run'
|
|
327
|
-
: 'idle';
|
|
328
|
-
if (action === motion.lastAction) action = action === 'walk' ? 'jump' : 'walk';
|
|
329
|
-
motion.lastAction = action;
|
|
330
|
-
if (action === 'idle') {
|
|
331
|
-
xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1800 + Math.random() * 1400);
|
|
332
|
-
return;
|
|
333
|
-
}
|
|
334
|
-
if (action === 'jump') {
|
|
335
|
-
xiaoheiAvatarSetMotionPhase(motion, 'jump-crouch', now, 280);
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
if (action === 'sit') {
|
|
339
|
-
xiaoheiAvatarSetMotionPhase(motion, 'sit-down', now, 680);
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
var distance = action === 'run'
|
|
343
|
-
? 0.045 + Math.random() * 0.025
|
|
344
|
-
: 0.026 + Math.random() * 0.020;
|
|
345
|
-
var direction = Math.random() < 0.5 ? -1 : 1;
|
|
346
|
-
if (motion.anchorT <= motion.walkMinT + 0.025) direction = 1;
|
|
347
|
-
if (motion.anchorT >= motion.walkMaxT - 0.025) direction = -1;
|
|
348
|
-
motion.walkDirection = direction;
|
|
349
|
-
motion.travelTargetT = THREE.MathUtils.clamp(
|
|
350
|
-
motion.anchorT + direction * distance,
|
|
351
|
-
motion.walkMinT,
|
|
352
|
-
motion.walkMaxT
|
|
353
|
-
);
|
|
354
|
-
motion.queuedAction = action;
|
|
355
|
-
xiaoheiAvatarSetMotionPhase(motion, 'turn', now, 440);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function xiaoheiAvatarAdvanceMotion(avatar, now) {
|
|
359
|
-
var motion = avatar.motion;
|
|
360
|
-
if (!motion) return;
|
|
361
|
-
if (!motion.lastNow) motion.lastNow = now;
|
|
362
|
-
var dt = Math.min(0.05, Math.max(0, (now - motion.lastNow) * 0.001));
|
|
363
|
-
motion.lastNow = now;
|
|
364
|
-
var scanComplete = !avatar.scan || avatar.scan.complete;
|
|
365
|
-
|
|
366
|
-
if (motion.poseReview) {
|
|
367
|
-
if (scanComplete && motion.reviewSeatReady && !motion.reviewStarted) {
|
|
368
|
-
motion.reviewStarted = now + 650;
|
|
369
|
-
}
|
|
370
|
-
if (motion.reviewStarted) {
|
|
371
|
-
motion.reviewProgress = THREE.MathUtils.clamp(
|
|
372
|
-
(now - motion.reviewStarted) / 1350,
|
|
373
|
-
0,
|
|
374
|
-
1
|
|
375
|
-
);
|
|
376
|
-
}
|
|
377
|
-
motion.phase = motion.reviewProgress < 1 ? 'sit-review-transition' : 'sit-review';
|
|
378
|
-
motion.action = motion.phase;
|
|
379
|
-
motion.anchorT = THREE.MathUtils.lerp(
|
|
380
|
-
motion.reviewStartT,
|
|
381
|
-
motion.reviewSeatT,
|
|
382
|
-
xiaoheiMotionSmoothstep(0, 0.58, motion.reviewProgress)
|
|
383
|
-
);
|
|
384
|
-
motion.walkBlend = 0;
|
|
385
|
-
motion.runBlend = 0;
|
|
386
|
-
if (motion.reportedAction !== motion.action) {
|
|
387
|
-
motion.reportedAction = motion.action;
|
|
388
|
-
document.documentElement.dataset.xiaoheiAvatarAction = motion.action + '-3d';
|
|
389
|
-
document.documentElement.dataset.xiaoheiAvatarPose = motion.action;
|
|
390
|
-
}
|
|
391
|
-
return;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
if (REDUCED || !scanComplete) {
|
|
395
|
-
motion.action = 'settle';
|
|
396
|
-
motion.walkBlend += (0 - motion.walkBlend) * (1 - Math.exp(-dt * 8));
|
|
397
|
-
motion.runBlend += (0 - motion.runBlend) * (1 - Math.exp(-dt * 8));
|
|
398
|
-
} else {
|
|
399
|
-
if (motion.phase === 'settle') {
|
|
400
|
-
xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1400);
|
|
401
|
-
} else if (motion.phase === 'idle' && now >= motion.phaseUntil) {
|
|
402
|
-
xiaoheiAvatarBeginIndependentAction(motion, now);
|
|
403
|
-
} else if (motion.phase === 'turn' && now >= motion.phaseUntil) {
|
|
404
|
-
var queuedAction = motion.queuedAction || 'walk';
|
|
405
|
-
motion.queuedAction = '';
|
|
406
|
-
xiaoheiAvatarSetMotionPhase(motion, queuedAction, now, 0);
|
|
407
|
-
} else if (motion.phase === 'jump-crouch' && now >= motion.phaseUntil) {
|
|
408
|
-
xiaoheiAvatarSetMotionPhase(motion, 'jump-air', now, 680);
|
|
409
|
-
} else if (motion.phase === 'jump-air' && now >= motion.phaseUntil) {
|
|
410
|
-
xiaoheiAvatarSetMotionPhase(motion, 'jump-land', now, 320);
|
|
411
|
-
} else if (motion.phase === 'jump-land' && now >= motion.phaseUntil) {
|
|
412
|
-
xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1500 + Math.random() * 1100);
|
|
413
|
-
} else if (motion.phase === 'sit-down' && now >= motion.phaseUntil) {
|
|
414
|
-
xiaoheiAvatarSetMotionPhase(motion, 'sit', now, 1650);
|
|
415
|
-
} else if (motion.phase === 'sit' && now >= motion.phaseUntil) {
|
|
416
|
-
xiaoheiAvatarSetMotionPhase(motion, 'stand-up', now, 720);
|
|
417
|
-
} else if (motion.phase === 'stand-up' && now >= motion.phaseUntil) {
|
|
418
|
-
xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1600 + Math.random() * 1200);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
var travelling = motion.phase === 'walk' || motion.phase === 'run';
|
|
422
|
-
if (travelling) {
|
|
423
|
-
var running = motion.phase === 'run';
|
|
424
|
-
motion.anchorT += motion.walkDirection
|
|
425
|
-
* (running ? 0.036 : motion.walkSpeed)
|
|
426
|
-
* dt;
|
|
427
|
-
motion.walkPhase += dt * (running ? 9.4 : 6.7);
|
|
428
|
-
var reachedTarget = motion.walkDirection > 0
|
|
429
|
-
? motion.anchorT >= motion.travelTargetT
|
|
430
|
-
: motion.anchorT <= motion.travelTargetT;
|
|
431
|
-
if (reachedTarget) {
|
|
432
|
-
motion.anchorT = motion.travelTargetT;
|
|
433
|
-
xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1500 + Math.random() * 1300);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
var actions = {
|
|
438
|
-
walk: 'walking',
|
|
439
|
-
run: 'running',
|
|
440
|
-
turn: 'turning',
|
|
441
|
-
'jump-crouch': 'jumping',
|
|
442
|
-
'jump-air': 'jumping',
|
|
443
|
-
'jump-land': 'landing',
|
|
444
|
-
'sit-down': 'sitting-down',
|
|
445
|
-
sit: 'sitting',
|
|
446
|
-
'stand-up': 'standing-up'
|
|
447
|
-
};
|
|
448
|
-
motion.action = actions[motion.phase] || 'waiting';
|
|
449
|
-
var locomotionTarget = travelling ? 1 : 0;
|
|
450
|
-
var runTarget = motion.phase === 'run' ? 1 : 0;
|
|
451
|
-
motion.walkBlend += (locomotionTarget - motion.walkBlend)
|
|
452
|
-
* (1 - Math.exp(-dt * 10));
|
|
453
|
-
motion.runBlend += (runTarget - motion.runBlend)
|
|
454
|
-
* (1 - Math.exp(-dt * 10));
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
if (motion.reportedAction !== motion.action) {
|
|
458
|
-
motion.reportedAction = motion.action;
|
|
459
|
-
document.documentElement.dataset.xiaoheiAvatarAction = motion.action + '-3d';
|
|
460
|
-
document.documentElement.dataset.xiaoheiAvatarPose = motion.action;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
function xiaoheiAvatarRestoreImportedRig(rig) {
|
|
465
|
-
Object.keys(rig.restByName).forEach(function (name) {
|
|
466
|
-
var bone = rig.bonesByName[name];
|
|
467
|
-
var rest = rig.restByName[name];
|
|
468
|
-
bone.position.copy(rest.position);
|
|
469
|
-
bone.quaternion.copy(rest.quaternion);
|
|
470
|
-
bone.scale.copy(rest.scale);
|
|
471
|
-
});
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
function xiaoheiAvatarApplyImportedDelta(rig, name, x, y, z) {
|
|
475
|
-
var bone = rig.bonesByName[name];
|
|
476
|
-
var rest = rig.restByName[name];
|
|
477
|
-
if (!bone || !rest) return;
|
|
478
|
-
xiaoheiMotionEuler.set(x, y, z, 'XYZ');
|
|
479
|
-
xiaoheiMotionDeltaQ.setFromEuler(xiaoheiMotionEuler);
|
|
480
|
-
bone.quaternion.copy(rest.quaternion).multiply(xiaoheiMotionDeltaQ);
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
function xiaoheiAvatarApplyImportedArmPose(rig, name, base, swing) {
|
|
484
|
-
var bone = rig.bonesByName[name];
|
|
485
|
-
var rest = rig.restByName[name];
|
|
486
|
-
if (!bone || !rest) return;
|
|
487
|
-
xiaoheiMotionEuler.set(swing, 0, 0, 'XYZ');
|
|
488
|
-
xiaoheiMotionDeltaQ.setFromEuler(xiaoheiMotionEuler);
|
|
489
|
-
bone.quaternion.copy(rest.quaternion).multiply(base).multiply(xiaoheiMotionDeltaQ);
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function xiaoheiAvatarApplyImportedArmBlend(rig, name, from, to, blend) {
|
|
493
|
-
var bone = rig.bonesByName[name];
|
|
494
|
-
var rest = rig.restByName[name];
|
|
495
|
-
if (!bone || !rest) return;
|
|
496
|
-
xiaoheiMotionPoseQ.copy(from).slerp(to, blend);
|
|
497
|
-
bone.quaternion.copy(rest.quaternion).multiply(xiaoheiMotionPoseQ);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/* Mixamo legs are hinge joints in the sagittal plane. Keep the complete
|
|
501
|
-
gait on each bone's local X axis: this prevents a procedural target from
|
|
502
|
-
twisting a knee sideways or rolling a shoe onto its outer edge. */
|
|
503
|
-
function xiaoheiAvatarResolveImportedLegPose(phase, blend, runBlend) {
|
|
504
|
-
var stanceEnd = THREE.MathUtils.lerp(0.62, 0.54, runBlend);
|
|
505
|
-
var forward = THREE.MathUtils.lerp(0.24, 0.34, runBlend);
|
|
506
|
-
var backward = THREE.MathUtils.lerp(-0.22, -0.30, runBlend);
|
|
507
|
-
var swingKnee = THREE.MathUtils.lerp(0.62, 0.82, runBlend);
|
|
508
|
-
var hip = 0;
|
|
509
|
-
var knee = 0;
|
|
510
|
-
if (phase < stanceEnd) {
|
|
511
|
-
var stance = xiaoheiMotionSmoothstep(0, stanceEnd, phase);
|
|
512
|
-
hip = THREE.MathUtils.lerp(forward, backward, stance);
|
|
513
|
-
knee = -0.045 - Math.sin(Math.PI * stance)
|
|
514
|
-
* THREE.MathUtils.lerp(0.055, 0.10, runBlend);
|
|
515
|
-
} else {
|
|
516
|
-
var swing = xiaoheiMotionSmoothstep(stanceEnd, 1, phase);
|
|
517
|
-
hip = THREE.MathUtils.lerp(backward, forward, swing);
|
|
518
|
-
knee = -0.045 - Math.sin(Math.PI * swing) * swingKnee;
|
|
519
|
-
}
|
|
520
|
-
hip *= blend;
|
|
521
|
-
knee *= blend;
|
|
522
|
-
return {
|
|
523
|
-
hip: hip,
|
|
524
|
-
knee: Math.min(0, knee),
|
|
525
|
-
foot: THREE.MathUtils.clamp(-hip - knee * 0.72, -0.30, 0.46)
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
|
|
529
|
-
function xiaoheiAvatarResolveImportedActionPose(avatar, now) {
|
|
530
|
-
var motion = avatar.motion;
|
|
531
|
-
var progress = xiaoheiAvatarMotionProgress(motion, now);
|
|
532
|
-
var pose = {
|
|
533
|
-
sit: 0,
|
|
534
|
-
crouch: 0,
|
|
535
|
-
air: 0,
|
|
536
|
-
rootY: 0,
|
|
537
|
-
spineX: 0,
|
|
538
|
-
armX: 0
|
|
539
|
-
};
|
|
540
|
-
if (motion.phase === 'sit-down') pose.sit = progress;
|
|
541
|
-
else if (motion.phase === 'sit') pose.sit = 1;
|
|
542
|
-
else if (motion.phase === 'stand-up') pose.sit = 1 - progress;
|
|
543
|
-
else if (motion.phase === 'jump-crouch') pose.crouch = progress;
|
|
544
|
-
else if (motion.phase === 'jump-air') {
|
|
545
|
-
pose.crouch = 1 - Math.sin(Math.PI * progress) * 0.48;
|
|
546
|
-
pose.air = Math.sin(Math.PI * progress);
|
|
547
|
-
} else if (motion.phase === 'jump-land') {
|
|
548
|
-
pose.crouch = 1 - progress;
|
|
549
|
-
}
|
|
550
|
-
pose.rootY = -pose.sit * avatar.reviewedHeight * 0.235
|
|
551
|
-
- pose.crouch * avatar.reviewedHeight * 0.052
|
|
552
|
-
+ pose.air * avatar.reviewedHeight * 0.13;
|
|
553
|
-
pose.spineX = pose.sit * 0.12 + pose.crouch * 0.10;
|
|
554
|
-
pose.armX = pose.crouch * 0.10 + pose.air * 0.12;
|
|
555
|
-
return pose;
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
function xiaoheiAvatarPoseImportedMotion(avatar, now) {
|
|
559
|
-
var motion = avatar.motion;
|
|
560
|
-
var rig = avatar.rig;
|
|
561
|
-
var seconds = now * 0.001;
|
|
562
|
-
var breath = Math.sin(seconds * 1.45);
|
|
563
|
-
var sway = Math.sin(seconds * 0.58 + 0.7);
|
|
564
|
-
var gaze = xiaoheiAvatarHover;
|
|
565
|
-
var pointerX = ndc.x <= 2 ? ndc.x : 0;
|
|
566
|
-
var pointerY = ndc.y <= 2 ? ndc.y : 0;
|
|
567
|
-
var walk = motion.walkBlend || 0;
|
|
568
|
-
var run = motion.runBlend || 0;
|
|
569
|
-
var step = Math.sin(motion.walkPhase || 0) * walk;
|
|
570
|
-
var actionPose = xiaoheiAvatarResolveImportedActionPose(avatar, now);
|
|
571
|
-
var armSwing = step * THREE.MathUtils.lerp(0.055, 0.15, run);
|
|
572
|
-
|
|
573
|
-
xiaoheiAvatarRestoreImportedRig(rig);
|
|
574
|
-
if (motion.poseReview) {
|
|
575
|
-
var review = xiaoheiMotionSmoothstep(0, 1, motion.reviewProgress || 0);
|
|
576
|
-
var support = xiaoheiMotionSmoothstep(0.12, 0.88, review);
|
|
577
|
-
var seated = xiaoheiMotionSmoothstep(0, 0.78, review);
|
|
578
|
-
var dangling = review > 0.98
|
|
579
|
-
? Math.sin((now - motion.reviewStarted) * 0.001 * 1.45) * 0.085
|
|
580
|
-
: 0;
|
|
581
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
582
|
-
rig, 'mixamorig:Spine', seated * 0.075, 0, seated * -0.055
|
|
583
|
-
);
|
|
584
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
585
|
-
rig, 'mixamorig:Spine2', seated * -0.035, 0, seated * 0.025
|
|
586
|
-
);
|
|
587
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
588
|
-
rig, 'mixamorig:Head', avatar.screenPitch || 0, 0, seated * 0.035
|
|
589
|
-
);
|
|
590
|
-
xiaoheiAvatarApplyImportedArmBlend(
|
|
591
|
-
rig, 'mixamorig:LeftArm',
|
|
592
|
-
xiaoheiMotionArmDown.leftUpper, xiaoheiMotionSitArms.leftUpper, support
|
|
593
|
-
);
|
|
594
|
-
xiaoheiAvatarApplyImportedArmBlend(
|
|
595
|
-
rig, 'mixamorig:RightArm',
|
|
596
|
-
xiaoheiMotionArmDown.rightUpper, xiaoheiMotionSitArms.rightUpper, support
|
|
597
|
-
);
|
|
598
|
-
xiaoheiAvatarApplyImportedArmBlend(
|
|
599
|
-
rig, 'mixamorig:LeftForeArm',
|
|
600
|
-
xiaoheiMotionArmDown.leftLower, xiaoheiMotionSitArms.leftLower, support
|
|
601
|
-
);
|
|
602
|
-
xiaoheiAvatarApplyImportedArmBlend(
|
|
603
|
-
rig, 'mixamorig:RightForeArm',
|
|
604
|
-
xiaoheiMotionArmDown.rightLower, xiaoheiMotionSitArms.rightLower, support
|
|
605
|
-
);
|
|
606
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
607
|
-
rig, 'mixamorig:LeftUpLeg', seated * 1.08, 0, 0
|
|
608
|
-
);
|
|
609
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
610
|
-
rig, 'mixamorig:LeftLeg', seated * (-1.02 + dangling), 0, 0
|
|
611
|
-
);
|
|
612
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
613
|
-
rig, 'mixamorig:LeftFoot', seated * 0.20, 0, 0
|
|
614
|
-
);
|
|
615
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
616
|
-
rig, 'mixamorig:RightUpLeg', seated * 0.78, 0, 0
|
|
617
|
-
);
|
|
618
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
619
|
-
rig, 'mixamorig:RightLeg', seated * -1.26, 0, 0
|
|
620
|
-
);
|
|
621
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
622
|
-
rig, 'mixamorig:RightFoot', seated * 0.36, 0, 0
|
|
623
|
-
);
|
|
624
|
-
avatar.model.position.y = (avatar.groundOffset || 0)
|
|
625
|
-
- avatar.reviewedHeight * 0.369 * seated;
|
|
626
|
-
avatar.model.scale.set(1, 1, 1);
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
630
|
-
rig, 'mixamorig:Spine',
|
|
631
|
-
breath * 0.012 + walk * THREE.MathUtils.lerp(0.025, 0.075, run)
|
|
632
|
-
+ actionPose.spineX,
|
|
633
|
-
-sway * 0.010,
|
|
634
|
-
-sway * 0.015
|
|
635
|
-
);
|
|
636
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
637
|
-
rig, 'mixamorig:Spine2',
|
|
638
|
-
-breath * 0.010,
|
|
639
|
-
sway * 0.012,
|
|
640
|
-
sway * 0.012
|
|
641
|
-
);
|
|
642
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
643
|
-
rig, 'mixamorig:Head',
|
|
644
|
-
(avatar.screenPitch || 0) + Math.sin(seconds * 0.78) * 0.018 - pointerY * gaze * 0.045,
|
|
645
|
-
pointerX * gaze * 0.12 - sway * 0.012,
|
|
646
|
-
sway * 0.018
|
|
647
|
-
);
|
|
648
|
-
xiaoheiAvatarApplyImportedArmPose(
|
|
649
|
-
rig, 'mixamorig:LeftArm',
|
|
650
|
-
xiaoheiMotionArmDown.leftUpper,
|
|
651
|
-
-armSwing - actionPose.armX + breath * 0.008
|
|
652
|
-
);
|
|
653
|
-
xiaoheiAvatarApplyImportedArmPose(
|
|
654
|
-
rig, 'mixamorig:RightArm',
|
|
655
|
-
xiaoheiMotionArmDown.rightUpper,
|
|
656
|
-
armSwing + actionPose.armX - breath * 0.008
|
|
657
|
-
);
|
|
658
|
-
xiaoheiAvatarApplyImportedArmPose(
|
|
659
|
-
rig, 'mixamorig:LeftForeArm',
|
|
660
|
-
xiaoheiMotionArmDown.leftLower,
|
|
661
|
-
run * Math.max(0, step) * 0.035
|
|
662
|
-
);
|
|
663
|
-
xiaoheiAvatarApplyImportedArmPose(
|
|
664
|
-
rig, 'mixamorig:RightForeArm',
|
|
665
|
-
xiaoheiMotionArmDown.rightLower,
|
|
666
|
-
-run * Math.max(0, -step) * 0.035
|
|
667
|
-
);
|
|
668
|
-
|
|
669
|
-
avatar.model.position.y = (avatar.groundOffset || 0) + actionPose.rootY;
|
|
670
|
-
avatar.model.scale.set(1, 1, 1);
|
|
671
|
-
if (
|
|
672
|
-
(motion.phase === 'walk' || motion.phase === 'run')
|
|
673
|
-
&& walk > 0.04
|
|
674
|
-
&& (!avatar.scan || avatar.scan.complete)
|
|
675
|
-
) {
|
|
676
|
-
var cycle = (motion.walkPhase / (Math.PI * 2)) % 1;
|
|
677
|
-
if (cycle < 0) cycle += 1;
|
|
678
|
-
var leftLeg = xiaoheiAvatarResolveImportedLegPose(cycle, walk, run);
|
|
679
|
-
var rightLeg = xiaoheiAvatarResolveImportedLegPose((cycle + 0.5) % 1, walk, run);
|
|
680
|
-
} else {
|
|
681
|
-
leftLeg = { hip: 0, knee: 0, foot: 0 };
|
|
682
|
-
rightLeg = { hip: 0, knee: 0, foot: 0 };
|
|
683
|
-
}
|
|
684
|
-
var seatedHip = actionPose.sit * 0.82;
|
|
685
|
-
var seatedKnee = actionPose.sit * -1.18;
|
|
686
|
-
var seatedFoot = actionPose.sit * 0.30;
|
|
687
|
-
var jumpHip = actionPose.crouch * 0.20;
|
|
688
|
-
var jumpKnee = actionPose.crouch * -0.58;
|
|
689
|
-
var jumpFoot = actionPose.crouch * 0.22;
|
|
690
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
691
|
-
rig, 'mixamorig:LeftUpLeg',
|
|
692
|
-
THREE.MathUtils.clamp(leftLeg.hip + seatedHip + jumpHip, -0.55, 1.10), 0, 0
|
|
693
|
-
);
|
|
694
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
695
|
-
rig, 'mixamorig:LeftLeg',
|
|
696
|
-
THREE.MathUtils.clamp(leftLeg.knee + seatedKnee + jumpKnee, -1.32, 0), 0, 0
|
|
697
|
-
);
|
|
698
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
699
|
-
rig, 'mixamorig:LeftFoot',
|
|
700
|
-
THREE.MathUtils.clamp(leftLeg.foot + seatedFoot + jumpFoot, -0.34, 0.52), 0, 0
|
|
701
|
-
);
|
|
702
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
703
|
-
rig, 'mixamorig:RightUpLeg',
|
|
704
|
-
THREE.MathUtils.clamp(rightLeg.hip + seatedHip + jumpHip, -0.55, 1.10), 0, 0
|
|
705
|
-
);
|
|
706
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
707
|
-
rig, 'mixamorig:RightLeg',
|
|
708
|
-
THREE.MathUtils.clamp(rightLeg.knee + seatedKnee + jumpKnee, -1.32, 0), 0, 0
|
|
709
|
-
);
|
|
710
|
-
xiaoheiAvatarApplyImportedDelta(
|
|
711
|
-
rig, 'mixamorig:RightFoot',
|
|
712
|
-
THREE.MathUtils.clamp(rightLeg.foot + seatedFoot + jumpFoot, -0.34, 0.52), 0, 0
|
|
713
|
-
);
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
function xiaoheiAvatarPoseMotion(avatar, now) {
|
|
717
|
-
var motion = avatar.motion;
|
|
718
|
-
var rig = avatar.rig;
|
|
719
|
-
if (!motion || !rig) return;
|
|
720
|
-
if (rig.imported) {
|
|
721
|
-
xiaoheiAvatarPoseImportedMotion(avatar, now);
|
|
722
|
-
return;
|
|
723
|
-
}
|
|
724
|
-
if (avatar.animation) {
|
|
725
|
-
if (!avatar.animation.lastNow) avatar.animation.lastNow = now;
|
|
726
|
-
var animationDelta = Math.min(
|
|
727
|
-
0.05,
|
|
728
|
-
Math.max(0, (now - avatar.animation.lastNow) * 0.001)
|
|
729
|
-
);
|
|
730
|
-
avatar.animation.lastNow = now;
|
|
731
|
-
if (!avatar.scan || avatar.scan.complete) avatar.animation.mixer.update(animationDelta);
|
|
732
|
-
avatar.model.position.y = avatar.groundOffset || 0;
|
|
733
|
-
avatar.model.scale.set(1, 1, 1);
|
|
734
|
-
return;
|
|
735
|
-
}
|
|
736
|
-
var bones = rig.bones;
|
|
737
|
-
var rest = rig.rest;
|
|
738
|
-
var seconds = now * 0.001;
|
|
739
|
-
var breath = Math.sin(seconds * 1.45);
|
|
740
|
-
var breathLift = Math.sin(seconds * 1.45 + 0.58);
|
|
741
|
-
var sway = Math.sin(seconds * 0.56 + 0.7);
|
|
742
|
-
var counterSway = Math.sin(seconds * 0.56 + 2.65);
|
|
743
|
-
var gaze = xiaoheiAvatarHover;
|
|
744
|
-
var pointerX = ndc.x <= 2 ? ndc.x : 0;
|
|
745
|
-
var pointerY = ndc.y <= 2 ? ndc.y : 0;
|
|
746
|
-
var walk = motion.walkBlend || 0;
|
|
747
|
-
var step = Math.sin(motion.walkPhase || 0);
|
|
748
|
-
var stepOpposite = Math.sin((motion.walkPhase || 0) + Math.PI);
|
|
749
|
-
var strideL = step * walk;
|
|
750
|
-
var strideR = stepOpposite * walk;
|
|
751
|
-
var footfall = Math.abs(Math.cos(motion.walkPhase || 0)) * walk;
|
|
752
|
-
|
|
753
|
-
bones.pelvis.position.y = rest.pelvisY
|
|
754
|
-
+ breath * avatar.reviewedHeight * 0.0035 * (1 - walk * 0.65)
|
|
755
|
-
+ footfall * avatar.reviewedHeight * 0.0055;
|
|
756
|
-
bones.spine.position.y = rest.spineY + breathLift * avatar.reviewedHeight * 0.0012;
|
|
757
|
-
bones.chest.position.y = rest.chestY + breathLift * avatar.reviewedHeight * 0.0018;
|
|
758
|
-
bones.neck.position.y = rest.neckY;
|
|
759
|
-
bones.head.position.y = rest.headY;
|
|
760
|
-
bones.upperArmL.position.x = rest.upperArmLX * 0.92;
|
|
761
|
-
bones.upperArmR.position.x = rest.upperArmRX * 0.92;
|
|
762
|
-
|
|
763
|
-
bones.pelvis.rotation.set(strideL * 0.025, sway * 0.006, sway * 0.013);
|
|
764
|
-
bones.spine.rotation.set(breath * 0.007 + walk * 0.035, -sway * 0.010, -sway * 0.020);
|
|
765
|
-
bones.chest.rotation.set(-breath * 0.009 - walk * 0.022, sway * 0.014, sway * 0.014);
|
|
766
|
-
bones.neck.rotation.set(-breath * 0.004, 0, -sway * 0.006);
|
|
767
|
-
bones.head.rotation.set(
|
|
768
|
-
(avatar.screenPitch || 0) + Math.sin(seconds * 0.78) * 0.020 - pointerY * gaze * 0.050,
|
|
769
|
-
pointerX * gaze * 0.135 + counterSway * 0.014,
|
|
770
|
-
sway * 0.026 - pointerX * gaze * 0.012
|
|
771
|
-
);
|
|
772
|
-
|
|
773
|
-
bones.upperArmL.rotation.set(
|
|
774
|
-
breath * 0.012 + strideR * 0.075,
|
|
775
|
-
-0.075 + sway * 0.010 + strideR * 0.18,
|
|
776
|
-
1.385 + breath * 0.022 - gaze * 0.016
|
|
777
|
-
);
|
|
778
|
-
bones.lowerArmL.rotation.set(0, 0, 0.165 + breathLift * 0.016 + gaze * 0.012);
|
|
779
|
-
bones.handL.rotation.set(0, -0.018, -0.055 + sway * 0.014);
|
|
780
|
-
bones.upperArmR.rotation.set(
|
|
781
|
-
-breath * 0.012 + strideL * 0.075,
|
|
782
|
-
0.075 - sway * 0.010 + strideL * 0.18,
|
|
783
|
-
-1.385 - breath * 0.022 + gaze * 0.016
|
|
784
|
-
);
|
|
785
|
-
bones.lowerArmR.rotation.set(0, 0, -0.165 - breathLift * 0.016 - gaze * 0.012);
|
|
786
|
-
bones.handR.rotation.set(0, 0.018, 0.055 - sway * 0.014);
|
|
787
|
-
|
|
788
|
-
bones.upperLegL.rotation.set(strideL * 0.24, 0, sway * 0.004);
|
|
789
|
-
bones.lowerLegL.rotation.set(Math.max(0, -strideL) * 0.28, 0, 0);
|
|
790
|
-
bones.footL.rotation.set(-strideL * 0.10 - Math.max(0, -strideL) * 0.16, 0, 0);
|
|
791
|
-
bones.upperLegR.rotation.set(strideR * 0.24, 0, -sway * 0.004);
|
|
792
|
-
bones.lowerLegR.rotation.set(Math.max(0, -strideR) * 0.28, 0, 0);
|
|
793
|
-
bones.footR.rotation.set(-strideR * 0.10 - Math.max(0, -strideR) * 0.16, 0, 0);
|
|
794
|
-
|
|
795
|
-
avatar.model.position.y = breath * avatar.reviewedHeight * 0.0018 * (1 - walk * 0.6);
|
|
796
|
-
avatar.model.scale.set(1, 1, 1);
|
|
797
|
-
}
|
|
798
|
-
`;
|
|
799
|
-
//# sourceMappingURL=avatar-motion.js.map
|