瀏覽代碼

mol-canvas: move spin() to update()

David Sehnal 6 年之前
父節點
當前提交
208b85977f
共有 1 個文件被更改,包括 2 次插入3 次删除
  1. 2 3
      src/mol-canvas3d/controls/trackball.ts

+ 2 - 3
src/mol-canvas3d/controls/trackball.ts

@@ -209,6 +209,8 @@ namespace TrackballControls {
 
 
         /** Update the object's position, direction and up vectors */
         /** Update the object's position, direction and up vectors */
         function update() {
         function update() {
+            if (p.spin) spin();
+
             Vec3.sub(_eye, object.position, target)
             Vec3.sub(_eye, object.position, target)
 
 
             rotateCamera()
             rotateCamera()
@@ -300,7 +302,6 @@ namespace TrackballControls {
         function spin() {
         function spin() {
             _spinSpeed[0] = (p.spinSpeed || 0) / 1000;
             _spinSpeed[0] = (p.spinSpeed || 0) / 1000;
             if (!_isInteracting) Vec2.add(_moveCurr, _movePrev, _spinSpeed);
             if (!_isInteracting) Vec2.add(_moveCurr, _movePrev, _spinSpeed);
-            if (p.spin) requestAnimationFrame(spin);
         }
         }
 
 
         // force an update at start
         // force an update at start
@@ -313,9 +314,7 @@ namespace TrackballControls {
 
 
             get props() { return p as Readonly<TrackballControlsProps> },
             get props() { return p as Readonly<TrackballControlsProps> },
             setProps: (props: Partial<TrackballControlsProps>) => {
             setProps: (props: Partial<TrackballControlsProps>) => {
-                const wasSpinning = p.spin
                 Object.assign(p, props)
                 Object.assign(p, props)
-                if (p.spin && !wasSpinning) requestAnimationFrame(spin)
             },
             },
 
 
             update,
             update,