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

set limit to rotate

Open mesmaili151 opened this issue 6 years ago • 4 comments

Hi, i have a animation thats starts with scrolling. camera-orbit="calc(-300rad + env(window-scroll-y) * -6rad) calc(80deg + env(window-scroll-y) * 0deg) calc(3m - env(window-scroll-y) * 1.5m)" How can i set a limit for rotating the animation with scrolling? i mean i want to rotate the animation with scroll just for 20deg and after that the animation stops.

mesmaili151 avatar Jun 15 '20 09:06 mesmaili151

Have you tried setting minCameraOrbit and maxCameraOrbit?

elalish avatar Jun 15 '20 16:06 elalish

yes, i tried

      min-camera-orbit='auto ..deg 20m'
      max-camera-orbit='auto ..deg 1000m'

but i think when we want to play animation with scroll, this function doesn't work !

mesmaili151 avatar Jun 16 '20 06:06 mesmaili151

The following page has an example of how to interpolate between the two rotations you desire

interpolate-or-tween-between-two-values

methot-ilya-3ds avatar Jun 16 '20 12:06 methot-ilya-3ds

@mesmaili151 If you are animating theta, phi and radius and you want the animation to stop before the scroll gets to 1, then you'll need to limit all three to the values your calc statements give when page scroll is at the value you want the animation to stop at. It'll be something along the lines of max-camera-orbit="20deg 10deg 30m". You'll also want to evaluate your calc statements at scroll=0 and use those for min-camera-orbit, or vice-versa if the values decrease during animation.

elalish avatar Jun 16 '20 15:06 elalish