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

Abierto
#134 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
15/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
javascript
Área
full-stack

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

能力 / 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 门槛刚好、社区能持续贡献的原因。

Lenguaje dominante
JavaScript
Estrellas
84
Forks
62
Merge medio
1 d 20 h
PR fusionados (30 d)
62

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de MiniMax-AI/MiniMax-Code-MiniApps

Todos los issues de MiniMax-AI/MiniMax-Code-MiniApps

Issues similares

Más issues de JavaScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.