Skip to content

Commit 87c6793

Browse files
committed
Fix AR button layout overlap on Transforms and Dynamic Scaling examples
This commit resolves separate layout overlap issues where large, multi-row control panels block the default bottom-right system AR button on narrow and high-density viewports (e.g., Samsung Galaxy S22 and Pixel 9 Pro Fold). Following a responsive custom AR button strategy, this change: 1. Adds a custom slotted 'View in AR' button to both the 'Model Transformations' (scenegraph/index.html) and 'Dynamic Scaling' (loading/index.html) examples. 2. Keeps their respective numeric/slider controls positioned at the default bottom-left. 3. Uses CSS Container Queries with a 700px width threshold to smoothly translate the custom AR button to the top-right corner on compact or high-density mobile viewports, ensuring complete visual separation and easy physical access. These changes have been visually validated side-by-side inside standalone simulated viewports for absolute layout robustness.
1 parent 6260fd0 commit 87c6793

2 files changed

Lines changed: 49 additions & 4 deletions

File tree

packages/modelviewer.dev/examples/loading/index.html

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,19 +433,36 @@ <h4>Our renderer tries to keep the frame rate between 38 and 60 frames per secon
433433
display: flex;
434434
flex-direction: column;
435435
align-items: flex-start;
436-
top: 16px;
436+
bottom: 16px;
437437
left: 16px;
438+
z-index: 10;
439+
}
440+
.custom-ar-button {
441+
position: absolute;
442+
top: 16px;
443+
right: 16px;
444+
background-color: white;
445+
border: 1px solid #dadce0;
446+
border-radius: 4px;
447+
padding: 8px 12px;
448+
font-weight: 500;
449+
font-size: 14px;
450+
color: #1a73e8;
451+
box-shadow: 0 2px 4px rgba(0,0,0,.1);
452+
cursor: pointer;
453+
z-index: 10;
438454
transform: translateY(calc(100cqh - 100% - 32px));
439-
transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
455+
transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
440456
}
441-
@container (max-width: 550px) {
442-
.controls {
457+
@container (max-width: 700px) {
458+
.custom-ar-button {
443459
transform: translateY(0px);
444460
}
445461
}
446462
</style>
447463
<model-viewer id="scale" alt="A 3D model of a toy car" camera-controls touch-action="pan-y" auto-rotate
448464
src="../../shared-assets/models/glTF-Sample-Assets/Models/ToyCar/glTF-Binary/ToyCar.glb" ar>
465+
<button slot="ar-button" class="custom-ar-button">View in AR</button>
449466
<div class="controls glass">
450467
<div>
451468
Reported DPR: <span id="reportedDpr"></span>

packages/modelviewer.dev/examples/scenegraph/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,37 @@ <h2 class="demo-title">Model Transformations</h2>
161161
</div>
162162
<example-snippet stamp-to="transforms" highlight-as="html">
163163
<template>
164+
<style>
165+
model-viewer#transform {
166+
container-type: size;
167+
}
168+
.custom-ar-button {
169+
position: absolute;
170+
top: 16px;
171+
right: 16px;
172+
background-color: white;
173+
border: 1px solid #dadce0;
174+
border-radius: 4px;
175+
padding: 8px 12px;
176+
font-weight: 500;
177+
font-size: 14px;
178+
color: #1a73e8;
179+
box-shadow: 0 2px 4px rgba(0,0,0,.1);
180+
cursor: pointer;
181+
z-index: 10;
182+
transform: translateY(calc(100cqh - 100% - 32px));
183+
transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
184+
}
185+
@container (max-width: 700px) {
186+
.custom-ar-button {
187+
transform: translateY(0px);
188+
}
189+
}
190+
</style>
164191
<model-viewer id="transform" orientation="20deg 0 0" shadow-intensity="1" camera-controls
165192
touch-action="pan-y" ar src="../../shared-assets/models/Astronaut.glb"
166193
alt="A 3D model of an astronaut">
194+
<button slot="ar-button" class="custom-ar-button">View in AR</button>
167195
<div class="controls glass">
168196
<div>Roll: <input id="roll" value="20" size="3" class="number"> degrees</div>
169197
<div>Pitch: <input id="pitch" value="0" size="3" class="number"> degrees</div>

0 commit comments

Comments
 (0)