{
  "schemaVersion": 1,
  "atomId": "board_entity_sprite.aiimage",
  "bundleType": "aiimage",
  "category": "visual",
  "mode": "generative",
  "label": {
    "zh": "棋盘实体精灵（单图旋转）",
    "en": "Board entity sprite (single image + rotation)"
  },
  "outputModes": ["2d-sprite", "3d-model"],
  "tags": [
    "visual",
    "sprite",
    "entity",
    "board",
    "direction",
    "top-down",
    "puzzle",
    "car",
    "vehicle",
    "arrow-replacement",
    "directional-indicator",
    "3d-model",
    "glb",
    "threejs"
  ],
  "bindingRoles": [
    "boardEntitySprite",
    "directionalIndicator"
  ],
  "generation3D": {
    "kind": "3d-model",
    "methods": ["procedural-geometry", "loaded-glb", "ai-generated"],
    "colorVariants": {
      "strategy": "material-color-swap",
      "description": "一个 geometry + N 种 MeshStandardMaterial.color = 多色变体，无需生成多个模型文件",
      "colorSet": ["teal", "red", "yellow", "purple", "green", "orange", "blue", "pink", "cyan", "salmon"],
      "codePattern": "const mat = new THREE.MeshStandardMaterial({ color: CAR_COLORS[i] }); const mesh = new THREE.Mesh(sharedGeo, mat);"
    },
    "canonicalFacing": "+Z",
    "normalize": "fit-unit-cube",
    "format": "glb",
    "postProcess": [
      { "step": "normalize-size", "method": "fit-to-unit-cube", "description": "缩放模型使其 bounding box 适配 1×1×1" },
      { "step": "verify-orientation", "expected": "+Z", "fallback": "rotate-Y-180" },
      { "step": "center-origin", "description": "确保模型原点在几何中心底部" }
    ]
  },
  "generation": {
    "kind": "single-image",
    "promptTemplate": "top-down bird's eye view of a cute cartoon {entity}, facing upward, simple flat design, bright vivid colors, game asset, white background, centered on canvas, no shadow, 256x256 icon style",
    "variables": {
      "entity": {
        "type": "string",
        "description": "实体类型，替换 prompt 中的 {entity}",
        "examples": ["car", "race car", "taxi", "bus", "airplane", "rocket", "boat", "ship", "fish", "turtle", "bird", "UFO", "ambulance", "fire truck"]
      }
    },
    "aspectRatio": "1:1",
    "model": "google/gemini-3.1-flash-image-preview",
    "style": "cartoon-flat",
    "platformSkill": "playcraft-image-generation",
    "postProcess": [
      { "step": "remove-background", "method": "floodfill" },
      { "step": "trim" },
      { "step": "verify-orientation", "expected": "up", "fallback": "rotate-180" },
      { "step": "convert", "format": "webp", "quality": 90 }
    ],
    "variants": {
      "description": "可选：批量生成多色变体。为同一实体生成 N 种颜色版本。",
      "colorSet": ["teal", "red", "yellow", "purple", "green", "orange", "blue", "pink", "cyan", "salmon"],
      "promptTemplate": "top-down bird's eye view of a cute cartoon {entity}, {color} colored body, facing upward, simple flat design, bright vivid colors, game asset, white background, centered on canvas, no shadow, 256x256 icon style",
      "outputPattern": "{entity}_{color}.webp",
      "referenceImage": "{entity}.webp"
    }
  },
  "result": {
    "outputFile": "{entity}.webp",
    "format": "webp",
    "usage": "single-image-with-rotation",
    "constraints": {
      "transparent": true,
      "centered": true,
      "defaultFacing": "declared-in-binding"
    }
  },
  "binding": {
    "role": "boardEntitySprite",
    "target": "assets/images/{entity}.webp",
    "type": "image-asset-reference",
    "integration": {
      "pattern": "single-image-rotation",
      "defaultFacing": "down",
      "directionToAngle": {
        "_comment": "旋转角度取决于图片默认朝向。以 defaultFacing=down 为例：",
        "up": "Math.PI",
        "right": "-Math.PI / 2",
        "down": "0",
        "left": "Math.PI / 2"
      },
      "codePattern": {
        "import": "import entityImg from 'assets/images/{entity}.webp';",
        "preload": "this.load.image('{entity}', entityImg);",
        "create": "const sprite = scene.add.image(x, y, '{entity}').setOrigin(0.5).setRotation(angle);",
        "scale": "sprite.setScale(Math.min(targetSize / sprite.width, targetSize / sprite.height));",
        "tint": "sprite.setTint(color); // 可选：着色或阻挡变红"
      }
    },
    "integration3D": {
      "pattern": "single-model-color-swap",
      "canonicalFacing": "+Z",
      "directionToAngleY": {
        "_comment": "Y 轴旋转角度。模型默认朝 +Z（ArrowDirection.Down 对应角度 0）",
        "up": "Math.PI",
        "right": "Math.PI / 2",
        "down": "0",
        "left": "-Math.PI / 2"
      },
      "codePattern": {
        "import": "import carModelUrl from 'assets/models/car.glb';",
        "load": "loader.loadAll({ models: [{ key: 'car', url: carModelUrl }] })",
        "create": "const gltf = loader.getModel('car'); const mesh = gltf.scene.children[0].clone(); mesh.rotation.y = directionToAngleY(direction);",
        "colorVariant": "const mat = (mesh as THREE.Mesh).material = new THREE.MeshStandardMaterial({ color: colorHex }); ",
        "scale": "mesh.scale.setScalar(cellSize * 0.8);"
      }
    }
  },
  "files": {
    "skill": "SKILL.md",
    "ref": [
      "ref/car.webp",
      "ref/car.png",
      "ref/ProceduralCar.ts"
    ]
  },
  "refAssets": {
    "car.webp": {
      "description": "俯视卡通小汽车（默认朝下），24KB webp，已完成去背景+裁切+压缩",
      "defaultFacing": "down",
      "size": "380x496",
      "generatedWith": {
        "prompt": "top-down bird's eye view of a cute cartoon car, facing upward, simple flat design, bright vivid colors, game asset, white background, centered on canvas, no shadow, 256x256 icon style",
        "model": "google/gemini-3.1-flash-image-preview",
        "postProcess": ["remove-background(floodfill)", "trim", "convert(webp,q90)"]
      }
    },
    "car.png": {
      "description": "同上的 PNG 高清版本（透明背景），409KB，作为备份或需要无损场景使用",
      "defaultFacing": "down"
    }
  }
}
