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

Zoom after page Scrolling and change default light

Open mesmaili151 opened this issue 6 years ago • 6 comments

Hi, i have 2 problem. 1 ) My model camera changes with this code after scroll: camera-orbit="calc(-300rad + env(window-scroll-y) * -6rad) calc(80deg + env(window-scroll-y) * 0deg) calc(3m - env(window-scroll-y) * 1.5m)" Now I want to zoom to the model with page scrolling and also change the camera view.

2 ) how can i change the models light?

thanks

mesmaili151 avatar Jun 10 '20 14:06 mesmaili151

@mesmaili151

  1. If I understand you correctly, your code is already working for scroll-based radius change and now you also want scroll-based field-of-view change? Try doing the same style of calc() on the field-of-view attribute. If that doesn't work, we can turn this into a bug.

  2. To change lighting you need to specify a new equirectangular environment-image attribute, as demonstrated in our lighting example.

elalish avatar Jun 10 '20 14:06 elalish

@elalish yes, thanks, but can you send me one example of field of view?

  1. so have i to use another image for light?

mesmaili151 avatar Jun 12 '20 08:06 mesmaili151

@mesmaili151 You could try field-of-view="calc(45deg - env(window-scroll-y) * 20deg)". And yes, lighting in model-viewer is specified by an image (preferably HDR), except the default light which is generated at runtime.

elalish avatar Jun 12 '20 15:06 elalish

@elalish thanks, its worked

mesmaili151 avatar Jun 15 '20 06:06 mesmaili151

@mesmaili151 Can you post a Glitch of what you've tried and what about it doesn't work? That'll give me a much better chance of helping.

elalish avatar Jun 15 '20 15:06 elalish

@elalish thanks, I told its worked for me.

mesmaili151 avatar Jun 15 '20 19:06 mesmaili151