-
Notifications
You must be signed in to change notification settings - Fork 890
Progress bars #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Progress bars #487
Conversation
| comments: 'none', | ||
| }), | ||
| ); | ||
| if (NODE_ENV !== 'development') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default run mode for the build script was set as "development", but should probably be "production" so that naively running Rollup with the config builds all the things.
530fc81 to
69c0e99
Compare
ce29777 to
ddbadd5
Compare
| pointer-events: none; | ||
| } | ||
| .click-to-view { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this entirely, as it is vestigial from <xr-model> prototype days
|
@cdata I wonder if we should simplify the default css properties for progress bar & future features. My concern is that the list of properties can be endless if we aren't extremely selective. I believe developers can further customize CSS if they want to, we should keep defaults to a minimum. To me, the most crucial properties for progress bar are:
If we set default poster image & progress-mask to background-size: cover, we can still have a pretty ok baseline results. The progress-mask color should be directly linked to background-color, without transparency. We should recommend using poster image with the same background color for consistency. WDYT? |
| @@ -0,0 +1,402 @@ | |||
| /* | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit, this would have been easier to read broken out into separate PRs. But, it was broken out into separate commits, so it was pretty easy to just go back there to take a look:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, agreed. Lot's of regret.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
src/features/loading.ts
Outdated
|
|
||
| get[$shouldRevealModel](): boolean { | ||
| return this.reveal === RevealStrategy.AUTO || | ||
| this.reveal === this[$posterDismissalSource]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the second clause be clearer as PosterDismissalSource.INTERACTION === this[$posterDismissalSource] or !!this[$posterDismissalSource]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose my thought (particularly with the second) is that we probably don't care what the dismissal source is, only if we have one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, at this stage we only care that a dismissal source is set. As written, it's only helpful if we had N+1 possible sources.
| (async () => { | ||
| const updateSourceProgress = this[$progressTracker].beginActivity(); | ||
| await this[$updateSource]( | ||
| (progress: number) => updateSourceProgress(progress * 0.9)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why * 0.9? So it doesn't go to 1.0 until we're actually done (below)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah
| @@ -0,0 +1,141 @@ | |||
| import {clamp} from '../utils.js'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File header?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix
|
@yuinchien thanks for the feedback. The CSS properties have been pared down to four. |
|
const modelViewer = document.querySelector('model-viewer'); modelViewer.addEventListener('progress', (event) => { when I put this code into an Angular Project, typescript show a few of error messages, I already achieved most of them but one it is still going, and the error says: Property 'detail' does not exist on type 'ProgressEvent'. This is my code in my component from Angular project: const modelViewerload = document.querySelector('model-viewer') as ModelViewerElement; I installed @google/model-viewer via npm, and this are my imports: I hope you can read me and find a solution. Thanks. |
|
maybe |
|
Yes, I did this and worked: |
Progress Bars
This change proposes the addition of the notion of instance-wide loading progress, as well as corresponding customizable visualizations and API. In other words: progress bars.
Some highlights of this change include:
progressevent is introduced, maps directly to our internal notion of progressslot="progress-bar"slot="poster"revealattribute has been introduced to control model visibilityreveal-when-loadedsemanticsreveal="interaction"defers loading / revealing model until user interactionreveal-when-loadedhas been removed in favor of newrevealattribute and related semanticsProgressTrackerutility class has been introduced to assist in tracking progress across multiple, uncoordinated, asynchronous actions at oncemodel-viewer-base,features/loading,templateandthree-components/CachingGLTFLoaderGLTFLoaderhave been copied over from the Three.js project<model-viewer>to have 1px-wide empty margins sometimesNew CSS custom properties
In keeping with our goal of enabling as much idiomatic customization as we can, the following CSS custom properties have been introduced by this change:
--poster-colorbackground-colorof the poster. Falls back to--background-colorif set. Defaults to#fff.--poster-imagebackground-imageof the poster. This is currently overridden by theposterattribute if it is set. Defaults tonone.--progress-bar-colorbackground-colorof the progress bar. Defaults torgba(0, 0, 0, 0.4).--progress-maskbackgroundof the progress mask. Defaults to#fff.Tracking progress
In order to present the model at the correct time, we must take into account an uncertain number of possible network actions (environment map, glTF w/ multiple sub-resources etc) as well as an uncertain number of script/GPU processing steps (env map generation, skybox, PMREM etc) in order for the model to be considered presentable. The notion of "progress" introduced by this change encompasses all such actions that are implemented today.
Here is an example of how complex the process of presenting one model can be. Note that this is a fairly heavy configuration, resulting in almost 70MB of total assets transferred before we reveal the model:
Examples
reveal="interaction"srcattribute changing over timeThe following is an abbreviated form of the markup used to create the custom progress bar example above:
Future work
delegatesFocuswas discovered in the course of this change crbug.com/950357Fixes #335
Fixes #489