@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,3 +0,0 @@
|
|
|
1
|
-
/** Runtime helpers inserted beside the Xiaohei model in ThreeUI's own r149 scene. */
|
|
2
|
-
export declare const XIAOHEI_AVATAR_MOTION_RUNTIME = "\n var xiaoheiMotionEuler = new THREE.Euler();\n var xiaoheiMotionDeltaQ = new THREE.Quaternion();\n var xiaoheiMotionPoseQ = new THREE.Quaternion();\n var xiaoheiMotionArmDown = {\n leftUpper: new THREE.Quaternion(0.54427280, 0.01192567, 0.03342154, 0.83815747),\n rightUpper: new THREE.Quaternion(0.54406160, -0.01540707, -0.03727146, 0.83807547),\n leftLower: new THREE.Quaternion(0, 0, 0, 1),\n rightLower: new THREE.Quaternion(0, 0, 0, 1)\n };\n var xiaoheiMotionSitArms = {\n leftUpper: new THREE.Quaternion(0.42277680, 0.04837124, 0.43673194, 0.79258139),\n rightUpper: new THREE.Quaternion(0.58108784, 0.00464093, 0.18044704, 0.79357061),\n leftLower: new THREE.Quaternion(0.00485389, -0.02619754, 0.18480416, 0.98241418),\n rightLower: new THREE.Quaternion(0.12449678, 0.00258430, -0.01948060, 0.99202538)\n };\n\n function xiaoheiMotionSmoothstep(a, b, value) {\n var t = Math.max(0, Math.min(1, (value - a) / (b - a)));\n return t * t * (3 - 2 * t);\n }\n\n function xiaoheiAvatarFindLegRegions(geometry, height) {\n var position = geometry.getAttribute('position');\n var index = geometry.getIndex();\n var parent = new Int32Array(position.count);\n for (var vertex = 0; vertex < position.count; vertex += 1) parent[vertex] = vertex;\n\n function find(vertexIndex) {\n var root = vertexIndex;\n while (parent[root] !== root) root = parent[root];\n while (parent[vertexIndex] !== vertexIndex) {\n var next = parent[vertexIndex];\n parent[vertexIndex] = root;\n vertexIndex = next;\n }\n return root;\n }\n\n function join(first, second) {\n var firstRoot = find(first);\n var secondRoot = find(second);\n if (firstRoot !== secondRoot) parent[secondRoot] = firstRoot;\n }\n\n if (index) {\n for (var offset = 0; offset < index.count; offset += 3) {\n var first = index.getX(offset);\n join(first, index.getX(offset + 1));\n join(first, index.getX(offset + 2));\n }\n }\n\n var regions = Object.create(null);\n for (vertex = 0; vertex < position.count; vertex += 1) {\n var root = find(vertex);\n var x = position.getX(vertex) / height;\n var y = position.getY(vertex) / height;\n var region = regions[root];\n if (!region) {\n region = regions[root] = { minX: x, maxX: x, minY: y, maxY: y };\n } else {\n region.minX = Math.min(region.minX, x);\n region.maxX = Math.max(region.maxX, x);\n region.minY = Math.min(region.minY, y);\n region.maxY = Math.max(region.maxY, y);\n }\n }\n\n var legSide = new Int8Array(position.count);\n for (vertex = 0; vertex < position.count; vertex += 1) {\n root = find(vertex);\n region = regions[root];\n /* The shorts are built from separate side panels too. Keep every island\n that rises into the garment on the pelvis, otherwise the two panels\n rotate like rigid armour plates when a thigh swings. */\n if (region.minY >= 0.36 || region.maxY >= 0.44) continue;\n if (region.maxX < 0.012 && region.minX > -0.19) legSide[vertex] = -1;\n else if (region.minX > -0.012 && region.maxX < 0.19) legSide[vertex] = 1;\n }\n return legSide;\n }\n\n function xiaoheiAvatarBuildRig(geometry, height) {\n var bones = {\n root: new THREE.Bone(),\n pelvis: new THREE.Bone(),\n spine: new THREE.Bone(),\n chest: new THREE.Bone(),\n neck: new THREE.Bone(),\n head: new THREE.Bone(),\n upperArmL: new THREE.Bone(),\n lowerArmL: new THREE.Bone(),\n handL: new THREE.Bone(),\n upperArmR: new THREE.Bone(),\n lowerArmR: new THREE.Bone(),\n handR: new THREE.Bone(),\n upperLegL: new THREE.Bone(),\n lowerLegL: new THREE.Bone(),\n footL: new THREE.Bone(),\n upperLegR: new THREE.Bone(),\n lowerLegR: new THREE.Bone(),\n footR: new THREE.Bone()\n };\n var boneNames = {\n root: 'root',\n pelvis: 'pelvis',\n spine: 'spine',\n chest: 'chest',\n neck: 'neck',\n head: 'head',\n upperArmL: 'upper-arm-left',\n lowerArmL: 'lower-arm-left',\n handL: 'hand-left',\n upperArmR: 'upper-arm-right',\n lowerArmR: 'lower-arm-right',\n handR: 'hand-right',\n upperLegL: 'upper-leg-left',\n lowerLegL: 'lower-leg-left',\n footL: 'foot-left',\n upperLegR: 'upper-leg-right',\n lowerLegR: 'lower-leg-right',\n footR: 'foot-right'\n };\n Object.keys(boneNames).forEach(function (key) {\n bones[key].name = 'xiaohei-rig-' + boneNames[key];\n });\n\n bones.root.add(bones.pelvis);\n bones.pelvis.position.set(0, height * 0.285, 0);\n bones.pelvis.add(bones.spine, bones.upperLegL, bones.upperLegR);\n bones.spine.position.set(0, height * 0.105, 0);\n bones.spine.add(bones.chest);\n bones.chest.position.set(0, height * 0.135, 0);\n bones.chest.add(bones.neck, bones.upperArmL, bones.upperArmR);\n bones.neck.position.set(0, height * 0.080, 0);\n bones.neck.add(bones.head);\n bones.head.position.set(0, height * 0.055, 0);\n\n bones.upperArmL.position.set(-height * 0.095, height * 0.035, 0);\n bones.upperArmL.add(bones.lowerArmL);\n bones.lowerArmL.position.set(-height * 0.125, 0, 0);\n bones.lowerArmL.add(bones.handL);\n bones.handL.position.set(-height * 0.085, 0, 0);\n bones.upperArmR.position.set(height * 0.095, height * 0.035, 0);\n bones.upperArmR.add(bones.lowerArmR);\n bones.lowerArmR.position.set(height * 0.125, 0, 0);\n bones.lowerArmR.add(bones.handR);\n bones.handR.position.set(height * 0.085, 0, 0);\n\n bones.upperLegL.position.set(-height * 0.055, height * 0.065, 0);\n bones.upperLegL.add(bones.lowerLegL);\n bones.lowerLegL.position.set(0, -height * 0.140, 0);\n bones.lowerLegL.add(bones.footL);\n bones.footL.position.set(0, -height * 0.120, height * 0.008);\n bones.upperLegR.position.set(height * 0.055, height * 0.065, 0);\n bones.upperLegR.add(bones.lowerLegR);\n bones.lowerLegR.position.set(0, -height * 0.140, 0);\n bones.lowerLegR.add(bones.footR);\n bones.footR.position.set(0, -height * 0.120, height * 0.008);\n\n var ordered = [\n bones.root,\n bones.pelvis,\n bones.spine,\n bones.chest,\n bones.neck,\n bones.head,\n bones.upperArmL,\n bones.lowerArmL,\n bones.handL,\n bones.upperArmR,\n bones.lowerArmR,\n bones.handR,\n bones.upperLegL,\n bones.lowerLegL,\n bones.footL,\n bones.upperLegR,\n bones.lowerLegR,\n bones.footR\n ];\n var position = geometry.getAttribute('position');\n var legSide = xiaoheiAvatarFindLegRegions(geometry, height);\n var skinIndex = new Uint16Array(position.count * 4);\n var skinWeight = new Float32Array(position.count * 4);\n\n function weightPair(vertex, firstIndex, firstWeight, secondIndex) {\n var offset = vertex * 4;\n var clamped = Math.max(0, Math.min(1, firstWeight));\n skinIndex[offset] = firstIndex;\n skinIndex[offset + 1] = secondIndex;\n skinWeight[offset] = clamped;\n skinWeight[offset + 1] = 1 - clamped;\n }\n\n for (var vertex = 0; vertex < position.count; vertex += 1) {\n var x = position.getX(vertex) / height;\n var y = position.getY(vertex) / height;\n var ax = Math.abs(x);\n var left = x < 0;\n\n var armMask = xiaoheiMotionSmoothstep(0.105, 0.155, ax)\n * xiaoheiMotionSmoothstep(0.515, 0.545, y)\n * (1 - xiaoheiMotionSmoothstep(0.615, 0.645, y));\n if (armMask > 0.06) {\n var upperArm = left ? 6 : 9;\n var lowerArm = left ? 7 : 10;\n var hand = left ? 8 : 11;\n if (ax < 0.190) {\n weightPair(vertex, upperArm, armMask, 3);\n } else if (ax < 0.270) {\n weightPair(vertex, lowerArm, xiaoheiMotionSmoothstep(0.205, 0.265, ax), upperArm);\n } else if (ax < 0.335) {\n weightPair(vertex, hand, xiaoheiMotionSmoothstep(0.292, 0.332, ax), lowerArm);\n } else {\n weightPair(vertex, hand, 1, lowerArm);\n }\n continue;\n }\n\n if (y >= 0.585) {\n var headWeight = xiaoheiMotionSmoothstep(0.595, 0.650, y);\n weightPair(vertex, 5, headWeight, 4);\n continue;\n }\n\n if (legSide[vertex]) {\n var legIsLeft = legSide[vertex] < 0;\n var upperLeg = legIsLeft ? 12 : 15;\n var lowerLeg = legIsLeft ? 13 : 16;\n var foot = legIsLeft ? 14 : 17;\n if (y < 0.135) {\n weightPair(vertex, foot, xiaoheiMotionSmoothstep(0.135, 0.075, y), lowerLeg);\n } else if (y < 0.270) {\n weightPair(vertex, lowerLeg, 1 - xiaoheiMotionSmoothstep(0.210, 0.270, y), upperLeg);\n } else {\n weightPair(vertex, upperLeg, 1 - xiaoheiMotionSmoothstep(0.340, 0.405, y), 1);\n }\n continue;\n }\n\n if (y >= 0.535) {\n weightPair(vertex, 4, xiaoheiMotionSmoothstep(0.545, 0.605, y), 3);\n } else if (y >= 0.420) {\n weightPair(vertex, 3, xiaoheiMotionSmoothstep(0.430, 0.515, y), 2);\n } else if (y >= 0.285) {\n weightPair(vertex, 2, xiaoheiMotionSmoothstep(0.300, 0.410, y), 1);\n } else {\n weightPair(vertex, 1, 1, 0);\n }\n }\n\n geometry.setAttribute('skinIndex', new THREE.Uint16BufferAttribute(skinIndex, 4));\n geometry.setAttribute('skinWeight', new THREE.Float32BufferAttribute(skinWeight, 4));\n return {\n rootBone: bones.root,\n skeleton: new THREE.Skeleton(ordered),\n bones: bones,\n rest: {\n pelvisY: bones.pelvis.position.y,\n spineY: bones.spine.position.y,\n chestY: bones.chest.position.y,\n neckY: bones.neck.position.y,\n headY: bones.head.position.y,\n upperArmLX: bones.upperArmL.position.x,\n upperArmRX: bones.upperArmR.position.x\n }\n };\n }\n\n function xiaoheiAvatarPrepareMotion(avatar) {\n avatar.motion = {\n action: 'settle',\n anchorLimb: 0,\n anchorT: 0.38,\n walkMinT: 0.30,\n walkMaxT: 0.48,\n walkSpeed: 0.021,\n walkDirection: 1,\n walkPhase: 0,\n walkBlend: 0,\n runBlend: 0,\n queuedAction: '',\n lastAction: '',\n travelTargetT: 0.38,\n poseReview: 'sit',\n reviewStarted: 0,\n reviewProgress: 0,\n reviewStartT: 0.38,\n reviewSeatT: 0.38,\n reviewSeatReady: false,\n phase: 'settle',\n phaseStarted: 0,\n phaseUntil: 0,\n lastNow: 0,\n reportedAction: ''\n };\n }\n\n function xiaoheiAvatarSetMotionPhase(motion, phase, now, duration) {\n motion.phase = phase;\n motion.phaseStarted = now;\n motion.phaseUntil = duration ? now + duration : 0;\n }\n\n function xiaoheiAvatarMotionProgress(motion, now) {\n var duration = motion.phaseUntil - motion.phaseStarted;\n if (duration <= 0) return 0;\n return xiaoheiMotionSmoothstep(\n 0,\n 1,\n (now - motion.phaseStarted) / duration\n );\n }\n\n function xiaoheiAvatarBeginIndependentAction(motion, now) {\n var roll = Math.random();\n var action = roll < 0.30\n ? 'walk'\n : roll < 0.48\n ? 'jump'\n : roll < 0.66\n ? 'sit'\n : roll < 0.82\n ? 'run'\n : 'idle';\n if (action === motion.lastAction) action = action === 'walk' ? 'jump' : 'walk';\n motion.lastAction = action;\n if (action === 'idle') {\n xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1800 + Math.random() * 1400);\n return;\n }\n if (action === 'jump') {\n xiaoheiAvatarSetMotionPhase(motion, 'jump-crouch', now, 280);\n return;\n }\n if (action === 'sit') {\n xiaoheiAvatarSetMotionPhase(motion, 'sit-down', now, 680);\n return;\n }\n var distance = action === 'run'\n ? 0.045 + Math.random() * 0.025\n : 0.026 + Math.random() * 0.020;\n var direction = Math.random() < 0.5 ? -1 : 1;\n if (motion.anchorT <= motion.walkMinT + 0.025) direction = 1;\n if (motion.anchorT >= motion.walkMaxT - 0.025) direction = -1;\n motion.walkDirection = direction;\n motion.travelTargetT = THREE.MathUtils.clamp(\n motion.anchorT + direction * distance,\n motion.walkMinT,\n motion.walkMaxT\n );\n motion.queuedAction = action;\n xiaoheiAvatarSetMotionPhase(motion, 'turn', now, 440);\n }\n\n function xiaoheiAvatarAdvanceMotion(avatar, now) {\n var motion = avatar.motion;\n if (!motion) return;\n if (!motion.lastNow) motion.lastNow = now;\n var dt = Math.min(0.05, Math.max(0, (now - motion.lastNow) * 0.001));\n motion.lastNow = now;\n var scanComplete = !avatar.scan || avatar.scan.complete;\n\n if (motion.poseReview) {\n if (scanComplete && motion.reviewSeatReady && !motion.reviewStarted) {\n motion.reviewStarted = now + 650;\n }\n if (motion.reviewStarted) {\n motion.reviewProgress = THREE.MathUtils.clamp(\n (now - motion.reviewStarted) / 1350,\n 0,\n 1\n );\n }\n motion.phase = motion.reviewProgress < 1 ? 'sit-review-transition' : 'sit-review';\n motion.action = motion.phase;\n motion.anchorT = THREE.MathUtils.lerp(\n motion.reviewStartT,\n motion.reviewSeatT,\n xiaoheiMotionSmoothstep(0, 0.58, motion.reviewProgress)\n );\n motion.walkBlend = 0;\n motion.runBlend = 0;\n if (motion.reportedAction !== motion.action) {\n motion.reportedAction = motion.action;\n document.documentElement.dataset.xiaoheiAvatarAction = motion.action + '-3d';\n document.documentElement.dataset.xiaoheiAvatarPose = motion.action;\n }\n return;\n }\n\n if (REDUCED || !scanComplete) {\n motion.action = 'settle';\n motion.walkBlend += (0 - motion.walkBlend) * (1 - Math.exp(-dt * 8));\n motion.runBlend += (0 - motion.runBlend) * (1 - Math.exp(-dt * 8));\n } else {\n if (motion.phase === 'settle') {\n xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1400);\n } else if (motion.phase === 'idle' && now >= motion.phaseUntil) {\n xiaoheiAvatarBeginIndependentAction(motion, now);\n } else if (motion.phase === 'turn' && now >= motion.phaseUntil) {\n var queuedAction = motion.queuedAction || 'walk';\n motion.queuedAction = '';\n xiaoheiAvatarSetMotionPhase(motion, queuedAction, now, 0);\n } else if (motion.phase === 'jump-crouch' && now >= motion.phaseUntil) {\n xiaoheiAvatarSetMotionPhase(motion, 'jump-air', now, 680);\n } else if (motion.phase === 'jump-air' && now >= motion.phaseUntil) {\n xiaoheiAvatarSetMotionPhase(motion, 'jump-land', now, 320);\n } else if (motion.phase === 'jump-land' && now >= motion.phaseUntil) {\n xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1500 + Math.random() * 1100);\n } else if (motion.phase === 'sit-down' && now >= motion.phaseUntil) {\n xiaoheiAvatarSetMotionPhase(motion, 'sit', now, 1650);\n } else if (motion.phase === 'sit' && now >= motion.phaseUntil) {\n xiaoheiAvatarSetMotionPhase(motion, 'stand-up', now, 720);\n } else if (motion.phase === 'stand-up' && now >= motion.phaseUntil) {\n xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1600 + Math.random() * 1200);\n }\n\n var travelling = motion.phase === 'walk' || motion.phase === 'run';\n if (travelling) {\n var running = motion.phase === 'run';\n motion.anchorT += motion.walkDirection\n * (running ? 0.036 : motion.walkSpeed)\n * dt;\n motion.walkPhase += dt * (running ? 9.4 : 6.7);\n var reachedTarget = motion.walkDirection > 0\n ? motion.anchorT >= motion.travelTargetT\n : motion.anchorT <= motion.travelTargetT;\n if (reachedTarget) {\n motion.anchorT = motion.travelTargetT;\n xiaoheiAvatarSetMotionPhase(motion, 'idle', now, 1500 + Math.random() * 1300);\n }\n }\n\n var actions = {\n walk: 'walking',\n run: 'running',\n turn: 'turning',\n 'jump-crouch': 'jumping',\n 'jump-air': 'jumping',\n 'jump-land': 'landing',\n 'sit-down': 'sitting-down',\n sit: 'sitting',\n 'stand-up': 'standing-up'\n };\n motion.action = actions[motion.phase] || 'waiting';\n var locomotionTarget = travelling ? 1 : 0;\n var runTarget = motion.phase === 'run' ? 1 : 0;\n motion.walkBlend += (locomotionTarget - motion.walkBlend)\n * (1 - Math.exp(-dt * 10));\n motion.runBlend += (runTarget - motion.runBlend)\n * (1 - Math.exp(-dt * 10));\n }\n\n if (motion.reportedAction !== motion.action) {\n motion.reportedAction = motion.action;\n document.documentElement.dataset.xiaoheiAvatarAction = motion.action + '-3d';\n document.documentElement.dataset.xiaoheiAvatarPose = motion.action;\n }\n }\n\n function xiaoheiAvatarRestoreImportedRig(rig) {\n Object.keys(rig.restByName).forEach(function (name) {\n var bone = rig.bonesByName[name];\n var rest = rig.restByName[name];\n bone.position.copy(rest.position);\n bone.quaternion.copy(rest.quaternion);\n bone.scale.copy(rest.scale);\n });\n }\n\n function xiaoheiAvatarApplyImportedDelta(rig, name, x, y, z) {\n var bone = rig.bonesByName[name];\n var rest = rig.restByName[name];\n if (!bone || !rest) return;\n xiaoheiMotionEuler.set(x, y, z, 'XYZ');\n xiaoheiMotionDeltaQ.setFromEuler(xiaoheiMotionEuler);\n bone.quaternion.copy(rest.quaternion).multiply(xiaoheiMotionDeltaQ);\n }\n\n function xiaoheiAvatarApplyImportedArmPose(rig, name, base, swing) {\n var bone = rig.bonesByName[name];\n var rest = rig.restByName[name];\n if (!bone || !rest) return;\n xiaoheiMotionEuler.set(swing, 0, 0, 'XYZ');\n xiaoheiMotionDeltaQ.setFromEuler(xiaoheiMotionEuler);\n bone.quaternion.copy(rest.quaternion).multiply(base).multiply(xiaoheiMotionDeltaQ);\n }\n\n function xiaoheiAvatarApplyImportedArmBlend(rig, name, from, to, blend) {\n var bone = rig.bonesByName[name];\n var rest = rig.restByName[name];\n if (!bone || !rest) return;\n xiaoheiMotionPoseQ.copy(from).slerp(to, blend);\n bone.quaternion.copy(rest.quaternion).multiply(xiaoheiMotionPoseQ);\n }\n\n /* Mixamo legs are hinge joints in the sagittal plane. Keep the complete\n gait on each bone's local X axis: this prevents a procedural target from\n twisting a knee sideways or rolling a shoe onto its outer edge. */\n function xiaoheiAvatarResolveImportedLegPose(phase, blend, runBlend) {\n var stanceEnd = THREE.MathUtils.lerp(0.62, 0.54, runBlend);\n var forward = THREE.MathUtils.lerp(0.24, 0.34, runBlend);\n var backward = THREE.MathUtils.lerp(-0.22, -0.30, runBlend);\n var swingKnee = THREE.MathUtils.lerp(0.62, 0.82, runBlend);\n var hip = 0;\n var knee = 0;\n if (phase < stanceEnd) {\n var stance = xiaoheiMotionSmoothstep(0, stanceEnd, phase);\n hip = THREE.MathUtils.lerp(forward, backward, stance);\n knee = -0.045 - Math.sin(Math.PI * stance)\n * THREE.MathUtils.lerp(0.055, 0.10, runBlend);\n } else {\n var swing = xiaoheiMotionSmoothstep(stanceEnd, 1, phase);\n hip = THREE.MathUtils.lerp(backward, forward, swing);\n knee = -0.045 - Math.sin(Math.PI * swing) * swingKnee;\n }\n hip *= blend;\n knee *= blend;\n return {\n hip: hip,\n knee: Math.min(0, knee),\n foot: THREE.MathUtils.clamp(-hip - knee * 0.72, -0.30, 0.46)\n };\n }\n\n function xiaoheiAvatarResolveImportedActionPose(avatar, now) {\n var motion = avatar.motion;\n var progress = xiaoheiAvatarMotionProgress(motion, now);\n var pose = {\n sit: 0,\n crouch: 0,\n air: 0,\n rootY: 0,\n spineX: 0,\n armX: 0\n };\n if (motion.phase === 'sit-down') pose.sit = progress;\n else if (motion.phase === 'sit') pose.sit = 1;\n else if (motion.phase === 'stand-up') pose.sit = 1 - progress;\n else if (motion.phase === 'jump-crouch') pose.crouch = progress;\n else if (motion.phase === 'jump-air') {\n pose.crouch = 1 - Math.sin(Math.PI * progress) * 0.48;\n pose.air = Math.sin(Math.PI * progress);\n } else if (motion.phase === 'jump-land') {\n pose.crouch = 1 - progress;\n }\n pose.rootY = -pose.sit * avatar.reviewedHeight * 0.235\n - pose.crouch * avatar.reviewedHeight * 0.052\n + pose.air * avatar.reviewedHeight * 0.13;\n pose.spineX = pose.sit * 0.12 + pose.crouch * 0.10;\n pose.armX = pose.crouch * 0.10 + pose.air * 0.12;\n return pose;\n }\n\n function xiaoheiAvatarPoseImportedMotion(avatar, now) {\n var motion = avatar.motion;\n var rig = avatar.rig;\n var seconds = now * 0.001;\n var breath = Math.sin(seconds * 1.45);\n var sway = Math.sin(seconds * 0.58 + 0.7);\n var gaze = xiaoheiAvatarHover;\n var pointerX = ndc.x <= 2 ? ndc.x : 0;\n var pointerY = ndc.y <= 2 ? ndc.y : 0;\n var walk = motion.walkBlend || 0;\n var run = motion.runBlend || 0;\n var step = Math.sin(motion.walkPhase || 0) * walk;\n var actionPose = xiaoheiAvatarResolveImportedActionPose(avatar, now);\n var armSwing = step * THREE.MathUtils.lerp(0.055, 0.15, run);\n\n xiaoheiAvatarRestoreImportedRig(rig);\n if (motion.poseReview) {\n var review = xiaoheiMotionSmoothstep(0, 1, motion.reviewProgress || 0);\n var support = xiaoheiMotionSmoothstep(0.12, 0.88, review);\n var seated = xiaoheiMotionSmoothstep(0, 0.78, review);\n var dangling = review > 0.98\n ? Math.sin((now - motion.reviewStarted) * 0.001 * 1.45) * 0.085\n : 0;\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:Spine', seated * 0.075, 0, seated * -0.055\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:Spine2', seated * -0.035, 0, seated * 0.025\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:Head', avatar.screenPitch || 0, 0, seated * 0.035\n );\n xiaoheiAvatarApplyImportedArmBlend(\n rig, 'mixamorig:LeftArm',\n xiaoheiMotionArmDown.leftUpper, xiaoheiMotionSitArms.leftUpper, support\n );\n xiaoheiAvatarApplyImportedArmBlend(\n rig, 'mixamorig:RightArm',\n xiaoheiMotionArmDown.rightUpper, xiaoheiMotionSitArms.rightUpper, support\n );\n xiaoheiAvatarApplyImportedArmBlend(\n rig, 'mixamorig:LeftForeArm',\n xiaoheiMotionArmDown.leftLower, xiaoheiMotionSitArms.leftLower, support\n );\n xiaoheiAvatarApplyImportedArmBlend(\n rig, 'mixamorig:RightForeArm',\n xiaoheiMotionArmDown.rightLower, xiaoheiMotionSitArms.rightLower, support\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:LeftUpLeg', seated * 1.08, 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:LeftLeg', seated * (-1.02 + dangling), 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:LeftFoot', seated * 0.20, 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:RightUpLeg', seated * 0.78, 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:RightLeg', seated * -1.26, 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:RightFoot', seated * 0.36, 0, 0\n );\n avatar.model.position.y = (avatar.groundOffset || 0)\n - avatar.reviewedHeight * 0.369 * seated;\n avatar.model.scale.set(1, 1, 1);\n return;\n }\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:Spine',\n breath * 0.012 + walk * THREE.MathUtils.lerp(0.025, 0.075, run)\n + actionPose.spineX,\n -sway * 0.010,\n -sway * 0.015\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:Spine2',\n -breath * 0.010,\n sway * 0.012,\n sway * 0.012\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:Head',\n (avatar.screenPitch || 0) + Math.sin(seconds * 0.78) * 0.018 - pointerY * gaze * 0.045,\n pointerX * gaze * 0.12 - sway * 0.012,\n sway * 0.018\n );\n xiaoheiAvatarApplyImportedArmPose(\n rig, 'mixamorig:LeftArm',\n xiaoheiMotionArmDown.leftUpper,\n -armSwing - actionPose.armX + breath * 0.008\n );\n xiaoheiAvatarApplyImportedArmPose(\n rig, 'mixamorig:RightArm',\n xiaoheiMotionArmDown.rightUpper,\n armSwing + actionPose.armX - breath * 0.008\n );\n xiaoheiAvatarApplyImportedArmPose(\n rig, 'mixamorig:LeftForeArm',\n xiaoheiMotionArmDown.leftLower,\n run * Math.max(0, step) * 0.035\n );\n xiaoheiAvatarApplyImportedArmPose(\n rig, 'mixamorig:RightForeArm',\n xiaoheiMotionArmDown.rightLower,\n -run * Math.max(0, -step) * 0.035\n );\n\n avatar.model.position.y = (avatar.groundOffset || 0) + actionPose.rootY;\n avatar.model.scale.set(1, 1, 1);\n if (\n (motion.phase === 'walk' || motion.phase === 'run')\n && walk > 0.04\n && (!avatar.scan || avatar.scan.complete)\n ) {\n var cycle = (motion.walkPhase / (Math.PI * 2)) % 1;\n if (cycle < 0) cycle += 1;\n var leftLeg = xiaoheiAvatarResolveImportedLegPose(cycle, walk, run);\n var rightLeg = xiaoheiAvatarResolveImportedLegPose((cycle + 0.5) % 1, walk, run);\n } else {\n leftLeg = { hip: 0, knee: 0, foot: 0 };\n rightLeg = { hip: 0, knee: 0, foot: 0 };\n }\n var seatedHip = actionPose.sit * 0.82;\n var seatedKnee = actionPose.sit * -1.18;\n var seatedFoot = actionPose.sit * 0.30;\n var jumpHip = actionPose.crouch * 0.20;\n var jumpKnee = actionPose.crouch * -0.58;\n var jumpFoot = actionPose.crouch * 0.22;\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:LeftUpLeg',\n THREE.MathUtils.clamp(leftLeg.hip + seatedHip + jumpHip, -0.55, 1.10), 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:LeftLeg',\n THREE.MathUtils.clamp(leftLeg.knee + seatedKnee + jumpKnee, -1.32, 0), 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:LeftFoot',\n THREE.MathUtils.clamp(leftLeg.foot + seatedFoot + jumpFoot, -0.34, 0.52), 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:RightUpLeg',\n THREE.MathUtils.clamp(rightLeg.hip + seatedHip + jumpHip, -0.55, 1.10), 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:RightLeg',\n THREE.MathUtils.clamp(rightLeg.knee + seatedKnee + jumpKnee, -1.32, 0), 0, 0\n );\n xiaoheiAvatarApplyImportedDelta(\n rig, 'mixamorig:RightFoot',\n THREE.MathUtils.clamp(rightLeg.foot + seatedFoot + jumpFoot, -0.34, 0.52), 0, 0\n );\n }\n\n function xiaoheiAvatarPoseMotion(avatar, now) {\n var motion = avatar.motion;\n var rig = avatar.rig;\n if (!motion || !rig) return;\n if (rig.imported) {\n xiaoheiAvatarPoseImportedMotion(avatar, now);\n return;\n }\n if (avatar.animation) {\n if (!avatar.animation.lastNow) avatar.animation.lastNow = now;\n var animationDelta = Math.min(\n 0.05,\n Math.max(0, (now - avatar.animation.lastNow) * 0.001)\n );\n avatar.animation.lastNow = now;\n if (!avatar.scan || avatar.scan.complete) avatar.animation.mixer.update(animationDelta);\n avatar.model.position.y = avatar.groundOffset || 0;\n avatar.model.scale.set(1, 1, 1);\n return;\n }\n var bones = rig.bones;\n var rest = rig.rest;\n var seconds = now * 0.001;\n var breath = Math.sin(seconds * 1.45);\n var breathLift = Math.sin(seconds * 1.45 + 0.58);\n var sway = Math.sin(seconds * 0.56 + 0.7);\n var counterSway = Math.sin(seconds * 0.56 + 2.65);\n var gaze = xiaoheiAvatarHover;\n var pointerX = ndc.x <= 2 ? ndc.x : 0;\n var pointerY = ndc.y <= 2 ? ndc.y : 0;\n var walk = motion.walkBlend || 0;\n var step = Math.sin(motion.walkPhase || 0);\n var stepOpposite = Math.sin((motion.walkPhase || 0) + Math.PI);\n var strideL = step * walk;\n var strideR = stepOpposite * walk;\n var footfall = Math.abs(Math.cos(motion.walkPhase || 0)) * walk;\n\n bones.pelvis.position.y = rest.pelvisY\n + breath * avatar.reviewedHeight * 0.0035 * (1 - walk * 0.65)\n + footfall * avatar.reviewedHeight * 0.0055;\n bones.spine.position.y = rest.spineY + breathLift * avatar.reviewedHeight * 0.0012;\n bones.chest.position.y = rest.chestY + breathLift * avatar.reviewedHeight * 0.0018;\n bones.neck.position.y = rest.neckY;\n bones.head.position.y = rest.headY;\n bones.upperArmL.position.x = rest.upperArmLX * 0.92;\n bones.upperArmR.position.x = rest.upperArmRX * 0.92;\n\n bones.pelvis.rotation.set(strideL * 0.025, sway * 0.006, sway * 0.013);\n bones.spine.rotation.set(breath * 0.007 + walk * 0.035, -sway * 0.010, -sway * 0.020);\n bones.chest.rotation.set(-breath * 0.009 - walk * 0.022, sway * 0.014, sway * 0.014);\n bones.neck.rotation.set(-breath * 0.004, 0, -sway * 0.006);\n bones.head.rotation.set(\n (avatar.screenPitch || 0) + Math.sin(seconds * 0.78) * 0.020 - pointerY * gaze * 0.050,\n pointerX * gaze * 0.135 + counterSway * 0.014,\n sway * 0.026 - pointerX * gaze * 0.012\n );\n\n bones.upperArmL.rotation.set(\n breath * 0.012 + strideR * 0.075,\n -0.075 + sway * 0.010 + strideR * 0.18,\n 1.385 + breath * 0.022 - gaze * 0.016\n );\n bones.lowerArmL.rotation.set(0, 0, 0.165 + breathLift * 0.016 + gaze * 0.012);\n bones.handL.rotation.set(0, -0.018, -0.055 + sway * 0.014);\n bones.upperArmR.rotation.set(\n -breath * 0.012 + strideL * 0.075,\n 0.075 - sway * 0.010 + strideL * 0.18,\n -1.385 - breath * 0.022 + gaze * 0.016\n );\n bones.lowerArmR.rotation.set(0, 0, -0.165 - breathLift * 0.016 - gaze * 0.012);\n bones.handR.rotation.set(0, 0.018, 0.055 - sway * 0.014);\n\n bones.upperLegL.rotation.set(strideL * 0.24, 0, sway * 0.004);\n bones.lowerLegL.rotation.set(Math.max(0, -strideL) * 0.28, 0, 0);\n bones.footL.rotation.set(-strideL * 0.10 - Math.max(0, -strideL) * 0.16, 0, 0);\n bones.upperLegR.rotation.set(strideR * 0.24, 0, -sway * 0.004);\n bones.lowerLegR.rotation.set(Math.max(0, -strideR) * 0.28, 0, 0);\n bones.footR.rotation.set(-strideR * 0.10 - Math.max(0, -strideR) * 0.16, 0, 0);\n\n avatar.model.position.y = breath * avatar.reviewedHeight * 0.0018 * (1 - walk * 0.6);\n avatar.model.scale.set(1, 1, 1);\n }\n";
|
|
3
|
-
//# sourceMappingURL=avatar-motion.d.ts.map
|