Skip to content

feat(demo): open a shared .3mf, .glb or .gltf in the viewer, then in AR (#3482) - #3510

Merged
ThomasGorisse merged 1 commit into
mainfrom
feat/3mf-open-with
Sep 6, 2026
Merged

ThomasGorisse merged 1 commit into
mainfrom
feat/3mf-open-with

Conversation

@ThomasGorisse

Copy link
Copy Markdown
Member

Follow-up to #3483, which taught the SDK to read 3MF. This is the half that lets a file
actually reach it.

Why

Ask ChatGPT for a 3D print from a drawing and it hands back a .3mf. On Android that file
lands in Downloads or in a chat thread and stops there: no installed app claims the type, so
the chooser is empty. The SDK reading the format changes nothing until something in the
chooser opens it.

The demo now declares ACTION_VIEW and ACTION_SEND filters for .3mf, .glb and
.gltf. The file opens in the model viewer under its own name, and the dock's View in AR
carries it into placement at the size the viewer just measured.

The bytes decide, not the metadata

Measured on emulator-5554 (API 36): a .3mf sent through the share sheet arrives with
application/octet-stream as its type and with no queryable display name at all. Both
metadata signals blank — a name/MIME check refuses a file the SDK reads perfectly.

So OpenedModelIntent stages the file first and sniffs it: glTF magic, a glTF-JSON
heuristic, and for a ZIP the SDK's own ThreeMfLoader.isThreeMf, so a .docx or a .jar
is not claimed merely for opening with PK. The declared name and MIME stay as the fallback
for a file too large to sniff.

Three things the platform forces

  • Three filter blocks, not one. A MIME-typed VIEW covers apps that know the type; a
    pathPattern block under application/octet-stream and */* covers the many that do not;
    SEND covers the share sheet.
  • ClipData before EXTRA_STREAM. A sender's FLAG_GRANT_READ_URI_PERMISSION only ever
    covers getData() and the ClipData, never a bare extra — read the extra of a share that
    carries both and openInputStream returns null.
  • The typed getParcelableExtra(name, Uri::class.java) returns null for a Uri on
    Android 13+
    (a real Uri is the hidden Uri$HierarchicalUri subclass). Tried first
    anyway, with the deprecated untyped reader documented behind it, so the day the platform
    fixes it this code is already on the good path.

The incoming file is copied into the app's cache: a content:// grant is scoped to the
launching intent and would expire across the viewer → AR navigation, and ARPlacementDemo
places by location string. Only the current file is kept.

Verified

ACTION_VIEW end to end on emulator-5554 with a three-colour, 68-vertex, 114-triangle
rocket .3mf: it opens upright with its three colours, titled rocket.3mf, and the dock's
View in AR arms the opened file for placement.

13 Robolectric tests cover intent routing (deep links must not be treated as files), the
name/MIME rules, the content sniffing against a genuine ZIP-built 3MF, and a check that the
manifest's pathPattern list and SupportedExtensions cannot drift apart.

Not verified: the ACTION_SEND path end to end — adb cannot reproduce a real share
sheet's ClipData grant, so that path is covered by unit tests and by the grant rule above,
not by a device run. The AR session itself does not start on this emulator ("could not start
an AR session"), so the handoff is verified up to the armed placement screen, not the
placement.

🤖 Generated with Claude Code

…AR (#3482)

Reading 3MF in the SDK only pays off if a file can reach it. On Android a `.3mf`
sitting in Downloads or arriving from a chat has nowhere to go: no installed app
claims the type, so the chooser is empty and the format is a dead end on the very
device it was generated on.

The demo now declares `ACTION_VIEW` and `ACTION_SEND` filters for `.3mf`, `.glb`
and `.gltf`, stages the incoming file and opens it in the model viewer under its
own name; the dock's "View in AR" carries the same file into placement, sized from
the bounds the viewer just measured.

Android's file typing is unreliable, so the bytes decide. Measured on
emulator-5554 (API 36): a `.3mf` sent through the share sheet arrives as
`application/octet-stream` *and* with no queryable display name, so both metadata
signals are blank and a metadata-only check refuses a file the SDK reads
perfectly. `OpenedModelIntent` therefore sniffs the staged file — glTF magic, a
glTF-JSON heuristic, and for a ZIP the SDK's own `ThreeMfLoader.isThreeMf`, so a
`.docx` or a `.jar` is not claimed merely for opening with `PK` — and falls back
to the declared name and MIME when the content says nothing.

Three further things the platform forces:

- The manifest needs three filter blocks, not one. A MIME-typed VIEW covers apps
  that know the type; a `pathPattern` block under `application/octet-stream` and
  `*/*` covers the ones that do not; SEND covers the share sheet.
- `EXTRA_STREAM` is read from the ClipData first. A sender's
  `FLAG_GRANT_READ_URI_PERMISSION` only ever covers `getData()` and the ClipData,
  never a bare extra, so a share carrying both must be read from the clip or
  `openInputStream` returns null.
- The typed `getParcelableExtra(name, Uri::class.java)` returns null for a `Uri`
  on Android 13+ (a real Uri is the hidden `Uri$HierarchicalUri` subclass), so the
  untyped reader stays as a documented fallback behind it.

The file is copied into the app's cache rather than used in place: a `content://`
grant is scoped to the launching intent and would expire across the viewer → AR
navigation, and `ARPlacementDemo` places by location string. Only the current file
is kept.

Verified on emulator-5554: a three-colour 68-vertex rocket `.3mf` opens upright
with its colours, titled `rocket.3mf`, and hands off to AR placement.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@ThomasGorisse
ThomasGorisse merged commit a87174e into main Sep 6, 2026
10 checks passed
@ThomasGorisse
ThomasGorisse deleted the feat/3mf-open-with branch September 6, 2026 00:07
ThomasGorisse added a commit that referenced this pull request Sep 6, 2026
…3482) (#3514)

#3510 stages an incoming file under the fixed name `opened-model`, deliberately: a
display name comes from whichever app shared the file, so putting it on a path
would mean sanitising untrusted text into a filesystem location, and there is never
more than one opened model to hold.

AR placement, though, receives only the `file://` location and derived its row label
from that path's basename. So the user opened `rocket.3mf`, tapped View in AR, and
was offered a model called `opened-model`.

The viewer already hands placement one thing the location cannot carry — the
real-world size it measured from the loaded bounds. The file's own name travels the
same way now, in `DemoSettings.openedModelDisplayName`, with the basename left as
the fallback.

Co-authored-by: Claude Fable 5.1 <[email protected]>
ThomasGorisse added a commit that referenced this pull request Sep 6, 2026
…face (#3519)

* docs(comms): say 3MF and the ChatGPT/Codex plugin on every public surface

The SDK learned to read 3MF (#3483), the demo learned to receive one from the
share sheet (#3510), and the repository became an OpenAI plugin (#3475). None of
the surfaces a user or an AI actually reads had been told.

- **Model Formats** — a new docs page states the whole matrix (glTF/GLB, USDZ,
  `.3mf` on Android with no new API), what the conversion does to units, axes,
  normals and colours, the two things the platform forces when receiving a shared
  file, and the formats still on the roadmap as issues rather than as promises.
- **`llms.txt`** — the other half of the contract: the formats that do NOT load.
  A generator that is not told invents `loadStl`; it now names #3486/#3487/#3488/
  #3491 instead.
- **The skill** — merged with #3511's rule rather than duplicated: only the unit
  and axis facts, and the unsupported-format list, are new.
- **The plugin** — README, CONTRIBUTING, the docs and the site now carry the two
  `codex plugin` commands that were actually exercised, and the manifest gains a
  3MF starter prompt, a matching test case and keywords.
- **Store listings** — rewritten against the shipped app. The Play copy led with a
  Dynamic Sky demo the Android app no longer has and never mentioned Open with;
  the ~50 screens now listed were resolved from `DemoRegistry`'s fragments and the
  iOS scene files.

Three things measured while writing, and fixed:

- `discord.gg/sceneview` returns `Unknown Invite` from Discord's API. It was on
  eight pages of the live site, including both landing-page CTAs. Replaced with
  the live invite the README already used.
- The footer's "Twitter" link pointed at an unrelated personal account. Removed
  rather than guessed at — there is no SceneView account to point it to.
- The MCP server ships 38 samples (`mcp/src/samples.ts`), not the 33 three
  surfaces claimed, and the README advertised two npm packages whose own
  deprecation notices call them archived scaffolding.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs(changelog): name the fragment after its PR (#3519)

Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
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.

1 participant