Skip to content

Commit

Permalink
Merge pull request #33 from Smithsonian/dev-ar
Browse files Browse the repository at this point in the history
Bug fixes and add message passing option for api AR call
  • Loading branch information
gjcope authored Nov 18, 2020
2 parents 9b269e2 + 12535f5 commit b38d20d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
32 changes: 32 additions & 0 deletions source/client/applications/ExplorerApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,38 @@ Version: ${ENV_VERSION}
this.evaluateProps();
}

//*** Support message passing over channel 2 ***//
{
// Add listener for the intial port transfer message
var port2;
window.addEventListener('message', initPort);

// Setup port for message passing
function initPort(e) {
port2 = e.ports[0];
if(port2) {
port2.onmessage = onMessage;
}
}

// Handle messages received on port2
function onMessage(e) {
if (ENV_DEVELOPMENT) {
console.log('Message received by VoyagerExplorer: "' + e.data + '"');
}

const analytics = system.getMainComponent(CVAnalytics);

if (e.data === "enableAR") {
const ARIns = system.getMainComponent(CVARManager).ins;

ARIns.enabled.setValue(true);
analytics.sendProperty("AR.enabled", true);
}

}
}

// start rendering
engine.pulse.start();
}
Expand Down
2 changes: 1 addition & 1 deletion source/client/components/CVARManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export default class CVARManager extends Component
}

const models = this.sceneNode.getGraphComponents(CVModel2);
const derivative = models[0].derivatives.get(EDerivativeUsage.iOSApp3D, EDerivativeQuality.AR);
const derivative = models[0] ? models[0].derivatives.get(EDerivativeUsage.iOSApp3D, EDerivativeQuality.AR) : null;

if(derivative) {
this.setup.navigation.setChanged(true); // set changed var to disable autoZoom for bounds changes
Expand Down
2 changes: 1 addition & 1 deletion source/client/ui/explorer/ShareMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class ShareMenu extends Popup
const twitterShareUrl = `http://twitter.com/share?text=${title}&url=${url}`;
const facebookShareUrl = `https://www.facebook.com/sharer/sharer.php?u=${url}`;
const linkedInShareUrl = `https://www.linkedin.com/shareArticle?url=${url}&mini=true&title=${title}`;
const iFrameEmbedCode = `<iframe name="Smithsonian Voyager" src="${this.url}" width="800" height="450" allowfullscreen="true"></iframe>`;
const iFrameEmbedCode = `<iframe name="Smithsonian Voyager" src="${this.url}" width="800" height="450" allow="xr; xr-spatial-tracking; fullscreen"></iframe>`;

const emailUrl = `mailto:?subject=${title}&body=${url}`;

Expand Down

0 comments on commit b38d20d

Please sign in to comment.