Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/model-viewer/src/features/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,15 @@ configuration or device capabilities');
const objectURL = generateUsdz ? await this.prepareUSDZ() : this.iosSrc!;
const modelUrl = new URL(objectURL, self.location.toString());

if(generateUsdz){
const location = self.location.toString();
const locationUrl = new URL(location);
const srcUrl = new URL(this.src!, locationUrl);
if(srcUrl.hash){
modelUrl.hash = srcUrl.hash;
Comment thread
milesgreen marked this conversation as resolved.
}
}

if (this.arScale === 'fixed') {
if (modelUrl.hash) {
modelUrl.hash += '&';
Expand Down
36 changes: 36 additions & 0 deletions packages/model-viewer/src/test/features/ar-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,42 @@ suite('ModelViewerElementBase with ARMixin', () => {
expect(url.hash).to.equal(
'#custom=path-to-banner.html&allowsContentScaling=0');
});

test('replicate src hash to usdz blob url', async () => {
element.src = assetPath('models/cube.gltf')+'#custom=path-to-banner.html';
element.arModes = 'webxr scene-viewer quick-look';

await (element as any)[$openIOSARQuickLook]();

expect(intentUrls.length).to.be.equal(1);

const url = new URL(intentUrls[0]);

expect(url.protocol).to.equal(
'blob:');

expect(url.hash).to.equal(
'#custom=path-to-banner.html');
});

test('replicate src hash to usdz blob and set hash for fixed scale', async () => {
element.src = assetPath('models/cube.gltf')+'#custom=path-to-banner.html';
element.arModes = 'webxr scene-viewer quick-look';
element.arScale = 'fixed';

await (element as any)[$openIOSARQuickLook]();

expect(intentUrls.length).to.be.equal(1);

const url = new URL(intentUrls[0]);

expect(url.protocol).to.equal(
'blob:');

expect(url.hash).to.equal(
'#custom=path-to-banner.html&allowsContentScaling=0');
});

});
});

Expand Down