feat(minimax-pet): 图集行数由图片高度推导,解除 9/11 行白名单

Ouverte
#134 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
15/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Active
Stack technique
javascript
Domaine
full-stack

Piste de recherche

Start with atlasVersionFromSize, ROWS and ANIMATIONS in miniapp/client/pet-player.js, then the spriteVersionNumber check and validateSprite in miniapp/node/pet-store.mjs. The open question is whether the maintainers want the fixed 9/11-row whitelist removed at all, so confirm that before writing code. If it is approved, done means row count derives from height and optional pet.json row metadata plays back, with v1 and v2 pets unchanged.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

能力 / Capability

让宠物图集的行数由图片高度推导,而不是现在的两个写死尺寸;并允许 pet.json 可选地声明第 11 行往后是什么、怎么播。

现状:三处硬约束(以 main 2026-11-13 为准)

1. 元数据层 —— miniapp/node/pet-store.mjs

if (spriteVersionNumber !== undefined && spriteVersionNumber !== 1 && spriteVersionNumber !== 2) {
  throw new PetError(400, 'invalid_pet_json', 'spriteVersionNumber must be 1 or 2 when present');
}

2. 尺寸判定 —— miniapp/client/pet-player.js

const CELL = { width: 192, height: 208, columns: 8 };
const ATLAS_WIDTH = CELL.width * CELL.columns; // 1536
const ROWS = { 1: 9, 2: 11 };
const LOOK_ROW = 9;

/** 1536×1872 → 1, 1536×2288 → 2, otherwise null. */
export function atlasVersionFromSize(width, height) {
  if (width !== ATLAS_WIDTH) return null;
  if (height === ROWS[1] * CELL.height) return 1;
  if (height === ROWS[2] * CELL.height) return 2;
  return null;
}

3. 加载和导入各校验一次 —— pet-player.js 与 pet-store.mjs 的 validateSprite

if (actual === null) {
  throw petError('sprite_size_invalid', `Spritesheet is ${w}×${h}; expected 1536×1872 (v1) or 1536×2288 (v2)`);
}

服务端是同一套逻辑(sprite_size_invalid / sprite_version_mismatch),所以导入和加载两条路都会被挡住。

为什么这构成限制

尺寸判定其实已经是「行数 × 208」算出来的(ROWS[n] * CELL.height),版本号只是它的别名。换句话说,几何计算本来支持任意行数,挡住的是一张只有两个条目的表。

同时播放规则也写死在播放器里:

export const ANIMATIONS = {
  idle: { row: 0, durations: [1680, 660, 660, 840, 840, 1920] },
  'running-right': { row: 1, durations: frames(8, 120, 220) },
  // …
};

所以只放开尺寸还不够——多出来的行没人播。两步都得动。

具体后果:我有一只 1536×4576(22 行)的宠物。第 0-10 行与 v2 完全同构(9 动作 + 16 视线),第 11-13 行是分层零件(身体 / 眼白 / 瞳孔 / 三档眼睑 / 触须 / 左右手 / 裙摆),第 14-21 行是 4 个一次性帧动作。它现在只能以 v2 形态提交(裁掉后 10 行,前 11 行、73 个有效帧、空格 15 个),分层和帧动作在官方播放器里完全不可见。

提议(两档,任选其一,也可以都关掉)

选项 1(最小,约 30-50 行)
不动图集尺寸。允许 pet.json 把现有 9 个动作行里的某一行(例如 review)声明为"一次性动作序列",按 manifest 播完再交还 idle。代价是占用一个标准动作行。

选项 2(推荐,约 100 行)

  1. 尺寸判定改成推导:宽度必须 1536,行数 = 高度 / 208,版本号只做声明校验而不是白名单;
  2. pet.json 增加一个可选字段,声明额外行的用途与播放规则(一次性 / 循环 / 播完交还 idle)。

v1(9 行)和 v2(11 行)的推导结果不变,现有第三方宠物和内置宠物零改动;不带该字段时行为与今天完全一致。

同类先例

openai/codex#20863(2026-05 开,至今 open,标签 app / enhancement / pets)提的是同一件事:宠物能提供图集,但"the app still owns the animation table and event mapping"。它的解法正是加一个向后兼容的可选 animation 字段,并明确"现有 8 列 × 9 行图集仍可作为第一种支持格式"。

明确不需要做的事

  • 不需要为了这个提案接受我的出图约定或图层坐标;
  • 不需要引入新的渲染管线;
  • 提案与同批提交的 v2 宠物无关,关掉不影响它。

什么情况下这个提案该关掉

如果"图集尺寸固定、动作表由 App 说了算"是有意的产品约束——这样所有宠物观感一致、社区只需要画图——那这个提案就应该关掉。我理解这也正是 v2 门槛刚好、社区能持续贡献的原因。

Langage dominant
JavaScript
Étoiles
84
Forks
62
Merge moyen
1 j 20 h
PR mergées (30 j)
62

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de MiniMax-AI/MiniMax-Code-MiniApps

Toutes les issues de MiniMax-AI/MiniMax-Code-MiniApps

Issues similaires

Plus d'issues JavaScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.