Skip to content

Commit 7263a43

Browse files
authored
fixed USDZ rotation (#4753)
1 parent 69d3689 commit 7263a43

File tree

2 files changed

+5
-2
lines changed
  • packages
    • model-viewer/src/features
    • modelviewer.dev/examples/augmentedreality

2 files changed

+5
-2
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ configuration or device capabilities');
425425

426426
await this[$triggerLoad]();
427427

428-
const {model, shadow} = this[$scene];
428+
const {model, shadow, target} = this[$scene];
429429
if (model == null) {
430430
return '';
431431
}
@@ -441,7 +441,10 @@ configuration or device capabilities');
441441
updateSourceProgress(0.2);
442442

443443
const exporter = new USDZExporter();
444+
target.remove(model);
445+
model.updateWorldMatrix(false, true);
444446
const arraybuffer = await exporter.parse(model);
447+
target.add(model);
445448
const blob = new Blob([arraybuffer], {
446449
type: 'model/vnd.usdz+zip',
447450
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ <h4></h4>
382382
</div>
383383
<example-snippet stamp-to="customButton" highlight-as="html">
384384
<template>
385-
<model-viewer ar camera-controls touch-action="pan-y" src="../../shared-assets/models/Astronaut.glb" alt="A 3D model of an astronaut">
385+
<model-viewer ar camera-controls touch-action="pan-y" auto-rotate src="../../shared-assets/models/Astronaut.glb" alt="A 3D model of an astronaut">
386386
<button slot="ar-button" style="background-color: white; border-radius: 4px; border: none; position: absolute; top: 16px; right: 16px; ">
387387
👋 Activate AR
388388
</button>

0 commit comments

Comments
 (0)