humanoid-chibi.js 2.98 KB
// humanoid-chibi.js — 分件人形「大头 chibi」骨架(RigDefinition)。
// 移植自旧原型 client/js/stage/rig/humanoid-chibi.js(注册名 humanoid_parts,全角色实际使用的就是它)。
//
// 与 humanoid_v1 的关键差异:这是按真实角色立绘(worker/lady 等,画布 454×750)调好骨距的骨架——
// neck 距 torso -273、head -30、face -120、upper_arm 85/-235、shin 间距 130。worker/lady 的部件对齐
// 数值(anchor/bonePos/scale)全部按本骨架的 setup-pose 调出,故角色必须绑本骨架而非 humanoid_v1,
// 否则骨距不符会把身体压扁、头显得过大(实测过的坑)。
//
// 坐标系:+y 向下,角度「度」;root 在双脚之间贴地(y=0),身体向上为负 y。bones 顺序父先于子。

/** @type {import('../types.js').RigDefinition} */
export const HUMANOID_CHIBI = {
  id: 'humanoid_parts',
  // rig 设计基准画布(部件图按此坐标系/尺度出图)。
  canvas: { width: 454, height: 750 },
  groundY: 0,

  bones: [
    { name: 'root', parent: null, pos: { x: 0, y: 0 }, rotation: 0 },
    { name: 'hip', parent: 'root', pos: { x: 0, y: -244 }, rotation: 0 },
    { name: 'torso', parent: 'hip', pos: { x: 0, y: 0 }, rotation: 0 },
    { name: 'neck', parent: 'torso', pos: { x: 0, y: -273 }, rotation: 0 },
    { name: 'head', parent: 'neck', pos: { x: 0, y: -30 }, rotation: 0 },
    // 表情子骨骼:挂在头下,跟随头一起动;表情图(眼/嘴)叠在脸区。
    { name: 'face', parent: 'head', pos: { x: 0, y: -120 }, rotation: 0 },

    { name: 'upper_arm_l', parent: 'torso', pos: { x: 85, y: -235 }, rotation: 4 },
    { name: 'lower_arm_l', parent: 'upper_arm_l', pos: { x: 0, y: 120 }, rotation: 0 },
    { name: 'upper_arm_r', parent: 'torso', pos: { x: -85, y: -235 }, rotation: -4 },
    { name: 'lower_arm_r', parent: 'upper_arm_r', pos: { x: 0, y: 120 }, rotation: 0 },

    { name: 'thigh_l', parent: 'hip', pos: { x: 30, y: 0 }, rotation: 0 },
    { name: 'shin_l', parent: 'thigh_l', pos: { x: 0, y: 130 }, rotation: 0 },
    { name: 'thigh_r', parent: 'hip', pos: { x: -30, y: 0 }, rotation: 0 },
    { name: 'shin_r', parent: 'thigh_r', pos: { x: 0, y: 130 }, rotation: 0 },
  ],

  // z-order(低=靠后)。右臂/右腿在身后,左臂/左腿在身前。
  slots: [
    { name: 'upper_arm_r', bone: 'upper_arm_r', zOrder: 2 },
    { name: 'lower_arm_r', bone: 'lower_arm_r', zOrder: 3 },
    { name: 'thigh_r', bone: 'thigh_r', zOrder: 4 },
    { name: 'shin_r', bone: 'shin_r', zOrder: 5 },
    { name: 'thigh_l', bone: 'thigh_l', zOrder: 6 },
    { name: 'shin_l', bone: 'shin_l', zOrder: 7 },
    { name: 'hip', bone: 'hip', zOrder: 9 },
    { name: 'torso', bone: 'torso', zOrder: 10 },
    { name: 'neck', bone: 'neck', zOrder: 11 },
    { name: 'head', bone: 'head', zOrder: 20 },
    { name: 'face', bone: 'face', zOrder: 25 },
    { name: 'upper_arm_l', bone: 'upper_arm_l', zOrder: 30 },
    { name: 'lower_arm_l', bone: 'lower_arm_l', zOrder: 31 },
  ],
}