salcoyot/jsc3d

Rotate on page load

Opened this issue · 1 comments

Hi, is there a way to set the 3D model to slowly rotate by itself on page load?
I'm relatively new to coding and wanted to do this for a school project. 

Thanks!

What version of the product are you using? On what operating system?
http://jsc3d.googlecode.com/svn/trunk/jsc3d/jsc3d.js



Original issue reported on code.google.com by nando1...@gmail.com on 14 Dec 2014 at 1:25

Override viewer.onloadingcomplete 
(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Viewer.html#onlo
adingcomplete) which will be called immediately as the model is loaded. In this 
callback function, set a timer to rotate the model a fixed angle around an axis 
using viewer.rotate() method 
(http://jsc3d.googlecode.com/svn/trunk/jsc3d/docs/symbols/JSC3D.Viewer.html#rota
te) at an expected frequency. The implementation would be like this:

  viewer.onloadingcomplete = function() {
    setInterval( function() {
      // rotate the model around an axis
      viewer.rotate(...);
      // tell the viewer to render a new frame
      viewer.update();
    }, an_expected_interval_in_millisecs);
  };

There's a live example demonstrating how to achieve this: 
http://jsc3d.googlecode.com/svn/trunk/jsc3d/demos/earth.html.

Original comment by Humu2...@gmail.com on 14 Dec 2014 at 3:08