Skip to content

Add 3MF export support (UI, exporter, and tests)#521

Open
tracygardner wants to merge 2 commits intomainfrom
codex/add-3mf-export
Open

Add 3MF export support (UI, exporter, and tests)#521
tracygardner wants to merge 2 commits intomainfrom
codex/add-3mf-export

Conversation

@tracygardner
Copy link
Copy Markdown
Contributor

@tracygardner tracygardner commented Apr 11, 2026

Motivation

  • Provide 3MF export as an additional export format so meshes can be exported in the 3MF container format.

Description

  • Added a `

Codex Task

Summary by CodeRabbit

  • New Features

    • Added support for exporting 3D models in 3MF format, now available alongside existing export options in the export menu.
    • The export block in the visual editor now includes a 3MF option.
  • Tests

    • Added test coverage for 3MF export to verify serialization and download behavior.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 11, 2026

Deploying flockxr with  Cloudflare Pages  Cloudflare Pages

Latest commit: ed0d829
Status: ✅  Deploy successful!
Preview URL: https://14454f68.flockxr.pages.dev
Branch Preview URL: https://codex-add-3mf-export.flockxr.pages.dev

View logs

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3985cf9b-d81b-426c-bd95-2310e3023d86

📥 Commits

Reviewing files that changed from the base of the PR and between 5ac81d6 and ed0d829.

📒 Files selected for processing (1)
  • api/xr.js

📝 Walkthrough

Walkthrough

Adds 3MF export support to flockXR.exportMesh: constructs a ThreeMfSerializer, calls SerializeToMemoryAsync on the mesh list, and downloads a .3mf file when output is produced; also adds a 3MF option to the Blockly export block and a test covering the flow.

Changes

Cohort / File(s) Summary
3MF Export Implementation
api/xr.js
Introduced a format === "3MF" branch that imports/ensures fflate on globalThis, instantiates flock.EXPORT.ThreeMfSerializer, awaits flock.EXPORT.ThreeMf.SerializeToMemoryAsync(serializer, ...meshList), downloads .3mf with MIME model/3mf if data present, and wraps the sequence in a try/catch with error logging.
UI Integration
blocks/connect.js
Added 3MF to the FORMAT dropdown for the export_mesh Blockly block.
Test Coverage
tests/xr-export.test.js
Added async test that stubs ThreeMfSerializer and SerializeToMemoryAsync, mocks flock.download, asserts serializer received expected meshes and download invoked with ${mesh.name}.3mf, MIME model/3mf, and Uint8Array data; restores originals in finally.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ExportMesh as flockXR.exportMesh
    participant Serializer as ThreeMfSerializer
    participant Serialize as SerializeToMemoryAsync
    participant Download as flock.download

    User->>ExportMesh: exportMesh(treeId, "3MF")
    ExportMesh->>Serializer: new ThreeMfSerializer()
    ExportMesh->>Serialize: SerializeToMemoryAsync(serializer, ...meshList)
    Serialize-->>ExportMesh: Uint8Array output
    alt Output present
        ExportMesh->>Download: download(filename: `${mesh.name}.3mf`, data, "model/3mf")
        Download-->>User: .3mf file
    else No output
        ExportMesh-->>ExportMesh: log "no output data produced"
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 Hop-hop, I zipped the mesh so neat,
Tiny bytes in a 3MF treat,
Serialize, pack, then down they fall —
A tiny model, ready to call. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding 3MF export support across UI (Blockly block), exporter (api/xr.js), and tests.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/add-3mf-export

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/xr-export.test.js`:
- Around line 121-132: The changed test file tests/xr-export.test.js is failing
Prettier; run the project's formatter on the modified files (e.g., npx prettier
--write or npm run format) to reformat the test and any related files so the CI
Prettier check passes, then re-stage the formatted changes — pay attention to
formatting around the mocked symbols like
flock.EXPORT.ThreeMf.SerializeToMemoryAsync, flock.EXPORT.ThreeMfSerializer,
flock.download, and the variables serializerInstance/serializeMeshes so no
lint/format differences remain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1a781241-c4a4-4453-af70-c5a689bfa391

📥 Commits

Reviewing files that changed from the base of the PR and between ad200a6 and 5ac81d6.

📒 Files selected for processing (3)
  • api/xr.js
  • blocks/connect.js
  • tests/xr-export.test.js

Comment on lines +121 to +132
const originalSerializeToMemoryAsync = flock.EXPORT.ThreeMf.SerializeToMemoryAsync;
const originalDownload = flock.download;

let serializerInstance;
let serializeMeshes;
let downloadedFile = null;

flock.EXPORT.ThreeMfSerializer = function MockThreeMfSerializer() {
serializerInstance = this;
};
flock.EXPORT.ThreeMf.SerializeToMemoryAsync = async (serializer, ...meshes) => {
serializeMeshes = meshes;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Run Prettier on changed files to unblock CI.

The PR currently fails the Prettier check; please run formatting before merge.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/xr-export.test.js` around lines 121 - 132, The changed test file
tests/xr-export.test.js is failing Prettier; run the project's formatter on the
modified files (e.g., npx prettier --write or npm run format) to reformat the
test and any related files so the CI Prettier check passes, then re-stage the
formatted changes — pay attention to formatting around the mocked symbols like
flock.EXPORT.ThreeMf.SerializeToMemoryAsync, flock.EXPORT.ThreeMfSerializer,
flock.download, and the variables serializerInstance/serializeMeshes so no
lint/format differences remain.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 11, 2026

Deploying flockdev with  Cloudflare Pages  Cloudflare Pages

Latest commit: ed0d829
Status: ✅  Deploy successful!
Preview URL: https://825e3ae7.flockdev.pages.dev
Branch Preview URL: https://codex-add-3mf-export.flockdev.pages.dev

View logs

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant