Question

I am trying to use rgl knitr and webgl to plot several interactive 3d plots in a sequence.

And I am getting quite a weird behavior: when trying to rotate the plots with a mouse they seem to get back to their initial position after each mouse drag. This makes the interaction quite unintuitive. I noticed that the last plot on a page is not affected by this, but all the rest are.

This can be seen on the original knitr example:

source: https://dl.dropboxusercontent.com/u/15335397/misc/webgl-rmd.Rmd

plots: https://dl.dropboxusercontent.com/u/15335397/misc/webgl-rmd.html

Notice the differences when trying to rotate the first and second figure.

What could be a potential cause? Maybe the problem can be solved by passing some additional parameters to the 3d and rgl plots (was not able to find any)? Or is it a minor bug of knitr and webgl?

Was it helpful?

Solution

This is a bug in knitr, and has been fixed in the development version. The reason for it is that rgl includes <script src="CanvasMatrix.js" type="text/javascript"></script> for every plot, even when there are multiple plots on the same page. I have removed this line on knitr's side, so that CanvasMatrix.js is only loaded once. The knitr example you mentioned works now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top