Skip to content

feat(ui-plugins): add Product 3D Showcase (product-3d-showcase) - #251

Open
ppppp2005-p wants to merge 10 commits into
zai-org:mainfrom
ppppp2005-p:feat/product-3d-showcase
Open

ppppp2005-p wants to merge 10 commits into
zai-org:mainfrom
ppppp2005-p:feat/product-3d-showcase

Conversation

@ppppp2005-p

Copy link
Copy Markdown

Plugin type (required) / 插件类型(必填)

  • UI Plugin / 是 UI 插件 — provides MCP Apps interactive pages / 提供 MCP Apps 交互页面
  • Standard plugin / 普通插件(非 UI)
  • Not applicable / 不适用

Affected plugin name(s) / 涉及的插件名称:product-3d-showcase (UI Plugin, new)

What / 改动内容

New community UI plugin Product 3D Showcase / 产品 3D 展示: glTF/GLB product model → multi-angle product images, a 360° turntable video and an offline web 3D viewer, all with one consistent studio look.

  • Tools:
    • showcase_open: model plus optional settings. Reports meshes, materials, textures and size, and reuses showcase.json when present.
    • showcase_save.
    • showcase_export: the panel renders and saves; the result is reported back with updateModelContext.
    • App-only: model_data, save_output (only .png/.webm with a magic-byte check, inside the output folder; WebM → MP4 via ffmpeg when available), save_viewer, workspace_files.
  • Model loading:
    • .gltf external buffers and images are inlined server-side.
    • A small GLTFLoader plugin loads textures through <img> and decodes data: buffers directly, so nothing needs fetch under the panel CSP (connect-src 'none').
  • Scene (shared by panel and viewer):
    • RoomEnvironment, key/fill/rim presets, ACES tone mapping and a ShadowMaterial floor, which works on transparent PNGs.
    • Bounding-sphere auto-framing per yaw/pitch/zoom.
  • Video:
    • Frame-by-frame WebCodecs VP9/VP8 encoding with a small built-in WebM muxer, so it is frame-exact regardless of render speed.
    • Falls back to MediaRecorder when WebCodecs is missing.
  • Viewer: index.html + viewer.js (a separate IIFE build) + model.js, which works over file://, with OrbitControls and auto-rotate.
  • Panel: live preview (drag, then "+ Add this view"), angle thumbnails, preset angles, settings and export progress.

Network / API / side effects:

  • Local stdio MCP server; no network, no API keys, no hooks.
  • ffmpeg is optional (MP4 only), called with argument arrays and no shell.
  • Writes only the output folder.

Third-party: three.js (MIT), MCP SDK / ext-apps (MIT), zod (MIT).

Tests:

  • vitest (self-contained: generated GLB/glTF when the real samples are absent) covering:
    • Settings normalisation (presets, clamping, duplicate names).
    • Opening a real GLB (Khronos WaterBottle, CC0).
    • .gltf inlining (Khronos Avocado, CC0) with byte-length checks.
    • Bad model, glTF 1.0 and OBJ errors.
    • The export plan.
    • save_output path and magic-byte guards.
    • Viewer files and HTML escaping.
  • Chrome e2e (official AppBridge host, panel CSP, SwiftShader WebGL):
    • The agent opens the bottle with a transparent background; the user drags to a new view, adds it, switches to soft lighting and exports.
    • Each PNG is checked for 1200 px, a transparent corner, an opaque centre and plausible fill, and front differs from back.
    • The WebM is checked for 720×720 and exactly 90 frames; the MP4 for h264/yuv420p and 90 frames.
    • The Avocado viewer opened from file:// renders the model with no page errors.
  • validate.py, build_dist.py, git diff --check and tsc pass.

A ZCode Desktop demo recording is attached in the comments. / ZCode 桌面版演示录屏见评论。

Self-check / 自查清单

  • Plugin name is unique kebab-case; new external plugin directory is external_plugins/<name>/
  • Usage category is set (productivity)
  • Plugin type and affected names are declared above
  • version 0.1.0 in both plugin.json and marketplace.json
  • README.md (EN) and README_CN.md (中文) both provided and equivalent
  • description_i18n has both en and zh-CN
  • No secrets, machine-specific paths, or private dependencies
  • Model/API/network dependencies documented
  • python3 scripts/validate.py and python3 scripts/build_dist.py pass locally
  • Exercised in ZCode Desktop (ZCode 4.0.0, macOS arm64: installed from a local marketplace, asked it to open models/WaterBottle.glb with the saved settings; the agent called showcase_open, then "导出全部" (Export all) was clicked in the panel, which rendered front.png, three-quarter-left.png, top.png (2000×2000, white background, studio lighting) and viewer/index.html into showcase/WaterBottle/; demo video in the comments)

Note on large models: model_data sends the model to the panel in parts of at most 4 Mi characters (offset/total), because ZCode Desktop closes a stdio MCP server when a single message is over 10 MB (a 9 MB GLB is about 12 MB as base64). Covered by test/model-parts.test.ts.

@ppppp2005-p

Copy link
Copy Markdown
Author

ZCode desktop demo (ZCode 4.0.0, macOS arm64)

product-3d-showcase-demo.mp4

Flow shown:

  1. Installed product-3d-showcase from a local marketplace built from this PR's branch.
  2. Asked ZCode to open models/WaterBottle.glb (Khronos sample, 8.6 MB, CC0) with the settings already saved in showcase/WaterBottle/showcase.json (white background, front / left 3/4 / top angles, studio lighting, no video), calling only showcase_open.
  3. The agent called showcase_open. The side panel opened with a live three.js preview of the bottle, the model picker, the angle list (front, three-quarter-left, top, each with a thumbnail) and the Save / 导出全部 (Export all) buttons.
  4. 导出全部 was clicked in the panel. The panel rendered and saved front.png, three-quarter-left.png and top.png (2000×2000, white background, ground shadow) and the offline web viewer viewer/index.html (+ viewer.js, model.js) into showcase/WaterBottle/; the panel lists the exported files. The last card shows the final state and the three exported images.

Found and fixed while testing in ZCode: the 9 MB model used to go to the panel as one ~12 MB message, which is over ZCode's 10 MB stdio limit, so the plugin server was dropped as soon as the panel opened. model_data now sends large models in parts (see test/model-parts.test.ts).

演示流程:本地 marketplace 安装 → showcase_open 打开 WaterBottle.glb,侧栏面板显示实时预览和角度 → 在面板里点“导出全部” → 生成 3 张 2000×2000 白底产品图和离线网页展示 viewer/index.html。测试中发现并修复:大模型一次性传给面板会超过 ZCode 10 MB 的单条消息上限,现已分段传输。

@panda920

Copy link
Copy Markdown
Collaborator

✅ Internal validation passed. A ZCode maintainer will review the change next; after acceptance, release checks run separately and this PR is closed automatically.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants