Skip to content

Commit 9fa1fa2

Browse files
authored
fix USDZ positioning (#4759)
1 parent 62e6682 commit 9fa1fa2

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

packages/model-viewer/src/features/ar.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,10 +441,16 @@ configuration or device capabilities');
441441
updateSourceProgress(0.2);
442442

443443
const exporter = new USDZExporter();
444+
444445
target.remove(model);
446+
model.position.copy(target.position);
445447
model.updateWorldMatrix(false, true);
448+
446449
const arraybuffer = await exporter.parse(model);
450+
451+
model.position.set(0, 0, 0);
447452
target.add(model);
453+
448454
const blob = new Blob([arraybuffer], {
449455
type: 'model/vnd.usdz+zip',
450456
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@ <h4>This demonstrates several augmented reality modes, including
312312
<div class="wrapper">
313313
<div class="heading">
314314
<h2 class="demo-title">Scene Viewer</h2>
315-
<h4>Here the Scene Viewer app is given priority, to make it easier to compare with the default WebXR, above.</h4>
315+
<h4>Here the Scene Viewer app is given priority, to make it easier to compare with the default WebXR, above. This also uses USDZ auto-generation for AR Quick Look on iOS, as compared to the separate ios-src file given above.</h4>
316316
</div>
317317
<example-snippet stamp-to="sceneViewer" highlight-as="html">
318318
<template>
319-
<model-viewer id="model-viewer" src="../../shared-assets/models/Astronaut.glb" ar ar-modes="scene-viewer" camera-controls touch-action="pan-y" alt="A 3D model of an astronaut" shadow-intensity="2" skybox-image="../../shared-assets/environments/spruit_sunrise_1k_HDR.jpg" skybox-height="2m" max-camera-orbit="auto 90deg auto">
319+
<model-viewer id="model-viewer" src="../../shared-assets/models/Astronaut.glb" ar ar-modes="scene-viewer quick-look" camera-controls touch-action="pan-y" alt="A 3D model of an astronaut" shadow-intensity="2" auto-rotate disable-pan skybox-image="../../shared-assets/environments/spruit_sunrise_1k_HDR.jpg" skybox-height="2m" max-camera-orbit="auto 90deg auto">
320320
<div id="error" class="hide">AR is not supported on this device</div>
321321
</model-viewer>
322322
<script>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ <h2 class="demo-title">Ground-projected Skybox</h2>
8181
</div>
8282
<example-snippet stamp-to="groundedSkybox" highlight-as="html">
8383
<template>
84-
<model-viewer camera-controls touch-action="pan-y" auto-rotate disable-pan skybox-image="../../shared-assets/environments/whipple_creek_regional_park_1k_HDR.jpg" skybox-height="1.5m" shadow-intensity="2" max-camera-orbit="auto 90deg auto" alt="A 3D astronaut model depicted within a forest" src="../../shared-assets/models/Astronaut.glb"></model-viewer>
84+
<model-viewer camera-controls touch-action="pan-y" disable-pan skybox-image="../../shared-assets/environments/whipple_creek_regional_park_1k_HDR.jpg" skybox-height="1.5m" shadow-intensity="2" max-camera-orbit="auto 90deg auto" alt="A 3D astronaut model depicted within a forest" src="../../shared-assets/models/Astronaut.glb"></model-viewer>
8585
</template>
8686
</example-snippet>
8787
</div>

0 commit comments

Comments
 (0)