Skip to content

Object3d device fixes - #487

Open
Peter-Pater wants to merge 2 commits into
google:mainfrom
Peter-Pater:object3d_device_fixes
Open

Object3d device fixes#487
Peter-Pater wants to merge 2 commits into
google:mainfrom
Peter-Pater:object3d_device_fixes

Conversation

@Peter-Pater

@Peter-Pater Peter-Pater commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Object3d device fixes (on top of PR 417)

Description

Continues #417, which extracted the objects_3d pipeline into the objects3d addon. The extraction was right, but the pipeline didn't work on a headset: boxes were the wrong size, in the wrong place, all facing the same direction.

Root cause — the wrong camera. Rays were cast through a clone of the XR render camera (the ~90° union frustum between the eyes) while the pixels came from the physical passthrough camera (~48° FOV, near the right eye). Different intrinsics, different pose, so every ray left at the wrong angle.

  • Build the frozen camera from the SDK's device-camera model, falling back to the old clone only when unavailable — simulator behaviour is unchanged.
  • Wait for a fresh video frame and pair it with the pose at its captureTime; captures were pairing seconds-old pixels with the current head pose.
  • Enable matchDepthView (the demo overrode the SDK default off), so the depth mesh every ray lands on is no longer rotated relative to the view.
  • Drop the unconditional 90° yaw snap — no confidence gate, up to 45° error.
  • Snap instead to the room's wall direction, estimated from depth-mesh vertical normals. The old grid was the session origin, i.e. wherever the user happened to face at startup.
  • Estimate yaw from a minimum-area rectangle over the convex hull, gated on scatter confidence; PCA alone lands 45° off when two faces are visible.
  • Fix a sign bug the snapping hid: extents measured along (cos a, +sin a), drawn along (cos a, −sin a).
  • Replace the 2,452-line inline demo copy with the addon page (929 lines);

Orientation is selectable via {mode: 'roomFrame' | 'free' | 'cardinal'}, defaulting to roomFrame, which degrades to today's output if estimation fails.

Type of Change

  • Bug fix
  • New feature / enhancement
  • New demo or sample
  • Documentation update

Checklist

  • Tested in simulator & device: Verified functionality in desktop simulator and/or physical hardware (where applicable).
  • Large Assets ($\ge$ 1MB): Submitted separately to xrblocks/proprietary-assets via jsdelivr CDN.
  • SDK Dynamic Dependencies: All new SDK dependencies are dynamically loaded at runtime.
  • Security: Confirmed no hardcoded API keys or secrets are committed.

Disclaimer:

Real-world performers suffers from small objects, sensor accuracy, and object cluttering, so it is not as perfect as in the simulator.

@dli7319

dli7319 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Should we merge 417 first?

@Peter-Pater

Copy link
Copy Markdown
Collaborator Author

Should we merge 417 first?

I am not entirely sure what the standard practice should be here since this is a follow-up PR. But maybe it is good to merge 417 first? This PR inherits all the commits previously made by @salmanmkc, so it should still merge correctly after 417 is merged.

@ruofeidu
ruofeidu requested a review from dli7319 August 5, 2026 19:59
@ruofeidu

ruofeidu commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Thank you Xincheng!

If this is merged, #417 can be closed I guess?

@salmanmkc

salmanmkc commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

i recommend making this a stacked pr, it came out 6 days ago:

it let's you see them both at the same time, #417 will be under and this on top and then they can both merge separately but in the same stack

image

or merge 417 first + rebase of main, it has another few commits that this pr doesn't have yet (probably conflicts)

@dli7319

dli7319 commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

@Peter-Pater Can you rebase onto main?

PR 417 was using the virtual camera's camera parameter rather than
the physical ones. Also improved the real-world boundingbox performance
by snapping it to the room frame rather than cardinal axises
@Peter-Pater
Peter-Pater force-pushed the object3d_device_fixes branch from e63078b to 35f82d6 Compare August 5, 2026 22:14
@Peter-Pater

Copy link
Copy Markdown
Collaborator Author

@Peter-Pater Can you rebase onto main?

Done :)

@salmanmkc

salmanmkc commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Thanks for this @Peter-Pater! Was this on Galaxy XR that you tested this on?

@dli7319 dli7319 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Tested it on Galaxy XR.
It's technically working but the whole app intermittently freezes on device during the detection.
And the WebGPU errors are still there.

/** A mesh of only horizontal (floor) triangles. */
function floorMesh(): THREE.Mesh {
const positions: number[] = [];
for (let i = 0; i < 20; ++i) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: comment on magic number

/*room_dim_m=*/20

or const ROOM_DIM_N = 20

});

it('recovers a rotated room', () => {
for (const d of [17, 30, 41]) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: magic number

const d of /room_dimension=/[17, 30, 41]
or const

const DEFAULTS = {
maxTriangles: 20000,
maxEdge: 0.2,
maxAbsNy: 0.25,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

comment on this?


const DEFAULTS = {
maxTriangles: 20000,
maxEdge: 0.2,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

what's the range, or a threshold?

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.

4 participants