Skip to content

Conversation

@chrismgeorge
Copy link
Contributor

@chrismgeorge chrismgeorge commented Dec 4, 2020

Design doc: (go/modelviewer-mobile-bridge)

Looking for a code review and a feature review. Especially interested in the usability of Scene Viewer.

@chrismgeorge
Copy link
Contributor Author

tagging @mounirlamouri for visibility

@chrismgeorge chrismgeorge changed the title Mobile with qr code Mobile Bridge Dec 10, 2020
@chrismgeorge
Copy link
Contributor Author

design doc: (go/modelviewer-mobile-bridge)

import {ConnectedLitElement} from '../../connected_lit_element/connected_lit_element.js';

@customElement('mobile-modal')
export class MobileModal extends ConnectedLitElement {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modal for displaying the QR Code & link

* The view loaded at /editor/view/?id=xyz
*/
@customElement('mobile-view')
export class MobileView extends ConnectedLitElement {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What gets rendered when we are looking at editor/view/id?=1234 on mobile

async fetchLoop() {
await fetch(this.updatesPipeUrl)
.then(response => response.json())
.then(json => this.waitForData(json))
Copy link
Contributor Author

@chrismgeorge chrismgeorge Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

json is the initial object sent that has properties that determine what has changed: i.e.:
{gltfChanged: boolean, stateChanged: boolean, envChanged: boolean, envIsHdr: boolean}
and is how we dynamically know what to GET

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally you either use .then or await but not both, since they do the same thing. Let's stick with await.

* Section for displaying QR Code and other info related to mobile
*/
@customElement('open-mobile-view')
export class OpenMobileView extends ConnectedLitElement {
Copy link
Contributor Author

@chrismgeorge chrismgeorge Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New section underneath the file manager for displaying the ar & mobile features

`
}

render() {
Copy link
Contributor Author

@chrismgeorge chrismgeorge Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.isOpen = false;
}

render() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export const getArConfig = (state: State) =>
state.entities.modelViewerSnippet.arConfig;

export function arReducer(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As more things are added, this reducer may become the "mobileReducer" to house all of the snippet config without a home and relevant to mobile, like iosSrc

@query('me-import-card') importCard!: ImportCard;

isTestingMobile(): boolean {
return window.location.search === '?id=testingMobile';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mobile view section is only visible at

/editor/?id=testingMobile

@chrismgeorge chrismgeorge requested a review from elalish December 15, 2020 20:12
@chrismgeorge
Copy link
Contributor Author

Added a Logical Flow section to the design doc: https://docs.google.com/document/d/1JHWioVxrhfwZyPMccRUyYqP4cl2Z0YggcpXl4UFyTmo/edit#heading=h.uh3hs9gwqhmu

Detailing the GET/POSTs that are being sent and listened for.

Importantly:
Screen Shot 2020-12-15 at 1 25 53 PM

Copy link
Contributor

@elalish elalish left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like these comments addressed, but I think it's good enough to merge as-is, especially since it's behind a flag. I'd like to get testing it in it's deployed state sooner than later.

<!-- Web animations for paper-dropdown -->
<script src="../../node_modules/web-animations-js/web-animations-next-lite.min.js"></script>
<script src="../../node_modules/js-beautify/js/lib/beautify-html.js"></script>
<script src="../../node_modules/js-beautify/js/lib/beautify-css.js"></script>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these dependencies needed when there's no UI?

.then(blob => {
// simulating createBlobUrlFromEnvironmentImage
const addOn = envIsHdr ? '#.hdr' : '';
const envUrl = URL.createObjectURL(blob) + addOn;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you're working around one of model-viewer's hacks here. We should really fix up how we recognize HDRs someday...

await this.waitForState(json.envChanged);
}
if (json.envChanged) {
await this.waitForEnv(json.envIsHdr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these really happen one after the other, or should they be in parallel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One after another. The important part is when the state snippet needs to be dispatch its data. It overrides information of the gltf and environment url.

async fetchLoop() {
await fetch(this.updatesPipeUrl)
.then(response => response.json())
.then(json => this.waitForData(json))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally you either use .then or await but not both, since they do the same thing. Let's stick with await.

await fetch(this.updatesPipeUrl)
.then(response => response.json())
.then(json => this.waitForData(json))
.catch((error) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use .catch outside of a try block?

const dropdown = event.target as Dropdown;
const key = dropdown.selectedItem?.getAttribute('value') || undefined;
if (key === 'default' || key === 'webxr') {
reduxStore.dispatch(dispatchArModes('webxr scene-viewer quick-look'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's simplify this. Maybe just a checkbox to default to scene-viewer instead of webxr? Quicklook can be always enabled, since it's the only option on iphones, and it's really controlled by the presence of an ios-src.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants