Skip to content

fix: scale the AR placement box padding with small models - #5211

Open
salmanmkc wants to merge 1 commit into
google:masterfrom
salmanmkc:salmanmkc-fix-placement-box-small-models
Open

salmanmkc wants to merge 1 commit into
google:masterfrom
salmanmkc:salmanmkc-fix-placement-box-small-models

Conversation

@salmanmkc

Copy link
Copy Markdown
Contributor

Reference Issue

Fixes #5150

In WebXR AR a 10-15 cm model gets a placement box with ~10 cm of padding on every side, and you can start a drag from that far out too. @smirnov-artur tracked it down in the issue: the corner radius is max(BASE_RADIUS * 0.7, modelSize * 0.2), so it's 10.5 cm for anything with a footprint under about a metre, and the same radius pads the touch hit plane and the controller hit box.

The radius is now modelSize * 0.5 (modelSize being half the smaller footprint side), capped at the old 10.5 cm and floored at 2.5 cm (MIN_TOUCH_AREA / 2). The floor keeps tiny models grabbable and keeps the radius above the 1.4 cm minimum line width, so the corner arcs don't fold inward. Footprints of 42 cm and up get exactly what they got before.

Hit plane width, square footprint:

model before after
2 cm (box already floored to 5 cm) 26 cm 10 cm
10 cm 31 cm 15 cm
15 cm 36 cm 22.5 cm
50 cm 71 cm 71 cm
2 m 2.4 m 2.4 m

The radius math was copied in three places, so it's one helper now. The controller hit box was also centred using BASE_RADIUS instead of the radius it's built with. That only cost ~2 cm before, but with the smaller radius it would have left the bottom 6 cm of a 10 cm model out of reach for controllers and hands, so it uses the real radius now.

Left the distance scaling alone (the box grows 15-30% at 1-1.5 m). Happy to look at that separately if you want.

Added PlacementBox-spec.ts. The 2 cm, 10 cm, thin wall model and hit box cases fail before the change; the 50 cm and 2 m cases pass both ways and pin the large-model behaviour. Haven't tried it on a device yet, only these tests and the existing AR suites.

Heads up on phones: a one-finger drag that starts on the hit plane moves the model and one that starts outside it rotates, so small models now have a smaller area that moves them. That's also what lets you rotate them without reaching way out past the model. If you'd rather keep a bigger touch target than the visible box, I can split those two.

The corner radius was floored at 10.5 cm, so small models got a placement
box and touch target far larger than the model. The radius now scales with
the footprint (half the smaller side), capped at the old 10.5 cm and floored
at 2.5 cm so tiny models stay grabbable. Footprints of 42 cm and up are
unchanged. The controller hit box is now centred with the radius it is built
with, so it still covers the bottom of small models.

Fixes google#5150

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.

WebXR manipulation gizmo has excessive offset from small 3D models, making interaction difficult

1 participant