model-viewer icon indicating copy to clipboard operation
model-viewer copied to clipboard

Ability to load 3d-model in background when hidden

Open bankey1443 opened this issue 5 years ago • 2 comments

Description

Wondering if there is a way for the model-viewer to load the 3d-model in the background i.e. when the model-viewer is not visible on the page. My use case is to attempt to load a pop-up modal in the background so when the user clicks on the product image, it opens up the modal with the preloaded and prerendered 3d-model versus the customer having to wait for the 3d-model to load and render on product image click.

I have tried using loading="eager" along with initiating the pop-up modal containing the model-viewer while hidden and ever variation in between, but it doesn't seem like the model actually loads until it is visible in the viewport, which is probably working as intended to save resources. I am wondering if there is a way to accomplish this sort of "preload", such as a load function I can directly call or if this might be possible option in the future.

Version

  • model-viewer: v1.3.0

Browser Affected

  • [x] Chrome
  • [ ] Edge
  • [ ] Firefox
  • [ ] IE
  • [ ] Safari

bankey1443 avatar Dec 30 '20 16:12 bankey1443

loading="eager" should do what you're expecting. Please post a repro link (as simple as you can) so I can figure out if there's a bug. Does it work without the popup?

elalish avatar Dec 30 '20 17:12 elalish

While creating a repro, I realized I was using an old version of the model-viewer on my local. Used the latest version and loading="eager" works perfectly. Sorry for the confusion.

bankey1443 avatar Dec 30 '20 20:12 bankey1443