{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "$p=new Polytope(POINTS=>[[1,0,0],[1,1,0],[1,0,1]]);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polymake: used package cdd\r\n",
       "  cddlib\r\n",
       "  Implementation of the double description method of Motzkin et al.\r\n",
       "  Copyright by Komei Fukuda.\r\n",
       "  http://www.ifor.math.ethz.ch/~fukuda/cdd_home/cdd.html\r\n",
       "\r\n",
       "1 0 0\r\n",
       "1 1 0\r\n",
       "1 0 1"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $p->VERTICES;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1/2"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $p->VOLUME;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polymake: used package lrs\r\n",
       "  Implementation of the reverse search algorithm of Avis and Fukuda.\r\n",
       "  Copyright by David Avis.\r\n",
       "  http://cgm.cs.mcgill.ca/~avis/lrs.html\r\n",
       "\r\n",
       "3 3"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $p->F_VECTOR;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "application \"group\";"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "$g=new Group(PERMUTATION_ACTION=>new PermutationAction(GENERATORS=>[[1,0,2],[0,2,1]]));"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polymake: used package permlib\r\n",
       "  A callable C++ library for permutation computations. \r\n",
       "  Written by Thomas Rehn.\r\n",
       "  http://www.math.uni-rostock.de/~rehn/software/permlib.html \r\n",
       "\r\n",
       "1 0 2\r\n",
       "0 2 1"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print $g->PERMUTATION_ACTION->STRONG_GENERATORS;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "application \"polytope\";"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "$c=cube(3);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "polymake: used package threejs\r\n",
       "   Three.js is a lightweight cross-browser JavaScript library/API used to create and display animated 3D computer graphics on a Web browser.\r\n",
       "   See http://github.com/mrdoob for the source code."
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "text/html": [
       "<!--\r\n",
       "polymake for sebastian\r\n",
       "Thu Mar  2 13:28:26 2017\r\n",
       "c\r\n",
       "-->\r\n",
       "\r\n",
       "\r\n",
       "<html>\r\n",
       "   <head>\r\n",
       "      <title>c</title>\r\n",
       "      <style>\r\n",
       "/*\r\n",
       "// COMMON_CODE_BLOCK_BEGIN\r\n",
       "*/\r\n",
       "\t\t\thtml{overflow: scroll;}\r\n",
       "\t\t\tbody { font-family: Arial, Helvetica, sans-serif}\r\n",
       "\t\t\tstrong{font-size: 18px;}\r\n",
       "\t\t\tcanvas {position: fixed; right: 50%; top: 0; transform: translate(50%,0); }\r\n",
       "\t\t\tinput[type='range'] {}\r\n",
       "\t\t\tinput[type='radio'] {margin-left:0;}\r\n",
       "\t\t\tinput[type='checkbox'] {margin-right:7px; margin-left: 0px; padding-left:0px;}\r\n",
       "\t\t\t.group{padding-bottom: 50px;}\r\n",
       "\t\t\t#settings{display: none; width: 15vw; min-height: 97vh; border-right:solid 1px silver; padding-right: 0.5vw; padding-top: 15px;}\r\n",
       "\t\t\t.indented{margin-left: 20px; margin-top: 15px; padding-bottom: 0px;} \r\n",
       "\t\t\t#shownObjectsList{overflow: auto; max-width: 150px; max-height: 150px;}\r\n",
       "\t\t\t#showSettingsButton{display: block;}\r\n",
       "\t\t\t#closeButtonContainer{position: absolute; top: 5px; width: 15.4vw; text-align: right;}\r\n",
       "\t\t\t#hideSettingsButton{display: none; opacity: 0.5; padding: 10px;}\r\n",
       "\t\t\t#resetButton{margin-top: 20px;}\r\n",
       "\t\t\tbutton{margin-left: 0;}\r\n",
       "\t\t\timg{cursor: pointer;}\r\n",
       "\t\t\t.suboption{padding-top: 30px;}\r\n",
       "\t\t\t#transparency{display: none;}\r\n",
       "\t\t\t#labelsCheckbox{margin-top: 10px;}\r\n",
       "\t\t\t\r\n",
       "\r\n",
       "\t\t\tinput[type=range] {\r\n",
       "\t\t\t  -webkit-appearance: none;\r\n",
       "\t\t\t  padding:0; \r\n",
       "\t\t\t  width:13vw; \r\n",
       "\t\t\t  margin-left: 20px;\r\n",
       "\t\t\t  margin-top: 20px;\r\n",
       "\t\t\t  display: block;\t\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]:focus {\r\n",
       "\t\t\t  outline: none;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]::-webkit-slider-runnable-track {\r\n",
       "\t\t\t  height: 4px;\r\n",
       "\t\t\t  cursor: pointer;\r\n",
       "\t\t\t  animate: 0.2s;\r\n",
       "\t\t\t  box-shadow: 0px 0px 0px #000000;\r\n",
       "\t\t\t  background: #E3E3E3;\r\n",
       "\t\t\t  border-radius: 0px;\r\n",
       "\t\t\t  border: 0px solid #000000;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]::-webkit-slider-thumb {\r\n",
       "\t\t\t  box-shadow: 1px 1px 2px #B8B8B8;\r\n",
       "\t\t\t  border: 1px solid #ABABAB;\r\n",
       "\t\t\t  height: 13px;\r\n",
       "\t\t\t  width: 25px;\r\n",
       "\t\t\t  border-radius: 20px;\r\n",
       "\t\t\t  background: #E0E0E0;\r\n",
       "\t\t\t  cursor: pointer;\r\n",
       "\t\t\t  -webkit-appearance: none;\r\n",
       "\t\t\t  margin-top: -5px;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]:focus::-webkit-slider-runnable-track {\r\n",
       "\t\t\t  background: #E3E3E3;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]::-moz-range-track {\r\n",
       "\t\t\t  height: 4px;\r\n",
       "\t\t\t  cursor: pointer;\r\n",
       "\t\t\t  animate: 0.2s;\r\n",
       "\t\t\t  box-shadow: 0px 0px 0px #000000;\r\n",
       "\t\t\t  background: #E3E3E3;\r\n",
       "\t\t\t  border-radius: 0px;\r\n",
       "\t\t\t  border: 0px solid #000000;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]::-moz-range-thumb {\r\n",
       "\t\t\t  box-shadow: 1px 1px 2px #B8B8B8;\r\n",
       "\t\t\t  border: 1px solid #ABABAB;\r\n",
       "\t\t\t  height: 13px;\r\n",
       "\t\t\t  width: 25px;\r\n",
       "\t\t\t  border-radius: 20px;\r\n",
       "\t\t\t  background: #E0E0E0;\r\n",
       "\t\t\t  cursor: pointer;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]::-ms-track {\r\n",
       "\t\t\t  height: 4px;\r\n",
       "\t\t\t  cursor: pointer;\r\n",
       "\t\t\t  animate: 0.2s;\r\n",
       "\t\t\t  background: transparent;\r\n",
       "\t\t\t  border-color: transparent;\r\n",
       "\t\t\t  color: transparent;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]::-ms-fill-lower {\r\n",
       "\t\t\t  background: #E3E3E3;\r\n",
       "\t\t\t  border: 0px solid #000000;\r\n",
       "\t\t\t  border-radius: 0px;\r\n",
       "\t\t\t  box-shadow: 0px 0px 0px #000000;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]::-ms-fill-upper {\r\n",
       "\t\t\t  background: #E3E3E3;\r\n",
       "\t\t\t  border: 0px solid #000000;\r\n",
       "\t\t\t  border-radius: 0px;\r\n",
       "\t\t\t  box-shadow: 0px 0px 0px #000000;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]::-ms-thumb {\r\n",
       "\t\t\t  box-shadow: 1px 1px 2px #B8B8B8;\r\n",
       "\t\t\t  border: 1px solid #ABABAB;\r\n",
       "\t\t\t  height: 13px;\r\n",
       "\t\t\t  width: 25px;\r\n",
       "\t\t\t  border-radius: 20px;\r\n",
       "\t\t\t  background: #E0E0E0;\r\n",
       "\t\t\t  cursor: pointer;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]:focus::-ms-fill-lower {\r\n",
       "\t\t\t  background: #E3E3E3;\r\n",
       "\t\t\t}\r\n",
       "\t\t\tinput[type=range]:focus::-ms-fill-upper {\r\n",
       "\t\t\t  background: #E3E3E3;\r\n",
       "\t\t\t}\r\n",
       "/*\r\n",
       "// COMMON_CODE_BLOCK_END\r\n",
       "*/\r\n",
       "\t\t</style>\r\n",
       "   </head>\r\n",
       "\r\n",
       "<body>\r\n",
       "\r\n",
       "\t\t<div id='settings'>\r\n",
       "\t\t\t<div class=group id=transparency>\r\n",
       "\t\t\t\t<strong>Transparency</strong>\r\n",
       "\t\t\t\t<input id='transparencyRange' type='range' min=0 max=1 step=0.01 value=0 oninput=changeTransparency(event)>\r\n",
       "\t\t\t</div>\r\n",
       "\t\t\t\r\n",
       "\t\t\t<div class=group id=rotation>\r\n",
       "\t\t\t\t<strong>Rotation</strong>\r\n",
       "\t\t\t\t<div class=indented>\r\n",
       "\t\t\t\t\t<div><input type='checkbox' onchange=changeRotationX(event)> x-axis</div>\r\n",
       "\t\t\t\t\t<div><input type='checkbox' onchange=changeRotationY(event)> y-axis</div>\r\n",
       "\t\t\t\t\t<div><input type='checkbox' onchange=changeRotationZ(event)> z-axis</div>\r\n",
       "\t\t\t\t\t<button id=resetButton onclick=resetScene()>Reset</button>\r\n",
       "\t\t\t\t</div>\r\n",
       "\r\n",
       "\t\t\t\t<div class=suboption>Rotation speed</div>\r\n",
       "\t\t\t\t<input id='rotationSpeedRange' type='range' min=0 max=5 step=0.01 value=2 oninput=changeRotationSpeedFactor(event)>\r\n",
       "\r\n",
       "\t\t\t</div>\r\n",
       "\r\n",
       "\r\n",
       "\t\t\t<div class=group id=display>\r\n",
       "\t\t\t\t<strong>Display</strong>\r\n",
       "\t\t\t\t<div class=indented>\r\n",
       "\t\t\t\t\t<div id=shownObjectsList></div>\r\n",
       "\t\t\t\t\t<div id=labelsCheckbox><input type='checkbox' onchange=displayOrHideLabels(event) checked>Labels</div>\r\n",
       "\t\t\t\t</div>\r\n",
       "\t\t\t</div>\r\n",
       "\r\n",
       "\r\n",
       "\t\t\t<div class=group id=svg>\r\n",
       "\t\t\t\t<strong>SVG</strong>\r\n",
       "\t\t\t\t<div class=indented>\r\n",
       "\t\t\t\t\t<form>\r\n",
       "\t\t\t\t\t\t<input type=\"radio\" name='screenshotMode' value='download' id=download checked> Download<br>\r\n",
       "\t\t\t\t\t\t<input type=\"radio\" name='screenshotMode' value='tab' id=tab > New tab<br>\r\n",
       "\t\t\t\t\t</form>\r\n",
       "\t\t\t\t\t<button onclick=takeSvgScreenshot()>Screenshot</button>\r\n",
       "\t\t\t\t</div>\r\n",
       "\t\t\t</div>\r\n",
       "\r\n",
       "\t\t</div>\t<!-- end of settings -->\r\n",
       "\r\n",
       "\t\t<div id=closeButtonContainer>\r\n",
       "\t\t\t<img id=hideSettingsButton src='js/images/close.svg' width=12 onclick=\"hideSettings(event)\">\r\n",
       "\t\t</div>\r\n",
       "\t\t<img id=showSettingsButton src='js/images/menu.svg' width=22 onclick=\"showSettings(event)\">\r\n",
       "<div id=\"model92584137253\"></div>\r\n",
       "\r\n",
       "\r\n",
       "\r\n",
       "<script src='resources/three.js'></script><script>\r\n",
       "// COMMON_CODE_BLOCK_BEGIN\r\n",
       "\tvar foldable = false;\r\n",
       "   var container = document.getElementById( 'model92584137253' );\r\n",
       "   var renderer = Detector.webgl? new THREE.WebGLRenderer({antialias: true}): new THREE.CanvasRenderer({antialias: true});\r\n",
       "\tvar svgRenderer = new THREE.SVGRenderer({antialias: true});\r\n",
       "   var box = document.getElementsByClassName( 'input_area' )[0];\r\n",
       "   var width = box.clientWidth*0.9 * 0.83;\r\n",
       "   var height = window.innerHeight * width/(window.innerWidth);\r\n",
       "   renderer.setSize(width, height);\r\n",
       "   svgRenderer.setSize(width, height);\r\n",
       "   renderer.setClearColor(0xFFFFFF, 1);\r\n",
       "   svgRenderer.setClearColor(0xFFFFFF, 1);\r\n",
       "\r\n",
       "   container.appendChild(renderer.domElement);\r\n",
       "\r\n",
       "   var scene = new THREE.Scene();\r\n",
       "   var camera = new THREE.PerspectiveCamera(75, width/height, 0.1, 1000);\r\n",
       "\r\n",
       "   camera.position.set(0, 0, 5);\r\n",
       "   camera.lookAt(0, 0, 0);\r\n",
       "   camera.up.set(0, 1, 0);\r\n",
       "\r\n",
       "   // class to allow move points together with labels and spheres\r\n",
       "   var PMPoint = function (x,y,z) {\r\n",
       "      this.vector = new THREE.Vector3(x,y,z);\r\n",
       "      this.sprite = null;\r\n",
       "      this.sphere = null;\r\n",
       "   }\r\n",
       "   PMPoint.prototype.makelabel = function(label) {\r\n",
       "      this.sprite = textSprite( label );\r\n",
       "      this.sprite.position.copy(this.vector);\r\n",
       "   }\r\n",
       "   PMPoint.prototype.makesphere = function(radius,material) {\r\n",
       "      this.sphere = new THREE.Mesh(new THREE.SphereGeometry(radius), material);\r\n",
       "      this.sphere.position.copy(this.vector);\r\n",
       "   }\r\n",
       "\r\n",
       "   PMPoint.prototype.setX = function(x) {\r\n",
       "      this.vector.setX(x);\r\n",
       "      if (this.sprite) {\r\n",
       "         this.sprite.position.setX(x);\r\n",
       "      }\r\n",
       "      if (this.sphere) {\r\n",
       "         this.sphere.position.setX(x);\r\n",
       "      }\r\n",
       "   };\r\n",
       "   PMPoint.prototype.setY = function(y) {\r\n",
       "      this.vector.setY(y);\r\n",
       "      if (this.sprite) {\r\n",
       "         this.sprite.position.setY(y);\r\n",
       "      }\r\n",
       "      if (this.sphere) {\r\n",
       "         this.sphere.position.setY(y);\r\n",
       "      }\r\n",
       "   };\r\n",
       "   PMPoint.prototype.setZ = function(z) {\r\n",
       "      this.vector.setZ(z);\r\n",
       "      if (this.sprite) {\r\n",
       "         this.sprite.position.setZ(z);\r\n",
       "      }\r\n",
       "      if (this.sphere) {\r\n",
       "         this.sphere.position.setZ(z);\r\n",
       "      }\r\n",
       "   };\r\n",
       "   PMPoint.prototype.set = function(x,y,z) {\r\n",
       "      this.vector.set(x,y,z);\r\n",
       "      if (this.sprite) {\r\n",
       "         this.sprite.position.set(x,y,z);\r\n",
       "      }\r\n",
       "      if (this.sphere) {\r\n",
       "         this.sphere.position.set(x,y,z);\r\n",
       "      }\r\n",
       "   };\r\n",
       "   PMPoint.prototype.add = function(o) {\r\n",
       "      if (this.sprite) {\r\n",
       "         o.add(this.sprite);\r\n",
       "      }\r\n",
       "      if (this.sphere) {\r\n",
       "         o.add(this.sphere);\r\n",
       "      }\r\n",
       "   };\r\n",
       "\r\n",
       "\r\n",
       "   var controls = new THREE.TrackballControls(camera, container);\r\n",
       "\tcontrols.zoomSpeed = 0.2;\r\n",
       "\tcontrols.rotateSpeed = 4;\r\n",
       "\r\n",
       "   var all_objects = [];\r\n",
       "   var centroids = [];\r\n",
       "\r\n",
       "// COMMON_CODE_BLOCK_END\r\n",
       "\r\n",
       "   var objectnames = [\"c\"];\r\n",
       "   var obj = new THREE.Object3D();\r\n",
       "   var allpoints = [];\r\n",
       "   allpoints.push(new PMPoint(-1, -1, -1));\r\n",
       "   allpoints.push(new PMPoint(1, -1, -1));\r\n",
       "   allpoints.push(new PMPoint(-1, 1, -1));\r\n",
       "   allpoints.push(new PMPoint(1, 1, -1));\r\n",
       "   allpoints.push(new PMPoint(-1, -1, 1));\r\n",
       "   allpoints.push(new PMPoint(1, -1, 1));\r\n",
       "   allpoints.push(new PMPoint(-1, 1, 1));\r\n",
       "   allpoints.push(new PMPoint(1, 1, 1));\r\n",
       "\r\n",
       "   <!-- Vertex style -->\r\n",
       "   var points_material = new THREE.MeshBasicMaterial ( {color: 0xFF0000, } );\r\n",
       "\r\n",
       "   points_material.side = THREE.DoubleSide;\r\n",
       "   points_material.transparent = true;\r\n",
       "\r\n",
       "   <!-- POINTS -->\r\n",
       "   allpoints[0].makesphere(0.02,points_material);\r\n",
       "   allpoints[1].makesphere(0.02,points_material);\r\n",
       "   allpoints[2].makesphere(0.02,points_material);\r\n",
       "   allpoints[3].makesphere(0.02,points_material);\r\n",
       "   allpoints[4].makesphere(0.02,points_material);\r\n",
       "   allpoints[5].makesphere(0.02,points_material);\r\n",
       "   allpoints[6].makesphere(0.02,points_material);\r\n",
       "   allpoints[7].makesphere(0.02,points_material);\r\n",
       "   allpoints[0].makelabel(\"0\");\r\n",
       "   allpoints[1].makelabel(\"1\");\r\n",
       "   allpoints[2].makelabel(\"2\");\r\n",
       "   allpoints[3].makelabel(\"3\");\r\n",
       "   allpoints[4].makelabel(\"4\");\r\n",
       "   allpoints[5].makelabel(\"5\");\r\n",
       "   allpoints[6].makelabel(\"6\");\r\n",
       "   allpoints[7].makelabel(\"7\");\r\n",
       "\r\n",
       "   for (index = 0; index < allpoints.length; ++index) {\r\n",
       "      allpoints[index].add(obj);\r\n",
       "   }\r\n",
       "   var faces = new THREE.Geometry();\r\n",
       "\r\n",
       "   <!-- VERTICES -->\r\n",
       "   faces.vertices.push(allpoints[0].vector);\r\n",
       "   faces.vertices.push(allpoints[1].vector);\r\n",
       "   faces.vertices.push(allpoints[2].vector);\r\n",
       "   faces.vertices.push(allpoints[3].vector);\r\n",
       "   faces.vertices.push(allpoints[4].vector);\r\n",
       "   faces.vertices.push(allpoints[5].vector);\r\n",
       "   faces.vertices.push(allpoints[6].vector);\r\n",
       "   faces.vertices.push(allpoints[7].vector);\r\n",
       "\r\n",
       "   centroids.push(computeCentroid(faces));\r\n",
       "\r\n",
       "   <!-- Facet style -->\r\n",
       "   var faces_material = new THREE.MeshBasicMaterial ( {color: 0x77EC9E, transparent: true, opacity: 1, side: THREE.DoubleSide , depthWrite: true, depthTest: true, } );\r\n",
       "\r\n",
       "   faces_material.side = THREE.DoubleSide;\r\n",
       "   faces_material.transparent = true;\r\n",
       "\r\n",
       "   <!-- FACETS --> \r\n",
       "   faces.faces.push(new THREE.Face3(0, 4, 6, undefined, undefined, 0));\r\n",
       "   faces.faces.push(new THREE.Face3(0, 6, 2, undefined, undefined, 0));\r\n",
       "\r\n",
       "   faces.faces.push(new THREE.Face3(7, 5, 1, undefined, undefined, 0));\r\n",
       "   faces.faces.push(new THREE.Face3(7, 1, 3, undefined, undefined, 0));\r\n",
       "\r\n",
       "   faces.faces.push(new THREE.Face3(5, 4, 0, undefined, undefined, 0));\r\n",
       "   faces.faces.push(new THREE.Face3(5, 0, 1, undefined, undefined, 0));\r\n",
       "\r\n",
       "   faces.faces.push(new THREE.Face3(2, 6, 7, undefined, undefined, 0));\r\n",
       "   faces.faces.push(new THREE.Face3(2, 7, 3, undefined, undefined, 0));\r\n",
       "\r\n",
       "   faces.faces.push(new THREE.Face3(0, 2, 3, undefined, undefined, 0));\r\n",
       "   faces.faces.push(new THREE.Face3(0, 3, 1, undefined, undefined, 0));\r\n",
       "\r\n",
       "   faces.faces.push(new THREE.Face3(6, 4, 5, undefined, undefined, 0));\r\n",
       "   faces.faces.push(new THREE.Face3(6, 5, 7, undefined, undefined, 0));\r\n",
       "\r\n",
       "\r\n",
       "   faces.computeFaceNormals();\r\n",
       "   faces.computeVertexNormals();\r\n",
       "\r\n",
       "   var object = new THREE.Mesh(faces, faces_material);\r\n",
       "   obj.add(object);\r\n",
       "\r\n",
       "   <!-- Edge style -->\r\n",
       "   var line_material = new THREE.LineBasicMaterial ( {color: 0x000000, linewidth: 1.5, } );\r\n",
       "\r\n",
       "   line_material.side = THREE.DoubleSide;\r\n",
       "   line_material.transparent = true;\r\n",
       "\r\n",
       "   <!-- EDGES --> \r\n",
       "   var line = new THREE.Geometry();\r\n",
       "   line.vertices.push(allpoints[0].vector);\r\n",
       "   line.vertices.push(allpoints[4].vector);\r\n",
       "   line.vertices.push(allpoints[6].vector);\r\n",
       "   line.vertices.push(allpoints[2].vector);\r\n",
       "   line.vertices.push(allpoints[0].vector);\r\n",
       "   obj.add(new THREE.Line(line, line_material));\r\n",
       "\r\n",
       "   var line = new THREE.Geometry();\r\n",
       "   line.vertices.push(allpoints[7].vector);\r\n",
       "   line.vertices.push(allpoints[5].vector);\r\n",
       "   line.vertices.push(allpoints[1].vector);\r\n",
       "   line.vertices.push(allpoints[3].vector);\r\n",
       "   line.vertices.push(allpoints[7].vector);\r\n",
       "   obj.add(new THREE.Line(line, line_material));\r\n",
       "\r\n",
       "   var line = new THREE.Geometry();\r\n",
       "   line.vertices.push(allpoints[5].vector);\r\n",
       "   line.vertices.push(allpoints[4].vector);\r\n",
       "   line.vertices.push(allpoints[0].vector);\r\n",
       "   line.vertices.push(allpoints[1].vector);\r\n",
       "   line.vertices.push(allpoints[5].vector);\r\n",
       "   obj.add(new THREE.Line(line, line_material));\r\n",
       "\r\n",
       "   var line = new THREE.Geometry();\r\n",
       "   line.vertices.push(allpoints[2].vector);\r\n",
       "   line.vertices.push(allpoints[6].vector);\r\n",
       "   line.vertices.push(allpoints[7].vector);\r\n",
       "   line.vertices.push(allpoints[3].vector);\r\n",
       "   line.vertices.push(allpoints[2].vector);\r\n",
       "   obj.add(new THREE.Line(line, line_material));\r\n",
       "\r\n",
       "   var line = new THREE.Geometry();\r\n",
       "   line.vertices.push(allpoints[0].vector);\r\n",
       "   line.vertices.push(allpoints[2].vector);\r\n",
       "   line.vertices.push(allpoints[3].vector);\r\n",
       "   line.vertices.push(allpoints[1].vector);\r\n",
       "   line.vertices.push(allpoints[0].vector);\r\n",
       "   obj.add(new THREE.Line(line, line_material));\r\n",
       "\r\n",
       "   var line = new THREE.Geometry();\r\n",
       "   line.vertices.push(allpoints[6].vector);\r\n",
       "   line.vertices.push(allpoints[4].vector);\r\n",
       "   line.vertices.push(allpoints[5].vector);\r\n",
       "   line.vertices.push(allpoints[7].vector);\r\n",
       "   line.vertices.push(allpoints[6].vector);\r\n",
       "   obj.add(new THREE.Line(line, line_material));\r\n",
       "\r\n",
       "   scene.add(obj);\r\n",
       "   all_objects.push(obj);\r\n",
       "\r\n",
       "// COMMON_CODE_BLOCK_BEGIN\r\n",
       "var xRotationEnabled = false;\r\n",
       "var yRotationEnabled = false;\r\n",
       "var zRotationEnabled = false;\r\n",
       "var rotationSpeedFactor = 1;\r\n",
       "var settingsShown = false;\r\n",
       "var labelsShown = true;\r\n",
       "var intervals = [];\r\n",
       "var timeouts = [];\r\n",
       "var explodingSpeed = 0.05;\r\n",
       "var explodeScale = 0;\r\n",
       "var XMLS = new XMLSerializer();\r\n",
       "var svgElement;\r\n",
       "\r\n",
       "\tvar render = function () {\r\n",
       "\r\n",
       "\t\trequestAnimationFrame(render);\r\n",
       "\r\n",
       "//\t\tcomment in for automatic explosion\r\n",
       "//\t\texplode(updateFactor());\r\n",
       "\r\n",
       "\t\tvar phi = 0.02 * rotationSpeedFactor;\r\n",
       "\r\n",
       "\t\tif (xRotationEnabled){\r\n",
       "\t\t\tscene.rotation.x += phi;\r\n",
       "\t\t}\r\n",
       "\t\tif(yRotationEnabled){\r\n",
       "\t\t\tscene.rotation.y += phi;\r\n",
       "\t\t}\r\n",
       "\t\tif(zRotationEnabled){\r\n",
       "\t\t\tscene.rotation.z += phi;\r\n",
       "\t\t}\r\n",
       "\r\n",
       "\t\tcontrols.update();\r\n",
       "\t\trenderer.render(scene, camera);\r\n",
       "\t};\r\n",
       "\r\n",
       "\trender();\r\n",
       "\r\n",
       "\tfunction computeCentroid(geom) {\r\n",
       "\t\tcentroid = new THREE.Vector3();\r\n",
       "\t\tgeom.vertices.forEach(function(v) {\r\n",
       "\t\t\tcentroid.add(v);\t\t\t\r\n",
       "\t\t});\r\n",
       "\t\tcentroid.divideScalar(geom.vertices.length);\r\n",
       "\t\treturn centroid;\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction changeTransparency(event){\r\n",
       "\t\tvar opacity = 1-Number(event.currentTarget.value);\r\n",
       "\t\tfor (var i=0; i<all_objects.length; i++){\r\n",
       "\t\t\tfor (var j=0; j<all_objects[i].children.length; j++){\r\n",
       "\t\t\t\tif (all_objects[i].children[j].material.type == \"MultiMaterial\") {\r\n",
       "\t\t\t\t\tfor (var k=0; k<all_objects[i].children[j].material.materials.length; k++){\r\n",
       "\t\t\t\t\t\tall_objects[i].children[j].material.materials[k].opacity = opacity;\r\n",
       "\t\t\t\t\t\tall_objects[i].children[j].material.materials[k].depthWrite = opacity < 0.5 ? false : true;\r\n",
       "\t\t\t\t\t\tall_objects[i].children[j].material.materials[k].depthTest = opacity < 0.5 ? false : true;\r\n",
       "\t\t\t\t\t}\r\n",
       "\t\t\t\t} else if (all_objects[i].children[j].material.transparent && \r\n",
       "\t\t\t\t\t\t\t  all_objects[i].children[j].material.type == \"MeshBasicMaterial\" &&\r\n",
       "\t\t\t\t\t\t\t  all_objects[i].children[j].geometry.type == \"Geometry\"){\r\n",
       "\t\t\t\t\tall_objects[i].children[j].material.opacity = opacity;\r\n",
       "\t\t\t\t\tall_objects[i].children[j].material.depthWrite = opacity < 0.5 ? false : true;\r\n",
       "\t\t\t\t\tall_objects[i].children[j].material.depthTest = opacity < 0.5 ? false : true;\r\n",
       "\t\t\t\t}\r\n",
       "\t\t\t}\r\n",
       "\t\t}\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction changeRotationX(event){\r\n",
       "\t\txRotationEnabled = event.currentTarget.checked;\r\n",
       "\t}\t\r\n",
       "\r\n",
       "\tfunction changeRotationY(event){\r\n",
       "\t\tyRotationEnabled = event.currentTarget.checked;\r\n",
       "\t}\t\r\n",
       "\r\n",
       "\tfunction changeRotationZ(event){\r\n",
       "\t\tzRotationEnabled = event.currentTarget.checked;\r\n",
       "\t}\t\r\n",
       "\r\n",
       "\r\n",
       "\tfunction changeRotationSpeedFactor(event){\r\n",
       "\t\trotationSpeedFactor = Number(event.currentTarget.value);\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction resetScene(){\r\n",
       "\t\tscene.rotation.set(0,0,0);\r\n",
       "\t\tcamera.position.set(0,0,5);\r\n",
       "\t\tcamera.up.set(0,1,0);\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction showSettings(event){\r\n",
       "\t\tevent.currentTarget.style.display = 'none';\r\n",
       "\t\tdocument.getElementById('settings').style.display = 'inline-block';\r\n",
       "\t\tdocument.getElementById('hideSettingsButton').style.display = 'inline';\r\n",
       "\t\tvar canvas = document.getElementsByTagName('canvas')[0];\r\n",
       "\t\tcanvas.style.right = '0px';\r\n",
       "\t\tcanvas.style.transform = 'translate(0,0)';\r\n",
       "\t\tsettingsShown = true;\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction hideSettings(event){\r\n",
       "\t\tevent.currentTarget.style.display = 'none';\r\n",
       "\t\tdocument.getElementById('settings').style.display = 'none';\r\n",
       "\t\tdocument.getElementById('showSettingsButton').style.display = 'block';\r\n",
       "\t\tvar canvas = document.getElementsByTagName('canvas')[0];\r\n",
       "\t\tcanvas.style.right = '50%';\r\n",
       "\t\tcanvas.style.transform = 'translate(50%,0)';\r\n",
       "\t\tsettingsShown = false;\r\n",
       "\t}\r\n",
       "\r\n",
       "\r\n",
       "\r\n",
       "\tvar pos = 150* Math.PI;\r\n",
       "\r\n",
       "\tfunction updateFactor() {\r\n",
       "\t\tpos++;\r\n",
       "\t\treturn Math.sin(.01*pos)+1;\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction makelabel(message, x, y, z, params) {\r\n",
       "\t\tvar spritey = textSprite( message, params );\r\n",
       "\t\tspritey.position.set(x, y, z);\r\n",
       "\t\tobj.add(spritey);\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction textSprite(message, parameters)\r\n",
       "\t{\r\n",
       "\t\tif ( parameters === undefined ) parameters = {};\r\n",
       "\r\n",
       "\t\tvar fontface = \"Helvetica\";\r\n",
       "\r\n",
       "\t\tvar fontsize = parameters.hasOwnProperty(\"fontsize\") ? \r\n",
       "\t\t\tparameters[\"fontsize\"] : 18;\r\n",
       "\t\tfontsize = fontsize*10;\r\n",
       "\r\n",
       "\t\tvar canvas = document.createElement('canvas');\r\n",
       "\t\tvar size = 1000;\r\n",
       "\t\tcanvas.width = size;\r\n",
       "\t\tcanvas.height = size;\r\n",
       "\t\tvar context = canvas.getContext('2d');\r\n",
       "\t\tcontext.font = fontsize + \"px \" + fontface;\r\n",
       "\r\n",
       "\t\t// text color\r\n",
       "\t\tcontext.fillStyle = \"rgba(0, 0, 0, 1.0)\";\r\n",
       "\r\n",
       "\t\tcontext.fillText(message, size/2, size/2);\r\n",
       "\r\n",
       "\t\t// canvas contents will be used for a texture\r\n",
       "\t\tvar texture = new THREE.Texture(canvas);\r\n",
       "\t\ttexture.needsUpdate = true;\r\n",
       "\r\n",
       "\t\tvar spriteMaterial = new THREE.SpriteMaterial(\r\n",
       "\t\t\t{map: texture, useScreenCoordinates: false});\r\n",
       "\t\tvar sprite = new THREE.Sprite(spriteMaterial);\r\n",
       "\t\treturn sprite;\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction takeSvgScreenshot(){\r\n",
       "\t\tif (labelsShown){\r\n",
       "\t\t\thideLabels();\r\n",
       "\t\t}\r\n",
       "\t\tsvgRenderer.render(scene,camera);\r\n",
       "\t\tsvgElement = XMLS.serializeToString(svgRenderer.domElement);\r\n",
       "\t\t\r\n",
       "\t\tif (labelsShown){\r\n",
       "\t\t\tdisplayLabels();\r\n",
       "\t\t}\r\n",
       "\r\n",
       "\t\tif (document.getElementById('tab').checked){\r\n",
       "\t\t\t//show in new tab\r\n",
       "\t\t\tvar myWindow = window.open(\"\",\"\");\r\n",
       "\t\t\tmyWindow.document.body.innerHTML = svgElement;\r\n",
       "\t\t} else{\r\n",
       "\t\t\t// download svg file \r\n",
       "\t\t\tdownload(\"screenshot.svg\", svgElement);\r\n",
       "\t\t}\r\n",
       "\t}\r\n",
       "\t\t\r\n",
       "\r\n",
       "\tfunction showOrHideObject(event){\r\n",
       "\t\tvar nr = Number(event.currentTarget.name);\r\n",
       "\t\tall_objects[nr].visible = event.currentTarget.checked;\r\n",
       "\t}\r\n",
       "\r\n",
       "\r\n",
       "\tfunction displayOrHideOptions(){\r\n",
       "\t\tfor (var i=0; i<all_objects.length; i++){\r\n",
       "\t\t\tfor (var j=0; j<all_objects[i].children.length; j++){\r\n",
       "\t\t\t\tif (all_objects[i].children[j].material.type == \"MultiMaterial\") {\r\n",
       "\t\t\t\t\tfor (var k=0; k<all_objects[i].children[j].material.materials.length; k++){\r\n",
       "\t\t\t\t\t\tif (all_objects[i].children[j].material.materials[k].transparent) {\r\n",
       "\t\t\t\t\t\t\tdocument.getElementById('transparency').style.display = 'block';\r\n",
       "\t\t\t\t\t\t\tdocument.getElementById('transparencyRange').value = 1 - \r\n",
       "\t\t\t\t\t\t\t    all_objects[i].children[j].material.materials[k].opacity;\r\n",
       "\t\t\t\t\t\t\treturn;\r\n",
       "\t\t\t\t\t\t}\r\n",
       "\t\t\t\t\t}\r\n",
       "\t\t\t\t} else if (all_objects[i].children[j].material.transparent && \r\n",
       "\t\t\t\t\t\t\t  all_objects[i].children[j].material.type == \"MeshBasicMaterial\" &&\r\n",
       "\t\t\t\t\t\t\t  all_objects[i].children[j].geometry.type == \"Geometry\"){\r\n",
       "\t\t\t\t\tdocument.getElementById('transparency').style.display = 'block';\r\n",
       "\t\t\t\t\treturn;\r\n",
       "\t\t\t\t}\r\n",
       "\t\t\t}\r\n",
       "\t\t}\r\n",
       "\t}\r\n",
       "\r\n",
       "\tdisplayOrHideOptions()\r\n",
       "\r\n",
       "\r\n",
       "\r\n",
       "\r\n",
       "// ---------------------- EXPLOSION ------------------------------------------------\r\n",
       "// ---------------------------------------------------------------------------------\r\n",
       "\r\n",
       "\tfunction explode(factor) {\r\n",
       "\t\tvar obj, c;\r\n",
       "\t\tvar c0 = centroids[0];\r\n",
       "\t\tfor (var i = 0; i<centroids.length; ++i) {\r\n",
       "\t\t\tc = centroids[i];\r\n",
       "\t\t\tobj = all_objects[all_objects.length - centroids.length + i];\r\n",
       "\t\t\tobj.position.set(c.x*factor, c.y*factor, c.z*factor);\r\n",
       "\t\t}\t\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction triggerExplode(event){\r\n",
       "\t\texplodeScale = Number(event.currentTarget.value);\r\n",
       "\t\texplode(explodeScale);\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction setExplodingSpeed(event){\r\n",
       "\t\texplodingSpeed = Number(event.currentTarget.value);\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction triggerAutomaticExplode(event){\r\n",
       "\t\tif (event.currentTarget.checked){\r\n",
       "\t\t\tstartExploding();\r\n",
       "\t\t} else {\r\n",
       "\t\t\tclearIntervals();\r\n",
       "\t\t}\t\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction startExploding(){\r\n",
       "\t\tintervals.push(setInterval(explodingInterval, 25));\r\n",
       "\t}\r\n",
       "\r\n",
       "\r\n",
       "\tfunction explodingInterval(){\r\n",
       "\t\texplodeScale += explodingSpeed;\r\n",
       "\t\tif (explodeScale <= 6){ \r\n",
       "\t\t\texplode(explodeScale);\r\n",
       "\t\t}\r\n",
       "\t\telse{\r\n",
       "\t\t\texplode(6);\r\n",
       "\t\t\texplodeScale = 6;\r\n",
       "\t\t\tclearIntervals();\r\n",
       "\t\t\ttimeouts.push(setTimeout(startUnexploding, 3000));\r\n",
       "\t\t}\r\n",
       "\t\tdocument.getElementById('explodeRange').value = explodeScale;\r\n",
       "\t}\r\n",
       "\r\n",
       "\r\n",
       "\tfunction startUnexploding(){\r\n",
       "\t\tintervals.push(setInterval(unexplodingInterval, 25));\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction unexplodingInterval(){\r\n",
       "\t\texplodeScale -= explodingSpeed;\r\n",
       "\t\tif (explodeScale >= 0){\t\r\n",
       "\t\t\texplode(explodeScale);\r\n",
       "\t\t}\r\n",
       "\t\telse {\r\n",
       "\t\t\texplode(0);\r\n",
       "\t\t\texplodeScale = 0;\r\n",
       "\t\t\tclearIntervals();\r\n",
       "\t\t\ttimeouts.push(setTimeout(startExploding, 3000));\r\n",
       "\t\t}\r\n",
       "\t\tdocument.getElementById('explodeRange').value = explodeScale;\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction clearIntervals(){\r\n",
       "\t\tintervals.forEach(function(interval){\r\n",
       "\t\t\tclearInterval(interval);\r\n",
       "\t\t});\r\n",
       "\t\tintervals = [];\r\n",
       "\t\ttimeouts.forEach(function(timeout){\r\n",
       "\t\t\tclearTimeout(timeout);\r\n",
       "\t\t});\r\n",
       "\t\ttimeouts = [];\r\n",
       "\t}\r\n",
       "\r\n",
       "\t\t\t\r\n",
       "\r\n",
       "\t// append checkboxes for displaying or hiding objects\r\n",
       "\tvar shownObjectsList = document.getElementById('shownObjectsList');\r\n",
       "\tfor (var i=0; i<all_objects.length; i++){\r\n",
       "\t\tvar objNode = document.createElement('span');\r\n",
       "\t\tobjNode.innerHTML = objectnames[i] + '<br>';\r\n",
       "\t\tvar checkbox = document.createElement('input');\r\n",
       "\t\tcheckbox.type = 'checkbox';\r\n",
       "\t\tcheckbox.checked = true;\r\n",
       "\t\tcheckbox.name = String(i);\r\n",
       "\t\tcheckbox.onchange = showOrHideObject;\r\n",
       "\t\tshownObjectsList.appendChild(checkbox);\r\n",
       "\t\tshownObjectsList.appendChild(objNode);\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction displayLabels(){\r\n",
       "\t\tfor (var i=0; i<all_objects.length; i++){\r\n",
       "\t\t\tfor (var j=0; j<all_objects[i].children.length; j++){\r\n",
       "\t\t\t\tvar child = all_objects[i].children[j];\r\n",
       "\t\t\t\tif (child.type == 'Sprite'){\r\n",
       "\t\t\t\t\tchild.visible = true;\r\n",
       "\t\t\t\t}\r\n",
       "\t\t\t}\r\n",
       "\t\t}\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction hideLabels(){\r\n",
       "\t\tfor (var i=0; i<all_objects.length; i++){\r\n",
       "\t\t\tfor (var j=0; j<all_objects[i].children.length; j++){\r\n",
       "\t\t\t\tvar child = all_objects[i].children[j];\r\n",
       "\t\t\t\tif (child.type == 'Sprite'){\r\n",
       "\t\t\t\t\tchild.visible = false;\r\n",
       "\t\t\t\t}\r\n",
       "\t\t\t}\r\n",
       "\t\t}\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction displayOrHideLabels(event){\r\n",
       "\t\tif (event.currentTarget.checked){\r\n",
       "\t\t\tdisplayLabels();\r\n",
       "\t\t\tlabelsShown = true;\r\n",
       "\t\t} else {\r\n",
       "\t\t\thideLabels();\r\n",
       "\t\t\tlabelsShown = false;\r\n",
       "\t\t}\r\n",
       "\t}\r\n",
       "\r\n",
       "\tfunction download(filename, text) {\r\n",
       "\t  var element = document.createElement('a');\r\n",
       "\t  element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));\r\n",
       "\t  element.setAttribute('download', filename);\r\n",
       "\r\n",
       "\t  element.style.display = 'none';\r\n",
       "\t  document.body.appendChild(element);\r\n",
       "\r\n",
       "\t  element.click();\r\n",
       "\r\n",
       "\t  document.body.removeChild(element);\r\n",
       "\t}\r\n",
       "\r\n",
       "\t\r\n",
       "\r\n",
       "// ------------------ SHORTCUTS --------------------------------------------\r\n",
       "// -------------------------------------------------------------------------\r\n",
       "\r\n",
       "/**\r\n",
       " * http://www.openjs.com/scripts/events/keyboard_shortcuts/\r\n",
       " * Version : 2.01.B\r\n",
       " * By Binny V A\r\n",
       " * License : BSD\r\n",
       " */\r\n",
       "shortcut = {\r\n",
       "\t'all_shortcuts':{},//All the shortcuts are stored in this array\r\n",
       "\t'add': function(shortcut_combination,callback,opt) {\r\n",
       "\t\t//Provide a set of default options\r\n",
       "\t\tvar default_options = {\r\n",
       "\t\t\t'type':'keydown',\r\n",
       "\t\t\t'propagate':false,\r\n",
       "\t\t\t'disable_in_input':false,\r\n",
       "\t\t\t'target':document,\r\n",
       "\t\t\t'keycode':false\r\n",
       "\t\t}\r\n",
       "\t\tif(!opt) opt = default_options;\r\n",
       "\t\telse {\r\n",
       "\t\t\tfor(var dfo in default_options) {\r\n",
       "\t\t\t\tif(typeof opt[dfo] == 'undefined') opt[dfo] = default_options[dfo];\r\n",
       "\t\t\t}\r\n",
       "\t\t}\r\n",
       "\r\n",
       "\t\tvar ele = opt.target;\r\n",
       "\t\tif(typeof opt.target == 'string') ele = document.getElementById(opt.target);\r\n",
       "\t\tvar ths = this;\r\n",
       "\t\tshortcut_combination = shortcut_combination.toLowerCase();\r\n",
       "\r\n",
       "\t\t//The function to be called at keypress\r\n",
       "\t\tvar func = function(e) {\r\n",
       "\t\t\te = e || window.event;\r\n",
       "\t\t\t\r\n",
       "\t\t\tif(opt['disable_in_input']) { //Don't enable shortcut keys in Input, Textarea fields\r\n",
       "\t\t\t\tvar element;\r\n",
       "\t\t\t\tif(e.target) element=e.target;\r\n",
       "\t\t\t\telse if(e.srcElement) element=e.srcElement;\r\n",
       "\t\t\t\tif(element.nodeType==3) element=element.parentNode;\r\n",
       "\r\n",
       "\t\t\t\tif(element.tagName == 'INPUT' || element.tagName == 'TEXTAREA') return;\r\n",
       "\t\t\t}\r\n",
       "\t\r\n",
       "\t\t\t//Find Which key is pressed\r\n",
       "\t\t\tif (e.keyCode) code = e.keyCode;\r\n",
       "\t\t\telse if (e.which) code = e.which;\r\n",
       "\t\t\tvar character = String.fromCharCode(code).toLowerCase();\r\n",
       "\t\t\t\r\n",
       "\t\t\tif(code == 188) character=\",\"; //If the user presses , when the type is onkeydown\r\n",
       "\t\t\tif(code == 190) character=\".\"; //If the user presses , when the type is onkeydown\r\n",
       "\r\n",
       "\t\t\tvar keys = shortcut_combination.split(\"+\");\r\n",
       "\t\t\t//Key Pressed - counts the number of valid keypresses - if it is same as the number of keys, the shortcut function is invoked\r\n",
       "\t\t\tvar kp = 0;\r\n",
       "\t\t\t\r\n",
       "\t\t\t//Work around for stupid Shift key bug created by using lowercase - as a result the shift+num combination was broken\r\n",
       "\t\t\tvar shift_nums = {\r\n",
       "\t\t\t\t\"`\":\"~\",\r\n",
       "\t\t\t\t\"1\":\"!\",\r\n",
       "\t\t\t\t\"2\":\"@\",\r\n",
       "\t\t\t\t\"3\":\"#\",\r\n",
       "\t\t\t\t\"4\":\"$\",\r\n",
       "\t\t\t\t\"5\":\"%\",\r\n",
       "\t\t\t\t\"6\":\"^\",\r\n",
       "\t\t\t\t\"7\":\"&\",\r\n",
       "\t\t\t\t\"8\":\"*\",\r\n",
       "\t\t\t\t\"9\":\"(\",\r\n",
       "\t\t\t\t\"0\":\")\",\r\n",
       "\t\t\t\t\"-\":\"_\",\r\n",
       "\t\t\t\t\"=\":\"+\",\r\n",
       "\t\t\t\t\";\":\":\",\r\n",
       "\t\t\t\t\"'\":\"\\\"\",\r\n",
       "\t\t\t\t\",\":\"<\",\r\n",
       "\t\t\t\t\".\":\">\",\r\n",
       "\t\t\t\t\"/\":\"?\",\r\n",
       "\t\t\t\t\"\\\\\":\"|\"\r\n",
       "\t\t\t}\r\n",
       "\t\t\t//Special Keys - and their codes\r\n",
       "\t\t\tvar special_keys = {\r\n",
       "\t\t\t\t'esc':27,\r\n",
       "\t\t\t\t'escape':27,\r\n",
       "\t\t\t\t'tab':9,\r\n",
       "\t\t\t\t'space':32,\r\n",
       "\t\t\t\t'return':13,\r\n",
       "\t\t\t\t'enter':13,\r\n",
       "\t\t\t\t'backspace':8,\r\n",
       "\t\r\n",
       "\t\t\t\t'scrolllock':145,\r\n",
       "\t\t\t\t'scroll_lock':145,\r\n",
       "\t\t\t\t'scroll':145,\r\n",
       "\t\t\t\t'capslock':20,\r\n",
       "\t\t\t\t'caps_lock':20,\r\n",
       "\t\t\t\t'caps':20,\r\n",
       "\t\t\t\t'numlock':144,\r\n",
       "\t\t\t\t'num_lock':144,\r\n",
       "\t\t\t\t'num':144,\r\n",
       "\t\t\t\t\r\n",
       "\t\t\t\t'pause':19,\r\n",
       "\t\t\t\t'break':19,\r\n",
       "\t\t\t\t\r\n",
       "\t\t\t\t'insert':45,\r\n",
       "\t\t\t\t'home':36,\r\n",
       "\t\t\t\t'delete':46,\r\n",
       "\t\t\t\t'end':35,\r\n",
       "\t\t\t\t\r\n",
       "\t\t\t\t'pageup':33,\r\n",
       "\t\t\t\t'page_up':33,\r\n",
       "\t\t\t\t'pu':33,\r\n",
       "\t\r\n",
       "\t\t\t\t'pagedown':34,\r\n",
       "\t\t\t\t'page_down':34,\r\n",
       "\t\t\t\t'pd':34,\r\n",
       "\t\r\n",
       "\t\t\t\t'left':37,\r\n",
       "\t\t\t\t'up':38,\r\n",
       "\t\t\t\t'right':39,\r\n",
       "\t\t\t\t'down':40,\r\n",
       "\t\r\n",
       "\t\t\t\t'f1':112,\r\n",
       "\t\t\t\t'f2':113,\r\n",
       "\t\t\t\t'f3':114,\r\n",
       "\t\t\t\t'f4':115,\r\n",
       "\t\t\t\t'f5':116,\r\n",
       "\t\t\t\t'f6':117,\r\n",
       "\t\t\t\t'f7':118,\r\n",
       "\t\t\t\t'f8':119,\r\n",
       "\t\t\t\t'f9':120,\r\n",
       "\t\t\t\t'f10':121,\r\n",
       "\t\t\t\t'f11':122,\r\n",
       "\t\t\t\t'f12':123\r\n",
       "\t\t\t}\r\n",
       "\t\r\n",
       "\t\t\tvar modifiers = { \r\n",
       "\t\t\t\tshift: { wanted:false, pressed:false},\r\n",
       "\t\t\t\tctrl : { wanted:false, pressed:false},\r\n",
       "\t\t\t\talt  : { wanted:false, pressed:false},\r\n",
       "\t\t\t\tmeta : { wanted:false, pressed:false}\t//Meta is Mac specific\r\n",
       "\t\t\t};\r\n",
       "                        \r\n",
       "\t\t\tif(e.ctrlKey)\tmodifiers.ctrl.pressed = true;\r\n",
       "\t\t\tif(e.shiftKey)\tmodifiers.shift.pressed = true;\r\n",
       "\t\t\tif(e.altKey)\tmodifiers.alt.pressed = true;\r\n",
       "\t\t\tif(e.metaKey)   modifiers.meta.pressed = true;\r\n",
       "                        \r\n",
       "\t\t\tfor(var i=0; k=keys[i],i<keys.length; i++) {\r\n",
       "\t\t\t\t//Modifiers\r\n",
       "\t\t\t\tif(k == 'ctrl' || k == 'control') {\r\n",
       "\t\t\t\t\tkp++;\r\n",
       "\t\t\t\t\tmodifiers.ctrl.wanted = true;\r\n",
       "\r\n",
       "\t\t\t\t} else if(k == 'shift') {\r\n",
       "\t\t\t\t\tkp++;\r\n",
       "\t\t\t\t\tmodifiers.shift.wanted = true;\r\n",
       "\r\n",
       "\t\t\t\t} else if(k == 'alt') {\r\n",
       "\t\t\t\t\tkp++;\r\n",
       "\t\t\t\t\tmodifiers.alt.wanted = true;\r\n",
       "\t\t\t\t} else if(k == 'meta') {\r\n",
       "\t\t\t\t\tkp++;\r\n",
       "\t\t\t\t\tmodifiers.meta.wanted = true;\r\n",
       "\t\t\t\t} else if(k.length > 1) { //If it is a special key\r\n",
       "\t\t\t\t\tif(special_keys[k] == code) kp++;\r\n",
       "\t\t\t\t\t\r\n",
       "\t\t\t\t} else if(opt['keycode']) {\r\n",
       "\t\t\t\t\tif(opt['keycode'] == code) kp++;\r\n",
       "\r\n",
       "\t\t\t\t} else { //The special keys did not match\r\n",
       "\t\t\t\t\tif(character == k) kp++;\r\n",
       "\t\t\t\t\telse {\r\n",
       "\t\t\t\t\t\tif(shift_nums[character] && e.shiftKey) { //Stupid Shift key bug created by using lowercase\r\n",
       "\t\t\t\t\t\t\tcharacter = shift_nums[character]; \r\n",
       "\t\t\t\t\t\t\tif(character == k) kp++;\r\n",
       "\t\t\t\t\t\t}\r\n",
       "\t\t\t\t\t}\r\n",
       "\t\t\t\t}\r\n",
       "\t\t\t}\r\n",
       "\t\t\t\r\n",
       "\t\t\tif(kp == keys.length && \r\n",
       "\t\t\t\t\t\tmodifiers.ctrl.pressed == modifiers.ctrl.wanted &&\r\n",
       "\t\t\t\t\t\tmodifiers.shift.pressed == modifiers.shift.wanted &&\r\n",
       "\t\t\t\t\t\tmodifiers.alt.pressed == modifiers.alt.wanted &&\r\n",
       "\t\t\t\t\t\tmodifiers.meta.pressed == modifiers.meta.wanted) {\r\n",
       "\t\t\t\tcallback(e);\r\n",
       "\t\r\n",
       "\t\t\t\tif(!opt['propagate']) { //Stop the event\r\n",
       "\t\t\t\t\t//e.cancelBubble is supported by IE - this will kill the bubbling process.\r\n",
       "\t\t\t\t\te.cancelBubble = true;\r\n",
       "\t\t\t\t\te.returnValue = false;\r\n",
       "\t\r\n",
       "\t\t\t\t\t//e.stopPropagation works in Firefox.\r\n",
       "\t\t\t\t\tif (e.stopPropagation) {\r\n",
       "\t\t\t\t\t\te.stopPropagation();\r\n",
       "\t\t\t\t\t\te.preventDefault();\r\n",
       "\t\t\t\t\t}\r\n",
       "\t\t\t\t\treturn false;\r\n",
       "\t\t\t\t}\r\n",
       "\t\t\t}\r\n",
       "\t\t}\r\n",
       "\t\tthis.all_shortcuts[shortcut_combination] = {\r\n",
       "\t\t\t'callback':func, \r\n",
       "\t\t\t'target':ele, \r\n",
       "\t\t\t'event': opt['type']\r\n",
       "\t\t};\r\n",
       "\t\t//Attach the function with the event\r\n",
       "\t\tif(ele.addEventListener) ele.addEventListener(opt['type'], func, false);\r\n",
       "\t\telse if(ele.attachEvent) ele.attachEvent('on'+opt['type'], func);\r\n",
       "\t\telse ele['on'+opt['type']] = func;\r\n",
       "\t},\r\n",
       "\r\n",
       "\t//Remove the shortcut - just specify the shortcut and I will remove the binding\r\n",
       "\t'remove':function(shortcut_combination) {\r\n",
       "\t\tshortcut_combination = shortcut_combination.toLowerCase();\r\n",
       "\t\tvar binding = this.all_shortcuts[shortcut_combination];\r\n",
       "\t\tdelete(this.all_shortcuts[shortcut_combination])\r\n",
       "\t\tif(!binding) return;\r\n",
       "\t\tvar type = binding['event'];\r\n",
       "\t\tvar ele = binding['target'];\r\n",
       "\t\tvar callback = binding['callback'];\r\n",
       "\r\n",
       "\t\tif(ele.detachEvent) ele.detachEvent('on'+type, callback);\r\n",
       "\t\telse if(ele.removeEventListener) ele.removeEventListener(type, callback, false);\r\n",
       "\t\telse ele['on'+type] = false;\r\n",
       "\t}\r\n",
       "}\r\n",
       "\r\n",
       "shortcut.add(\"Alt+Left\",function() {\r\n",
       "\tvar event = new Event('click');\r\n",
       "\tif (settingsShown){\r\n",
       "\t\tdocument.getElementById('hideSettingsButton').dispatchEvent(event);\r\n",
       "\t} else{\r\n",
       "\t\tdocument.getElementById('showSettingsButton').dispatchEvent(event);\r\n",
       "\t}\r\n",
       "});\r\n",
       "\r\n",
       "\r\n",
       "if (foldable) moveToBaryCenter();\r\n",
       "\r\n",
       "\r\n",
       "// COMMON_CODE_BLOCK_END\r\n",
       "</script>\r\n",
       "\r\n",
       "</body>\r\n",
       "</html>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "$c->VISUAL;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "$d=cube(3);"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": [
    "$d->VISUAL;"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true,
    "deletable": true,
    "editable": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "polymake",
   "language": "polymake",
   "name": "polymake"
  },
  "language_info": {
   "codemirror_mode": "perl",
   "file_extension": ".pl",
   "mimetype": "text/x-polymake",
   "name": "polymake"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
