diff --git a/NEWS.md b/NEWS.md index 91f8bd58..19024444 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,8 @@ `list(c(1,2,3), c(4,5,6)) (#485) * a new function `xyzmatrix2list()` is added to achieve this output format directly +* `xyzmatrix()` can now extract coordinates from a 3-vector like `c(1,3,5)` + (#486) # 1.10.3 diff --git a/docs/404.html b/docs/404.html index bfd50493..1759d08f 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1,74 +1,34 @@ - - - - + + + + - Page not found (404) • nat - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + - - - - -
-
- + +
+ + + - - -
+
+
-
+ + - - diff --git a/docs/articles/Installation.html b/docs/articles/Installation.html index 2fd2522f..5782f76f 100644 --- a/docs/articles/Installation.html +++ b/docs/articles/Installation.html @@ -26,6 +26,8 @@ + +
+
-
-

-Preface

+
+

Preface +

This document provides additional details about installation that may help you solve certain difficulties, especially on Windows or Mac platforms.

-

The source code for this vignette is available at https://github.com/natverse/nat/blob/master/vignettes/Installation.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow this link to edit and suggest an alternative wording. Don’t be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you!

+

The source code for this vignette is available at https://github.com/natverse/nat/blob/master/vignettes/Installation.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow this link to edit and suggest an alternative wording. Don’t be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you!

-
-

-Prerequisites

+
+

Prerequisites +

nat is an R package and therefore runs on Mac/Linux/Windows. The only pre-requisite for most functionality is a recent version of R (>=3.1.0 recommended).

-

3D visualisation is provided by the rgl package based on OpenGL. On Mac OS X if you use RStudio or R from the terminal, you must have a copy of XQuartz, the X11 window manager, installed. This is no longer a default install since Mac OS X 10.8. You need to install XQuartz, before installing the nat package. Logout and login for the installation to take effect. You can get it from https://xquartz.macosforge.org/landing/. This page is also linked from the Download R for (Mac) OS X page.

+

3D visualisation is provided by the rgl package based on OpenGL. On Mac OS X if you use RStudio or R from the terminal, you must have a copy of XQuartz, the X11 window manager, installed. This is no longer a default install since Mac OS X 10.8. You need to install XQuartz, before installing the nat package. Logout and login for the installation to take effect. You can get it from https://www.xquartz.org/. This page is also linked from the Download R for (Mac) OS X page.

If you want to apply non-rigid registrations calculated by the Computational Morphometry Toolkit (CMTK) you will need to install that separately – see section External Dependencies below.

-
-

-Basic Installation

+
+

Basic Installation +

As of v1.0 there is a released version on CRAN. This is normally updated only every few months.

+install.packages("nat")

If you wish to run the package tests, it is necessary to install with all dependencies:

-install.packages("nat", dependencies=TRUE)
+install.packages("nat", dependencies=TRUE)
-
-

-Development version

-

nat remains under quite active development, so we generally suggest using the development version directly from github. The recommended way to do this is to install Hadley Wickham’s invaluable devtools package (if you have not already done so) and then use that to install nat.

+
+

Development version +

+

nat remains under quite active development, so we generally suggest using the development version directly from github. The recommended way to do this is to install Hadley Wickham’s invaluable devtools package (if you have not already done so) and then use that to install nat.

 # install devtools if required
-if (!require("devtools")) install.packages("devtools")
+if (!require("devtools")) install.packages("devtools")
 # then install nat
-devtools::install_github("natverse/nat")
-

The nat package includes extensive unit tests which are run along with R’s (extremely fastidious) package check routines by the Travis continuous integration server. The master branch is therefore considered very stable and may well contain fixes or enhancements over released versions. However, you can install any release version including the latest release as follows:

+devtools::install_github("natverse/nat")
+

The nat package includes extensive unit tests which are run along with R’s (extremely fastidious) package check routines by the Travis continuous integration server. The master branch is therefore considered very stable and may well contain fixes or enhancements over released versions. However, you can install any release version including the latest release as follows:

-devtools::install_github("natverse/nat@v1.8.6")
-

The same syntax can be used to install any arbitrary version that you want from github. See ?install_github for details.

-

Note: Windows users need Rtools to install in this way, but devtools should offer to install this for you if you do not already have it.

+devtools::install_github("natverse/nat@v1.8.6")
+

The same syntax can be used to install any arbitrary version that you want from github. See ?install_github for details.

+

Note: Windows users need Rtools to install in this way, but devtools should offer to install this for you if you do not already have it.

-
-

-External Dependencies

-

nat is self sufficient for core functionality, but the transformation of 3D data using Computational Morphometry Toolkit (CMTK) registrations depends on an external installation of that toolkit. CMTK binaries can be downloaded for Windows, Linux and Mac at http://www.nitrc.org/projects/cmtk/. Source code is available from the same site or an unofficial mirror repository at https://github.com/jefferis/cmtk. We have extensive experience of using CMTK under Linux (where we compile from source) and Mac (where we compile or use the MacOSX-10.6-x86_64.dmg binary installers). We have also used neurodebian to install as part of the Travis continuous integration setup (see the project’s .travis.yml file).

-
-

-CMTK+nat on Windows

+
+

External Dependencies +

+

nat is self sufficient for core functionality, but the transformation of 3D data using Computational Morphometry Toolkit (CMTK) registrations depends on an external installation of that toolkit. CMTK binaries can be downloaded for Windows, Linux and Mac at https://www.nitrc.org/projects/cmtk/. Source code is available from the same site or an unofficial mirror repository at https://github.com/jefferis/cmtk. We have extensive experience of using CMTK under Linux (where we compile from source) and Mac (where we compile or use the MacOSX-10.6-x86_64.dmg binary installers). In the past we have also used neurodebian to install as part of the Travis continuous integration setup (see the project’s .travis.yml file).

+
+

CMTK+nat on Windows +

We have much less experience using CMTK on Windows than on Mac/Linux platforms. Experiments in May 2016 suggest that the best option is to use the cygwin CMTK distribution (cygwin provides a linux like environment). Here are the steps we took:

    -
  • You must ensure that you have at least version nat v1.8.5. It is recommended that follow the steps for installing the development version of nat straight from github as described in section Development version +
  • You must ensure that you have at least version nat v1.8.5. It is recommended that follow the steps for installing the development version of nat straight from github as described in section Development version
  • -
  • Install Cygwin accepting the default path C:\cygwin64 +
  • Install Cygwin accepting the default path C:\cygwin64
  • When you run Cygwin’s setup.exe, you should also install all fftw3 packages. (fftw3 is a CMTK dependency which provides fast Fourier transform functions)
  • Download CMTK-3.3.1-CYGWIN-x86_64.tar.gz to the cygwin folder (C:\cygwin64)
  • Start a Cygwin terminal and go to the root directory with the command cd / (this is the same place as C:\cygwin64 in the Windows file system).
  • On the Terminal, issue the following command tar -xvf CMTK-3.3.1-CYGWIN-x86_64.tar.gz to extract CMTK to the cygwin folder.
  • Optionally add C:\cygwin64\bin to your windows path (since v1.8.10 nat should look after this - see ?cmtk.bindir).
  • -
  • The nat function cmtk.bindir() should now correctly identify the CMTK binary directory. You can test that the executables are working by trying the following in R library(nat);cmtk.dof2mat(version = TRUE) which should then respond with “3.3.1” if you have installed the CMTK version we have just mentioned.
  • +
  • The nat function cmtk.bindir() should now correctly identify the CMTK binary directory. You can test that the executables are working by trying the following in R library(nat);cmtk.dof2mat(version = TRUE) which should then respond with “3.3.1” if you have installed the CMTK version we have just mentioned.
@@ -198,11 +200,13 @@

-

Site built with pkgdown 1.6.1.

+

+

Site built with pkgdown 2.0.1.

@@ -211,5 +215,7 @@

+ + diff --git a/docs/articles/Installation_files/accessible-code-block-0.0.1/empty-anchor.js b/docs/articles/Installation_files/accessible-code-block-0.0.1/empty-anchor.js deleted file mode 100644 index ca349fd6..00000000 --- a/docs/articles/Installation_files/accessible-code-block-0.0.1/empty-anchor.js +++ /dev/null @@ -1,15 +0,0 @@ -// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> -// v0.0.1 -// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. - -document.addEventListener('DOMContentLoaded', function() { - const codeList = document.getElementsByClassName("sourceCode"); - for (var i = 0; i < codeList.length; i++) { - var linkList = codeList[i].getElementsByTagName('a'); - for (var j = 0; j < linkList.length; j++) { - if (linkList[j].innerHTML === "") { - linkList[j].setAttribute('aria-hidden', 'true'); - } - } - } -}); diff --git a/docs/articles/Installation_files/anchor-sections-1.0/anchor-sections.css b/docs/articles/Installation_files/anchor-sections-1.0/anchor-sections.css deleted file mode 100644 index 07aee5fc..00000000 --- a/docs/articles/Installation_files/anchor-sections-1.0/anchor-sections.css +++ /dev/null @@ -1,4 +0,0 @@ -/* Styles for section anchors */ -a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;} -a.anchor-section::before {content: '#';} -.hasAnchor:hover a.anchor-section {visibility: visible;} diff --git a/docs/articles/Installation_files/anchor-sections-1.0/anchor-sections.js b/docs/articles/Installation_files/anchor-sections-1.0/anchor-sections.js deleted file mode 100644 index 570f99a0..00000000 --- a/docs/articles/Installation_files/anchor-sections-1.0/anchor-sections.js +++ /dev/null @@ -1,33 +0,0 @@ -// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020. -document.addEventListener('DOMContentLoaded', function() { - // Do nothing if AnchorJS is used - if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) { - return; - } - - const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); - - // Do nothing if sections are already anchored - if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) { - return null; - } - - // Use section id when pandoc runs with --section-divs - const section_id = function(x) { - return ((x.classList.contains('section') || (x.tagName === 'SECTION')) - ? x.id : ''); - }; - - // Add anchors - h.forEach(function(x) { - const id = x.id || section_id(x.parentElement); - if (id === '') { - return null; - } - let anchor = document.createElement('a'); - anchor.href = '#' + id; - anchor.classList = ['anchor-section']; - x.classList.add('hasAnchor'); - x.appendChild(anchor); - }); -}); diff --git a/docs/articles/Installation_files/header-attrs-2.7/header-attrs.js b/docs/articles/Installation_files/header-attrs-2.7/header-attrs.js deleted file mode 100644 index dd57d92e..00000000 --- a/docs/articles/Installation_files/header-attrs-2.7/header-attrs.js +++ /dev/null @@ -1,12 +0,0 @@ -// Pandoc 2.9 adds attributes on both header and div. We remove the former (to -// be compatible with the behavior of Pandoc < 2.8). -document.addEventListener('DOMContentLoaded', function(e) { - var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); - var i, h, a; - for (i = 0; i < hs.length; i++) { - h = hs[i]; - if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 - a = h.attributes; - while (a.length > 0) h.removeAttribute(a[0].name); - } -}); diff --git a/docs/articles/NeuroGeometry.html b/docs/articles/NeuroGeometry.html index 271a2e0f..d8324018 100644 --- a/docs/articles/NeuroGeometry.html +++ b/docs/articles/NeuroGeometry.html @@ -26,6 +26,8 @@ + +
-
+ +
-
-

-Introduction

+
+

Introduction +

One of the key distinguishing features of nat is the ability to analyse neuronal morphology and connectivity from a geometric perspective. In other words nat provides functions to analyse the placement of neurons within the context of the brain and the organisation of local circuits.
This vignette will give a few examples, but this is only skimming the surface of what is possible.

-

If you see an analysis in a paper associated with the Jefferis lab but cannot figure out how to use nat to achieve this, then feel free to contact the nat–user Google group to ask for help.

+

If you see an analysis in a paper associated with the Jefferis lab but cannot figure out how to use nat to achieve this, then feel free to contact the nat–user Google group to ask for help.

-
-

-Vertex information

+
+

Vertex information +

-
## Loading required package: rgl
-
## Registered S3 method overwritten by 'nat':
-##   method             from
-##   as.mesh3d.ashape3d rgl
-
## 
-## Attaching package: 'nat'
-
## The following object is masked from 'package:rgl':
-## 
-##     wire3d
-
## The following objects are masked from 'package:base':
-## 
-##     intersect, setdiff, union
+library(nat)
+
## Loading required package: rgl
+
## Registered S3 method overwritten by 'nat':
+##   method             from
+##   as.mesh3d.ashape3d rgl
+
## 
+## Attaching package: 'nat'
+
## The following object is masked from 'package:rgl':
+## 
+##     wire3d
+
## The following objects are masked from 'package:base':
+## 
+##     intersect, setdiff, union

One of the key tools for geometric work in nat is the xyzmatrix function, which extracts 3-D coordinate information from any object containing vertices.

 n=Cell07PNs[[1]]
 xyz=xyzmatrix(n)
-summary(xyz)
-
##        X               Y                Z        
-##  Min.   :186.9   Min.   : 90.36   Min.   : 88.2  
-##  1st Qu.:225.6   1st Qu.: 97.56   1st Qu.:103.4  
-##  Median :258.4   Median :102.70   Median :112.9  
-##  Mean   :249.4   Mean   :104.03   Mean   :120.9  
-##  3rd Qu.:277.7   3rd Qu.:109.04   3rd Qu.:139.0  
-##  Max.   :289.5   Max.   :132.71   Max.   :157.3
+summary(xyz)
+
##        X               Y                Z        
+##  Min.   :186.9   Min.   : 90.36   Min.   : 88.2  
+##  1st Qu.:225.6   1st Qu.: 97.56   1st Qu.:103.4  
+##  Median :258.4   Median :102.70   Median :112.9  
+##  Mean   :249.4   Mean   :104.03   Mean   :120.9  
+##  3rd Qu.:277.7   3rd Qu.:109.04   3rd Qu.:139.0  
+##  Max.   :289.5   Max.   :132.71   Max.   :157.3
-plot(xyz[,c("X","Y")], type='p')
+plot(xyz[,c("X","Y")], type='p')

This also works for neuronlists, so we can extract all of the points in a collection of neurons:

 xyz=xyzmatrix(Cell07PNs)

We could ask for all the points close to a specific X coordinate

-close_to_x250=abs(xyz[,'X']-250)<10
-table(close_to_x250)
-
## close_to_x250
-## FALSE  TRUE 
-## 20479  1728
-

We can also select points interactively by using the rgl::select3d function.

+close_to_x250=abs(xyz[,'X']-250)<10 +table(close_to_x250)
+
## close_to_x250
+## FALSE  TRUE 
+## 20479  1728
+

We can also select points interactively by using the rgl::select3d function.

-
-

-Worked example - plane cutting a tract

+
+

Worked example - plane cutting a tract +

As a worked example let’s try to find the plane cutting a tract defined by the axons of some example neurons:

-plot(Cell07PNs, WithNodes=F)
+plot(Cell07PNs, WithNodes=F)
 dist=10
-abline(v=250, col='red')
-abline(v=c(250-dist, 250+dist), col='red', lty='dotted')
+abline(v=250, col='red') +abline(v=c(250-dist, 250+dist), col='red', lty='dotted')

We could ask for all the points close to a specific X coordinate

-close_to_x250=abs(xyz[,'X']-250)<10
-table(close_to_x250)
-
## close_to_x250
-## FALSE  TRUE 
-## 20479  1728
+close_to_x250=abs(xyz[,'X']-250)<10 +table(close_to_x250)
+
## close_to_x250
+## FALSE  TRUE 
+## 20479  1728

Let’s find the centroid of those selected points:

-centroid=colMeans(xyz[close_to_x250,])
+centroid=colMeans(xyz[close_to_x250,])
 centroid
-
##         X         Y         Z 
-## 251.16788  94.76735 141.11495
+
##         X         Y         Z 
+## 251.16788  94.76735 141.11495
-plot(Cell07PNs, WithNodes=F)
-points(matrix(centroid[1:2],ncol=2), pch=20)
+plot(Cell07PNs, WithNodes=F) +points(matrix(centroid[1:2],ncol=2), pch=20)

-
-

-PCA to find tract vector

+
+

PCA to find tract vector +

Now let’s do a principal components analysis on those points

-pc=prcomp(xyz[close_to_x250,])
+pc=prcomp(xyz[close_to_x250,])
 pc1=pc$rotation[,'PC1']
-plot(Cell07PNs, WithNodes=F)
-points(matrix(centroid[1:2],ncol=2), pch=20)
-res=rbind(centroid-pc1*10, centroid, centroid+pc1*10)
-lines(res[,1:2])
+plot(Cell07PNs, WithNodes=F) +points(matrix(centroid[1:2],ncol=2), pch=20) +res=rbind(centroid-pc1*10, centroid, centroid+pc1*10) +lines(res[,1:2])

OK, perhaps it would be better if we only used the spine of the neurons

 # There is a problem with one neuron with a loop, hence OmitFailures
 spines=nlapply(Cell07PNs, spine, UseStartPoint=T, OmitFailures = T)
-
## Warning in get.shortest.paths(ng, from = from, to = to, mode = "all"): At
-## structural_properties.c:4597 :Couldn't reach some vertices
+
## Warning in get.shortest.paths(ng, from = from, to = to, mode = "all"): At
+## structural_properties.c:4745 :Couldn't reach some vertices
 xyz=xyzmatrix(spines)
-close_to_x250=abs(xyz[,'X']-250)<10
-table(close_to_x250)
-
## close_to_x250
-## FALSE  TRUE 
-##  5137   876
+close_to_x250=abs(xyz[,'X']-250)<10 +table(close_to_x250)
+
## close_to_x250
+## FALSE  TRUE 
+##  5137   876
-pc=prcomp(xyz[close_to_x250,])
+pc=prcomp(xyz[close_to_x250,])
 pc1=pc$rotation[,'PC1']
-plot(spines, WithNodes=F)
-points(matrix(centroid[1:2],ncol=2), pch=20)
-res=rbind(centroid-pc1*10, centroid, centroid+pc1*10)
+plot(spines, WithNodes=F)
+points(matrix(centroid[1:2],ncol=2), pch=20)
+res=rbind(centroid-pc1*10, centroid, centroid+pc1*10)
 # nb 1:2 => just the xy coords
-lines(res[,1:2])
+lines(res[,1:2])

-
-

-Tract vector for each neuron

+
+

Tract vector for each neuron +

Alternatively, we could find the vector of the first PC for each neuron. Let’s write a function to do that and then apply it to the spine of each neuron.

 # returns 6 vector
@@ -246,39 +248,39 @@ 

# second three values first principal component tract_vector <- function(n, xval=250, thresh=10) { p=xyzmatrix(n) - near=abs(p[,'X']-xval)<thresh - pc=prcomp(p[near,]) - c(colMeans(p[near,]), pc$rotation[,'PC1']) + near=abs(p[,'X']-xval)<thresh + pc=prcomp(p[near,]) + c(colMeans(p[near,]), pc$rotation[,'PC1']) } -tvs=sapply(spines, tract_vector) -mean_cent=rowMeans(tvs[1:3,]) -mean_vec=rowMeans(tvs[4:6,]) +tvs=sapply(spines, tract_vector) +mean_cent=rowMeans(tvs[1:3,]) +mean_vec=rowMeans(tvs[4:6,]) # nb *10 to make the vector longer (10 µm) and more visible -res2=rbind(mean_cent-mean_vec*10, mean_cent, mean_cent+mean_vec*10) -plot(spines, col='grey', WithNodes=F) -lines(res2[,1:2], lwd=3)

+res2=rbind(mean_cent-mean_vec*10, mean_cent, mean_cent+mean_vec*10) +plot(spines, col='grey', WithNodes=F) +lines(res2[,1:2], lwd=3)

-
-

-Lines crossing a plane

+
+

Lines crossing a plane +

We can look at the plane we have defined in a 3D context as follows:

 plc=plane_coefficients(mean_cent, mean_vec)
-plot3d(Cell07PNs[c(1,30)], col='grey', WithNodes = F)
-planes3d(plc[,1:3], d=plc[,'d'])
+plot3d(Cell07PNs[c(1,30)], col='grey', WithNodes = F) +planes3d(plc[,1:3], d=plc[,'d'])

We can also make a small square plane centred on the chosen point

-library(rgl)
-clear3d()
+library(rgl)
+clear3d()
 make_centred_plane <- function(point, normal, scale = 1) {
   # find the two orthogonal vectors to this one
-  uv = Morpho::tangentPlane(normal)
-  uv = sapply(uv, "*", scale, simplify = F)
-  qmesh3d(
-  cbind(
+  uv = Morpho::tangentPlane(normal)
+  uv = sapply(uv, "*", scale, simplify = F)
+  qmesh3d(
+  cbind(
   point + uv$z,
   point + uv$y,
   point - uv$z,
@@ -290,34 +292,34 @@ 

} plane=make_centred_plane(mean_cent, mean_vec, scale=15) plot3d(spines, col='grey') -shade3d(plane, col='red')

+shade3d(plane, col='red')

Finally, we can find the positions at which each neuron intersects the plane. Note that when there are multiple intersections, we only choose the closest point to the centroid that we calculated when defining the plane.

-intersections=t(sapply(Cell07PNs, intersect_plane, plc, closestpoint=mean_cent))
+intersections=t(sapply(Cell07PNs, intersect_plane, plc, closestpoint=mean_cent))
 # center those intersection points
 intersections.cent=scale(intersections, center = T, scale = F)
-d=sqrt(rowSums(intersections.cent^2))
-mean(d)
-
## [1] 3.118692
+d=sqrt(rowSums(intersections.cent^2)) +mean(d)
+
## [1] 3.118692

Then we can plot those positions on the plane

-spheres3d(intersections, col='red', rad=.5)
-shade3d(plane, col='black')
+spheres3d(intersections, col='red', rad=.5)
+shade3d(plane, col='black')
 plot3d(spines, col='grey')
-
-

Finally we can construct a 2D coordinate system on the plane and project the intersection positions onto that.

+
+

Finally we can construct a 2D coordinate system on the plane and project the intersection positions onto that.

 # find pair of orthogonal tangent vectors of plane
-uv = Morpho::tangentPlane(mean_vec)
+uv = Morpho::tangentPlane(mean_vec)
 # centre our points on mean
 sp=scale(intersections, scale = F, center=T)
-DotProduct=function(a,b) sum(a*b)
+DotProduct=function(a,b) sum(a*b)
 # find coordinates w.r.t. to our two basis vectors
-xy=data.frame(u=apply(sp, 1, DotProduct, uv[[1]]),
-           v=apply(sp, 1, DotProduct, uv[[2]]))
+xy=data.frame(u=apply(sp, 1, DotProduct, uv[[1]]),
+           v=apply(sp, 1, DotProduct, uv[[2]]))
 # maintain consist x-y aspect ratio 
-plot(xy, pch=19, asp=1, main = "Position of Axon intersection in plane", 
+plot(xy, pch=19, asp=1, main = "Position of Axon intersection in plane", 
      xlab="u /µm", ylab="v /µm")

@@ -335,11 +337,13 @@

-

Site built with pkgdown 1.6.1.

+

+

Site built with pkgdown 2.0.1.

@@ -348,5 +352,7 @@

+ + diff --git a/docs/articles/NeuroGeometry_files/CanvasMatrix4-0.105.13/CanvasMatrix.src.js b/docs/articles/NeuroGeometry_files/CanvasMatrix4-0.105.13/CanvasMatrix.src.js deleted file mode 100644 index 2bfbd588..00000000 --- a/docs/articles/NeuroGeometry_files/CanvasMatrix4-0.105.13/CanvasMatrix.src.js +++ /dev/null @@ -1,729 +0,0 @@ -/* globals CanvasMatrix4: true */ -/* globals WebGLFloatArray */ -/* jshint eqeqeq: false */ -/* - * Copyright (C) 2009 Apple Inc. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - * Copyright (2016) Duncan Murdoch - fixed CanvasMatrix4.ortho, - * cleaned up. - */ -/* - CanvasMatrix4 class - - This class implements a 4x4 matrix. It has functions which - duplicate the functionality of the OpenGL matrix stack and - glut functions. - - IDL: - - [ - Constructor(in CanvasMatrix4 matrix), // copy passed matrix into new CanvasMatrix4 - Constructor(in sequence array) // create new CanvasMatrix4 with 16 floats (row major) - Constructor() // create new CanvasMatrix4 with identity matrix - ] - interface CanvasMatrix4 { - attribute float m11; - attribute float m12; - attribute float m13; - attribute float m14; - attribute float m21; - attribute float m22; - attribute float m23; - attribute float m24; - attribute float m31; - attribute float m32; - attribute float m33; - attribute float m34; - attribute float m41; - attribute float m42; - attribute float m43; - attribute float m44; - - void load(in CanvasMatrix4 matrix); // copy the values from the passed matrix - void load(in sequence array); // copy 16 floats into the matrix - sequence getAsArray(); // return the matrix as an array of 16 floats - WebGLFloatArray getAsCanvasFloatArray(); // return the matrix as a WebGLFloatArray with 16 values - void makeIdentity(); // replace the matrix with identity - void transpose(); // replace the matrix with its transpose - void invert(); // replace the matrix with its inverse - - void translate(in float x, in float y, in float z); // multiply the matrix by passed translation values on the right - void scale(in float x, in float y, in float z); // multiply the matrix by passed scale values on the right - void rotate(in float angle, // multiply the matrix by passed rotation values on the right - in float x, in float y, in float z); // (angle is in degrees) - void multRight(in CanvasMatrix matrix); // multiply the matrix by the passed matrix on the right - void multLeft(in CanvasMatrix matrix); // multiply the matrix by the passed matrix on the left - void ortho(in float left, in float right, // multiply the matrix by the passed ortho values on the right - in float bottom, in float top, - in float near, in float far); - void frustum(in float left, in float right, // multiply the matrix by the passed frustum values on the right - in float bottom, in float top, - in float near, in float far); - void perspective(in float fovy, in float aspect, // multiply the matrix by the passed perspective values on the right - in float zNear, in float zFar); - void lookat(in float eyex, in float eyey, in float eyez, // multiply the matrix by the passed lookat - in float ctrx, in float ctry, in float ctrz, // values on the right - in float upx, in float upy, in float upz); - } -*/ - -CanvasMatrix4 = function(m) -{ - if (typeof m == 'object') { - if ("length" in m && m.length >= 16) { - this.load(m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9], m[10], m[11], m[12], m[13], m[14], m[15]); - return; - } - else if (m instanceof CanvasMatrix4) { - this.load(m); - return; - } - } - this.makeIdentity(); -}; - -CanvasMatrix4.prototype.load = function() -{ - if (arguments.length == 1 && typeof arguments[0] == 'object') { - var matrix = arguments[0]; - - if ("length" in matrix && matrix.length == 16) { - this.m11 = matrix[0]; - this.m12 = matrix[1]; - this.m13 = matrix[2]; - this.m14 = matrix[3]; - - this.m21 = matrix[4]; - this.m22 = matrix[5]; - this.m23 = matrix[6]; - this.m24 = matrix[7]; - - this.m31 = matrix[8]; - this.m32 = matrix[9]; - this.m33 = matrix[10]; - this.m34 = matrix[11]; - - this.m41 = matrix[12]; - this.m42 = matrix[13]; - this.m43 = matrix[14]; - this.m44 = matrix[15]; - return; - } - - if (arguments[0] instanceof CanvasMatrix4) { - - this.m11 = matrix.m11; - this.m12 = matrix.m12; - this.m13 = matrix.m13; - this.m14 = matrix.m14; - - this.m21 = matrix.m21; - this.m22 = matrix.m22; - this.m23 = matrix.m23; - this.m24 = matrix.m24; - - this.m31 = matrix.m31; - this.m32 = matrix.m32; - this.m33 = matrix.m33; - this.m34 = matrix.m34; - - this.m41 = matrix.m41; - this.m42 = matrix.m42; - this.m43 = matrix.m43; - this.m44 = matrix.m44; - return; - } - } - - this.makeIdentity(); -}; - -CanvasMatrix4.prototype.getAsArray = function() -{ - return [ - this.m11, this.m12, this.m13, this.m14, - this.m21, this.m22, this.m23, this.m24, - this.m31, this.m32, this.m33, this.m34, - this.m41, this.m42, this.m43, this.m44 - ]; -}; - -CanvasMatrix4.prototype.getAsWebGLFloatArray = function() -{ - return new WebGLFloatArray(this.getAsArray()); -}; - -CanvasMatrix4.prototype.makeIdentity = function() -{ - this.m11 = 1; - this.m12 = 0; - this.m13 = 0; - this.m14 = 0; - - this.m21 = 0; - this.m22 = 1; - this.m23 = 0; - this.m24 = 0; - - this.m31 = 0; - this.m32 = 0; - this.m33 = 1; - this.m34 = 0; - - this.m41 = 0; - this.m42 = 0; - this.m43 = 0; - this.m44 = 1; -}; - -CanvasMatrix4.prototype.transpose = function() -{ - var tmp = this.m12; - this.m12 = this.m21; - this.m21 = tmp; - - tmp = this.m13; - this.m13 = this.m31; - this.m31 = tmp; - - tmp = this.m14; - this.m14 = this.m41; - this.m41 = tmp; - - tmp = this.m23; - this.m23 = this.m32; - this.m32 = tmp; - - tmp = this.m24; - this.m24 = this.m42; - this.m42 = tmp; - - tmp = this.m34; - this.m34 = this.m43; - this.m43 = tmp; -}; - -CanvasMatrix4.prototype.invert = function() -{ - // Calculate the 4x4 determinant - // If the determinant is zero, - // then the inverse matrix is not unique. - var det = this._determinant4x4(); - - if (Math.abs(det) < 1e-8) - return null; - - this._makeAdjoint(); - - // Scale the adjoint matrix to get the inverse - this.m11 /= det; - this.m12 /= det; - this.m13 /= det; - this.m14 /= det; - - this.m21 /= det; - this.m22 /= det; - this.m23 /= det; - this.m24 /= det; - - this.m31 /= det; - this.m32 /= det; - this.m33 /= det; - this.m34 /= det; - - this.m41 /= det; - this.m42 /= det; - this.m43 /= det; - this.m44 /= det; -}; - -CanvasMatrix4.prototype.translate = function(x,y,z) -{ - if (x === undefined) - x = 0; - if (y === undefined) - y = 0; - if (z === undefined) - z = 0; - - var matrix = new CanvasMatrix4(); - matrix.m41 = x; - matrix.m42 = y; - matrix.m43 = z; - - this.multRight(matrix); -}; - -CanvasMatrix4.prototype.scale = function(x,y,z) -{ - if (x === undefined) - x = 1; - if (z === undefined) { - if (y === undefined) { - y = x; - z = x; - } - else - z = 1; - } - else if (y === undefined) - y = x; - - var matrix = new CanvasMatrix4(); - matrix.m11 = x; - matrix.m22 = y; - matrix.m33 = z; - - this.multRight(matrix); -}; - -CanvasMatrix4.prototype.rotate = function(angle,x,y,z) -{ - // angles are in degrees. Switch to radians - angle = angle / 180 * Math.PI; - - angle /= 2; - var sinA = Math.sin(angle); - var cosA = Math.cos(angle); - var sinA2 = sinA * sinA; - - // normalize - var length = Math.sqrt(x * x + y * y + z * z); - if (length === 0) { - // bad vector, just use something reasonable - x = 0; - y = 0; - z = 1; - } else if (length != 1) { - x /= length; - y /= length; - z /= length; - } - - var mat = new CanvasMatrix4(); - - // optimize case where axis is along major axis - if (x == 1 && y === 0 && z === 0) { - mat.m11 = 1; - mat.m12 = 0; - mat.m13 = 0; - mat.m21 = 0; - mat.m22 = 1 - 2 * sinA2; - mat.m23 = 2 * sinA * cosA; - mat.m31 = 0; - mat.m32 = -2 * sinA * cosA; - mat.m33 = 1 - 2 * sinA2; - mat.m14 = mat.m24 = mat.m34 = 0; - mat.m41 = mat.m42 = mat.m43 = 0; - mat.m44 = 1; - } else if (x === 0 && y == 1 && z === 0) { - mat.m11 = 1 - 2 * sinA2; - mat.m12 = 0; - mat.m13 = -2 * sinA * cosA; - mat.m21 = 0; - mat.m22 = 1; - mat.m23 = 0; - mat.m31 = 2 * sinA * cosA; - mat.m32 = 0; - mat.m33 = 1 - 2 * sinA2; - mat.m14 = mat.m24 = mat.m34 = 0; - mat.m41 = mat.m42 = mat.m43 = 0; - mat.m44 = 1; - } else if (x === 0 && y === 0 && z == 1) { - mat.m11 = 1 - 2 * sinA2; - mat.m12 = 2 * sinA * cosA; - mat.m13 = 0; - mat.m21 = -2 * sinA * cosA; - mat.m22 = 1 - 2 * sinA2; - mat.m23 = 0; - mat.m31 = 0; - mat.m32 = 0; - mat.m33 = 1; - mat.m14 = mat.m24 = mat.m34 = 0; - mat.m41 = mat.m42 = mat.m43 = 0; - mat.m44 = 1; - } else { - var x2 = x*x; - var y2 = y*y; - var z2 = z*z; - - mat.m11 = 1 - 2 * (y2 + z2) * sinA2; - mat.m12 = 2 * (x * y * sinA2 + z * sinA * cosA); - mat.m13 = 2 * (x * z * sinA2 - y * sinA * cosA); - mat.m21 = 2 * (y * x * sinA2 - z * sinA * cosA); - mat.m22 = 1 - 2 * (z2 + x2) * sinA2; - mat.m23 = 2 * (y * z * sinA2 + x * sinA * cosA); - mat.m31 = 2 * (z * x * sinA2 + y * sinA * cosA); - mat.m32 = 2 * (z * y * sinA2 - x * sinA * cosA); - mat.m33 = 1 - 2 * (x2 + y2) * sinA2; - mat.m14 = mat.m24 = mat.m34 = 0; - mat.m41 = mat.m42 = mat.m43 = 0; - mat.m44 = 1; - } - this.multRight(mat); -}; - -CanvasMatrix4.prototype.multRight = function(mat) -{ - var m11 = (this.m11 * mat.m11 + this.m12 * mat.m21 + - this.m13 * mat.m31 + this.m14 * mat.m41); - var m12 = (this.m11 * mat.m12 + this.m12 * mat.m22 + - this.m13 * mat.m32 + this.m14 * mat.m42); - var m13 = (this.m11 * mat.m13 + this.m12 * mat.m23 + - this.m13 * mat.m33 + this.m14 * mat.m43); - var m14 = (this.m11 * mat.m14 + this.m12 * mat.m24 + - this.m13 * mat.m34 + this.m14 * mat.m44); - - var m21 = (this.m21 * mat.m11 + this.m22 * mat.m21 + - this.m23 * mat.m31 + this.m24 * mat.m41); - var m22 = (this.m21 * mat.m12 + this.m22 * mat.m22 + - this.m23 * mat.m32 + this.m24 * mat.m42); - var m23 = (this.m21 * mat.m13 + this.m22 * mat.m23 + - this.m23 * mat.m33 + this.m24 * mat.m43); - var m24 = (this.m21 * mat.m14 + this.m22 * mat.m24 + - this.m23 * mat.m34 + this.m24 * mat.m44); - - var m31 = (this.m31 * mat.m11 + this.m32 * mat.m21 + - this.m33 * mat.m31 + this.m34 * mat.m41); - var m32 = (this.m31 * mat.m12 + this.m32 * mat.m22 + - this.m33 * mat.m32 + this.m34 * mat.m42); - var m33 = (this.m31 * mat.m13 + this.m32 * mat.m23 + - this.m33 * mat.m33 + this.m34 * mat.m43); - var m34 = (this.m31 * mat.m14 + this.m32 * mat.m24 + - this.m33 * mat.m34 + this.m34 * mat.m44); - - var m41 = (this.m41 * mat.m11 + this.m42 * mat.m21 + - this.m43 * mat.m31 + this.m44 * mat.m41); - var m42 = (this.m41 * mat.m12 + this.m42 * mat.m22 + - this.m43 * mat.m32 + this.m44 * mat.m42); - var m43 = (this.m41 * mat.m13 + this.m42 * mat.m23 + - this.m43 * mat.m33 + this.m44 * mat.m43); - var m44 = (this.m41 * mat.m14 + this.m42 * mat.m24 + - this.m43 * mat.m34 + this.m44 * mat.m44); - - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; - this.m14 = m14; - - this.m21 = m21; - this.m22 = m22; - this.m23 = m23; - this.m24 = m24; - - this.m31 = m31; - this.m32 = m32; - this.m33 = m33; - this.m34 = m34; - - this.m41 = m41; - this.m42 = m42; - this.m43 = m43; - this.m44 = m44; -}; - -CanvasMatrix4.prototype.multLeft = function(mat) -{ - var m11 = (mat.m11 * this.m11 + mat.m12 * this.m21 + - mat.m13 * this.m31 + mat.m14 * this.m41); - var m12 = (mat.m11 * this.m12 + mat.m12 * this.m22 + - mat.m13 * this.m32 + mat.m14 * this.m42); - var m13 = (mat.m11 * this.m13 + mat.m12 * this.m23 + - mat.m13 * this.m33 + mat.m14 * this.m43); - var m14 = (mat.m11 * this.m14 + mat.m12 * this.m24 + - mat.m13 * this.m34 + mat.m14 * this.m44); - - var m21 = (mat.m21 * this.m11 + mat.m22 * this.m21 + - mat.m23 * this.m31 + mat.m24 * this.m41); - var m22 = (mat.m21 * this.m12 + mat.m22 * this.m22 + - mat.m23 * this.m32 + mat.m24 * this.m42); - var m23 = (mat.m21 * this.m13 + mat.m22 * this.m23 + - mat.m23 * this.m33 + mat.m24 * this.m43); - var m24 = (mat.m21 * this.m14 + mat.m22 * this.m24 + - mat.m23 * this.m34 + mat.m24 * this.m44); - - var m31 = (mat.m31 * this.m11 + mat.m32 * this.m21 + - mat.m33 * this.m31 + mat.m34 * this.m41); - var m32 = (mat.m31 * this.m12 + mat.m32 * this.m22 + - mat.m33 * this.m32 + mat.m34 * this.m42); - var m33 = (mat.m31 * this.m13 + mat.m32 * this.m23 + - mat.m33 * this.m33 + mat.m34 * this.m43); - var m34 = (mat.m31 * this.m14 + mat.m32 * this.m24 + - mat.m33 * this.m34 + mat.m34 * this.m44); - - var m41 = (mat.m41 * this.m11 + mat.m42 * this.m21 + - mat.m43 * this.m31 + mat.m44 * this.m41); - var m42 = (mat.m41 * this.m12 + mat.m42 * this.m22 + - mat.m43 * this.m32 + mat.m44 * this.m42); - var m43 = (mat.m41 * this.m13 + mat.m42 * this.m23 + - mat.m43 * this.m33 + mat.m44 * this.m43); - var m44 = (mat.m41 * this.m14 + mat.m42 * this.m24 + - mat.m43 * this.m34 + mat.m44 * this.m44); - - this.m11 = m11; - this.m12 = m12; - this.m13 = m13; - this.m14 = m14; - - this.m21 = m21; - this.m22 = m22; - this.m23 = m23; - this.m24 = m24; - - this.m31 = m31; - this.m32 = m32; - this.m33 = m33; - this.m34 = m34; - - this.m41 = m41; - this.m42 = m42; - this.m43 = m43; - this.m44 = m44; -}; - -CanvasMatrix4.prototype.ortho = function(left, right, bottom, top, near, far) -{ - var tx = (left + right) / (left - right); - var ty = (top + bottom) / (bottom - top); - var tz = (far + near) / (near - far); - - var matrix = new CanvasMatrix4(); - matrix.m11 = 2 / (right - left); - matrix.m12 = 0; - matrix.m13 = 0; - matrix.m14 = 0; - matrix.m21 = 0; - matrix.m22 = 2 / (top - bottom); - matrix.m23 = 0; - matrix.m24 = 0; - matrix.m31 = 0; - matrix.m32 = 0; - matrix.m33 = -2 / (far - near); - matrix.m34 = 0; - matrix.m41 = tx; - matrix.m42 = ty; - matrix.m43 = tz; - matrix.m44 = 1; - - this.multRight(matrix); -}; - -CanvasMatrix4.prototype.frustum = function(left, right, bottom, top, near, far) -{ - var matrix = new CanvasMatrix4(); - var A = (right + left) / (right - left); - var B = (top + bottom) / (top - bottom); - var C = -(far + near) / (far - near); - var D = -(2 * far * near) / (far - near); - - matrix.m11 = (2 * near) / (right - left); - matrix.m12 = 0; - matrix.m13 = 0; - matrix.m14 = 0; - - matrix.m21 = 0; - matrix.m22 = 2 * near / (top - bottom); - matrix.m23 = 0; - matrix.m24 = 0; - - matrix.m31 = A; - matrix.m32 = B; - matrix.m33 = C; - matrix.m34 = -1; - - matrix.m41 = 0; - matrix.m42 = 0; - matrix.m43 = D; - matrix.m44 = 0; - - this.multRight(matrix); -}; - -CanvasMatrix4.prototype.perspective = function(fovy, aspect, zNear, zFar) -{ - var top = Math.tan(fovy * Math.PI / 360) * zNear; - var bottom = -top; - var left = aspect * bottom; - var right = aspect * top; - this.frustum(left, right, bottom, top, zNear, zFar); -}; - -CanvasMatrix4.prototype.lookat = function(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz) -{ - var matrix = new CanvasMatrix4(), - xx, xy, xz; - - // Make rotation matrix - - // Z vector - var zx = eyex - centerx; - var zy = eyey - centery; - var zz = eyez - centerz; - var mag = Math.sqrt(zx * zx + zy * zy + zz * zz); - if (mag) { - zx /= mag; - zy /= mag; - zz /= mag; - } - - // Y vector - var yx = upx; - var yy = upy; - var yz = upz; - - // X vector = Y cross Z - xx = yy * zz - yz * zy; - xy = -yx * zz + yz * zx; - xz = yx * zy - yy * zx; - - // Recompute Y = Z cross X - yx = zy * xz - zz * xy; - yy = -zx * xz + zz * xx; - yx = zx * xy - zy * xx; - - // cross product gives area of parallelogram, which is < 1.0 for - // non-perpendicular unit-length vectors; so normalize x, y here - - mag = Math.sqrt(xx * xx + xy * xy + xz * xz); - if (mag) { - xx /= mag; - xy /= mag; - xz /= mag; - } - - mag = Math.sqrt(yx * yx + yy * yy + yz * yz); - if (mag) { - yx /= mag; - yy /= mag; - yz /= mag; - } - - matrix.m11 = xx; - matrix.m12 = xy; - matrix.m13 = xz; - matrix.m14 = 0; - - matrix.m21 = yx; - matrix.m22 = yy; - matrix.m23 = yz; - matrix.m24 = 0; - - matrix.m31 = zx; - matrix.m32 = zy; - matrix.m33 = zz; - matrix.m34 = 0; - - matrix.m41 = 0; - matrix.m42 = 0; - matrix.m43 = 0; - matrix.m44 = 1; - matrix.translate(-eyex, -eyey, -eyez); - - this.multRight(matrix); -}; - -// Support functions -CanvasMatrix4.prototype._determinant2x2 = function(a, b, c, d) -{ - return a * d - b * c; -}; - -CanvasMatrix4.prototype._determinant3x3 = function(a1, a2, a3, b1, b2, b3, c1, c2, c3) -{ - return a1 * this._determinant2x2(b2, b3, c2, c3) - - b1 * this._determinant2x2(a2, a3, c2, c3) + - c1 * this._determinant2x2(a2, a3, b2, b3); -}; - -CanvasMatrix4.prototype._determinant4x4 = function() -{ - var a1 = this.m11; - var b1 = this.m12; - var c1 = this.m13; - var d1 = this.m14; - - var a2 = this.m21; - var b2 = this.m22; - var c2 = this.m23; - var d2 = this.m24; - - var a3 = this.m31; - var b3 = this.m32; - var c3 = this.m33; - var d3 = this.m34; - - var a4 = this.m41; - var b4 = this.m42; - var c4 = this.m43; - var d4 = this.m44; - - return a1 * this._determinant3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4) - - b1 * this._determinant3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4) + - c1 * this._determinant3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4) - - d1 * this._determinant3x3(a2, a3, a4, b2, b3, b4, c2, c3, c4); -}; - -CanvasMatrix4.prototype._makeAdjoint = function() -{ - var a1 = this.m11; - var b1 = this.m12; - var c1 = this.m13; - var d1 = this.m14; - - var a2 = this.m21; - var b2 = this.m22; - var c2 = this.m23; - var d2 = this.m24; - - var a3 = this.m31; - var b3 = this.m32; - var c3 = this.m33; - var d3 = this.m34; - - var a4 = this.m41; - var b4 = this.m42; - var c4 = this.m43; - var d4 = this.m44; - - // Row column labeling reversed since we transpose rows & columns - this.m11 = this._determinant3x3(b2, b3, b4, c2, c3, c4, d2, d3, d4); - this.m21 = - this._determinant3x3(a2, a3, a4, c2, c3, c4, d2, d3, d4); - this.m31 = this._determinant3x3(a2, a3, a4, b2, b3, b4, d2, d3, d4); - this.m41 = - this._determinant3x3(a2, a3, a4, b2, b3, b4, c2, c3, c4); - - this.m12 = - this._determinant3x3(b1, b3, b4, c1, c3, c4, d1, d3, d4); - this.m22 = this._determinant3x3(a1, a3, a4, c1, c3, c4, d1, d3, d4); - this.m32 = - this._determinant3x3(a1, a3, a4, b1, b3, b4, d1, d3, d4); - this.m42 = this._determinant3x3(a1, a3, a4, b1, b3, b4, c1, c3, c4); - - this.m13 = this._determinant3x3(b1, b2, b4, c1, c2, c4, d1, d2, d4); - this.m23 = - this._determinant3x3(a1, a2, a4, c1, c2, c4, d1, d2, d4); - this.m33 = this._determinant3x3(a1, a2, a4, b1, b2, b4, d1, d2, d4); - this.m43 = - this._determinant3x3(a1, a2, a4, b1, b2, b4, c1, c2, c4); - - this.m14 = - this._determinant3x3(b1, b2, b3, c1, c2, c3, d1, d2, d3); - this.m24 = this._determinant3x3(a1, a2, a3, c1, c2, c3, d1, d2, d3); - this.m34 = - this._determinant3x3(a1, a2, a3, b1, b2, b3, d1, d2, d3); - this.m44 = this._determinant3x3(a1, a2, a3, b1, b2, b3, c1, c2, c3); -}; diff --git a/docs/articles/NeuroGeometry_files/CanvasMatrix4-0.105.13/CanvasMatrix.min.js b/docs/articles/NeuroGeometry_files/CanvasMatrix4-0.108.3/CanvasMatrix.min.js similarity index 100% rename from docs/articles/NeuroGeometry_files/CanvasMatrix4-0.105.13/CanvasMatrix.min.js rename to docs/articles/NeuroGeometry_files/CanvasMatrix4-0.108.3/CanvasMatrix.min.js diff --git a/docs/articles/NeuroGeometry_files/accessible-code-block-0.0.1/empty-anchor.js b/docs/articles/NeuroGeometry_files/accessible-code-block-0.0.1/empty-anchor.js deleted file mode 100644 index ca349fd6..00000000 --- a/docs/articles/NeuroGeometry_files/accessible-code-block-0.0.1/empty-anchor.js +++ /dev/null @@ -1,15 +0,0 @@ -// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> -// v0.0.1 -// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. - -document.addEventListener('DOMContentLoaded', function() { - const codeList = document.getElementsByClassName("sourceCode"); - for (var i = 0; i < codeList.length; i++) { - var linkList = codeList[i].getElementsByTagName('a'); - for (var j = 0; j < linkList.length; j++) { - if (linkList[j].innerHTML === "") { - linkList[j].setAttribute('aria-hidden', 'true'); - } - } - } -}); diff --git a/docs/articles/NeuroGeometry_files/anchor-sections-1.0/anchor-sections.css b/docs/articles/NeuroGeometry_files/anchor-sections-1.0/anchor-sections.css deleted file mode 100644 index 07aee5fc..00000000 --- a/docs/articles/NeuroGeometry_files/anchor-sections-1.0/anchor-sections.css +++ /dev/null @@ -1,4 +0,0 @@ -/* Styles for section anchors */ -a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;} -a.anchor-section::before {content: '#';} -.hasAnchor:hover a.anchor-section {visibility: visible;} diff --git a/docs/articles/NeuroGeometry_files/anchor-sections-1.0/anchor-sections.js b/docs/articles/NeuroGeometry_files/anchor-sections-1.0/anchor-sections.js deleted file mode 100644 index 570f99a0..00000000 --- a/docs/articles/NeuroGeometry_files/anchor-sections-1.0/anchor-sections.js +++ /dev/null @@ -1,33 +0,0 @@ -// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020. -document.addEventListener('DOMContentLoaded', function() { - // Do nothing if AnchorJS is used - if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) { - return; - } - - const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); - - // Do nothing if sections are already anchored - if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) { - return null; - } - - // Use section id when pandoc runs with --section-divs - const section_id = function(x) { - return ((x.classList.contains('section') || (x.tagName === 'SECTION')) - ? x.id : ''); - }; - - // Add anchors - h.forEach(function(x) { - const id = x.id || section_id(x.parentElement); - if (id === '') { - return null; - } - let anchor = document.createElement('a'); - anchor.href = '#' + id; - anchor.classList = ['anchor-section']; - x.classList.add('hasAnchor'); - x.appendChild(anchor); - }); -}); diff --git a/docs/articles/NeuroGeometry_files/crosstalk-1.1.0.1/css/crosstalk.css b/docs/articles/NeuroGeometry_files/crosstalk-1.1.0.1/css/crosstalk.css deleted file mode 100644 index 46befd2e..00000000 --- a/docs/articles/NeuroGeometry_files/crosstalk-1.1.0.1/css/crosstalk.css +++ /dev/null @@ -1,27 +0,0 @@ -/* Adjust margins outwards, so column contents line up with the edges of the - parent of container-fluid. */ -.container-fluid.crosstalk-bscols { - margin-left: -30px; - margin-right: -30px; - white-space: normal; -} - -/* But don't adjust the margins outwards if we're directly under the body, - i.e. we were the top-level of something at the console. */ -body > .container-fluid.crosstalk-bscols { - margin-left: auto; - margin-right: auto; -} - -.crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column { - display: inline-block; - padding-right: 12px; - vertical-align: top; -} - -@media only screen and (max-width:480px) { - .crosstalk-input-checkboxgroup .crosstalk-options-group .crosstalk-options-column { - display: block; - padding-right: inherit; - } -} diff --git a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-1-1.png b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-1-1.png index 30b44a15..f5af9908 100644 Binary files a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-1-1.png and b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-1-1.png differ diff --git a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-10-1.png b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-10-1.png index 875dc658..b610986a 100644 Binary files a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-10-1.png and b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-10-1.png differ diff --git a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-12-1.png b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-12-1.png index b154f8ee..2ff00e7c 100644 Binary files a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-12-1.png and b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-12-1.png differ diff --git a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-13-1.png b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-13-1.png index 2b57bbbc..fdca132a 100644 Binary files a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-13-1.png and b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-13-1.png differ diff --git a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-16-1.png b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-16-1.png index fee221c0..92d278dc 100644 Binary files a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-16-1.png and b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-16-1.png differ diff --git a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-4-1.png index e31f7802..65e730ba 100644 Binary files a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-6-1.png index 1ca954d2..5677b2a7 100644 Binary files a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-7-1.png b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-7-1.png index d879ee5b..9f82d1c0 100644 Binary files a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-7-1.png and b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-7-1.png differ diff --git a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-9-1.png index 57a6b21a..d5c75fff 100644 Binary files a/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-9-1.png and b/docs/articles/NeuroGeometry_files/figure-html/unnamed-chunk-9-1.png differ diff --git a/docs/articles/NeuroGeometry_files/header-attrs-2.7/header-attrs.js b/docs/articles/NeuroGeometry_files/header-attrs-2.7/header-attrs.js deleted file mode 100644 index dd57d92e..00000000 --- a/docs/articles/NeuroGeometry_files/header-attrs-2.7/header-attrs.js +++ /dev/null @@ -1,12 +0,0 @@ -// Pandoc 2.9 adds attributes on both header and div. We remove the former (to -// be compatible with the behavior of Pandoc < 2.8). -document.addEventListener('DOMContentLoaded', function(e) { - var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); - var i, h, a; - for (i = 0; i < hs.length; i++) { - h = hs[i]; - if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 - a = h.attributes; - while (a.length > 0) h.removeAttribute(a[0].name); - } -}); diff --git a/docs/articles/NeuroGeometry_files/htmlwidgets-1.5.3/htmlwidgets.js b/docs/articles/NeuroGeometry_files/htmlwidgets-1.5.4/htmlwidgets.js similarity index 99% rename from docs/articles/NeuroGeometry_files/htmlwidgets-1.5.3/htmlwidgets.js rename to docs/articles/NeuroGeometry_files/htmlwidgets-1.5.4/htmlwidgets.js index 3d227624..da8b2367 100644 --- a/docs/articles/NeuroGeometry_files/htmlwidgets-1.5.3/htmlwidgets.js +++ b/docs/articles/NeuroGeometry_files/htmlwidgets-1.5.4/htmlwidgets.js @@ -251,7 +251,7 @@ try { result = eval("(" + code + ")"); } catch(error) { - if (!error instanceof SyntaxError) { + if (!(error instanceof SyntaxError)) { throw error; } try { diff --git a/docs/articles/NeuroGeometry_files/jquery-1.11.3/jquery.min.js b/docs/articles/NeuroGeometry_files/jquery-1.11.3/jquery.min.js deleted file mode 100644 index a1c07fd8..00000000 --- a/docs/articles/NeuroGeometry_files/jquery-1.11.3/jquery.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! jQuery v3.4.1 | (c) JS Foundation and other contributors | jquery.org/license */ -!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1",k=function(e,t){return new k.fn.init(e,t)},p=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;function d(e){var t=!!e&&"length"in e&&e.length,n=w(e);return!m(e)&&!x(e)&&("array"===n||0===t||"number"==typeof t&&0+~]|"+M+")"+M+"*"),U=new RegExp(M+"|>"),X=new RegExp($),V=new RegExp("^"+I+"$"),G={ID:new RegExp("^#("+I+")"),CLASS:new RegExp("^\\.("+I+")"),TAG:new RegExp("^("+I+"|[*])"),ATTR:new RegExp("^"+W),PSEUDO:new RegExp("^"+$),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+M+"*(even|odd|(([+-]|)(\\d*)n|)"+M+"*(?:([+-]|)"+M+"*(\\d+)|))"+M+"*\\)|)","i"),bool:new RegExp("^(?:"+R+")$","i"),needsContext:new RegExp("^"+M+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+M+"*((?:-\\d)?\\d*)"+M+"*\\)|)(?=[^-]|$)","i")},Y=/HTML$/i,Q=/^(?:input|select|textarea|button)$/i,J=/^h\d$/i,K=/^[^{]+\{\s*\[native \w/,Z=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,ee=/[+~]/,te=new RegExp("\\\\([\\da-f]{1,6}"+M+"?|("+M+")|.)","ig"),ne=function(e,t,n){var r="0x"+t-65536;return r!=r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,1023&r|56320)},re=/([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,ie=function(e,t){return t?"\0"===e?"\ufffd":e.slice(0,-1)+"\\"+e.charCodeAt(e.length-1).toString(16)+" ":"\\"+e},oe=function(){T()},ae=be(function(e){return!0===e.disabled&&"fieldset"===e.nodeName.toLowerCase()},{dir:"parentNode",next:"legend"});try{H.apply(t=O.call(m.childNodes),m.childNodes),t[m.childNodes.length].nodeType}catch(e){H={apply:t.length?function(e,t){L.apply(e,O.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function se(t,e,n,r){var i,o,a,s,u,l,c,f=e&&e.ownerDocument,p=e?e.nodeType:9;if(n=n||[],"string"!=typeof t||!t||1!==p&&9!==p&&11!==p)return n;if(!r&&((e?e.ownerDocument||e:m)!==C&&T(e),e=e||C,E)){if(11!==p&&(u=Z.exec(t)))if(i=u[1]){if(9===p){if(!(a=e.getElementById(i)))return n;if(a.id===i)return n.push(a),n}else if(f&&(a=f.getElementById(i))&&y(e,a)&&a.id===i)return n.push(a),n}else{if(u[2])return H.apply(n,e.getElementsByTagName(t)),n;if((i=u[3])&&d.getElementsByClassName&&e.getElementsByClassName)return H.apply(n,e.getElementsByClassName(i)),n}if(d.qsa&&!A[t+" "]&&(!v||!v.test(t))&&(1!==p||"object"!==e.nodeName.toLowerCase())){if(c=t,f=e,1===p&&U.test(t)){(s=e.getAttribute("id"))?s=s.replace(re,ie):e.setAttribute("id",s=k),o=(l=h(t)).length;while(o--)l[o]="#"+s+" "+xe(l[o]);c=l.join(","),f=ee.test(t)&&ye(e.parentNode)||e}try{return H.apply(n,f.querySelectorAll(c)),n}catch(e){A(t,!0)}finally{s===k&&e.removeAttribute("id")}}}return g(t.replace(B,"$1"),e,n,r)}function ue(){var r=[];return function e(t,n){return r.push(t+" ")>b.cacheLength&&delete e[r.shift()],e[t+" "]=n}}function le(e){return e[k]=!0,e}function ce(e){var t=C.createElement("fieldset");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function fe(e,t){var n=e.split("|"),r=n.length;while(r--)b.attrHandle[n[r]]=t}function pe(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function de(t){return function(e){return"input"===e.nodeName.toLowerCase()&&e.type===t}}function he(n){return function(e){var t=e.nodeName.toLowerCase();return("input"===t||"button"===t)&&e.type===n}}function ge(t){return function(e){return"form"in e?e.parentNode&&!1===e.disabled?"label"in e?"label"in e.parentNode?e.parentNode.disabled===t:e.disabled===t:e.isDisabled===t||e.isDisabled!==!t&&ae(e)===t:e.disabled===t:"label"in e&&e.disabled===t}}function ve(a){return le(function(o){return o=+o,le(function(e,t){var n,r=a([],e.length,o),i=r.length;while(i--)e[n=r[i]]&&(e[n]=!(t[n]=e[n]))})})}function ye(e){return e&&"undefined"!=typeof e.getElementsByTagName&&e}for(e in d=se.support={},i=se.isXML=function(e){var t=e.namespaceURI,n=(e.ownerDocument||e).documentElement;return!Y.test(t||n&&n.nodeName||"HTML")},T=se.setDocument=function(e){var t,n,r=e?e.ownerDocument||e:m;return r!==C&&9===r.nodeType&&r.documentElement&&(a=(C=r).documentElement,E=!i(C),m!==C&&(n=C.defaultView)&&n.top!==n&&(n.addEventListener?n.addEventListener("unload",oe,!1):n.attachEvent&&n.attachEvent("onunload",oe)),d.attributes=ce(function(e){return e.className="i",!e.getAttribute("className")}),d.getElementsByTagName=ce(function(e){return e.appendChild(C.createComment("")),!e.getElementsByTagName("*").length}),d.getElementsByClassName=K.test(C.getElementsByClassName),d.getById=ce(function(e){return a.appendChild(e).id=k,!C.getElementsByName||!C.getElementsByName(k).length}),d.getById?(b.filter.ID=function(e){var t=e.replace(te,ne);return function(e){return e.getAttribute("id")===t}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n=t.getElementById(e);return n?[n]:[]}}):(b.filter.ID=function(e){var n=e.replace(te,ne);return function(e){var t="undefined"!=typeof e.getAttributeNode&&e.getAttributeNode("id");return t&&t.value===n}},b.find.ID=function(e,t){if("undefined"!=typeof t.getElementById&&E){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("id"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("id"))&&n.value===e)return[o]}return[]}}),b.find.TAG=d.getElementsByTagName?function(e,t){return"undefined"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):d.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("*"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},b.find.CLASS=d.getElementsByClassName&&function(e,t){if("undefined"!=typeof t.getElementsByClassName&&E)return t.getElementsByClassName(e)},s=[],v=[],(d.qsa=K.test(C.querySelectorAll))&&(ce(function(e){a.appendChild(e).innerHTML="",e.querySelectorAll("[msallowcapture^='']").length&&v.push("[*^$]="+M+"*(?:''|\"\")"),e.querySelectorAll("[selected]").length||v.push("\\["+M+"*(?:value|"+R+")"),e.querySelectorAll("[id~="+k+"-]").length||v.push("~="),e.querySelectorAll(":checked").length||v.push(":checked"),e.querySelectorAll("a#"+k+"+*").length||v.push(".#.+[+~]")}),ce(function(e){e.innerHTML="";var t=C.createElement("input");t.setAttribute("type","hidden"),e.appendChild(t).setAttribute("name","D"),e.querySelectorAll("[name=d]").length&&v.push("name"+M+"*[*^$|!~]?="),2!==e.querySelectorAll(":enabled").length&&v.push(":enabled",":disabled"),a.appendChild(e).disabled=!0,2!==e.querySelectorAll(":disabled").length&&v.push(":enabled",":disabled"),e.querySelectorAll("*,:x"),v.push(",.*:")})),(d.matchesSelector=K.test(c=a.matches||a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.msMatchesSelector))&&ce(function(e){d.disconnectedMatch=c.call(e,"*"),c.call(e,"[s!='']:x"),s.push("!=",$)}),v=v.length&&new RegExp(v.join("|")),s=s.length&&new RegExp(s.join("|")),t=K.test(a.compareDocumentPosition),y=t||K.test(a.contains)?function(e,t){var n=9===e.nodeType?e.documentElement:e,r=t&&t.parentNode;return e===r||!(!r||1!==r.nodeType||!(n.contains?n.contains(r):e.compareDocumentPosition&&16&e.compareDocumentPosition(r)))}:function(e,t){if(t)while(t=t.parentNode)if(t===e)return!0;return!1},D=t?function(e,t){if(e===t)return l=!0,0;var n=!e.compareDocumentPosition-!t.compareDocumentPosition;return n||(1&(n=(e.ownerDocument||e)===(t.ownerDocument||t)?e.compareDocumentPosition(t):1)||!d.sortDetached&&t.compareDocumentPosition(e)===n?e===C||e.ownerDocument===m&&y(m,e)?-1:t===C||t.ownerDocument===m&&y(m,t)?1:u?P(u,e)-P(u,t):0:4&n?-1:1)}:function(e,t){if(e===t)return l=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=[e],s=[t];if(!i||!o)return e===C?-1:t===C?1:i?-1:o?1:u?P(u,e)-P(u,t):0;if(i===o)return pe(e,t);n=e;while(n=n.parentNode)a.unshift(n);n=t;while(n=n.parentNode)s.unshift(n);while(a[r]===s[r])r++;return r?pe(a[r],s[r]):a[r]===m?-1:s[r]===m?1:0}),C},se.matches=function(e,t){return se(e,null,null,t)},se.matchesSelector=function(e,t){if((e.ownerDocument||e)!==C&&T(e),d.matchesSelector&&E&&!A[t+" "]&&(!s||!s.test(t))&&(!v||!v.test(t)))try{var n=c.call(e,t);if(n||d.disconnectedMatch||e.document&&11!==e.document.nodeType)return n}catch(e){A(t,!0)}return 0":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(e){return e[1]=e[1].replace(te,ne),e[3]=(e[3]||e[4]||e[5]||"").replace(te,ne),"~="===e[2]&&(e[3]=" "+e[3]+" "),e.slice(0,4)},CHILD:function(e){return e[1]=e[1].toLowerCase(),"nth"===e[1].slice(0,3)?(e[3]||se.error(e[0]),e[4]=+(e[4]?e[5]+(e[6]||1):2*("even"===e[3]||"odd"===e[3])),e[5]=+(e[7]+e[8]||"odd"===e[3])):e[3]&&se.error(e[0]),e},PSEUDO:function(e){var t,n=!e[6]&&e[2];return G.CHILD.test(e[0])?null:(e[3]?e[2]=e[4]||e[5]||"":n&&X.test(n)&&(t=h(n,!0))&&(t=n.indexOf(")",n.length-t)-n.length)&&(e[0]=e[0].slice(0,t),e[2]=n.slice(0,t)),e.slice(0,3))}},filter:{TAG:function(e){var t=e.replace(te,ne).toLowerCase();return"*"===e?function(){return!0}:function(e){return e.nodeName&&e.nodeName.toLowerCase()===t}},CLASS:function(e){var t=p[e+" "];return t||(t=new RegExp("(^|"+M+")"+e+"("+M+"|$)"))&&p(e,function(e){return t.test("string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute("class")||"")})},ATTR:function(n,r,i){return function(e){var t=se.attr(e,n);return null==t?"!="===r:!r||(t+="","="===r?t===i:"!="===r?t!==i:"^="===r?i&&0===t.indexOf(i):"*="===r?i&&-1:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i;function j(e,n,r){return m(n)?k.grep(e,function(e,t){return!!n.call(e,t,e)!==r}):n.nodeType?k.grep(e,function(e){return e===n!==r}):"string"!=typeof n?k.grep(e,function(e){return-1)[^>]*|#([\w-]+))$/;(k.fn.init=function(e,t,n){var r,i;if(!e)return this;if(n=n||q,"string"==typeof e){if(!(r="<"===e[0]&&">"===e[e.length-1]&&3<=e.length?[null,e,null]:L.exec(e))||!r[1]&&t)return!t||t.jquery?(t||n).find(e):this.constructor(t).find(e);if(r[1]){if(t=t instanceof k?t[0]:t,k.merge(this,k.parseHTML(r[1],t&&t.nodeType?t.ownerDocument||t:E,!0)),D.test(r[1])&&k.isPlainObject(t))for(r in t)m(this[r])?this[r](t[r]):this.attr(r,t[r]);return this}return(i=E.getElementById(r[2]))&&(this[0]=i,this.length=1),this}return e.nodeType?(this[0]=e,this.length=1,this):m(e)?void 0!==n.ready?n.ready(e):e(k):k.makeArray(e,this)}).prototype=k.fn,q=k(E);var H=/^(?:parents|prev(?:Until|All))/,O={children:!0,contents:!0,next:!0,prev:!0};function P(e,t){while((e=e[t])&&1!==e.nodeType);return e}k.fn.extend({has:function(e){var t=k(e,this),n=t.length;return this.filter(function(){for(var e=0;e\x20\t\r\n\f]*)/i,he=/^$|^module$|\/(?:java|ecma)script/i,ge={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};function ve(e,t){var n;return n="undefined"!=typeof e.getElementsByTagName?e.getElementsByTagName(t||"*"):"undefined"!=typeof e.querySelectorAll?e.querySelectorAll(t||"*"):[],void 0===t||t&&A(e,t)?k.merge([e],n):n}function ye(e,t){for(var n=0,r=e.length;nx",y.noCloneChecked=!!me.cloneNode(!0).lastChild.defaultValue;var Te=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,Ee=/^([^.]*)(?:\.(.+)|)/;function ke(){return!0}function Se(){return!1}function Ne(e,t){return e===function(){try{return E.activeElement}catch(e){}}()==("focus"===t)}function Ae(e,t,n,r,i,o){var a,s;if("object"==typeof t){for(s in"string"!=typeof n&&(r=r||n,n=void 0),t)Ae(e,s,n,r,t[s],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Se;else if(!i)return e;return 1===o&&(a=i,(i=function(e){return k().off(e),a.apply(this,arguments)}).guid=a.guid||(a.guid=k.guid++)),e.each(function(){k.event.add(this,t,i,r,n)})}function De(e,i,o){o?(Q.set(e,i,!1),k.event.add(e,i,{namespace:!1,handler:function(e){var t,n,r=Q.get(this,i);if(1&e.isTrigger&&this[i]){if(r.length)(k.event.special[i]||{}).delegateType&&e.stopPropagation();else if(r=s.call(arguments),Q.set(this,i,r),t=o(this,i),this[i](),r!==(n=Q.get(this,i))||t?Q.set(this,i,!1):n={},r!==n)return e.stopImmediatePropagation(),e.preventDefault(),n.value}else r.length&&(Q.set(this,i,{value:k.event.trigger(k.extend(r[0],k.Event.prototype),r.slice(1),this)}),e.stopImmediatePropagation())}})):void 0===Q.get(e,i)&&k.event.add(e,i,ke)}k.event={global:{},add:function(t,e,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.get(t);if(v){n.handler&&(n=(o=n).handler,i=o.selector),i&&k.find.matchesSelector(ie,i),n.guid||(n.guid=k.guid++),(u=v.events)||(u=v.events={}),(a=v.handle)||(a=v.handle=function(e){return"undefined"!=typeof k&&k.event.triggered!==e.type?k.event.dispatch.apply(t,arguments):void 0}),l=(e=(e||"").match(R)||[""]).length;while(l--)d=g=(s=Ee.exec(e[l])||[])[1],h=(s[2]||"").split(".").sort(),d&&(f=k.event.special[d]||{},d=(i?f.delegateType:f.bindType)||d,f=k.event.special[d]||{},c=k.extend({type:d,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&k.expr.match.needsContext.test(i),namespace:h.join(".")},o),(p=u[d])||((p=u[d]=[]).delegateCount=0,f.setup&&!1!==f.setup.call(t,r,h,a)||t.addEventListener&&t.addEventListener(d,a)),f.add&&(f.add.call(t,c),c.handler.guid||(c.handler.guid=n.guid)),i?p.splice(p.delegateCount++,0,c):p.push(c),k.event.global[d]=!0)}},remove:function(e,t,n,r,i){var o,a,s,u,l,c,f,p,d,h,g,v=Q.hasData(e)&&Q.get(e);if(v&&(u=v.events)){l=(t=(t||"").match(R)||[""]).length;while(l--)if(d=g=(s=Ee.exec(t[l])||[])[1],h=(s[2]||"").split(".").sort(),d){f=k.event.special[d]||{},p=u[d=(r?f.delegateType:f.bindType)||d]||[],s=s[2]&&new RegExp("(^|\\.)"+h.join("\\.(?:.*\\.|)")+"(\\.|$)"),a=o=p.length;while(o--)c=p[o],!i&&g!==c.origType||n&&n.guid!==c.guid||s&&!s.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(p.splice(o,1),c.selector&&p.delegateCount--,f.remove&&f.remove.call(e,c));a&&!p.length&&(f.teardown&&!1!==f.teardown.call(e,h,v.handle)||k.removeEvent(e,d,v.handle),delete u[d])}else for(d in u)k.event.remove(e,d+t[l],n,r,!0);k.isEmptyObject(u)&&Q.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,a,s=k.event.fix(e),u=new Array(arguments.length),l=(Q.get(this,"events")||{})[s.type]||[],c=k.event.special[s.type]||{};for(u[0]=s,t=1;t\x20\t\r\n\f]*)[^>]*)\/>/gi,qe=/\s*$/g;function Oe(e,t){return A(e,"table")&&A(11!==t.nodeType?t:t.firstChild,"tr")&&k(e).children("tbody")[0]||e}function Pe(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Re(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Me(e,t){var n,r,i,o,a,s,u,l;if(1===t.nodeType){if(Q.hasData(e)&&(o=Q.access(e),a=Q.set(t,o),l=o.events))for(i in delete a.handle,a.events={},l)for(n=0,r=l[i].length;n")},clone:function(e,t,n){var r,i,o,a,s,u,l,c=e.cloneNode(!0),f=oe(e);if(!(y.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||k.isXMLDoc(e)))for(a=ve(c),r=0,i=(o=ve(e)).length;r").attr(n.scriptAttrs||{}).prop({charset:n.scriptCharset,src:n.url}).on("load error",i=function(e){r.remove(),i=null,e&&t("error"===e.type?404:200,e.type)}),E.head.appendChild(r[0])},abort:function(){i&&i()}}});var Vt,Gt=[],Yt=/(=)\?(?=&|$)|\?\?/;k.ajaxSetup({jsonp:"callback",jsonpCallback:function(){var e=Gt.pop()||k.expando+"_"+kt++;return this[e]=!0,e}}),k.ajaxPrefilter("json jsonp",function(e,t,n){var r,i,o,a=!1!==e.jsonp&&(Yt.test(e.url)?"url":"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&Yt.test(e.data)&&"data");if(a||"jsonp"===e.dataTypes[0])return r=e.jsonpCallback=m(e.jsonpCallback)?e.jsonpCallback():e.jsonpCallback,a?e[a]=e[a].replace(Yt,"$1"+r):!1!==e.jsonp&&(e.url+=(St.test(e.url)?"&":"?")+e.jsonp+"="+r),e.converters["script json"]=function(){return o||k.error(r+" was not called"),o[0]},e.dataTypes[0]="json",i=C[r],C[r]=function(){o=arguments},n.always(function(){void 0===i?k(C).removeProp(r):C[r]=i,e[r]&&(e.jsonpCallback=t.jsonpCallback,Gt.push(r)),o&&m(i)&&i(o[0]),o=i=void 0}),"script"}),y.createHTMLDocument=((Vt=E.implementation.createHTMLDocument("").body).innerHTML="
",2===Vt.childNodes.length),k.parseHTML=function(e,t,n){return"string"!=typeof e?[]:("boolean"==typeof t&&(n=t,t=!1),t||(y.createHTMLDocument?((r=(t=E.implementation.createHTMLDocument("")).createElement("base")).href=E.location.href,t.head.appendChild(r)):t=E),o=!n&&[],(i=D.exec(e))?[t.createElement(i[1])]:(i=we([e],t,o),o&&o.length&&k(o).remove(),k.merge([],i.childNodes)));var r,i,o},k.fn.load=function(e,t,n){var r,i,o,a=this,s=e.indexOf(" ");return-1").append(k.parseHTML(e)).find(r):e)}).always(n&&function(e,t){a.each(function(){n.apply(this,o||[e.responseText,t,e])})}),this},k.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(e,t){k.fn[t]=function(e){return this.on(t,e)}}),k.expr.pseudos.animated=function(t){return k.grep(k.timers,function(e){return t===e.elem}).length},k.offset={setOffset:function(e,t,n){var r,i,o,a,s,u,l=k.css(e,"position"),c=k(e),f={};"static"===l&&(e.style.position="relative"),s=c.offset(),o=k.css(e,"top"),u=k.css(e,"left"),("absolute"===l||"fixed"===l)&&-1<(o+u).indexOf("auto")?(a=(r=c.position()).top,i=r.left):(a=parseFloat(o)||0,i=parseFloat(u)||0),m(t)&&(t=t.call(e,n,k.extend({},s))),null!=t.top&&(f.top=t.top-s.top+a),null!=t.left&&(f.left=t.left-s.left+i),"using"in t?t.using.call(e,f):c.css(f)}},k.fn.extend({offset:function(t){if(arguments.length)return void 0===t?this:this.each(function(e){k.offset.setOffset(this,t,e)});var e,n,r=this[0];return r?r.getClientRects().length?(e=r.getBoundingClientRect(),n=r.ownerDocument.defaultView,{top:e.top+n.pageYOffset,left:e.left+n.pageXOffset}):{top:0,left:0}:void 0},position:function(){if(this[0]){var e,t,n,r=this[0],i={top:0,left:0};if("fixed"===k.css(r,"position"))t=r.getBoundingClientRect();else{t=this.offset(),n=r.ownerDocument,e=r.offsetParent||n.documentElement;while(e&&(e===n.body||e===n.documentElement)&&"static"===k.css(e,"position"))e=e.parentNode;e&&e!==r&&1===e.nodeType&&((i=k(e).offset()).top+=k.css(e,"borderTopWidth",!0),i.left+=k.css(e,"borderLeftWidth",!0))}return{top:t.top-i.top-k.css(r,"marginTop",!0),left:t.left-i.left-k.css(r,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var e=this.offsetParent;while(e&&"static"===k.css(e,"position"))e=e.offsetParent;return e||ie})}}),k.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(t,i){var o="pageYOffset"===i;k.fn[t]=function(e){return _(this,function(e,t,n){var r;if(x(e)?r=e:9===e.nodeType&&(r=e.defaultView),void 0===n)return r?r[i]:e[t];r?r.scrollTo(o?r.pageXOffset:n,o?n:r.pageYOffset):e[t]=n},t,e,arguments.length)}}),k.each(["top","left"],function(e,n){k.cssHooks[n]=ze(y.pixelPosition,function(e,t){if(t)return t=_e(e,n),$e.test(t)?k(e).position()[n]+"px":t})}),k.each({Height:"height",Width:"width"},function(a,s){k.each({padding:"inner"+a,content:s,"":"outer"+a},function(r,o){k.fn[o]=function(e,t){var n=arguments.length&&(r||"boolean"!=typeof e),i=r||(!0===e||!0===t?"margin":"border");return _(this,function(e,t,n){var r;return x(e)?0===o.indexOf("outer")?e["inner"+a]:e.document.documentElement["client"+a]:9===e.nodeType?(r=e.documentElement,Math.max(e.body["scroll"+a],r["scroll"+a],e.body["offset"+a],r["offset"+a],r["client"+a])):void 0===n?k.css(e,t,i):k.style(e,t,n,i)},s,n?e:void 0,n)}})}),k.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,n){k.fn[n]=function(e,t){return 0"," ","+","~","preFilter","excess","unquoted","nodeNameSelector","pattern","operator","check","result","what","simple","forward","ofType","xml","uniqueCache","outerCache","nodeIndex","start","parent","useCache","lastChild","uniqueID","pseudo","args","setFilters","idx","matched","not","matcher","unmatched","has","lang","elemLang","hash","location","root","focus","activeElement","hasFocus","href","tabIndex","enabled","checked","selected","selectedIndex","empty","header","button","even","odd","lt","gt","radio","checkbox","file","password","image","submit","reset","tokens","combinator","base","skip","checkNonElements","doneName","oldCache","newCache","elementMatcher","matchers","condense","newUnmatched","mapped","setMatcher","postFilter","postFinder","postSelector","temp","preMap","postMap","preexisting","contexts","multipleContexts","matcherIn","matcherOut","matcherFromTokens","checkContext","leadingRelative","implicitRelative","matchContext","matchAnyContext","filters","parseOnly","soFar","preFilters","cached","elementMatchers","setMatchers","bySet","byElement","superMatcher","outermost","matchedCount","setMatched","contextBackup","dirrunsUnique","token","compiled","defaultValue","unique","isXMLDoc","escapeSelector","until","truncate","is","siblings","n","rneedsContext","rsingleTag","winnow","qualifier","self","rootjQuery","parseHTML","ready","rparentsprev","guaranteedUnique","children","contents","prev","sibling","targets","l","closest","index","prevAll","add","addBack","parents","parentsUntil","nextAll","nextUntil","prevUntil","contentDocument","content","reverse","rnothtmlwhite","Identity","v","Thrower","ex","adoptValue","resolve","reject","noValue","method","promise","fail","then","Callbacks","object","flag","firing","memory","fired","locked","queue","firingIndex","fire","once","stopOnFalse","remove","disable","lock","fireWith","Deferred","func","tuples","state","always","deferred","catch","pipe","fns","newDefer","tuple","returned","progress","notify","onFulfilled","onRejected","onProgress","maxDepth","depth","special","that","mightThrow","TypeError","notifyWith","resolveWith","process","exceptionHook","stackTrace","rejectWith","getStackHook","setTimeout","stateString","when","singleValue","remaining","resolveContexts","resolveValues","master","updateFunc","rerrorNames","stack","console","warn","message","readyException","readyList","completed","removeEventListener","readyWait","wait","readyState","doScroll","access","chainable","emptyGet","raw","bulk","rmsPrefix","rdashAlpha","fcamelCase","all","letter","toUpperCase","camelCase","string","acceptData","owner","Data","uid","defineProperty","configurable","set","data","prop","hasData","dataPriv","dataUser","rbrace","rmultiDash","dataAttr","JSON","parse","removeData","_data","_removeData","dequeue","startLength","hooks","_queueHooks","stop","setter","clearQueue","count","defer","pnum","source","rcssNum","cssExpand","isAttached","composed","getRootNode","isHiddenWithinTree","style","display","css","swap","old","adjustCSS","valueParts","tween","adjusted","scale","maxIterations","currentValue","initial","unit","cssNumber","initialInUnit","defaultDisplayMap","showHide","show","values","body","hide","toggle","rcheckableType","rtagName","rscriptType","wrapMap","option","thead","col","tr","td","_default","getAll","setGlobalEval","refElements","optgroup","tbody","tfoot","colgroup","caption","th","div","buildFragment","scripts","selection","ignored","wrap","attached","fragment","createDocumentFragment","nodes","htmlPrefilter","createTextNode","checkClone","cloneNode","noCloneChecked","rkeyEvent","rmouseEvent","rtypenamespace","returnTrue","returnFalse","expectSync","err","safeActiveElement","on","types","one","origFn","event","off","leverageNative","notAsync","saved","isTrigger","delegateType","stopPropagation","stopImmediatePropagation","preventDefault","trigger","Event","handleObjIn","eventHandle","events","t","handleObj","handlers","namespaces","origType","elemData","handle","triggered","dispatch","bindType","delegateCount","setup","mappedTypes","origCount","teardown","removeEvent","nativeEvent","handlerQueue","fix","delegateTarget","preDispatch","isPropagationStopped","currentTarget","isImmediatePropagationStopped","rnamespace","postDispatch","matchedHandlers","matchedSelectors","addProp","hook","enumerable","originalEvent","writable","load","noBubble","click","beforeunload","returnValue","props","isDefaultPrevented","defaultPrevented","relatedTarget","timeStamp","now","isSimulated","altKey","bubbles","cancelable","changedTouches","ctrlKey","detail","eventPhase","metaKey","pageX","pageY","shiftKey","view","char","charCode","keyCode","buttons","clientX","clientY","offsetX","offsetY","pointerId","pointerType","screenX","screenY","targetTouches","toElement","touches","which","blur","mouseenter","mouseleave","pointerenter","pointerleave","orig","related","rxhtmlTag","rnoInnerhtml","rchecked","rcleanScript","manipulationTarget","disableScript","restoreScript","cloneCopyEvent","dest","pdataOld","pdataCur","udataOld","udataCur","domManip","collection","hasScripts","iNoClone","valueIsFunction","html","_evalUrl","keepData","cleanData","dataAndEvents","deepDataAndEvents","srcElements","destElements","inPage","detach","append","prepend","insertBefore","before","after","replaceWith","replaceChild","appendTo","prependTo","insertAfter","replaceAll","original","insert","rnumnonpx","getStyles","opener","getComputedStyle","rboxStyle","curCSS","computed","width","minWidth","maxWidth","getPropertyValue","pixelBoxStyles","addGetHookIf","conditionFn","hookFn","computeStyleTests","container","cssText","divStyle","pixelPositionVal","reliableMarginLeftVal","roundPixelMeasures","marginLeft","right","pixelBoxStylesVal","boxSizingReliableVal","position","scrollboxSizeVal","offsetWidth","measure","round","parseFloat","backgroundClip","clearCloneStyle","boxSizingReliable","pixelPosition","reliableMarginLeft","scrollboxSize","cssPrefixes","emptyStyle","vendorProps","finalPropName","final","cssProps","capName","vendorPropName","rdisplayswap","rcustomProp","cssShow","visibility","cssNormalTransform","letterSpacing","fontWeight","setPositiveNumber","subtract","max","boxModelAdjustment","dimension","box","isBorderBox","styles","computedVal","extra","delta","ceil","getWidthOrHeight","valueIsBorderBox","offsetProp","getClientRects","Tween","easing","cssHooks","opacity","animationIterationCount","columnCount","fillOpacity","flexGrow","flexShrink","gridArea","gridColumn","gridColumnEnd","gridColumnStart","gridRow","gridRowEnd","gridRowStart","lineHeight","order","orphans","widows","zIndex","zoom","origName","isCustomProp","setProperty","isFinite","getBoundingClientRect","scrollboxSizeBuggy","left","margin","padding","border","prefix","suffix","expand","expanded","parts","propHooks","run","percent","eased","duration","pos","step","fx","scrollTop","scrollLeft","linear","p","swing","cos","PI","fxNow","inProgress","opt","rfxtypes","rrun","schedule","hidden","requestAnimationFrame","interval","tick","createFxNow","genFx","includeWidth","height","createTween","animation","Animation","tweeners","properties","stopped","prefilters","currentTime","startTime","tweens","opts","specialEasing","originalProperties","originalOptions","gotoEnd","propFilter","bind","complete","timer","anim","*","tweener","oldfire","propTween","restoreDisplay","isBox","dataShow","unqueued","overflow","overflowX","overflowY","prefilter","speed","speeds","fadeTo","to","animate","optall","doAnimation","finish","stopQueue","timers","cssFn","slideDown","slideUp","slideToggle","fadeIn","fadeOut","fadeToggle","slow","fast","delay","time","timeout","clearTimeout","checkOn","optSelected","radioValue","boolHook","removeAttr","nType","attrHooks","attrNames","getter","lowercaseName","rfocusable","rclickable","stripAndCollapse","getClass","classesToArray","removeProp","propFix","tabindex","parseInt","for","class","addClass","classes","curValue","clazz","finalValue","removeClass","toggleClass","stateVal","isValidValue","classNames","hasClass","rreturn","valHooks","optionSet","focusin","rfocusMorph","stopPropagationCallback","onlyHandlers","bubbleType","ontype","lastElement","eventPath","parentWindow","simulate","triggerHandler","attaches","rquery","parseXML","DOMParser","parseFromString","rbracket","rCRLF","rsubmitterTypes","rsubmittable","buildParams","traditional","param","s","valueOrFunction","encodeURIComponent","serialize","serializeArray","r20","rhash","rantiCache","rheaders","rnoContent","rprotocol","transports","allTypes","originAnchor","addToPrefiltersOrTransports","structure","dataTypeExpression","dataType","dataTypes","inspectPrefiltersOrTransports","jqXHR","inspected","seekingTransport","inspect","prefilterOrFactory","dataTypeOrTransport","ajaxExtend","flatOptions","ajaxSettings","active","lastModified","etag","url","isLocal","protocol","processData","async","contentType","accepts","json","responseFields","converters","* text","text html","text json","text xml","ajaxSetup","settings","ajaxPrefilter","ajaxTransport","ajax","transport","cacheURL","responseHeadersString","responseHeaders","timeoutTimer","urlAnchor","fireGlobals","uncached","callbackContext","globalEventContext","completeDeferred","statusCode","requestHeaders","requestHeadersNames","strAbort","getResponseHeader","getAllResponseHeaders","setRequestHeader","overrideMimeType","mimeType","status","abort","statusText","finalText","crossDomain","host","hasContent","ifModified","headers","beforeSend","success","send","nativeStatusText","responses","isSuccess","response","modified","ct","finalDataType","firstDataType","ajaxHandleResponses","conv2","current","conv","dataFilter","throws","ajaxConvert","getJSON","getScript","text script","wrapAll","firstElementChild","wrapInner","htmlIsFunction","unwrap","visible","offsetHeight","xhr","XMLHttpRequest","xhrSuccessStatus","0","1223","xhrSupported","cors","errorCallback","open","username","xhrFields","onload","onerror","onabort","ontimeout","onreadystatechange","responseType","responseText","binary","scriptAttrs","charset","scriptCharset","evt","oldCallbacks","rjsonp","jsonp","jsonpCallback","originalSettings","callbackName","overwritten","responseContainer","jsonProp","createHTMLDocument","implementation","keepScripts","parsed","params","animated","offset","setOffset","curPosition","curLeft","curCSSTop","curTop","curOffset","curCSSLeft","curElem","using","rect","win","pageYOffset","pageXOffset","offsetParent","parentOffset","scrollTo","Height","Width","","defaultExtra","funcName","hover","fnOver","fnOut","unbind","delegate","undelegate","proxy","holdReady","hold","parseJSON","isNumeric","isNaN","define","amd","_jQuery","_$","$","noConflict"],"mappings":";CAaA,SAAYA,EAAQC,GAEnB,aAEuB,iBAAXC,QAAiD,iBAAnBA,OAAOC,QAShDD,OAAOC,QAAUH,EAAOI,SACvBH,EAASD,GAAQ,GACjB,SAAUK,GACT,IAAMA,EAAED,SACP,MAAM,IAAIE,MAAO,4CAElB,OAAOL,EAASI,IAGlBJ,EAASD,GAtBX,CA0BuB,oBAAXO,OAAyBA,OAASC,KAAM,SAAUD,EAAQE,GAMtE,aAEA,IAAIC,EAAM,GAENN,EAAWG,EAAOH,SAElBO,EAAWC,OAAOC,eAElBC,EAAQJ,EAAII,MAEZC,EAASL,EAAIK,OAEbC,EAAON,EAAIM,KAEXC,EAAUP,EAAIO,QAEdC,EAAa,GAEbC,EAAWD,EAAWC,SAEtBC,EAASF,EAAWG,eAEpBC,EAAaF,EAAOD,SAEpBI,EAAuBD,EAAWE,KAAMZ,QAExCa,EAAU,GAEVC,EAAa,SAAqBC,GAMhC,MAAsB,mBAARA,GAA8C,iBAAjBA,EAAIC,UAIjDC,EAAW,SAAmBF,GAChC,OAAc,MAAPA,GAAeA,IAAQA,EAAIpB,QAM/BuB,EAA4B,CAC/BC,MAAM,EACNC,KAAK,EACLC,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.min.js"} \ No newline at end of file diff --git a/docs/articles/NeuroGeometry_files/rglWebGL-binding-0.105.13/rglWebGL.js b/docs/articles/NeuroGeometry_files/rglWebGL-binding-0.108.3/rglWebGL.js similarity index 100% rename from docs/articles/NeuroGeometry_files/rglWebGL-binding-0.105.13/rglWebGL.js rename to docs/articles/NeuroGeometry_files/rglWebGL-binding-0.108.3/rglWebGL.js diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/controls.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/controls.src.js deleted file mode 100644 index 218ccdf8..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/controls.src.js +++ /dev/null @@ -1,591 +0,0 @@ - - /** - * Change the displayed subset - * @param { Object } el - Element of the control; not used. - * @param { Object } control - The subset control data. - */ - rglwidgetClass.prototype.subsetSetter = function(el, control) { - if (typeof control.subscenes === "undefined" || - control.subscenes === null) - control.subscenes = this.scene.rootSubscene; - var value = Math.round(control.value), - subscenes = [].concat(control.subscenes), - fullset = [].concat(control.fullset), - i, j, subsceneid, - adds = [], deletes = []; - if (isNaN(value)) - value = control.value = 0; - if (control.accumulate) - for (i=0; i <= value; i++) - adds = adds.concat(control.subsets[i]); - else - adds = adds.concat(control.subsets[value]); - deletes = fullset.filter(function(x) { return adds.indexOf(x) < 0; }); - for (i = 0; i < subscenes.length; i++) { - subsceneid = subscenes[i]; - if (typeof this.getObj(subsceneid) === "undefined") - this.alertOnce("typeof object is undefined"); - for (j = 0; j < adds.length; j++) - this.addToSubscene(adds[j], subsceneid); - for (j = 0; j < deletes.length; j++) - this.delFromSubscene(deletes[j], subsceneid); - } - }; - - /** - * Change the requested property - * @param { Object } el - Element of the control; not used. - * @param { Object } control - The property setter control data. - */ - rglwidgetClass.prototype.propertySetter = function(el, control) { - var value = control.value, - values = [].concat(control.values), - svals = [].concat(control.param), - direct = values[0] === null, - entries = [].concat(control.entries), - ncol = entries.length, - nrow = values.length/ncol, - properties = this.repeatToLen(control.properties, ncol), - objids = this.repeatToLen(control.objids, ncol), - property, objid = objids[0], - obj = this.getObj(objid), - propvals, i, j, v1, v2, p, entry, gl, needsBinding, - newprop, newid, - - getPropvals = function() { - if (property === "userMatrix") - return obj.par3d.userMatrix.getAsArray(); - else if (property === "scale" || property === "FOV" || property === "zoom") - return [].concat(obj.par3d[property]); - else - return [].concat(obj[property]); - }, - - putPropvals = function(newvals) { - if (newvals.length === 1) - newvals = newvals[0]; - if (property === "userMatrix") - obj.par3d.userMatrix.load(newvals); - else if (property === "scale" || property === "FOV" || property === "zoom") - obj.par3d[property] = newvals; - else - obj[property] = newvals; - }; - - if (direct && typeof value === "undefined") - return; - - if (control.interp) { - values = values.slice(0, ncol).concat(values). - concat(values.slice(ncol*(nrow-1), ncol*nrow)); - svals = [-Infinity].concat(svals).concat(Infinity); - for (i = 1; i < svals.length; i++) { - if (value <= svals[i]) { - if (svals[i] === Infinity) - p = 1; - else - p = (svals[i] - value)/(svals[i] - svals[i-1]); - break; - } - } - } else if (!direct) { - value = Math.round(value); - } - - for (j=0; j value - svals[j-1]) - j = j - 1; - } - break; - } - } - - obj = this.getObj(control.objid); - // First, make sure color attributes vary in original - if (typeof obj.vOffsets !== "undefined") { - varies = true; - for (k = 0; k < ncol; k++) { - attrib = attributes[k]; - if (typeof attrib !== "undefined") { - ofs = obj.vOffsets[ofss[attrib]]; - if (ofs < 0) { - switch(attrib) { - case "alpha": - case "red": - case "green": - case "blue": - obj.colors = [obj.colors[0], obj.colors[0]]; - break; - } - varies = false; - } - } - } - if (!varies) - this.initObj(control.objid); - } - propvals = obj.values; - aliases = obj.alias; - if (typeof aliases === "undefined") - aliases = []; - for (k=0; k= 0) { - if (ofs < 3) { - if (obj.normals[vertex][ofs] !== newval) { // Assume no aliases here... - obj.normals[vertex][ofs] = newval; - obj.initialized = false; - } - } else { - if (obj.offsets[vertex][0] !== newval) { - obj.offsets[vertex][0] = newval; - obj.initialized = false; - } - } - continue; - } - } - // Not a plane setting... - ofs = obj.vOffsets[ofss[attrib]]; - if (ofs < 0) - this.alertOnce("Attribute '"+attrib+"' not found in object "+control.objid); - else { - stride = obj.vOffsets.stride; - ofs = ofs + pos[attrib]; - entry = vertex*stride + ofs; - propvals[entry] = newval; - if (typeof alias !== "undefined") - for (a = 0; a < alias.length; a++) - propvals[alias[a]*stride + ofs] = newval; - } - } - if (typeof obj.buf !== "undefined") { - var gl = this.gl || this.initGL(); - gl.bindBuffer(gl.ARRAY_BUFFER, obj.buf); - gl.bufferData(gl.ARRAY_BUFFER, propvals, gl.STATIC_DRAW); - } - }; - - /** - * Change the requested vertex properties by age - * @param { Object } el - Element of the control; not used. - * @param { Object } control - The age setter control data. - */ - rglwidgetClass.prototype.ageSetter = function(el, control) { - var objids = [].concat(control.objids), - nobjs = objids.length, - time = control.value, - births = [].concat(control.births), - ages = [].concat(control.ages), - steps = births.length, - j = Array(steps), - p = Array(steps), - i, k, l, age, j0, propvals, stride, ofs, objid, obj, - attrib, dim, varies, alias, aliases, a, d, - attribs = ["colors", "alpha", "radii", "vertices", - "normals", "origins", "texcoords", - "x", "y", "z", - "red", "green", "blue"], - ofss = ["cofs", "cofs", "radofs", "vofs", - "nofs", "oofs", "tofs", - "vofs", "vofs", "vofs", - "cofs", "cofs", "cofs"], - dims = [3,1,1,3, - 3,2,2, - 1,1,1, - 1,1,1], - pos = [0,3,0,0, - 0,0,0, - 0,1,2, - 0,1,2]; - /* Infinity doesn't make it through JSON */ - ages[0] = -Infinity; - ages[ages.length-1] = Infinity; - for (i = 0; i < steps; i++) { - if (births[i] !== null) { // NA in R becomes null - age = time - births[i]; - for (j0 = 1; age > ages[j0]; j0++); - if (ages[j0] === Infinity) - p[i] = 1; - else if (ages[j0] > ages[j0-1]) - p[i] = (ages[j0] - age)/(ages[j0] - ages[j0-1]); - else - p[i] = 0; - j[i] = j0; - } - } - // First, make sure color attributes vary in original - for (l = 0; l < nobjs; l++) { - objid = objids[l]; - obj = this.getObj(objid); - varies = true; - if (typeof obj.vOffsets === "undefined") - continue; - for (k = 0; k < attribs.length; k++) { - attrib = control[attribs[k]]; - if (typeof attrib !== "undefined") { - ofs = obj.vOffsets[ofss[k]]; - if (ofs < 0) { - switch(attribs[k]) { - case "colors": - case "alpha": - case "red": - case "green": - case "blue": - obj.colors = [obj.colors[0], obj.colors[0]]; - break; - } - varies = false; - } - } - } - if (!varies) - this.initObj(objid); - } - for (l = 0; l < nobjs; l++) { - objid = objids[l]; - obj = this.getObj(objid); - if (typeof obj.vOffsets === "undefined") - continue; - aliases = obj.alias; - if (typeof aliases === "undefined") - aliases = []; - propvals = obj.values; - stride = obj.vOffsets.stride; - for (k = 0; k < attribs.length; k++) { - attrib = control[attribs[k]]; - if (typeof attrib !== "undefined") { - ofs = obj.vOffsets[ofss[k]]; - if (ofs >= 0) { - dim = dims[k]; - ofs = ofs + pos[k]; - for (i = 0; i < steps; i++) { - alias = aliases[i]; - if (births[i] !== null) { - for (d=0; d < dim; d++) { - propvals[i*stride + ofs + d] = p[i]*attrib[dim*(j[i]-1) + d] + (1-p[i])*attrib[dim*j[i] + d]; - if (typeof alias !== "undefined") - for (a=0; a < alias.length; a++) - propvals[alias[a]*stride + ofs + d] = propvals[i*stride + ofs + d]; - } - } - } - } else - this.alertOnce("\'"+attribs[k]+"\' property not found in object "+objid); - } - } - obj.values = propvals; - if (typeof obj.buf !== "undefined") { - var gl = this.gl || this.initGL(); - gl.bindBuffer(gl.ARRAY_BUFFER, obj.buf); - gl.bufferData(gl.ARRAY_BUFFER, obj.values, gl.STATIC_DRAW); - } - } - }; - - /** - * Bridge to old style control - * @param { Object } el - Element of the control; not used. - * @param { Object } control - The bridge control data. - */ - rglwidgetClass.prototype.oldBridge = function(el, control) { - var attrname, global = window[control.prefix + "rgl"]; - if (global) - for (attrname in global) - this[attrname] = global[attrname]; - window[control.prefix + "rgl"] = this; - }; - - /** - * Set up a player control - * @param { Object } el - The player control element - * @param { Object } control - The player data. - */ - rglwidgetClass.prototype.Player = function(el, control) { - var - self = this, - components = [].concat(control.components), - buttonLabels = [].concat(control.buttonLabels), - - Tick = function() { /* "this" will be a timer */ - var i, - nominal = this.value, - slider = this.Slider, - labels = this.outputLabels, - output = this.Output, - step; - if (typeof slider !== "undefined" && nominal !== slider.value) - slider.value = nominal; - if (typeof output !== "undefined") { - step = Math.round((nominal - output.sliderMin)/output.sliderStep); - if (labels !== null) { - output.innerHTML = labels[step]; - } else { - step = step*output.sliderStep + output.sliderMin; - output.innerHTML = step.toPrecision(output.outputPrecision); - } - } - for (i=0; i < this.actions.length; i++) { - this.actions[i].value = nominal; - } - self.applyControls(el, this.actions, false); - self.drawScene(); - }, - - OnSliderInput = function() { /* "this" will be the slider */ - this.rgltimer.value = Number(this.value); - this.rgltimer.Tick(); - }, - - addSlider = function(min, max, step, value) { - var slider = document.createElement("input"); - slider.type = "range"; - slider.min = min; - slider.max = max; - slider.step = step; - slider.value = value; - slider.oninput = OnSliderInput; - slider.sliderActions = control.actions; - slider.sliderScene = this; - slider.className = "rgl-slider"; - slider.id = el.id + "-slider"; - el.rgltimer.Slider = slider; - slider.rgltimer = el.rgltimer; - el.appendChild(slider); - }, - - addLabel = function(labels, min, step, precision) { - var output = document.createElement("output"); - output.sliderMin = min; - output.sliderStep = step; - output.outputPrecision = precision; - output.className = "rgl-label"; - output.id = el.id + "-label"; - el.rgltimer.Output = output; - el.rgltimer.outputLabels = labels; - el.appendChild(output); - }, - - addButton = function(which, label, active) { - var button = document.createElement("input"), - onclicks = {Reverse: function() { this.rgltimer.reverse();}, - Play: function() { this.rgltimer.play(); - this.value = this.rgltimer.enabled ? this.inactiveValue : this.activeValue; }, - Slower: function() { this.rgltimer.slower(); }, - Faster: function() { this.rgltimer.faster(); }, - Reset: function() { this.rgltimer.reset(); }, - Step: function() { this.rgltimer.step(); } - }; - button.rgltimer = el.rgltimer; - button.type = "button"; - button.value = label; - button.activeValue = label; - button.inactiveValue = active; - if (which === "Play") - button.rgltimer.PlayButton = button; - button.onclick = onclicks[which]; - button.className = "rgl-button"; - button.id = el.id + "-" + which; - el.appendChild(button); - }; - - if (typeof control.reinit !== "undefined" && control.reinit !== null) { - control.actions.reinit = control.reinit; - } - el.rgltimer = new rgltimerClass(Tick, control.start, control.interval, control.stop, - control.step, control.value, control.rate, control.loop, control.actions); - for (var i=0; i < components.length; i++) { - switch(components[i]) { - case "Slider": addSlider(control.start, control.stop, - control.step, control.value); - break; - case "Label": addLabel(control.labels, control.start, - control.step, control.precision); - break; - default: - addButton(components[i], buttonLabels[i], control.pause); - } - } - el.rgltimer.Tick(); - }; - - /** - * Apply all registered controls - * @param { Object } el - DOM element of the control - * @param { Object } x - List of actions to apply - * @param { boolean } [draw=true] - Whether to redraw after applying - */ - rglwidgetClass.prototype.applyControls = function(el, x, draw) { - var self = this, reinit = x.reinit, i, control, type; - for (i = 0; i < x.length; i++) { - control = x[i]; - type = control.type; - self[type](el, control); - } - if (typeof reinit !== "undefined" && reinit !== null) { - reinit = [].concat(reinit); - for (i = 0; i < reinit.length; i++) - self.getObj(reinit[i]).initialized = false; - } - if (typeof draw === "undefined" || draw) - self.drawScene(); - }; - - /** - * Handler for scene change - * @param { Object } message - What sort of scene change to do? - */ - rglwidgetClass.prototype.sceneChangeHandler = function(message) { - var self = document.getElementById(message.elementId).rglinstance, - objs = message.objects, mat = message.material, - root = message.rootSubscene, - initSubs = message.initSubscenes, - redraw = message.redrawScene, - skipRedraw = message.skipRedraw, - deletes, subs, allsubs = [], i,j; - if (typeof message.delete !== "undefined") { - deletes = [].concat(message.delete); - if (typeof message.delfromSubscenes !== "undefined") - subs = [].concat(message.delfromSubscenes); - else - subs = []; - for (i = 0; i < deletes.length; i++) { - for (j = 0; j < subs.length; j++) { - self.delFromSubscene(deletes[i], subs[j]); - } - delete self.scene.objects[deletes[i]]; - } - } - if (typeof objs !== "undefined") { - Object.keys(objs).forEach(function(key){ - key = parseInt(key, 10); - self.scene.objects[key] = objs[key]; - self.initObj(key); - var obj = self.getObj(key), - subs = [].concat(obj.inSubscenes), k; - allsubs = allsubs.concat(subs); - for (k = 0; k < subs.length; k++) - self.addToSubscene(key, subs[k]); - }); - } - if (typeof mat !== "undefined") { - self.scene.material = mat; - } - if (typeof root !== "undefined") { - self.scene.rootSubscene = root; - } - if (typeof initSubs !== "undefined") - allsubs = allsubs.concat(initSubs); - allsubs = self.unique(allsubs); - for (i = 0; i < allsubs.length; i++) { - self.initSubscene(allsubs[i]); - } - if (typeof skipRedraw !== "undefined") { - root = self.getObj(self.scene.rootSubscene); - root.par3d.skipRedraw = skipRedraw; - } - if (redraw) - self.drawScene(); - }; diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/draw.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/draw.src.js deleted file mode 100644 index d05a4267..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/draw.src.js +++ /dev/null @@ -1,963 +0,0 @@ - - /** - * Start drawing - * @returns { boolean } Previous state - */ - rglwidgetClass.prototype.startDrawing = function() { - var value = this.drawing; - this.drawing = true; - return value; - }; - - /** - * Stop drawing and check for context loss - * @param { boolean } saved - Previous state - */ - rglwidgetClass.prototype.stopDrawing = function(saved) { - this.drawing = saved; - if (!saved && this.gl && this.gl.isContextLost()) - this.restartCanvas(); - }; - - /** - * Update the triangles used to display a plane - * @param { number } id - id of the plane - * @param { Object } bbox - bounding box in which to display the plane - */ - rglwidgetClass.prototype.planeUpdateTriangles = function(obj, bbox) { - var perms = [[0,0,1], [1,2,2], [2,1,0]], - x, xrow, elem, A, d, nhits, i, j, k, u, v, w, intersect, which, v0, v2, vx, reverse, - face1 = [], face2 = [], normals = [], - nPlanes = obj.normals.length; - obj.bbox = bbox; - obj.vertices = []; - obj.initialized = false; - for (elem = 0; elem < nPlanes; elem++) { -// Vertex Av = normal.getRecycled(elem); - x = []; - A = obj.normals[elem]; - d = obj.offsets[elem][0]; - nhits = 0; - for (i=0; i<3; i++) - for (j=0; j<2; j++) - for (k=0; k<2; k++) { - u = perms[0][i]; - v = perms[1][i]; - w = perms[2][i]; - if (A[w] !== 0.0) { - intersect = -(d + A[u]*bbox[j+2*u] + A[v]*bbox[k+2*v])/A[w]; - if (bbox[2*w] < intersect && intersect < bbox[1+2*w]) { - xrow = []; - xrow[u] = bbox[j+2*u]; - xrow[v] = bbox[k+2*v]; - xrow[w] = intersect; - x.push(xrow); - face1[nhits] = j + 2*u; - face2[nhits] = k + 2*v; - nhits++; - } - } - } - - if (nhits > 3) { - /* Re-order the intersections so the triangles work */ - for (i=0; i i+1) { - this.swap(x, i+1, which); - this.swap(face1, i+1, which); - this.swap(face2, i+1, which); - } - } - } - if (nhits >= 3) { - /* Put in order so that the normal points out the FRONT of the faces */ - v0 = [x[0][0] - x[1][0] , x[0][1] - x[1][1], x[0][2] - x[1][2]]; - v2 = [x[2][0] - x[1][0] , x[2][1] - x[1][1], x[2][2] - x[1][2]]; - /* cross-product */ - vx = this.xprod(v0, v2); - reverse = this.dotprod(vx, A) > 0; - - for (i=0; i= 0) { - gl.enableVertexAttribArray( obj.normLoc ); - gl.vertexAttribPointer(obj.normLoc, 3, gl.FLOAT, false, 4*obj.vOffsets.stride, 4*obj.vOffsets.nofs); - return true; - } else - return false; - }; - - rglwidgetClass.prototype.doTexture = function(obj) { - var gl = this.gl, - is_spheres = obj.type === "spheres"; - gl.enableVertexAttribArray( obj.texLoc ); - if (is_spheres) - gl.vertexAttribPointer(obj.texLoc, 2, gl.FLOAT, false, 4*this.sphere.vOffsets.stride, 4*this.sphere.vOffsets.tofs); - else - gl.vertexAttribPointer(obj.texLoc, 2, gl.FLOAT, false, 4*obj.vOffsets.stride, 4*obj.vOffsets.tofs); - gl.activeTexture(gl.TEXTURE0); - gl.bindTexture(gl.TEXTURE_2D, obj.texture); - gl.uniform1i( obj.sampler, 0); - return true; - }; - - rglwidgetClass.prototype.doUserAttributes = function(obj) { - if (typeof obj.userAttributes !== "undefined") { - var gl = this.gl; - for (var attr in obj.userAttribSizes) { // Not all attributes may have been used - gl.enableVertexAttribArray( obj.userAttribLocations[attr] ); - gl.vertexAttribPointer( obj.userAttribLocations[attr], obj.userAttribSizes[attr], - gl.FLOAT, false, 4*obj.vOffsets.stride, 4*obj.userAttribOffsets[attr]); - } - } - }; - - rglwidgetClass.prototype.doUserUniforms = function(obj) { - if (typeof obj.userUniforms !== "undefined") { - var gl = this.gl; - for (var attr in obj.userUniformLocations) { - var loc = obj.userUniformLocations[attr]; - if (loc !== null) { - var uniform = obj.userUniforms[attr]; - if (typeof uniform.length === "undefined") - gl.uniform1f(loc, uniform); - else if (typeof uniform[0].length === "undefined") { - uniform = new Float32Array(uniform); - switch(uniform.length) { - case 2: gl.uniform2fv(loc, uniform); break; - case 3: gl.uniform3fv(loc, uniform); break; - case 4: gl.uniform4fv(loc, uniform); break; - default: console.warn("bad uniform length"); - } - } else if (uniform.length === 4 && uniform[0].length === 4) - gl.uniformMatrix4fv(loc, false, new Float32Array(uniform.getAsArray())); - else - console.warn("unsupported uniform matrix"); - } - } - } - }; - - rglwidgetClass.prototype.doLoadIndices = function(obj, pass, indices) { - var gl = this.gl, - f = obj.f[pass], - type = obj.type, - fat_lines = this.isSet(obj.flags, this.f_fat_lines), - fnew, step; - switch(type){ - case "points": - step = 1; - break; - case "abclines": - case "lines": - if (fat_lines) - step = 6; - else - step = 2; - break; - case "linestrip": - if (fat_lines) - step = 6; - else - step = 1; - break; - case "sphere": - case "planes": - case "triangles": - step = 3; - break; - case "text": - case "sprites": - case "quads": - case "surface": - step = 6; - break; - default: - console.error("loadIndices for "+type); - return 0; - } - if (obj.index_uint) - fnew = new Uint32Array(step * indices.length); - else - fnew = new Uint16Array(step * indices.length); - for (var i = 0; i < indices.length; i++) { - for (var j = 0; j < step; j++) { - fnew[step*i + j] = f[step*indices[i] + j]; - } - } - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, fnew, gl.DYNAMIC_DRAW); - return fnew.length; - }; - - rglwidgetClass.prototype.doMasking = function(mask) { - var gl = this.gl; - gl.depthMask(mask); - }; - - rglwidgetClass.prototype.doBlending = function(blend) { - var gl = this.gl; - if (blend) { - gl.blendFuncSeparate(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, - gl.ONE, gl.ONE); - gl.enable(gl.BLEND); - } else { - gl.disable(gl.BLEND); - } - }; - - /** - * Set up for fog in the subscene - * @param { number } id - id of background object - */ - rglwidgetClass.prototype.doFog = function(obj, subscene) { - var gl = this.gl, fogmode, color, - observer = subscene.par3d.observer[2], - sintheta = Math.sin(subscene.par3d.FOV*Math.PI/180/2), - parms = [this.frustum.near - 2*observer, - this.frustum.far - 2*observer, - this.fogScale, - (1-sintheta)/(1+sintheta)]; - if (typeof this.fogType === "undefined") - this.fogType = "none"; - if (typeof this.fogScale === "undefined") - parms[2] = 1; - if (sintheta === 0) - parms[3] = 1/3; - switch(this.fogType){ - case "none": fogmode = 0; break; - case "linear": - fogmode = 1; break; - case "exp": - fogmode = 2; break; - case "exp2": - fogmode = 3; - break; - default: console.error("Unknown fogtype "+this.fogType); - } - gl.uniform1i(obj.uFogMode, fogmode); - color = this.fogColor; - gl.uniform3f(obj.uFogColor, color[0], color[1], color[2]); - gl.uniform4f(obj.uFogParms, parms[0], parms[1], parms[2], parms[3]); - }; - - /* The draw methods are called twice. When - this.opaquePass is true, they should draw opaque parts - of the scene, and return the list of transparent - pieces. Here context is the context array on input, - modified when the matrices are changed. - When this.opaquePass is false, the context argument - contains a "piece", i.e. an ordered list of parts - of the object to draw. */ - - rglwidgetClass.prototype.drawSimple = function(obj, subscene, context) { - var - flags = obj.flags, - type = obj.type, - is_lit = this.isSet(flags, this.f_is_lit), - has_texture = this.isSet(flags, this.f_has_texture), - is_transparent = this.isSet(flags, this.f_is_transparent), - fixed_size = this.isSet(flags, this.f_fixed_size), - fixed_quads = this.isSet(flags, this.f_fixed_quads), - is_lines = this.isSet(flags, this.f_is_lines), - fat_lines = this.isSet(flags, this.f_fat_lines), - is_twosided = this.isSet(flags, this.f_is_twosided), - has_fog = this.isSet(flags, this.f_has_fog), - gl = this.gl || this.initGL(), - count, - pass, mode, pmode, - enabled = {}; - - if (!obj.initialized) - this.initObj(obj.id); - - count = obj.vertexCount; - if (!count) - return []; - - is_transparent = is_transparent || obj.someHidden; - - if (is_transparent && this.opaquePass) - return this.getPieces(context, obj.id, 0, obj); - - this.doDepthTest(obj); - - this.doMasking(this.getObjMaterial(obj, "depth_mask")); - - gl.useProgram(obj.prog); - - this.doPolygonOffset(obj); - - gl.bindBuffer(gl.ARRAY_BUFFER, obj.buf); - - gl.uniformMatrix4fv( obj.prMatLoc, false, new Float32Array(this.prMatrix.getAsArray()) ); - gl.uniformMatrix4fv( obj.mvMatLoc, false, new Float32Array(this.mvMatrix.getAsArray()) ); - - this.doClipping(obj, subscene); - - if (is_lit) - this.doLighting(obj, subscene); - - if (has_fog) - this.doFog(obj, subscene); - - this.doUserAttributes(obj); - - this.doUserUniforms(obj); - - gl.enableVertexAttribArray( this.posLoc ); - enabled.posLoc = true; - - if (has_texture || obj.type === "text") - enabled.texLoc = this.doTexture(obj); - - enabled.colLoc = this.doColors(obj); - if (is_lit) - enabled.normLoc = this.doNormals(obj); - - if (fixed_size) { - gl.uniform2f( obj.textScaleLoc, 0.75/this.vp.width, 0.75/this.vp.height); - } - - if (fixed_quads) { - gl.enableVertexAttribArray( obj.ofsLoc ); - enabled.ofsLoc = true; - gl.vertexAttribPointer(obj.ofsLoc, 2, gl.FLOAT, false, 4*obj.vOffsets.stride, 4*obj.vOffsets.oofs); - } - - for (pass = 0; pass < obj.passes; pass++) { - pmode = obj.pmode[pass]; - if (pmode === "culled") - continue; - - mode = fat_lines && (is_lines || pmode === "lines") ? "TRIANGLES" : this.mode4type[type]; - - if (is_twosided) - gl.uniform1i(obj.frontLoc, pass !== 0); - - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, obj.ibuf[pass]); - if (!this.opaquePass) { - if (type === "sphere" && obj.fastTransparency) - count = this.doLoadIndices(obj, pass, this.sphere.fastpieces[0].indices); - else - count = this.doLoadIndices(obj, pass, context.indices); - } else { - count = obj.f[pass].length; - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, obj.f[pass], gl.STATIC_DRAW); - } - if (!is_lines && pmode === "lines" && !fat_lines) { - mode = "LINES"; - } else if (pmode === "points") { - mode = "POINTS"; - } - - if ((is_lines || pmode === "lines") && fat_lines) { - gl.enableVertexAttribArray(obj.pointLoc); - enabled.pointLoc = true; - gl.vertexAttribPointer(obj.pointLoc, 2, gl.FLOAT, false, 4*obj.vOffsets.stride, 4*obj.vOffsets.pointofs); - gl.enableVertexAttribArray(obj.nextLoc ); - enabled.nextLoc = true; - gl.vertexAttribPointer(obj.nextLoc, 3, gl.FLOAT, false, 4*obj.vOffsets.stride, 4*obj.vOffsets.nextofs); - gl.uniform1f(obj.aspectLoc, this.vp.width/this.vp.height); - gl.uniform1f(obj.lwdLoc, this.getMaterial(obj.id, "lwd")/this.vp.height); - } - - gl.vertexAttribPointer(this.posLoc, 3, gl.FLOAT, false, 4*obj.vOffsets.stride, 4*obj.vOffsets.vofs); - - gl.drawElements(gl[mode], count, obj.index_uint ? gl.UNSIGNED_INT : gl.UNSIGNED_SHORT, 0); - } - this.disableArrays(obj, enabled); - return []; - }; - - rglwidgetClass.prototype.drawPlanes = function(obj, subscene, context) { - if (obj.bbox !== subscene.par3d.bbox || !obj.initialized) { - this.planeUpdateTriangles(obj, subscene.par3d.bbox); - } - return this.drawSimple(obj, subscene, context); - }; - - /** - * Draw spheres in a subscene - * @param { object } obj - object to draw - * @param { object } subscene - * @param { object } context - */ - - /** - * Drawing spheres happens in six ways: - * 1 opaquepass, not transparent: transform and draw this.sphere count times - * 2 opaquepass, transparent, not fast: transform & collect sphere pieces count times - * 3 opaquepass, transparent, fast: order the centres into separate pieces, order this.sphere once - * 4 not opaquepass, not transparent: do nothing - * 5 not opaquepass, transparent, not fast: transform for one sphere, draw one merged piece - * 6 not opaquepass, transparent, fast: transform for one sphere, draw this.sphere in fixed order. - **/ - - rglwidgetClass.prototype.drawSpheres = function(obj, subscene, context) { - var flags = obj.flags, - is_transparent = this.isSet(flags, this.f_is_transparent), - sphereMV, baseofs, ofs, sscale, i, - count, nc, scount, scale, indices, sphereNorm, - enabled = {}, drawing, - saveNorm = new CanvasMatrix4(this.normMatrix), - saveMV = new CanvasMatrix4(this.mvMatrix), - savePRMV = null, - result = [], idx; - - if (!obj.initialized) - this.initObj(obj.id); - - count = obj.vertexCount; - if (!count) - return result; - - is_transparent = is_transparent || obj.someHidden; - - if (!this.opaquePass && !is_transparent) - return result; - - if (this.prmvMatrix !== null) - savePRMV = new CanvasMatrix4(this.prmvMatrix); - - scale = subscene.par3d.scale; - sphereNorm = new CanvasMatrix4(); - sphereNorm.scale(scale[0], scale[1], scale[2]); - sphereNorm.multRight(saveNorm); - this.normMatrix = sphereNorm; - - if (this.opaquePass) { - context = context.slice(); - context.push(obj.id); - } - - drawing = this.opaquePass !== is_transparent; - if (drawing) { - nc = obj.colorCount; - if (nc === 1) { - this.sphere.onecolor = obj.onecolor; - } - } - - this.initSphereFromObj(obj); - - if (!this.opaquePass && obj.fastTransparency && typeof this.sphere.fastpieces === "undefined") { - this.sphere.fastpieces = this.getPieces(context.context, obj.id, 0, this.sphere); - this.sphere.fastpieces = this.sortPieces(this.sphere.fastpieces); - this.sphere.fastpieces = this.mergePieces(this.sphere.fastpieces); - } - - if (this.opaquePass) - scount = count; - else { - indices = context.indices; - if (obj.fastTransparency) - scount = indices.length; /* Each item gives the center of a whole sphere */ - else - scount = 1; /* Each item is a fragment of the sphere, at location subid */ - } - for (i = 0; i < scount; i++) { - sphereMV = new CanvasMatrix4(); - if (this.opaquePass) - idx = i; - else if (obj.fastTransparency) - idx = indices[i]; - else - idx = context.subid; - if (typeof idx === "undefined") - console.error("idx is undefined"); - baseofs = idx*obj.vOffsets.stride; - ofs = baseofs + obj.vOffsets.radofs; - sscale = obj.values[ofs]; - - sphereMV.scale(sscale/scale[0], sscale/scale[1], sscale/scale[2]); - sphereMV.translate(obj.values[baseofs], - obj.values[baseofs+1], - obj.values[baseofs+2]); - sphereMV.multRight(saveMV); - this.mvMatrix = sphereMV; - this.setprmvMatrix(); - if (drawing) { - if (nc > 1) { - this.sphere.onecolor = this.flatten(obj.sphereColors[idx % obj.sphereColors.length]); - } - this.drawSimple(this.sphere, subscene, context); - } else - result = result.concat(this.getSpherePieces(context, i, obj)); - } - if (drawing) - this.disableArrays(obj, enabled); - this.normMatrix = saveNorm; - this.mvMatrix = saveMV; - this.prmvMatrix = savePRMV; - - return result; - }; - - /** - * Prepare clipplanes for drawing - * @param { object } obj - clip planes object - * @param { object } subscene - */ - rglwidgetClass.prototype.drawClipplanes = function(obj) { - var count = obj.offsets.length, - IMVClip = []; - for (var i=0; i < count; i++) { - IMVClip[i] = this.multMV(this.invMatrix, obj.vClipplane.slice(4*i, 4*(i+1))); - } - obj.IMVClip = IMVClip; - return []; - }; - - rglwidgetClass.prototype.drawLinestrip = function(obj, subscene, context) { - var origIndices, i, j; - if (this.opaquePass) - return this.drawSimple(obj, subscene, context); - origIndices = context.indices.slice(); - for (i=0; i < origIndices.length; i++) { - j = origIndices[i]; - if (j < obj.centers.length - 1) { - context.indices = [j, j+1]; - this.drawSimple(obj, subscene, context); - } - } - context.indices = origIndices; - return []; - }; - - /** - * Draw a sprites object in a subscene - * @param { object } obj - object to draw - * @param { object } subscene - * @param { object } context - */ - rglwidgetClass.prototype.drawSprites = function(obj, subscene, context) { - var flags = obj.flags, - is_transparent = this.isSet(flags, this.f_is_transparent), - sprites3d = this.isSet(flags, this.f_sprites_3d), - i,j, - origMV = new CanvasMatrix4( this.mvMatrix ), - origPRMV = null, - pos, radius, userMatrix, - result = []; - - if (!sprites3d) { - return this.drawSimple(obj, subscene, context); - } - - if (!obj.initialized) - this.initObj(obj.id); - - if (!obj.vertexCount) - return result; - - is_transparent = is_transparent || obj.someHidden; - - var norigs = obj.vertices.length, - savenorm = new CanvasMatrix4(this.normMatrix), - iOrig; - - this.normMatrix = subscene.spriteNormmat; - userMatrix = obj.userMatrix; - - if (this.opaquePass) { - context = context.slice(); - context.push(obj.id); - } else - norigs = 1; - - if (this.prmvMatrix !== null) - origPRMV = new CanvasMatrix4( this.prmvMatrix ); - - for (iOrig=0; iOrig < norigs; iOrig++) { - if (this.opaquePass) - j = iOrig; - else - j = context.subid; - - pos = this.multVM([].concat(obj.vertices[j]).concat(1.0), - origMV); - radius = obj.radii.length > 1 ? obj.radii[j][0] : obj.radii[0][0]; - this.mvMatrix = new CanvasMatrix4(userMatrix); - this.mvMatrix.scale(radius); - this.mvMatrix.translate(pos[0]/pos[3], pos[1]/pos[3], pos[2]/pos[3]); - this.setprmvMatrix(); - for (i=0; i < obj.objects.length; i++) - if (this.opaquePass) - result = result.concat(this.drawObjId(obj.objects[i], subscene.id, context.concat(j))); - else - this.drawObjId(obj.objects[i], subscene.id, context); - } - this.normMatrix = savenorm; - this.mvMatrix = origMV; - if (origPRMV !== null) - this.prmvMatrix = origPRMV; - return result; - }; - - rglwidgetClass.prototype.drawObjId = function(id, subsceneid, context) { - if (typeof id !== "number") - this.alertOnce("drawObjId id is "+typeof id); - - return this.drawObj(this.getObj(id), this.getObj(subsceneid), context); - }; - - /** - * Draw an object in a subscene - * @param { number } obj - object to draw - * @param { number } subsceneid - id of subscene - */ - rglwidgetClass.prototype.drawObj = function(obj, subscene, context) { - switch(obj.type) { - case "abclines": - case "surface": - case "triangles": - case "quads": - case "lines": - case "points": - case "text": - return this.drawSimple(obj, subscene, context); - case "linestrip": - return this.drawLinestrip(obj, subscene, context); - case "planes": - return this.drawPlanes(obj, subscene, context); - case "spheres": - return this.drawSpheres(obj, subscene, context); - case "clipplanes": - return this.drawClipplanes(obj); - case "sprites": - return this.drawSprites(obj, subscene, context); - case "light": - case "bboxdeco": - return []; - } - - console.error("drawObj for type = "+obj.type); - }; - - /** - * Draw the background for a subscene - * @param { number } id - id of background object - * @param { number } subsceneid - id of subscene - */ - rglwidgetClass.prototype.drawBackground = function(id, subsceneid) { - var gl = this.gl || this.initGL(), - obj = this.getObj(id), - bg, i; - - if (!obj.initialized) - this.initObj(id); - - if (obj.colors.length) { - bg = obj.colors[0]; - gl.clearColor(bg[0], bg[1], bg[2], bg[3]); - gl.depthMask(true); - /* jshint bitwise: false */ - gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); - /* jshint bitwise: true */ - this.fogColor = bg; - } else - this.fogColor = [0,0,0,0]; - - this.fogType = obj.fogtype; - this.fogScale = obj.fogscale; - if (typeof obj.quad !== "undefined") { - this.prMatrix.makeIdentity(); - this.mvMatrix.makeIdentity(); - gl.disable(gl.BLEND); - gl.disable(gl.DEPTH_TEST); - gl.depthMask(false); - for (i=0; i < obj.quad.length; i++) - this.drawObjId(obj.quad[i], subsceneid); - } - }; - - /** - * Draw a subscene - * @param { number } subsceneid - id of subscene - * @param { boolean } opaquePass - is this the opaque drawing pass? - */ - rglwidgetClass.prototype.drawSubscene = function(subsceneid, context) { - var sub = this.getObj(subsceneid), - objects = this.scene.objects, - clipids = sub.clipplanes, - subids = sub.objects, - subscene_has_faces = false, - subscene_needs_sorting = false, - flags, i, obj, result = []; - - if (sub.par3d.skipRedraw) - return result; - - if (this.opaquePass) { - for (i=0; i < subids.length; i++) { - obj = objects[subids[i]]; - flags = obj.flags; - if (typeof flags !== "undefined") { - subscene_has_faces = subscene_has_faces || - (this.isSet(flags, this.f_is_lit) && - !this.isSet(flags, this.f_fixed_quads)); - obj.is_transparent = obj.someHidden || - this.isSet(flags, this.f_is_transparent); - subscene_needs_sorting = subscene_needs_sorting || - obj.is_transparent || - this.isSet(flags, this.f_depth_sort); - } - } - } - - this.setViewport(subsceneid); - - this.setprMatrix(subsceneid); - this.setmvMatrix(subsceneid); - - if (typeof sub.backgroundId !== "undefined" && this.opaquePass) - this.drawBackground(sub.backgroundId, subsceneid); - - if (subids.length) { - if (subscene_has_faces) { - this.setnormMatrix(subsceneid); - if (this.isSet(sub.flags, this.f_sprites_3d) && - typeof sub.spriteNormmat === "undefined") { - sub.spriteNormmat = new CanvasMatrix4(this.normMatrix); - } - } - - if (subscene_needs_sorting) - this.setprmvMatrix(); - - if (clipids.length > 0) { - this.invMatrix = new CanvasMatrix4(this.mvMatrix); - this.invMatrix.invert(); - for (i = 0; i < clipids.length; i++) - this.drawObjId(clipids[i], subsceneid); - } - - subids = sub.opaque.concat(sub.transparent); - if (this.opaquePass) { - context = context.slice(); - context.push(subsceneid); - - this.doBlending(false); - this.subsceneid = subsceneid; - if (typeof this.sphere !== "undefined") // reset this.sphere.fastpieces; it will be recreated if needed - this.sphere.fastpieces = undefined; - for (i = 0; i < subids.length; i++) - result = result.concat(this.drawObjId(subids[i], subsceneid, context)); - subids = sub.subscenes; - for (i = 0; i < subids.length; i++) - result = result.concat(this.drawSubscene(subids[i], context)); - } - } - return result; - }; - - /** - * Set the context for drawing transparently - */ - rglwidgetClass.prototype.setContext = function(context) { - var result = [], objid, obj, type; - context = context.slice(); - context.reverse(); - while (context.length > 0) { - objid = context.pop(); - obj = this.getObj(objid); - type = obj.type; - switch (type) { - case "subscene": - this.drawSubscene(objid, false); - break; - case "sprites": - result = result.concat(context.pop()); - break; - case "spheres": - // this.initSphereFromObj(obj); // FIXME: not needed? - break; - default: - console.error("bad type '", type, "' in setContext"); - } - } - return result; - }; - - /** - * Draw the transparent pieces of a scene - */ - rglwidgetClass.prototype.drawPieces = function(pieces) { - var i, prevcontext = [], context; - this.doBlending(true); - for (i = 0; i < pieces.length; i++) { - context = pieces[i].context.slice(); - if (context !== prevcontext) { - prevcontext = context.slice(); - context = this.setContext(context); - } - this.drawObjId(pieces[i].objid, this.subsceneid, - pieces[i]); - } - }; - - /** - * Draw the whole scene - */ - rglwidgetClass.prototype.drawScene = function() { - var wasDrawing = this.startDrawing(), - pieces; - if (!wasDrawing) { - if (this.select.state !== "inactive") - this.selectionChanged(); - - this.doStartScene(); - this.opaquePass = true; - pieces = this.drawSubscene(this.scene.rootSubscene, []); - this.opaquePass = false; - pieces = this.sortPieces(pieces); - pieces = this.mergePieces(pieces); - this.drawPieces(pieces); - } - this.stopDrawing(wasDrawing); - }; diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/init.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/init.src.js deleted file mode 100644 index 9ea7a8bf..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/init.src.js +++ /dev/null @@ -1,1026 +0,0 @@ - - /** - * Initial test for WebGL - */ - rglwidgetClass.prototype.initGL0 = function() { - if (!window.WebGLRenderingContext){ - alert("Your browser does not support WebGL. See http://get.webgl.org"); - return; - } - }; - - /** - * Initialize WebGL - * @returns { Object } the WebGL context - */ - rglwidgetClass.prototype.initGL = function() { - var self = this; - if (this.gl) { - if (!this.drawing && this.gl.isContextLost()) - this.restartCanvas(); - else - return this.gl; - } - // if (!this.isInBrowserViewport()) return; Return what??? At this point we know this.gl is null. - this.canvas.addEventListener("webglcontextrestored", - this.onContextRestored, false); - this.canvas.addEventListener("webglcontextlost", - this.onContextLost, false); - this.gl = this.canvas.getContext("webgl", this.webGLoptions) || - this.canvas.getContext("experimental-webgl", this.webGLoptions); - this.index_uint = this.gl.getExtension("OES_element_index_uint"); - var save = this.startDrawing(); - Object.keys(this.scene.objects).forEach(function(key){ - self.initObj(parseInt(key, 10)); - }); - this.stopDrawing(save); - return this.gl; - }; - - /** - * Resize the display to match element - * @param { Object } el - DOM element to match - */ - rglwidgetClass.prototype.resize = function(el) { - this.canvas.width = el.width; - this.canvas.height = el.height; - }; - - /** - * Initialize the sphere object - */ - rglwidgetClass.prototype.initSphere = function() { - var verts = this.scene.sphereVerts, - reuse = verts.reuse, result; - if (typeof reuse !== "undefined") { - var prev = document.getElementById(reuse).rglinstance.sphere; - result = {values: prev.values, - vOffsets: prev.vOffsets, - it: prev.it, - centers: prev.centers, - vertexCount: prev.vertexCount, - f: prev.f, - indices: prev.indices}; - } else { - var n = verts.it[0].length, i, j, k, - centers = new Array(n); - for (i = 0; i < n; i++) { // faces - centers[i] = [0,0,0]; - for (j = 0; j < 3; j++) // x, y, z - for (k = 0; k < 3; k++) // vertices - centers[i][j] += verts.vb[j][verts.it[k][i]]/3; - } - result = {values: new Float32Array(this.flatten(this.cbind(this.transpose(verts.vb), - this.transpose(verts.texcoords)))), - it: new Uint16Array(this.flatten(this.transpose(verts.it))), - vOffsets: {vofs:0, cofs:-1, nofs:0, radofs:-1, oofs:-1, - tofs:3, nextofs:-1, pointofs:-1, stride:5}, - centers: centers - }; - // Add default indices - result.vertexCount = verts.vb[0].length; - result.f = []; - result.indices = {}; - } - result.colorCount = 1; - result.type = "sphere"; - this.sphere = result; - this.initSphereGL(); - }; - - /** - * Do the gl part of initializing the sphere - */ - rglwidgetClass.prototype.initSphereGL = function() { - var gl = this.gl || this.initGL(), sphere = this.sphere; - if (gl.isContextLost()) return; - sphere.buf = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, sphere.buf); - gl.bufferData(gl.ARRAY_BUFFER, sphere.values, gl.STATIC_DRAW); - sphere.ibuf = [gl.createBuffer(), gl.createBuffer()]; - return; - }; - - /* Initialize common sphere object from spheres object - */ - rglwidgetClass.prototype.initSphereFromObj = function(obj) { - var i, pass, f, mode, sphere = this.sphere; - sphere.ofsLoc = obj.ofsLoc; - sphere.texLoc = obj.texLoc; - sphere.sampler = obj.sampler; - sphere.uFogMode = obj.uFogMode; - sphere.uFogColor = obj.uFogColor; - sphere.uFogParms = obj.uFogParms; - sphere.userAttribLocations = obj.userAttribLocations; - sphere.userUniformLocations = obj.userUniformLocations; - sphere.normLoc = obj.normLoc; - sphere.clipLoc = obj.clipLoc; - sphere.nextLoc = obj.nextLoc; - sphere.pointLoc = obj.pointLoc; - sphere.aspectLoc = obj.aspectLoc; - sphere.lwdLoc = obj.lwdLoc; - sphere.prog = obj.prog; - sphere.material = obj.material; - sphere.flags = obj.flags; - sphere.someHidden = obj.someHidden; - sphere.fastTransparency = obj.fastTransparency; - sphere.nlights = obj.nlights; - sphere.emission = obj.emission; - sphere.emissionLoc = obj.emissionLoc; - sphere.shininess = obj.shininess; - sphere.shininessLoc = obj.shininessLoc; - sphere.ambient = obj.ambient; - sphere.ambientLoc = obj.ambientLoc; - sphere.specular = obj.specular; - sphere.specularLoc = obj.specularLoc; - sphere.diffuse = obj.diffuse; - sphere.diffuseLoc = obj.diffuseLoc; - sphere.lightDir = obj.lightDir; - sphere.lightDirLoc = obj.lightDirLoc; - sphere.viewpoint = obj.viewpoint; - sphere.viewpointLoc = obj.viewpointLoc; - sphere.finite = obj.finite; - sphere.finiteLoc = obj.finiteLoc; - sphere.prMatLoc = obj.prMatLoc; - sphere.mvMatLoc = obj.mvMatLoc; - sphere.normMatLoc = obj.normMatLoc; - sphere.frontLoc = obj.frontLoc; - sphere.index_uint = false; - sphere.is_transparent = obj.is_transparent; - sphere.ignoreExtent = obj.ignoreExtent; - if (sphere.passes !== obj.passes || - JSON.stringify(sphere.pmode) !== JSON.stringify(obj.pmode)) { - sphere.passes = obj.passes; - sphere.pmode = obj.pmode; - for (pass = 0; pass < obj.passes; pass++) { - mode = sphere.pmode[pass]; - if (typeof sphere.indices[mode] === "undefined") { - f = []; - switch (mode) { - case "culled": break; - case "points": - f.length = sphere.vertexCount; - for (i=0; i < f.length; i++) - f[i] = i; - break; - case "lines": - f.length = 2*sphere.it.length; - for (i=0; i < sphere.it.length/3; i++) { - f[6*i] = sphere.it[3*i]; - f[6*i + 1] = sphere.it[3*i + 1]; - f[6*i + 2] = sphere.it[3*i + 1]; - f[6*i + 3] = sphere.it[3*i + 2]; - f[6*i + 4] = sphere.it[3*i + 2]; - f[6*i + 5] = sphere.it[3*i]; - } - break; - case "filled": - f = sphere.it; - } - sphere.indices[mode] = new Uint16Array(f); - } - sphere.f[pass] = sphere.indices[mode]; - } - } - // console.log("Names in spheres not in sphere:"+JSON.stringify(this.keydiff(obj, sphere))); - sphere.initialized = true; - }; - - /** - * Initialize a subscene - * @param { number } id - id of subscene. - */ - rglwidgetClass.prototype.initSubscene = function(id) { - var sub = this.getObj(id), - i, obj; - - if (sub.type !== "subscene") - return; - - sub.par3d.userMatrix = this.toCanvasMatrix4(sub.par3d.userMatrix); - sub.par3d.userProjection = this.toCanvasMatrix4(sub.par3d.userProjection); - sub.par3d.userProjection.transpose(); - sub.par3d.listeners = [].concat(sub.par3d.listeners); - sub.backgroundId = undefined; - sub.subscenes = []; - sub.clipplanes = []; - sub.transparent = []; - sub.opaque = []; - sub.lights = []; - for (i=0; i < sub.objects.length; i++) { - obj = this.getObj(sub.objects[i]); - if (typeof obj === "undefined") { - sub.objects.splice(i, 1); - i--; - } else if (obj.type === "background") - sub.backgroundId = obj.id; - else - sub[this.whichList(obj.id)].push(obj.id); - } - }; - - /** - * Initialize object for display - * @param { number } id - id of object to initialize - */ - rglwidgetClass.prototype.initObj = function(id) { - var obj = this.getObj(id), - flags = obj.flags, - type = obj.type, - is_lit = this.isSet(flags, this.f_is_lit), - fat_lines = this.isSet(flags, this.f_fat_lines), - has_texture = this.isSet(flags, this.f_has_texture), - fixed_quads = this.isSet(flags, this.f_fixed_quads), - is_transparent = obj.is_transparent, - depth_sort = this.isSet(flags, this.f_depth_sort), - sprites_3d = this.isSet(flags, this.f_sprites_3d), - fixed_size = this.isSet(flags, this.f_fixed_size), - is_twosided = this.isSet(flags, this.f_is_twosided), - is_brush = this.isSet(flags, this.f_is_brush), - has_fog = this.isSet(flags, this.f_has_fog), - has_normals = typeof obj.normals !== "undefined", - gl = this.gl || this.initGL(), - polygon_offset, - texinfo, drawtype, nclipplanes, f, nrows, oldrows, - i,j,v,v1,v2, mat, uri, matobj, pass, pmode, - dim, nx, nz, nrow; - - if (typeof id !== "number") { - this.alertOnce("initObj id is "+typeof id); - } - - obj.initialized = true; - - obj.someHidden = false; // used in selection - - if (type === "bboxdeco" || type === "subscene") - return; - - if (type === "spheres" && typeof this.sphere === "undefined") - this.initSphere(); - - if (type === "light") { - obj.ambient = new Float32Array(obj.colors[0].slice(0,3)); - obj.diffuse = new Float32Array(obj.colors[1].slice(0,3)); - obj.specular = new Float32Array(obj.colors[2].slice(0,3)); - obj.lightDir = new Float32Array(obj.vertices[0]); - return; - } - - if (type === "clipplanes") { - obj.vClipplane = this.flatten(this.cbind(obj.normals, obj.offsets)); - return; - } - - if (type === "background" && typeof obj.ids !== "undefined") { - obj.quad = this.flatten([].concat(obj.ids)); - return; - } - - polygon_offset = this.getMaterial(id, "polygon_offset"); - if (polygon_offset[0] !== 0 || polygon_offset[1] !== 0) - obj.polygon_offset = polygon_offset; - - if (is_transparent) { - depth_sort = ["triangles", "quads", "surface", - "spheres", "sprites", "text"].indexOf(type) >= 0; - } - - if (is_brush) - this.initSelection(id); - - if (typeof obj.vertices === "undefined") - obj.vertices = []; - - v = obj.vertices; - obj.vertexCount = v.length; - if (!obj.vertexCount) return; - - if (is_twosided && !has_normals) { - if (typeof obj.userAttributes === "undefined") - obj.userAttributes = {}; - v1 = Array(v.length); - v2 = Array(v.length); - if (obj.type === "triangles" || obj.type === "quads") { - if (obj.type === "triangles") - nrow = 3; - else - nrow = 4; - for (i=0; i= 0) { - key = this.scene.crosstalk.key[j]; - options = this.scene.crosstalk.options[j]; - colors = colors.slice(0); - for (i = 0; i < v.length; i++) - colors[i] = obj.colors[i % obj.colors.length].slice(0); - if ( (selection = this.scene.crosstalk.selection) && - (selection.length || !options.selectedIgnoreNone) ) - for (i = 0; i < v.length; i++) { - if (!selection.includes(key[i])) { - if (options.deselectedColor) - colors[i] = options.deselectedColor.slice(0); - colors[i][3] = colors[i][3]*options.deselectedFade; /* default: mostly transparent if not selected */ - } else if (options.selectedColor) - colors[i] = options.selectedColor.slice(0); - } - if ( (filter = this.scene.crosstalk.filter) ) - for (i = 0; i < v.length; i++) - if (!filter.includes(key[i])) { - if (options.filteredColor) - colors[i] = options.filteredColor.slice(0); - colors[i][3] = colors[i][3]*options.filteredFade; /* default: completely hidden if filtered */ - } - } - if (obj.type === "spheres") - obj.sphereColors = colors; - - nc = obj.colorCount = colors.length; - if (nc > 1) { - cofs = stride; - stride = stride + 4; - v = this.cbind(v, colors); - } else { - cofs = -1; - obj.onecolor = this.flatten(colors); - } - - if (has_normals) { - nofs = stride; - stride = stride + 3; - v = this.cbind(v, typeof obj.pnormals !== "undefined" ? obj.pnormals : obj.normals); - } else - nofs = -1; - - if (typeof obj.radii !== "undefined") { - radofs = stride; - stride = stride + 1; - // FIXME: always concat the radii? - if (obj.radii.length === v.length) { - v = this.cbind(v, obj.radii); - } else if (obj.radii.length === 1) { - v = v.map(function(row) { return row.concat(obj.radii[0]);}); - } - } else - radofs = -1; - - // Add default indices - f = Array(v.length); - for (i = 0; i < v.length; i++) - f[i] = i; - obj.f = [f,f]; - - if (type === "sprites" && !sprites_3d) { - tofs = stride; - stride += 2; - oofs = stride; - stride += 2; - vnew = new Array(4*v.length); - fnew = new Array(4*v.length); - alias = new Array(v.length); - var rescale = fixed_size ? 72 : 1, - size = obj.radii, s = rescale*size[0]/2; - last = v.length; - f = obj.f[0]; - for (i=0; i < v.length; i++) { - if (size.length > 1) - s = rescale*size[i]/2; - vnew[i] = v[i].concat([0,0,-s,-s]); - fnew[4*i] = f[i]; - vnew[last]= v[i].concat([1,0, s,-s]); - fnew[4*i+1] = last++; - vnew[last]= v[i].concat([1,1, s, s]); - fnew[4*i+2] = last++; - vnew[last]= v[i].concat([0,1,-s, s]); - fnew[4*i+3] = last++; - alias[i] = [last-3, last-2, last-1]; - } - v = vnew; - obj.vertexCount = v.length; - obj.f = [fnew, fnew]; - } else if (type === "text") { - tofs = stride; - stride += 2; - oofs = stride; - stride += 2; - vnew = new Array(4*v.length); - f = obj.f[0]; - fnew = new Array(4*f.length); - alias = new Array(v.length); - last = v.length; - adj = this.flatten(obj.adj); - if (typeof obj.pos !== "undefined") { - pos = this.flatten(obj.pos); - offset = adj[0]; - } - for (i=0; i < v.length; i++) { - if (typeof pos !== "undefined") - adj = this.getAdj(pos[i % pos.length], offset, obj.texts[i]); - vnew[i] = v[i].concat([0,-0.5]).concat(adj); - fnew[4*i] = f[i]; - vnew[last] = v[i].concat([1,-0.5]).concat(adj); - fnew[4*i+1] = last++; - vnew[last] = v[i].concat([1, 1.5]).concat(adj); - fnew[4*i+2] = last++; - vnew[last] = v[i].concat([0, 1.5]).concat(adj); - fnew[4*i+3] = last++; - alias[i] = [last-3, last-2, last-1]; - for (j=0; j < 4; j++) { - v1 = vnew[fnew[4*i+j]]; - v1[tofs+2] = 2*(v1[tofs]-v1[tofs+2])*texinfo.widths[i]; - v1[tofs+3] = 2*(v1[tofs+1]-v1[tofs+3])*texinfo.textHeights[i]; - v1[tofs] = (texinfo.offsetsx[i] + v1[tofs]*texinfo.widths[i])/texinfo.canvasX; - v1[tofs+1] = 1.0-(texinfo.offsetsy[i] - - v1[tofs+1]*texinfo.textHeights[i])/texinfo.canvasY; - vnew[fnew[4*i+j]] = v1; - } - } - v = vnew; - obj.vertexCount = v.length; - obj.f = [fnew, fnew]; - } else if (typeof obj.texcoords !== "undefined") { - tofs = stride; - stride += 2; - oofs = -1; - v = this.cbind(v, obj.texcoords); - } else { - tofs = -1; - oofs = -1; - } - - obj.alias = alias; - - if (typeof obj.userAttributes !== "undefined") { - obj.userAttribOffsets = {}; - obj.userAttribLocations = {}; - obj.userAttribSizes = {}; - for (attr in obj.userAttributes) { - obj.userAttribLocations[attr] = gl.getAttribLocation(obj.prog, attr); - if (obj.userAttribLocations[attr] >= 0) { // Attribute may not have been used - obj.userAttribOffsets[attr] = stride; - v = this.cbind(v, obj.userAttributes[attr]); - stride = v[0].length; - obj.userAttribSizes[attr] = stride - obj.userAttribOffsets[attr]; - } - } - } - - if (typeof obj.userUniforms !== "undefined") { - obj.userUniformLocations = {}; - for (attr in obj.userUniforms) - obj.userUniformLocations[attr] = gl.getUniformLocation(obj.prog, attr); - } - - if (sprites_3d) { - obj.userMatrix = new CanvasMatrix4(obj.usermatrix); - obj.objects = this.flatten([].concat(obj.ids)); - is_lit = false; - for (i=0; i < obj.objects.length; i++) - this.initObj(obj.objects[i]); - } - - if (is_lit && !fixed_quads) { - obj.normLoc = gl.getAttribLocation(obj.prog, "aNorm"); - } - - nclipplanes = this.countClipplanes(); - if (nclipplanes && !sprites_3d) { - obj.clipLoc = []; - for (i=0; i < nclipplanes; i++) - obj.clipLoc[i] = gl.getUniformLocation(obj.prog,"vClipplane" + i); - } - - if (is_lit) { - obj.emissionLoc = gl.getUniformLocation(obj.prog, "emission"); - obj.emission = new Float32Array(this.stringToRgb(this.getMaterial(id, "emission"))); - obj.shininessLoc = gl.getUniformLocation(obj.prog, "shininess"); - obj.shininess = this.getMaterial(id, "shininess"); - obj.nlights = this.countLights(); - obj.ambientLoc = []; - obj.ambient = new Float32Array(this.stringToRgb(this.getMaterial(id, "ambient"))); - obj.specularLoc = []; - obj.specular = new Float32Array(this.stringToRgb(this.getMaterial(id, "specular"))); - obj.diffuseLoc = []; - obj.lightDirLoc = []; - obj.viewpointLoc = []; - obj.finiteLoc = []; - for (i=0; i < obj.nlights; i++) { - obj.ambientLoc[i] = gl.getUniformLocation(obj.prog, "ambient" + i); - obj.specularLoc[i] = gl.getUniformLocation(obj.prog, "specular" + i); - obj.diffuseLoc[i] = gl.getUniformLocation(obj.prog, "diffuse" + i); - obj.lightDirLoc[i] = gl.getUniformLocation(obj.prog, "lightDir" + i); - obj.viewpointLoc[i] = gl.getUniformLocation(obj.prog, "viewpoint" + i); - obj.finiteLoc[i] = gl.getUniformLocation(obj.prog, "finite" + i); - } - } - - obj.passes = is_twosided + 1; - obj.pmode = new Array(obj.passes); - for (pass = 0; pass < obj.passes; pass++) { - if (type === "triangles" || type === "quads" || type === "surface" || type === "spheres") - pmode = this.getMaterial(id, (pass === 0) ? "front" : "back"); - else pmode = "filled"; - obj.pmode[pass] = pmode; - } - if (type !== "spheres") { - obj.f.length = obj.passes; - for (pass = 0; pass < obj.passes; pass++) { - f = fnew = obj.f[pass]; - pmode = obj.pmode[pass]; - if (pmode === "culled") - f = []; - else if (pmode === "points") { - // stay with default - } else if ((type === "quads" || type === "text" || - type === "sprites") && !sprites_3d) { - nrows = Math.floor(obj.vertexCount/4); - if (pmode === "filled") { - fnew = Array(6*nrows); - for (i=0; i < nrows; i++) { - fnew[6*i] = f[4*i]; - fnew[6*i+1] = f[4*i + 1]; - fnew[6*i+2] = f[4*i + 2]; - fnew[6*i+3] = f[4*i]; - fnew[6*i+4] = f[4*i + 2]; - fnew[6*i+5] = f[4*i + 3]; - } - } else { - fnew = Array(8*nrows); - for (i=0; i < nrows; i++) { - fnew[8*i] = f[4*i]; - fnew[8*i+1] = f[4*i + 1]; - fnew[8*i+2] = f[4*i + 1]; - fnew[8*i+3] = f[4*i + 2]; - fnew[8*i+4] = f[4*i + 2]; - fnew[8*i+5] = f[4*i + 3]; - fnew[8*i+6] = f[4*i + 3]; - fnew[8*i+7] = f[4*i]; - } - } - } else if (type === "triangles") { - nrows = Math.floor(obj.vertexCount/3); - if (pmode === "filled") { - fnew = Array(3*nrows); - for (i=0; i < fnew.length; i++) { - fnew[i] = f[i]; - } - } else if (pmode === "lines") { - fnew = Array(6*nrows); - for (i=0; i < nrows; i++) { - fnew[6*i] = f[3*i]; - fnew[6*i + 1] = f[3*i + 1]; - fnew[6*i + 2] = f[3*i + 1]; - fnew[6*i + 3] = f[3*i + 2]; - fnew[6*i + 4] = f[3*i + 2]; - fnew[6*i + 5] = f[3*i]; - } - } - } else if (type === "spheres") { - // default - } else if (type === "surface") { - dim = obj.dim[0]; - nx = dim[0]; - nz = dim[1]; - if (pmode === "filled") { - fnew = []; - for (j=0; j 65535) { - if (this.index_uint) { - obj.f[pass] = new Uint32Array(obj.f[pass]); - obj.index_uint = true; - } else - this.alertOnce("Object has "+obj.vertexCount+" vertices, not supported in this browser."); - } else { - obj.f[pass] = new Uint16Array(obj.f[pass]); - obj.index_uint = false; - } - } - - if (stride !== v[0].length) { - this.alertOnce("problem in stride calculation"); - } - - obj.vOffsets = {vofs:0, cofs:cofs, nofs:nofs, radofs:radofs, oofs:oofs, tofs:tofs, - nextofs:nextofs, pointofs:pointofs, stride:stride}; - - obj.values = new Float32Array(this.flatten(v)); - - if (type !== "spheres" && !sprites_3d) { - obj.buf = gl.createBuffer(); - gl.bindBuffer(gl.ARRAY_BUFFER, obj.buf); - gl.bufferData(gl.ARRAY_BUFFER, obj.values, gl.STATIC_DRAW); // - obj.ibuf = Array(obj.passes); - obj.ibuf[0] = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, obj.ibuf[0]); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, obj.f[0], gl[drawtype]); - if (is_twosided) { - obj.ibuf[1] = gl.createBuffer(); - gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, obj.ibuf[1]); - gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, obj.f[1], gl[drawtype]); - } - } - - if (!sprites_3d) { - obj.mvMatLoc = gl.getUniformLocation(obj.prog, "mvMatrix"); - obj.prMatLoc = gl.getUniformLocation(obj.prog, "prMatrix"); - } - - if (fixed_size) { - obj.textScaleLoc = gl.getUniformLocation(obj.prog, "textScale"); - } - - if (is_lit && !sprites_3d) { - obj.normMatLoc = gl.getUniformLocation(obj.prog, "normMatrix"); - } - - if (is_twosided) { - obj.frontLoc = gl.getUniformLocation(obj.prog, "front"); - } - }; - - /** - * Initialize the DOM object - * @param { Object } el - the DOM object - * @param { Object } x - the scene data sent by JSON from R - */ - rglwidgetClass.prototype.initialize = function(el, x) { - this.textureCanvas = document.createElement("canvas"); - this.textureCanvas.style.display = "block"; - this.scene = x; - this.normMatrix = new CanvasMatrix4(); - this.saveMat = {}; - this.distance = null; - this.posLoc = 0; - this.colLoc = 1; - if (el) { - el.rglinstance = this; - this.el = el; - this.webGLoptions = el.rglinstance.scene.webGLoptions; - this.initCanvas(); - } - if (typeof Shiny !== "undefined") { - var self = this; - Shiny.addCustomMessageHandler("shinyGetPar3d", - function(message) { - var i, param, - subscene = self.getObj(message.subscene), - parameters = [].concat(message.parameters), - result = {tag: message.tag, subscene: message.subscene}; - if (typeof subscene !== "undefined") { - for (i = 0; i < parameters.length; i++) { - param = parameters[i]; - result[param] = subscene.par3d[param]; - } - } else { - console.log("subscene "+message.subscene+" undefined."); - } - Shiny.setInputValue("par3d:shinyPar3d", result, {priority: "event"}); - }); - - Shiny.addCustomMessageHandler("shinySetPar3d", - function(message) { - var param = message.parameter, - subscene = self.getObj(message.subscene); - if (typeof subscene !== "undefined") { - subscene.par3d[param] = message.value; - subscene.initialized = false; - self.drawScene(); - } else { - console.log("subscene "+message.subscene+" undefined."); - } - }); - - Shiny.addCustomMessageHandler("resetBrush", - function(message) { - if (message === self.scene.selectionInput) { - self.clearBrush(null); - self.recordSelection(0); - } - }); - } - }; - - /** - * Restart the WebGL canvas - */ - rglwidgetClass.prototype.restartCanvas = function() { - var newcanvas = document.createElement("canvas"), - self = this; - newcanvas.width = this.el.width; - newcanvas.height = this.el.height; - newcanvas.addEventListener("webglcontextrestored", - this.onContextRestored, false); - newcanvas.addEventListener("webglcontextlost", - this.onContextLost, false); - while (this.el.firstChild) { - this.el.removeChild(this.el.firstChild); - } - this.el.appendChild(newcanvas); - this.canvas = newcanvas; - this.setMouseHandlers(); - if (this.gl) - Object.keys(this.scene.objects).forEach(function(key){ - self.getObj(parseInt(key, 10)).texture = undefined; - }); - this.gl = null; - }; - - /** - * Initialize the WebGL canvas - */ - rglwidgetClass.prototype.initCanvas = function() { - this.restartCanvas(); - var objs = this.scene.objects, - self = this; - Object.keys(objs).forEach(function(key){ - var id = parseInt(key, 10), - obj = self.getObj(id); - if (typeof obj.reuse !== "undefined") - self.copyObj(id, obj.reuse); - }); - Object.keys(objs).forEach(function(key){ - self.initSubscene(parseInt(key, 10)); - }); - this.setMouseHandlers(); - - this.onContextRestored = function() { - self.initGL(); - self.drawScene(); - }; - - this.onContextLost = function(event) { - if (!self.drawing) - this.gl = null; - event.preventDefault(); - }; - - this.initGL0(); - this.lazyLoadScene = function() { - if (typeof self.slide === "undefined") - self.slide = self.getSlide(); - if (self.isInBrowserViewport()) { - if (!self.gl || self.gl.isContextLost()) - self.initGL(); - self.drawScene(); - } - }; - window.addEventListener("DOMContentLoaded", this.lazyLoadScene, false); - window.addEventListener("load", this.lazyLoadScene, false); - window.addEventListener("resize", this.lazyLoadScene, false); - window.addEventListener("scroll", this.lazyLoadScene, false); - this.slide = this.getSlide(); - if (this.slide) { - if (typeof this.slide.rgl === "undefined") - this.slide.rgl = [this]; - else - this.slide.rgl.push(this); - if (this.scene.context.rmarkdown) - if (this.scene.context.rmarkdown === "ioslides_presentation") { - this.slide.setAttribute("slideenter", "this.rgl.forEach(function(scene) { scene.lazyLoadScene.call(window);})"); - } else if (this.scene.context.rmarkdown === "slidy_presentation") { - // This method would also work in ioslides, but it gets triggered - // something like 5 times per slide for every slide change, so - // you'd need a quicker function than lazyLoadScene. - var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver, - observer = new MutationObserver(function(mutations) { - mutations.forEach(function() { - self.slide.rgl.forEach(function(scene) { scene.lazyLoadScene.call(window); });});}); - observer.observe(this.slide, { attributes: true, attributeFilter:["class"] }); - } - } - }; diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/mouse.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/mouse.src.js deleted file mode 100644 index 1c55d974..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/mouse.src.js +++ /dev/null @@ -1,446 +0,0 @@ - - rglwidgetClass.prototype.getCursor = function(mode) { - switch(mode) { - case "none": - return "none"; - case "trackball": - case "xAxis": - case "yAxis": - case "zAxis": - case "polar": - return "grab"; - case "selecting": - return "crosshair"; - case "fov": - case "zoom": - return "zoom-in"; - } - return "dragging"; - }; - - /** - * Set mouse mode for a subscene - * @param { string } mode - name of mode - * @param { number } button - button number (1 to 3) - * @param { number } subscene - subscene id number - * @param { number } stayActive - if truthy, don't clear brush - */ - rglwidgetClass.prototype.setMouseMode = function(mode, button, subscene, stayActive) { - var sub = this.getObj(subscene), - which = ["left", "right", "middle"][button - 1]; - if (!stayActive && sub.par3d.mouseMode[which] === "selecting") - this.clearBrush(null); - sub.par3d.mouseMode[which] = mode; - if (button === 1) - this.canvas.style.cursor = this.getCursor(mode); - }; - - /** - * Compute mouse coordinates relative to current canvas - * @returns { Object } - * @param { Object } event - event object from mouse click - */ - rglwidgetClass.prototype.relMouseCoords = function(event) { - var rect = this.canvas.getBoundingClientRect(); - return {x:event.clientX-rect.left, y:event.clientY-rect.top}; - }; - - /** - * Send mouse selection to Shiny - */ - rglwidgetClass.prototype.recordSelection = function(subid) { - var result = {}; - if (typeof this.select !== "undefined" && - typeof this.select.state !== "undefined" && - this.select.state !== "inactive") { - result = { subscene: subid, - state: this.select.state, - region: this.select.region - }; - this.setmvMatrix(subid); - result.model = this.mvMatrix; - this.setprMatrix(subid); - result.proj = this.prMatrix; - this.getViewport(subid); - result.view = this.vp; - } else - result.state = "inactive"; - Shiny.setInputValue(this.scene.selectionInput + ":shinyMouse3d", result); - }; - - /** - * Set mouse handlers for the scene - */ - rglwidgetClass.prototype.setMouseHandlers = function() { - var self = this, activeSubscene, handler, - handlers = {}, drag = 0; - - handlers.rotBase = 0; - - this.screenToVector = function(x, y) { - var viewport = this.getObj(activeSubscene).par3d.viewport, - width = viewport.width*this.canvas.width, - height = viewport.height*this.canvas.height, - radius = Math.max(width, height)/2.0, - cx = width/2.0, - cy = height/2.0, - px = (x-cx)/radius, - py = (y-cy)/radius, - plen = Math.sqrt(px*px+py*py); - if (plen > 1.e-6) { - px = px/plen; - py = py/plen; - } - var angle = (Math.SQRT2 - plen)/Math.SQRT2*Math.PI/2, - z = Math.sin(angle), - zlen = Math.sqrt(1.0 - z*z); - px = px * zlen; - py = py * zlen; - return [px, py, z]; - }; - - handlers.trackballdown = function(x,y) { - var activeSub = this.getObj(activeSubscene), - activeModel = this.getObj(this.useid(activeSub.id, "model")), - i, l = activeModel.par3d.listeners; - handlers.rotBase = this.screenToVector(x, y); - this.saveMat = []; - for (i = 0; i < l.length; i++) { - activeSub = this.getObj(l[i]); - activeSub.saveMat = new CanvasMatrix4(activeSub.par3d.userMatrix); - } - this.canvas.style.cursor = "grabbing"; - }; - - handlers.trackballmove = function(x,y) { - var rotCurrent = this.screenToVector(x,y), - rotBase = handlers.rotBase, - dot = rotBase[0]*rotCurrent[0] + - rotBase[1]*rotCurrent[1] + - rotBase[2]*rotCurrent[2], - angle = Math.acos( dot/this.vlen(rotBase)/this.vlen(rotCurrent) )*180.0/Math.PI, - axis = this.xprod(rotBase, rotCurrent), - objects = this.scene.objects, - activeSub = this.getObj(activeSubscene), - activeModel = this.getObj(this.useid(activeSub.id, "model")), - l = activeModel.par3d.listeners, - i; - for (i = 0; i < l.length; i++) { - activeSub = this.getObj(l[i]); - activeSub.par3d.userMatrix.load(objects[l[i]].saveMat); - activeSub.par3d.userMatrix.rotate(angle, axis[0], axis[1], axis[2]); - } - this.drawScene(); - }; - handlers.trackballend = 0; - - this.clamp = function(x, lo, hi) { - return Math.max(lo, Math.min(x, hi)); - }; - - this.screenToPolar = function(x,y) { - var viewport = this.getObj(activeSubscene).par3d.viewport, - width = viewport.width*this.canvas.width, - height = viewport.height*this.canvas.height, - r = Math.min(width, height)/2, - dx = this.clamp(x - width/2, -r, r), - dy = this.clamp(y - height/2, -r, r); - return [Math.asin(dx/r), Math.asin(-dy/r)]; - }; - - handlers.polardown = function(x,y) { - var activeSub = this.getObj(activeSubscene), - activeModel = this.getObj(this.useid(activeSub.id, "model")), - i, l = activeModel.par3d.listeners; - handlers.dragBase = this.screenToPolar(x, y); - this.saveMat = []; - for (i = 0; i < l.length; i++) { - activeSub = this.getObj(l[i]); - activeSub.saveMat = new CanvasMatrix4(activeSub.par3d.userMatrix); - activeSub.camBase = [-Math.atan2(activeSub.saveMat.m13, activeSub.saveMat.m11), - Math.atan2(activeSub.saveMat.m32, activeSub.saveMat.m22)]; - } - this.canvas.style.cursor = "grabbing"; - }; - - handlers.polarmove = function(x,y) { - var dragCurrent = this.screenToPolar(x,y), - activeSub = this.getObj(activeSubscene), - activeModel = this.getObj(this.useid(activeSub.id, "model")), - objects = this.scene.objects, - l = activeModel.par3d.listeners, - i, j, changepos = []; - for (i = 0; i < l.length; i++) { - activeSub = this.getObj(l[i]); - for (j=0; j<2; j++) - changepos[j] = -(dragCurrent[j] - handlers.dragBase[j]); - activeSub.par3d.userMatrix.makeIdentity(); - activeSub.par3d.userMatrix.rotate(changepos[0]*180/Math.PI, 0,-1,0); - activeSub.par3d.userMatrix.multRight(objects[l[i]].saveMat); - activeSub.par3d.userMatrix.rotate(changepos[1]*180/Math.PI, -1,0,0); - } - this.drawScene(); - }; - handlers.polarend = 0; - - handlers.axisdown = function(x) { - handlers.rotBase = this.screenToVector(x, this.canvas.height/2); - var activeSub = this.getObj(activeSubscene), - activeModel = this.getObj(this.useid(activeSub.id, "model")), - i, l = activeModel.par3d.listeners; - for (i = 0; i < l.length; i++) { - activeSub = this.getObj(l[i]); - activeSub.saveMat = new CanvasMatrix4(activeSub.par3d.userMatrix); - } - this.canvas.style.cursor = "grabbing"; - }; - - handlers.axismove = function(x) { - var rotCurrent = this.screenToVector(x, this.canvas.height/2), - rotBase = handlers.rotBase, - angle = (rotCurrent[0] - rotBase[0])*180/Math.PI, - rotMat = new CanvasMatrix4(); - rotMat.rotate(angle, handlers.axis[0], handlers.axis[1], handlers.axis[2]); - var activeSub = this.getObj(activeSubscene), - activeModel = this.getObj(this.useid(activeSub.id, "model")), - i, l = activeModel.par3d.listeners; - for (i = 0; i < l.length; i++) { - activeSub = this.getObj(l[i]); - activeSub.par3d.userMatrix.load(activeSub.saveMat); - activeSub.par3d.userMatrix.multLeft(rotMat); - } - this.drawScene(); - }; - handlers.axisend = 0; - - handlers.y0zoom = 0; - handlers.zoomdown = function(x, y) { - var activeSub = self.getObj(activeSubscene), - activeProjection = self.getObj(self.useid(activeSub.id, "projection")), - i, l = activeProjection.par3d.listeners; - handlers.y0zoom = y; - for (i = 0; i < l.length; i++) { - activeSub = self.getObj(l[i]); - activeSub.zoom0 = Math.log(activeSub.par3d.zoom); - } - self.canvas.style.cursor = "zoom-in"; - }; - handlers.zoommove = function(x, y) { - var activeSub = self.getObj(activeSubscene), - activeProjection = self.getObj(self.useid(activeSub.id, "projection")), - i, l = activeProjection.par3d.listeners; - for (i = 0; i < l.length; i++) { - activeSub = self.getObj(l[i]); - activeSub.par3d.zoom = Math.exp(activeSub.zoom0 + (y-handlers.y0zoom)/self.canvas.height); - } - self.drawScene(); - }; - handlers.zoomend = 0; - - handlers.y0fov = 0; - handlers.fovdown = function(x, y) { - handlers.y0fov = y; - var activeSub = this.getObj(activeSubscene), - activeProjection = this.getObj(this.useid(activeSub.id, "projection")), - i, l = activeProjection.par3d.listeners; - for (i = 0; i < l.length; i++) { - activeSub = this.getObj(l[i]); - activeSub.fov0 = activeSub.par3d.FOV; - } - this.canvas.style.cursor = "zoom-in"; - }; - handlers.fovmove = function(x, y) { - var activeSub = this.getObj(activeSubscene), - activeProjection = this.getObj(this.useid(activeSub.id, "projection")), - i, l = activeProjection.par3d.listeners; - for (i = 0; i < l.length; i++) { - activeSub = this.getObj(l[i]); - activeSub.par3d.FOV = Math.max(1, Math.min(179, activeSub.fov0 + - 180*(y-handlers.y0fov)/this.canvas.height)); - } - this.drawScene(); - }; - handlers.fovend = 0; - - handlers.selectingdown = function(x, y) { - var viewport = this.getObj(activeSubscene).par3d.viewport, - width = viewport.width*this.canvas.width, - height = viewport.height*this.canvas.height, - p = {x: 2.0*x/width - 1.0, y: 2.0*y/height - 1.0}; - this.select.region = {p1: p, p2: p}; - if (this.select.subscene && this.select.subscene !== activeSubscene) - this.delFromSubscene(this.scene.brushId, this.select.subscene); - this.select.subscene = activeSubscene; - this.addToSubscene(this.scene.brushId, activeSubscene); - this.select.state = "changing"; - if (typeof this.scene.brushId !== "undefined") - this.getObj(this.scene.brushId).initialized = false; - if (typeof this.scene.selectionInput !== "undefined") - self.recordSelection(activeSubscene); - this.drawScene(); - this.canvas.style.cursor = "crosshair"; - }; - - handlers.selectingmove = function(x, y) { - var viewport = this.getObj(activeSubscene).par3d.viewport, - width = viewport.width*this.canvas.width, - height = viewport.height*this.canvas.height; - if (this.select.state === "inactive") - return; - this.select.region.p2 = {x: 2.0*x/width - 1.0, y: 2.0*y/height - 1.0}; - if (typeof this.scene.brushId !== "undefined") - this.getObj(this.scene.brushId).initialized = false; - if (typeof this.scene.selectionInput !== "undefined") - this.recordSelection(activeSubscene); - this.drawScene(); - }; - - handlers.selectingend = 0; - - this.canvas.onmousedown = function ( ev ){ - if (!ev.which) // Use w3c defns in preference to MS - switch (ev.button) { - case 0: ev.which = 1; break; - case 1: - case 4: ev.which = 2; break; - case 2: ev.which = 3; - } - drag = ["left", "middle", "right"][ev.which-1]; - var coords = self.relMouseCoords(ev); - coords.y = self.canvas.height-coords.y; - activeSubscene = self.whichSubscene(coords); - var sub = self.getObj(activeSubscene), f; - handler = sub.par3d.mouseMode[drag]; - switch (handler) { - case "xAxis": - handler = "axis"; - handlers.axis = [1.0, 0.0, 0.0]; - break; - case "yAxis": - handler = "axis"; - handlers.axis = [0.0, 1.0, 0.0]; - break; - case "zAxis": - handler = "axis"; - handlers.axis = [0.0, 0.0, 1.0]; - break; - } - f = handlers[handler + "down"]; - if (f) { - coords = self.translateCoords(activeSubscene, coords); - f.call(self, coords.x, coords.y); - ev.preventDefault(); - } else - console.warn("Mouse handler '" + handler + "' is not implemented."); - - }; - - this.canvas.onmouseup = function ( ev ){ - if ( drag === 0 ) return; - var f = handlers[handler + "end"]; - if (f) { - f.call(self); - ev.preventDefault(); - } - drag = 0; - this.onmousemove( ev ); - }; - - this.canvas.onmouseout = this.canvas.onmouseup; - - this.canvas.onmousemove = function ( ev ) { - var coords = self.relMouseCoords(ev), sub, f; - coords.y = self.canvas.height - coords.y; - if ( drag === 0 ) { - activeSubscene = self.whichSubscene(coords); sub = self.getObj(activeSubscene); - this.style.cursor = self.getCursor(sub.par3d.mouseMode.left); - } else { - f = handlers[handler + "move"]; - if (f) { - coords = self.translateCoords(activeSubscene, coords); - f.call(self, coords.x, coords.y); - } - } - }; - - handlers.setZoom = function(ds) { - var i; - if (typeof activeSubscene === "undefined") - activeSubscene = self.scene.rootSubscene; - var activeSub = self.getObj(activeSubscene), - activeProjection = self.getObj(self.useid(activeSub.id, "projection")), - l = activeProjection.par3d.listeners; - - for (i = 0; i < l.length; i++) { - activeSub = self.getObj(l[i]); - activeSub.par3d.zoom *= ds; - } - self.drawScene(); - }; - - handlers.wheelHandler = function(ev) { - var del = 1.02; - if (ev.shiftKey) del = 1.002; - var ds = ((ev.detail || ev.wheelDelta) > 0) ? del : (1 / del); - handlers.setZoom(ds); - ev.preventDefault(); - }; - - handlers.get_finger_dist = function(ev) { - var diffX = ev.touches[0].clientX - ev.touches[1].clientX, - diffY = ev.touches[0].clientY - ev.touches[1].clientY; - return Math.sqrt(diffX * diffX + diffY * diffY); - }; - - handlers.touchstart = function(ev) { - var touch = ev.touches[0], - mouseEvent = new MouseEvent("mousedown", - { - clientX: touch.clientX, - clientY: touch.clientY - }); - ev.preventDefault(); - if (ev.touches.length === 2) { - var coords = self.relMouseCoords(touch); - coords.y = self.canvas.height-coords.y; - activeSubscene = self.whichSubscene(coords); - handlers.finger_dist0 = handlers.get_finger_dist(ev); - handlers.zoomdown(coords.x, coords.y); - } - this.dispatchEvent(mouseEvent); - }; - - handlers.touchend = function(ev) { - var mouseEvent; - ev.preventDefault(); - if (ev.touches.length === 1) { - mouseEvent = new MouseEvent("mouseup", {}); - this.dispatchEvent(mouseEvent); - } - }; - - handlers.touchmove = function(ev) { - var touch = ev.touches[0], - mouseEvent; - ev.preventDefault(); - if (ev.touches.length > 1) { - var coords = self.relMouseCoords(touch), - new_dist = handlers.get_finger_dist(ev); - coords.y = self.canvas.height*Math.log(handlers.finger_dist0/new_dist) + handlers.y0zoom; - handlers.zoommove(coords.x, coords.y); - } else { - mouseEvent = new MouseEvent("mousemove", - { - clientX: touch.clientX, - clientY: touch.clientY - }); - this.dispatchEvent(mouseEvent); - } - }; - - this.canvas.addEventListener("DOMMouseScroll", handlers.wheelHandler, false); - this.canvas.addEventListener("mousewheel", handlers.wheelHandler, false); - this.canvas.addEventListener("touchstart", handlers.touchstart, {passive: false}); - this.canvas.addEventListener("touchend", handlers.touchend, {passive: false}); - this.canvas.addEventListener("touchmove", handlers.touchmove, {passive: false}); - }; diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/pieces.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/pieces.src.js deleted file mode 100644 index a1eac78e..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/pieces.src.js +++ /dev/null @@ -1,94 +0,0 @@ -// These functions order the centers of displayed objects so they -// can be drawn using the painters algorithm, necessary to support -// transparency. - -// Note that objid is not obj.id when drawing spheres. - - rglwidgetClass.prototype.getPieces = function(context, objid, subid, obj) { - var n = obj.centers.length, - depth, - result = new Array(n), - z, w, i; - context = context.slice(); - - for(i=0; i 0) { - var i, - thiscontext = pieces[0].context, - thisobjid = pieces[0].objid, - thissubid = pieces[0].subid, - indices = []; - for (i= 0; i < pieces.length; i++) { - if (pieces[i].context !== thiscontext || - pieces[i].objid !== thisobjid || - pieces[i].subid !== thissubid) { - result.push({context: thiscontext, objid: thisobjid, - subid: thissubid, indices: indices}); - thiscontext = pieces[i].context; - thisobjid = pieces[i].objid; - thissubid = pieces[i].subid; - indices = []; - } - indices.push(pieces[i].index); - } - result.push({context: thiscontext, objid: thisobjid, - subid: thissubid, - indices: indices}); - } - return result; - }; - - rglwidgetClass.prototype.sortPieces = function(pieces) { - var compare = function(i,j) { - var diff = j.depth - i.depth; - // We want to avoid context or obj changes, - // so sort on those next. - if (diff === 0) { - var c1 = j.context.slice(), - c2 = i.context.slice(); - diff = c1.length - c2.length; - while (diff === 0 && c1.length > 0) { - diff = c1.pop() - c2.pop(); - } - if (diff === 0) - diff = j.objid - i.objid; - if (diff === 0) - diff = j.subid - i.subid; - } - return diff; - }, result = []; - if (pieces.length) - result = pieces.sort(compare); - return result; - }; diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/projection.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/projection.src.js deleted file mode 100644 index 6df3c796..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/projection.src.js +++ /dev/null @@ -1,145 +0,0 @@ - - /** - * Get the viewport - */ - - rglwidgetClass.prototype.getViewport = function(id) { - var vp = this.getObj(id).par3d.viewport, - x = vp.x*this.canvas.width, - y = vp.y*this.canvas.height, - width = vp.width*this.canvas.width, - height = vp.height*this.canvas.height; - this.vp = {x:x, y:y, width:width, height:height}; - }; - - /** - * Set the gl viewport and scissor test - * @param { number } id - id of subscene - */ - rglwidgetClass.prototype.setViewport = function(id) { - var gl = this.gl || this.initGL(); - this.getViewport(id); - gl.viewport(this.vp.x, this.vp.y, this.vp.width, this.vp.height); - gl.scissor(this.vp.x, this.vp.y, this.vp.width, this.vp.height); - gl.enable(gl.SCISSOR_TEST); - }; - - /** - * Set the projection matrix for a subscene - * @param { number } id - id of subscene - */ - rglwidgetClass.prototype.setprMatrix = function(id) { - var subscene = this.getObj(id), - embedding = subscene.embeddings.projection; - if (embedding === "replace") - this.prMatrix.makeIdentity(); - else - this.setprMatrix(subscene.parent); - if (embedding === "inherit") - return; - // This is based on the Frustum::enclose code from geom.cpp - var bbox = subscene.par3d.bbox, - scale = subscene.par3d.scale, - ranges = [(bbox[1]-bbox[0])*scale[0]/2, - (bbox[3]-bbox[2])*scale[1]/2, - (bbox[5]-bbox[4])*scale[2]/2], - radius = Math.sqrt(this.sumsq(ranges))*1.1; // A bit bigger to handle labels - if (radius <= 0) radius = 1; - var observer = subscene.par3d.observer, - distance = observer[2], - FOV = subscene.par3d.FOV, ortho = FOV === 0, - t = ortho ? 1 : Math.tan(FOV*Math.PI/360), - near = distance - radius, - far = distance + radius, - hlen, - aspect = this.vp.width/this.vp.height, - z = subscene.par3d.zoom, - userProjection = subscene.par3d.userProjection; - if (far < 0.0) - far = 1.0; - if (near < far/100.0) - near = far/100.0; - this.frustum = {near:near, far:far}; - hlen = t*near; - if (ortho) { - if (aspect > 1) - this.prMatrix.ortho(-hlen*aspect*z, hlen*aspect*z, - -hlen*z, hlen*z, near, far); - else - this.prMatrix.ortho(-hlen*z, hlen*z, - -hlen*z/aspect, hlen*z/aspect, - near, far); - } else { - if (aspect > 1) - this.prMatrix.frustum(-hlen*aspect*z, hlen*aspect*z, - -hlen*z, hlen*z, near, far); - else - this.prMatrix.frustum(-hlen*z, hlen*z, - -hlen*z/aspect, hlen*z/aspect, - near, far); - } - this.prMatrix.multRight(userProjection); - }; - - /** - * Set the model-view matrix for a subscene - * @param { number } id - id of the subscene - */ - rglwidgetClass.prototype.setmvMatrix = function(id) { - var observer = this.getObj(id).par3d.observer; - this.mvMatrix.makeIdentity(); - this.setmodelMatrix(id); - this.mvMatrix.translate(-observer[0], -observer[1], -observer[2]); - - }; - - /** - * Set the model matrix for a subscene - * @param { number } id - id of the subscene - */ - rglwidgetClass.prototype.setmodelMatrix = function(id) { - var subscene = this.getObj(id), - embedding = subscene.embeddings.model; - if (embedding !== "inherit") { - var scale = subscene.par3d.scale, - bbox = subscene.par3d.bbox, - center = [(bbox[0]+bbox[1])/2, - (bbox[2]+bbox[3])/2, - (bbox[4]+bbox[5])/2]; - this.mvMatrix.translate(-center[0], -center[1], -center[2]); - this.mvMatrix.scale(scale[0], scale[1], scale[2]); - this.mvMatrix.multRight( subscene.par3d.userMatrix ); - } - if (embedding !== "replace") - this.setmodelMatrix(subscene.parent); - }; - - /** - * Set the normals matrix for a subscene - * @param { number } subsceneid - id of the subscene - */ - rglwidgetClass.prototype.setnormMatrix = function(subsceneid) { - var self = this, - recurse = function(id) { - var sub = self.getObj(id), - embedding = sub.embeddings.model; - if (embedding !== "inherit") { - var scale = sub.par3d.scale; - self.normMatrix.scale(1/scale[0], 1/scale[1], 1/scale[2]); - self.normMatrix.multRight(sub.par3d.userMatrix); - } - if (embedding !== "replace") - recurse(sub.parent); - }; - self.normMatrix.makeIdentity(); - recurse(subsceneid); - }; - - /** - * Set the combined projection-model-view matrix - */ - rglwidgetClass.prototype.setprmvMatrix = function() { - this.prmvMatrix = new CanvasMatrix4( this.mvMatrix ); - this.prmvMatrix.multRight( this.prMatrix ); - }; - diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/rglClass.min.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/rglClass.min.js deleted file mode 100644 index f5b0792b..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/rglClass.min.js +++ /dev/null @@ -1,4 +0,0 @@ -rglwidgetClass=function(){this.canvas=null,this.userMatrix=new CanvasMatrix4,this.types=[],this.prMatrix=new CanvasMatrix4,this.mvMatrix=new CanvasMatrix4,this.vp=null,this.prmvMatrix=null,this.origs=null,this.gl=null,this.scene=null,this.select={state:"inactive",subscene:null,region:{p1:{x:0,y:0},p2:{x:0,y:0}}},this.drawing=!1},rglwidgetClass.prototype.f_is_lit=1,rglwidgetClass.prototype.f_is_smooth=2,rglwidgetClass.prototype.f_has_texture=4,rglwidgetClass.prototype.f_depth_sort=8,rglwidgetClass.prototype.f_fixed_quads=16,rglwidgetClass.prototype.f_is_transparent=32,rglwidgetClass.prototype.f_is_lines=64,rglwidgetClass.prototype.f_sprites_3d=128,rglwidgetClass.prototype.f_is_subscene=256,rglwidgetClass.prototype.f_is_clipplanes=512,rglwidgetClass.prototype.f_fixed_size=1024,rglwidgetClass.prototype.f_is_points=2048,rglwidgetClass.prototype.f_is_twosided=4096,rglwidgetClass.prototype.f_fat_lines=8192,rglwidgetClass.prototype.f_is_brush=16384,rglwidgetClass.prototype.f_has_fog=32768,rglwidgetClass.prototype.fogNone=0,rglwidgetClass.prototype.fogLinear=1,rglwidgetClass.prototype.fogExp=2,rglwidgetClass.prototype.fogExp2=3,rglwidgetClass.prototype.start=function(){"undefined"!=typeof this.prefix&&(this.debugelement=document.getElementById(this.prefix+"debug"),this.debug("")),this.drag=0,this.drawScene()},rglwidgetClass.prototype.multMV=function(M,v){return[M.m11*v[0]+M.m12*v[1]+M.m13*v[2]+M.m14*v[3],M.m21*v[0]+M.m22*v[1]+M.m23*v[2]+M.m24*v[3],M.m31*v[0]+M.m32*v[1]+M.m33*v[2]+M.m34*v[3],M.m41*v[0]+M.m42*v[1]+M.m43*v[2]+M.m44*v[3]]},rglwidgetClass.prototype.multVM=function(v,M){return[M.m11*v[0]+M.m21*v[1]+M.m31*v[2]+M.m41*v[3],M.m12*v[0]+M.m22*v[1]+M.m32*v[2]+M.m42*v[3],M.m13*v[0]+M.m23*v[1]+M.m33*v[2]+M.m43*v[3],M.m14*v[0]+M.m24*v[1]+M.m34*v[2]+M.m44*v[3]]},rglwidgetClass.prototype.vlen=function(v){return Math.sqrt(this.dotprod(v,v))},rglwidgetClass.prototype.dotprod=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]},rglwidgetClass.prototype.xprod=function(a,b){return[a[1]*b[2]-a[2]*b[1],a[2]*b[0]-a[0]*b[2],a[0]*b[1]-a[1]*b[0]]},rglwidgetClass.prototype.cbind=function(a,b){return b.lengthi;i++)value=arr[i],Array.isArray(value)?this.flatten(value,result):result.push(value);return result},rglwidgetClass.prototype.setElement=function(a,i,value){if(Array.isArray(a[0])){var dim=a.length,col=Math.floor(i/dim),row=i%dim;a[row][col]=value}else a[i]=value},rglwidgetClass.prototype.transpose=function(a){var i,newArray=[],n=a.length,m=a[0].length;for(i=0;m>i;i++)newArray.push([]);for(i=0;n>i;i++)for(var j=0;m>j;j++)newArray[j].push(a[i][j]);return newArray},rglwidgetClass.prototype.sumsq=function(x){var i,result=0;for(i=0;i>16&255)/255,(bigint>>8&255)/255,(255&bigint)/255]},rglwidgetClass.prototype.whichList=function(id){var obj=this.getObj(id),flags=obj.flags;return"light"===obj.type?"lights":this.isSet(flags,this.f_is_subscene)?"subscenes":this.isSet(flags,this.f_is_clipplanes)?"clipplanes":this.isSet(flags,this.f_is_transparent)?"transparent":"opaque"},rglwidgetClass.prototype.componentProduct=function(x,y){"undefined"==typeof y&&this.alertOnce("Bad arg to componentProduct");var i,result=new Float32Array(3);for(i=0;3>i;i++)result[i]=x[i]*y[i];return result},rglwidgetClass.prototype.getPowerOfTwo=function(value){for(var pow=1;value>pow;)pow*=2;return pow},rglwidgetClass.prototype.unique=function(arr){return arr=[].concat(arr),arr.filter(function(value,index,self){return self.indexOf(value)===index})},rglwidgetClass.prototype.equalArrays=function(a,b){return a===b||a&&b&&a.length===b.length&&a.every(function(v,i){return v===b[i]})},rglwidgetClass.prototype.repeatToLen=function(arr,len){for(arr=[].concat(arr);arr.length=-windHeight&&rect.left>=-windWidth&&rect.bottom<=2*windHeight&&rect.right<=2*windWidth},rglwidgetClass.prototype.keydiff=function(obj1,obj2){var i,keys=Object.keys(obj1),result=[];for(i=0;i-1},rglwidgetClass.prototype.translateCoords=function(subsceneid,coords){var viewport=this.getObj(subsceneid).par3d.viewport;return{x:coords.x-viewport.x*this.canvas.width,y:coords.y-viewport.y*this.canvas.height}},rglwidgetClass.prototype.inViewport=function(coords,subsceneid){var viewport=this.getObj(subsceneid).par3d.viewport,x0=coords.x-viewport.x*this.canvas.width,y0=coords.y-viewport.y*this.canvas.height;return x0>=0&&x0<=viewport.width*this.canvas.width&&y0>=0&&y0<=viewport.height*this.canvas.height},rglwidgetClass.prototype.whichSubscene=function(coords){var self=this,recurse=function(subsceneid){var i,id,subscenes=self.getChildSubscenes(subsceneid);for(i=0;i-1&&(thesub.objects.splice(i,1),thelist=this.whichList(id),i=thesub[thelist].indexOf(id),thesub[thelist].splice(i,1))},rglwidgetClass.prototype.setSubsceneEntries=function(ids,subsceneid){var sub=this.getObj(subsceneid);sub.objects=ids,this.initSubscene(subsceneid)},rglwidgetClass.prototype.getSubsceneEntries=function(subscene){return this.getObj(subscene).objects},rglwidgetClass.prototype.getChildSubscenes=function(subscene){return this.getObj(subscene).subscenes},rglwidgetClass.prototype.useid=function(subsceneid,type){var sub=this.getObj(subsceneid);return"inherit"===sub.embeddings[type]?this.useid(sub.parent,type):subsceneid},rglwidgetClass.prototype.getVertexShader=function(id){var result,obj=this.getObj(id),userShader=obj.userVertexShader,flags=obj.flags,type=obj.type,is_lit=this.isSet(flags,this.f_is_lit),has_texture=this.isSet(flags,this.f_has_texture),fixed_quads=this.isSet(flags,this.f_fixed_quads),sprites_3d=this.isSet(flags,this.f_sprites_3d),nclipplanes=this.countClipplanes(),fixed_size=this.isSet(flags,this.f_fixed_size),is_points=this.isSet(flags,this.f_is_points),is_twosided=this.isSet(flags,this.f_is_twosided),fat_lines=this.isSet(flags,this.f_fat_lines),is_brush=this.isSet(flags,this.f_is_brush),has_fog=this.isSet(flags,this.f_has_fog),has_normals="undefined"!=typeof obj.normals,needs_vnormal=is_lit&&!fixed_quads&&!is_brush||is_twosided&&(has_normals||"spheres"===obj.type);if("clipplanes"!==type&&!sprites_3d){if("undefined"!=typeof userShader)return userShader;if(result=" /* ****** "+type+" object "+id+" vertex shader ****** */\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n#else\n precision mediump float;\n#endif\n#endif\n attribute vec3 aPos;\n attribute vec4 aCol;\n uniform mat4 mvMatrix;\n uniform mat4 prMatrix;\n varying vec4 vCol;\n varying vec4 vPosition;\n",needs_vnormal&&(result+=" attribute vec3 aNorm;\n uniform mat4 normMatrix;\n varying vec3 vNormal;\n"),(has_texture||"text"===type)&&(result+=" attribute vec2 aTexcoord;\n varying vec2 vTexcoord;\n"),fixed_size&&(result+=" uniform vec2 textScale;\n"),fixed_quads&&(result+=" attribute vec2 aOfs;\n"),is_twosided&&(result+=has_normals||"spheres"===obj.type?" varying float normz;\n":" attribute vec3 aPos1;\n attribute vec3 aPos2;\n varying float normz;\n"),fat_lines&&(result+=" attribute vec3 aNext;\n attribute vec2 aPoint;\n varying vec2 vPoint;\n varying float vLength;\n uniform float uAspect;\n uniform float uLwd;\n"),result+=" void main(void) {\n",!nclipplanes&&fixed_quads&&!has_fog||is_brush||(result+=" vPosition = mvMatrix * vec4(aPos, 1.);\n"),fixed_quads||is_brush||(result+=" gl_Position = prMatrix * vPosition;\n"),is_points){var size=this.getMaterial(id,"size");result=result+" gl_PointSize = "+size.toFixed(1)+";\n"}return result+=" vCol = aCol;\n",needs_vnormal&&(result+=" vNormal = normalize((normMatrix * vec4(aNorm, 1.)).xyz);\n"),(has_texture||"text"===type)&&(result+=" vTexcoord = aTexcoord;\n"),fixed_size&&(result+=" vec4 pos = prMatrix * mvMatrix * vec4(aPos, 1.);\n pos = pos/pos.w;\n gl_Position = pos + vec4(aOfs*textScale, 0.,0.);\n"),"sprites"!==type||fixed_size||(result+=" vec4 pos = mvMatrix * vec4(aPos, 1.);\n pos = pos/pos.w + vec4(aOfs, 0., 0.);\n gl_Position = prMatrix*pos;\n"),is_twosided&&(result+=has_normals||"spheres"===obj.type?" normz = vNormal.z;":" vec4 pos1 = prMatrix*(mvMatrix*vec4(aPos1, 1.));\n pos1 = pos1/pos1.w - gl_Position/gl_Position.w;\n vec4 pos2 = prMatrix*(mvMatrix*vec4(aPos2, 1.));\n pos2 = pos2/pos2.w - gl_Position/gl_Position.w;\n normz = pos1.x*pos2.y - pos1.y*pos2.x;\n"),fat_lines&&(result+=" vec2 aspectVec = vec2(uAspect, 1.0);\n mat4 projViewModel = prMatrix * mvMatrix;\n vec4 currentProjected = projViewModel * vec4(aPos, 1.0);\n currentProjected = currentProjected/currentProjected.w;\n vec4 nextProjected = projViewModel * vec4(aNext, 1.0);\n vec2 currentScreen = currentProjected.xy * aspectVec;\n vec2 nextScreen = (nextProjected.xy / nextProjected.w) * aspectVec;\n float len = uLwd;\n vec2 dir = vec2(1.0, 0.0);\n vPoint = aPoint;\n vLength = length(nextScreen - currentScreen)/2.0;\n vLength = vLength/(vLength + len);\n if (vLength > 0.0) {\n dir = normalize(nextScreen - currentScreen);\n }\n vec2 normal = vec2(-dir.y, dir.x);\n dir.x /= uAspect;\n normal.x /= uAspect;\n vec4 offset = vec4(len*(normal*aPoint.x*aPoint.y - dir), 0.0, 0.0);\n gl_Position = currentProjected + offset;\n"),is_brush&&(result+=" gl_Position = vec4(aPos, 1.);\n"),result+=" }\n"}},rglwidgetClass.prototype.getFragmentShader=function(id){var i,texture_format,nlights,result,obj=this.getObj(id),userShader=obj.userFragmentShader,flags=obj.flags,type=obj.type,is_lit=this.isSet(flags,this.f_is_lit),has_texture=this.isSet(flags,this.f_has_texture),fixed_quads=this.isSet(flags,this.f_fixed_quads),sprites_3d=this.isSet(flags,this.f_sprites_3d),is_twosided=this.isSet(flags,this.f_is_twosided),fat_lines=this.isSet(flags,this.f_fat_lines),is_transparent=this.isSet(flags,this.f_is_transparent),has_fog=this.isSet(flags,this.f_has_fog),nclipplanes=this.countClipplanes();if("clipplanes"!==type&&!sprites_3d){if("undefined"!=typeof userShader)return userShader;for(has_texture&&(texture_format=this.getMaterial(id,"textype")),result="/* ****** "+type+" object "+id+" fragment shader ****** */\n#ifdef GL_ES\n#ifdef GL_FRAGMENT_PRECISION_HIGH\n precision highp float;\n#else\n precision mediump float;\n#endif\n#endif\n varying vec4 vCol; // carries alpha\n varying vec4 vPosition;\n",(has_texture||"text"===type)&&(result+=" varying vec2 vTexcoord;\n uniform sampler2D uSampler;\n"),has_fog&&(result+=" uniform int uFogMode;\n uniform vec3 uFogColor;\n uniform vec4 uFogParms;\n"),is_lit&&!fixed_quads&&(result+=" varying vec3 vNormal;\n"),i=0;nclipplanes>i;i++)result=result+" uniform vec4 vClipplane"+i+";\n";if(is_lit&&(nlights=this.countLights(),nlights?result+=" uniform mat4 mvMatrix;\n":is_lit=!1),is_lit)for(result+=" uniform vec3 emission;\n uniform float shininess;\n",i=0;nlights>i;i++)result=result+" uniform vec3 ambient"+i+";\n uniform vec3 specular"+i+"; // light*material\n uniform vec3 diffuse"+i+";\n uniform vec3 lightDir"+i+";\n uniform bool viewpoint"+i+";\n uniform bool finite"+i+";\n";for(is_twosided&&(result+=" uniform bool front;\n varying float normz;\n"),fat_lines&&(result+=" varying vec2 vPoint;\n varying float vLength;\n"),result+=" void main(void) {\n vec4 fragColor;\n",fat_lines&&(result+=" vec2 point = vPoint;\n bool neg = point.y < 0.0;\n point.y = neg ? (point.y + vLength)/(1.0 - vLength) :\n -(point.y - vLength)/(1.0 - vLength);\n",is_transparent&&"linestrip"===type&&(result+=" if (neg && length(point) <= 1.0) discard;\n"),result+=" point.y = min(point.y, 0.0);\n if (length(point) > 1.0) discard;\n"),i=0;nclipplanes>i;i++)result=result+" if (dot(vPosition, vClipplane"+i+") < 0.0) discard;\n";if(fixed_quads?result+=" vec3 n = vec3(0., 0., 1.);\n":is_lit&&(result+=" vec3 n = normalize(vNormal);\n"),is_twosided&&(result+=" if ((normz <= 0.) != front) discard;\n"),is_lit)for(result+=" vec3 eye = normalize(-vPosition.xyz);\n vec3 lightdir;\n vec4 colDiff;\n vec3 halfVec;\n vec4 lighteffect = vec4(emission, 0.);\n vec3 col;\n float nDotL;\n",fixed_quads||(result+=" n = -faceforward(n, n, eye);\n"),i=0;nlights>i;i++)result=result+" colDiff = vec4(vCol.rgb * diffuse"+i+", vCol.a);\n lightdir = lightDir"+i+";\n if (!viewpoint"+i+")\n lightdir = (mvMatrix * vec4(lightdir, 1.)).xyz;\n if (!finite"+i+") {\n halfVec = normalize(lightdir + eye);\n } else {\n lightdir = normalize(lightdir - vPosition.xyz);\n halfVec = normalize(lightdir + eye);\n }\n col = ambient"+i+";\n nDotL = dot(n, lightdir);\n col = col + max(nDotL, 0.) * colDiff.rgb;\n col = col + pow(max(dot(halfVec, n), 0.), shininess) * specular"+i+";\n lighteffect = lighteffect + vec4(col, colDiff.a);\n";else result+=" vec4 colDiff = vCol;\n vec4 lighteffect = colDiff;\n";return"text"===type&&(result+=" vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);\n"),has_texture?result=result+{rgb:" vec4 textureColor = lighteffect*vec4(texture2D(uSampler, vTexcoord).rgb, 1.);\n",rgba:" vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);\n",alpha:" vec4 textureColor = texture2D(uSampler, vTexcoord);\n float luminance = dot(vec3(1.,1.,1.), textureColor.rgb)/3.;\n textureColor = vec4(lighteffect.rgb, lighteffect.a*luminance);\n",luminance:" vec4 textureColor = vec4(lighteffect.rgb*dot(texture2D(uSampler, vTexcoord).rgb, vec3(1.,1.,1.))/3., lighteffect.a);\n","luminance.alpha":" vec4 textureColor = texture2D(uSampler, vTexcoord);\n float luminance = dot(vec3(1.,1.,1.),textureColor.rgb)/3.;\n textureColor = vec4(lighteffect.rgb*luminance, lighteffect.a*textureColor.a);\n"}[texture_format]+" fragColor = textureColor;\n":result+="text"===type?" if (textureColor.a < 0.1)\n discard;\n else\n fragColor = textureColor;\n":" fragColor = lighteffect;\n",result+=has_fog?" float fogF;\n if (uFogMode > 0) {\n fogF = (uFogParms.y - vPosition.z/vPosition.w)/(uFogParms.y - uFogParms.x);\n if (uFogMode > 1)\n fogF = mix(uFogParms.w, 1.0, fogF);\n fogF = fogF*uFogParms.z;\n if (uFogMode == 2)\n fogF = 1.0 - exp(-fogF);\n else if (uFogMode == 3)\n fogF = 1.0 - exp(-fogF*fogF);\n fogF = clamp(fogF, 0.0, 1.0);\n gl_FragColor = vec4(mix(fragColor.rgb, uFogColor, fogF), fragColor.a);\n } else gl_FragColor = fragColor;\n":" gl_FragColor = fragColor;\n",result+=" }\n"}},rglwidgetClass.prototype.getShader=function(shaderType,code){var shader,gl=this.gl;return shader=gl.createShader(shaderType),gl.shaderSource(shader,code),gl.compileShader(shader),gl.getShaderParameter(shader,gl.COMPILE_STATUS)||gl.isContextLost()||alert(gl.getShaderInfoLog(shader)),shader},rglwidgetClass.prototype.handleLoadedTexture=function(texture,textureCanvas){var gl=this.gl||this.initGL();gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,!0),gl.bindTexture(gl.TEXTURE_2D,texture),gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,textureCanvas),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.LINEAR),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR_MIPMAP_NEAREST),gl.generateMipmap(gl.TEXTURE_2D),gl.bindTexture(gl.TEXTURE_2D,null)},rglwidgetClass.prototype.getMaxTexSize=function(){var gl=this.gl||this.initGL();return Math.min(4096,gl.getParameter(gl.MAX_TEXTURE_SIZE))},rglwidgetClass.prototype.loadImageToTexture=function(uri,texture){var canvas=this.textureCanvas,ctx=canvas.getContext("2d"),image=new Image,self=this;image.onload=function(){for(var w=image.width,h=image.height,canvasX=self.getPowerOfTwo(w),canvasY=self.getPowerOfTwo(h),maxTexSize=self.getMaxTexSize();canvasX>1&&canvasY>1&&(canvasX>maxTexSize||canvasY>maxTexSize);)canvasX/=2,canvasY/=2;canvas.width=canvasX,canvas.height=canvasY,ctx.imageSmoothingEnabled=!0,ctx.drawImage(image,0,0,canvasX,canvasY),self.handleLoadedTexture(texture,canvas),self.drawScene()},image.src=uri},rglwidgetClass.prototype.drawTextToCanvas=function(text,cex,family,font){var canvasX,canvasY,i,width,offsetx,line,scaling=20,textColour="white",backgroundColour="rgba(0,0,0,0)",canvas=this.textureCanvas,ctx=canvas.getContext("2d"),textHeight=0,textHeights=[],widths=[],offsety=0,lines=[],offsetsx=[],offsetsy=[],lineoffsetsy=[],fontStrings=[],maxTexSize=this.getMaxTexSize(),getFontString=function(i){textHeights[i]=scaling*cex[i];var fontString=textHeights[i]+"px",family0=family[i],font0=font[i];return"sans"===family0?family0="sans-serif":"mono"===family0&&(family0="monospace"),fontString=fontString+" "+family0,(2===font0||4===font0)&&(fontString="bold "+fontString),(3===font0||4===font0)&&(fontString="italic "+fontString),fontString};for(cex=this.repeatToLen(cex,text.length),family=this.repeatToLen(family,text.length),font=this.repeatToLen(font,text.length),canvasX=1,line=-1,offsetx=maxTexSize,i=0;imaxTexSize&&(offsety+=2*textHeight,line>=0&&(lineoffsetsy[line]=offsety),line+=1,offsety>maxTexSize&&console.error("Too many strings for texture."),textHeight=0,offsetx=0),textHeight=Math.max(textHeight,textHeights[i]),offsetsx[i]=offsetx,offsetx+=width,canvasX=Math.max(canvasX,offsetx),lines[i]=line;for(offsety=lineoffsetsy[line]=offsety+2*textHeight,i=0;i=radius&&(radius=1);var hlen,observer=subscene.par3d.observer,distance=observer[2],FOV=subscene.par3d.FOV,ortho=0===FOV,t=ortho?1:Math.tan(FOV*Math.PI/360),near=distance-radius,far=distance+radius,aspect=this.vp.width/this.vp.height,z=subscene.par3d.zoom,userProjection=subscene.par3d.userProjection;0>far&&(far=1),far/100>near&&(near=far/100),this.frustum={near:near,far:far},hlen=t*near,ortho?aspect>1?this.prMatrix.ortho(-hlen*aspect*z,hlen*aspect*z,-hlen*z,hlen*z,near,far):this.prMatrix.ortho(-hlen*z,hlen*z,-hlen*z/aspect,hlen*z/aspect,near,far):aspect>1?this.prMatrix.frustum(-hlen*aspect*z,hlen*aspect*z,-hlen*z,hlen*z,near,far):this.prMatrix.frustum(-hlen*z,hlen*z,-hlen*z/aspect,hlen*z/aspect,near,far),this.prMatrix.multRight(userProjection)}},rglwidgetClass.prototype.setmvMatrix=function(id){var observer=this.getObj(id).par3d.observer;this.mvMatrix.makeIdentity(),this.setmodelMatrix(id),this.mvMatrix.translate(-observer[0],-observer[1],-observer[2])},rglwidgetClass.prototype.setmodelMatrix=function(id){var subscene=this.getObj(id),embedding=subscene.embeddings.model;if("inherit"!==embedding){var scale=subscene.par3d.scale,bbox=subscene.par3d.bbox,center=[(bbox[0]+bbox[1])/2,(bbox[2]+bbox[3])/2,(bbox[4]+bbox[5])/2];this.mvMatrix.translate(-center[0],-center[1],-center[2]),this.mvMatrix.scale(scale[0],scale[1],scale[2]),this.mvMatrix.multRight(subscene.par3d.userMatrix)}"replace"!==embedding&&this.setmodelMatrix(subscene.parent)},rglwidgetClass.prototype.setnormMatrix=function(subsceneid){var self=this,recurse=function(id){var sub=self.getObj(id),embedding=sub.embeddings.model;if("inherit"!==embedding){var scale=sub.par3d.scale;self.normMatrix.scale(1/scale[0],1/scale[1],1/scale[2]),self.normMatrix.multRight(sub.par3d.userMatrix)}"replace"!==embedding&&recurse(sub.parent)};self.normMatrix.makeIdentity(),recurse(subsceneid)},rglwidgetClass.prototype.setprmvMatrix=function(){this.prmvMatrix=new CanvasMatrix4(this.mvMatrix),this.prmvMatrix.multRight(this.prMatrix)},rglwidgetClass.prototype.getCursor=function(mode){switch(mode){case"none":return"none";case"trackball":case"xAxis":case"yAxis":case"zAxis":case"polar":return"grab";case"selecting":return"crosshair";case"fov":case"zoom":return"zoom-in"}return"dragging"},rglwidgetClass.prototype.setMouseMode=function(mode,button,subscene,stayActive){var sub=this.getObj(subscene),which=["left","right","middle"][button-1];stayActive||"selecting"!==sub.par3d.mouseMode[which]||this.clearBrush(null),sub.par3d.mouseMode[which]=mode,1===button&&(this.canvas.style.cursor=this.getCursor(mode))},rglwidgetClass.prototype.relMouseCoords=function(event){var rect=this.canvas.getBoundingClientRect();return{x:event.clientX-rect.left,y:event.clientY-rect.top}},rglwidgetClass.prototype.recordSelection=function(subid){var result={};"undefined"!=typeof this.select&&"undefined"!=typeof this.select.state&&"inactive"!==this.select.state?(result={subscene:subid,state:this.select.state,region:this.select.region},this.setmvMatrix(subid),result.model=this.mvMatrix,this.setprMatrix(subid),result.proj=this.prMatrix,this.getViewport(subid),result.view=this.vp):result.state="inactive",Shiny.setInputValue(this.scene.selectionInput+":shinyMouse3d",result)},rglwidgetClass.prototype.setMouseHandlers=function(){var activeSubscene,handler,self=this,handlers={},drag=0;handlers.rotBase=0,this.screenToVector=function(x,y){var viewport=this.getObj(activeSubscene).par3d.viewport,width=viewport.width*this.canvas.width,height=viewport.height*this.canvas.height,radius=Math.max(width,height)/2,cx=width/2,cy=height/2,px=(x-cx)/radius,py=(y-cy)/radius,plen=Math.sqrt(px*px+py*py);plen>1e-6&&(px/=plen,py/=plen);var angle=(Math.SQRT2-plen)/Math.SQRT2*Math.PI/2,z=Math.sin(angle),zlen=Math.sqrt(1-z*z);return px*=zlen,py*=zlen,[px,py,z]},handlers.trackballdown=function(x,y){var i,activeSub=this.getObj(activeSubscene),activeModel=this.getObj(this.useid(activeSub.id,"model")),l=activeModel.par3d.listeners;for(handlers.rotBase=this.screenToVector(x,y),this.saveMat=[],i=0;ij;j++)changepos[j]=-(dragCurrent[j]-handlers.dragBase[j]);activeSub.par3d.userMatrix.makeIdentity(),activeSub.par3d.userMatrix.rotate(180*changepos[0]/Math.PI,0,-1,0),activeSub.par3d.userMatrix.multRight(objects[l[i]].saveMat),activeSub.par3d.userMatrix.rotate(180*changepos[1]/Math.PI,-1,0,0)}this.drawScene()},handlers.polarend=0,handlers.axisdown=function(x){handlers.rotBase=this.screenToVector(x,this.canvas.height/2);var i,activeSub=this.getObj(activeSubscene),activeModel=this.getObj(this.useid(activeSub.id,"model")),l=activeModel.par3d.listeners;for(i=0;i0?del:1/del;handlers.setZoom(ds),ev.preventDefault()},handlers.get_finger_dist=function(ev){var diffX=ev.touches[0].clientX-ev.touches[1].clientX,diffY=ev.touches[0].clientY-ev.touches[1].clientY;return Math.sqrt(diffX*diffX+diffY*diffY)},handlers.touchstart=function(ev){var touch=ev.touches[0],mouseEvent=new MouseEvent("mousedown",{clientX:touch.clientX,clientY:touch.clientY});if(ev.preventDefault(),2===ev.touches.length){var coords=self.relMouseCoords(touch);coords.y=self.canvas.height-coords.y,activeSubscene=self.whichSubscene(coords),handlers.finger_dist0=handlers.get_finger_dist(ev),handlers.zoomdown(coords.x,coords.y)}this.dispatchEvent(mouseEvent)},handlers.touchend=function(ev){var mouseEvent;ev.preventDefault(),1===ev.touches.length&&(mouseEvent=new MouseEvent("mouseup",{}),this.dispatchEvent(mouseEvent))},handlers.touchmove=function(ev){var mouseEvent,touch=ev.touches[0];if(ev.preventDefault(),ev.touches.length>1){var coords=self.relMouseCoords(touch),new_dist=handlers.get_finger_dist(ev);coords.y=self.canvas.height*Math.log(handlers.finger_dist0/new_dist)+handlers.y0zoom,handlers.zoommove(coords.x,coords.y)}else mouseEvent=new MouseEvent("mousemove",{clientX:touch.clientX,clientY:touch.clientY}),this.dispatchEvent(mouseEvent)},this.canvas.addEventListener("DOMMouseScroll",handlers.wheelHandler,!1),this.canvas.addEventListener("mousewheel",handlers.wheelHandler,!1),this.canvas.addEventListener("touchstart",handlers.touchstart,{passive:!1}),this.canvas.addEventListener("touchend",handlers.touchend,{passive:!1}),this.canvas.addEventListener("touchmove",handlers.touchmove,{passive:!1})},rglwidgetClass.prototype.initGL0=function(){return window.WebGLRenderingContext?void 0:void alert("Your browser does not support WebGL. See http://get.webgl.org")},rglwidgetClass.prototype.initGL=function(){var self=this;if(this.gl){if(this.drawing||!this.gl.isContextLost())return this.gl;this.restartCanvas()}this.canvas.addEventListener("webglcontextrestored",this.onContextRestored,!1),this.canvas.addEventListener("webglcontextlost",this.onContextLost,!1),this.gl=this.canvas.getContext("webgl",this.webGLoptions)||this.canvas.getContext("experimental-webgl",this.webGLoptions),this.index_uint=this.gl.getExtension("OES_element_index_uint");var save=this.startDrawing();return Object.keys(this.scene.objects).forEach(function(key){self.initObj(parseInt(key,10))}),this.stopDrawing(save),this.gl},rglwidgetClass.prototype.resize=function(el){this.canvas.width=el.width,this.canvas.height=el.height},rglwidgetClass.prototype.initSphere=function(){var result,verts=this.scene.sphereVerts,reuse=verts.reuse;if("undefined"!=typeof reuse){var prev=document.getElementById(reuse).rglinstance.sphere;result={values:prev.values,vOffsets:prev.vOffsets,it:prev.it,centers:prev.centers,vertexCount:prev.vertexCount,f:prev.f,indices:prev.indices}}else{var i,j,k,n=verts.it[0].length,centers=new Array(n);for(i=0;n>i;i++)for(centers[i]=[0,0,0],j=0;3>j;j++)for(k=0;3>k;k++)centers[i][j]+=verts.vb[j][verts.it[k][i]]/3;result={values:new Float32Array(this.flatten(this.cbind(this.transpose(verts.vb),this.transpose(verts.texcoords)))),it:new Uint16Array(this.flatten(this.transpose(verts.it))),vOffsets:{vofs:0,cofs:-1,nofs:0,radofs:-1,oofs:-1,tofs:3,nextofs:-1,pointofs:-1,stride:5},centers:centers},result.vertexCount=verts.vb[0].length,result.f=[],result.indices={}}result.colorCount=1,result.type="sphere",this.sphere=result,this.initSphereGL()},rglwidgetClass.prototype.initSphereGL=function(){var gl=this.gl||this.initGL(),sphere=this.sphere;gl.isContextLost()||(sphere.buf=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,sphere.buf),gl.bufferData(gl.ARRAY_BUFFER,sphere.values,gl.STATIC_DRAW),sphere.ibuf=[gl.createBuffer(),gl.createBuffer()])},rglwidgetClass.prototype.initSphereFromObj=function(obj){var i,pass,f,mode,sphere=this.sphere;if(sphere.ofsLoc=obj.ofsLoc,sphere.texLoc=obj.texLoc,sphere.sampler=obj.sampler,sphere.uFogMode=obj.uFogMode,sphere.uFogColor=obj.uFogColor,sphere.uFogParms=obj.uFogParms,sphere.userAttribLocations=obj.userAttribLocations,sphere.userUniformLocations=obj.userUniformLocations,sphere.normLoc=obj.normLoc,sphere.clipLoc=obj.clipLoc,sphere.nextLoc=obj.nextLoc,sphere.pointLoc=obj.pointLoc,sphere.aspectLoc=obj.aspectLoc,sphere.lwdLoc=obj.lwdLoc,sphere.prog=obj.prog,sphere.material=obj.material,sphere.flags=obj.flags,sphere.someHidden=obj.someHidden,sphere.fastTransparency=obj.fastTransparency,sphere.nlights=obj.nlights,sphere.emission=obj.emission,sphere.emissionLoc=obj.emissionLoc,sphere.shininess=obj.shininess,sphere.shininessLoc=obj.shininessLoc,sphere.ambient=obj.ambient,sphere.ambientLoc=obj.ambientLoc,sphere.specular=obj.specular,sphere.specularLoc=obj.specularLoc,sphere.diffuse=obj.diffuse,sphere.diffuseLoc=obj.diffuseLoc,sphere.lightDir=obj.lightDir,sphere.lightDirLoc=obj.lightDirLoc,sphere.viewpoint=obj.viewpoint,sphere.viewpointLoc=obj.viewpointLoc,sphere.finite=obj.finite,sphere.finiteLoc=obj.finiteLoc,sphere.prMatLoc=obj.prMatLoc,sphere.mvMatLoc=obj.mvMatLoc,sphere.normMatLoc=obj.normMatLoc,sphere.frontLoc=obj.frontLoc,sphere.index_uint=!1,sphere.is_transparent=obj.is_transparent,sphere.ignoreExtent=obj.ignoreExtent,sphere.passes!==obj.passes||JSON.stringify(sphere.pmode)!==JSON.stringify(obj.pmode))for(sphere.passes=obj.passes,sphere.pmode=obj.pmode,pass=0;pass=0),is_brush&&this.initSelection(id),"undefined"==typeof obj.vertices&&(obj.vertices=[]),v=obj.vertices,obj.vertexCount=v.length,obj.vertexCount){if(is_twosided&&!has_normals){if("undefined"==typeof obj.userAttributes&&(obj.userAttributes={}),v1=Array(v.length),v2=Array(v.length),"triangles"===obj.type||"quads"===obj.type)for(nrow="triangles"===obj.type?3:4,i=0;ij;j++)v1[nrow*i+j]=v[nrow*i+(j+1)%nrow],v2[nrow*i+j]=v[nrow*i+(j+2)%nrow];else if("surface"===obj.type)for(dim=obj.dim[0],nx=dim[0],nz=dim[1],j=0;nx>j;j++)for(i=0;nz>i;i++)nz>i+1&&nx>j+1?(v2[j+nx*i]=v[j+nx*(i+1)],v1[j+nx*i]=v[j+1+nx*(i+1)]):nz>i+1?(v2[j+nx*i]=v[j-1+nx*i],v1[j+nx*i]=v[j+nx*(i+1)]):(v2[j+nx*i]=v[j+nx*(i-1)],v1[j+nx*i]=v[j-1+nx*(i-1)]);obj.userAttributes.aPos1=v1,obj.userAttributes.aPos2=v2}if(!sprites_3d){if(gl.isContextLost())return;obj.prog=gl.createProgram(),gl.attachShader(obj.prog,this.getShader(gl.VERTEX_SHADER,this.getVertexShader(id))),gl.attachShader(obj.prog,this.getShader(gl.FRAGMENT_SHADER,this.getFragmentShader(id))),gl.bindAttribLocation(obj.prog,0,"aPos"),gl.bindAttribLocation(obj.prog,1,"aCol"),gl.linkProgram(obj.prog);var linked=gl.getProgramParameter(obj.prog,gl.LINK_STATUS);if(!linked){var lastError=gl.getProgramInfoLog(obj.prog);return console.warn("Error in program linking:"+lastError),void gl.deleteProgram(obj.prog)}}"text"===type&&(texinfo=this.drawTextToCanvas(obj.texts,this.flatten(obj.cex),this.flatten(obj.family),this.flatten(obj.family))),fixed_quads&&!sprites_3d&&(obj.ofsLoc=gl.getAttribLocation(obj.prog,"aOfs")),(has_texture||"text"===type)&&(obj.texture||(obj.texture=gl.createTexture()),obj.texLoc=gl.getAttribLocation(obj.prog,"aTexcoord"),obj.sampler=gl.getUniformLocation(obj.prog,"uSampler")),has_fog&&!sprites_3d&&(obj.uFogMode=gl.getUniformLocation(obj.prog,"uFogMode"),obj.uFogColor=gl.getUniformLocation(obj.prog,"uFogColor"),obj.uFogParms=gl.getUniformLocation(obj.prog,"uFogParms")),has_texture&&(mat=obj.material,"undefined"!=typeof mat.uri?uri=mat.uri:"undefined"==typeof mat.uriElementId?(matobj=this.getObj(mat.uriId),uri="undefined"!=typeof matobj?matobj.material.uri:""):uri=document.getElementById(mat.uriElementId).rglinstance.getObj(mat.uriId).material.uri,this.loadImageToTexture(uri,obj.texture)),"text"===type&&this.handleLoadedTexture(obj.texture,this.textureCanvas);var nc,cofs,nofs,radofs,oofs,tofs,vnew,fnew,alias,colors,key,selection,filter,adj,pos,offset,attr,last,options,stride=3,nextofs=-1,pointofs=-1;if(obj.alias=void 0,colors=obj.colors,j=this.scene.crosstalk.id.indexOf(id),j>=0){for(key=this.scene.crosstalk.key[j],options=this.scene.crosstalk.options[j],colors=colors.slice(0),i=0;i1?(cofs=stride,stride+=4,v=this.cbind(v,colors)):(cofs=-1,obj.onecolor=this.flatten(colors)),has_normals?(nofs=stride,stride+=3,v=this.cbind(v,"undefined"!=typeof obj.pnormals?obj.pnormals:obj.normals)):nofs=-1,"undefined"!=typeof obj.radii?(radofs=stride,stride+=1,obj.radii.length===v.length?v=this.cbind(v,obj.radii):1===obj.radii.length&&(v=v.map(function(row){return row.concat(obj.radii[0])}))):radofs=-1,f=Array(v.length),i=0;ij;j++)v1=vnew[fnew[4*i+j]],v1[tofs+2]=2*(v1[tofs]-v1[tofs+2])*texinfo.widths[i],v1[tofs+3]=2*(v1[tofs+1]-v1[tofs+3])*texinfo.textHeights[i],v1[tofs]=(texinfo.offsetsx[i]+v1[tofs]*texinfo.widths[i])/texinfo.canvasX,v1[tofs+1]=1-(texinfo.offsetsy[i]-v1[tofs+1]*texinfo.textHeights[i])/texinfo.canvasY,vnew[fnew[4*i+j]]=v1;v=vnew,obj.vertexCount=v.length,obj.f=[fnew,fnew]}else"undefined"!=typeof obj.texcoords?(tofs=stride,stride+=2,oofs=-1,v=this.cbind(v,obj.texcoords)):(tofs=-1,oofs=-1);else{tofs=stride,stride+=2,oofs=stride,stride+=2,vnew=new Array(4*v.length),fnew=new Array(4*v.length),alias=new Array(v.length);var rescale=fixed_size?72:1,size=obj.radii,s=rescale*size[0]/2;for(last=v.length,f=obj.f[0],i=0;i1&&(s=rescale*size[i]/2),vnew[i]=v[i].concat([0,0,-s,-s]),fnew[4*i]=f[i],vnew[last]=v[i].concat([1,0,s,-s]),fnew[4*i+1]=last++,vnew[last]=v[i].concat([1,1,s,s]),fnew[4*i+2]=last++,vnew[last]=v[i].concat([0,1,-s,s]),fnew[4*i+3]=last++,alias[i]=[last-3,last-2,last-1];v=vnew,obj.vertexCount=v.length,obj.f=[fnew,fnew]}if(obj.alias=alias,"undefined"!=typeof obj.userAttributes){obj.userAttribOffsets={},obj.userAttribLocations={},obj.userAttribSizes={};for(attr in obj.userAttributes)obj.userAttribLocations[attr]=gl.getAttribLocation(obj.prog,attr),obj.userAttribLocations[attr]>=0&&(obj.userAttribOffsets[attr]=stride,v=this.cbind(v,obj.userAttributes[attr]),stride=v[0].length,obj.userAttribSizes[attr]=stride-obj.userAttribOffsets[attr])}if("undefined"!=typeof obj.userUniforms){obj.userUniformLocations={};for(attr in obj.userUniforms)obj.userUniformLocations[attr]=gl.getUniformLocation(obj.prog,attr)}if(sprites_3d)for(obj.userMatrix=new CanvasMatrix4(obj.usermatrix),obj.objects=this.flatten([].concat(obj.ids)),is_lit=!1,i=0;ii;i++)obj.clipLoc[i]=gl.getUniformLocation(obj.prog,"vClipplane"+i);if(is_lit)for(obj.emissionLoc=gl.getUniformLocation(obj.prog,"emission"),obj.emission=new Float32Array(this.stringToRgb(this.getMaterial(id,"emission"))),obj.shininessLoc=gl.getUniformLocation(obj.prog,"shininess"),obj.shininess=this.getMaterial(id,"shininess"),obj.nlights=this.countLights(),obj.ambientLoc=[],obj.ambient=new Float32Array(this.stringToRgb(this.getMaterial(id,"ambient"))),obj.specularLoc=[],obj.specular=new Float32Array(this.stringToRgb(this.getMaterial(id,"specular"))),obj.diffuseLoc=[],obj.lightDirLoc=[],obj.viewpointLoc=[],obj.finiteLoc=[],i=0;ii;i++)fnew[6*i]=f[3*i],fnew[6*i+1]=f[3*i+1],fnew[6*i+2]=f[3*i+1],fnew[6*i+3]=f[3*i+2],fnew[6*i+4]=f[3*i+2],fnew[6*i+5]=f[3*i]}else if("spheres"===type);else if("surface"===type)if(dim=obj.dim[0],nx=dim[0],nz=dim[1],"filled"===pmode)for(fnew=[],j=0;nx-1>j;j++)for(i=0;nz-1>i;i++)fnew.push(f[j+nx*i],f[j+nx*(i+1)],f[j+1+nx*(i+1)],f[j+nx*i],f[j+1+nx*(i+1)],f[j+1+nx*i]);else if("lines"===pmode)for(fnew=[],j=0;nx>j;j++)for(i=0;nz>i;i++)nz>i+1&&fnew.push(f[j+nx*i],f[j+nx*(i+1)]),nx>j+1&&fnew.push(f[j+nx*i],f[j+1+nx*i])}else if(nrows=Math.floor(obj.vertexCount/4),"filled"===pmode)for(fnew=Array(6*nrows),i=0;nrows>i;i++)fnew[6*i]=f[4*i],fnew[6*i+1]=f[4*i+1],fnew[6*i+2]=f[4*i+2],fnew[6*i+3]=f[4*i],fnew[6*i+4]=f[4*i+2],fnew[6*i+5]=f[4*i+3];else for(fnew=Array(8*nrows),i=0;nrows>i;i++)fnew[8*i]=f[4*i],fnew[8*i+1]=f[4*i+1],fnew[8*i+2]=f[4*i+1],fnew[8*i+3]=f[4*i+2],fnew[8*i+4]=f[4*i+2],fnew[8*i+5]=f[4*i+3],fnew[8*i+6]=f[4*i+3],fnew[8*i+7]=f[4*i];obj.f[pass]=fnew,drawtype=depth_sort?"DYNAMIC_DRAW":"STATIC_DRAW"}if(fat_lines){for(alias=void 0,obj.nextLoc=gl.getAttribLocation(obj.prog,"aNext"),obj.pointLoc=gl.getAttribLocation(obj.prog,"aPoint"),obj.aspectLoc=gl.getUniformLocation(obj.prog,"uAspect"),obj.lwdLoc=gl.getUniformLocation(obj.prog,"uLwd"),pass=0;passj;j++)vnew[k][nextofs+j]=vnew[f[i+1]][j];for(vnew[k][pointofs]=-1,vnew[k][pointofs+1]=-1,fnew[ind]=k,last++,vnew[last]=vnew[k].slice(),vnew[last][pointofs]=1,fnew[ind+1]=last,alias[f[i]].push(last-1,last),last++,k=last,vnew[k]=vnew[f[i+1]].slice(),j=0;3>j;j++)vnew[k][nextofs+j]=vnew[f[i]][j];vnew[k][pointofs]=-1,vnew[k][pointofs+1]=1,fnew[ind+2]=k,fnew[ind+3]=fnew[ind+1],last++,vnew[last]=vnew[k].slice(),vnew[last][pointofs]=1,fnew[ind+4]=last,fnew[ind+5]=fnew[ind+2],ind+=6,alias[f[i+1]].push(last-1,last)}if(vnew.length=last+1,v=vnew,obj.vertexCount=v.length,"undefined"!=typeof alias&&"undefined"!=typeof obj.alias){var oldalias=obj.alias,newalias=Array(obj.alias.length);for(i=0;i65535?this.index_uint?(obj.f[pass]=new Uint32Array(obj.f[pass]),obj.index_uint=!0):this.alertOnce("Object has "+obj.vertexCount+" vertices, not supported in this browser."):(obj.f[pass]=new Uint16Array(obj.f[pass]),obj.index_uint=!1);stride!==v[0].length&&this.alertOnce("problem in stride calculation"),obj.vOffsets={vofs:0,cofs:cofs,nofs:nofs,radofs:radofs,oofs:oofs,tofs:tofs,nextofs:nextofs,pointofs:pointofs,stride:stride},obj.values=new Float32Array(this.flatten(v)),"spheres"===type||sprites_3d||(obj.buf=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,obj.buf),gl.bufferData(gl.ARRAY_BUFFER,obj.values,gl.STATIC_DRAW),obj.ibuf=Array(obj.passes),obj.ibuf[0]=gl.createBuffer(),gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,obj.ibuf[0]),gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,obj.f[0],gl[drawtype]),is_twosided&&(obj.ibuf[1]=gl.createBuffer(),gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,obj.ibuf[1]),gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,obj.f[1],gl[drawtype]))),sprites_3d||(obj.mvMatLoc=gl.getUniformLocation(obj.prog,"mvMatrix"),obj.prMatLoc=gl.getUniformLocation(obj.prog,"prMatrix")),fixed_size&&(obj.textScaleLoc=gl.getUniformLocation(obj.prog,"textScale")),is_lit&&!sprites_3d&&(obj.normMatLoc=gl.getUniformLocation(obj.prog,"normMatrix")),is_twosided&&(obj.frontLoc=gl.getUniformLocation(obj.prog,"front"))}}},rglwidgetClass.prototype.initialize=function(el,x){if(this.textureCanvas=document.createElement("canvas"),this.textureCanvas.style.display="block",this.scene=x,this.normMatrix=new CanvasMatrix4,this.saveMat={},this.distance=null,this.posLoc=0,this.colLoc=1,el&&(el.rglinstance=this,this.el=el,this.webGLoptions=el.rglinstance.scene.webGLoptions,this.initCanvas()),"undefined"!=typeof Shiny){var self=this;Shiny.addCustomMessageHandler("shinyGetPar3d",function(message){var i,param,subscene=self.getObj(message.subscene),parameters=[].concat(message.parameters),result={tag:message.tag,subscene:message.subscene};if("undefined"!=typeof subscene)for(i=0;ii;i++)z=this.prmvMatrix.m13*obj.centers[i][0]+this.prmvMatrix.m23*obj.centers[i][1]+this.prmvMatrix.m33*obj.centers[i][2]+this.prmvMatrix.m43,w=this.prmvMatrix.m14*obj.centers[i][0]+this.prmvMatrix.m24*obj.centers[i][1]+this.prmvMatrix.m34*obj.centers[i][2]+this.prmvMatrix.m44,depth=z/w,result[i]={context:context,objid:objid,subid:subid,index:i,depth:depth};return result},rglwidgetClass.prototype.getSpherePieces=function(context,subid,obj){return obj.fastTransparency?0===subid?this.getPieces(context,obj.id,-1,obj):[]:this.getPieces(context,obj.id,subid,this.sphere)},rglwidgetClass.prototype.mergePieces=function(pieces){var result=[];if(pieces.length>0){var i,thiscontext=pieces[0].context,thisobjid=pieces[0].objid,thissubid=pieces[0].subid,indices=[];for(i=0;i0;)diff=c1.pop()-c2.pop();0===diff&&(diff=j.objid-i.objid),0===diff&&(diff=j.subid-i.subid)}return diff},result=[];return pieces.length&&(result=pieces.sort(compare)),result},rglwidgetClass.prototype.startDrawing=function(){var value=this.drawing;return this.drawing=!0,value},rglwidgetClass.prototype.stopDrawing=function(saved){this.drawing=saved,!saved&&this.gl&&this.gl.isContextLost()&&this.restartCanvas()},rglwidgetClass.prototype.planeUpdateTriangles=function(obj,bbox){var x,xrow,elem,A,d,nhits,i,j,k,u,v,w,intersect,which,v0,v2,vx,reverse,perms=[[0,0,1],[1,2,2],[2,1,0]],face1=[],face2=[],normals=[],nPlanes=obj.normals.length;for(obj.bbox=bbox,obj.vertices=[],obj.initialized=!1,elem=0;nPlanes>elem;elem++){for(x=[],A=obj.normals[elem],d=obj.offsets[elem][0],nhits=0,i=0;3>i;i++)for(j=0;2>j;j++)for(k=0;2>k;k++)u=perms[0][i],v=perms[1][i],w=perms[2][i],0!==A[w]&&(intersect=-(d+A[u]*bbox[j+2*u]+A[v]*bbox[k+2*v])/A[w],bbox[2*w]3)for(i=0;nhits-2>i;i++){for(which=0,j=i+1;nhits>j;j++)if(face1[i]===face1[j]||face1[i]===face2[j]||face2[i]===face1[j]||face2[i]===face2[j]){which=j;break}which>i+1&&(this.swap(x,i+1,which),this.swap(face1,i+1,which),this.swap(face2,i+1,which))}if(nhits>=3)for(v0=[x[0][0]-x[1][0],x[0][1]-x[1][1],x[0][2]-x[1][2]],v2=[x[2][0]-x[1][0],x[2][1]-x[1][1],x[2][2]-x[1][2]],vx=this.xprod(v0,v2),reverse=this.dotprod(vx,A)>0,i=0;nhits-2>i;i++)for(obj.vertices.push(x[0]),normals.push(A),j=1;3>j;j++)obj.vertices.push(x[i+(reverse?3-j:j)]),normals.push(A)}obj.pnormals=normals},rglwidgetClass.prototype.mode4type={points:"POINTS",linestrip:"LINE_STRIP",abclines:"LINES",lines:"LINES",sprites:"TRIANGLES",planes:"TRIANGLES",text:"TRIANGLES",quads:"TRIANGLES",surface:"TRIANGLES",triangles:"TRIANGLES",sphere:"TRIANGLES"},rglwidgetClass.prototype.disableArrays=function(obj,enabled){var i,attr,gl=this.gl||this.initGL(),objLocs=["normLoc","texLoc","ofsLoc","pointLoc","nextLoc"],thisLocs=["posLoc","colLoc"];for(i=0;i=0?(gl.enableVertexAttribArray(obj.normLoc),gl.vertexAttribPointer(obj.normLoc,3,gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.vOffsets.nofs),!0):!1},rglwidgetClass.prototype.doTexture=function(obj){var gl=this.gl,is_spheres="spheres"===obj.type;return gl.enableVertexAttribArray(obj.texLoc),is_spheres?gl.vertexAttribPointer(obj.texLoc,2,gl.FLOAT,!1,4*this.sphere.vOffsets.stride,4*this.sphere.vOffsets.tofs):gl.vertexAttribPointer(obj.texLoc,2,gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.vOffsets.tofs),gl.activeTexture(gl.TEXTURE0),gl.bindTexture(gl.TEXTURE_2D,obj.texture),gl.uniform1i(obj.sampler,0),!0},rglwidgetClass.prototype.doUserAttributes=function(obj){if("undefined"!=typeof obj.userAttributes){var gl=this.gl;for(var attr in obj.userAttribSizes)gl.enableVertexAttribArray(obj.userAttribLocations[attr]),gl.vertexAttribPointer(obj.userAttribLocations[attr],obj.userAttribSizes[attr],gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.userAttribOffsets[attr])}},rglwidgetClass.prototype.doUserUniforms=function(obj){if("undefined"!=typeof obj.userUniforms){var gl=this.gl;for(var attr in obj.userUniformLocations){var loc=obj.userUniformLocations[attr];if(null!==loc){var uniform=obj.userUniforms[attr];if("undefined"==typeof uniform.length)gl.uniform1f(loc,uniform);else if("undefined"==typeof uniform[0].length)switch(uniform=new Float32Array(uniform),uniform.length){case 2:gl.uniform2fv(loc,uniform);break;case 3:gl.uniform3fv(loc,uniform);break;case 4:gl.uniform4fv(loc,uniform);break;default:console.warn("bad uniform length")}else 4===uniform.length&&4===uniform[0].length?gl.uniformMatrix4fv(loc,!1,new Float32Array(uniform.getAsArray())):console.warn("unsupported uniform matrix")}}}},rglwidgetClass.prototype.doLoadIndices=function(obj,pass,indices){var fnew,step,gl=this.gl,f=obj.f[pass],type=obj.type,fat_lines=this.isSet(obj.flags,this.f_fat_lines);switch(type){case"points":step=1;break;case"abclines":case"lines":step=fat_lines?6:2;break;case"linestrip":step=fat_lines?6:1;break;case"sphere":case"planes":case"triangles":step=3;break;case"text":case"sprites":case"quads":case"surface":step=6;break;default:return console.error("loadIndices for "+type),0}fnew=obj.index_uint?new Uint32Array(step*indices.length):new Uint16Array(step*indices.length);for(var i=0;ij;j++)fnew[step*i+j]=f[step*indices[i]+j];return gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,fnew,gl.DYNAMIC_DRAW),fnew.length},rglwidgetClass.prototype.doMasking=function(mask){var gl=this.gl;gl.depthMask(mask)},rglwidgetClass.prototype.doBlending=function(blend){var gl=this.gl;blend?(gl.blendFuncSeparate(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA,gl.ONE,gl.ONE),gl.enable(gl.BLEND)):gl.disable(gl.BLEND)},rglwidgetClass.prototype.doFog=function(obj,subscene){var fogmode,color,gl=this.gl,observer=subscene.par3d.observer[2],sintheta=Math.sin(subscene.par3d.FOV*Math.PI/180/2),parms=[this.frustum.near-2*observer,this.frustum.far-2*observer,this.fogScale,(1-sintheta)/(1+sintheta)];switch("undefined"==typeof this.fogType&&(this.fogType="none"),"undefined"==typeof this.fogScale&&(parms[2]=1),0===sintheta&&(parms[3]=1/3),this.fogType){case"none":fogmode=0;break;case"linear":fogmode=1;break;case"exp":fogmode=2;break;case"exp2":fogmode=3;break;default:console.error("Unknown fogtype "+this.fogType)}gl.uniform1i(obj.uFogMode,fogmode),color=this.fogColor,gl.uniform3f(obj.uFogColor,color[0],color[1],color[2]),gl.uniform4f(obj.uFogParms,parms[0],parms[1],parms[2],parms[3])},rglwidgetClass.prototype.drawSimple=function(obj,subscene,context){var count,pass,mode,pmode,flags=obj.flags,type=obj.type,is_lit=this.isSet(flags,this.f_is_lit),has_texture=this.isSet(flags,this.f_has_texture),is_transparent=this.isSet(flags,this.f_is_transparent),fixed_size=this.isSet(flags,this.f_fixed_size),fixed_quads=this.isSet(flags,this.f_fixed_quads),is_lines=this.isSet(flags,this.f_is_lines),fat_lines=this.isSet(flags,this.f_fat_lines),is_twosided=this.isSet(flags,this.f_is_twosided),has_fog=this.isSet(flags,this.f_has_fog),gl=this.gl||this.initGL(),enabled={};if(obj.initialized||this.initObj(obj.id),count=obj.vertexCount,!count)return[];if(is_transparent=is_transparent||obj.someHidden,is_transparent&&this.opaquePass)return this.getPieces(context,obj.id,0,obj);for(this.doDepthTest(obj),this.doMasking(this.getObjMaterial(obj,"depth_mask")),gl.useProgram(obj.prog),this.doPolygonOffset(obj),gl.bindBuffer(gl.ARRAY_BUFFER,obj.buf),gl.uniformMatrix4fv(obj.prMatLoc,!1,new Float32Array(this.prMatrix.getAsArray())),gl.uniformMatrix4fv(obj.mvMatLoc,!1,new Float32Array(this.mvMatrix.getAsArray())),this.doClipping(obj,subscene),is_lit&&this.doLighting(obj,subscene),has_fog&&this.doFog(obj,subscene),this.doUserAttributes(obj),this.doUserUniforms(obj),gl.enableVertexAttribArray(this.posLoc),enabled.posLoc=!0,(has_texture||"text"===obj.type)&&(enabled.texLoc=this.doTexture(obj)),enabled.colLoc=this.doColors(obj),is_lit&&(enabled.normLoc=this.doNormals(obj)),fixed_size&&gl.uniform2f(obj.textScaleLoc,.75/this.vp.width,.75/this.vp.height),fixed_quads&&(gl.enableVertexAttribArray(obj.ofsLoc),enabled.ofsLoc=!0,gl.vertexAttribPointer(obj.ofsLoc,2,gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.vOffsets.oofs)),pass=0;passi;i++)sphereMV=new CanvasMatrix4,idx=this.opaquePass?i:obj.fastTransparency?indices[i]:context.subid,"undefined"==typeof idx&&console.error("idx is undefined"),baseofs=idx*obj.vOffsets.stride,ofs=baseofs+obj.vOffsets.radofs,sscale=obj.values[ofs],sphereMV.scale(sscale/scale[0],sscale/scale[1],sscale/scale[2]),sphereMV.translate(obj.values[baseofs],obj.values[baseofs+1],obj.values[baseofs+2]),sphereMV.multRight(saveMV),this.mvMatrix=sphereMV,this.setprmvMatrix(),drawing?(nc>1&&(this.sphere.onecolor=this.flatten(obj.sphereColors[idx%obj.sphereColors.length])),this.drawSimple(this.sphere,subscene,context)):result=result.concat(this.getSpherePieces(context,i,obj));return drawing&&this.disableArrays(obj,enabled),this.normMatrix=saveNorm,this.mvMatrix=saveMV,this.prmvMatrix=savePRMV,result},rglwidgetClass.prototype.drawClipplanes=function(obj){for(var count=obj.offsets.length,IMVClip=[],i=0;count>i;i++)IMVClip[i]=this.multMV(this.invMatrix,obj.vClipplane.slice(4*i,4*(i+1)));return obj.IMVClip=IMVClip,[]},rglwidgetClass.prototype.drawLinestrip=function(obj,subscene,context){var origIndices,i,j;if(this.opaquePass)return this.drawSimple(obj,subscene,context);for(origIndices=context.indices.slice(),i=0;iiOrig;iOrig++)for(j=this.opaquePass?iOrig:context.subid,pos=this.multVM([].concat(obj.vertices[j]).concat(1),origMV),radius=obj.radii.length>1?obj.radii[j][0]:obj.radii[0][0],this.mvMatrix=new CanvasMatrix4(userMatrix),this.mvMatrix.scale(radius),this.mvMatrix.translate(pos[0]/pos[3],pos[1]/pos[3],pos[2]/pos[3]),this.setprmvMatrix(),i=0;i0)for(this.invMatrix=new CanvasMatrix4(this.mvMatrix),this.invMatrix.invert(),i=0;i0;)switch(objid=context.pop(),obj=this.getObj(objid),type=obj.type){case"subscene":this.drawSubscene(objid,!1);break;case"sprites":result=result.concat(context.pop());break;case"spheres":break;default:console.error("bad type '",type,"' in setContext")}return result},rglwidgetClass.prototype.drawPieces=function(pieces){var i,context,prevcontext=[];for(this.doBlending(!0),i=0;i=i;i++)adds=adds.concat(control.subsets[i]);else adds=adds.concat(control.subsets[value]);for(deletes=fullset.filter(function(x){return adds.indexOf(x)<0}),i=0;ivalue-svals[j-1]&&(j-=1);break}if(obj=this.getObj(control.objid),"undefined"!=typeof obj.vOffsets){for(varies=!0,k=0;ncol>k;k++)if(attrib=attributes[k],"undefined"!=typeof attrib&&(ofs=obj.vOffsets[ofss[attrib]],0>ofs)){switch(attrib){case"alpha":case"red":case"green":case"blue":obj.colors=[obj.colors[0],obj.colors[0]]}varies=!1}varies||this.initObj(control.objid)}for(propvals=obj.values,aliases=obj.alias,"undefined"==typeof aliases&&(aliases=[]),k=0;ncol>k;k++)if(newval=direct?value:interp?p*values[j-1][k]+(1-p)*values[j][k]:values[j][k],attrib=attributes[k],vertex=vertices[k],alias=aliases[vertex],("planes"===obj.type||"clipplanes"===obj.type)&&(ofs=["nx","ny","nz","offset"].indexOf(attrib),ofs>=0))3>ofs?obj.normals[vertex][ofs]!==newval&&(obj.normals[vertex][ofs]=newval,obj.initialized=!1):obj.offsets[vertex][0]!==newval&&(obj.offsets[vertex][0]=newval,obj.initialized=!1);else if(ofs=obj.vOffsets[ofss[attrib]],0>ofs)this.alertOnce("Attribute '"+attrib+"' not found in object "+control.objid);else if(stride=obj.vOffsets.stride,ofs+=pos[attrib],entry=vertex*stride+ofs,propvals[entry]=newval,"undefined"!=typeof alias)for(a=0;ai;i++)if(null!==births[i]){for(age=time-births[i],j0=1;age>ages[j0];j0++);p[i]=1/0===ages[j0]?1:ages[j0]>ages[j0-1]?(ages[j0]-age)/(ages[j0]-ages[j0-1]):0,j[i]=j0}for(l=0;nobjs>l;l++)if(objid=objids[l],obj=this.getObj(objid),varies=!0,"undefined"!=typeof obj.vOffsets){for(k=0;kofs)){switch(attribs[k]){case"colors":case"alpha":case"red":case"green":case"blue":obj.colors=[obj.colors[0],obj.colors[0]]}varies=!1}varies||this.initObj(objid)}for(l=0;nobjs>l;l++)if(objid=objids[l],obj=this.getObj(objid),"undefined"!=typeof obj.vOffsets){for(aliases=obj.alias,"undefined"==typeof aliases&&(aliases=[]),propvals=obj.values,stride=obj.vOffsets.stride,k=0;k=0){for(dim=dims[k],ofs+=pos[k],i=0;steps>i;i++)if(alias=aliases[i],null!==births[i])for(d=0;dim>d;d++)if(propvals[i*stride+ofs+d]=p[i]*attrib[dim*(j[i]-1)+d]+(1-p[i])*attrib[dim*j[i]+d],"undefined"!=typeof alias)for(a=0;a=0){for(keys=this.scene.crosstalk.key[j],obj=this.getObj(id),someHidden=!1,k=0;k=xmin&&xmax>=x&&y>=ymin&&ymax>=y&&z>=-1&&1>=z?selection.push(keys[k]):someHidden=!0);obj.someHidden=someHidden&&(filter||selection.length),obj.initialized=!1,this.equalArrays(selection,this.scene.crosstalk.selection)||(handle=this.scene.crosstalk.sel_handle[j],handle.set(selection,{rglSubsceneId:this.select.subscene}))}},rglwidgetClass.prototype.selection=function(event,filter){var i,j,ids,obj,keys,selection,someHidden,crosstalk=this.scene.crosstalk;for(crosstalk=this.scene.crosstalk,filter?(filter=crosstalk.filter=event.value,selection=crosstalk.selection):(selection=crosstalk.selection=event.value,filter=crosstalk.filter),ids=crosstalk.id,i=0;ithis.stopTime+this.stepSize/2||this.value this.stopTime + this.stepSize/2 || this.value < this.startTime - this.stepSize/2) { - if (!this.loop) { - this.reset(); - } else { - var cycle = this.stopTime - this.startTime + this.stepSize, - newval = (this.value - this.startTime) % cycle + this.startTime; - if (newval < this.startTime) { - newval += cycle; - } - this.realStart += (this.value - newval)*1000/this.multiplier/this.rate; - this.value = newval; - } - } - }; - - /** - * Reset to start values - */ - rgltimerClass.prototype.reset = function() { - this.value = this.startTime; - this.newmultiplier(1); - if (typeof this.Tick !== "undefined") { - this.Tick(this.value); - } - if (this.enabled) - this.play(); /* really pause... */ - if (typeof this.PlayButton !== "undefined") - this.PlayButton.value = "Play"; - }; - - /** - * Increase the multiplier to play faster - */ - rgltimerClass.prototype.faster = function() { - this.newmultiplier(Math.SQRT2*this.multiplier); - }; - - /** - * Decrease the multiplier to play slower - */ - rgltimerClass.prototype.slower = function() { - this.newmultiplier(this.multiplier/Math.SQRT2); - }; - - /** - * Change sign of multiplier to reverse direction - */ - rgltimerClass.prototype.reverse = function() { - this.newmultiplier(-this.multiplier); - }; - - /** - * Set multiplier for play speed - * @param { number } newmult - new value - */ - rgltimerClass.prototype.newmultiplier = function(newmult) { - if (newmult !== this.multiplier) { - this.realStart += 1000*(this.value - this.startTime)/this.rate*(1/this.multiplier - 1/newmult); - this.multiplier = newmult; - } - }; - - /** - * Take one step - */ - rgltimerClass.prototype.step = function() { - this.value += this.rate*this.multiplier; - this.forceToRange(); - if (typeof this.Tick !== "undefined") - this.Tick(this.value); - }; diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/selection.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/selection.src.js deleted file mode 100644 index 4a63e52c..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/selection.src.js +++ /dev/null @@ -1,122 +0,0 @@ - - /** - * Respond to brush change - */ - rglwidgetClass.prototype.selectionChanged = function() { - var i, j, k, id, subid = this.select.subscene, subscene, - objids, obj, - p1 = this.select.region.p1, p2 = this.select.region.p2, - filter, selection = [], handle, keys, xmin, x, xmax, ymin, y, ymax, z, v, - someHidden; - if (!subid) - return; - subscene = this.getObj(subid); - objids = subscene.objects; - filter = this.scene.crosstalk.filter; - this.setmvMatrix(subid); - this.setprMatrix(subid); - this.setprmvMatrix(); - xmin = Math.min(p1.x, p2.x); - xmax = Math.max(p1.x, p2.x); - ymin = Math.min(p1.y, p2.y); - ymax = Math.max(p1.y, p2.y); - for (i = 0; i < objids.length; i++) { - id = objids[i]; - j = this.scene.crosstalk.id.indexOf(id); - if (j >= 0) { - keys = this.scene.crosstalk.key[j]; - obj = this.getObj(id); - someHidden = false; - for (k = 0; k < keys.length; k++) { - if (filter && filter.indexOf(keys[k]) < 0) { - someHidden = true; - continue; - } - v = [].concat(obj.vertices[k]).concat(1.0); - v = this.multVM(v, this.prmvMatrix); - x = v[0]/v[3]; - y = v[1]/v[3]; - z = v[2]/v[3]; - if (xmin <= x && x <= xmax && ymin <= y && y <= ymax && -1.0 <= z && z <= 1.0) { - selection.push(keys[k]); - } else - someHidden = true; - } - obj.someHidden = someHidden && (filter || selection.length); - obj.initialized = false; - /* Who should we notify? Only shared data in the current subscene, or everyone? */ - if (!this.equalArrays(selection, this.scene.crosstalk.selection)) { - handle = this.scene.crosstalk.sel_handle[j]; - handle.set(selection, {rglSubsceneId: this.select.subscene}); - } - } - } - }; - - /** - * Respond to selection or filter change from crosstalk - * @param { Object } event - crosstalk event - * @param { boolean } filter - filter or selection? - */ - rglwidgetClass.prototype.selection = function(event, filter) { - var i, j, ids, obj, keys, crosstalk = this.scene.crosstalk, - selection, someHidden; - - // Record the message and find out if this event makes some objects have mixed values: - - crosstalk = this.scene.crosstalk; - - if (filter) { - filter = crosstalk.filter = event.value; - selection = crosstalk.selection; - } else { - selection = crosstalk.selection = event.value; - filter = crosstalk.filter; - } - ids = crosstalk.id; - for (i = 0; i < ids.length ; i++) { - obj = this.getObj(ids[i]); - obj.initialized = false; - keys = crosstalk.key[i]; - someHidden = false; - for (j = 0; j < keys.length && !someHidden; j++) { - if ((filter && filter.indexOf(keys[j]) < 0) || - (selection.length && selection.indexOf(keys[j]) < 0)) - someHidden = true; - } - obj.someHidden = someHidden; - } - this.drawScene(); - }; - - /** - * Clear the selection brush - * @param { number } except - Subscene that should ignore this request - */ - rglwidgetClass.prototype.clearBrush = function(except) { - if (this.select.subscene !== except) { - this.select.region = {p1: {x:Infinity, y:Infinity}, - p2: {x:Infinity, y:Infinity}}; - this.selectionChanged(); - this.select.state = "inactive"; - this.delFromSubscene(this.scene.brushId, this.select.subscene); - } - this.drawScene(); - }; - - /** - * Set the vertices in the selection box object - */ - rglwidgetClass.prototype.initSelection = function(id) { - if (typeof this.select.region === "undefined") - return; - var obj = this.getObj(id), - p1 = this.select.region.p1, - p2 = this.select.region.p2; - - obj.vertices = [[p1.x, p1.y, 0.0], - [p2.x, p1.y, 0.0], - [p2.x, p2.y, 0.0], - [p1.x, p2.y, 0.0], - [p1.x, p1.y, 0.0]]; - }; diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/shaders.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/shaders.src.js deleted file mode 100644 index c3d3e1c6..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/shaders.src.js +++ /dev/null @@ -1,369 +0,0 @@ - - /** - * Generate the vertex shader for an object - * @returns {string} - * @param { number } id - Id of object - */ - rglwidgetClass.prototype.getVertexShader = function(id) { - var obj = this.getObj(id), - userShader = obj.userVertexShader, - flags = obj.flags, - type = obj.type, - is_lit = this.isSet(flags, this.f_is_lit), - has_texture = this.isSet(flags, this.f_has_texture), - fixed_quads = this.isSet(flags, this.f_fixed_quads), - sprites_3d = this.isSet(flags, this.f_sprites_3d), - nclipplanes = this.countClipplanes(), - fixed_size = this.isSet(flags, this.f_fixed_size), - is_points = this.isSet(flags, this.f_is_points), - is_twosided = this.isSet(flags, this.f_is_twosided), - fat_lines = this.isSet(flags, this.f_fat_lines), - is_brush = this.isSet(flags, this.f_is_brush), - has_fog = this.isSet(flags, this.f_has_fog), - has_normals = typeof obj.normals !== "undefined", - needs_vnormal = (is_lit && !fixed_quads && !is_brush) || (is_twosided && (has_normals || obj.type === "spheres")), - result; - - if (type === "clipplanes" || sprites_3d) return; - - if (typeof userShader !== "undefined") return userShader; - - result = " /* ****** "+type+" object "+id+" vertex shader ****** */\n"+ - "#ifdef GL_ES\n"+ - "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"+ - " precision highp float;\n"+ - "#else\n"+ - " precision mediump float;\n"+ - "#endif\n"+ - "#endif\n"+ - " attribute vec3 aPos;\n"+ - " attribute vec4 aCol;\n"+ - " uniform mat4 mvMatrix;\n"+ - " uniform mat4 prMatrix;\n"+ - " varying vec4 vCol;\n"+ - " varying vec4 vPosition;\n"; - - if (needs_vnormal) - result = result + " attribute vec3 aNorm;\n"+ - " uniform mat4 normMatrix;\n"+ - " varying vec3 vNormal;\n"; - - if (has_texture || type === "text") - result = result + " attribute vec2 aTexcoord;\n"+ - " varying vec2 vTexcoord;\n"; - - if (fixed_size) - result = result + " uniform vec2 textScale;\n"; - - if (fixed_quads) - result = result + " attribute vec2 aOfs;\n"; - - if (is_twosided) - if (has_normals || obj.type === "spheres") - result = result + " varying float normz;\n"; - else - result = result + " attribute vec3 aPos1;\n"+ - " attribute vec3 aPos2;\n"+ - " varying float normz;\n"; - - if (fat_lines) { - result = result + " attribute vec3 aNext;\n"+ - " attribute vec2 aPoint;\n"+ - " varying vec2 vPoint;\n"+ - " varying float vLength;\n"+ - " uniform float uAspect;\n"+ - " uniform float uLwd;\n"; - } - - result = result + " void main(void) {\n"; - - if ((nclipplanes || !fixed_quads || has_fog) && !is_brush) - result = result + " vPosition = mvMatrix * vec4(aPos, 1.);\n"; - - if (!fixed_quads && !is_brush) - result = result + " gl_Position = prMatrix * vPosition;\n"; - - if (is_points) { - var size = this.getMaterial(id, "size"); - result = result + " gl_PointSize = "+size.toFixed(1)+";\n"; - } - - result = result + " vCol = aCol;\n"; - - if (needs_vnormal) - result = result + " vNormal = normalize((normMatrix * vec4(aNorm, 1.)).xyz);\n"; - - if (has_texture || type === "text") - result = result + " vTexcoord = aTexcoord;\n"; - - if (fixed_size) - result = result + " vec4 pos = prMatrix * mvMatrix * vec4(aPos, 1.);\n"+ - " pos = pos/pos.w;\n"+ - " gl_Position = pos + vec4(aOfs*textScale, 0.,0.);\n"; - - if (type === "sprites" && !fixed_size) - result = result + " vec4 pos = mvMatrix * vec4(aPos, 1.);\n"+ - " pos = pos/pos.w + vec4(aOfs, 0., 0.);\n"+ - " gl_Position = prMatrix*pos;\n"; - - if (is_twosided) - if (has_normals || obj.type === "spheres") - result = result + " normz = vNormal.z;"; - else - result = result + " vec4 pos1 = prMatrix*(mvMatrix*vec4(aPos1, 1.));\n"+ - " pos1 = pos1/pos1.w - gl_Position/gl_Position.w;\n"+ - " vec4 pos2 = prMatrix*(mvMatrix*vec4(aPos2, 1.));\n"+ - " pos2 = pos2/pos2.w - gl_Position/gl_Position.w;\n"+ - " normz = pos1.x*pos2.y - pos1.y*pos2.x;\n"; - - if (fat_lines) - /* This code was inspired by Matt Deslauriers' code in https://mattdesl.svbtle.com/drawing-lines-is-hard */ - result = result + " vec2 aspectVec = vec2(uAspect, 1.0);\n"+ - " mat4 projViewModel = prMatrix * mvMatrix;\n"+ - " vec4 currentProjected = projViewModel * vec4(aPos, 1.0);\n"+ - " currentProjected = currentProjected/currentProjected.w;\n"+ - " vec4 nextProjected = projViewModel * vec4(aNext, 1.0);\n"+ - " vec2 currentScreen = currentProjected.xy * aspectVec;\n"+ - " vec2 nextScreen = (nextProjected.xy / nextProjected.w) * aspectVec;\n"+ - " float len = uLwd;\n"+ - " vec2 dir = vec2(1.0, 0.0);\n"+ - " vPoint = aPoint;\n"+ - " vLength = length(nextScreen - currentScreen)/2.0;\n"+ - " vLength = vLength/(vLength + len);\n"+ - " if (vLength > 0.0) {\n"+ - " dir = normalize(nextScreen - currentScreen);\n"+ - " }\n"+ - " vec2 normal = vec2(-dir.y, dir.x);\n"+ - " dir.x /= uAspect;\n"+ - " normal.x /= uAspect;\n"+ - " vec4 offset = vec4(len*(normal*aPoint.x*aPoint.y - dir), 0.0, 0.0);\n"+ - " gl_Position = currentProjected + offset;\n"; - - if (is_brush) - result = result + " gl_Position = vec4(aPos, 1.);\n"; - - result = result + " }\n"; - - // console.log(result); - return result; - }; - - /** - * Generate the fragment shader for an object - * @returns {string} - * @param { number } id - Id of object - */ - rglwidgetClass.prototype.getFragmentShader = function(id) { - var obj = this.getObj(id), - userShader = obj.userFragmentShader, - flags = obj.flags, - type = obj.type, - is_lit = this.isSet(flags, this.f_is_lit), - has_texture = this.isSet(flags, this.f_has_texture), - fixed_quads = this.isSet(flags, this.f_fixed_quads), - sprites_3d = this.isSet(flags, this.f_sprites_3d), - is_twosided = this.isSet(flags, this.f_is_twosided), - fat_lines = this.isSet(flags, this.f_fat_lines), - is_transparent = this.isSet(flags, this.f_is_transparent), - has_fog = this.isSet(flags, this.f_has_fog), - nclipplanes = this.countClipplanes(), i, - texture_format, nlights, - result; - - if (type === "clipplanes" || sprites_3d) return; - - if (typeof userShader !== "undefined") return userShader; - - if (has_texture) - texture_format = this.getMaterial(id, "textype"); - - result = "/* ****** "+type+" object "+id+" fragment shader ****** */\n"+ - "#ifdef GL_ES\n"+ - "#ifdef GL_FRAGMENT_PRECISION_HIGH\n"+ - " precision highp float;\n"+ - "#else\n"+ - " precision mediump float;\n"+ - "#endif\n"+ - "#endif\n"+ - " varying vec4 vCol; // carries alpha\n"+ - " varying vec4 vPosition;\n"; - - if (has_texture || type === "text") - result = result + " varying vec2 vTexcoord;\n"+ - " uniform sampler2D uSampler;\n"; - - if (has_fog) - result = result + " uniform int uFogMode;\n"+ - " uniform vec3 uFogColor;\n"+ - " uniform vec4 uFogParms;\n"; - - if (is_lit && !fixed_quads) - result = result + " varying vec3 vNormal;\n"; - - for (i = 0; i < nclipplanes; i++) - result = result + " uniform vec4 vClipplane"+i+";\n"; - - if (is_lit) { - nlights = this.countLights(); - if (nlights) - result = result + " uniform mat4 mvMatrix;\n"; - else - is_lit = false; - } - - if (is_lit) { - result = result + " uniform vec3 emission;\n"+ - " uniform float shininess;\n"; - - for (i=0; i < nlights; i++) { - result = result + " uniform vec3 ambient" + i + ";\n"+ - " uniform vec3 specular" + i +"; // light*material\n"+ - " uniform vec3 diffuse" + i + ";\n"+ - " uniform vec3 lightDir" + i + ";\n"+ - " uniform bool viewpoint" + i + ";\n"+ - " uniform bool finite" + i + ";\n"; - } - } - - if (is_twosided) - result = result + " uniform bool front;\n"+ - " varying float normz;\n"; - - if (fat_lines) - result = result + " varying vec2 vPoint;\n"+ - " varying float vLength;\n"; - - result = result + " void main(void) {\n"+ - " vec4 fragColor;\n"; - - if (fat_lines) { - result = result + " vec2 point = vPoint;\n"+ - " bool neg = point.y < 0.0;\n"+ - " point.y = neg ? "+ - " (point.y + vLength)/(1.0 - vLength) :\n"+ - " -(point.y - vLength)/(1.0 - vLength);\n"; - if (is_transparent && type === "linestrip") - result = result+" if (neg && length(point) <= 1.0) discard;\n"; - result = result + " point.y = min(point.y, 0.0);\n"+ - " if (length(point) > 1.0) discard;\n"; - } - - for (i=0; i < nclipplanes;i++) - result = result + " if (dot(vPosition, vClipplane"+i+") < 0.0) discard;\n"; - - if (fixed_quads) { - result = result + " vec3 n = vec3(0., 0., 1.);\n"; - } else if (is_lit) { - result = result + " vec3 n = normalize(vNormal);\n"; - } - - if (is_twosided) { - result = result + " if ((normz <= 0.) != front) discard;\n"; - } - - if (is_lit) { - result = result + " vec3 eye = normalize(-vPosition.xyz);\n"+ - " vec3 lightdir;\n"+ - " vec4 colDiff;\n"+ - " vec3 halfVec;\n"+ - " vec4 lighteffect = vec4(emission, 0.);\n"+ - " vec3 col;\n"+ - " float nDotL;\n"; - if (!fixed_quads) { - result = result + " n = -faceforward(n, n, eye);\n"; - } - for (i=0; i < nlights; i++) { - result = result + " colDiff = vec4(vCol.rgb * diffuse" + i + ", vCol.a);\n"+ - " lightdir = lightDir" + i + ";\n"+ - " if (!viewpoint" + i +")\n"+ - " lightdir = (mvMatrix * vec4(lightdir, 1.)).xyz;\n"+ - " if (!finite" + i + ") {\n"+ - " halfVec = normalize(lightdir + eye);\n"+ - " } else {\n"+ - " lightdir = normalize(lightdir - vPosition.xyz);\n"+ - " halfVec = normalize(lightdir + eye);\n"+ - " }\n"+ - " col = ambient" + i + ";\n"+ - " nDotL = dot(n, lightdir);\n"+ - " col = col + max(nDotL, 0.) * colDiff.rgb;\n"+ - " col = col + pow(max(dot(halfVec, n), 0.), shininess) * specular" + i + ";\n"+ - " lighteffect = lighteffect + vec4(col, colDiff.a);\n"; - } - - } else { - result = result + " vec4 colDiff = vCol;\n"+ - " vec4 lighteffect = colDiff;\n"; - } - - if (type === "text") - result = result + " vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);\n"; - - if (has_texture) { - result = result + { - rgb: " vec4 textureColor = lighteffect*vec4(texture2D(uSampler, vTexcoord).rgb, 1.);\n", - rgba: " vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);\n", - alpha: " vec4 textureColor = texture2D(uSampler, vTexcoord);\n"+ - " float luminance = dot(vec3(1.,1.,1.), textureColor.rgb)/3.;\n"+ - " textureColor = vec4(lighteffect.rgb, lighteffect.a*luminance);\n", - luminance: " vec4 textureColor = vec4(lighteffect.rgb*dot(texture2D(uSampler, vTexcoord).rgb, vec3(1.,1.,1.))/3., lighteffect.a);\n", - "luminance.alpha":" vec4 textureColor = texture2D(uSampler, vTexcoord);\n"+ - " float luminance = dot(vec3(1.,1.,1.),textureColor.rgb)/3.;\n"+ - " textureColor = vec4(lighteffect.rgb*luminance, lighteffect.a*textureColor.a);\n" - }[texture_format]+ - " fragColor = textureColor;\n"; - } else if (type === "text") { - result = result + " if (textureColor.a < 0.1)\n"+ - " discard;\n"+ - " else\n"+ - " fragColor = textureColor;\n"; - } else - result = result + " fragColor = lighteffect;\n"; - - if (has_fog) { - // uFogParms elements: x = near, y = far, z = fogscale, w = (1-sin(FOV/2))/(1+sin(FOV/2)) - // In Exp and Exp2: use density = density/far - // fogF will be the proportion of fog - // Initialize it to the linear value - result = result + " float fogF;\n"+ - " if (uFogMode > 0) {\n"+ - " fogF = (uFogParms.y - vPosition.z/vPosition.w)/(uFogParms.y - uFogParms.x);\n"+ - " if (uFogMode > 1)\n"+ - " fogF = mix(uFogParms.w, 1.0, fogF);\n"+ - " fogF = fogF*uFogParms.z;\n"+ - " if (uFogMode == 2)\n"+ - " fogF = 1.0 - exp(-fogF);\n"+ - // Docs are wrong: use (density*c)^2, not density*c^2 - // https://gitlab.freedesktop.org/mesa/mesa/-/blob/master/src/mesa/swrast/s_fog.c#L58 - " else if (uFogMode == 3)\n"+ - " fogF = 1.0 - exp(-fogF*fogF);\n"+ - " fogF = clamp(fogF, 0.0, 1.0);\n"+ - " gl_FragColor = vec4(mix(fragColor.rgb, uFogColor, fogF), fragColor.a);\n"+ - // " if (fogF < 0.) gl_FragColor = vec4(1.0,0.0,0.0,1.0); else if (fogF < 1.0) gl_FragColor = vec4(mix(fragColor.rgb, uFogColor, fogF), fragColor.a);else gl_FragColor = vec4(0.0,1.0,0.0,1.0);\n"+ - " } else gl_FragColor = fragColor;\n"; - } else - result = result + " gl_FragColor = fragColor;\n"; - - //if (fat_lines) - // result = result + " gl_FragColor = vec4(0.0, abs(point.x), abs(point.y), 1.0);" - result = result + " }\n"; - - // console.log(result); - return result; - }; - - /** - * Call gl functions to create and compile shader - * @returns {Object} - * @param { number } shaderType - gl code for shader type - * @param { string } code - code for the shader - */ - rglwidgetClass.prototype.getShader = function(shaderType, code) { - var gl = this.gl, shader; - shader = gl.createShader(shaderType); - gl.shaderSource(shader, code); - gl.compileShader(shader); - if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS) && !gl.isContextLost()) - alert(gl.getShaderInfoLog(shader)); - return shader; - }; - diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/subscenes.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/subscenes.src.js deleted file mode 100644 index 6f7eff5c..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/subscenes.src.js +++ /dev/null @@ -1,153 +0,0 @@ - /** - * Is a particular id in a subscene? - * @returns { boolean } - * @param {number} id Which id? - * @param {number} subscene Which subscene id? - */ - rglwidgetClass.prototype.inSubscene = function(id, subscene) { - return this.getObj(subscene).objects.indexOf(id) > -1; - }; - - /** - * Translate from window coordinates to viewport coordinates - * @returns { Object } translated coordinates - * @param { number } subsceneid - which subscene to use? - * @param { Object } coords - point to translate - */ - rglwidgetClass.prototype.translateCoords = function(subsceneid, coords) { - var viewport = this.getObj(subsceneid).par3d.viewport; - return {x: coords.x - viewport.x*this.canvas.width, - y: coords.y - viewport.y*this.canvas.height}; - }; - - /** - * Check whether point is in viewport of subscene - * @returns {boolean} - * @param { Object } coords - screen coordinates of point - * @param { number } subsceneid - subscene to check - */ - rglwidgetClass.prototype.inViewport = function(coords, subsceneid) { - var viewport = this.getObj(subsceneid).par3d.viewport, - x0 = coords.x - viewport.x*this.canvas.width, - y0 = coords.y - viewport.y*this.canvas.height; - return 0 <= x0 && x0 <= viewport.width*this.canvas.width && - 0 <= y0 && y0 <= viewport.height*this.canvas.height; - }; - - /** - * Find which subscene contains a point - * @returns { number } subscene id - * @param { Object } coords - coordinates of point - */ - rglwidgetClass.prototype.whichSubscene = function(coords) { - var self = this, - recurse = function(subsceneid) { - var subscenes = self.getChildSubscenes(subsceneid), i, id; - for (i=0; i < subscenes.length; i++) { - id = recurse(subscenes[i]); - if (typeof(id) !== "undefined") - return(id); - } - if (self.inViewport(coords, subsceneid)) - return(subsceneid); - else - return undefined; - }, - rootid = this.scene.rootSubscene, - result = recurse(rootid); - if (typeof(result) === "undefined") - result = rootid; - return result; - }; - - /** - * Add an id to a subscene. - * @param {number} id Which id? - * @param {number} subscene Which subscene id? - */ - rglwidgetClass.prototype.addToSubscene = function(id, subscene) { - var thelist, - thesub = this.getObj(subscene), - ids = [id], - obj = this.getObj(id), i; - if (typeof obj !== "undefined" && typeof (obj.newIds) !== "undefined") { - ids = ids.concat(obj.newIds); - } - thesub.objects = [].concat(thesub.objects); - for (i = 0; i < ids.length; i++) { - id = ids[i]; - if (thesub.objects.indexOf(id) === -1) { - thelist = this.whichList(id); - thesub.objects.push(id); - thesub[thelist].push(id); - } - } - }; - - /** - * Delete an id from a subscene - * @param { number } id - the id to add - * @param { number } subscene - the id of the subscene - */ - rglwidgetClass.prototype.delFromSubscene = function(id, subscene) { - var thelist, - thesub = this.getObj(subscene), - obj = this.getObj(id), - ids = [id], i, j; - if (typeof obj !== "undefined" && typeof (obj.newIds) !== "undefined") - ids = ids.concat(obj.newIds); - thesub.objects = [].concat(thesub.objects); // It might be a scalar - for (j=0; j -1) { - thesub.objects.splice(i, 1); - thelist = this.whichList(id); - i = thesub[thelist].indexOf(id); - thesub[thelist].splice(i, 1); - } - } - }; - - /** - * Set the ids in a subscene - * @param { number[] } ids - the ids to set - * @param { number } subsceneid - the id of the subscene - */ - rglwidgetClass.prototype.setSubsceneEntries = function(ids, subsceneid) { - var sub = this.getObj(subsceneid); - sub.objects = ids; - this.initSubscene(subsceneid); - }; - - /** - * Get the ids in a subscene - * @returns {number[]} - * @param { number } subscene - the id of the subscene - */ - rglwidgetClass.prototype.getSubsceneEntries = function(subscene) { - return this.getObj(subscene).objects; - }; - - /** - * Get the ids of the subscenes within a subscene - * @returns { number[] } - * @param { number } subscene - the id of the subscene - */ - rglwidgetClass.prototype.getChildSubscenes = function(subscene) { - return this.getObj(subscene).subscenes; - }; - - /** - * Find a particular subscene by inheritance - * @returns { number } id of subscene to use - * @param { number } subsceneid - child subscene - * @param { string } type - type of inheritance: "projection" or "model" - */ - rglwidgetClass.prototype.useid = function(subsceneid, type) { - var sub = this.getObj(subsceneid); - if (sub.embeddings[type] === "inherit") - return(this.useid(sub.parent, type)); - else - return subsceneid; - }; diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/textures.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/textures.src.js deleted file mode 100644 index f4e4cb97..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/textures.src.js +++ /dev/null @@ -1,147 +0,0 @@ - - /** - * Handle a texture after its image has been loaded - * @param { Object } texture - the gl texture object - * @param { Object } textureCanvas - the canvas holding the image - */ - rglwidgetClass.prototype.handleLoadedTexture = function(texture, textureCanvas) { - var gl = this.gl || this.initGL(); - gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true); - - gl.bindTexture(gl.TEXTURE_2D, texture); - gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, textureCanvas); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR); - gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR_MIPMAP_NEAREST); - gl.generateMipmap(gl.TEXTURE_2D); - - gl.bindTexture(gl.TEXTURE_2D, null); - }; - - /** - * Get maximum dimension of texture in current browser. - * @returns {number} - */ - rglwidgetClass.prototype.getMaxTexSize = function() { - var gl = this.gl || this.initGL(); - return Math.min(4096, gl.getParameter(gl.MAX_TEXTURE_SIZE)); - }; - - /** - * Load an image to a texture - * @param { string } uri - The image location - * @param { Object } texture - the gl texture object - */ - rglwidgetClass.prototype.loadImageToTexture = function(uri, texture) { - var canvas = this.textureCanvas, - ctx = canvas.getContext("2d"), - image = new Image(), - self = this; - - image.onload = function() { - var w = image.width, - h = image.height, - canvasX = self.getPowerOfTwo(w), - canvasY = self.getPowerOfTwo(h), - maxTexSize = self.getMaxTexSize(); - while (canvasX > 1 && canvasY > 1 && (canvasX > maxTexSize || canvasY > maxTexSize)) { - canvasX /= 2; - canvasY /= 2; - } - canvas.width = canvasX; - canvas.height = canvasY; - ctx.imageSmoothingEnabled = true; - ctx.drawImage(image, 0, 0, canvasX, canvasY); - self.handleLoadedTexture(texture, canvas); - self.drawScene(); - }; - image.src = uri; - }; - - /** - * Draw text to the texture canvas - * @returns { Object } object with text measurements - * @param { string } text - the text - * @param { number } cex - expansion - * @param { string } family - font family - * @param { number } font - font number - */ - rglwidgetClass.prototype.drawTextToCanvas = function(text, cex, family, font) { - var canvasX, canvasY, - scaling = 20, - textColour = "white", - - backgroundColour = "rgba(0,0,0,0)", - canvas = this.textureCanvas, - ctx = canvas.getContext("2d"), - i, textHeight = 0, textHeights = [], width, widths = [], - offsetx, offsety = 0, line, lines = [], offsetsx = [], - offsetsy = [], lineoffsetsy = [], fontStrings = [], - maxTexSize = this.getMaxTexSize(), - getFontString = function(i) { - textHeights[i] = scaling*cex[i]; - var fontString = textHeights[i] + "px", - family0 = family[i], - font0 = font[i]; - if (family0 === "sans") - family0 = "sans-serif"; - else if (family0 === "mono") - family0 = "monospace"; - fontString = fontString + " " + family0; - if (font0 === 2 || font0 === 4) - fontString = "bold " + fontString; - if (font0 === 3 || font0 === 4) - fontString = "italic " + fontString; - return fontString; - }; - cex = this.repeatToLen(cex, text.length); - family = this.repeatToLen(family, text.length); - font = this.repeatToLen(font, text.length); - - canvasX = 1; - line = -1; - offsetx = maxTexSize; - for (i = 0; i < text.length; i++) { - ctx.font = fontStrings[i] = getFontString(i); - width = widths[i] = ctx.measureText(text[i]).width; - if (offsetx + width > maxTexSize) { - offsety = offsety + 2*textHeight; - if (line >= 0) - lineoffsetsy[line] = offsety; - line += 1; - if (offsety > maxTexSize) - console.error("Too many strings for texture."); - textHeight = 0; - offsetx = 0; - } - textHeight = Math.max(textHeight, textHeights[i]); - offsetsx[i] = offsetx; - offsetx += width; - canvasX = Math.max(canvasX, offsetx); - lines[i] = line; - } - offsety = lineoffsetsy[line] = offsety + 2*textHeight; - for (i = 0; i < text.length; i++) { - offsetsy[i] = lineoffsetsy[lines[i]]; - } - - canvasX = this.getPowerOfTwo(canvasX); - canvasY = this.getPowerOfTwo(offsety); - - canvas.width = canvasX; - canvas.height = canvasY; - - ctx.fillStyle = backgroundColour; - ctx.fillRect(0, 0, ctx.canvas.width, ctx.canvas.height); - - ctx.textBaseline = "alphabetic"; - for(i = 0; i < text.length; i++) { - ctx.font = fontStrings[i]; - ctx.fillStyle = textColour; - ctx.textAlign = "left"; - ctx.fillText(text[i], offsetsx[i], offsetsy[i]); - } - return {canvasX:canvasX, canvasY:canvasY, - widths:widths, textHeights:textHeights, - offsetsx:offsetsx, offsetsy:offsetsy}; - }; - diff --git a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/utils.src.js b/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/utils.src.js deleted file mode 100644 index af3c367c..00000000 --- a/docs/articles/NeuroGeometry_files/rglwidgetClass-0.105.13/utils.src.js +++ /dev/null @@ -1,502 +0,0 @@ - - /** - * Multiply matrix by vector - * @returns {number[]} - * @param M {number[][]} Left operand - * @param v {number[]} Right operand - */ - rglwidgetClass.prototype.multMV = function(M, v) { - return [ M.m11 * v[0] + M.m12 * v[1] + M.m13 * v[2] + M.m14 * v[3], - M.m21 * v[0] + M.m22 * v[1] + M.m23 * v[2] + M.m24 * v[3], - M.m31 * v[0] + M.m32 * v[1] + M.m33 * v[2] + M.m34 * v[3], - M.m41 * v[0] + M.m42 * v[1] + M.m43 * v[2] + M.m44 * v[3] - ]; - }; - - /** - * Multiply row vector by Matrix - * @returns {number[]} - * @param v {number[]} left operand - * @param M {number[][]} right operand - */ - rglwidgetClass.prototype.multVM = function(v, M) { - return [ M.m11 * v[0] + M.m21 * v[1] + M.m31 * v[2] + M.m41 * v[3], - M.m12 * v[0] + M.m22 * v[1] + M.m32 * v[2] + M.m42 * v[3], - M.m13 * v[0] + M.m23 * v[1] + M.m33 * v[2] + M.m43 * v[3], - M.m14 * v[0] + M.m24 * v[1] + M.m34 * v[2] + M.m44 * v[3] - ]; - }; - - /** - * Euclidean length of a vector - * @returns {number} - * @param v {number[]} - */ - rglwidgetClass.prototype.vlen = function(v) { - return Math.sqrt(this.dotprod(v, v)); - }; - - /** - * Dot product of two vectors - * @instance rglwidgetClass - * @returns {number} - * @param a {number[]} - * @param b {number[]} - */ - rglwidgetClass.prototype.dotprod = function(a, b) { - return a[0]*b[0] + a[1]*b[1] + a[2]*b[2]; - }; - - /** - * Cross product of two vectors - * @returns {number[]} - * @param a {number[]} - * @param b {number[]} - */ - rglwidgetClass.prototype.xprod = function(a, b) { - return [a[1]*b[2] - a[2]*b[1], - a[2]*b[0] - a[0]*b[2], - a[0]*b[1] - a[1]*b[0]]; - }; - - /** - * Bind vectors or matrices by columns - * @returns {number[][]} - * @param a {number[]|number[][]} - * @param b {number[]|number[][]} - */ - rglwidgetClass.prototype.cbind = function(a, b) { - if (b.length < a.length) - b = this.repeatToLen(b, a.length); - else if (a.length < b.length) - a = this.repeatToLen(a, b.length); - return a.map(function(currentValue, index) { - return currentValue.concat(b[index]); - }); - }; - - /** - * Swap elements - * @returns {any[]} - * @param a {any[]} - * @param i {number} Element to swap - * @param j {number} Other element to swap - */ - rglwidgetClass.prototype.swap = function(a, i, j) { - var temp = a[i]; - a[i] = a[j]; - a[j] = temp; - }; - - /** - * Flatten a matrix into a vector - * @returns {any[]} - * @param a {any[][]} - */ - rglwidgetClass.prototype.flatten = function(arr, result) { - var value; - if (typeof result === "undefined") result = []; - for (var i = 0, length = arr.length; i < length; i++) { - value = arr[i]; - if (Array.isArray(value)) { - this.flatten(value, result); - } else { - result.push(value); - } - } - return result; - }; - - /** - * set element of 1d or 2d array as if it was flattened. - * Column major, zero based! - * @returns {any[]|any[][]} - * @param {any[]|any[][]} a - array - * @param {number} i - element - * @param {any} value - */ - rglwidgetClass.prototype.setElement = function(a, i, value) { - if (Array.isArray(a[0])) { - var dim = a.length, - col = Math.floor(i/dim), - row = i % dim; - a[row][col] = value; - } else { - a[i] = value; - } - }; - - /** - * Transpose an array - * @returns {any[][]} - * @param {any[][]} a - */ - rglwidgetClass.prototype.transpose = function(a) { - var newArray = [], - n = a.length, - m = a[0].length, - i; - for(i = 0; i < m; i++){ - newArray.push([]); - } - - for(i = 0; i < n; i++){ - for(var j = 0; j < m; j++){ - newArray[j].push(a[i][j]); - } - } - return newArray; - }; - - /** - * Calculate sum of squares of a numeric vector - * @returns {number} - * @param {number[]} x - */ - rglwidgetClass.prototype.sumsq = function(x) { - var result = 0, i; - for (i=0; i < x.length; i++) - result += x[i]*x[i]; - return result; - }; - - /** - * Convert a matrix to a CanvasMatrix4 - * @returns {CanvasMatrix4} - * @param {number[][]|number[]} mat - */ - rglwidgetClass.prototype.toCanvasMatrix4 = function(mat) { - if (mat instanceof CanvasMatrix4) - return mat; - var result = new CanvasMatrix4(); - mat = this.flatten(this.transpose(mat)); - result.load(mat); - return result; - }; - - /** - * Convert an R-style numeric colour string to an rgb vector - * @returns {number[]} - * @param {string} s - */ - /* jshint bitwise:false */ - rglwidgetClass.prototype.stringToRgb = function(s) { - s = s.replace("#", ""); - var bigint = parseInt(s, 16); - return [((bigint >> 16) & 255)/255, - ((bigint >> 8) & 255)/255, - (bigint & 255)/255]; - }; - /* jshint bitwise:true */ - /** - * Which list does a particular id come from? - * @returns { string } - * @param {number} id The id to look up. - */ - rglwidgetClass.prototype.whichList = function(id) { - var obj = this.getObj(id), - flags = obj.flags; - if (obj.type === "light") - return "lights"; - if (this.isSet(flags, this.f_is_subscene)) - return "subscenes"; - if (this.isSet(flags, this.f_is_clipplanes)) - return "clipplanes"; - if (this.isSet(flags, this.f_is_transparent)) - return "transparent"; - return "opaque"; - }; - - /** - * Take a component-by-component product of two 3 vectors - * @returns {number[]} - * @param {number[]} x - * @param {number[]} y - */ - rglwidgetClass.prototype.componentProduct = function(x, y) { - if (typeof y === "undefined") { - this.alertOnce("Bad arg to componentProduct"); - } - var result = new Float32Array(3), i; - for (i = 0; i<3; i++) - result[i] = x[i]*y[i]; - return result; - }; - - /** - * Get next higher power of two - * @returns { number } - * @param { number } value - input value - */ - rglwidgetClass.prototype.getPowerOfTwo = function(value) { - var pow = 1; - while(pow= -windHeight && - rect.left >= -windWidth && - rect.bottom <= 2*windHeight && - rect.right <= 2*windWidth); - }; - - rglwidgetClass.prototype.keydiff = function(obj1, obj2) { - var keys = Object.keys(obj1), i, result = []; - for (i=0;ii;i++)value=arr[i],Array.isArray(value)?this.flatten(value,result):result.push(value);return result},rglwidgetClass.prototype.setElement=function(a,i,value){if(Array.isArray(a[0])){var dim=a.length,col=Math.floor(i/dim),row=i%dim;a[row][col]=value}else a[i]=value},rglwidgetClass.prototype.transpose=function(a){var i,newArray=[],n=a.length,m=a[0].length;for(i=0;m>i;i++)newArray.push([]);for(i=0;n>i;i++)for(var j=0;m>j;j++)newArray[j].push(a[i][j]);return newArray},rglwidgetClass.prototype.sumsq=function(x){var i,result=0;for(i=0;i>16&255)/255,(bigint>>8&255)/255,(255&bigint)/255]},rglwidgetClass.prototype.whichList=function(id){var obj=this.getObj(id),flags=obj.flags;return"light"===obj.type?"lights":this.isSet(flags,this.f_is_subscene)?"subscenes":this.isSet(flags,this.f_is_clipplanes)?"clipplanes":this.isSet(flags,this.f_is_transparent)?"transparent":"opaque"},rglwidgetClass.prototype.componentProduct=function(x,y){"undefined"==typeof y&&this.alertOnce("Bad arg to componentProduct");var i,result=new Float32Array(3);for(i=0;3>i;i++)result[i]=x[i]*y[i];return result},rglwidgetClass.prototype.getPowerOfTwo=function(value){for(var pow=1;value>pow;)pow*=2;return pow},rglwidgetClass.prototype.unique=function(arr){return arr=[].concat(arr),arr.filter(function(value,index,self){return self.indexOf(value)===index})},rglwidgetClass.prototype.equalArrays=function(a,b){return a===b||a&&b&&a.length===b.length&&a.every(function(v,i){return v===b[i]})},rglwidgetClass.prototype.repeatToLen=function(arr,len){if(arr=[].concat(arr),!arr.length)throw new RangeError("array is length 0");for(;arr.length=-windHeight&&rect.left>=-windWidth&&rect.bottom<=2*windHeight&&rect.right<=2*windWidth},rglwidgetClass.prototype.keydiff=function(obj1,obj2){var i,keys=Object.keys(obj1),result=[];for(i=0;i=2&&cross(lower[lower.length-2],lower[lower.length-1],points[i])<=0;)lower.pop();lower.push(points[i])}for(i=points.length-1;i>=0;i--){for(;upper.length>=2&&cross(upper[upper.length-2],upper[upper.length-1],points[i])<=0;)upper.pop();upper.push(points[i])}return upper.pop(),lower.pop(),lower.concat(upper)},rglwidgetClass.prototype.signif=function(x,digits){return parseFloat(x.toPrecision(digits))},rglwidgetClass.prototype.missing=function(x){return"-Inf"!==x&&"Inf"!==x&&(isNaN(x)||null===x||"undefined"==typeof x)},rglwidgetClass.prototype.logMatrix=function(M){console.log("matrix(c("+M.m11+","+M.m12+","+M.m13+","+M.m14+",\n"+M.m21+","+M.m22+","+M.m23+","+M.m24+",\n"+M.m31+","+M.m32+","+M.m33+","+M.m34+",\n"+M.m41+","+M.m42+","+M.m43+","+M.m44+"), byrow=TRUE, ncol=4)")},rglwidgetClass.prototype.logVec3=function(v){console.log("c("+v[0]+","+v[1]+","+v[2]+")")},rglwidgetClass.prototype.vsum=function(x,y){var i,result=[].concat(x);for(i=0;i64&&91>nChr?nChr-65:nChr>96&&123>nChr?nChr-71:nChr>47&&58>nChr?nChr+4:43===nChr?62:47===nChr?63:0},rglwidgetClass.prototype.base64DecToArr=function(sBase64,nBlocksSize){for(var nMod3,nMod4,sB64Enc=sBase64.replace(/[^A-Za-z0-9\+\/]/g,""),nInLen=sB64Enc.length,nOutLen=nBlocksSize?Math.ceil((3*nInLen+1>>2)/nBlocksSize)*nBlocksSize:3*nInLen+1>>2,taBytes=new Uint8Array(nOutLen),nUint24=0,nOutIdx=0,nInIdx=0;nInLen>nInIdx;nInIdx++)if(nMod4=3&nInIdx,nUint24|=this.b64ToUint6(sB64Enc.charCodeAt(nInIdx))<<6*(3-nMod4),3===nMod4||nInLen-nInIdx===1){for(nMod3=0;3>nMod3&&nOutLen>nOutIdx;nMod3++,nOutIdx++)taBytes[nOutIdx]=nUint24>>>(16>>>nMod3&24)&255;nUint24=0}return taBytes},rglwidgetClass.prototype.getArrayBuffer=function(base64){return this.base64DecToArr(base64,4).buffer},rglwidgetClass.prototype.getBufferedData=function(v){var bytes,values,row,i,j,k,typeSignedByte=5120,typeUnsignedByte=5121,typeSignedShort=5122,typeUnsignedShort=5123,typeSignedInt=5124,typeUnsignedInt=5125,typeFloat=5126,typeDouble=5130,buf=this.scene.buffer,accessor=buf.accessors[parseInt(v,10)],bufferView=buf.bufferViews[accessor.bufferView],buffer=buf.buffers[bufferView.buffer],lens={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},rowsizes={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:2,MAT3:3,MAT4:4},offset=0,len=lens[accessor.type],rowsize=rowsizes[accessor.type],count=len*accessor.count,nrows=count/rowsize,arr=[];switch("string"==typeof buffer.bytes&&(buffer.bytes=this.getArrayBuffer(buffer.bytes)),bytes=buffer.bytes,"undefined"!=typeof accessor.byteOffset&&(offset+=accessor.byteOffset),"undefined"!=typeof bufferView.byteOffset&&(offset+=bufferView.byteOffset),accessor.componentType){case typeSignedByte:values=new Int8Array(buffer.bytes,offset,count);break;case typeUnsignedByte:values=new Uint8Array(buffer.bytes,offset,count);break;case typeSignedShort:values=new Int16Array(buffer.bytes,offset,count);break;case typeUnsignedShort:values=new Uint16Array(buffer.bytes,offset,count);break;case typeSignedInt:values=new Int32Array(buffer.bytes,offset,count);break;case typeUnsignedInt:values=new Uint32Array(buffer.bytes,offset,count);break;case typeFloat:values=new Float32Array(buffer.bytes,offset,count);break;case typeDouble:values=new Float64Array(buffer.bytes,offset,count)}for(k=0,i=0;nrows>i;i++){for(row=[],j=0;rowsize>j;j++)row.push(values[k++]);arr.push(row)}return arr},rglwidgetClass.prototype.expandBufferedFields=function(obj){var i,field,fields=["vertices","normals","indices","texcoords","colors","centers"];for(i=0;i-1},rglwidgetClass.prototype.translateCoords=function(subsceneid,coords){var viewport=this.getObj(subsceneid).par3d.viewport;return{x:coords.x-viewport.x*this.canvas.width,y:coords.y-viewport.y*this.canvas.height}},rglwidgetClass.prototype.inViewport=function(coords,subsceneid){var viewport=this.getObj(subsceneid).par3d.viewport,x0=coords.x-viewport.x*this.canvas.width,y0=coords.y-viewport.y*this.canvas.height;return x0>=0&&x0<=viewport.width*this.canvas.width&&y0>=0&&y0<=viewport.height*this.canvas.height},rglwidgetClass.prototype.whichSubscene=function(coords){var self=this,recurse=function(subsceneid){var i,id,subscenes=self.getChildSubscenes(subsceneid);for(i=0;i-1&&(thesub.objects.splice(i,1),thelist=this.whichList(id),i=thesub[thelist].indexOf(id),thesub[thelist].splice(i,1))},rglwidgetClass.prototype.setSubsceneEntries=function(ids,subsceneid){var sub=this.getObj(subsceneid);sub.objects=ids,this.initSubscene(subsceneid)},rglwidgetClass.prototype.getSubsceneEntries=function(subscene){return this.getObj(subscene).objects},rglwidgetClass.prototype.getChildSubscenes=function(subscene){return this.getObj(subscene).subscenes},rglwidgetClass.prototype.useid=function(subsceneid,type){var sub=this.getObj(subsceneid);return"inherit"===sub.embeddings[type]?this.useid(sub.parent,type):subsceneid},rglwidgetClass.prototype.getBBoxDeco=function(sub){var i,obj,objects=sub.objects;for(i=0;ii;i++)result=result+" uniform vec4 vClipplane"+i+";\n";if(is_lit&&(nlights=this.countLights(),nlights?result+=" uniform mat4 mvMatrix;\n":is_lit=!1),is_lit)for(result+=" uniform vec3 emission;\n uniform float shininess;\n",i=0;nlights>i;i++)result=result+" uniform vec3 ambient"+i+";\n uniform vec3 specular"+i+"; // light*material\n uniform vec3 diffuse"+i+";\n uniform vec3 lightDir"+i+";\n uniform bool viewpoint"+i+";\n uniform bool finite"+i+";\n";if(is_twosided&&(result+=" uniform bool front;\n varying float normz;\n"),fat_lines&&(result+=" varying vec2 vPoint;\n varying float vLength;\n"),result+=" void main(void) {\n vec4 fragColor;\n",fat_lines&&(result+=" vec2 point = vPoint;\n bool neg = point.y < 0.0;\n point.y = neg ? (point.y + vLength)/(1.0 - vLength) :\n -(point.y - vLength)/(1.0 - vLength);\n",is_transparent&&"linestrip"===type&&(result+=" if (neg && length(point) <= 1.0) discard;\n"),result+=" point.y = min(point.y, 0.0);\n if (length(point) > 1.0) discard;\n"),is_points){var round=this.getMaterial(obj,"point_antialias");round&&(result+=" vec2 coord = gl_PointCoord - vec2(0.5);\n if (length(coord) > 0.5) discard;\n")}for(i=0;nclipplanes>i;i++)result=result+" if (dot(vPosition, vClipplane"+i+") < 0.0) discard;\n";if(fixed_quads?result+=" vec3 n = vec3(0., 0., 1.);\n":is_lit&&(result+=" vec3 n = normalize(vNormal.xyz);\n"),is_twosided&&(result+=" if ((normz <= 0.) != front) discard;\n"),is_lit)for(result+=" vec3 eye = normalize(-vPosition.xyz);\n vec3 lightdir;\n vec4 colDiff;\n vec3 halfVec;\n vec4 lighteffect = vec4(emission, 0.);\n vec3 col;\n float nDotL;\n",fixed_quads||(result+=" n = -faceforward(n, n, eye);\n"),i=0;nlights>i;i++)result=result+" colDiff = vec4(vCol.rgb * diffuse"+i+", vCol.a);\n lightdir = lightDir"+i+";\n if (!viewpoint"+i+")\n lightdir = (mvMatrix * vec4(lightdir, 1.)).xyz;\n if (!finite"+i+") {\n halfVec = normalize(lightdir + eye);\n } else {\n lightdir = normalize(lightdir - vPosition.xyz);\n halfVec = normalize(lightdir + eye);\n }\n col = ambient"+i+";\n nDotL = dot(n, lightdir);\n col = col + max(nDotL, 0.) * colDiff.rgb;\n col = col + pow(max(dot(halfVec, n), 0.), shininess) * specular"+i+";\n lighteffect = lighteffect + vec4(col, colDiff.a);\n";else result+=" vec4 colDiff = vCol;\n vec4 lighteffect = colDiff;\n";return"text"===type&&(result+=" vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);\n"),has_texture?result=result+{rgb:" vec4 textureColor = lighteffect*vec4(texture2D(uSampler, vTexcoord).rgb, 1.);\n",rgba:" vec4 textureColor = lighteffect*texture2D(uSampler, vTexcoord);\n",alpha:" vec4 textureColor = texture2D(uSampler, vTexcoord);\n float luminance = dot(vec3(1.,1.,1.), textureColor.rgb)/3.;\n textureColor = vec4(lighteffect.rgb, lighteffect.a*luminance);\n",luminance:" vec4 textureColor = vec4(lighteffect.rgb*dot(texture2D(uSampler, vTexcoord).rgb, vec3(1.,1.,1.))/3., lighteffect.a);\n","luminance.alpha":" vec4 textureColor = texture2D(uSampler, vTexcoord);\n float luminance = dot(vec3(1.,1.,1.),textureColor.rgb)/3.;\n textureColor = vec4(lighteffect.rgb*luminance, lighteffect.a*textureColor.a);\n"}[texture_format]+" fragColor = textureColor;\n":result+="text"===type?" if (textureColor.a < 0.1)\n discard;\n else\n fragColor = textureColor;\n":" fragColor = lighteffect;\n",result+=has_fog?" float fogF;\n if (uFogMode > 0) {\n fogF = (uFogParms.y - vPosition.z/vPosition.w)/(uFogParms.y - uFogParms.x);\n if (uFogMode > 1)\n fogF = mix(uFogParms.w, 1.0, fogF);\n fogF = fogF*uFogParms.z;\n if (uFogMode == 2)\n fogF = 1.0 - exp(-fogF);\n else if (uFogMode == 3)\n fogF = 1.0 - exp(-fogF*fogF);\n fogF = clamp(fogF, 0.0, 1.0);\n gl_FragColor = vec4(mix(fragColor.rgb, uFogColor, fogF), fragColor.a);\n } else gl_FragColor = fragColor;\n":" gl_FragColor = fragColor;\n",result+=" }\n"}},rglwidgetClass.prototype.getShader=function(shaderType,code){var shader,gl=this.gl;return shader=gl.createShader(shaderType),gl.shaderSource(shader,code),gl.compileShader(shader),gl.getShaderParameter(shader,gl.COMPILE_STATUS)||gl.isContextLost()||alert(gl.getShaderInfoLog(shader)),shader},rglwidgetClass.prototype.getTexFilter=function(filter){var gl=this.gl||this.initGL();switch(filter){case"nearest":return gl.NEAREST;case"linear":return gl.LINEAR;case"nearest.mipmap.nearest":return gl.NEAREST_MIPMAP_NEAREST;case"linear.mipmap.nearest":return gl.LINEAR_MIPMAP_NEAREST;case"nearest.mipmap.linear":return gl.NEAREST_MIPMAP_LINEAR;case"linear.mipmap.linear":return gl.LINEAR_MIPMAP_LINEAR;default:console.error("Unknown filter: "+filter)}},rglwidgetClass.prototype.handleLoadedTexture=function(texture,textureCanvas){var gl=this.gl||this.initGL();gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,!0),gl.bindTexture(gl.TEXTURE_2D,texture),gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,gl.RGBA,gl.UNSIGNED_BYTE,textureCanvas),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.LINEAR),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR_MIPMAP_NEAREST),gl.generateMipmap(gl.TEXTURE_2D),gl.bindTexture(gl.TEXTURE_2D,null)},rglwidgetClass.prototype.getMaxTexSize=function(){var gl=this.gl||this.initGL();return Math.min(4096,gl.getParameter(gl.MAX_TEXTURE_SIZE))},rglwidgetClass.prototype.loadImageToTexture=function(uri,texture){var canvas=this.textureCanvas,ctx=canvas.getContext("2d"),image=new Image,self=this;image.onload=function(){for(var w=image.width,h=image.height,canvasX=self.getPowerOfTwo(w),canvasY=self.getPowerOfTwo(h),maxTexSize=self.getMaxTexSize();canvasX>1&&canvasY>1&&(canvasX>maxTexSize||canvasY>maxTexSize);)canvasX/=2,canvasY/=2;canvas.width=canvasX,canvas.height=canvasY,ctx.imageSmoothingEnabled=!0,ctx.drawImage(image,0,0,canvasX,canvasY),self.handleLoadedTexture(texture,canvas),self.drawScene()},image.src=uri},rglwidgetClass.prototype.drawTextToCanvas=function(text,cex,family,font){var canvasX,canvasY,i,width,offsetx,line,scaling=20,textColour="white",backgroundColour="rgba(0,0,0,0)",canvas=this.textureCanvas,ctx=canvas.getContext("2d"),textHeight=0,textHeights=[],widths=[],offsety=0,lines=[],offsetsx=[],offsetsy=[],lineoffsetsy=[],fontStrings=[],maxTexSize=this.getMaxTexSize(),getFontString=function(i){textHeights[i]=scaling*cex[i];var fontString=textHeights[i]+"px",family0=family[i],font0=font[i];return"sans"===family0?family0="sans-serif":"mono"===family0&&(family0="monospace"),fontString=fontString+" "+family0,(2===font0||4===font0)&&(fontString="bold "+fontString),(3===font0||4===font0)&&(fontString="italic "+fontString),fontString};for(cex=this.repeatToLen(cex,text.length),family=this.repeatToLen(family,text.length),font=this.repeatToLen(font,text.length),canvasX=1,line=-1,offsetx=maxTexSize,i=0;imaxTexSize&&(offsety+=2*textHeight,line>=0&&(lineoffsetsy[line]=offsety),line+=1,offsety>maxTexSize&&console.error("Too many strings for texture."),textHeight=0,offsetx=0),textHeight=Math.max(textHeight,textHeights[i]),offsetsx[i]=offsetx,offsetx+=width,canvasX=Math.max(canvasX,offsetx),lines[i]=line;for(offsety=lineoffsetsy[line]=offsety+2*textHeight,i=0;i=radius&&(radius=1);var hlen,observer=subscene.par3d.observer,distance=observer[2],FOV=subscene.par3d.FOV,ortho=0===FOV,t=ortho?1:Math.tan(FOV*Math.PI/360),near=distance-radius,far=distance+radius,aspect=this.vp.width/this.vp.height,z=subscene.par3d.zoom,userProjection=subscene.par3d.userProjection;0>far&&(far=1),far/100>near&&(near=far/100),this.frustum={near:near,far:far},hlen=t*near,ortho?aspect>1?this.prMatrix.ortho(-hlen*aspect*z,hlen*aspect*z,-hlen*z,hlen*z,near,far):this.prMatrix.ortho(-hlen*z,hlen*z,-hlen*z/aspect,hlen*z/aspect,near,far):aspect>1?this.prMatrix.frustum(-hlen*aspect*z,hlen*aspect*z,-hlen*z,hlen*z,near,far):this.prMatrix.frustum(-hlen*z,hlen*z,-hlen*z/aspect,hlen*z/aspect,near,far),this.prMatrix.multRight(userProjection)}},rglwidgetClass.prototype.setmvMatrix=function(id){var observer=this.getObj(id).par3d.observer;this.mvMatrix.makeIdentity(),this.setmodelMatrix(id),this.mvMatrix.translate(-observer[0],-observer[1],-observer[2])},rglwidgetClass.prototype.setmodelMatrix=function(id){var subscene=this.getObj(id),embedding=subscene.embeddings.model;if("inherit"!==embedding){var scale=subscene.par3d.scale,bbox=subscene.par3d.bbox,center=[(bbox[0]+bbox[1])/2,(bbox[2]+bbox[3])/2,(bbox[4]+bbox[5])/2];this.mvMatrix.translate(-center[0],-center[1],-center[2]),this.mvMatrix.scale(scale[0],scale[1],scale[2]),this.mvMatrix.multRight(subscene.par3d.userMatrix)}"replace"!==embedding&&this.setmodelMatrix(subscene.parent)},rglwidgetClass.prototype.setnormMatrix2=function(){this.normMatrix=new CanvasMatrix4(this.mvMatrix),this.normMatrix.invert(),this.normMatrix.transpose()},rglwidgetClass.prototype.setprmvMatrix=function(){this.prmvMatrix=new CanvasMatrix4(this.mvMatrix),this.prmvMatrix.multRight(this.prMatrix)},rglwidgetClass.prototype.setInvPrMatrix=function(){this.invPrMatrix=new CanvasMatrix4(this.prMatrix),this.invPrMatrix.invert(),this.invPrMatrix.transpose()},rglwidgetClass.prototype.getCursor=function(mode){switch(mode){case"none":return"none";case"trackball":case"xAxis":case"yAxis":case"zAxis":case"polar":return"grab";case"selecting":return"crosshair";case"fov":case"zoom":return"zoom-in";case"user":return"default"}return"dragging"},rglwidgetClass.prototype.setMouseMode=function(mode,button,subscene,stayActive){var sub=this.getObj(subscene),which=["none","left","right","middle","wheel"][button];stayActive||"selecting"!==sub.par3d.mouseMode[which]||this.clearBrush(null),sub.par3d.mouseMode[which]=mode,(1===button||0===button&&"none"!==mode)&&(this.canvas.style.cursor=this.getCursor(mode)),0===button&&"none"!==mode&&(sub.needsBegin=mode) +},rglwidgetClass.prototype.relMouseCoords=function(event){var rect=this.canvas.getBoundingClientRect();return{x:event.clientX-rect.left,y:event.clientY-rect.top}},rglwidgetClass.prototype.recordSelection=function(subid){var result={};"undefined"!=typeof this.select&&"undefined"!=typeof this.select.state&&"inactive"!==this.select.state?(result={subscene:subid,state:this.select.state,region:this.select.region},this.setmvMatrix(subid),result.model=this.mvMatrix,this.setprMatrix(subid),result.proj=this.prMatrix,this.getViewport(subid),result.view=this.vp):result.state="inactive",Shiny.setInputValue(this.scene.selectionInput+":shinyMouse3d",result)},rglwidgetClass.prototype.setMouseHandlers=function(){var activeSubscene,handler,self=this,handlers={},drag=0;handlers.rotBase=0,self.screenToVector=function(x,y){var viewport=self.getObj(activeSubscene).par3d.viewport,width=viewport.width*self.canvas.width,height=viewport.height*self.canvas.height,radius=Math.max(width,height)/2,cx=width/2,cy=height/2,px=(x-cx)/radius,py=(y-cy)/radius,plen=Math.sqrt(px*px+py*py);plen>1e-6&&(px/=plen,py/=plen);var angle=(Math.SQRT2-plen)/Math.SQRT2*Math.PI/2,z=Math.sin(angle),zlen=Math.sqrt(1-z*z);return px*=zlen,py*=zlen,[px,py,z]},handlers.trackballdown=function(x,y){var i,activeSub=self.getObj(activeSubscene),activeModel=self.getObj(self.useid(activeSub.id,"model")),l=activeModel.par3d.listeners;for(handlers.rotBase=self.screenToVector(x,y),self.saveMat=[],i=0;ij;j++)changepos[j]=-(dragCurrent[j]-handlers.dragBase[j]);activeSub.par3d.userMatrix.makeIdentity(),activeSub.par3d.userMatrix.rotate(180*changepos[0]/Math.PI,0,-1,0),activeSub.par3d.userMatrix.multRight(objects[l[i]].saveMat),activeSub.par3d.userMatrix.rotate(180*changepos[1]/Math.PI,-1,0,0)}self.drawScene()},handlers.polarend=0,handlers.axisdown=function(x){handlers.rotBase=self.screenToVector(x,self.canvas.height/2);var i,activeSub=self.getObj(activeSubscene),activeModel=self.getObj(self.useid(activeSub.id,"model")),l=activeModel.par3d.listeners;for(i=0;i1){var coords=self.relMouseCoords(touch),new_dist=handlers.get_finger_dist(ev);coords.y=self.canvas.height*Math.log(handlers.finger_dist0/new_dist)+handlers.y0zoom,handlers.zoommove(coords.x,coords.y)}else mouseEvent=new MouseEvent("mousemove",{clientX:touch.clientX,clientY:touch.clientY}),self.dispatchEvent(mouseEvent)},self.canvas.addEventListener("DOMMouseScroll",handlers.wheelHandler,!1),self.canvas.addEventListener("mousewheel",handlers.wheelHandler,!1),self.canvas.addEventListener("touchstart",handlers.touchstart,{passive:!1}),self.canvas.addEventListener("touchend",handlers.touchend,{passive:!1}),self.canvas.addEventListener("touchmove",handlers.touchmove,{passive:!1})},rglwidgetClass.prototype.initGL0=function(){return window.WebGLRenderingContext?void 0:void this.alertOnce("Your browser does not support WebGL. See http://get.webgl.org")},rglwidgetClass.prototype.initGL=function(){var self=this,success=!1;if(this.gl){if(this.drawing||!this.gl.isContextLost())return this.gl;this.restartCanvas()}this.canvas.addEventListener("webglcontextrestored",this.onContextRestored,!1),this.canvas.addEventListener("webglcontextlost",this.onContextLost,!1),this.gl=this.canvas.getContext("webgl",this.webGLoptions)||this.canvas.getContext("experimental-webgl",this.webGLoptions),success=!!(this.gl&&this.gl instanceof WebGLRenderingContext),success||this.alertOnce("Your browser does not support WebGL. See http://get.webgl.org"),this.index_uint=this.gl.getExtension("OES_element_index_uint");var save=this.startDrawing();return Object.keys(this.scene.objects).forEach(function(key){self.initObjId(parseInt(key,10))}),this.stopDrawing(save),this.gl},rglwidgetClass.prototype.resize=function(el){this.canvas.width=el.width,this.canvas.height=el.height},rglwidgetClass.prototype.initSphere=function(sections,segments){var i,j,k,ind,mod1,pole,v=[],phi=[],theta=[],it=[],centers=[],result={};for(i=0;sections-1>i;i++)phi.push((i+1)/sections-.5);for(j=0;segments>j;j++)for(theta.push(2*j/segments),i=0;sections-1>i;i++)v.push([Math.sin(Math.PI*theta[j])*Math.cos(Math.PI*phi[i]),Math.sin(Math.PI*phi[i]),Math.cos(Math.PI*theta[j])*Math.cos(Math.PI*phi[i]),theta[j]/2,phi[i]+.5]);for(pole=v.length,v.push([0,-1,0,0,0]),v.push([0,1,0,0,1]),result.values=new Float32Array(this.flatten(v)),result.vertexCount=v.length,mod1=segments*(sections-1),j=0;segments>j;j++){for(i=0;sections-2>i;i++)ind=i+(sections-1)*j,it.push([ind%mod1,(ind+sections-1)%mod1,(ind+sections)%mod1]),it.push([ind%mod1,(ind+sections)%mod1,(ind+1)%mod1]);it.push([pole,(j+1)*(sections-1)%mod1,((j+1)*(sections-1)-sections+1)%mod1]),it.push([pole+1,((j+1)*(sections-1)-1)%mod1,((j+1)*(sections-1)+sections-2)%mod1])}for(result.it=new Uint16Array(this.flatten(it)),i=0;ij;j++)for(k=0;3>k;k++)centers[i][j]+=v[it[i][k]][j]/3;result.centers=centers,result.vOffsets={vofs:0,cofs:-1,nofs:0,radofs:-1,oofs:-1,tofs:3,nextofs:-1,pointofs:-1,stride:5},result.f=[],result.indices={},result.colorCount=1,result.type="sphere",this.sphere=result,this.initShapeGL(this.sphere)},rglwidgetClass.prototype.initCube=function(){var i,j,k,i0,i1,i2,normal,v=[[0,0,0],[1,0,0],[0,1,0],[1,1,0],[0,0,1],[1,0,1],[0,1,1],[1,1,1]],ib=[[0,2,3,1],[2,6,7,3],[1,3,7,5],[0,4,6,2],[0,1,5,4],[4,5,7,6]],centers=[],result={};for(i=0;ij;j++)for(k=0;4>k;k++)centers[i][j]+=v[ib[i][k]][j]/4;for(result.centers=centers,result.values=new Float32Array(144),result.vertexCount=24,result.vertices=new Array(24),result.normals=new Array(24),i=0;6>i;i++){for(j=0;4>j;j++)for(i0=ib[i][j],result.vertices[4*i+j]=v[i0],i1=ib[i][(j+1)%4],i2=ib[i][(j+2)%4],0===j&&(normal=this.normalize(this.xprod(this.vdiff(v[i1],v[i0]),this.vdiff(v[i2],v[i0])))),result.normals[4*i+j]=normal,k=0;3>k;k++)result.values[24*i+6*j+k]=v[i0][k],result.values[24*i+6*j+3+k]=normal[k];for(j=0;4>j;j++)ib[i][j]=4*i+j}result.ib=new Uint16Array(this.flatten(ib)),result.vOffsets={vofs:0,cofs:-1,nofs:3,radofs:-1,oofs:-1,tofs:-1,nextofs:-1,pointofs:-1,stride:6},result.f=[],result.indices={},result.colorCount=1,result.type="quads",this.cube=result,this.initShapeGL(this.cube)},rglwidgetClass.prototype.initShapeGL=function(shape){var gl=this.gl||this.initGL();gl.isContextLost()||(shape.buf=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,shape.buf),gl.bufferData(gl.ARRAY_BUFFER,shape.values,gl.STATIC_DRAW),shape.ibuf=[gl.createBuffer(),gl.createBuffer()])},rglwidgetClass.prototype.initShapeFromObj=function(shape,obj){var i,pass,f,mode,self=this,is_back=function(i){var normal=shape.normals[i],pt=shape.vertices[i];return normal.push(-self.dotprod(normal,pt)),normal=self.multVM(normal,self.normMatrix),normal[2]<0};if(shape.ofsLoc=obj.ofsLoc,shape.texLoc=obj.texLoc,shape.sampler=obj.sampler,shape.uFogMode=obj.uFogMode,shape.uFogColor=obj.uFogColor,shape.uFogParms=obj.uFogParms,shape.userAttribLocations=obj.userAttribLocations,shape.userUniformLocations=obj.userUniformLocations,shape.normLoc=obj.normLoc,shape.invPrMatLoc=obj.invPrMatLoc,shape.clipLoc=obj.clipLoc,shape.nextLoc=obj.nextLoc,shape.pointLoc=obj.pointLoc,shape.aspectLoc=obj.aspectLoc,shape.lwdLoc=obj.lwdLoc,shape.prog=obj.prog,shape.material=obj.material,shape.flags=obj.flags,shape.someHidden=obj.someHidden,shape.fastTransparency=obj.fastTransparency,shape.nlights=obj.nlights,shape.emission=obj.emission,shape.emissionLoc=obj.emissionLoc,shape.shininess=obj.shininess,shape.shininessLoc=obj.shininessLoc,shape.ambient=obj.ambient,shape.ambientLoc=obj.ambientLoc,shape.specular=obj.specular,shape.specularLoc=obj.specularLoc,shape.diffuse=obj.diffuse,shape.diffuseLoc=obj.diffuseLoc,shape.lightDir=obj.lightDir,shape.lightDirLoc=obj.lightDirLoc,shape.viewpoint=obj.viewpoint,shape.viewpointLoc=obj.viewpointLoc,shape.finite=obj.finite,shape.finiteLoc=obj.finiteLoc,shape.prMatLoc=obj.prMatLoc,shape.mvMatLoc=obj.mvMatLoc,shape.normMatLoc=obj.normMatLoc,shape.frontLoc=obj.frontLoc,shape.index_uint=!1,shape.is_transparent=obj.is_transparent,shape.ignoreExtent=obj.ignoreExtent,shape.passes!==obj.passes||JSON.stringify(shape.pmode)!==JSON.stringify(obj.pmode))for(shape.passes=obj.passes,shape.pmode=obj.pmode,pass=0;pass1?[obj.colors[1]]:[obj.colors[0]],axes:obj.axes,initialized:!1},this.scene.objects[obj.ticks.id]=obj.ticks,obj.labels={id:obj.id+.3,type:"text",flags:this.f_has_fog+this.f_fixed_size+this.f_fixed_quads,material:{lit:!1},colors:obj.colors.length>1?[obj.colors[1]]:[obj.colors[0]],cex:[[1]],family:[["sans"]],font:[[1]],adj:[[.5,.5,.5]],ignoreExtent:!0,initialized:!1},this.scene.objects[obj.labels.id]=obj.labels,obj.initialized=!0},rglwidgetClass.prototype.initObjId=function(id){return"number"!=typeof id&&this.alertOnce("initObj id is "+typeof id),this.initObj(this.getObj(id))},rglwidgetClass.prototype.initObj=function(obj){var polygon_offset,texinfo,drawtype,nclipplanes,f,nrows,oldrows,i,j,v,v1,v2,mat,uri,matobj,pass,pmode,dim,nx,nz,nrow,flags=obj.flags,type=obj.type,is_lit=this.isSet(flags,this.f_is_lit),fat_lines=this.isSet(flags,this.f_fat_lines),has_texture=this.isSet(flags,this.f_has_texture),fixed_quads=this.isSet(flags,this.f_fixed_quads),is_transparent=this.isSet(flags,this.f_is_transparent),depth_sort=this.isSet(flags,this.f_depth_sort),sprites_3d=this.isSet(flags,this.f_sprites_3d),fixed_size=this.isSet(flags,this.f_fixed_size),is_twosided=this.isSet(flags,this.f_is_twosided),is_brush=this.isSet(flags,this.f_is_brush),has_fog=this.isSet(flags,this.f_has_fog),has_normals="undefined"!=typeof obj.normals||"spheres"===obj.type,has_indices="undefined"!=typeof obj.indices,gl=this.gl||this.initGL();if(obj.initialized=!0,obj.someHidden=!1,obj.is_transparent=is_transparent,this.expandBufferedFields(obj),"subscene"!==type){if("bboxdeco"===type)return this.initBBox(obj);if("spheres"===type&&"undefined"==typeof this.sphere&&this.initSphere(16,16),"light"===type)return obj.ambient=new Float32Array(obj.colors[0].slice(0,3)),obj.diffuse=new Float32Array(obj.colors[1].slice(0,3)),obj.specular=new Float32Array(obj.colors[2].slice(0,3)),void(obj.lightDir=new Float32Array(obj.vertices[0]));if("clipplanes"===type)return void(obj.vClipplane=this.flatten(this.cbind(obj.normals,obj.offsets)));if("background"===type&&"undefined"!=typeof obj.ids)return void(obj.quad=this.flatten([].concat(obj.ids)));if(polygon_offset=this.getMaterial(obj,"polygon_offset"),(0!==polygon_offset[0]||0!==polygon_offset[1])&&(obj.polygon_offset=polygon_offset),is_transparent&&(depth_sort=["triangles","quads","surface","spheres","sprites","text"].indexOf(type)>=0),is_brush&&this.initSelection(obj.id),"undefined"==typeof obj.vertices&&(obj.vertices=[]),v=obj.vertices,obj.vertexCount=has_indices?obj.indices.length:v.length,obj.vertexCount){if(is_twosided&&!has_normals){if("undefined"==typeof obj.userAttributes&&(obj.userAttributes={}),v1=Array(v.length),v2=Array(v.length),"triangles"===obj.type||"quads"===obj.type)for(nrow="triangles"===obj.type?3:4,i=0;ij;j++)v1[nrow*i+j]=v[nrow*i+(j+1)%nrow],v2[nrow*i+j]=v[nrow*i+(j+2)%nrow];else if("surface"===obj.type)for(dim=obj.dim[0],nx=dim[0],nz=dim[1],j=0;nx>j;j++)for(i=0;nz>i;i++)nz>i+1&&nx>j+1?(v2[j+nx*i]=v[j+nx*(i+1)],v1[j+nx*i]=v[j+1+nx*(i+1)]):nz>i+1?(v2[j+nx*i]=v[j-1+nx*i],v1[j+nx*i]=v[j+nx*(i+1)]):(v2[j+nx*i]=v[j+nx*(i-1)],v1[j+nx*i]=v[j-1+nx*(i-1)]);obj.userAttributes.aPos1=v1,obj.userAttributes.aPos2=v2}if(!sprites_3d){if(gl.isContextLost())return;"undefined"!=typeof obj.prog&&(gl.deleteProgram(obj.prog),obj.prog=void 0),obj.prog=gl.createProgram(),gl.attachShader(obj.prog,this.getShader(gl.VERTEX_SHADER,this.getVertexShader(obj))),gl.attachShader(obj.prog,this.getShader(gl.FRAGMENT_SHADER,this.getFragmentShader(obj))),gl.bindAttribLocation(obj.prog,0,"aPos"),gl.bindAttribLocation(obj.prog,1,"aCol"),gl.linkProgram(obj.prog);var linked=gl.getProgramParameter(obj.prog,gl.LINK_STATUS);if(!linked){var lastError=gl.getProgramInfoLog(obj.prog);return console.warn("Error in program linking:"+lastError),void gl.deleteProgram(obj.prog)}}"text"===type&&(texinfo=this.drawTextToCanvas(obj.texts,this.flatten(obj.cex),this.flatten(obj.family),this.flatten(obj.family))),fixed_quads&&!sprites_3d&&(obj.ofsLoc=gl.getAttribLocation(obj.prog,"aOfs")),(has_texture||"text"===type)&&(obj.texture||(obj.texture=gl.createTexture(),gl.bindTexture(gl.TEXTURE_2D,obj.texture),gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,1,1,0,gl.RGBA,gl.UNSIGNED_BYTE,new Uint8Array([255,255,255,255]))),obj.texLoc=gl.getAttribLocation(obj.prog,"aTexcoord"),obj.sampler=gl.getUniformLocation(obj.prog,"uSampler")),has_fog&&!sprites_3d&&(obj.uFogMode=gl.getUniformLocation(obj.prog,"uFogMode"),obj.uFogColor=gl.getUniformLocation(obj.prog,"uFogColor"),obj.uFogParms=gl.getUniformLocation(obj.prog,"uFogParms")),has_texture&&(mat=obj.material,"undefined"!=typeof mat.uri?uri=mat.uri:"undefined"==typeof mat.uriElementId?(matobj=this.getObj(mat.uriId),uri="undefined"!=typeof matobj?matobj.material.uri:""):uri=document.getElementById(mat.uriElementId).rglinstance.getObj(mat.uriId).material.uri,this.loadImageToTexture(uri,obj.texture)),"text"===type&&this.handleLoadedTexture(obj.texture,this.textureCanvas);var nc,cofs,nofs,radofs,oofs,tofs,vnew,fnew,alias,colors,key,selection,filter,adj,offset,attr,last,options,stride=3,nextofs=-1,pointofs=-1;if(obj.alias=void 0,colors=obj.colors,j=this.scene.crosstalk.id.indexOf(obj.id),j>=0){for(key=this.scene.crosstalk.key[j],options=this.scene.crosstalk.options[j],colors=colors.slice(0),i=0;i1?(cofs=stride,stride+=4,v=this.cbind(v,colors)):(cofs=-1,obj.onecolor=this.flatten(colors)),has_normals&&"spheres"!==obj.type?(nofs=stride,stride+=3,v=this.cbind(v,"undefined"!=typeof obj.pnormals?obj.pnormals:obj.normals)):nofs=-1,"undefined"!=typeof obj.radii?(radofs=stride,stride+=1,obj.radii.length===v.length?v=this.cbind(v,obj.radii):1===obj.radii.length&&(v=v.map(function(row){return row.concat(obj.radii[0])}))):radofs=-1,has_indices)for(f=Array(obj.indices.length),i=0;ij;j++)v1=vnew[fnew[4*i+j]],v1[tofs+2]=2*(v1[tofs]-v1[tofs+2])*texinfo.widths[i],v1[tofs+3]=2*(v1[tofs+1]-v1[tofs+3])*texinfo.textHeights[i],v1[tofs]=(texinfo.offsetsx[i]+v1[tofs]*texinfo.widths[i])/texinfo.canvasX,v1[tofs+1]=1-(texinfo.offsetsy[i]-v1[tofs+1]*texinfo.textHeights[i])/texinfo.canvasY,vnew[fnew[4*i+j]]=v1;v=vnew,obj.vertexCount=v.length,obj.f=[fnew,fnew]}else"undefined"!=typeof obj.texcoords?(tofs=stride,stride+=2,oofs=-1,v=this.cbind(v,obj.texcoords)):(tofs=-1,oofs=-1);else{tofs=stride,stride+=2,oofs=stride,stride+=3,vnew=new Array(4*v.length),fnew=new Array(4*v.length),alias=new Array(v.length);var rescale=fixed_size?72:1,size=obj.radii,s=rescale*size[0]/2;for(last=v.length,f=obj.f[0],obj.adj=this.flatten(obj.adj),"undefined"!=typeof obj.pos?(obj.pos=this.flatten(obj.pos),offset=obj.adj[0]):offset=0,i=0;i1&&(s=rescale*size[i]/2),adj[0]=2*s*(adj[0]-.5),adj[1]=2*s*(adj[1]-.5),adj[2]=2*s*(adj[2]-.5),vnew[i]=v[i].concat([0,0]).concat([-s-adj[0],-s-adj[1],-adj[2]]),fnew[4*i]=f[i],vnew[last]=v[i].concat([1,0]).concat([s-adj[0],-s-adj[1],-adj[2]]),fnew[4*i+1]=last++,vnew[last]=v[i].concat([1,1]).concat([s-adj[0],s-adj[1],-adj[2]]),fnew[4*i+2]=last++,vnew[last]=v[i].concat([0,1]).concat([-s-adj[0],s-adj[1],-adj[2]]),fnew[4*i+3]=last++,alias[i]=[last-3,last-2,last-1];v=vnew,obj.vertexCount=v.length,obj.f=[fnew,fnew]}if(obj.alias=alias,"undefined"!=typeof obj.userAttributes){obj.userAttribOffsets={},obj.userAttribLocations={},obj.userAttribSizes={};for(attr in obj.userAttributes)obj.userAttribLocations[attr]=gl.getAttribLocation(obj.prog,attr),obj.userAttribLocations[attr]>=0&&(obj.userAttribOffsets[attr]=stride,v=this.cbind(v,obj.userAttributes[attr]),stride=v[0].length,obj.userAttribSizes[attr]=stride-obj.userAttribOffsets[attr])}if("undefined"!=typeof obj.userUniforms){obj.userUniformLocations={};for(attr in obj.userUniforms)obj.userUniformLocations[attr]=gl.getUniformLocation(obj.prog,attr)}if(sprites_3d)for(obj.userMatrix=new CanvasMatrix4,obj.userMatrix.load(this.flatten(obj.usermatrix)),obj.objects=this.flatten([].concat(obj.ids)),is_lit=!1,obj.adj=this.flatten(obj.adj),"undefined"!=typeof obj.pos?(obj.pos=this.flatten(obj.pos),obj.offset=obj.adj[0]):obj.offset=0,i=0;ii;i++)obj.clipLoc[i]=gl.getUniformLocation(obj.prog,"vClipplane"+i);if(is_lit)for(obj.emissionLoc=gl.getUniformLocation(obj.prog,"emission"),obj.emission=new Float32Array(this.stringToRgb(this.getMaterial(obj,"emission"))),obj.shininessLoc=gl.getUniformLocation(obj.prog,"shininess"),obj.shininess=this.getMaterial(obj,"shininess"),obj.nlights=this.countLights(),obj.ambientLoc=[],obj.ambient=new Float32Array(this.stringToRgb(this.getMaterial(obj,"ambient"))),obj.specularLoc=[],obj.specular=new Float32Array(this.stringToRgb(this.getMaterial(obj,"specular"))),obj.diffuseLoc=[],obj.lightDirLoc=[],obj.viewpointLoc=[],obj.finiteLoc=[],i=0;ii;i++)fnew[6*i]=f[3*i],fnew[6*i+1]=f[3*i+1],fnew[6*i+2]=f[3*i+1],fnew[6*i+3]=f[3*i+2],fnew[6*i+4]=f[3*i+2],fnew[6*i+5]=f[3*i]}else if("spheres"===type);else if("surface"===type)if(dim=obj.dim[0],nx=dim[0],nz=dim[1],"filled"===pmode)for(fnew=[],j=0;nx-1>j;j++)for(i=0;nz-1>i;i++)fnew.push(f[j+nx*i],f[j+nx*(i+1)],f[j+1+nx*(i+1)],f[j+nx*i],f[j+1+nx*(i+1)],f[j+1+nx*i]);else if("lines"===pmode)for(fnew=[],j=0;nx>j;j++)for(i=0;nz>i;i++)nz>i+1&&fnew.push(f[j+nx*i],f[j+nx*(i+1)]),nx>j+1&&fnew.push(f[j+nx*i],f[j+1+nx*i])}else if(nrows=Math.floor(obj.vertexCount/4),"filled"===pmode)for(fnew=Array(6*nrows),i=0;nrows>i;i++)fnew[6*i]=f[4*i],fnew[6*i+1]=f[4*i+1],fnew[6*i+2]=f[4*i+2],fnew[6*i+3]=f[4*i],fnew[6*i+4]=f[4*i+2],fnew[6*i+5]=f[4*i+3];else for(fnew=Array(8*nrows),i=0;nrows>i;i++)fnew[8*i]=f[4*i],fnew[8*i+1]=f[4*i+1],fnew[8*i+2]=f[4*i+1],fnew[8*i+3]=f[4*i+2],fnew[8*i+4]=f[4*i+2],fnew[8*i+5]=f[4*i+3],fnew[8*i+6]=f[4*i+3],fnew[8*i+7]=f[4*i];obj.f[pass]=fnew,drawtype=depth_sort?"DYNAMIC_DRAW":"STATIC_DRAW"}if(fat_lines){for(alias=void 0,obj.nextLoc=gl.getAttribLocation(obj.prog,"aNext"),obj.pointLoc=gl.getAttribLocation(obj.prog,"aPoint"),obj.aspectLoc=gl.getUniformLocation(obj.prog,"uAspect"),obj.lwdLoc=gl.getUniformLocation(obj.prog,"uLwd"),pass=0;passj;j++)vnew[k][nextofs+j]=vnew[f[i+1]][j];for(vnew[k][pointofs]=-1,vnew[k][pointofs+1]=-1,fnew[ind]=k,last++,vnew[last]=vnew[k].slice(),vnew[last][pointofs]=1,fnew[ind+1]=last,alias[f[i]].push(last-1,last),last++,k=last,vnew[k]=vnew[f[i+1]].slice(),j=0;3>j;j++)vnew[k][nextofs+j]=vnew[f[i]][j];vnew[k][pointofs]=-1,vnew[k][pointofs+1]=1,fnew[ind+2]=k,fnew[ind+3]=fnew[ind+1],last++,vnew[last]=vnew[k].slice(),vnew[last][pointofs]=1,fnew[ind+4]=last,fnew[ind+5]=fnew[ind+2],ind+=6,alias[f[i+1]].push(last-1,last)}if(vnew.length=last+1,v=vnew,obj.vertexCount=v.length,"undefined"!=typeof alias&&"undefined"!=typeof obj.alias){var oldalias=obj.alias,newalias=Array(obj.alias.length);for(i=0;i65535?this.index_uint?(obj.f[pass]=new Uint32Array(obj.f[pass]),obj.index_uint=!0):this.alertOnce("Object has "+obj.vertexCount+" vertices, not supported in this browser."):(obj.f[pass]=new Uint16Array(obj.f[pass]),obj.index_uint=!1);stride!==v[0].length&&this.alertOnce("problem in stride calculation"),obj.vOffsets={vofs:0,cofs:cofs,nofs:nofs,radofs:radofs,oofs:oofs,tofs:tofs,nextofs:nextofs,pointofs:pointofs,stride:stride},obj.values=new Float32Array(this.flatten(v)),"spheres"===type||sprites_3d||(obj.buf=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,obj.buf),gl.bufferData(gl.ARRAY_BUFFER,obj.values,gl.STATIC_DRAW),obj.ibuf=Array(obj.passes),obj.ibuf[0]=gl.createBuffer(),gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,obj.ibuf[0]),gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,obj.f[0],gl[drawtype]),is_twosided&&(obj.ibuf[1]=gl.createBuffer(),gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,obj.ibuf[1]),gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,obj.f[1],gl[drawtype]))),sprites_3d||(obj.mvMatLoc=gl.getUniformLocation(obj.prog,"mvMatrix"),obj.prMatLoc=gl.getUniformLocation(obj.prog,"prMatrix")),fixed_size&&(obj.textScaleLoc=gl.getUniformLocation(obj.prog,"textScale")),is_lit&&!sprites_3d&&(obj.normMatLoc=gl.getUniformLocation(obj.prog,"normMatrix")),is_twosided&&(obj.frontLoc=gl.getUniformLocation(obj.prog,"front"),has_normals&&(obj.invPrMatLoc=gl.getUniformLocation(obj.prog,"invPrMatrix")))}}},rglwidgetClass.prototype.initialize=function(el,x){if(this.textureCanvas=document.createElement("canvas"),this.textureCanvas.style.display="block",this.scene=x,this.normMatrix=new CanvasMatrix4,this.invPrMatrix=new CanvasMatrix4,this.saveMat={},this.distance=null,this.posLoc=0,this.colLoc=1,el&&(el.rglinstance=this,this.el=el,this.webGLoptions=el.rglinstance.scene.webGLoptions,this.initCanvas()),"undefined"!=typeof Shiny){var self=this;Shiny.addCustomMessageHandler("shinyGetPar3d",function(message){var i,param,subscene=self.getObj(message.subscene),parameters=[].concat(message.parameters),result={tag:message.tag,subscene:message.subscene};if("undefined"!=typeof subscene)for(i=0;ii;i++)z=this.prmvMatrix.m13*obj.centers[i][0]+this.prmvMatrix.m23*obj.centers[i][1]+this.prmvMatrix.m33*obj.centers[i][2]+this.prmvMatrix.m43,w=this.prmvMatrix.m14*obj.centers[i][0]+this.prmvMatrix.m24*obj.centers[i][1]+this.prmvMatrix.m34*obj.centers[i][2]+this.prmvMatrix.m44,depth=z/w,result[i]={context:context,objid:objid,subid:subid,index:i,depth:depth};return result},rglwidgetClass.prototype.getSpherePieces=function(context,subid,obj){return obj.fastTransparency?0===subid?this.getPieces(context,obj.id,-1,obj):[]:this.getPieces(context,obj.id,subid,this.sphere)},rglwidgetClass.prototype.getCubePieces=function(context,obj){return this.getPieces(context,obj.id,0,this.cube)},rglwidgetClass.prototype.mergePieces=function(pieces){var result=[];if(pieces.length>0){var i,thiscontext=pieces[0].context,thisobjid=pieces[0].objid,thissubid=pieces[0].subid,indices=[];for(i=0;i0;)diff=c1.pop()-c2.pop();0===diff&&(diff=j.objid-i.objid),0===diff&&(diff=j.subid-i.subid)}return diff},result=[];return pieces.length&&(result=pieces.sort(compare)),result},rglwidgetClass.prototype.startDrawing=function(){var value=this.drawing;return this.drawing=!0,value},rglwidgetClass.prototype.stopDrawing=function(saved){this.drawing=saved,!saved&&this.gl&&this.gl.isContextLost()&&this.restartCanvas()},rglwidgetClass.prototype.planeUpdateTriangles=function(obj,bbox){var x,xrow,elem,A,d,nhits,i,j,k,u,v,w,intersect,which,v0,v2,vx,reverse,perms=[[0,0,1],[1,2,2],[2,1,0]],face1=[],face2=[],normals=[],nPlanes=obj.normals.length;for(obj.bbox=bbox,obj.vertices=[],obj.initialized=!1,elem=0;nPlanes>elem;elem++){for(x=[],A=obj.normals[elem],d=obj.offsets[elem][0],nhits=0,i=0;3>i;i++)for(j=0;2>j;j++)for(k=0;2>k;k++)u=perms[0][i],v=perms[1][i],w=perms[2][i],0!==A[w]&&(intersect=-(d+A[u]*bbox[j+2*u]+A[v]*bbox[k+2*v])/A[w],bbox[2*w]3)for(i=0;nhits-2>i;i++){for(which=0,j=i+1;nhits>j;j++)if(face1[i]===face1[j]||face1[i]===face2[j]||face2[i]===face1[j]||face2[i]===face2[j]){which=j;break}which>i+1&&(this.swap(x,i+1,which),this.swap(face1,i+1,which),this.swap(face2,i+1,which))}if(nhits>=3)for(v0=[x[0][0]-x[1][0],x[0][1]-x[1][1],x[0][2]-x[1][2]],v2=[x[2][0]-x[1][0],x[2][1]-x[1][1],x[2][2]-x[1][2]],vx=this.xprod(v0,v2),reverse=this.dotprod(vx,A)>0,i=0;nhits-2>i;i++)for(obj.vertices.push(x[0]),normals.push(A),j=1;3>j;j++)obj.vertices.push(x[i+(reverse?3-j:j)]),normals.push(A)}obj.pnormals=normals},rglwidgetClass.prototype.mode4type={points:"POINTS",linestrip:"LINE_STRIP",abclines:"LINES",lines:"LINES",sprites:"TRIANGLES",planes:"TRIANGLES",text:"TRIANGLES",quads:"TRIANGLES",surface:"TRIANGLES",triangles:"TRIANGLES",sphere:"TRIANGLES"},rglwidgetClass.prototype.disableArrays=function(obj,enabled){var i,attr,gl=this.gl||this.initGL(),objLocs=["normLoc","texLoc","ofsLoc","pointLoc","nextLoc"],thisLocs=["posLoc","colLoc"];for(i=0;i=0?(gl.enableVertexAttribArray(obj.normLoc),gl.vertexAttribPointer(obj.normLoc,3,gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.vOffsets.nofs),!0):!1},rglwidgetClass.prototype.doTexture=function(obj){var gl=this.gl,is_spheres="spheres"===obj.type;return gl.enableVertexAttribArray(obj.texLoc),is_spheres?gl.vertexAttribPointer(obj.texLoc,2,gl.FLOAT,!1,4*this.sphere.vOffsets.stride,4*this.sphere.vOffsets.tofs):gl.vertexAttribPointer(obj.texLoc,2,gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.vOffsets.tofs),gl.activeTexture(gl.TEXTURE0),gl.bindTexture(gl.TEXTURE_2D,obj.texture),gl.uniform1i(obj.sampler,0),!0},rglwidgetClass.prototype.doUserAttributes=function(obj){if("undefined"!=typeof obj.userAttributes){var gl=this.gl;for(var attr in obj.userAttribSizes)gl.enableVertexAttribArray(obj.userAttribLocations[attr]),gl.vertexAttribPointer(obj.userAttribLocations[attr],obj.userAttribSizes[attr],gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.userAttribOffsets[attr])}},rglwidgetClass.prototype.doUserUniforms=function(obj){if("undefined"!=typeof obj.userUniforms){var gl=this.gl;for(var attr in obj.userUniformLocations){var loc=obj.userUniformLocations[attr];if(null!==loc){var uniform=obj.userUniforms[attr];if("undefined"==typeof uniform.length)gl.uniform1f(loc,uniform);else if("undefined"==typeof uniform[0].length)switch(uniform=new Float32Array(uniform),uniform.length){case 2:gl.uniform2fv(loc,uniform);break;case 3:gl.uniform3fv(loc,uniform);break;case 4:gl.uniform4fv(loc,uniform);break;default:console.warn("bad uniform length")}else 4===uniform.length&&4===uniform[0].length?gl.uniformMatrix4fv(loc,!1,new Float32Array(uniform.getAsArray())):console.warn("unsupported uniform matrix")}}}},rglwidgetClass.prototype.doLoadIndices=function(obj,pass,indices){var fnew,step,gl=this.gl,f=obj.f[pass],type=obj.type,fat_lines=this.isSet(obj.flags,this.f_fat_lines);switch(type){case"points":step=1;break;case"abclines":case"lines":step=fat_lines?6:2;break;case"linestrip":step=fat_lines?6:1;break;case"sphere":case"planes":case"triangles":step=3;break;case"text":case"sprites":case"quads":case"surface":step=6;break;default:return console.error("loadIndices for "+type),0}fnew=obj.index_uint?new Uint32Array(step*indices.length):new Uint16Array(step*indices.length);for(var i=0;ij;j++)fnew[step*i+j]=f[step*indices[i]+j];return gl.bufferData(gl.ELEMENT_ARRAY_BUFFER,fnew,gl.DYNAMIC_DRAW),fnew.length},rglwidgetClass.prototype.doMasking=function(mask){var gl=this.gl;gl.depthMask(mask)},rglwidgetClass.prototype.doBlending=function(blend){var gl=this.gl;blend?(gl.blendFuncSeparate(gl.SRC_ALPHA,gl.ONE_MINUS_SRC_ALPHA,gl.ONE,gl.ONE),gl.enable(gl.BLEND)):gl.disable(gl.BLEND)},rglwidgetClass.prototype.doFog=function(obj,subscene){var fogmode,color,gl=this.gl,observer=subscene.par3d.observer[2],sintheta=Math.sin(subscene.par3d.FOV*Math.PI/180/2),parms=[this.frustum.near-2*observer,this.frustum.far-2*observer,this.fogScale,(1-sintheta)/(1+sintheta)];switch("undefined"==typeof this.fogType&&(this.fogType="none"),"undefined"==typeof this.fogScale&&(parms[2]=1),0===sintheta&&(parms[3]=1/3),this.fogType){case"none":fogmode=0;break;case"linear":fogmode=1;break;case"exp":fogmode=2;break;case"exp2":fogmode=3;break;default:console.error("Unknown fogtype "+this.fogType)}gl.uniform1i(obj.uFogMode,fogmode),color=this.fogColor,gl.uniform3f(obj.uFogColor,color[0],color[1],color[2]),gl.uniform4f(obj.uFogParms,parms[0],parms[1],parms[2],parms[3])},rglwidgetClass.prototype.drawSimple=function(obj,subscene,context){var count,pass,mode,pmode,flags=obj.flags,type=obj.type,is_lit=this.isSet(flags,this.f_is_lit),has_texture=this.isSet(flags,this.f_has_texture),is_transparent=this.isSet(flags,this.f_is_transparent),fixed_size=this.isSet(flags,this.f_fixed_size),fixed_quads=this.isSet(flags,this.f_fixed_quads),is_lines=this.isSet(flags,this.f_is_lines),fat_lines=this.isSet(flags,this.f_fat_lines),is_twosided=this.isSet(flags,this.f_is_twosided),has_fog=this.isSet(flags,this.f_has_fog),has_normals="undefined"!=typeof obj.normals||"sphere"===obj.type,gl=this.gl||this.initGL(),enabled={};if(obj.initialized||this.initObj(obj),count=obj.vertexCount,!count)return[];if(is_transparent=is_transparent||obj.someHidden,is_transparent&&this.opaquePass)return this.getPieces(context,obj.id,0,obj);for(this.doDepthTest(obj),this.doMasking(this.getMaterial(obj,"depth_mask")),gl.useProgram(obj.prog),this.doPolygonOffset(obj),gl.bindBuffer(gl.ARRAY_BUFFER,obj.buf),gl.uniformMatrix4fv(obj.prMatLoc,!1,new Float32Array(this.prMatrix.getAsArray())),gl.uniformMatrix4fv(obj.mvMatLoc,!1,new Float32Array(this.mvMatrix.getAsArray())),this.doClipping(obj,subscene),is_lit&&this.doLighting(obj,subscene),has_fog&&this.doFog(obj,subscene),this.doUserAttributes(obj),this.doUserUniforms(obj),gl.enableVertexAttribArray(this.posLoc),enabled.posLoc=!0,(has_texture||"text"===obj.type)&&(enabled.texLoc=this.doTexture(obj)),enabled.colLoc=this.doColors(obj),is_lit&&(enabled.normLoc=this.doNormals(obj)),fixed_size&&gl.uniform3f(obj.textScaleLoc,.75/this.vp.width,.75/this.vp.height,1),fixed_quads&&(gl.enableVertexAttribArray(obj.ofsLoc),enabled.ofsLoc=!0,gl.vertexAttribPointer(obj.ofsLoc,3,gl.FLOAT,!1,4*obj.vOffsets.stride,4*obj.vOffsets.oofs)),pass=0;passi;i++)sphereMV=new CanvasMatrix4,idx=this.opaquePass?i:obj.fastTransparency?indices[i]:context.subid,"undefined"==typeof idx&&console.error("idx is undefined"),baseofs=idx*obj.vOffsets.stride,ofs=baseofs+obj.vOffsets.radofs,sscale=obj.values[ofs],sphereMV.scale(sscale/scale[0],sscale/scale[1],sscale/scale[2]),sphereMV.translate(obj.values[baseofs],obj.values[baseofs+1],obj.values[baseofs+2]),sphereMV.multRight(saveMV),this.mvMatrix=sphereMV,this.setnormMatrix2(),this.setprmvMatrix(),drawing?(nc>1&&(this.sphere.onecolor=obj.values.slice(baseofs+obj.vOffsets.cofs,baseofs+obj.vOffsets.cofs+4)),this.drawSimple(this.sphere,subscene,context)):result=result.concat(this.getSpherePieces(context,i,obj));return drawing&&this.disableArrays(obj,enabled),this.normMatrix=saveNorm,this.mvMatrix=saveMV,this.prmvMatrix=savePRMV,result},rglwidgetClass.prototype.drawClipplanes=function(obj){for(var count=obj.offsets.length,IMVClip=[],i=0;count>i;i++)IMVClip[i]=this.multMV(this.invMatrix,obj.vClipplane.slice(4*i,4*(i+1)));return obj.IMVClip=IMVClip,[]},rglwidgetClass.prototype.drawLinestrip=function(obj,subscene,context){var origIndices,i,j,margin=obj.material.margin;if("undefined"!=typeof margin&&!this.marginVecToDataVec(obj,subscene))return[];if(this.opaquePass)return this.drawSimple(obj,subscene,context);for(origIndices=context.indices.slice(),i=0;iiOrig;iOrig++)for(j=this.opaquePass?iOrig:context.subid,pos=this.multVM([].concat(obj.vertices[j]).concat(1),origMV),radius=obj.radii.length>1?obj.radii[j][0]:obj.radii[0][0],this.mvMatrix=new CanvasMatrix4(userMatrix),adj=this.getAdj(obj,j,offset),this.mvMatrix.translate(1-2*adj[0],1-2*adj[1],1-2*adj[2]),this.mvMatrix.scale(radius),this.mvMatrix.translate(pos[0]/pos[3],pos[1]/pos[3],pos[2]/pos[3]),this.setprmvMatrix(),i=0;i0)for(this.invMatrix=new CanvasMatrix4(this.mvMatrix),this.invMatrix.invert(),i=0;i0;)switch(objid=context.pop(),obj=this.getObj(objid),type=obj.type){case"subscene":this.drawSubscene(objid,!1);break;case"sprites":result=result.concat(context.pop());break;case"spheres":break;case"bboxdeco":result=result.concat(context.pop());break;default:console.error("bad type '",type,"' in setContext")}return result},rglwidgetClass.prototype.drawPieces=function(pieces){var i,context,prevcontext=[];for(this.doBlending(!0),i=0;i=i;i++)adds=adds.concat(control.subsets[i]);else adds=adds.concat(control.subsets[value]);for(deletes=fullset.filter(function(x){return adds.indexOf(x)<0}),i=0;ivalue-svals[j-1]&&(j-=1);break}if(obj=this.getObj(control.objid),"undefined"!=typeof obj.vOffsets){for(varies=!0,k=0;ncol>k;k++)if(attrib=attributes[k],"undefined"!=typeof attrib&&(ofs=obj.vOffsets[ofss[attrib]],0>ofs)){switch(attrib){case"alpha":case"red":case"green":case"blue":obj.colors=[obj.colors[0],obj.colors[0]]}varies=!1}varies||this.initObjId(control.objid)}for(propvals=obj.values,aliases=obj.alias,"undefined"==typeof aliases&&(aliases=[]),k=0;ncol>k;k++)if(newval=direct?value:interp?p*values[j-1][k]+(1-p)*values[j][k]:values[j][k],attrib=attributes[k],vertex=vertices[k],alias=aliases[vertex],("planes"===obj.type||"clipplanes"===obj.type)&&(ofs=["nx","ny","nz","offset"].indexOf(attrib),ofs>=0))3>ofs?obj.normals[vertex][ofs]!==newval&&(obj.normals[vertex][ofs]=newval,obj.initialized=!1):obj.offsets[vertex][0]!==newval&&(obj.offsets[vertex][0]=newval,obj.initialized=!1);else if(ofs=obj.vOffsets[ofss[attrib]],0>ofs)this.alertOnce("Attribute '"+attrib+"' not found in object "+control.objid);else if(stride=obj.vOffsets.stride,ofs+=pos[attrib],entry=vertex*stride+ofs,propvals[entry]=newval,"undefined"!=typeof alias)for(a=0;ai;i++)if(null!==births[i]){for(age=time-births[i],j0=1;age>ages[j0];j0++);p[i]=1/0===ages[j0]?1:ages[j0]>ages[j0-1]?(ages[j0]-age)/(ages[j0]-ages[j0-1]):0,j[i]=j0}for(l=0;nobjs>l;l++)if(objid=objids[l],obj=this.getObj(objid),varies=!0,"undefined"!=typeof obj.vOffsets){for(k=0;kofs)){switch(attribs[k]){case"colors":case"alpha":case"red":case"green":case"blue":obj.colors=[obj.colors[0],obj.colors[0]]}varies=!1}varies||this.initObjId(objid)}for(l=0;nobjs>l;l++)if(objid=objids[l],obj=this.getObj(objid),"undefined"!=typeof obj.vOffsets){for(aliases=obj.alias,"undefined"==typeof aliases&&(aliases=[]),propvals=obj.values,stride=obj.vOffsets.stride,k=0;k=0){for(dim=dims[k],ofs+=pos[k],i=0;steps>i;i++)if(alias=aliases[i],null!==births[i])for(d=0;dim>d;d++)if(propvals[i*stride+ofs+d]=p[i]*attrib[dim*(j[i]-1)+d]+(1-p[i])*attrib[dim*j[i]+d],"undefined"!=typeof alias)for(a=0;a=0){for(keys=this.scene.crosstalk.key[j],obj=this.getObj(id),someHidden=!1,k=0;k=xmin&&xmax>=x&&y>=ymin&&ymax>=y&&z>=-1&&1>=z?selection.push(keys[k]):someHidden=!0);obj.someHidden=someHidden&&(filter||selection.length),obj.initialized=!1,this.equalArrays(selection,this.scene.crosstalk.selection)||(handle=this.scene.crosstalk.sel_handle[j],handle.set(selection,{rglSubsceneId:this.select.subscene}))}},rglwidgetClass.prototype.selection=function(event,filter){var i,j,ids,obj,keys,selection,someHidden,crosstalk=this.scene.crosstalk;for(crosstalk=this.scene.crosstalk,filter?(filter=crosstalk.filter=event.value,selection=crosstalk.selection):(selection=crosstalk.selection=event.value,filter=crosstalk.filter),ids=crosstalk.id,i=0;ithis.stopTime+this.stepSize/2||this.value=1.5*h+.5)?1/(1+h):1.5/(1+h5),i_small=dx10&&(cell=9+cell/10),cell*=shrink_sml,min_n>1&&(cell/=min_n)):(cell=dx,ndiv>1&&(cell/=ndiv)),20*DBL_MIN>cell?cell=20*DBL_MIN:10*cell>DBL_MAX&&(cell=.1*DBL_MAX),base=Math.pow(10,Math.floor(Math.log10(cell))),unit=base,(U=2*base)-cell1||!i_small)&&(0!==lo?lo*=1-DBL_EPSILON:lo=-DBL_MIN,0!==up?up*=1+DBL_EPSILON:up=+DBL_MIN);ns*unit>lo+rounding_eps*unit;)ns--;for(;up-rounding_eps*unit>nu*unit;)nu++;return k=Math.floor(.5+nu-ns),min_n>k?(k=min_n-k,ns>=0?(nu+=k/2,ns-=k/2+k%2):(ns-=k/2,nu+=k/2+k%2),ndiv=min_n):ndiv=k,return_bounds?(lo>ns*unit&&(lo=ns*unit),nu*unit>up&&(up=nu*unit)):(lo=ns,up=nu),{lo:lo,up:up,ndiv:ndiv,unit:unit}},rglwidgetClass.prototype.getTickEdges=function(prmv){var dim,i,j,k,edges,hull,step,vertices=[[0,0,0,1],[0,0,1,1],[0,1,0,1],[0,1,1,1],[1,0,0,1],[1,0,1,1],[1,1,0,1],[1,1,1,1]],result=[],proj=[];for(i=0;idim;dim++){for(edges=[],step=Math.pow(2,2-dim),i=0;4>i;i++)for(j=0===dim?i:1===dim?i+2*(i>1):2*i,k=0;knewval&&(best=j,best2=edges[i][1],val=newval);"undefined"!=typeof best?(result[dim]=vertices[best].slice(0,3),result[dim][dim]=void 0):result[dim]=void 0}}return result},rglwidgetClass.prototype.getTickLocations=function(obj){var dim,i,limits,value,len,delta,range,locations=[],result=[[],[],[]],bbox=obj.bbox;for(obj.needsAxisCallback=!1,dim=0;3>dim;dim++)switch(limits=bbox.slice(2*dim,2*dim+2),range=limits[1]-limits[0],obj.axes.mode[dim]){case"custom":for(i=0;ii;i++)result[dim].push(i*delta);break;case"fixednum":for(len=obj.axes.nticks[dim],delta=len>1?range/(len-1):0,i=0;len>i;i++)result[dim].push(i*delta/range);break;case"pretty":for(locations=this.R_pretty(limits[0],limits[1],5,2,.75,[1.5,2.75],0,0),i=locations.lo;i<=locations.up;i++)value=(i*locations.unit-limits[0])/range,value>0&&1>value&&result[dim].push(value);break;case"user":obj.needsAxisCallback=!0}return result},rglwidgetClass.prototype.getTickVertices=function(ticks){var dim,i,j,locations,edge,vertices=[],edges=ticks.edges;for(dim=0;3>dim;dim++)if(locations=ticks.locations[dim],locations.length)for(i=0;ij;j++)(2>dim&&j===1-dim||2===dim&&0===j)&&(edge[j]+=2*(edge[j]-.5)/ticks.axes.marklen[dim]);vertices.push(edge)}ticks.vertices=vertices,ticks.vertexCount=vertices.length,ticks.values=new Float32Array(this.flatten(vertices)),ticks.initialized=!1},rglwidgetClass.prototype.placeTickLabels=function(obj){var i,j,k,vertex,locations,dim,ticks=obj.ticks,labels=obj.labels,vertices=[],tickvertices=ticks.vertices,edges=obj.ticks.edges;for(j=0,dim=0;3>dim;dim++)if("undefined"!=typeof edges[dim]&&(locations=ticks.locations[dim],locations.length))for(i=0;i=tickvertices.length)break;for(vertex=tickvertices[j].slice(),k=0;3>k;k++)vertex[k]+=2*(tickvertices[j+1][k]-vertex[k]);vertices.push(vertex),j+=2}labels.vertices=vertices,labels.centers=labels.vertices,labels.initialized=!1},rglwidgetClass.prototype.setTickLabels=function(obj){var mode,locations,nticks,dim,i,limits,range,values,max,ticks=obj.ticks,labels=[],start=0,edges=obj.ticks.edges;for(dim=0;3>dim;dim++)if("undefined"!=typeof edges[dim]){if(mode=obj.axes.mode[dim],nticks=obj.axes.nticks[dim],"custom"===mode)labels=labels.concat(obj.texts.slice(start,start+nticks));else{for(limits=obj.bbox.slice(2*dim,2*(dim+1)),range=limits[1]-limits[0],locations=ticks.locations[dim],max=-1/0,values=[],i=0;ii;i++)expand=obj.axes.expand[i],center[i]=(bbox[2*i]+bbox[2*i+1])/2,bbox[2*i]=center[i]-expand*(bbox[2*i+1]-center[i]),bbox[2*i+1]=center[i]+expand*(bbox[2*i+1]-center[i]);obj.bbox=bbox,obj.center=center},rglwidgetClass.prototype.setBBoxMatrices=function(obj){var bboxNorm,bboxMV,scale,saved={normMatrix:new CanvasMatrix4(this.normMatrix),mvMatrix:new CanvasMatrix4(this.mvMatrix)},bbox=obj.bbox;return bboxNorm=new CanvasMatrix4,scale=[bbox[1]-bbox[0],bbox[3]-bbox[2],bbox[5]-bbox[4]],bboxNorm.scale(1/scale[0],1/scale[1],1/scale[2]),bboxNorm.multRight(saved.normMatrix),this.normMatrix=bboxNorm,bboxMV=new CanvasMatrix4,bboxMV.scale(scale[0],scale[1],scale[2]),bboxMV.translate(bbox[0],bbox[2],bbox[4]),bboxMV.multRight(saved.mvMatrix),this.mvMatrix=obj.mvMatrix=bboxMV,saved.prmvMatrix=null===this.prmvMatrix?null:new CanvasMatrix4(this.prmvMatrix),this.setprmvMatrix(),obj.prmvMatrix=this.prmvMatrix,saved},rglwidgetClass.prototype.restoreBBoxMatrices=function(saved){this.normMatrix=saved.normMatrix,this.mvMatrix=saved.mvMatrix,this.prmvMatrix=saved.prmvMatrix},rglwidgetClass.prototype.getMarginParameters=function(bboxdeco,material){var saved,edges,i,line,level,trans,scale,bbox=bboxdeco.bbox,edge=[].concat(material.edge),at=material.margin;if(material.floating){if(saved=this.setBBoxMatrices(bboxdeco),edges=this.getTickEdges(this.prmvMatrix)[at],this.restoreBBoxMatrices(saved),"undefined"==typeof edges)return void 0;for(i=0;3>i;i++)edges[i]<1&&(edges[i]=-1),edge[i]=edge[i]*edges[i]}switch(at){case 0:line=1,level=2;break;case 1:line=0,level=2;break;case 2:line=0,level=1}return scale=[edge[0]*(bbox[1]-bbox[0])/bboxdeco.axes.marklen[0],edge[1]*(bbox[3]-bbox[2])/bboxdeco.axes.marklen[1],edge[2]*(bbox[5]-bbox[4])/bboxdeco.axes.marklen[2]],trans=[1===edge[0]?bbox[1]:bbox[0],1===edge[1]?bbox[3]:bbox[2],1===edge[2]?bbox[5]:bbox[4]],{at:at,line:line,level:level,trans:trans,scale:scale}},rglwidgetClass.prototype.fixVertex=function(orig,parms,center,bbox){var vertex=[0,0,0];return vertex[parms.at]=this.missing(orig[0])?center[parms.at]:"-Inf"===orig[0]?bbox[2*parms.at]:"Inf"===orig[0]?bbox[2*parms.at+1]:orig[0],vertex[parms.line]=parms.scale[parms.line]*orig[1]+parms.trans[parms.line],vertex[parms.level]=parms.scale[parms.level]*orig[2]+parms.trans[parms.level],vertex},rglwidgetClass.prototype.fixNormal=function(orig,parms){var vertex=[0,0,0];return vertex[parms.at]=orig[0],vertex[parms.line]=orig[1]/parms.scale[parms.line],vertex[parms.level]=orig[2]/parms.scale[parms.level],vertex},rglwidgetClass.prototype.marginVecToDataVec=function(obj,subscene){var center,bbox,parms,parmsjson,i,vertex,bboxdeco=this.getBBoxDeco(subscene),orig=obj.orig,vertices=[],normals=[],centers=[];if("undefined"==typeof orig&&(orig={vert:obj.vertices,norm:obj.normals,cent:obj.centers,doNormals:"undefined"!=typeof obj.normals,doCenters:"undefined"!=typeof obj.centers,parms:""},obj.orig=orig),"undefined"!=typeof bboxdeco){if(this.setBbox(bboxdeco,subscene),center=bboxdeco.center,bbox=bboxdeco.bbox,parms=this.getMarginParameters(bboxdeco,obj.material),"undefined"==typeof parms)return!1;if(parmsjson=JSON.stringify(parms),parmsjson===orig.parms)return!0;for(orig.parms=parmsjson,i=0;ii;i++)if("user"===obj.axes.mode[i]&&(axis=["x","y","z"][i],"undefined"!=typeof obj.callbacks&&"undefined"!=typeof(code=obj.callbacks[axis]))){if("undefined"!=typeof edges[i])for(j=0;3>j;j++)"undefined"!=typeof edges[i][j]&&(axis+=edges[i][j]>0?"+":"-");fn=Function('"use strict";return ('+code+")")(),fn.call(this,axis)}}; diff --git a/docs/articles/index.html b/docs/articles/index.html index 19f87a3d..6fbfe3e0 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -1,74 +1,12 @@ - - - - - - - -Articles • nat - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Articles • nat - - + + - - -
-
- -
- - -
- +
- - + + diff --git a/docs/articles/neurons-as-graph.html b/docs/articles/neurons-as-graph.html index a567dd23..831e57af 100644 --- a/docs/articles/neurons-as-graph.html +++ b/docs/articles/neurons-as-graph.html @@ -26,6 +26,8 @@ + +
+
-
-

-Introduction

+
+

Introduction +

Neurons can helpfully be treated as graphs (branching trees) in which nodes connected by edges define the morphology of the neuron. The nat package provides a number of built-in functions that allow you to analyse the branching structure of graphs

-

https://natverse.github.io/nat/reference/index.html#section-neurons-as-graphs-

+

https://natverse.org/nat/reference/index.html

or use aspects of the branching structure to manipulate graphs. Examples of such functions include the strahler_order function which calculates the Strahler branch order for each node or segment in the neuron or the spine function that extracts the longest path across the neuron.

More sophisticated analysis and manipulations can be carried out by converting neuron objects into ngraph objects.

-
-

-Neurons as Graphs

-

A neuron will typically be a graph in the form of a binary tree. We follow the convention of the Matlab trees toolbox by Hermann Cuntz and colleagues in treating the root (typically the soma) as the origin of the graph and then having directed edges leaving the root.

+
+

Neurons as Graphs +

+

A neuron will typically be a graph in the form of a binary tree. We follow the convention of the Matlab trees toolbox by Hermann Cuntz and colleagues in treating the root (typically the soma) as the origin of the graph and then having directed edges leaving the root.

neuron-as-graph

@@ -151,347 +153,347 @@

  • have some other significance e.g. are globally unique across all neurons in a database and therefore have large values (which may be challenging for R to to represent give its maxint of 2^31 - 1=2.1474836^{9})
  • -library(nat)
    +library(nat)
     n=Cell07PNs[[1]]
    -summary(n)
    -
    ##   root nodes segments branchpoints endpoints cable.length
    -## 1    1   180       33           16        18     297.1763
    +summary(n)

    +
    ##   root nodes segments branchpoints endpoints cable.length nTrees
    +## 1    1   180       33           16        18     297.1763      1

    We can extract the points as follows:

    -
    ## [1] 1
    +
    ## [1] 1
    -
    ##  [1]  34  48  51  75  78  95  98  99 108 109 115 119 135 143 160 169
    +
    ##  [1]  34  48  51  75  78  95  98  99 108 109 115 119 135 143 160 169
    -
    ##  [1]   1  42  59  62  80  85  96 100 102 112 117 121 134 148 154 165 172 180
    +
    ##  [1]   1  42  59  62  80  85  96 100 102 112 117 121 134 148 154 165 172 180

    Segments are unbranched connected sequences of nodes that terminate in a branch point or end point.

    -
    -

    -Built-in neuron graph functions

    +
    +

    Built-in neuron graph functions +

    We will give a few examples of the use of the built-in functions that treat neurons as graphs.

    -
    -

    -Strahler Order

    -

    The branching structure of a neuron is commonly summarised by calculating the Strahler Order.

    +
    +

    Strahler Order +

    +

    The branching structure of a neuron is commonly summarised by calculating the Strahler Order.

     n=Cell07PNs[[1]]
     so=strahler_order(n)
    -orders=1:max(so$points)
    +orders=1:max(so$points)
     for (i in orders) {
    -  plot(subset(n, so$points==i), col=i, add = i!=1, boundingbox = boundingbox(n))
    +  plot(subset(n, so$points==i), col=i, add = i!=1, boundingbox = boundingbox(n))
     }

    Note the use of multiple calls to plot.neuron using the add=TRUE argument for all but the first plot. Note also the use of the boundingbox argument/function in order to ensure that the plot is set up with appropriate axes for the whole neuron even if only part of it is plotted in the first call to plot.

    -
    -

    -Spine

    +
    +

    Spine +

    You can find the longest path across a neuron using the spine function.

     n=Cell07PNs[[1]]
     sp=spine(n)
    -plot(n, col='grey')
    -plot(sp, add=T, col='blue')
    +plot(n, col='grey') +plot(sp, add=T, col='blue')

    spine has a variety of options that you can use to control the results.

    -
    -

    -Segment graph

    +
    +

    Segment graph +

    You can use the segmentgraph function to make a simplified representation of the branching structure of the neuron. In this object (which has class igraph associated with the powerful igraph package) each unbranched segment in the original neuron (which might have contained many vertices) is collapsed to a single edge joining the branch points (which are retained).

     sg=segmentgraph(Cell07PNs[[1]])
    -plot(sg)
    +plot(sg)

    It can be useful to plot the graph with a tree layout:

    -plot(sg, layout=igraph::layout_as_tree, edge.arrow.size=.3, vertex.size=15)
    +plot(sg, layout=igraph::layout_as_tree, edge.arrow.size=.3, vertex.size=15)

    Note that the root of the neuron is placed at the top of the plot (point number 1 in the graph above) and that successive branching orders and leaves are placed on levels further down the plot. Note also that the labels on the plot correspond to the identifiers of the points in the original neuron (aka the PointNo field, see first section).

    If you need to work with the original identifiers of the points in the segmentgraph object, they are stored as igraph node attributes. You can access them like this:

    -igraph::V(sg)$label
    -
    ##  [1]   1  34  42  48  51  59  62  75  78  80  85  95  96  98  99 100 102 108 109
    -## [20] 112 115 117 119 121 134 135 143 148 154 160 165 169 172 180
    +igraph::V(sg)$label
    +
    ##  [1]   1  34  42  48  51  59  62  75  78  80  85  95  96  98  99 100 102 108 109
    +## [20] 112 115 117 119 121 134 135 143 148 154 160 165 169 172 180
    -igraph::V(sg)$vid
    -
    ##  [1]   1  34  42  48  51  59  62  75  78  80  85  95  96  98  99 100 102 108 109
    -## [20] 112 115 117 119 121 134 135 143 148 154 160 165 169 172 180
    +igraph::V(sg)$vid
    +
    ##  [1]   1  34  42  48  51  59  62  75  78  80  85  95  96  98  99 100 102 108 109
    +## [20] 112 115 117 119 121 134 135 143 148 154 160 165 169 172 180

    label encodes the PointNo column and vid the raw integer index of the point in the node array. If and only if the PointNo identifier is a sequentially increasing integer starting at 1, then these will be identical. The SWC format is a little vague about whether they should indeed be the same, but is normally understood to imply it. However there are many SWC files in the wild that violate this assumption.

    -

    You can also use the endpoints() and rootpoints() functions with the segmentgraph objects as well as any function that expects an igraph object. We can use this to find the branchpoints upstream of all end points using the igraph::adjacent_vertices() function. We use mode="all" to handle the situation where the root node is also an end point (i.e. a leaf node).

    +

    You can also use the endpoints() and rootpoints() functions with the segmentgraph objects as well as any function that expects an igraph object. We can use this to find the branchpoints upstream of all end points using the igraph::adjacent_vertices() function. We use mode="all" to handle the situation where the root node is also an end point (i.e. a leaf node).

    -
    ##  [1]  1  3  6  7 10 11 13 16 17 20 22 24 25 28 29 31 33 34
    +
    ##  [1]  1  3  6  7 10 11 13 16 17 20 22 24 25 28 29 31 33 34
    -ups=unlist(igraph::adjacent_vertices(sg, endpoints(sg), mode='all'))
    +ups=unlist(igraph::adjacent_vertices(sg, endpoints(sg), mode='all'))
     # this maps the segmentgraph node indices back to indices for the neuron
    -igraph::V(sg)$vid[ups]
    -
    ##  [1]  34  34  51  51  78  78  95  99  99 109 115 119 119 143 143 160 169 169
    +igraph::V(sg)$vid[ups]
    +
    ##  [1]  34  34  51  51  78  78  95  99  99 109 115 119 119 143 143 160 169 169

    Here we plot those terminal branchpoints in red while internal branches are displayed in blue.

    -plot(n, WithNodes = F)
    -terminal_branches=igraph::V(sg)$vid[ups]
    +plot(n, WithNodes = F)
    +terminal_branches=igraph::V(sg)$vid[ups]
     other_branches=setdiff(branchpoints(n), terminal_branches)
    -points(xyzmatrix(n)[terminal_branches,1:2], col='red')
    -points(xyzmatrix(n)[other_branches,1:2], col='blue')
    +points(xyzmatrix(n)[terminal_branches,1:2], col='red') +points(xyzmatrix(n)[other_branches,1:2], col='blue')

    -
    -

    -ngraph objects

    -

    The nat package provides a bridge for neurons to the rich cross-platform igraph library. We provide a class ngraph that is a thin wrapper for the igraph class. This looks after things that we might need to know about a neuron (like the 3D coordinates of each node) while still giving access to all of the graph functions in the igraph package.

    +
    +

    ngraph objects +

    +

    The nat package provides a bridge for neurons to the rich cross-platform igraph library. We provide a class ngraph that is a thin wrapper for the igraph class. This looks after things that we might need to know about a neuron (like the 3D coordinates of each node) while still giving access to all of the graph functions in the igraph package.

     g=as.ngraph(Cell07PNs[[1]])
    -class(g)
    -
    ## [1] "ngraph" "igraph"
    +class(g)
    +
    ## [1] "ngraph" "igraph"
     g
    -
    ## IGRAPH 4386416 DN-- 180 179 -- 
    -## + attr: name (v/n), X (v/n), Y (v/n), Z (v/n), diam (v/n)
    -## + edges from 4386416 (vertex names):
    -##  [1]  1-> 2  2-> 3  3-> 4  4-> 5  5-> 6  6-> 7  7-> 8  8-> 9  9->10 10->11
    -## [11] 11->12 12->13 13->14 14->15 15->16 16->17 17->18 18->19 19->20 20->21
    -## [21] 21->22 22->23 23->24 24->25 25->26 26->27 27->28 28->29 29->30 30->31
    -## [31] 31->32 32->33 33->34 34->35 35->36 36->37 37->38 38->39 39->40 40->41
    -## [41] 41->42 34->43 43->44 44->45 45->46 46->47 47->48 48->49 49->50 50->51
    -## [51] 51->52 52->53 53->54 54->55 55->56 56->57 57->58 58->59 51->60 60->61
    -## [61] 61->62 48->63 63->64 64->65 65->66 66->67 67->68 68->69 69->70 70->71
    -## [71] 71->72 72->73 73->74 74->75 75->76 76->77 77->78 78->79 79->80 78->81
    -## + ... omitted several edges
    +
    ## IGRAPH c0855af DN-- 180 179 -- 
    +## + attr: name (v/n), X (v/n), Y (v/n), Z (v/n), diam (v/n)
    +## + edges from c0855af (vertex names):
    +##  [1]  1-> 2  2-> 3  3-> 4  4-> 5  5-> 6  6-> 7  7-> 8  8-> 9  9->10 10->11
    +## [11] 11->12 12->13 13->14 14->15 15->16 16->17 17->18 18->19 19->20 20->21
    +## [21] 21->22 22->23 23->24 24->25 25->26 26->27 27->28 28->29 29->30 30->31
    +## [31] 31->32 32->33 33->34 34->35 35->36 36->37 37->38 38->39 39->40 40->41
    +## [41] 41->42 34->43 43->44 44->45 45->46 46->47 47->48 48->49 49->50 50->51
    +## [51] 51->52 52->53 53->54 54->55 55->56 56->57 57->58 58->59 51->60 60->61
    +## [61] 61->62 48->63 63->64 64->65 65->66 66->67 67->68 68->69 69->70 70->71
    +## [71] 71->72 72->73 73->74 74->75 75->76 76->77 77->78 78->79 79->80 78->81
    +## + ... omitted several edges

    You can use functions such as

    -igraph::diameter(g)
    -
    ## [1] 89
    +igraph::diameter(g)
    +
    ## [1] 89

    to find the length of the longest path across the neuron. This is defined in terms of the number of intervening nodes. You can also make a graph in which the edge weights are the euclidean distance between the connected 3D nodes:

     gw=as.ngraph(Cell07PNs[[1]], weights=TRUE)
    -igraph::diameter(gw)
    -
    ## [1] 186.0859
    +igraph::diameter(gw)
    +
    ## [1] 186.0859

    This gives you the longest path length (geodesic) across the graph in units of µm in this case.

    -

    Note that although you can do library(igraph), it adds a lot of functions to the search path, some of which have name clashes, so I often just use the package name (igraph::) prepended to the function that I want to call.

    -
    -

    -Walking along ngraph objects

    +

    Note that although you can do library(igraph), it adds a lot of functions to the search path, some of which have name clashes, so I often just use the package name (igraph::) prepended to the function that I want to call.

    +
    +

    Walking along ngraph objects +

    You can use the graph representation of neurons e.g. to find the path between nodes.

     g=as.ngraph(Cell07PNs[[1]], weights=TRUE)
     eg=endpoints(g)
     
    -p=igraph::shortest_paths(g, from=1, to=180)
    +p=igraph::shortest_paths(g, from=1, to=180)
     p$vpath[[1]]
    -
    ## + 90/180 vertices, named, from 6e0a78c:
    -##  [1] 1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19 
    -## [20] 20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  43  44  45  46 
    -## [39] 47  48  63  64  65  66  67  68  69  70  71  72  73  74  75  86  87  88  89 
    -## [58] 90  91  92  93  94  95  97  98  103 104 105 106 107 108 135 155 156 157 158
    -## [77] 159 160 166 167 168 169 173 174 175 176 177 178 179 180
    +
    ## + 90/180 vertices, named, from 03d8b9a:
    +##  [1] 1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19 
    +## [20] 20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  43  44  45  46 
    +## [39] 47  48  63  64  65  66  67  68  69  70  71  72  73  74  75  86  87  88  89 
    +## [58] 90  91  92  93  94  95  97  98  103 104 105 106 107 108 135 155 156 157 158
    +## [77] 159 160 166 167 168 169 173 174 175 176 177 178 179 180
     # fails
    -p2=igraph::shortest_paths(g, from=180, to=1)
    -
    ## Warning in igraph::shortest_paths(g, from = 180, to = 1): At
    -## structural_properties.c:4597 :Couldn't reach some vertices
    +p2=igraph::shortest_paths(g, from=180, to=1)
    +
    ## Warning in igraph::shortest_paths(g, from = 180, to = 1): At
    +## structural_properties.c:4745 :Couldn't reach some vertices
     p2$vpath[[1]]
    -
    ## + 1/180 vertex, named, from 6e0a78c:
    -## [1] 1
    +
    ## + 1/180 vertex, named, from 03d8b9a:
    +## [1] 1
     # mode all will find the path irrespective of direction of links, which are
     # directed from the soma
    -p3=igraph::shortest_paths(g, from=180, to=1, mode = 'all')
    +p3=igraph::shortest_paths(g, from=180, to=1, mode = 'all')
     p3$vpath[[1]]
    -
    ## + 90/180 vertices, named, from 6e0a78c:
    -##  [1] 180 179 178 177 176 175 174 173 169 168 167 166 160 159 158 157 156 155 135
    -## [20] 108 107 106 105 104 103 98  97  95  94  93  92  91  90  89  88  87  86  75 
    -## [39] 74  73  72  71  70  69  68  67  66  65  64  63  48  47  46  45  44  43  34 
    -## [58] 33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15 
    -## [77] 14  13  12  11  10  9   8   7   6   5   4   3   2   1
    +
    ## + 90/180 vertices, named, from 03d8b9a:
    +##  [1] 180 179 178 177 176 175 174 173 169 168 167 166 160 159 158 157 156 155 135
    +## [20] 108 107 106 105 104 103 98  97  95  94  93  92  91  90  89  88  87  86  75 
    +## [39] 74  73  72  71  70  69  68  67  66  65  64  63  48  47  46  45  44  43  34 
    +## [58] 33  32  31  30  29  28  27  26  25  24  23  22  21  20  19  18  17  16  15 
    +## [77] 14  13  12  11  10  9   8   7   6   5   4   3   2   1
    -all.equal(p$vpath[[1]], rev(p3$vpath[[1]]))
    -
    ## [1] TRUE
    +all.equal(p$vpath[[1]], rev(p3$vpath[[1]]))
    +
    ## [1] TRUE
     # just the distances - by default uses mode=all
    -igraph::distances(g, v=1, to=180)
    -
    ##        180
    -## 1 186.0859
    +igraph::distances(g, v=1, to=180)
    +
    ##        180
    +## 1 186.0859
    -igraph::distances(g, v=180, to=1)
    -
    ##            1
    -## 180 186.0859
    +igraph::distances(g, v=180, to=1)

    +
    ##            1
    +## 180 186.0859
    -
    -

    -Node identifiers and indices

    +
    +

    Node identifiers and indices +

    Note that in the previous code block, nodes are identified by their index (i.e. an integer starting at 1). As already discussed, some neurons have an arbitrary numeric identifier for each node (this can be a large integer from a database table e.g. for CATMAID neurons). You access this identifier in all of the above calls by quoting it. For example:

     # using raw indices
    -igraph::distances(g, v=180, to=1)
    -
    ##            1
    -## 180 186.0859
    +igraph::distances(g, v=180, to=1)
    +
    ##            1
    +## 180 186.0859
     # using node identifiers
    -igraph::distances(g, v='180', to='1')
    -
    ##            1
    -## 180 186.0859
    +igraph::distances(g, v='180', to='1')
    +
    ##            1
    +## 180 186.0859
    -igraph::shortest_paths(g, from='1', to='180')$vpath[[1]]
    -
    ## + 90/180 vertices, named, from 6e0a78c:
    -##  [1] 1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19 
    -## [20] 20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  43  44  45  46 
    -## [39] 47  48  63  64  65  66  67  68  69  70  71  72  73  74  75  86  87  88  89 
    -## [58] 90  91  92  93  94  95  97  98  103 104 105 106 107 108 135 155 156 157 158
    -## [77] 159 160 166 167 168 169 173 174 175 176 177 178 179 180
    +igraph::shortest_paths(g, from='1', to='180')$vpath[[1]]
    +
    ## + 90/180 vertices, named, from 03d8b9a:
    +##  [1] 1   2   3   4   5   6   7   8   9   10  11  12  13  14  15  16  17  18  19 
    +## [20] 20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  43  44  45  46 
    +## [39] 47  48  63  64  65  66  67  68  69  70  71  72  73  74  75  86  87  88  89 
    +## [58] 90  91  92  93  94  95  97  98  103 104 105 106 107 108 135 155 156 157 158
    +## [77] 159 160 166 167 168 169 173 174 175 176 177 178 179 180

    In this instance, the results are identical since the node identifiers are the same as the raw indices. If we manipulate the node identifiers to add 1000 to each

     # make a copy of `ngraph` object and add 1000 to each identifier
     g2=g
    -igraph::V(g2)$name <- igraph::V(g2)$name+1000
    +igraph::V(g2)$name <- igraph::V(g2)$name+1000
     # make a neuron with thoose identifiers to see what happened to its structure:
     n2=as.neuron(g2)
     head(n2$d)
    -
    ##   PointNo Label        X        Y        Z    W Parent
    -## 1    1001     2 186.8660 132.7093 88.20393 1.01     -1
    -## 2    1002     2 187.3355 131.1558 90.59680 1.27   1001
    -## 3    1003     2 188.1165 130.2545 93.14326 1.14   1002
    -## 4    1004     2 188.4680 129.4757 94.97399 1.27   1003
    -## 5    1005     2 188.2875 128.7542 97.45621 1.27   1004
    -## 6    1006     2 188.2733 127.9567 99.16801 1.27   1005
    +
    ##   PointNo Label        X        Y        Z    W Parent
    +## 1    1001     2 186.8660 132.7093 88.20393 1.01     -1
    +## 2    1002     2 187.3355 131.1558 90.59680 1.27   1001
    +## 3    1003     2 188.1165 130.2545 93.14326 1.14   1002
    +## 4    1004     2 188.4680 129.4757 94.97399 1.27   1003
    +## 5    1005     2 188.2875 128.7542 97.45621 1.27   1004
    +## 6    1006     2 188.2733 127.9567 99.16801 1.27   1005

    then find path by identifier:

    -p2=igraph::shortest_paths(g2, from='1001', to='1180')$vpath[[1]]
    +p2=igraph::shortest_paths(g2, from='1001', to='1180')$vpath[[1]]
     p2
    -
    ## + 90/180 vertices, named, from 6e0a78c:
    -##  [1] 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
    -## [16] 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
    -## [31] 1031 1032 1033 1034 1043 1044 1045 1046 1047 1048 1063 1064 1065 1066 1067
    -## [46] 1068 1069 1070 1071 1072 1073 1074 1075 1086 1087 1088 1089 1090 1091 1092
    -## [61] 1093 1094 1095 1097 1098 1103 1104 1105 1106 1107 1108 1135 1155 1156 1157
    -## [76] 1158 1159 1160 1166 1167 1168 1169 1173 1174 1175 1176 1177 1178 1179 1180
    +
    ## + 90/180 vertices, named, from 03d8b9a:
    +##  [1] 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015
    +## [16] 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030
    +## [31] 1031 1032 1033 1034 1043 1044 1045 1046 1047 1048 1063 1064 1065 1066 1067
    +## [46] 1068 1069 1070 1071 1072 1073 1074 1075 1086 1087 1088 1089 1090 1091 1092
    +## [61] 1093 1094 1095 1097 1098 1103 1104 1105 1106 1107 1108 1135 1155 1156 1157
    +## [76] 1158 1159 1160 1166 1167 1168 1169 1173 1174 1175 1176 1177 1178 1179 1180

    Note that when the path is printed it shows the node identifiers. But when using the path, it may be necessary to convert to integers. This results in raw indices again.

    -as.integer(p2)
    -
    ##  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
    -## [20]  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  43  44  45  46
    -## [39]  47  48  63  64  65  66  67  68  69  70  71  72  73  74  75  86  87  88  89
    -## [58]  90  91  92  93  94  95  97  98 103 104 105 106 107 108 135 155 156 157 158
    -## [77] 159 160 166 167 168 169 173 174 175 176 177 178 179 180
    +as.integer(p2) +
    ##  [1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19
    +## [20]  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  43  44  45  46
    +## [39]  47  48  63  64  65  66  67  68  69  70  71  72  73  74  75  86  87  88  89
    +## [58]  90  91  92  93  94  95  97  98 103 104 105 106 107 108 135 155 156 157 158
    +## [77] 159 160 166 167 168 169 173 174 175 176 177 178 179 180
    -names(p2)
    -
    ##  [1] "1001" "1002" "1003" "1004" "1005" "1006" "1007" "1008" "1009" "1010"
    -## [11] "1011" "1012" "1013" "1014" "1015" "1016" "1017" "1018" "1019" "1020"
    -## [21] "1021" "1022" "1023" "1024" "1025" "1026" "1027" "1028" "1029" "1030"
    -## [31] "1031" "1032" "1033" "1034" "1043" "1044" "1045" "1046" "1047" "1048"
    -## [41] "1063" "1064" "1065" "1066" "1067" "1068" "1069" "1070" "1071" "1072"
    -## [51] "1073" "1074" "1075" "1086" "1087" "1088" "1089" "1090" "1091" "1092"
    -## [61] "1093" "1094" "1095" "1097" "1098" "1103" "1104" "1105" "1106" "1107"
    -## [71] "1108" "1135" "1155" "1156" "1157" "1158" "1159" "1160" "1166" "1167"
    -## [81] "1168" "1169" "1173" "1174" "1175" "1176" "1177" "1178" "1179" "1180"
    +names(p2) +
    ##  [1] "1001" "1002" "1003" "1004" "1005" "1006" "1007" "1008" "1009" "1010"
    +## [11] "1011" "1012" "1013" "1014" "1015" "1016" "1017" "1018" "1019" "1020"
    +## [21] "1021" "1022" "1023" "1024" "1025" "1026" "1027" "1028" "1029" "1030"
    +## [31] "1031" "1032" "1033" "1034" "1043" "1044" "1045" "1046" "1047" "1048"
    +## [41] "1063" "1064" "1065" "1066" "1067" "1068" "1069" "1070" "1071" "1072"
    +## [51] "1073" "1074" "1075" "1086" "1087" "1088" "1089" "1090" "1091" "1092"
    +## [61] "1093" "1094" "1095" "1097" "1098" "1103" "1104" "1105" "1106" "1107"
    +## [71] "1108" "1135" "1155" "1156" "1157" "1158" "1159" "1160" "1166" "1167"
    +## [81] "1168" "1169" "1173" "1174" "1175" "1176" "1177" "1178" "1179" "1180"
    -
    -

    -Downstream nodes

    +
    +

    Downstream nodes +

    You can also ask for nodes upstream or downstream of a given starting node. For example the neurons in the Cell07PNs set have a tag called AxonLHEP that defines the entry point of the axon into the lateral horn neuropil of the fly brain. Here we defined

     n=Cell07PNs[[1]]
     g=as.ngraph(n)
     # find the nodes distal to this point
     # nb you must set unreachable=F if you only want to get downstream nodes
    -igraph::dfs(g, neimode='out', unreachable = FALSE, root=n$AxonLHEP)
    -
    ## $root
    -## [1] 71
    -## 
    -## $neimode
    -## [1] "out"
    -## 
    -## $order
    -## + 180/180 vertices, named, from 3f8e45b:
    -##   [1] 72   73   74   75   76   77   78   79   80   81   82   83   84   85   86  
    -##  [16] 87   88   89   90   91   92   93   94   95   96   97   98   99   100  101 
    -##  [31] 102  103  104  105  106  107  108  109  110  111  112  113  114  115  116 
    -##  [46] 117  118  119  120  121  122  123  124  125  126  127  128  129  130  131 
    -##  [61] 132  133  134  135  136  137  138  139  140  141  142  143  144  145  146 
    -##  [76] 147  148  149  150  151  152  153  154  155  156  157  158  159  160  161 
    -##  [91] 162  163  164  165  166  167  168  169  170  171  172  173  174  175  176 
    -## [106] 177  178  179  180  <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -## [121] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -## [136] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -## + ... omitted several vertices
    -## 
    -## $order.out
    -## NULL
    -## 
    -## $father
    -## NULL
    -## 
    -## $dist
    -## NULL
    +igraph::dfs(g, neimode='out', unreachable = FALSE, root=n$AxonLHEP)
    +
    ## $root
    +## [1] 71
    +## 
    +## $neimode
    +## [1] "out"
    +## 
    +## $order
    +## + 180/180 vertices, named, from 8cee915:
    +##   [1] 72   73   74   75   76   77   78   79   80   81   82   83   84   85   86  
    +##  [16] 87   88   89   90   91   92   93   94   95   96   97   98   99   100  101 
    +##  [31] 102  103  104  105  106  107  108  109  110  111  112  113  114  115  116 
    +##  [46] 117  118  119  120  121  122  123  124  125  126  127  128  129  130  131 
    +##  [61] 132  133  134  135  136  137  138  139  140  141  142  143  144  145  146 
    +##  [76] 147  148  149  150  151  152  153  154  155  156  157  158  159  160  161 
    +##  [91] 162  163  164  165  166  167  168  169  170  171  172  173  174  175  176 
    +## [106] 177  178  179  180  <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +## [121] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +## [136] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +## + ... omitted several vertices
    +## 
    +## $order.out
    +## NULL
    +## 
    +## $father
    +## NULL
    +## 
    +## $dist
    +## NULL
     # the proximal nodes back to the soma (including any branches)
    -igraph::dfs(g, neimode='in', unreachable = FALSE, root=n$AxonLHEP)
    -
    ## $root
    -## [1] 71
    -## 
    -## $neimode
    -## [1] "in"
    -## 
    -## $order
    -## + 180/180 vertices, named, from 3f8e45b:
    -##   [1] 72   71   70   69   68   67   66   65   64   63   48   47   46   45   44  
    -##  [16] 43   34   33   32   31   30   29   28   27   26   25   24   23   22   21  
    -##  [31] 20   19   18   17   16   15   14   13   12   11   10   9    8    7    6   
    -##  [46] 5    4    3    2    1    <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -##  [61] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -##  [76] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -##  [91] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -## [106] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -## [121] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -## [136] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    -## + ... omitted several vertices
    -## 
    -## $order.out
    -## NULL
    -## 
    -## $father
    -## NULL
    -## 
    -## $dist
    -## NULL
    +igraph::dfs(g, neimode='in', unreachable = FALSE, root=n$AxonLHEP)
    +
    ## $root
    +## [1] 71
    +## 
    +## $neimode
    +## [1] "in"
    +## 
    +## $order
    +## + 180/180 vertices, named, from 8cee915:
    +##   [1] 72   71   70   69   68   67   66   65   64   63   48   47   46   45   44  
    +##  [16] 43   34   33   32   31   30   29   28   27   26   25   24   23   22   21  
    +##  [31] 20   19   18   17   16   15   14   13   12   11   10   9    8    7    6   
    +##  [46] 5    4    3    2    1    <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +##  [61] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +##  [76] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +##  [91] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +## [106] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +## [121] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +## [136] <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA> <NA>
    +## + ... omitted several vertices
    +## 
    +## $order.out
    +## NULL
    +## 
    +## $father
    +## NULL
    +## 
    +## $dist
    +## NULL

    Note that dfs (depth first search) provides a good way to visit all the nodes of the neuron

    Let’s use this to make a function that prunes neurons downstream of this axon entry point:

     prune_from_lhep <- function(n, ...) {
       g=as.ngraph(n)
    -  downstream_indices=igraph::dfs(g, root = n$AxonLHEP, unreachable = FALSE)$order
    +  downstream_indices=igraph::dfs(g, root = n$AxonLHEP, unreachable = FALSE)$order
       prune_vertices(n, verticestoprune = downstream_indices, invert = TRUE)
     }
     pruned=nlapply(Cell07PNs[1:3], prune_from_lhep)
    -plot(Cell07PNs[1:3], col='grey')
    -plot(pruned, lwd=2, add = T)
    +plot(Cell07PNs[1:3], col='grey') +plot(pruned, lwd=2, add = T)

    The pruned neurons show up in red, green, and blue in the above plot.

    -
    -

    -Distal nodes

    +
    +

    Distal nodes +

    As of nat v1.10.0 there is a distal_to() function to provide a simpler access to nodes defined by graph position.

     n=Cell07PNs[[1]]
     distal_to(n, node.idx = n$AxonLHEP)
    -
    ##   [1]  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89
    -##  [19]  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107
    -##  [37] 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
    -##  [55] 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
    -##  [73] 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
    -##  [91] 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
    -## [109] 180
    +
    ##   [1]  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89
    +##  [19]  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107
    +##  [37] 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
    +##  [55] 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
    +##  [73] 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
    +##  [91] 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
    +## [109] 180

    One can find the complement (i.e. all the nodes that are not in the distal set) by comparing with the indices of all vertices.

    -setdiff(seq_len(nvertices(n)), distal_to(n, node.idx = n$AxonLHEP))
    -
    ##  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
    -## [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
    -## [51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    +setdiff(seq_len(nvertices(n)), distal_to(n, node.idx = n$AxonLHEP))
    +
    ##  [1]  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
    +## [26] 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
    +## [51] 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

    distal_to() allows you to write a slightly simpler version of the function above:

     prune_from_lhep2 <- function(n, ...) {
    @@ -499,13 +501,13 @@ 

    prune_vertices(n, verticestoprune = downstream_indices, invert = TRUE) } -all.equal(nlapply(Cell07PNs[1:3], prune_from_lhep2), pruned)

    -
    ## [1] TRUE
    +all.equal(nlapply(Cell07PNs[1:3], prune_from_lhep2), pruned)
    +
    ## [1] TRUE

    Notice that distal_to() will help with the situation where you need to find nodes using their identifiers rather than indices. For example tags in neurons loaded from the CATMAID reconstruction tool are defined by ids not indices.

     tokeep=distal_to(dl1neuron, node.pointno = dl1neuron$tags$SCHLEGEL_LH)
    -plot(dl1neuron, WithNodes = F, soma=2000)
    -plot(prune_vertices(dl1neuron, tokeep, invert = T), add=T, WithNodes = F, col='red', lwd=2)
    +plot(dl1neuron, WithNodes = F, soma=2000) +plot(prune_vertices(dl1neuron, tokeep, invert = T), add=T, WithNodes = F, col='red', lwd=2)

    @@ -522,11 +524,13 @@

    @@ -535,5 +539,7 @@

    + + diff --git a/docs/articles/neurons-as-graph_files/accessible-code-block-0.0.1/empty-anchor.js b/docs/articles/neurons-as-graph_files/accessible-code-block-0.0.1/empty-anchor.js deleted file mode 100644 index ca349fd6..00000000 --- a/docs/articles/neurons-as-graph_files/accessible-code-block-0.0.1/empty-anchor.js +++ /dev/null @@ -1,15 +0,0 @@ -// Hide empty tag within highlighted CodeBlock for screen reader accessibility (see https://github.com/jgm/pandoc/issues/6352#issuecomment-626106786) --> -// v0.0.1 -// Written by JooYoung Seo (jooyoung@psu.edu) and Atsushi Yasumoto on June 1st, 2020. - -document.addEventListener('DOMContentLoaded', function() { - const codeList = document.getElementsByClassName("sourceCode"); - for (var i = 0; i < codeList.length; i++) { - var linkList = codeList[i].getElementsByTagName('a'); - for (var j = 0; j < linkList.length; j++) { - if (linkList[j].innerHTML === "") { - linkList[j].setAttribute('aria-hidden', 'true'); - } - } - } -}); diff --git a/docs/articles/neurons-as-graph_files/anchor-sections-1.0/anchor-sections.css b/docs/articles/neurons-as-graph_files/anchor-sections-1.0/anchor-sections.css deleted file mode 100644 index 07aee5fc..00000000 --- a/docs/articles/neurons-as-graph_files/anchor-sections-1.0/anchor-sections.css +++ /dev/null @@ -1,4 +0,0 @@ -/* Styles for section anchors */ -a.anchor-section {margin-left: 10px; visibility: hidden; color: inherit;} -a.anchor-section::before {content: '#';} -.hasAnchor:hover a.anchor-section {visibility: visible;} diff --git a/docs/articles/neurons-as-graph_files/anchor-sections-1.0/anchor-sections.js b/docs/articles/neurons-as-graph_files/anchor-sections-1.0/anchor-sections.js deleted file mode 100644 index 570f99a0..00000000 --- a/docs/articles/neurons-as-graph_files/anchor-sections-1.0/anchor-sections.js +++ /dev/null @@ -1,33 +0,0 @@ -// Anchor sections v1.0 written by Atsushi Yasumoto on Oct 3rd, 2020. -document.addEventListener('DOMContentLoaded', function() { - // Do nothing if AnchorJS is used - if (typeof window.anchors === 'object' && anchors.hasOwnProperty('hasAnchorJSLink')) { - return; - } - - const h = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); - - // Do nothing if sections are already anchored - if (Array.from(h).some(x => x.classList.contains('hasAnchor'))) { - return null; - } - - // Use section id when pandoc runs with --section-divs - const section_id = function(x) { - return ((x.classList.contains('section') || (x.tagName === 'SECTION')) - ? x.id : ''); - }; - - // Add anchors - h.forEach(function(x) { - const id = x.id || section_id(x.parentElement); - if (id === '') { - return null; - } - let anchor = document.createElement('a'); - anchor.href = '#' + id; - anchor.classList = ['anchor-section']; - x.classList.add('hasAnchor'); - x.appendChild(anchor); - }); -}); diff --git a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-19-1.png b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-19-1.png index b0e421c0..e0ba3075 100644 Binary files a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-19-1.png and b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-19-1.png differ diff --git a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-23-1.png b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-23-1.png index 2d542335..ac86050d 100644 Binary files a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-23-1.png and b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-23-1.png differ diff --git a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-3-1.png b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-3-1.png index d2c73614..7b0d43a0 100644 Binary files a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-3-1.png and b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-3-1.png differ diff --git a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-4-1.png b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-4-1.png index 3ce1882d..491f6077 100644 Binary files a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-4-1.png and b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-4-1.png differ diff --git a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-5-1.png b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-5-1.png index a1afad25..266e68ca 100644 Binary files a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-5-1.png and b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-5-1.png differ diff --git a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-6-1.png index 1ef0dd39..fc8cd242 100644 Binary files a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-9-1.png b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-9-1.png index ac9bc6ec..e8f47c9f 100644 Binary files a/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-9-1.png and b/docs/articles/neurons-as-graph_files/figure-html/unnamed-chunk-9-1.png differ diff --git a/docs/articles/neurons-as-graph_files/header-attrs-2.7/header-attrs.js b/docs/articles/neurons-as-graph_files/header-attrs-2.7/header-attrs.js deleted file mode 100644 index dd57d92e..00000000 --- a/docs/articles/neurons-as-graph_files/header-attrs-2.7/header-attrs.js +++ /dev/null @@ -1,12 +0,0 @@ -// Pandoc 2.9 adds attributes on both header and div. We remove the former (to -// be compatible with the behavior of Pandoc < 2.8). -document.addEventListener('DOMContentLoaded', function(e) { - var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); - var i, h, a; - for (i = 0; i < hs.length; i++) { - h = hs[i]; - if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 - a = h.attributes; - while (a.length > 0) h.removeAttribute(a[0].name); - } -}); diff --git a/docs/articles/neurons-intro.html b/docs/articles/neurons-intro.html index 029157aa..e06334be 100644 --- a/docs/articles/neurons-intro.html +++ b/docs/articles/neurons-intro.html @@ -26,6 +26,8 @@ + +
    - -
    + + +
    -
    -

    -Preface

    +
    +

    Preface +

    This vignette is designed to give you a good introduction to some of the key features of nat by teaching you about how it handles individual neurons and collections of neurons.

    -

    The source code for this vignette is available at https://github.com/natverse/nat/blob/master/vignettes/neurons-intro.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow this link to edit and suggest an alternative wording. Don’t be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you!

    +

    The source code for this vignette is available at https://github.com/natverse/nat/blob/master/vignettes/neurons-intro.Rmd. If you find something unclear or notice a typo, I would be very happy if you would click on the Pencil Icon on that page or follow this link to edit and suggest an alternative wording. Don’t be shy about doing this; I have to review any change and even if your suggestion is not perfect it will still be a prompt for me to improve this document. Thank you!

    -
    -

    -Startup

    +
    +

    Startup +

    Install the package if required

    -install.packages('nat', dependencies = TRUE)
    +install.packages('nat', dependencies = TRUE)

    Load the package

    +library(nat)
    -
    -

    -Neurons and Neuronlists

    +
    +

    Neurons and Neuronlists +

    There are a number of basic built in types of data in R such as vectors and matrices, but it is also very easy to define new data types with specialised features to enable powerful and efficient analysis of particular kinds of data. These specialised data types are called classes and a specific instance of a class is an object (a neuroscience analogy: this is the difference between talking about the general class of mitral cells and the specific cell that you just sealed onto with your patch clamp electrode.)

    We will look at two key classes that nat defines for handling 3D structures of neurons

    • neuron
    • neuronlist
    -
    -

    -Sample Data

    -

    As an example we’re going to look at a data set of olfactory projection neurons originally published as Supplemental Information to accompany Jefferis, Potter et al, Cell (2007). A subset of the original data are distributed as a sample data object with the nat package, which we can load like so.

    +
    +

    Sample Data +

    +

    As an example we’re going to look at a data set of olfactory projection neurons originally published as Supplemental Information to accompany Jefferis, Potter et al, Cell (2007). A subset of the original data are distributed as a sample data object with the nat package, which we can load like so.

    -data("Cell07PNs")
    -

    For more information about these data see Cell07PNs.

    +data("Cell07PNs")
    +

    For more information about these data see Cell07PNs.

    This Cell07PNs object has two classes neuronlist and the base class list

    -class(Cell07PNs)
    -
    ## [1] "neuronlist" "list"
    +class(Cell07PNs)
    +
    ## [1] "neuronlist" "list"

    Many R objects inherit from the base class list (objects can have multiple classes in the same way that a mitral cell is also neuron) because this is a convenient container class into which you can put a variety of different kinds of data. In this case the Cell07PNs neuronlist contains 40 objects:

    -length(Cell07PNs)
    -
    ## [1] 40
    +length(Cell07PNs)
    +
    ## [1] 40
     # access the first neuron in the neuronlist
    -class(Cell07PNs[[1]])
    -
    ## [1] "neuron" "list"
    +class(Cell07PNs[[1]])
    +
    ## [1] "neuron" "list"

    each representing a traced neuron. We will now look in detail at these two classes.

    -
    -

    -Neurons

    +
    +

    Neurons +

    We start by extracting the first neuron in Cell07PNs, and assigning it to a variable. We can then plot the neuron so that we have an image of what we are talking about.

     n1=Cell07PNs[[1]]
    -plot(n1)
    +plot(n1)

    -
    -

    -Neuron internal structure

    +
    +

    Neuron internal structure +

    The str function (short for structure) allows us to take a look at the internal structure of this neuron object.

     # Use =1 so that we don't show complete structure
     # for objects inside n1
    -str(n1, max.level=1)
    -
    ## List of 24
    -##  $ CellType     : chr "DA1"
    -##  $ NeuronName   : chr "EBH11R"
    -##  $ InputFileName: 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc"
    -##  $ CreatedAt    : POSIXt[1:1], format: "2006-01-17 15:21:14"
    -##  $ NodeName     : Named chr "jefferis.joh.cam.ac.uk"
    -##   ..- attr(*, "names")= chr "nodename"
    -##  $ InputFileStat:'data.frame':   1 obs. of  10 variables:
    -##  $ InputFileMD5 : Named chr "fcacee3f874cbe2c6ad96214e6fee337"
    -##   ..- attr(*, "names")= 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc"
    -##  $ NumPoints    : int 180
    -##  $ StartPoint   : num 1
    -##  $ BranchPoints : num [1:16] 34 48 51 75 78 95 98 99 108 109 ...
    -##  $ EndPoints    : num [1:18] 1 42 59 62 80 85 96 100 102 112 ...
    -##  $ NumSegs      : int 33
    -##  $ SegList      :List of 33
    -##  $ d            :'data.frame':   180 obs. of  7 variables:
    -##  $ OrientInfo   :List of 5
    -##  $ SegOrders    : num [1:33] 1 2 2 3 4 4 3 4 5 5 ...
    -##  $ MBPoints     : int [1:2] 34 48
    -##  $ LHBranchPoint: int 75
    -##  $ SegTypes     : num [1:33] 1 3 1 3 3 3 1 2 2 2 ...
    -##  $ AxonSegNos   :List of 3
    -##  $ LHSegNos     : num [1:26] 8 9 10 11 12 13 14 15 16 17 ...
    -##  $ MBSegNos     :List of 2
    -##  $ NumMBBranches: num 2
    -##  $ AxonLHEP     : num 72
    -##  - attr(*, "class")= chr [1:2] "neuron" "list"
    -

    From this you can see that there are a large number of fields inside the neuron. Each field can be accessed using the $ or [[ operators

    +str(n1, max.level=1)
    +
    ## List of 24
    +##  $ CellType     : chr "DA1"
    +##  $ NeuronName   : chr "EBH11R"
    +##  $ InputFileName: 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc"
    +##  $ CreatedAt    : POSIXt[1:1], format: "2006-01-17 15:21:14"
    +##  $ NodeName     : Named chr "jefferis.joh.cam.ac.uk"
    +##   ..- attr(*, "names")= chr "nodename"
    +##  $ InputFileStat:'data.frame':   1 obs. of  10 variables:
    +##  $ InputFileMD5 : Named chr "fcacee3f874cbe2c6ad96214e6fee337"
    +##   ..- attr(*, "names")= 'AsIs' chr "/GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc"
    +##  $ NumPoints    : int 180
    +##  $ StartPoint   : num 1
    +##  $ BranchPoints : num [1:16] 34 48 51 75 78 95 98 99 108 109 ...
    +##  $ EndPoints    : num [1:18] 1 42 59 62 80 85 96 100 102 112 ...
    +##  $ NumSegs      : int 33
    +##  $ SegList      :List of 33
    +##  $ d            :'data.frame':   180 obs. of  7 variables:
    +##  $ OrientInfo   :List of 5
    +##  $ SegOrders    : num [1:33] 1 2 2 3 4 4 3 4 5 5 ...
    +##  $ MBPoints     : int [1:2] 34 48
    +##  $ LHBranchPoint: int 75
    +##  $ SegTypes     : num [1:33] 1 3 1 3 3 3 1 2 2 2 ...
    +##  $ AxonSegNos   :List of 3
    +##  $ LHSegNos     : num [1:26] 8 9 10 11 12 13 14 15 16 17 ...
    +##  $ MBSegNos     :List of 2
    +##  $ NumMBBranches: num 2
    +##  $ AxonLHEP     : num 72
    +##  - attr(*, "class")= chr [1:2] "neuron" "list"
    +

    From this you can see that there are a large number of fields inside the neuron. Each field can be accessed using the $ or [[ operators

     n1$NumPoints
    -
    ## [1] 180
    +
    ## [1] 180
     n1[["NumPoints"]]
    -
    ## [1] 180
    +
    ## [1] 180

    There are a set of core fields (described in ?neuron documentation); the key ones will be described shortly. However there are also quite a few user fields in this neuron and you can safely add any field you like so long as its name does not clash with an existing field. For example:

     n1$Comment='The sex of this specimen is uncertain'

    The single most important field in a neuron is the $d data.frame. This contains a block of data closely reminiscent of the SWC data format for traced neurons:

    -str(n1$d)
    -
    ## 'data.frame':    180 obs. of  7 variables:
    -##  $ PointNo: int  1 2 3 4 5 6 7 8 9 10 ...
    -##  $ Label  : num  2 2 2 2 2 2 2 2 2 2 ...
    -##  $ X      : num  187 187 188 188 188 ...
    -##  $ Y      : num  133 131 130 129 129 ...
    -##  $ Z      : num  88.2 90.6 93.1 95 97.5 ...
    -##  $ W      : num  1.01 1.27 1.14 1.27 1.27 1.27 1.27 1.27 1.27 1.27 ...
    -##  $ Parent : num  -1 1 2 3 4 5 6 7 8 9 ...
    +str(n1$d)
    +
    ## 'data.frame':    180 obs. of  7 variables:
    +##  $ PointNo: int  1 2 3 4 5 6 7 8 9 10 ...
    +##  $ Label  : num  2 2 2 2 2 2 2 2 2 2 ...
    +##  $ X      : num  187 187 188 188 188 ...
    +##  $ Y      : num  133 131 130 129 129 ...
    +##  $ Z      : num  88.2 90.6 93.1 95 97.5 ...
    +##  $ W      : num  1.01 1.27 1.14 1.27 1.27 1.27 1.27 1.27 1.27 1.27 ...
    +##  $ Parent : num  -1 1 2 3 4 5 6 7 8 9 ...

    Each row defines a node in a branched tree with a unique integer identifier, PointNo, normally but not always sequentially numbered from 1. The X,Y,Z columns encode the position of each vertex and the W column encodes the diameter of the neurite at that position.

    -
    -

    -Methods for neurons

    -

    R’s simple S3 object oriented system allows specialised functions for particular classes to be defined. These functions tailored to a particular class are called methods. Methods can be provided for pre-existing functions supplied with base R as well as new user-written functions. The system is quite simple. If a function foo is defined as a generic function then you can define new functions called foo.bar that will be called when you write foo(x) and x has class bar.

    +
    +

    Methods for neurons +

    +

    R’s simple S3 object oriented system allows specialised functions for particular classes to be defined. These functions tailored to a particular class are called methods. Methods can be provided for pre-existing functions supplied with base R as well as new user-written functions. The system is quite simple. If a function foo is defined as a generic function then you can define new functions called foo.bar that will be called when you write foo(x) and x has class bar.

    We already used one such method without comment, plot.neuron. There is a base R function called plot. nat defines a new function called plot.neuron, which R interprets as a plot method specialised for neuron objects. When the base R plot function is called, it looks at the class of its first object to see whether a specialised method exists. If there is none, it will use a fallback method called plot.default.

    The plot.neuron method interprets the branching structure of a neuron and draws line segments joining up the connected nodes at the appropriate 2D positions. You can compare it with what you would get if you just plotted the XY position of all nodes joined together by a single line:

    -plot(n1$d$X, n1$d$Y, type = 'l')
    +plot(n1$d$X, n1$d$Y, type = 'l')

    You can find out what methods are available for a particular class like so:

    -methods(class = 'neuron')
    -
    ##  [1] all.equal          as.neuron          as.ngraph          as.seglist        
    -##  [5] branchpoints       dotprops           endpoints          intersect_plane   
    -##  [9] ndigest            nvertices          Ops                plot              
    -## [13] plot3d             potential_synapses print              prune_in_volume   
    -## [17] prune_online       prune_twigs        prune              resample          
    -## [21] rootpoints         scale              sholl_analysis     subset            
    -## [25] summary            write.vtk          xform              xyzmatrix         
    -## [29] xyzmatrix<-       
    -## see '?methods' for accessing help and source code
    -

    You can then find the help page for any method in the console with ?plot.neuron. Note that if you write ?plot you will get the documentation for the basic plot function supplied with R.

    -

    It is also good idea to look at nat’s function reference page which groups available functions into categories that often reflect the class of object they can work on.

    -

    In R, operators such as * or + are actually special functions with two arguments, so one can add methods for these in the same way. In the following example we use this arithmetic to shift a neuron by a small amount:

    +methods(class = 'neuron')
    +
    ##  [1] all.equal          as.neuron          as.ngraph          as.seglist        
    +##  [5] branchpoints       dotprops           endpoints          intersect_plane   
    +##  [9] ndigest            nvertices          Ops                plot              
    +## [13] plot3d             potential_synapses print              prune_in_volume   
    +## [17] prune_online       prune_twigs        prune              reroot            
    +## [21] resample           rootpoints         scale              sholl_analysis    
    +## [25] subset             summary            write.vtk          xform             
    +## [29] xyzmatrix          xyzmatrix<-       
    +## see '?methods' for accessing help and source code
    +

    You can then find the help page for any method in the console with ?plot.neuron. Note that if you write ?plot you will get the documentation for the basic plot function supplied with R.

    +

    It is also good idea to look at nat’s function reference page which groups available functions into categories that often reflect the class of object they can work on.

    +

    In R, operators such as * or + are actually special functions with two arguments, so one can add methods for these in the same way. In the following example we use this arithmetic to shift a neuron by a small amount:

    -plot(n1, col = 'black', WithNodes = F, main="Shifting neurons")
    +plot(n1, col = 'black', WithNodes = F, main="Shifting neurons")
     # shift by 3 microns in x,y,z
    -plot(n1+3, col = 'red', add = TRUE, WithNodes = F)
    +plot(n1+3, col = 'red', add = TRUE, WithNodes = F)
     # shift by -5 microns in y
    -plot(n1+c(0,-5,0), col = 'blue', add = TRUE, WithNodes = F)
    +plot(n1+c(0,-5,0), col = 'blue', add = TRUE, WithNodes = F)

    Another specialised method is subset.neuron which we can use to extract part of a neuron into a new object. For example, a simple spatial criterion, X location must be >240, is used to extract the axon terminal arborisation field in this example

    -plot(n1, col = 'black', WithAllPoints = T, main="Subsetting a neuron")
    +plot(n1, col = 'black', WithAllPoints = T, main="Subsetting a neuron")
     # keep only nodes with X position >20
     n1.lh=subset(n1, X>240)
     # plot the selected part of the neuron in blue
    -plot(n1.lh, col='blue', lwd=3, add=TRUE)
    +plot(n1.lh, col='blue', lwd=3, add=TRUE)
     # add a line illustrating the cut point
    -abline(v=240, lty=2)
    +abline(v=240, lty=2)

    We can also summarise the morphological properties of a neuron using the summary.neuron method, which allows us to compare measurements for the original neuron and the axon arbour that we just cut out above.

    -summary(n1)
    -
    ##   root nodes segments branchpoints endpoints cable.length
    -## 1    1   180       33           16        18     297.1763
    +summary(n1) +
    ##   root nodes segments branchpoints endpoints cable.length nTrees
    +## 1    1   180       33           16        18     297.1763      1
    -summary(n1.lh)
    -
    ##   root nodes segments branchpoints endpoints cable.length
    -## 1    1   111       27           13        15     156.7654
    -

    See nat’s function reference page for additional functions for working with neurons.

    +summary(n1.lh) +
    ##   root nodes segments branchpoints endpoints cable.length nTrees
    +## 1    1   111       27           13        15     156.7654      1
    +

    See nat’s function reference page for additional functions for working with neurons.

    -
    -

    -Neuronlists

    +
    +

    Neuronlists +

    The data statement above loaded a neuronlist object called Cell07PNs containing 40 neuron objects. neuronlist objects are key data structures in nat for convenient handling of collections of neurons.

    Structure of neuronlist objects

    @@ -305,103 +307,103 @@

    The difference between single and double bracket subscript operators

    The single bracket operator makes a new list containing a specified subset of elements in the original list, while the double bracket operator extracts the object at the given position. So in the figure x[1] is a neuronlist object of length 1, whereas x[[1]] is the neuron object at the first position in the list.

    -

    You can see this distinction by comparing the action of the [ and [[ operators on the sample dataset we used earlier.

    +

    You can see this distinction by comparing the action of the [ and [[ operators on the sample dataset we used earlier.

    The original neuronlist

     Cell07PNs
    -
    ## 'neuronlist' containing 40 'neuron' objects and 'data.frame' with 27 vars [4.4 MB]
    +
    ## 'neuronlist' containing 40 'neuron' objects and 'data.frame' with 27 vars [4.4 MB]

    A length 1 neuronlist

     Cell07PNs[1]
    -
    ## 'neuronlist' containing 1 'neuron' object and 'data.frame' with 27 vars [51.1 kB]
    +
    ## 'neuronlist' containing 1 'neuron' object and 'data.frame' with 27 vars [51.1 kB]

    The first element, a neuron.

     Cell07PNs[[1]]
    -
    ## 'neuron' with 180 vertices in 1 tree
    -
    -

    -Worked Examples

    +
    ## 'neuron' with 180 vertices in 1 tree
    +
    +

    Worked Examples +

    Let us start by extracting the first five neurons from our sample data.

     # we can select neurons by indexing 
     first5=Cell07PNs[1:5]
    -summary(first5)
    -
    ##        root nodes segments branchpoints endpoints cable.length
    -## EBH11R    1   180       33           16        18     297.1763
    -## EBH20L    1   200       26           12        15     327.0929
    -## EBH20R    1   199       25           12        14     347.6153
    -## EBI12L    1   169       23           11        13     294.4680
    -## EBI22R    1   160       27           13        15     303.0150
    +summary(first5)
    +
    ##        root nodes segments branchpoints endpoints cable.length nTrees
    +## EBH11R    1   180       33           16        18     297.1763      1
    +## EBH20L    1   200       26           12        15     327.0929      1
    +## EBH20R    1   199       25           12        14     347.6153      1
    +## EBI12L    1   169       23           11        13     294.4680      1
    +## EBI22R    1   160       27           13        15     303.0150      1

    Each neuron in the neuronlist has an associated name which can be used to select it. We can get the names of all neurons using the names function.

    -names(Cell07PNs)
    -
    ##  [1] "EBH11R" "EBH20L" "EBH20R" "EBI12L" "EBI22R" "EBJ23L" "EBJ3R"  "EBN19L"
    -##  [9] "EBO15L" "EBO53L" "ECA34L" "ECB3L"  "LI23L"  "LIC2R"  "LJ5L"   "MC3B"  
    -## [17] "MH16L"  "MM14L"  "NA7L"   "NH15L"  "NH29B"  "NI16L"  "NIA8L"  "NIA8R" 
    -## [25] "NNA9L"  "NNC4R"  "NNE1L"  "OFD2L"  "OKC9R"  "SDD8L"  "SH21L"  "SL20L" 
    -## [33] "TKC8R"  "TL4R"   "TS7L"   "TT27R"  "VA15R"  "VA20R"  "VB37L"  "VB58L"
    +names(Cell07PNs)
    +
    ##  [1] "EBH11R" "EBH20L" "EBH20R" "EBI12L" "EBI22R" "EBJ23L" "EBJ3R"  "EBN19L"
    +##  [9] "EBO15L" "EBO53L" "ECA34L" "ECB3L"  "LI23L"  "LIC2R"  "LJ5L"   "MC3B"  
    +## [17] "MH16L"  "MM14L"  "NA7L"   "NH15L"  "NH29B"  "NI16L"  "NIA8L"  "NIA8R" 
    +## [25] "NNA9L"  "NNC4R"  "NNE1L"  "OFD2L"  "OKC9R"  "SDD8L"  "SH21L"  "SL20L" 
    +## [33] "TKC8R"  "TL4R"   "TS7L"   "TT27R"  "VA15R"  "VA20R"  "VB37L"  "VB58L"
    -nl3=Cell07PNs[c("EBH11R", "EBH20L", "EBH20R")]
    -all.equal(nl3, Cell07PNs[1:3])
    -
    ## [1] TRUE
    -

    You can also use the $ operator to access a single neuron e.g. Cell07PNs$EBH11R. This can be quite useful when working interactively in the console because RStudio will offer to autocomplete the neuron name when you start typing past the $ symbol, but is not recommended for scripts.

    +nl3=Cell07PNs[c("EBH11R", "EBH20L", "EBH20R")] +all.equal(nl3, Cell07PNs[1:3])
    +
    ## [1] TRUE
    +

    You can also use the $ operator to access a single neuron e.g. Cell07PNs$EBH11R. This can be quite useful when working interactively in the console because RStudio will offer to autocomplete the neuron name when you start typing past the $ symbol, but is not recommended for scripts.

    -
    -

    -Metadata

    +
    +

    Metadata +

    The names of neurons are also used to index a data.frame object attached to the neuronlist with one row for each neuron. You can use the head function to give a summary of the attached metadata in this neuronlist. Using the as.data.frame method on a neuronlist allows you to extract this attached metadata to a separate object.

     head(Cell07PNs)
    -
    ##         Brain RegistrationScore Notes Glomerulus Batch Directory Traced
    -## EBH11R EBH11R                 4              DA1   PN2    unsure    yes
    -## EBH20L EBH20L                 4              DL3   PN2   unsure2    yes
    -## EBH20R EBH20R                 4              DA1   PN2   unsure2    yes
    -## EBI12L EBI12L                 4              DA1   PN2   unsure3    yes
    -## EBI22R EBI22R                 4              DL3   PN2   unsure3    yes
    -## EBJ23L EBJ23L                 4              DL3   PN2   unsure4    yes
    -##        Scored.By Sex Include     ID HaveWarp HaveAsc
    -## EBH11R       ACH   M         EBH11R     TRUE    TRUE
    -## EBH20L       ACH             EBH20L     TRUE    TRUE
    -## EBH20R       ACH   M         EBH20R     TRUE    TRUE
    -## EBI12L       ACH   F         EBI12L     TRUE    TRUE
    -## EBI22R       ACH             EBI22R     TRUE    TRUE
    -## EBJ23L       ACH             EBJ23L     TRUE    TRUE
    -##                                                 TraceFile AscBatch Status
    -## EBH11R /GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc      New       
    -## EBH20L /GD/projects/PN2/TransformedTraces/DL3/EBH20L.tasc      New       
    -## EBH20R /GD/projects/PN2/TransformedTraces/DA1/EBH20R.tasc      New       
    -## EBI12L /GD/projects/PN2/TransformedTraces/DA1/EBI12L.tasc      New       
    -## EBI22R /GD/projects/PN2/TransformedTraces/DL3/EBI22R.tasc      New       
    -## EBJ23L /GD/projects/PN2/TransformedTraces/DL3/EBJ23L.tasc      New       
    -##        GlomSeq NumNAs MBP1 MBP2 LHBP PNType Seq nTrees StartPoint
    -## EBH11R       1      0   34   48   75    iPN  13      1          1
    -## EBH20L       1      0   29   29   77    iPN  15      1          1
    -## EBH20R       2      0   24   80  147    iPN  16      1          1
    -## EBI12L       3      0   29   59   89    iPN  18      1          1
    -## EBI22R       2      0   34   34   56    iPN  20      1          1
    -## EBJ23L       3      0   23   23   52    iPN  21      1          1
    -##                  CreatedAt
    -## EBH11R 2006-01-17 15:21:14
    -## EBH20L 2006-01-17 15:21:14
    -## EBH20R 2006-01-17 15:21:14
    -## EBI12L 2006-01-17 15:21:15
    -## EBI22R 2006-01-17 15:21:15
    -## EBJ23L 2006-01-17 15:21:15
    -##                                                                                             WarpFile
    -## EBH11R  /GD/projects/PN2/allreg/warp/unsure/average-goodbrains_EBH11R101_warp_m0g40c4e1e-1x16r3.list
    -## EBH20L /GD/projects/PN2/allreg/warp/unsure2/average-goodbrains_EBH20L101_warp_m0g40c4e1e-1x16r3.list
    -## EBH20R /GD/projects/PN2/allreg/warp/unsure2/average-goodbrains_EBH20R101_warp_m0g40c4e1e-1x16r3.list
    -## EBI12L /GD/projects/PN2/allreg/warp/unsure3/average-goodbrains_EBI12L101_warp_m0g40c4e1e-1x16r3.list
    -## EBI22R /GD/projects/PN2/allreg/warp/unsure3/average-goodbrains_EBI22R101_warp_m0g40c4e1e-1x16r3.list
    -## EBJ23L /GD/projects/PN2/allreg/warp/unsure4/average-goodbrains_EBJ23L101_warp_m0g40c4e1e-1x16r3.list
    +
    ##         Brain RegistrationScore Notes Glomerulus Batch Directory Traced
    +## EBH11R EBH11R                 4              DA1   PN2    unsure    yes
    +## EBH20L EBH20L                 4              DL3   PN2   unsure2    yes
    +## EBH20R EBH20R                 4              DA1   PN2   unsure2    yes
    +## EBI12L EBI12L                 4              DA1   PN2   unsure3    yes
    +## EBI22R EBI22R                 4              DL3   PN2   unsure3    yes
    +## EBJ23L EBJ23L                 4              DL3   PN2   unsure4    yes
    +##        Scored.By Sex Include     ID HaveWarp HaveAsc
    +## EBH11R       ACH   M         EBH11R     TRUE    TRUE
    +## EBH20L       ACH             EBH20L     TRUE    TRUE
    +## EBH20R       ACH   M         EBH20R     TRUE    TRUE
    +## EBI12L       ACH   F         EBI12L     TRUE    TRUE
    +## EBI22R       ACH             EBI22R     TRUE    TRUE
    +## EBJ23L       ACH             EBJ23L     TRUE    TRUE
    +##                                                 TraceFile AscBatch Status
    +## EBH11R /GD/projects/PN2/TransformedTraces/DA1/EBH11R.tasc      New       
    +## EBH20L /GD/projects/PN2/TransformedTraces/DL3/EBH20L.tasc      New       
    +## EBH20R /GD/projects/PN2/TransformedTraces/DA1/EBH20R.tasc      New       
    +## EBI12L /GD/projects/PN2/TransformedTraces/DA1/EBI12L.tasc      New       
    +## EBI22R /GD/projects/PN2/TransformedTraces/DL3/EBI22R.tasc      New       
    +## EBJ23L /GD/projects/PN2/TransformedTraces/DL3/EBJ23L.tasc      New       
    +##        GlomSeq NumNAs MBP1 MBP2 LHBP PNType Seq nTrees StartPoint
    +## EBH11R       1      0   34   48   75    iPN  13      1          1
    +## EBH20L       1      0   29   29   77    iPN  15      1          1
    +## EBH20R       2      0   24   80  147    iPN  16      1          1
    +## EBI12L       3      0   29   59   89    iPN  18      1          1
    +## EBI22R       2      0   34   34   56    iPN  20      1          1
    +## EBJ23L       3      0   23   23   52    iPN  21      1          1
    +##                  CreatedAt
    +## EBH11R 2006-01-17 15:21:14
    +## EBH20L 2006-01-17 15:21:14
    +## EBH20R 2006-01-17 15:21:14
    +## EBI12L 2006-01-17 15:21:15
    +## EBI22R 2006-01-17 15:21:15
    +## EBJ23L 2006-01-17 15:21:15
    +##                                                                                             WarpFile
    +## EBH11R  /GD/projects/PN2/allreg/warp/unsure/average-goodbrains_EBH11R101_warp_m0g40c4e1e-1x16r3.list
    +## EBH20L /GD/projects/PN2/allreg/warp/unsure2/average-goodbrains_EBH20L101_warp_m0g40c4e1e-1x16r3.list
    +## EBH20R /GD/projects/PN2/allreg/warp/unsure2/average-goodbrains_EBH20R101_warp_m0g40c4e1e-1x16r3.list
    +## EBI12L /GD/projects/PN2/allreg/warp/unsure3/average-goodbrains_EBI12L101_warp_m0g40c4e1e-1x16r3.list
    +## EBI22R /GD/projects/PN2/allreg/warp/unsure3/average-goodbrains_EBI22R101_warp_m0g40c4e1e-1x16r3.list
    +## EBJ23L /GD/projects/PN2/allreg/warp/unsure4/average-goodbrains_EBJ23L101_warp_m0g40c4e1e-1x16r3.list
    -df=as.data.frame(Cell07PNs)
    -nrow(df)
    -
    ## [1] 40
    +df=as.data.frame(Cell07PNs) +nrow(df)
    +
    ## [1] 40
     # rownames of data.frame are the same as names of Cell07PNs list.
    -all.equal(rownames(df), names(Cell07PNs))
    -
    ## [1] TRUE
    +all.equal(rownames(df), names(Cell07PNs))
    +
    ## [1] TRUE

    You can use columns in the attached metadata in expressions that select or operate on the neurons in the list. In the next two examples we