Class PlotRecorder
java.lang.Object
com.eco.bio7.spatial.PlotRecorder
Records a plot of the plot API (see Plot3D) frame by frame, e.g., a plot
which is updated in each step of a simulation (see Plot3D.update), and
exports the recording to an HTML page with WebGL: the plot with the axes, the
title and the legends of each frame, Play/Pause, a timeline, the speed and a
loop (the view can be rotated and zoomed while the recording plays) or for
Blender as an animation (see exportBlender).
PlotRecorder recorder = new PlotRecorder().speed(10);
for (int t = 0; t < 100; t++) {
step(); // the model
plot.clearLayers().add(Plot3D.scatter(x, y, z)).update();
recorder.frame(plot);
}
recorder.export("/path/recording.html");
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionautoplay(boolean autoplay) Plays the recording when the page is opened (default false).blender(boolean keep) Keeps the geometry of the frames for the Blender export (default true, false needs less memory for a long recording which is only exported to HTML).clear()Removes the recorded frames.Writes the HTML page of the recording.exportBlender(String file) Exports the recording for Blender as an animation: a glTF file (*.glb) with the objects of all frames (an object which doesn't change is exported once) and a Python script with the same name (*.py) which imports the file and animates the visibility of the objects and the texts (the frames 1 ...Records the current state of a plot as a frame (the plot is computed if it was not displayed or updated).intframes()Returns the number of the recorded frames.loop(boolean loop) Plays the recording again from the start (default true, a check box of the page).maxFrames(int maxFrames) The maximum number of the frames (default 10000, further frames are ignored).speed(double framesPerSecond) The speed of the playback in frames per second (default 10).toHtml()Returns the HTML page of the recording.
-
Constructor Details
-
PlotRecorder
public PlotRecorder()
-
-
Method Details
-
frame
Records the current state of a plot as a frame (the plot is computed if it was not displayed or updated).- Parameters:
plot- the plot- Returns:
- the recorder
-
speed
The speed of the playback in frames per second (default 10). -
loop
Plays the recording again from the start (default true, a check box of the page). -
autoplay
Plays the recording when the page is opened (default false). -
maxFrames
The maximum number of the frames (default 10000, further frames are ignored). -
blender
Keeps the geometry of the frames for the Blender export (default true, false needs less memory for a long recording which is only exported to HTML). -
exportBlender
Exports the recording for Blender as an animation: a glTF file (*.glb) with the objects of all frames (an object which doesn't change is exported once) and a Python script with the same name (*.py) which imports the file and animates the visibility of the objects and the texts (the frames 1 ... n of the timeline of Blender with the speed of the recording), e.g., to render a film. In Blender: Scripting - Open - Run Script.- Parameters:
file- the glTF file (*.glb), the script is written next to it- Returns:
- the path of the Python script
- Throws:
IOException- if a file cannot be written
-
frames
public int frames()Returns the number of the recorded frames. -
clear
Removes the recorded frames. -
toHtml
Returns the HTML page of the recording. -
export
Writes the HTML page of the recording.- Parameters:
file- the HTML file- Returns:
- the recorder
- Throws:
IOException- if the file cannot be written
-