Skip to content

Commit

Permalink
fixed USDZ generation with reveal=interaction (google#2421)
Browse files Browse the repository at this point in the history
  • Loading branch information
elalish authored May 25, 2021
1 parent 8c82352 commit d1d3e5f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
19 changes: 13 additions & 6 deletions packages/model-viewer/src/features/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const $onARStatus = Symbol('onARStatus');
const $onARTracking = Symbol('onARTracking');
const $onARTap = Symbol('onARTap');
const $selectARMode = Symbol('selectARMode');
const $triggerLoad = Symbol('triggerLoad');

export declare interface ARInterface {
ar: boolean;
Expand Down Expand Up @@ -260,12 +261,7 @@ configuration or device capabilities');
protected async[$enterARWithWebXR]() {
console.log('Attempting to present in AR with WebXR...');

if (!this.loaded) {
this[$preload] = true;
this[$updateSource]();
await waitForEvent(this, 'load');
this[$preload] = false;
}
await this[$triggerLoad]();

try {
this[$arButtonContainer].removeEventListener(
Expand All @@ -286,6 +282,15 @@ configuration or device capabilities');
}
}

async[$triggerLoad]() {
if (!this.loaded) {
this[$preload] = true;
this[$updateSource]();
await waitForEvent(this, 'load');
this[$preload] = false;
}
}

[$shouldAttemptPreload](): boolean {
return super[$shouldAttemptPreload]() || this[$preload];
}
Expand Down Expand Up @@ -392,6 +397,8 @@ configuration or device capabilities');
async prepareUSDZ(): Promise<string> {
const updateSourceProgress = this[$progressTracker].beginActivity();

await this[$triggerLoad]();

const scene = this[$scene];

const shadow = scene.shadow;
Expand Down
2 changes: 1 addition & 1 deletion packages/modelviewer.dev/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h3 class="grouping-title grouping-title-new quick-start">Quick Start</h3>
<script type="module" src="https://unpkg.com/@google/model-viewer/dist/model-viewer.js"></script>

<!-- Use it like any other HTML element -->
<model-viewer src="shared-assets/models/Astronaut.glb" alt="A 3D model of an astronaut" auto-rotate camera-controls></model-viewer>
<model-viewer src="shared-assets/models/Astronaut.glb" alt="A 3D model of an astronaut" ar ar-modes="webxr scene-viewer quick-look" environment-image="neutral" auto-rotate camera-controls></model-viewer>
</template>
</example-snippet>
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/modelviewer.dev/styles/examples.css
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ model-viewer:focus {
box-sizing: border-box;
}

.examples-container > .sample > .demo {
.sample > .demo {
height: 100vh;
}

Expand Down Expand Up @@ -754,7 +754,7 @@ paper-button {
padding-top: 0px;
}

.examples-container > .sample > .demo {
.sample > .demo {
top: 0;
height: 150vw;
}
Expand Down

0 comments on commit d1d3e5f

Please sign in to comment.