[R] rgl::writeWebGL( , prefix = , )

Duncan Murdoch murdoch.duncan at gmail.com
Tue Feb 3 16:14:35 CET 2015


On 03/02/2015 9:43 AM, Keith.Jewell at campdenbri.co.uk wrote:
> Dear all,
>
> I am using writeWebGL to create an HTML page containing an interactive 3D plot. It works fine with the default prefix="" but fails when I specify a prefix "for different scenes displayed on the same web page" (quoting ?writeWebGL).  I'm sure I'm misreading the help, and would appreciate guidance.
>
> Briefly, it works fine with the default writeWebGL( ,prefix="", ) and the template containing %WebGL%
> I have not been able to make it work with any other value of prefix; e.g. writeWebGL( ,prefix="A",) and the template containing %AWebGL%
>
> Here is code illustrating the problem.
>
> First create three templates:
> a) Vanilla: copied system.file(file.path("WebGL", "template.html"), package="rgl") to file.path(getwd(), "template.html")
>
> b) First attempt: ?writeWebGL says # "[the template] should contain a single line containing paste("%", prefix, "WebGL%"), e.g. %WebGL% with the default empty prefix"
> paste("%", "A", "WebGL%")
> # [1] "% A WebGL%"
> so file.path(getwd(), "templateA.html") is a copy of (a) replacing %WebGL% with % A WebGL%
>
> c) Second attempt: file.path(getwd(), "templateB.html") is  a copy of (a) replacing %WebGL% with %AWebGL%
>
> then, in R
> #-----------
> library(rgl)
> plot3d(1:5, 1:5, 1:5) # generate rgl scene
> #-----------
> # a) vanilla
> writeWebGL(dir=getwd(), template = file.path(getwd(), "template.html"), prefix="")
> # works OK; result opens and works in IE
> #----------------
> # b) First attempt, my reading of ?writeWebGL
> writeWebGL(dir=getwd(), template = file.path(getwd(), "templateA.html"), prefix="A")
> # Error in writeWebGL(dir = getwd(), template = file.path(getwd(), "templateA.html"),  :
> #                       template ‘m://templateA.html’ does not contain %AWebGL%
> # so it looks as if the help is trivially wrong, it should be paste0
> paste0("%", "A", "WebGL%")

Yes, that's right.  I'll fix it.

> # [1] "%AWebGL%"
> #----------------
> # c) second attempt using %AWebGL%
> writeWebGL(dir=getwd(), template = file.path(getwd(), "templateB.html"), prefix="A")
> # runs without error in R but IE displays "You must enable Javascript to view this page properly."
> #--------------
>
> I don't understand why (c) is different from (a).

There may be an error in the generated Javascript.  In Firefox, you 
could ask to see the browser console log, and it would report if there 
was an error on the page; sometimes those make the Javascript fail, and 
it falls back to the error message you saw.  I don't know how/if you can 
do that in IE.


>
> Here are the system details:
>
> R version 3.1.0 (2014-04-10)
> Platform: i386-w64-mingw32/i386 (32-bit)
>
> locale:
> [1] LC_COLLATE=English_United Kingdom.1252
> [2] LC_CTYPE=English_United Kingdom.1252
> [3] LC_MONETARY=English_United Kingdom.1252
> [4] LC_NUMERIC=C
> [5] LC_TIME=English_United Kingdom.1252
>
> attached base packages:
> [1] grDevices datasets  splines   graphics  stats     tcltk     utils
>   [8] tools     methods   base
>
> other attached packages:
> [1] knitr_1.8       animation_2.3   rgl_0.95.1158   CBRIutils_1.0

That's an old version of rgl; current on CRAN is 0.95.1201. 
<http://cran.r-project.org/src/contrib/rgl_0.95.1201.tar.gz> (CRAN OSX 
currently has an old binary; I don't recommend that you use it.  I don't 
know why they haven't updated to the current one.) r-forge has even 
newer versions, but I'm in the middle of some changes there, so I don't 
recommend using that version right now.

Duncan Murdoch
<http://cran.r-project.org/src/contrib/rgl_0.95.1201.tar.gz>
>   [5] stringr_0.6.2   svSocket_0.9-55 TinnR_1.0-5     R2HTML_2.3.1
>   [9] Hmisc_3.12-2    Formula_1.1-1   survival_2.37-7
>
> loaded via a namespace (and not attached):
> [1] cluster_1.15.3  devtools_1.6.1  evaluate_0.5.5  formatR_1.0
> [5] grid_3.1.0      highr_0.4       lattice_0.20-29 rpart_4.1-8
> [9] svMisc_0.9-70
>
> Internet Explorer 11 Version 11.0.9600.17420
>
> Any advice is welcome.
>
>
> Keith Jewell - Statistician
> Tel: +44 (0)1386 842055
> Web:  www.campdenbri.co.uk
> Email:  keith.jewell at campdenBRI.co.uk
>
> Campden BRI (Chipping Campden) Limited - part of the Campden BRI group
> Station Road ♦ Chipping Campden ♦ Gloucestershire ♦ GL55 6LD ♦ UK
>
>
>
> ________________________________
>
> The information in this document and attachments is given after the exercise of all reasonable care and skill in its compilation, preparation and issue, but is provided without liability in its application or use. It may contain privileged information that is exempt from disclosure by law and may be confidential. If you are not the intended recipient you must not copy, distribute or take any action in reliance on it. If you have received this document in error please notify us and delete this message from your system immediately.
>
> Unless otherwise expressly agreed in writing and signed by a duly authorised representative of Campden BRI, all goods & services procured and provided by Campden BRI shall be subject to our relevant Standard Terms and Conditions copies of which are available on request or can be downloaded from our website at http://www.campdenbri.co.uk/campdenbri/terms.php
>
> • In the event of supplying technical services, such services shall be subject to Campden BRI Standard Terms and Conditions of Supply of Goods/Services.
>
> • In the event of supplying training, conferences, seminars and events, such services shall be subject to Campden BRI Standard Terms and Condition for the Supply of Training including Conferences, Seminars and Events.
>
> • In the event of our procurement of goods and services, such goods and services shall be provided subject to Campden BRI Standard Terms and Conditions of Purchase of Goods and/or Services.
>
> Companies (trading) within the Campden BRI Group:
> Campden BRI (private company limited by guarantee, registered number 510618)
> Campden BRI (Chipping Campden) Limited (private company limited by shares, registered number 3836922)
> Campden BRI (Nutfield) (private company limited by guarantee, registered number 2690377)
>
> All companies are registered in England and Wales with the registered office at Station Road, Chipping Campden, Gloucestershire, GL55 6LD.
>
> The Campden BRI Group may monitor e-mail traffic data and also the content of e-mail for the purposes of security and staff training.
>
> ____________________________________________________________
> This e-mail has been scanned for all viruses by MessageLabs.
> ____________________________________________________________
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list