Skip to content

3MFLoader: Support external component parts.#33370

Open
jameszhong2008 wants to merge 1 commit intomrdoob:devfrom
jameszhong2008:fix-3mf-production-components
Open

3MFLoader: Support external component parts.#33370
jameszhong2008 wants to merge 1 commit intomrdoob:devfrom
jameszhong2008:fix-3mf-production-components

Conversation

@jameszhong2008
Copy link
Copy Markdown
Contributor

Summary

Add support for 3MF component references that point to external model parts via p:path / path.

This fixes 3MF files exported by tools like BambuStudio where the main 3D/3dmodel.model contains composite objects whose meshes live in 3D/Objects/*.model.

Changes

  • parse and preserve component part paths
  • track model part path for each parsed model document
  • resolve composite components against the referenced model part instead of always using the current model
  • scope built object cache keys by modelPath + objectId to avoid collisions across external model parts
  • throw clearer errors when referenced model parts or object resources are missing

Problem

The loader previously assumed every component.objectid referenced an object inside the current model part. For production-extension style 3MF files, components may instead reference objects stored in another model part such as 3D/Objects/object_1.model.

That caused resources.object[ objectId ] to resolve to undefined, eventually throwing when reading mesh.

Result

3MF files with external component parts can now be loaded correctly instead of failing during composite object construction.

@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Apr 13, 2026

Can you please share a test asset so it's possible to verify your change? The asset should be added to the drop-down UI field in https://threejs.org/examples/webgl_loader_3mf.

@Mugen87 Mugen87 changed the title Support external 3MF component parts 3MFLoader: Support external component parts. Apr 13, 2026
@Mugen87
Copy link
Copy Markdown
Collaborator

Mugen87 commented Apr 13, 2026

While reviewing your PR, I have noticed your branch jameszhong2008:fix-3mf-production-components is 4559 commits behind dev. That is not good. Please do a rebase.

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