I use Sketchup for animation as a hobby and have some comments:
One is the Animation object and using the nextFrame method . . .
I find creating a class to handle nextFrame just creates extra code that makes the program more difficult to understand. A benefit it offers is that when the nextFrame message handler is complete, it returns control to Sketchup and you can interact with the model between each frame.
I see adding scenes/pages and adding frameChangeObservers to pages as the second method
If you need to have real animation during Sketchup’s built-in scene-to-scene camera interpolation, then frame change observers allow that. One of the arguments to the “frameChange” method is a ratio that allows the developer to know how far the scene’s camera interpolation has progressed, allowing a potential “real time” animation.
I find observers unintuitive, and Sketchup doesn’t allow user’s to purge all observers. Although Sketchup can write video files of scene-to-scene animation, it does not run any Ruby code during the “File…Export…Animation” menu option.
A different code flow…
The “nextFrame” and “frameChange” methods are message handlers called by Sketchup, and not by any developer code. I find they create additional unnecessary code and are less intuitive. The vast majority of my animations involve the camera and grouped objects. If a developer uses the “move!” method that groups and component instances support, then the animation isn’t slowed down by logging of edit undo operations, and it isn’t necessary to include edit…undo exception handling. Since the “move!” method by itself doesn’t refresh the view, it is necessary after repositioning models to perform “view.refresh”. If it is necessary to animate loose drawing objects like faces and edges, or vertices, then the “transform_by_vectors” and “transform_entities” methods are required (which can also animate group and components), but they do log edit undo operations. A developer can replace the “view.refresh” with “view.write_image” to write each animation frame, and then merge them together outside of Sketchup. The image writes though take quite a bit of time. The move and refresh statements are in a simpler loop that outputs a frame each time through the loop.
These programs are Ruby scripts, but they are not plugins and I do not develop them in the plugins folder or subfolders.