e7bc59b9ebda

Switch to Hugo
[view raw] [browse files]
author Steve Losh <steve@stevelosh.com>
date Fri, 07 Oct 2016 12:48:36 +0000
parents bbf39c61e3fe
children de64f1b0d5c0
branches/tags (none)
files DESIGN.mdown LICENSE Makefile config.toml content/404.html content/about.html content/about/index.markdown content/blog/2008/02/microsoft-entourage-applescript-frustration.html content/blog/2008/02/microsoft-entourage-applescript-frustration.markdown content/blog/2008/04/shooting-girl-jam.html content/blog/2008/04/shooting-girl-jam.markdown content/blog/2008/08/beauty-in-computer-science-recursion.html content/blog/2008/08/beauty-in-computer-science-recursion.markdown content/blog/2008/08/negative-space-dancing.html content/blog/2008/08/negative-space-dancing.markdown content/blog/2008/08/on-leading.html content/blog/2008/08/on-leading.markdown content/blog/2009/01/deploying-site-fabric-and-mercurial.html content/blog/2009/01/deploying-site-fabric-and-mercurial.markdown content/blog/2009/01/going-open-source.html content/blog/2009/01/going-open-source.markdown content/blog/2009/01/site-redesign.html content/blog/2009/01/site-redesign.markdown content/blog/2009/02/how-and-why-i-dj.html content/blog/2009/02/how-and-why-i-dj.markdown content/blog/2009/02/how-i-shoot-dances.html content/blog/2009/02/how-i-shoot-dances.markdown content/blog/2009/03/candy-colored-terminal.html content/blog/2009/03/candy-colored-terminal.markdown content/blog/2009/03/mercurial-bash-prompts.html content/blog/2009/03/mercurial-bash-prompts.markdown content/blog/2009/04/why-people-dont-like-metal.html content/blog/2009/04/why-people-dont-like-metal.markdown content/blog/2009/05/what-i-hate-about-mercurial.html content/blog/2009/05/what-i-hate-about-mercurial.markdown content/blog/2009/06/how-to-contribute-to-mercurial.html content/blog/2009/06/how-to-contribute-to-mercurial.markdown content/blog/2009/08/a-guide-to-branching-in-mercurial.html content/blog/2009/08/a-guide-to-branching-in-mercurial.markdown content/blog/2009/11/my-sitesprint-project-lindyhub.html content/blog/2009/11/my-sitesprint-project-lindyhub.markdown content/blog/2010/01/moving-from-django-to-hyde.html content/blog/2010/01/moving-from-django-to-hyde.markdown content/blog/2010/01/the-real-difference-between-mercurial-and-git.html content/blog/2010/01/the-real-difference-between-mercurial-and-git.markdown content/blog/2010/02/mercurial-workflows-branch-as-needed.html content/blog/2010/02/mercurial-workflows-branch-as-needed.markdown content/blog/2010/02/my-extravagant-zsh-prompt.html content/blog/2010/02/my-extravagant-zsh-prompt.markdown content/blog/2010/04/a-faster-feed-apart.html content/blog/2010/04/a-faster-feed-apart.markdown content/blog/2010/05/mercurial-workflows-stable-default.html content/blog/2010/05/mercurial-workflows-stable-default.markdown content/blog/2010/06/mercurial-workflows-translation-branches.html content/blog/2010/06/mercurial-workflows-translation-branches.markdown content/blog/2010/08/a-git-users-guide-to-mercurial-queues.html content/blog/2010/08/a-git-users-guide-to-mercurial-queues.markdown content/blog/2010/09/coming-home-to-vim.html content/blog/2010/09/coming-home-to-vim.markdown content/blog/2010/09/making-my-site-sing.html content/blog/2010/09/making-my-site-sing.markdown content/blog/2010/11/keep-calm-and-carry-on.html content/blog/2010/11/keep-calm-and-carry-on.markdown content/blog/2011/05/on-learning-and-teaching.html content/blog/2011/05/on-learning-and-teaching.markdown content/blog/2011/05/paper-free.html content/blog/2011/05/paper-free.markdown content/blog/2011/06/django-advice.html content/blog/2011/06/django-advice.markdown content/blog/2011/09/writing-vim-plugins.html content/blog/2011/09/writing-vim-plugins.markdown content/blog/2012/04/volatile-software.html content/blog/2012/04/volatile-software.markdown content/blog/2012/07/caves-of-clojure-01.html content/blog/2012/07/caves-of-clojure-01.markdown content/blog/2012/07/caves-of-clojure-02.html content/blog/2012/07/caves-of-clojure-02.markdown content/blog/2012/07/caves-of-clojure-03-1.html content/blog/2012/07/caves-of-clojure-03-1.markdown content/blog/2012/07/caves-of-clojure-03-2.html content/blog/2012/07/caves-of-clojure-03-2.markdown content/blog/2012/07/caves-of-clojure-03-3.html content/blog/2012/07/caves-of-clojure-03-3.markdown content/blog/2012/07/caves-of-clojure-03-4.html content/blog/2012/07/caves-of-clojure-03-4.markdown content/blog/2012/07/caves-of-clojure-04.html content/blog/2012/07/caves-of-clojure-04.markdown content/blog/2012/07/caves-of-clojure-05.html content/blog/2012/07/caves-of-clojure-05.markdown content/blog/2012/07/caves-of-clojure-06.html content/blog/2012/07/caves-of-clojure-06.markdown content/blog/2012/07/caves-of-clojure-interlude-1.html content/blog/2012/07/caves-of-clojure-interlude-1.markdown content/blog/2012/10/a-modern-space-cadet.html content/blog/2012/10/a-modern-space-cadet.markdown content/blog/2012/10/caves-of-clojure-07-1.html content/blog/2012/10/caves-of-clojure-07-1.markdown content/blog/2012/10/the-homely-mutt.html content/blog/2012/10/the-homely-mutt.markdown content/blog/2012/10/why-i-two-space.html content/blog/2012/10/why-i-two-space.markdown content/blog/2013/03/list-out-of-lambda.html content/blog/2013/03/list-out-of-lambda.markdown content/blog/2013/04/git-koans.html content/blog/2013/04/git-koans.markdown content/blog/2013/09/teach-dont-tell.html content/blog/2013/09/teach-dont-tell.markdown content/blog/2015/07/nat-geo-a2540.html content/blog/2015/07/nat-geo-a2540.markdown content/blog/2015/07/nat-geo-mc5350.html content/blog/2015/07/nat-geo-mc5350.markdown content/blog/2015/11/beat-the-data.html content/blog/2015/11/beat-the-data.markdown content/blog/2015/11/happy-little-words.html content/blog/2015/11/happy-little-words.markdown content/blog/2015/12/ludum-dare-34.html content/blog/2015/12/ludum-dare-34.markdown content/blog/2015/12/permutation-patterns.html content/blog/2015/12/permutation-patterns.markdown content/blog/2016/02/midpoint-displacement.html content/blog/2016/02/midpoint-displacement.markdown content/blog/2016/03/recursive-midpoint-displacement.html content/blog/2016/03/recursive-midpoint-displacement.markdown content/blog/2016/06/diamond-square.html content/blog/2016/06/diamond-square.markdown content/blog/2016/06/symbolic-computation.html content/blog/2016/06/symbolic-computation.markdown content/blog/2016/08/lisp-jam-postmortem.html content/blog/2016/08/lisp-jam-postmortem.markdown content/blog/2016/08/playing-with-syntax.html content/blog/2016/08/playing-with-syntax.markdown content/blog/2016/09/iterate-averaging.html content/blog/2016/09/iterate-averaging.markdown content/blog/index.html content/feed.html content/index.html content/links.html content/links/index.markdown content/projects/badwolf.html content/projects/clam.html content/projects/clojure-postmark.html content/projects/d.html content/projects/django-hoptoad.html content/projects/friendly-find.html content/projects/fuego.html content/projects/grabtweets.html content/projects/gundo.html content/projects/hg-paste.html content/projects/hg-prompt.html content/projects/hgtab.html content/projects/index.html content/projects/learnvimscriptthehardway.html content/projects/lindyjam-com.html content/projects/peat.html content/projects/roul.html content/projects/splice.html content/projects/stevelosh-com.html content/projects/t.html content/projects/threesome.html content/projects/typkov.html content/projects/vitality.html content/projects/women-in-water.html content/resume.html content/resume/index.markdown custom/__init__.py custom/processors.py custom/templatetags/__init__.py custom/templatetags/mathjax.py layout/_flatpage.html layout/_post.html layout/_splash.html layout/skeleton/_atom.xml layout/skeleton/_base.html layout/skeleton/_body.html layout/skeleton/_index.html layout/skeleton/_innerindex.html layout/skeleton/_innerlisting.html layout/skeleton/_listing.html layout/skeleton/_listingitem.html layout/skeleton/_root.html layouts/shortcodes/toc.html media/css/aal.css media/css/print.less media/css/pygments-clean.css media/css/pygments-monokai-light.css media/css/sjl.less media/diamond-square.monopic media/images/blog/2009/02/dj-playlist-sorting.png media/images/blog/2009/02/dj-playlist-unrated.png media/images/blog/2009/03/prompt-with-branch.png media/images/blog/2009/03/prompt-with-dirty.png media/images/blog/2009/03/prompt-without-branch.png media/images/blog/2009/03/terminal-colors.png media/images/blog/2009/08/branch-anon.png media/images/blog/2009/08/branch-base.png media/images/blog/2009/08/branch-bookmark.png media/images/blog/2009/08/branch-clone.png media/images/blog/2009/08/branch-named.png media/images/blog/2010/01/mercurial-vs-git.jpg media/images/blog/2010/02/hg-branching-1-after-merge.png media/images/blog/2010/02/hg-branching-1-needs-merge.png media/images/blog/2010/02/hg-branching-1-other.png media/images/blog/2010/02/hg-branching-1-start.png media/images/blog/2010/02/zsh-prompt-comments.png media/images/blog/2010/02/zsh-prompt.png media/images/blog/2010/05/default-stable-example.png media/images/blog/2010/06/translation-branches.png media/images/blog/2010/08/git-basics.png media/images/blog/2010/08/mercurial-basics.png media/images/blog/2010/08/mq-multiple.png media/images/blog/2010/08/mq-one.png media/images/blog/2010/08/mq-two.png media/images/blog/2010/08/mq-versioned.png media/images/blog/2010/09/rainbow.png media/images/blog/2010/09/vim.png media/images/blog/2011/05/rules-1-doxie.png media/images/blog/2011/05/rules-2-jotnot.png media/images/blog/2011/05/rules-3-ocr.png media/images/blog/2011/05/rules-4-clean.png media/images/blog/2012/07/caves-01-01.png media/images/blog/2012/07/caves-02-01.png media/images/blog/2012/07/caves-02-02.png media/images/blog/2012/07/caves-02-03.png media/images/blog/2012/07/caves-03-1-01.png media/images/blog/2012/07/caves-03-1-02.png media/images/blog/2012/07/caves-03-1-03.png media/images/blog/2012/07/caves-03-2-01.png media/images/blog/2012/07/caves-03-2-02.png media/images/blog/2012/07/caves-03-2-03.png media/images/blog/2012/07/caves-03-3-01.png media/images/blog/2012/07/caves-03-3-02.png media/images/blog/2012/07/caves-04-01.png media/images/blog/2012/07/caves-04-02.png media/images/blog/2012/07/caves-04-03.png media/images/blog/2012/07/caves-05-01.png media/images/blog/2012/07/caves-05-02.png media/images/blog/2012/07/caves-05-03.png media/images/blog/2012/07/caves-06-01.png media/images/blog/2012/07/caves-interlude-1-01.png media/images/blog/2012/07/caves-interlude-1-02.png media/images/blog/2012/10/caves-07-1-1.png media/images/blog/2012/10/caves-07-1-2.png media/images/blog/2012/10/kb-apple.jpg media/images/blog/2012/10/kb-caps.png media/images/blog/2012/10/kb-das.jpg media/images/blog/2012/10/kb-hex.png media/images/blog/2012/10/kb-hhkb.jpg media/images/blog/2012/10/kb-irc.png media/images/blog/2012/10/kb-key-overlaid.png media/images/blog/2012/10/kb-pck.png media/images/blog/2012/10/kb-realforce.jpg media/images/blog/2012/10/kb-size.jpg media/images/blog/2012/10/keychain-1.png media/images/blog/2012/10/keychain-2.png media/images/blog/2012/10/keychain-3.png media/images/blog/2012/10/mutt-attachments.png media/images/blog/2012/10/mutt-contacts-1.png media/images/blog/2012/10/mutt-index.png media/images/blog/2012/10/mutt-pager.png media/images/blog/2012/10/mutt-ready-to-send.png media/images/blog/2012/10/mutt-send-1.png media/images/blog/2012/10/mutt-urls.png media/images/blog/2012/10/what-the-mutt.png media/images/blog/2015/07/full/nat-geo-a2540-01.jpg media/images/blog/2015/07/full/nat-geo-a2540-02.jpg media/images/blog/2015/07/full/nat-geo-a2540-03.jpg media/images/blog/2015/07/full/nat-geo-a2540-04.jpg media/images/blog/2015/07/full/nat-geo-a2540-05.jpg media/images/blog/2015/07/full/nat-geo-a2540-06.jpg media/images/blog/2015/07/full/nat-geo-a2540-07.jpg media/images/blog/2015/07/full/nat-geo-a2540-08.jpg media/images/blog/2015/07/full/nat-geo-a2540-09.jpg media/images/blog/2015/07/full/nat-geo-a2540-10.jpg media/images/blog/2015/07/full/nat-geo-a2540-11.jpg media/images/blog/2015/07/full/nat-geo-a2540-12.jpg media/images/blog/2015/07/full/nat-geo-a2540-13.jpg media/images/blog/2015/07/full/nat-geo-a2540-14.jpg media/images/blog/2015/07/full/nat-geo-a2540-15.jpg media/images/blog/2015/07/full/nat-geo-a2540-16.jpg media/images/blog/2015/07/full/nat-geo-a2540-17.jpg media/images/blog/2015/07/full/nat-geo-a2540-18.jpg media/images/blog/2015/07/full/nat-geo-a2540-19.jpg media/images/blog/2015/07/full/nat-geo-a2540-20.jpg media/images/blog/2015/07/full/nat-geo-a2540-21.jpg media/images/blog/2015/07/full/nat-geo-a2540-22.jpg media/images/blog/2015/07/full/nat-geo-a2540-23.jpg media/images/blog/2015/07/full/nat-geo-a2540-24.jpg media/images/blog/2015/07/full/nat-geo-a2540-25.jpg media/images/blog/2015/07/full/nat-geo-a2540-26.jpg media/images/blog/2015/07/full/nat-geo-a2540-27.jpg media/images/blog/2015/07/full/nat-geo-a2540-28.jpg media/images/blog/2015/07/full/nat-geo-a2540-29.jpg media/images/blog/2015/07/full/nat-geo-a2540-30.jpg media/images/blog/2015/07/full/nat-geo-a2540-31.jpg media/images/blog/2015/07/full/nat-geo-a2540-32.jpg media/images/blog/2015/07/full/nat-geo-a2540-33.jpg media/images/blog/2015/07/full/nat-geo-a2540-34.jpg media/images/blog/2015/07/full/nat-geo-a2540-35.jpg media/images/blog/2015/07/full/nat-geo-a2540-36.jpg media/images/blog/2015/07/full/nat-geo-a2540-37.jpg media/images/blog/2015/07/full/nat-geo-a2540-38.jpg media/images/blog/2015/07/full/nat-geo-a2540-39.jpg media/images/blog/2015/07/full/nat-geo-a2540-40.jpg media/images/blog/2015/07/full/nat-geo-a2540-41.jpg media/images/blog/2015/07/full/nat-geo-a2540-42.jpg media/images/blog/2015/07/full/nat-geo-a2540-43.jpg media/images/blog/2015/07/full/nat-geo-a2540-44.jpg media/images/blog/2015/07/full/nat-geo-a2540-45.jpg media/images/blog/2015/07/full/nat-geo-a2540-46.jpg media/images/blog/2015/07/full/nat-geo-a2540-47.jpg media/images/blog/2015/07/full/nat-geo-a2540-48.jpg media/images/blog/2015/07/full/nat-geo-a2540-49.jpg media/images/blog/2015/07/full/nat-geo-mc5350-01.jpg media/images/blog/2015/07/full/nat-geo-mc5350-02.jpg media/images/blog/2015/07/full/nat-geo-mc5350-03.jpg media/images/blog/2015/07/full/nat-geo-mc5350-04.jpg media/images/blog/2015/07/full/nat-geo-mc5350-05.jpg media/images/blog/2015/07/full/nat-geo-mc5350-06.jpg media/images/blog/2015/07/full/nat-geo-mc5350-07.jpg media/images/blog/2015/07/full/nat-geo-mc5350-08.jpg media/images/blog/2015/07/full/nat-geo-mc5350-09.jpg media/images/blog/2015/07/full/nat-geo-mc5350-10.jpg media/images/blog/2015/07/full/nat-geo-mc5350-11.jpg media/images/blog/2015/07/full/nat-geo-mc5350-12.jpg media/images/blog/2015/07/full/nat-geo-mc5350-13.jpg media/images/blog/2015/07/full/nat-geo-mc5350-14.jpg media/images/blog/2015/07/full/nat-geo-mc5350-15.jpg media/images/blog/2015/07/full/nat-geo-mc5350-16.jpg media/images/blog/2015/07/full/nat-geo-mc5350-17.jpg media/images/blog/2015/07/full/nat-geo-mc5350-18.jpg media/images/blog/2015/07/full/nat-geo-mc5350-19.jpg media/images/blog/2015/07/full/nat-geo-mc5350-20.jpg media/images/blog/2015/07/full/nat-geo-mc5350-21.jpg media/images/blog/2015/07/full/nat-geo-mc5350-22.jpg media/images/blog/2015/07/full/nat-geo-mc5350-23.jpg media/images/blog/2015/07/full/nat-geo-mc5350-24.jpg media/images/blog/2015/07/full/nat-geo-mc5350-25.jpg media/images/blog/2015/07/full/nat-geo-mc5350-26.jpg media/images/blog/2015/07/full/nat-geo-mc5350-27.jpg media/images/blog/2015/07/full/nat-geo-mc5350-28.jpg media/images/blog/2015/07/full/nat-geo-mc5350-29.jpg media/images/blog/2015/07/full/nat-geo-mc5350-30.jpg media/images/blog/2015/07/full/nat-geo-mc5350-31.jpg media/images/blog/2015/07/full/nat-geo-mc5350-32.jpg media/images/blog/2015/07/full/nat-geo-mc5350-33.jpg media/images/blog/2015/07/full/nat-geo-mc5350-34.jpg media/images/blog/2015/07/full/nat-geo-mc5350-35.jpg media/images/blog/2015/07/full/nat-geo-mc5350-36.jpg media/images/blog/2015/07/full/nat-geo-mc5350-37.jpg media/images/blog/2015/07/full/nat-geo-mc5350-38.jpg media/images/blog/2015/07/full/nat-geo-mc5350-39.jpg media/images/blog/2015/07/full/nat-geo-mc5350-40.jpg media/images/blog/2015/07/full/nat-geo-mc5350-41.jpg media/images/blog/2015/07/full/nat-geo-mc5350-42.jpg media/images/blog/2015/07/full/nat-geo-mc5350-43.jpg media/images/blog/2015/07/full/nat-geo-mc5350-44.jpg media/images/blog/2015/07/full/nat-geo-mc5350-45.jpg media/images/blog/2015/07/full/nat-geo-mc5350-46.jpg media/images/blog/2015/07/full/nat-geo-mc5350-47.jpg media/images/blog/2015/07/full/nat-geo-mc5350-48.jpg media/images/blog/2015/07/full/nat-geo-mc5350-49.jpg media/images/blog/2015/07/full/nat-geo-mc5350-50.jpg media/images/blog/2015/07/full/nat-geo-mc5350-51.jpg media/images/blog/2015/07/full/nat-geo-mc5350-52.jpg media/images/blog/2015/07/full/nat-geo-mc5350-53.jpg media/images/blog/2015/07/full/nat-geo-mc5350-54.jpg media/images/blog/2015/07/full/nat-geo-mc5350-55.jpg media/images/blog/2015/07/full/nat-geo-mc5350-56.jpg media/images/blog/2015/07/full/nat-geo-mc5350-57.jpg media/images/blog/2015/07/full/nat-geo-mc5350-58.jpg media/images/blog/2015/07/full/nat-geo-mc5350-59.jpg media/images/blog/2015/07/full/nat-geo-mc5350-60.jpg media/images/blog/2015/07/full/nat-geo-mc5350-61.jpg media/images/blog/2015/07/full/nat-geo-mc5350-62.jpg media/images/blog/2015/07/full/nat-geo-mc5350-63.jpg media/images/blog/2015/07/full/nat-geo-mc5350-64.jpg media/images/blog/2015/07/full/nat-geo-mc5350-65.jpg media/images/blog/2015/07/full/nat-geo-mc5350-66.jpg media/images/blog/2015/07/full/nat-geo-mc5350-67.jpg media/images/blog/2015/07/full/nat-geo-mc5350-68.jpg media/images/blog/2015/07/full/nat-geo-mc5350-69.jpg media/images/blog/2015/07/full/nat-geo-mc5350-70.jpg media/images/blog/2015/07/full/nat-geo-mc5350-71.jpg media/images/blog/2015/07/full/nat-geo-mc5350-72.jpg media/images/blog/2015/07/full/nat-geo-mc5350-73.jpg media/images/blog/2015/07/full/nat-geo-mc5350-74.jpg media/images/blog/2015/07/full/nat-geo-mc5350-75.jpg media/images/blog/2015/07/full/nat-geo-mc5350-76.jpg media/images/blog/2015/07/full/nat-geo-mc5350-77.jpg media/images/blog/2015/07/full/nat-geo-mc5350-78.jpg media/images/blog/2015/07/full/nat-geo-mc5350-79.jpg media/images/blog/2015/07/full/nat-geo-mc5350-80.jpg media/images/blog/2015/07/nat-geo-a2540-01.jpg media/images/blog/2015/07/nat-geo-a2540-02.jpg media/images/blog/2015/07/nat-geo-a2540-03.jpg media/images/blog/2015/07/nat-geo-a2540-04.jpg media/images/blog/2015/07/nat-geo-a2540-05.jpg media/images/blog/2015/07/nat-geo-a2540-06.jpg media/images/blog/2015/07/nat-geo-a2540-07.jpg media/images/blog/2015/07/nat-geo-a2540-08.jpg media/images/blog/2015/07/nat-geo-a2540-09.jpg media/images/blog/2015/07/nat-geo-a2540-10.jpg media/images/blog/2015/07/nat-geo-a2540-11.jpg media/images/blog/2015/07/nat-geo-a2540-12.jpg media/images/blog/2015/07/nat-geo-a2540-13.jpg media/images/blog/2015/07/nat-geo-a2540-14.jpg media/images/blog/2015/07/nat-geo-a2540-15.jpg media/images/blog/2015/07/nat-geo-a2540-16.jpg media/images/blog/2015/07/nat-geo-a2540-17.jpg media/images/blog/2015/07/nat-geo-a2540-18.jpg media/images/blog/2015/07/nat-geo-a2540-19.jpg media/images/blog/2015/07/nat-geo-a2540-20.jpg media/images/blog/2015/07/nat-geo-a2540-21.jpg media/images/blog/2015/07/nat-geo-a2540-22.jpg media/images/blog/2015/07/nat-geo-a2540-23.jpg media/images/blog/2015/07/nat-geo-a2540-24.jpg media/images/blog/2015/07/nat-geo-a2540-25.jpg media/images/blog/2015/07/nat-geo-a2540-26.jpg media/images/blog/2015/07/nat-geo-a2540-27.jpg media/images/blog/2015/07/nat-geo-a2540-28.jpg media/images/blog/2015/07/nat-geo-a2540-29.jpg media/images/blog/2015/07/nat-geo-a2540-30.jpg media/images/blog/2015/07/nat-geo-a2540-31.jpg media/images/blog/2015/07/nat-geo-a2540-32.jpg media/images/blog/2015/07/nat-geo-a2540-33.jpg media/images/blog/2015/07/nat-geo-a2540-34.jpg media/images/blog/2015/07/nat-geo-a2540-35.jpg media/images/blog/2015/07/nat-geo-a2540-36.jpg media/images/blog/2015/07/nat-geo-a2540-37.jpg media/images/blog/2015/07/nat-geo-a2540-38.jpg media/images/blog/2015/07/nat-geo-a2540-39.jpg media/images/blog/2015/07/nat-geo-a2540-40.jpg media/images/blog/2015/07/nat-geo-a2540-41.jpg media/images/blog/2015/07/nat-geo-a2540-42.jpg media/images/blog/2015/07/nat-geo-a2540-43.jpg media/images/blog/2015/07/nat-geo-a2540-44.jpg media/images/blog/2015/07/nat-geo-a2540-45.jpg media/images/blog/2015/07/nat-geo-a2540-46.jpg media/images/blog/2015/07/nat-geo-a2540-47.jpg media/images/blog/2015/07/nat-geo-a2540-48.jpg media/images/blog/2015/07/nat-geo-a2540-49.jpg media/images/blog/2015/07/nat-geo-mc5350-01.jpg media/images/blog/2015/07/nat-geo-mc5350-02.jpg media/images/blog/2015/07/nat-geo-mc5350-03.jpg media/images/blog/2015/07/nat-geo-mc5350-04.jpg media/images/blog/2015/07/nat-geo-mc5350-05.jpg media/images/blog/2015/07/nat-geo-mc5350-06.jpg media/images/blog/2015/07/nat-geo-mc5350-07.jpg media/images/blog/2015/07/nat-geo-mc5350-08.jpg media/images/blog/2015/07/nat-geo-mc5350-09.jpg media/images/blog/2015/07/nat-geo-mc5350-10.jpg media/images/blog/2015/07/nat-geo-mc5350-11.jpg media/images/blog/2015/07/nat-geo-mc5350-12.jpg media/images/blog/2015/07/nat-geo-mc5350-13.jpg media/images/blog/2015/07/nat-geo-mc5350-14.jpg media/images/blog/2015/07/nat-geo-mc5350-15.jpg media/images/blog/2015/07/nat-geo-mc5350-16.jpg media/images/blog/2015/07/nat-geo-mc5350-17.jpg media/images/blog/2015/07/nat-geo-mc5350-18.jpg media/images/blog/2015/07/nat-geo-mc5350-19.jpg media/images/blog/2015/07/nat-geo-mc5350-20.jpg media/images/blog/2015/07/nat-geo-mc5350-21.jpg media/images/blog/2015/07/nat-geo-mc5350-22.jpg media/images/blog/2015/07/nat-geo-mc5350-23.jpg media/images/blog/2015/07/nat-geo-mc5350-24.jpg media/images/blog/2015/07/nat-geo-mc5350-25.jpg media/images/blog/2015/07/nat-geo-mc5350-26.jpg media/images/blog/2015/07/nat-geo-mc5350-27.jpg media/images/blog/2015/07/nat-geo-mc5350-28.jpg media/images/blog/2015/07/nat-geo-mc5350-29.jpg media/images/blog/2015/07/nat-geo-mc5350-30.jpg media/images/blog/2015/07/nat-geo-mc5350-31.jpg media/images/blog/2015/07/nat-geo-mc5350-32.jpg media/images/blog/2015/07/nat-geo-mc5350-33.jpg media/images/blog/2015/07/nat-geo-mc5350-34.jpg media/images/blog/2015/07/nat-geo-mc5350-35.jpg media/images/blog/2015/07/nat-geo-mc5350-36.jpg media/images/blog/2015/07/nat-geo-mc5350-37.jpg media/images/blog/2015/07/nat-geo-mc5350-38.jpg media/images/blog/2015/07/nat-geo-mc5350-39.jpg media/images/blog/2015/07/nat-geo-mc5350-40.jpg media/images/blog/2015/07/nat-geo-mc5350-41.jpg media/images/blog/2015/07/nat-geo-mc5350-42.jpg media/images/blog/2015/07/nat-geo-mc5350-43.jpg media/images/blog/2015/07/nat-geo-mc5350-44.jpg media/images/blog/2015/07/nat-geo-mc5350-45.jpg media/images/blog/2015/07/nat-geo-mc5350-46.jpg media/images/blog/2015/07/nat-geo-mc5350-47.jpg media/images/blog/2015/07/nat-geo-mc5350-48.jpg media/images/blog/2015/07/nat-geo-mc5350-49.jpg media/images/blog/2015/07/nat-geo-mc5350-50.jpg media/images/blog/2015/07/nat-geo-mc5350-51.jpg media/images/blog/2015/07/nat-geo-mc5350-52.jpg media/images/blog/2015/07/nat-geo-mc5350-53.jpg media/images/blog/2015/07/nat-geo-mc5350-54.jpg media/images/blog/2015/07/nat-geo-mc5350-55.jpg media/images/blog/2015/07/nat-geo-mc5350-56.jpg media/images/blog/2015/07/nat-geo-mc5350-57.jpg media/images/blog/2015/07/nat-geo-mc5350-58.jpg media/images/blog/2015/07/nat-geo-mc5350-59.jpg media/images/blog/2015/07/nat-geo-mc5350-60.jpg media/images/blog/2015/07/nat-geo-mc5350-61.jpg media/images/blog/2015/07/nat-geo-mc5350-62.jpg media/images/blog/2015/07/nat-geo-mc5350-63.jpg media/images/blog/2015/07/nat-geo-mc5350-64.jpg media/images/blog/2015/07/nat-geo-mc5350-65.jpg media/images/blog/2015/07/nat-geo-mc5350-66.jpg media/images/blog/2015/07/nat-geo-mc5350-67.jpg media/images/blog/2015/07/nat-geo-mc5350-68.jpg media/images/blog/2015/07/nat-geo-mc5350-69.jpg media/images/blog/2015/07/nat-geo-mc5350-70.jpg media/images/blog/2015/07/nat-geo-mc5350-71.jpg media/images/blog/2015/07/nat-geo-mc5350-72.jpg media/images/blog/2015/07/nat-geo-mc5350-73.jpg media/images/blog/2015/07/nat-geo-mc5350-74.jpg media/images/blog/2015/07/nat-geo-mc5350-75.jpg media/images/blog/2015/07/nat-geo-mc5350-76.jpg media/images/blog/2015/07/nat-geo-mc5350-77.jpg media/images/blog/2015/07/nat-geo-mc5350-78.jpg media/images/blog/2015/07/nat-geo-mc5350-79.jpg media/images/blog/2015/07/nat-geo-mc5350-80.jpg media/images/blog/2015/11/btd-s2-ggsteve-large.png media/images/blog/2015/11/btd-s2-ggsteve.png media/images/blog/2015/11/btd-s3-bob-large.png media/images/blog/2015/11/btd-s3-bob.png media/images/blog/2015/11/btd-s3-douche-large.png media/images/blog/2015/11/btd-s3-douche.png media/images/blog/2015/11/btd-s3-ggsteve-large.png media/images/blog/2015/11/btd-s3-ggsteve.png media/images/blog/2015/11/btd-s3-innuendo-large.png media/images/blog/2015/11/btd-s3-innuendo.png media/images/blog/2015/11/btd-s3-mouthnoises-large.png media/images/blog/2015/11/btd-s3-mouthnoises.png media/images/blog/2015/11/btd-s3-percentile-bob-large.png media/images/blog/2015/11/btd-s3-percentile-bob.png media/images/blog/2015/11/btd-s3-percentile-cringe-large.png media/images/blog/2015/11/btd-s3-percentile-cringe.png media/images/blog/2015/11/btd-s3-percentile-drugs-large.png media/images/blog/2015/11/btd-s3-percentile-drugs.png media/images/blog/2015/11/btd-s3-percentile-steve-large.png media/images/blog/2015/11/btd-s3-percentile-steve.png media/images/blog/2015/11/btd-s3-percentile-the-large.png media/images/blog/2015/11/btd-s3-percentile-the.png media/images/blog/2015/11/btd-s3-ruined-large.png media/images/blog/2015/11/btd-s3-ruined.png media/images/blog/2015/11/btd-s3-steve-large.png media/images/blog/2015/11/btd-s3-steve.png media/images/blog/2015/11/btd-s3-subjects-large.png media/images/blog/2015/11/btd-s3-subjects.png media/images/blog/2015/11/btd-s3-the-large.png media/images/blog/2015/11/btd-s3-the.png media/images/blog/2015/11/btd-ssp-bob-large.png media/images/blog/2015/11/btd-ssp-bob.png media/images/blog/2015/11/btd-ssp-gg-large.png media/images/blog/2015/11/btd-ssp-gg.png media/images/blog/2015/11/btd-ssp-rip__devil-large.png media/images/blog/2015/11/btd-ssp-rip__devil.png media/images/blog/2015/11/btd-ssp-ruined-large.png media/images/blog/2015/11/btd-ssp-ruined.png media/images/blog/2015/11/btd-ssp-steve-large.png media/images/blog/2015/11/btd-ssp-steve.png media/images/blog/2015/11/btd-ssp-the-large.png media/images/blog/2015/11/btd-ssp-the.png media/images/blog/2015/11/btd-volume-comparison-large.png media/images/blog/2015/11/btd-volume-comparison.png media/images/blog/2015/11/hlw-heknew-large.png media/images/blog/2015/11/hlw-heknew.png media/images/blog/2015/11/hlw-higg-large.png media/images/blog/2015/11/hlw-higg.png media/images/blog/2015/11/hlw-love-large.png media/images/blog/2015/11/hlw-love.png media/images/blog/2015/11/hlw-ripdevil-large.png media/images/blog/2015/11/hlw-ripdevil.png media/images/blog/2015/11/hlw-total-large.png media/images/blog/2015/11/hlw-total.png media/images/blog/2015/12/silt-initial.gif media/images/blog/2015/12/silt-later.gif media/images/blog/2016/08/aspect-flavor.png media/images/blog/2016/08/aspect-visible.png media/images/blog/2016/08/bad-tiling-ds.png media/images/blog/2016/08/good-tiling-ds.png media/images/blog/2016/08/silt-names.png media/images/blog/2016/08/silt1-inspect.png media/images/blog/2016/08/silt1-terrain.png media/images/blog/2016/08/silt2-inspect.png media/images/blog/2016/08/silt2-terrain.png media/images/blog/2016/09/loop-macro.jpg media/images/hr.png media/images/hrb.png media/images/projects/fuego/Fuego-4852.jpg media/images/projects/fuego/Fuego-4887.jpg media/images/projects/fuego/Fuego-4919.jpg media/images/projects/fuego/Fuego-4941.jpg media/images/projects/fuego/Fuego-4985.jpg media/images/projects/fuego/Fuego-5133.jpg media/images/projects/hg-prompt/prompt.png media/images/projects/lindyjam-com/lindyjamcom-splash.png media/images/projects/t/t-screenshot.png media/images/projects/women-in-water/alex-tele.jpg media/images/projects/women-in-water/alex-wide.jpg media/images/projects/women-in-water/anna-tele.jpg media/images/projects/women-in-water/anna-wide.jpg media/images/projects/women-in-water/erin-tele.jpg media/images/projects/women-in-water/erin-wide.jpg media/images/projects/women-in-water/leah-tele.jpg media/images/projects/women-in-water/leah-wide.jpg media/images/projects/women-in-water/lizza-tele.jpg media/images/projects/women-in-water/lizza-wide.jpg media/images/rhythm.png media/images/self.jpg media/js/TrackballControls.js media/js/jquery.js media/js/jquery.timeago.js media/js/print.js media/js/sjl.js media/js/terrain1.js media/js/terrain2.js media/js/terrain3.js media/js/three.min.js media/js/utils/modi.js media/js/wisp/terrain1.js media/js/wisp/terrain1.wisp media/js/wisp/terrain2.js media/js/wisp/terrain2.wisp media/js/wisp/terrain3.js media/js/wisp/terrain3.wisp media/midpoint-displacement.monopic nginx.conf requirements.txt settings.py static/media/css/aal.css static/media/css/print.css static/media/css/print.less static/media/css/pygments-clean.css static/media/css/pygments-monokai-light.css static/media/css/sjl.css static/media/css/sjl.less static/media/diamond-square.monopic static/media/images/blog/2009/02/dj-playlist-sorting.png static/media/images/blog/2009/02/dj-playlist-unrated.png static/media/images/blog/2009/03/prompt-with-branch.png static/media/images/blog/2009/03/prompt-with-dirty.png static/media/images/blog/2009/03/prompt-without-branch.png static/media/images/blog/2009/03/terminal-colors.png static/media/images/blog/2009/08/branch-anon.png static/media/images/blog/2009/08/branch-base.png static/media/images/blog/2009/08/branch-bookmark.png static/media/images/blog/2009/08/branch-clone.png static/media/images/blog/2009/08/branch-named.png static/media/images/blog/2010/01/mercurial-vs-git.jpg static/media/images/blog/2010/02/hg-branching-1-after-merge.png static/media/images/blog/2010/02/hg-branching-1-needs-merge.png static/media/images/blog/2010/02/hg-branching-1-other.png static/media/images/blog/2010/02/hg-branching-1-start.png static/media/images/blog/2010/02/zsh-prompt-comments.png static/media/images/blog/2010/02/zsh-prompt.png static/media/images/blog/2010/05/default-stable-example.png static/media/images/blog/2010/06/translation-branches.png static/media/images/blog/2010/08/git-basics.png static/media/images/blog/2010/08/mercurial-basics.png static/media/images/blog/2010/08/mq-multiple.png static/media/images/blog/2010/08/mq-one.png static/media/images/blog/2010/08/mq-two.png static/media/images/blog/2010/08/mq-versioned.png static/media/images/blog/2010/09/rainbow.png static/media/images/blog/2010/09/vim.png static/media/images/blog/2011/05/rules-1-doxie.png static/media/images/blog/2011/05/rules-2-jotnot.png static/media/images/blog/2011/05/rules-3-ocr.png static/media/images/blog/2011/05/rules-4-clean.png static/media/images/blog/2012/07/caves-01-01.png static/media/images/blog/2012/07/caves-02-01.png static/media/images/blog/2012/07/caves-02-02.png static/media/images/blog/2012/07/caves-02-03.png static/media/images/blog/2012/07/caves-03-1-01.png static/media/images/blog/2012/07/caves-03-1-02.png static/media/images/blog/2012/07/caves-03-1-03.png static/media/images/blog/2012/07/caves-03-2-01.png static/media/images/blog/2012/07/caves-03-2-02.png static/media/images/blog/2012/07/caves-03-2-03.png static/media/images/blog/2012/07/caves-03-3-01.png static/media/images/blog/2012/07/caves-03-3-02.png static/media/images/blog/2012/07/caves-04-01.png static/media/images/blog/2012/07/caves-04-02.png static/media/images/blog/2012/07/caves-04-03.png static/media/images/blog/2012/07/caves-05-01.png static/media/images/blog/2012/07/caves-05-02.png static/media/images/blog/2012/07/caves-05-03.png static/media/images/blog/2012/07/caves-06-01.png static/media/images/blog/2012/07/caves-interlude-1-01.png static/media/images/blog/2012/07/caves-interlude-1-02.png static/media/images/blog/2012/10/caves-07-1-1.png static/media/images/blog/2012/10/caves-07-1-2.png static/media/images/blog/2012/10/kb-apple.jpg static/media/images/blog/2012/10/kb-caps.png static/media/images/blog/2012/10/kb-das.jpg static/media/images/blog/2012/10/kb-hex.png static/media/images/blog/2012/10/kb-hhkb.jpg static/media/images/blog/2012/10/kb-irc.png static/media/images/blog/2012/10/kb-key-overlaid.png static/media/images/blog/2012/10/kb-pck.png static/media/images/blog/2012/10/kb-realforce.jpg static/media/images/blog/2012/10/kb-size.jpg static/media/images/blog/2012/10/keychain-1.png static/media/images/blog/2012/10/keychain-2.png static/media/images/blog/2012/10/keychain-3.png static/media/images/blog/2012/10/mutt-attachments.png static/media/images/blog/2012/10/mutt-contacts-1.png static/media/images/blog/2012/10/mutt-index.png static/media/images/blog/2012/10/mutt-pager.png static/media/images/blog/2012/10/mutt-ready-to-send.png static/media/images/blog/2012/10/mutt-send-1.png static/media/images/blog/2012/10/mutt-urls.png static/media/images/blog/2012/10/what-the-mutt.png static/media/images/blog/2015/07/full/nat-geo-a2540-01.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-02.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-03.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-04.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-05.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-06.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-07.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-08.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-09.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-10.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-11.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-12.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-13.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-14.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-15.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-16.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-17.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-18.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-19.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-20.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-21.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-22.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-23.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-24.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-25.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-26.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-27.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-28.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-29.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-30.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-31.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-32.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-33.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-34.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-35.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-36.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-37.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-38.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-39.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-40.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-41.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-42.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-43.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-44.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-45.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-46.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-47.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-48.jpg static/media/images/blog/2015/07/full/nat-geo-a2540-49.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-01.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-02.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-03.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-04.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-05.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-06.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-07.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-08.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-09.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-10.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-11.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-12.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-13.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-14.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-15.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-16.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-17.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-18.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-19.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-20.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-21.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-22.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-23.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-24.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-25.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-26.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-27.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-28.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-29.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-30.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-31.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-32.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-33.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-34.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-35.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-36.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-37.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-38.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-39.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-40.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-41.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-42.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-43.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-44.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-45.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-46.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-47.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-48.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-49.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-50.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-51.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-52.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-53.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-54.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-55.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-56.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-57.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-58.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-59.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-60.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-61.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-62.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-63.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-64.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-65.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-66.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-67.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-68.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-69.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-70.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-71.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-72.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-73.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-74.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-75.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-76.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-77.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-78.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-79.jpg static/media/images/blog/2015/07/full/nat-geo-mc5350-80.jpg static/media/images/blog/2015/07/nat-geo-a2540-01.jpg static/media/images/blog/2015/07/nat-geo-a2540-02.jpg static/media/images/blog/2015/07/nat-geo-a2540-03.jpg static/media/images/blog/2015/07/nat-geo-a2540-04.jpg static/media/images/blog/2015/07/nat-geo-a2540-05.jpg static/media/images/blog/2015/07/nat-geo-a2540-06.jpg static/media/images/blog/2015/07/nat-geo-a2540-07.jpg static/media/images/blog/2015/07/nat-geo-a2540-08.jpg static/media/images/blog/2015/07/nat-geo-a2540-09.jpg static/media/images/blog/2015/07/nat-geo-a2540-10.jpg static/media/images/blog/2015/07/nat-geo-a2540-11.jpg static/media/images/blog/2015/07/nat-geo-a2540-12.jpg static/media/images/blog/2015/07/nat-geo-a2540-13.jpg static/media/images/blog/2015/07/nat-geo-a2540-14.jpg static/media/images/blog/2015/07/nat-geo-a2540-15.jpg static/media/images/blog/2015/07/nat-geo-a2540-16.jpg static/media/images/blog/2015/07/nat-geo-a2540-17.jpg static/media/images/blog/2015/07/nat-geo-a2540-18.jpg static/media/images/blog/2015/07/nat-geo-a2540-19.jpg static/media/images/blog/2015/07/nat-geo-a2540-20.jpg static/media/images/blog/2015/07/nat-geo-a2540-21.jpg static/media/images/blog/2015/07/nat-geo-a2540-22.jpg static/media/images/blog/2015/07/nat-geo-a2540-23.jpg static/media/images/blog/2015/07/nat-geo-a2540-24.jpg static/media/images/blog/2015/07/nat-geo-a2540-25.jpg static/media/images/blog/2015/07/nat-geo-a2540-26.jpg static/media/images/blog/2015/07/nat-geo-a2540-27.jpg static/media/images/blog/2015/07/nat-geo-a2540-28.jpg static/media/images/blog/2015/07/nat-geo-a2540-29.jpg static/media/images/blog/2015/07/nat-geo-a2540-30.jpg static/media/images/blog/2015/07/nat-geo-a2540-31.jpg static/media/images/blog/2015/07/nat-geo-a2540-32.jpg static/media/images/blog/2015/07/nat-geo-a2540-33.jpg static/media/images/blog/2015/07/nat-geo-a2540-34.jpg static/media/images/blog/2015/07/nat-geo-a2540-35.jpg static/media/images/blog/2015/07/nat-geo-a2540-36.jpg static/media/images/blog/2015/07/nat-geo-a2540-37.jpg static/media/images/blog/2015/07/nat-geo-a2540-38.jpg static/media/images/blog/2015/07/nat-geo-a2540-39.jpg static/media/images/blog/2015/07/nat-geo-a2540-40.jpg static/media/images/blog/2015/07/nat-geo-a2540-41.jpg static/media/images/blog/2015/07/nat-geo-a2540-42.jpg static/media/images/blog/2015/07/nat-geo-a2540-43.jpg static/media/images/blog/2015/07/nat-geo-a2540-44.jpg static/media/images/blog/2015/07/nat-geo-a2540-45.jpg static/media/images/blog/2015/07/nat-geo-a2540-46.jpg static/media/images/blog/2015/07/nat-geo-a2540-47.jpg static/media/images/blog/2015/07/nat-geo-a2540-48.jpg static/media/images/blog/2015/07/nat-geo-a2540-49.jpg static/media/images/blog/2015/07/nat-geo-mc5350-01.jpg static/media/images/blog/2015/07/nat-geo-mc5350-02.jpg static/media/images/blog/2015/07/nat-geo-mc5350-03.jpg static/media/images/blog/2015/07/nat-geo-mc5350-04.jpg static/media/images/blog/2015/07/nat-geo-mc5350-05.jpg static/media/images/blog/2015/07/nat-geo-mc5350-06.jpg static/media/images/blog/2015/07/nat-geo-mc5350-07.jpg static/media/images/blog/2015/07/nat-geo-mc5350-08.jpg static/media/images/blog/2015/07/nat-geo-mc5350-09.jpg static/media/images/blog/2015/07/nat-geo-mc5350-10.jpg static/media/images/blog/2015/07/nat-geo-mc5350-11.jpg static/media/images/blog/2015/07/nat-geo-mc5350-12.jpg static/media/images/blog/2015/07/nat-geo-mc5350-13.jpg static/media/images/blog/2015/07/nat-geo-mc5350-14.jpg static/media/images/blog/2015/07/nat-geo-mc5350-15.jpg static/media/images/blog/2015/07/nat-geo-mc5350-16.jpg static/media/images/blog/2015/07/nat-geo-mc5350-17.jpg static/media/images/blog/2015/07/nat-geo-mc5350-18.jpg static/media/images/blog/2015/07/nat-geo-mc5350-19.jpg static/media/images/blog/2015/07/nat-geo-mc5350-20.jpg static/media/images/blog/2015/07/nat-geo-mc5350-21.jpg static/media/images/blog/2015/07/nat-geo-mc5350-22.jpg static/media/images/blog/2015/07/nat-geo-mc5350-23.jpg static/media/images/blog/2015/07/nat-geo-mc5350-24.jpg static/media/images/blog/2015/07/nat-geo-mc5350-25.jpg static/media/images/blog/2015/07/nat-geo-mc5350-26.jpg static/media/images/blog/2015/07/nat-geo-mc5350-27.jpg static/media/images/blog/2015/07/nat-geo-mc5350-28.jpg static/media/images/blog/2015/07/nat-geo-mc5350-29.jpg static/media/images/blog/2015/07/nat-geo-mc5350-30.jpg static/media/images/blog/2015/07/nat-geo-mc5350-31.jpg static/media/images/blog/2015/07/nat-geo-mc5350-32.jpg static/media/images/blog/2015/07/nat-geo-mc5350-33.jpg static/media/images/blog/2015/07/nat-geo-mc5350-34.jpg static/media/images/blog/2015/07/nat-geo-mc5350-35.jpg static/media/images/blog/2015/07/nat-geo-mc5350-36.jpg static/media/images/blog/2015/07/nat-geo-mc5350-37.jpg static/media/images/blog/2015/07/nat-geo-mc5350-38.jpg static/media/images/blog/2015/07/nat-geo-mc5350-39.jpg static/media/images/blog/2015/07/nat-geo-mc5350-40.jpg static/media/images/blog/2015/07/nat-geo-mc5350-41.jpg static/media/images/blog/2015/07/nat-geo-mc5350-42.jpg static/media/images/blog/2015/07/nat-geo-mc5350-43.jpg static/media/images/blog/2015/07/nat-geo-mc5350-44.jpg static/media/images/blog/2015/07/nat-geo-mc5350-45.jpg static/media/images/blog/2015/07/nat-geo-mc5350-46.jpg static/media/images/blog/2015/07/nat-geo-mc5350-47.jpg static/media/images/blog/2015/07/nat-geo-mc5350-48.jpg static/media/images/blog/2015/07/nat-geo-mc5350-49.jpg static/media/images/blog/2015/07/nat-geo-mc5350-50.jpg static/media/images/blog/2015/07/nat-geo-mc5350-51.jpg static/media/images/blog/2015/07/nat-geo-mc5350-52.jpg static/media/images/blog/2015/07/nat-geo-mc5350-53.jpg static/media/images/blog/2015/07/nat-geo-mc5350-54.jpg static/media/images/blog/2015/07/nat-geo-mc5350-55.jpg static/media/images/blog/2015/07/nat-geo-mc5350-56.jpg static/media/images/blog/2015/07/nat-geo-mc5350-57.jpg static/media/images/blog/2015/07/nat-geo-mc5350-58.jpg static/media/images/blog/2015/07/nat-geo-mc5350-59.jpg static/media/images/blog/2015/07/nat-geo-mc5350-60.jpg static/media/images/blog/2015/07/nat-geo-mc5350-61.jpg static/media/images/blog/2015/07/nat-geo-mc5350-62.jpg static/media/images/blog/2015/07/nat-geo-mc5350-63.jpg static/media/images/blog/2015/07/nat-geo-mc5350-64.jpg static/media/images/blog/2015/07/nat-geo-mc5350-65.jpg static/media/images/blog/2015/07/nat-geo-mc5350-66.jpg static/media/images/blog/2015/07/nat-geo-mc5350-67.jpg static/media/images/blog/2015/07/nat-geo-mc5350-68.jpg static/media/images/blog/2015/07/nat-geo-mc5350-69.jpg static/media/images/blog/2015/07/nat-geo-mc5350-70.jpg static/media/images/blog/2015/07/nat-geo-mc5350-71.jpg static/media/images/blog/2015/07/nat-geo-mc5350-72.jpg static/media/images/blog/2015/07/nat-geo-mc5350-73.jpg static/media/images/blog/2015/07/nat-geo-mc5350-74.jpg static/media/images/blog/2015/07/nat-geo-mc5350-75.jpg static/media/images/blog/2015/07/nat-geo-mc5350-76.jpg static/media/images/blog/2015/07/nat-geo-mc5350-77.jpg static/media/images/blog/2015/07/nat-geo-mc5350-78.jpg static/media/images/blog/2015/07/nat-geo-mc5350-79.jpg static/media/images/blog/2015/07/nat-geo-mc5350-80.jpg static/media/images/blog/2015/11/btd-s2-ggsteve-large.png static/media/images/blog/2015/11/btd-s2-ggsteve.png static/media/images/blog/2015/11/btd-s3-bob-large.png static/media/images/blog/2015/11/btd-s3-bob.png static/media/images/blog/2015/11/btd-s3-douche-large.png static/media/images/blog/2015/11/btd-s3-douche.png static/media/images/blog/2015/11/btd-s3-ggsteve-large.png static/media/images/blog/2015/11/btd-s3-ggsteve.png static/media/images/blog/2015/11/btd-s3-innuendo-large.png static/media/images/blog/2015/11/btd-s3-innuendo.png static/media/images/blog/2015/11/btd-s3-mouthnoises-large.png static/media/images/blog/2015/11/btd-s3-mouthnoises.png static/media/images/blog/2015/11/btd-s3-percentile-bob-large.png static/media/images/blog/2015/11/btd-s3-percentile-bob.png static/media/images/blog/2015/11/btd-s3-percentile-cringe-large.png static/media/images/blog/2015/11/btd-s3-percentile-cringe.png static/media/images/blog/2015/11/btd-s3-percentile-drugs-large.png static/media/images/blog/2015/11/btd-s3-percentile-drugs.png static/media/images/blog/2015/11/btd-s3-percentile-steve-large.png static/media/images/blog/2015/11/btd-s3-percentile-steve.png static/media/images/blog/2015/11/btd-s3-percentile-the-large.png static/media/images/blog/2015/11/btd-s3-percentile-the.png static/media/images/blog/2015/11/btd-s3-ruined-large.png static/media/images/blog/2015/11/btd-s3-ruined.png static/media/images/blog/2015/11/btd-s3-steve-large.png static/media/images/blog/2015/11/btd-s3-steve.png static/media/images/blog/2015/11/btd-s3-subjects-large.png static/media/images/blog/2015/11/btd-s3-subjects.png static/media/images/blog/2015/11/btd-s3-the-large.png static/media/images/blog/2015/11/btd-s3-the.png static/media/images/blog/2015/11/btd-ssp-bob-large.png static/media/images/blog/2015/11/btd-ssp-bob.png static/media/images/blog/2015/11/btd-ssp-gg-large.png static/media/images/blog/2015/11/btd-ssp-gg.png static/media/images/blog/2015/11/btd-ssp-rip__devil-large.png static/media/images/blog/2015/11/btd-ssp-rip__devil.png static/media/images/blog/2015/11/btd-ssp-ruined-large.png static/media/images/blog/2015/11/btd-ssp-ruined.png static/media/images/blog/2015/11/btd-ssp-steve-large.png static/media/images/blog/2015/11/btd-ssp-steve.png static/media/images/blog/2015/11/btd-ssp-the-large.png static/media/images/blog/2015/11/btd-ssp-the.png static/media/images/blog/2015/11/btd-volume-comparison-large.png static/media/images/blog/2015/11/btd-volume-comparison.png static/media/images/blog/2015/11/hlw-heknew-large.png static/media/images/blog/2015/11/hlw-heknew.png static/media/images/blog/2015/11/hlw-higg-large.png static/media/images/blog/2015/11/hlw-higg.png static/media/images/blog/2015/11/hlw-love-large.png static/media/images/blog/2015/11/hlw-love.png static/media/images/blog/2015/11/hlw-ripdevil-large.png static/media/images/blog/2015/11/hlw-ripdevil.png static/media/images/blog/2015/11/hlw-total-large.png static/media/images/blog/2015/11/hlw-total.png static/media/images/blog/2015/12/silt-initial.gif static/media/images/blog/2015/12/silt-later.gif static/media/images/blog/2016/08/aspect-flavor.png static/media/images/blog/2016/08/aspect-visible.png static/media/images/blog/2016/08/bad-tiling-ds.png static/media/images/blog/2016/08/good-tiling-ds.png static/media/images/blog/2016/08/silt-names.png static/media/images/blog/2016/08/silt1-inspect.png static/media/images/blog/2016/08/silt1-terrain.png static/media/images/blog/2016/08/silt2-inspect.png static/media/images/blog/2016/08/silt2-terrain.png static/media/images/blog/2016/09/loop-macro.jpg static/media/images/hr.png static/media/images/hrb.png static/media/images/projects/fuego/Fuego-4852.jpg static/media/images/projects/fuego/Fuego-4887.jpg static/media/images/projects/fuego/Fuego-4919.jpg static/media/images/projects/fuego/Fuego-4941.jpg static/media/images/projects/fuego/Fuego-4985.jpg static/media/images/projects/fuego/Fuego-5133.jpg static/media/images/projects/hg-prompt/prompt.png static/media/images/projects/lindyjam-com/lindyjamcom-splash.png static/media/images/projects/t/t-screenshot.png static/media/images/projects/women-in-water/alex-tele.jpg static/media/images/projects/women-in-water/alex-wide.jpg static/media/images/projects/women-in-water/anna-tele.jpg static/media/images/projects/women-in-water/anna-wide.jpg static/media/images/projects/women-in-water/erin-tele.jpg static/media/images/projects/women-in-water/erin-wide.jpg static/media/images/projects/women-in-water/leah-tele.jpg static/media/images/projects/women-in-water/leah-wide.jpg static/media/images/projects/women-in-water/lizza-tele.jpg static/media/images/projects/women-in-water/lizza-wide.jpg static/media/images/rhythm.png static/media/images/self.jpg static/media/js/TrackballControls.js static/media/js/jquery.js static/media/js/jquery.timeago.js static/media/js/print.js static/media/js/sjl.js static/media/js/terrain1.js static/media/js/terrain2.js static/media/js/terrain3.js static/media/js/three.min.js static/media/js/utils/modi.js static/media/js/wisp/terrain1.js static/media/js/wisp/terrain1.wisp static/media/js/wisp/terrain2.js static/media/js/wisp/terrain2.wisp static/media/js/wisp/terrain3.js static/media/js/wisp/terrain3.wisp static/media/midpoint-displacement.monopic themes/stevelosh/LICENSE.md themes/stevelosh/archetypes/blog.md themes/stevelosh/archetypes/default.md themes/stevelosh/layouts/404.html themes/stevelosh/layouts/_default/list.html themes/stevelosh/layouts/_default/single.html themes/stevelosh/layouts/blog/single.html themes/stevelosh/layouts/index.html themes/stevelosh/layouts/partials/footer.html themes/stevelosh/layouts/partials/header.html themes/stevelosh/theme.toml yuicompressor-2.4.2.jar

Changes

--- a/DESIGN.mdown	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-Some notes on the design, mostly for myself.
-
-Images
-======
-
-Full images for posts should be 580 pixels wide (or less) and a multiple of 25
-pixels tall.
-
-Headers
-=======
-
-Blog and project content block should use h2 and lower. h1 elements are
-reserved for the layout.
--- a/LICENSE	Tue Sep 20 15:23:05 2016 +0000
+++ b/LICENSE	Fri Oct 07 12:48:36 2016 +0000
@@ -1,4 +1,4 @@
-Copyright (c) 2008-2010 Steve Losh
+Copyright (c) 2016 Steve Losh
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -16,4 +16,4 @@
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
\ No newline at end of file
+THE SOFTWARE.
--- a/Makefile	Tue Sep 20 15:23:05 2016 +0000
+++ b/Makefile	Fri Oct 07 12:48:36 2016 +0000
@@ -1,31 +1,19 @@
-.PHONY: clean generate regen serve deploy
+.PHONY: clean generate serve deploy
+
+less := $(shell ffind --literal '.less')
+style := $(subst .less,.css,$(less))
 
-wisps := $(shell ffind --literal '.wisp')
-javascripts := $(subst .wisp,.js,$(wisps))
-bundles := $(subst /wisp/,/,$(javascripts))
+static/media/css/%.css: static/media/css/%.less
+	lessc $< > $@
 
-generate: $(bundles)
-	hyde -g -s .
+generate:
+	hugo -t stevelosh
 
 clean:
-	rm -rf ./deploy
+	rm -rf public
 
 serve:
-	hyde -w -s . -k
-
-regen: clean generate
-
-deploy: generate
-	rsync -avz ./deploy/ sl:/var/www/stevelosh.com
+	hugo server -t stevelosh
 
-media/js/wisp/%.js: media/js/wisp/%.wisp
-	cat $< | wisp > $@
-
-media/js/terrain1.js: $(javascripts)
-	browserify media/js/wisp/terrain1.js -do $@
-
-media/js/terrain2.js: $(javascripts)
-	browserify media/js/wisp/terrain2.js -do $@
-
-media/js/terrain3.js: $(javascripts)
-	browserify media/js/wisp/terrain3.js -do $@
+deploy: public
+	# rsync -avz ./deploy/ sl:/var/www/stevelosh.com
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.toml	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,13 @@
+baseurl = "http://stevelosh.com/"
+languageCode = "en-us"
+title = "Steve Losh"
+PluralizeListTitles = false
+PygmentsCodeFences = true
+pygmentsuseclasses = true
+
+[Params]
+    DateForm = "January 2, 2006"
+    DateFormFull = "2006-01-02T15:04:05Z"
+
+[author]
+    name = "Steve Losh"
--- a/content/404.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-{% extends "_flatpage.html" %}
-
-{% hyde
-    title: "Not Found"
-    exclude: True
-%}
-
-
-{% block article %}
-
-OH GOD HOW DID THIS GET HERE SOMEONE IS NOT GOOD WITH LINK
-==========================================================
-
-{% endblock %}
--- a/content/about.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-{% extends "skeleton/_base.html" %}
-{% hyde
-    title: "About"
-%}
-
-{% block content %}
-    <img src="/media/images/self.jpg" class="self right" />
-
-    <div id="leaf-title"><h1>{{ page.title|safe|typogrify }}</h1></div>
-    
-    <div id="leaf-content">
-        {% filter typogrify %}
-            {% markdown %}
-I'm **Steve**. I'm currently living in **Reykjavík, Iceland**.  
-I do a lot of different things.
-
-If you want to get in touch with me you can [email
-me](mailto:steve@stevelosh.com) or find me on [BitBucket][], [GitHub][], or
-[Twitter][].
-
-[Twitter]: http://twitter.com/stevelosh/
-[BitBucket]: http://bitbucket.org/sjl/
-[GitHub]: http://github.com/sjl/
-
-
-Programming
------------
-
-I went to [Rochester Institute of Technology](http://rit.edu/) for a degree in
-Computer Science.
-
-I've done a lot of different things in the field so far. Right now the things
-that are captivating me are artificial intelligence and clean, simple,
-*useful* web applications.
-
-I find programming beautiful. That might sound strange, but there are aspects
-of programming and math that I can't describe any other way.
-
-You can take a look at my [projects][] to see some of the major stuff I've
-worked on, or cut to the chase and look at [my BitBucket account][BitBucket].
-
-[projects]: /projects/
-
-Photography
-----------
-
-I like photographing people. Other things as well, but especially people.
-I tend to gravitate toward the "art" aspects of photography more than the
-"journalism" aspects, but I can appreciate both.
-
-I shoot digital and film (35mm and medium format) depending on my time limits
-and mood. I develop film in my bathroom and print it in a rented darkroom.
-When I print digital I use a lab nearby; I don't have the money for a
-professional printer just yet.
-
-Dancing
--------
-
-I teach blues dancing here in Rochester as part of [Lady Luck Blues][].
-I started blues dancing a few years ago and haven't stopped since. My favorite
-aspect of dancing is connection and blues seems to bring that out more than any
-other dance.
-
-I've also been swing dancing for about seven years. My first love is Lindy Hop; I
-go to classes, workshops and exchanges as often as my schedule and budget will
-allow.
-
-Lately I've begun getting my feet wet in tango. Whether it'll ever become as
-important to me as blues or Lindy remains to be seen.
-
-[Lady Luck Blues]: http://ladyluckblues.com/
-
-Music
------
-
-I play electric and upright bass. I've played in a metal band in the past, but
-right now my focus is on jazz and blues.
-
-I DJ at swing and blues dances fairly often. My taste is pretty broad, and
-I'll cater to whatever the floor wants, but I tend to personally enjoy
-slightly down-tempo, small-group music. Let me know if you need a DJ for a
-dance.
-
-About the Site
------------
-
-If you want to know more about my site you should check out the [blog
-post][hyderewrite] about how I rewrote it.
-
-[hyderewrite]: /blog/2010/01/moving-from-django-to-hyde/
-            {% endmarkdown %}
-        {% endfilter %}
-    </div>
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/about/index.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,83 @@
++++
+date = "2010-09-20T12:34:11Z"
+draft = false
+title = "About"
+
++++
+
+I'm **Steve**. I'm currently living in **Reykjavík, Iceland**.  
+I do a lot of different things.
+
+If you want to get in touch with me you can [email
+me](mailto:steve@stevelosh.com) or find me on [BitBucket][], [GitHub][], or
+[Twitter][].
+
+[Twitter]: http://twitter.com/stevelosh/
+[BitBucket]: http://bitbucket.org/sjl/
+[GitHub]: http://github.com/sjl/
+
+Programming
+-----------
+
+I went to [Rochester Institute of Technology](http://rit.edu/) for a degree in
+Computer Science.
+
+I've done a lot of different things in the field so far. Right now the things
+that are captivating me are artificial intelligence and clean, simple,
+*useful* web applications.
+
+I find programming beautiful. That might sound strange, but there are aspects
+of programming and math that I can't describe any other way.
+
+You can take a look at my [projects][] to see some of the major stuff I've
+worked on, or cut to the chase and look at [my BitBucket account][BitBucket].
+
+[projects]: /projects/
+
+Photography
+----------
+
+I like photographing people. Other things as well, but especially people.
+I tend to gravitate toward the "art" aspects of photography more than the
+"journalism" aspects, but I can appreciate both.
+
+I shoot digital and film (35mm and medium format) depending on my time limits
+and mood. I develop film in my bathroom and print it in a rented darkroom.
+When I print digital I use a lab nearby; I don't have the money for a
+professional printer just yet.
+
+Dancing
+-------
+
+I teach blues dancing here in Rochester as part of [Lady Luck Blues][].
+I started blues dancing a few years ago and haven't stopped since. My favorite
+aspect of dancing is connection and blues seems to bring that out more than any
+other dance.
+
+I've also been swing dancing for about seven years. My first love is Lindy Hop; I
+go to classes, workshops and exchanges as often as my schedule and budget will
+allow.
+
+Lately I've begun getting my feet wet in tango. Whether it'll ever become as
+important to me as blues or Lindy remains to be seen.
+
+[Lady Luck Blues]: http://ladyluckblues.com/
+
+Music
+-----
+
+I play electric and upright bass. I've played in a metal band in the past, but
+right now my focus is on jazz and blues.
+
+I DJ at swing and blues dances fairly often. My taste is pretty broad, and
+I'll cater to whatever the floor wants, but I tend to personally enjoy
+slightly down-tempo, small-group music. Let me know if you need a DJ for a
+dance.
+
+About the Site
+-----------
+
+If you want to know more about my site you should check out the [blog
+post][hyderewrite] about how I rewrote it.
+
+[hyderewrite]: /blog/2010/01/moving-from-django-to-hyde/
--- a/content/blog/2008/02/microsoft-entourage-applescript-frustration.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Entourage + Applescript = Frustration"
-    snip: "This is ridiculous."
-    created: 2008-02-21 15:25:45
-%}
-
-{% block article %}
-
-I've been working on a project lately to automate the setup of some rules and
-schedules in Microsoft Entourage. This isn't the easiest thing in the world
-because Entourage doesn't really support AppleScript for creating rules or
-schedules (though it does an admirable job in a lot of other areas).
-
-We've resorted to GUI scripting to get the job done. This basically means
-we're telling our script to click button X, wait a bit, put "abc" in text
-field Y, click button Z, etc. This is painful, fragile and slow but it does
-what we need in all but one case.
-
-That case is selecting a folder. The folder list dialog that pops up doesn't
-seem to use any of Apple's UI components which makes GUI scripting it nearly
-impossible. Only "nearly" though, because there's a way to get around it: the
-keyboard. AppleScript can type into a window by sending a series of key codes.
-You can select something from the folder list by typing its name, which means
-that as long as you know the name (we do) you can select it. Almost.
-
-There's one more snag: selection by typing will only ever select the first
-item in the list. This means that if you want to select "Inbox" and both the
-"On My Computer" list and the "youremail@server.com" list are open, you can
-only get the first Inbox. Oh, and good luck predicting which one will show up
-first. It seemed to be different each time I opened the window.
-
-Once again the keyboard comes to our rescue. A simple (and excruciatingly
-ugly) fix is to make sure that the only account listing that's open is the one
-we want. How can we do that? Send an up arrow key code 50 times to move to the
-beginning of the list, then left and down codes 50 times. This collapses the
-entire tree. Then just type the name of the account to select it, send the
-right arrow code to expand the tree, and type the folder name to select it.
-
-It's painful, but it works. If anyone has a better solution please let me know
-so I can rip this monstrosity out of my code and try to forget about it.
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2008/02/microsoft-entourage-applescript-frustration.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,43 @@
++++
+title = "Entourage + Applescript = Frustration"
+snip = "This is ridiculous."
+date = 2008-02-21T15:25:45Z
+draft = false
+
++++
+
+
+## Hello?
+
+I've been working on a project lately to automate the setup of some rules and
+schedules in Microsoft Entourage. This isn't the easiest thing in the world
+because Entourage doesn't really support AppleScript for creating rules or
+schedules (though it does an admirable job in a lot of other areas).
+
+We've resorted to GUI scripting to get the job done. This basically means
+we're telling our script to click button X, wait a bit, put "abc" in text
+field Y, click button Z, etc. This is painful, fragile and slow but it does
+what we need in all but one case.
+
+That case is selecting a folder. The folder list dialog that pops up doesn't
+seem to use any of Apple's UI components which makes GUI scripting it nearly
+impossible. Only "nearly" though, because there's a way to get around it: the
+keyboard. AppleScript can type into a window by sending a series of key codes.
+You can select something from the folder list by typing its name, which means
+that as long as you know the name (we do) you can select it. Almost.
+
+There's one more snag: selection by typing will only ever select the first
+item in the list. This means that if you want to select "Inbox" and both the
+"On My Computer" list and the "youremail@server.com" list are open, you can
+only get the first Inbox. Oh, and good luck predicting which one will show up
+first. It seemed to be different each time I opened the window.
+
+Once again the keyboard comes to our rescue. A simple (and excruciatingly
+ugly) fix is to make sure that the only account listing that's open is the one
+we want. How can we do that? Send an up arrow key code 50 times to move to the
+beginning of the list, then left and down codes 50 times. This collapses the
+entire tree. Then just type the name of the account to select it, send the
+right arrow code to expand the tree, and type the folder name to select it.
+
+It's painful, but it works. If anyone has a better solution please let me know
+so I can rip this monstrosity out of my code and try to forget about it.
--- a/content/blog/2008/04/shooting-girl-jam.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,203 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Shooting Girl Jam"
-    snip: "I’m finally getting the kind of dancing photos I want."
-    created: 2008-04-29 18:31:16
-%}
-
-
-{% block article %}
-
-<a href="http://www.flickr.com/photos/sjl7678/2450406138/"
-   title="GirlJamSaturday-5383 by Steve Losh, on Flickr">
-    <img src="http://farm4.static.flickr.com/3009/2450406138_473b84b17b_m.jpg"
-         width="240" height="161" alt="GirlJamSaturday-5383"
-         class="left" />
-</a>
-
-This past weekend (April 25-28) was [Northeast Girl Jam][] in Rochester, New
-York. Girl Jam is a swing dancing workshop weekend that focuses on classes for
-the followers. It was a huge success; we had a lot of people attend and
-everyone seemed to have a great time. The dances had a ton of energy and the
-late night parties were wonderful (as always).
-
-I took a bunch of photographs over the course of the weekend, mostly during
-the performances and competitions. Once I posted them I got a bunch of
-questions asking me how I did it, so I figured I'd write here about it in more
-detail. I used different techniques each day so I'll go through them one by
-one.
-
-Friday
-------
-
-My goal for the first two nights was to get images with the dancers sharp
-enough to recognize but with enough blur to convey the feeling of movement and
-energy in the room. I started playing with this technique at the blues parties
-in the past and I think I'm really starting to get the hang of it.
-
-<a href="http://www.flickr.com/photos/sjl7678/2449562969/"
-   title="GirlJamFriday-4873 by Steve Losh, on Flickr">
-    <img src="http://farm3.static.flickr.com/2349/2449562969_68c82066e8_m.jpg"
-         width="161" height="240" alt="GirlJamFriday-4873"
-         class="left" />
-</a>
-
-On Friday I only had one of my flashes with me, so I had to make some
-tradeoffs. I bounced the flash from the ceiling to get more even lighting
-(directional light from a bare flash is usually too harsh), but since the
-ceilings in Tango Cafe are so high it took a lot of power. I wound up shooting
-at ISO 1600 and 3200 for most of the night so that my flash could be on a
-lower power setting and fire faster. Even at that ISO the noise isn't really
-that bad since the photos are exposed well (thanks to the flash). This photo
-was shot at ISO 3200 and I don't think the noise distracts from the image much
-at all.
-
-<a href="http://www.flickr.com/photos/sjl7678/2449565301/"
-   title="GirlJamFriday-4943 by Steve Losh, on Flickr">
-    <img src="http://farm3.static.flickr.com/2186/2449565301_e2491e6b7a_m.jpg"
-         width="240" height="161" alt="GirlJamFriday-4943"
-         class="right" />
-</a>
-
-I was using a wide angle lens (18mm) so that I could get entire bodies into
-the frame. One of the things I love about Lindy Hop is that it really uses the
-entire body which this photo really shows off. Cropping off huge parts of
-people in every single shot makes that much harder to see. I set the aperture
-to about f/4 and that gave me enough depth of field to get most things in
-focus at 18mm. I set the shutter speed depending on the amount of ambient
-light; it varied from 1/30 to 1/4 or so.
-
-<a href="http://www.flickr.com/photos/sjl7678/2450392386/"
-   title="GirlJamFriday-5007 by Steve Losh, on Flickr">
-    <img src="http://farm3.static.flickr.com/2410/2450392386_a61067e07f_m.jpg"
-         width="161" height="240" alt="GirlJamFriday-5007"
-         class="left" />
-</a>
-
-The trick that really made a difference in taking good photos is that once I
-set the exposure I stopped looking at the camera entirely. I didn't review my
-shots as I took them and I didn't even look through the viewfinder to compose.
-Using a wide lens meant that I could just point the camera in the general
-direction of the dancers and still get them. I took this photo at the late
-night and the camera was held against my ribs as I did.
-
-Why did I do that? I can perfectly compose an image but if the dancers aren't
-doing something interesting it's going to be a boring photo. I've been dancing
-long enough that I'm starting to be able to predict when something cool will
-happen in a dance, but that only works if I'm paying complete attention to it.
-Messing with the camera distracts me and I can only get the most obvious
-moments. Ignoring the camera and watching the dancers means I can pick up more
-subtle parts of the dance and capture those (as well as the obvious ones).
-
-Saturday
---------
-
-On Saturday I brought along two flashes to the dance and had Sergey hold one
-while I held the other (thanks Sergey!). Two flashes means twice as much
-light, which means I can shoot with recycle times twice as fast and have more
-even light coverage.
-
-<a href="http://www.flickr.com/photos/sjl7678/2450405794/"
-   title="GirlJamSaturday-5379 by Steve Losh, on Flickr">
-    <img src="http://farm3.static.flickr.com/2227/2450405794_940545d63d_m.jpg"
-         width="161" height="240" alt="GirlJamSaturday-5379"
-         class="left" />
-</a>
-
-Since I was able to shoot twice as many photos I was able to experiment with
-getting up close. Using a wide angle lens let me get most of the dancers in
-the frame when super close and allowed me to play around with really
-interesting perspectives. This photo is one of my favorites from the weekend.
-Getting really close to Nina means that the distance between her and Carl is
-exaggerated and adds to the sense of tension. Once again, the flashes freeze
-the dancers and the ambient light burns in a bit of blur to add some movement.
-This photo was also shot at ISO 1600 but the noise is definitely not the main
-focus of this picture. As long as you don't underexpose noise is usually not a
-problem in these kind of photos.
-
-<a href="http://www.flickr.com/photos/sjl7678/2450404742/"
-   title="GirlJamSaturday-5349 by Steve Losh, on Flickr">
-    <img src="http://farm3.static.flickr.com/2256/2450404742_3d9a3df777_m.jpg"
-         width="161" height="240" alt="GirlJamSaturday-5349"
-         class="right" />
-</a>
-
-Not only did I try getting up close, I also tried varying my angle more than I
-usually do. I usually brace the camera against my ribs when taking these kinds
-of photos for a few reasons:
-
-* It's a safe height that will get the whole dancer in the frame.
-* My ribs are vertical and so aligning the camera with them means that it's
-  not wildly tilted up or down and I don't accidentally get ceiling- or
-  floor-only photos.
-* It keeps the camera close to my body where it's much less likely to be
-  whacked by a stray limb.
-
-Getting lower and higher gives me different perspectives that can have really
-nifty results. The problem is that it's much harder to know if the subject is
-completely (or even mostly) in the frame when the camera is in an awkward
-position. To get a photo like this I probably shot four or five at strange
-angles that I deleted.
-
-One other fun thing to notice: you can see Sergey holding the flash right to
-the left of her hips. I probably could have cloned out the flare in Photoshop
-but I don't think it really detracts from the image much at all.
-
-Sunday
--------
-  
-<a href="http://www.flickr.com/photos/sjl7678/2449592347/"
-   title="GirlJamSunday-5647 by Steve Losh, on Flickr">
-    <img src="http://farm4.static.flickr.com/3066/2449592347_6a17602cd9_m.jpg"
-         width="161" height="240" alt="GirlJamSunday-5647"
-         class="left" />
-</a>
-
-On Sunday I shot at a few of the workshops since there wasn't a dance. A
-workshop has a very different feeling than a dance and so I didn't want to try
-the same approach as the other two nights. Instead of using flash and a wide
-lens I switched to a fast normal lens (my 50mm f/1.4). The light coming
-through the windows was bright enough that I was able to shoot at around 1/60
-at f/2 or f/2.8 and ISO 800 or 1600.
-
-Once again the noise isn't much of a problem because the photos are exposed
-well as this picture shows. The shutter speed is just slow enough to get some
-blur at the ends of the limbs but not enough to lose all detail.
-
-<a href="http://www.flickr.com/photos/sjl7678/2449590741/"
-   title="GirlJamSunday-5512 by Steve Losh, on Flickr">
-    <img src="http://farm3.static.flickr.com/2076/2449590741_b47a5ced4c_m.jpg"
-         width="161" height="240" alt="GirlJamSunday-5512"
-         class="right" />
-</a>
-
-Since I was using a normal lens instead of a wide angle I had to mostly
-abandon the idea of getting big group photos and instead try to capture
-individual people as they learned. Using a wide aperture let me isolate the
-people from the sea of arms and legs in the backgrounds and gave the images a
-soft quality that helps reflect the feeling of the afternoon.
-
-I really like the soft-yet-directional light that came from the big stained
-glass windows combined with the overhead lights. Lately I've been using flash
-a lot in my photography and it was fun to get back to using natural light. I'm
-going to try to practice with it more in the near future.
-
-Overall
--------
-
-Northeast Girl Jam was awesome. I had a great time dancing and photographing
-and got to see a lot of old friends (and meet new ones). If you're sad you
-missed it there's another event in Rochester next month: [Stompology][]. It's
-a weekend of solo jazz and Charleston workshops and awesome swing dances.
-
-If you'd like to see the rest of the photos I took this weekend I posted them
-on [Flickr][]. Feel free to comment there or find me on [Twitter][twsl];
-advice/questions/comments are always appreciated!
-
-[Flickr]: http://flickr.com/photos/sjl7678/collections/72157604785390431/
-[Stompology]: http://stompology.com/
-[Northeast Girl Jam]: http://jojojackson.com/NEGJ/Home.html
-[twsl]: {{links.twsl}}
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2008/04/shooting-girl-jam.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,199 @@
++++
+title = "Shooting Girl Jam"
+snip = "I'm finally getting the kind of dancing photos I want."
+date = 2008-04-29T18:31:16Z
+draft = false
+
++++
+
+<a href="http://www.flickr.com/photos/sjl7678/2450406138/"
+   title="GirlJamSaturday-5383 by Steve Losh, on Flickr">
+    <img src="http://farm4.static.flickr.com/3009/2450406138_473b84b17b_m.jpg"
+         width="240" height="161" alt="GirlJamSaturday-5383"
+         class="left" />
+</a>
+
+This past weekend (April 25-28) was [Northeast Girl Jam][] in Rochester, New
+York. Girl Jam is a swing dancing workshop weekend that focuses on classes for
+the followers. It was a huge success; we had a lot of people attend and
+everyone seemed to have a great time. The dances had a ton of energy and the
+late night parties were wonderful (as always).
+
+I took a bunch of photographs over the course of the weekend, mostly during
+the performances and competitions. Once I posted them I got a bunch of
+questions asking me how I did it, so I figured I'd write here about it in more
+detail. I used different techniques each day so I'll go through them one by
+one.
+
+[Northeast Girl Jam]: http://jojojackson.com/NEGJ/Home.html
+
+Friday
+------
+
+My goal for the first two nights was to get images with the dancers sharp
+enough to recognize but with enough blur to convey the feeling of movement and
+energy in the room. I started playing with this technique at the blues parties
+in the past and I think I'm really starting to get the hang of it.
+
+<a href="http://www.flickr.com/photos/sjl7678/2449562969/"
+   title="GirlJamFriday-4873 by Steve Losh, on Flickr">
+    <img src="http://farm3.static.flickr.com/2349/2449562969_68c82066e8_m.jpg"
+         width="161" height="240" alt="GirlJamFriday-4873"
+         class="left" />
+</a>
+
+On Friday I only had one of my flashes with me, so I had to make some
+tradeoffs. I bounced the flash from the ceiling to get more even lighting
+(directional light from a bare flash is usually too harsh), but since the
+ceilings in Tango Cafe are so high it took a lot of power. I wound up shooting
+at ISO 1600 and 3200 for most of the night so that my flash could be on a
+lower power setting and fire faster. Even at that ISO the noise isn't really
+that bad since the photos are exposed well (thanks to the flash). This photo
+was shot at ISO 3200 and I don't think the noise distracts from the image much
+at all.
+
+<a href="http://www.flickr.com/photos/sjl7678/2449565301/"
+   title="GirlJamFriday-4943 by Steve Losh, on Flickr">
+    <img src="http://farm3.static.flickr.com/2186/2449565301_e2491e6b7a_m.jpg"
+         width="240" height="161" alt="GirlJamFriday-4943"
+         class="right" />
+</a>
+
+I was using a wide angle lens (18mm) so that I could get entire bodies into
+the frame. One of the things I love about Lindy Hop is that it really uses the
+entire body which this photo really shows off. Cropping off huge parts of
+people in every single shot makes that much harder to see. I set the aperture
+to about f/4 and that gave me enough depth of field to get most things in
+focus at 18mm. I set the shutter speed depending on the amount of ambient
+light; it varied from 1/30 to 1/4 or so.
+
+<a href="http://www.flickr.com/photos/sjl7678/2450392386/"
+   title="GirlJamFriday-5007 by Steve Losh, on Flickr">
+    <img src="http://farm3.static.flickr.com/2410/2450392386_a61067e07f_m.jpg"
+         width="161" height="240" alt="GirlJamFriday-5007"
+         class="left" />
+</a>
+
+The trick that really made a difference in taking good photos is that once I
+set the exposure I stopped looking at the camera entirely. I didn't review my
+shots as I took them and I didn't even look through the viewfinder to compose.
+Using a wide lens meant that I could just point the camera in the general
+direction of the dancers and still get them. I took this photo at the late
+night and the camera was held against my ribs as I did.
+
+Why did I do that? I can perfectly compose an image but if the dancers aren't
+doing something interesting it's going to be a boring photo. I've been dancing
+long enough that I'm starting to be able to predict when something cool will
+happen in a dance, but that only works if I'm paying complete attention to it.
+Messing with the camera distracts me and I can only get the most obvious
+moments. Ignoring the camera and watching the dancers means I can pick up more
+subtle parts of the dance and capture those (as well as the obvious ones).
+
+Saturday
+--------
+
+On Saturday I brought along two flashes to the dance and had Sergey hold one
+while I held the other (thanks Sergey!). Two flashes means twice as much
+light, which means I can shoot with recycle times twice as fast and have more
+even light coverage.
+
+<a href="http://www.flickr.com/photos/sjl7678/2450405794/"
+   title="GirlJamSaturday-5379 by Steve Losh, on Flickr">
+    <img src="http://farm3.static.flickr.com/2227/2450405794_940545d63d_m.jpg"
+         width="161" height="240" alt="GirlJamSaturday-5379"
+         class="left" />
+</a>
+
+Since I was able to shoot twice as many photos I was able to experiment with
+getting up close. Using a wide angle lens let me get most of the dancers in
+the frame when super close and allowed me to play around with really
+interesting perspectives. This photo is one of my favorites from the weekend.
+Getting really close to Nina means that the distance between her and Carl is
+exaggerated and adds to the sense of tension. Once again, the flashes freeze
+the dancers and the ambient light burns in a bit of blur to add some movement.
+This photo was also shot at ISO 1600 but the noise is definitely not the main
+focus of this picture. As long as you don't underexpose noise is usually not a
+problem in these kind of photos.
+
+<a href="http://www.flickr.com/photos/sjl7678/2450404742/"
+   title="GirlJamSaturday-5349 by Steve Losh, on Flickr">
+    <img src="http://farm3.static.flickr.com/2256/2450404742_3d9a3df777_m.jpg"
+         width="161" height="240" alt="GirlJamSaturday-5349"
+         class="right" />
+</a>
+
+Not only did I try getting up close, I also tried varying my angle more than I
+usually do. I usually brace the camera against my ribs when taking these kinds
+of photos for a few reasons:
+
+* It's a safe height that will get the whole dancer in the frame.
+* My ribs are vertical and so aligning the camera with them means that it's
+  not wildly tilted up or down and I don't accidentally get ceiling- or
+  floor-only photos.
+* It keeps the camera close to my body where it's much less likely to be
+  whacked by a stray limb.
+
+Getting lower and higher gives me different perspectives that can have really
+nifty results. The problem is that it's much harder to know if the subject is
+completely (or even mostly) in the frame when the camera is in an awkward
+position. To get a photo like this I probably shot four or five at strange
+angles that I deleted.
+
+One other fun thing to notice: you can see Sergey holding the flash right to
+the left of her hips. I probably could have cloned out the flare in Photoshop
+but I don't think it really detracts from the image much at all.
+
+Sunday
+-------
+  
+<a href="http://www.flickr.com/photos/sjl7678/2449592347/"
+   title="GirlJamSunday-5647 by Steve Losh, on Flickr">
+    <img src="http://farm4.static.flickr.com/3066/2449592347_6a17602cd9_m.jpg"
+         width="161" height="240" alt="GirlJamSunday-5647"
+         class="left" />
+</a>
+
+On Sunday I shot at a few of the workshops since there wasn't a dance. A
+workshop has a very different feeling than a dance and so I didn't want to try
+the same approach as the other two nights. Instead of using flash and a wide
+lens I switched to a fast normal lens (my 50mm f/1.4). The light coming
+through the windows was bright enough that I was able to shoot at around 1/60
+at f/2 or f/2.8 and ISO 800 or 1600.
+
+Once again the noise isn't much of a problem because the photos are exposed
+well as this picture shows. The shutter speed is just slow enough to get some
+blur at the ends of the limbs but not enough to lose all detail.
+
+<a href="http://www.flickr.com/photos/sjl7678/2449590741/"
+   title="GirlJamSunday-5512 by Steve Losh, on Flickr">
+    <img src="http://farm3.static.flickr.com/2076/2449590741_b47a5ced4c_m.jpg"
+         width="161" height="240" alt="GirlJamSunday-5512"
+         class="right" />
+</a>
+
+Since I was using a normal lens instead of a wide angle I had to mostly
+abandon the idea of getting big group photos and instead try to capture
+individual people as they learned. Using a wide aperture let me isolate the
+people from the sea of arms and legs in the backgrounds and gave the images a
+soft quality that helps reflect the feeling of the afternoon.
+
+I really like the soft-yet-directional light that came from the big stained
+glass windows combined with the overhead lights. Lately I've been using flash
+a lot in my photography and it was fun to get back to using natural light. I'm
+going to try to practice with it more in the near future.
+
+Overall
+-------
+
+Northeast Girl Jam was awesome. I had a great time dancing and photographing
+and got to see a lot of old friends (and meet new ones). If you're sad you
+missed it there's another event in Rochester next month: [Stompology][]. It's
+a weekend of solo jazz and Charleston workshops and awesome swing dances.
+
+If you'd like to see the rest of the photos I took this weekend I posted them
+on [Flickr][]. Feel free to comment there or find me on [Twitter][twsl];
+advice/questions/comments are always appreciated!
+
+[Flickr]: http://flickr.com/photos/sjl7678/collections/72157604785390431/
+[Stompology]: http://stompology.com/
+[twsl]: http://twitter.com/stevelosh/
--- a/content/blog/2008/08/beauty-in-computer-science-recursion.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,183 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Beauty in Computer Science"
-    snip: "Why I love what I do."
-    created: 2008-08-29 15:30:38
-%}
-
-
-{% block article %}
-
-When I went to college, I majored in Computer Science. I haven't really
-written anything about this part of my life yet, so I figured this might be a
-good time to start.
-
-I decided to major in CS when I was in high school. I learned to program on my
-own and enjoyed the challenge of it. I also knew that programming jobs are
-fairly common and pay well enough that I wouldn't have to worrying about
-paying my rent. I wasn't artistic in high school, and CS seemed like a
-logical, sterile field that I felt I could do well in.
-
-During the years I spent at RIT I changed quite a bit. I think the most
-important, or at least the most obvious, change has been my becoming more
-artistic. Between dancing, playing bass and photography I've developed a
-creative side that I never thought I could. Has this led me away from Computer
-Science at all?
-
-No. While I became a programmer for practical reasons, I stayed one for
-entirely different reasons. Computer Science (and math in general) is
-beautiful. It took me years to slowly realize this, but now that I have I see
-that it's more beautiful than any dance, photograph or music I've ever
-encountered. This post is the first in a series of posts that I hope can
-communicate why I find CS beautiful, or at least point in the right direction.
-
-A Quick Primer on "Functions" for Non-Programmers
----------
-
-I know that most (if not all) of the people that read my website don't
-program. I'm going to try to avoid using extremely technical, computer sciency
-terms in these posts, but there are at least a few basic things that I need to
-explain. The first is what a function is.
-
-Think of a function as a set of instructions. A recipe is a decent example.
-Imagine you have a piece of paper with the following written on it:
-
-1. Heat a frying pan.
-2. Crack two eggs into a bowl.
-3. Mix the eggs.
-4. Pour the mixture into the hot frying pan.
-5. Stir the mixture until it is solid.
-6. Take the mixture out of the pan.
-
-That's the simplest example of a function: a list of instructions that you
-follow in the order you get them. The next idea is a "parameter." That recipe
-only told us how to make food for one person, wouldn't it be nice to know how
-to make enough for two or more? Imagine the paper now says this:
-
-1. Heat a frying pan.
-2. Crack NUMBER_OF_PEOPLE * 2 eggs into a bowl.
-3. Mix the eggs.
-4. Pour the mixture into the hot frying pan.
-5. Stir the mixture until it is solid.
-6. Take the mixture out of the pan.
-
-Now we still have a single piece of paper, but by just substituting in the
-number of people we're cooking for we have instructions for making any amount
-of food. If we have three people, NUMBER_OF_PEOPLE * 2 eggs becomes 3 * 2
-eggs, or 6 eggs.
-
-The last important concept is "calling." Once you have one function, you can
-use it in other functions, like so:
-
-1. Put a plate on the table.
-2. Refer to the other piece of paper and do what it says, for 1 person.
-3. Put the result of that on the plate.
-4. Eat it.
-
-See how we did a few things, then referred to the other piece of paper instead
-of repeating ourselves? This lets you make small tasks and put them together
-to form bigger ones. That's enough of a primer for now; if something's not
-clear please find me on [Twitter][twsl] and let me know.
-
-[twsl]: {{links.twsl}}
-
-What's Recursion?
----------------
-
-Recursion is a term that means, basically, a function calls (or refers to)
-itself. This concept can be hard to grasp, but once you do it slowly turns
-into something breathtakingly beautiful.
-
-Here's a simple example: imagine you're 10 meters away from a doorway and you
-want to walk out of it. A function that could help you do this might be: "Walk
-11 meters." That's pretty simple.
-
-What if we want to be able to walk out of a doorway that's any number of
-meters ahead of us? We could say: "Walk DISTANCE + 1 meters." This works, but
-requires that you know how many meters away the door is before you even start
-walking. What if we don't?
-
-How about we just do a little at a time and see how it goes? "Walk 2 meters.
-If you're out of the doorway, stop. Otherwise, repeat this function." If the
-doorway is 3 meters in front of us, we'll walk 2, check if we're out (we're
-not), and repeat. We'll walk 2, check if we're out (we are), and stop. This
-function is recursive; it refers back to itself.
-
-Why is it beautiful?
---------------
-
-The beauty of recursion, for me, is that you can build infinitely large or
-complex tasks or structures using one or two tiny, simple parts. I'll give an
-example of this because I think it's the easiest way for me to show it.
-
-Imagine that you only know three things: how to add 1 to a number, how to
-subtract 1 from a number, and what 0 means. Now imagine that you want to be
-able to add any two (positive) numbers (integers) together. How could you do
-this? Here's a function:
-
-    :::text
-    function add(x, y):
-        if y = 0:
-            return x
-        otherwise:
-            return add( x+1, y-1 )
-
-Don't let the new notation scare you; it's the same kind of function as
-always. In English, it says "This function is named 'add' and needs two
-parameters (x and y). Step one is to see if y is 0. If it is, the result is x.
-If it's not, then the result is whatever you get from performing this function
-with the following parameters: x+1, y-1."
-
-It might not be immediately obvious that this will actually perform the
-addition we're used to, so let's try it. First, let's try adding 1 + 0. In
-that case, we check if y is 0. It is, so the result is x, or 1. So far, so
-good.
-
-Let's try 2 + 1. Is y equal to 0? No, so we need to call add with some new
-parameters. 2+1 is 3, 1-0 is 0, so the result is now whatever we get from
-add(3, 0). We start following the instructions of add. Does y equal 0? Yes, so
-the result is 3, which is what we expect.
-
-One more for good measure: 9 + 2. First we check if y is 0. It's not, so the
-result is then add(9+1, 2-1), or add(10,1). Start over. Is y zero? Nope, so
-the result is now add(11, 0). Start over. Is y zero? Yes, so the result is x,
-or 11.
-
-So What?
---------
-
-This will work for any x and any y (as long as they're both positive, negative
-numbers make it just a tiny bit more complicated). This might not seem
-impressive, but think about what we've done. We've created something that can
-add any two numbers together. There are an infinite amount of numbers. This
-tiny function that we've made from the simplest of parts can generate more
-results than there are people on this planet. Or atoms in the universe. To me,
-this is amazing. Not "magic trick" amazing or "miracle" amazing but "I can
-understand and create something that can describe more knowledge than the
-whole of humanity couldn't hope to describe in a thousand lifetimes" amazing.
-
-Computer Science (and math in general) is full of this kind of beauty. I've
-tried to find parallels in my other interests; the closest I've found is the
-photograph [Pale Blue Dot][]. It's a photo taken by the Voyager 1 space probe
-showing an immense amount of space with the tiniest blue speck in the middle,
-which is Earth.
-
-When you view the photograph, it's a mostly black field with a little fleck of
-blue pigment. Not terribly complicated or interesting, until you realize that
-that blue fleck is a representation of the planet that billions of people have
-lived and died on. A smidgen of blue ink, in the right context, represents
-every place a human has ever called "home."
-
-Our addition function might not seems nearly as nifty as this, but it actually
-represents more than even this photo ever can. There are a finite number of
-people on Earth, but the addition function can add more numbers that that.
-Even if you count every second in the life of every person that has ever lived
-on our planet, the addition function can create more numbers than that.
-
-This awes me more than any myth, photograph, story, song, legend or dance ever
-has. It's the reason I stayed a Computer Scientist.
-
-[Pale Blue Dot]: http://en.wikipedia.org/wiki/Pale_Blue_Dot
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2008/08/beauty-in-computer-science-recursion.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,180 @@
++++
+title = "Beauty in Computer Science"
+snip = "Why I love what I do."
+date = 2008-08-29T15:30:38Z
+draft = false
+
++++
+
+When I went to college, I majored in Computer Science. I haven't really
+written anything about this part of my life yet, so I figured this might be a
+good time to start.
+
+I decided to major in CS when I was in high school. I learned to program on my
+own and enjoyed the challenge of it. I also knew that programming jobs are
+fairly common and pay well enough that I wouldn't have to worrying about
+paying my rent. I wasn't artistic in high school, and CS seemed like a
+logical, sterile field that I felt I could do well in.
+
+During the years I spent at RIT I changed quite a bit. I think the most
+important, or at least the most obvious, change has been my becoming more
+artistic. Between dancing, playing bass and photography I've developed a
+creative side that I never thought I could. Has this led me away from Computer
+Science at all?
+
+No. While I became a programmer for practical reasons, I stayed one for
+entirely different reasons. Computer Science (and math in general) is
+beautiful. It took me years to slowly realize this, but now that I have I see
+that it's more beautiful than any dance, photograph or music I've ever
+encountered. This post is the first in a series of posts that I hope can
+communicate why I find CS beautiful, or at least point in the right direction.
+
+A Quick Primer on "Functions" for Non-Programmers
+---------
+
+I know that most (if not all) of the people that read my website don't
+program. I'm going to try to avoid using extremely technical, computer sciency
+terms in these posts, but there are at least a few basic things that I need to
+explain. The first is what a function is.
+
+Think of a function as a set of instructions. A recipe is a decent example.
+Imagine you have a piece of paper with the following written on it:
+
+1. Heat a frying pan.
+2. Crack two eggs into a bowl.
+3. Mix the eggs.
+4. Pour the mixture into the hot frying pan.
+5. Stir the mixture until it is solid.
+6. Take the mixture out of the pan.
+
+That's the simplest example of a function: a list of instructions that you
+follow in the order you get them. The next idea is a "parameter." That recipe
+only told us how to make food for one person, wouldn't it be nice to know how
+to make enough for two or more? Imagine the paper now says this:
+
+1. Heat a frying pan.
+2. Crack NUMBER_OF_PEOPLE * 2 eggs into a bowl.
+3. Mix the eggs.
+4. Pour the mixture into the hot frying pan.
+5. Stir the mixture until it is solid.
+6. Take the mixture out of the pan.
+
+Now we still have a single piece of paper, but by just substituting in the
+number of people we're cooking for we have instructions for making any amount
+of food. If we have three people, NUMBER_OF_PEOPLE * 2 eggs becomes 3 * 2
+eggs, or 6 eggs.
+
+The last important concept is "calling." Once you have one function, you can
+use it in other functions, like so:
+
+1. Put a plate on the table.
+2. Refer to the other piece of paper and do what it says, for 1 person.
+3. Put the result of that on the plate.
+4. Eat it.
+
+See how we did a few things, then referred to the other piece of paper instead
+of repeating ourselves? This lets you make small tasks and put them together
+to form bigger ones. That's enough of a primer for now; if something's not
+clear please find me on [Twitter][twsl] and let me know.
+
+[twsl]: {{links.twsl}}
+
+What's Recursion?
+---------------
+
+Recursion is a term that means, basically, a function calls (or refers to)
+itself. This concept can be hard to grasp, but once you do it slowly turns
+into something breathtakingly beautiful.
+
+Here's a simple example: imagine you're 10 meters away from a doorway and you
+want to walk out of it. A function that could help you do this might be: "Walk
+11 meters." That's pretty simple.
+
+What if we want to be able to walk out of a doorway that's any number of
+meters ahead of us? We could say: "Walk DISTANCE + 1 meters." This works, but
+requires that you know how many meters away the door is before you even start
+walking. What if we don't?
+
+How about we just do a little at a time and see how it goes? "Walk 2 meters.
+If you're out of the doorway, stop. Otherwise, repeat this function." If the
+doorway is 3 meters in front of us, we'll walk 2, check if we're out (we're
+not), and repeat. We'll walk 2, check if we're out (we are), and stop. This
+function is recursive; it refers back to itself.
+
+Why is it beautiful?
+--------------
+
+The beauty of recursion, for me, is that you can build infinitely large or
+complex tasks or structures using one or two tiny, simple parts. I'll give an
+example of this because I think it's the easiest way for me to show it.
+
+Imagine that you only know three things: how to add 1 to a number, how to
+subtract 1 from a number, and what 0 means. Now imagine that you want to be
+able to add any two (positive) numbers (integers) together. How could you do
+this? Here's a function:
+
+```text
+function add(x, y):
+    if y = 0:
+        return x
+    otherwise:
+        return add( x+1, y-1 )
+```
+
+Don't let the new notation scare you; it's the same kind of function as
+always. In English, it says "This function is named 'add' and needs two
+parameters (x and y). Step one is to see if y is 0. If it is, the result is x.
+If it's not, then the result is whatever you get from performing this function
+with the following parameters: x+1, y-1."
+
+It might not be immediately obvious that this will actually perform the
+addition we're used to, so let's try it. First, let's try adding 1 + 0. In
+that case, we check if y is 0. It is, so the result is x, or 1. So far, so
+good.
+
+Let's try 2 + 1. Is y equal to 0? No, so we need to call add with some new
+parameters. 2+1 is 3, 1-0 is 0, so the result is now whatever we get from
+add(3, 0). We start following the instructions of add. Does y equal 0? Yes, so
+the result is 3, which is what we expect.
+
+One more for good measure: 9 + 2. First we check if y is 0. It's not, so the
+result is then add(9+1, 2-1), or add(10,1). Start over. Is y zero? Nope, so
+the result is now add(11, 0). Start over. Is y zero? Yes, so the result is x,
+or 11.
+
+So What?
+--------
+
+This will work for any x and any y (as long as they're both positive, negative
+numbers make it just a tiny bit more complicated). This might not seem
+impressive, but think about what we've done. We've created something that can
+add any two numbers together. There are an infinite amount of numbers. This
+tiny function that we've made from the simplest of parts can generate more
+results than there are people on this planet. Or atoms in the universe. To me,
+this is amazing. Not "magic trick" amazing or "miracle" amazing but "I can
+understand and create something that can describe more knowledge than the
+whole of humanity couldn't hope to describe in a thousand lifetimes" amazing.
+
+Computer Science (and math in general) is full of this kind of beauty. I've
+tried to find parallels in my other interests; the closest I've found is the
+photograph [Pale Blue Dot][]. It's a photo taken by the Voyager 1 space probe
+showing an immense amount of space with the tiniest blue speck in the middle,
+which is Earth.
+
+When you view the photograph, it's a mostly black field with a little fleck of
+blue pigment. Not terribly complicated or interesting, until you realize that
+that blue fleck is a representation of the planet that billions of people have
+lived and died on. A smidgen of blue ink, in the right context, represents
+every place a human has ever called "home."
+
+Our addition function might not seems nearly as nifty as this, but it actually
+represents more than even this photo ever can. There are a finite number of
+people on Earth, but the addition function can add more numbers that that.
+Even if you count every second in the life of every person that has ever lived
+on our planet, the addition function can create more numbers than that.
+
+This awes me more than any myth, photograph, story, song, legend or dance ever
+has. It's the reason I stayed a Computer Scientist.
+
+[Pale Blue Dot]: http://en.wikipedia.org/wiki/Pale_Blue_Dot
+
--- a/content/blog/2008/08/negative-space-dancing.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,103 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Negative Space in Dancing"
-    snip: "It’s not just for artsy kids."
-    created: 2008-08-31 15:33:57
-%}
-
-
-{% block article %}
-
-Last night a few of us from Rochester drove to Buffalo for a swing event.
-There were three classes during the afternoon that were pretty fun. There was
-a dance in the evening which had a great turnout and plenty of energy. As nice
-as all that was, the real highlight of the day/night was the blues party after
-the dance. Matt and I ended up DJ'ing it and it was absolutely awesome. I got
-to meet and dance with a whole bunch of new people that I hope to dance with
-again soon.
-
-One concept I try to use in my blues (and tango) dancing is that of negative
-space. I've found that a lot of blues dancers don't really seem to quite get
-that idea. I'm not saying that it's the "right" way to blues dance but it's
-something that's changed how I dance and I wanted to write something about it
-to share it with anyone interested.
-
-What is negative space?
--------------------
-
-Negative space is a term used a lot in painting, photography, graphic design,
-etc. It basically means that for a given photo (or painting, whatever) the
-whole frame isn't filled with "things." Two examples of this taken from my
-flickr favorites are [this photo][1] and [this one][2]. In both of these
-images the subject takes up only a small portion of the frame. The expanses of
-even texture and tone add certain qualities to the photos that can't be
-achieved otherwise.
-
-A photographer that takes this to an extreme is Hiroshi Sugimoto, in his
-[Seascape][] series. He uses long exposures and darkroom techniques to produce
-images of nothing but negative space. The sea blends into a seamless texture
-and the sky becomes a single tone. Even though there isn't a physical object
-between the two, the division between them forms a subject of its own.
-
-How does it relate to dancing?
-------------------------
-
-Most of the blues dancers I know come from a Lindy Hop background. Lindy Hop
-is a dance of movement and momentum; that's part of what makes it so much fun.
-When blues dancing I think a lot of Lindy Hoppers never catch on to this idea:
-*you don't need to be moving all of the time*. It's alright to slow down and
-actually stop for one, two, three, four measures. It gives the dance a chance
-to breathe and lets you focus on your connection with your partner without
-movement getting in the way.
-
-"Won't that be boring?" No. Absolutely not. Stopping can provide things that
-you can't really get while moving. It can add tension, release it, and
-completely change the mood of a dance. It really does have a lot in common
-with negative space in art, and it adds a lot to a dance.
-
-Negative space does not mean "empty space," although it's often described like
-that. In the first photo I linked to the wall is indeed blank, but has color
-and texture that can give you plenty to look at. In the second, the expanses
-of white are just that: white. They are not empty; they have a distinct tone:
-white. If they were black, or even a light grey the photo would be entirely
-different.
-
-In dancing, movement is important but not the only thing we think about.
-Posture and body positioning is one example. "Feeling" or "mood" is another,
-more elusive, one. Just because the movement is gone doesn't mean all these
-other things go away automatically; they're still there until you let them go.
-
-Taking it to the extreme like Sugimoto's Seascapes is also emphatically *not*
-boring. In some of the best blues dances I've ever had there were parts where
-we didn't really move for several measures at a time. When this happens, both
-of you create your own negative space through your posture, etc. Neither of
-these spaces are empty.
-
-Where these spaces meet is your connection. Like the horizons in Sugimoto's
-photographs it becomes the main subject. By eliminating motion you're free to
-focus your attention on other aspects of the connection. Sometimes these
-aren't obvious at first. One example Mihai likes to talk about is breathing.
-Another is understanding where your partner's weight is.
-
-By giving yourself time to really feel the connection with your partner you
-have time to examine it much more closely. You can introduce tiny movements
-(like the waves that fleck the surface of the water in Sugimito's seas) that
-interrupt the absolute flatness of the spaces and let you explore the
-interactions between them. Not only does this let you learn about how your
-partner is connected to you in a more in-depth way, it's very, very fun.
-
-I don't have a particularly amazing ending for this post. The main points I
-wanted to get across are these: Negative space in dancing is removing most or
-all of the movement for a longer-than-normal about of time. Negative space is
-not empty space unless you ignore all the other aspects of the dance like
-posture, mood and connection. Negative space can add things to a dance that
-you can't get otherwise.
-
-Try it.
-
-[1]: http://flickr.com/photos/theoperamafia/2790037114/
-[2]: http://flickr.com/photos/jodiseva/2385347094/
-[Seascape]: http://www.sugimotohiroshi.com/seascape.html
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2008/08/negative-space-dancing.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,99 @@
++++
+title = "Negative Space in Dancing"
+snip = "It’s not just for artsy kids."
+date = 2008-08-31T15:33:57Z
+draft = false
+
++++
+
+Last night a few of us from Rochester drove to Buffalo for a swing event.
+There were three classes during the afternoon that were pretty fun. There was
+a dance in the evening which had a great turnout and plenty of energy. As nice
+as all that was, the real highlight of the day/night was the blues party after
+the dance. Matt and I ended up DJ'ing it and it was absolutely awesome. I got
+to meet and dance with a whole bunch of new people that I hope to dance with
+again soon.
+
+One concept I try to use in my blues (and tango) dancing is that of negative
+space. I've found that a lot of blues dancers don't really seem to quite get
+that idea. I'm not saying that it's the "right" way to blues dance but it's
+something that's changed how I dance and I wanted to write something about it
+to share it with anyone interested.
+
+What is negative space?
+-------------------
+
+Negative space is a term used a lot in painting, photography, graphic design,
+etc. It basically means that for a given photo (or painting, whatever) the
+whole frame isn't filled with "things." Two examples of this taken from my
+flickr favorites are [this photo][1] and [this one][2]. In both of these
+images the subject takes up only a small portion of the frame. The expanses of
+even texture and tone add certain qualities to the photos that can't be
+achieved otherwise.
+
+A photographer that takes this to an extreme is Hiroshi Sugimoto, in his
+[Seascape][] series. He uses long exposures and darkroom techniques to produce
+images of nothing but negative space. The sea blends into a seamless texture
+and the sky becomes a single tone. Even though there isn't a physical object
+between the two, the division between them forms a subject of its own.
+
+How does it relate to dancing?
+------------------------
+
+Most of the blues dancers I know come from a Lindy Hop background. Lindy Hop
+is a dance of movement and momentum; that's part of what makes it so much fun.
+When blues dancing I think a lot of Lindy Hoppers never catch on to this idea:
+*you don't need to be moving all of the time*. It's alright to slow down and
+actually stop for one, two, three, four measures. It gives the dance a chance
+to breathe and lets you focus on your connection with your partner without
+movement getting in the way.
+
+"Won't that be boring?" No. Absolutely not. Stopping can provide things that
+you can't really get while moving. It can add tension, release it, and
+completely change the mood of a dance. It really does have a lot in common
+with negative space in art, and it adds a lot to a dance.
+
+Negative space does not mean "empty space," although it's often described like
+that. In the first photo I linked to the wall is indeed blank, but has color
+and texture that can give you plenty to look at. In the second, the expanses
+of white are just that: white. They are not empty; they have a distinct tone:
+white. If they were black, or even a light grey the photo would be entirely
+different.
+
+In dancing, movement is important but not the only thing we think about.
+Posture and body positioning is one example. "Feeling" or "mood" is another,
+more elusive, one. Just because the movement is gone doesn't mean all these
+other things go away automatically; they're still there until you let them go.
+
+Taking it to the extreme like Sugimoto's Seascapes is also emphatically *not*
+boring. In some of the best blues dances I've ever had there were parts where
+we didn't really move for several measures at a time. When this happens, both
+of you create your own negative space through your posture, etc. Neither of
+these spaces are empty.
+
+Where these spaces meet is your connection. Like the horizons in Sugimoto's
+photographs it becomes the main subject. By eliminating motion you're free to
+focus your attention on other aspects of the connection. Sometimes these
+aren't obvious at first. One example Mihai likes to talk about is breathing.
+Another is understanding where your partner's weight is.
+
+By giving yourself time to really feel the connection with your partner you
+have time to examine it much more closely. You can introduce tiny movements
+(like the waves that fleck the surface of the water in Sugimito's seas) that
+interrupt the absolute flatness of the spaces and let you explore the
+interactions between them. Not only does this let you learn about how your
+partner is connected to you in a more in-depth way, it's very, very fun.
+
+I don't have a particularly amazing ending for this post. The main points I
+wanted to get across are these: Negative space in dancing is removing most or
+all of the movement for a longer-than-normal about of time. Negative space is
+not empty space unless you ignore all the other aspects of the dance like
+posture, mood and connection. Negative space can add things to a dance that
+you can't get otherwise.
+
+Try it.
+
+[1]: http://flickr.com/photos/theoperamafia/2790037114/
+[2]: http://flickr.com/photos/jodiseva/2385347094/
+[Seascape]: http://www.sugimotohiroshi.com/seascape.html
+
--- a/content/blog/2008/08/on-leading.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "On Leading"
-    snip: "Some of my thoughts on leading after five years of doing it."
-    created: 2008-08-01 15:28:33
-%}
-
-
-{% block article %}
-
-For those of you that don't know, one of the things I do with my free time is
-dancing. I've been swing dancing (Lindy Hop) for about five years, blues
-dancing for a year or so, and recently started learning tango. All of these
-dances are improvised partner dances and so rely heavily on leading and
-following. People do make routines but at least 95% of it is unrehearsed
-social dancing with partners you might have never met.
-
-As a male I'm usually in the role of leader, though I do try to follow when I
-get the chance. I've learned a lot over the years so I'm going to write a few
-posts about leading, and this is the first. I'm going to use the traditional
-pronouns to make things easier to read, but everything applies to both genders
-in both roles.
-
-Beginning
------
-
-When a guy is first taught how to swing dance (or blues, or tango; everything
-I'm saying applies to all three) he's usually taught that his main job is to
-lead. This sounds obvious, but it's a lot for a beginner to take in. He has to
-learn the footwork and ingrain it into his memory so it becomes automatic,
-which takes some time. The next step is learning individual moves: not only
-how to do them himself but also how to lead a follower to do them at the same
-time. It takes coordination and most of all practice.
-
-Leading at this point involves clearly showing the follower where she should
-go and what she should do. "Placing the follower's weight" is a concept that's
-a bit tricky but very useful. If a leader isn't clear in his leading the
-follower won't be able to follow him unless she "cheats" and just does what
-she knows he wants her to do (because she's danced with him before and so
-knows what he's trying to do). This falls apart when the leader dances with a
-new partner. Without leading and following swing dancing just doesn't work, so
-leading clearly is the main role of a beginner guy.
-
-Moving On
------
-
-Let me take a second to explain something I see happen very often with leaders
-that take classes and progress nicely in their skill. Once the leader gets the
-basics down pat and starts learning more moves, there seems to be a tendency
-to learn things that let him show off. The followers get to really shine in
-Lindy Hop quite a bit, so it's only natural for the guys to want to measure up
-and look cool themselves. Unfortunately I think this gets in the way of my
-next idea.
-
-I think once a leader reaches a point where he's comfortable with the
-structure of the dance and has a repertoire of moves and vocabulary of
-movements, his role changes. His job is no longer "lead." His role becomes
-*"lead the follower you are dancing with right now."*
-
-Every follower is different. Every single one has a different level of
-experience, a different style, and a different personality (as it relates to
-dancing). If the leader simply leads every dance the same way, those dances
-are not as good as they could be. An "advanced" leader leading a beginner
-follower in a lot of complicated movements she's not capable of following yet
-turns into a complete mess. He goes away from the dance feeling bored or
-frustrated (or worse, arrogant) and she goes away feeling confused,
-discouraged or angry. This is not a good thing.
-
-Paying attention to the follow's level is critical. I'm not saying "only do
-moves that the follower has learned and can easily follow." Pushing the
-follower slightly beyond her comfortable, "automatic" level is wonderful and
-helps her immensely; but going totally over her head and confusing the hell
-out of her just so he can show off (to her or others) is obnoxious. This also
-works in reverse: followers, please challenge your leaders but be mindful of
-their skill.
-
-Experience isn't the only difference between followers. Each follower has her
-own style that won't always fit perfectly with the leader's personal style.
-Adjusting his style to mesh better with hers makes the connection between
-partners so much better, which makes the dance that much more fun. This also
-works both ways. Followers are generally better at "listening" to their
-partner because it's their main job; if a lead makes an effort to really
-listen to the follow and change his leading to incorporate her ideas,
-personality, style and level it makes an enormous difference.
-
-The point I'm trying to make is that "leading" a follower is not just leading.
-It's paying attention to the follower and leading *her*.
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2008/08/on-leading.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,86 @@
++++
+title = "On Leading"
+snip = "Some of my thoughts on leading after five years of doing it."
+date = 2008-08-01T15:28:33Z
+draft = false
+
++++
+
+For those of you that don't know, one of the things I do with my free time is
+dancing. I've been swing dancing (Lindy Hop) for about five years, blues
+dancing for a year or so, and recently started learning tango. All of these
+dances are improvised partner dances and so rely heavily on leading and
+following. People do make routines but at least 95% of it is unrehearsed
+social dancing with partners you might have never met.
+
+As a male I'm usually in the role of leader, though I do try to follow when I
+get the chance. I've learned a lot over the years so I'm going to write a few
+posts about leading, and this is the first. I'm going to use the traditional
+pronouns to make things easier to read, but everything applies to both genders
+in both roles.
+
+Beginning
+-----
+
+When a guy is first taught how to swing dance (or blues, or tango; everything
+I'm saying applies to all three) he's usually taught that his main job is to
+lead. This sounds obvious, but it's a lot for a beginner to take in. He has to
+learn the footwork and ingrain it into his memory so it becomes automatic,
+which takes some time. The next step is learning individual moves: not only
+how to do them himself but also how to lead a follower to do them at the same
+time. It takes coordination and most of all practice.
+
+Leading at this point involves clearly showing the follower where she should
+go and what she should do. "Placing the follower's weight" is a concept that's
+a bit tricky but very useful. If a leader isn't clear in his leading the
+follower won't be able to follow him unless she "cheats" and just does what
+she knows he wants her to do (because she's danced with him before and so
+knows what he's trying to do). This falls apart when the leader dances with a
+new partner. Without leading and following swing dancing just doesn't work, so
+leading clearly is the main role of a beginner guy.
+
+Moving On
+-----
+
+Let me take a second to explain something I see happen very often with leaders
+that take classes and progress nicely in their skill. Once the leader gets the
+basics down pat and starts learning more moves, there seems to be a tendency
+to learn things that let him show off. The followers get to really shine in
+Lindy Hop quite a bit, so it's only natural for the guys to want to measure up
+and look cool themselves. Unfortunately I think this gets in the way of my
+next idea.
+
+I think once a leader reaches a point where he's comfortable with the
+structure of the dance and has a repertoire of moves and vocabulary of
+movements, his role changes. His job is no longer "lead." His role becomes
+*"lead the follower you are dancing with right now."*
+
+Every follower is different. Every single one has a different level of
+experience, a different style, and a different personality (as it relates to
+dancing). If the leader simply leads every dance the same way, those dances
+are not as good as they could be. An "advanced" leader leading a beginner
+follower in a lot of complicated movements she's not capable of following yet
+turns into a complete mess. He goes away from the dance feeling bored or
+frustrated (or worse, arrogant) and she goes away feeling confused,
+discouraged or angry. This is not a good thing.
+
+Paying attention to the follow's level is critical. I'm not saying "only do
+moves that the follower has learned and can easily follow." Pushing the
+follower slightly beyond her comfortable, "automatic" level is wonderful and
+helps her immensely; but going totally over her head and confusing the hell
+out of her just so he can show off (to her or others) is obnoxious. This also
+works in reverse: followers, please challenge your leaders but be mindful of
+their skill.
+
+Experience isn't the only difference between followers. Each follower has her
+own style that won't always fit perfectly with the leader's personal style.
+Adjusting his style to mesh better with hers makes the connection between
+partners so much better, which makes the dance that much more fun. This also
+works both ways. Followers are generally better at "listening" to their
+partner because it's their main job; if a lead makes an effort to really
+listen to the follow and change his leading to incorporate her ideas,
+personality, style and level it makes an enormous difference.
+
+The point I'm trying to make is that "leading" a follower is not just leading.
+It's paying attention to the follower and leading *her*.
+
--- a/content/blog/2009/01/deploying-site-fabric-and-mercurial.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,319 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Deploying with Fabric &amp; Mercurial"
-    snip: "Trimming typing."
-    created: 2009-01-15 20:51:09
-%}
-
-{% block article %}
-
-Earlier tonight I added support for the [Mint][] [Bird Feeder][] plugin to my
-site's [RSS feeds][]. Bird Feeder isn't designed to work with [Django][] so I
-had to change a few things to get it up and running. I mostly followed the
-[instructions on
-Hicks-Wright.net](http://hicks-wright.net/blog/minty-django-feeds/) with a few
-tweaks.
-
-While I was trying to get things running smoothly I had to redeploy the site a
-bunch of times so I could test the changes I made. If I were simply FTP'ing
-the files over each time I wanted to redeploy it would have been a huge pain.
-Fortunately, I have another way to do it that cuts down on my typing.
-
-[Mint]: http://haveamint.com
-[Bird Feeder]: http://haveamint.com/peppermill/pepper/11/bird_feeder/
-[RSS feeds]: /rss/
-[Django]: {{links.django}}
-
-[TOC]
-
-My Basic Deployment Steps
--------------------------
-
-The code for my site is stored in a Mercurial repository. There are actually
-three copies of the repository that I use:
-
-* One is on my local machine, which I commit to as I make changes.
-* One is on [BitBucket][], which I use to share the code with the public.
-* One is on my host's webserver, and is what actually gets served as the website.
-
-When I'm ready to deploy a new version of the site, I push the changes I've
-made on my local repository to the one on BitBucket, then pull the changes
-from BitBucket down to the server. Using push/pull means I don't have to worry
-about transferring the files myself. Using BitBucket in the middle (instead of
-going right from my local machine to the server) means I don't have to worry
-about serving either repository myself and dealing with port forwarding or
-security issues.
-
-[BitBucket]: http://bitbucket.org
-
-Putting BitBucket in the Middle
--------------------------------
-
-Using BitBucket as an intermediate repository is actually fairly simple. Here
-are the basic steps I use to get a project up and running like this.
-
-First, create a new repository on BitBucket. Make sure the name is what you
-want. Feel free to make it private if you just want it for this, or public if
-you want to [go open source][].
-
-[go open source]: /blog/entry/2009/1/13/going-open-source/
-
-### Set Up Your Local Machine
-
-Clone this new, empty repository to your local machine. If you already have
-code written you'll need to copy it into this folder after cloning. I don't
-know if there's a way to push a brand-new repository to BitBucket; if you know
-how please tell me.
-
-On your local machine, edit the `.hg/hgrc` file in the repository and change
-the default path to:
-
-    :::ini
-    default = ssh://hg@bitbucket.org/username/repositoryname/
-
-That will let you push/pull to and from BitBucket over SSH. Doing it that way
-means you can use public/private key authentication and avoid typing your
-password every single time. A fairly comprehensive guide to that can be found
-[here](http://www.securityfocus.com/infocus/1810). You can ignore the
-server-side configuration; you just need to add your public key on BitBucket's
-account settings page and you should be set.
-
-**UPDATE:**  I didn't realize it before, but BitBucket has a [guide to using SSH with BitBucket](http://bitbucket.org/help/using-ssh/).  It's definitely worth looking at.
-
-Now you should be able to use `hg push` and `hg pull` on your local machine to
-push and pull changes to and from the BitBucket repository. The next step is
-getting it set up on the server side.
-
-### Set Up Your Server
-
-On your server, use `hg clone` to clone the BitBucket repository to wherever
-you want to serve it from. Edit the `.hg/hgrc` file in that one and change the
-default path to the same value as before:
-
-    :::ini
-    default = ssh://hg@bitbucket.org/username/repositoryname/
-
-Once again, set up public/private key authentication; this time between the
-server and BitBucket. You can either copy your public and private keys from
-your local machine to the server (if you trust/own it) or you can create a new
-pair and add its public key to your BitBucket account as well.
-
-While you're at it, set up public/private key authentication to go from your
-local machine to your server too. It'll pay off in the long run.
-
-Now that you've got both sides working, you can develop and deploy like so:
-
-* Make changes on your local machine, committing as you go.
-* Push the changes to BitBucket.
-* SSH into your server and pull the changes down.
-* Restart the web server process if necessary.
-
-Not too bad! Instead of manually managing file transfers you can let Mercurial
-do it for you. It'll only pull down the files that have changed, and will
-always put them in exactly the right spot. That's pretty convenient, but we
-can do better.
-
-Weaving it All Together with Fabric
------------------------------------
-
-Being able to push and pull is all well and good, but that's still a lot of
-typing. You need to enter a command to push your changes, a command to SSH to
-the server, a command to change to the deploy directory, a command to pull the
-changes, and a command to restart the server process. That's five commands,
-which is four commands too many for me.
-
-To automate the process, I use the wonderful [Fabric][] tool. If you haven't
-seen it before you should take a look. To follow along with the rest of the
-section you should read the examples on the site and install Fabric on your
-local machine.
-
-### My Current Setup
-
-Here's the fabfile I use for deploying my site to my host ([WebFaction][]).
-It's pretty specific to my needs but I'm sure it will give you an idea of
-where to start.
-
-[Fabric]: {{links.fabric}}
-[WebFaction]: {{links.webfaction}}
-
-    :::python
-    def prod():
-        """Set the target to production."""
-        set(fab_hosts=['sjl.webfactional.com'])
-        set(fab_key_filename='/Users/sjl/.ssh/stevelosh')
-        set(remote_app_dir='~/webapps/stevelosh/stevelosh')
-        set(remote_apache_dir='~/webapps/stevelosh/apache2')
-
-    def deploy():
-        """Deploy the site."""
-        require('fab_hosts', provided_by = [prod,])
-        local("hg push")
-        run("cd $(remote_app_dir); hg pull; hg update")
-        run("cd $(remote_app_dir); python2.5 manage.py syncdb")
-        run("$(remote_apache_dir)/bin/stop; sleep 1; $(remote_apache_dir)/bin/start")
-
-    def debugon():
-        """Turn debug mode on for the production server."""
-        require('fab_hosts', provided_by = [prod,])
-        run("cd $(remote_app_dir); sed -i -e 's/DEBUG = .*/DEBUG = True/' deploy.py")
-        run("$(remote_apache_dir)/bin/stop; sleep 1; $(remote_apache_dir)/bin/start")
-
-    def debugoff():
-        """Turn debug mode off for the production server."""
-        require('fab_hosts', provided_by = [prod,])
-        run("cd $(remote_app_dir); sed -i -e 's/DEBUG = .*/DEBUG = False/' deploy.py")
-        run("$(remote_apache_dir)/bin/stop; sleep 1; $(remote_apache_dir)/bin/start")
-
-When I'm finished committing to my local repository and I want to deploy the
-site, I just use the command `fab prod deploy` on my local machine. Fabric
-pushes my local repository to BitBucket, logs into the server (with my public
-key&mdash;no typing in passwords), pulls down the new changes from BitBucket
-and restarts the server process.
-
-I also set up a couple of debug commands so I can type `fab prod debugon` and
-`fab prod debugoff` to change the `settings.DEBUG` option of my Django app.
-Sometimes it's useful to turn on debug to find out exactly why a page is
-breaking on the server.
-
-### Extending It
-
-The reason I split off the `prod` command is so I can set up a separate test
-app (on the server) in the future and reuse the `deploy` and `debug` commands.
-All I'd need to do is add a `test` command, which might look something like
-this:
-
-    :::python
-    def test():
-        """Set the target to test."""
-        set(fab_hosts=['sjl.webfactional.com'])
-        set(fab_key_filename='/Users/sjl/.ssh/stevelosh')
-        set(remote_app_dir = '~/webapps/stevelosh-test/stevelosh')
-        set(remote_apache_dir = '~/webapps/stevelosh-test/apache2')
-
-Deploying the test site would then be a simple `fab test deploy` command.
-
-Why Should You Try This?
-------------------------
-
-After you've gotten all of this set up the first time it will start saving you
-time every time you deploy. It also prevents stupid mistakes like FTP'ing your
-files to the wrong directory on the server. It frees you from those headaches
-and lets you concentrate on the real work to be done instead of the busywork.
-Plus setting it up again for a second project is a breeze after you've done it
-once.
-
-Obviously the exact details of this won't be a perfect fit for everyone. Maybe
-you prefer using git and [GitHub][] for version control. I'm sure there's a
-similar way to automate the process on that side of the fence. If you decide
-to write something about the details of that please let me know and I'll link
-it here.
-
-My hope is that this will at least give you some ideas about saving yourself
-some time. If that helps you create better websites, I'll be happy. Please
-feel free to find me on [Twitter][twsl] with any questions or thoughts you have!
-
-[GitHub]: http://github.com/
-[twsl]: {{links.twsl}}
-
-Update
-------
-
-It's been over a year since I originally wrote this entry and I've learned
-quite a bit since then. I don't have the time right now to go back and rewrite
-the entire article, but here are some of the main things that have changed:
-
-* I now use [virtualenv and pip][venv] when deploying Django sites. It
-  sandboxes each site very nicely and makes it easy to deploy.
-
-[venv]: http://clemesha.org/blog/2009/jul/05/modern-python-hacker-tools-virtualenv-fabric-pip/
-
-* I no longer go "through" BitBucket when deploying -- I push directly from my
-  local machine to the server. This eliminates an extra step, and I can always
-  push to BitBucket once I'm done with a series of changes.
-
-* Fabric is completely different. "Ownership/maintenance" of the project has
-  transferred to a new person and the format of fabfiles has drastically
-  changed.
-
-Here's a sample fabfile from one of the projects I'm working on now. There are
-no comments, but I think most things should be self-explanitory. If you have
-any questions just find me on [Twitter][twsl] and I'll be glad to answer them.
-
-    from fabric.api import *
-    
-    REMOTE_HG_PATH = '/home/sjl/bin/hg'
-    
-    def prod():
-        """Set the target to production."""
-        env.hosts = ['sjl.webfactional.com']
-        env.remote_app_dir = 'webapps/SAMPLE/SAMPLE'
-        env.remote_apache_dir = '~/webapps/SAMPLE/apache2'
-        env.local_settings_file = 'local_settings-prod.py'
-        env.remote_push_dest = 'ssh://webf/%s' % env.remote_app_dir
-        env.tag = 'production'
-        env.venv_name = 'SAMPLE_prod'
-    
-    def test():
-        """Set the target to test."""
-        env.hosts = ['sjl.webfactional.com']
-        env.remote_app_dir = 'webapps/SAMPLE_test/lindyhub'
-        env.remote_apache_dir = '~/webapps/SAMPLE_test/apache2'
-        env.local_settings_file = 'local_settings-test.py'
-        env.remote_push_dest = 'ssh://webf/%s' % env.remote_app_dir
-        env.tag = 'test'
-        env.venv_name = 'SAMPLE_test'
-    
-    def deploy():
-        """Deploy the site.
-        
-        This will also add a local Mercurial tag with the name of the environment
-        (test or production) to your the local repository, and then sync it to
-        the remote repo as well.
-        
-        This is nice because you can easily see which changeset is currently
-        deployed to a particular environment in 'hg glog'.
-        """
-        require('hosts', provided_by=[prod, test])
-        require('remote_app_dir', provided_by=[prod, test])
-        require('remote_apache_dir', provided_by=[prod, test])
-        require('local_settings_file', provided_by=[prod, test])
-        require('remote_push_dest', provided_by=[prod, test])
-        require('tag', provided_by=[prod, test])
-        require('venv_name', provided_by=[prod, test])
-        
-        local("hg tag --local --force %s" % env.tag)
-        local("hg push %s --remotecmd %s" % (env.remote_push_dest, REMOTE_HG_PATH))
-        put(".hg/localtags", "%s/.hg/localtags" % env.remote_app_dir)
-        run("cd %s; hg update -C %s" % (env.remote_app_dir, env.tag))
-        put("%s" % env.local_settings_file, "%s/local_settings.py" % env.remote_app_dir)
-        
-        run("workon %s; cd %s; python manage.py syncdb" % (env.venv_name, env.remote_app_dir))
-        restart()
-    
-    def restart():
-        """Restart apache on the server."""
-        require('hosts', provided_by=[prod, test])
-        require('remote_apache_dir', provided_by=[prod, test])
-        
-        run("%s/bin/stop; sleep 2; %s/bin/start" % (env.remote_apache_dir, env.remote_apache_dir))
-    
-    def debugon():
-        """Turn debug mode on for the server."""
-        require('hosts', provided_by=[prod, test])
-        require('remote_app_dir', provided_by=[prod, test])
-        require('remote_apache_dir', provided_by=[prod, test])
-        
-        run("cd %s; sed -i -e 's/DEBUG = .*/DEBUG = True/' local_settings.py" % env.remote_app_dir)
-        restart()
-    
-    def debugoff():
-        """Turn debug mode off for the server."""
-        require('hosts', provided_by=[prod, test])
-        require('remote_app_dir', provided_by=[prod, test])
-        require('remote_apache_dir', provided_by=[prod, test])
-        
-        run("cd %s; sed -i -e 's/DEBUG = .*/DEBUG = False/' local_settings.py" % env.remote_app_dir)
-        restart()
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/01/deploying-site-fabric-and-mercurial.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,320 @@
++++
+title = "Deploying with Fabric & Mercurial"
+snip = "Trimming typing."
+date = 2009-01-15T20:51:09Z
+draft = false
+
++++
+
+Earlier tonight I added support for the [Mint][] [Bird Feeder][] plugin to my
+site's [RSS feeds][]. Bird Feeder isn't designed to work with [Django][] so I
+had to change a few things to get it up and running. I mostly followed the
+[instructions on
+Hicks-Wright.net](http://hicks-wright.net/blog/minty-django-feeds/) with a few
+tweaks.
+
+While I was trying to get things running smoothly I had to redeploy the site a
+bunch of times so I could test the changes I made. If I were simply FTP'ing
+the files over each time I wanted to redeploy it would have been a huge pain.
+Fortunately, I have another way to do it that cuts down on my typing.
+
+[Mint]: http://haveamint.com
+[Bird Feeder]: http://haveamint.com/peppermill/pepper/11/bird_feeder/
+[RSS feeds]: /rss/
+[Django]: {{links.django}}
+
+{{% toc %}}
+
+My Basic Deployment Steps
+-------------------------
+
+The code for my site is stored in a Mercurial repository. There are actually
+three copies of the repository that I use:
+
+* One is on my local machine, which I commit to as I make changes.
+* One is on [BitBucket][], which I use to share the code with the public.
+* One is on my host's webserver, and is what actually gets served as the website.
+
+When I'm ready to deploy a new version of the site, I push the changes I've
+made on my local repository to the one on BitBucket, then pull the changes
+from BitBucket down to the server. Using push/pull means I don't have to worry
+about transferring the files myself. Using BitBucket in the middle (instead of
+going right from my local machine to the server) means I don't have to worry
+about serving either repository myself and dealing with port forwarding or
+security issues.
+
+[BitBucket]: http://bitbucket.org
+
+Putting BitBucket in the Middle
+-------------------------------
+
+Using BitBucket as an intermediate repository is actually fairly simple. Here
+are the basic steps I use to get a project up and running like this.
+
+First, create a new repository on BitBucket. Make sure the name is what you
+want. Feel free to make it private if you just want it for this, or public if
+you want to [go open source][].
+
+[go open source]: /blog/entry/2009/1/13/going-open-source/
+
+### Set Up Your Local Machine
+
+Clone this new, empty repository to your local machine. If you already have
+code written you'll need to copy it into this folder after cloning. I don't
+know if there's a way to push a brand-new repository to BitBucket; if you know
+how please tell me.
+
+On your local machine, edit the `.hg/hgrc` file in the repository and change
+the default path to:
+
+```ini
+default = ssh://hg@bitbucket.org/username/repositoryname/
+```
+
+That will let you push/pull to and from BitBucket over SSH. Doing it that way
+means you can use public/private key authentication and avoid typing your
+password every single time. A fairly comprehensive guide to that can be found
+[here](http://www.securityfocus.com/infocus/1810). You can ignore the
+server-side configuration; you just need to add your public key on BitBucket's
+account settings page and you should be set.
+
+**UPDATE:**  I didn't realize it before, but BitBucket has a [guide to using SSH with BitBucket](http://bitbucket.org/help/using-ssh/).  It's definitely worth looking at.
+
+Now you should be able to use `hg push` and `hg pull` on your local machine to
+push and pull changes to and from the BitBucket repository. The next step is
+getting it set up on the server side.
+
+### Set Up Your Server
+
+On your server, use `hg clone` to clone the BitBucket repository to wherever
+you want to serve it from. Edit the `.hg/hgrc` file in that one and change the
+default path to the same value as before:
+
+```ini
+default = ssh://hg@bitbucket.org/username/repositoryname/
+```
+
+Once again, set up public/private key authentication; this time between the
+server and BitBucket. You can either copy your public and private keys from
+your local machine to the server (if you trust/own it) or you can create a new
+pair and add its public key to your BitBucket account as well.
+
+While you're at it, set up public/private key authentication to go from your
+local machine to your server too. It'll pay off in the long run.
+
+Now that you've got both sides working, you can develop and deploy like so:
+
+* Make changes on your local machine, committing as you go.
+* Push the changes to BitBucket.
+* SSH into your server and pull the changes down.
+* Restart the web server process if necessary.
+
+Not too bad! Instead of manually managing file transfers you can let Mercurial
+do it for you. It'll only pull down the files that have changed, and will
+always put them in exactly the right spot. That's pretty convenient, but we
+can do better.
+
+Weaving it All Together with Fabric
+-----------------------------------
+
+Being able to push and pull is all well and good, but that's still a lot of
+typing. You need to enter a command to push your changes, a command to SSH to
+the server, a command to change to the deploy directory, a command to pull the
+changes, and a command to restart the server process. That's five commands,
+which is four commands too many for me.
+
+To automate the process, I use the wonderful [Fabric][] tool. If you haven't
+seen it before you should take a look. To follow along with the rest of the
+section you should read the examples on the site and install Fabric on your
+local machine.
+
+### My Current Setup
+
+Here's the fabfile I use for deploying my site to my host ([WebFaction][]).
+It's pretty specific to my needs but I'm sure it will give you an idea of
+where to start.
+
+[Fabric]: {{links.fabric}}
+[WebFaction]: {{links.webfaction}}
+
+```python
+def prod():
+    """Set the target to production."""
+    set(fab_hosts=['sjl.webfactional.com'])
+    set(fab_key_filename='/Users/sjl/.ssh/stevelosh')
+    set(remote_app_dir='~/webapps/stevelosh/stevelosh')
+    set(remote_apache_dir='~/webapps/stevelosh/apache2')
+
+def deploy():
+    """Deploy the site."""
+    require('fab_hosts', provided_by = [prod,])
+    local("hg push")
+    run("cd $(remote_app_dir); hg pull; hg update")
+    run("cd $(remote_app_dir); python2.5 manage.py syncdb")
+    run("$(remote_apache_dir)/bin/stop; sleep 1; $(remote_apache_dir)/bin/start")
+
+def debugon():
+    """Turn debug mode on for the production server."""
+    require('fab_hosts', provided_by = [prod,])
+    run("cd $(remote_app_dir); sed -i -e 's/DEBUG = .*/DEBUG = True/' deploy.py")
+    run("$(remote_apache_dir)/bin/stop; sleep 1; $(remote_apache_dir)/bin/start")
+
+def debugoff():
+    """Turn debug mode off for the production server."""
+    require('fab_hosts', provided_by = [prod,])
+    run("cd $(remote_app_dir); sed -i -e 's/DEBUG = .*/DEBUG = False/' deploy.py")
+    run("$(remote_apache_dir)/bin/stop; sleep 1; $(remote_apache_dir)/bin/start")
+```
+
+When I'm finished committing to my local repository and I want to deploy the
+site, I just use the command `fab prod deploy` on my local machine. Fabric
+pushes my local repository to BitBucket, logs into the server (with my public
+key&mdash;no typing in passwords), pulls down the new changes from BitBucket
+and restarts the server process.
+
+I also set up a couple of debug commands so I can type `fab prod debugon` and
+`fab prod debugoff` to change the `settings.DEBUG` option of my Django app.
+Sometimes it's useful to turn on debug to find out exactly why a page is
+breaking on the server.
+
+### Extending It
+
+The reason I split off the `prod` command is so I can set up a separate test
+app (on the server) in the future and reuse the `deploy` and `debug` commands.
+All I'd need to do is add a `test` command, which might look something like
+this:
+
+```python
+def test():
+    """Set the target to test."""
+    set(fab_hosts=['sjl.webfactional.com'])
+    set(fab_key_filename='/Users/sjl/.ssh/stevelosh')
+    set(remote_app_dir = '~/webapps/stevelosh-test/stevelosh')
+    set(remote_apache_dir = '~/webapps/stevelosh-test/apache2')
+```
+
+Deploying the test site would then be a simple `fab test deploy` command.
+
+Why Should You Try This?
+------------------------
+
+After you've gotten all of this set up the first time it will start saving you
+time every time you deploy. It also prevents stupid mistakes like FTP'ing your
+files to the wrong directory on the server. It frees you from those headaches
+and lets you concentrate on the real work to be done instead of the busywork.
+Plus setting it up again for a second project is a breeze after you've done it
+once.
+
+Obviously the exact details of this won't be a perfect fit for everyone. Maybe
+you prefer using git and [GitHub][] for version control. I'm sure there's a
+similar way to automate the process on that side of the fence. If you decide
+to write something about the details of that please let me know and I'll link
+it here.
+
+My hope is that this will at least give you some ideas about saving yourself
+some time. If that helps you create better websites, I'll be happy. Please
+feel free to find me on [Twitter][twsl] with any questions or thoughts you have!
+
+[GitHub]: http://github.com/
+[twsl]: {{links.twsl}}
+
+Update
+------
+
+It's been over a year since I originally wrote this entry and I've learned
+quite a bit since then. I don't have the time right now to go back and rewrite
+the entire article, but here are some of the main things that have changed:
+
+* I now use [virtualenv and pip][venv] when deploying Django sites. It
+  sandboxes each site very nicely and makes it easy to deploy.
+
+[venv]: http://clemesha.org/blog/2009/jul/05/modern-python-hacker-tools-virtualenv-fabric-pip/
+
+* I no longer go "through" BitBucket when deploying — I push directly from my
+  local machine to the server. This eliminates an extra step, and I can always
+  push to BitBucket once I'm done with a series of changes.
+
+* Fabric is completely different. "Ownership/maintenance" of the project has
+  transferred to a new person and the format of fabfiles has drastically
+  changed.
+
+Here's a sample fabfile from one of the projects I'm working on now. There are
+no comments, but I think most things should be self-explanitory. If you have
+any questions just find me on [Twitter][twsl] and I'll be glad to answer them.
+
+    from fabric.api import *
+
+    REMOTE_HG_PATH = '/home/sjl/bin/hg'
+
+    def prod():
+        """Set the target to production."""
+        env.hosts = ['sjl.webfactional.com']
+        env.remote_app_dir = 'webapps/SAMPLE/SAMPLE'
+        env.remote_apache_dir = '~/webapps/SAMPLE/apache2'
+        env.local_settings_file = 'local_settings-prod.py'
+        env.remote_push_dest = 'ssh://webf/%s' % env.remote_app_dir
+        env.tag = 'production'
+        env.venv_name = 'SAMPLE_prod'
+
+    def test():
+        """Set the target to test."""
+        env.hosts = ['sjl.webfactional.com']
+        env.remote_app_dir = 'webapps/SAMPLE_test/lindyhub'
+        env.remote_apache_dir = '~/webapps/SAMPLE_test/apache2'
+        env.local_settings_file = 'local_settings-test.py'
+        env.remote_push_dest = 'ssh://webf/%s' % env.remote_app_dir
+        env.tag = 'test'
+        env.venv_name = 'SAMPLE_test'
+
+    def deploy():
+        """Deploy the site.
+
+        This will also add a local Mercurial tag with the name of the environment
+        (test or production) to your the local repository, and then sync it to
+        the remote repo as well.
+
+        This is nice because you can easily see which changeset is currently
+        deployed to a particular environment in 'hg glog'.
+        """
+        require('hosts', provided_by=[prod, test])
+        require('remote_app_dir', provided_by=[prod, test])
+        require('remote_apache_dir', provided_by=[prod, test])
+        require('local_settings_file', provided_by=[prod, test])
+        require('remote_push_dest', provided_by=[prod, test])
+        require('tag', provided_by=[prod, test])
+        require('venv_name', provided_by=[prod, test])
+
+        local("hg tag --local --force %s" % env.tag)
+        local("hg push %s --remotecmd %s" % (env.remote_push_dest, REMOTE_HG_PATH))
+        put(".hg/localtags", "%s/.hg/localtags" % env.remote_app_dir)
+        run("cd %s; hg update -C %s" % (env.remote_app_dir, env.tag))
+        put("%s" % env.local_settings_file, "%s/local_settings.py" % env.remote_app_dir)
+
+        run("workon %s; cd %s; python manage.py syncdb" % (env.venv_name, env.remote_app_dir))
+        restart()
+
+    def restart():
+        """Restart apache on the server."""
+        require('hosts', provided_by=[prod, test])
+        require('remote_apache_dir', provided_by=[prod, test])
+
+        run("%s/bin/stop; sleep 2; %s/bin/start" % (env.remote_apache_dir, env.remote_apache_dir))
+
+    def debugon():
+        """Turn debug mode on for the server."""
+        require('hosts', provided_by=[prod, test])
+        require('remote_app_dir', provided_by=[prod, test])
+        require('remote_apache_dir', provided_by=[prod, test])
+
+        run("cd %s; sed -i -e 's/DEBUG = .*/DEBUG = True/' local_settings.py" % env.remote_app_dir)
+        restart()
+
+    def debugoff():
+        """Turn debug mode off for the server."""
+        require('hosts', provided_by=[prod, test])
+        require('remote_app_dir', provided_by=[prod, test])
+        require('remote_apache_dir', provided_by=[prod, test])
+
+        run("cd %s; sed -i -e 's/DEBUG = .*/DEBUG = False/' local_settings.py" % env.remote_app_dir)
+        restart()
+
--- a/content/blog/2009/01/going-open-source.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,138 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Going Open Source"
-    snip: "Why I’m making the code to this website public."
-    created: 2009-01-13 20:08:56
-%}
-
-{% block article %}
-
-Well, I've finally taken the plunge and made this site open source. It's held
-in a [Mercurial][] repository, but you can view or download the source code
-from <http://bitbucket.org/sjl/stevelosh/> without any special tools.
-
-The site was built with the [Django][] framework. If you want to know more
-check out the [project page][]. This post isn't going to duplicate what's
-there; instead I want to write about why I made the site open source at all.
-There are a couple of main reasons, and not *all* of them are selfish!
-
-[Mercurial]: {{links.mercurial}}
-[Django]: {{links.django}}
-[project page]: /projects/stevelosh-com
-
-I Get More Traffic
-------------------
-
-The first reason to make a site open source is to try to get more hits. You
-certainly don't *lose* any hits from doing it, and when developers find your
-link on places like [DjangoSites][] they might be more inclined to visit if
-they knew they could look at the source code later.
-
-You also have the chance to post on [Twitter][], [Tumblr][], or other places
-about the source code of the site. Each of those posts can expose more people
-to the website. It's easy to overdo this though. I heartily agree with the
-sentiments of [howtousetwitterformarketingandpr.com][htutfmapr] on that issue.
-
-Don't worry, I won't be obnoxious about it.
-
-[DjangoSites]: http://djangosites.org/
-[Twitter]: http://twitter.com/
-[Tumblr]: http://tumblr.com/
-[htutfmapr]: http://howtousetwitterformarketingandpr.com
-
-I Can Give Back to the (Programming) Community
-----------------------------------------------
-
-Yeah, I know.  It sounds cliched, but it's true.  
-
-The open source community has produced a *ridiculous* amount of software, some
-of which we use every day. Software like [Apache][], [Django][], and countless
-others simply wouldn't exist in anything remotely close to their current
-forms.
-
-Being able to look at the source code for a particular project can be
-extremely helpful to someone trying to learn how to do something similar.
-Instead of firing up an email client and sending a message to the creator they
-can simply look at how it works themselves. They can download it, tweak it,
-break it, and figure out what makes it tick. There's no substitute for that.
-
-I strongly believe that the world would be a better place if everyone shared
-their knowledge (in all fields) and we all learned from each other. In some
-cases it's simply not practical, but more often than not I think people want
-to horde their knowledge and feel superior. Sure, that might be nice for your
-ego, but does it really make the world a happier, more beautiful place to
-live?
-
-[Apache]: http://apache.org/
-
-I Might Get Free Code!
-----------------------
-
-Well, probably not, but who knows? Maybe some developer has a lot of free time
-on his or her hands?
-
-Distributed version control systems like [Mercurial][] make it extremely easy
-to help out with open source projects. For example, if you were looking
-through my code and saw a bug that you wanted to fix, you could do the
-following:
-
-* Clone the repository to your own machine. * Fix the bug in that local copy,
-committing to your local repository as you go. * Go back to the website and
-click the "Pull Request" button. * I review the changes. * If I like them I
-press a button to merge them into the main repository.
-
-Once the changes are in the main repository I just run a single script to
-redeploy the site as usual and the changes are live. It's really an almost
-painless process. Compare that to something like Subversion or (ick) CVS:
-
-* Check out the repository to your own machine.
-* Fix the bug in that local copy, without committing (don't mess up!).
-* Create a patch using diff or something similar.
-* Email me the patch.
-* I review the changes.
-* If I like them I check out a fresh copy of the repository.
-* I apply the patch to this copy.
-* I merge the patch back into the main repository.
-
-It's much more difficult because I don't want to just give any anonymous
-person commit access to my repository.
-
-It Makes Me Fix My Damn Code
-----------------------------
-
-This is probably the most tangible and important benefit of my open sourcing
-this site. It forced me to rewrite parts of the code that weren't secure and
-do it the right way.
-
-Passwords stored in source control? Yeah, *definitely* a bad thing.
-
-Of course, it *was* kind of a pain in the ass to refactor a bunch of stuff.
-Really, though, the main problem I had was my own procrastination and going
-open source was a good nudge. Plus when I start work on another site I'll know
-how to do it right the first time.
-
-Aside from major security and privacy issues, it also gives me a big incentive
-to clean up my code and make it more elegant. Clean, elegant code makes me
-happy. It's less likely to have bugs (because there are fewer places for them
-to hide) and it's far easier to maintain in the long run.
-
-It's also simply more fun to read and work with.
-
-You Should Probably Try It
---------------------------
-
-Obviously not all software is appropriate for open sourcing, but if you've got
-a pet project that you've been working and you think it might benefit from a
-few more sets of eyes, try it!
-
-You don't need to spend money or configure much of anything to share your
-code; sites like [BitBucket][] and [GitHub][] offer free hosting and great
-interfaces for repositories of open source code.
-
-If you have any questions or comments I'd love to hear them!
-
-[BitBucket]: http://bitbucket.org/
-[GitHub]: http://github.com/
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/01/going-open-source.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,135 @@
++++
+title = "Going Open Source"
+snip = "Why I’m making the code to this website public."
+date = 2009-01-13T20:08:56Z
+draft = false
+
++++
+
+Well, I've finally taken the plunge and made this site open source. It's held
+in a [Mercurial][] repository, but you can view or download the source code
+from <http://bitbucket.org/sjl/stevelosh/> without any special tools.
+
+The site was built with the [Django][] framework. If you want to know more
+check out the [project page][]. This post isn't going to duplicate what's
+there; instead I want to write about why I made the site open source at all.
+There are a couple of main reasons, and not *all* of them are selfish!
+
+[Mercurial]: {{links.mercurial}}
+[Django]: {{links.django}}
+[project page]: /projects/stevelosh-com
+
+I Get More Traffic
+------------------
+
+The first reason to make a site open source is to try to get more hits. You
+certainly don't *lose* any hits from doing it, and when developers find your
+link on places like [DjangoSites][] they might be more inclined to visit if
+they knew they could look at the source code later.
+
+You also have the chance to post on [Twitter][], [Tumblr][], or other places
+about the source code of the site. Each of those posts can expose more people
+to the website. It's easy to overdo this though. I heartily agree with the
+sentiments of [howtousetwitterformarketingandpr.com][htutfmapr] on that issue.
+
+Don't worry, I won't be obnoxious about it.
+
+[DjangoSites]: http://djangosites.org/
+[Twitter]: http://twitter.com/
+[Tumblr]: http://tumblr.com/
+[htutfmapr]: http://howtousetwitterformarketingandpr.com
+
+I Can Give Back to the (Programming) Community
+----------------------------------------------
+
+Yeah, I know.  It sounds cliched, but it's true.  
+
+The open source community has produced a *ridiculous* amount of software, some
+of which we use every day. Software like [Apache][], [Django][], and countless
+others simply wouldn't exist in anything remotely close to their current
+forms.
+
+Being able to look at the source code for a particular project can be
+extremely helpful to someone trying to learn how to do something similar.
+Instead of firing up an email client and sending a message to the creator they
+can simply look at how it works themselves. They can download it, tweak it,
+break it, and figure out what makes it tick. There's no substitute for that.
+
+I strongly believe that the world would be a better place if everyone shared
+their knowledge (in all fields) and we all learned from each other. In some
+cases it's simply not practical, but more often than not I think people want
+to horde their knowledge and feel superior. Sure, that might be nice for your
+ego, but does it really make the world a happier, more beautiful place to
+live?
+
+[Apache]: http://apache.org/
+
+I Might Get Free Code!
+----------------------
+
+Well, probably not, but who knows? Maybe some developer has a lot of free time
+on his or her hands?
+
+Distributed version control systems like [Mercurial][] make it extremely easy
+to help out with open source projects. For example, if you were looking
+through my code and saw a bug that you wanted to fix, you could do the
+following:
+
+* Clone the repository to your own machine. * Fix the bug in that local copy,
+committing to your local repository as you go. * Go back to the website and
+click the "Pull Request" button. * I review the changes. * If I like them I
+press a button to merge them into the main repository.
+
+Once the changes are in the main repository I just run a single script to
+redeploy the site as usual and the changes are live. It's really an almost
+painless process. Compare that to something like Subversion or (ick) CVS:
+
+* Check out the repository to your own machine.
+* Fix the bug in that local copy, without committing (don't mess up!).
+* Create a patch using diff or something similar.
+* Email me the patch.
+* I review the changes.
+* If I like them I check out a fresh copy of the repository.
+* I apply the patch to this copy.
+* I merge the patch back into the main repository.
+
+It's much more difficult because I don't want to just give any anonymous
+person commit access to my repository.
+
+It Makes Me Fix My Damn Code
+----------------------------
+
+This is probably the most tangible and important benefit of my open sourcing
+this site. It forced me to rewrite parts of the code that weren't secure and
+do it the right way.
+
+Passwords stored in source control? Yeah, *definitely* a bad thing.
+
+Of course, it *was* kind of a pain in the ass to refactor a bunch of stuff.
+Really, though, the main problem I had was my own procrastination and going
+open source was a good nudge. Plus when I start work on another site I'll know
+how to do it right the first time.
+
+Aside from major security and privacy issues, it also gives me a big incentive
+to clean up my code and make it more elegant. Clean, elegant code makes me
+happy. It's less likely to have bugs (because there are fewer places for them
+to hide) and it's far easier to maintain in the long run.
+
+It's also simply more fun to read and work with.
+
+You Should Probably Try It
+--------------------------
+
+Obviously not all software is appropriate for open sourcing, but if you've got
+a pet project that you've been working and you think it might benefit from a
+few more sets of eyes, try it!
+
+You don't need to spend money or configure much of anything to share your
+code; sites like [BitBucket][] and [GitHub][] offer free hosting and great
+interfaces for repositories of open source code.
+
+If you have any questions or comments I'd love to hear them!
+
+[BitBucket]: http://bitbucket.org/
+[GitHub]: http://github.com/
+
--- a/content/blog/2009/01/site-redesign.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Site Redesign"
-    snip: "Yeah, I know.  Again."
-    created: 2009-01-11 17:58:23
-%}
-
-{% block article %}
-
-Well, I've redesigned the site again. This time it's all me. I built the site
-from the ground up with [Django][] and [Python][]. Why? Several reasons:
-
-* I already pay for hosting at [WebFaction][] for other sites so also paying
-  [Squarespace][] for my personal one was too wasteful.
-* I wanted to practice designing another site with [Django][].
-* I wanted more flexibility than [Squarespace][] supports and I'm not afraid
-  to get my hands dirty with code.
-
-If you want to know more about how I created the site, check out the site's
-[project page][].
-
-Moving over
------------
-
-I've tried to make transitioning to the new site as easy as possible. For
-example, I set up the urls so that links to the entries on the old blog will
-redirect to entries on the new one if they exist.
-
-Coming soon
------------
-
-I'm going to work on porting over more of the old blog entries in the next day
-or two. I don't want to bring them all over; just the best ones.
-
-I'm also going to implement an RSS feed that will encompass projects and blog
-entries.
-
-Let me know what you think!
-
-[Python]: {{links.python}}
-[Django]: {{links.django}}
-[WebFaction]: {{links.webfaction}}
-[Squarespace]: http://www.squarespace.com/
-[project page]: /projects/stevelosh-com
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/01/site-redesign.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,44 @@
++++
+title = "Site Redesign"
+snip = "Yeah, I know.  Again."
+date = 2009-01-11T17:58:23Z
+draft = false
+
++++
+
+Well, I've redesigned the site again. This time it's all me. I built the site
+from the ground up with [Django][] and [Python][]. Why? Several reasons:
+
+* I already pay for hosting at [WebFaction][] for other sites so also paying
+  [Squarespace][] for my personal one was too wasteful.
+* I wanted to practice designing another site with [Django][].
+* I wanted more flexibility than [Squarespace][] supports and I'm not afraid
+  to get my hands dirty with code.
+
+If you want to know more about how I created the site, check out the site's
+[project page][].
+
+Moving over
+-----------
+
+I've tried to make transitioning to the new site as easy as possible. For
+example, I set up the urls so that links to the entries on the old blog will
+redirect to entries on the new one if they exist.
+
+Coming soon
+-----------
+
+I'm going to work on porting over more of the old blog entries in the next day
+or two. I don't want to bring them all over; just the best ones.
+
+I'm also going to implement an RSS feed that will encompass projects and blog
+entries.
+
+Let me know what you think!
+
+[Python]: {{links.python}}
+[Django]: {{links.django}}
+[WebFaction]: {{links.webfaction}}
+[Squarespace]: http://www.squarespace.com/
+[project page]: /projects/stevelosh-com
+
--- a/content/blog/2009/02/how-and-why-i-dj.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "How &amp; Why I DJ"
-    snip: "I like playing music for dancers."
-    created: 2009-02-06 17:53:44
-%}
-
-{% block article %}
-
-I've been DJ'ing at swing and blues dances for a while now. It's extremely fun
-and rewarding. I've got a system that I use to keep myself sane while doing it
-and I felt like sharing. Let me know what you think!
-
-[TOC]
-
-## How I Started
-
-When I was just starting to get really interested in dancing I didn't think
-I'd want to DJ much. I thought it would be a lot of work and that I'd hate
-having to stay near a computer during a dance. It just didn't seem like very
-much fun.
-
-The only reason I began to try my hand at it was because we needed to have
-good music to play at RIT Swing Dance Club when my old roommates and I started
-teaching there. I wanted the other people to have a good time and hear the
-awesome music that we love dancing to. I figured that it didn't need to be a
-big deal; I'd just find some cool music and play it at club.
-
-Once I started, I realized that I really like being able to play great music
-for other people to dance to. It sounds cliche, but it really *is* rewarding.
-There's something special about having a kind of control over an entire dance
-floor.
-
-After I became comfortable DJ'ing at club it was only a matter of time before
-I started [signing up to DJ][ljdj] at [Lindy Jam][] and then playing music at
-our little blues parties. I love it. DJ'ing is good for me &mdash; it forces
-me to look for interesting new music and really *listen* to it to hear how it
-works. Really listening (without dancing) closely to swing or blues music is
-something that I don't think enough dancers do.
-
-## Where Do I Find Music?
-
-Most of the music I play comes from [eMusic][]. It's a great site &mdash; you
-pay $15 and get about 40 tracks per month. That's far cheaper than iTunes and
-it's all DRM-free mp3 files. They have a great collection of jazz and blues
-(and a lot of indie and classical music too). I highly recommend them if
-you're looking for some awesome music.
-
-Previously I've wanted nothing to do with iTunes because of the DRM.
-Thankfully Apple has announced that they've convinced the record labels to
-allow DRM-free downloads of everything. I'll still get most of my music from
-eMusic (it's cheaper) but if they don't have a song I want I'll definitely
-look on iTunes.
-
-As for CDs and vinyl, I do occasionally buy and rip some, but for the most
-part digital music is simply faster, easier, and cheaper to use.
-
-## Sorting My Music
-
-Over the past couple of years I've turned into a pretty organized person. If I
-don't have a good method of sorting and organizing my music I'll go crazy when
-I try to DJ. I've developed a way of organizing everything over the years I've
-been DJ'ing which seems to work pretty well for me.
-
-### "Danceable" Music
-
-The first thing I do when I download a new CD from eMusic is skim each track
-and decide if it's even remotely danceable. If it's got a beat I can dance to
-at all, it goes into my "Lindy & Blues" playlist in iTunes. I don't worry
-about how good the song is &mdash; the important part for me is getting the
-decent songs into that playlist so I don't forget about them.
-
-### Tempo
-
-My next step is tagging danceable songs with BPM (beats per minute)
-information. This is really nice to know when you're out at a dane and
-thinking: "I should play a song that's a bit faster than that last one."
-
-I've experimented with a couple of different methods in the past but they all
-seemed pretty cumbersome. The solution came in the form of this [Tempo
-Widget][] for my Mac's dashboard. Click the button on each beat, double click
-the numbers to save the BPM to the currently playing iTunes song.
-
-That's nice, but it's not enough for a nerd like me. The mouse is so slow;
-what I really needed was a way to use the keyboard for everything so I could
-fly through tagging my songs in less than 15 seconds each. I opened up the
-code for the widget and added a couple things. I can press any key on a beat
-instead of clicking the button, and I can hit Cmd+S to save the BPM to the
-iTunes song instead of double clicking the numbers.
-
-I also use [Quicksilver][] to add keyboard shortcuts to move to the
-next/previous song in iTunes. Now that I've got all that done, when I want to
-tag a bunch of new songs with BPMs I can do this:
-
-1. Start playing the first song and open up the dashboard.
-2. Press any key on each beat until I have a consistent BPM displaying.
-3. Press Cmd+S to save the BPM to the song.
-4. Press Cmd+Option+Ctrl+Right Arrow to move to the next song.
-5. Repeat steps 2-5 for each song.
-
-It usually takes me 15 seconds or less per song and saves me a ton of time (I
-have about 900 songs tagged with BPMs right now!). If you're interested in my
-modified version of the Tempo Widget let me know.
-
-### Rating (Smartly)
-
-Let's face it: some songs are better than others. Some songs are fun to dance
-to, but others almost *force* you out of your seat. I like to be able to
-glance at my playlist and have a rough idea of which *really awesome* songs
-I've got at a specific tempo.
-
-Some people might say: "You should know all of your music by heart and
-shouldn't need to rely on ratings." I disagree &mdash; maybe I'm just not as
-diligent in studying but there's no way I could remember every single song in
-my playlist. Of course you should know your music, but that doesn't mean you
-can't use whatever tools you like to make your DJ'ing even more effective.
-Ratings help me remember to play a song that I might otherwise have forgotten
-about and let me see what my options are if I really need a fantastic song
-*right now*.
-
-Unfortunately I didn't start rating my danceable songs until a month or two
-ago and so I'm only about halfway through. One thing that helps is iTunes'
-Smart Playlists. I can create a smart playlist that only shows me songs that
-are in my "Lindy & Blues" playlist but aren't yet rated.
-
-![Unrated Smart Playlist Screenshot](/media/images{{parent_url}}/dj-playlist-unrated.png "Unrated Smart Playlist")
-
-I have an iPod as well, so when I'm out and listening to my music I can set
-the rating right on the iPod. When I get back to my computer I plug in the
-iPod and it syncs the ratings back to iTunes for me.
-
-## At a Dance
-
-All of the steps I've talked about so far have one goal: to make playing great
-music at an actual dance easier.
-
-### Previewing
-
-I rarely preview songs before I play them; I know my collection pretty well
-and usually have a good idea whether or not a song will fit. Still, it's
-definitely nice to be able to hear a song now and then.
-
-Some DJ's really love external sound cards which let you have two music
-players open on your machine; one plays the music going to the room speakers
-and the other plays into a set of headphones. I don't use this setup for a few
-reasons:
-
-* I can't be bothered to buy an external sound card.  I know, I'm lazy.
-* Computers are tricky, and adding another sound card into the mix makes
-  things trickier. Having another audio interface often causes some headaches
-  when you're ready to DJ and no sound is coming out of one port because
-  there's a configuration option messed up somewhere.
-* I don't trust myself. I can easily see myself accidentally trying to preview
-  on the music player that's going to the room.
-
-What do I do instead? I use my iPod. Sure, the interface isn't as easy to
-navigate as a music player on a laptop, but it doesn't cost any extra money (I
-have it anyway) and there's no chance of accidentally messing up the currently
-playing song.
-
-### Running Playlists
-
-Throughout the night as I decide which songs I want to play I put them in two
-separate lists. First they go into my "Short List" which is usually around
-five to ten songs that I think I'll want to play fairly soon. That gives me
-easy access to songs I'll probably play soon.
-
-The "Running" playlist is the one that's actually playing through the
-speakers. I usually have one or two songs queued up ahead of time in case I
-get distracted from my laptop for a bit.
-
-### Sorting on the Fly
-
-All the work I put into tagging and rating my music pays off when I'm actually
-trying to decide what to play next. When I'm looking through my collection my
-iTunes window will usually look like this (except for being slightly bigger
-and having the sidebar showing):
-
-![Sorted Danceable Playlist Screenshot](/media/images{{parent_url}}/dj-playlist-sorting.png "Sorted Danceable Playlist")
-
-I can use the search bar in the upper right if I'm looking for something
-specific. I can sort by BPM if I know I want a song at a rough tempo. The
-ratings draw my eyes to the songs that I love the most. The comments are there
-to remind me about songs that have long intro/outros, double timed sections,
-etc. Having all of that at my fingers makes it much easier for me to find
-exactly what I want and get it to the speakers.
-
-## And So...
-
-I wrote this because I wanted to share how and why I DJ for dancers. If you're
-a DJ, I hope I've given you a couple of ideas for new tricks to make your job
-easier. **Let me know what you think on [Twitter][twsl]!**
-
-If you don't DJ but think you might want to, great! Please don't be scared off
-by my absurdly organized workflow &mdash; just because it works for me doesn't
-mean you have to do it. Find some good music and [sign up to DJ at Lindy
-Jam][ljdj]! If you think two hours is too long for you as when you're first
-learning to DJ just ask myself, Matt, Jesse, Mike or Beth if we'll share the
-night half & half with you. If you have any questions please let me know!
-
-
-[Lindy Jam]: http://lindyjam.com/
-[ljdj]: http://lindyjam.com/schedule/
-[eMusic]: http://emusic.com/
-[Quicksilver]: http://www.blacktree.com/
-[Tempo Widget]: http://mac.softpedia.com/get/Dashboard-Widgets/Music/Tempo-Widget.shtml
-[twsl]: {{links.twsl}}
-
-
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/02/how-and-why-i-dj.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,209 @@
++++
+title = "How & Why I DJ"
+snip = "I like playing music for dancers."
+date = 2009-02-06T17:53:44Z
+draft = false
+
++++
+
+I've been DJ'ing at swing and blues dances for a while now. It's extremely fun
+and rewarding. I've got a system that I use to keep myself sane while doing it
+and I felt like sharing. Let me know what you think!
+
+{{% toc %}}
+
+## How I Started
+
+When I was just starting to get really interested in dancing I didn't think
+I'd want to DJ much. I thought it would be a lot of work and that I'd hate
+having to stay near a computer during a dance. It just didn't seem like very
+much fun.
+
+The only reason I began to try my hand at it was because we needed to have
+good music to play at RIT Swing Dance Club when my old roommates and I started
+teaching there. I wanted the other people to have a good time and hear the
+awesome music that we love dancing to. I figured that it didn't need to be a
+big deal; I'd just find some cool music and play it at club.
+
+Once I started, I realized that I really like being able to play great music
+for other people to dance to. It sounds cliche, but it really *is* rewarding.
+There's something special about having a kind of control over an entire dance
+floor.
+
+After I became comfortable DJ'ing at club it was only a matter of time before
+I started [signing up to DJ][ljdj] at [Lindy Jam][] and then playing music at
+our little blues parties. I love it. DJ'ing is good for me &mdash; it forces
+me to look for interesting new music and really *listen* to it to hear how it
+works. Really listening (without dancing) closely to swing or blues music is
+something that I don't think enough dancers do.
+
+## Where Do I Find Music?
+
+Most of the music I play comes from [eMusic][]. It's a great site &mdash; you
+pay $15 and get about 40 tracks per month. That's far cheaper than iTunes and
+it's all DRM-free mp3 files. They have a great collection of jazz and blues
+(and a lot of indie and classical music too). I highly recommend them if
+you're looking for some awesome music.
+
+Previously I've wanted nothing to do with iTunes because of the DRM.
+Thankfully Apple has announced that they've convinced the record labels to
+allow DRM-free downloads of everything. I'll still get most of my music from
+eMusic (it's cheaper) but if they don't have a song I want I'll definitely
+look on iTunes.
+
+As for CDs and vinyl, I do occasionally buy and rip some, but for the most
+part digital music is simply faster, easier, and cheaper to use.
+
+## Sorting My Music
+
+Over the past couple of years I've turned into a pretty organized person. If I
+don't have a good method of sorting and organizing my music I'll go crazy when
+I try to DJ. I've developed a way of organizing everything over the years I've
+been DJ'ing which seems to work pretty well for me.
+
+### "Danceable" Music
+
+The first thing I do when I download a new CD from eMusic is skim each track
+and decide if it's even remotely danceable. If it's got a beat I can dance to
+at all, it goes into my "Lindy & Blues" playlist in iTunes. I don't worry
+about how good the song is &mdash; the important part for me is getting the
+decent songs into that playlist so I don't forget about them.
+
+### Tempo
+
+My next step is tagging danceable songs with BPM (beats per minute)
+information. This is really nice to know when you're out at a dane and
+thinking: "I should play a song that's a bit faster than that last one."
+
+I've experimented with a couple of different methods in the past but they all
+seemed pretty cumbersome. The solution came in the form of this [Tempo
+Widget][] for my Mac's dashboard. Click the button on each beat, double click
+the numbers to save the BPM to the currently playing iTunes song.
+
+That's nice, but it's not enough for a nerd like me. The mouse is so slow;
+what I really needed was a way to use the keyboard for everything so I could
+fly through tagging my songs in less than 15 seconds each. I opened up the
+code for the widget and added a couple things. I can press any key on a beat
+instead of clicking the button, and I can hit Cmd+S to save the BPM to the
+iTunes song instead of double clicking the numbers.
+
+I also use [Quicksilver][] to add keyboard shortcuts to move to the
+next/previous song in iTunes. Now that I've got all that done, when I want to
+tag a bunch of new songs with BPMs I can do this:
+
+1. Start playing the first song and open up the dashboard.
+2. Press any key on each beat until I have a consistent BPM displaying.
+3. Press Cmd+S to save the BPM to the song.
+4. Press Cmd+Option+Ctrl+Right Arrow to move to the next song.
+5. Repeat steps 2-5 for each song.
+
+It usually takes me 15 seconds or less per song and saves me a ton of time (I
+have about 900 songs tagged with BPMs right now!). If you're interested in my
+modified version of the Tempo Widget let me know.
+
+### Rating (Smartly)
+
+Let's face it: some songs are better than others. Some songs are fun to dance
+to, but others almost *force* you out of your seat. I like to be able to
+glance at my playlist and have a rough idea of which *really awesome* songs
+I've got at a specific tempo.
+
+Some people might say: "You should know all of your music by heart and
+shouldn't need to rely on ratings." I disagree &mdash; maybe I'm just not as
+diligent in studying but there's no way I could remember every single song in
+my playlist. Of course you should know your music, but that doesn't mean you
+can't use whatever tools you like to make your DJ'ing even more effective.
+Ratings help me remember to play a song that I might otherwise have forgotten
+about and let me see what my options are if I really need a fantastic song
+*right now*.
+
+Unfortunately I didn't start rating my danceable songs until a month or two
+ago and so I'm only about halfway through. One thing that helps is iTunes'
+Smart Playlists. I can create a smart playlist that only shows me songs that
+are in my "Lindy & Blues" playlist but aren't yet rated.
+
+![Unrated Smart Playlist Screenshot](/media/images/blog/2009/02/dj-playlist-unrated.png "Unrated Smart Playlist")
+
+I have an iPod as well, so when I'm out and listening to my music I can set
+the rating right on the iPod. When I get back to my computer I plug in the
+iPod and it syncs the ratings back to iTunes for me.
+
+## At a Dance
+
+All of the steps I've talked about so far have one goal: to make playing great
+music at an actual dance easier.
+
+### Previewing
+
+I rarely preview songs before I play them; I know my collection pretty well
+and usually have a good idea whether or not a song will fit. Still, it's
+definitely nice to be able to hear a song now and then.
+
+Some DJ's really love external sound cards which let you have two music
+players open on your machine; one plays the music going to the room speakers
+and the other plays into a set of headphones. I don't use this setup for a few
+reasons:
+
+* I can't be bothered to buy an external sound card.  I know, I'm lazy.
+* Computers are tricky, and adding another sound card into the mix makes
+  things trickier. Having another audio interface often causes some headaches
+  when you're ready to DJ and no sound is coming out of one port because
+  there's a configuration option messed up somewhere.
+* I don't trust myself. I can easily see myself accidentally trying to preview
+  on the music player that's going to the room.
+
+What do I do instead? I use my iPod. Sure, the interface isn't as easy to
+navigate as a music player on a laptop, but it doesn't cost any extra money (I
+have it anyway) and there's no chance of accidentally messing up the currently
+playing song.
+
+### Running Playlists
+
+Throughout the night as I decide which songs I want to play I put them in two
+separate lists. First they go into my "Short List" which is usually around
+five to ten songs that I think I'll want to play fairly soon. That gives me
+easy access to songs I'll probably play soon.
+
+The "Running" playlist is the one that's actually playing through the
+speakers. I usually have one or two songs queued up ahead of time in case I
+get distracted from my laptop for a bit.
+
+### Sorting on the Fly
+
+All the work I put into tagging and rating my music pays off when I'm actually
+trying to decide what to play next. When I'm looking through my collection my
+iTunes window will usually look like this (except for being slightly bigger
+and having the sidebar showing):
+
+![Sorted Danceable Playlist Screenshot](/media/images/blog/2009/02/dj-playlist-sorting.png "Sorted Danceable Playlist")
+
+I can use the search bar in the upper right if I'm looking for something
+specific. I can sort by BPM if I know I want a song at a rough tempo. The
+ratings draw my eyes to the songs that I love the most. The comments are there
+to remind me about songs that have long intro/outros, double timed sections,
+etc. Having all of that at my fingers makes it much easier for me to find
+exactly what I want and get it to the speakers.
+
+## And So...
+
+I wrote this because I wanted to share how and why I DJ for dancers. If you're
+a DJ, I hope I've given you a couple of ideas for new tricks to make your job
+easier. **Let me know what you think on [Twitter][twsl]!**
+
+If you don't DJ but think you might want to, great! Please don't be scared off
+by my absurdly organized workflow &mdash; just because it works for me doesn't
+mean you have to do it. Find some good music and [sign up to DJ at Lindy
+Jam][ljdj]! If you think two hours is too long for you as when you're first
+learning to DJ just ask myself, Matt, Jesse, Mike or Beth if we'll share the
+night half & half with you. If you have any questions please let me know!
+
+
+[Lindy Jam]: http://lindyjam.com/
+[ljdj]: http://lindyjam.com/schedule/
+[eMusic]: http://emusic.com/
+[Quicksilver]: http://www.blacktree.com/
+[Tempo Widget]: http://mac.softpedia.com/get/Dashboard-Widgets/Music/Tempo-Widget.shtml
+[twsl]: {{links.twsl}}
+
+
+
--- a/content/blog/2009/02/how-i-shoot-dances.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,371 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "How I Shoot Dances"
-    snip: "Slow shutter and flash."
-    created: 2009-02-09 18:04:36
-%}
-
-{% block article %}
-
-Last weekend [Gordon Webster][] came to Rochester, NY to play a dance at The
-Keg. It was awesome (of course) and everyone had a great time.
-
-I took a lot of photos during the course of the night (around 360 actually)
-and some of them turned out pretty nice. A few people have wondered how I got
-the look I did, so I decided to write a post about it.
-
-I'm assuming you know what basic terms like aperture and shutter speed mean.
-If not, look for a post over at [LindyBloggers][] fairly soon about shooting
-dances with a point-and-shoot camera.
-
-[Gordon Webster]: http://webster.suresong.com/
-[LindyBloggers]: http://lindybloggers.com/
-
-[TOC]
-
-Shooting Dancers is Tough
--------------------------
-
-One of the reasons I got into photography seriously was so that I could shoot
-dancers and musicians. I've since branched out and become interested in a lot
-of other aspects of photography, but dancing is a huge part of my life and
-photographing dancers is still something I absolutely love.
-
-I (like many others) thought that getting a DSLR would let me take awesome
-dancing photos with a bit of practice. Well, it's not that simple. Dances are
-one of the hardest things I shoot for a couple of reasons.
-
-### We Move
-
-Dancing, especially in a dance like Lindy Hop, involves a lot of movement. It
-makes focusing a huge pain unless you've got *really* good eyes. I don't. When
-I first started out the majority (at least 70%) of my dance photos were out of
-focus. It's much more difficult than shooting a still (or even slowly moving)
-target.
-
-Moving quickly also means you need a fast shutter speed if you want anything
-to be sharp. You can focus perfectly but that won't freeze any movement. This
-wouldn't be an issue if it wasn't for the second main problem.
-
-### The Lighting at Dances is Awful
-
-Seriously, it's terrible. It's always fairly dark to set the mood; you don't
-want to dance in a brightly lit place unless you're competing. To make matters
-worse, it's almost always ridiculously uneven. Part of the room with usually
-be two or three stops darker than the rest.
-
-Only shooting in one place helps, but is fairy boring. A lot of people will
-stay in the same general area for most of the night (damn cliques!) and so if
-you only shoot one section of the floor you'll miss a lot of people.
-
-What Doesn't Work (for Me (Usually))
-------------------------------------
-
-I've tried a couple of different techniques to overcome these problems. Some
-of them work in some situations but most of the time they leave me unhappy.
-
-<a href="http://www.flickr.com/photos/sjl7678/2449590741/"
-   title="GirlJamSunday-5512 by Steve Losh, on Flickr">
-    <img src="http://farm3.static.flickr.com/2076/2449590741_b47a5ced4c_m.jpg"
-         width="161" height="240" alt="GirlJamSunday-5512"
-         class="right" />
-</a>
-
-### Fast Primes, High ISO
-
-The first remedy I turned to was buying a fast prime lens (Pentax 50mm f/1.4)
-so that it would let in more light. With that lens I would turn up the ISO to
-1600 or so to get even more sensitivity and hope for the best. This kind of
-works, but has some issues.
-
-#### The Good
-
-Shooting with a fast prime means I only have to carry one lens around and
-don't need to change it during the night. They're usually pretty light too, so
-they're easier to work with. 50mm is a nice focal length that lets you stand
-far enough away to not get kicked. You also don't need to annoy people with
-flash.
-
-The wide apertures let more light in so you can actually get some decently
-exposed photos at workable shutter speeds. The ISO isn't much of an problem as
-long as you expose the photo right (if you have to bring up the exposure more
-than a half stop in post it looks terrible).
-
-This solution really excels if you're shooting classes or workshops. The light
-there is usually much better than at actual dances but still not ideal. The
-wide apertures let you soak up all of that light and you can get some really
-nice photos. The example in this section was taken at Girl Jam last year
-during one of the classes with my 50mm.
-
-#### The Bad
-
-Focusing on moving dancers is hard enough at "normal" apertures; trying to
-nail the focus when you've only got six inches of depth of field at f/1.4 is
-*nearly fucking impossible*. Maybe other photographers are better at manually
-focusing or have amazing Canon/Nikon cameras that can focus on a black cat in
-a darkroom, but I'm not and I don't.
-
-The focal length of most fast primes is generally around 50mm. This isn't too
-bad, but I've grown to really love wide angle lenses. 50mm feels too far and
-detached for my taste. Yours may be different, so give it a try.
-
-<a href="http://www.flickr.com/photos/sjl7678/3256610463/"
-   title="LindyJam-0095 by Steve Losh, on Flickr">
-    <img src="http://farm4.static.flickr.com/3400/3256610463_5465877459_m.jpg"
-         width="181" height="240" alt="LindyJam-0095"
-         class="right" />
-</a>
-
-### Bounced Flash, Max Sync Speed
-
-For a while I was adamant that I would never use flash. I figured it would be
-annoying and that the "unnatural" light from the flash would somehow look
-wrong. I avoided it for a while in favor of fast primes and "natural" light.
-
-Eventually I noticed that some other photographers shot with flash at dances
-and it didn't annoy me (while dancing) at all. I decided to give it a shot and
-see how it worked, especially since I was getting really into [Strobist][] and
-studio lighting at the time.
-
-[Strobist]: http://strobist.com/
-
-The basic idea is that you use an external flash (preferably off camera,
-synched with a cord or radio triggers) and bounce the light from the ceiling
-to get more even coverage. You set the aperture to something moderate like f/4
-or f/5.6 and the ISO fairly low. You turn the shutter speed down as low as it
-will go and still sync up and let the strobe do the hard work.
-
-#### The Good
-
-You get sharp photos! What's more, focusing is no longer something you will
-curse vehemently! When you're shooting at f/4 or f/5.6 you have a good amount
-of depth of field so the focus doesn't have to be absolutely perfect.
-
-The flash only lasts about 1/1000 of a second. No one moves much in that time,
-so you get perfectly sharp photos despite the movement.
-
-Now that you're not relying on wide apertures you can start using different
-focal lengths instead of sticking with the fast prime or two that you have.
-You could even use a zoom lens if you don't want to change lenses all the
-time.
-
-#### The Bad
-
-Bouncing from the ceiling is far, far better than keeping your flash on camera
-and pointing it straight at the subjects, but unless the room has obnoxiously
-high ceilings you're still going to get a lot of falloff towards the back of
-the room. You might not mind; it *does* help isolate the subjects from their
-surroundings but I found myself getting tired of it pretty quickly.
-
-You also have to carry a flash, sync cord or triggers, and extra batteries
-around which is kind of a pain. I don't mind, but if you like traveling light
-it could bother you.
-
-This section's example is one of the better results of this technique: Tango
-Cafe's ceilings are very high so the light is pretty even everywhere. High
-ceilings come at a price, however: you need more power from the flash to
-illuminate everything and so can't shoot as fast.
-
-Rethinking My Approach
-----------------------
-
-After using these two methods for a while I stopped and looked at my photos. I
-wasn't as happy with them as I would have liked. I sat down and asked myself:
-"Why is that?" The photos were exposed well and aside from the focusing
-mishaps were pretty sharp. What was missing?
-
-<a href="http://www.flickr.com/photos/sjl7678/299107896/"
-   title="CIMG0171.JPG by Steve Losh, on Flickr">
-    <img src="http://farm1.static.flickr.com/120/299107896_fbec7e2df7_m.jpg"
-         width="240" height="155" alt="CIMG0171.JPG"
-         class="right" />
-</a>
-
-Eventually I came up with my answer: "Movement." Lindy Hop is very much about
-movement; it's one of the most important parts of the dance, maybe even *the*
-most important part. Getting tack sharp photos is great, but it's very hard to
-convey movement with them unless you're a much better photographer than I am.
-
-Most people are not photographers. Most dancers are also not photographers.
-The majority of Lindy Hoppers will take photos with small point-and-shoot
-cameras, *if* they can drag themselves away from dancing for a little while!
-
-The result is that we don't usually see many dance photos (because we're too
-busy dancing to take them) and the ones that we do see are usually blurry
-(because point and shoot cameras in their default modes are just not equipped
-to take sharp ones).
-
-<a href="http://www.flickr.com/photos/sjl7678/299107792/"
-   title="CIMG0141.JPG by Steve Losh, on Flickr">
-    <img src="http://farm1.static.flickr.com/118/299107792_0b4907245f_m.jpg"
-         width="240" height="180" alt="CIMG0141.JPG"
-         class="right" />
-</a>
-
-Even with their flaws, *we love them* because they're the few photographic
-memories we have of some of the best nights of our lives.
-
-I wanted people to have the same feeling toward my photography as they do
-toward these informal snapshots. I wanted to capture the essence of these
-pictures we're so grateful for but use my experience to make something even
-better.
-
-I think I've finally figured out how.
-
-Using Everything
-----------------
-
-What evokes the feeling of movement in the point-and-shoot shots we look at? I
-think it's the blurriness. Our culture is used to looking at photographs and
-we know that "blurry photograph" usually means "moving subject" even if we're
-not always 100% clear on the physics of it.
-
-<a href="http://www.flickr.com/photos/sjl7678/3264591984/"
-   title="GW-0453 by Steve Losh, on Flickr">
-    <img src="http://farm1.static.flickr.com/250/3264591984_296047fb19_m.jpg"
-         width="181" height="240" alt="GW-0453"
-         class="right" />
-</a>
-
-As photographers, we know what causes it. A subject moving while the shutter
-is open produces blur. Longer shutter speeds mean more blur. The little
-cameras that most of our memories come from simply don't have the aperture or
-sensitivity of our hefty DSLRs &ndash; all the poor little things can do is
-leave their shutters open a bit longer to get the light they need. That's why
-those cameras make blurry photos with their default settings.
-
-So how can I add some blurriness to my images? Use a slower shutter speed! I
-also want to keep some sharpness though, so the dancers are more recognizable.
-To do this, I use flash *at the same time*. The flash freezes the subjects
-enough to make them look good and then slow shutter speed and ambient light
-take over to add some movement.
-
-### The Technique
-
-What do you need to do this kind of thing? You can get by with any modern
-camera with a built-in flash, but to really have the flexibility that will
-make you happy you need the following things:
-
-* **A camera with a hot shoe or PC jack and manual controls**. I use a Pentax
-  K20D when I feel like lugging it out and a Canon G10 when I don't.
-* **An external flash.** I use an $80 Vivitar 285hv which will work with
-  anything, so no complaining about how your camera maker only sells $400
-  speedlights.
-* **A way to sync your flash with the camera.** Some of the more expensive
-  flashes have a wireless mode. If not, you can buy radio triggers for $60 or
-  so, or buy a sync cable for $15 to $20. Trust me, having the flash *off* of
-  the camera makes things so much easier.
-
-<a href="http://www.flickr.com/photos/sjl7678/3264540604/"
-   title="GW-0290 by Steve Losh, on Flickr">
-    <img src="http://farm1.static.flickr.com/195/3264540604_f4665b50e6_m.jpg"
-         width="240" height="181" alt="GW-0290" 
-         class="right" />
-</a>
-
-#### Step 1 &ndash; Dial in the Flash
-
-The first step to getting this look is to figure out what kind of exposure you
-need with *the flash alone* to get a well-lit shot.
-
-Turn your shutter speed down to the fastest it will sync (1/180th is usually
-fine) and use trial and error to find a nice combination of aperture, ISO and
-flash power. The actual numbers will depend on several things: how low the
-ceilings are, how powerful your flash is, etc.
-
-Aim for the lowest flash power you can while still keeping a good exposure, a
-narrow enough aperture to make focusing easy, and modest ISO noise. Once you
-figure it out you can probably keep those settings for the rest of the night,
-unless the ceilings are higher on one side of the room or something else
-equally annoying.
-
-#### Step 2 &ndash; Dial in the Ambient
-
-This is the step that adds the movement. First, tone down your flash-only
-exposure by a half or whole stop. Do this by reducing the ISO, aperture, or
-flash power; any of those is fine.
-
-Now that your photo is underexposed, turn off the flash. It will probably be
-completely black now. *Do not touch the ISO or aperture to fix this.* Lengthen
-the shutter speed until you're about two stops underexposed; it will be blurry
-and dark as hell but this is what you want right now.
-
-<a href="http://www.flickr.com/photos/sjl7678/3263800481/"
-   title="GW-0580 by Steve Losh, on Flickr">
-    <img src="http://farm1.static.flickr.com/196/3263800481_9ebf0a47f3_m.jpg"
-         width="240" height="181" alt="GW-0580"
-         class="right" />
-</a>
-
-#### Step 3 &ndash; Combine and Adjust
-
-Turn the flash back on. Do not touch any other settings &ndash; flip the
-switch on the flash and start shooting. This will let the flash illuminate the
-subjects (because you dialed in the power, ISO and aperture before and haven't
-changed them) and the ambient fill in and add movement (because you adjusted
-the shutter speed).
-
-Your first few shots will probably be underexposed or overexposed and have too
-much or too little blur. Don't worry, it always takes me at least a half hour
-to start taking decent photos this way. You really need to play with the
-settings as you go to find out what's going to work for the lighting *that
-night*.
-
-#### Things to Watch Out For
-
-There are a couple of tricky parts to this style of shooting that I'll
-mention. First I'll talk about the typical problems you'll see right away.
-More than one of these certainly might apply; fix them one at a time.
-
-<a href="http://www.flickr.com/photos/sjl7678/3263819663/"
-   title="GW-0656 by Steve Losh, on Flickr">
-    <img src="http://farm1.static.flickr.com/192/3263819663_4f97c18da4_m.jpg"
-         width="181" height="240" alt="GW-0656"
-         class="right" /></a>
-
-* **If the background is dark or there is not enough blur,** you need to use a
-  longer shutter speed to let more ambient light in.
-* **If the dancers are not sharp enough,** you need *more* flash power. Turn
-  it up a little bit at a time.
-* **If people's shirts, faces and limbs are overexposed *and not blurry*,**
-  you need to turn down the flash. Bring it down a bit by reducing the power,
-  narrowing the aperture or reducing the ISO.
-* **If shirts, faces and limbs are overexposed *and blurry*,** you need to
-  shorten the shutter speed to let less ambient light in.
-
-I'm warning you now, fixing one of these will probably fuck something else up.
-It can be really infuriating, but if you slow down, stay calm and think
-through it logically you'll be able to narrow it down and figure out what you
-need. It's a really good feeling when you finally nail it.
-
-There are two other tricky problems that I'm still working on myself:
-
-* **Dances are unevenly lit.** When you walk over to the other side of the
-  room to shoot, you'll have to adjust the shutter speed to compensate for the
-  different amount of ambient light. You really only have a range of about
-  half a stop where the ambient gives you the right amount of blur, so you
-  have to be careful and stay on your toes.
-* **Watch where you bounce.** In rooms with low ceilings, where you point the
-  flash on the ceiling has a huge effect on the lighting. You need to be
-  conscious of what part of the ceiling you're bouncing from to get good
-  results.
-
-Good Luck!
-----------
-
-I hope this post helped you out. Even if you hate how my photos look and don't
-want to make anything like them, at least it will show you what *not* to do.
-I'd love to hear comments or advice on what you like or don't like, and what I
-could do better. If you've got questions I'll do my best to answer them too!
-
-Now go dance, have fun, and make beautiful photographs so we can all remember
-the fantastic events we make happen!
-
-<a href="http://www.flickr.com/photos/sjl7678/3263760493/"
-   title="GW-0438 by Steve Losh, on Flickr">
-    <img src="http://farm1.static.flickr.com/196/3263760493_08c525cfe7.jpg"
-         width="500" height="377" alt="GW-0438" />
-</a>
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/02/how-i-shoot-dances.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,368 @@
++++
+title = "How I Shoot Dances"
+snip = "Slow shutter and flash."
+date = 2009-02-09T18:04:36Z
+draft = false
+
++++
+
+Last weekend [Gordon Webster][] came to Rochester, NY to play a dance at The
+Keg. It was awesome (of course) and everyone had a great time.
+
+I took a lot of photos during the course of the night (around 360 actually)
+and some of them turned out pretty nice. A few people have wondered how I got
+the look I did, so I decided to write a post about it.
+
+I'm assuming you know what basic terms like aperture and shutter speed mean.
+If not, look for a post over at [LindyBloggers][] fairly soon about shooting
+dances with a point-and-shoot camera.
+
+[Gordon Webster]: http://webster.suresong.com/
+[LindyBloggers]: http://lindybloggers.com/
+
+{{% toc %}}
+
+Shooting Dancers is Tough
+-------------------------
+
+One of the reasons I got into photography seriously was so that I could shoot
+dancers and musicians. I've since branched out and become interested in a lot
+of other aspects of photography, but dancing is a huge part of my life and
+photographing dancers is still something I absolutely love.
+
+I (like many others) thought that getting a DSLR would let me take awesome
+dancing photos with a bit of practice. Well, it's not that simple. Dances are
+one of the hardest things I shoot for a couple of reasons.
+
+### We Move
+
+Dancing, especially in a dance like Lindy Hop, involves a lot of movement. It
+makes focusing a huge pain unless you've got *really* good eyes. I don't. When
+I first started out the majority (at least 70%) of my dance photos were out of
+focus. It's much more difficult than shooting a still (or even slowly moving)
+target.
+
+Moving quickly also means you need a fast shutter speed if you want anything
+to be sharp. You can focus perfectly but that won't freeze any movement. This
+wouldn't be an issue if it wasn't for the second main problem.
+
+### The Lighting at Dances is Awful
+
+Seriously, it's terrible. It's always fairly dark to set the mood; you don't
+want to dance in a brightly lit place unless you're competing. To make matters
+worse, it's almost always ridiculously uneven. Part of the room with usually
+be two or three stops darker than the rest.
+
+Only shooting in one place helps, but is fairy boring. A lot of people will
+stay in the same general area for most of the night (damn cliques!) and so if
+you only shoot one section of the floor you'll miss a lot of people.
+
+What Doesn't Work (for Me (Usually))
+------------------------------------
+
+I've tried a couple of different techniques to overcome these problems. Some
+of them work in some situations but most of the time they leave me unhappy.
+
+<a href="http://www.flickr.com/photos/sjl7678/2449590741/"
+   title="GirlJamSunday-5512 by Steve Losh, on Flickr">
+    <img src="http://farm3.static.flickr.com/2076/2449590741_b47a5ced4c_m.jpg"
+         width="161" height="240" alt="GirlJamSunday-5512"
+         class="right" />
+</a>
+
+### Fast Primes, High ISO
+
+The first remedy I turned to was buying a fast prime lens (Pentax 50mm f/1.4)
+so that it would let in more light. With that lens I would turn up the ISO to
+1600 or so to get even more sensitivity and hope for the best. This kind of
+works, but has some issues.
+
+#### The Good
+
+Shooting with a fast prime means I only have to carry one lens around and
+don't need to change it during the night. They're usually pretty light too, so
+they're easier to work with. 50mm is a nice focal length that lets you stand
+far enough away to not get kicked. You also don't need to annoy people with
+flash.
+
+The wide apertures let more light in so you can actually get some decently
+exposed photos at workable shutter speeds. The ISO isn't much of an problem as
+long as you expose the photo right (if you have to bring up the exposure more
+than a half stop in post it looks terrible).
+
+This solution really excels if you're shooting classes or workshops. The light
+there is usually much better than at actual dances but still not ideal. The
+wide apertures let you soak up all of that light and you can get some really
+nice photos. The example in this section was taken at Girl Jam last year
+during one of the classes with my 50mm.
+
+#### The Bad
+
+Focusing on moving dancers is hard enough at "normal" apertures; trying to
+nail the focus when you've only got six inches of depth of field at f/1.4 is
+*nearly fucking impossible*. Maybe other photographers are better at manually
+focusing or have amazing Canon/Nikon cameras that can focus on a black cat in
+a darkroom, but I'm not and I don't.
+
+The focal length of most fast primes is generally around 50mm. This isn't too
+bad, but I've grown to really love wide angle lenses. 50mm feels too far and
+detached for my taste. Yours may be different, so give it a try.
+
+<a href="http://www.flickr.com/photos/sjl7678/3256610463/"
+   title="LindyJam-0095 by Steve Losh, on Flickr">
+    <img src="http://farm4.static.flickr.com/3400/3256610463_5465877459_m.jpg"
+         width="181" height="240" alt="LindyJam-0095"
+         class="right" />
+</a>
+
+### Bounced Flash, Max Sync Speed
+
+For a while I was adamant that I would never use flash. I figured it would be
+annoying and that the "unnatural" light from the flash would somehow look
+wrong. I avoided it for a while in favor of fast primes and "natural" light.
+
+Eventually I noticed that some other photographers shot with flash at dances
+and it didn't annoy me (while dancing) at all. I decided to give it a shot and
+see how it worked, especially since I was getting really into [Strobist][] and
+studio lighting at the time.
+
+[Strobist]: http://strobist.com/
+
+The basic idea is that you use an external flash (preferably off camera,
+synched with a cord or radio triggers) and bounce the light from the ceiling
+to get more even coverage. You set the aperture to something moderate like f/4
+or f/5.6 and the ISO fairly low. You turn the shutter speed down as low as it
+will go and still sync up and let the strobe do the hard work.
+
+#### The Good
+
+You get sharp photos! What's more, focusing is no longer something you will
+curse vehemently! When you're shooting at f/4 or f/5.6 you have a good amount
+of depth of field so the focus doesn't have to be absolutely perfect.
+
+The flash only lasts about 1/1000 of a second. No one moves much in that time,
+so you get perfectly sharp photos despite the movement.
+
+Now that you're not relying on wide apertures you can start using different
+focal lengths instead of sticking with the fast prime or two that you have.
+You could even use a zoom lens if you don't want to change lenses all the
+time.
+
+#### The Bad
+
+Bouncing from the ceiling is far, far better than keeping your flash on camera
+and pointing it straight at the subjects, but unless the room has obnoxiously
+high ceilings you're still going to get a lot of falloff towards the back of
+the room. You might not mind; it *does* help isolate the subjects from their
+surroundings but I found myself getting tired of it pretty quickly.
+
+You also have to carry a flash, sync cord or triggers, and extra batteries
+around which is kind of a pain. I don't mind, but if you like traveling light
+it could bother you.
+
+This section's example is one of the better results of this technique: Tango
+Cafe's ceilings are very high so the light is pretty even everywhere. High
+ceilings come at a price, however: you need more power from the flash to
+illuminate everything and so can't shoot as fast.
+
+Rethinking My Approach
+----------------------
+
+After using these two methods for a while I stopped and looked at my photos. I
+wasn't as happy with them as I would have liked. I sat down and asked myself:
+"Why is that?" The photos were exposed well and aside from the focusing
+mishaps were pretty sharp. What was missing?
+
+<a href="http://www.flickr.com/photos/sjl7678/299107896/"
+   title="CIMG0171.JPG by Steve Losh, on Flickr">
+    <img src="http://farm1.static.flickr.com/120/299107896_fbec7e2df7_m.jpg"
+         width="240" height="155" alt="CIMG0171.JPG"
+         class="right" />
+</a>
+
+Eventually I came up with my answer: "Movement." Lindy Hop is very much about
+movement; it's one of the most important parts of the dance, maybe even *the*
+most important part. Getting tack sharp photos is great, but it's very hard to
+convey movement with them unless you're a much better photographer than I am.
+
+Most people are not photographers. Most dancers are also not photographers.
+The majority of Lindy Hoppers will take photos with small point-and-shoot
+cameras, *if* they can drag themselves away from dancing for a little while!
+
+The result is that we don't usually see many dance photos (because we're too
+busy dancing to take them) and the ones that we do see are usually blurry
+(because point and shoot cameras in their default modes are just not equipped
+to take sharp ones).
+
+<a href="http://www.flickr.com/photos/sjl7678/299107792/"
+   title="CIMG0141.JPG by Steve Losh, on Flickr">
+    <img src="http://farm1.static.flickr.com/118/299107792_0b4907245f_m.jpg"
+         width="240" height="180" alt="CIMG0141.JPG"
+         class="right" />
+</a>
+
+Even with their flaws, *we love them* because they're the few photographic
+memories we have of some of the best nights of our lives.
+
+I wanted people to have the same feeling toward my photography as they do
+toward these informal snapshots. I wanted to capture the essence of these
+pictures we're so grateful for but use my experience to make something even
+better.
+
+I think I've finally figured out how.
+
+Using Everything
+----------------
+
+What evokes the feeling of movement in the point-and-shoot shots we look at? I
+think it's the blurriness. Our culture is used to looking at photographs and
+we know that "blurry photograph" usually means "moving subject" even if we're
+not always 100% clear on the physics of it.
+
+<a href="http://www.flickr.com/photos/sjl7678/3264591984/"
+   title="GW-0453 by Steve Losh, on Flickr">
+    <img src="http://farm1.static.flickr.com/250/3264591984_296047fb19_m.jpg"
+         width="181" height="240" alt="GW-0453"
+         class="right" />
+</a>
+
+As photographers, we know what causes it. A subject moving while the shutter
+is open produces blur. Longer shutter speeds mean more blur. The little
+cameras that most of our memories come from simply don't have the aperture or
+sensitivity of our hefty DSLRs &ndash; all the poor little things can do is
+leave their shutters open a bit longer to get the light they need. That's why
+those cameras make blurry photos with their default settings.
+
+So how can I add some blurriness to my images? Use a slower shutter speed! I
+also want to keep some sharpness though, so the dancers are more recognizable.
+To do this, I use flash *at the same time*. The flash freezes the subjects
+enough to make them look good and then slow shutter speed and ambient light
+take over to add some movement.
+
+### The Technique
+
+What do you need to do this kind of thing? You can get by with any modern
+camera with a built-in flash, but to really have the flexibility that will
+make you happy you need the following things:
+
+* **A camera with a hot shoe or PC jack and manual controls**. I use a Pentax
+  K20D when I feel like lugging it out and a Canon G10 when I don't.
+* **An external flash.** I use an $80 Vivitar 285hv which will work with
+  anything, so no complaining about how your camera maker only sells $400
+  speedlights.
+* **A way to sync your flash with the camera.** Some of the more expensive
+  flashes have a wireless mode. If not, you can buy radio triggers for $60 or
+  so, or buy a sync cable for $15 to $20. Trust me, having the flash *off* of
+  the camera makes things so much easier.
+
+<a href="http://www.flickr.com/photos/sjl7678/3264540604/"
+   title="GW-0290 by Steve Losh, on Flickr">
+    <img src="http://farm1.static.flickr.com/195/3264540604_f4665b50e6_m.jpg"
+         width="240" height="181" alt="GW-0290" 
+         class="right" />
+</a>
+
+#### Step 1 &ndash; Dial in the Flash
+
+The first step to getting this look is to figure out what kind of exposure you
+need with *the flash alone* to get a well-lit shot.
+
+Turn your shutter speed down to the fastest it will sync (1/180th is usually
+fine) and use trial and error to find a nice combination of aperture, ISO and
+flash power. The actual numbers will depend on several things: how low the
+ceilings are, how powerful your flash is, etc.
+
+Aim for the lowest flash power you can while still keeping a good exposure, a
+narrow enough aperture to make focusing easy, and modest ISO noise. Once you
+figure it out you can probably keep those settings for the rest of the night,
+unless the ceilings are higher on one side of the room or something else
+equally annoying.
+
+#### Step 2 &ndash; Dial in the Ambient
+
+This is the step that adds the movement. First, tone down your flash-only
+exposure by a half or whole stop. Do this by reducing the ISO, aperture, or
+flash power; any of those is fine.
+
+Now that your photo is underexposed, turn off the flash. It will probably be
+completely black now. *Do not touch the ISO or aperture to fix this.* Lengthen
+the shutter speed until you're about two stops underexposed; it will be blurry
+and dark as hell but this is what you want right now.
+
+<a href="http://www.flickr.com/photos/sjl7678/3263800481/"
+   title="GW-0580 by Steve Losh, on Flickr">
+    <img src="http://farm1.static.flickr.com/196/3263800481_9ebf0a47f3_m.jpg"
+         width="240" height="181" alt="GW-0580"
+         class="right" />
+</a>
+
+#### Step 3 &ndash; Combine and Adjust
+
+Turn the flash back on. Do not touch any other settings &ndash; flip the
+switch on the flash and start shooting. This will let the flash illuminate the
+subjects (because you dialed in the power, ISO and aperture before and haven't
+changed them) and the ambient fill in and add movement (because you adjusted
+the shutter speed).
+
+Your first few shots will probably be underexposed or overexposed and have too
+much or too little blur. Don't worry, it always takes me at least a half hour
+to start taking decent photos this way. You really need to play with the
+settings as you go to find out what's going to work for the lighting *that
+night*.
+
+#### Things to Watch Out For
+
+There are a couple of tricky parts to this style of shooting that I'll
+mention. First I'll talk about the typical problems you'll see right away.
+More than one of these certainly might apply; fix them one at a time.
+
+<a href="http://www.flickr.com/photos/sjl7678/3263819663/"
+   title="GW-0656 by Steve Losh, on Flickr">
+    <img src="http://farm1.static.flickr.com/192/3263819663_4f97c18da4_m.jpg"
+         width="181" height="240" alt="GW-0656"
+         class="right" /></a>
+
+* **If the background is dark or there is not enough blur,** you need to use a
+  longer shutter speed to let more ambient light in.
+* **If the dancers are not sharp enough,** you need *more* flash power. Turn
+  it up a little bit at a time.
+* **If people's shirts, faces and limbs are overexposed *and not blurry*,**
+  you need to turn down the flash. Bring it down a bit by reducing the power,
+  narrowing the aperture or reducing the ISO.
+* **If shirts, faces and limbs are overexposed *and blurry*,** you need to
+  shorten the shutter speed to let less ambient light in.
+
+I'm warning you now, fixing one of these will probably fuck something else up.
+It can be really infuriating, but if you slow down, stay calm and think
+through it logically you'll be able to narrow it down and figure out what you
+need. It's a really good feeling when you finally nail it.
+
+There are two other tricky problems that I'm still working on myself:
+
+* **Dances are unevenly lit.** When you walk over to the other side of the
+  room to shoot, you'll have to adjust the shutter speed to compensate for the
+  different amount of ambient light. You really only have a range of about
+  half a stop where the ambient gives you the right amount of blur, so you
+  have to be careful and stay on your toes.
+* **Watch where you bounce.** In rooms with low ceilings, where you point the
+  flash on the ceiling has a huge effect on the lighting. You need to be
+  conscious of what part of the ceiling you're bouncing from to get good
+  results.
+
+Good Luck!
+----------
+
+I hope this post helped you out. Even if you hate how my photos look and don't
+want to make anything like them, at least it will show you what *not* to do.
+I'd love to hear comments or advice on what you like or don't like, and what I
+could do better. If you've got questions I'll do my best to answer them too!
+
+Now go dance, have fun, and make beautiful photographs so we can all remember
+the fantastic events we make happen!
+
+<a href="http://www.flickr.com/photos/sjl7678/3263760493/"
+   title="GW-0438 by Steve Losh, on Flickr">
+    <img src="http://farm1.static.flickr.com/196/3263760493_08c525cfe7.jpg"
+         width="500" height="377" alt="GW-0438" />
+</a>
+
--- a/content/blog/2009/03/candy-colored-terminal.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Candy Colored Terminal"
-    snip: "Better colors for the OS X Terminal."
-    created: 2009-03-18 18:26:28
-%}
-
-{% block article %}
-
-Yesterday I wrote a blog post about [adding Mercurial information to your bash
-prompt](/blog/entry/2009/3/17/mercurial-bash-prompts/). Almost all of the
-comments on that entry so far have been asking for the colors I used in the
-Terminal screenshots, so that's what this post is for.
-
-The first section of this entry will be able overcoming the limitations of the
-OS X Terminal application. Skip it if you're using another (better) terminal
-application.
-
-The OS X Terminal and Colors
-----------------------------
-
-OS X's Terminal doesn't support 256-color mode. I have no idea why. Apple, if
-you're reading, *please fix this*. Because of this, if you want to make the
-colors prettier you've only got the 16 ANSI colors to work with.
-
-Once again, Apple fails hard with Terminal.app. You can't change the 16 ANSI
-colors -- you can only change the default text color and background.
-Seriously, Apple, what the hell?
-
-To fix this, you'll need to install [SIMBL][] and [TerminalColors][]. Follow
-the instructions on those pages and be sure to restart Terminal once you've
-finished. Now you can change the ANSI colors be hitting the "More" button
-under the text color settings.
-
-[SIMBL]: http://www.culater.net/software/SIMBL/SIMBL.php
-[TerminalColors]: http://ciaranwal.sh/2007/11/01/customising-colours-in-leopard-terminal
-
-Picking Some Colors
--------------------
-
-Now that we've beaten Terminal.app into compliance, it's time to pick some
-pretty colors. I love the [Monokai][] color scheme for [TextMate][] and so I
-based my choices on that. Here's what it looks like:
-
-![Screenshot of my Terminal, with colors.](/media/images{{parent_url}}/terminal-colors.png "My Terminal colors.")
-
-[Monokai]: http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
-[TextMate]: http://macromates.com/
-
-Here are the RGB values I'm using:
-
-* Black: 0, 0, 0
-* Red: 229, 34, 34
-* Green: 166, 227, 45
-* Yellow: 252, 149, 30
-* Blue: 196, 141, 255
-* Magenta: 250, 37, 115
-* Cyan: 103, 217, 240
-* White: 242, 242, 242
-
-The window background is just set to plain old 0, 0, 0 with a 95% opacity.
-
-Not all of the colors match the names: "blue" is actually more of a purple,
-and "yellow" is much more orange. That doesn't really matter much though
-because they're different enough from each other to still be useful.
-
-Now that the colors are set up you can use them in the normal way. Check out
-[this guide][] if you don't know how to do that. Here's the full code for my
-bash prompt:
-
-**UPDATE:** I've cleaned up the code a lot thanks to the kind folks in #bash
-on freenode who helped set me straight on bash quoting and escaping. I've also
-switched to using my [hg-prompt extension](/projects/hg-prompt/) for the
-repository information.
-
-[this guide]: http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
-
-    :::bash
-    D=$'\e[37;40m'
-    PINK=$'\e[35;40m'
-    GREEN=$'\e[32;40m'
-    ORANGE=$'\e[33;40m'
-    
-    hg_ps1() {
-        hg prompt "{${D} on ${PINK}{branch}}{${D} at ${ORANGE}{bookmark}}{${GREEN}{status}}" 2> /dev/null
-    }
-    
-    export PS1='\n${PINK}\u ${D}at ${ORANGE}\h ${D}in ${GREEN}\w$(hg_ps1)\
-    ${D}\n$ '
-
-I hope this helps! If you'd like to share your color schemes or tell me how to
-make the code for my prompt a bit less ugly, please find me on [Twitter][twsl]!
-
-[twsl]: {{links.twsl}}
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/03/candy-colored-terminal.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,95 @@
++++
+title = "Candy Colored Terminal"
+snip = "Better colors for the OS X Terminal."
+date = 2009-03-18T18:26:28Z
+draft = false
+
++++
+
+Yesterday I wrote a blog post about [adding Mercurial information to your bash
+prompt](/blog/entry/2009/3/17/mercurial-bash-prompts/). Almost all of the
+comments on that entry so far have been asking for the colors I used in the
+Terminal screenshots, so that's what this post is for.
+
+The first section of this entry will be able overcoming the limitations of the
+OS X Terminal application. Skip it if you're using another (better) terminal
+application.
+
+The OS X Terminal and Colors
+----------------------------
+
+OS X's Terminal doesn't support 256-color mode. I have no idea why. Apple, if
+you're reading, *please fix this*. Because of this, if you want to make the
+colors prettier you've only got the 16 ANSI colors to work with.
+
+Once again, Apple fails hard with Terminal.app. You can't change the 16 ANSI
+colors — you can only change the default text color and background.
+Seriously, Apple, what the hell?
+
+To fix this, you'll need to install [SIMBL][] and [TerminalColors][]. Follow
+the instructions on those pages and be sure to restart Terminal once you've
+finished. Now you can change the ANSI colors be hitting the "More" button
+under the text color settings.
+
+[SIMBL]: http://www.culater.net/software/SIMBL/SIMBL.php
+[TerminalColors]: http://ciaranwal.sh/2007/11/01/customising-colours-in-leopard-terminal
+
+Picking Some Colors
+-------------------
+
+Now that we've beaten Terminal.app into compliance, it's time to pick some
+pretty colors. I love the [Monokai][] color scheme for [TextMate][] and so I
+based my choices on that. Here's what it looks like:
+
+![Screenshot of my Terminal, with colors.](/media/images/blog/2009/03/terminal-colors.png "My Terminal colors.")
+
+[Monokai]: http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
+[TextMate]: http://macromates.com/
+
+Here are the RGB values I'm using:
+
+* Black: 0, 0, 0
+* Red: 229, 34, 34
+* Green: 166, 227, 45
+* Yellow: 252, 149, 30
+* Blue: 196, 141, 255
+* Magenta: 250, 37, 115
+* Cyan: 103, 217, 240
+* White: 242, 242, 242
+
+The window background is just set to plain old 0, 0, 0 with a 95% opacity.
+
+Not all of the colors match the names: "blue" is actually more of a purple,
+and "yellow" is much more orange. That doesn't really matter much though
+because they're different enough from each other to still be useful.
+
+Now that the colors are set up you can use them in the normal way. Check out
+[this guide][] if you don't know how to do that. Here's the full code for my
+bash prompt:
+
+**UPDATE:** I've cleaned up the code a lot thanks to the kind folks in #bash
+on freenode who helped set me straight on bash quoting and escaping. I've also
+switched to using my [hg-prompt extension](/projects/hg-prompt/) for the
+repository information.
+
+[this guide]: http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
+
+```bash
+D=$'\e[37;40m'
+PINK=$'\e[35;40m'
+GREEN=$'\e[32;40m'
+ORANGE=$'\e[33;40m'
+
+hg_ps1() {
+    hg prompt "{${D} on ${PINK}{branch}}{${D} at ${ORANGE}{bookmark}}{${GREEN}{status}}" 2> /dev/null
+}
+
+export PS1='\n${PINK}\u ${D}at ${ORANGE}\h ${D}in ${GREEN}\w$(hg_ps1)\
+${D}\n$ '
+```
+
+I hope this helps! If you'd like to share your color schemes or tell me how to
+make the code for my prompt a bit less ugly, please find me on [Twitter][twsl]!
+
+[twsl]: {{links.twsl}}
+
--- a/content/blog/2009/03/mercurial-bash-prompts.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,184 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Mercurial Bash Prompts"
-    snip: "Always know where you are."
-    created: 2009-03-17 21:34:55
-%}
-
-{% block article %}
-
-I've been spending a lot of time in the Terminal lately. I use bash, and it
-lets you configure the prompt pretty much however you want. I won't go into
-how to do the most basic configuration here - if you want to get up to speed
-check out this [guide][].
-
-In this post I'm just going to talk about one simple addition that I
-personally find very helpful: displaying the current branch of a [Mercurial][]
-repository.
-
-Update: the hg-prompt Extension
----------------
-
-I swear, this is the last time I'm updating this entry. I went ahead and made
-an extension for Mercurial called
-[hg-prompt](http://stevelosh.com/projects/hg-prompt/) that does everything
-much more elegantly. **Use that instead!**
-
-[guide]: http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
-[Mercurial]: {{links.mercurial}}
-[git version]: http://gist.github.com/31631
-
-My Starting Point
------------------
-
-Here's what my prompt looked like a couple of days ago:
-
-![My bash prompt without the branch displayed](/media/images{{parent_url}}/prompt-without-branch.png "My bash prompt without the branch displayed.")
-
-Here's the code in my `.bashrc` file to create it. I've stripped out the color
-information to save space.
-
-    :::bash
-    export PS1='\n\u at \h in \w\n$ '
-
-I use the same prompt on every computer I work with, so with this prompt I can
-see which user I'm logged in as, which machine I'm on, and where in the
-filesystem I am. It's a lot of useful information at a glance but doesn't seem
-too cluttered.
-
-I have a linebreak in there because the filesystem path can get pretty long.
-If I kept it all on one line most of my commands would be wrapped around
-anyway, which I find harder to read.
-
-Adding the Mercurial Branch
----------------------------
-
-I use Mercurial for version control, and I use branches quite a bit when I'm
-developing. One problem with this is that it's easy to forget which branch I'm
-on at a given moment. I *could* just use `hg branch` to find out, but that
-gets tedious to type, even when aliased to something like `hb`.
-
-A few days ago I got the idea that I could just display the current branch on
-my prompt whenever I'm in a directory that's part of a repository. Here's what
-my prompt looks like now:
-
-![My bash prompt with the branch displayed](/media/images{{parent_url}}/prompt-with-branch.png "My bash prompt with the branch displayed.")
-
-And here's the code in my `.bashrc` that does it:
-
-    :::bash
-    hg_in_repo() {
-        hg branch 2> /dev/null | awk '{print "on "}'
-    }
-
-    hg_branch() {
-        hg branch 2> /dev/null | awk '{print $1}'
-    }
-
-    export PS1='\n\u at \h in \w $(hg_in_repo)$(hg_branch)\n$ '
-
-The `on branchname` piece is only displayed when you're in a directory that's
-part of a Mercurial repository.
-
-I've split it up into two separate functions because I wanted to have `on` and
-`branchname` displayed in two different colors. I couldn't seem to include the
-color codes in the awk command, so I split it up and put the colors in the
-export statement with the rest of them. If you don't care about colors (or
-don't mind having both words the same color) you can just collapse it into one
-function.
-
-Updated: Is It Dirty?
----------------------
-
-After I posted this entry Matt Kemp commented with a link to a [git
-version][]. One feature that version has is a simple indicator of whether or
-not the repository you're in is dirty. I ported it to Mercurial and here's the
-result:
-
-![My bash prompt with the branch and dirty indicator displayed](/media/images{{parent_url}}/prompt-with-dirty.png "My bash prompt with the branch and dirty indicator displayed.")
-
-And the code in `.bashrc`:
-
-    :::bash
-    hg_dirty() {
-        hg status --no-color 2> /dev/null \
-        | awk '$1 == "?" { print "?" } $1 != "?" { print "!" }' \
-        | sort | uniq | head -c1
-    }
-    
-    hg_in_repo() {
-        [[ `hg branch 2> /dev/null` ]] && echo 'on '
-    }
-
-    hg_branch() {
-        hg branch 2> /dev/null
-    }
-
-    export PS1='\n\u at \h in \w $(hg_in_repo)$(hg_branch)$(hg_dirty)\n$ '
-
-This gives you a `?` after the branch when there are untracked files (and
-*only* untracked files), and a `!` if there are any modified, tracked files.
-
-Updated: Bookmarks Too!
-----------------
-
-I've added another piece to show bookmarks as well. I've also figured out how
-to add colors directly in the functions, so here's the (much nicer) updated
-code all at once:
-
-    :::bash
-    DEFAULT="[37;40m"
-    PINK="[35;40m"
-    GREEN="[32;40m"
-    ORANGE="[33;40m"
-    
-    hg_dirty() {
-        hg status --no-color 2> /dev/null \
-        | awk '$1 == "?" { unknown = 1 } 
-               $1 != "?" { changed = 1 }
-               END {
-                 if (changed) printf "!"
-                 else if (unknown) printf "?" 
-               }'
-    }
-    
-    hg_branch() {
-        hg branch 2> /dev/null | \
-            awk '{ printf "\033[37;0m on \033[35;40m" $1 }'
-        hg bookmarks 2> /dev/null | \
-            awk '/\*/ { printf "\033[37;0m at \033[33;40m" $2 }'
-    }
-    
-    export PS1='\n\e${PINK}\u \
-    \e${DEFAULT}at \e${ORANGE}\h \
-    \e${DEFAULT}in \e${GREEN}\w\
-    $(hg_branch)\e${GREEN}$(hg_dirty)\
-    \e${DEFAULT}\n$ '
-
-These are some pretty simple changes but they help keep me sane. One thing to
-be aware of: if you use all of these it does slow down the rendering of the
-prompt by a tiny, but noticeable, amount. I'm not the strongest bash scripter,
-so if there's a better way to do this (or a way that will make it faster and
-reduce the delay) please let me know!
-
-**UPDATE:** Matt Kemp posted a link to a [git version][] of this below. If you
-use git, check it out! One thing that version has that I didn't think of is an
-indicator of whether the repository is dirty (has uncommitted changes). I'm
-going to go ahead and steal that idea for my prompt too.
-
-**UPDATE:** By request, I've written [an entry about the
-colors](/blog/entry/2009/3/18/candy-colored-terminal/).
-
-**UPDATE:** Kevin Bullock pointed out that the Python interpreter needed to be
-started a bunch of times which will degrade performance. I've changed up the
-"dirty" code a bit to reduce the number of interpreters needed. It's still not
-as efficient as his version, but I think it's about as good as I'm going to
-get if I want separate colors for the pieces and don't want to rely on an
-external script.
-
-**FINAL UPDATE:** I made an extension for Mercurial called
-[hg-prompt](http://stevelosh.com/projects/hg-prompt/) that does everything
-much more elegantly. **Use that instead!**
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/03/mercurial-bash-prompts.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,185 @@
++++
+title = "Mercurial Bash Prompts"
+snip = "Always know where you are."
+date = 2009-03-17T21:34:55Z
+draft = false
+
++++
+
+I've been spending a lot of time in the Terminal lately. I use bash, and it
+lets you configure the prompt pretty much however you want. I won't go into
+how to do the most basic configuration here - if you want to get up to speed
+check out this [guide][].
+
+In this post I'm just going to talk about one simple addition that I
+personally find very helpful: displaying the current branch of a [Mercurial][]
+repository.
+
+Update: the hg-prompt Extension
+---------------
+
+I swear, this is the last time I'm updating this entry. I went ahead and made
+an extension for Mercurial called
+[hg-prompt](http://stevelosh.com/projects/hg-prompt/) that does everything
+much more elegantly. **Use that instead!**
+
+[guide]: http://www.ibm.com/developerworks/linux/library/l-tip-prompt/
+[Mercurial]: {{links.mercurial}}
+[git version]: http://gist.github.com/31631
+
+My Starting Point
+-----------------
+
+Here's what my prompt looked like a couple of days ago:
+
+![My bash prompt without the branch displayed](/media/images/blog/2009/03/prompt-without-branch.png "My bash prompt without the branch displayed.")
+
+Here's the code in my `.bashrc` file to create it. I've stripped out the color
+information to save space.
+
+```bash
+export PS1='\n\u at \h in \w\n$ '
+```
+
+I use the same prompt on every computer I work with, so with this prompt I can
+see which user I'm logged in as, which machine I'm on, and where in the
+filesystem I am. It's a lot of useful information at a glance but doesn't seem
+too cluttered.
+
+I have a linebreak in there because the filesystem path can get pretty long.
+If I kept it all on one line most of my commands would be wrapped around
+anyway, which I find harder to read.
+
+Adding the Mercurial Branch
+---------------------------
+
+I use Mercurial for version control, and I use branches quite a bit when I'm
+developing. One problem with this is that it's easy to forget which branch I'm
+on at a given moment. I *could* just use `hg branch` to find out, but that
+gets tedious to type, even when aliased to something like `hb`.
+
+A few days ago I got the idea that I could just display the current branch on
+my prompt whenever I'm in a directory that's part of a repository. Here's what
+my prompt looks like now:
+
+![My bash prompt with the branch displayed](/media/images/blog/2009/03/prompt-with-branch.png "My bash prompt with the branch displayed.")
+
+And here's the code in my `.bashrc` that does it:
+
+```bash
+hg_in_repo() {
+    hg branch 2> /dev/null | awk '{print "on "}'
+}
+
+hg_branch() {
+    hg branch 2> /dev/null | awk '{print $1}'
+}
+
+export PS1='\n\u at \h in \w $(hg_in_repo)$(hg_branch)\n$ '
+```
+
+The `on branchname` piece is only displayed when you're in a directory that's
+part of a Mercurial repository.
+
+I've split it up into two separate functions because I wanted to have `on` and
+`branchname` displayed in two different colors. I couldn't seem to include the
+color codes in the awk command, so I split it up and put the colors in the
+export statement with the rest of them. If you don't care about colors (or
+don't mind having both words the same color) you can just collapse it into one
+function.
+
+Updated: Is It Dirty?
+---------------------
+
+After I posted this entry Matt Kemp commented with a link to a [git
+version][]. One feature that version has is a simple indicator of whether or
+not the repository you're in is dirty. I ported it to Mercurial and here's the
+result:
+
+![My bash prompt with the branch and dirty indicator displayed](/media/images/blog/2009/03/prompt-with-dirty.png "My bash prompt with the branch and dirty indicator displayed.")
+
+And the code in `.bashrc`:
+
+```bash
+hg_dirty() {
+    hg status --no-color 2> /dev/null \
+    | awk '$1 == "?" { print "?" } $1 != "?" { print "!" }' \
+    | sort | uniq | head -c1
+}
+
+hg_in_repo() {
+    [[ `hg branch 2> /dev/null` ]] && echo 'on '
+}
+
+hg_branch() {
+    hg branch 2> /dev/null
+}
+
+export PS1='\n\u at \h in \w $(hg_in_repo)$(hg_branch)$(hg_dirty)\n$ '
+```
+
+This gives you a `?` after the branch when there are untracked files (and
+*only* untracked files), and a `!` if there are any modified, tracked files.
+
+Updated: Bookmarks Too!
+----------------
+
+I've added another piece to show bookmarks as well. I've also figured out how
+to add colors directly in the functions, so here's the (much nicer) updated
+code all at once:
+
+```bash
+DEFAULT="[37;40m"
+PINK="[35;40m"
+GREEN="[32;40m"
+ORANGE="[33;40m"
+
+hg_dirty() {
+    hg status --no-color 2> /dev/null \
+    | awk '$1 == "?" { unknown = 1 } 
+           $1 != "?" { changed = 1 }
+           END {
+             if (changed) printf "!"
+             else if (unknown) printf "?" 
+           }'
+}
+
+hg_branch() {
+    hg branch 2> /dev/null | \
+        awk '{ printf "\033[37;0m on \033[35;40m" $1 }'
+    hg bookmarks 2> /dev/null | \
+        awk '/\*/ { printf "\033[37;0m at \033[33;40m" $2 }'
+}
+
+export PS1='\n\e${PINK}\u \
+\e${DEFAULT}at \e${ORANGE}\h \
+\e${DEFAULT}in \e${GREEN}\w\
+$(hg_branch)\e${GREEN}$(hg_dirty)\
+\e${DEFAULT}\n$ '
+```
+
+These are some pretty simple changes but they help keep me sane. One thing to
+be aware of: if you use all of these it does slow down the rendering of the
+prompt by a tiny, but noticeable, amount. I'm not the strongest bash scripter,
+so if there's a better way to do this (or a way that will make it faster and
+reduce the delay) please let me know!
+
+**UPDATE:** Matt Kemp posted a link to a [git version][] of this below. If you
+use git, check it out! One thing that version has that I didn't think of is an
+indicator of whether the repository is dirty (has uncommitted changes). I'm
+going to go ahead and steal that idea for my prompt too.
+
+**UPDATE:** By request, I've written [an entry about the
+colors](/blog/entry/2009/3/18/candy-colored-terminal/).
+
+**UPDATE:** Kevin Bullock pointed out that the Python interpreter needed to be
+started a bunch of times which will degrade performance. I've changed up the
+"dirty" code a bit to reduce the number of interpreters needed. It's still not
+as efficient as his version, but I think it's about as good as I'm going to
+get if I want separate colors for the pieces and don't want to rely on an
+external script.
+
+**FINAL UPDATE:** I made an extension for Mercurial called
+[hg-prompt](http://stevelosh.com/projects/hg-prompt/) that does everything
+much more elegantly. **Use that instead!**
+
--- a/content/blog/2009/04/why-people-dont-like-metal.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,130 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Why People Don’t Like Metal"
-    snip: "It’s probably not what you think."
-    created: 2009-04-02 22:32:27
-%}
-
-{% block article %}
-
-I don't think I've ever written a blog entry strictly about music. Usually
-I'll reference it when I write about dancing, but today I just want to talk
-about music. In particular, metal.
-
-"Metal" can refer to a lot of music. For this post I'm referring to the newer
-forms of metal that sprung up in the past decade or so. One example of this is
-[Should Have Stayed in the
-Shallows](http://www.youtube.com/watch?v=hmkLQRp8htY) by [Fear Before (the
-March of Flames)](http://www.fearbefore.net/). I know there are many, many
-more bands out there but this one song is a good sample of what I want to talk
-about.
-
-"I Don't Like all the Screaming"
-------
-
-If you play a metal song for someone that doesn't usually listen to the genre,
-this is probably the first thing you'll hear. There might be a mention of
-"everything is so loud" but almost without fail the screaming is what seems to
-turn people off. Why is that?
-
-The vocals of a song are usually the most noticeable part, especially for
-nonmusicians. Most people who don't play an instrument don't have the
-background to absorb and appreciate complicated instrumental work in any kind
-of music, but *everyone has vocal cords*. Everyone can appreciate speech and
-singing at some level.
-
-So what is it about screaming that most people don't like? If you ask them,
-you'll get an answer, but I don't think it's the correct one.
-
-"I Can't Understand the Words"
------
-
-This is what you'll usually hear when you press the issue. It seems reasonable
--- the lyrics to most metal bands are indecipherable without a written copy,
-even to people that love them. Surely this is the problem?
-
-I don't think it is. To get at the *real* issue, I usually respond with one
-more question:
-
-**Do you enjoy any bands whose vocalist sings in a language you don't know?**
-
-I've never had anyone tell me: "I can't stand *any* music not in my own
-language." I'm sure there are some out there that feel that way, but I think
-they would be in the minority. I've met plenty of people that enjoy hearing
-[Sigur Rós](http://www.sigur-ros.co.uk/) and I'm fairly certain that *exactly
-none of them* speak Icelandic fluently. Many don't even pronounce the name
-correctly.
-
-If people enjoy listening to music with vocals in a language they don't
-understand, then their dislike of metal must not stem purely from
-unintelligible lyrics. What could it come from?
-
-Timbre
-------
-
-Here's one idea: many people are put off by the
-[timbre](http://en.wikipedia.org/wiki/Timbre) of a metal band.
-
-Timbre usually refers to the quality of a musical sound or note. It's what
-makes an E on a guitar sound different than an E on a cello, even if it's the
-same pitch. It's how you can tell your mother's voice from your friend's
-voice, even if she speaks at the same frequency.
-
-A concept I first came across when reading [This Is Your Brain On
-Music](http://www.amazon.com/This-Your-Brain-Music-Obsession/dp/0452288525/)
-is "the timbre of a band as a whole." The idea of timbre can be expanded to
-neatly describe why two bands playing the same song in the same key can sound
-*completely* different. The instruments of the band each contribute their own
-sound and when taken together you have a timbre just as unique as a particular
-instrument's.
-
-Metal bands each have their own timbre, but they're all related -- that's what
-makes them into a genre. A screaming vocalist is an extremely distinct element
-of this that isn't really found anywhere else. Perhaps the answer to "why do
-people dislike metal?" is that they simply don't enjoy the timbre, just as
-some people don't enjoy violins or saxophones.
-
-Lack of Musical Background
------
-
-This is another possible answer. As I mentioned before, everyone has vocal
-cords. Everyone can relate to a singer through the words they're singing. Even
-if the words are in a different language they can still relate to the act of
-singing. Not everyone knows how to sing well, but I believe you'd be hard
-pressed to find someone that has never sung in the shower or somewhere just as
-private.
-
-Very few people can (or want to) relate to screaming. Screaming is something
-we usually do only when threatened or angry, which is hopefully a minority of
-our lives. So once the vocalist is screaming constantly, people that don't
-enjoy metal no longer have the element they're most used to focusing on.
-
-What's left? If you can't understand the words, the voice becomes another
-instrument instead of something "special." Many people simply haven't ever
-tried listening to and appreciating purely instrumental music and so they lose
-interest.
-
-What Can We Do?
------
-
-I'm sure I haven't completely nailed down the reasons why people don't enjoy
-metal. It's almost certainly a combination of quite a few things. But if
-someone is genuinely interested in learning more about metal and about why
-people like it -- perhaps a close friend listens and they'd like to know more
--- I think there's two things they can do that may help.
-
-**Think of the vocals as another instrument, and listen to how they interact
-with the rest of the band.**
-
-Admittedly, there's a lot of really terrible metal out there. As the genre has
-expanded in popularity a lot of "musicians" (barely) have jumped in and
-created bands no more musically meaningful than the average pop singer. It's
-easy to come across this and dismiss the whole genre as a bunch of untalented
-hacks.
-
-Word of mouth is probably the best way to pick out the good from the bad. If
-you look hard enough you can find some amazing music that you might grow to
-love and appreciate.
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/04/why-people-dont-like-metal.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,127 @@
++++
+title = "Why People Don’t Like Metal"
+snip = "It’s probably not what you think."
+date = 2009-04-02T22:32:27Z
+draft = false
+
++++
+
+I don't think I've ever written a blog entry strictly about music. Usually
+I'll reference it when I write about dancing, but today I just want to talk
+about music. In particular, metal.
+
+"Metal" can refer to a lot of music. For this post I'm referring to the newer
+forms of metal that sprung up in the past decade or so. One example of this is
+[Should Have Stayed in the
+Shallows](http://www.youtube.com/watch?v=hmkLQRp8htY) by [Fear Before (the
+March of Flames)](http://www.fearbefore.net/). I know there are many, many
+more bands out there but this one song is a good sample of what I want to talk
+about.
+
+"I Don't Like all the Screaming"
+------
+
+If you play a metal song for someone that doesn't usually listen to the genre,
+this is probably the first thing you'll hear. There might be a mention of
+"everything is so loud" but almost without fail the screaming is what seems to
+turn people off. Why is that?
+
+The vocals of a song are usually the most noticeable part, especially for
+nonmusicians. Most people who don't play an instrument don't have the
+background to absorb and appreciate complicated instrumental work in any kind
+of music, but *everyone has vocal cords*. Everyone can appreciate speech and
+singing at some level.
+
+So what is it about screaming that most people don't like? If you ask them,
+you'll get an answer, but I don't think it's the correct one.
+
+"I Can't Understand the Words"
+-----
+
+This is what you'll usually hear when you press the issue. It seems reasonable
+-- the lyrics to most metal bands are indecipherable without a written copy,
+even to people that love them. Surely this is the problem?
+
+I don't think it is. To get at the *real* issue, I usually respond with one
+more question:
+
+**Do you enjoy any bands whose vocalist sings in a language you don't know?**
+
+I've never had anyone tell me: "I can't stand *any* music not in my own
+language." I'm sure there are some out there that feel that way, but I think
+they would be in the minority. I've met plenty of people that enjoy hearing
+[Sigur Rós](http://www.sigur-ros.co.uk/) and I'm fairly certain that *exactly
+none of them* speak Icelandic fluently. Many don't even pronounce the name
+correctly.
+
+If people enjoy listening to music with vocals in a language they don't
+understand, then their dislike of metal must not stem purely from
+unintelligible lyrics. What could it come from?
+
+Timbre
+------
+
+Here's one idea: many people are put off by the
+[timbre](http://en.wikipedia.org/wiki/Timbre) of a metal band.
+
+Timbre usually refers to the quality of a musical sound or note. It's what
+makes an E on a guitar sound different than an E on a cello, even if it's the
+same pitch. It's how you can tell your mother's voice from your friend's
+voice, even if she speaks at the same frequency.
+
+A concept I first came across when reading [This Is Your Brain On
+Music](http://www.amazon.com/This-Your-Brain-Music-Obsession/dp/0452288525/)
+is "the timbre of a band as a whole." The idea of timbre can be expanded to
+neatly describe why two bands playing the same song in the same key can sound
+*completely* different. The instruments of the band each contribute their own
+sound and when taken together you have a timbre just as unique as a particular
+instrument's.
+
+Metal bands each have their own timbre, but they're all related — that's what
+makes them into a genre. A screaming vocalist is an extremely distinct element
+of this that isn't really found anywhere else. Perhaps the answer to "why do
+people dislike metal?" is that they simply don't enjoy the timbre, just as
+some people don't enjoy violins or saxophones.
+
+Lack of Musical Background
+-----
+
+This is another possible answer. As I mentioned before, everyone has vocal
+cords. Everyone can relate to a singer through the words they're singing. Even
+if the words are in a different language they can still relate to the act of
+singing. Not everyone knows how to sing well, but I believe you'd be hard
+pressed to find someone that has never sung in the shower or somewhere just as
+private.
+
+Very few people can (or want to) relate to screaming. Screaming is something
+we usually do only when threatened or angry, which is hopefully a minority of
+our lives. So once the vocalist is screaming constantly, people that don't
+enjoy metal no longer have the element they're most used to focusing on.
+
+What's left? If you can't understand the words, the voice becomes another
+instrument instead of something "special." Many people simply haven't ever
+tried listening to and appreciating purely instrumental music and so they lose
+interest.
+
+What Can We Do?
+-----
+
+I'm sure I haven't completely nailed down the reasons why people don't enjoy
+metal. It's almost certainly a combination of quite a few things. But if
+someone is genuinely interested in learning more about metal and about why
+people like it — perhaps a close friend listens and they'd like to know more
+— I think there's two things they can do that may help.
+
+**Think of the vocals as another instrument, and listen to how they interact
+with the rest of the band.**
+
+Admittedly, there's a lot of really terrible metal out there. As the genre has
+expanded in popularity a lot of "musicians" (barely) have jumped in and
+created bands no more musically meaningful than the average pop singer. It's
+easy to come across this and dismiss the whole genre as a bunch of untalented
+hacks.
+
+Word of mouth is probably the best way to pick out the good from the bad. If
+you look hard enough you can find some amazing music that you might grow to
+love and appreciate.
+
--- a/content/blog/2009/05/what-i-hate-about-mercurial.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,232 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "What I Hate About Mercurial"
-    snip: "Hg, I love you, but sometimes you bring me down."
-    created: 2009-05-29 19:51:05
-%}
-
-{% block article %}
-
-This entry was inspired by [Jacob Kaplan-Moss][JKM], who was inspired by
-[Titus][], who was inspired by [brian d foy][BDF]. The premise is that you
-can't really claim to know much about a piece of software until you can name a
-few things you hate about it.
-
-[JKM]: http://jacobian.org/writing/hate-python/
-[Titus]: http://ivory.idyll.org/blog/mar-07/five-things-I-hate-about-python
-[BDF]: http://use.perl.org/~brian_d_foy/journal/32556?from=rss
-
-Jacob and Titus talked about Python, and so have a bunch of other people, so I
-figured I'd write about something a bit different:
-[Mercurial](http://selenic.com/mercurial).
-
-I love Mercurial to death, but there *are* a few things about it that annoy
-me. Here they are, in no particular order.
-
-[TOC]
-
-Configuration Through a Textfile
---------------------------------
-
-This is one of the things that [git](http://git-scm.com/) people seem to like
-to [bring up](http://jointheconversation.org/2008/11/24/on-mercurial.html):
-"It doesn't have a command to set your username and email and such? Lame."
-
-I personally don't mind editing a text file -- `vim ~/.hgrc` really isn't that
-hard to type and the format is simple enough that you get the hang of it in
-about ten seconds. It forces you to know *where* the config file is, which is
-nice when the magic "Oh man, I could put my config files under *version
-control*!" moment strikes.
-
-That said, this is on the list because I'd like to see a command to edit some
-of the common options just so people will *stop complaining* about something
-so trivial.
-
-"hg rm" is a Confusing Mess
----------------------------
-
-Here's part of the help for the `hg rm` command:
-
-> This only removes files from the current branch, not from the entire
-> project history. -A can be used to remove only files that have already
-> been deleted, -f can be used to force deletion, and -Af can be used
-> to remove files from the next revision without deleting them.
-
-What the hell? If `-A` won't remove files that are still present, and `-f`
-forces the files to be deleted, why the fuck does combining them mean *the
-exact opposite of both*?
-
-I had to look up the syntax every single time I wanted to use this command,
-until I added this alias to my `~/.hgrc`:
-
-    :::ini
-    [alias]
-    untrack = rm -Af
-
-Now I can use `hg untrack whatever.py` to stop tracking a file.
-
-Addremove Can Track Renames But Won't Unless You Ask It Really Nicely
----------------------------------------------------------------------
-
-It took me a while to realize this, but Mercurial can actually record file
-renames -- not just separate adds and removes -- when using `hg addremove`.
-Here's what happens when you move a file and then use `hg addremove` normally
-to have Mercurial track the changes.
-
-    :::console
-    sjl at ecgtheow in ~/Desktop/test on default 
-    $ ls
-    total 16
-    -rw-r--r--  1 sjl    14B May 29 20:12 a
-    -rw-r--r--  1 sjl    12B May 29 20:12 b
-    
-    sjl at ecgtheow in ~/Desktop/test on default 
-    $ mv b c
-    
-    sjl at ecgtheow in ~/Desktop/test on default! 
-    $ hg addremove
-    removing b
-    adding c
-    
-    sjl at ecgtheow in ~/Desktop/test on default! 
-    $ hg diff
-    diff --git a/b b/b
-    deleted file mode 100644
-    --- a/b
-    +++ /dev/null
-    @@ -1,1 +0,0 @@
-    -To you too!
-    diff --git a/c b/c
-    new file mode 100644
-    --- /dev/null
-    +++ b/c
-    @@ -0,0 +1,1 @@
-    +To you too!
-    
-    sjl at ecgtheow in ~/Desktop/test on default! 
-    $ hg commit -m 'Normal addremove.'
-    
-    sjl at ecgtheow in ~/Desktop/test on default 
-    $ 
-
-Now watch what happens when we tell Mercurial to detect renames when using `hg
-addremove`:
-
-    :::console
-    sjl at ecgtheow in ~/Desktop/test on default 
-    $ ls
-    total 16
-    -rw-r--r--  1 sjl    14B May 29 20:12 a
-    -rw-r--r--  1 sjl    12B May 29 20:12 c
-    
-    sjl at ecgtheow in ~/Desktop/test on default 
-    $ mv c b
-    
-    sjl at ecgtheow in ~/Desktop/test on default! 
-    $ hg addremove --similarity 100
-    adding b
-    removing c
-    recording removal of c as rename to b (100% similar)
-    
-    sjl at ecgtheow in ~/Desktop/test on default! 
-    $ hg diff
-    diff --git a/c b/b
-    rename from c
-    rename to b
-    
-    sjl at ecgtheow in ~/Desktop/test on default! 
-    $ hg commit -m 'This time with rename detection.'
-    
-    sjl at ecgtheow in ~/Desktop/test on default 
-    $ 
-
-This time it notices the rename, and records it. The diff is far, far easier
-to read, and if a branch is merged in where someone else changed that file,
-the changes will follow it over.
-
-The `--similarity` option is a percentage. I have an entry in my `~/.hgrc`
-file to default that to 100, which means that renames will only be
-automatically detected if the files are *identical*. It's safer, but might not
-always catch everything.
-
-I wish I had known this earlier or that Mercurial defaulted to 100% to catch
-the obvious renames.
-
-And yes, I realize I could use `hg rename` to rename it and it *would* get
-recorded, but usually I'm moving files by some other method and using `hg
-addremove` to clean up later.
-
-Now, while we're on the topic...
-
-Why the Hell Does Status Not Show Renames?
-------------------------------------------
-
-Assuming they're recorded, I wish `hg status` would show that a file has been
-renamed. Here's what we get instead:
-
-    :::console
-    sjl at ecgtheow in ~/Desktop/test on default 
-    $ hg rename b c
-    
-    sjl at ecgtheow in ~/Desktop/test on default! 
-    $ hg stat
-    A c
-    R b
-    
-    sjl at ecgtheow in ~/Desktop/test on default! 
-    $ hg diff
-    diff --git a/b b/c
-    rename from b
-    rename to c
-
-No, `hg status`, it clearly *wasn't* an add and a remove, according to `hg
-diff`. Why doesn't `hg status` have a separate character for "renamed" files
-so we can tell them apart?
-
-Get Git Out of My Mercurial
----------------------------
-
-I *hate* that half of Mercurial's commands need a `--git` option to be really
-useful. Is there any reason not to make this the default format and have a
-`--useless` option for backwards compatibility?
-
-I always add it to the defaults in my `~/.hgrc` but it makes me feel kind of
-dirty when I do. It adds a bunch of unnecessary lines to the config file and
-confuses new people.
-
-BitBucket Could Be Prettier
----------------------------
-
-Don't get me wrong, [BitBucket](http://bitbucket.org/) is an awesome site, but
-compared to [GitHub](http://github.com/) it looks a bit dull and unappealing.
-
-It's definitely more usable (how the hell do I view a graph of all
-branches/merges of a given repository on GitHub?) but there's something about
-GitHub's design that just makes it pop.
-
-Mercurial's Site Could Be *Much* Prettier
------------------------------------------
-
-Mercurial's site is ugly. Very ugly. It seems strange to me that the ugly
-version control system (git) has a fairly good-looking site while the much
-more elegant Mercurial has something that looks so boring and dated.
-
-I know, [mercurial-scm.org](http://mercurial-scm.org/) aims to fix this. Thank
-you from the bottom of my heart but please, hurry. The wiki is hurting my
-eyes.
-
-But Hey, at Least It's Not Git!
---------------------------------
-
-All of those things annoy me, but they're small problems compared to the
-revulsion I get when I try to use git every so often.
-
-Maybe that would be a good topic for another entry. At the very least it'll
-probably get me a ton of pageviews and comments saying: "Git's changed, man!
-It's not like it used to be, it's totally intuitive now! You just gotta learn
-how it stores the data!"
-
-I learned, and I'll still take Mercurial despite the small annoyances.
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/05/what-i-hate-about-mercurial.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,233 @@
++++
+title = "What I Hate About Mercurial"
+snip = "Hg, I love you, but sometimes you bring me down."
+date = 2009-05-29T19:51:05Z
+draft = false
+
++++
+
+This entry was inspired by [Jacob Kaplan-Moss][JKM], who was inspired by
+[Titus][], who was inspired by [brian d foy][BDF]. The premise is that you
+can't really claim to know much about a piece of software until you can name a
+few things you hate about it.
+
+[JKM]: http://jacobian.org/writing/hate-python/
+[Titus]: http://ivory.idyll.org/blog/mar-07/five-things-I-hate-about-python
+[BDF]: http://use.perl.org/~brian_d_foy/journal/32556?from=rss
+
+Jacob and Titus talked about Python, and so have a bunch of other people, so I
+figured I'd write about something a bit different:
+[Mercurial](http://selenic.com/mercurial).
+
+I love Mercurial to death, but there *are* a few things about it that annoy
+me. Here they are, in no particular order.
+
+{{% toc %}}
+
+Configuration Through a Textfile
+--------------------------------
+
+This is one of the things that [git](http://git-scm.com/) people seem to like
+to [bring up](http://jointheconversation.org/2008/11/24/on-mercurial.html):
+"It doesn't have a command to set your username and email and such? Lame."
+
+I personally don't mind editing a text file — `vim ~/.hgrc` really isn't that
+hard to type and the format is simple enough that you get the hang of it in
+about ten seconds. It forces you to know *where* the config file is, which is
+nice when the magic "Oh man, I could put my config files under *version
+control*!" moment strikes.
+
+That said, this is on the list because I'd like to see a command to edit some
+of the common options just so people will *stop complaining* about something
+so trivial.
+
+"hg rm" is a Confusing Mess
+---------------------------
+
+Here's part of the help for the `hg rm` command:
+
+> This only removes files from the current branch, not from the entire
+> project history. -A can be used to remove only files that have already
+> been deleted, -f can be used to force deletion, and -Af can be used
+> to remove files from the next revision without deleting them.
+
+What the hell? If `-A` won't remove files that are still present, and `-f`
+forces the files to be deleted, why the fuck does combining them mean *the
+exact opposite of both*?
+
+I had to look up the syntax every single time I wanted to use this command,
+until I added this alias to my `~/.hgrc`:
+
+```ini
+[alias]
+untrack = rm -Af
+```
+
+Now I can use `hg untrack whatever.py` to stop tracking a file.
+
+Addremove Can Track Renames But Won't Unless You Ask It Really Nicely
+---------------------------------------------------------------------
+
+It took me a while to realize this, but Mercurial can actually record file
+renames — not just separate adds and removes — when using `hg addremove`.
+Here's what happens when you move a file and then use `hg addremove` normally
+to have Mercurial track the changes.
+
+```console
+sjl at ecgtheow in ~/Desktop/test on default 
+$ ls
+total 16
+-rw-r--r--  1 sjl    14B May 29 20:12 a
+-rw-r--r--  1 sjl    12B May 29 20:12 b
+
+sjl at ecgtheow in ~/Desktop/test on default 
+$ mv b c
+
+sjl at ecgtheow in ~/Desktop/test on default! 
+$ hg addremove
+removing b
+adding c
+
+sjl at ecgtheow in ~/Desktop/test on default! 
+$ hg diff
+diff --git a/b b/b
+deleted file mode 100644
+--- a/b
++++ /dev/null
+@@ -1,1 +0,0 @@
+-To you too!
+diff --git a/c b/c
+new file mode 100644
+--- /dev/null
++++ b/c
+@@ -0,0 +1,1 @@
++To you too!
+
+sjl at ecgtheow in ~/Desktop/test on default! 
+$ hg commit -m 'Normal addremove.'
+
+sjl at ecgtheow in ~/Desktop/test on default 
+$ 
+```
+
+Now watch what happens when we tell Mercurial to detect renames when using `hg
+addremove`:
+
+```console
+sjl at ecgtheow in ~/Desktop/test on default 
+$ ls
+total 16
+-rw-r--r--  1 sjl    14B May 29 20:12 a
+-rw-r--r--  1 sjl    12B May 29 20:12 c
+
+sjl at ecgtheow in ~/Desktop/test on default 
+$ mv c b
+
+sjl at ecgtheow in ~/Desktop/test on default! 
+$ hg addremove --similarity 100
+adding b
+removing c
+recording removal of c as rename to b (100% similar)
+
+sjl at ecgtheow in ~/Desktop/test on default! 
+$ hg diff
+diff --git a/c b/b
+rename from c
+rename to b
+
+sjl at ecgtheow in ~/Desktop/test on default! 
+$ hg commit -m 'This time with rename detection.'
+
+sjl at ecgtheow in ~/Desktop/test on default 
+$ 
+```
+
+This time it notices the rename, and records it. The diff is far, far easier
+to read, and if a branch is merged in where someone else changed that file,
+the changes will follow it over.
+
+The `--similarity` option is a percentage. I have an entry in my `~/.hgrc`
+file to default that to 100, which means that renames will only be
+automatically detected if the files are *identical*. It's safer, but might not
+always catch everything.
+
+I wish I had known this earlier or that Mercurial defaulted to 100% to catch
+the obvious renames.
+
+And yes, I realize I could use `hg rename` to rename it and it *would* get
+recorded, but usually I'm moving files by some other method and using `hg
+addremove` to clean up later.
+
+Now, while we're on the topic...
+
+Why the Hell Does Status Not Show Renames?
+------------------------------------------
+
+Assuming they're recorded, I wish `hg status` would show that a file has been
+renamed. Here's what we get instead:
+
+```console
+sjl at ecgtheow in ~/Desktop/test on default 
+$ hg rename b c
+
+sjl at ecgtheow in ~/Desktop/test on default! 
+$ hg stat
+A c
+R b
+
+sjl at ecgtheow in ~/Desktop/test on default! 
+$ hg diff
+diff --git a/b b/c
+rename from b
+rename to c
+```
+
+No, `hg status`, it clearly *wasn't* an add and a remove, according to `hg
+diff`. Why doesn't `hg status` have a separate character for "renamed" files
+so we can tell them apart?
+
+Get Git Out of My Mercurial
+---------------------------
+
+I *hate* that half of Mercurial's commands need a `--git` option to be really
+useful. Is there any reason not to make this the default format and have a
+`--useless` option for backwards compatibility?
+
+I always add it to the defaults in my `~/.hgrc` but it makes me feel kind of
+dirty when I do. It adds a bunch of unnecessary lines to the config file and
+confuses new people.
+
+BitBucket Could Be Prettier
+---------------------------
+
+Don't get me wrong, [BitBucket](http://bitbucket.org/) is an awesome site, but
+compared to [GitHub](http://github.com/) it looks a bit dull and unappealing.
+
+It's definitely more usable (how the hell do I view a graph of all
+branches/merges of a given repository on GitHub?) but there's something about
+GitHub's design that just makes it pop.
+
+Mercurial's Site Could Be *Much* Prettier
+-----------------------------------------
+
+Mercurial's site is ugly. Very ugly. It seems strange to me that the ugly
+version control system (git) has a fairly good-looking site while the much
+more elegant Mercurial has something that looks so boring and dated.
+
+I know, [mercurial-scm.org](http://mercurial-scm.org/) aims to fix this. Thank
+you from the bottom of my heart but please, hurry. The wiki is hurting my
+eyes.
+
+But Hey, at Least It's Not Git!
+--------------------------------
+
+All of those things annoy me, but they're small problems compared to the
+revulsion I get when I try to use git every so often.
+
+Maybe that would be a good topic for another entry. At the very least it'll
+probably get me a ton of pageviews and comments saying: "Git's changed, man!
+It's not like it used to be, it's totally intuitive now! You just gotta learn
+how it stores the data!"
+
+I learned, and I'll still take Mercurial despite the small annoyances.
+
--- a/content/blog/2009/06/how-to-contribute-to-mercurial.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,391 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "How to Contribute to Mercurial"
-    snip: "Ten minutes of setup will make it easier."
-    created: 2009-06-01 20:09:44
-%}
-
-{% block article %}
-
-After my last post on [What I Hate About Mercurial][hate], seydar commented
-that I should contribute a patch to add untrack/forget functionality. I
-decided to take the advice, stop being lazy and write one.
-
-It's a very, very simple change and I'm not sure if it will even make it into
-the core repository, but even so it gave me a chance to figure out how to set
-up a decent development environment for hacking on Mercurial. I figured that
-other people might find that information useful so I decided to write this.
-
-[hate]: http://stevelosh.com/blog/entry/2009/5/29/what-i-hate-about-mercurial/
-
-[TOC]
-
-About This Guide
-----------------
-
-This is meant to be a guide to get yourself set up to work on Mercurial's code
-base and contribute your work back to the community. It's *not* a guide for
-actually working on the code.
-
-I'm going to go ahead and assume a few (small) things:
-
-1. You're running OS X or some form of Linux. If you're using Windows, I'm
-   sorry, but I just don't use it enough to really help.
-2. You've got [Python][] installed.
-3. You've got a copy of Mercurial installed in some way (MacPorts, apt-get,
-   source, etc).
-4. You're familiar with (and have clients for) IRC and email.
-
-If those things are true, let's get started. The entire process should take
-between 15 and 45 minutes, depending on how comfortable you are with bash,
-Python, and Mercurial itself.
-
-[Python]: {{links.python}}
-
-Join the Community
-------------------
-
-The first step to contributing is to join the community. Things will probably
-go more smoothly if other developers have seen your name before and those
-other developers are a great resource if you get stuck.
-
-Join the [#mercurial channel on Freenode][irc]. A lot of other Mercurial
-developers hang out in there and it's a good place to go if you want some
-really quick feedback. Take a few minutes and [register your nick][register]
-on Freenode, just because it's a good thing to do.
-
-You should also [subscribe][] to the Mercurial development [mailing list][].
-That's where you're going to be sending your work, so it's good to start
-getting an idea of how people use the list as soon as possible.
-
-[irc]: irc://irc.freenode.net/#mercurial
-[register]: http://freenode.net/faq.shtml#userregistration
-[subscribe]: http://www.selenic.com/mailman/listinfo/mercurial-devel/
-[mailing list]: http://www.selenic.com/pipermail/mercurial-devel/
-
-Grab the Source
----------------
-
-Now you'll want to grab the Mercurial source code so you can start changing
-it. The repository you almost certainly want to clone is the [crew
-repository][].
-
-Several people (listed [here][crew members]) have write access to this and
-it's where most changes go before they're pulled into the main Mercurial
-repositories. Your want your changes to apply cleanly to the tip of crew if
-you want them to have the best chance of being accepted.
-
-Go ahead and clone it somewhere on your machine (replace `hg-crew` if you
-prefer a different name for the folder):
-
-    :::text
-    hg clone http://hg.intevation.org/mercurial/crew hg-crew
-
-It's going to take a little while. Mercurial might be fast but its repository
-has over 8,600 changesets. While you're waiting you can move on to the next
-step.
-
-[crew repository]: http://hg.intevation.org/mercurial/crew
-[crew members]: http://www.selenic.com/mercurial/wiki/CrewRepository
-
-Set Up virtualenv
------------------
-
-This might not seem like it's necessary, but trust me, it's a good thing to
-do. It will make things easier down the road, I promise.
-
-No, *really*, take ten minutes and do this. You'll thank me.
-
-[virtualenv][] is a tool that lets you create separate Python development
-environments that are isolated from each other. The packages and binaries for
-one won't contaminate the others. It will make testing our work on Mercurial
-painless.
-
-Open a new terminal window while the crew repository is busy cloning. Install
-virtualenv in the usual Python fashion:
-
-    :::text
-    sudo easy_install virtualenv
-
-Now install the [virtualenvwrapper][] tool:
-
-    :::text
-    sudo easy_install virtualenvwrapper
-
-This is a nifty little shell script that makes working with virtual
-environments much more pleasant. Before you can use it, you'll need to source
-it into your `~/.bashrc` or `~/.bash_profile` file, as well as choose a place
-to stick the environments themselves:
-
-    :::bash
-    export WORKON_HOME=$HOME/lib/virtualenvs
-    source /(path to python)/bin/virtualenvwrapper_bashrc
-
-As you can see, I prefer to put the `virtualenvs` folder inside my `~/lib`
-folder. You can change that to any place you like.
-
-You'll also need to replace the `(path to python)` with the actual path to
-wherever Python is installed on your system. If you're not sure, here's a
-simple, slow, and horribly inefficient but effective command to figure it out:
-
-    :::text
-    find / -name 'virtualenvwrapper_bashrc' 2> /dev/null
-
-Once you've got the necessary lines in your `~/.bashrc` you can close that
-terminal window.
-
-[virtualenv]: http://pypi.python.org/pypi/virtualenv
-[virtualenvwrapper]: http://www.doughellmann.com/projects/virtualenvwrapper/
-
-Set Up A Public Repository
---------------------------
-
-This isn't strictly required, but it's polite and only takes a minute or two.
-If you've already got a method of sharing your repositories (using hgwebdir
-with your website, for example) go ahead and use that.
-
-If not, head over to [BitBucket][], sign up for an account if you don't
-already have one (it's free), and create a new public repository there. I've
-named mine [hg-crew-sjl][] to be explicit about what it contains, but that's
-not terribly important.
-
-Why bother doing this when you're just going to email your work anyway? Some
-people (myself included) find it easier to pull changes from another
-repository than to apply them from emails. It also gets your changes out into
-a public place so other developers can view and modify *your* modifications.
-
-It's also nice to have an easily accessible clone of your personal repository
-if you're not at your own machine and want to do some more work.
-
-[BitBucket]: http://bitbucket.org/
-[hg-crew-sjl]: http://bitbucket.org/sjl/hg-crew-sjl/
-
-Set Up Your Local Clone
------------------------
-
-By now the crew repository should be finished cloning to your local machine.
-The first thing we want to do is set up the paths so we can push and pull
-easily. Modify the `.hg/hgrc` file inside that repository (*not* your
-`~/.hgrc` file!) to look like this:
-
-    :::ini
-    [paths]
-    default = http://bitbucket.org/(username)/(repo name)/
-    crew = http://hg.intevation.org/mercurial/crew
-
-Replace `(username)` with your BitBucket username and `(repo name)` with the
-name of the BitBucket repository, obviously.
-
-Now you can run `hg push` to push any changes you commit locally to your
-public BitBucket repository, and `hg pull crew` to grab new changes from the
-crew repository.
-
-Build Mercurial
----------------
-
-Make sure you're in your local crew repository, and run:
-
-    :::text
-    make local
-
-This will build Mercurial from the source files. It should finish fairly
-quickly. Once that's done, run the tests to make sure everything is working
-correctly:
-
-    :::text
-    make tests
-
-Those will take a long time to run. While you wait, move on to the next step.
-
-Create a Virtual Environment for Mercurial Development
-------------------------------------------------------
-
-While the test suite is running you're going to make a new virtual environment
-to use for testing your changes to Mercurial. First you need to create it, so
-open up a new terminal window and run:
-
-    :::text
-    mkvirtualenv hg-dev
-
-You can name it something else if you don't like `hg-dev`. Notice how your
-shell prompt now has `(hg-dev)` prepended to it? That's there to remind you
-that you're working in that environment.
-
-Creating the environment automatically puts you into it for that shell
-session. To get into it in the future you'll use:
-
-    :::text
-    workon hg-dev
-
-Now you need to link the Mercurial libraries you're going to change to this
-environment, so you can use it to test your code. Run the following three
-commands:
-
-    :::text
-    ln -s (full path to crew)/mercurial $WORKON_HOME/hg-dev/lib/python2.6/site-packages/
-    ln -s (full path to crew)/hgext $WORKON_HOME/hg-dev/lib/python2.6/site-packages/
-    ln -s (full path to crew)/hg $WORKON_HOME/hg-dev/bin/
-
-Replace `(full path to crew)` with the *full* path to your local crew
-repository, and `hg-dev` with the name of your virtual environment (if you
-named it differently than I did).
-
-Why Bother With a Virtual Environment?
---------------------------------------
-
-It's probably the most work in this entire process, so why did I insist you
-set it up? Watch this:
-
-    :::console
-    sjl at ecgtheow in ~/src/hg-crew-sjl on default 
-    $ hg --version
-    Mercurial Distributed SCM (version 1.2.1)
-    
-    Copyright (C) 2005-2009 Matt Mackall <mpm@selenic.com> and others
-    This is free software; see the source for copying conditions. There is NO
-    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-    
-    sjl at ecgtheow in ~/src/hg-crew-sjl on default 
-    $ workon hg-dev
-    
-    (hg-dev)
-    sjl at ecgtheow in ~/src/hg-crew-sjl on default 
-    $ hg --version
-    Mercurial Distributed SCM (version 7956a823daa3)
-    
-    Copyright (C) 2005-2009 Matt Mackall <mpm@selenic.com> and others
-    This is free software; see the source for copying conditions. There is NO
-    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-    
-    (hg-dev)
-    sjl at ecgtheow in ~/src/hg-crew-sjl on default 
-    $ 
-
-Look at the version numbers. Notice how they changed?
-
-**You can now use** `workon hg-dev` **to make the** `hg` **command run
-Mercurial with your changes!**
-
-This makes it simple to test your work as you go. I keep two terminal windows
-open while working on the Mercurial source:
-
-* One is in my local crew repository to diff, commit, etc with the standard
-  version of Mercurial.
-* The other is in a test repository. I've run `workon hg-dev` to switch to my
-  modified version so I can try out my changes.
-
-Get To Work!
-------------
-
-That's it for the initial setup. Now you can start adding all the wonderful
-features you have in mind. A simple workflow might go something like this:
-
-1. Open two terminal windows and use `workon hg-dev` in the second one to
-   switch to the virtual environment.
-2. Make some changes to the Mercurial codebase.
-3. Test your changes in the second terminal window.
-4. Repeat 3 and 4, using the first terminal window to commit to the local
-   repository as you go.
-
-Once you're finished with your shiny new feature, how do you get it into the
-main Mercurial code so we can all benefit from it?
-
-Modify the Test Suite
----------------------
-
-Before you go off and submit a patch, you need to make sure it works with the
-current tests. You can run the tests by going to the repository and using:
-
-    :::text
-    cd tests
-    python run-tests.py
-
-It's going to take a while, just like before. If you changed something that
-modifies the output of a command it will probably break some of the existing
-tests. That's alright, but you'll need to fix them to reflect your changes.
-The simplest way to do this is to use the `--interactive` flag:
-
-    :::text
-    python run-tests.py --interactive
-
-Using `--interactive` will prompt you each time a test fails and ask if you
-want to accept the new output as the "correct" output. This makes it simple to
-update the existing tests to take your changes into account.
-
-Obviously you should **only accept these updates if they make sense**. Pay
-attention to the output and make sure you didn't accidentally break something!
-
-Add to the Test Suite
-----------------------
-
-If you've implemented an entirely new feature (as opposed to just modifying an
-existing one) you should add some tests of your own. This will make sure no
-one else will inadvertently break whatever you've added.
-
-There's a nice [guide][test-guide] to this on the Mercurial site. Follow it to
-add some tests for your changes.
-
-From what I've heard it's preferable to append to an existing set of tests (if
-it makes sense) instead of adding a brand new test file -- the tests run
-pretty slowly and adding new files make them even slower.
-
-[test-guide]: http://www.selenic.com/mercurial/wiki/WritingTests#Writing_a_shell_script_test
-
-Email Your Patches to the Mailing List
---------------------------------------
-
-You've finally got your code working and updated the tests. It's time to share
-your changes with the rest of the Mercurial developers.
-
-If you want your patches to get accepted, you should take the time to read the
-[guide to contributing changes][] and the [guide to making successful
-patches][] on the Mercurial site. They're short but contain most of what you
-need to know.
-
-[guide to contributing changes]: http://www.selenic.com/mercurial/wiki/ContributingChanges
-[guide to making successful patches]: http://www.selenic.com/mercurial/wiki/SuccessfulPatch
-
-I prefer to use the [patchbomb][] extension to email the patches because it
-takes care of the formatting for me. To enable and configure it you'll need to
-make some additions to your `~/.hgrc` file:
-
-    :::ini
-    [extensions]
-    hgext.patchbomb =
-    
-    [email]
-    method = smtp from = Your Name <you@yourdomain.com>
-    
-    [smtp]
-    host = smtp.youremailhost.com username = yourusername tls = True
-
-You'll need to tweak those settings with your own email address, mail server,
-and so on. Once that's done, you can have patchbomb package up your changes
-and email them out:
-
-    :::text
-    hg email --rev (your first revision):(your last revision)
-
-The command will guide you through filling out some more information, and then
-send out the patches. `hg help email` has a lot more information on how to use
-it.
-
-I usually email them to myself first just in case I mess up a revision number
-and email six thousand changesets. Flooding my own inbox is much better than
-flooding the list's.
-
-[patchbomb]: http://www.selenic.com/mercurial/wiki/PatchbombExtension
-
-That's It, Now Go Contribute!
------------------------------
-
-That's about the extent of my knowledge on contributing to Mercurial. As I
-said before, I've only done one patch so far, but I wanted to write this while
-everything about setting up the environment was fresh in my mind.
-
-If any of the other Mercurial developers would like to chime in and suggest
-corrections or additions -- or if anyone has any questions -- I'll be happy to
-update the post. I hope it's helpful!
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/06/how-to-contribute-to-mercurial.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,404 @@
++++
+title = "How to Contribute to Mercurial"
+snip = "Ten minutes of setup will make it easier."
+date = 2009-06-01T20:09:44Z
+draft = false
+
++++
+
+After my last post on [What I Hate About Mercurial][hate], seydar commented
+that I should contribute a patch to add untrack/forget functionality. I
+decided to take the advice, stop being lazy and write one.
+
+It's a very, very simple change and I'm not sure if it will even make it into
+the core repository, but even so it gave me a chance to figure out how to set
+up a decent development environment for hacking on Mercurial. I figured that
+other people might find that information useful so I decided to write this.
+
+[hate]: http://stevelosh.com/blog/entry/2009/5/29/what-i-hate-about-mercurial/
+
+{{% toc %}}
+
+About This Guide
+----------------
+
+This is meant to be a guide to get yourself set up to work on Mercurial's code
+base and contribute your work back to the community. It's *not* a guide for
+actually working on the code.
+
+I'm going to go ahead and assume a few (small) things:
+
+1. You're running OS X or some form of Linux. If you're using Windows, I'm
+   sorry, but I just don't use it enough to really help.
+2. You've got [Python][] installed.
+3. You've got a copy of Mercurial installed in some way (MacPorts, apt-get,
+   source, etc).
+4. You're familiar with (and have clients for) IRC and email.
+
+If those things are true, let's get started. The entire process should take
+between 15 and 45 minutes, depending on how comfortable you are with bash,
+Python, and Mercurial itself.
+
+[Python]: {{links.python}}
+
+Join the Community
+------------------
+
+The first step to contributing is to join the community. Things will probably
+go more smoothly if other developers have seen your name before and those
+other developers are a great resource if you get stuck.
+
+Join the [#mercurial channel on Freenode][irc]. A lot of other Mercurial
+developers hang out in there and it's a good place to go if you want some
+really quick feedback. Take a few minutes and [register your nick][register]
+on Freenode, just because it's a good thing to do.
+
+You should also [subscribe][] to the Mercurial development [mailing list][].
+That's where you're going to be sending your work, so it's good to start
+getting an idea of how people use the list as soon as possible.
+
+[irc]: irc://irc.freenode.net/#mercurial
+[register]: http://freenode.net/faq.shtml#userregistration
+[subscribe]: http://www.selenic.com/mailman/listinfo/mercurial-devel/
+[mailing list]: http://www.selenic.com/pipermail/mercurial-devel/
+
+Grab the Source
+---------------
+
+Now you'll want to grab the Mercurial source code so you can start changing
+it. The repository you almost certainly want to clone is the [crew
+repository][].
+
+Several people (listed [here][crew members]) have write access to this and
+it's where most changes go before they're pulled into the main Mercurial
+repositories. Your want your changes to apply cleanly to the tip of crew if
+you want them to have the best chance of being accepted.
+
+Go ahead and clone it somewhere on your machine (replace `hg-crew` if you
+prefer a different name for the folder):
+
+```text
+hg clone http://hg.intevation.org/mercurial/crew hg-crew
+```
+
+It's going to take a little while. Mercurial might be fast but its repository
+has over 8,600 changesets. While you're waiting you can move on to the next
+step.
+
+[crew repository]: http://hg.intevation.org/mercurial/crew
+[crew members]: http://www.selenic.com/mercurial/wiki/CrewRepository
+
+Set Up virtualenv
+-----------------
+
+This might not seem like it's necessary, but trust me, it's a good thing to
+do. It will make things easier down the road, I promise.
+
+No, *really*, take ten minutes and do this. You'll thank me.
+
+[virtualenv][] is a tool that lets you create separate Python development
+environments that are isolated from each other. The packages and binaries for
+one won't contaminate the others. It will make testing our work on Mercurial
+painless.
+
+Open a new terminal window while the crew repository is busy cloning. Install
+virtualenv in the usual Python fashion:
+
+```text
+sudo easy_install virtualenv
+```
+
+Now install the [virtualenvwrapper][] tool:
+
+```text
+sudo easy_install virtualenvwrapper
+```
+
+This is a nifty little shell script that makes working with virtual
+environments much more pleasant. Before you can use it, you'll need to source
+it into your `~/.bashrc` or `~/.bash_profile` file, as well as choose a place
+to stick the environments themselves:
+
+```bash
+export WORKON_HOME=$HOME/lib/virtualenvs
+source /(path to python)/bin/virtualenvwrapper_bashrc
+```
+
+As you can see, I prefer to put the `virtualenvs` folder inside my `~/lib`
+folder. You can change that to any place you like.
+
+You'll also need to replace the `(path to python)` with the actual path to
+wherever Python is installed on your system. If you're not sure, here's a
+simple, slow, and horribly inefficient but effective command to figure it out:
+
+```text
+find / -name 'virtualenvwrapper_bashrc' 2> /dev/null
+```
+
+Once you've got the necessary lines in your `~/.bashrc` you can close that
+terminal window.
+
+[virtualenv]: http://pypi.python.org/pypi/virtualenv
+[virtualenvwrapper]: http://www.doughellmann.com/projects/virtualenvwrapper/
+
+Set Up A Public Repository
+--------------------------
+
+This isn't strictly required, but it's polite and only takes a minute or two.
+If you've already got a method of sharing your repositories (using hgwebdir
+with your website, for example) go ahead and use that.
+
+If not, head over to [BitBucket][], sign up for an account if you don't
+already have one (it's free), and create a new public repository there. I've
+named mine [hg-crew-sjl][] to be explicit about what it contains, but that's
+not terribly important.
+
+Why bother doing this when you're just going to email your work anyway? Some
+people (myself included) find it easier to pull changes from another
+repository than to apply them from emails. It also gets your changes out into
+a public place so other developers can view and modify *your* modifications.
+
+It's also nice to have an easily accessible clone of your personal repository
+if you're not at your own machine and want to do some more work.
+
+[BitBucket]: http://bitbucket.org/
+[hg-crew-sjl]: http://bitbucket.org/sjl/hg-crew-sjl/
+
+Set Up Your Local Clone
+-----------------------
+
+By now the crew repository should be finished cloning to your local machine.
+The first thing we want to do is set up the paths so we can push and pull
+easily. Modify the `.hg/hgrc` file inside that repository (*not* your
+`~/.hgrc` file!) to look like this:
+
+```ini
+[paths]
+default = http://bitbucket.org/(username)/(repo name)/
+crew = http://hg.intevation.org/mercurial/crew
+```
+
+Replace `(username)` with your BitBucket username and `(repo name)` with the
+name of the BitBucket repository, obviously.
+
+Now you can run `hg push` to push any changes you commit locally to your
+public BitBucket repository, and `hg pull crew` to grab new changes from the
+crew repository.
+
+Build Mercurial
+---------------
+
+Make sure you're in your local crew repository, and run:
+
+```text
+make local
+```
+
+This will build Mercurial from the source files. It should finish fairly
+quickly. Once that's done, run the tests to make sure everything is working
+correctly:
+
+```text
+make tests
+```
+
+Those will take a long time to run. While you wait, move on to the next step.
+
+Create a Virtual Environment for Mercurial Development
+------------------------------------------------------
+
+While the test suite is running you're going to make a new virtual environment
+to use for testing your changes to Mercurial. First you need to create it, so
+open up a new terminal window and run:
+
+```text
+mkvirtualenv hg-dev
+```
+
+You can name it something else if you don't like `hg-dev`. Notice how your
+shell prompt now has `(hg-dev)` prepended to it? That's there to remind you
+that you're working in that environment.
+
+Creating the environment automatically puts you into it for that shell
+session. To get into it in the future you'll use:
+
+```text
+workon hg-dev
+```
+
+Now you need to link the Mercurial libraries you're going to change to this
+environment, so you can use it to test your code. Run the following three
+commands:
+
+```text
+ln -s (full path to crew)/mercurial $WORKON_HOME/hg-dev/lib/python2.6/site-packages/
+ln -s (full path to crew)/hgext $WORKON_HOME/hg-dev/lib/python2.6/site-packages/
+ln -s (full path to crew)/hg $WORKON_HOME/hg-dev/bin/
+```
+
+Replace `(full path to crew)` with the *full* path to your local crew
+repository, and `hg-dev` with the name of your virtual environment (if you
+named it differently than I did).
+
+Why Bother With a Virtual Environment?
+--------------------------------------
+
+It's probably the most work in this entire process, so why did I insist you
+set it up? Watch this:
+
+```console
+sjl at ecgtheow in ~/src/hg-crew-sjl on default 
+$ hg --version
+Mercurial Distributed SCM (version 1.2.1)
+
+Copyright (C) 2005-2009 Matt Mackall <mpm@selenic.com> and others
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+sjl at ecgtheow in ~/src/hg-crew-sjl on default 
+$ workon hg-dev
+
+(hg-dev)
+sjl at ecgtheow in ~/src/hg-crew-sjl on default 
+$ hg --version
+Mercurial Distributed SCM (version 7956a823daa3)
+
+Copyright (C) 2005-2009 Matt Mackall <mpm@selenic.com> and others
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+(hg-dev)
+sjl at ecgtheow in ~/src/hg-crew-sjl on default 
+$ 
+```
+
+Look at the version numbers. Notice how they changed?
+
+**You can now use** `workon hg-dev` **to make the** `hg` **command run
+Mercurial with your changes!**
+
+This makes it simple to test your work as you go. I keep two terminal windows
+open while working on the Mercurial source:
+
+* One is in my local crew repository to diff, commit, etc with the standard
+  version of Mercurial.
+* The other is in a test repository. I've run `workon hg-dev` to switch to my
+  modified version so I can try out my changes.
+
+Get To Work!
+------------
+
+That's it for the initial setup. Now you can start adding all the wonderful
+features you have in mind. A simple workflow might go something like this:
+
+1. Open two terminal windows and use `workon hg-dev` in the second one to
+   switch to the virtual environment.
+2. Make some changes to the Mercurial codebase.
+3. Test your changes in the second terminal window.
+4. Repeat 3 and 4, using the first terminal window to commit to the local
+   repository as you go.
+
+Once you're finished with your shiny new feature, how do you get it into the
+main Mercurial code so we can all benefit from it?
+
+Modify the Test Suite
+---------------------
+
+Before you go off and submit a patch, you need to make sure it works with the
+current tests. You can run the tests by going to the repository and using:
+
+```text
+cd tests
+python run-tests.py
+```
+
+It's going to take a while, just like before. If you changed something that
+modifies the output of a command it will probably break some of the existing
+tests. That's alright, but you'll need to fix them to reflect your changes.
+The simplest way to do this is to use the `--interactive` flag:
+
+```text
+python run-tests.py --interactive
+```
+
+Using `--interactive` will prompt you each time a test fails and ask if you
+want to accept the new output as the "correct" output. This makes it simple to
+update the existing tests to take your changes into account.
+
+Obviously you should **only accept these updates if they make sense**. Pay
+attention to the output and make sure you didn't accidentally break something!
+
+Add to the Test Suite
+----------------------
+
+If you've implemented an entirely new feature (as opposed to just modifying an
+existing one) you should add some tests of your own. This will make sure no
+one else will inadvertently break whatever you've added.
+
+There's a nice [guide][test-guide] to this on the Mercurial site. Follow it to
+add some tests for your changes.
+
+From what I've heard it's preferable to append to an existing set of tests (if
+it makes sense) instead of adding a brand new test file — the tests run
+pretty slowly and adding new files make them even slower.
+
+[test-guide]: http://www.selenic.com/mercurial/wiki/WritingTests#Writing_a_shell_script_test
+
+Email Your Patches to the Mailing List
+--------------------------------------
+
+You've finally got your code working and updated the tests. It's time to share
+your changes with the rest of the Mercurial developers.
+
+If you want your patches to get accepted, you should take the time to read the
+[guide to contributing changes][] and the [guide to making successful
+patches][] on the Mercurial site. They're short but contain most of what you
+need to know.
+
+[guide to contributing changes]: http://www.selenic.com/mercurial/wiki/ContributingChanges
+[guide to making successful patches]: http://www.selenic.com/mercurial/wiki/SuccessfulPatch
+
+I prefer to use the [patchbomb][] extension to email the patches because it
+takes care of the formatting for me. To enable and configure it you'll need to
+make some additions to your `~/.hgrc` file:
+
+```ini
+[extensions]
+hgext.patchbomb =
+
+[email]
+method = smtp from = Your Name <you@yourdomain.com>
+
+[smtp]
+host = smtp.youremailhost.com username = yourusername tls = True
+```
+
+You'll need to tweak those settings with your own email address, mail server,
+and so on. Once that's done, you can have patchbomb package up your changes
+and email them out:
+
+```text
+hg email --rev (your first revision):(your last revision)
+```
+
+The command will guide you through filling out some more information, and then
+send out the patches. `hg help email` has a lot more information on how to use
+it.
+
+I usually email them to myself first just in case I mess up a revision number
+and email six thousand changesets. Flooding my own inbox is much better than
+flooding the list's.
+
+[patchbomb]: http://www.selenic.com/mercurial/wiki/PatchbombExtension
+
+That's It, Now Go Contribute!
+-----------------------------
+
+That's about the extent of my knowledge on contributing to Mercurial. As I
+said before, I've only done one patch so far, but I wanted to write this while
+everything about setting up the environment was fresh in my mind.
+
+If any of the other Mercurial developers would like to chime in and suggest
+corrections or additions — or if anyone has any questions — I'll be happy to
+update the post. I hope it's helpful!
+
--- a/content/blog/2009/08/a-guide-to-branching-in-mercurial.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,409 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "A Guide to Branching in Mercurial"
-    snip: "With illustrations and comparisons to git."
-    created: 2009-08-30 20:27:12
-%}
-
-{% block article_class %}with-diagrams{% endblock %}
-
-{% block article %}
-
-I've been hanging out in the [#mercurial][hg-irc] and [#bitbucket][bb-irc]
-channels on freenode a lot lately, and I've noticed a topic that comes up a
-lot is "how does [Mercurial][hg]'s branching differ from [git][]'s branching?"
-
-[hg]: {{links.mercurial}}
-[git]: http://git-scm.com/
-[hg-irc]: irc://irc.freenode.net/#mercurial
-[bb-irc]: irc://irc.freenode.net/#bitbucket
-[freenode]: http://freenode.net/
-
-A while ago [Nick Quaranto][nick] and I were talking about Mercurial and git's
-branching models on Twitter and I wrote out a [quick longreply][lreply] about
-the main differences. Since then I've pointed some git users toward that post
-and they seemed to like it, so I figured I'd turn it into something a bit more
-detailed.
-
-**Disclaimer:** this post is not intended to be a guide to the commands used
-for working with Mercurial. It is only meant to be a guide to the *concepts*
-behind the branching models. For more information on daily use and commands,
-the [hg book][book] is a great resource (if you find it useful, please
-[buy][book-buy] a paper copy to support Bryan and have a printed copy of the
-[best editing fail of all time][editfail]).
-
-[nick]: http://litanyagainstfear.com/
-[lreply]: http://a.longreply.com/178502
-[book]: http://hgbook.red-bean.com/
-[book-buy]: http://search.barnesandnoble.com/Mercurial/Bryan-OSullivan/e/9780596800673/?itm=1
-[editfail]: http://twitpic.com/cwod4
-
-[TOC]
-
-Prologue
---------
-
-Before I start explaining the different branching models, here's a simple
-repository I'll use as an example:
-
-![Basic Repository Diagram](/media/images{{ parent_url }}/branch-base.png "Basic Repository")
-
-The repository is in the `~/src/test-project` folder. It has three changesets
-in it: numbers 0, 1 and 2.
-
-**For git users:** each changeset in a Mercurial repository has a hash as an
-identifier, just like with git. However, Mercurial also assigns numbers to
-each changeset in a repository. The numbers are *only* for that local
-repository -- two clones might have different numbers assigned to different
-changesets depending on the order of pulls/pushes/etc. They're just there for
-convenience while you're working with a repository.
-
-The default branch name in Mercurial is "default". Don't worry about what that
-means for now, we'll get to it. I'm mentioning it because there's a little
-`default` marker in the diagram.
-
-In all of these diagrams, a marker like that with a dashed border doesn't
-actually exist as an object anywhere. Those are special names that you can use
-to identify a changeset instead of the hash or number -- Mercurial will
-calculate the revision on the fly.
-
-For now, ignore the `default` marker. I've colored it grey in each of the
-diagrams where it doesn't matter.
-
-Branching with Clones
----------------------
-
-The slowest, safest way to create a branch with Mercurial is to make a new
-clone of the repository:
-
-    :::console
-    $ cd ~/src
-    $ hg clone test-project test-project-feature-branch 
-
-Now you've got two copies of the repository. You can commit separately in each
-one and push/pull changesets between them as often as you like. Once you've
-made some changes in each one, the result might look like this:
-
-![Clone Diagram](/media/images{{ parent_url }}/branch-clone.png "Branching with Clones")
-
-We've got two copies of the repository. Both contain the changesets that
-existed at the time we branched/cloned. If we push from `test-project` into
-`test-project-feature-branch` the "Fix a critical bug" changeset will be
-pushed over.
-
-**For git users:** Remember how I mentioned that the changeset numbers are
-local to a repository? We can see this clearly here -- there are two different
-changesets with the number 3. The numbers are *only* used while working inside
-a single repository. For pushing, pulling, or talking to other people you
-should use the hashes.
-
-### Advantages
-
-Cloning is a very safe way of creating a branch. The two repositories are
-completely isolated until you push or pull, so there's no danger of breaking
-anything in one branch when you're working in another.
-
-Discarding a branch you don't want any more is *very* easy with cloned
-branches. It's as simple as `rm -rf test-project-feature-branch`. There's no
-need to mess around with editing repository history, you just delete the damn
-thing.
-
-### Disadvantages
-
-Creating a branch by cloning locally is slower than the other methods, though
-Mercurial will use hardlinks when cloning if your OS supports them (most do)
-so it won't be *too* slow.
-
-However, the clone branching method can really slow things down when other
-developers (not located nearby) want to work on the project. If you publish
-two branches as separate repositories (such as `stable` and `version-2`),
-contributors will have to clone down *both* repositories through the internet
-if they want to work on both branches. That can take a lot of extra time,
-depending on the repository size and bandwidth.
-
-It can become especially wasteful if, for example, there are 10,000 changesets
-before the branch point and maybe 100 per branch after. Instead of pulling
-down 10,200 changesets you need to pull down 20,200. If you want to work on
-three different branches, you're pulling down 30,300 instead of 10,300.
-
-There is a way to avoid this large download cost, as pointed out by Guido
-Ostkamp and timeless_mbp in [#mercurial][hg-irc]. The idea is that you clone
-one branch down from the server, then pull *all* the branches into it, then
-clone locally to split that repository back into branches. This avoids the
-cost of cloning down the same changesets over and over.
-
-An example of this method with three branches would look something like this:
-
-    :::console
-    $ hg clone http://server/project-main project
-    $ cd project
-    $ hg pull http://server/project-branch1
-    $ hg pull http://server/project-branch2
-    $ cd ..
-    $ hg clone project project-main --rev [head of mainline branch]
-    $ hg clone project project-branch1 --rev [head of branch1]
-    $ hg clone project project-branch2 --rev [head of branch2]
-    $ rm -rf project
-    $ cd project-main
-    $ [edit .hg/hgrc file to make the default path http://server/project-main]
-    $ cd ../project-branch1
-    $ [edit .hg/hgrc to make the default path http://server/project-branch1]
-    $ cd ../project-branch2
-    $ [edit .hg/hgrc to make the default path http://server/project-branch2]
-
-This example assumes you know the IDs of the branch heads off the top of your
-head, which you probably don't. You'll have to look them up.
-
-It also assumes that there is only one new head per branch, when there might
-be more. If `branch1` has two heads which are not in `mainline`, you would
-need to look up the IDs of *both* and specify both in the clone command.
-
-Another annoyance shows up when you're working on a project that relies on
-your code being at a specific file path. If you branch by cloning you'll need
-to rename directories (or change the file path configuration) every time you
-want to switch branches. This might not be a common situation (most build
-tools don't care about the absolute path to the code) but it *does* appear now
-and then.
-
-I personally don't like this method and don't use it. Others do though, so
-it's good to understand it (Mercurial itself uses this model).
-
-### Comparison to git
-
-Git can use this method of branching too, although I don't see it very often.
-Technically this is the exact same thing as creating a fork on [GitHub][], but
-most people think of "fork" and "branch" as separate concepts.
-
-[GitHub]: http://github.com/
-
-Branching with Bookmarks
-------------------------
-
-The next way to branch is to use a bookmark.  For example:
-
-    :::console
-    $ cd ~/src/test-project
-    $ hg bookmark main
-    $ hg bookmark feature
-
-[bookmark]: http://mercurial.selenic.com/wiki/BookmarksExtension
-
-Now you've got two bookmarks (essentially a tag) for your two branches at the
-current changeset.
-
-To switch to one of these branches you can use `hg update feature` to update
-to the tip changeset of that branch and mark yourself as working on that
-branch. When you commit, it will move the bookmark to the newly created
-changeset.
-
-**Note:** for more detailed information on actually using bookmarks day-to-day
-please read the [bookmarks page][bookmark]. This guide is meant to show the
-different branching models, and bookmarks have a few quirks that you should
-know about if you're going to use them.
-
-Here's what the repository would look like with this method:
-
-![Bookmark Diagram](/media/images{{ parent_url }}/branch-bookmark.png "Branching with Bookmarks")
-
-The diagram of the changesets is pretty simple: the branch point was at
-changeset 2 and each branch has one new changeset on it.
-
-Now let's look at the markers. The `default` marker is still there, and we're
-still going to ignore it.
-
-There are two new labels in this diagram -- these represent the bookmarks.
-Notice how their outlines are *not* dashed? This is because bookmarks are
-actual objects stored on disk, not just convenient shortcuts that Mercurial
-will let you use.
-
-When you use a bookmark name as a revision Mercurial will look up the revision
-it points at and use that.
-
-### Advantages
-
-Bookmarks give you a quick, lightweight way to give meaningful labels to your
-branches.
-
-You can delete them when you no longer need them. For example, if we finish
-development of the new feature and merge the changes in the main branch, we
-probably don't need to keep the `feature` bookmark around any more.
-
-### Disadvantages
-
-Being lightweight can also be a disadvantage. If you delete a bookmark, then
-look at your code a year later and wonder what all those changesets that got
-merged into main were for, the bookmark name is gone. This probably isn't a
-big issue if you write good changeset summaries.
-
-Bookmarks are local. They do *not* get transferred during a push or pull!
-There has been some whispering about adding this is Mercurial 1.4, but for now
-if you want to give someone else your bookmarks you'll need to manually give
-them the file the bookmarks are kept in.
-
-**UPDATE:** As of Mercurial 1.6 [bookmarks can be pushed and
-pulled][remote-book] between repositories.
-
-[remote-book]: http://mercurial.selenic.com/wiki/BookmarksExtension#Working_With_Remote_Repositories
-
-### Comparison to git
-
-Branching with bookmarks is very close to the way git usually handles
-branching. Mercurial bookmarks are like git refs: named pointers to changesets
-that move on commit.
-
-The biggest difference is that git refs are transferred when pushing/pulling
-and Mercurial bookmarks are not.
-
-Branching with Named Branches
------------------------------
-
-The third way of branching is to use Mercurial's named branches. Some people
-prefer this method (myself included) and many others don't.
-
-To create a new named branch:
-
-    :::console
-    $ cd ~/src/test-project
-    $ hg branch feature
-
-When you commit the newly created changeset will be on the same branch as its
-parent, unless you've used `hg branch` to mark it as being on a different one.
-
-Here's what a repository using named branches might look like:
-
-![Named Branch Diagram](/media/images{{ parent_url }}/branch-named.png "Branching with Named Branches")
-
-An important difference with this method is that the branch name is
-permanently recorded as part of the changeset's metadata (as you can see in
-changeset 4 in the diagram).
-
-**Note:** The default branch is called `default` and is not normally shown
-unless you ask for verbose output.
-
-Now it's time to explain those magic dashed-border labels we've been ignoring.
-Using a branch name to specify a revision is shorthand for "the tip changeset
-of this named branch". In this example repository:
-
-* Running `hg update default` would update to changeset 3, which is the tip of
-  the `default` branch.
-* Running `hg update feature` would update to changeset 4, which is the tip of
-  the `feature` branch.
-
-Neither of these labels actually exist as an object anywhere on disk (like a
-bookmark would). When you use them Mercurial calculates the appropriate
-revision on the fly.
-
-### Advantages
-
-The biggest advantage to using named branches is that every changeset on a
-branch has the branch name as part of its metadata, which I find very helpful
-(especially when using [graphlog][]).
-
-[graphlog]: http://mercurial.selenic.com/wiki/GraphlogExtension
-
-### Disadvantages
-
-Many people don't like cluttering up changeset metadata with branch names,
-especially if they're small branches that are going to be merged pretty
-quickly.
-
-In the past there was also the problem of not having a way to "close" a
-branch, which means that over time the list of branches could get huge. This
-was fixed in Mercurial 1.2 which introduced the `--close-branch` option for
-`hg commit`.
-
-### Comparison to git
-
-As far as I know git has no equivalent to Mercurial's named branches. Branch
-information is never stored as part of a git changeset's metadata.
-
-Branching Anonymously
----------------------
-
-The last method of branching with Mercurial is the fastest and easiest: update
-to any revision you want and commit. You don't have to think up a name for it
-or do anything else -- just update and commit.
-
-When you update to a specific revision, Mercurial will mark the parent of the
-working directory as that changeset. When you commit, the newly created
-changeset's parent will be the parent of the working directory.
-
-The result of updating and committing without doing anything else would be:
-
-![Anonymous Diagram](/media/images{{ parent_url }}/branch-anon.png "Branching Anonymously")
-
-How do you switch back and forth between branches once you do this? Just use
-`hg update --check REV` with the revision number (or hash) (you can shorten
-`--check` to `-c`).
-
-**Note:** the `--check` option was added in Mercurial 1.3, but it was broken.
-It's fixed in 1.3.1. If you're using something earlier than 1.3.1, you really
-should update.
-
-Logging commands like `hg log` and `hg graphlog` will show you all the
-changesets in the repository, so there's no danger of "losing" changesets.
-
-### Advantages
-
-This is the fastest, easiest way to branch. You don't have to think of a name
-or close/delete anything when you're finished -- just update and commit.
-
-This method is *great* for quick-fix, two-or-three-changeset branches.
-
-### Disadvantages
-
-Using anonymous branching obviously means that there won't be any descriptive
-name for a branch, so you'll need to write good commit messages if you want to
-remember what a branch was for a couple of months later.
-
-Not having a single name to represent a branch means that you'll need to look
-up the revision numbers or hashes with `hg log` or `hg graphlog` each time you
-want to switch back and forth. If you're switching a lot this might be more
-trouble than it's worth.
-
-### Comparison to git
-
-Git has no real way to handle this. Sure, it lets you update and commit, but
-if you don't create a (named) ref to that new commit you're never going to
-find it again once you switch to another one. Well, unless you feel like
-grep'ing through a bunch of log output.
-
-Oh, and hopefully it doesn't get garbage collected.
-
-Sometimes you might not want to think up a name for a quick-fix branch. With
-git you *have* to name it if you want to really do anything with it, with
-Mercurial you don't.
-
-One More Difference Between Mercurial and git
----------------------------------------------
-
-There's one more *big* difference between Mercurial's branching and git's
-branching:
-
-**Mercurial will push/pull *all* branches by default, while git will push/pull
-only the *current* branch.**
-
-This is important if you're a git user working with Mercurial. If you want to
-push/pull only a single branch with Mercurial you can use the `--rev` option
-(`-r` for short) and specify the tip revision of the branch:
-
-    :::console
-    $ hg push --rev branchname
-    $ hg push --rev bookmarkname
-    $ hg push --rev 4
-
-If you specify a revision, Mercurial will push that changeset and any
-ancestors of it that the target doesn't already have.
-
-This doesn't apply when you use the "Branching with Clones" method because the
-branches are separate repositories.
-
-Conclusion
-----------
-
-I hope this guide is helpful. If you see anything I've missed, especially on
-the git side of things (I don't use git any more than I have to) or have any
-questions please let me know!
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/08/a-guide-to-branching-in-mercurial.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,409 @@
++++
+title = "A Guide to Branching in Mercurial"
+snip = "With illustrations and comparisons to git."
+date = 2009-08-30T20:27:12Z
+draft = false
+
++++
+
+I've been hanging out in the [#mercurial][hg-irc] and [#bitbucket][bb-irc]
+channels on freenode a lot lately, and I've noticed a topic that comes up a
+lot is "how does [Mercurial][hg]'s branching differ from [git][]'s branching?"
+
+[hg]: {{links.mercurial}}
+[git]: http://git-scm.com/
+[hg-irc]: irc://irc.freenode.net/#mercurial
+[bb-irc]: irc://irc.freenode.net/#bitbucket
+[freenode]: http://freenode.net/
+
+A while ago [Nick Quaranto][nick] and I were talking about Mercurial and git's
+branching models on Twitter and I wrote out a [quick longreply][lreply] about
+the main differences. Since then I've pointed some git users toward that post
+and they seemed to like it, so I figured I'd turn it into something a bit more
+detailed.
+
+**Disclaimer:** this post is not intended to be a guide to the commands used
+for working with Mercurial. It is only meant to be a guide to the *concepts*
+behind the branching models. For more information on daily use and commands,
+the [hg book][book] is a great resource (if you find it useful, please
+[buy][book-buy] a paper copy to support Bryan and have a printed copy of the
+[best editing fail of all time][editfail]).
+
+[nick]: http://litanyagainstfear.com/
+[lreply]: http://a.longreply.com/178502
+[book]: http://hgbook.red-bean.com/
+[book-buy]: http://search.barnesandnoble.com/Mercurial/Bryan-OSullivan/e/9780596800673/?itm=1
+[editfail]: http://twitpic.com/cwod4
+
+{{% toc %}}
+
+Prologue
+--------
+
+Before I start explaining the different branching models, here's a simple
+repository I'll use as an example:
+
+<img class="diagram" src="/media/images/blog/2009/08/branch-base.png" alt="Basic Repository"/>
+
+The repository is in the `~/src/test-project` folder. It has three changesets
+in it: numbers 0, 1 and 2.
+
+**For git users:** each changeset in a Mercurial repository has a hash as an
+identifier, just like with git. However, Mercurial also assigns numbers to
+each changeset in a repository. The numbers are *only* for that local
+repository — two clones might have different numbers assigned to different
+changesets depending on the order of pulls/pushes/etc. They're just there for
+convenience while you're working with a repository.
+
+The default branch name in Mercurial is "default". Don't worry about what that
+means for now, we'll get to it. I'm mentioning it because there's a little
+`default` marker in the diagram.
+
+In all of these diagrams, a marker like that with a dashed border doesn't
+actually exist as an object anywhere. Those are special names that you can use
+to identify a changeset instead of the hash or number — Mercurial will
+calculate the revision on the fly.
+
+For now, ignore the `default` marker. I've colored it grey in each of the
+diagrams where it doesn't matter.
+
+Branching with Clones
+---------------------
+
+The slowest, safest way to create a branch with Mercurial is to make a new
+clone of the repository:
+
+```console
+$ cd ~/src
+$ hg clone test-project test-project-feature-branch 
+```
+
+Now you've got two copies of the repository. You can commit separately in each
+one and push/pull changesets between them as often as you like. Once you've
+made some changes in each one, the result might look like this:
+
+<img class="diagram" src="/media/images/blog/2009/08/branch-clone.png" alt="Branching with Clones"/>
+
+We've got two copies of the repository. Both contain the changesets that
+existed at the time we branched/cloned. If we push from `test-project` into
+`test-project-feature-branch` the "Fix a critical bug" changeset will be
+pushed over.
+
+**For git users:** Remember how I mentioned that the changeset numbers are
+local to a repository? We can see this clearly here — there are two different
+changesets with the number 3. The numbers are *only* used while working inside
+a single repository. For pushing, pulling, or talking to other people you
+should use the hashes.
+
+### Advantages
+
+Cloning is a very safe way of creating a branch. The two repositories are
+completely isolated until you push or pull, so there's no danger of breaking
+anything in one branch when you're working in another.
+
+Discarding a branch you don't want any more is *very* easy with cloned
+branches. It's as simple as `rm -rf test-project-feature-branch`. There's no
+need to mess around with editing repository history, you just delete the damn
+thing.
+
+### Disadvantages
+
+Creating a branch by cloning locally is slower than the other methods, though
+Mercurial will use hardlinks when cloning if your OS supports them (most do)
+so it won't be *too* slow.
+
+However, the clone branching method can really slow things down when other
+developers (not located nearby) want to work on the project. If you publish
+two branches as separate repositories (such as `stable` and `version-2`),
+contributors will have to clone down *both* repositories through the internet
+if they want to work on both branches. That can take a lot of extra time,
+depending on the repository size and bandwidth.
+
+It can become especially wasteful if, for example, there are 10,000 changesets
+before the branch point and maybe 100 per branch after. Instead of pulling
+down 10,200 changesets you need to pull down 20,200. If you want to work on
+three different branches, you're pulling down 30,300 instead of 10,300.
+
+There is a way to avoid this large download cost, as pointed out by Guido
+Ostkamp and timeless_mbp in [#mercurial][hg-irc]. The idea is that you clone
+one branch down from the server, then pull *all* the branches into it, then
+clone locally to split that repository back into branches. This avoids the
+cost of cloning down the same changesets over and over.
+
+An example of this method with three branches would look something like this:
+
+```console
+$ hg clone http://server/project-main project
+$ cd project
+$ hg pull http://server/project-branch1
+$ hg pull http://server/project-branch2
+$ cd ..
+$ hg clone project project-main --rev [head of mainline branch]
+$ hg clone project project-branch1 --rev [head of branch1]
+$ hg clone project project-branch2 --rev [head of branch2]
+$ rm -rf project
+$ cd project-main
+$ [edit .hg/hgrc file to make the default path http://server/project-main]
+$ cd ../project-branch1
+$ [edit .hg/hgrc to make the default path http://server/project-branch1]
+$ cd ../project-branch2
+$ [edit .hg/hgrc to make the default path http://server/project-branch2]
+```
+
+This example assumes you know the IDs of the branch heads off the top of your
+head, which you probably don't. You'll have to look them up.
+
+It also assumes that there is only one new head per branch, when there might
+be more. If `branch1` has two heads which are not in `mainline`, you would
+need to look up the IDs of *both* and specify both in the clone command.
+
+Another annoyance shows up when you're working on a project that relies on
+your code being at a specific file path. If you branch by cloning you'll need
+to rename directories (or change the file path configuration) every time you
+want to switch branches. This might not be a common situation (most build
+tools don't care about the absolute path to the code) but it *does* appear now
+and then.
+
+I personally don't like this method and don't use it. Others do though, so
+it's good to understand it (Mercurial itself uses this model).
+
+### Comparison to git
+
+Git can use this method of branching too, although I don't see it very often.
+Technically this is the exact same thing as creating a fork on [GitHub][], but
+most people think of "fork" and "branch" as separate concepts.
+
+[GitHub]: http://github.com/
+
+Branching with Bookmarks
+------------------------
+
+The next way to branch is to use a bookmark.  For example:
+
+```console
+$ cd ~/src/test-project
+$ hg bookmark main
+$ hg bookmark feature
+```
+
+[bookmark]: http://mercurial.selenic.com/wiki/BookmarksExtension
+
+Now you've got two bookmarks (essentially a tag) for your two branches at the
+current changeset.
+
+To switch to one of these branches you can use `hg update feature` to update
+to the tip changeset of that branch and mark yourself as working on that
+branch. When you commit, it will move the bookmark to the newly created
+changeset.
+
+**Note:** for more detailed information on actually using bookmarks day-to-day
+please read the [bookmarks page][bookmark]. This guide is meant to show the
+different branching models, and bookmarks have a few quirks that you should
+know about if you're going to use them.
+
+Here's what the repository would look like with this method:
+
+<img class="diagram" src="/media/images/blog/2009/08/branch-bookmark.png" alt="Branching with Bookmarks"/>
+
+The diagram of the changesets is pretty simple: the branch point was at
+changeset 2 and each branch has one new changeset on it.
+
+Now let's look at the markers. The `default` marker is still there, and we're
+still going to ignore it.
+
+There are two new labels in this diagram — these represent the bookmarks.
+Notice how their outlines are *not* dashed? This is because bookmarks are
+actual objects stored on disk, not just convenient shortcuts that Mercurial
+will let you use.
+
+When you use a bookmark name as a revision Mercurial will look up the revision
+it points at and use that.
+
+### Advantages
+
+Bookmarks give you a quick, lightweight way to give meaningful labels to your
+branches.
+
+You can delete them when you no longer need them. For example, if we finish
+development of the new feature and merge the changes in the main branch, we
+probably don't need to keep the `feature` bookmark around any more.
+
+### Disadvantages
+
+Being lightweight can also be a disadvantage. If you delete a bookmark, then
+look at your code a year later and wonder what all those changesets that got
+merged into main were for, the bookmark name is gone. This probably isn't a
+big issue if you write good changeset summaries.
+
+Bookmarks are local. They do *not* get transferred during a push or pull!
+There has been some whispering about adding this is Mercurial 1.4, but for now
+if you want to give someone else your bookmarks you'll need to manually give
+them the file the bookmarks are kept in.
+
+**UPDATE:** As of Mercurial 1.6 [bookmarks can be pushed and
+pulled][remote-book] between repositories.
+
+[remote-book]: http://mercurial.selenic.com/wiki/BookmarksExtension#Working_With_Remote_Repositories
+
+### Comparison to git
+
+Branching with bookmarks is very close to the way git usually handles
+branching. Mercurial bookmarks are like git refs: named pointers to changesets
+that move on commit.
+
+The biggest difference is that git refs are transferred when pushing/pulling
+and Mercurial bookmarks are not.
+
+Branching with Named Branches
+-----------------------------
+
+The third way of branching is to use Mercurial's named branches. Some people
+prefer this method (myself included) and many others don't.
+
+To create a new named branch:
+
+```console
+$ cd ~/src/test-project
+$ hg branch feature
+```
+
+When you commit the newly created changeset will be on the same branch as its
+parent, unless you've used `hg branch` to mark it as being on a different one.
+
+Here's what a repository using named branches might look like:
+
+<img class="diagram" src="/media/images/blog/2009/08/branch-named.png" alt="Branching with Named Branches"/>
+
+An important difference with this method is that the branch name is
+permanently recorded as part of the changeset's metadata (as you can see in
+changeset 4 in the diagram).
+
+**Note:** The default branch is called `default` and is not normally shown
+unless you ask for verbose output.
+
+Now it's time to explain those magic dashed-border labels we've been ignoring.
+Using a branch name to specify a revision is shorthand for "the tip changeset
+of this named branch". In this example repository:
+
+* Running `hg update default` would update to changeset 3, which is the tip of
+  the `default` branch.
+* Running `hg update feature` would update to changeset 4, which is the tip of
+  the `feature` branch.
+
+Neither of these labels actually exist as an object anywhere on disk (like a
+bookmark would). When you use them Mercurial calculates the appropriate
+revision on the fly.
+
+### Advantages
+
+The biggest advantage to using named branches is that every changeset on a
+branch has the branch name as part of its metadata, which I find very helpful
+(especially when using [graphlog][]).
+
+[graphlog]: http://mercurial.selenic.com/wiki/GraphlogExtension
+
+### Disadvantages
+
+Many people don't like cluttering up changeset metadata with branch names,
+especially if they're small branches that are going to be merged pretty
+quickly.
+
+In the past there was also the problem of not having a way to "close" a
+branch, which means that over time the list of branches could get huge. This
+was fixed in Mercurial 1.2 which introduced the `--close-branch` option for
+`hg commit`.
+
+### Comparison to git
+
+As far as I know git has no equivalent to Mercurial's named branches. Branch
+information is never stored as part of a git changeset's metadata.
+
+Branching Anonymously
+---------------------
+
+The last method of branching with Mercurial is the fastest and easiest: update
+to any revision you want and commit. You don't have to think up a name for it
+or do anything else — just update and commit.
+
+When you update to a specific revision, Mercurial will mark the parent of the
+working directory as that changeset. When you commit, the newly created
+changeset's parent will be the parent of the working directory.
+
+The result of updating and committing without doing anything else would be:
+
+<img class="diagram" src="/media/images/blog/2009/08/branch-anon.png" alt="Branching Anonymously"/>
+
+How do you switch back and forth between branches once you do this? Just use
+`hg update --check REV` with the revision number (or hash) (you can shorten
+`--check` to `-c`).
+
+**Note:** the `--check` option was added in Mercurial 1.3, but it was broken.
+It's fixed in 1.3.1. If you're using something earlier than 1.3.1, you really
+should update.
+
+Logging commands like `hg log` and `hg graphlog` will show you all the
+changesets in the repository, so there's no danger of "losing" changesets.
+
+### Advantages
+
+This is the fastest, easiest way to branch. You don't have to think of a name
+or close/delete anything when you're finished — just update and commit.
+
+This method is *great* for quick-fix, two-or-three-changeset branches.
+
+### Disadvantages
+
+Using anonymous branching obviously means that there won't be any descriptive
+name for a branch, so you'll need to write good commit messages if you want to
+remember what a branch was for a couple of months later.
+
+Not having a single name to represent a branch means that you'll need to look
+up the revision numbers or hashes with `hg log` or `hg graphlog` each time you
+want to switch back and forth. If you're switching a lot this might be more
+trouble than it's worth.
+
+### Comparison to git
+
+Git has no real way to handle this. Sure, it lets you update and commit, but
+if you don't create a (named) ref to that new commit you're never going to
+find it again once you switch to another one. Well, unless you feel like
+grep'ing through a bunch of log output.
+
+Oh, and hopefully it doesn't get garbage collected.
+
+Sometimes you might not want to think up a name for a quick-fix branch. With
+git you *have* to name it if you want to really do anything with it, with
+Mercurial you don't.
+
+One More Difference Between Mercurial and git
+---------------------------------------------
+
+There's one more *big* difference between Mercurial's branching and git's
+branching:
+
+**Mercurial will push/pull *all* branches by default, while git will push/pull
+only the *current* branch.**
+
+This is important if you're a git user working with Mercurial. If you want to
+push/pull only a single branch with Mercurial you can use the `--rev` option
+(`-r` for short) and specify the tip revision of the branch:
+
+```console
+$ hg push --rev branchname
+$ hg push --rev bookmarkname
+$ hg push --rev 4
+```
+
+If you specify a revision, Mercurial will push that changeset and any
+ancestors of it that the target doesn't already have.
+
+This doesn't apply when you use the "Branching with Clones" method because the
+branches are separate repositories.
+
+Conclusion
+----------
+
+I hope this guide is helpful. If you see anything I've missed, especially on
+the git side of things (I don't use git any more than I have to) or have any
+questions please let me know!
+
--- a/content/blog/2009/11/my-sitesprint-project-lindyhub.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,246 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "My SiteSprint Project: LindyHub"
-    snip: "I want to make something awesome for dancers."
-    created: 2009-11-16 19:15:07
-%}
-
-{% block article %}
-
-If you're a web designer and/or developer, you might have heard of
-[SiteSprint][]. From the SiteSprint page:
-
->What is the Site Sprint?  
->A challenge to do something about our personal websites. If you were looking 
->for a reason to rework an existing site or launch a new one, here it is.
-
-The event has a couple of rules:
-
->The Rules  
->1. Launch by 12/15  
->2. Document your process  
->3. On launch, share what you did and how you did it
-
-I've decided to join in and finish up a pet project of mine that I've been
-working on (very sporadically) for the past six months or so: [LindyHub][]
-
-[SiteSprint]: http://sitesprint.info/
-[LindyHub]: http://lindyhub.com/
-
-[TOC]
-
-Preface: About Swing Dancing
-----------------------------
-
-If you're a dancer, go ahead and skip to the next section. This is for the
-programmers and designers that might not have heard of Lindy Hop.
-
-[Lindy Hop][] is a form of swing dancing. I've been doing it for six years and
-love it.
-
-Part of the Lindy Hop culture consists of "exchanges" and "workshop weekends".
-The general idea is that a group of dancers will host one of these events on a
-weekend. They'll hire DJs or bands, and teachers if they're going to have
-classes, and plan out a whole weekend of awesomeness.
-
-Dancers from far and wide will travel to these events to meet and dance with
-new people (and old friends).
-
-If you want more background on dancing find me on [Twitter][twsl] and I'll
-gladly explain more, but this in-a-nutshell explanation should be enough for
-you to understand the rest of this entry.
-
-[Lindy Hop]: http://en.wikipedia.org/wiki/Lindy_hop
-[twsl]: {{links.twsl}}
-
-The Problem
------------
-
-LindyHub is a project I've been working on for about six months off and on in
-my spare time and it was rolling around in my head before that.
-
-Over the last few years or so I've been getting back into web development and
-design. At the beginning of this year I started to notice a trend: most
-websites for Lindy Hop and blues events are very basic and unpolished. Some of
-the things I've noticed about almost every event site:
-
-* They have a form for you to register for the event, but the form almost
-  never has any nice inline validation of your input.
-* Every site's form is different -- you have to read every single one
-  carefully to see exactly what they want.
-* You end up entering the same information every single time for every event:
-  name, phone number, email, etc.
-* Housing is a toss up. Sometimes they have a place for it in the registration
-  form, other times they just say "Email aaa@bbb.com if you need housing."
-  That's a lot of emails for the housing coordinator to sort through and quite
-  often it can become a mess.
-* Some of them list addresses for each venue, which is great for those of us
-  that have GPSes. Sometimes they just give driving directions to and from
-  each one, which is terrible if you just want to type each one into your GPS
-  or print off directions from Google Maps before you go.
-* Only one event that I've gone to ([Blues Muse][] in Philly) has had a "Who's
-  Coming" list so you could see who else was going to the event (you could
-  choose whether or not to let them show your name when you registered).
-  Sometimes you can figure this out from Facebook event pages, but that's
-  pretty unreliable.
-
-There are other things, but those are the big ones.
-
-Now, I completely understand why people don't add those features to their
-event sites. It doesn't make sense to spend 10 hours adding cool features that
-are nice to have but not really necessary if your website is only going to be
-used for a single event. Those 10 hours could be spent promoting your event
-and getting more people to come which is better for everyone.
-
-Around the time I was noticing these things I was also starting to get back
-into contributing to open source projects. Two of the big project hosting
-sites nowadays are [BitBucket][] and [GitHub][]. I noticed how they both make
-starting a new project almost trivially easy -- you sign up for an account and
-within two minutes people can view and contribute back to your new project.
-They've fostered a lot of collaboration in the open source community and it's
-been a very good thing all around.
-
-The two ideas came together in my head pretty quickly. I started thinking
-about designing a site that made setting up a dance event almost as easy as
-forking a project on BitBucket.
-
-Sure, every organizer spending 10 hours to add cool features to their event
-site doesn't really make sense. But what if one person spent a couple hundred
-hours and built a site that let every organizer add those features in 10
-*minutes*? After 20 or 30 events it's saved those couple hundred hours and
-just gets better from there.
-
-The more I thought about it the more it seemed like a good idea. I'd been
-learning a lot about web development and about six months ago I decided I was
-competent enough to handle something like this, and started working on the
-LindyHub core.
-
-[Blues Muse]: http://www.lindyandblues.com/events/2009/bluesmuse/
-[BitBucket]: http://bitbucket.org/
-[GitHub]: http://github.com/
-
-LindyHub's Current State
-------------------------
-
-I've been working on LindyHub off and on for the past six months or so, and it
-has been coming along pretty well. I decided to use SiteSprint as motivation
-to buckle down and complete it to a point where I can invite a few organizers
-to give it a try in a "closed-beta" period. From there I'll work out any kinks
-and open it up for public use.
-
-Here are some of the things the site can do *right now*:
-
-* Users can sign up and create profiles for themselves. "Forgot my password"
-  and such is supported.
-* They can view (and search for) events that are happening in the future, and
-  comment on them.
-* They can create a new event and add things to its schedule.
-* The schedule is formatted nicely. If an event starts before 5 AM it's
-  grouped with the previous day's events because it's probably a late night
-  dance.
-* Venues will add links to Google Maps if the organizers put in the address.
-* Organizers can let LindyHub handle event registration for them. They specify
-  how they want to be paid: door, check, and/or PayPal. If it's PayPal,
-  LindyHub takes the email address that should receive the money and handles
-  creating the PayPal "Buy Now" button.
-* Early registration is supported -- organizers can specify a cutoff date and
-  the early/late prices if they like.
-* LindyHub doesn't *have* to be used for the registration. Organizers can opt
-  to handle registration themselves and just put the event on LindyHub to help
-  more people find it.
-* Users can register for events quickly and easily. LindyHub will ask them how
-  they want to pay and tell them how to do it.
-* When they register they can allow other people to see that they're going to
-  the event. If they do, they'll show up in the list on the event page.
-* Organizers can see nicely formatted lists of registration/payment
-  information and housing requests.
-
-My Goals for the Sprint (and Beyond)
-------------------------------------
-
-Some of the things I'm planning on adding to the site in during the sprint
-are:
-
-* Redesign the interface. I'm not a designer, but I can certainly do better
-  than the spartan design I've thrown together during development.
-* Better, Javascript-based form fields. They'll validate the input before you
-  even click "Submit" (so you can correct mistakes immediately) and provide
-  nice date/time pickers for the date and time fields. I wanted to make sure
-  the site works 100% for people with JavaScript turned off before I started
-  relying on it to make things pretty.
-* Mobile stylesheets for iPhone users.
-* Tagging events with tags like "lindyhop, blues, workshop, exchange,
-  gordonwebster, etc." This will make it easier to find events you're
-  interested in. This will also be easy to add.
-* "Friending" other users. This would let you see what your friends are going
-  to and would be awesome (for me, at least).
-* Location-based features. LindyHub can already store your hometown and the
-  locations of events. It wouldn't be terribly difficult to parse this
-  information into a latitude and longitude. Once that's done it's simple to
-  calculate the distance to events and say "Show me all events within 300
-  miles of my hometown" or "Show me everyone going to this event that lives
-  within 30 miles of me because we might want to carpool."
-* Automatically email reminders to people a week before the event. The emails
-  could include links to Google Maps for the first (and other) venues to make
-  it take only one click to print directions. There are a lot of other things
-  that would be nice to include too -- I've been holding off on this because
-  it really requires the attention of a copywriter to get right.
-* Provide an easy-to-use interface for organizers to assign people that have
-  requested housing to people that offer it.
-* Send emails to guest/host groups automatically to make sure guests have
-  their host's contact information (and vice versa).
-* Translations into different languages. This will be pretty simple if someone
-  wants to volunteer to translate (I only speak English and American Sign
-  Language myself).
-* Suggesting events a user might like. This is something for the far future,
-  but it would give me a chance to play around in another favorite area of
-  mine: artificial intelligence. I have some ideas on how to implement it but
-  it's not critical so I'm not looking at it right now.
-
-There are a whole slew of other things I have tumbling about in my head, but
-those should be enough to give you an idea of where the site can go.
-
-**Above all, my goal is to spend as much time as it takes to create a site
-that will save organizers a few hours of their time and make it easier for
-dancers to find events they want to go to.**
-
-I *don't* want to try to create a site that will accommodate *every* event. If
-I make LindyHub flexible enough to handle Frankie 95 it will become so
-complicated that no other events will want to use it. I want it to work for
-the 85% or 90% of events that just need the most common features. Doing that
-will make it far, far easier to use, which means more people will use it.
-
-For the Nerds: What I'm Using
------------------------------
-
-LindyHub is built with [Django][] and [Python][].
-
-It's hosted on [WebFaction][] and uses a [PostgreSQL][] database to store its
-data.
-
-It uses [Aardvark Legs][] to keep me sane while writing the CSS, and will use
-[jQuery][] for the inline form validation.
-
-I'm happy to go further in depth if you're curious -- find me on [Twitter][twsl].
-
-[Django]: {{links.django}}
-[Python]: {{links.python}}
-[WebFaction]: {{links.webfaction}}
-[PostgreSQL]: http://www.postgresql.org/
-[Aardvark Legs]: {{links.aardvarklegs}}
-[jQuery]: http://jquery.com/
-
-If You're Interested, Follow My Progress!
------------------------------------------
-
-I'm going to be working on the site a lot over the next month. I might write
-another blog entry or two, but I'll try to post updates to
-[@lindyhub][twitter] on Twitter much more often.
-
-If there's anything specific you want to know find me on [Twitter][twsl] and
-I'll be happy to answer!
-
-[twitter]: http://twitter.com/lindyhub/
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2009/11/my-sitesprint-project-lindyhub.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,243 @@
++++
+title = "My SiteSprint Project: LindyHub"
+snip = "I want to make something awesome for dancers."
+date = 2009-11-16T19:15:07Z
+draft = false
+
++++
+
+If you're a web designer and/or developer, you might have heard of
+[SiteSprint][]. From the SiteSprint page:
+
+>What is the Site Sprint?  
+>A challenge to do something about our personal websites. If you were looking 
+>for a reason to rework an existing site or launch a new one, here it is.
+
+The event has a couple of rules:
+
+>The Rules  
+>1. Launch by 12/15  
+>2. Document your process  
+>3. On launch, share what you did and how you did it
+
+I've decided to join in and finish up a pet project of mine that I've been
+working on (very sporadically) for the past six months or so: [LindyHub][]
+
+[SiteSprint]: http://sitesprint.info/
+[LindyHub]: http://lindyhub.com/
+
+{{% toc %}}
+
+Preface: About Swing Dancing
+----------------------------
+
+If you're a dancer, go ahead and skip to the next section. This is for the
+programmers and designers that might not have heard of Lindy Hop.
+
+[Lindy Hop][] is a form of swing dancing. I've been doing it for six years and
+love it.
+
+Part of the Lindy Hop culture consists of "exchanges" and "workshop weekends".
+The general idea is that a group of dancers will host one of these events on a
+weekend. They'll hire DJs or bands, and teachers if they're going to have
+classes, and plan out a whole weekend of awesomeness.
+
+Dancers from far and wide will travel to these events to meet and dance with
+new people (and old friends).
+
+If you want more background on dancing find me on [Twitter][twsl] and I'll
+gladly explain more, but this in-a-nutshell explanation should be enough for
+you to understand the rest of this entry.
+
+[Lindy Hop]: http://en.wikipedia.org/wiki/Lindy_hop
+[twsl]: {{links.twsl}}
+
+The Problem
+-----------
+
+LindyHub is a project I've been working on for about six months off and on in
+my spare time and it was rolling around in my head before that.
+
+Over the last few years or so I've been getting back into web development and
+design. At the beginning of this year I started to notice a trend: most
+websites for Lindy Hop and blues events are very basic and unpolished. Some of
+the things I've noticed about almost every event site:
+
+* They have a form for you to register for the event, but the form almost
+  never has any nice inline validation of your input.
+* Every site's form is different — you have to read every single one
+  carefully to see exactly what they want.
+* You end up entering the same information every single time for every event:
+  name, phone number, email, etc.
+* Housing is a toss up. Sometimes they have a place for it in the registration
+  form, other times they just say "Email aaa@bbb.com if you need housing."
+  That's a lot of emails for the housing coordinator to sort through and quite
+  often it can become a mess.
+* Some of them list addresses for each venue, which is great for those of us
+  that have GPSes. Sometimes they just give driving directions to and from
+  each one, which is terrible if you just want to type each one into your GPS
+  or print off directions from Google Maps before you go.
+* Only one event that I've gone to ([Blues Muse][] in Philly) has had a "Who's
+  Coming" list so you could see who else was going to the event (you could
+  choose whether or not to let them show your name when you registered).
+  Sometimes you can figure this out from Facebook event pages, but that's
+  pretty unreliable.
+
+There are other things, but those are the big ones.
+
+Now, I completely understand why people don't add those features to their
+event sites. It doesn't make sense to spend 10 hours adding cool features that
+are nice to have but not really necessary if your website is only going to be
+used for a single event. Those 10 hours could be spent promoting your event
+and getting more people to come which is better for everyone.
+
+Around the time I was noticing these things I was also starting to get back
+into contributing to open source projects. Two of the big project hosting
+sites nowadays are [BitBucket][] and [GitHub][]. I noticed how they both make
+starting a new project almost trivially easy — you sign up for an account and
+within two minutes people can view and contribute back to your new project.
+They've fostered a lot of collaboration in the open source community and it's
+been a very good thing all around.
+
+The two ideas came together in my head pretty quickly. I started thinking
+about designing a site that made setting up a dance event almost as easy as
+forking a project on BitBucket.
+
+Sure, every organizer spending 10 hours to add cool features to their event
+site doesn't really make sense. But what if one person spent a couple hundred
+hours and built a site that let every organizer add those features in 10
+*minutes*? After 20 or 30 events it's saved those couple hundred hours and
+just gets better from there.
+
+The more I thought about it the more it seemed like a good idea. I'd been
+learning a lot about web development and about six months ago I decided I was
+competent enough to handle something like this, and started working on the
+LindyHub core.
+
+[Blues Muse]: http://www.lindyandblues.com/events/2009/bluesmuse/
+[BitBucket]: http://bitbucket.org/
+[GitHub]: http://github.com/
+
+LindyHub's Current State
+------------------------
+
+I've been working on LindyHub off and on for the past six months or so, and it
+has been coming along pretty well. I decided to use SiteSprint as motivation
+to buckle down and complete it to a point where I can invite a few organizers
+to give it a try in a "closed-beta" period. From there I'll work out any kinks
+and open it up for public use.
+
+Here are some of the things the site can do *right now*:
+
+* Users can sign up and create profiles for themselves. "Forgot my password"
+  and such is supported.
+* They can view (and search for) events that are happening in the future, and
+  comment on them.
+* They can create a new event and add things to its schedule.
+* The schedule is formatted nicely. If an event starts before 5 AM it's
+  grouped with the previous day's events because it's probably a late night
+  dance.
+* Venues will add links to Google Maps if the organizers put in the address.
+* Organizers can let LindyHub handle event registration for them. They specify
+  how they want to be paid: door, check, and/or PayPal. If it's PayPal,
+  LindyHub takes the email address that should receive the money and handles
+  creating the PayPal "Buy Now" button.
+* Early registration is supported — organizers can specify a cutoff date and
+  the early/late prices if they like.
+* LindyHub doesn't *have* to be used for the registration. Organizers can opt
+  to handle registration themselves and just put the event on LindyHub to help
+  more people find it.
+* Users can register for events quickly and easily. LindyHub will ask them how
+  they want to pay and tell them how to do it.
+* When they register they can allow other people to see that they're going to
+  the event. If they do, they'll show up in the list on the event page.
+* Organizers can see nicely formatted lists of registration/payment
+  information and housing requests.
+
+My Goals for the Sprint (and Beyond)
+------------------------------------
+
+Some of the things I'm planning on adding to the site in during the sprint
+are:
+
+* Redesign the interface. I'm not a designer, but I can certainly do better
+  than the spartan design I've thrown together during development.
+* Better, Javascript-based form fields. They'll validate the input before you
+  even click "Submit" (so you can correct mistakes immediately) and provide
+  nice date/time pickers for the date and time fields. I wanted to make sure
+  the site works 100% for people with JavaScript turned off before I started
+  relying on it to make things pretty.
+* Mobile stylesheets for iPhone users.
+* Tagging events with tags like "lindyhop, blues, workshop, exchange,
+  gordonwebster, etc." This will make it easier to find events you're
+  interested in. This will also be easy to add.
+* "Friending" other users. This would let you see what your friends are going
+  to and would be awesome (for me, at least).
+* Location-based features. LindyHub can already store your hometown and the
+  locations of events. It wouldn't be terribly difficult to parse this
+  information into a latitude and longitude. Once that's done it's simple to
+  calculate the distance to events and say "Show me all events within 300
+  miles of my hometown" or "Show me everyone going to this event that lives
+  within 30 miles of me because we might want to carpool."
+* Automatically email reminders to people a week before the event. The emails
+  could include links to Google Maps for the first (and other) venues to make
+  it take only one click to print directions. There are a lot of other things
+  that would be nice to include too — I've been holding off on this because
+  it really requires the attention of a copywriter to get right.
+* Provide an easy-to-use interface for organizers to assign people that have
+  requested housing to people that offer it.
+* Send emails to guest/host groups automatically to make sure guests have
+  their host's contact information (and vice versa).
+* Translations into different languages. This will be pretty simple if someone
+  wants to volunteer to translate (I only speak English and American Sign
+  Language myself).
+* Suggesting events a user might like. This is something for the far future,
+  but it would give me a chance to play around in another favorite area of
+  mine: artificial intelligence. I have some ideas on how to implement it but
+  it's not critical so I'm not looking at it right now.
+
+There are a whole slew of other things I have tumbling about in my head, but
+those should be enough to give you an idea of where the site can go.
+
+**Above all, my goal is to spend as much time as it takes to create a site
+that will save organizers a few hours of their time and make it easier for
+dancers to find events they want to go to.**
+
+I *don't* want to try to create a site that will accommodate *every* event. If
+I make LindyHub flexible enough to handle Frankie 95 it will become so
+complicated that no other events will want to use it. I want it to work for
+the 85% or 90% of events that just need the most common features. Doing that
+will make it far, far easier to use, which means more people will use it.
+
+For the Nerds: What I'm Using
+-----------------------------
+
+LindyHub is built with [Django][] and [Python][].
+
+It's hosted on [WebFaction][] and uses a [PostgreSQL][] database to store its
+data.
+
+It uses [Aardvark Legs][] to keep me sane while writing the CSS, and will use
+[jQuery][] for the inline form validation.
+
+I'm happy to go further in depth if you're curious — find me on [Twitter][twsl].
+
+[Django]: {{links.django}}
+[Python]: {{links.python}}
+[WebFaction]: {{links.webfaction}}
+[PostgreSQL]: http://www.postgresql.org/
+[Aardvark Legs]: {{links.aardvarklegs}}
+[jQuery]: http://jquery.com/
+
+If You're Interested, Follow My Progress!
+-----------------------------------------
+
+I'm going to be working on the site a lot over the next month. I might write
+another blog entry or two, but I'll try to post updates to
+[@lindyhub][twitter] on Twitter much more often.
+
+If there's anything specific you want to know find me on [Twitter][twsl] and
+I'll be happy to answer!
+
+[twitter]: http://twitter.com/lindyhub/
+
--- a/content/blog/2010/01/moving-from-django-to-hyde.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,461 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Moving from Django to Hyde"
-    snip: "Another year, another rewrite."
-    created: 2010-01-15 20:14:00
-%}
-
-{% block article %}
-
-Almost exactly one year ago I posted a blog entry about how I [rewrote this
-site][rewrite] using [Django][]. It's a new year, and once again I've
-rewritten the site.
-
-If you've visited my site before you may have noticed some small style tweaks.
-I've cleaned up a few things and I think the site looks better overall. The
-biggest change, however, is that I completely rewrote the core -- this time
-with [Hyde][].
-
-Hyde is a "static site generator" written in [Python][], similar to
-[Jekyll][], [Blatter][] and [Pilcrow][]. I chose it over the others because
-it's written in Python (unlike Jekyll), more flexible than Blatter and more
-mature than Pilcrow.
-
-Rewriting an existing site that gets a decent amount of visitors is different
-than creating a new site from scratch, so I decided to write this entry to
-describe some of the issues I ran into and how I tackled them.
-
-[Django]: {{links.django}}
-[rewrite]: /blog/2009/01/site-redesign/
-[Hyde]: {{links.hyde}}
-[Python]: {{links.python}}
-[Jekyll]: http://jekyllrb.com/
-[Blatter]: {{links.blatter}}
-[Pilcrow]: http://inky.github.com/pilcrow/
-
-[TOC]
-
-Why Static?
------------
-
-There are a couple of reasons I decided to switch to a static site.
-
-### Less Memory Needed
-
-I use [WebFaction][] for my web hosting, and with my current plan I have a
-limit on how much memory I can use at any given time. Each Django site takes
-up around 20mb of memory on the server.
-
-By switching to a static set of HTML pages for my site I save those 20mb so I
-can use them for something else (like a staging site for another project). My
-site doesn't particularly *need* all of the functionality Django can provide,
-so I figured I'd switch to a static site and save the memory.
-
-[WebFaction]: {{links.webfaction}}
-
-### Static Pages are Faster
-
-My site doesn't get an enormous amount of traffic, so the Django instances
-weren't really working very hard. Still, serving a static page through Apache
-or nginx is always going to be faster than running it through Django.
-Faster-loading pages is always a good thing, even if the speed increase isn't
-very large.
-
-### Easier to Maintain
-
-This is the main reason I switched. Previously, to edit a blog entry I would
-log in through Django's admin interface and edit the entry. With Hyde, I
-simply edit a file (or create a new one) on my machine and then run a single
-command to publish it.
-
-Another problem with the old site is that I needed to be connected to the
-internet to get to the admin interface, so I couldn't update entries (or
-publish new ones) offline. I usually have an internet connection, but
-occasionally I don't. Now I can edit as much as I like on my own machine and
-only need a connection to publish the finished product.
-
-### Easier to Backup
-
-One more advantage of Hyde is that the site structure *and* content are all
-held in the same place. I keep everything in a [Mercurial][] repository, and
-so every time I push that repository somewhere it creates a full backup of the
-site's code *and* content. If WebFaction's server catches on fire I still have
-everything on my local machine (and on BitBucket).
-
-I've toyed around with backing up Django's database tables when I had my old
-site, but this new method is far less work.
-
-[Mercurial]: {{links.mercurial}}
-
-Getting Started
----------------
-
-I wanted a fresh start when I was rewriting the site, so I went ahead and
-created a brand new folder and Mercurial repository for it.
-
-I used `hyde --init` to lay out a skeleton in the new folder. Then I stripped
-out a lot of the default items that get added with `--init` and created the
-directory structure I wanted to use, with stubs for each of the main content
-files I knew I'd need.
-
-Finally, I went ahead and filled some of the basic values in the `settings.py`
-file.
-
-Layout and Styling
-------------------
-
-Once I had a skeleton in place I started working on layout of the site.
-
-### Cleanup
-
-The templates created by `hyde --init` are functional, but when you look at
-the code they're a mess. The indentation is strange and inconsistent and
-there's trailing whitespace all over the place. I like clean code so I sat
-down and cleaned everything up before I started making any real changes.
-
-### Rewriting the Layout and Styles
-
-After I finished cleaning up the templates I duplicated the HTML structure and
-styles of the old site from scratch. The old site had gone through a bunch of
-iterations and I was a bit sloppy in my editing, so there was a lot of cruft
-that had snuck in. I wanted a truly *fresh* start for the site, so I buckled
-down and did it all again.
-
-### A New CSS Framework
-
-Previously I used the [Blueprint CSS framework][blueprint] to make laying out
-the site easier. Blueprint is a great framework, but it's more powerful than I
-need for a site as simple as this one. The site now uses [Aardvark Legs][aal],
-which is a much simpler framework that simply sets up a great vertical rhythm
-and leaves you free to lay out the horizontal structure yourself.
-
-### Pagination
-
-Before the rewrite the list of blog entries used to be paginated. Hyde
-supports pagination but I decided against using it because I simply don't
-write enough to make it necessary. All the blog entries are now listed on a
-single page, which means that you can use Cmd+F to find an article if you're
-looking for something specific.
-
-[blueprint]: http://www.blueprintcss.org/
-[aal]: {{links.aardvarklegs}}
-
-Using Fabric to Type Less
--------------------------
-
-I realized very quickly that typing `hyde -g -s . && hyde -w -s .` would get
-old pretty quickly, so I installed [Fabric][] and wrote a fabfile.
-
-Fabric is a tool written in Python that lets you define tasks and execute them
-by running `fab taskname`. Fabfiles are pure Python, so you can build larger
-tasks out of smaller ones very easily and do just about anything you want.
-It's similar to [ant][], but without the excessive over-engineering.
-
-You can view the [current fabfile][fabfile] on BitBucket. At the time of this
-entry it looks like this:
-
-    :::python
-    from fabric.api import *
-    import os
-    import fabric.contrib.project as project
-
-    PROD = 'sjl.webfactional.com'
-    DEST_PATH = '/home/sjl/webapps/slc/'
-    ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
-    DEPLOY_PATH = os.path.join(ROOT_PATH, 'deploy')
-
-    def clean():
-        local('rm -rf ./deploy')
-
-    def regen():
-        clean()
-        local('hyde -g -s .')
-
-    def serve():
-        local('hyde -w -s .')
-
-    def reserve():
-        regen()
-        serve()
-
-    def smush():
-        local('smusher ./media/images')
-
-    @hosts(PROD)
-    def publish():
-        regen()
-        project.rsync_project(
-            remote_dir=DEST_PATH,
-            local_dir=DEPLOY_PATH.rstrip('/') + '/',
-            delete=True
-        )
-
-The task I use most often while developing is `fab reserve`, which regenerates
-the site and then starts serving it so I can view the result in a browser.
-
-I use `fab smush` whenever I add new images. This runs [smusher][] on all of
-the images to optimize them without reducing quality.
-
-When I'm ready to publish changes to the live site I run `fab publish`, which
-will regenerate my local version and copy it up to the WebFaction server.
-
-[Fabric]: {{links.fabric}}
-[ant]: http://ant.apache.org/
-[fabfile]: http://bitbucket.org/sjl/stevelosh/src/tip/fabfile.py
-[smusher]: http://github.com/grosser/smusher
-
-Moving the Content
-------------------
-
-The content of the old site (blog entries, projects, and static pages like the
-[about page][]) was fairly easy to migrate over to the new one, because both
-versions use [Markdown][] to format the text.
-
-First I created an empty file for each page with a filename that matched the
-"slug" (last part of the URL) of the old page. Then I manually copied over the
-title, creation time and content for every page. I could have written a script
-to do this, but I don't have enough pages on the site to make it worth the
-time.
-
-[about page]: /about/
-[Markdown]: {{links.markdown}}
-
-Converting the Comments
------------------------
-
-At this point the new site was looking very much like the old one. The styles
-were (roughly) matching and the blog posts, entries, and static pages were all
-rendered nicely.
-
-The next big task was migrating all of the comments. Since the new site is
-static it can't handle dynamic content like comments on its own, so I decided
-to use [Disqus][]. I use Disqus for the comments on the [hg tip][] site and
-it's very nice. For that site I used it from the beginning, but for this
-rewrite I needed to somehow import all the old comments.
-
-To migrate the comments over I used [django-disqus][], but there was a small
-snag that I needed to deal with first.
-
-When I first wrote the old site I was just getting back into Django after not
-using it for a long time. I didn't know about Django's built-in comment
-models, so I created my own. They weren't as good as Django's, but they did
-the job and I didn't care enough to change them.
-
-This became a problem when it was time to import the old comments into Disqus.
-django-disqus only supports importing comments from Django's built-in comment
-models. To work around this I first had to convert the old comments into
-Django's built-in ones. I wrote a [small, hacky Python
-script][convert-comments] to do it:
-
-    :::python
-    #!/usr/bin/env python
-    
-    from django.core.management import setup_environ
-    import settings
-    setup_environ(settings)
-    
-    from markdown import Markdown
-    from django.contrib.comments.models import Comment
-    from django.contrib.sites.models import Site
-    from stevelosh.blog.models import Comment as BlogComment
-    from stevelosh.projects.models import Comment as ProjectComment
-    
-    
-    mdown = Markdown()
-    
-    site = Site.objects.all()[0]
-    blog_comments = BlogComment.objects.filter(spam=False)
-    project_comments = ProjectComment.objects.filter(spam=False)
-    
-    for bc in blog_comments:
-        c = Comment()
-        c.content_object = bc.entry
-        c.user_name = bc.name
-        c.comment = mdown.convert(bc.body)
-        c.submit_date = bc.submitted
-        c.site = site
-        c.is_public = True
-        c.is_removed = False
-        c.save()
-        # print 'http://%s%s' % (site.domain, c.content_object.get_absolute_url())
-    
-    for pc in project_comments:
-        c = Comment()
-        c.content_object = pc.project
-        c.user_name = pc.name
-        c.comment = mdown.convert(pc.body)
-        c.submit_date = pc.submitted
-        c.site = site
-        c.is_public = True
-        c.is_removed = False
-        c.save()
-        # print 'http://%s%s' % (site.domain, c.content_object.get_absolute_url())
-
-Yes, it's ugly. No, I don't care. It was run once or twice locally and once on
-the live server. It worked and I'll never need to run it again.
-
-Once I had the comments converted I could use django-disqus to migrate them.
-The import went very smoothly -- I ran one command and after a couple of
-minutes everything was in Disqus. Once that finished it was just a matter of
-adding the Disqus JavaScript to one of the templates.
-
-[Disqus]: http://disqus.com/
-[hg tip]: {{links.hgtip}}
-[django-disqus]: http://github.com/arthurk/django-disqus
-[convert-comments]: http://bitbucket.org/sjl/stevelosh/src/da98105753a1/convert-comments.py
-
-Rewriting the Old URLs
-----------------------
-
-Since I was pretty much starting from scratch with this rewrite I decided to
-clean up the URL structure of my blog. Previously a blog entry's URL looked
-like this:
-
-    :::text
-    http://stevelosh.com/blog/entry/2009/08/30/a-guide-to-branching-in-mercurial/
-
-The `/entry/` part of the URL was useless -- it just took up space, so I got
-rid of it. The year and month are useful to get an idea of how old an entry is
-just by looking at the link, so I left them in. The day, however, probably
-doesn't matter that much, so I took it out.
-
-The new URLs look like this:
-
-    :::text
-    http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/
-
-The problem with rewriting the URL structure is that there are already links
-around the web pointing at my entries. I didn't want those old links to break,
-so I crafted an [`.htaccess` file][htaccess] that would rewrite the old URLs
-into the new ones:
-
-    {% templatetag openblock %} if GENERATE_CLEAN_URLS {% templatetag closeblock %}
-    RewriteEngine on
-    RewriteBase {% templatetag openvariable %} node.site.settings.SITE_ROOT {% templatetag closevariable %}
-    
-    # Old URLs
-    RewriteRule ^blog/entry/(\d+)/(\d\d)/\d+/([^/]*)/?$ /blog/$1/$2/$3/ [R=301,L]
-    RewriteRule ^blog/entry/(\d+)/(\d)/\d+/([^/]*)/?$ /blog/$1/0$2/$3/ [R=301,L]
-    
-    {% templatetag openblock %} hyde_listing_page_rewrite_rules {% templatetag closeblock %}
-    
-    # listing pages whose names are the same as their enclosing folder's
-    RewriteCond %{REQUEST_FILENAME}/$1.html -f
-    RewriteRule ^([^/]*)/$ %{REQUEST_FILENAME}/$1.html
-    
-    # regular pages
-    RewriteCond %{REQUEST_FILENAME}.html -f
-    RewriteRule ^.*$ %{REQUEST_FILENAME}.html
-    
-    {% templatetag openblock %} endif {% templatetag closeblock %}
-
-Most of that file is the stock Hyde `.htaccess` file -- the two lines under `#
-Old URLs` are the ones that I added. It took me a while to get it right
-because I don't work with Apache's `mod_rewrite` very often, but it was worth
-it to avoid breaking all of the old links.
-
-[htaccess]: http://bitbucket.org/sjl/stevelosh/src/tip/content/.htaccess
-
-Creating an RSS Feed
---------------------
-
-I had an RSS feed for the old site which Django made very easy to set up. I
-definitely needed a feed for the new site, and fortunately Hyde provides a
-simple sample template that can be used to make an ATOM feed.
-
-I cleaned up the whitespace and formatting of that template a bit, adjusted a
-few variables for my needs, put it on [FeedBurner][] and everything was ready.
-
-[FeedBurner]: http://www.feedburner.com/
-
-Merging the Repositories
-------------------------
-
-The last step before I was finished was to merge the old and new repositories
-together so I wouldn't lose any of the history. It's probably not *too*
-important to keep the old site's history around, but I put a lot of work into
-it over the past year and it has some sentimental value.
-
-Fortunately it's very easy to [combine Mercurial repositories][combinerepos].
-I just pulled the old repository into the new one, merged the old head into
-the new one while discarding all the changes, and pushed it up to BitBucket.
-
-[combinerepos]: http://hgtip.com/tips/advanced/2009-11-17-combining-repositories/
-
-Still to Come
--------------
-
-At this point I felt the site was ready to be released, so I set up a new site
-on WebFaction and used Fabric to deploy it.
-
-I'm very happy with the result, but there are still a few things I'm going to
-fix/change in the future.
-
-### "Ago" Dates
-
-**UPDATE:** This is done. I've started using [timeago.js][] to render the
-"ago" dates.
-
-If you look at the top of each blog entry and project there's a line beneath
-the title that looks something like:
-
-    :::text
-    Posted on Monday, November 16, 2009 (1 month, 3 weeks ago).
-
-The `(1 month, 3 weeks ago)` part of that line is something that I really
-appreciate on blogs. When they just list the date I always have to do the math
-in my head to figure out roughly how old something is.
-
-With a static site, however, those times will quickly become inaccurate if I
-don't regenerate and publish the site regularly. I'm still thinking about the
-best way to work this out.
-
-One option is to use a cron job on the WebFaction server to regenerate the
-site every day, which would keep the times *fairly* accurate.
-
-Another option would be to use a bit of JavaScript to calculate and render the
-time when the page is loaded. This would make it *completely* accurate but
-wouldn't work if someone is browsing with JavaScript turned off.
-
-[timeago.js]: http://timeago.yarp.com/
-
-### Categories
-
-**UPDATE:** I've added categories.  Check out [this changeset][categorycset] to see what I had to do.
-
-Right now all the blog entries (and projects) are listed in a single
-chronological list. It would be great to break them up into categories so
-people can easily find the articles they're interested in.
-
-Hyde supports categories but I haven't spent the time to learn how to use them
-yet. I also need to figure out a way to work a list of categories into the
-design without cluttering things up too much.
-
-[categorycset]: http://bitbucket.org/sjl/stevelosh/changeset/08d7552b6237/
-
-### Use LessCSS
-
-**UPDATE:** This is done.  The main style file now uses LessCSS.
-
-[LessCSS][] is a language that extends CSS with some useful features like
-variables, mixins, operations and nested rules. It can make the styles of a
-site much, much cleaner.
-
-Hyde includes a LessCSS "processor" that will automatically render your
-LessCSS files into normal CSS. I'm planning on rewriting the site's styles in
-LessCSS and using the processor once I get some free time.
-
-[lesscss]: {{links.lesscss}}
-
-View the Code
--------------
-
-The code is on [BitBucket][bb-repo] and [GitHub][gh-repo]. Feel free to poke
-around and see how I've set things up. If you have questions or suggestions
-I'd love to hear them!
-
-[bb-repo]: http://bitbucket.org/sjl/stevelosh/
-[gh-repo]: http://github.com/sjl/stevelosh/
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/01/moving-from-django-to-hyde.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,462 @@
++++
+title = "Moving from Django to Hyde"
+snip = "Another year, another rewrite."
+date = 2010-01-15T20:14:00Z
+draft = false
+
++++
+
+Almost exactly one year ago I posted a blog entry about how I [rewrote this
+site][rewrite] using [Django][]. It's a new year, and once again I've
+rewritten the site.
+
+If you've visited my site before you may have noticed some small style tweaks.
+I've cleaned up a few things and I think the site looks better overall. The
+biggest change, however, is that I completely rewrote the core — this time
+with [Hyde][].
+
+Hyde is a "static site generator" written in [Python][], similar to
+[Jekyll][], [Blatter][] and [Pilcrow][]. I chose it over the others because
+it's written in Python (unlike Jekyll), more flexible than Blatter and more
+mature than Pilcrow.
+
+Rewriting an existing site that gets a decent amount of visitors is different
+than creating a new site from scratch, so I decided to write this entry to
+describe some of the issues I ran into and how I tackled them.
+
+[Django]: {{links.django}}
+[rewrite]: /blog/2009/01/site-redesign/
+[Hyde]: {{links.hyde}}
+[Python]: {{links.python}}
+[Jekyll]: http://jekyllrb.com/
+[Blatter]: {{links.blatter}}
+[Pilcrow]: http://inky.github.com/pilcrow/
+
+{{% toc %}}
+
+Why Static?
+-----------
+
+There are a couple of reasons I decided to switch to a static site.
+
+### Less Memory Needed
+
+I use [WebFaction][] for my web hosting, and with my current plan I have a
+limit on how much memory I can use at any given time. Each Django site takes
+up around 20mb of memory on the server.
+
+By switching to a static set of HTML pages for my site I save those 20mb so I
+can use them for something else (like a staging site for another project). My
+site doesn't particularly *need* all of the functionality Django can provide,
+so I figured I'd switch to a static site and save the memory.
+
+[WebFaction]: {{links.webfaction}}
+
+### Static Pages are Faster
+
+My site doesn't get an enormous amount of traffic, so the Django instances
+weren't really working very hard. Still, serving a static page through Apache
+or nginx is always going to be faster than running it through Django.
+Faster-loading pages is always a good thing, even if the speed increase isn't
+very large.
+
+### Easier to Maintain
+
+This is the main reason I switched. Previously, to edit a blog entry I would
+log in through Django's admin interface and edit the entry. With Hyde, I
+simply edit a file (or create a new one) on my machine and then run a single
+command to publish it.
+
+Another problem with the old site is that I needed to be connected to the
+internet to get to the admin interface, so I couldn't update entries (or
+publish new ones) offline. I usually have an internet connection, but
+occasionally I don't. Now I can edit as much as I like on my own machine and
+only need a connection to publish the finished product.
+
+### Easier to Backup
+
+One more advantage of Hyde is that the site structure *and* content are all
+held in the same place. I keep everything in a [Mercurial][] repository, and
+so every time I push that repository somewhere it creates a full backup of the
+site's code *and* content. If WebFaction's server catches on fire I still have
+everything on my local machine (and on BitBucket).
+
+I've toyed around with backing up Django's database tables when I had my old
+site, but this new method is far less work.
+
+[Mercurial]: {{links.mercurial}}
+
+Getting Started
+---------------
+
+I wanted a fresh start when I was rewriting the site, so I went ahead and
+created a brand new folder and Mercurial repository for it.
+
+I used `hyde --init` to lay out a skeleton in the new folder. Then I stripped
+out a lot of the default items that get added with `--init` and created the
+directory structure I wanted to use, with stubs for each of the main content
+files I knew I'd need.
+
+Finally, I went ahead and filled some of the basic values in the `settings.py`
+file.
+
+Layout and Styling
+------------------
+
+Once I had a skeleton in place I started working on layout of the site.
+
+### Cleanup
+
+The templates created by `hyde --init` are functional, but when you look at
+the code they're a mess. The indentation is strange and inconsistent and
+there's trailing whitespace all over the place. I like clean code so I sat
+down and cleaned everything up before I started making any real changes.
+
+### Rewriting the Layout and Styles
+
+After I finished cleaning up the templates I duplicated the HTML structure and
+styles of the old site from scratch. The old site had gone through a bunch of
+iterations and I was a bit sloppy in my editing, so there was a lot of cruft
+that had snuck in. I wanted a truly *fresh* start for the site, so I buckled
+down and did it all again.
+
+### A New CSS Framework
+
+Previously I used the [Blueprint CSS framework][blueprint] to make laying out
+the site easier. Blueprint is a great framework, but it's more powerful than I
+need for a site as simple as this one. The site now uses [Aardvark Legs][aal],
+which is a much simpler framework that simply sets up a great vertical rhythm
+and leaves you free to lay out the horizontal structure yourself.
+
+### Pagination
+
+Before the rewrite the list of blog entries used to be paginated. Hyde
+supports pagination but I decided against using it because I simply don't
+write enough to make it necessary. All the blog entries are now listed on a
+single page, which means that you can use Cmd+F to find an article if you're
+looking for something specific.
+
+[blueprint]: http://www.blueprintcss.org/
+[aal]: {{links.aardvarklegs}}
+
+Using Fabric to Type Less
+-------------------------
+
+I realized very quickly that typing `hyde -g -s . && hyde -w -s .` would get
+old pretty quickly, so I installed [Fabric][] and wrote a fabfile.
+
+Fabric is a tool written in Python that lets you define tasks and execute them
+by running `fab taskname`. Fabfiles are pure Python, so you can build larger
+tasks out of smaller ones very easily and do just about anything you want.
+It's similar to [ant][], but without the excessive over-engineering.
+
+You can view the [current fabfile][fabfile] on BitBucket. At the time of this
+entry it looks like this:
+
+```python
+from fabric.api import *
+import os
+import fabric.contrib.project as project
+
+PROD = 'sjl.webfactional.com'
+DEST_PATH = '/home/sjl/webapps/slc/'
+ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
+DEPLOY_PATH = os.path.join(ROOT_PATH, 'deploy')
+
+def clean():
+    local('rm -rf ./deploy')
+
+def regen():
+    clean()
+    local('hyde -g -s .')
+
+def serve():
+    local('hyde -w -s .')
+
+def reserve():
+    regen()
+    serve()
+
+def smush():
+    local('smusher ./media/images')
+
+@hosts(PROD)
+def publish():
+    regen()
+    project.rsync_project(
+        remote_dir=DEST_PATH,
+        local_dir=DEPLOY_PATH.rstrip('/') + '/',
+        delete=True
+    )
+```
+
+The task I use most often while developing is `fab reserve`, which regenerates
+the site and then starts serving it so I can view the result in a browser.
+
+I use `fab smush` whenever I add new images. This runs [smusher][] on all of
+the images to optimize them without reducing quality.
+
+When I'm ready to publish changes to the live site I run `fab publish`, which
+will regenerate my local version and copy it up to the WebFaction server.
+
+[Fabric]: {{links.fabric}}
+[ant]: http://ant.apache.org/
+[fabfile]: http://bitbucket.org/sjl/stevelosh/src/tip/fabfile.py
+[smusher]: http://github.com/grosser/smusher
+
+Moving the Content
+------------------
+
+The content of the old site (blog entries, projects, and static pages like the
+[about page][]) was fairly easy to migrate over to the new one, because both
+versions use [Markdown][] to format the text.
+
+First I created an empty file for each page with a filename that matched the
+"slug" (last part of the URL) of the old page. Then I manually copied over the
+title, creation time and content for every page. I could have written a script
+to do this, but I don't have enough pages on the site to make it worth the
+time.
+
+[about page]: /about/
+[Markdown]: {{links.markdown}}
+
+Converting the Comments
+-----------------------
+
+At this point the new site was looking very much like the old one. The styles
+were (roughly) matching and the blog posts, entries, and static pages were all
+rendered nicely.
+
+The next big task was migrating all of the comments. Since the new site is
+static it can't handle dynamic content like comments on its own, so I decided
+to use [Disqus][]. I use Disqus for the comments on the [hg tip][] site and
+it's very nice. For that site I used it from the beginning, but for this
+rewrite I needed to somehow import all the old comments.
+
+To migrate the comments over I used [django-disqus][], but there was a small
+snag that I needed to deal with first.
+
+When I first wrote the old site I was just getting back into Django after not
+using it for a long time. I didn't know about Django's built-in comment
+models, so I created my own. They weren't as good as Django's, but they did
+the job and I didn't care enough to change them.
+
+This became a problem when it was time to import the old comments into Disqus.
+django-disqus only supports importing comments from Django's built-in comment
+models. To work around this I first had to convert the old comments into
+Django's built-in ones. I wrote a [small, hacky Python
+script][convert-comments] to do it:
+
+    :::python
+    #!/usr/bin/env python
+
+    from django.core.management import setup_environ
+    import settings
+    setup_environ(settings)
+
+    from markdown import Markdown
+    from django.contrib.comments.models import Comment
+    from django.contrib.sites.models import Site
+    from stevelosh.blog.models import Comment as BlogComment
+    from stevelosh.projects.models import Comment as ProjectComment
+
+
+    mdown = Markdown()
+
+    site = Site.objects.all()[0]
+    blog_comments = BlogComment.objects.filter(spam=False)
+    project_comments = ProjectComment.objects.filter(spam=False)
+
+    for bc in blog_comments:
+        c = Comment()
+        c.content_object = bc.entry
+        c.user_name = bc.name
+        c.comment = mdown.convert(bc.body)
+        c.submit_date = bc.submitted
+        c.site = site
+        c.is_public = True
+        c.is_removed = False
+        c.save()
+        # print 'http://%s%s' % (site.domain, c.content_object.get_absolute_url())
+
+    for pc in project_comments:
+        c = Comment()
+        c.content_object = pc.project
+        c.user_name = pc.name
+        c.comment = mdown.convert(pc.body)
+        c.submit_date = pc.submitted
+        c.site = site
+        c.is_public = True
+        c.is_removed = False
+        c.save()
+        # print 'http://%s%s' % (site.domain, c.content_object.get_absolute_url())
+
+Yes, it's ugly. No, I don't care. It was run once or twice locally and once on
+the live server. It worked and I'll never need to run it again.
+
+Once I had the comments converted I could use django-disqus to migrate them.
+The import went very smoothly — I ran one command and after a couple of
+minutes everything was in Disqus. Once that finished it was just a matter of
+adding the Disqus JavaScript to one of the templates.
+
+[Disqus]: http://disqus.com/
+[hg tip]: {{links.hgtip}}
+[django-disqus]: http://github.com/arthurk/django-disqus
+[convert-comments]: http://bitbucket.org/sjl/stevelosh/src/da98105753a1/convert-comments.py
+
+Rewriting the Old URLs
+----------------------
+
+Since I was pretty much starting from scratch with this rewrite I decided to
+clean up the URL structure of my blog. Previously a blog entry's URL looked
+like this:
+
+```text
+http://stevelosh.com/blog/entry/2009/08/30/a-guide-to-branching-in-mercurial/
+```
+
+The `/entry/` part of the URL was useless — it just took up space, so I got
+rid of it. The year and month are useful to get an idea of how old an entry is
+just by looking at the link, so I left them in. The day, however, probably
+doesn't matter that much, so I took it out.
+
+The new URLs look like this:
+
+```text
+http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/
+```
+
+The problem with rewriting the URL structure is that there are already links
+around the web pointing at my entries. I didn't want those old links to break,
+so I crafted an [`.htaccess` file][htaccess] that would rewrite the old URLs
+into the new ones:
+
+    {% templatetag openblock %} if GENERATE_CLEAN_URLS {% templatetag closeblock %}
+    RewriteEngine on
+    RewriteBase {% templatetag openvariable %} node.site.settings.SITE_ROOT {% templatetag closevariable %}
+
+    # Old URLs
+    RewriteRule ^blog/entry/(\d+)/(\d\d)/\d+/([^/]*)/?$ /blog/$1/$2/$3/ [R=301,L]
+    RewriteRule ^blog/entry/(\d+)/(\d)/\d+/([^/]*)/?$ /blog/$1/0$2/$3/ [R=301,L]
+
+    {% templatetag openblock %} hyde_listing_page_rewrite_rules {% templatetag closeblock %}
+
+    # listing pages whose names are the same as their enclosing folder's
+    RewriteCond %{REQUEST_FILENAME}/$1.html -f
+    RewriteRule ^([^/]*)/$ %{REQUEST_FILENAME}/$1.html
+
+    # regular pages
+    RewriteCond %{REQUEST_FILENAME}.html -f
+    RewriteRule ^.*$ %{REQUEST_FILENAME}.html
+
+    {% templatetag openblock %} endif {% templatetag closeblock %}
+
+Most of that file is the stock Hyde `.htaccess` file — the two lines under `#
+Old URLs` are the ones that I added. It took me a while to get it right
+because I don't work with Apache's `mod_rewrite` very often, but it was worth
+it to avoid breaking all of the old links.
+
+[htaccess]: http://bitbucket.org/sjl/stevelosh/src/tip/content/.htaccess
+
+Creating an RSS Feed
+--------------------
+
+I had an RSS feed for the old site which Django made very easy to set up. I
+definitely needed a feed for the new site, and fortunately Hyde provides a
+simple sample template that can be used to make an ATOM feed.
+
+I cleaned up the whitespace and formatting of that template a bit, adjusted a
+few variables for my needs, put it on [FeedBurner][] and everything was ready.
+
+[FeedBurner]: http://www.feedburner.com/
+
+Merging the Repositories
+------------------------
+
+The last step before I was finished was to merge the old and new repositories
+together so I wouldn't lose any of the history. It's probably not *too*
+important to keep the old site's history around, but I put a lot of work into
+it over the past year and it has some sentimental value.
+
+Fortunately it's very easy to [combine Mercurial repositories][combinerepos].
+I just pulled the old repository into the new one, merged the old head into
+the new one while discarding all the changes, and pushed it up to BitBucket.
+
+[combinerepos]: http://hgtip.com/tips/advanced/2009-11-17-combining-repositories/
+
+Still to Come
+-------------
+
+At this point I felt the site was ready to be released, so I set up a new site
+on WebFaction and used Fabric to deploy it.
+
+I'm very happy with the result, but there are still a few things I'm going to
+fix/change in the future.
+
+### "Ago" Dates
+
+**UPDATE:** This is done. I've started using [timeago.js][] to render the
+"ago" dates.
+
+If you look at the top of each blog entry and project there's a line beneath
+the title that looks something like:
+
+```text
+Posted on Monday, November 16, 2009 (1 month, 3 weeks ago).
+```
+
+The `(1 month, 3 weeks ago)` part of that line is something that I really
+appreciate on blogs. When they just list the date I always have to do the math
+in my head to figure out roughly how old something is.
+
+With a static site, however, those times will quickly become inaccurate if I
+don't regenerate and publish the site regularly. I'm still thinking about the
+best way to work this out.
+
+One option is to use a cron job on the WebFaction server to regenerate the
+site every day, which would keep the times *fairly* accurate.
+
+Another option would be to use a bit of JavaScript to calculate and render the
+time when the page is loaded. This would make it *completely* accurate but
+wouldn't work if someone is browsing with JavaScript turned off.
+
+[timeago.js]: http://timeago.yarp.com/
+
+### Categories
+
+**UPDATE:** I've added categories.  Check out [this changeset][categorycset] to see what I had to do.
+
+Right now all the blog entries (and projects) are listed in a single
+chronological list. It would be great to break them up into categories so
+people can easily find the articles they're interested in.
+
+Hyde supports categories but I haven't spent the time to learn how to use them
+yet. I also need to figure out a way to work a list of categories into the
+design without cluttering things up too much.
+
+[categorycset]: http://bitbucket.org/sjl/stevelosh/changeset/08d7552b6237/
+
+### Use LessCSS
+
+**UPDATE:** This is done.  The main style file now uses LessCSS.
+
+[LessCSS][] is a language that extends CSS with some useful features like
+variables, mixins, operations and nested rules. It can make the styles of a
+site much, much cleaner.
+
+Hyde includes a LessCSS "processor" that will automatically render your
+LessCSS files into normal CSS. I'm planning on rewriting the site's styles in
+LessCSS and using the processor once I get some free time.
+
+[lesscss]: {{links.lesscss}}
+
+View the Code
+-------------
+
+The code is on [BitBucket][bb-repo] and [GitHub][gh-repo]. Feel free to poke
+around and see how I've set things up. If you have questions or suggestions
+I'd love to hear them!
+
+[bb-repo]: http://bitbucket.org/sjl/stevelosh/
+[gh-repo]: http://github.com/sjl/stevelosh/
+
--- a/content/blog/2010/01/the-real-difference-between-mercurial-and-git.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,136 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "The Real Difference Between Mercurial and Git"
-    snip: "It’s not their features."
-    created: 2010-01-20 21:56:00
-%}
-
-{% block article %}
-
-There are a
-[lot](http://nubyonrails.com/articles/five-features-from-mercurial-that-would-make-git-suck-less)
-of
-[other](http://www.rockstarprogrammer.org/post/2008/apr/06/differences-between-mercurial-and-git/)
-[blog](http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/)
-[posts](http://jointheconversation.org/2008/11/24/on-mercurial.html)
-and
-[web sites](http://www.whygitisbetterthanx.com/)
-comparing [Mercurial][] and [git][].
-
-Some of them are just plain outdated or wrong
-([whygitisbetterthanx.com](http://whygitisbetterthanx.com/) for example, lists
-"cheap local branching" as a git advantage over Mercurial, when Mercurial
-actually has [*cheaper* branching][hgbranch] than git!).
-
-Even the ones that aren't factually incorrect often seem to focus on features
-and speed. While this may have been relevant in the past, both systems have
-borrowed so much from each other that I don't think it's a very big deal
-today.
-
-This post is about what I feel are the last, most *important* differences
-between git and Mercurial.
-
-[Mercurial]: {{links.mercurial}}
-[git]: {{links.git}}
-[hgbranch]: /blog/2009/08/a-guide-to-branching-in-mercurial/#branching-anonymously
-
-[TOC]
-
-The Big Difference
-------------------
-
-I think there's still one very, very important difference left: **the systems
-*feel* very different to use**.
-
-This might sound trivial, but I don't think it is. How a system "feels"
-matters. Version control is something you use *constantly*, so it's important
-to find a system that fits your way of thinking.
-
-I'm a visual learner, so I find it helpful to make visual analogies when I'm
-trying to explain something. Here's how I visualize the difference between
-Mercurial and git:
-
-![Swiss Army Knife and Kitchen Utensils](/media/images{{parent_url}}/mercurial-vs-git.jpg "Mercurial vs. Git")
-
-Each git command is like a Swiss Army knife. For example, `git checkout` can
-switch the working directory to a new branch, update file contents to that of
-a previous revision, and even create a new branch. It's an efficient way to
-work once you learn all the arguments and how they interact with each other.
-
-Mercurial is like a well-equipped kitchen -- it has a lot of tools that each
-do one simple, well-defined thing, and do it well. To switch the working
-directory you use `hg update`. To update file contents to what they were at a
-previous revision you use `hg revert`. To create a new branch you use `hg
-branch`. This means there are more commands to learn, but each command is much
-simpler and more specific to a single conceptual task.
-
-I personally find Mercurial's philosophy easier to work with. It's easy for me
-to wrap my head around commands when they're more modular and less monolithic.
-
-For example, I find Mercurial's `help` entries easier to understand. This
-might just be because git's `help` entries are simply too long to read and
-digest when I'm in the middle of coding:
-
-    :::console
-    $ git help checkout | wc -l
-    236
-    
-    $ (hg help update && hg help branch && hg help revert) | wc -l
-    100
-
-I realize that not everyone feels the same way as I do. If you like git's way
-of thinking better, you should certainly use it.
-
-Other Differences
------------------
-
-Aside from their "feels" I see two other big differences that still remain
-between git and Mercurial.
-
-### BitBucket and GitHub
-
-A major difference between the two systems is their most popular hosting
-sites: [BitBucket][] and [GitHub][]. GitHub is leaps and bounds above
-BitBucket in pretty much any aspect you look at: graphic design, popularity,
-speed, and/or features. Every time I've seriously considered moving to git it
-was purely because of this disparity.
-
-I don't like using git itself (though it's *far* better than SVN or CVS), but
-GitHub is such an awesome site that I've considered switching just to use it.
-You can chalk it up to "popularity" (i.e. git has more users, so GitHub is
-more profitable and so has more money to spend on development), but the fact
-is that GitHub is still far better than BitBucket.
-
-[BitBucket]: {{links.bitbucket}}
-[GitHub]: {{links.github}}
-
-### Git's Index
-
-One of the features that git users talk about often is git's
-[index][gitindex]. Mercurial has the [record][] extension, but it's not really
-the same thing.
-
-I personally don't like the index. I feel that git encourages people to check
-in changesets that contain code which they've never tested (or even built)
-because the index is such a prominent part of git's workflow.
-
-Yes, one can argue that you don't actually *push* changes until you've got a
-working state. The problem is that when you then try to run `git bisect` later
-to find a bug you'll have to waste time skipping over changesets that don't
-build. You could use `git rebase --interactive` to fold partial changesets
-into one big one, but again, my gut feeling is that few people actually bother
-*testing* the results.
-
-With all that said, I've [considered][] creating a Mercurial extension that
-adds git's index functionality to Mercurial, because I think it would make the
-transition to Mercurial easier for git users. I've had enough experience with
-Mercurial's internals to know that such a thing is *possible*, but I simply
-don't have the time to do it *all* myself. If you're interested in helping out
-please let me know!
-
-[gitindex]: http://book.git-scm.com/1_the_git_index.html
-[record]: http://mercurial.selenic.com/wiki/RecordExtension
-[considered]: http://twitter.com/stevelosh/status/7106305374
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/01/the-real-difference-between-mercurial-and-git.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,134 @@
++++
+title = "The Real Difference Between Mercurial and Git"
+snip = "It’s not their features."
+date = 2010-01-20T21:56:00Z
+draft = false
+
++++
+
+There are a
+[lot](http://nubyonrails.com/articles/five-features-from-mercurial-that-would-make-git-suck-less)
+of
+[other](http://www.rockstarprogrammer.org/post/2008/apr/06/differences-between-mercurial-and-git/)
+[blog](http://importantshock.wordpress.com/2008/08/07/git-vs-mercurial/)
+[posts](http://jointheconversation.org/2008/11/24/on-mercurial.html)
+and
+[web sites](http://www.whygitisbetterthanx.com/)
+comparing [Mercurial][] and [git][].
+
+Some of them are just plain outdated or wrong
+([whygitisbetterthanx.com](http://whygitisbetterthanx.com/) for example, lists
+"cheap local branching" as a git advantage over Mercurial, when Mercurial
+actually has [*cheaper* branching][hgbranch] than git!).
+
+Even the ones that aren't factually incorrect often seem to focus on features
+and speed. While this may have been relevant in the past, both systems have
+borrowed so much from each other that I don't think it's a very big deal
+today.
+
+This post is about what I feel are the last, most *important* differences
+between git and Mercurial.
+
+[Mercurial]: {{links.mercurial}}
+[git]: {{links.git}}
+[hgbranch]: /blog/2009/08/a-guide-to-branching-in-mercurial/#branching-anonymously
+
+{{% toc %}}
+
+The Big Difference
+------------------
+
+I think there's still one very, very important difference left: **the systems
+*feel* very different to use**.
+
+This might sound trivial, but I don't think it is. How a system "feels"
+matters. Version control is something you use *constantly*, so it's important
+to find a system that fits your way of thinking.
+
+I'm a visual learner, so I find it helpful to make visual analogies when I'm
+trying to explain something. Here's how I visualize the difference between
+Mercurial and git:
+
+![Swiss Army Knife and Kitchen Utensils](/media/images/blog/2010/01/mercurial-vs-git.jpg "Mercurial vs. Git")
+
+Each git command is like a Swiss Army knife. For example, `git checkout` can
+switch the working directory to a new branch, update file contents to that of
+a previous revision, and even create a new branch. It's an efficient way to
+work once you learn all the arguments and how they interact with each other.
+
+Mercurial is like a well-equipped kitchen — it has a lot of tools that each
+do one simple, well-defined thing, and do it well. To switch the working
+directory you use `hg update`. To update file contents to what they were at a
+previous revision you use `hg revert`. To create a new branch you use `hg
+branch`. This means there are more commands to learn, but each command is much
+simpler and more specific to a single conceptual task.
+
+I personally find Mercurial's philosophy easier to work with. It's easy for me
+to wrap my head around commands when they're more modular and less monolithic.
+
+For example, I find Mercurial's `help` entries easier to understand. This
+might just be because git's `help` entries are simply too long to read and
+digest when I'm in the middle of coding:
+
+```console
+$ git help checkout | wc -l
+236
+
+$ (hg help update && hg help branch && hg help revert) | wc -l
+100
+```
+
+I realize that not everyone feels the same way as I do. If you like git's way
+of thinking better, you should certainly use it.
+
+Other Differences
+-----------------
+
+Aside from their "feels" I see two other big differences that still remain
+between git and Mercurial.
+
+### BitBucket and GitHub
+
+A major difference between the two systems is their most popular hosting
+sites: [BitBucket][] and [GitHub][]. GitHub is leaps and bounds above
+BitBucket in pretty much any aspect you look at: graphic design, popularity,
+speed, and/or features. Every time I've seriously considered moving to git it
+was purely because of this disparity.
+
+I don't like using git itself (though it's *far* better than SVN or CVS), but
+GitHub is such an awesome site that I've considered switching just to use it.
+You can chalk it up to "popularity" (i.e. git has more users, so GitHub is
+more profitable and so has more money to spend on development), but the fact
+is that GitHub is still far better than BitBucket.
+
+[BitBucket]: {{links.bitbucket}}
+[GitHub]: {{links.github}}
+
+### Git's Index
+
+One of the features that git users talk about often is git's
+[index][gitindex]. Mercurial has the [record][] extension, but it's not really
+the same thing.
+
+I personally don't like the index. I feel that git encourages people to check
+in changesets that contain code which they've never tested (or even built)
+because the index is such a prominent part of git's workflow.
+
+Yes, one can argue that you don't actually *push* changes until you've got a
+working state. The problem is that when you then try to run `git bisect` later
+to find a bug you'll have to waste time skipping over changesets that don't
+build. You could use `git rebase --interactive` to fold partial changesets
+into one big one, but again, my gut feeling is that few people actually bother
+*testing* the results.
+
+With all that said, I've [considered][] creating a Mercurial extension that
+adds git's index functionality to Mercurial, because I think it would make the
+transition to Mercurial easier for git users. I've had enough experience with
+Mercurial's internals to know that such a thing is *possible*, but I simply
+don't have the time to do it *all* myself. If you're interested in helping out
+please let me know!
+
+[gitindex]: http://book.git-scm.com/1_the_git_index.html
+[record]: http://mercurial.selenic.com/wiki/RecordExtension
+[considered]: http://twitter.com/stevelosh/status/7106305374
+
--- a/content/blog/2010/02/mercurial-workflows-branch-as-needed.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,148 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Mercurial Workflows: Branch As Needed"
-    snip: "Part 1 of several."
-    created: 2010-02-28 14:00:00
-%}
-
-{% block article_class %}with-diagrams{% endblock %}
-
-{% block article %}
-
-A while ago [Vincent Driessen][] posted an example of [a successful git
-branching model][gitbranch]. A lot of git users found that article very
-helpful, and [Dirkjan Ochtman][] [told me][djctweet] I should write a similar
-article for Mercurial users.
-
-[Vincent Driessen]: http://nvie.com/
-[gitbranch]: http://nvie.com/git-model
-[Dirkjan Ochtman]: http://dirkjan.ochtman.nl/
-[djctweet]: http://twitter.com/djco/status/8061889499
-
-I decided that I didn't want to just write a single entry about one branching
-workflow. Mercurial is flexible enough to support many different workflows and
-some of them will fit a given project better than others. Instead I'm going to
-write a series of posts, each one about a particular workflow.
-
-I'm going to start off with the simplest example I can think of: "Don't worry
-about branching at all, just deal with it whenever it happens."
-
-**Note:** In this series I'm going to assume you're comfortable with basic
-Mercurial commands and you know how Mercurial's various forms of branching
-work. If you need some review on Mercurial's commands you should look at the
-[hg book][]. If you need more information on branching concepts you might like
-my [Guide to Branching in Mercurial][hgbranching].
-
-[hg book]: http://hgbook.red-bean.com/
-[hgbranching]: /blog/2009/08/a-guide-to-branching-in-mercurial/
-
-[TOC]
-
-"Branch as Needed" in a Nutshell
---------------------------------
-
-The general idea of this workflow is that you don't worry about branching
-until it actually happens.
-
-The benefit is that it takes no extra work up front and keeps things very
-simple.
-
-The drawback is that it doesn't scale very well. It's great for small projects
-but it for larger ones you'll probably want something a bit more structured.
-
-An Example Scenario
--------------------
-
-This workflow is most suited to small projects. Here's a sample repository
-with only a single, linear series of changes:
-
-![Sample Repository Diagram](/media/images{{ parent_url }}/hg-branching-1-start.png "Sample Repository")
-
-In this example there's mostly just a single developer (you) working on the
-project to add features, fix bugs, etc.
-
-The repository is online so other people can get the code. They can add
-features and fix bugs if they want, but it doesn't happen very often because
-it's a small project.
-
-**Note:** I find it helpful to have graphs of the changesets in a repository
-so I can see what's going on. If you want some nice, quick ASCII-art graphs of
-your own repositories you can [use the graphlog extension][glog].
-
-[glog]: http://hgtip.com/tips/beginner/2009-10-03-stay-sane-with-graphlog/
-
-Branch Setup
-------------
-
-In this workflow you don't do any up-front setup at all. Just use Mercurial as
-you normally would, committing your changes along the way and pushing them to
-somewhere where other people can get them (like [BitBucket][]).
-
-[BitBucket]: http://bitbucket.org/
-
-Contributing to the Project
----------------------------
-
-Let's say someone else starts using your project and finds a bug. They go
-ahead and fix the bug themselves and commit a changeset for the fix. They
-could then push their copy of the repository to somewhere public (like their
-own BitBucket account) and it would look something like this:
-
-![Contributor Repository Diagram](/media/images{{ parent_url }}/hg-branching-1-other.png "Contributor Repository")
-
-Once their changes are somewhere public they can email you and say:
-
-> Hey, I fixed a bug in your project.
-> 
-> The fix is changeset be3063198fea in my copy of your repository at
-> http://.../
-
-Merging Changes from Contributors
----------------------------------
-
-When you get an email like this you would head over to their repository and
-take a look at the changeset. If you decide it's good and want to incorporate
-it into your own repository it's as simple as running `hg pull
-http://their/repo/`.
-
-If you haven't made any new changes your repository would now look exactly
-like theirs. You can update to the new tip and continue working as usual.
-
-What if you've made changes between the time they cloned (or last pulled) your
-repository and the time you read the email & pulled their changes? In that
-case your repository will look like this after you pull from them:
-
-![Sample Repository Before Merging Diagram](/media/images{{ parent_url }}/hg-branching-1-needs-merge.png "Sample Repository Before Merging")
-
-Because John's bugfix changeset and your refactoring changeset both have the
-same parent there are now two "anonymous branches" in your repository. This
-doesn't bother Mercurial at all -- repositories can have as many "anonymous
-branches" as you like.
-
-You'll probably want to merge these branches, so you'd run `hg update
-a2125cb20c54` (if you weren't already there) and then `hg merge be3063198fea`
-to merge John's bugfix with your new changes. The result would look like this:
-
-![Sample Repository After Merging Diagram](/media/images{{ parent_url }}/hg-branching-1-after-merge.png "Sample Repository After Merging")
-
-Now you're back to having just one head and you can continue working as usual,
-with John's changes and your changes all merged together.
-
-Summary
--------
-
-This workflow is the simplest one possible. There's no up-front setup and it's
-very easy for new people to contribute to the project -- they just clone,
-commit, push, and tell you about their changes. It's great for small projects
-with one main developer and the occasional contributor.
-
-If you have a project with a lot of people working together this can get
-pretty chaotic. Your repository graph will end up looking like a tangled mess.
-In that case you'll want a workflow with a bit more structure.
-
-I'm planning on writing at least two or three more posts about some more
-complicated branching workflows in the future. If you have any specific
-examples you think I should write about please let me know!
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/02/mercurial-workflows-branch-as-needed.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,143 @@
++++
+title = "Mercurial Workflows: Branch As Needed"
+snip = "Part 1 of several."
+date = 2010-02-28T14:00:00Z
+draft = false
+
++++
+
+A while ago [Vincent Driessen][] posted an example of [a successful git
+branching model][gitbranch]. A lot of git users found that article very
+helpful, and [Dirkjan Ochtman][] [told me][djctweet] I should write a similar
+article for Mercurial users.
+
+[Vincent Driessen]: http://nvie.com/
+[gitbranch]: http://nvie.com/git-model
+[Dirkjan Ochtman]: http://dirkjan.ochtman.nl/
+[djctweet]: http://twitter.com/djco/status/8061889499
+
+I decided that I didn't want to just write a single entry about one branching
+workflow. Mercurial is flexible enough to support many different workflows and
+some of them will fit a given project better than others. Instead I'm going to
+write a series of posts, each one about a particular workflow.
+
+I'm going to start off with the simplest example I can think of: "Don't worry
+about branching at all, just deal with it whenever it happens."
+
+**Note:** In this series I'm going to assume you're comfortable with basic
+Mercurial commands and you know how Mercurial's various forms of branching
+work. If you need some review on Mercurial's commands you should look at the
+[hg book][]. If you need more information on branching concepts you might like
+my [Guide to Branching in Mercurial][hgbranching].
+
+[hg book]: http://hgbook.red-bean.com/
+[hgbranching]: /blog/2009/08/a-guide-to-branching-in-mercurial/
+
+{{% toc %}}
+
+"Branch as Needed" in a Nutshell
+--------------------------------
+
+The general idea of this workflow is that you don't worry about branching
+until it actually happens.
+
+The benefit is that it takes no extra work up front and keeps things very
+simple.
+
+The drawback is that it doesn't scale very well. It's great for small projects
+but it for larger ones you'll probably want something a bit more structured.
+
+An Example Scenario
+-------------------
+
+This workflow is most suited to small projects. Here's a sample repository
+with only a single, linear series of changes:
+
+<img class="diagram" src="/media/images/blog/2010/02/hg-branching-1-start.png" alt="Sample Repository"/>
+
+In this example there's mostly just a single developer (you) working on the
+project to add features, fix bugs, etc.
+
+The repository is online so other people can get the code. They can add
+features and fix bugs if they want, but it doesn't happen very often because
+it's a small project.
+
+**Note:** I find it helpful to have graphs of the changesets in a repository
+so I can see what's going on. If you want some nice, quick ASCII-art graphs of
+your own repositories you can [use the graphlog extension][glog].
+
+[glog]: http://hgtip.com/tips/beginner/2009-10-03-stay-sane-with-graphlog/
+
+Branch Setup
+------------
+
+In this workflow you don't do any up-front setup at all. Just use Mercurial as
+you normally would, committing your changes along the way and pushing them to
+somewhere where other people can get them (like [BitBucket][]).
+
+[BitBucket]: http://bitbucket.org/
+
+Contributing to the Project
+---------------------------
+
+Let's say someone else starts using your project and finds a bug. They go
+ahead and fix the bug themselves and commit a changeset for the fix. They
+could then push their copy of the repository to somewhere public (like their
+own BitBucket account) and it would look something like this:
+
+<img class="diagram" src="/media/images/blog/2010/02/hg-branching-1-other.png" alt="Contributor Repository"/>
+
+Once their changes are somewhere public they can email you and say:
+
+> Hey, I fixed a bug in your project.
+> 
+> The fix is changeset be3063198fea in my copy of your repository at
+> http://.../
+
+Merging Changes from Contributors
+---------------------------------
+
+When you get an email like this you would head over to their repository and
+take a look at the changeset. If you decide it's good and want to incorporate
+it into your own repository it's as simple as running `hg pull
+http://their/repo/`.
+
+If you haven't made any new changes your repository would now look exactly
+like theirs. You can update to the new tip and continue working as usual.
+
+What if you've made changes between the time they cloned (or last pulled) your
+repository and the time you read the email & pulled their changes? In that
+case your repository will look like this after you pull from them:
+
+<img class="diagram" src="/media/images/blog/2010/02/hg-branching-1-needs-merge.png" alt="Sample Repository Before Merging"/>
+
+Because John's bugfix changeset and your refactoring changeset both have the
+same parent there are now two "anonymous branches" in your repository. This
+doesn't bother Mercurial at all — repositories can have as many "anonymous
+branches" as you like.
+
+You'll probably want to merge these branches, so you'd run `hg update
+a2125cb20c54` (if you weren't already there) and then `hg merge be3063198fea`
+to merge John's bugfix with your new changes. The result would look like this:
+
+<img class="diagram" src="/media/images/blog/2010/02/hg-branching-1-after-merge.png" alt="Sample Repository After Merging"/>
+
+Now you're back to having just one head and you can continue working as usual,
+with John's changes and your changes all merged together.
+
+Summary
+-------
+
+This workflow is the simplest one possible. There's no up-front setup and it's
+very easy for new people to contribute to the project — they just clone,
+commit, push, and tell you about their changes. It's great for small projects
+with one main developer and the occasional contributor.
+
+If you have a project with a lot of people working together this can get
+pretty chaotic. Your repository graph will end up looking like a tangled mess.
+In that case you'll want a workflow with a bit more structure.
+
+I'm planning on writing at least two or three more posts about some more
+complicated branching workflows in the future. If you have any specific
+examples you think I should write about please let me know!
+
--- a/content/blog/2010/02/my-extravagant-zsh-prompt.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,485 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "My Extravagant Zsh Prompt"
-    snip: "It’s big, but my monitor isn’t running out of ink."
-    created: 2010-02-01 01:05:00
-%}
-
-{% block article %}
-
-I spend a lot of time in a Terminal window at a command line. Up until about a
-month ago I was using [bash][] for my shell. I decided to try switching to
-[Zsh][] after hearing a lot of good things about it and I'm very happy with
-the change.
-
-A few days ago I [tweeted][] my current Zsh prompt and the general response
-was: "Cool, but how did you do it?" I promised to write more about it when I
-got some free time, and it looks like that time is now.
-
-**One quick note:** This entry is about the prompt that *I* find useful. You
-are not me, so you'll almost certainly have different needs. That's great!
-Take this prompt and hack it to make whatever works for you. If you're feeling
-generous you should find me on [Twitter][twsl] and show me what you changed --
-I might want to steal/appropriate your changes.
-
-**Another quick note:** I've customized the colors of my Terminal. They're
-based on the [Monokai][] TextMate theme, and I think they look very nice. The
-colors will be different for you. If you want colors like mine you should take
-a look at the [entry][candy] I wrote about it.
-
-[bash]: http://en.wikipedia.org/wiki/Bash
-[Zsh]: http://www.zsh.org/
-[tweeted]: http://twitter.com/stevelosh/status/8259755151
-[Monokai]: http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
-[candy]: /blog/2009/03/candy-colored-terminal/
-[twsl]: {{links.twsl}}
-
-[TOC]
-
-Why Should You Care?
---------------------
-
-Many people use the command line every day and never bother to customize their
-prompts. It's just a bit of text that's printed before every command -- why
-should you waste time learning how to customize it?
-
-I feel that the *most* important aspect of my command line work is the prompt.
-Your prompt is something you'll see *literally* thousands of times a day. Why
-not take 30 minutes and customize it into something that's much more useful?
-
-I firmly believe I'm right in thinking this way. 30 minutes (or even 3 hours)
-of customization to make your work easier for the **rest of your life** (or at
-least however long you stay with your current shell) *is* worth it.
-
-This Entry is About Zsh Prompts
--------------------------------
-
-As I mentioned earlier I now use Zsh as my command line shell. If you use bash
-(the default on most modern systems) the syntax to create the shell will be
-different.
-
-Really, though, you should give Zsh a try.
-
-Screenshots
------------
-
-I can write all day, but in the end I think a screenshot will be more helpful
-than anything I write.
-
-Here's a sample of my current Zsh prompt:
-
-![My Zsh Prompt](/media/images{{parent_url}}/zsh-prompt.png "My Zsh Prompt")
-
-And here's a version of that screenshot with some comments added to explain
-things:
-
-![My Zsh Prompt with Comments](/media/images{{parent_url}}/zsh-prompt-comments.png "My Zsh Prompt with Comments")
-
-If you want to know *how* I created that prompt, read on!
-
-Oh My Zsh!
-----------
-
-The first thing I'd do when starting out with Zsh is to install
-[robbyrussell's][robr] [oh-my-zsh][omz]. It's a great collection of very
-useful Zsh configurations and aliases which set some sane defaults and make
-working with Zsh much nicer.
-
-The instructions for installing it are on the project page.
-
-[robr]: http://github.com/robbyrussell
-[omz]: http://github.com/robbyrussell/oh-my-zsh
-
-Define a "Theme"
-----------------
-
-oh-my-zsh uses [theme files][themes] to specify how your prompt looks.
-
-An oh-my-zsh theme file is just a Zsh script which sets a few variables that
-the oh-my-zsh scripts use to render your prompt.
-
-Go ahead and create a new theme file for your prompt. Call it whatever you
-like. I called my theme "prose" because it's more verbose than the others.
-Copy the contents of one of the other themes to get started.
-
-The `PROMPT` variable is what you'll be modifying to change how your prompt
-looks. That's the `PROMPT=whatever` line of the theme file.
-
-Once you're done making your awesome prompt you should fork oh-my-zsh on
-GitHub and commit/push your new theme so other people can see and use your
-prompt.
-
-[themes]: http://github.com/robbyrussell/oh-my-zsh/tree/master/themes/
-
-Username and Hostname
----------------------
-
-The first two pieces of my prompt are the simplest: username and hostname. I
-SSH between machines pretty frequently so I find it nice to have these in my
-prompt to remind me of where I am.
-
-These are things that you'll find in many, many Zsh prompts. For more
-information about this kind of stuff check out [this page][zshpr].
-
-After adding in the colors this piece of my `PROMPT` variable looks like this:
-
-    :::text
-    %{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%}
-
-[zshpr]: http://www.acm.uiuc.edu/workshops/zsh/prompt/escapes.html
-
-Current Directory
------------------
-
-I like to have the current working directory displayed in my prompt. Zsh has
-two built-in ways to show the current directory:
-
-* **%d** shows the *entire* path.
-* **%~** shows the path with any variables replaced.
-
-Unfortunately neither of these work for me.
-
-If I'm in a directory that's under my home directory I want to see `~` instead
-of the full path. This would seem to mean that I should use `%~`, but there's
-a catch.
-
-The `%~` sequence also replaces any directories that happen to be environment
-variables. That means if I'm in something under my `virtualenvs` directory
-I'll see `~WORKON_HOME/venv_name` which is extremely ugly.
-
-To get around this I defined a simple function that implements the behavior I
-want.
-
-To add this to your prompt you'll first need to add the following function to
-your theme:
-
-    :::bash
-    function collapse_pwd {
-        echo $(pwd | sed -e "s,^$HOME,~,")
-    }
-
-Then add `$(collapse_pwd)` to your `PROMPT` variable wherever you'd like the
-directory to show up.
-
-After adding in the colors this piece of my `PROMPT` variable looks like this:
-
-    :::text
-    in %{$fg_bold[green]%}$(collapse_pwd)%{$reset_color%}
-
-**UPDATE:** In a comment Juliano pointed out a better way to do this. I've
-gotten rid of the `collapse_pwd` function and put this into my `PROMPT`
-variable instead:
-
-    :::bash
-    ${PWD/#$HOME/~}
-
-My Right-Prompt: Battery Capacity
----------------------------------
-
-The next piece of my prompt I'll talk about is the most stand-alone one: the
-battery charge.
-
-I work exclusively on laptops. I don't own a desktop machine -- I have a
-Macbook, Macbook Pro and Asus EEE PC and my work machine is a Macbook Pro. I
-work from coffeeshops and client meetings pretty often, so it's nice to have a
-reminder of my remaining battery power to know when I need to plug in.
-
-On the right-hand side of the prompt in the screenshot you can see a series of
-green triangles. These represent my current battery charge and they turn to
-empty triangles as the battery becomes depleted. Once the battery reaches 60%
-they turn yellow and once it reaches 40% they turn red.
-
-To do this I wrote a *very* simple Python script to output my current battery
-capacity. The entire script is shown below.
-
-    :::python
-    #!/usr/bin/env python
-    # coding=UTF-8
-    
-    import math, subprocess
-    
-    p = subprocess.Popen(["ioreg", "-rc", "AppleSmartBattery"], stdout=subprocess.PIPE)
-    output = p.communicate()[0]
-    
-    o_max = [l for l in output.splitlines() if 'MaxCapacity' in l][0]
-    o_cur = [l for l in output.splitlines() if 'CurrentCapacity' in l][0]
-    
-    b_max = float(o_max.rpartition('=')[-1].strip())
-    b_cur = float(o_cur.rpartition('=')[-1].strip())
-    
-    charge = b_cur / b_max
-    charge_threshold = int(math.ceil(10 * charge))
-    
-    # Output
-    
-    total_slots, slots = 10, []
-    filled = int(math.ceil(charge_threshold * (total_slots / 10.0))) * u'▸'
-    empty = (total_slots - len(filled)) * u'▹'
-    
-    out = (filled + empty).encode('utf-8')
-    import sys
-    
-    color_green = '%{%}'
-    color_yellow = '%{%}'
-    color_red = '%{%}'
-    color_reset = '%{%}'
-    color_out = (
-        color_green if len(filled) > 6
-        else color_yellow if len(filled) > 4
-        else color_red
-    )
-    
-    out = color_out + out + color_reset
-    sys.stdout.write(out)
-
-**Note:** The `color_*` variables contain UTF-8 characters which don't show up
-in a normal web browser. They *should* be preserved when copying and pasting
-from a decent browser. If the colors don't work find me on [Twitter][twsl] and
-I'll put the raw script up somewhere so you can download it.
-
-**UPDATE:** [ehamberg][] [sent me][ehbtweet] the beginnings of a
-Linux-compatible battery capacity script. If you flesh it out and make it into
-a complete script please let me know and I'll add it here.
-
-[ehamberg]: http://twitter.com/ehamberg/
-[ehbtweet]: http://twitter.com/ehamberg/status/8503213690
-
-I've put this script in a file named `batcharge.py` in my `~/bin/` directory.
-You can of course name it and place it anything/anywhere you like.
-
-No, it's not perfect. No, I don't care. It gets the job done and any
-brainpower I could spend on making it more efficient could be better spent on
-writing or working on something else.
-
-If you want to improve it, feel free and *please* send me the link to your work on
-[Twitter][twsl] so I can use it!
-
-Now that you've got the script, it's time to add it to your prompt.
-
-If you want this to appear on the right-hand side of your screen (like mine
-does) you'll need to add two things to your theme file. The first is a
-function that calls the script:
-
-    :::bash
-    function battery_charge {
-        echo `$BAT_CHARGE` 2>/dev/null
-    }
-
-After that you'll need to define the Zsh `RPROMPT` variable:
-
-    :::bash
-    RPROMPT='$(battery_charge)'
-
-Once those are in your theme file any new Terminal windows you open should
-show the battery capacity to the right of your prompt!
-
-Repository Types
-----------------
-
-In my personal work and my full-time job I work with both
-[Mercurial][mercurial] and [git][] repositories. I find it helpful to have a
-visual reminder of what kind of repository I'm working in.
-
-To do this I've replaced the standard `$` character in my prompt with
-different Unicode characters depending on what kind of repository I'm
-currently in:
-
-* `○` means "I'm not in any repository."
-* `☿` means "I'm in a Mercurial repository."
-* `±` means "I'm in a git repository."
-
-Those particular characters are meant to reflect the logos of the various
-projects. You can of course change them to anything that makes sense to you.
-
-[mercurial]: {{links.mercurial}}
-[git]: {{links.git}}
-
-To add this feature to your prompt you'll need to do two things in your theme
-file. First, add the following function:
-
-    :::bash
-    function prompt_char {
-        git branch >/dev/null 2>/dev/null && echo '±' && return
-        hg root >/dev/null 2>/dev/null && echo '☿' && return
-        echo '○'
-    }
-
-Then add `$(prompt_char)` somewhere inside your `PROMPT` variable -- wherever
-you want the character to be displayed (probably at the end).
-
-Mercurial Repository Information
---------------------------------
-
-I use Mercurial at work and for my own personal projects and I find it very
-handy to have some information about the current repository right in my
-prompt. It keeps me "oriented," especially when I'm using [MQ][] and
-manipulating the state of a repo.
-
-[MQ]: http://mercurial.selenic.com/wiki/MqExtension
-
-In the past I toyed around with some shell scripts to do this but eventually I
-got fed up with the poor performance and horrible readability of that
-solution.
-
-To fix this I wrote a small Mercurial extension called [hg-prompt][]. It adds
-an `hg prompt` command to Mercurial that will let you output information about
-the current repository. It's designed especially for use in shell prompts
-(hence the name).
-
-I open sourced the code a while ago and since then a few people have made
-feature requests and/or contributed patches. It's grown into a nice, flexible
-little tool. You can check out the [documentation][hgpdoc] to see all the
-things it can do.
-
-[hg-prompt]: /projects/hg-prompt/
-[hgpdoc]: http://sjl.bitbucket.org/hg-prompt/
-
-I only use a few of the features myself:
-
-* The current repository branch.
-* The "dirty" state of the repo (whether there are untracked/uncommitted files).
-* Any tags pointing at the current revision.
-* An "update" character to show whether running `hg update` would do anything.
-* A list of MQ patches (if any are present).
-
-To put this into my prompt I've added a function to my theme:
-
-    :::bash
-    function hg_prompt_info {
-        hg prompt --angle-brackets "\
-    < on <branch>>\
-    < at <tags|, >>\
-    <status|modified|unknown><update><
-    patches: <patches|join( → )>>" 2>/dev/null
-    }
-
-Inside my `PROMPT` variable I use `$(hg_prompt_info)` to show the information.
-The `2>/dev/null` makes sure no output is shown if I don't happen to be in a
-Mercurial repository.
-
-Of course this isn't nearly as pretty or readable without color. Unfortunately
-adding color codes makes the actual code almost unreadable:
-
-    :::bash
-    function hg_prompt_info {
-        hg prompt --angle-brackets "\
-    < on %{$fg[magenta]%}<branch>%{$reset_color%}>\
-    < at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
-    %{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
-    patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
-    }
-
-**Small note:** My favorite part of this prompt is that applied MQ patches are
-orange while unapplied patches are grey. It makes it very obvious what's going
-on.
-
-Showing all the MQ patches isn't something that will work for everyone. If you
-work on repositories that ever have more than 5 or 6 patches at a time the
-output is going to be too overwhelming. There are some other MQ-related
-hg-prompt keywords that you might find useful though.
-
-Git Repository Information
---------------------------
-
-Unfortunately I can't *always* use Mercurial. Many projects that I contribute
-to use git.
-
-I could try to use the [hg-git][] extension to let me use Mercurial to work
-with them, but the extension just isn't fast or mature enough for my taste.
-I've ended up buckling down and jumping down the rabbit hole that is git's
-CLI.
-
-[hg-git]: http://hg-git.github.com/
-
-Git doesn't seem to have any equivalent to hg-prompt, but I still wanted to
-have some information in my prompt so I don't get disoriented. oh-my-zsh has a
-bit of support for this, but it wasn't quite enough for me so I [hacked
-something together][omzgitcommit] to add the last bit of functionality I
-wanted.
-
-[omzgitcommit]: http://github.com/sjl/oh-my-zsh/commit/3d22ee248c6bce357c018a93d31f8d292d2cb4cd
-
-When I'm in a git repository my prompt now shows:
-
-* The current git branch.
-* Whether there are any changes in the index.
-* Whether there are any changes *not* in the index.
-
-Adding this to your prompt is very simple because oh-my-zsh has built-in
-support for it. All you need to do is define a few variables in your theme:
-
-    :::bash
-    ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
-    ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-    ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
-    ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
-    ZSH_THEME_GIT_PROMPT_CLEAN=""
-
-Once you do that you can put `$(git_prompt_info)` into your `PROMPT` variable
-to make it show up.
-
-**Note:** The `ZSH_THEME_GIT_PROMPT_UNTRACKED` variable is the part I added.
-If your want to use that one (to be able to see indexed and unindexed changes
-separately) you'll need to use [my fork of oh-my-zsh][omzfork].
-
-[omzfork]: http://github.com/sjl/oh-my-zsh/
-
-The Whole Thing
----------------
-
-Here's what my new "prose" theme file currently looks like in its entirety:
-
-    :::bash
-    function collapse_pwd {
-        echo $(pwd | sed -e "s,^$HOME,~,")
-    }
-    
-    function prompt_char {
-        git branch >/dev/null 2>/dev/null && echo '±' && return
-        hg root >/dev/null 2>/dev/null && echo '☿' && return
-        echo '○'
-    }
-    
-    function battery_charge {
-        echo `$BAT_CHARGE` 2>/dev/null
-    }
-    
-    function virtualenv_info {
-        [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
-    }
-    
-    function hg_prompt_info {
-        hg prompt --angle-brackets "\
-    < on %{$fg[magenta]%}<branch>%{$reset_color%}>\
-    < at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
-    %{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
-    patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
-    }
-    
-    PROMPT='
-    %{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}$(collapse_pwd)%{$reset_color%}$(hg_prompt_info)$(git_prompt_info)
-    $(virtualenv_info)$(prompt_char) '
-    
-    RPROMPT='$(battery_charge)'
-    
-    ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
-    ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
-    ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
-    ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
-    ZSH_THEME_GIT_PROMPT_CLEAN=""
-
-The file is also [on GitHub][prosetheme]. Remember, you'll need
-[my fork of oh-my-zsh][omzfork] to use the `ZSH_THEME_GIT_PROMPT_UNTRACKED`
-feature.
-
-[prosetheme]: http://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
-
-A shell prompt is something that we'll each see thousands of times a day, so
-it's something that you should take the time to customize into a useful tool.
-Feel free to use my prompt as a starting point or just as a source of ideas.
-
-If you have any questions, suggestions, or examples of your own please fine me on
-[Twitter][twsl] -- I'd love to hear them!
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/02/my-extravagant-zsh-prompt.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,494 @@
++++
+title = "My Extravagant Zsh Prompt"
+snip = "It’s big, but my monitor isn’t running out of ink."
+date = 2010-02-01T01:05:00Z
+draft = false
+
++++
+
+I spend a lot of time in a Terminal window at a command line. Up until about a
+month ago I was using [bash][] for my shell. I decided to try switching to
+[Zsh][] after hearing a lot of good things about it and I'm very happy with
+the change.
+
+A few days ago I [tweeted][] my current Zsh prompt and the general response
+was: "Cool, but how did you do it?" I promised to write more about it when I
+got some free time, and it looks like that time is now.
+
+**One quick note:** This entry is about the prompt that *I* find useful. You
+are not me, so you'll almost certainly have different needs. That's great!
+Take this prompt and hack it to make whatever works for you. If you're feeling
+generous you should find me on [Twitter][twsl] and show me what you changed --
+I might want to steal/appropriate your changes.
+
+**Another quick note:** I've customized the colors of my Terminal. They're
+based on the [Monokai][] TextMate theme, and I think they look very nice. The
+colors will be different for you. If you want colors like mine you should take
+a look at the [entry][candy] I wrote about it.
+
+[bash]: http://en.wikipedia.org/wiki/Bash
+[Zsh]: http://www.zsh.org/
+[tweeted]: http://twitter.com/stevelosh/status/8259755151
+[Monokai]: http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
+[candy]: /blog/2009/03/candy-colored-terminal/
+[twsl]: {{links.twsl}}
+
+{{% toc %}}
+
+Why Should You Care?
+--------------------
+
+Many people use the command line every day and never bother to customize their
+prompts. It's just a bit of text that's printed before every command — why
+should you waste time learning how to customize it?
+
+I feel that the *most* important aspect of my command line work is the prompt.
+Your prompt is something you'll see *literally* thousands of times a day. Why
+not take 30 minutes and customize it into something that's much more useful?
+
+I firmly believe I'm right in thinking this way. 30 minutes (or even 3 hours)
+of customization to make your work easier for the **rest of your life** (or at
+least however long you stay with your current shell) *is* worth it.
+
+This Entry is About Zsh Prompts
+-------------------------------
+
+As I mentioned earlier I now use Zsh as my command line shell. If you use bash
+(the default on most modern systems) the syntax to create the shell will be
+different.
+
+Really, though, you should give Zsh a try.
+
+Screenshots
+-----------
+
+I can write all day, but in the end I think a screenshot will be more helpful
+than anything I write.
+
+Here's a sample of my current Zsh prompt:
+
+![My Zsh Prompt](/media/images/blog/2009/02/zsh-prompt.png "My Zsh Prompt")
+
+And here's a version of that screenshot with some comments added to explain
+things:
+
+![My Zsh Prompt with Comments](/media/images/blog/2009/02/zsh-prompt-comments.png "My Zsh Prompt with Comments")
+
+If you want to know *how* I created that prompt, read on!
+
+Oh My Zsh!
+----------
+
+The first thing I'd do when starting out with Zsh is to install
+[robbyrussell's][robr] [oh-my-zsh][omz]. It's a great collection of very
+useful Zsh configurations and aliases which set some sane defaults and make
+working with Zsh much nicer.
+
+The instructions for installing it are on the project page.
+
+[robr]: http://github.com/robbyrussell
+[omz]: http://github.com/robbyrussell/oh-my-zsh
+
+Define a "Theme"
+----------------
+
+oh-my-zsh uses [theme files][themes] to specify how your prompt looks.
+
+An oh-my-zsh theme file is just a Zsh script which sets a few variables that
+the oh-my-zsh scripts use to render your prompt.
+
+Go ahead and create a new theme file for your prompt. Call it whatever you
+like. I called my theme "prose" because it's more verbose than the others.
+Copy the contents of one of the other themes to get started.
+
+The `PROMPT` variable is what you'll be modifying to change how your prompt
+looks. That's the `PROMPT=whatever` line of the theme file.
+
+Once you're done making your awesome prompt you should fork oh-my-zsh on
+GitHub and commit/push your new theme so other people can see and use your
+prompt.
+
+[themes]: http://github.com/robbyrussell/oh-my-zsh/tree/master/themes/
+
+Username and Hostname
+---------------------
+
+The first two pieces of my prompt are the simplest: username and hostname. I
+SSH between machines pretty frequently so I find it nice to have these in my
+prompt to remind me of where I am.
+
+These are things that you'll find in many, many Zsh prompts. For more
+information about this kind of stuff check out [this page][zshpr].
+
+After adding in the colors this piece of my `PROMPT` variable looks like this:
+
+```text
+%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%}
+```
+
+[zshpr]: http://www.acm.uiuc.edu/workshops/zsh/prompt/escapes.html
+
+Current Directory
+-----------------
+
+I like to have the current working directory displayed in my prompt. Zsh has
+two built-in ways to show the current directory:
+
+* **%d** shows the *entire* path.
+* **%~** shows the path with any variables replaced.
+
+Unfortunately neither of these work for me.
+
+If I'm in a directory that's under my home directory I want to see `~` instead
+of the full path. This would seem to mean that I should use `%~`, but there's
+a catch.
+
+The `%~` sequence also replaces any directories that happen to be environment
+variables. That means if I'm in something under my `virtualenvs` directory
+I'll see `~WORKON_HOME/venv_name` which is extremely ugly.
+
+To get around this I defined a simple function that implements the behavior I
+want.
+
+To add this to your prompt you'll first need to add the following function to
+your theme:
+
+```bash
+function collapse_pwd {
+    echo $(pwd | sed -e "s,^$HOME,~,")
+}
+```
+
+Then add `$(collapse_pwd)` to your `PROMPT` variable wherever you'd like the
+directory to show up.
+
+After adding in the colors this piece of my `PROMPT` variable looks like this:
+
+```text
+in %{$fg_bold[green]%}$(collapse_pwd)%{$reset_color%}
+```
+
+**UPDATE:** In a comment Juliano pointed out a better way to do this. I've
+gotten rid of the `collapse_pwd` function and put this into my `PROMPT`
+variable instead:
+
+```bash
+${PWD/#$HOME/~}
+```
+
+My Right-Prompt: Battery Capacity
+---------------------------------
+
+The next piece of my prompt I'll talk about is the most stand-alone one: the
+battery charge.
+
+I work exclusively on laptops. I don't own a desktop machine — I have a
+Macbook, Macbook Pro and Asus EEE PC and my work machine is a Macbook Pro. I
+work from coffeeshops and client meetings pretty often, so it's nice to have a
+reminder of my remaining battery power to know when I need to plug in.
+
+On the right-hand side of the prompt in the screenshot you can see a series of
+green triangles. These represent my current battery charge and they turn to
+empty triangles as the battery becomes depleted. Once the battery reaches 60%
+they turn yellow and once it reaches 40% they turn red.
+
+To do this I wrote a *very* simple Python script to output my current battery
+capacity. The entire script is shown below.
+
+```python
+#!/usr/bin/env python
+# coding=UTF-8
+
+import math, subprocess
+
+p = subprocess.Popen(["ioreg", "-rc", "AppleSmartBattery"], stdout=subprocess.PIPE)
+output = p.communicate()[0]
+
+o_max = [l for l in output.splitlines() if 'MaxCapacity' in l][0]
+o_cur = [l for l in output.splitlines() if 'CurrentCapacity' in l][0]
+
+b_max = float(o_max.rpartition('=')[-1].strip())
+b_cur = float(o_cur.rpartition('=')[-1].strip())
+
+charge = b_cur / b_max
+charge_threshold = int(math.ceil(10 * charge))
+
+# Output
+
+total_slots, slots = 10, []
+filled = int(math.ceil(charge_threshold * (total_slots / 10.0))) * u'▸'
+empty = (total_slots - len(filled)) * u'▹'
+
+out = (filled + empty).encode('utf-8')
+import sys
+
+color_green = '%{%}'
+color_yellow = '%{%}'
+color_red = '%{%}'
+color_reset = '%{%}'
+color_out = (
+    color_green if len(filled) > 6
+    else color_yellow if len(filled) > 4
+    else color_red
+)
+
+out = color_out + out + color_reset
+sys.stdout.write(out)
+```
+
+**Note:** The `color_*` variables contain UTF-8 characters which don't show up
+in a normal web browser. They *should* be preserved when copying and pasting
+from a decent browser. If the colors don't work find me on [Twitter][twsl] and
+I'll put the raw script up somewhere so you can download it.
+
+**UPDATE:** [ehamberg][] [sent me][ehbtweet] the beginnings of a
+Linux-compatible battery capacity script. If you flesh it out and make it into
+a complete script please let me know and I'll add it here.
+
+[ehamberg]: http://twitter.com/ehamberg/
+[ehbtweet]: http://twitter.com/ehamberg/status/8503213690
+
+I've put this script in a file named `batcharge.py` in my `~/bin/` directory.
+You can of course name it and place it anything/anywhere you like.
+
+No, it's not perfect. No, I don't care. It gets the job done and any
+brainpower I could spend on making it more efficient could be better spent on
+writing or working on something else.
+
+If you want to improve it, feel free and *please* send me the link to your work on
+[Twitter][twsl] so I can use it!
+
+Now that you've got the script, it's time to add it to your prompt.
+
+If you want this to appear on the right-hand side of your screen (like mine
+does) you'll need to add two things to your theme file. The first is a
+function that calls the script:
+
+```bash
+function battery_charge {
+    echo `$BAT_CHARGE` 2>/dev/null
+}
+```
+
+After that you'll need to define the Zsh `RPROMPT` variable:
+
+```bash
+RPROMPT='$(battery_charge)'
+```
+
+Once those are in your theme file any new Terminal windows you open should
+show the battery capacity to the right of your prompt!
+
+Repository Types
+----------------
+
+In my personal work and my full-time job I work with both
+[Mercurial][mercurial] and [git][] repositories. I find it helpful to have a
+visual reminder of what kind of repository I'm working in.
+
+To do this I've replaced the standard `$` character in my prompt with
+different Unicode characters depending on what kind of repository I'm
+currently in:
+
+* `○` means "I'm not in any repository."
+* `☿` means "I'm in a Mercurial repository."
+* `±` means "I'm in a git repository."
+
+Those particular characters are meant to reflect the logos of the various
+projects. You can of course change them to anything that makes sense to you.
+
+[mercurial]: {{links.mercurial}}
+[git]: {{links.git}}
+
+To add this feature to your prompt you'll need to do two things in your theme
+file. First, add the following function:
+
+```bash
+function prompt_char {
+    git branch >/dev/null 2>/dev/null && echo '±' && return
+    hg root >/dev/null 2>/dev/null && echo '☿' && return
+    echo '○'
+}
+```
+
+Then add `$(prompt_char)` somewhere inside your `PROMPT` variable — wherever
+you want the character to be displayed (probably at the end).
+
+Mercurial Repository Information
+--------------------------------
+
+I use Mercurial at work and for my own personal projects and I find it very
+handy to have some information about the current repository right in my
+prompt. It keeps me "oriented," especially when I'm using [MQ][] and
+manipulating the state of a repo.
+
+[MQ]: http://mercurial.selenic.com/wiki/MqExtension
+
+In the past I toyed around with some shell scripts to do this but eventually I
+got fed up with the poor performance and horrible readability of that
+solution.
+
+To fix this I wrote a small Mercurial extension called [hg-prompt][]. It adds
+an `hg prompt` command to Mercurial that will let you output information about
+the current repository. It's designed especially for use in shell prompts
+(hence the name).
+
+I open sourced the code a while ago and since then a few people have made
+feature requests and/or contributed patches. It's grown into a nice, flexible
+little tool. You can check out the [documentation][hgpdoc] to see all the
+things it can do.
+
+[hg-prompt]: /projects/hg-prompt/
+[hgpdoc]: http://sjl.bitbucket.org/hg-prompt/
+
+I only use a few of the features myself:
+
+* The current repository branch.
+* The "dirty" state of the repo (whether there are untracked/uncommitted files).
+* Any tags pointing at the current revision.
+* An "update" character to show whether running `hg update` would do anything.
+* A list of MQ patches (if any are present).
+
+To put this into my prompt I've added a function to my theme:
+
+```bash
+function hg_prompt_info {
+    hg prompt --angle-brackets "\
+< on <branch>>\
+< at <tags|, >>\
+<status|modified|unknown><update><
+patches: <patches|join( → )>>" 2>/dev/null
+}
+```
+
+Inside my `PROMPT` variable I use `$(hg_prompt_info)` to show the information.
+The `2>/dev/null` makes sure no output is shown if I don't happen to be in a
+Mercurial repository.
+
+Of course this isn't nearly as pretty or readable without color. Unfortunately
+adding color codes makes the actual code almost unreadable:
+
+```bash
+function hg_prompt_info {
+    hg prompt --angle-brackets "\
+< on %{$fg[magenta]%}<branch>%{$reset_color%}>\
+< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
+%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
+patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
+}
+```
+
+**Small note:** My favorite part of this prompt is that applied MQ patches are
+orange while unapplied patches are grey. It makes it very obvious what's going
+on.
+
+Showing all the MQ patches isn't something that will work for everyone. If you
+work on repositories that ever have more than 5 or 6 patches at a time the
+output is going to be too overwhelming. There are some other MQ-related
+hg-prompt keywords that you might find useful though.
+
+Git Repository Information
+--------------------------
+
+Unfortunately I can't *always* use Mercurial. Many projects that I contribute
+to use git.
+
+I could try to use the [hg-git][] extension to let me use Mercurial to work
+with them, but the extension just isn't fast or mature enough for my taste.
+I've ended up buckling down and jumping down the rabbit hole that is git's
+CLI.
+
+[hg-git]: http://hg-git.github.com/
+
+Git doesn't seem to have any equivalent to hg-prompt, but I still wanted to
+have some information in my prompt so I don't get disoriented. oh-my-zsh has a
+bit of support for this, but it wasn't quite enough for me so I [hacked
+something together][omzgitcommit] to add the last bit of functionality I
+wanted.
+
+[omzgitcommit]: http://github.com/sjl/oh-my-zsh/commit/3d22ee248c6bce357c018a93d31f8d292d2cb4cd
+
+When I'm in a git repository my prompt now shows:
+
+* The current git branch.
+* Whether there are any changes in the index.
+* Whether there are any changes *not* in the index.
+
+Adding this to your prompt is very simple because oh-my-zsh has built-in
+support for it. All you need to do is define a few variables in your theme:
+
+```bash
+ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
+ZSH_THEME_GIT_PROMPT_CLEAN=""
+```
+
+Once you do that you can put `$(git_prompt_info)` into your `PROMPT` variable
+to make it show up.
+
+**Note:** The `ZSH_THEME_GIT_PROMPT_UNTRACKED` variable is the part I added.
+If your want to use that one (to be able to see indexed and unindexed changes
+separately) you'll need to use [my fork of oh-my-zsh][omzfork].
+
+[omzfork]: http://github.com/sjl/oh-my-zsh/
+
+The Whole Thing
+---------------
+
+Here's what my new "prose" theme file currently looks like in its entirety:
+
+```bash
+function collapse_pwd {
+    echo $(pwd | sed -e "s,^$HOME,~,")
+}
+
+function prompt_char {
+    git branch >/dev/null 2>/dev/null && echo '±' && return
+    hg root >/dev/null 2>/dev/null && echo '☿' && return
+    echo '○'
+}
+
+function battery_charge {
+    echo `$BAT_CHARGE` 2>/dev/null
+}
+
+function virtualenv_info {
+    [ $VIRTUAL_ENV ] && echo '('`basename $VIRTUAL_ENV`') '
+}
+
+function hg_prompt_info {
+    hg prompt --angle-brackets "\
+< on %{$fg[magenta]%}<branch>%{$reset_color%}>\
+< at %{$fg[yellow]%}<tags|%{$reset_color%}, %{$fg[yellow]%}>%{$reset_color%}>\
+%{$fg[green]%}<status|modified|unknown><update>%{$reset_color%}<
+patches: <patches|join( → )|pre_applied(%{$fg[yellow]%})|post_applied(%{$reset_color%})|pre_unapplied(%{$fg_bold[black]%})|post_unapplied(%{$reset_color%})>>" 2>/dev/null
+}
+
+PROMPT='
+%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}$(collapse_pwd)%{$reset_color%}$(hg_prompt_info)$(git_prompt_info)
+$(virtualenv_info)$(prompt_char) '
+
+RPROMPT='$(battery_charge)'
+
+ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
+ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[green]%}!"
+ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[green]%}?"
+ZSH_THEME_GIT_PROMPT_CLEAN=""
+```
+
+The file is also [on GitHub][prosetheme]. Remember, you'll need
+[my fork of oh-my-zsh][omzfork] to use the `ZSH_THEME_GIT_PROMPT_UNTRACKED`
+feature.
+
+[prosetheme]: http://github.com/sjl/oh-my-zsh/blob/master/themes/prose.zsh-theme
+
+A shell prompt is something that we'll each see thousands of times a day, so
+it's something that you should take the time to customize into a useful tool.
+Feel free to use my prompt as a starting point or just as a source of ideas.
+
+If you have any questions, suggestions, or examples of your own please fine me on
+[Twitter][twsl] — I'd love to hear them!
+
--- a/content/blog/2010/04/a-faster-feed-apart.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,449 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "A Faster Feed Apart"
-    snip: "Rethinking A Feed Apart’s backend."
-    created: 2010-04-30 22:55:00
-%}
-
-{% block article %}
-
-[An Event Apart][aea] is a conference for web developers and designers that
-happens a few times a year in various cities.  [A Feed Apart][afa] is a site
-that aggregates tweets during each conference and displays them in a live
-stream so attendees can follow them during the conference, and people not
-attending can see what the attendees are talking about.
-
-A Feed Apart was originally written by [Nick Sergeant][nick] and [Pete
-Karl][pete] of [Lion Burger][lionburger] during one of the conferences.  Since
-then a lot of people have used it and love it.
-
-The current A Feed Apart site is not without its problems.  It was written in
-a single night so it's not perfect.  During the last conference it went down
-several times and lost some tweets along the way.
-
-I work at [Dumbwaiter Design][dwaiter] with Nick and one day he mentioned that
-it would be cool if we rewrote A Feed Apart from the ground up.  He's learned
-a lot about how people use the site and what the big problems are, so we'd have
-a better idea of what we need to accomplish.
-
-Nick, myself and [Ali Ali][ali] have risen to the challenge and started
-rewriting A Feed Apart.  Ali is a designer and is taking care of the design of
-the new site.  Nick is handling all the frontend HTML, CSS and Javascript.  My
-job is the backend.
-
-Ali posted a [blog entry][aliblog] about the design of the new version so
-I figured I'd write about the backend to show how I'm trying to improve it.  If
-you have any advice I'd love to hear it -- the next An Event Apart conference
-is about three weeks away so there's still time to add improvements.
-
-[aea]: http://aneventapart.com/
-[afa]: http://afeedapart.com/
-[nick]: http://nicksergeant.com/
-[pete]: http://pkarl.com/
-[lionburger]: http://lionburger.com/
-[dwaiter]: http://dwaiter.com/
-[ali]: http://alialithinks.com/
-[aliblog]: http://www.dcamm.com/blog/archives/765
-
-[TOC]
-
-How AFA is Used
----------------
-
-You can't hope to improve on a site unless you know how people are going to use
-it.  AFA has been around for a while and Nick has learned a lot about what
-people want to get out of it.
-
-There are three main kinds of users of AFA:
-
-* People attending the conference
-* People that wish they were attending the conference
-* The speakers/organizers of the conference
-
-### People Attending the Conference
-
-People that attend AEA are web developers and designers.  They're up-to-date on
-the latest technology and almost all of them use [Twitter][].
-
-During the conference you'll see a sea of laptops in the audience.  Attendees
-will tweet about whatever is happening *right now*.  There's a huge amount of
-conversation that happens between attendees that AFA is trying to collect and
-present.
-
-A simple example is one that Nick mentioned to me: if a presenter mentions
-a website during her presentation someone will tweet the URL so other people
-can have a link to easily click on.  Attendees will also tweet their agreement
-or disagreement with what the presenter is saying *as they're speaking*.
-
-The most important aspect of AFA for this group of people is the *real time
-conversation*.  If AFA doesn't show tweets until a minute after they've been
-posted it's useless to these people.
-
-Another important part of AFA for attendees is that it's a one-stop-shop for
-the conversation behind AEA.  Switching between windows/tabs/applications to
-read and contribute is annoying.
-
-### People That Wish They Were Attending the Conference
-
-The next group of users is those that can't attend the conference for a variety
-of reasons but are still interested in what's going on.
-
-For this group the real time nature of AFA is unimportant.  They're probably
-not going to be following the conversation 24/7 so if a tweet takes a few
-minutes to display it's not a big deal.
-
-What these people *do* care about is the integrity of the stream.  They don't
-want to miss any part of the conversation.  If AFA loses tweets they're better
-off doing a simple search on Twitter because they'll get the whole story.
-
-### Speakers and Organizers
-
-The last main group of users is the speakers and organizers of AEA.
-
-Any speaker worth their salt will want to know what people are said about their
-presentation.  Obviously they can't be reading AFA while they're presenting,
-but afterword they'll certainly want to go back and see what people were saying
-during their specific presentation.
-
-Likewise, organizers want to know which presentations people liked and which
-ones people didn't enjoy.  This could easily influence who they choose to
-invite to future conferences.
-
-For this group the most important aspect of AFA is the organization of the
-conversation into chunks, each of which applies to a single presentation.  By
-reading through each chunk of conversation they can get an idea of the general
-response to each presentation.
-
-[Twitter]: http://twitter.com/
-
-Goals
------
-
-Once we identified the main users of AFA we were able to come up with the goals
-for the new version of the site:
-
-* **Stay sane while developing.**  Ali, Nick and myself are rewriting the site
-  as a side project, so we don't want it to take *too* much of our time or cause
-  *too* much stress.
-
-* **Provide the real time conversation.**  The site needs to be fast and
-  responsive, so people at the conferences can use it to converse.
-
-* **Don't miss anything.**  People following along from home shouldn't feel
-  like they're missing anything.  We want to provide a *complete* version of the
-  conversation happening behind the event.
-
-* **Organize the conversation.**  Presenters and speakers need a way to see
-  what people are saying about them.  They want to know what people think about
-  each "chunk" of the event.
-
-* **Grease the wheels of (physical) social interaction.**  This is something
-  that AFA hasn't tried to address before, but that we'd like to work on with
-  this version.  There are a lot of people at each conference and we'd like to
-  help them get together.  Whether it's going out for dinner or meeting up at the
-  [Media Temple][mt] party we want to get people talking to each other.  I won't
-  talk about this goal in this post because we're still figuring out the best way
-  to do it.
-
-[mt]: http://mediatemple.net/
-
-Staying Sane
-------------
-
-If the three of us tried to create the site with nothing more than a couple of
-laptops and a few chats in person we'd go crazy.  We use a few tools to help us
-manage the development of the site.
-
-To create **wireframes of the design** we're using a free account at [Hot
-Gloo][hotgloo].  Hot Gloo is a great tool that lets us quickly sketch out ideas
-and comment on them.
-
-To share **design comps** we're using [Dropbox][].  It's simple to set up
-a shared Dropbox folder and Nick and I can get real time updates when Ali makes
-changes to the design.
-
-To **work together on the code** Nick and I use [Mercurial][] repositories.
-Mercurial lets us work on the same code bases simultaneously and we almost
-never have to worry about merging.  We use [Codebase][] for hosting and issue
-tracking.
-
-[hotgloo]: http://hotgloo.com/
-[Dropbox]: http://dropbox.com/
-[Mercurial]: http://hg-scm.org/
-[Codebase]: http://codebasehq.com/
-
-Being Real Time
----------------
-
-The previous version of AFA wasn't *truly* real time.  When you went to the
-site your browser would ask AFA for the newest updates every 10 seconds.
-
-There are two main problems with this approach.  The first is that it's not
-really *real time*.  I've noticed this being an issue in my own experience.
-
-When I watch any of the various "live streams" of [Apple][] press conferences
-I'm usually at work where other people are also watching.  We very rarely load
-the pages of the streaming sites like Gizmodo at the exact same second, so our
-browsers will be out of sync with each other.  Nick might get an update that
-I would have to wait 8 more seconds to see.
-
-When I glance over at his screen and see an update that I don't have
-I instinctively refresh the page to get it.  This defeats the purpose of the
-"live updating" code that the developers of these sites worked on.  They may as
-well have just made a static page and told me to refresh.
-
-The second problem is that querying every 10 seconds can be taxing on the
-site's database.  We're doing this as a side project so we don't have unlimited
-funding for a hefty database server.  If 1,000 people are querying for updates
-every 10 seconds that's 100 requests per second to the database.  This means we
-need to have some kind of in-memory cacheing if we want the site to feel snappy
-on modest hardware.
-
-We want the new AFA to be truly real time.  To do this we need to use [long
-polling][longpolling] by users' browsers to wait for updates and return them as
-soon as they come in.  We also need to retrieve the updates as fast as we
-possibly can, and they need to be stored in memory to avoid hitting the
-database constantly.
-
-[Apple]: http://apple.com/
-[longpolling]: http://en.wikipedia.org/wiki/Push_technology#Long_polling
-
-### Retrieving Updates
-
-The bulk of the conversation about AEA conferences comes from Twitter.  Tweets
-are the most important items that we need to display on the site, so we're
-using Twitter's streaming API to pull them in.
-
-Since we don't want to tie up an entire server to pull in tweets I've decided
-to create a [Diesel][]-based application called **The Nozzletron** to parse the
-streaming API.  Diesel is a [Python][] framework that takes an elegant approach
-to asynchronous communication with clients and servers.
-
-Twitter's streaming API accepts HTTP requests and returns "chunked" responses,
-each of which is a tweet.  Unfortunately the Diesel's built-in HTTP client
-doesn't handle chunked HTTP responses so I had to write some code to handle
-them myself.
-
-The Nozzletron will connect to Twitter's streaming API and wait for data to
-come in.  If there's no data to process it will relinquish the server's
-processor so it can do other things.  Processing a single tweet that comes in
-doesn't take much time, so the server is free to do other things most of the
-time.
-
-I've also created another application called **The Flickrtron** to pull in
-[Flickr][] photos.  Unfortunately Flickr doesn't have a streaming API like
-Twitter so I have to resort to polling Flickr's API every few minutes for new
-photos.  Flickr is much less of a real time medium than Twitter though, so
-I don't think this is a very big problem.
-
-I'm using a Python library called [Beej's Flickr API][flickrapi] to talk to
-Flickr.  It is horrible.  It calls itself an "API" but is really just a thin
-wrapper around calls to the Flickr API.  The objects it returns for API calls
-are Elementtree objects representing the XML of the response.
-
-I wish I could do something like:
-
-    :::python
-    thumb_url = photo.thumbnail_url
-
-Instead I have to use this monstrosity:
-
-    :::python
-    thumb_url = "http://farm%s.static.flickr.com/%s/%s_%s_s.jpg" % (
-        photo.get('farm'), photo.get('server'), photo.get('id'),
-        photo.get('secret'),
-    )
-
-I wish there were a better Python Flickr API out there but there doesn't seem
-to be one.  If I've missed it please let me know!
-
-[Diesel]: http://dieselweb.org/
-[Python]: http://python.org/
-[Flickr]: http://flickr.com/
-[flickrapi]: http://stuvel.eu/projects/flickrapi
-
-### Storing Updates
-
-We need a fast way to store and retrieve updates so AFA can provide a real time
-view of the conversation happening at AEA.  With this in mind I've chosen
-[Redis][] to store the updates of the currently-happening event.
-
-Redis is an easy-to-set-up, disgustingly-fast, in-memory data store.  It's
-similar to [memcached][] but has more intelligent data structures that make my
-life easier for this project.
-
-As updates (tweets and flickr photos) are scraped by The Nozzletron and The
-Flickrtron they're placed at the tail end of a Redis list.  That means I can
-quickly and easily get all the items since item `N` when a user's browser
-requests them with a single `LRANGE {list-key} N -1` call.
-
-I'm also keeping a few other pieces of information in Redis.  For example,
-there's a set of photo IDs held in the `{item-key}:flickrtron:grabbed_photos`
-key that keeps track of all of the photos we've already seen.
-
-This makes it easy to tell if we've already seen a photo (and therefore don't
-need to query Flickr for more information) -- it's a simple `SISMEMBER
-{item-key}:flickrtron:grabbed_photos {photo-id}` call.
-
-I'm also using Redis to store statistics about the site like:
-
-* How many tweets we've scraped.
-* How many photos we've scraped.
-* How many people are currently waiting for updates.
-
-This kind of information will be extremely valuable in the future when we're
-planning improvements to the site.  Redis makes it fast and safe to update this
-information using the `INCRBY` and `DECR` commands.
-
-There's one more component to The Nozzletron and The Flickrton that I haven't
-mentioned.  Both use Redis' `PUBLISH` command to push new updates out to users'
-browsers as they arrive.  I'll talk more about that in the next section.
-
-[Redis]: http://code.google.com/p/redis/
-[memcached]: http://memcached.org/
-
-### Sending Updates to Users
-
-As I mentioned before we want to send updates to users *as soon as they're
-received*.  To do this I've created another Diesel-based application called
-**Halley** to handle this [Comet][]-style communication.
-
-Halley has a few components.  The first uses Diesel's [Redis API][dieselredis]
-to subscribe to a Redis channel like `live:{event-id}:items` and
-[fire][dieselfire] off messages whenever something new comes in.  As soon as
-a new update comes in from The Nozzletron or The Flickrtron all of Halley's
-clients will get it.
-
-When I started working on AFA Diesel's Redis client didn't support the very new
-`PUBLISH`/`SUBSCRIBE`/`UNSUBSCRIBE` commands.  I implemented them, put my
-changes on [BitBucket][], sent a pull request, and started talking to the
-Diesel crew on IRC.
-
-One of the maintainers pulled my patches and made them even better.  Now
-Diesel's Redis client has full `PUBLISH`/`SUBSCRIBE`/`UNSUBSCRIBE` support.
-It's a great example of how open source projects can produce awesome results.
-
-The other main component of Halley is an HTTP server that listens for
-connections from browsers.  The Javascript on the site will call Halley and say
-"I need updates since number `X`", where `X` is the length of the Redis list of
-updates at the last time it spoke to the server.
-
-Halley uses Diesel's [HTTP Server][dieselhttp] to manage these requests.
-
-If a client is asking for everything since `X` and `X` is a smaller number than
-the current number of items it will return the updates that have happened since
-then.  This might happen if we return an update and then two more updates
-happen before the browser gets around to sending another request.
-
-If a client is asking for everything since `X` and `X` is equal to the current
-number of items Halley will wait for a new message to be fired from the
-[Loop][dieselloop] that's watching the Redis channel.  While Halley waits she
-relinquishes the processor to the server so other requests can be handled.
-
-There's a bit of code to prevent DoS attacks that request every item in the
-queue over and over again, of course.
-
-[Comet]: http://en.wikipedia.org/wiki/Comet_(programming)
-[dieselredis]: http://bitbucket.org/boomplex/diesel/src/tip/diesel/protocols/redis.py
-[dieselfire]: http://bitbucket.org/boomplex/diesel/src/tip/diesel/core.py#cl-90
-[BitBucket]: http://bitbucket.org/
-[dieselhttp]: http://bitbucket.org/boomplex/diesel/src/tip/diesel/protocols/http.py#cl-156
-[dieselloop]: http://bitbucket.org/boomplex/diesel/src/tip/diesel/core.py#cl-179
-
-Organizing the Conversation
----------------------------
-
-The live stream is an important component of AFA, but it's not the only one.
-We also need to organize updates into logical chunks by event and presentation,
-and provide archives of old events so people can see what happened.
-
-The main AFA site is built with [Django][] and served with [Gunicorn][] and
-[Nginx][].  It uses a [Postgresql][] database to store data that's not "live".
-Because queries for live data are handled with Diesel and Redis we don't need
-to send those request through the full Django/Postgresql stack.  Django and
-Postgresql are only involved when you load a fresh page, and they're *more*
-than capable of handling the amount of traffic that AFA gets for those kind of
-requests.
-
-I've created an application called **The Strainer** to copy data from the live
-stream to the Postgresql database.  The Strainer looks at the list of live
-items in Redis, parses those items into Django models and saves them to the
-Postgresql database.
-
-Using two different types of stores (Redis and Postgresql) means we can get the
-best of both worlds for AFA:
-
-* We can keep the live data that's accessed *constantly* in an in-memory Redis
-  datastore which makes it blazingly fast.
-
-* We can keep the less-frequently-used data in an on-disk Postgresql database
-  which lets us to keep our memory usage low and hosting costs down.
-
-Django's models and managers make it very easy to separate updates out into the
-various sessions and presentations that happen at the conferences.
-
-Sessions and presentations are much less in-demand than the live stream so we
-can take advantage of Django's abstractions without worrying about the extra
-memory/CPU usage we incur by doing so.
-
-[Django]: http://djangoproject.com/
-[Gunicorn]: http://gunicorn.org/
-[Nginx]: http://nginx.org/
-[Postgresql]: http://www.postgresql.org/
-
-Staying Consistent
-------------------
-
-Another problem AFA has faced in the past is losing tweets.  No code is perfect
-(and mine *certainly* is not) so we need to anticipate that some of the
-applications we're using will crash at some point.
-
-I'm using [Supervisord][] to monitor the various processes of AFA on the
-server.  If a process crashes for some reason it will be restarted
-automatically.
-
-Supervisord also has a wonderful Python API, so I've created a simple Dashboard
-view in the Django site that lets us stop/start/restart each individual process
-with a simple web interface. The dashboard also shows us the current memory
-usage of the server and some other statistics so we can monitor how things are
-working through a web browser (instead of SSH'ing into the server, which is
-a pain on a phone).
-
-[Supervisord]: http://supervisord.org/
-
-Getting Bigger
---------------
-
-An Event Apart is a large event, but it's not a *huge* event.  Despite this
-I've been trying to build the backend in a way that can be easily scaled.
-
-Right now it's hosted on a single server, but each of the individual components
-could be moved to a separate server with less than an hour of work each:
-
-* Redis
-* Postgresql
-* Django, Nginx and Gunicorn
-* The Nozzletron
-* The Flickrtron
-* The Strainer
-* Halley
-
-Moving Django/Gunicorn, Nginx, Redis, Halley, and Postgresql to dedicated
-servers would increase the performance of the site *immensely*.  I can't
-imagine an event that would provide enough traffic to require more than that.
-
-Even if there were an event that needed that kind of throughput, we could
-easily split the single Halley and Redis servers into multiple load-balanced
-servers.
-
-A Work in Progress
-------------------
-
-This new version of A Feed Apart is still being built.  I'm learning new things
-every time I work on it, and I'm sure there's still room for improvement.
-
-If you have any questions, advice, or want me to go more in-depth about
-a specific aspect of the site's backend please let me know!
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/04/a-faster-feed-apart.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,448 @@
++++
+title = "A Faster Feed Apart"
+snip = "Rethinking A Feed Apart’s backend."
+date = 2010-04-30T22:55:00Z
+draft = false
+
++++
+
+[An Event Apart][aea] is a conference for web developers and designers that
+happens a few times a year in various cities.  [A Feed Apart][afa] is a site
+that aggregates tweets during each conference and displays them in a live
+stream so attendees can follow them during the conference, and people not
+attending can see what the attendees are talking about.
+
+A Feed Apart was originally written by [Nick Sergeant][nick] and [Pete
+Karl][pete] of [Lion Burger][lionburger] during one of the conferences.  Since
+then a lot of people have used it and love it.
+
+The current A Feed Apart site is not without its problems.  It was written in
+a single night so it's not perfect.  During the last conference it went down
+several times and lost some tweets along the way.
+
+I work at [Dumbwaiter Design][dwaiter] with Nick and one day he mentioned that
+it would be cool if we rewrote A Feed Apart from the ground up.  He's learned
+a lot about how people use the site and what the big problems are, so we'd have
+a better idea of what we need to accomplish.
+
+Nick, myself and [Ali Ali][ali] have risen to the challenge and started
+rewriting A Feed Apart.  Ali is a designer and is taking care of the design of
+the new site.  Nick is handling all the frontend HTML, CSS and Javascript.  My
+job is the backend.
+
+Ali posted a [blog entry][aliblog] about the design of the new version so
+I figured I'd write about the backend to show how I'm trying to improve it.  If
+you have any advice I'd love to hear it — the next An Event Apart conference
+is about three weeks away so there's still time to add improvements.
+
+[aea]: http://aneventapart.com/
+[afa]: http://afeedapart.com/
+[nick]: http://nicksergeant.com/
+[pete]: http://pkarl.com/
+[lionburger]: http://lionburger.com/
+[dwaiter]: http://dwaiter.com/
+[ali]: http://alialithinks.com/
+[aliblog]: http://www.dcamm.com/blog/archives/765
+
+{{% toc %}}
+
+How AFA is Used
+---------------
+
+You can't hope to improve on a site unless you know how people are going to use
+it.  AFA has been around for a while and Nick has learned a lot about what
+people want to get out of it.
+
+There are three main kinds of users of AFA:
+
+* People attending the conference
+* People that wish they were attending the conference
+* The speakers/organizers of the conference
+
+### People Attending the Conference
+
+People that attend AEA are web developers and designers.  They're up-to-date on
+the latest technology and almost all of them use [Twitter][].
+
+During the conference you'll see a sea of laptops in the audience.  Attendees
+will tweet about whatever is happening *right now*.  There's a huge amount of
+conversation that happens between attendees that AFA is trying to collect and
+present.
+
+A simple example is one that Nick mentioned to me: if a presenter mentions
+a website during her presentation someone will tweet the URL so other people
+can have a link to easily click on.  Attendees will also tweet their agreement
+or disagreement with what the presenter is saying *as they're speaking*.
+
+The most important aspect of AFA for this group of people is the *real time
+conversation*.  If AFA doesn't show tweets until a minute after they've been
+posted it's useless to these people.
+
+Another important part of AFA for attendees is that it's a one-stop-shop for
+the conversation behind AEA.  Switching between windows/tabs/applications to
+read and contribute is annoying.
+
+### People That Wish They Were Attending the Conference
+
+The next group of users is those that can't attend the conference for a variety
+of reasons but are still interested in what's going on.
+
+For this group the real time nature of AFA is unimportant.  They're probably
+not going to be following the conversation 24/7 so if a tweet takes a few
+minutes to display it's not a big deal.
+
+What these people *do* care about is the integrity of the stream.  They don't
+want to miss any part of the conversation.  If AFA loses tweets they're better
+off doing a simple search on Twitter because they'll get the whole story.
+
+### Speakers and Organizers
+
+The last main group of users is the speakers and organizers of AEA.
+
+Any speaker worth their salt will want to know what people are said about their
+presentation.  Obviously they can't be reading AFA while they're presenting,
+but afterword they'll certainly want to go back and see what people were saying
+during their specific presentation.
+
+Likewise, organizers want to know which presentations people liked and which
+ones people didn't enjoy.  This could easily influence who they choose to
+invite to future conferences.
+
+For this group the most important aspect of AFA is the organization of the
+conversation into chunks, each of which applies to a single presentation.  By
+reading through each chunk of conversation they can get an idea of the general
+response to each presentation.
+
+[Twitter]: http://twitter.com/
+
+Goals
+-----
+
+Once we identified the main users of AFA we were able to come up with the goals
+for the new version of the site:
+
+* **Stay sane while developing.**  Ali, Nick and myself are rewriting the site
+  as a side project, so we don't want it to take *too* much of our time or cause
+  *too* much stress.
+
+* **Provide the real time conversation.**  The site needs to be fast and
+  responsive, so people at the conferences can use it to converse.
+
+* **Don't miss anything.**  People following along from home shouldn't feel
+  like they're missing anything.  We want to provide a *complete* version of the
+  conversation happening behind the event.
+
+* **Organize the conversation.**  Presenters and speakers need a way to see
+  what people are saying about them.  They want to know what people think about
+  each "chunk" of the event.
+
+* **Grease the wheels of (physical) social interaction.**  This is something
+  that AFA hasn't tried to address before, but that we'd like to work on with
+  this version.  There are a lot of people at each conference and we'd like to
+  help them get together.  Whether it's going out for dinner or meeting up at the
+  [Media Temple][mt] party we want to get people talking to each other.  I won't
+  talk about this goal in this post because we're still figuring out the best way
+  to do it.
+
+[mt]: http://mediatemple.net/
+
+Staying Sane
+------------
+
+If the three of us tried to create the site with nothing more than a couple of
+laptops and a few chats in person we'd go crazy.  We use a few tools to help us
+manage the development of the site.
+
+To create **wireframes of the design** we're using a free account at [Hot
+Gloo][hotgloo].  Hot Gloo is a great tool that lets us quickly sketch out ideas
+and comment on them.
+
+To share **design comps** we're using [Dropbox][].  It's simple to set up
+a shared Dropbox folder and Nick and I can get real time updates when Ali makes
+changes to the design.
+
+To **work together on the code** Nick and I use [Mercurial][] repositories.
+Mercurial lets us work on the same code bases simultaneously and we almost
+never have to worry about merging.  We use [Codebase][] for hosting and issue
+tracking.
+
+[hotgloo]: http://hotgloo.com/
+[Dropbox]: http://dropbox.com/
+[Mercurial]: http://hg-scm.org/
+[Codebase]: http://codebasehq.com/
+
+Being Real Time
+---------------
+
+The previous version of AFA wasn't *truly* real time.  When you went to the
+site your browser would ask AFA for the newest updates every 10 seconds.
+
+There are two main problems with this approach.  The first is that it's not
+really *real time*.  I've noticed this being an issue in my own experience.
+
+When I watch any of the various "live streams" of [Apple][] press conferences
+I'm usually at work where other people are also watching.  We very rarely load
+the pages of the streaming sites like Gizmodo at the exact same second, so our
+browsers will be out of sync with each other.  Nick might get an update that
+I would have to wait 8 more seconds to see.
+
+When I glance over at his screen and see an update that I don't have
+I instinctively refresh the page to get it.  This defeats the purpose of the
+"live updating" code that the developers of these sites worked on.  They may as
+well have just made a static page and told me to refresh.
+
+The second problem is that querying every 10 seconds can be taxing on the
+site's database.  We're doing this as a side project so we don't have unlimited
+funding for a hefty database server.  If 1,000 people are querying for updates
+every 10 seconds that's 100 requests per second to the database.  This means we
+need to have some kind of in-memory cacheing if we want the site to feel snappy
+on modest hardware.
+
+We want the new AFA to be truly real time.  To do this we need to use [long
+polling][longpolling] by users' browsers to wait for updates and return them as
+soon as they come in.  We also need to retrieve the updates as fast as we
+possibly can, and they need to be stored in memory to avoid hitting the
+database constantly.
+
+[Apple]: http://apple.com/
+[longpolling]: http://en.wikipedia.org/wiki/Push_technology#Long_polling
+
+### Retrieving Updates
+
+The bulk of the conversation about AEA conferences comes from Twitter.  Tweets
+are the most important items that we need to display on the site, so we're
+using Twitter's streaming API to pull them in.
+
+Since we don't want to tie up an entire server to pull in tweets I've decided
+to create a [Diesel][]-based application called **The Nozzletron** to parse the
+streaming API.  Diesel is a [Python][] framework that takes an elegant approach
+to asynchronous communication with clients and servers.
+
+Twitter's streaming API accepts HTTP requests and returns "chunked" responses,
+each of which is a tweet.  Unfortunately the Diesel's built-in HTTP client
+doesn't handle chunked HTTP responses so I had to write some code to handle
+them myself.
+
+The Nozzletron will connect to Twitter's streaming API and wait for data to
+come in.  If there's no data to process it will relinquish the server's
+processor so it can do other things.  Processing a single tweet that comes in
+doesn't take much time, so the server is free to do other things most of the
+time.
+
+I've also created another application called **The Flickrtron** to pull in
+[Flickr][] photos.  Unfortunately Flickr doesn't have a streaming API like
+Twitter so I have to resort to polling Flickr's API every few minutes for new
+photos.  Flickr is much less of a real time medium than Twitter though, so
+I don't think this is a very big problem.
+
+I'm using a Python library called [Beej's Flickr API][flickrapi] to talk to
+Flickr.  It is horrible.  It calls itself an "API" but is really just a thin
+wrapper around calls to the Flickr API.  The objects it returns for API calls
+are Elementtree objects representing the XML of the response.
+
+I wish I could do something like:
+
+```python
+thumb_url = photo.thumbnail_url
+```
+
+Instead I have to use this monstrosity:
+
+```python
+thumb_url = "http://farm%s.static.flickr.com/%s/%s_%s_s.jpg" % (
+    photo.get('farm'), photo.get('server'), photo.get('id'),
+    photo.get('secret'),
+)
+```
+
+I wish there were a better Python Flickr API out there but there doesn't seem
+to be one.  If I've missed it please let me know!
+
+[Diesel]: http://dieselweb.org/
+[Python]: http://python.org/
+[Flickr]: http://flickr.com/
+[flickrapi]: http://stuvel.eu/projects/flickrapi
+
+### Storing Updates
+
+We need a fast way to store and retrieve updates so AFA can provide a real time
+view of the conversation happening at AEA.  With this in mind I've chosen
+[Redis][] to store the updates of the currently-happening event.
+
+Redis is an easy-to-set-up, disgustingly-fast, in-memory data store.  It's
+similar to [memcached][] but has more intelligent data structures that make my
+life easier for this project.
+
+As updates (tweets and flickr photos) are scraped by The Nozzletron and The
+Flickrtron they're placed at the tail end of a Redis list.  That means I can
+quickly and easily get all the items since item `N` when a user's browser
+requests them with a single `LRANGE {list-key} N -1` call.
+
+I'm also keeping a few other pieces of information in Redis.  For example,
+there's a set of photo IDs held in the `{item-key}:flickrtron:grabbed_photos`
+key that keeps track of all of the photos we've already seen.
+
+This makes it easy to tell if we've already seen a photo (and therefore don't
+need to query Flickr for more information) — it's a simple `SISMEMBER
+{item-key}:flickrtron:grabbed_photos {photo-id}` call.
+
+I'm also using Redis to store statistics about the site like:
+
+* How many tweets we've scraped.
+* How many photos we've scraped.
+* How many people are currently waiting for updates.
+
+This kind of information will be extremely valuable in the future when we're
+planning improvements to the site.  Redis makes it fast and safe to update this
+information using the `INCRBY` and `DECR` commands.
+
+There's one more component to The Nozzletron and The Flickrton that I haven't
+mentioned.  Both use Redis' `PUBLISH` command to push new updates out to users'
+browsers as they arrive.  I'll talk more about that in the next section.
+
+[Redis]: http://code.google.com/p/redis/
+[memcached]: http://memcached.org/
+
+### Sending Updates to Users
+
+As I mentioned before we want to send updates to users *as soon as they're
+received*.  To do this I've created another Diesel-based application called
+**Halley** to handle this [Comet][]-style communication.
+
+Halley has a few components.  The first uses Diesel's [Redis API][dieselredis]
+to subscribe to a Redis channel like `live:{event-id}:items` and
+[fire][dieselfire] off messages whenever something new comes in.  As soon as
+a new update comes in from The Nozzletron or The Flickrtron all of Halley's
+clients will get it.
+
+When I started working on AFA Diesel's Redis client didn't support the very new
+`PUBLISH`/`SUBSCRIBE`/`UNSUBSCRIBE` commands.  I implemented them, put my
+changes on [BitBucket][], sent a pull request, and started talking to the
+Diesel crew on IRC.
+
+One of the maintainers pulled my patches and made them even better.  Now
+Diesel's Redis client has full `PUBLISH`/`SUBSCRIBE`/`UNSUBSCRIBE` support.
+It's a great example of how open source projects can produce awesome results.
+
+The other main component of Halley is an HTTP server that listens for
+connections from browsers.  The Javascript on the site will call Halley and say
+"I need updates since number `X`", where `X` is the length of the Redis list of
+updates at the last time it spoke to the server.
+
+Halley uses Diesel's [HTTP Server][dieselhttp] to manage these requests.
+
+If a client is asking for everything since `X` and `X` is a smaller number than
+the current number of items it will return the updates that have happened since
+then.  This might happen if we return an update and then two more updates
+happen before the browser gets around to sending another request.
+
+If a client is asking for everything since `X` and `X` is equal to the current
+number of items Halley will wait for a new message to be fired from the
+[Loop][dieselloop] that's watching the Redis channel.  While Halley waits she
+relinquishes the processor to the server so other requests can be handled.
+
+There's a bit of code to prevent DoS attacks that request every item in the
+queue over and over again, of course.
+
+[Comet]: http://en.wikipedia.org/wiki/Comet_(programming)
+[dieselredis]: http://bitbucket.org/boomplex/diesel/src/tip/diesel/protocols/redis.py
+[dieselfire]: http://bitbucket.org/boomplex/diesel/src/tip/diesel/core.py#cl-90
+[BitBucket]: http://bitbucket.org/
+[dieselhttp]: http://bitbucket.org/boomplex/diesel/src/tip/diesel/protocols/http.py#cl-156
+[dieselloop]: http://bitbucket.org/boomplex/diesel/src/tip/diesel/core.py#cl-179
+
+Organizing the Conversation
+---------------------------
+
+The live stream is an important component of AFA, but it's not the only one.
+We also need to organize updates into logical chunks by event and presentation,
+and provide archives of old events so people can see what happened.
+
+The main AFA site is built with [Django][] and served with [Gunicorn][] and
+[Nginx][].  It uses a [Postgresql][] database to store data that's not "live".
+Because queries for live data are handled with Diesel and Redis we don't need
+to send those request through the full Django/Postgresql stack.  Django and
+Postgresql are only involved when you load a fresh page, and they're *more*
+than capable of handling the amount of traffic that AFA gets for those kind of
+requests.
+
+I've created an application called **The Strainer** to copy data from the live
+stream to the Postgresql database.  The Strainer looks at the list of live
+items in Redis, parses those items into Django models and saves them to the
+Postgresql database.
+
+Using two different types of stores (Redis and Postgresql) means we can get the
+best of both worlds for AFA:
+
+* We can keep the live data that's accessed *constantly* in an in-memory Redis
+  datastore which makes it blazingly fast.
+
+* We can keep the less-frequently-used data in an on-disk Postgresql database
+  which lets us to keep our memory usage low and hosting costs down.
+
+Django's models and managers make it very easy to separate updates out into the
+various sessions and presentations that happen at the conferences.
+
+Sessions and presentations are much less in-demand than the live stream so we
+can take advantage of Django's abstractions without worrying about the extra
+memory/CPU usage we incur by doing so.
+
+[Django]: http://djangoproject.com/
+[Gunicorn]: http://gunicorn.org/
+[Nginx]: http://nginx.org/
+[Postgresql]: http://www.postgresql.org/
+
+Staying Consistent
+------------------
+
+Another problem AFA has faced in the past is losing tweets.  No code is perfect
+(and mine *certainly* is not) so we need to anticipate that some of the
+applications we're using will crash at some point.
+
+I'm using [Supervisord][] to monitor the various processes of AFA on the
+server.  If a process crashes for some reason it will be restarted
+automatically.
+
+Supervisord also has a wonderful Python API, so I've created a simple Dashboard
+view in the Django site that lets us stop/start/restart each individual process
+with a simple web interface. The dashboard also shows us the current memory
+usage of the server and some other statistics so we can monitor how things are
+working through a web browser (instead of SSH'ing into the server, which is
+a pain on a phone).
+
+[Supervisord]: http://supervisord.org/
+
+Getting Bigger
+--------------
+
+An Event Apart is a large event, but it's not a *huge* event.  Despite this
+I've been trying to build the backend in a way that can be easily scaled.
+
+Right now it's hosted on a single server, but each of the individual components
+could be moved to a separate server with less than an hour of work each:
+
+* Redis
+* Postgresql
+* Django, Nginx and Gunicorn
+* The Nozzletron
+* The Flickrtron
+* The Strainer
+* Halley
+
+Moving Django/Gunicorn, Nginx, Redis, Halley, and Postgresql to dedicated
+servers would increase the performance of the site *immensely*.  I can't
+imagine an event that would provide enough traffic to require more than that.
+
+Even if there were an event that needed that kind of throughput, we could
+easily split the single Halley and Redis servers into multiple load-balanced
+servers.
+
+A Work in Progress
+------------------
+
+This new version of A Feed Apart is still being built.  I'm learning new things
+every time I work on it, and I'm sure there's still room for improvement.
+
+If you have any questions, advice, or want me to go more in-depth about
+a specific aspect of the site's backend please let me know!
+
--- a/content/blog/2010/05/mercurial-workflows-stable-default.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,163 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Mercurial Workflows: Stable &amp; Default"
-    snip: "Part 2 of several."
-    created: 2010-05-17 18:27:00
-%}
-
-{% block article %}
-
-This entry is the second in my series describing various Mercurial workflows.
-The [first][branch-as-needed] describes the simplest one: branching only
-when necessary.
-
-If you're working on a larger project you might want something with a bit more
-structure. This post is about the "stable and default" workflow.
-
-[branch-as-needed]: /blog/2010/02/mercurial-workflows-branch-as-needed/
-
-[TOC]
-
-"Stable and Default" in a Nutshell
-----------------------------------
-
-The general idea of this workflow is that you keep two branches: `default` and
-`stable`.
-
-* **`default`** is the branch where new features and functionality are added.
-* **`stable`** is where bug fixes are added, as well as documentation improvements
-  that don't pertain to new features.
-
-Each time you make a bug fix in `stable` you merge it into `default`, so
-`default` is always a superset of `stable`.
-
-Periodically (whenever you're ready for a "major release") you'll merge
-`default` into `stable` so new features can be included in releases.
-
-[Mercurial][] itself [uses][hg-branches] this workflow for development, so it
-can scale well to projects of moderate to large size.
-
-[Mercurial]: http://hg-scm.org/
-[hg-branches]: http://selenic.com/repo/hg/branches/
-
-Branch Setup
-------------
-
-To get started using this workflow you'll need to create a `stable` named
-branch:
-
-    :::console
-    hg branch stable
-    hg commit -m "Create the stable branch."
-
-Once you do this users of your project can clone the `stable` branch and be
-confident that they're getting a relatively stable version of your code.  To
-clone a branch like this they would do something like:
-
-    :::console
-    hg clone http://bitbucket.org/you/yourproject#stable
-
-This will clone your project's repository and include only changesets on the
-`stable` branch (and any of their ancestors).
-
-Making Changes
---------------
-
-The goal of this workflow is to do all non-bugfix development on the `default`
-branch.  Pure bug fixes should go on the `stable` branch so `stable` stays as,
-well, "stable" as possible.
-
-Users that want to live on the bleeding edge of development can use the
-`default` branch of your project.  Hopefully your project has some users that
-are willing to work with `default` and inform you of bugs found with the new
-functionality you add to it.
-
-Whenever you make a change to `stable` you'll want to merge it into `default`
-so that `default` always remains a superset of `stable`. This makes `default`
-as stable as it can possibly be.  It also makes it easier to merge `default`
-back into stable whenever you're ready for a major release.
-
-Here's an example of how your repository's graph will end up looking:
-
-![Sample Default and Stable Graph](/media/images{{parent_url}}/default-stable-example.png "Sample Default and Stable Graph")
-
-Notice how each time some changes are made on `stable` they're merged to
-`default`.
-
-Releasing Major Versions
-------------------------
-
-There will come a time when you're ready to release non-bugfix improvements to
-your project to the general public. Non-bugfix improvements are made in the
-`default` branch, so when you're ready to do this you'll merge `default` into
-`stable`.
-
-Because your project has more `stable` users than bleeding-edge users, you'll
-probably get more bug reports than usual after you release a major version.
-This is to be expected and you should be ready for it.
-
-Tagging Releases
-----------------
-
-Any decent project should tag releases.  This lets users easily use a version
-of your project that they know works.
-
-Wondering how to decide when to tag releases, and what to use for the tags?
-The [semantic versioning][semver] specification is a great guide that makes it
-easy for your users to know (in a broad sense) what each release changes.
-
-In a nutshell, tags in a semantically versioned project work like this:
-
-* Tags are of the form "v[MAJOR].[MINOR].[BUGFIX]"
-* Tags with a major version of "0" make no guarantees about anything. They are
-  used for alpha/beta versions of the project.
-* An increase in the bugfix version of a project means "bugs were fixed."
-* An increase in the minor version of a project means "functionality has been
-  added without breaking backwards compatibility."
-* An increase in the major version of a project means "backwards compatibility
-  has been broken."
-
-Unfortunately this workflow makes it a bit more complicated to add semantic
-versioning tags to your project. The rules for semantic tagging would work like
-this:
-
-* When you fix a bug on the `stable` branch, increment the bugfix version on
-  `stable` and merge `stable` into `default`.
-* When you add new functionality and are ready to release it to the public,
-  merge `default` into stable and increment the minor version of `stable`.
-* When you're ready for a backwards-incompatible release, merge `default` into
-  stable and increment the major version of `stable`.
-
-The problem with this is that `default` never has any version tags. However,
-this probably isn't a big deal because users of `default` are those that want
-to live on the bleeding edge of your project and aren't as concerned with
-stability.
-
-[semver]: http://semver.org/
-
-Why Default and Stable Instead of Default and Dev?
---------------------------------------------------
-
-In the workflow I've described there are two branches: `default` and `stable`.
-You might be wondering why `default` is used for new development and the
-"stable" branch is relegated to a named branch.
-
-The reason is that `default` will typically have many, many more changesets
-added to it than `stable`, and so making the "development" branch the default
-makes it easier on the developers.
-
-There is absolutely *nothing* wrong with making `default` the "stable" branch
-and creating a `dev` branch for "unstable" changes. If your project rarely adds
-new functionality but is more concerned with fixing bugs this version of the
-workflow will obviously be better for you.
-
-This version also has the added advantage of giving users that naively clone
-your project (without a branch specified) the stable version.  Since many users
-don't bother to read instructions even when you provide them, there is a strong
-argument for using it even when your project is *not* overly concerned with bug
-fixes.
-
-It's up to you to decide which version you want to use.
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/05/mercurial-workflows-stable-default.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,162 @@
++++
+title = "Mercurial Workflows: Stable & Default"
+snip = "Part 2 of several."
+date = 2010-05-17T18:27:00Z
+draft = false
+
++++
+
+This entry is the second in my series describing various Mercurial workflows.
+The [first][branch-as-needed] describes the simplest one: branching only
+when necessary.
+
+If you're working on a larger project you might want something with a bit more
+structure. This post is about the "stable and default" workflow.
+
+[branch-as-needed]: /blog/2010/02/mercurial-workflows-branch-as-needed/
+
+{{% toc %}}
+
+"Stable and Default" in a Nutshell
+----------------------------------
+
+The general idea of this workflow is that you keep two branches: `default` and
+`stable`.
+
+* **`default`** is the branch where new features and functionality are added.
+* **`stable`** is where bug fixes are added, as well as documentation improvements
+  that don't pertain to new features.
+
+Each time you make a bug fix in `stable` you merge it into `default`, so
+`default` is always a superset of `stable`.
+
+Periodically (whenever you're ready for a "major release") you'll merge
+`default` into `stable` so new features can be included in releases.
+
+[Mercurial][] itself [uses][hg-branches] this workflow for development, so it
+can scale well to projects of moderate to large size.
+
+[Mercurial]: http://hg-scm.org/
+[hg-branches]: http://selenic.com/repo/hg/branches/
+
+Branch Setup
+------------
+
+To get started using this workflow you'll need to create a `stable` named
+branch:
+
+```console
+hg branch stable
+hg commit -m "Create the stable branch."
+```
+
+Once you do this users of your project can clone the `stable` branch and be
+confident that they're getting a relatively stable version of your code.  To
+clone a branch like this they would do something like:
+
+```console
+hg clone http://bitbucket.org/you/yourproject#stable
+```
+
+This will clone your project's repository and include only changesets on the
+`stable` branch (and any of their ancestors).
+
+Making Changes
+--------------
+
+The goal of this workflow is to do all non-bugfix development on the `default`
+branch.  Pure bug fixes should go on the `stable` branch so `stable` stays as,
+well, "stable" as possible.
+
+Users that want to live on the bleeding edge of development can use the
+`default` branch of your project.  Hopefully your project has some users that
+are willing to work with `default` and inform you of bugs found with the new
+functionality you add to it.
+
+Whenever you make a change to `stable` you'll want to merge it into `default`
+so that `default` always remains a superset of `stable`. This makes `default`
+as stable as it can possibly be.  It also makes it easier to merge `default`
+back into stable whenever you're ready for a major release.
+
+Here's an example of how your repository's graph will end up looking:
+
+![Sample Default and Stable Graph](/media/images/blog/2010/05/default-stable-example.png "Sample Default and Stable Graph")
+
+Notice how each time some changes are made on `stable` they're merged to
+`default`.
+
+Releasing Major Versions
+------------------------
+
+There will come a time when you're ready to release non-bugfix improvements to
+your project to the general public. Non-bugfix improvements are made in the
+`default` branch, so when you're ready to do this you'll merge `default` into
+`stable`.
+
+Because your project has more `stable` users than bleeding-edge users, you'll
+probably get more bug reports than usual after you release a major version.
+This is to be expected and you should be ready for it.
+
+Tagging Releases
+----------------
+
+Any decent project should tag releases.  This lets users easily use a version
+of your project that they know works.
+
+Wondering how to decide when to tag releases, and what to use for the tags?
+The [semantic versioning][semver] specification is a great guide that makes it
+easy for your users to know (in a broad sense) what each release changes.
+
+In a nutshell, tags in a semantically versioned project work like this:
+
+* Tags are of the form "v[MAJOR].[MINOR].[BUGFIX]"
+* Tags with a major version of "0" make no guarantees about anything. They are
+  used for alpha/beta versions of the project.
+* An increase in the bugfix version of a project means "bugs were fixed."
+* An increase in the minor version of a project means "functionality has been
+  added without breaking backwards compatibility."
+* An increase in the major version of a project means "backwards compatibility
+  has been broken."
+
+Unfortunately this workflow makes it a bit more complicated to add semantic
+versioning tags to your project. The rules for semantic tagging would work like
+this:
+
+* When you fix a bug on the `stable` branch, increment the bugfix version on
+  `stable` and merge `stable` into `default`.
+* When you add new functionality and are ready to release it to the public,
+  merge `default` into stable and increment the minor version of `stable`.
+* When you're ready for a backwards-incompatible release, merge `default` into
+  stable and increment the major version of `stable`.
+
+The problem with this is that `default` never has any version tags. However,
+this probably isn't a big deal because users of `default` are those that want
+to live on the bleeding edge of your project and aren't as concerned with
+stability.
+
+[semver]: http://semver.org/
+
+Why Default and Stable Instead of Default and Dev?
+--------------------------------------------------
+
+In the workflow I've described there are two branches: `default` and `stable`.
+You might be wondering why `default` is used for new development and the
+"stable" branch is relegated to a named branch.
+
+The reason is that `default` will typically have many, many more changesets
+added to it than `stable`, and so making the "development" branch the default
+makes it easier on the developers.
+
+There is absolutely *nothing* wrong with making `default` the "stable" branch
+and creating a `dev` branch for "unstable" changes. If your project rarely adds
+new functionality but is more concerned with fixing bugs this version of the
+workflow will obviously be better for you.
+
+This version also has the added advantage of giving users that naively clone
+your project (without a branch specified) the stable version.  Since many users
+don't bother to read instructions even when you provide them, there is a strong
+argument for using it even when your project is *not* overly concerned with bug
+fixes.
+
+It's up to you to decide which version you want to use.
+
--- a/content/blog/2010/06/mercurial-workflows-translation-branches.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Mercurial Workflows: Translation Branches"
-    snip: "Uncommon but useful."
-    created: 2010-06-11 08:15:00
-%}
-
-{% block article_class %}with-diagrams{% endblock %}
-
-{% block article %}
-
-This entry is the third in my series describing various [Mercurial][] workflows.
-The [first][branch-as-needed] describes the simplest one: branching only when
-necessary, and the [second][default-and-stable] describes the classic "default
-and stable" workflow.
-
-I've been experimenting with another workflow lately and it's proven itself to
-be pretty useful, so I wanted to write about it.
-
-[Mercurial]: {{ links.mercurial }}
-[branch-as-needed]: /blog/2010/02/mercurial-workflows-branch-as-needed/
-[default-and-stable]: /blog/2010/05/mercurial-workflows-stable-default/
-
-[TOC]
-
-A Real Example
---------------
-
-I created the [hgtip.com][] site a while back as a resource for all those tiny
-little tips that make working with Mercurial easier. People seemed to like it
-and eventually there was some interest in translating the site to other
-languages.
-
-The site itself is a collection of flat files that are run through [Hyde][] to
-generate a set of static HTML pages. The content of the site is held in
-a [subrepo][] which people can clone to contribute without worrying about the
-site's structure.
-
-When coming up with a strategy for managing translations I had the following
-requirements:
-
-* Translations need to be version controlled. Version control is extremely
-  helpful, so we need to use it.
-* Contributing translations should be (almost) as easy as contributing to the
-  main site. I didn't want it to be much more work than a simple clone, commit,
-  push.
-* I make typos when creating tips, and sometimes people comment with ideas
-  I hadn't thought of, which I then add to the tips. When the main (English)
-  version of a tip is updated it needs to be easy for translators to see
-  exactly what changed so they can update their translations.
-
-After thinking about the problem for a while I settled on using Mercurial's
-named branches to manage translations.
-
-[hgtip.com]: http://hgtip.com/
-[Hyde]: {{ links.hyde }}
-[subrepo]: http://mercurial.selenic.com/wiki/subrepos
-
-
-Branch Structure
-----------------
-
-For the content of hgtip I (currently) have three branches: `default`, `ja`,
-and `de`.
-
-`default` contains the English version of the tips, while `ja` and `de` contain
-the Japanese and German translations.
-
-As other people translate the existing tips they commit to the appropriate
-branch. When I publish the site to the server I can easily update to each
-branch to render the content, one at a time.
-
-When I add new tips I commit them to the `default` branch and merge `default`
-into all the translation branches. This adds the new file to the translation
-branches so it gets rendered (in English) on the other versions of the site.
-
-When a translator is ready to translate any new tips, they can run `hg log -b
-THEIRBRANCH` to see what's been merged into the branch and find the tips they
-need to translate.
-
-Here's a diagram to help explain what's going on. As new tips are added they
-get merged into the translation branches. When a translator has time to
-translate a tip, they commit to their branch.
-
-![Translation Branching Diagram](/media/images{{ parent_url }}/translation-branches.png "Translation Branches")
-
-
-Linebreaks
-----------
-
-There's one small issue that arises with a workflow like this, and it happens
-when I fix a typo (or add an update) in an existing tip.
-
-If I fix a typo in `beginner/sometip.html`, it will cause a merge conflict when
-someone tries to merge it into a translation branch. This is generally a good
-thing because it shows the translator where the change was. They can then fix
-the conflict by changing the translation, commit, and everything works.
-
-The tricky part is that Mercurial will only show line-by-line diffs. If each
-paragraph of a tip is a single line, Mercurial will only tell you the paragraph
-that changed. For large paragraphs this is annoying because you need to figure
-out by hand exactly which word was modified.
-
-To avoid this I always make sure that lines are hard-wrapped with linebreaks.
-You can do this easily by pressing `Ctrl-Q` in TextMate or using `gqip` in vim.
-I'm sure Emacs has an equivalent as well.
-
-This doesn't affect the output because hgtip uses [Markdown][] and Markdown
-ignores single linebreaks. If you're using another markup language this might
-be a bigger problem for you than it is for me.
-
-[Markdown]: {{ links.markdown }}
-
-A Work in Progress
-------------------
-
-This is the first time I've ever used this branching structure and I haven't
-hear about other people using it.  I'm sure there are some tricks that might
-make things smoother, so if you have any advice I'd love to hear it!
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/06/mercurial-workflows-translation-branches.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,118 @@
++++
+title = "Mercurial Workflows: Translation Branches"
+snip = "Uncommon but useful."
+date = 2010-06-11T08:15:00Z
+draft = false
+
++++
+
+This entry is the third in my series describing various [Mercurial][] workflows.
+The [first][branch-as-needed] describes the simplest one: branching only when
+necessary, and the [second][default-and-stable] describes the classic "default
+and stable" workflow.
+
+I've been experimenting with another workflow lately and it's proven itself to
+be pretty useful, so I wanted to write about it.
+
+[Mercurial]: {{ links.mercurial }}
+[branch-as-needed]: /blog/2010/02/mercurial-workflows-branch-as-needed/
+[default-and-stable]: /blog/2010/05/mercurial-workflows-stable-default/
+
+{{% toc %}}
+
+A Real Example
+--------------
+
+I created the [hgtip.com][] site a while back as a resource for all those tiny
+little tips that make working with Mercurial easier. People seemed to like it
+and eventually there was some interest in translating the site to other
+languages.
+
+The site itself is a collection of flat files that are run through [Hyde][] to
+generate a set of static HTML pages. The content of the site is held in
+a [subrepo][] which people can clone to contribute without worrying about the
+site's structure.
+
+When coming up with a strategy for managing translations I had the following
+requirements:
+
+* Translations need to be version controlled. Version control is extremely
+  helpful, so we need to use it.
+* Contributing translations should be (almost) as easy as contributing to the
+  main site. I didn't want it to be much more work than a simple clone, commit,
+  push.
+* I make typos when creating tips, and sometimes people comment with ideas
+  I hadn't thought of, which I then add to the tips. When the main (English)
+  version of a tip is updated it needs to be easy for translators to see
+  exactly what changed so they can update their translations.
+
+After thinking about the problem for a while I settled on using Mercurial's
+named branches to manage translations.
+
+[hgtip.com]: http://hgtip.com/
+[Hyde]: {{ links.hyde }}
+[subrepo]: http://mercurial.selenic.com/wiki/subrepos
+
+
+Branch Structure
+----------------
+
+For the content of hgtip I (currently) have three branches: `default`, `ja`,
+and `de`.
+
+`default` contains the English version of the tips, while `ja` and `de` contain
+the Japanese and German translations.
+
+As other people translate the existing tips they commit to the appropriate
+branch. When I publish the site to the server I can easily update to each
+branch to render the content, one at a time.
+
+When I add new tips I commit them to the `default` branch and merge `default`
+into all the translation branches. This adds the new file to the translation
+branches so it gets rendered (in English) on the other versions of the site.
+
+When a translator is ready to translate any new tips, they can run `hg log -b
+THEIRBRANCH` to see what's been merged into the branch and find the tips they
+need to translate.
+
+Here's a diagram to help explain what's going on. As new tips are added they
+get merged into the translation branches. When a translator has time to
+translate a tip, they commit to their branch.
+
+<img src="/media/images/blog/2010/06/translation-branches.png"
+     class="diagram"
+     alt="Translation Branching Diagram"/>
+
+Linebreaks
+----------
+
+There's one small issue that arises with a workflow like this, and it happens
+when I fix a typo (or add an update) in an existing tip.
+
+If I fix a typo in `beginner/sometip.html`, it will cause a merge conflict when
+someone tries to merge it into a translation branch. This is generally a good
+thing because it shows the translator where the change was. They can then fix
+the conflict by changing the translation, commit, and everything works.
+
+The tricky part is that Mercurial will only show line-by-line diffs. If each
+paragraph of a tip is a single line, Mercurial will only tell you the paragraph
+that changed. For large paragraphs this is annoying because you need to figure
+out by hand exactly which word was modified.
+
+To avoid this I always make sure that lines are hard-wrapped with linebreaks.
+You can do this easily by pressing `Ctrl-Q` in TextMate or using `gqip` in vim.
+I'm sure Emacs has an equivalent as well.
+
+This doesn't affect the output because hgtip uses [Markdown][] and Markdown
+ignores single linebreaks. If you're using another markup language this might
+be a bigger problem for you than it is for me.
+
+[Markdown]: {{ links.markdown }}
+
+A Work in Progress
+------------------
+
+This is the first time I've ever used this branching structure and I haven't
+hear about other people using it.  I'm sure there are some tricks that might
+make things smoother, so if you have any advice I'd love to hear it!
+
--- a/content/blog/2010/08/a-git-users-guide-to-mercurial-queues.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,267 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "A Git User's Guide to Mercurial Queues"
-    snip: "MQ is git's index on steroids."
-    created: 2010-08-10 21:00:00
-%}
-
-{% block article_class %}with-diagrams{% endblock %}
-
-{% block article %}
-
-I've been using [Mercurial Queues][MQ] more and more lately. At the last
-Mercurial sprint [Brendan Cully][brendan] said something that made me realize
-that MQ behaves very much like a souped-up version of [git][]'s index.
-
-I wanted to write a blog post about the similarities between the two concepts
-so that git users could understand [Mercurial][]'s MQ extension a bit better
-and see how it can take that concept even further than git does.
-
-This post is *not* intended to be a guide to MQ's day-to-day commands -- it's
-simply trying to explain MQ in a way that git users might find more
-understandable.  For a primer on MQ commands you can check out [the MQ chapter
-in the hg book][mq-book].
-
-[MQ]: http://mercurial.selenic.com/wiki/MqExtension
-[brendan]: http://cs.ubc.ca/~brendan/
-[git]: {{links.git}}
-[Mercurial]: {{links.mercurial}}
-[mq-book]: http://hgbook.red-bean.com/read/managing-change-with-mercurial-queues.html
-
-[TOC]
-
-Git Basics
-----------
-
-Let's take a few moments to review how git works so we're all on the same page
-with our terminology.
-
-When you're working with a git repository you have three "layers" to work with:
-
-* The working directory
-* The index
-* The git repository
-
-You use `git add` to shove changes from the working directory into the index
-and `git commit` to shove changes from the index into the repository:
-
-![Git Basics Diagram](/media/images{{ parent_url }}/git-basics.png "Git Basics")
-
-This is a very powerful model because it lets you build your changesets
-piece-by-piece and commit them permanently only when you're ready.
-
-Mercurial Basics
-----------------
-
-With basic, stock Mercurial you only have two "layers" to work with:
-
-* The working directory
-* The Mercurial repository
-
-You use `hg commit` to shove changes from the working directory into the
-repository:
-
-![Mercurial Basics Diagram](/media/images{{ parent_url }}/mercurial-basics.png "Mercurial Basics")
-
-This model doesn't give you as much flexibility in creating changesets as
-git's does. You can use the [record extension][record] to get closer, but it's still
-not the same.
-
-[record]: http://mercurial.selenic.com/wiki/RecordExtension
-
-Let's take a look at MQ to see how it can give us everything git's index does
-*and more.*
-
-Using MQ with a Single Patch
-----------------------------
-
-The most basic way to use MQ is to create a single patch with `hg qnew NAME`.
-You can make changes in your working directory and use `hg qrefresh` (or `hg
-qrecord`) to put them into the patch. Once you're done with your patch and
-ready for it to become a commit you can run `hg qfinish`:
-
-![MQ with One Patch](/media/images{{ parent_url }}/mq-one.png "MQ with One Patch")
-
-This looks a lot like the diagram of how git works, doesn't it?  MQ gives you an
-"intermediate" area to put changes, similar to how git's index works.
-
-Using MQ with Two (or More) Patches
------------------------------------
-
-This single "intermediate" area is where git stops.  For many workflows it's
-enough, but if you want more power MQ has you covered.
-
-MQ is called Mercurial *Queues* for a reason.  You can have more than one patch
-in your queue, which means you can have multiple "intermediate" areas if you
-need them.
-
-For example: say you're adding a feature that requires some API changes to your
-project.  You'd like to commit the changes to the API in one changeset, and the
-changes to the interface in another changeset.  You can do this by creating two
-patches with `hg qnew api-changes; hg qnew interface-changes`:
-
-![MQ with Two Patches](/media/images{{ parent_url }}/mq-two.png "MQ with Two Patches")
-
-You can move back and forth between these patches with `hg qpop` and `hg
-qpush`. If you're working on the interface and realize you forgot to make
-a necessary change to the API you can:
-
-* `hg qpop` the `interface-changes` patch to get to the `api-changes` patch.
-* Make your API changes.
-* `hg qrefresh` to put those changes into the `api-changes` patch.
-* `hg qpush` to get back to work on the interface.
-
-Using multiple patches is like having multiple git indexes to store related
-changes until you're ready to commit them permanently.
-
-Multiple Patch Queues
----------------------
-
-What happens when you want to work on two features, each with two patches, at
-the same time?  You *could* simply create four patches and let the second
-feature live on top of the first, but there's a better way.
-
-Mercurial 1.6 (I think) added the `hg qqueue` command, which lets you create
-*multiple* patch queues, each one living in its own directory. That means you
-can create a separate queue (with its own set of patches) with `hg qqueue -c
-NAME` for each feature:
-
-![MQ with Multiple Queues](/media/images{{ parent_url }}/mq-multiple.png "MQ with Multiple Queues")
-
-You can switch patch queues with `hg qqueue NAME`.  This gives you multiple
-sets of "intermediate" areas like git's index to work with.  This is probably
-not something you'll need very often, but it's there when you *do* need it.
-
-You can see that MQ is already quite a bit more flexible than git's index, but
-it has one more trick up its sleeve.
-
-Versioned Patch Queues
-----------------------
-
-Let me prefix this section by saying: "You might think you need to use versioned
-patch queues, but you probably don't."  Versioned queues can be tricky to wrap
-your head around, but once you understand them you'll realize how powerful they
-can be.
-
-Let's pause a second to look at how MQ actually stores its patches.
-
-When you create a new patch with `hg qnew interface-changes` Mercurial will
-create a `patches` folder inside the `.hg` folder of your project.  Your new
-patch is stored in a file inside that folder (along with some other metadata
-files):
-
-    :::text
-    yourproject/
-    |
-    +-- .hg/
-    |   |
-    |   +-- patches/
-    |   |   |
-    |   |   +-- api-changes
-    |   |   +-- interface-changes
-    |   |   `-- ... other MQ-related files ...
-    |   |
-    |   `-- ... other Mercurial-related files ...
-    |
-    `-- ... your project's files ...
-
-When you create a new patch queue with `hg qqueue -c some-feature` Mercurial
-creates a completely separate `patches-some-feature` folder in `.hg`:
-
-    :::text
-    yourproject/
-    |
-    +-- .hg/
-    |   |
-    |   +-- patches/
-    |   |   |
-    |   |   +-- api-changes
-    |   |   +-- interface-changes
-    |   |   `-- ... other MQ-related files ...
-    |   |
-    |   +-- patches-some-feature/
-    |   |   |
-    |   |   +-- api-changes
-    |   |   +-- interface-changes
-    |   |   `-- ... other MQ-related files ...
-    |   |
-    |   `-- ... other mercurial-related files ...
-    |
-    `-- ... your project's files ...
-
-These folders are normal filesystem folders. The patches inside them are
-plain-text files.
-
-This gives them a very important property:
-
-**They can be turned into Mercurial repositories to track changes.**
-
-Once you understand what this means, you should have several "oh my god"
-moments where you realize several very interesting things:
-
-* Not only can you have multiple sets of "intermediate" areas to work with, you
-  can *version* them to keep track of the changes!
-* You can share queues with other people with Mercurial's vanilla push/pull
-  commands.
-* You can collaborate with other people and merge your changes to these
-  "intermediate" areas with Mercurial's vanilla push/pull/merge commands.
-* You can `hg serve` these patch repositories so other people can see what your
-  patches look like before they've been permanently committed to your project's
-  repository.
-
-Versioning patch queues means you can end up with a (hard to read) diagram like
-this:
-
-![Versioned Queues](/media/images{{ parent_url }}/mq-versioned.png "Versioned Queues")
-
-To facilitate working with versioned patch queues all Mercurial commands come
-with a `--mq` option to apply the command to the queue repository instead of
-the current one (so you don't need to `cd` to the queue repository all the
-time).
-
-Versioning patch queues is an *incredibly* powerful concept, and most of the
-time you won't need it, but it's nice to have it when you do.
-
-It's also nice to know that [BitBucket][] has [special support][] for version
-patch queues.
-
-[BitBucket]: http://bitbucket.org/
-[special support]: http://ches.nausicaamedia.com/articles/technogeekery/using-mercurial-queues-and-bitbucket-org
-
-Problems with MQ
-----------------
-
-Despite how powerful MQ is (or perhaps *because* of it) it has some problems.
-Most could be fixed if someone had a week or two to spend on it, but so far no
-one has stepped up.
-
-I'd do it if I could afford to take a week away from full-time/freelance work,
-but I can't right now.  If you want to be the hero of at least one MQ user (me)
-here's what sucks about MQ:
-
-* There's no easy way to pull changes *out* of an MQ patch.
-* There's no easy way to split an MQ patch into two patches (the current
-  horrible "workaround" is to empty the current patch, `hg qrecord` part one,
-  and `hg qnew` to make a new patch with part two).
-* You can't pop a patch once you've made changes in your working directory. You
-  need to [shelve][] the changes, pop the patch, and then unshelve the changes.
-
-[shelve]: http://mercurial.selenic.com/wiki/ShelveExtension
-
-In addition there's another MQ-related change that would be very, very nice:
-
-* Refactor the record extension and put it into core Mercurial, so that
-  `hg qrecord` could be used without an extra extension (and we could have `hg
-  commit --interactive`).
-
-If someone takes the time to fix these problems I'll love them forever.  Until
-then we're stuck with the powerful-but-sometimes-clumsy MQ interface.
-
-Hopefully this post has given git users (and Mercurial users) an idea of how
-powerful MQ can be.  If you have any questions please find me on
-[Twitter][twsl] and me know!
-
-[twsl]: {{links.twsl}}
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/08/a-git-users-guide-to-mercurial-queues.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,264 @@
++++
+title = "A Git User's Guide to Mercurial Queues"
+snip = "MQ is git's index on steroids."
+date = 2010-08-10T21:00:00Z
+draft = false
+
++++
+
+I've been using [Mercurial Queues][MQ] more and more lately. At the last
+Mercurial sprint [Brendan Cully][brendan] said something that made me realize
+that MQ behaves very much like a souped-up version of [git][]'s index.
+
+I wanted to write a blog post about the similarities between the two concepts
+so that git users could understand [Mercurial][]'s MQ extension a bit better
+and see how it can take that concept even further than git does.
+
+This post is *not* intended to be a guide to MQ's day-to-day commands — it's
+simply trying to explain MQ in a way that git users might find more
+understandable.  For a primer on MQ commands you can check out [the MQ chapter
+in the hg book][mq-book].
+
+[MQ]: http://mercurial.selenic.com/wiki/MqExtension
+[brendan]: http://cs.ubc.ca/~brendan/
+[git]: {{links.git}}
+[Mercurial]: {{links.mercurial}}
+[mq-book]: http://hgbook.red-bean.com/read/managing-change-with-mercurial-queues.html
+
+{{% toc %}}
+
+Git Basics
+----------
+
+Let's take a few moments to review how git works so we're all on the same page
+with our terminology.
+
+When you're working with a git repository you have three "layers" to work with:
+
+* The working directory
+* The index
+* The git repository
+
+You use `git add` to shove changes from the working directory into the index
+and `git commit` to shove changes from the index into the repository:
+
+<img class="diagram" src="/media/images/blog/2010/08/git-basics.png" alt="Git Basics"/>
+
+This is a very powerful model because it lets you build your changesets
+piece-by-piece and commit them permanently only when you're ready.
+
+Mercurial Basics
+----------------
+
+With basic, stock Mercurial you only have two "layers" to work with:
+
+* The working directory
+* The Mercurial repository
+
+You use `hg commit` to shove changes from the working directory into the
+repository:
+
+<img class="diagram" src="/media/images/blog/2010/08/mercurial-basics.png" alt="Mercurial Basics"/>
+
+This model doesn't give you as much flexibility in creating changesets as
+git's does. You can use the [record extension][record] to get closer, but it's still
+not the same.
+
+[record]: http://mercurial.selenic.com/wiki/RecordExtension
+
+Let's take a look at MQ to see how it can give us everything git's index does
+*and more.*
+
+Using MQ with a Single Patch
+----------------------------
+
+The most basic way to use MQ is to create a single patch with `hg qnew NAME`.
+You can make changes in your working directory and use `hg qrefresh` (or `hg
+qrecord`) to put them into the patch. Once you're done with your patch and
+ready for it to become a commit you can run `hg qfinish`:
+
+<img class="diagram" src="/media/images/blog/2010/08/mq-one.png" alt="MQ with One Patch"/>
+
+This looks a lot like the diagram of how git works, doesn't it?  MQ gives you an
+"intermediate" area to put changes, similar to how git's index works.
+
+Using MQ with Two (or More) Patches
+-----------------------------------
+
+This single "intermediate" area is where git stops.  For many workflows it's
+enough, but if you want more power MQ has you covered.
+
+MQ is called Mercurial *Queues* for a reason.  You can have more than one patch
+in your queue, which means you can have multiple "intermediate" areas if you
+need them.
+
+For example: say you're adding a feature that requires some API changes to your
+project.  You'd like to commit the changes to the API in one changeset, and the
+changes to the interface in another changeset.  You can do this by creating two
+patches with `hg qnew api-changes; hg qnew interface-changes`:
+
+<img class="diagram" src="/media/images/blog/2010/08/mq-two.png" alt="MQ with Two Patches"/>
+
+You can move back and forth between these patches with `hg qpop` and `hg
+qpush`. If you're working on the interface and realize you forgot to make
+a necessary change to the API you can:
+
+* `hg qpop` the `interface-changes` patch to get to the `api-changes` patch.
+* Make your API changes.
+* `hg qrefresh` to put those changes into the `api-changes` patch.
+* `hg qpush` to get back to work on the interface.
+
+Using multiple patches is like having multiple git indexes to store related
+changes until you're ready to commit them permanently.
+
+Multiple Patch Queues
+---------------------
+
+What happens when you want to work on two features, each with two patches, at
+the same time?  You *could* simply create four patches and let the second
+feature live on top of the first, but there's a better way.
+
+Mercurial 1.6 (I think) added the `hg qqueue` command, which lets you create
+*multiple* patch queues, each one living in its own directory. That means you
+can create a separate queue (with its own set of patches) with `hg qqueue -c
+NAME` for each feature:
+
+<img class="diagram" src="/media/images/blog/2010/08/mq-multiple.png" alt="MQ with Multiple Queues"/>
+
+You can switch patch queues with `hg qqueue NAME`.  This gives you multiple
+sets of "intermediate" areas like git's index to work with.  This is probably
+not something you'll need very often, but it's there when you *do* need it.
+
+You can see that MQ is already quite a bit more flexible than git's index, but
+it has one more trick up its sleeve.
+
+Versioned Patch Queues
+----------------------
+
+Let me prefix this section by saying: "You might think you need to use versioned
+patch queues, but you probably don't."  Versioned queues can be tricky to wrap
+your head around, but once you understand them you'll realize how powerful they
+can be.
+
+Let's pause a second to look at how MQ actually stores its patches.
+
+When you create a new patch with `hg qnew interface-changes` Mercurial will
+create a `patches` folder inside the `.hg` folder of your project.  Your new
+patch is stored in a file inside that folder (along with some other metadata
+files):
+
+```text
+yourproject/
+|
++-- .hg/
+|   |
+|   +-- patches/
+|   |   |
+|   |   +-- api-changes
+|   |   +-- interface-changes
+|   |   `-- ... other MQ-related files ...
+|   |
+|   `-- ... other Mercurial-related files ...
+|
+`-- ... your project's files ...
+```
+
+When you create a new patch queue with `hg qqueue -c some-feature` Mercurial
+creates a completely separate `patches-some-feature` folder in `.hg`:
+
+```text
+yourproject/
+|
++-- .hg/
+|   |
+|   +-- patches/
+|   |   |
+|   |   +-- api-changes
+|   |   +-- interface-changes
+|   |   `-- ... other MQ-related files ...
+|   |
+|   +-- patches-some-feature/
+|   |   |
+|   |   +-- api-changes
+|   |   +-- interface-changes
+|   |   `-- ... other MQ-related files ...
+|   |
+|   `-- ... other mercurial-related files ...
+|
+`-- ... your project's files ...
+```
+
+These folders are normal filesystem folders. The patches inside them are
+plain-text files.
+
+This gives them a very important property:
+
+**They can be turned into Mercurial repositories to track changes.**
+
+Once you understand what this means, you should have several "oh my god"
+moments where you realize several very interesting things:
+
+* Not only can you have multiple sets of "intermediate" areas to work with, you
+  can *version* them to keep track of the changes!
+* You can share queues with other people with Mercurial's vanilla push/pull
+  commands.
+* You can collaborate with other people and merge your changes to these
+  "intermediate" areas with Mercurial's vanilla push/pull/merge commands.
+* You can `hg serve` these patch repositories so other people can see what your
+  patches look like before they've been permanently committed to your project's
+  repository.
+
+Versioning patch queues means you can end up with a (hard to read) diagram like
+this:
+
+<img class="diagram" src="/media/images/blog/2010/08/mq-versioned.png" alt="Versioned Queues"/>
+
+To facilitate working with versioned patch queues all Mercurial commands come
+with a `--mq` option to apply the command to the queue repository instead of
+the current one (so you don't need to `cd` to the queue repository all the
+time).
+
+Versioning patch queues is an *incredibly* powerful concept, and most of the
+time you won't need it, but it's nice to have it when you do.
+
+It's also nice to know that [BitBucket][] has [special support][] for version
+patch queues.
+
+[BitBucket]: http://bitbucket.org/
+[special support]: http://ches.nausicaamedia.com/articles/technogeekery/using-mercurial-queues-and-bitbucket-org
+
+Problems with MQ
+----------------
+
+Despite how powerful MQ is (or perhaps *because* of it) it has some problems.
+Most could be fixed if someone had a week or two to spend on it, but so far no
+one has stepped up.
+
+I'd do it if I could afford to take a week away from full-time/freelance work,
+but I can't right now.  If you want to be the hero of at least one MQ user (me)
+here's what sucks about MQ:
+
+* There's no easy way to pull changes *out* of an MQ patch.
+* There's no easy way to split an MQ patch into two patches (the current
+  horrible "workaround" is to empty the current patch, `hg qrecord` part one,
+  and `hg qnew` to make a new patch with part two).
+* You can't pop a patch once you've made changes in your working directory. You
+  need to [shelve][] the changes, pop the patch, and then unshelve the changes.
+
+[shelve]: http://mercurial.selenic.com/wiki/ShelveExtension
+
+In addition there's another MQ-related change that would be very, very nice:
+
+* Refactor the record extension and put it into core Mercurial, so that
+  `hg qrecord` could be used without an extra extension (and we could have `hg
+  commit --interactive`).
+
+If someone takes the time to fix these problems I'll love them forever.  Until
+then we're stuck with the powerful-but-sometimes-clumsy MQ interface.
+
+Hopefully this post has given git users (and Mercurial users) an idea of how
+powerful MQ can be.  If you have any questions please find me on
+[Twitter][twsl] and me know!
+
+[twsl]: {{links.twsl}}
+
--- a/content/blog/2010/09/coming-home-to-vim.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,942 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Coming Home to Vim"
-        snip: "I'm sorry I ever left, baby."
-        created: 2010-09-20 18:15:00
-    %}
-
-    {% block article %}
-
-I'm a programmer. I work with text files for 6-12 hours every weekday so I care
-about the text editor I use. If switching to a different editor can increase my
-efficiency by even 10% it would save a good chunk of my time and let me get
-back to making cool things.
-
-I don't buy the "you're thinking 90% of the time and only typing 10% of the
-time, so your editor doesn't really matter" argument. Even if the premise is
-true, the conclusion is wrong.
-
-If I think for 10 minutes and then start typing, I want the typing to take the
-shortest time possible so I can get back to thinking. Any time I spend typing
-is an interruption that I want to minimize so I can keep my train of thought.
-
-I recently started using [Vim][] as my primary editor. As I'm adjusting I'm
-finding a lot of [the][arrows] [blog][nutheads] [posts][mind] [people][katz]
-[have][nvie] [written][grok] [about][home] Vim very helpful, so I'm hoping this
-post will help people too.
-
-[Vim]: http://www.vim.org/
-[arrows]: http://jeetworks.org/node/89
-[nutheads]: http://www.viemu.com/a-why-vi-vim.html
-[mind]: http://wekeroad.com/2010/07/29/vim-is-your-daddy/
-[katz]: http://yehudakatz.com/2010/07/29/everyone-who-tried-to-convince-me-to-use-vim-was-wrong/
-[nvie]: http://nvie.com/posts/how-i-boosted-my-vim/
-[grok]: http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118
-[home]: http://weblog.jamisbuck.org/2008/10/10/coming-home-to-vim
-
-[TOC]
-
-Some Background About Me
-------------------------
-
-I used Vim exclusively from about 2002 to 2005. I never really learned much
-about it and mostly used it as a glorified [nano][].
-
-In 2006 I decided it was time for a change. I wanted an editor that "fit" with
-OS X. I tried [SubEthaEdit][] for a while and it was kind of cool. The
-collaborative editing was more polished than any other version I've seen,
-though I didn't have much use for it.
-
-As cool as SubEthaEdit was, I always felt like there was a better editor out
-there for me. Then I found [TextMate][].
-
-At the time I thought TextMate was amazing (and it really was). It *looked*
-like a Mac application. It was super easy to learn (all the OS X text movement
-commands just worked). There were bundles for everything.
-
-I still used Vim occasionally (like when I had a job and only had a Windows
-machine), but for the most part I was a TextMate kid.
-
-After using TextMate for four years I decided it was time for another change.
-Development on TextMate has stalled while TextMate Forever (err, TextMate 2) is
-in the works. I started thinking about Vim (and reading blog posts by others
-about how they switched back) and decided to give it another try.
-
-A few months ago I bought [Learning the vi and Vim Editors][] and went
-cold-turkey with Vim as my main text editor. I haven't looked back since.
-
-[nano]: http://en.wikipedia.org/wiki/Nano_(text_editor)
-[SubEthaEdit]: http://www.codingmonkeys.de/subethaedit/
-[TextMate]: http://macromates.com/
-[Learning the vi and Vim Editors]: http://amzn.com/059652983X
-
-Why I Switched to TextMate
---------------------------
-
-As I mentioned before, there were a few reasons I switched to TextMate in the
-first place.
-
-First of all: it looks and acts like a real OS X application.  You can drag
-files onto the icon to open them, it supports all the default OS X text
-movement commands, and the chrome looks like it belongs on OS X. I don't know
-if [MacVim][] was around at the time, but if it was I never found it.
-
-This matters. The effort required to get started with a new editor is
-dramatically reduced if that editor supports all the conventions of the
-operating system you use every day.
-
-It also has a vibrant community of people writing bundles for it, so there was
-support for almost anything I wanted to use.
-
-[MacVim]: http://code.google.com/p/macvim/
-
-Why I Came Back to Vim
-----------------------
-
-I came back to Vim for a number of reasons.
-
-First of all: I started reading about and desiring features that didn't seem to
-be coming to TextMate any time soon. The biggest of those was split windows.
-I saw the appeal of split windows right away and now that I use them I can't
-imagine not having them.
-
-Another reason is version control. A while ago I started keeping my
-[dotfiles][] in a [Mercurial][] repository which makes it extremely easy to set
-up new machines.  Vim keeps all of its configuration in two simple places:
-a simple `~/.vimrc` file and a `~/.vim` directory full of plain text files.
-
-Vim's plain text configuration files and plugins are very easy to version
-control. They diff well, unlike TextMate's multiple `Bundles` directories and
-ugly XML file format.
-
-Vim's community has been around far longer than TextMate's so there's an even
-richer set of plugins, bundles and syntax files available.
-
-Another reason people give for enjoying Vim is that it runs everywhere. Yes,
-it's nice to have my favorite editor available when I SSH into a machine, but
-it's not a huge deal if I don't. I almost always edit files on my own machine
-and then deploy them with an automated script of some kind, so editing on
-a server is very rare for me.
-
-[dotfiles]: http://bitbucket.org/sjl/dotfiles/
-[Mercurial]: http://hg-scm.org/
-
-Core Differences
-----------------
-
-For me, Vim and TextMate are very different.  TextMate relies mainly on
-keyboard shortcuts (involving Shift, Ctrl, Cmd and Alt) to do more than simply
-edit text. Vim uses a "modal editing" idea to accomplish the same task.
-
-TextMate's philosophy is much the same as any normal OS X application's, and
-I said that acting like the OS reduces the barrier of entry for a text editor,
-so why do I prefer Vim's philosophy?
-
-First I should prefix my answer with this: I'm not averse to a learning curve
-for something as important to me as a text editor.  Yes, it's awesome if
-I don't need to unnecessarily rewire my brain, but if it's going to save me
-a lot of time then I'm willing to cut a bit of slack here.
-
-My problem with TextMate's philosophy can be summed up in one word:
-"shadowing".
-
-If I want to define a new command in a bundle (or if someone else has already
-done it), I'm never really sure if I'm "overwriting" some other command that my
-fingers know but my brain doesn't really register.
-
-By the time I try to use the default command it could be days or weeks after
-I defined the custom one, and I need to figure out what I did all over again.
-It's quite frustrating.
-
-Vim's "insert" mode means that when I'm editing text I'm using the normal OS
-X text movement shortcuts that I know and love.  When I want to do something
-special I enter normal mode and don't have to worry about shadowed commands
-(Vim's leader key also helps with this).
-
-Vim's "Feeling"
----------------
-
-Vim's normal mode has a unique "feeling" that I haven't seen in any other text
-editor (although [E][] may [change that][modalE]). I've heard it described in
-a number of ways, and I think that while no one analogy fully explains it,
-together they give a pretty good description.
-
-[E]: http://www.e-texteditor.com/
-[modalE]: http://e-texteditor.com/blog/2010/beyond-vi
-
-### A "Language" of Text Editing
-
-One way to think about Vim's normal-mode commands is like a language.  You have
-"verbs" and "nouns".  For example: the "change" command (`c`) would be a verb
-and the "word" item (`w`) is a noun.  You can combine them to form imperative
-sentences that talk about what you want to do with your text.
-
-The wonderful part about this is that whenever you learn a new verb (like
-"delete" (`d`)) you can immediately apply it to all the nouns you know, and
-vice versa.
-
-Vim also has "adjectives" like "inside" and "around" (`i` and `a`) that let you
-craft sentences like "change inside parenthesis" (`ci(` or `cib`).  Once you
-learn one of these you can immediately apply it to all the verbs and nouns you
-already know.
-
-### The Physics of Text
-
-The second way to describe the feeling of Vim is "physics".  It's a much less
-concrete description but I think it's still useful.
-
-If I throw a bowling ball into the air it behaves much the same way as if
-I throw a turkey sandwich.  They might have very different effects when they
-land on someone but the act of throwing them is pretty much the same.
-
-Vim's operators/actions/verbs act the same way. `daw` has a very different
-effect than `da{` but they can both be understood with a basic underlying
-principle: `da<something>` will "delete around `<something>`".
-
-### "Programming" Your Editing
-
-The last way that I hear people talking about Vim's editing is: "it feels like
-you're 'programming' your text".
-
-This analogy is often made by programmers (obviously) and I think it works on
-more than one level.
-
-First: Vim's basic editing commands can be likened to function calls.  `daw`
-can be thought of a running a function like `delete(type='word', around=True)`.
-I don't think this way (I prefer the language and physics analogies) but other
-people do.
-
-Although I don't think of the *basic* Vim commands as programming I do see
-some aspects of it in other areas.  For example: say I define a leader command
-in my `~/.vimrc` file:
-
-    :::vim
-    nnoremap <leader>1 yypVr=
-
-I think of this as defining `<leader>1` to be a function that performs the
-following actions:
-
-* Yank/copy the current line.
-* Paste it below (and move down to the pasted version).
-* Select the copied line.
-* Replace every character with `=`.
-
-Another more obvious "programming" aspect of Vim is creating macros. Macros are
-like tiny little functions you create to help you when you're editing a file.
-You can define them, execute them, and even edit them by pasting, editing and
-yanking them back.
-
-Getting Started
----------------
-
-When I switched back to Vim I did a few things that helped make my transition
-stick.
-
-First: I bought [Learning the vi and Vim Editors][] and read it cover to cover.
-It helps quite a bit to know the history behind Vim, and the book also teaches
-you the basics of Vim's editing commands.
-
-I also looked through [the Vim subreddit][rvim] to find some good blog posts about
-switching.  A lot of people have written about it and it was very helpful to
-read about their experiences.
-
-And finally, the most important part: I switched cold-turkey.  Vim runs everywhere, so
-there's really no excuse for not doing this.  Every decent OS has a version of
-Vim that makes insert mode "just work" for their OS (like gvim or MacVim), so
-the barrier to entry these days is pretty low.
-
-You can get Vim and start using it right away by staying in insert mode most of
-the time. Then you can start learning its real features at your own pace.
-Trying to use two different editors at once just slows down the learning
-process and makes you less productive in both.
-
-[rvim]: http://reddit.com/r/vim/
-
-Making Vim More Useful
-----------------------
-
-One of the flaws of Vim is that it takes quite a bit of configuration to make
-it behave in a decent way. The defaults are backwards-compatible with vi (i.e.
-older than most college students) and not very helpful.
-
-Here are a few of the things I do to make Vim a bit more palatable.
-
-**A quick side note:** even if you don't use Vim, you *need* to [remap your
-capslock key][capslock] to something useful.  Just do it, you'll thank me.
-
-[capslock]: http://c2.com/cgi/wiki?RemapCapsLock
-
-### Important .vimrc Lines
-
-I won't go through every line in [my `~/.vimrc` file][sjlvimrc], but here are some of the
-lines that I simply could not live without.
-
-[sjlvimrc]: http://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc
-
-First, a few lines that you absolutely must have:
-
-    :::vim
-    filetype off
-    call pathogen#runtime_append_all_bundles()
-    filetype plugin indent on
-
-    set nocompatible
-
-    set modelines=0
-
-The `filetype` and `call` lines are for loading Pathogen, which is described in
-the bundles section. See [Pathogen's docs][pathogendocs] to learn about why the
-first `filetype` line is there.
-
-[pathogendocs]: http://www.vim.org/scripts/script.php?script_id=2332
-
-`set nocompatible` gets rid of all the crap that Vim does to be vi compatible.
-It's 2010 -- we don't need to be compatible with vi at the expense of
-functionality any more.
-
-The `modelines` bit prevents some [security exploits][] having to do with
-modelines in files.  I never use modelines so I don't miss any functionality
-here.
-
-[security exploits]: http://lists.alioth.debian.org/pipermail/pkg-vim-maintainers/2007-June/004020.html
-
-Next I set my tab settings:
-
-    :::vim
-    set tabstop=4
-    set shiftwidth=4
-    set softtabstop=4
-    set expandtab
-
-I like all tabs to expand to four spaces.  Check out [this Vimcast][vctabs] to
-learn more about each of these options.
-
-[vctabs]: http://vimcasts.org/episodes/tabs-and-spaces/
-
-Next are a few options that just make things better:
-
-    :::vim
-    set encoding=utf-8
-    set scrolloff=3
-    set autoindent
-    set showmode
-    set showcmd
-    set hidden
-    set wildmenu
-    set wildmode=list:longest
-    set visualbell
-    set cursorline
-    set ttyfast
-    set ruler
-    set backspace=indent,eol,start
-    set laststatus=2
-    set relativenumber
-    set undofile
-
-Each of these lines are basically to make Vim behave in a sane manner.  The two
-"interesting" ones are the last two, and both deal with features that are
-[new in Vim 7.3][vim73].
-
-[vim73]: http://groups.google.com/group/vim_announce/browse_thread/thread/66c02efd1523554b
-
-`relativenumber` changes Vim's line number column to display how far away each
-line is from the current one, instead of showing the absolute line number.
-
-I almost never care what numeric line I'm on in a file (and if I do I can see
-it in the status line), so I don't miss the normal line numbers. I *do* care
-how far away a particular line might be, because it tells me what number I need
-to use with motion commands like `d<NUMBER>d`.
-
-`undofile` tells Vim to create `<FILENAME>.un~` files whenever you edit a file.
-These files contain undo information so you can undo previous actions even
-after you close and reopen a file.
-
-Next I change the `<leader>` key:
-
-    :::vim
-    let mapleader = ","
-
-For me `,` is easier to type than `\`. I use leader commands constantly so it's
-worth changing.
-
-The next thing I do is tame searching/moving:
-
-    :::vim
-    nnoremap / /\v
-    vnoremap / /\v
-    set ignorecase
-    set smartcase
-    set gdefault
-    set incsearch
-    set showmatch
-    set hlsearch
-    nnoremap <leader><space> :noh<cr>
-    nnoremap <tab> %
-    vnoremap <tab> %
-
-The first two lines fix Vim's horribly broken default regex "handling" by
-automatically inserting a `\v` before any string you search for.  This turns
-off Vim's crazy default regex characters and makes searches use normal regexes.
-I already know Perl/Python compatible regex formatting, why would I want to
-learn another scheme?
-
-`ignorecase` and `smartcase` together make Vim deal with case-sensitive search
-intelligently. If you search for an all-lowercase string your search will be
-case-insensitive, but if one or more characters is uppercase the search will be
-case-sensitive. Most of the time this does what you want.
-
-`gdefault` applies substitutions globally on lines.  For example, instead of
-`:%s/foo/bar/g` you just type `:%s/foo/bar/`.  This is almost always what you
-want (when was the last time you wanted to only replace the first occurrence of
-a word on a line?) and if you need the previous behavior you just tack on the
-`g` again.
-
-`incsearch`, `showmatch` and `hlsearch` work together to highlight search
-results (as you type).  It's really quite handy, as long as you have the next
-line as well.
-
-The `<leader><space>` mapping makes it easy to clear out a search by typing
-`,<space>`. This gets rid of the distracting highlighting once I've found what
-I'm looking for.
-
-The last two lines make the tab key match bracket pairs. I use this to move
-around all the time and `<tab>` is a hell of a lot easier to type than `%`.
-
-The next section makes Vim handle long lines correctly:
-
-    :::vim
-    set wrap
-    set textwidth=79
-    set formatoptions=qrn1
-    set colorcolumn=85
-
-These lines manage my line wrapping settings and also show a colored column at
-85 characters (so I can see when I write a too-long line of code).
-
-See [`:help fo-table`][fotable] and the Vimcasts on [soft wrapping][] and [hard wrapping][] for more information.
-
-[fotable]: http://vimdoc.sourceforge.net/htmldoc/change.html#fo-table
-[soft wrapping]: http://vimcasts.org/episodes/soft-wrapping-text/
-[hard wrapping]: http://vimcasts.org/episodes/hard-wrapping-text/
-
-Next comes something other TextMate refugees may like:
-
-    :::vim
-    set list
-    set listchars=tab:▸\ ,eol:¬
-
-This makes Vim show invisible characters with the same characters that TextMate
-uses.  You might need to adjust your color scheme so they're not too
-distracting. [This Vimcast][vcinvis] has more information.
-
-[vcinvis]: http://vimcasts.org/episodes/show-invisibles/
-
-New Vim users will want the following lines to teach them to do things right:
-
-    :::vim
-    nnoremap <up> <nop>
-    nnoremap <down> <nop>
-    nnoremap <left> <nop>
-    nnoremap <right> <nop>
-    inoremap <up> <nop>
-    inoremap <down> <nop>
-    inoremap <left> <nop>
-    inoremap <right> <nop>
-    nnoremap j gj
-    nnoremap k gk
-
-This will disable the arrow keys while you're in normal mode to help you learn
-to use `hjkl`.  Trust me, you want to learn to use `hjkl`.  Playing a lot of
-[Nethack][] also helps.
-
-[Nethack]: http://www.nethack.org/
-
-It also disables the arrow keys in insert mode to force you to get back into
-normal mode the instant you're done inserting text, which is the "right way" to
-do things.
-
-It also makes j and k work the way you expect instead of working in some
-archaic "movement by file line instead of screen line" fashion.
-
-Next, get rid of that stupid goddamned help key that you will invaribly hit
-*constantly* while aiming for escape:
-
-    :::vim
-    inoremap <F1> <ESC>
-    nnoremap <F1> <ESC>
-    vnoremap <F1> <ESC>
-
-I also like to make `;` do the same thing as `:` -- it's one less key to hit
-every time I want to save a file:
-
-    :::vim
-    nnoremap ; :
-
-I don't remap `:` back to `;` because it seems to break a bunch of plugins.
-
-Finally, I really like TextMate's "save on losing focus" feature.  I can't
-remember a time when I *didn't* want to save a file after tabbing away from my
-editor (especially with version control and Vim's persistent undo):
-
-    :::vim
-    au FocusLost * :wa
-
-Those are the most important bits of my `~/.vimrc` file. Next I'll talk about
-the wonderful namespace of customization that is Vim's `<leader>` key.
-
-### Using the Leader
-
-Vim dedicates an entire keyboard key for user-specific customizations. This is
-called the "leader" and by default it's mapped to `\`. As I mentioned in the
-previous section I prefer to use `,` instead.
-
-Each person will find little things they type or execute often and want to
-create shortcuts for those things. The leader is a kind of "namespace" to keep
-those customizations separate and prevent them from shadowing default commands.
-
-Here are a few of the things I use leader commands for.  You'll certainly have
-different ideas than I do, but this might give you an idea of what you can do.
-
-I use `,W` to mean "strip all trailing whitespace in the current file" so I can
-clean things up quickly:
-
-    :::vim
-    nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
-
-I use Ack a lot (described below), so I mapped a leader key for it:
-
-    :::vim
-    nnoremap <leader>a :Ack
-
-I work with HTML often, so I have `,ft` mapped to a "fold tag" function:
-
-    :::vim
-    nnoremap <leader>ft Vatzf
-
-I also work with Nick Sergeant and he likes his CSS properties sorted, so
-here's a `,S` mapping that sorts them for me:
-
-    :::vim
-    nnoremap <leader>S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR>
-
-This next mapping imitates TextMates `Ctrl+Q` function to re-hardwrap
-paragraphs of text:
-
-    :::vim
-    nnoremap <leader>q gqip
-
-I have a `,v` mapping to reselect the text that was just pasted so I can
-perform commands (like indentation) on it:
-
-    :::vim
-    nnoremap <leader>v V`]
-
-This last mapping lets me quickly open up my `~/.vimrc` file in a vertically
-split window so I can add new things to it on the fly.
-
-    :::vim
-    nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
-
-### Quicker Escaping
-
-One thing you'll find yourself constantly doing in Vim is moving from insert
-mode to normal mode.  The default way to do this is by hitting Escape, but that
-key is out of the way and hard to hit.
-
-Another way is to use `Ctrl+C` or `Ctrl+[`, but I don't like using a chord for
-something I press that often.
-
-I personally use `jj` to exit back to normal mode. The only time I've ever
-actually tried to hit two `j`'s in a row is just now while writing this entry,
-so it doesn't conflict with my normal typing at all:
-
-    :::vim
-    inoremap jj <ESC>
-
-### Working With Split Windows
-
-Being able to split my editor window and see more than one file at once is one
-of the main reasons I switched to Vim.  I know I'm not alone here after reading
-various posts around the internet asking for this feature in TextMate.
-
-Vim's default commands for interacting with splits, however, are kind of
-clunky.  I've added a few mappings to my `~/.vimrc` that make things work a bit
-smoother.
-
-This first mapping makes `,w` open a new vertical split and switch over to it.
-Because really, how often do you split your window and not want to do something
-in the new split?
-
-    :::vim
-    nnoremap <leader>w <C-w>v<C-w>l
-
-You might notice that this mapping is for vertical splits.  I almost *never*
-use horizontal splits. All of my screens are widescreen, so I can fit several
-files onscreen if they're split vertically. Horizontal splits don't let me see
-enough of the file. If I *really* want a horizontal split I can use `<C-w>s`
-to get one.
-
-This next set of mappings maps `<C-[h/j/k/l]>` to the commands needed to move
-around your splits.  If you remap your capslock key to `Ctrl` it makes for very
-easy navigation.
-
-    :::vim
-    nnoremap <C-h> <C-w>h
-    nnoremap <C-j> <C-w>j
-    nnoremap <C-k> <C-w>k
-    nnoremap <C-l> <C-w>l
-
-Aesthetics
-----------
-
-I know some people say: "looks don't matter, the only thing that's important is
-functionality". That's completely wrong.
-
-If I'm looking at something for multiple hours each day it had damn well better
-look pretty. There are three main steps to making Vim look pretty (for me, on
-OS X -- your mileage may vary).
-
-First: get [MacVim][].  It makes Vim look (and behave) like a native Mac
-application. It helps it avoid standing out like a sore thumb among your other
-applications. Linux and Windows users will probably want gvim.
-
-Next: pick a decent font.  I prefer 12 point [Menlo][].  You might have
-a different preference, but at least try out a few and find one that has a nice
-balance between line height (so you can get a good amount of lines on the
-screen) and readability (slashed zeros, please).
-
-Finally: find a good color scheme. I've been using [a slightly modified
-version][myMolokai] of [Molokai][] (a port of the TextMate [Monokai][] theme)
-since I came back to Vim, but recently I've also started flirting with
-[Mustang][] and [Clouds Midnight][].  Spend an hour and find something that
-looks good to you.
-
-Here's what my current setup looks like:
-
-![Current Vim Setup Screenshot](/media/images{{ parent_url }}/vim.png "My Current Vim Setup")
-
-[Menlo]: http://arstechnica.com/apple/news/2009/06/font-changes-coming-to-mac-os-x-snow-leopard.ars
-[myMolokai]: http://bitbucket.org/sjl/dotfiles/src/tip/vim/colors/molokai.vim
-[Molokai]: http://www.vim.org/scripts/script.php?script_id=2340
-[Monokai]: http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
-[Mustang]: http://hcalves.deviantart.com/art/Mustang-Vim-Colorscheme-98974484
-[Clouds Midnight]: http://forr.st/~yZn
-
-Bundles I Use
--------------
-
-Vim has been around for a *long* time, and many people have written extensions
-for it.  Here are a few of the bundles I couldn't live without in my day-to-day
-editing.
-
-### Pathogen
-
-First of all: [Tim Pope][] has created the wonderful [Pathogen][] plugin that
-makes managing *other* Vim plugins painless.  Instead of scattering their files
-throughout your `~/.vim/` folder you can keep their files inside a single
-folder in `~/.vim/bundles/`.
-
-Install it and keep your sanity.
-
-[Tim Pope]: http://github.com/tpope
-[Pathogen]: http://github.com/tpope/vim-pathogen
-
-### PeepOpen
-
-One of TextMate's "killer features" is its `Cmd+T` key. It lets you open files
-quickly by typing fragments of their names.
-
-There are a number of Vim plugins out there that try to emulate it.  My
-favorite is [PeepOpen][].  Yes, it's OS X only and costs money, but it's worth
-it.  It looks good and "just works".
-
-PeepOpen has some nifty little features, like showing Git metadata in the file
-list. I've [offered a patch][] to add the same functionality for Mercurial but
-haven't heard back from the developers.
-
-If you don't use OS X (or want a free alternative to PeepOpen) I hear the
-[Command-T][] plugin is quite nice.
-
-[PeepOpen]: http://peepcode.com/products/peepopen
-[offered a patch]: http://github.com/topfunky/PeepOpen-Issues/issues#issue/91
-[Command-T]: https://wincent.com/products/command-t
-
-### NERDTree
-
-One plugin you'll hear about in almost all of these "switching to Vim" blog
-posts is [NERDTree][]. It's a little plugin for browsing files in your project,
-and it works great. There's no better "TextMate file-drawer" plugin around.
-
-[NERDTree]: http://github.com/scrooloose/nerdtree
-
-### NERDCommenter
-
-Want to be able to comment and uncomment code with a few keypresses?  You need
-[NERDCommenter][]. It's surprising that Vim doesn't have decent commenting
-functionality built in, but NERDCommenter fixes that.
-
-I really only use this plugin for one single function: "toggle comment" with
-`<leader>c<space>`. That function alone is worth installing it.
-
-[NERDCommenter]: http://github.com/scrooloose/nerdcommenter
-
-### Ack
-
-If you're a programmer and you don't know about [Ack][], you need to start
-using it now. It's far, far better than grep.
-
-The [Ack plugin][ack.vim] for Vim integrates Ack with Vim's quickfix window so
-you can easily search and jump to results.
-
-As I mentioned in the section about leader mappings I've got `,a` mapped to
-bring up Ack all ready to search.
-
-[Ack]: http://betterthangrep.com/
-[ack.vim]: http://github.com/mileszs/ack.vim
-
-### Snipmate
-
-Another feature of TextMate that was *amazing* when I first saw it was
-snippets. [SnipMate][] is a Vim plugin that emulates TextMate snippets.
-
-It also stores them in easily-version-controlled plain text files, which is
-a bonus over TextMate's snippets.
-
-[SnipMate]: http://github.com/msanders/snipmate.vim
-
-### Sparkup
-
-[Sparkup][] is pretty much a great port of [Zen Coding][] for Vim. If you write
-HTML at all this plugin will save you a ton of typing.
-
-In a nutshell it lets you type something like:
-
-    :::text
-    div.content>h1.post-title+p{Sample Content}
-
-Press `Cmd+E` and it will expand to this:
-
-    :::html
-    <div class="content">
-        <h1 class="post-title"></h1>
-        <p>Sample Content</p>
-    </div>
-
-It's far less typing and it adds up over time.
-
-[Sparkup]: http://github.com/rstacruz/sparkup
-[Zen Coding]: http://code.google.com/p/zen-coding/
-
-### Yankring
-
-Vim's copying and pasting functionality (which uses registers) is very, very
-powerful, but it's not exactly "user friendly". The [YankRing][] plugin adds
-a lot *more* power, but also adds a few features that make copying and pasting
-much more pleasant.
-
-For example, after you paste some text you can replace that paste with the
-previous item you copied with `Ctrl-P`.  You can cycle back further by just
-hitting `Ctrl-P` over and over.
-
-YankRing also shares your yanked text between Vim windows, which makes things
-"just work" when you want to paste text from one window into another.
-
-You can also show a list of all your previously yanked text with `:YRShow`.
-Mapping that command to a key is quite helpful:
-
-    :::vim
-    nnoremap <silent> <F3> :YRShow<cr>
-    inoremap <silent> <F3> <ESC>:YRShow<cr>
-
-YankRing offers a ton of other cool functionality but I haven't had the time or
-motivation to really dig in and find out how to use it.
-
-[YankRing]: http://www.vim.org/scripts/script.php?script_id=1234
-
-### Surround (and Repeat)
-
-Another of Time Pope's plugins that I use all the time is the [Surround][]
-plugin.  It adds another layer to Vim's physics: "surrounding items".
-
-For example, you can "change surrounding single quotes to double quotes" by
-using `cs'"`. Or if you're writing something in Markdown and want to italicize
-a word you can use `ysiW*`.
-
-All the nouns and verbs you already know can be used, which fits with Vim's
-philosophy and makes it extremely powerful.
-
-The [Repeat][] plugin is necessary to make these surround actions repeatable
-with `.`.
-
-[Surround]: http://github.com/tpope/vim-surround
-[Repeat]: http://github.com/tpope/vim-repeat
-
-### Slime
-
-Emacs users often tout SLIME as one of Emacs' "killer features". When writing
-LISP code it's unchallengably awesome.
-
-Vim doesn't have anything like SLIME. It's not integrated with any language the
-way Emacs is coupled to LISP. You can, however, achieve *some* of the power of
-SLIME in Vim.
-
-[Jonathan Palardy][] has written a little Vim plugin called [Slime.vim][] that
-lets Vim easily communicate with a screen session, probably one running a REPL
-for some language like LISP, Python or Ruby.
-
-The general idea is that you'll fire up LISP in a screen session, then go over
-to Vim and use `Ctrl+C Ctrl+C` to put chunks of code in your Vim window into
-the screen session.
-
-It works and is quite handy for when you want to experiment with the contents
-of a file. Add a mapping for shoving over the entire file and you're all set to
-bash out and test some code quickly.
-
-I personally use [a slightly modified version][mySlime] that removes a bit of
-the flexibility I don't need to make it quicker to use. Maybe some day I'll
-expand on it and push it up to BitBucket and GitHub in a repo of its own.
-
-[Slime.vim]: http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/
-[Jonathan Palardy]: http://technotales.wordpress.com/
-[mySlime]: http://bitbucket.org/sjl/dotfiles/src/tip/vim/plugin/slime.vim
-
-### Scratch
-
-The [Scratch][] plugin adds a function to quickly open a "scratch" buffer that
-will never be saved.
-
-I have it mapped to `<leader><tab>` and use it with slime to quickly stick
-a bit of code that I don't want in my actual file into the REPL.
-
-[Scratch]: http://www.vim.org/scripts/script.php?script_id=664
-
-### Rainbow Parentheses
-
-[Rainbow Parentheses][] is a Vim plugin that colorizes parentheses, square
-brackets, curly brackets and angle brackets according to their nesting.
-
-It's easiest to describe what this looks like with a screenshot:
-
-![Rainbow Parentheses Screenshot](/media/images{{ parent_url }}/rainbow.png "Rainbow Parentheses")
-
-I use [a slightly modified version][myRainbow]. I have it mapped to `<leader>R`
-and off by default.  When I'm dealing with a particularly hairy piece of code
-that has lots of nesting I simply hit `<leader>R` and get some color that helps
-me keep my place.
-
-[Rainbow Parentheses]: http://www.vim.org/scripts/script.php?script_id=1561
-[myRainbow]: http://bitbucket.org/sjl/dotfiles/src/tip/vim/bundle/rainbow/
-
-Things I Want
--------------
-
-Although Vim is definitely my new favorite editor, this blog post wouldn't be
-complete without a few complaints.
-
-If anyone fixes/implements any of these I'll gladly buy them several beers.
-
-### HTML Indentation that Doesn't Suck
-
-I write a lot of HTML. One thing that annoys the hell out of me is Vim's
-"smart" indenting of HTML. I've tried every combination of `cindent`,
-`smartindent` and `autoindent` and I can't seem to get Vim to behave sanely.
-
-The problem is that sometimes when I press return after a tag that I've already
-created Vim will unindent the new line *and the previous line*. This is
-excruciatingly annoying.
-
-All I want is the following:
-
-* When I press return, create a new line at the same indentation level as the
-  current one. Don't try to be clever and adjust the indent of new line in
-  any fashion.
-* If I press tab at the beginning of a line, indent the *current line* by
-  one tabstop.
-* If I press backspace at the beginning of a line, delete one tabstop on that
-  line only.
-
-Please, someone make this happen and restore my sanity.
-
-### Python Support for Slime
-
-Earlier I mentioned that I use the slime plugin. One language it doesn't work
-very well with is Python, because it preserves whitespace when it moves the
-code over the REPL.
-
-This is a problem with Python because if you try to move over an indented block
-of code you'll get "unexpected indent" problems.
-
-I'd love for someone to tweak slime so it intelligently unindents Python code.
-I have some ideas on how this could work but unfortunately I don't have the
-time to implement them.
-
-### Gundo
-
-A little-known fact about Vim is that it doesn't keep a list of your undo
-history, it keeps a *tree*.
-
-If I make 5 changes, undo 2 and then make 2 more Vim keeps track of *all* of
-them. You can use `:undolist` to see the list of leaves in this "undo tree".
-
-What I want is for someone to make an awesome "graphical undo" plugin that
-shows a graph of the undo tree, much like Mercurial's graphlog extension shows
-a graph of the changesets in a repository.
-
-This graph would actually be simpler than Mercurial's graphlog because there
-are no merges to deal with.
-
-For bonus points let me browse the tree with `j` and `k`, press `p` to preview
-a diff of what would happen if I went back to that version, and press `<CR>` to
-actually go back.
-
-**UPDATE:** I got tired of waiting, so I [wrote it myself][Gundo].
-
-[Gundo]: http://bitbucket.org/sjl/gundo.vim/
-
-### A Mercurial Version of Fugitive
-
-The final thing I'd like is for someone to make a Mercurial plugin for Vim that
-is as awesome as Tim Pope's [Fugitive][].
-
-There's some Mercurial support for Vim out there, but for the most part it's
-tied up in plugins that support multiple version control systems.
-
-Any plugin that tries to support every system will fail at supporting one
-single system perfectly, so I'd love for someone to come along and make an
-*awesome* Vim plugin that lets you use Mercurial to its fullest while
-inside Vim.
-
-I simply don't know vimscript well enough to do this on my own, but if someone
-else is interested I can certainly help out on the Mercurial and user interface
-aspects.
-
-[Fugitive]: http://github.com/tpope/vim-fugitive
-
-Overall Thoughts
-----------------
-
-Transitioning back to Vim after using TextMate for a few years wasn't trivial,
-but I feel that it was worth the effort.  I have features like split windows
-now and there are plugins that can provide anything I miss from TextMate.
-
-If TextMate 2 ever gets released it would have to do some pretty amazing things
-for me to want to switch back.
-
-Overall I'm very happy with Vim.  There are a lot of things that could be
-improved, especially with the default settings (who cares about vi
-compatibility in 2010?), but a text editor is worth a learning curve.
-
-In my eyes Vim has two huge advantages over almost any other editor out there.
-The first is it's *huge* ecosystem of plugins and syntax definitions, which is
-only rivaled by Emacs (and *possibly* TextMate, though I doubt it). The second
-is it's "modal editing" philosophy, which is extremely powerful and hasn't been
-adopted by any other mainstream editor (except for *very* recent versions of
-E).
-
-If you've got questions or comments you should [find me on Twitter][twsl] and
-let me know.
-
-[twsl]: {{links.twsl}}
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/09/coming-home-to-vim.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,964 @@
++++
+title = "Coming Home to Vim"
+snip = "I'm sorry I ever left, baby."
+date = 2010-09-20T18:15:00Z
+draft = false
+
++++
+
+I'm a programmer. I work with text files for 6-12 hours every weekday so I care
+about the text editor I use. If switching to a different editor can increase my
+efficiency by even 10% it would save a good chunk of my time and let me get
+back to making cool things.
+
+I don't buy the "you're thinking 90% of the time and only typing 10% of the
+time, so your editor doesn't really matter" argument. Even if the premise is
+true, the conclusion is wrong.
+
+If I think for 10 minutes and then start typing, I want the typing to take the
+shortest time possible so I can get back to thinking. Any time I spend typing
+is an interruption that I want to minimize so I can keep my train of thought.
+
+I recently started using [Vim][] as my primary editor. As I'm adjusting I'm
+finding a lot of [the][arrows] [blog][nutheads] [posts][mind] [people][katz]
+[have][nvie] [written][grok] [about][home] Vim very helpful, so I'm hoping this
+post will help people too.
+
+[Vim]: http://www.vim.org/
+[arrows]: http://jeetworks.org/node/89
+[nutheads]: http://www.viemu.com/a-why-vi-vim.html
+[mind]: http://wekeroad.com/2010/07/29/vim-is-your-daddy/
+[katz]: http://yehudakatz.com/2010/07/29/everyone-who-tried-to-convince-me-to-use-vim-was-wrong/
+[nvie]: http://nvie.com/posts/how-i-boosted-my-vim/
+[grok]: http://stackoverflow.com/questions/1218390/what-is-your-most-productive-shortcut-with-vim/1220118#1220118
+[home]: http://weblog.jamisbuck.org/2008/10/10/coming-home-to-vim
+
+{{% toc %}}
+
+Some Background About Me
+------------------------
+
+I used Vim exclusively from about 2002 to 2005. I never really learned much
+about it and mostly used it as a glorified [nano][].
+
+In 2006 I decided it was time for a change. I wanted an editor that "fit" with
+OS X. I tried [SubEthaEdit][] for a while and it was kind of cool. The
+collaborative editing was more polished than any other version I've seen,
+though I didn't have much use for it.
+
+As cool as SubEthaEdit was, I always felt like there was a better editor out
+there for me. Then I found [TextMate][].
+
+At the time I thought TextMate was amazing (and it really was). It *looked*
+like a Mac application. It was super easy to learn (all the OS X text movement
+commands just worked). There were bundles for everything.
+
+I still used Vim occasionally (like when I had a job and only had a Windows
+machine), but for the most part I was a TextMate kid.
+
+After using TextMate for four years I decided it was time for another change.
+Development on TextMate has stalled while TextMate Forever (err, TextMate 2) is
+in the works. I started thinking about Vim (and reading blog posts by others
+about how they switched back) and decided to give it another try.
+
+A few months ago I bought [Learning the vi and Vim Editors][] and went
+cold-turkey with Vim as my main text editor. I haven't looked back since.
+
+[nano]: http://en.wikipedia.org/wiki/Nano_(text_editor)
+[SubEthaEdit]: http://www.codingmonkeys.de/subethaedit/
+[TextMate]: http://macromates.com/
+[Learning the vi and Vim Editors]: http://amzn.com/059652983X
+
+Why I Switched to TextMate
+--------------------------
+
+As I mentioned before, there were a few reasons I switched to TextMate in the
+first place.
+
+First of all: it looks and acts like a real OS X application.  You can drag
+files onto the icon to open them, it supports all the default OS X text
+movement commands, and the chrome looks like it belongs on OS X. I don't know
+if [MacVim][] was around at the time, but if it was I never found it.
+
+This matters. The effort required to get started with a new editor is
+dramatically reduced if that editor supports all the conventions of the
+operating system you use every day.
+
+It also has a vibrant community of people writing bundles for it, so there was
+support for almost anything I wanted to use.
+
+[MacVim]: http://code.google.com/p/macvim/
+
+Why I Came Back to Vim
+----------------------
+
+I came back to Vim for a number of reasons.
+
+First of all: I started reading about and desiring features that didn't seem to
+be coming to TextMate any time soon. The biggest of those was split windows.
+I saw the appeal of split windows right away and now that I use them I can't
+imagine not having them.
+
+Another reason is version control. A while ago I started keeping my
+[dotfiles][] in a [Mercurial][] repository which makes it extremely easy to set
+up new machines.  Vim keeps all of its configuration in two simple places:
+a simple `~/.vimrc` file and a `~/.vim` directory full of plain text files.
+
+Vim's plain text configuration files and plugins are very easy to version
+control. They diff well, unlike TextMate's multiple `Bundles` directories and
+ugly XML file format.
+
+Vim's community has been around far longer than TextMate's so there's an even
+richer set of plugins, bundles and syntax files available.
+
+Another reason people give for enjoying Vim is that it runs everywhere. Yes,
+it's nice to have my favorite editor available when I SSH into a machine, but
+it's not a huge deal if I don't. I almost always edit files on my own machine
+and then deploy them with an automated script of some kind, so editing on
+a server is very rare for me.
+
+[dotfiles]: http://bitbucket.org/sjl/dotfiles/
+[Mercurial]: http://hg-scm.org/
+
+Core Differences
+----------------
+
+For me, Vim and TextMate are very different.  TextMate relies mainly on
+keyboard shortcuts (involving Shift, Ctrl, Cmd and Alt) to do more than simply
+edit text. Vim uses a "modal editing" idea to accomplish the same task.
+
+TextMate's philosophy is much the same as any normal OS X application's, and
+I said that acting like the OS reduces the barrier of entry for a text editor,
+so why do I prefer Vim's philosophy?
+
+First I should prefix my answer with this: I'm not averse to a learning curve
+for something as important to me as a text editor.  Yes, it's awesome if
+I don't need to unnecessarily rewire my brain, but if it's going to save me
+a lot of time then I'm willing to cut a bit of slack here.
+
+My problem with TextMate's philosophy can be summed up in one word:
+"shadowing".
+
+If I want to define a new command in a bundle (or if someone else has already
+done it), I'm never really sure if I'm "overwriting" some other command that my
+fingers know but my brain doesn't really register.
+
+By the time I try to use the default command it could be days or weeks after
+I defined the custom one, and I need to figure out what I did all over again.
+It's quite frustrating.
+
+Vim's "insert" mode means that when I'm editing text I'm using the normal OS
+X text movement shortcuts that I know and love.  When I want to do something
+special I enter normal mode and don't have to worry about shadowed commands
+(Vim's leader key also helps with this).
+
+Vim's "Feeling"
+---------------
+
+Vim's normal mode has a unique "feeling" that I haven't seen in any other text
+editor (although [E][] may [change that][modalE]). I've heard it described in
+a number of ways, and I think that while no one analogy fully explains it,
+together they give a pretty good description.
+
+[E]: http://www.e-texteditor.com/
+[modalE]: http://e-texteditor.com/blog/2010/beyond-vi
+
+### A "Language" of Text Editing
+
+One way to think about Vim's normal-mode commands is like a language.  You have
+"verbs" and "nouns".  For example: the "change" command (`c`) would be a verb
+and the "word" item (`w`) is a noun.  You can combine them to form imperative
+sentences that talk about what you want to do with your text.
+
+The wonderful part about this is that whenever you learn a new verb (like
+"delete" (`d`)) you can immediately apply it to all the nouns you know, and
+vice versa.
+
+Vim also has "adjectives" like "inside" and "around" (`i` and `a`) that let you
+craft sentences like "change inside parenthesis" (`ci(` or `cib`).  Once you
+learn one of these you can immediately apply it to all the verbs and nouns you
+already know.
+
+### The Physics of Text
+
+The second way to describe the feeling of Vim is "physics".  It's a much less
+concrete description but I think it's still useful.
+
+If I throw a bowling ball into the air it behaves much the same way as if
+I throw a turkey sandwich.  They might have very different effects when they
+land on someone but the act of throwing them is pretty much the same.
+
+Vim's operators/actions/verbs act the same way. `daw` has a very different
+effect than `da{` but they can both be understood with a basic underlying
+principle: `da<something>` will "delete around `<something>`".
+
+### "Programming" Your Editing
+
+The last way that I hear people talking about Vim's editing is: "it feels like
+you're 'programming' your text".
+
+This analogy is often made by programmers (obviously) and I think it works on
+more than one level.
+
+First: Vim's basic editing commands can be likened to function calls.  `daw`
+can be thought of a running a function like `delete(type='word', around=True)`.
+I don't think this way (I prefer the language and physics analogies) but other
+people do.
+
+Although I don't think of the *basic* Vim commands as programming I do see
+some aspects of it in other areas.  For example: say I define a leader command
+in my `~/.vimrc` file:
+
+```vim
+nnoremap <leader>1 yypVr=
+```
+
+I think of this as defining `<leader>1` to be a function that performs the
+following actions:
+
+* Yank/copy the current line.
+* Paste it below (and move down to the pasted version).
+* Select the copied line.
+* Replace every character with `=`.
+
+Another more obvious "programming" aspect of Vim is creating macros. Macros are
+like tiny little functions you create to help you when you're editing a file.
+You can define them, execute them, and even edit them by pasting, editing and
+yanking them back.
+
+Getting Started
+---------------
+
+When I switched back to Vim I did a few things that helped make my transition
+stick.
+
+First: I bought [Learning the vi and Vim Editors][] and read it cover to cover.
+It helps quite a bit to know the history behind Vim, and the book also teaches
+you the basics of Vim's editing commands.
+
+I also looked through [the Vim subreddit][rvim] to find some good blog posts about
+switching.  A lot of people have written about it and it was very helpful to
+read about their experiences.
+
+And finally, the most important part: I switched cold-turkey.  Vim runs everywhere, so
+there's really no excuse for not doing this.  Every decent OS has a version of
+Vim that makes insert mode "just work" for their OS (like gvim or MacVim), so
+the barrier to entry these days is pretty low.
+
+You can get Vim and start using it right away by staying in insert mode most of
+the time. Then you can start learning its real features at your own pace.
+Trying to use two different editors at once just slows down the learning
+process and makes you less productive in both.
+
+[rvim]: http://reddit.com/r/vim/
+
+Making Vim More Useful
+----------------------
+
+One of the flaws of Vim is that it takes quite a bit of configuration to make
+it behave in a decent way. The defaults are backwards-compatible with vi (i.e.
+older than most college students) and not very helpful.
+
+Here are a few of the things I do to make Vim a bit more palatable.
+
+**A quick side note:** even if you don't use Vim, you *need* to [remap your
+capslock key][capslock] to something useful.  Just do it, you'll thank me.
+
+[capslock]: http://c2.com/cgi/wiki?RemapCapsLock
+
+### Important .vimrc Lines
+
+I won't go through every line in [my `~/.vimrc` file][sjlvimrc], but here are some of the
+lines that I simply could not live without.
+
+[sjlvimrc]: http://bitbucket.org/sjl/dotfiles/src/tip/vim/.vimrc
+
+First, a few lines that you absolutely must have:
+
+```vim
+filetype off
+call pathogen#runtime_append_all_bundles()
+filetype plugin indent on
+
+set nocompatible
+
+set modelines=0
+```
+
+The `filetype` and `call` lines are for loading Pathogen, which is described in
+the bundles section. See [Pathogen's docs][pathogendocs] to learn about why the
+first `filetype` line is there.
+
+[pathogendocs]: http://www.vim.org/scripts/script.php?script_id=2332
+
+`set nocompatible` gets rid of all the crap that Vim does to be vi compatible.
+It's 2010 — we don't need to be compatible with vi at the expense of
+functionality any more.
+
+The `modelines` bit prevents some [security exploits][] having to do with
+modelines in files.  I never use modelines so I don't miss any functionality
+here.
+
+[security exploits]: http://lists.alioth.debian.org/pipermail/pkg-vim-maintainers/2007-June/004020.html
+
+Next I set my tab settings:
+
+```vim
+set tabstop=4
+set shiftwidth=4
+set softtabstop=4
+set expandtab
+```
+
+I like all tabs to expand to four spaces.  Check out [this Vimcast][vctabs] to
+learn more about each of these options.
+
+[vctabs]: http://vimcasts.org/episodes/tabs-and-spaces/
+
+Next are a few options that just make things better:
+
+```vim
+set encoding=utf-8
+set scrolloff=3
+set autoindent
+set showmode
+set showcmd
+set hidden
+set wildmenu
+set wildmode=list:longest
+set visualbell
+set cursorline
+set ttyfast
+set ruler
+set backspace=indent,eol,start
+set laststatus=2
+set relativenumber
+set undofile
+```
+
+Each of these lines are basically to make Vim behave in a sane manner.  The two
+"interesting" ones are the last two, and both deal with features that are
+[new in Vim 7.3][vim73].
+
+[vim73]: http://groups.google.com/group/vim_announce/browse_thread/thread/66c02efd1523554b
+
+`relativenumber` changes Vim's line number column to display how far away each
+line is from the current one, instead of showing the absolute line number.
+
+I almost never care what numeric line I'm on in a file (and if I do I can see
+it in the status line), so I don't miss the normal line numbers. I *do* care
+how far away a particular line might be, because it tells me what number I need
+to use with motion commands like `d<NUMBER>d`.
+
+`undofile` tells Vim to create `<FILENAME>.un~` files whenever you edit a file.
+These files contain undo information so you can undo previous actions even
+after you close and reopen a file.
+
+Next I change the `<leader>` key:
+
+```vim
+let mapleader = ","
+```
+
+For me `,` is easier to type than `\`. I use leader commands constantly so it's
+worth changing.
+
+The next thing I do is tame searching/moving:
+
+```vim
+nnoremap / /\v
+vnoremap / /\v
+set ignorecase
+set smartcase
+set gdefault
+set incsearch
+set showmatch
+set hlsearch
+nnoremap <leader><space> :noh<cr>
+nnoremap <tab> %
+vnoremap <tab> %
+```
+
+The first two lines fix Vim's horribly broken default regex "handling" by
+automatically inserting a `\v` before any string you search for.  This turns
+off Vim's crazy default regex characters and makes searches use normal regexes.
+I already know Perl/Python compatible regex formatting, why would I want to
+learn another scheme?
+
+`ignorecase` and `smartcase` together make Vim deal with case-sensitive search
+intelligently. If you search for an all-lowercase string your search will be
+case-insensitive, but if one or more characters is uppercase the search will be
+case-sensitive. Most of the time this does what you want.
+
+`gdefault` applies substitutions globally on lines.  For example, instead of
+`:%s/foo/bar/g` you just type `:%s/foo/bar/`.  This is almost always what you
+want (when was the last time you wanted to only replace the first occurrence of
+a word on a line?) and if you need the previous behavior you just tack on the
+`g` again.
+
+`incsearch`, `showmatch` and `hlsearch` work together to highlight search
+results (as you type).  It's really quite handy, as long as you have the next
+line as well.
+
+The `<leader><space>` mapping makes it easy to clear out a search by typing
+`,<space>`. This gets rid of the distracting highlighting once I've found what
+I'm looking for.
+
+The last two lines make the tab key match bracket pairs. I use this to move
+around all the time and `<tab>` is a hell of a lot easier to type than `%`.
+
+The next section makes Vim handle long lines correctly:
+
+```vim
+set wrap
+set textwidth=79
+set formatoptions=qrn1
+set colorcolumn=85
+```
+
+These lines manage my line wrapping settings and also show a colored column at
+85 characters (so I can see when I write a too-long line of code).
+
+See [`:help fo-table`][fotable] and the Vimcasts on [soft wrapping][] and [hard wrapping][] for more information.
+
+[fotable]: http://vimdoc.sourceforge.net/htmldoc/change.html#fo-table
+[soft wrapping]: http://vimcasts.org/episodes/soft-wrapping-text/
+[hard wrapping]: http://vimcasts.org/episodes/hard-wrapping-text/
+
+Next comes something other TextMate refugees may like:
+
+```vim
+set list
+set listchars=tab:▸\ ,eol:¬
+```
+
+This makes Vim show invisible characters with the same characters that TextMate
+uses.  You might need to adjust your color scheme so they're not too
+distracting. [This Vimcast][vcinvis] has more information.
+
+[vcinvis]: http://vimcasts.org/episodes/show-invisibles/
+
+New Vim users will want the following lines to teach them to do things right:
+
+```vim
+nnoremap <up> <nop>
+nnoremap <down> <nop>
+nnoremap <left> <nop>
+nnoremap <right> <nop>
+inoremap <up> <nop>
+inoremap <down> <nop>
+inoremap <left> <nop>
+inoremap <right> <nop>
+nnoremap j gj
+nnoremap k gk
+```
+
+This will disable the arrow keys while you're in normal mode to help you learn
+to use `hjkl`.  Trust me, you want to learn to use `hjkl`.  Playing a lot of
+[Nethack][] also helps.
+
+[Nethack]: http://www.nethack.org/
+
+It also disables the arrow keys in insert mode to force you to get back into
+normal mode the instant you're done inserting text, which is the "right way" to
+do things.
+
+It also makes j and k work the way you expect instead of working in some
+archaic "movement by file line instead of screen line" fashion.
+
+Next, get rid of that stupid goddamned help key that you will invaribly hit
+*constantly* while aiming for escape:
+
+```vim
+inoremap <F1> <ESC>
+nnoremap <F1> <ESC>
+vnoremap <F1> <ESC>
+```
+
+I also like to make `;` do the same thing as `:` — it's one less key to hit
+every time I want to save a file:
+
+```vim
+nnoremap ; :
+```
+
+I don't remap `:` back to `;` because it seems to break a bunch of plugins.
+
+Finally, I really like TextMate's "save on losing focus" feature.  I can't
+remember a time when I *didn't* want to save a file after tabbing away from my
+editor (especially with version control and Vim's persistent undo):
+
+```vim
+au FocusLost * :wa
+```
+
+Those are the most important bits of my `~/.vimrc` file. Next I'll talk about
+the wonderful namespace of customization that is Vim's `<leader>` key.
+
+### Using the Leader
+
+Vim dedicates an entire keyboard key for user-specific customizations. This is
+called the "leader" and by default it's mapped to `\`. As I mentioned in the
+previous section I prefer to use `,` instead.
+
+Each person will find little things they type or execute often and want to
+create shortcuts for those things. The leader is a kind of "namespace" to keep
+those customizations separate and prevent them from shadowing default commands.
+
+Here are a few of the things I use leader commands for.  You'll certainly have
+different ideas than I do, but this might give you an idea of what you can do.
+
+I use `,W` to mean "strip all trailing whitespace in the current file" so I can
+clean things up quickly:
+
+```vim
+nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR>
+```
+
+I use Ack a lot (described below), so I mapped a leader key for it:
+
+```vim
+nnoremap <leader>a :Ack
+```
+
+I work with HTML often, so I have `,ft` mapped to a "fold tag" function:
+
+```vim
+nnoremap <leader>ft Vatzf
+```
+
+I also work with Nick Sergeant and he likes his CSS properties sorted, so
+here's a `,S` mapping that sorts them for me:
+
+```vim
+nnoremap <leader>S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR>
+```
+
+This next mapping imitates TextMates `Ctrl+Q` function to re-hardwrap
+paragraphs of text:
+
+```vim
+nnoremap <leader>q gqip
+```
+
+I have a `,v` mapping to reselect the text that was just pasted so I can
+perform commands (like indentation) on it:
+
+```vim
+nnoremap <leader>v V`]
+```
+
+This last mapping lets me quickly open up my `~/.vimrc` file in a vertically
+split window so I can add new things to it on the fly.
+
+```vim
+nnoremap <leader>ev <C-w><C-v><C-l>:e $MYVIMRC<cr>
+```
+
+### Quicker Escaping
+
+One thing you'll find yourself constantly doing in Vim is moving from insert
+mode to normal mode.  The default way to do this is by hitting Escape, but that
+key is out of the way and hard to hit.
+
+Another way is to use `Ctrl+C` or `Ctrl+[`, but I don't like using a chord for
+something I press that often.
+
+I personally use `jj` to exit back to normal mode. The only time I've ever
+actually tried to hit two `j`'s in a row is just now while writing this entry,
+so it doesn't conflict with my normal typing at all:
+
+```vim
+inoremap jj <ESC>
+```
+
+### Working With Split Windows
+
+Being able to split my editor window and see more than one file at once is one
+of the main reasons I switched to Vim.  I know I'm not alone here after reading
+various posts around the internet asking for this feature in TextMate.
+
+Vim's default commands for interacting with splits, however, are kind of
+clunky.  I've added a few mappings to my `~/.vimrc` that make things work a bit
+smoother.
+
+This first mapping makes `,w` open a new vertical split and switch over to it.
+Because really, how often do you split your window and not want to do something
+in the new split?
+
+```vim
+nnoremap <leader>w <C-w>v<C-w>l
+```
+
+You might notice that this mapping is for vertical splits.  I almost *never*
+use horizontal splits. All of my screens are widescreen, so I can fit several
+files onscreen if they're split vertically. Horizontal splits don't let me see
+enough of the file. If I *really* want a horizontal split I can use `<C-w>s`
+to get one.
+
+This next set of mappings maps `<C-[h/j/k/l]>` to the commands needed to move
+around your splits.  If you remap your capslock key to `Ctrl` it makes for very
+easy navigation.
+
+```vim
+nnoremap <C-h> <C-w>h
+nnoremap <C-j> <C-w>j
+nnoremap <C-k> <C-w>k
+nnoremap <C-l> <C-w>l
+```
+
+Aesthetics
+----------
+
+I know some people say: "looks don't matter, the only thing that's important is
+functionality". That's completely wrong.
+
+If I'm looking at something for multiple hours each day it had damn well better
+look pretty. There are three main steps to making Vim look pretty (for me, on
+OS X — your mileage may vary).
+
+First: get [MacVim][].  It makes Vim look (and behave) like a native Mac
+application. It helps it avoid standing out like a sore thumb among your other
+applications. Linux and Windows users will probably want gvim.
+
+Next: pick a decent font.  I prefer 12 point [Menlo][].  You might have
+a different preference, but at least try out a few and find one that has a nice
+balance between line height (so you can get a good amount of lines on the
+screen) and readability (slashed zeros, please).
+
+Finally: find a good color scheme. I've been using [a slightly modified
+version][myMolokai] of [Molokai][] (a port of the TextMate [Monokai][] theme)
+since I came back to Vim, but recently I've also started flirting with
+[Mustang][] and [Clouds Midnight][].  Spend an hour and find something that
+looks good to you.
+
+Here's what my current setup looks like:
+
+![Current Vim Setup Screenshot](/media/images/blog/2010/09/vim.png "My Current Vim Setup")
+
+[Menlo]: http://arstechnica.com/apple/news/2009/06/font-changes-coming-to-mac-os-x-snow-leopard.ars
+[myMolokai]: http://bitbucket.org/sjl/dotfiles/src/tip/vim/colors/molokai.vim
+[Molokai]: http://www.vim.org/scripts/script.php?script_id=2340
+[Monokai]: http://www.monokai.nl/blog/2006/07/15/textmate-color-theme/
+[Mustang]: http://hcalves.deviantart.com/art/Mustang-Vim-Colorscheme-98974484
+[Clouds Midnight]: http://forr.st/~yZn
+
+Bundles I Use
+-------------
+
+Vim has been around for a *long* time, and many people have written extensions
+for it.  Here are a few of the bundles I couldn't live without in my day-to-day
+editing.
+
+### Pathogen
+
+First of all: [Tim Pope][] has created the wonderful [Pathogen][] plugin that
+makes managing *other* Vim plugins painless.  Instead of scattering their files
+throughout your `~/.vim/` folder you can keep their files inside a single
+folder in `~/.vim/bundles/`.
+
+Install it and keep your sanity.
+
+[Tim Pope]: http://github.com/tpope
+[Pathogen]: http://github.com/tpope/vim-pathogen
+
+### PeepOpen
+
+One of TextMate's "killer features" is its `Cmd+T` key. It lets you open files
+quickly by typing fragments of their names.
+
+There are a number of Vim plugins out there that try to emulate it.  My
+favorite is [PeepOpen][].  Yes, it's OS X only and costs money, but it's worth
+it.  It looks good and "just works".
+
+PeepOpen has some nifty little features, like showing Git metadata in the file
+list. I've [offered a patch][] to add the same functionality for Mercurial but
+haven't heard back from the developers.
+
+If you don't use OS X (or want a free alternative to PeepOpen) I hear the
+[Command-T][] plugin is quite nice.
+
+[PeepOpen]: http://peepcode.com/products/peepopen
+[offered a patch]: http://github.com/topfunky/PeepOpen-Issues/issues#issue/91
+[Command-T]: https://wincent.com/products/command-t
+
+### NERDTree
+
+One plugin you'll hear about in almost all of these "switching to Vim" blog
+posts is [NERDTree][]. It's a little plugin for browsing files in your project,
+and it works great. There's no better "TextMate file-drawer" plugin around.
+
+[NERDTree]: http://github.com/scrooloose/nerdtree
+
+### NERDCommenter
+
+Want to be able to comment and uncomment code with a few keypresses?  You need
+[NERDCommenter][]. It's surprising that Vim doesn't have decent commenting
+functionality built in, but NERDCommenter fixes that.
+
+I really only use this plugin for one single function: "toggle comment" with
+`<leader>c<space>`. That function alone is worth installing it.
+
+[NERDCommenter]: http://github.com/scrooloose/nerdcommenter
+
+### Ack
+
+If you're a programmer and you don't know about [Ack][], you need to start
+using it now. It's far, far better than grep.
+
+The [Ack plugin][ack.vim] for Vim integrates Ack with Vim's quickfix window so
+you can easily search and jump to results.
+
+As I mentioned in the section about leader mappings I've got `,a` mapped to
+bring up Ack all ready to search.
+
+[Ack]: http://betterthangrep.com/
+[ack.vim]: http://github.com/mileszs/ack.vim
+
+### Snipmate
+
+Another feature of TextMate that was *amazing* when I first saw it was
+snippets. [SnipMate][] is a Vim plugin that emulates TextMate snippets.
+
+It also stores them in easily-version-controlled plain text files, which is
+a bonus over TextMate's snippets.
+
+[SnipMate]: http://github.com/msanders/snipmate.vim
+
+### Sparkup
+
+[Sparkup][] is pretty much a great port of [Zen Coding][] for Vim. If you write
+HTML at all this plugin will save you a ton of typing.
+
+In a nutshell it lets you type something like:
+
+```text
+div.content>h1.post-title+p{Sample Content}
+```
+
+Press `Cmd+E` and it will expand to this:
+
+```html
+<div class="content">
+    <h1 class="post-title"></h1>
+    <p>Sample Content</p>
+</div>
+```
+
+It's far less typing and it adds up over time.
+
+[Sparkup]: http://github.com/rstacruz/sparkup
+[Zen Coding]: http://code.google.com/p/zen-coding/
+
+### Yankring
+
+Vim's copying and pasting functionality (which uses registers) is very, very
+powerful, but it's not exactly "user friendly". The [YankRing][] plugin adds
+a lot *more* power, but also adds a few features that make copying and pasting
+much more pleasant.
+
+For example, after you paste some text you can replace that paste with the
+previous item you copied with `Ctrl-P`.  You can cycle back further by just
+hitting `Ctrl-P` over and over.
+
+YankRing also shares your yanked text between Vim windows, which makes things
+"just work" when you want to paste text from one window into another.
+
+You can also show a list of all your previously yanked text with `:YRShow`.
+Mapping that command to a key is quite helpful:
+
+```vim
+nnoremap <silent> <F3> :YRShow<cr>
+inoremap <silent> <F3> <ESC>:YRShow<cr>
+```
+
+YankRing offers a ton of other cool functionality but I haven't had the time or
+motivation to really dig in and find out how to use it.
+
+[YankRing]: http://www.vim.org/scripts/script.php?script_id=1234
+
+### Surround (and Repeat)
+
+Another of Time Pope's plugins that I use all the time is the [Surround][]
+plugin.  It adds another layer to Vim's physics: "surrounding items".
+
+For example, you can "change surrounding single quotes to double quotes" by
+using `cs'"`. Or if you're writing something in Markdown and want to italicize
+a word you can use `ysiW*`.
+
+All the nouns and verbs you already know can be used, which fits with Vim's
+philosophy and makes it extremely powerful.
+
+The [Repeat][] plugin is necessary to make these surround actions repeatable
+with `.`.
+
+[Surround]: http://github.com/tpope/vim-surround
+[Repeat]: http://github.com/tpope/vim-repeat
+
+### Slime
+
+Emacs users often tout SLIME as one of Emacs' "killer features". When writing
+LISP code it's unchallengably awesome.
+
+Vim doesn't have anything like SLIME. It's not integrated with any language the
+way Emacs is coupled to LISP. You can, however, achieve *some* of the power of
+SLIME in Vim.
+
+[Jonathan Palardy][] has written a little Vim plugin called [Slime.vim][] that
+lets Vim easily communicate with a screen session, probably one running a REPL
+for some language like LISP, Python or Ruby.
+
+The general idea is that you'll fire up LISP in a screen session, then go over
+to Vim and use `Ctrl+C Ctrl+C` to put chunks of code in your Vim window into
+the screen session.
+
+It works and is quite handy for when you want to experiment with the contents
+of a file. Add a mapping for shoving over the entire file and you're all set to
+bash out and test some code quickly.
+
+I personally use [a slightly modified version][mySlime] that removes a bit of
+the flexibility I don't need to make it quicker to use. Maybe some day I'll
+expand on it and push it up to BitBucket and GitHub in a repo of its own.
+
+[Slime.vim]: http://technotales.wordpress.com/2007/10/03/like-slime-for-vim/
+[Jonathan Palardy]: http://technotales.wordpress.com/
+[mySlime]: http://bitbucket.org/sjl/dotfiles/src/tip/vim/plugin/slime.vim
+
+### Scratch
+
+The [Scratch][] plugin adds a function to quickly open a "scratch" buffer that
+will never be saved.
+
+I have it mapped to `<leader><tab>` and use it with slime to quickly stick
+a bit of code that I don't want in my actual file into the REPL.
+
+[Scratch]: http://www.vim.org/scripts/script.php?script_id=664
+
+### Rainbow Parentheses
+
+[Rainbow Parentheses][] is a Vim plugin that colorizes parentheses, square
+brackets, curly brackets and angle brackets according to their nesting.
+
+It's easiest to describe what this looks like with a screenshot:
+
+![Rainbow Parentheses Screenshot](/media/images/blog/2010/09/rainbow.png "Rainbow Parentheses")
+
+I use [a slightly modified version][myRainbow]. I have it mapped to `<leader>R`
+and off by default.  When I'm dealing with a particularly hairy piece of code
+that has lots of nesting I simply hit `<leader>R` and get some color that helps
+me keep my place.
+
+[Rainbow Parentheses]: http://www.vim.org/scripts/script.php?script_id=1561
+[myRainbow]: http://bitbucket.org/sjl/dotfiles/src/tip/vim/bundle/rainbow/
+
+Things I Want
+-------------
+
+Although Vim is definitely my new favorite editor, this blog post wouldn't be
+complete without a few complaints.
+
+If anyone fixes/implements any of these I'll gladly buy them several beers.
+
+### HTML Indentation that Doesn't Suck
+
+I write a lot of HTML. One thing that annoys the hell out of me is Vim's
+"smart" indenting of HTML. I've tried every combination of `cindent`,
+`smartindent` and `autoindent` and I can't seem to get Vim to behave sanely.
+
+The problem is that sometimes when I press return after a tag that I've already
+created Vim will unindent the new line *and the previous line*. This is
+excruciatingly annoying.
+
+All I want is the following:
+
+* When I press return, create a new line at the same indentation level as the
+  current one. Don't try to be clever and adjust the indent of new line in
+  any fashion.
+* If I press tab at the beginning of a line, indent the *current line* by
+  one tabstop.
+* If I press backspace at the beginning of a line, delete one tabstop on that
+  line only.
+
+Please, someone make this happen and restore my sanity.
+
+### Python Support for Slime
+
+Earlier I mentioned that I use the slime plugin. One language it doesn't work
+very well with is Python, because it preserves whitespace when it moves the
+code over the REPL.
+
+This is a problem with Python because if you try to move over an indented block
+of code you'll get "unexpected indent" problems.
+
+I'd love for someone to tweak slime so it intelligently unindents Python code.
+I have some ideas on how this could work but unfortunately I don't have the
+time to implement them.
+
+### Gundo
+
+A little-known fact about Vim is that it doesn't keep a list of your undo
+history, it keeps a *tree*.
+
+If I make 5 changes, undo 2 and then make 2 more Vim keeps track of *all* of
+them. You can use `:undolist` to see the list of leaves in this "undo tree".
+
+What I want is for someone to make an awesome "graphical undo" plugin that
+shows a graph of the undo tree, much like Mercurial's graphlog extension shows
+a graph of the changesets in a repository.
+
+This graph would actually be simpler than Mercurial's graphlog because there
+are no merges to deal with.
+
+For bonus points let me browse the tree with `j` and `k`, press `p` to preview
+a diff of what would happen if I went back to that version, and press `<CR>` to
+actually go back.
+
+**UPDATE:** I got tired of waiting, so I [wrote it myself][Gundo].
+
+[Gundo]: http://bitbucket.org/sjl/gundo.vim/
+
+### A Mercurial Version of Fugitive
+
+The final thing I'd like is for someone to make a Mercurial plugin for Vim that
+is as awesome as Tim Pope's [Fugitive][].
+
+There's some Mercurial support for Vim out there, but for the most part it's
+tied up in plugins that support multiple version control systems.
+
+Any plugin that tries to support every system will fail at supporting one
+single system perfectly, so I'd love for someone to come along and make an
+*awesome* Vim plugin that lets you use Mercurial to its fullest while
+inside Vim.
+
+I simply don't know vimscript well enough to do this on my own, but if someone
+else is interested I can certainly help out on the Mercurial and user interface
+aspects.
+
+[Fugitive]: http://github.com/tpope/vim-fugitive
+
+Overall Thoughts
+----------------
+
+Transitioning back to Vim after using TextMate for a few years wasn't trivial,
+but I feel that it was worth the effort.  I have features like split windows
+now and there are plugins that can provide anything I miss from TextMate.
+
+If TextMate 2 ever gets released it would have to do some pretty amazing things
+for me to want to switch back.
+
+Overall I'm very happy with Vim.  There are a lot of things that could be
+improved, especially with the default settings (who cares about vi
+compatibility in 2010?), but a text editor is worth a learning curve.
+
+In my eyes Vim has two huge advantages over almost any other editor out there.
+The first is it's *huge* ecosystem of plugins and syntax definitions, which is
+only rivaled by Emacs (and *possibly* TextMate, though I doubt it). The second
+is it's "modal editing" philosophy, which is extremely powerful and hasn't been
+adopted by any other mainstream editor (except for *very* recent versions of
+E).
+
+If you've got questions or comments you should [find me on Twitter][twsl] and
+let me know.
+
+[twsl]: {{links.twsl}}
+
--- a/content/blog/2010/09/making-my-site-sing.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,229 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Making My Site Sing"
-    snip: "Designing with music."
-    created: 2010-09-08 20:10:00
-%}
-
-{% block article %}
-
-Every year or so I get the urge to redesign my site. It's only been seven
-months since the last time, so I guess working with [Nick Sergeant][] and
-[Ali Ali][] at [Dumbwaiter Design][] has made me less satisfied than usual
-with my previous design.
-
-I didn't switch frameworks this time -- I'm still [using Hyde][] to generate
-a set of flat HTML files.  I only changed the structure and layout of the
-rendered site.
-
-I'm a programmer, not a designer, but I think it looks fairly good.  I wanted
-to write about how I went about designing the site because it might help other
-programmers.
-
-[Nick Sergeant]: http://nick.sg/
-[Ali Ali]: http://alialithinks.com/
-[Dumbwaiter Design]: http://dwaiter.com/
-[using Hyde]: /blog/2010/01/moving-from-django-to-hyde/
-
-[TOC]
-
-Finding a Starting Point
-------------------------
-
-The first thing I had to do was come up with a basic idea for the style and
-typography of the site.
-
-I decided to go with my usual style: dark text on a light background, very few
-images, and an overall feeling of "minimal."  If I had the graphic design
-skills to make something impressive to look at I'd use them, but I don't, so
-I wanted to stick with what I'm good at.
-
-I read a lot of programmers' blogs and one thing that annoys me is that I often
-end up using [Safari Reader][] to make their sites pleasant to read.  I want my
-site to be pleasant to read *without* extra tools like Reader, so I took the easy
-route and based the site's typography on Reader itself.
-
-Reader uses 18px [Palatino][] body text with a 25px line height, so that's what
-I went with.  I considered using [Georgia][] instead of Palatino, but
-unfortunately Georgia has an absolutely terrible bold weight. I also kept the
-width of the site small to mimic Reader.
-
-[Safari Reader]: http://www.apple.com/safari/whats-new.html#reader
-[Palatino]: http://en.wikipedia.org/wiki/Palatino
-[Georgia]: http://en.wikipedia.org/wiki/Georgia_(typeface)
-
-Creating a Vertical Rhythm
---------------------------
-
-Once I had a line height in place I could start working on a [vertical rhythm][].
-I used [Aardvark Legs][] as a base stylesheet and edited it to fit the new font
-size and line height.
-
-Unfortunately the original post by Aardvark Legs' author seems to have
-disappeared.  In a nutshell: it's a CSS file that helps you set up a consistent
-vertical rhythm.
-
-I tried to keep myself honest by including a tiny bit of Javascript in the
-footer of the site that displays the vertical rhythm. If you click on it you
-should see that everything lines up properly (except the footer itself, which
-falls on a halfway point).
-
-For some entries the rhythm might not be perfect in non-Webkit browsers because
-I had to use some [Webkit-specific styling][scrollbars] to fix the height of
-scrollbars of wide `<pre>` blocks.
-
-[vertical rhythm]: http://www.alistapart.com/articles/settingtypeontheweb/
-[aardvark legs]: http://aardvark.fecklessmind.com/
-[scrollbars]: http://webkit.org/blog/363/styling-scrollbars/
-
-Designing to a Dominant Seventh
--------------------------------
-
-In my spare time I play upright bass and teach blues dancing. I listen to a lot
-of jazz and blues music while doing both and one of the more common chords in
-those genres is a [dominant seventh][].
-
-What does this have to do with my site's design? Although I had a font size of
-18px for the body text I still needed to decide on sizes for headers and other
-site elements. Dominant seventh chords sound beautiful, so I used the notes in
-the chord to come up with these sizes.
-
-Here are the sizes I came up with (after rounding off to the nearest pixel):
-
-* Root: 18 pixels
-* Major third: 23 pixels
-* Perfect fifth: 27 pixels
-* Minor seventh: 32 pixels
-* Octave: 36 pixels
-* Major tenth: 45 pixels
-
-This gave me a variety of sizes to work with.  Here are a few places where
-I used them:
-
-* Base font size: root
-* `h1` elements: major tenth
-* `h2` elements: minor seventh
-* `h3` elements: major third
-* `h4` elements: root
-* "Logo" in the header: major third
-* Navigation links: root
-* Footer text: perfect fifth (an octave down)
-
-You might notice that I don't use a straight perfect fifth anywhere in the
-design.  There are two reasons for this.
-
-First: the perfect fifth and the line height I got from Reader are only two
-pixels apart, which would feel dissonant.
-
-Second: the perfect fifth is the most "generic" note in the chord, so
-eliminating it doesn't really change the feeling of the dominant seventh at
-all.
-
-Once I had my line height and header sizes I had plenty to work on.  I made
-images, blockquotes, code blocks, and everything else fit the rhythm. After
-that I decided to start playing with some other things.
-
-[dominant seventh]: http://en.wikipedia.org/wiki/Dominant_seventh_chord
-
-Removing Comments
------------------
-
-The first thing I did after I got the rhythm of the site down was to remove the
-[Disqus][] comments.
-
-I did this for two reasons.  The first and most "practical" reason was that
-they simply looked out of place.  It's hard to style content from a third-party
-site to look great with the rhythm of the site so I got rid of it altogether.
-
-The second reason is something I've learned from music and dancing: the most
-important notes are the ones you *don't* play.
-
-I'm usually pretty busy with full-time and freelance work and don't have enough
-time to properly respond to comments on the site.  Having comments here,
-then, is like having calls without responses -- it doesn't work very well.
-
-If someone wants to tell me something they can easily find me on
-[Twitter][twsl] and talk to me or discuss a post on [Hacker News][].
-
-[Disqus]: http://disqus.com/
-[twsl]: {{links.twsl}}
-[Hacker News]: http://news.ycombinator.com/
-
-Adding Applause with Flattr
----------------------------
-
-I've started using [Flattr][] to help show my appreciation to people that make
-good things on the internet.  Since I was redesigning the site I figured I'd
-include Flattr buttons on my blog posts.
-
-One reason was simple: it lets people give me money for the things I write.
-Another reason is a bit more altruistic: if more people see Flattr buttons
-around the web more people will sign up and help out creators.
-
-I like to think of Flattr as applause at a jazz show or a dance.  It doesn't
-really contribute anything to the conversation but it *does* let you easily
-show your appreciaton.
-
-The worst part of this was going through all my old blog posts and submitting
-them to Flattr.
-
-[Flattr]: http://flattr.com/
-
-Printing Nicely with Print Links
---------------------------------
-
-This is something that my old site also had but I never really talked about
-(except on [Forrst][]).
-
-If you print one of my site's pages you'll notice that any links inside
-a paragraph of content will show up in a list after the paragraph.  I think
-this makes it easier to refer to a printed copy because you can type in the
-URLs without having to visit my site again.
-
-To do this I use [a little bit of Javascript][printjs].  I *could* put the URLs
-directly after the links using just CSS, but I think that breaks up the content
-and makes it harder to read.
-
-[Forrst]: http://forrst.com/
-[printjs]: http://bitbucket.org/sjl/stevelosh/src/tip/media/js/print.js
-
-Showing Context with Scrolly Headers
-------------------------------------
-
-The last trick I pulled out of my sleeve was the "scrolly headers" to the left
-of the content, which you've probably already noticed.
-
-I tend to write fairly long blog posts and I think about their structure quite
-a bit.  Now that I'm using a much larger font I feel that it's too easy to get
-lost while reading them. If you switch away from the page for a bit and come
-back you might not remember where you were.
-
-To help fix this I wrote a bit of Javascript to display the top-level headers
-of post content to the left of the content.  I think this might help people
-keep their place more easily.
-
-Influences and Goals
---------------------
-
-While redesigning I had two main influences in mind:
-[Eivind Uggedal's site][uggedal] and [Simon Hørup Eskildsen's site][sirupsen].
-I hope they don't mind that I took a lot of elements from their designs to make
-my own.
-
-As I was making the new site I had a very simple goal: "make sure no one ever
-wants to use Safari Reader on my site."
-
-The design isn't particularly memorable (hell, it pretty much looks like you
-just used Safari Reader), but I don't think that's a problem.  I'm not
-a designer so I don't want my site to be remembered for its design. I want it
-to be remembered for the content, so I aimed for a design that highlights that
-content and gets out of the way.
-
-If you have comments, questions, or suggestions feel free to find me on
-[Twitter][twsl].
-
-[uggedal]: http://uggedal.com/
-[sirupsen]: http://sirupsen.com/
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/09/making-my-site-sing.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,226 @@
++++
+title = "Making My Site Sing"
+snip = "Designing with music."
+date = 2010-09-08T20:10:00Z
+draft = false
+
++++
+
+Every year or so I get the urge to redesign my site. It's only been seven
+months since the last time, so I guess working with [Nick Sergeant][] and
+[Ali Ali][] at [Dumbwaiter Design][] has made me less satisfied than usual
+with my previous design.
+
+I didn't switch frameworks this time — I'm still [using Hyde][] to generate
+a set of flat HTML files.  I only changed the structure and layout of the
+rendered site.
+
+I'm a programmer, not a designer, but I think it looks fairly good.  I wanted
+to write about how I went about designing the site because it might help other
+programmers.
+
+[Nick Sergeant]: http://nick.sg/
+[Ali Ali]: http://alialithinks.com/
+[Dumbwaiter Design]: http://dwaiter.com/
+[using Hyde]: /blog/2010/01/moving-from-django-to-hyde/
+
+{{% toc %}}
+
+Finding a Starting Point
+------------------------
+
+The first thing I had to do was come up with a basic idea for the style and
+typography of the site.
+
+I decided to go with my usual style: dark text on a light background, very few
+images, and an overall feeling of "minimal."  If I had the graphic design
+skills to make something impressive to look at I'd use them, but I don't, so
+I wanted to stick with what I'm good at.
+
+I read a lot of programmers' blogs and one thing that annoys me is that I often
+end up using [Safari Reader][] to make their sites pleasant to read.  I want my
+site to be pleasant to read *without* extra tools like Reader, so I took the easy
+route and based the site's typography on Reader itself.
+
+Reader uses 18px [Palatino][] body text with a 25px line height, so that's what
+I went with.  I considered using [Georgia][] instead of Palatino, but
+unfortunately Georgia has an absolutely terrible bold weight. I also kept the
+width of the site small to mimic Reader.
+
+[Safari Reader]: http://www.apple.com/safari/whats-new.html#reader
+[Palatino]: http://en.wikipedia.org/wiki/Palatino
+[Georgia]: http://en.wikipedia.org/wiki/Georgia_(typeface)
+
+Creating a Vertical Rhythm
+--------------------------
+
+Once I had a line height in place I could start working on a [vertical rhythm][].
+I used [Aardvark Legs][] as a base stylesheet and edited it to fit the new font
+size and line height.
+
+Unfortunately the original post by Aardvark Legs' author seems to have
+disappeared.  In a nutshell: it's a CSS file that helps you set up a consistent
+vertical rhythm.
+
+I tried to keep myself honest by including a tiny bit of Javascript in the
+footer of the site that displays the vertical rhythm. If you click on it you
+should see that everything lines up properly (except the footer itself, which
+falls on a halfway point).
+
+For some entries the rhythm might not be perfect in non-Webkit browsers because
+I had to use some [Webkit-specific styling][scrollbars] to fix the height of
+scrollbars of wide `<pre>` blocks.
+
+[vertical rhythm]: http://www.alistapart.com/articles/settingtypeontheweb/
+[aardvark legs]: http://aardvark.fecklessmind.com/
+[scrollbars]: http://webkit.org/blog/363/styling-scrollbars/
+
+Designing to a Dominant Seventh
+-------------------------------
+
+In my spare time I play upright bass and teach blues dancing. I listen to a lot
+of jazz and blues music while doing both and one of the more common chords in
+those genres is a [dominant seventh][].
+
+What does this have to do with my site's design? Although I had a font size of
+18px for the body text I still needed to decide on sizes for headers and other
+site elements. Dominant seventh chords sound beautiful, so I used the notes in
+the chord to come up with these sizes.
+
+Here are the sizes I came up with (after rounding off to the nearest pixel):
+
+* Root: 18 pixels
+* Major third: 23 pixels
+* Perfect fifth: 27 pixels
+* Minor seventh: 32 pixels
+* Octave: 36 pixels
+* Major tenth: 45 pixels
+
+This gave me a variety of sizes to work with.  Here are a few places where
+I used them:
+
+* Base font size: root
+* `h1` elements: major tenth
+* `h2` elements: minor seventh
+* `h3` elements: major third
+* `h4` elements: root
+* "Logo" in the header: major third
+* Navigation links: root
+* Footer text: perfect fifth (an octave down)
+
+You might notice that I don't use a straight perfect fifth anywhere in the
+design.  There are two reasons for this.
+
+First: the perfect fifth and the line height I got from Reader are only two
+pixels apart, which would feel dissonant.
+
+Second: the perfect fifth is the most "generic" note in the chord, so
+eliminating it doesn't really change the feeling of the dominant seventh at
+all.
+
+Once I had my line height and header sizes I had plenty to work on.  I made
+images, blockquotes, code blocks, and everything else fit the rhythm. After
+that I decided to start playing with some other things.
+
+[dominant seventh]: http://en.wikipedia.org/wiki/Dominant_seventh_chord
+
+Removing Comments
+-----------------
+
+The first thing I did after I got the rhythm of the site down was to remove the
+[Disqus][] comments.
+
+I did this for two reasons.  The first and most "practical" reason was that
+they simply looked out of place.  It's hard to style content from a third-party
+site to look great with the rhythm of the site so I got rid of it altogether.
+
+The second reason is something I've learned from music and dancing: the most
+important notes are the ones you *don't* play.
+
+I'm usually pretty busy with full-time and freelance work and don't have enough
+time to properly respond to comments on the site.  Having comments here,
+then, is like having calls without responses — it doesn't work very well.
+
+If someone wants to tell me something they can easily find me on
+[Twitter][twsl] and talk to me or discuss a post on [Hacker News][].
+
+[Disqus]: http://disqus.com/
+[twsl]: {{links.twsl}}
+[Hacker News]: http://news.ycombinator.com/
+
+Adding Applause with Flattr
+---------------------------
+
+I've started using [Flattr][] to help show my appreciation to people that make
+good things on the internet.  Since I was redesigning the site I figured I'd
+include Flattr buttons on my blog posts.
+
+One reason was simple: it lets people give me money for the things I write.
+Another reason is a bit more altruistic: if more people see Flattr buttons
+around the web more people will sign up and help out creators.
+
+I like to think of Flattr as applause at a jazz show or a dance.  It doesn't
+really contribute anything to the conversation but it *does* let you easily
+show your appreciaton.
+
+The worst part of this was going through all my old blog posts and submitting
+them to Flattr.
+
+[Flattr]: http://flattr.com/
+
+Printing Nicely with Print Links
+--------------------------------
+
+This is something that my old site also had but I never really talked about
+(except on [Forrst][]).
+
+If you print one of my site's pages you'll notice that any links inside
+a paragraph of content will show up in a list after the paragraph.  I think
+this makes it easier to refer to a printed copy because you can type in the
+URLs without having to visit my site again.
+
+To do this I use [a little bit of Javascript][printjs].  I *could* put the URLs
+directly after the links using just CSS, but I think that breaks up the content
+and makes it harder to read.
+
+[Forrst]: http://forrst.com/
+[printjs]: http://bitbucket.org/sjl/stevelosh/src/tip/media/js/print.js
+
+Showing Context with Scrolly Headers
+------------------------------------
+
+The last trick I pulled out of my sleeve was the "scrolly headers" to the left
+of the content, which you've probably already noticed.
+
+I tend to write fairly long blog posts and I think about their structure quite
+a bit.  Now that I'm using a much larger font I feel that it's too easy to get
+lost while reading them. If you switch away from the page for a bit and come
+back you might not remember where you were.
+
+To help fix this I wrote a bit of Javascript to display the top-level headers
+of post content to the left of the content.  I think this might help people
+keep their place more easily.
+
+Influences and Goals
+--------------------
+
+While redesigning I had two main influences in mind:
+[Eivind Uggedal's site][uggedal] and [Simon Hørup Eskildsen's site][sirupsen].
+I hope they don't mind that I took a lot of elements from their designs to make
+my own.
+
+As I was making the new site I had a very simple goal: "make sure no one ever
+wants to use Safari Reader on my site."
+
+The design isn't particularly memorable (hell, it pretty much looks like you
+just used Safari Reader), but I don't think that's a problem.  I'm not
+a designer so I don't want my site to be remembered for its design. I want it
+to be remembered for the content, so I aimed for a design that highlights that
+content and gets out of the way.
+
+If you have comments, questions, or suggestions feel free to find me on
+[Twitter][twsl].
+
+[uggedal]: http://uggedal.com/
+[sirupsen]: http://sirupsen.com/
+
--- a/content/blog/2010/11/keep-calm-and-carry-on.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,248 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Keep Calm and Carry On"
-    snip: "You don't always need to be sexy."
-    created: 2010-11-05 16:30:00
-%}
-
-{% block article %}
-
-I've been dancing quite a bit lately, both going to exchanges and teaching
-blues dancing with [Lady Luck Blues][llb]. I haven't written anything about
-dancing in quite a while, so I figured it was time for another blog post.
-
-This post will be about a particular idea (or if you prefer: "pet peeve") of
-mine about blues dancing today. I'm going to take a while to get to the point,
-but I think it's worth the reading.
-
-[llb]: http://ladyluckblues.com/
-
-[TOC]
-
-Saint James Infirmary
----------------------
-
-For this post I'm going to use a very popular song as an example: "Saint James
-Infirmary".  I'm sure almost every blues dancer has heard this song at some
-point (probably many times).
-
-There are *many* versions of this song around.  Here's one if you'd like to
-listen to it to refresh your memory:
-["Saint James Infirmary" by Snooks Eaglin on YouTube][sji].
-
-[sji]: http://www.youtube.com/watch?v=23VSDneTo60
-
-What is this Song About?
-------------------------
-
-Saint James Infirmary is a very old song.  There's a great overview of its
-history on [the Wikipedia page][wiki].
-
-Let's take a look at the lyrics and try to figure out what the song is trying
-to say.  The first verse goes (roughly) like this:
-
->I went down to Saint James infirmary,<br/>
->saw my baby there.<br/>
->She was stretched out on a long white table,<br/>
->so sweet, so cold, so fair.
-
-The first thing we learn about the song is that the singer's lover has died.
-He goes to the morgue to view her body. We can already tell that this is not
-going to be a happy song.
-
-Let's look at the next verse:
-
->Let her go, let her go, god bless her<br/>
->wherever she may be.<br/>
->She can look this whole world all over<br/>
->and never find another man like me.
-
-In the first part of this verse the singer is accepting the fact that his lover
-is dead, and wishing her well in any afterlife she may be in.  The second part
-is a bit less clear, but he seems to be telling us that there's no man on Earth
-that loves (or, rather, "loved") her like he does.
-
-The last verse gets even darker (note: this verse's lyrics often vary quite
-a bit between versions, but the idea is the same):
-
->When I die you can bury me in straight laced shoes,<br/>
->a box-back coat and a Stetson hat.<br/>
->Put a twenty-dollar gold piece on my watch chain<br/>
->so all the boys will know I died standing pat.
-
-All of a sudden the singer is talking about his *own* death.  What happened?
-
-The singer's lover died, he accepted her death, and now he gives instructions
-on what to do when he dies. I'm sure some people will disagree, but to me it
-definitely seems like he's contemplating suicide.
-
-Now that we've got a pretty clear idea of the "mood" of this song, I want to
-talk about what bothers me about how many blues dancers seem to dance to it.
-
-[wiki]: http://en.wikipedia.org/wiki/Saint_James_Infirmary
-
-The Problem
------------
-
-Blues dancing is commonly seen as a "sexy" dance.  There's good reason for
-this: many blues songs are lewd and suggestive, so being sexy as you dance fits
-the music.
-
-The problem I see often is that dancers get comfortable in one "mood" of
-dancing (usually "sexy") and don't bother to explore other ones.
-
-Almost without fail I see people dancing to Saint James Infirmary and trying
-(often succeeding) to be sexy.  They use lots of hip and body movement like
-they do with other blues songs.
-
-I want to say something to them.
-
-**Stop it.**
-
-**You're doing it wrong.**
-
-**You there, doing the body roll: *stop*, god damn it!**
-
-Saint James Infirmary is *not* a "sexy" song.  It's about death and suicide,
-not hooking up!
-
-Would you ask someone for a date at their friend's funeral?  No?  Then why
-would you dance like that to this song?  It doesn't make sense and it's
-completely inappropriate.
-
-We often talk about "musicality" in dance classes, but often it's just about
-"hitting the breaks right."  There's more to it than that.  Reflecting the
-music in your dancing isn't just about hitting the notes, it's about matching
-the *mood* of the song too!
-
-The Solution
-------------
-
-Now is the time when I'm supposed to tell you how to fix things.  I'm not the
-best dancer out there, and it's hard to describe dancing in text, but I'll do
-my best.
-
-If you don't agree with the specific things I mention that's completely cool --
-my goal is to at least get people *thinking* about these ideas, not to tell
-them one specific way to implement them.
-
-### Followers
-
-The one major thing I'd like to tell followers is: "stop being sexy."  There
-are songs where that is completely appropriate, but this is not one of them.
-
-If you're only used to trying to be sexy, what can you do instead?
-
-The simple answer is: "just follow."  Don't worry about adding styling if
-you're not comfortable with it -- a solid follower is much more fun to dance
-with than one that's trying to force a style she has no experience with.
-
-The more complicated answer is: "use styling that reflects the mood of the
-song." Unfortunately I don't have much experience with following so I can't
-really describe this.  Take a private lesson with someone like
-[Mike Legett][mike] or [Carsie Blanton][carsie] if you want to get a more
-informed opinion.
-
-[mike]: http://www.mikethegirl.com/
-[carsie]: http://www.carsieblanton.com/
-
-### Leaders
-
-As a leader, when I dance to this song I think about taking on one of two
-personas:
-
-* The singer -- someone who has just lost a lover.
-* A friend of the singer that is comforting him (or her, if my follower is
-  female).
-
-In both cases I try to eliminate any "swagger" or "bravado" from my styling
-(not that I personally use much of that anyway).  Funerals are not the place to
-be an alpha male.
-
-If I'm taking on the singer's persona (someone that has lost a lover) I'll
-usually dance in a "ballroomy" style.  I'll use short movements (like muffled
-sobs) punctuated by larger, sweeping movements (cries or wails). I'll (gasp)
-slightly collapse my posture just a tiny bit to express the depression.
-
-If I choose the other case (comforting someone) I won't collapse my posture at
-all.  I'll try to represent the shoulder that someone would cry on when their
-lover dies. I'll try to be strong, confident and solid, but not really
-"manly."
-
-In both cases I'll almost always stay in close embrace for the whole song.
-Whether you're comforting someone or being comforted, a hug is usually helpful
-in dark times, so it feels appropriate to use close embrace.
-
-There are many other things you could do as a leader that would fit the song.
-As long as you're conciously thinking of them and not just defaulting to
-a style you're comfortable with, I'm happy.
-
-The Real Problem
-----------------
-
-Having said all that, I actually think the problem I've described is more of
-a symptom, and there's a more fundamental problem with our community (and
-culture in general) today:
-
-**People don't simply *listen* to music any more.**
-
-They hear music while dancing, or put on headphones while doing homework, or
-turn on the radios in their cars, but they never just sit down to *listen* to
-a song without doing anything else.
-
-Many years ago, families would sit around the radio during the evenings and
-just listen to the music.  Today the radio has been replaced by television, so
-we no longer even have those hours.
-
-Dancers may be dancing provocatively to Saint James Infirmary because *they
-don't even realize it's a sad song*!  Even though they've heard it many times
-it never really registers, because they're always focusing on something else
-when they hear it.
-
-The Real Solution
------------------
-
-This root problem has a much more clear solution: **listen to music, damn it!**
-
-Here's the basic idea:
-
-* Find a good album.  Ask around, there are plenty out there.
-* Find a good pair of headphones.  Your iPod earbuds do not count.  Borrow a pair
-  if necessary.
-* Turn off the television, put away books, turn off your phone and your laptop
-  (or at least quit everything on your laptop if you're using it to play the music).
-* Start the album.
-
-Now that you're finally listening, what should you be trying to hear? Here are
-a few suggestions:
-
-* Try just listening to a couple of songs.  Take in the lyrics (if they have
-  them) and the overall "mood" of the instruments.
-* Listen to the energy of the songs.  Jazz and blues musicians will usually make
-  the energy rise and fall throughout the song.
-* Pick a single instrument and listen to it for an entire song.  Try not to let
-  your mind wander -- really focus on just one instrument.  This is where a decent
-  pair of headphones will really help.
-* Pick a different instrument and listen to it for an entire song.  Try to notice
-  differences in how the two instruments play.  For example, a bassist will often
-  be playing for the entire song, while a horn player will frequently stop playing
-  while others are soloing.
-
-Once you've listened to the entire album, without stopping, get a notebook and
-write down some of the things you noticed.  You don't have to have any amazing
-revelations -- the point is to make yourself put into words what you're
-hearing.
-
-Do this at least once or twice a week for a few months.
-
-Putting down these thoughts on paper will help you wrap your head around music
-when you hear it during a dance.  After a while you'll start hearing structure
-and themes in the music and can adjust your dancing to match them.
-
-Music is the foundation of dancing, so the more we listen the better our
-dancing will be.
-
-We'll all become better dancers if we just stop and *listen*.
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2010/11/keep-calm-and-carry-on.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,245 @@
++++
+title = "Keep Calm and Carry On"
+snip = "You don't always need to be sexy."
+date = 2010-11-05T16:30:00Z
+draft = false
+
++++
+
+I've been dancing quite a bit lately, both going to exchanges and teaching
+blues dancing with [Lady Luck Blues][llb]. I haven't written anything about
+dancing in quite a while, so I figured it was time for another blog post.
+
+This post will be about a particular idea (or if you prefer: "pet peeve") of
+mine about blues dancing today. I'm going to take a while to get to the point,
+but I think it's worth the reading.
+
+[llb]: http://ladyluckblues.com/
+
+{{% toc %}}
+
+Saint James Infirmary
+---------------------
+
+For this post I'm going to use a very popular song as an example: "Saint James
+Infirmary".  I'm sure almost every blues dancer has heard this song at some
+point (probably many times).
+
+There are *many* versions of this song around.  Here's one if you'd like to
+listen to it to refresh your memory:
+["Saint James Infirmary" by Snooks Eaglin on YouTube][sji].
+
+[sji]: http://www.youtube.com/watch?v=23VSDneTo60
+
+What is this Song About?
+------------------------
+
+Saint James Infirmary is a very old song.  There's a great overview of its
+history on [the Wikipedia page][wiki].
+
+Let's take a look at the lyrics and try to figure out what the song is trying
+to say.  The first verse goes (roughly) like this:
+
+>I went down to Saint James infirmary,<br/>
+>saw my baby there.<br/>
+>She was stretched out on a long white table,<br/>
+>so sweet, so cold, so fair.
+
+The first thing we learn about the song is that the singer's lover has died.
+He goes to the morgue to view her body. We can already tell that this is not
+going to be a happy song.
+
+Let's look at the next verse:
+
+>Let her go, let her go, god bless her<br/>
+>wherever she may be.<br/>
+>She can look this whole world all over<br/>
+>and never find another man like me.
+
+In the first part of this verse the singer is accepting the fact that his lover
+is dead, and wishing her well in any afterlife she may be in.  The second part
+is a bit less clear, but he seems to be telling us that there's no man on Earth
+that loves (or, rather, "loved") her like he does.
+
+The last verse gets even darker (note: this verse's lyrics often vary quite
+a bit between versions, but the idea is the same):
+
+>When I die you can bury me in straight laced shoes,<br/>
+>a box-back coat and a Stetson hat.<br/>
+>Put a twenty-dollar gold piece on my watch chain<br/>
+>so all the boys will know I died standing pat.
+
+All of a sudden the singer is talking about his *own* death.  What happened?
+
+The singer's lover died, he accepted her death, and now he gives instructions
+on what to do when he dies. I'm sure some people will disagree, but to me it
+definitely seems like he's contemplating suicide.
+
+Now that we've got a pretty clear idea of the "mood" of this song, I want to
+talk about what bothers me about how many blues dancers seem to dance to it.
+
+[wiki]: http://en.wikipedia.org/wiki/Saint_James_Infirmary
+
+The Problem
+-----------
+
+Blues dancing is commonly seen as a "sexy" dance.  There's good reason for
+this: many blues songs are lewd and suggestive, so being sexy as you dance fits
+the music.
+
+The problem I see often is that dancers get comfortable in one "mood" of
+dancing (usually "sexy") and don't bother to explore other ones.
+
+Almost without fail I see people dancing to Saint James Infirmary and trying
+(often succeeding) to be sexy.  They use lots of hip and body movement like
+they do with other blues songs.
+
+I want to say something to them.
+
+**Stop it.**
+
+**You're doing it wrong.**
+
+**You there, doing the body roll: *stop*, god damn it!**
+
+Saint James Infirmary is *not* a "sexy" song.  It's about death and suicide,
+not hooking up!
+
+Would you ask someone for a date at their friend's funeral?  No?  Then why
+would you dance like that to this song?  It doesn't make sense and it's
+completely inappropriate.
+
+We often talk about "musicality" in dance classes, but often it's just about
+"hitting the breaks right."  There's more to it than that.  Reflecting the
+music in your dancing isn't just about hitting the notes, it's about matching
+the *mood* of the song too!
+
+The Solution
+------------
+
+Now is the time when I'm supposed to tell you how to fix things.  I'm not the
+best dancer out there, and it's hard to describe dancing in text, but I'll do
+my best.
+
+If you don't agree with the specific things I mention that's completely cool --
+my goal is to at least get people *thinking* about these ideas, not to tell
+them one specific way to implement them.
+
+### Followers
+
+The one major thing I'd like to tell followers is: "stop being sexy."  There
+are songs where that is completely appropriate, but this is not one of them.
+
+If you're only used to trying to be sexy, what can you do instead?
+
+The simple answer is: "just follow."  Don't worry about adding styling if
+you're not comfortable with it — a solid follower is much more fun to dance
+with than one that's trying to force a style she has no experience with.
+
+The more complicated answer is: "use styling that reflects the mood of the
+song." Unfortunately I don't have much experience with following so I can't
+really describe this.  Take a private lesson with someone like
+[Mike Legett][mike] or [Carsie Blanton][carsie] if you want to get a more
+informed opinion.
+
+[mike]: http://www.mikethegirl.com/
+[carsie]: http://www.carsieblanton.com/
+
+### Leaders
+
+As a leader, when I dance to this song I think about taking on one of two
+personas:
+
+* The singer — someone who has just lost a lover.
+* A friend of the singer that is comforting him (or her, if my follower is
+  female).
+
+In both cases I try to eliminate any "swagger" or "bravado" from my styling
+(not that I personally use much of that anyway).  Funerals are not the place to
+be an alpha male.
+
+If I'm taking on the singer's persona (someone that has lost a lover) I'll
+usually dance in a "ballroomy" style.  I'll use short movements (like muffled
+sobs) punctuated by larger, sweeping movements (cries or wails). I'll (gasp)
+slightly collapse my posture just a tiny bit to express the depression.
+
+If I choose the other case (comforting someone) I won't collapse my posture at
+all.  I'll try to represent the shoulder that someone would cry on when their
+lover dies. I'll try to be strong, confident and solid, but not really
+"manly."
+
+In both cases I'll almost always stay in close embrace for the whole song.
+Whether you're comforting someone or being comforted, a hug is usually helpful
+in dark times, so it feels appropriate to use close embrace.
+
+There are many other things you could do as a leader that would fit the song.
+As long as you're conciously thinking of them and not just defaulting to
+a style you're comfortable with, I'm happy.
+
+The Real Problem
+----------------
+
+Having said all that, I actually think the problem I've described is more of
+a symptom, and there's a more fundamental problem with our community (and
+culture in general) today:
+
+**People don't simply *listen* to music any more.**
+
+They hear music while dancing, or put on headphones while doing homework, or
+turn on the radios in their cars, but they never just sit down to *listen* to
+a song without doing anything else.
+
+Many years ago, families would sit around the radio during the evenings and
+just listen to the music.  Today the radio has been replaced by television, so
+we no longer even have those hours.
+
+Dancers may be dancing provocatively to Saint James Infirmary because *they
+don't even realize it's a sad song*!  Even though they've heard it many times
+it never really registers, because they're always focusing on something else
+when they hear it.
+
+The Real Solution
+-----------------
+
+This root problem has a much more clear solution: **listen to music, damn it!**
+
+Here's the basic idea:
+
+* Find a good album.  Ask around, there are plenty out there.
+* Find a good pair of headphones.  Your iPod earbuds do not count.  Borrow a pair
+  if necessary.
+* Turn off the television, put away books, turn off your phone and your laptop
+  (or at least quit everything on your laptop if you're using it to play the music).
+* Start the album.
+
+Now that you're finally listening, what should you be trying to hear? Here are
+a few suggestions:
+
+* Try just listening to a couple of songs.  Take in the lyrics (if they have
+  them) and the overall "mood" of the instruments.
+* Listen to the energy of the songs.  Jazz and blues musicians will usually make
+  the energy rise and fall throughout the song.
+* Pick a single instrument and listen to it for an entire song.  Try not to let
+  your mind wander — really focus on just one instrument.  This is where a decent
+  pair of headphones will really help.
+* Pick a different instrument and listen to it for an entire song.  Try to notice
+  differences in how the two instruments play.  For example, a bassist will often
+  be playing for the entire song, while a horn player will frequently stop playing
+  while others are soloing.
+
+Once you've listened to the entire album, without stopping, get a notebook and
+write down some of the things you noticed.  You don't have to have any amazing
+revelations — the point is to make yourself put into words what you're
+hearing.
+
+Do this at least once or twice a week for a few months.
+
+Putting down these thoughts on paper will help you wrap your head around music
+when you hear it during a dance.  After a while you'll start hearing structure
+and themes in the music and can adjust your dancing to match them.
+
+Music is the foundation of dancing, so the more we listen the better our
+dancing will be.
+
+We'll all become better dancers if we just stop and *listen*.
+
--- a/content/blog/2011/05/on-learning-and-teaching.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,258 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "On Learning and Teaching"
-        snip: "Learning one thing isn't enough."
-        created: 2011-05-22 17:00:00
-    %}
-
-    {% block article %}
-
-I recently read a blog entry by [Zack Kurmas][] called "[The deep end of the
-pool][]".  In it he talks about why he thinks some students succeed in introductory
-Computer Science classes while others fail.  If you're a programmer and haven't read
-it, stop right now and read it.
-
-In a nutshell: I think he's pretty much correct.  I wanted to write this post because
-I think I have a solution to the problem that might work, at least for some people.
-
-[TOC]
-
-[Zack Kurmas]: http://www.cis.gvsu.edu/~kurmasz/
-[The deep end of the pool]: http://spin.atomicobject.com/2011/05/17/the-deep-end-of-the-pool/
-
-Background
-----------
-
-I'm a computer programmer by trade.  I went to [RIT][] for five years to  get my
-degree in Computer Science and before that I was working with toy programs during
-high school.
-
-While I was at RIT I started going to [Swing Dance Club][].  I learned to swing dance
-there about eight years ago.  A few years later I started I began teaching Swing
-Dance Club with some of my friends, and about a year ago I started teaching Blues
-Dancing with [Lady Luck Blues][].
-
-I have a couple of other semi-serious hobbies that I've taken classes in as well:
-photography and bass playing.
-
-To summarize: I've had experience in a bunch of different areas, and I've been
-teaching one of them for a while.
-
-**Disclaimer:** one thing I've never studied is teaching itself, so feel free to take
-everything I say about it with a large grain of salt.  I haven't done any hard
-research and I could be completely wrong.
-
-[RIT]: http://rit.edu/
-[Swing Dance Club]: http://www.rit.edu/sg/swing/
-[Lady Luck Blues]: http://ladyluckblues.com/
-
-Similarities in Dancing and Programming
----------------
-
-In his article, Zack talks about programming syntax being a stumbling block for
-beginners.  I think he's very right and I think there's a similar concept in dancing.
-
-### Programming Syntax
-
-If you're a programmer you can skip this section.
-
-For the non-programmers: "syntax" is the combination of letters, numbers and symbols
-that you write to create computer programs. For example, look at the following two
-bits of text:
-
-    if x == 2:
-        print "Hello"
-    x = 10
-
-    if x == 2:
-        print 'Hello"
-    x = 10
-
-Notice the difference?  The first snippet says `"Hello"` while the second says
-`'Hello"`.  Notice how the first uses two double quotes (`"`) while the second uses
-one double and one single quote (`'`).
-
-The first bit of code will work, but the second one won't.  Little differences like
-these might not seem like a big deal, but to a computer they're as different as
-`abcdefg` and `o34%^8@@.com`.
-
-### Dancing Footwork
-
-If you're a dancer you can skip this section.
-
-For the non-dancers: "footwork" is the pattern of steps you make when you dance.  For
-example, in Lindy Hop (a style of swing dancing) the basic footwork looks like this:
-
-    Beats:   1   2   3   4   5   6   7   8
-    Steps:   x   x   x  xx   x   x   x  xx
-
-For East Coast Swing, the basic footwork looks like this:
-
-    Beats:   1   2   3   4   5   6
-    Steps:   x   x   x  xx   x  xx
-
-Notice the differences?  Lindy Hop footwork is based on an eight beat pattern, while
-East Coast footwork is based on six beats.  The patterns also have the "extra steps"
-in different places.
-
-When you're dancing with a partner you both need to be doing the same footwork,
-otherwise you can't really dance together.
-
-### Footwork is Syntax and Syntax is Footwork
-
-When you're learning both programming and dancing there are lots of deep, high-level
-concepts you can tackle.  For programming you have things like object orientation,
-recursion, and API design.  In dancing you have things like musicality, listening to
-your follower, and negative space.
-
-However: in my experience teaching dancing you need to learn and understand the
-footwork before you can learn the higher concepts.  If you're still thinking about
-where to put your feet when you're dancing you won't have the spare brainpower to
-think about those other concepts.
-
-In Zack's post he says the same thing about programming.  If you're still struggling
-with understanding the syntax of programs you can't simultaneously pay attention to
-the higher concepts that are being taught. I've never taught programming but my
-personal observations of programmers make me think he's right.
-
-To be clear: there aren't just two levels (low and high).  There are many
-levels/layers, each of which builds on the last.  Also: the layers are not linear --
-learning concept A might allow you to learn either B or C.
-
-However: the same idea applies most of the time.  You need to learn and internalize
-lower levels before moving on to the higher ones.
-
-Plateaus in Learning
-------------------
-
-One thing I've noticed while learning dancing, programming, photography, and other
-skills is that my learning seems to progress quickly at times and slowly at others.
-
-When I'm learning quickly everything is great.  I feel good about myself and my
-abilities and I throw myself into learning as much as I can.
-
-On the other hand when I'm learning slowly (hitting a "plateau") I often get
-frustrated or discouraged.  Nothing I try seems to speed up my ascent out of these
-plateaus.  It seems like the only thing that works is time and practice of what
-I already know.
-
-I think the reason for this is that once I learn a bunch of new concepts my brain
-needs some time to process them.  I can learn the concepts and use them if
-I concentrate, but it's not effortless.  I think the reason I finally start learning
-quickly again after some time is that I've internalized the previous concepts and now
-I can move on to more difficult ones which build on the previous ones.
-
-The first plateau of programming is the syntax and the first plateau of dancing is
-footwork.  The bad part about this is that dancing when you only know footwork or
-programming when you only know syntax isn't much fun.  You can't do all of the most
-interesting things that make these skills so rewarding.
-
-Getting Through Plateaus
-------------------------
-
-In my own experience the hardest part about teaching is getting students through the
-plateaus.  Because it just takes time and practice to process what they've already
-learned there's not much I can do to help them.  Students take more advanced classes
-but don't really grab them until they're fluent in the things they've previously
-learned.
-
-As a teacher, this is incredibly frustrating.  I want to teach my students what
-I know, but I know they won't absorb it until they've absorbed the previous lessons.
-
-### The Lie and the Solution
-
-Here's the kicker, and what I think might provide the solution to this problem: **I
-lied when I said that the only things that help me through plateaus are time and
-practice.**
-
-There's one more thing that helps me get through plateaus: **connecting the concepts
-I'm trying to internalize with concepts from other skills that I already know.**
-
-An example of this that I've written about before is [negative space][].  When I was
-learning blues dancing I realized that "stopping your movement" was simply
-a different expression of the concept of "negative space" in photography.
-
-I had already struggled through internalizing the concept of negative space in
-photography, so when I connected this with dancing it helped make things "click"
-together and made the plateau shorter.
-
-[negative space]: http://stevelosh.com/blog/2008/08/negative-space-dancing/
-
-### The Problem with the Solution
-
-In my own life this solution is great.
-
-I have a bunch of hobbies and all of them mesh together in different ways.  Sometimes
-I can connect what I know in one to what I know in another and get through these
-plateaus more quickly.  When I can't do that I can focus on one of my other hobbies
-while practicing another, which reduces the frustration of not progressing faster.
-
-When teaching students, however, this isn't a trick I can use effectively.
-
-I can't really tell a student: "you need to find something else to focus on for
-a while while you internalize what I've taught you."  If they want to learn dancing,
-they'll feel like taking more dance classes is the way to go.  They're paying me to
-teach them so I obviously have to try to teach them.
-
-I sometimes try to teach the "analogies" between skills that have helped me.
-Sometimes this works well -- the "Negative Space in Dancing" class that my partner
-and I have taught seems to go over well with most of the students.
-
-The problem is that everyone has different skills.  Trying to connect a concept in
-programming to a concept in photography is futile if the student doesn't understand
-the photographic concept.
-
-### The Solution to the Problem with the Solution
-
-Disclaimer: once again, I've never studied teaching itself, so this might not be
-a new idea and/or I could be completely wrong about this.
-
-I've thought a long time about a way to fix this.  For students that are simply
-taking a class here and there with me, I haven't found a good solution.
-
-However, for students enrolled in a longer series of classes, like college students
-studying a major, I think there might be a way to use this idea (linking concepts
-from disparate skills) to help them learn.
-
-When I went to RIT I didn't just take Computer Science classes.  I had to take a few
-science classes, a few math classes, a few history classes, and so on.  I believe
-other colleges work on the same system: you take many classes in your major and one
-or two classes in everything else.  The idea is that you become a "well-rounded"
-person.
-
-The bad part about this process is that one or two classes is not enough to get to
-one of these "plateaus", struggle through it, and continue on.  Therefore you don't
-have time to internalize the skills you learn, which means that you can't connect
-them to concepts in your major.
-
-I'm also not sure how effective these random classes are at making students
-"well-rounded".  If you don't get far enough to internalize the skills you learn in
-a class are they really useful to you once you're done with those classes?
-
-I think the way around this is to ditch the "one major and a tiny bit of everything
-else" process and move to a "one major and two or three minors" process.
-
-This will help students past the plateaus that discourage them, because they'll have
-learned enough in their "minors" to be able to connect concepts to those in their
-major.  Teachers might not be able to teach specific analogies because the students
-will all have different minors, but each student will be able to connect the concepts
-in their majors on their own to whatever they happen to know from their minors.
-
-This process also has another benefit: students will leave college retaining more
-skills that they would have otherwise.  A programming student could leave college
-with a real, effective amount of knowledge in music; a writing major could leave with
-a real, effective amount of knowledge in biology, and so on.
-
-Conclusion
-----------
-
-I'm not naive enough to think that any college is going to change their entire
-curriculum based on some random guy's blog post.
-
-My intended audience for this post is not colleges, but people that want to learn
-skills faster and more effectively.  I know that there are a lot of people out there
-hungry for knowledge and I hope that some of them can benefit from the ideas I've
-given, learn faster, and make the world a better place.
-
-    {% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2011/05/on-learning-and-teaching.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,255 @@
++++
+title = "On Learning and Teaching"
+snip = "Learning one thing isn't enough."
+date = 2011-05-22T17:00:00Z
+draft = false
+
++++
+
+I recently read a blog entry by [Zack Kurmas][] called "[The deep end of the
+pool][]".  In it he talks about why he thinks some students succeed in introductory
+Computer Science classes while others fail.  If you're a programmer and haven't read
+it, stop right now and read it.
+
+In a nutshell: I think he's pretty much correct.  I wanted to write this post because
+I think I have a solution to the problem that might work, at least for some people.
+
+{{% toc %}}
+
+[Zack Kurmas]: http://www.cis.gvsu.edu/~kurmasz/
+[The deep end of the pool]: http://spin.atomicobject.com/2011/05/17/the-deep-end-of-the-pool/
+
+Background
+----------
+
+I'm a computer programmer by trade.  I went to [RIT][] for five years to  get my
+degree in Computer Science and before that I was working with toy programs during
+high school.
+
+While I was at RIT I started going to [Swing Dance Club][].  I learned to swing dance
+there about eight years ago.  A few years later I started I began teaching Swing
+Dance Club with some of my friends, and about a year ago I started teaching Blues
+Dancing with [Lady Luck Blues][].
+
+I have a couple of other semi-serious hobbies that I've taken classes in as well:
+photography and bass playing.
+
+To summarize: I've had experience in a bunch of different areas, and I've been
+teaching one of them for a while.
+
+**Disclaimer:** one thing I've never studied is teaching itself, so feel free to take
+everything I say about it with a large grain of salt.  I haven't done any hard
+research and I could be completely wrong.
+
+[RIT]: http://rit.edu/
+[Swing Dance Club]: http://www.rit.edu/sg/swing/
+[Lady Luck Blues]: http://ladyluckblues.com/
+
+Similarities in Dancing and Programming
+---------------
+
+In his article, Zack talks about programming syntax being a stumbling block for
+beginners.  I think he's very right and I think there's a similar concept in dancing.
+
+### Programming Syntax
+
+If you're a programmer you can skip this section.
+
+For the non-programmers: "syntax" is the combination of letters, numbers and symbols
+that you write to create computer programs. For example, look at the following two
+bits of text:
+
+    if x == 2:
+        print "Hello"
+    x = 10
+
+    if x == 2:
+        print 'Hello"
+    x = 10
+
+Notice the difference?  The first snippet says `"Hello"` while the second says
+`'Hello"`.  Notice how the first uses two double quotes (`"`) while the second uses
+one double and one single quote (`'`).
+
+The first bit of code will work, but the second one won't.  Little differences like
+these might not seem like a big deal, but to a computer they're as different as
+`abcdefg` and `o34%^8@@.com`.
+
+### Dancing Footwork
+
+If you're a dancer you can skip this section.
+
+For the non-dancers: "footwork" is the pattern of steps you make when you dance.  For
+example, in Lindy Hop (a style of swing dancing) the basic footwork looks like this:
+
+    Beats:   1   2   3   4   5   6   7   8
+    Steps:   x   x   x  xx   x   x   x  xx
+
+For East Coast Swing, the basic footwork looks like this:
+
+    Beats:   1   2   3   4   5   6
+    Steps:   x   x   x  xx   x  xx
+
+Notice the differences?  Lindy Hop footwork is based on an eight beat pattern, while
+East Coast footwork is based on six beats.  The patterns also have the "extra steps"
+in different places.
+
+When you're dancing with a partner you both need to be doing the same footwork,
+otherwise you can't really dance together.
+
+### Footwork is Syntax and Syntax is Footwork
+
+When you're learning both programming and dancing there are lots of deep, high-level
+concepts you can tackle.  For programming you have things like object orientation,
+recursion, and API design.  In dancing you have things like musicality, listening to
+your follower, and negative space.
+
+However: in my experience teaching dancing you need to learn and understand the
+footwork before you can learn the higher concepts.  If you're still thinking about
+where to put your feet when you're dancing you won't have the spare brainpower to
+think about those other concepts.
+
+In Zack's post he says the same thing about programming.  If you're still struggling
+with understanding the syntax of programs you can't simultaneously pay attention to
+the higher concepts that are being taught. I've never taught programming but my
+personal observations of programmers make me think he's right.
+
+To be clear: there aren't just two levels (low and high).  There are many
+levels/layers, each of which builds on the last.  Also: the layers are not linear --
+learning concept A might allow you to learn either B or C.
+
+However: the same idea applies most of the time.  You need to learn and internalize
+lower levels before moving on to the higher ones.
+
+Plateaus in Learning
+------------------
+
+One thing I've noticed while learning dancing, programming, photography, and other
+skills is that my learning seems to progress quickly at times and slowly at others.
+
+When I'm learning quickly everything is great.  I feel good about myself and my
+abilities and I throw myself into learning as much as I can.
+
+On the other hand when I'm learning slowly (hitting a "plateau") I often get
+frustrated or discouraged.  Nothing I try seems to speed up my ascent out of these
+plateaus.  It seems like the only thing that works is time and practice of what
+I already know.
+
+I think the reason for this is that once I learn a bunch of new concepts my brain
+needs some time to process them.  I can learn the concepts and use them if
+I concentrate, but it's not effortless.  I think the reason I finally start learning
+quickly again after some time is that I've internalized the previous concepts and now
+I can move on to more difficult ones which build on the previous ones.
+
+The first plateau of programming is the syntax and the first plateau of dancing is
+footwork.  The bad part about this is that dancing when you only know footwork or
+programming when you only know syntax isn't much fun.  You can't do all of the most
+interesting things that make these skills so rewarding.
+
+Getting Through Plateaus
+------------------------
+
+In my own experience the hardest part about teaching is getting students through the
+plateaus.  Because it just takes time and practice to process what they've already
+learned there's not much I can do to help them.  Students take more advanced classes
+but don't really grab them until they're fluent in the things they've previously
+learned.
+
+As a teacher, this is incredibly frustrating.  I want to teach my students what
+I know, but I know they won't absorb it until they've absorbed the previous lessons.
+
+### The Lie and the Solution
+
+Here's the kicker, and what I think might provide the solution to this problem: **I
+lied when I said that the only things that help me through plateaus are time and
+practice.**
+
+There's one more thing that helps me get through plateaus: **connecting the concepts
+I'm trying to internalize with concepts from other skills that I already know.**
+
+An example of this that I've written about before is [negative space][].  When I was
+learning blues dancing I realized that "stopping your movement" was simply
+a different expression of the concept of "negative space" in photography.
+
+I had already struggled through internalizing the concept of negative space in
+photography, so when I connected this with dancing it helped make things "click"
+together and made the plateau shorter.
+
+[negative space]: http://stevelosh.com/blog/2008/08/negative-space-dancing/
+
+### The Problem with the Solution
+
+In my own life this solution is great.
+
+I have a bunch of hobbies and all of them mesh together in different ways.  Sometimes
+I can connect what I know in one to what I know in another and get through these
+plateaus more quickly.  When I can't do that I can focus on one of my other hobbies
+while practicing another, which reduces the frustration of not progressing faster.
+
+When teaching students, however, this isn't a trick I can use effectively.
+
+I can't really tell a student: "you need to find something else to focus on for
+a while while you internalize what I've taught you."  If they want to learn dancing,
+they'll feel like taking more dance classes is the way to go.  They're paying me to
+teach them so I obviously have to try to teach them.
+
+I sometimes try to teach the "analogies" between skills that have helped me.
+Sometimes this works well — the "Negative Space in Dancing" class that my partner
+and I have taught seems to go over well with most of the students.
+
+The problem is that everyone has different skills.  Trying to connect a concept in
+programming to a concept in photography is futile if the student doesn't understand
+the photographic concept.
+
+### The Solution to the Problem with the Solution
+
+Disclaimer: once again, I've never studied teaching itself, so this might not be
+a new idea and/or I could be completely wrong about this.
+
+I've thought a long time about a way to fix this.  For students that are simply
+taking a class here and there with me, I haven't found a good solution.
+
+However, for students enrolled in a longer series of classes, like college students
+studying a major, I think there might be a way to use this idea (linking concepts
+from disparate skills) to help them learn.
+
+When I went to RIT I didn't just take Computer Science classes.  I had to take a few
+science classes, a few math classes, a few history classes, and so on.  I believe
+other colleges work on the same system: you take many classes in your major and one
+or two classes in everything else.  The idea is that you become a "well-rounded"
+person.
+
+The bad part about this process is that one or two classes is not enough to get to
+one of these "plateaus", struggle through it, and continue on.  Therefore you don't
+have time to internalize the skills you learn, which means that you can't connect
+them to concepts in your major.
+
+I'm also not sure how effective these random classes are at making students
+"well-rounded".  If you don't get far enough to internalize the skills you learn in
+a class are they really useful to you once you're done with those classes?
+
+I think the way around this is to ditch the "one major and a tiny bit of everything
+else" process and move to a "one major and two or three minors" process.
+
+This will help students past the plateaus that discourage them, because they'll have
+learned enough in their "minors" to be able to connect concepts to those in their
+major.  Teachers might not be able to teach specific analogies because the students
+will all have different minors, but each student will be able to connect the concepts
+in their majors on their own to whatever they happen to know from their minors.
+
+This process also has another benefit: students will leave college retaining more
+skills that they would have otherwise.  A programming student could leave college
+with a real, effective amount of knowledge in music; a writing major could leave with
+a real, effective amount of knowledge in biology, and so on.
+
+Conclusion
+----------
+
+I'm not naive enough to think that any college is going to change their entire
+curriculum based on some random guy's blog post.
+
+My intended audience for this post is not colleges, but people that want to learn
+skills faster and more effectively.  I know that there are a lot of people out there
+hungry for knowledge and I hope that some of them can benefit from the ideas I've
+given, learn faster, and make the world a better place.
+
--- a/content/blog/2011/05/paper-free.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,233 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Going Paper-Free for $220"
-        snip: "It feels like the future!"
-        created: 2011-05-26 13:44:00
-    %}
-
-    {% block article %}
-
-It's 2011. Personal computers have been around and popular for well over a decade
-now, and yet we still have to deal with a huge amount of physical paper.
-
-I've been wanting to go paper-free for a long time now. The advantages are obvious:
-
-- Paper takes up physical space in our homes that digital files don't.
-- Digital files, if properly encrypted, are far more secure than sheets of paper that
-  could be stolen.
-- Digital files can be searched in an instant, while papers have to be laboriously
-  sorted through.
-- Digital files can be backed up perfectly and easily.
-
-After reading [this article][] I was psyched to scan and shred all the boxes of paper
-sitting in my apartment, but the $420+ price tag was hard to swallow. I started
-looking around for other options.
-
-[this article]: http://ryanwaggoner.com/2010/11/how-i-filled-two-dumpsters-and-went-paperless-with-the-fujitsu-scansnap-s1500/
-
-Here are the requirements I have for any paper-free system:
-
-- The scanned files need to be OCR'ed so I can search them easily. I'm too lazy to
-  categorize and tag files manually.
-- I need to be able to scan files anywhere.  If I'm out at dinner I want to be able
-  to snap a picture of my receipt and tear it up right there.
-- No "cloud" services allowed for unencrypted important documents. I simply don't
-  trust Google/Dropbox/etc enough to put my bank statements and such there.
-- Files need to be backed up securely in case my apartment burns down.
-- The entire process needs to be automated as much as possible, otherwise I'll get
-  lazy and not scan things.
-
-It's taken me a while, but I've finally got a system I'm happy with. This post will
-describe each part and how they fit together. The total cost is about $220, $160 of
-which is for a physical scanner.
-
-Note: I use OS X and an iPhone, so this post will focus on that platform. However,
-the important pieces of software will run on Windows and I'm sure there are
-Windows/Android equivalents to the other pieces.
-
-[TOC]
-
-Scanning at Home
-----------------
-
-The first step to becoming paper-free is obviously scanning your documents.  There
-are a lot of scanners out there, some more expensive than others. I eventually
-settled on a [Doxie][] for $160.
-
-[Doxie]: http://www.getdoxie.com/
-
-I chose the Doxie because:
-
-- It's compact.
-- It runs with a single USB cable.
-- It's cross-platform.
-- Its software has a great, polished UI.
-- It has a "multiple-function button" that lets you control it without the
-  mouse/keyboard.
-
-The first, second, and last points mean that (with a USB extension cable) I can scan
-documents while sitting on the couch and watching Netflix, which is critical for lazy
-people like me.
-
-I set Doxie to save scans on my Desktop. The scanning process is pretty simple so
-I won't describe it here. Check out Doxie's documentation for more information.
-
-**Note:** When I first received my Doxie and tried to calibrate it, it simply made
-a grinding noise and wouldn't feed the paper.  I emailed their tech support and
-within half an hour I got a response back saying they were shipping me a replacement
-immediately.
-
-When I got the replacement it worked like a charm.  Their customer service was so
-great that I'd still recommend the Doxie even though my first one was a dud.
-
-Scanning on the Go
-------------------
-
-As I mentioned before, I want to be able to scan things while out and about with my
-iPhone. There are a bunch of iPhone document-scanning apps out there. I settled on
-[JotNot][] for $7 because it has a decent UI and supports multiple-page PDFs.
-
-JotNot's UI is pretty easy to get the hang of so I won't go over it here.
-
-Once I finish scanning something I send the PDF to a [Dropbox][] folder called
-"JotNot". 
-
-I know I said in my requirements that "cloud" services weren't allowed, but I make an
-exception for non-critical things that I'd be scanning with my phone. I don't care if
-Dropbox knows how much I spent on dinner.
-
-[JotNot]: http://itunes.apple.com/us/app/jotnot-scanner-pro/id307868751?mt=8
-[Dropbox]: http://www.dropbox.com/
-
-OCR'ing Scanned Documents
--------------------------
-
-The next step is to run the scanned PDFs through an OCR program so they can be
-searched with Spotlight.
-
-I looked at a lot of OCR software and finally settled on [PDF OCR X][] for $30. It
-has a simple interface, does a pretty good job at OCR'ing, has a free version so
-I could try it out, and is cross-platform.
-
-Using it is simple: you drag a PDF onto the app and select your desired settings
-(make sure to choose "searchable PDF" as the output format). The app will think for
-a while and then create a new PDF next to the old one with the searchable text
-embedded.
-
-Once you've done this once you should go into the preferences and change it to
-non-interactive mode so that it won't prompt you for the settings every time you use
-it.
-
-[PDF OCR X]: http://solutions.weblite.ca/pdfocrx/
-
-Gluing Everything Together
---------------------------
-
-So far we've got two folders with scanned PDFs and a method for OCR'ing them. The
-next step is to automate the process.
-
-I use an app called [Hazel][] to do this. It's $21 for a license and well worth it.
-We'll set up four rules to make our lives easier.
-
-Before we start we need to create two folders somewhere (you can name them whatever
-you like):
-
-- Pending OCR: A folder to hold documents that are waiting to be OCR'ed.
-- Dead Trees: A folder to hold the final, OCR'ed versions of our documents.
-
-The first rule watches the Desktop for scans from Doxie.  Any files placed on the
-Desktop whose name starts with "Doxie Doc" will be renamed to include the current
-date and time, and then moved to the "Pending OCR" folder.
-
-![Rule 1 Screenshot](/media/images{{ parent_url }}/rules-1-doxie.png "Rule 1")
-
-**Note:**: you'll need to click the `date created` bubble and then "Edit Date" to get
-the time as well as the date into the filename.
-
-The second rule watches the "JotNot" folder for scans from the iPhone app.  Any PDFs
-that appear in here (i.e. that are synced down from Dropbox) will be moved to the
-"Pending OCR" folder.  We don't need to rename them like we did with the Doxie scans
-because JotNot already includes the date and time of scans in the filenames by
-default.
-
-![Rule 2 Screenshot](/media/images{{ parent_url }}/rules-2-jotnot.png "Rule 2")
-
-Now that we've got all of our scans going into the same folder (with unique names) we
-can set up a rule to OCR them.  The third rule watches the "Pending OCR" folder for
-PDFs.  When a PDF lands in the folder it will be moved to its final destination
-folder ("Dead Trees" in my case) and then opened in PDF OCR X.  Because I've put PDF
-OCR X in non-interactive mode the files will automatically be OCR'ed without any
-intervention from me.
-
-![Rule 3 Screenshot](/media/images{{ parent_url }}/rules-3-ocr.png "Rule 3")
-
-The fourth and final rule watches for the OCR'ed copies of our scans and runs
-a script to move the originals to the trash once the searchable versions are ready.
-It doesn't delete the files completely because I want a safety net in case something
-goes wrong.
-
-![Rule 4 Screenshot](/media/images{{ parent_url }}/rules-4-clean.png "Rule 4")
-
-**Note:** make sure you change the Shell to `/usr/bin/python`.  Here's the text of
-the script so you can copy and paste it:
-
-    import sys, os
-
-    RM_CMD = r"""osascript -e 'tell app "Finder" to move the POSIX file "%s" to trash'"""
-    old_file = sys.argv[1].rsplit('.', 2)[0]
-    if os.path.exists(old_file):
-        os.system(RM_CMD % os.path.abspath(old_file))
-
-Once these four rules are in place we can simply scan a document with Doxie or JotNot
-and it will automatically be OCR'ed and placed in our "Dead Trees" folder, with no
-intervention from us!
-
-[Hazel]: http://www.noodlesoft.com/hazel.php
-
-Backing Up
-----------
-
-A while ago I was using Mozy for full backups. Recently they changed their pricing so
-it was no longer unlimited. When that happened I switched to [Backblaze][] and
-couldn't be happier.
-
-Backblaze's UI is leaps and bounds above Mozy's, and they offer an option to generate
-a secure encryption key for encrypting your backups. I highly recommend this, but be
-sure to have a few copies of your key because you'll need it to restore your backups.
-
-Backblaze is also only $5 per month (less if you pay for a year in advance) for
-unlimited backups which is definitely a bargain.  As a bonus, they just released
-a ["find my computer" feature][find-computer] that's kind of like a lightweight
-version of [Undercover][], so it's an even better deal.
-
-[Backblaze]: http://www.backblaze.com/
-[Undercover]: http://www.orbicule.com/undercover/
-[find-computer]: http://blog.backblaze.com/2011/05/23/lost-your-computer-get-it-back-backblaze-launches-locate-my-computer/
-
-Destroying the Originals
-------------------------
-
-Once the documents are scanned and backed up it's time to destroy the physical paper.
-If you live in a rural area you could burn them for free.
-
-Those of us that can't start random fires need a paper shredder. I use a shredder
-I picked up a long time ago -- any crosscut shredder will do the job.
-
-Summary
--------
-
-After all of this I've now got a mostly-automated system that lets me go paper-free.
-The costs are:
-
-- Doxie Scanner: $160
-- JotNot: $7
-- PDF OCR X: $30
-- Hazel: $21
-- Backblaze: $5 per month
-
-For me the $218 initial cost is worth it.  Now I can search all of my paper in
-a instant and my apartment is much less cluttered. If you have the money to spare I'd
-definitely consider trying it.
-
-    {% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2011/05/paper-free.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,230 @@
++++
+title = "Going Paper-Free for $220"
+snip = "It feels like the future!"
+date = 2011-05-26T13:44:00Z
+draft = false
+
++++
+
+It's 2011. Personal computers have been around and popular for well over a decade
+now, and yet we still have to deal with a huge amount of physical paper.
+
+I've been wanting to go paper-free for a long time now. The advantages are obvious:
+
+- Paper takes up physical space in our homes that digital files don't.
+- Digital files, if properly encrypted, are far more secure than sheets of paper that
+  could be stolen.
+- Digital files can be searched in an instant, while papers have to be laboriously
+  sorted through.
+- Digital files can be backed up perfectly and easily.
+
+After reading [this article][] I was psyched to scan and shred all the boxes of paper
+sitting in my apartment, but the $420+ price tag was hard to swallow. I started
+looking around for other options.
+
+[this article]: http://ryanwaggoner.com/2010/11/how-i-filled-two-dumpsters-and-went-paperless-with-the-fujitsu-scansnap-s1500/
+
+Here are the requirements I have for any paper-free system:
+
+- The scanned files need to be OCR'ed so I can search them easily. I'm too lazy to
+  categorize and tag files manually.
+- I need to be able to scan files anywhere.  If I'm out at dinner I want to be able
+  to snap a picture of my receipt and tear it up right there.
+- No "cloud" services allowed for unencrypted important documents. I simply don't
+  trust Google/Dropbox/etc enough to put my bank statements and such there.
+- Files need to be backed up securely in case my apartment burns down.
+- The entire process needs to be automated as much as possible, otherwise I'll get
+  lazy and not scan things.
+
+It's taken me a while, but I've finally got a system I'm happy with. This post will
+describe each part and how they fit together. The total cost is about $220, $160 of
+which is for a physical scanner.
+
+Note: I use OS X and an iPhone, so this post will focus on that platform. However,
+the important pieces of software will run on Windows and I'm sure there are
+Windows/Android equivalents to the other pieces.
+
+{{% toc %}}
+
+Scanning at Home
+----------------
+
+The first step to becoming paper-free is obviously scanning your documents.  There
+are a lot of scanners out there, some more expensive than others. I eventually
+settled on a [Doxie][] for $160.
+
+[Doxie]: http://www.getdoxie.com/
+
+I chose the Doxie because:
+
+- It's compact.
+- It runs with a single USB cable.
+- It's cross-platform.
+- Its software has a great, polished UI.
+- It has a "multiple-function button" that lets you control it without the
+  mouse/keyboard.
+
+The first, second, and last points mean that (with a USB extension cable) I can scan
+documents while sitting on the couch and watching Netflix, which is critical for lazy
+people like me.
+
+I set Doxie to save scans on my Desktop. The scanning process is pretty simple so
+I won't describe it here. Check out Doxie's documentation for more information.
+
+**Note:** When I first received my Doxie and tried to calibrate it, it simply made
+a grinding noise and wouldn't feed the paper.  I emailed their tech support and
+within half an hour I got a response back saying they were shipping me a replacement
+immediately.
+
+When I got the replacement it worked like a charm.  Their customer service was so
+great that I'd still recommend the Doxie even though my first one was a dud.
+
+Scanning on the Go
+------------------
+
+As I mentioned before, I want to be able to scan things while out and about with my
+iPhone. There are a bunch of iPhone document-scanning apps out there. I settled on
+[JotNot][] for $7 because it has a decent UI and supports multiple-page PDFs.
+
+JotNot's UI is pretty easy to get the hang of so I won't go over it here.
+
+Once I finish scanning something I send the PDF to a [Dropbox][] folder called
+"JotNot". 
+
+I know I said in my requirements that "cloud" services weren't allowed, but I make an
+exception for non-critical things that I'd be scanning with my phone. I don't care if
+Dropbox knows how much I spent on dinner.
+
+[JotNot]: http://itunes.apple.com/us/app/jotnot-scanner-pro/id307868751?mt=8
+[Dropbox]: http://www.dropbox.com/
+
+OCR'ing Scanned Documents
+-------------------------
+
+The next step is to run the scanned PDFs through an OCR program so they can be
+searched with Spotlight.
+
+I looked at a lot of OCR software and finally settled on [PDF OCR X][] for $30. It
+has a simple interface, does a pretty good job at OCR'ing, has a free version so
+I could try it out, and is cross-platform.
+
+Using it is simple: you drag a PDF onto the app and select your desired settings
+(make sure to choose "searchable PDF" as the output format). The app will think for
+a while and then create a new PDF next to the old one with the searchable text
+embedded.
+
+Once you've done this once you should go into the preferences and change it to
+non-interactive mode so that it won't prompt you for the settings every time you use
+it.
+
+[PDF OCR X]: http://solutions.weblite.ca/pdfocrx/
+
+Gluing Everything Together
+--------------------------
+
+So far we've got two folders with scanned PDFs and a method for OCR'ing them. The
+next step is to automate the process.
+
+I use an app called [Hazel][] to do this. It's $21 for a license and well worth it.
+We'll set up four rules to make our lives easier.
+
+Before we start we need to create two folders somewhere (you can name them whatever
+you like):
+
+- Pending OCR: A folder to hold documents that are waiting to be OCR'ed.
+- Dead Trees: A folder to hold the final, OCR'ed versions of our documents.
+
+The first rule watches the Desktop for scans from Doxie.  Any files placed on the
+Desktop whose name starts with "Doxie Doc" will be renamed to include the current
+date and time, and then moved to the "Pending OCR" folder.
+
+![Rule 1 Screenshot](/media/images/blog/2011/05/rules-1-doxie.png "Rule 1")
+
+**Note:**: you'll need to click the `date created` bubble and then "Edit Date" to get
+the time as well as the date into the filename.
+
+The second rule watches the "JotNot" folder for scans from the iPhone app.  Any PDFs
+that appear in here (i.e. that are synced down from Dropbox) will be moved to the
+"Pending OCR" folder.  We don't need to rename them like we did with the Doxie scans
+because JotNot already includes the date and time of scans in the filenames by
+default.
+
+![Rule 2 Screenshot](/media/images/blog/2011/05/rules-2-jotnot.png "Rule 2")
+
+Now that we've got all of our scans going into the same folder (with unique names) we
+can set up a rule to OCR them.  The third rule watches the "Pending OCR" folder for
+PDFs.  When a PDF lands in the folder it will be moved to its final destination
+folder ("Dead Trees" in my case) and then opened in PDF OCR X.  Because I've put PDF
+OCR X in non-interactive mode the files will automatically be OCR'ed without any
+intervention from me.
+
+![Rule 3 Screenshot](/media/images/blog/2011/05/rules-3-ocr.png "Rule 3")
+
+The fourth and final rule watches for the OCR'ed copies of our scans and runs
+a script to move the originals to the trash once the searchable versions are ready.
+It doesn't delete the files completely because I want a safety net in case something
+goes wrong.
+
+![Rule 4 Screenshot](/media/images/blog/2011/05/rules-4-clean.png "Rule 4")
+
+**Note:** make sure you change the Shell to `/usr/bin/python`.  Here's the text of
+the script so you can copy and paste it:
+
+    import sys, os
+
+    RM_CMD = r"""osascript -e 'tell app "Finder" to move the POSIX file "%s" to trash'"""
+    old_file = sys.argv[1].rsplit('.', 2)[0]
+    if os.path.exists(old_file):
+        os.system(RM_CMD % os.path.abspath(old_file))
+
+Once these four rules are in place we can simply scan a document with Doxie or JotNot
+and it will automatically be OCR'ed and placed in our "Dead Trees" folder, with no
+intervention from us!
+
+[Hazel]: http://www.noodlesoft.com/hazel.php
+
+Backing Up
+----------
+
+A while ago I was using Mozy for full backups. Recently they changed their pricing so
+it was no longer unlimited. When that happened I switched to [Backblaze][] and
+couldn't be happier.
+
+Backblaze's UI is leaps and bounds above Mozy's, and they offer an option to generate
+a secure encryption key for encrypting your backups. I highly recommend this, but be
+sure to have a few copies of your key because you'll need it to restore your backups.
+
+Backblaze is also only $5 per month (less if you pay for a year in advance) for
+unlimited backups which is definitely a bargain.  As a bonus, they just released
+a ["find my computer" feature][find-computer] that's kind of like a lightweight
+version of [Undercover][], so it's an even better deal.
+
+[Backblaze]: http://www.backblaze.com/
+[Undercover]: http://www.orbicule.com/undercover/
+[find-computer]: http://blog.backblaze.com/2011/05/23/lost-your-computer-get-it-back-backblaze-launches-locate-my-computer/
+
+Destroying the Originals
+------------------------
+
+Once the documents are scanned and backed up it's time to destroy the physical paper.
+If you live in a rural area you could burn them for free.
+
+Those of us that can't start random fires need a paper shredder. I use a shredder
+I picked up a long time ago — any crosscut shredder will do the job.
+
+Summary
+-------
+
+After all of this I've now got a mostly-automated system that lets me go paper-free.
+The costs are:
+
+- Doxie Scanner: $160
+- JotNot: $7
+- PDF OCR X: $30
+- Hazel: $21
+- Backblaze: $5 per month
+
+For me the $218 initial cost is worth it.  Now I can search all of my paper in
+a instant and my apartment is much less cluttered. If you have the money to spare I'd
+definitely consider trying it.
+
--- a/content/blog/2011/06/django-advice.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1064 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Django Advice"
-        snip: "Some useful things I've learned."
-        created: 2011-06-30 08:30:00
-    %}
-
-    {% block article %}
-
-For the past year and a half or so I've been working full-time at [Dumbwaiter
-Design][] doing [Django][] development. I've picked up a bunch of useful tricks along
-the way that help me work, and I figured I'd share them.
-
-I'm sure there are better ways to do some of the things that I mention.  If you know
-of any feel free to hit me up on [Twitter][] and let me know.
-
-Also: this entry was written over several months, so if there are inconsistencies let
-me know and I'll try to fix them.
-
-[Dumbwaiter Design]: http://dwaiter.com/
-[Django]: {{links.django}}
-[Twitter]: http://twitter.com/stevelosh
-
-[TOC]
-
-Vagrant
--------
-
-I used to develop Django sites by running them on my OS X laptop locally and
-deploying to a Linode VPS.  I had a whole section of this post written up about
-tricks and tips for working with that setup.
-
-Then I found [Vagrant][].
-
-I just deleted the entire section of this post I wrote.
-
-Vagrant gives you a better way of working.  You need to use it.
-
-[Vagrant]: http://vagrantup.com/
-
-### Why Vagrant?
-
-If you haven't used it before, Vagrant is basically a tool for managing
-[VirtualBox][] VMs.  It makes it easy to start, pause, and resume VMs.  Instead of
-installing Django in a virtualenv and developing against that, you run a VM which
-runs your site and develop against that.
-
-This may not sound like much, but it's kind of a big deal.  The critical difference
-is that you can now develop against the same setup that you'll be using in
-production.
-
-This cuts out a huge amount of pain that stems from OS differences.  Here are a few
-examples off the top of my head:
-
-* URLField and MacPorts Python 2.5 on OS X.  There's a [bug][] where using
-  verify\_exists will crash your site every time you save a model, unless you set
-  a particular environment variable with no debug information.  Yeah, I spent
-  a couple of hours tracking that one down at work.  Awesome.
-* Installing PIL on OS X is no picnic.  [homebrew][] makes things better, if you use it,
-  so this one isn't a huge deal.
-* Every time you update Python in-place on your local machines, ALL of your
-  virtualenvs break because the Python binaries inside are linked against global
-  Python library files.  Have fun recreating them.  I hope you froze your
-  `requirements.txt` files before you updated.
-
-Using Vagrant and VMs means you can just worry about ONE operating system and its
-quirks.  It saves you a ton of time.
-
-Aside from that, there's another benefit to using Vagrant: it strongly encourages you
-to learn and use an automated provisioning system.  Support for Puppet and Chef is
-built in.  I chose Puppet, but if you prefer Chef that's cool too.
-
-You can also use other tools like Fabric or some simple scripts, but I'd strongly
-recommend giving Puppet or Chef a fair shot.  It's a lot to learn, but they're both
-widely tested and very powerful.
-
-Because you're developing against a VM and deploying to a VM, you can reuse 90% of
-the provisioning code across the two.
-
-When I make a new site, I do the following to initialize a new Vagrant VM:
-
-1. `vagrant up` (which runs Puppet to initialize the VM)
-2. `fab dev bootstrap`
-
-When I'm ready to go live, I do the following:
-
-1. Buy a Linode VPS.
-2. Run Puppet to initialize the VPS.
-3. Enter the Linode info in my fabfile.
-4. `fab prod bootstrap`
-
-No more screwing around with different paths, different versions of Nginx, different
-versions of Python.  When I'm developing something I can be pretty confident it will
-"just work" in production without any major surprises.
-
-[VirtualBox]: http://www.virtualbox.org/
-[bug]: https://trac.macports.org/ticket/24421
-[homebrew]: http://mxcl.github.com/homebrew/
-
-### Using Fabric to Stay Fast and Automate Everything
-
-One of the problems with this setup is that I can't just run `python manage.py
-whatever` any more because I need it to run on the VM.
-
-To get around this I've created many simple [Fabric][] tasks to automate the common
-things I need to do.  Fabric is an awesome little Python utility for scripting tasks
-(like deployments).  We use it constantly at Dumbwaiter.  Here are a few examples
-from our fabfiles.
-
-[Fabric]: http://fabfile.org/
-
-This first set is for running abitrary commands easily.
-
-`cmd` and `vcmd` will `cd` into the site directory on the VM and run a command of my
-choosing.  `vcmd` will prefix the command with the path to the virtualenv's `bin`
-directory, so I can do something like `fab dev vcmd`, `pip install markdown`.
-
-The `sdo` commands do the same thing, but `sudo`'ed.
-
-    :::python
-    def cmd(cmd=""):
-        '''Run a command in the site directory.  Usable from other commands or the CLI.'''
-        require('site_path')
-
-
-        if not cmd:
-            sys.stdout.write(_cyan("Command to run: "))
-            cmd = raw_input().strip()
-
-        if cmd:
-            with cd(env.site_path):
-                run(cmd)
-
-    def sdo(cmd=""):
-        '''Sudo a command in the site directory.  Usable from other commands or the CLI.'''
-        require('site_path')
-
-        if not cmd:
-            sys.stdout.write(_cyan("Command to run: sudo "))
-            cmd = raw_input().strip()
-
-        if cmd:
-            with cd(env.site_path):
-                sudo(cmd)
-
-    def vcmd(cmd=""):
-        '''Run a virtualenv-based command in the site directory.  Usable from other commands or the CLI.'''
-        require('site_path')
-        require('venv_path')
-
-        if not cmd:
-            sys.stdout.write(_cyan("Command to run: %s/bin/" % env.venv_path.rstrip('/')))
-            cmd = raw_input().strip()
-
-        if cmd:
-            with cd(env.site_path):
-                run(env.venv_path.rstrip('/') + '/bin/' + cmd)
-
-    def vsdo(cmd=""):
-        '''Sudo a virtualenv-based command in the site directory.  Usable from other commands or the CLI.'''
-        require('site_path')
-        require('venv_path')
-
-        if not cmd:
-            sys.stdout.write(_cyan("Command to run: sudo %s/bin/" % env.venv_path.rstrip('/')))
-            cmd = raw_input().strip()
-
-        if cmd:
-            with cd(env.site_path):
-                sudo(env.venv_path.rstrip('/') + '/bin/' + cmd)
-
-This next set is just some common commands that I need to run often.
-
-    :::python
-    def syncdb():
-        '''Run syncdb.'''
-        require('site_path')
-        require('venv_path')
-
-        with cd(env.site_path):
-            run(_python('manage.py syncdb --noinput'))
-
-    def collectstatic():
-        '''Collect static media.'''
-        require('site_path')
-        require('venv_path')
-
-        with cd(env.site_path):
-            sudo(_python('manage.py collectstatic --noinput'))
-
-    def rebuild_index():
-        '''Rebuild the search index.'''
-        require('site_path')
-        require('venv_path')
-        require('process_owner')
-
-        with cd(env.site_path):
-            sudo(_python('manage.py rebuild_index'))
-            sudo('chown -R %s .xapian' % env.process_owner)
-
-    def update_index():
-        '''Update the search index.'''
-        require('site_path')
-        require('venv_path')
-        require('process_owner')
-
-        with cd(env.site_path):
-            sudo(_python('manage.py update_index'))
-            sudo('chown -R %s .xapian' % env.process_owner)
-
-We also use Fabric to automate some of the more complex things we need to do.
-
-This task `curl`'s the site's home page to make sure we haven't completely borked
-things.  We use it in lots of other tasks as a sanity check.
-
-    :::python
-    def check():
-        '''Check that the home page of the site returns an HTTP 200.'''
-        require('site_url')
-
-        print('Checking site status...')
-
-        if not '200 OK' in local('curl --silent -I "%s"' % env.site_url, capture=True):
-            _sad()
-        else:
-            _happy()
-
-The `_happy` and `_sad` functions just print out some simple messages to get our
-attention:
-
-    :::python
-    from fabric.colors import red, green
-
-    def _happy():
-        print(green('\nLooks good from here!\n'))
-
-    def _sad():
-        print(red(r'''
-              ___           ___
-             /  /\         /__/\
-            /  /::\        \  \:\
-           /  /:/\:\        \__\:\
-          /  /:/  \:\   ___ /  /::\
-         /__/:/ \__\:\ /__/\  /:/\:\
-         \  \:\ /  /:/ \  \:\/:/__\/
-          \  \:\  /:/   \  \::/
-           \  \:\/:/     \  \:\
-            \  \::/       \  \:\
-             \__\/         \__\/
-              ___           ___           ___           ___
-             /__/\         /  /\         /  /\         /  /\     ___
-             \  \:\       /  /::\       /  /:/_       /  /:/_   /__/\
-              \  \:\     /  /:/\:\     /  /:/ /\     /  /:/ /\  \  \:\
-          _____\__\:\   /  /:/  \:\   /  /:/ /:/_   /  /:/ /::\  \  \:\
-         /__/::::::::\ /__/:/ \__\:\ /__/:/ /:/ /\ /__/:/ /:/\:\  \  \:\
-         \  \:\~~\~~\/ \  \:\ /  /:/ \  \:\/:/ /:/ \  \:\/:/~/:/   \  \:\
-          \  \:\  ~~~   \  \:\  /:/   \  \::/ /:/   \  \::/ /:/     \__\/
-           \  \:\        \  \:\/:/     \  \:\/:/     \__\/ /:/          __
-            \  \:\        \  \::/       \  \::/        /__/:/          /__/\
-             \__\/         \__\/         \__\/         \__\/           \__\/
-
-
-             Something seems to have gone wrong!
-             You should probably take a look at that.
-        '''))
-
-This one is for when `python manage.py reset APP` is broken because you've changed
-some `db_column` names and Django chokes because of some constraits and you just want
-to **reset the fucking app**.
-
-It's the "NUKE IT FROM ORBIT!!" option.
-
-    :::python
-    def KILL_IT_WITH_FIRE(app):
-        require('site_path')
-        require('venv_path')
-
-        with cd(env.site_path):
-            # Generate and download the reset SQL.
-            sudo(_python('manage.py sqlreset %s > reset.orig.sql' % app))
-            get('reset.orig.sql')
-
-            with open('reset.sql', 'w') as f:
-                with open('reset.orig.sql') as orig:
-                    # Step through the first chunk of the file (the "drop" part).
-                    line = orig.readline()
-                    while not line.startswith('CREATE'):
-                        if 'CONSTRAINT' in line:
-                            # Don't write out CONSTRAINT lines.
-                            # They're a problem when you change db_colum names.
-                            pass
-                        elif 'DROP TABLE' in line:
-                            # Cascade drops.
-                            # Hence with "with fire" part of this task's name.
-                            line = line[:-2] + ' CASCADE;\n'
-                            f.write(line)
-                        else:
-                            # Write other lines through untoched.
-                            f.write(line)
-                        line = orig.readline()
-
-                    # Write out the rest of the file untouched.
-                    f.write(line)
-                    f.write(orig.read())
-
-        # Upload the processed SQL file.
-        put('reset.sql', os.path.join(env.site_path, 'reset.ready.sql'), use_sudo=True)
-
-        with cd(env.site_path):
-            # Use the SQL to reset the app, and fake a migration.
-            run(_python('manage.py dbshell < reset.ready.sql'))
-            sudo(_python('manage.py migrate --fake --delete-ghost-migrations ' + app))
-
-This task uses Mercurial's local tags to add a `production` or `staging` tag in your local
-repository, so you can easy see where the production/staging servers are at
-compared to your local repo.
-
-    :::python
-    def retag():
-        '''Check which revision the site is at and update the local tag.
-
-        Useful if someone else has deployed (which makes your production/staging local
-        tag incorrect.
-        '''
-        require('site_path', provided_by=['prod', 'stag'])
-        require('env_name', provided_by=['prod', 'stag'])
-
-        with cd(env.site_path):
-            current = run('hg id --rev . --quiet').strip(' \n+')
-
-        local('hg tag --local --force %s --rev %s' % (env.env_name, current))
-
-This task tails the Gunicorn logs on the server so you can quickly find out what's
-happening when things blow up.
-
-    :::python
-    def tailgun(follow=''):
-        """Tail the Gunicorn log file."""
-        require('site_path')
-
-        with cd(env.site_path):
-            if follow:
-                run('tail -f .gunicorn.log')
-            else:
-                run('tail .gunicorn.log')
-
-We've got a lot of other tasks but they're pretty specific to our setup.
-
-Wrangling Databases with South
-------------------------------
-
-If you're not using [South][], you need to start.  Now.
-
-No, really, I'll wait.  Take 30 minutes, try the [tutorial][Southtut], wrap your head
-around it and come back.  It's far more important than this blog post.
-
-[South]: http://south.aeracode.org/
-[Southtut]: http://south.aeracode.org/docs/tutorial/index.html
-
-### Useful Fabric Tasks
-
-South is awesome but its commands are very long-winded.  Here's the set of fabric
-tasks I use to save quite a bit of typing:
-
-    :::python
-    def migrate(args=''):
-        '''Run any needed migrations.'''
-        require('site_path')
-        require('venv_path')
-
-        with cd(env.site_path):
-            sudo(_python('manage.py migrate ' + args))
-
-    def migrate_fake(args=''):
-        '''Run any needed migrations with --fake.'''
-        require('site_path')
-        require('venv_path')
-
-        with cd(env.site_path):
-            sudo(_python('manage.py migrate --fake ' + args))
-
-    def migrate_reset(args=''):
-        '''Run any needed migrations with --fake.  No, seriously.'''
-        require('site_path')
-        require('venv_path')
-
-        with cd(env.site_path):
-            sudo(_python('manage.py migrate --fake --delete-ghost-migrations ' + args))
-
-Remember that running a migration without specifying an app will migrate everything,
-so a simple `fab dev migrate` will do the trick.
-
-Watching for Changes
----------------------
-
-When developing locally you'll want to make a change to your code and have the server
-reload that code automatically.  The Django development server does this, and we can
-hack it into our Vagrant/Gunicorn setup too.
-
-First, add a `monitor.py` file at the root of your project (I believe I found this
-code [here][monitor], but I may be wrong):
-
-    :::python
-    import os
-    import sys
-    import time
-    import signal
-    import threading
-    import atexit
-    import Queue
-
-    _interval = 1.0
-    _times = {}
-    _files = []
-
-    _running = False
-    _queue = Queue.Queue()
-    _lock = threading.Lock()
-
-    def _restart(path):
-        _queue.put(True)
-        prefix = 'monitor (pid=%d):' % os.getpid()
-        print >> sys.stderr, '%s Change detected to \'%s\'.' % (prefix, path)
-        print >> sys.stderr, '%s Triggering process restart.' % prefix
-        os.kill(os.getpid(), signal.SIGINT)
-
-    def _modified(path):
-        try:
-            # If path doesn't denote a file and were previously
-            # tracking it, then it has been removed or the file type
-            # has changed so force a restart. If not previously
-            # tracking the file then we can ignore it as probably
-            # pseudo reference such as when file extracted from a
-            # collection of modules contained in a zip file.
-
-            if not os.path.isfile(path):
-                return path in _times
-
-            # Check for when file last modified.
-
-            mtime = os.stat(path).st_mtime
-            if path not in _times:
-                _times[path] = mtime
-
-            # Force restart when modification time has changed, even
-            # if time now older, as that could indicate older file
-            # has been restored.
-
-            if mtime != _times[path]:
-                return True
-        except:
-            # If any exception occured, likely that file has been
-            # been removed just before stat(), so force a restart.
-
-            return True
-
-        return False
-
-    def _monitor():
-        while 1:
-            # Check modification times on all files in sys.modules.
-
-            for module in sys.modules.values():
-                if not hasattr(module, '__file__'):
-                    continue
-                path = getattr(module, '__file__')
-                if not path:
-                    continue
-                if os.path.splitext(path)[1] in ['.pyc', '.pyo', '.pyd']:
-                    path = path[:-1]
-                if _modified(path):
-                    return _restart(path)
-
-            # Check modification times on files which have
-            # specifically been registered for monitoring.
-
-            for path in _files:
-                if _modified(path):
-                    return _restart(path)
-
-            # Go to sleep for specified interval.
-
-            try:
-                return _queue.get(timeout=_interval)
-            except:
-                pass
-
-    _thread = threading.Thread(target=_monitor)
-    _thread.setDaemon(True)
-
-    def _exiting():
-        try:
-            _queue.put(True)
-        except:
-            pass
-        _thread.join()
-
-    atexit.register(_exiting)
-
-    def track(path):
-        if not path in _files:
-            _files.append(path)
-
-    def start(interval=1.0):
-        global _interval
-        if interval < _interval:
-            _interval = interval
-
-        global _running
-        _lock.acquire()
-        if not _running:
-            prefix = 'monitor (pid=%d):' % os.getpid()
-            print >> sys.stderr, '%s Starting change monitor.' % prefix
-            _running = True
-            _thread.start()
-        _lock.release()
-
-Next add a `post_fork` hook to your Gunicorn config file that uses the monitor to
-watch for changes:
-
-    :::python
-    def post_fork(server, worker):
-        import monitor
-        import local_settings
-        if local_settings.DEBUG:
-            server.log.info("Starting change monitor.")
-            monitor.start(interval=1.0)
-
-Now the Gunicorn server will automatically restart whenever code is changed.  Use
-whatever method for determining debug status that you like.  We use
-`local_settings.py` files which all have `DEBUG` variables, so that works for us.
-
-It will *not* restart when you add new code (e.g. when you install a new app), so
-you'll need to handle that manually with `fab dev restart`, but that's not too bad!
-
-[monitor]: http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
-
-### Using the Werkzeug Debugger with Gunicorn
-
-The final piece of the puzzle is being able to use the fantastic [Werkzeug
-Debugger][debug] while running on the development VM with Gunicorn.
-
-To do this, create a `debug_wsgi.py` file at the root of your project:
-
-    :::python
-    import os
-    import sys
-    import site
-
-    parent = os.path.dirname
-    site_dir = parent(os.path.abspath(__file__))
-    project_dir = parent(parent(os.path.abspath(__file__)))
-
-    sys.path.insert(0, project_dir)
-    sys.path.insert(0, site_dir)
-
-    site.addsitedir('VIRTUALENV_SITE_PACKAGES')
-
-    from django.core.management import setup_environ
-    import settings
-    setup_environ(settings)
-
-    import django.core.handlers.wsgi
-    application = django.core.handlers.wsgi.WSGIHandler()
-
-    from werkzeug.debug import DebuggedApplication
-    application = DebuggedApplication(application, evalex=True)
-
-    def null_technical_500_response(request, exc_type, exc_value, tb):
-        raise exc_type, exc_value, tb
-    from django.views import debug
-    debug.technical_500_response = null_technical_500_response
-
-Have Gunicorn use this file to run your development server with `gunicorn
-debug_wsgi:application`.
-
-Make sure to replace `'VIRTUALENV_SITE_PACKAGES'` with the _full_ path to your
-virtualenv's `site_packages` directory.  You might want to make this a setting in
-a machine-specific settings file.
-
-[debug]: http://werkzeug.pocoo.org/docs/debug/
-
-### Pulling Uploads
-
-Once you give a client access to a site they'll probably be uploading images (through
-Django's built-in file uploading features or with [django-filebrowser][]).
-
-When you're making changes locally it's often useful to have these uploaded files on
-your local VM, otherwise you end up with a bunch of broken images.
-
-Here's a simple Fabric task that will pull down all the uploads from the server:
-
-    :::python
-    def pull_uploads():
-        '''Copy the uploads from the site to your local machine.'''
-        require('uploads_path')
-
-        sudo('chmod -R a+r "%s"' % env.uploads_path)
-
-        rsync_command = r"""rsync -av -e 'ssh -p %s' %s@%s:%s %s""" % (
-            env.port,
-            env.user, env.host,
-            env.uploads_path.rstrip('/') + '/',
-            'media/uploads'
-        )
-        print local(rsync_command, capture=False)
-
-You might be wondering about the line that strips `/` characters and then adds them
-back in.  `rsync` does different things depending on whether you end a path with
-a `/`, so this is actually pretty important.
-
-In your host task you'll need to set the `uploads_path` variable to something like
-this:
-
-    :::python
-    import os
-    env.site_path = os.path.join('var', 'www', 'myproject')
-    env.uploads_path = os.path.join(env.site_path, 'media', 'uploads')
-
-Now you can run `fab production pull_uploads` to pull down all the files people have
-uploaded to the production server.
-
-[django-filebrowser]: http://code.google.com/p/django-filebrowser/
-
-### Preventing Accidents
-
-Deploying to test and staging servers should be quick and easy. Deploying to
-production servers should be harder to prevent people from accidentally doing it.
-
-I've created a little function that I call before deploying to production servers.
-It forces me to type in random words from the system word list before proceeding to
-make sure I *really* know what I'm doing:
-
-    :::python
-    import os, random
-
-    from fabric.api import *
-    from fabric.operations import prompt
-    from fabric.utils import abort
-
-    WORDLIST_PATHS = [os.path.join('/', 'usr', 'share', 'dict', 'words')]
-    DEFAULT_MESSAGE = "Are you sure you want to do this?"
-    WORD_PROMPT = '  [%d/%d] Type "%s" to continue (^C quits): '
-
-    def prevent_horrible_accidents(msg=DEFAULT_MESSAGE, horror_rating=1):
-        """Prompt the user to enter random words to prevent doing something stupid."""
-
-        valid_wordlist_paths = [wp for wp in WORDLIST_PATHS if os.path.exists(wp)]
-
-        if not valid_wordlist_paths:
-            abort('No wordlists found!')
-
-        with open(valid_wordlist_paths[0]) as wordlist_file:
-            words = wordlist_file.readlines()
-
-        print msg
-
-        for i in range(int(horror_rating)):
-            word = words[random.randint(0, len(words))].strip()
-            p_msg = WORD_PROMPT % (i+1, horror_rating, word)
-            answer = prompt(p_msg, validate=r'^%s$' % word)
-
-You may need to adjust `WORDLIST_PATHS` if you're not on OS X.
-
-Working with Third-Party Apps
------------------------------
-
-One of the best parts about working with Django is that many problems have already
-been solved and the solutions have been released as open-source applications.
-
-We use quite a few open-source apps, and there are a couple of tricks I've learned to
-make working with them easier.
-
-### Installing Apps from Repositories
-
-If I'm going to use an open-source Django app in a project I'll almost always install
-it as an editable repository on the VM with `pip install -e`.
-
-Others may disagree with me on this, but I think it's the best way to work.
-
-Often I'll find a bug that I think may be in one of the third-party apps I'm using.
-Installing the apps as repositories makes it easy to read their source and figure out
-if the bug is really in the app.
-
-If the bug *is* in the third-party app having the app installed as a repository makes
-it simple to fix the bug, fork the project on BitBucket or GitHub, send a pull
-request, and get back to work.
-
-### Mirroring Repositories
-
-One problem we've run into at Dumbwaiter is that the repos for third-party apps we
-use are scattered across GitHub, BitBucket, Google Code, and other servers.  If any
-one of these services goes down we're stuck waiting for it to come back up.
-
-A while ago I took half a day and consolidated all of these repos onto one of the
-servers that we control.  The basic process went like this:
-
-* Use [hg-git][] and [hgsubversion][] to convert the git and SVN repos to Mercurial
-  repos.
-* Set up a master `mirror` Mercurial repo with all the app repos as subrepos.
-* Push the master repo and all the subrepos up to one of our Linodes.
-
-Now we can use `-e ssh://hg@OUR_LINODE/mirror/APP@REV_THAT_WORKS#egg=APP` in our
-`requirements.txt` files to install apps from our mirror.  When we want to update our
-dependencies we can simply pull from the upstream repos and commit in the mirror
-repo.
-
-If our mirror goes down it's not a big deal, because we have far bigger problems to
-worry about than new projects.
-
-I wrote a few scripts to automate updating apps and such, but they're extremely hacky
-so I don't want to post them here.  Take half a day and write your own set -- it's
-definitely worth it to have your own mirror of your specific dependencies.
-
-[hg-git]: http://hg-git.github.com/
-[hgsubversion]: https://bitbucket.org/durin42/hgsubversion/wiki/Home
-
-### Using BCVI to Edit Files
-
-I said that when I find a bug that I think is in a third-party app I'll poke around
-with the app and try to figure it out.  But since all the apps are installed in
-a virtualenv on the Vagrant VM it might seem like it's a pain in the ass to edit
-those files!
-
-Luckily [BCVI][] exists.  It's a utility that opens a "back channel" to your local
-machine when you SSH and lets you run `vi FILE` to open that file in
-Vim/MacVim/GVim/etc on your *local* machine.  When you save the file it uploads it
-back to the server automatically for you.
-
-It can be a bit tricky to set up, but it's worth it.  Trust me.
-
-[BCVI]: http://sshmenu.sourceforge.net/articles/bcvi/
-
-Improving the Admin Interface
------------------------------
-
-I'm going to be honest: Django's admin interface is the main reason I'm still using
-it.  Other frameworks like [Flask][] are great, but Django's admin saves me
-*ridiculous* amounts of time when I'm making simple CRUD sites for clients.
-
-That said, the Django admin isn't the prettiest thing around, but we can give it
-a facelift.
-
-[Flask]: http://flask.pocoo.org/
-
-### Enter Grappelli
-
-[Grappelli][] is a Django app that reskins the admin interface beautifully.  It also
-adds some functionality like drag-and-drop reordering of inlines, and allows you to
-customize the dashboard to your liking.  *Every* Django site I work on uses Grappelli
--- it's just that good.
-
-The downside of Grappelli is that it changes quite a lot and breaks backwards
-compatibility at the drop of a hat.
-
-If you're going to use Grappelli you *must* freeze your requirements.txt files and
-work with a single version at a time.  Trying to always work from the trunk will make
-you drink.
-
-[Grappelli]: http://django-grappelli.readthedocs.org/
-
-### An Ugly Hack to Show Usable Foreign Key Fields
-
-A limitation of both Grappelli and the stock Django admin is that it seems like you
-can't easily show fields from related models in the admin list view.
-
-For example, if you're new to Django you might expect this to work:
-
-    :::python
-    class BlogEntryAdmin(admin.ModelAdmin):
-        list_display = ('title', 'author__name')
-
-Unfortunately Django chokes on the `author__name` lookup.  You can *display* the name
-without too much fuss:
-
-    :::python
-    class BlogEntryAdmin(admin.ModelAdmin):
-        list_display = ('title', 'author_name')
-
-        def author_name(self, obj):
-            return obj.name
-
-That will display the name just fine.  However, it won't be a fully-fledged column in
-the Django admin because you can't sort on it.
-
-It may seem like this is the end -- if it could be a fully-functional field, why
-wouldn't Django just let you use `author__name`?  Luckily we can add one more line to
-fix the problem:
-
-    :::python
-    class BlogEntryAdmin(admin.ModelAdmin):
-        list_display = ('title', 'author_name')
-
-        def author_name(self, obj):
-            return obj.name
-        author_name.admin_order_field = 'author__name'
-
-Now the author name has all the functionality of a real `list_display` entry.
-
-Using Django-Annoying
----------------------
-
-If you haven't heard of [django-annoying][] you should definitely check it out.  It's
-got a bunch of miscellaneous functions that fix some common, annoying parts of
-Django.
-
-My two personal favorites from the package are a pair of decorators that help make
-your views much, much cleaner.
-
-[django-annoying]: https://bitbucket.org/offline/django-annoying/wiki/Home
-
-### The render\_to Decorator
-
-The decorator is called `render_to` and it eliminates the ugly `render_to_response`
-calls that Django normally forces you to use in every single view.
-
-Normally you'd use something like this:
-
-    :::python
-    def videos(request):
-        videos = Video.objects.all()
-        return render_to_response('video_list.html', { 'videos': videos },
-                                  context_instance=RequestContext(request))
-
-With `render_to` your view gets much cleaner:
-
-    :::python
-    @render_to('video_list.html')
-    def videos(request):
-        videos = Video.objects.all()
-        return { 'videos': videos }
-
-Less typing `context_instance=...` over and over, and less syntax to remember.
-
-Yes, I know about Django 1.3's `render` shortcut.  You have to type `request` every
-single time with `render`, so the `render_to` decorator still wins.
-
-### The ajax\_request Decorator
-
-The `ajax_request` decorator is like `render_to` for AJAX requests.  You simply
-return a Python dictionary from your view and the decorator handles the JSON encoding
-and such:
-
-    :::python
-    @ajax_request
-    def ajax_get_entries(request):
-        blog_entries = BlogEntry.objects.all()
-        return { 'entries': [(entry.title, entry.get_absolute_url())
-                             for entry in entries]}
-
-Templating Tricks
------------------
-
-I'm not a frontend developer, but I've done my share of HTML hacking at Dumbwaiter.
-Here are a few of the tricks I've learned.
-
-### Null Checks and Fallbacks
-
-A common pattern I see in Django templates looks like this:
-
-    :::django
-    {% templatetag openblock %} if business.title {% templatetag closeblock %}
-        {% templatetag openvariable %} business.title {% templatetag closevariable %}
-    {% templatetag openblock %} else {% templatetag closeblock %}
-        {% templatetag openvariable %} business.short_title {% templatetag closevariable %}
-    {% templatetag openblock %} endif {% templatetag closeblock %}
-
-Here's a simpler way to do that:
-
-    :::django
-    {% templatetag openblock %} firstof business.title business.short_title {% templatetag closeblock %}
-
-`firstof` will return the first non-Falsy item in its arguments.
-
-### Manipulating Query Strings
-
-Query strings are normally not a big deal, but every once in a while you'll have
-a model listing page where you need to filter by category, and number of spaces, and
-tags, etc all at once.
-
-If you're trying to manage GET queries manually it can get pretty hairy very fast.
-
-[This Django snippet][qstring] makes working with query strings in templates
-a breeze.
-
-[qstring]: http://djangosnippets.org/snippets/2237/
-
-### Satisfying Your Designer with Typogrify
-
-If you haven't heard of [Typogrify][] you should take a look at it.  It makes it easy
-to add all the typographic goodness your designers are looking for.
-
-[Typogrify]: http://code.google.com/p/typogrify/
-
-The Flat Page Trainwreck
-------------------------
-
-Creating a site for a client is very different than creating a site for yourself.
-For pretty much every client we've dealt with we've heard: "can't we just create
-a new page at /drink-special/ for this special deal we're running?"
-
-Having clients go through you to make new pages is simply too much overhead.  We
-needed a way to let clients create new pages (like `/drink-special/`) on the fly,
-without our intervention.
-
-Django has a "flatpages" app that solves this problem.  Kind of.
-
-When using flat pages clients need to do two things that are often too much for
-non-technical people:
-
-* Manage URLs manually.
-* Write all content as raw HTML in a single text field.
-
-We've tried a lot of Django CMS apps at Dumbwaiter, and none of them made us happy.
-They all seemed to have some or all of the following problems:
-
-* They take over your site and make you write a "Django-WhateverCMS site" instead of
-  a "Django site".
-* They're extremely feature-rich and complicated with features like
-  internationalization, redirects, versions, and many others.  This is great if you
-  need the flexibility, but bad if your clients just need to create a couple of
-  pages.
-* They break `APPEND_TRAILING_SLASH` and make you clutter your `urls.py` files with
-  a bunch of extra code ot handle this.
-
-I finally got fed up and wrote my own Django CMS app: [Stoat][].  Stoat is designed
-to be sleek, with only the features that our clients need.
-
-It's not officially version 1.0 yet, but we're using it for a few clients and it's
-working well.  Check it out if you're looking for a more lightweight CMS app.
-
-[Stoat]: http://stoat.rtfd.org/
-
-Editing with Vim
-----------------
-
-I [use Vim][vimpost] to edit everything.  Naturally I've found a bunch of plugins,
-mappings and other tricks that make it even better when working on Django projects.
-
-[vimpost]: /blog/2010/09/coming-home-to-vim/
-
-### Vim for Django
-
-There are a lot of ways to make Vim work with Django.  I won't go into all of them in
-this post, but a good place to start is [this Django wiki page][vimdjango].
-
-[vimdjango]: https://code.djangoproject.com/wiki/UsingVimWithDjango
-
-### Filetype Mappings
-
-Most files in a Django project have one of two extensions: `.py` and `.html`.
-Unfortunately these extensions aren't unique to Django, so Vim doesn't automatically
-set the correct `filetype` when you open one.
-
-I've added a few mappings to my `.vimrc` to make it quick and easy to set the correct
-`filetype`:
-
-    :::vim
-    nnoremap _dt :set ft=htmldjango<CR>
-    nnoremap _pd :set ft=python.django<CR>
-
-I also have a few autocommands that set the filetype for me when I'm editing a file
-whose name "sounds like" a Django file:
-
-    :::vim
-    au BufNewFile,BufRead admin.py     setlocal filetype=python.django
-    au BufNewFile,BufRead urls.py      setlocal filetype=python.django
-    au BufNewFile,BufRead models.py    setlocal filetype=python.django
-    au BufNewFile,BufRead views.py     setlocal filetype=python.django
-    au BufNewFile,BufRead settings.py  setlocal filetype=python.django
-    au BufNewFile,BufRead forms.py     setlocal filetype=python.django
-
-### Python Sanity Checking
-
-Lets be honest here: it takes a lot of work to turn Vim into an "IDE", and even then
-it doesn't reach the level of something like Eclipse for Java.  Anyone who claims it
-has the same levels of integration and functionality is simply lying.
-
-With that said I'll make an opinionated statement that is going to piss some of you
-off.
-
-**I am a programmer, not an IDE operator.**
-
-I know Python.
-
-I know Django.
-
-I don't need to hit Cmd+Space twice for every line of code I write.
-
-When someone asks me "how do you run your site" I do **not** answer: "click the green
-triangle in Eclipse".
-
-However, I am human.  I do stupid things like forgetting a colon or forgetting an
-import.  To help me with those problems I've turned to [Syntastic][] and Kevin
-Watters' [Pyflakes fork][] for Vim.
-
-Syntastic is a Vim plugin that adds on-the-fly syntax-checking for many different
-file formats.  If you have Pyflakes installed it will automatically show you errors
-in your code.
-
-Pyflakes doesn't have IDE-level integration with your code.  It doesn't check that
-whatever libraries you `import` actually exist.  It simply checks that your files are
-probably-valid Python, and tells you when they're not.
-
-This is enough for me.  It catches the stupid mistakes I make.  The less-stupid,
-more-subtle mistakes slip by it, but to be fair many of them would have slipped by an
-"IDE" as well.
-
-[Pyflakes fork]: https://github.com/kevinw/pyflakes
-[Syntastic]: http://www.vim.org/scripts/script.php?script_id=2736
-
-### Javascript Sanity Checking and Folding
-
-Syntastic also supports Javascript if you have Javascript Lint installed (`brew
-install jsl` on OS X).  It's not perfect but it *will* catch things like using
-trailing commas in object literals.
-
-Some people like using CTags to get an overview of their code.  I take a more
-low-tech approach and am in love with code folding.  When I fold my code
-I automatically get an overview of everything in each file.
-
-By default Vim doesn't fold Javascript files, but you can add some basic, perfectly
-serviceable folding with these two lines in your .vimrc:
-
-    :::vim
-    au FileType javascript setlocal foldmethod=marker
-    au FileType javascript setlocal foldmarker={,}
-
-
-### Django Autocommands
-
-I *rarely* work with raw HTML files any more.  Whenever I open a file ending in
-`.html` it's almost always a Django template (or a [Jinja][] template, which has
-a very similar syntax).  I've added an autocommand to automatically set the correct
-filetype whenever I open a `.html` file:
-
-[Jinja]: http://jinja.pocoo.org/
-
-    :::vim
-    au BufNewFile,BufRead *.html setlocal filetype=htmldjango
-
-I also have some autocommands that tweak how a few specific files are handled:
-
-    :::vim
-    au BufNewFile,BufRead urls.py      setlocal nowrap
-    au BufNewFile,BufRead settings.py  normal! zR
-    au BufNewFile,BufRead dashboard.py normal! zR
-
-This automatically unfolds `urls.py`, `dashboard.py` and `settings.py` (I prefer
-seeing those unfolded) and unsets line wrapping for `urls.py` (lines in a `urls.py`
-file can get long and are hard to read when wrapped).
-
-Conclusion
-----------
-
-I hope that this longer-than-expected blog entry has given you at least one or two
-things to think about.
-
-I've learned a lot while working with Django for Dumbwaiter every day, but I'm sure
-there's still a lot I've missed.  If you see something I could be doing better please
-let me know!
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2011/06/django-advice.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,1088 @@
++++
+title = "Django Advice"
+snip = "Some useful things I've learned."
+date = 2011-06-30T08:30:00Z
+draft = false
+
++++
+
+For the past year and a half or so I've been working full-time at [Dumbwaiter
+Design][] doing [Django][] development. I've picked up a bunch of useful tricks along
+the way that help me work, and I figured I'd share them.
+
+I'm sure there are better ways to do some of the things that I mention.  If you know
+of any feel free to hit me up on [Twitter][] and let me know.
+
+Also: this entry was written over several months, so if there are inconsistencies let
+me know and I'll try to fix them.
+
+[Dumbwaiter Design]: http://dwaiter.com/
+[Django]: {{links.django}}
+[Twitter]: http://twitter.com/stevelosh
+
+{{% toc %}}
+
+Vagrant
+-------
+
+I used to develop Django sites by running them on my OS X laptop locally and
+deploying to a Linode VPS.  I had a whole section of this post written up about
+tricks and tips for working with that setup.
+
+Then I found [Vagrant][].
+
+I just deleted the entire section of this post I wrote.
+
+Vagrant gives you a better way of working.  You need to use it.
+
+[Vagrant]: http://vagrantup.com/
+
+### Why Vagrant?
+
+If you haven't used it before, Vagrant is basically a tool for managing
+[VirtualBox][] VMs.  It makes it easy to start, pause, and resume VMs.  Instead of
+installing Django in a virtualenv and developing against that, you run a VM which
+runs your site and develop against that.
+
+This may not sound like much, but it's kind of a big deal.  The critical difference
+is that you can now develop against the same setup that you'll be using in
+production.
+
+This cuts out a huge amount of pain that stems from OS differences.  Here are a few
+examples off the top of my head:
+
+* URLField and MacPorts Python 2.5 on OS X.  There's a [bug][] where using
+  verify\_exists will crash your site every time you save a model, unless you set
+  a particular environment variable with no debug information.  Yeah, I spent
+  a couple of hours tracking that one down at work.  Awesome.
+* Installing PIL on OS X is no picnic.  [homebrew][] makes things better, if you use it,
+  so this one isn't a huge deal.
+* Every time you update Python in-place on your local machines, ALL of your
+  virtualenvs break because the Python binaries inside are linked against global
+  Python library files.  Have fun recreating them.  I hope you froze your
+  `requirements.txt` files before you updated.
+
+Using Vagrant and VMs means you can just worry about ONE operating system and its
+quirks.  It saves you a ton of time.
+
+Aside from that, there's another benefit to using Vagrant: it strongly encourages you
+to learn and use an automated provisioning system.  Support for Puppet and Chef is
+built in.  I chose Puppet, but if you prefer Chef that's cool too.
+
+You can also use other tools like Fabric or some simple scripts, but I'd strongly
+recommend giving Puppet or Chef a fair shot.  It's a lot to learn, but they're both
+widely tested and very powerful.
+
+Because you're developing against a VM and deploying to a VM, you can reuse 90% of
+the provisioning code across the two.
+
+When I make a new site, I do the following to initialize a new Vagrant VM:
+
+1. `vagrant up` (which runs Puppet to initialize the VM)
+2. `fab dev bootstrap`
+
+When I'm ready to go live, I do the following:
+
+1. Buy a Linode VPS.
+2. Run Puppet to initialize the VPS.
+3. Enter the Linode info in my fabfile.
+4. `fab prod bootstrap`
+
+No more screwing around with different paths, different versions of Nginx, different
+versions of Python.  When I'm developing something I can be pretty confident it will
+"just work" in production without any major surprises.
+
+[VirtualBox]: http://www.virtualbox.org/
+[bug]: https://trac.macports.org/ticket/24421
+[homebrew]: http://mxcl.github.com/homebrew/
+
+### Using Fabric to Stay Fast and Automate Everything
+
+One of the problems with this setup is that I can't just run `python manage.py
+whatever` any more because I need it to run on the VM.
+
+To get around this I've created many simple [Fabric][] tasks to automate the common
+things I need to do.  Fabric is an awesome little Python utility for scripting tasks
+(like deployments).  We use it constantly at Dumbwaiter.  Here are a few examples
+from our fabfiles.
+
+[Fabric]: http://fabfile.org/
+
+This first set is for running abitrary commands easily.
+
+`cmd` and `vcmd` will `cd` into the site directory on the VM and run a command of my
+choosing.  `vcmd` will prefix the command with the path to the virtualenv's `bin`
+directory, so I can do something like `fab dev vcmd`, `pip install markdown`.
+
+The `sdo` commands do the same thing, but `sudo`'ed.
+
+```python
+def cmd(cmd=""):
+    '''Run a command in the site directory.  Usable from other commands or the CLI.'''
+    require('site_path')
+
+
+    if not cmd:
+        sys.stdout.write(_cyan("Command to run: "))
+        cmd = raw_input().strip()
+
+    if cmd:
+        with cd(env.site_path):
+            run(cmd)
+
+def sdo(cmd=""):
+    '''Sudo a command in the site directory.  Usable from other commands or the CLI.'''
+    require('site_path')
+
+    if not cmd:
+        sys.stdout.write(_cyan("Command to run: sudo "))
+        cmd = raw_input().strip()
+
+    if cmd:
+        with cd(env.site_path):
+            sudo(cmd)
+
+def vcmd(cmd=""):
+    '''Run a virtualenv-based command in the site directory.  Usable from other commands or the CLI.'''
+    require('site_path')
+    require('venv_path')
+
+    if not cmd:
+        sys.stdout.write(_cyan("Command to run: %s/bin/" % env.venv_path.rstrip('/')))
+        cmd = raw_input().strip()
+
+    if cmd:
+        with cd(env.site_path):
+            run(env.venv_path.rstrip('/') + '/bin/' + cmd)
+
+def vsdo(cmd=""):
+    '''Sudo a virtualenv-based command in the site directory.  Usable from other commands or the CLI.'''
+    require('site_path')
+    require('venv_path')
+
+    if not cmd:
+        sys.stdout.write(_cyan("Command to run: sudo %s/bin/" % env.venv_path.rstrip('/')))
+        cmd = raw_input().strip()
+
+    if cmd:
+        with cd(env.site_path):
+            sudo(env.venv_path.rstrip('/') + '/bin/' + cmd)
+```
+
+This next set is just some common commands that I need to run often.
+
+```python
+def syncdb():
+    '''Run syncdb.'''
+    require('site_path')
+    require('venv_path')
+
+    with cd(env.site_path):
+        run(_python('manage.py syncdb --noinput'))
+
+def collectstatic():
+    '''Collect static media.'''
+    require('site_path')
+    require('venv_path')
+
+    with cd(env.site_path):
+        sudo(_python('manage.py collectstatic --noinput'))
+
+def rebuild_index():
+    '''Rebuild the search index.'''
+    require('site_path')
+    require('venv_path')
+    require('process_owner')
+
+    with cd(env.site_path):
+        sudo(_python('manage.py rebuild_index'))
+        sudo('chown -R %s .xapian' % env.process_owner)
+
+def update_index():
+    '''Update the search index.'''
+    require('site_path')
+    require('venv_path')
+    require('process_owner')
+
+    with cd(env.site_path):
+        sudo(_python('manage.py update_index'))
+        sudo('chown -R %s .xapian' % env.process_owner)
+```
+
+We also use Fabric to automate some of the more complex things we need to do.
+
+This task `curl`'s the site's home page to make sure we haven't completely borked
+things.  We use it in lots of other tasks as a sanity check.
+
+```python
+def check():
+    '''Check that the home page of the site returns an HTTP 200.'''
+    require('site_url')
+
+    print('Checking site status...')
+
+    if not '200 OK' in local('curl --silent -I "%s"' % env.site_url, capture=True):
+        _sad()
+    else:
+        _happy()
+```
+
+The `_happy` and `_sad` functions just print out some simple messages to get our
+attention:
+
+```python
+from fabric.colors import red, green
+
+def _happy():
+    print(green('\nLooks good from here!\n'))
+
+def _sad():
+    print(red(r'''
+          ___           ___
+         /  /\         /__/\
+        /  /::\        \  \:\
+       /  /:/\:\        \__\:\
+      /  /:/  \:\   ___ /  /::\
+     /__/:/ \__\:\ /__/\  /:/\:\
+     \  \:\ /  /:/ \  \:\/:/__\/
+      \  \:\  /:/   \  \::/
+       \  \:\/:/     \  \:\
+        \  \::/       \  \:\
+         \__\/         \__\/
+          ___           ___           ___           ___
+         /__/\         /  /\         /  /\         /  /\     ___
+         \  \:\       /  /::\       /  /:/_       /  /:/_   /__/\
+          \  \:\     /  /:/\:\     /  /:/ /\     /  /:/ /\  \  \:\
+      _____\__\:\   /  /:/  \:\   /  /:/ /:/_   /  /:/ /::\  \  \:\
+     /__/::::::::\ /__/:/ \__\:\ /__/:/ /:/ /\ /__/:/ /:/\:\  \  \:\
+     \  \:\~~\~~\/ \  \:\ /  /:/ \  \:\/:/ /:/ \  \:\/:/~/:/   \  \:\
+      \  \:\  ~~~   \  \:\  /:/   \  \::/ /:/   \  \::/ /:/     \__\/
+       \  \:\        \  \:\/:/     \  \:\/:/     \__\/ /:/          __
+        \  \:\        \  \::/       \  \::/        /__/:/          /__/\
+         \__\/         \__\/         \__\/         \__\/           \__\/
+
+
+         Something seems to have gone wrong!
+         You should probably take a look at that.
+    '''))
+```
+
+This one is for when `python manage.py reset APP` is broken because you've changed
+some `db_column` names and Django chokes because of some constraits and you just want
+to **reset the fucking app**.
+
+It's the "NUKE IT FROM ORBIT!!" option.
+
+```python
+def KILL_IT_WITH_FIRE(app):
+    require('site_path')
+    require('venv_path')
+
+    with cd(env.site_path):
+        # Generate and download the reset SQL.
+        sudo(_python('manage.py sqlreset %s > reset.orig.sql' % app))
+        get('reset.orig.sql')
+
+        with open('reset.sql', 'w') as f:
+            with open('reset.orig.sql') as orig:
+                # Step through the first chunk of the file (the "drop" part).
+                line = orig.readline()
+                while not line.startswith('CREATE'):
+                    if 'CONSTRAINT' in line:
+                        # Don't write out CONSTRAINT lines.
+                        # They're a problem when you change db_colum names.
+                        pass
+                    elif 'DROP TABLE' in line:
+                        # Cascade drops.
+                        # Hence with "with fire" part of this task's name.
+                        line = line[:-2] + ' CASCADE;\n'
+                        f.write(line)
+                    else:
+                        # Write other lines through untoched.
+                        f.write(line)
+                    line = orig.readline()
+
+                # Write out the rest of the file untouched.
+                f.write(line)
+                f.write(orig.read())
+
+    # Upload the processed SQL file.
+    put('reset.sql', os.path.join(env.site_path, 'reset.ready.sql'), use_sudo=True)
+
+    with cd(env.site_path):
+        # Use the SQL to reset the app, and fake a migration.
+        run(_python('manage.py dbshell < reset.ready.sql'))
+        sudo(_python('manage.py migrate --fake --delete-ghost-migrations ' + app))
+```
+
+This task uses Mercurial's local tags to add a `production` or `staging` tag in your local
+repository, so you can easy see where the production/staging servers are at
+compared to your local repo.
+
+```python
+def retag():
+    '''Check which revision the site is at and update the local tag.
+
+    Useful if someone else has deployed (which makes your production/staging local
+    tag incorrect.
+    '''
+    require('site_path', provided_by=['prod', 'stag'])
+    require('env_name', provided_by=['prod', 'stag'])
+
+    with cd(env.site_path):
+        current = run('hg id --rev . --quiet').strip(' \n+')
+
+    local('hg tag --local --force %s --rev %s' % (env.env_name, current))
+```
+
+This task tails the Gunicorn logs on the server so you can quickly find out what's
+happening when things blow up.
+
+```python
+def tailgun(follow=''):
+    """Tail the Gunicorn log file."""
+    require('site_path')
+
+    with cd(env.site_path):
+        if follow:
+            run('tail -f .gunicorn.log')
+        else:
+            run('tail .gunicorn.log')
+```
+
+We've got a lot of other tasks but they're pretty specific to our setup.
+
+Wrangling Databases with South
+------------------------------
+
+If you're not using [South][], you need to start.  Now.
+
+No, really, I'll wait.  Take 30 minutes, try the [tutorial][Southtut], wrap your head
+around it and come back.  It's far more important than this blog post.
+
+[South]: http://south.aeracode.org/
+[Southtut]: http://south.aeracode.org/docs/tutorial/index.html
+
+### Useful Fabric Tasks
+
+South is awesome but its commands are very long-winded.  Here's the set of fabric
+tasks I use to save quite a bit of typing:
+
+```python
+def migrate(args=''):
+    '''Run any needed migrations.'''
+    require('site_path')
+    require('venv_path')
+
+    with cd(env.site_path):
+        sudo(_python('manage.py migrate ' + args))
+
+def migrate_fake(args=''):
+    '''Run any needed migrations with --fake.'''
+    require('site_path')
+    require('venv_path')
+
+    with cd(env.site_path):
+        sudo(_python('manage.py migrate --fake ' + args))
+
+def migrate_reset(args=''):
+    '''Run any needed migrations with --fake.  No, seriously.'''
+    require('site_path')
+    require('venv_path')
+
+    with cd(env.site_path):
+        sudo(_python('manage.py migrate --fake --delete-ghost-migrations ' + args))
+```
+
+Remember that running a migration without specifying an app will migrate everything,
+so a simple `fab dev migrate` will do the trick.
+
+Watching for Changes
+---------------------
+
+When developing locally you'll want to make a change to your code and have the server
+reload that code automatically.  The Django development server does this, and we can
+hack it into our Vagrant/Gunicorn setup too.
+
+First, add a `monitor.py` file at the root of your project (I believe I found this
+code [here][monitor], but I may be wrong):
+
+```python
+import os
+import sys
+import time
+import signal
+import threading
+import atexit
+import Queue
+
+_interval = 1.0
+_times = {}
+_files = []
+
+_running = False
+_queue = Queue.Queue()
+_lock = threading.Lock()
+
+def _restart(path):
+    _queue.put(True)
+    prefix = 'monitor (pid=%d):' % os.getpid()
+    print >> sys.stderr, '%s Change detected to \'%s\'.' % (prefix, path)
+    print >> sys.stderr, '%s Triggering process restart.' % prefix
+    os.kill(os.getpid(), signal.SIGINT)
+
+def _modified(path):
+    try:
+        # If path doesn't denote a file and were previously
+        # tracking it, then it has been removed or the file type
+        # has changed so force a restart. If not previously
+        # tracking the file then we can ignore it as probably
+        # pseudo reference such as when file extracted from a
+        # collection of modules contained in a zip file.
+
+        if not os.path.isfile(path):
+            return path in _times
+
+        # Check for when file last modified.
+
+        mtime = os.stat(path).st_mtime
+        if path not in _times:
+            _times[path] = mtime
+
+        # Force restart when modification time has changed, even
+        # if time now older, as that could indicate older file
+        # has been restored.
+
+        if mtime != _times[path]:
+            return True
+    except:
+        # If any exception occured, likely that file has been
+        # been removed just before stat(), so force a restart.
+
+        return True
+
+    return False
+
+def _monitor():
+    while 1:
+        # Check modification times on all files in sys.modules.
+
+        for module in sys.modules.values():
+            if not hasattr(module, '__file__'):
+                continue
+            path = getattr(module, '__file__')
+            if not path:
+                continue
+            if os.path.splitext(path)[1] in ['.pyc', '.pyo', '.pyd']:
+                path = path[:-1]
+            if _modified(path):
+                return _restart(path)
+
+        # Check modification times on files which have
+        # specifically been registered for monitoring.
+
+        for path in _files:
+            if _modified(path):
+                return _restart(path)
+
+        # Go to sleep for specified interval.
+
+        try:
+            return _queue.get(timeout=_interval)
+        except:
+            pass
+
+_thread = threading.Thread(target=_monitor)
+_thread.setDaemon(True)
+
+def _exiting():
+    try:
+        _queue.put(True)
+    except:
+        pass
+    _thread.join()
+
+atexit.register(_exiting)
+
+def track(path):
+    if not path in _files:
+        _files.append(path)
+
+def start(interval=1.0):
+    global _interval
+    if interval < _interval:
+        _interval = interval
+
+    global _running
+    _lock.acquire()
+    if not _running:
+        prefix = 'monitor (pid=%d):' % os.getpid()
+        print >> sys.stderr, '%s Starting change monitor.' % prefix
+        _running = True
+        _thread.start()
+    _lock.release()
+```
+
+Next add a `post_fork` hook to your Gunicorn config file that uses the monitor to
+watch for changes:
+
+```python
+def post_fork(server, worker):
+    import monitor
+    import local_settings
+    if local_settings.DEBUG:
+        server.log.info("Starting change monitor.")
+        monitor.start(interval=1.0)
+```
+
+Now the Gunicorn server will automatically restart whenever code is changed.  Use
+whatever method for determining debug status that you like.  We use
+`local_settings.py` files which all have `DEBUG` variables, so that works for us.
+
+It will *not* restart when you add new code (e.g. when you install a new app), so
+you'll need to handle that manually with `fab dev restart`, but that's not too bad!
+
+[monitor]: http://code.google.com/p/modwsgi/wiki/ReloadingSourceCode
+
+### Using the Werkzeug Debugger with Gunicorn
+
+The final piece of the puzzle is being able to use the fantastic [Werkzeug
+Debugger][debug] while running on the development VM with Gunicorn.
+
+To do this, create a `debug_wsgi.py` file at the root of your project:
+
+```python
+import os
+import sys
+import site
+
+parent = os.path.dirname
+site_dir = parent(os.path.abspath(__file__))
+project_dir = parent(parent(os.path.abspath(__file__)))
+
+sys.path.insert(0, project_dir)
+sys.path.insert(0, site_dir)
+
+site.addsitedir('VIRTUALENV_SITE_PACKAGES')
+
+from django.core.management import setup_environ
+import settings
+setup_environ(settings)
+
+import django.core.handlers.wsgi
+application = django.core.handlers.wsgi.WSGIHandler()
+
+from werkzeug.debug import DebuggedApplication
+application = DebuggedApplication(application, evalex=True)
+
+def null_technical_500_response(request, exc_type, exc_value, tb):
+    raise exc_type, exc_value, tb
+from django.views import debug
+debug.technical_500_response = null_technical_500_response
+```
+
+Have Gunicorn use this file to run your development server with `gunicorn
+debug_wsgi:application`.
+
+Make sure to replace `'VIRTUALENV_SITE_PACKAGES'` with the _full_ path to your
+virtualenv's `site_packages` directory.  You might want to make this a setting in
+a machine-specific settings file.
+
+[debug]: http://werkzeug.pocoo.org/docs/debug/
+
+### Pulling Uploads
+
+Once you give a client access to a site they'll probably be uploading images (through
+Django's built-in file uploading features or with [django-filebrowser][]).
+
+When you're making changes locally it's often useful to have these uploaded files on
+your local VM, otherwise you end up with a bunch of broken images.
+
+Here's a simple Fabric task that will pull down all the uploads from the server:
+
+```python
+def pull_uploads():
+    '''Copy the uploads from the site to your local machine.'''
+    require('uploads_path')
+
+    sudo('chmod -R a+r "%s"' % env.uploads_path)
+
+    rsync_command = r"""rsync -av -e 'ssh -p %s' %s@%s:%s %s""" % (
+        env.port,
+        env.user, env.host,
+        env.uploads_path.rstrip('/') + '/',
+        'media/uploads'
+    )
+    print local(rsync_command, capture=False)
+```
+
+You might be wondering about the line that strips `/` characters and then adds them
+back in.  `rsync` does different things depending on whether you end a path with
+a `/`, so this is actually pretty important.
+
+In your host task you'll need to set the `uploads_path` variable to something like
+this:
+
+```python
+import os
+env.site_path = os.path.join('var', 'www', 'myproject')
+env.uploads_path = os.path.join(env.site_path, 'media', 'uploads')
+```
+
+Now you can run `fab production pull_uploads` to pull down all the files people have
+uploaded to the production server.
+
+[django-filebrowser]: http://code.google.com/p/django-filebrowser/
+
+### Preventing Accidents
+
+Deploying to test and staging servers should be quick and easy. Deploying to
+production servers should be harder to prevent people from accidentally doing it.
+
+I've created a little function that I call before deploying to production servers.
+It forces me to type in random words from the system word list before proceeding to
+make sure I *really* know what I'm doing:
+
+```python
+import os, random
+
+from fabric.api import *
+from fabric.operations import prompt
+from fabric.utils import abort
+
+WORDLIST_PATHS = [os.path.join('/', 'usr', 'share', 'dict', 'words')]
+DEFAULT_MESSAGE = "Are you sure you want to do this?"
+WORD_PROMPT = '  [%d/%d] Type "%s" to continue (^C quits): '
+
+def prevent_horrible_accidents(msg=DEFAULT_MESSAGE, horror_rating=1):
+    """Prompt the user to enter random words to prevent doing something stupid."""
+
+    valid_wordlist_paths = [wp for wp in WORDLIST_PATHS if os.path.exists(wp)]
+
+    if not valid_wordlist_paths:
+        abort('No wordlists found!')
+
+    with open(valid_wordlist_paths[0]) as wordlist_file:
+        words = wordlist_file.readlines()
+
+    print msg
+
+    for i in range(int(horror_rating)):
+        word = words[random.randint(0, len(words))].strip()
+        p_msg = WORD_PROMPT % (i+1, horror_rating, word)
+        answer = prompt(p_msg, validate=r'^%s$' % word)
+```
+
+You may need to adjust `WORDLIST_PATHS` if you're not on OS X.
+
+Working with Third-Party Apps
+-----------------------------
+
+One of the best parts about working with Django is that many problems have already
+been solved and the solutions have been released as open-source applications.
+
+We use quite a few open-source apps, and there are a couple of tricks I've learned to
+make working with them easier.
+
+### Installing Apps from Repositories
+
+If I'm going to use an open-source Django app in a project I'll almost always install
+it as an editable repository on the VM with `pip install -e`.
+
+Others may disagree with me on this, but I think it's the best way to work.
+
+Often I'll find a bug that I think may be in one of the third-party apps I'm using.
+Installing the apps as repositories makes it easy to read their source and figure out
+if the bug is really in the app.
+
+If the bug *is* in the third-party app having the app installed as a repository makes
+it simple to fix the bug, fork the project on BitBucket or GitHub, send a pull
+request, and get back to work.
+
+### Mirroring Repositories
+
+One problem we've run into at Dumbwaiter is that the repos for third-party apps we
+use are scattered across GitHub, BitBucket, Google Code, and other servers.  If any
+one of these services goes down we're stuck waiting for it to come back up.
+
+A while ago I took half a day and consolidated all of these repos onto one of the
+servers that we control.  The basic process went like this:
+
+* Use [hg-git][] and [hgsubversion][] to convert the git and SVN repos to Mercurial
+  repos.
+* Set up a master `mirror` Mercurial repo with all the app repos as subrepos.
+* Push the master repo and all the subrepos up to one of our Linodes.
+
+Now we can use `-e ssh://hg@OUR_LINODE/mirror/APP@REV_THAT_WORKS#egg=APP` in our
+`requirements.txt` files to install apps from our mirror.  When we want to update our
+dependencies we can simply pull from the upstream repos and commit in the mirror
+repo.
+
+If our mirror goes down it's not a big deal, because we have far bigger problems to
+worry about than new projects.
+
+I wrote a few scripts to automate updating apps and such, but they're extremely hacky
+so I don't want to post them here.  Take half a day and write your own set — it's
+definitely worth it to have your own mirror of your specific dependencies.
+
+[hg-git]: http://hg-git.github.com/
+[hgsubversion]: https://bitbucket.org/durin42/hgsubversion/wiki/Home
+
+### Using BCVI to Edit Files
+
+I said that when I find a bug that I think is in a third-party app I'll poke around
+with the app and try to figure it out.  But since all the apps are installed in
+a virtualenv on the Vagrant VM it might seem like it's a pain in the ass to edit
+those files!
+
+Luckily [BCVI][] exists.  It's a utility that opens a "back channel" to your local
+machine when you SSH and lets you run `vi FILE` to open that file in
+Vim/MacVim/GVim/etc on your *local* machine.  When you save the file it uploads it
+back to the server automatically for you.
+
+It can be a bit tricky to set up, but it's worth it.  Trust me.
+
+[BCVI]: http://sshmenu.sourceforge.net/articles/bcvi/
+
+Improving the Admin Interface
+-----------------------------
+
+I'm going to be honest: Django's admin interface is the main reason I'm still using
+it.  Other frameworks like [Flask][] are great, but Django's admin saves me
+*ridiculous* amounts of time when I'm making simple CRUD sites for clients.
+
+That said, the Django admin isn't the prettiest thing around, but we can give it
+a facelift.
+
+[Flask]: http://flask.pocoo.org/
+
+### Enter Grappelli
+
+[Grappelli][] is a Django app that reskins the admin interface beautifully.  It also
+adds some functionality like drag-and-drop reordering of inlines, and allows you to
+customize the dashboard to your liking.  *Every* Django site I work on uses Grappelli
+-- it's just that good.
+
+The downside of Grappelli is that it changes quite a lot and breaks backwards
+compatibility at the drop of a hat.
+
+If you're going to use Grappelli you *must* freeze your requirements.txt files and
+work with a single version at a time.  Trying to always work from the trunk will make
+you drink.
+
+[Grappelli]: http://django-grappelli.readthedocs.org/
+
+### An Ugly Hack to Show Usable Foreign Key Fields
+
+A limitation of both Grappelli and the stock Django admin is that it seems like you
+can't easily show fields from related models in the admin list view.
+
+For example, if you're new to Django you might expect this to work:
+
+```python
+class BlogEntryAdmin(admin.ModelAdmin):
+    list_display = ('title', 'author__name')
+```
+
+Unfortunately Django chokes on the `author__name` lookup.  You can *display* the name
+without too much fuss:
+
+```python
+class BlogEntryAdmin(admin.ModelAdmin):
+    list_display = ('title', 'author_name')
+
+    def author_name(self, obj):
+        return obj.name
+```
+
+That will display the name just fine.  However, it won't be a fully-fledged column in
+the Django admin because you can't sort on it.
+
+It may seem like this is the end — if it could be a fully-functional field, why
+wouldn't Django just let you use `author__name`?  Luckily we can add one more line to
+fix the problem:
+
+```python
+class BlogEntryAdmin(admin.ModelAdmin):
+    list_display = ('title', 'author_name')
+
+    def author_name(self, obj):
+        return obj.name
+    author_name.admin_order_field = 'author__name'
+```
+
+Now the author name has all the functionality of a real `list_display` entry.
+
+Using Django-Annoying
+---------------------
+
+If you haven't heard of [django-annoying][] you should definitely check it out.  It's
+got a bunch of miscellaneous functions that fix some common, annoying parts of
+Django.
+
+My two personal favorites from the package are a pair of decorators that help make
+your views much, much cleaner.
+
+[django-annoying]: https://bitbucket.org/offline/django-annoying/wiki/Home
+
+### The render\_to Decorator
+
+The decorator is called `render_to` and it eliminates the ugly `render_to_response`
+calls that Django normally forces you to use in every single view.
+
+Normally you'd use something like this:
+
+```python
+def videos(request):
+    videos = Video.objects.all()
+    return render_to_response('video_list.html', { 'videos': videos },
+                              context_instance=RequestContext(request))
+```
+
+With `render_to` your view gets much cleaner:
+
+```python
+@render_to('video_list.html')
+def videos(request):
+    videos = Video.objects.all()
+    return { 'videos': videos }
+```
+
+Less typing `context_instance=...` over and over, and less syntax to remember.
+
+Yes, I know about Django 1.3's `render` shortcut.  You have to type `request` every
+single time with `render`, so the `render_to` decorator still wins.
+
+### The ajax\_request Decorator
+
+The `ajax_request` decorator is like `render_to` for AJAX requests.  You simply
+return a Python dictionary from your view and the decorator handles the JSON encoding
+and such:
+
+```python
+@ajax_request
+def ajax_get_entries(request):
+    blog_entries = BlogEntry.objects.all()
+    return { 'entries': [(entry.title, entry.get_absolute_url())
+                         for entry in entries]}
+```
+
+Templating Tricks
+-----------------
+
+I'm not a frontend developer, but I've done my share of HTML hacking at Dumbwaiter.
+Here are a few of the tricks I've learned.
+
+### Null Checks and Fallbacks
+
+A common pattern I see in Django templates looks like this:
+
+```django
+{% templatetag openblock %} if business.title {% templatetag closeblock %}
+    {% templatetag openvariable %} business.title {% templatetag closevariable %}
+{% templatetag openblock %} else {% templatetag closeblock %}
+    {% templatetag openvariable %} business.short_title {% templatetag closevariable %}
+{% templatetag openblock %} endif {% templatetag closeblock %}
+```
+
+Here's a simpler way to do that:
+
+```django
+{% templatetag openblock %} firstof business.title business.short_title {% templatetag closeblock %}
+```
+
+`firstof` will return the first non-Falsy item in its arguments.
+
+### Manipulating Query Strings
+
+Query strings are normally not a big deal, but every once in a while you'll have
+a model listing page where you need to filter by category, and number of spaces, and
+tags, etc all at once.
+
+If you're trying to manage GET queries manually it can get pretty hairy very fast.
+
+[This Django snippet][qstring] makes working with query strings in templates
+a breeze.
+
+[qstring]: http://djangosnippets.org/snippets/2237/
+
+### Satisfying Your Designer with Typogrify
+
+If you haven't heard of [Typogrify][] you should take a look at it.  It makes it easy
+to add all the typographic goodness your designers are looking for.
+
+[Typogrify]: http://code.google.com/p/typogrify/
+
+The Flat Page Trainwreck
+------------------------
+
+Creating a site for a client is very different than creating a site for yourself.
+For pretty much every client we've dealt with we've heard: "can't we just create
+a new page at /drink-special/ for this special deal we're running?"
+
+Having clients go through you to make new pages is simply too much overhead.  We
+needed a way to let clients create new pages (like `/drink-special/`) on the fly,
+without our intervention.
+
+Django has a "flatpages" app that solves this problem.  Kind of.
+
+When using flat pages clients need to do two things that are often too much for
+non-technical people:
+
+* Manage URLs manually.
+* Write all content as raw HTML in a single text field.
+
+We've tried a lot of Django CMS apps at Dumbwaiter, and none of them made us happy.
+They all seemed to have some or all of the following problems:
+
+* They take over your site and make you write a "Django-WhateverCMS site" instead of
+  a "Django site".
+* They're extremely feature-rich and complicated with features like
+  internationalization, redirects, versions, and many others.  This is great if you
+  need the flexibility, but bad if your clients just need to create a couple of
+  pages.
+* They break `APPEND_TRAILING_SLASH` and make you clutter your `urls.py` files with
+  a bunch of extra code ot handle this.
+
+I finally got fed up and wrote my own Django CMS app: [Stoat][].  Stoat is designed
+to be sleek, with only the features that our clients need.
+
+It's not officially version 1.0 yet, but we're using it for a few clients and it's
+working well.  Check it out if you're looking for a more lightweight CMS app.
+
+[Stoat]: http://stoat.rtfd.org/
+
+Editing with Vim
+----------------
+
+I [use Vim][vimpost] to edit everything.  Naturally I've found a bunch of plugins,
+mappings and other tricks that make it even better when working on Django projects.
+
+[vimpost]: /blog/2010/09/coming-home-to-vim/
+
+### Vim for Django
+
+There are a lot of ways to make Vim work with Django.  I won't go into all of them in
+this post, but a good place to start is [this Django wiki page][vimdjango].
+
+[vimdjango]: https://code.djangoproject.com/wiki/UsingVimWithDjango
+
+### Filetype Mappings
+
+Most files in a Django project have one of two extensions: `.py` and `.html`.
+Unfortunately these extensions aren't unique to Django, so Vim doesn't automatically
+set the correct `filetype` when you open one.
+
+I've added a few mappings to my `.vimrc` to make it quick and easy to set the correct
+`filetype`:
+
+```vim
+nnoremap _dt :set ft=htmldjango<CR>
+nnoremap _pd :set ft=python.django<CR>
+```
+
+I also have a few autocommands that set the filetype for me when I'm editing a file
+whose name "sounds like" a Django file:
+
+```vim
+au BufNewFile,BufRead admin.py     setlocal filetype=python.django
+au BufNewFile,BufRead urls.py      setlocal filetype=python.django
+au BufNewFile,BufRead models.py    setlocal filetype=python.django
+au BufNewFile,BufRead views.py     setlocal filetype=python.django
+au BufNewFile,BufRead settings.py  setlocal filetype=python.django
+au BufNewFile,BufRead forms.py     setlocal filetype=python.django
+```
+
+### Python Sanity Checking
+
+Lets be honest here: it takes a lot of work to turn Vim into an "IDE", and even then
+it doesn't reach the level of something like Eclipse for Java.  Anyone who claims it
+has the same levels of integration and functionality is simply lying.
+
+With that said I'll make an opinionated statement that is going to piss some of you
+off.
+
+**I am a programmer, not an IDE operator.**
+
+I know Python.
+
+I know Django.
+
+I don't need to hit Cmd+Space twice for every line of code I write.
+
+When someone asks me "how do you run your site" I do **not** answer: "click the green
+triangle in Eclipse".
+
+However, I am human.  I do stupid things like forgetting a colon or forgetting an
+import.  To help me with those problems I've turned to [Syntastic][] and Kevin
+Watters' [Pyflakes fork][] for Vim.
+
+Syntastic is a Vim plugin that adds on-the-fly syntax-checking for many different
+file formats.  If you have Pyflakes installed it will automatically show you errors
+in your code.
+
+Pyflakes doesn't have IDE-level integration with your code.  It doesn't check that
+whatever libraries you `import` actually exist.  It simply checks that your files are
+probably-valid Python, and tells you when they're not.
+
+This is enough for me.  It catches the stupid mistakes I make.  The less-stupid,
+more-subtle mistakes slip by it, but to be fair many of them would have slipped by an
+"IDE" as well.
+
+[Pyflakes fork]: https://github.com/kevinw/pyflakes
+[Syntastic]: http://www.vim.org/scripts/script.php?script_id=2736
+
+### Javascript Sanity Checking and Folding
+
+Syntastic also supports Javascript if you have Javascript Lint installed (`brew
+install jsl` on OS X).  It's not perfect but it *will* catch things like using
+trailing commas in object literals.
+
+Some people like using CTags to get an overview of their code.  I take a more
+low-tech approach and am in love with code folding.  When I fold my code
+I automatically get an overview of everything in each file.
+
+By default Vim doesn't fold Javascript files, but you can add some basic, perfectly
+serviceable folding with these two lines in your .vimrc:
+
+```vim
+au FileType javascript setlocal foldmethod=marker
+au FileType javascript setlocal foldmarker={,}
+
+```
+
+### Django Autocommands
+
+I *rarely* work with raw HTML files any more.  Whenever I open a file ending in
+`.html` it's almost always a Django template (or a [Jinja][] template, which has
+a very similar syntax).  I've added an autocommand to automatically set the correct
+filetype whenever I open a `.html` file:
+
+[Jinja]: http://jinja.pocoo.org/
+
+```vim
+au BufNewFile,BufRead *.html setlocal filetype=htmldjango
+```
+
+I also have some autocommands that tweak how a few specific files are handled:
+
+```vim
+au BufNewFile,BufRead urls.py      setlocal nowrap
+au BufNewFile,BufRead settings.py  normal! zR
+au BufNewFile,BufRead dashboard.py normal! zR
+```
+
+This automatically unfolds `urls.py`, `dashboard.py` and `settings.py` (I prefer
+seeing those unfolded) and unsets line wrapping for `urls.py` (lines in a `urls.py`
+file can get long and are hard to read when wrapped).
+
+Conclusion
+----------
+
+I hope that this longer-than-expected blog entry has given you at least one or two
+things to think about.
+
+I've learned a lot while working with Django for Dumbwaiter every day, but I'm sure
+there's still a lot I've missed.  If you see something I could be doing better please
+let me know!
+
--- a/content/blog/2011/09/writing-vim-plugins.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,599 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Writing Vim Plugins"
-        snip: "It's pretty much black magic."
-        created: 2011-09-06 09:13:00
-    %}
-
-    {% block article %}
-
-
-A while ago I wrote a [post][vimpost] about switching back to [Vim][].  Since then
-I've written two plugins for Vim, one of which has been officially "released".
-
-A couple of people have asked me if I'd write a guide to creating Vim plugins.
-I don't feel confident enough to write an official "guide", but I do have some advice
-for Vim plugin authors that might be useful.
-
-[vimpost]: http://stevelosh.com/blog/2010/09/coming-home-to-vim/
-[Vim]: http://www.vim.org/
-
-[TOC]
-
-Other People Who Know More Than I Do
-------------------------------------
-
-Writing two decently-sized Vim plugins has given me some experience, but there are
-a lot of people that know far more than I do.  There are two in particular that come
-to mind.  I'd love for them to write some guides (or even books) about modern-day Vim
-scripting.
-
-### Tim Pope
-
-The first is [Tim Pope][].  He's written a ton of Vim plugins like [Pathogen][],
-[Surround][], [Repeat][], [Speeddating][] and [Fugitive][].  Each of those is clear,
-focused and polished.
-
-It would be awesome to read a guide on the ins and outs of Vim scripting by him.
-
-[Tim Pope]: http://tpo.pe/
-[Pathogen]: https://github.com/tpope/vim-pathogen
-[Surround]: https://github.com/tpope/vim-surround
-[Repeat]: https://github.com/tpope/vim-repeat
-[Speeddating]: https://github.com/tpope/vim-speeddating
-[Fugitive]: https://github.com/tpope/vim-fugitive
-
-### Scrooloose
-
-The other person that comes to mind is [Scrooloose][], author of [NERDTree][],
-[NERDCommenter][] and [Syntastic][].
-
-His plugins are large and full-featured but work incredibly well, considering how
-tricky and painful Vimscript is to work with.  I'd love to read a guide on writing
-large-scale Vim plugins by him.
-
-[Scrooloose]: http://got-ravings.blogspot.com/
-[NERDTree]: https://github.com/scrooloose/nerdtree
-[NERDCommenter]: https://github.com/scrooloose/nerdcommenter
-[Syntastic]: https://github.com/scrooloose/syntastic
-
-Be Pathogen-Compatible
-----------------------
-
-It's 2011.  When writing your plugin, *please* make its source compatible with
-[Pathogen][].  It's very easy to do this -- just set up your project's files like
-this:
-
-    :::text
-    yourplugin/
-        doc/
-            yourplugin.txt
-        plugin/
-            yourplugin.vim
-        ...
-        README
-        LICENSE
-
-This will let users use Pathogen (or [Vundle][]) to install and use your plugin.
-
-The days of "unzip and drag the files into the right directories" and the horror of
-Vimballs are over.  Pathogen and Vundle are the right way to manage plugins, so let
-your users use them.
-
-[Vundle]: https://github.com/gmarik/vundle
-
-Please, For the Love of God, Use normal!
-----------------------------------------
-
-My first piece of actual scripting advice is something simple but important.  If
-you're writing a Vim plugin and need to perform some actions, you might be tempted to
-use `normal`.  Don't.  Instead, you need to use `normal!`.
-
-`normal!` is like `normal`, but ignores mappings the user has set up.  If you use
-plain old `normal dd` and I've remapped `dd` to do something else, the call will use
-my mapping and probably not do what your plugin expects.  Using `normal!` ensures
-that the call will do what you expect no matter what the user has mapped.
-
-This is a single instance of a more general theme. Vim is very customizable and users
-will do lots of crazy things in their `.vimrc` files.  If a key can be mapped or
-a setting changed, you *have* to assume that some user of your plugin will have
-mapped or changed it.
-
-Mapping Keys the Right Way
---------------------------
-
-Most plugins add key mappings to make them easier to use.  Unfortunately this can be
-tricky to get right.  You can never tell what keys your users have already mapped
-themselves, and shadowing someone's favorite key mapping will break their muscle
-memory and annoy them to no end.
-
-### When to Map Keys
-
-The first question to ask is whether your plugin needs to map keys itself at all.
-
-My [Gundo][] plugin has only one feature that needs to be mapped to a key in order to
-make it useful: the "toggle Gundo" action.
-
-Gundo doesn't map this key itself, because no matter what "default" mapping I pick
-someone will have already mapped it.  Instead I added a section right in the README
-file that shows how a user can map the key themselves:
-
-    :::vim
-    nnoremap <F5> :GundoToggle<CR>
-
-By making users add this line to their `.vimrc` themselves it shows them which key is
-used to toggle Gundo (which they would have to know anyway) and also makes it obvious
-how to change it to suit their taste.
-
-[Gundo]: http://sjl.bitbucket.org/gundo.vim/
-
-### imap and nmap are Pure Evil
-
-Sometimes forcing the user to map their own keys won't work.  Perhaps your plugin has
-many mappings that would be tedious for a user to set up manually (like my
-[Threesome][] plugin), or its mappings are mnemonic and wouldn't really make sense if
-mapped to other keys.
-
-I'll talk more about how to deal with this in a moment, but the most important thing
-to remember when mapping your own keys is that you must always, *always*,
-***always*** use the `noremap` forms of the various `map` commands.
-
-If you map a key with `nmap` and the user has remapped a key that your mapping uses,
-your mapped key will almost certainly not do what you want.  Using `nnoremap` will
-ignore user mappings and do what you expect.
-
-This is the same principle as `normal` and `normal!`: *never* trust your users'
-configurations.
-
-[Threesome]: http://sjl.bitbucket.org/threesome.vim
-
-### Let Me Configure Mappings
-
-If you feel that your plugin must map some keys, please make those mappings
-configurable in some way.
-
-There are a number of ways to do this.  The easiest way is to provide a configuration
-option that disables all mappings.  The user can them remap the keys as they see fit.
-For example:
-
-    :::vim
-    if !exists('g:yourplugin_map_keys')
-        let g:yourplugin_map_keys = 1
-    endif
-
-    if g:yourplugin_map_keys
-        nnoremap <leader>d :call <sid>YourPluginDelete()<CR>
-    endif
-
-Normal users will get the mappings automatically set up for them, and power users can
-remap the keys to whatever they wish to avoid shadowing their own mappings.
-
-If your plugin's mappings all start with a common prefix (like `<leader>` or
-`<localleader>`) you have another option: allow users to configure this prefix.  This
-is the approach I've used in [Threesome][].  It works like this:
-
-    :::vim
-    if !exists('g:yourplugin_map_prefix')
-        let g:yourplugin_map_prefix = '<leader>'
-    endif
-
-    execute "nnoremap"  g:yourplugin_map_prefix."d"  ":call <sid>YourPluginDelete()<CR>"
-
-The `execute` command lets you build the mapping string dynamically so your users can
-change the mapping prefix.
-
-There is a third option for solving this problem: the `hasmapto()` Vim function.
-Some plugins will use this to map a command to a key *unless* the user has already
-mapped that command to something else.  I don't personally like this option because
-it feels less clear to me, but I know other people feel differently so I wanted to
-mention it.
-
-Localize Mappings and Settings
-------------------------------
-
-The next step in being a good Vim plugin author is to try to minimize the effects of
-your key mappings and setting changes.  Some plugins will need to have global
-effects but others will not.
-
-For example: if you're writing a plugin for working with Python files it should only
-take effect for Python buffers, not all buffers.
-
-### Localizing Mappings
-
-Key binding are easy to localize to single buffers.  All of the `noremap` commands
-can take an extra `<buffer>` argument that will localize the mapping to the current
-buffer.
-
-    :::vim
-    " Remaps <leader>z globally
-    nnoremap <leader>z :YourPluginFoo<cr>
-
-    " Remaps <leader>z only in the current buffer
-    nnoremap <buffer> <leader>z :YourPluginFoo<cr>
-
-However, the problem is that you need to run this command in every buffer you want
-the mapping active.  To do this your plugin can use an `autocommand`.  Here's a full
-example, using this concept plus the previously mentioned configuration options:
-
-    if !exists('g:yourplugin_map_keys')
-        let g:yourplugin_map_keys = 1
-    endif
-
-    if !exists('g:yourplugin_map_prefix')
-        let g:yourplugin_map_prefix = '<leader>'
-    endif
-
-    if g:yourplugin_map_keys
-        execute "autocommand FileType python" "nnoremap <buffer>" g:yourplugin_map_prefix."d"  ":call <sid>YourPluginDelete()<CR>"
-    endif
-
-Now your plugin will define a key mapping only for Python buffers, and your users can
-disable or customize this mapping as they see fit.
-
-This mapping command is quite ugly.  Unfortunately that's the price of using
-Vimscript and trying to make a plugin that will work for many users.  Later I'll talk
-about one possible solution to this ugliness.
-
-### Localizing Settings
-
-Just as you should make mappings local to buffers when appropriate, you should do the
-same with settings like `foldmethod`, `foldmarker` and `shiftwidth`.  Not all
-settings can be set locally in a buffer.  You can read `:help <settingname>` to see
-if it's possible.
-
-You can use `setlocal` instead of `set` to localize settings to individual buffers.
-Like with mappings you'll need to use an autocommand to run the `setlocal` command
-every time the users opens a new buffer.
-
-Autoload is Your Friend
------------------------
-
-If your plugin is something that users will be using all the time you can skip this
-section.
-
-If you're writing something that will only be used in specific cases, you can help
-your users by using Vim's `autoload` functionality to delay loading its code until
-the user actually tries to use it.
-
-The way `autoload` works is fairly simple.  Normally you would bind a key to call one of your
-plugin's functions with something like this:
-
-    :::vim
-    nnoremap <leader>z :call YourPluginFunction()<CR>
-
-You can use autoloading by prepending `yourplugin#` to the name of the function:
-
-    :::vim
-    nnoremap <leader>z :call yourplugin#YourPluginFunction()<CR>
-
-When this mapping is run, Vim will do the following:
-
-1. Check to see if `YourPluginFunction` is already defined.  If so, call it.
-2. Otherwise, look in `~/.vim/autoload/` for a file named `yourplugin.vim`.
-3. If it exists, parse and load the file (which presumably defines
-  `YourPluginFunction` somewhere inside of it).
-4. Call the function.
-
-This means that instead of putting all of your plugin's code in
-`plugin/yourplugin.vim` you can put just the key mapping code there and pull the rest
-out into `autoload/yourplugin.vim`.
-
-If your plugin has a decent amount of code this can reduce the startup time of Vim by
-a significant amount.
-
-Check out the full documentation of `autoload` by running `:help autoload` to learn
-much more.
-
-Backwards Compatibility is a Big Deal
--------------------------------------
-
-Once you've written your Vim plugin and released it into the wild, you have to
-maintain it.  Users will find bugs and ask for new features.
-
-Part of being a responsible developer of any kind, including a Vim plugin author, is
-maintaining backwards compatibility, *especially* for tools that users will use every
-day and burn into their muscle memory.  Users rely on tools to work, and tools that
-break backwards compatibility will quickly lose users' trust.
-
-Maintaining backwards compatibility will cause your plugin's code to get crufty in
-spots, but it's the price of maintaining your users' happiness.
-
-### What Matters for Backards Compatibility?
-
-For a Vim plugin the most important part of staying backwards compatible is ensuring
-that key mappings, customized or not, continue to do what users expect.
-
-If your plugin maps key `X` to do `Y`, then pressing `X` should *always* do `Y`, even
-if you change how `Y` is called by renaming `Y` to `Z`.  This may mean changing `Y`
-into a wrapper function which simply calls `Z`.
-
-There are many other aspects of backwards compatibility that you will have to
-consider, depending on the purpose of your plugin.  The rule of thumb you should
-follow is: if a user uses this plugin on a daily basis and has its usage burned into
-their muscle memory, updating the plugin should not make them relearn anything.
-
-### Use Semantic Versioning So I Can Stay Sane
-
-A fast, simple, easy way to document your plugin's state is to use [semantic
-versioning][].
-
-Semantic versioning is simply the idea that instead of picking arbitrary version
-numbers for releases of your project, you use version numbers that describe the
-backwards-compatible state in a meaningful way.
-
-In a nutshell, these rules describe how you should select version numbers for new
-releases:
-
-* Version numbers have three components: `major.minor.bugfix`.  For example: `1.2.4`
-  or `2.13.0`.
-* Versions with a major version of 0 (e.g. `0.2.3`) make no guarantees about
-  backwards compatibility.  You are free to break anything you want.  It's only after
-  you release `1.0.0` that you begin making promises.
-* If a release introduces backwards-incompatible changes, increment the major version
-  number.
-* If a release is backwards-compatible, but adds *new* features, increment the minor
-  version number.
-* If a release simply fixes bugs, refactors code, or improves performance, increment
-  the bugfix version number.
-
-This simple scheme makes it easy for users to tell (in a broad sense) what has
-changed when they update your project.
-
-If only the bugfix number has changed they can update without fear and continue on
-without worrying about changes unless they're curious.
-
-If the minor version number has changed they might want to look at the changelog to
-see what new features they may want to take advantage of, but if they're busy they
-can simply update and move on.
-
-If the major version number has changed it's a major red flag, and they'll want to
-read the changelog carefully to see what is different.
-
-Some people don't like semantic versioning for the following reason:
-
-> If I have to increment the major version number every time I make
-> backwards-incompatible changes, I'll quickly be at ugly versions like 24.1.2!
-
-To this I say: "Yes, but if that happens you're doing things wrong in the first
-place."
-
-Keep your project in "beta" (i.e. version `0.*.*`) for as long as you need to
-experiment freely.  *Take your time* and make sure you've gotten things (mostly)
-right.  Once you release `1.0.0` it's time to start being responsible and caring
-about backwards compatibility.
-
-Breaking functionality all the time harms your users by reducing their productivity
-and frustrating them.  Yes, it means adding some cruft to your code over time, but
-it's the price of not being evil.
-
-[semantic versioning]: http://semver.org/
-
-Document Everything
--------------------
-
-A critical part of releasing a Vim plugin to the world is writing documentation for
-it.  Vim has fantastic documentation itself, so your plugins should follow in its
-footsteps and provide thorough docs.
-
-### Pick Some Requirements and Stick to Them
-
-The most important part of your documentation is telling users what they need to have
-in order to use your plugin.  Vim runs on nearly every system imaginable and can be
-compiled in many different ways, so being specific about your plugin's requirements
-will save users a lot of trial and error.
-
-* Does your plugin only work with Vim version X.Y or later?
-* Does it require Python/Ruby/etc support compiled in?  Which version?
-* Does it not work on Windows?
-* Does it rely on an external tool?
-
-If the answer to any of those questions is "yes", you *must* mention it in the
-documentation.
-
-### Write a README
-
-The first step to documenting your plugin is to write a README file for the
-repository.  You can also use the text of this file as the description if you upload
-your plugin to the [vim website][], or the content of your plugin's website if you
-create one for it.
-
-Some examples of things to include in your README are:
-
-* An overview of what the plugin does.
-* Screenshots, if possible.
-* Requirements.
-* Installation instructions.
-* Common configuration options that many users will want to know.
-* Links to:
-    * A canonical web address to find the plugin.
-    * The bug tracker for the plugin.
-    * The source code or repository of the plugin.
-
-[vim website]: http://www.vim.org/
-
-### Create a Simple Website
-
-This isn't strictly necessary, but having a simple website for your plugin is an
-extra touch that makes it seem more polished.
-
-It also gives you a canonical URL that people can visit to get the latest information
-about your plugin.
-
-I've made simple sites for both of my plugins: [Gundo][] and [Threesome][].  Feel
-free to use them as an example or even take their code and use it for your own plugin
-sites if you like.
-
-### Write a Vim Help Document
-
-The bulk of your plugin's documentation should be in the form of a Vim help document.
-Users are used to using Vim's `:help` and they'll expect to be able to use it to
-learn about your plugin.
-
-Creating a help document is as easy as creating a `doc/yourplugin.txt` file in your
-project.  It will be indexed automatically by `pathogen#helptags()` so your users
-will have the docs at their fingertips.
-
-Two easy ways to learn the syntax of help files are by reading `:help help-writing`
-and using an existing plugin's help file as an example.
-
-Take your time and craft a beautiful help file you can be proud of.  Don't be afraid
-to add a bit of personality to your docs to break the dryness.  The [syntastic help
-file][syntastic help] is a great example (especially the `About` section).
-
-Things to include in your documentation:
-
-* A brief overview of the plugin.
-* A more in-depth description of how the plugin is used.
-* Every single key mapping the plugin creates.
-* Ways to extend the plugin, if applicable.
-* All configuration variables (including their default values!).
-* The plugin's changelog.
-* The plugin's license.
-* Links to the plugin's repository and bug tracker.
-
-In a nutshell: your help file should contain *anything* a user would ever need to know
-about your plugin.
-
-[syntastic help]: https://github.com/scrooloose/syntastic/blob/master/doc/syntastic.txt
-
-### Keep a Changelog
-
-The last part of documenting your project is keeping a changelog.  You can skip this
-while your project is still in "beta" (i.e. less than version `1.0.0`) but once you
-officially release a real version you need to keep your users informed about what has
-changed between releases.
-
-I like to include this log in the README, the plugin's website, and the
-documentation to make it as easy as possible for users to see what's changed.
-
-Try to keep the language of the changelog at a high enough level for your users to
-understand without knowing anything about the implementation of your plugin.  Things
-like "added feature X" and "fixed bug Y" are great, while things like "refactored the
-inner workings of utility function Z" are best left in commit messages.
-
-Making Vimscript Palatable
---------------------------
-
-The worst part about writing Vim plugins is, without a doubt, dealing with Vimscript.
-It's an esoteric language that's grown organically over the years seemingly without
-any strong design direction.
-
-Features are added to Vim, then Vimscript features are added to control those
-features, then hacky workarounds are added for flexibility.
-
-The syntax is terse, ugly and inconsistent.  Is `" foo` a comment?  Sometimes.
-
-Much of the time you'll spend writing your first plugin will be learning how to do
-things in Vimscript.  The help documentation on all of its features is thorough, but
-it can be hard to find what you're looking for if you don't know the exact name.
-Looking through other plugins is often very helpful in pointing you toward what you
-need.
-
-There are a couple of ways to ease the pain of Vimscript, and I'll briefly talk about
-two of them here.
-
-### Wrap. Everything.
-
-The first piece of advice I have is this: if you want to make your plugins readable
-and maintainable then you need to wrap up functionality even more than you would in
-other languages.
-
-For example, my [Gundo][] plugin has a few utility functions that look like this:
-
-    :::vim
-    function! s:GundoGoToWindowForBufferName(name)"{{{
-        if bufwinnr(bufnr(a:name)) != -1
-            exe bufwinnr(bufnr(a:name)) . "wincmd w"
-            return 1
-        else
-            return 0
-        endif
-    endfunction"}}}
-
-This function will go to the window for the given buffer name and gracefully handle
-the case where the buffer/window does not exist.  It's verbose but much more readable
-than the alternative of using that `if` statement in every place I need to switch
-windows.
-
-As you write your plugin you'll "grow" a number of these utility functions.  Any time
-you duplicate code you should think about creating one, but you should also do so any
-time you write a particularly hairy line of Vimscript.  Pulling complex lines out
-into named functions will save you a lot of reviewing and rethinking down the line.
-
-### Scripting Vim with Other Languages
-
-Another option for making Vimscript less painful is to simply not use it much at all.
-Vim includes support for creating plugins in a number of other languages like Python
-and Ruby.  Many plugin authors choose to move nearly all of their code into another
-language, using a small Vimscript "wrapper" to expose it to the user.
-
-I decided to try this approach with [Threesome][] after seeing it used in the
-[vim-orgmode][] plugin to great effect.  Overall I consider it to be a good idea,
-with a few caveats.
-
-First, using another language will requires your plugin's users to use a version of
-Vim compiled with support for that version.  In this day and age it's usually not
-a problem, but if you want your plugin to run everywhere then it's not an option.
-
-Using another language adds overhead.  You need to not only learn Vimscript but also
-the interface between Vim and the language.  For small plugins this can add more
-complexity to the project than it saves, but for larger plugins it can pay for
-itself.  It's up to you to decide whether it's worth it.
-
-Finally, using another language does not entirely insulate you from the
-eccentricities of Vimscript.  You still need to learn how to do most things in
-Vimscript -- using another language simply lets you wrap most of this up more neatly
-than you otherwise could.
-
-[vim-orgmode]: https://github.com/jceb/vim-orgmode
-
-### Unit Testing Will Make You Drink
-
-Unit testing (and other types of testing) is becoming more and more popular today.
-In particular the Python and Ruby communities seem to be getting more and more
-excited about it as time goes on.
-
-Unfortunately, unit testing Vim plugins lies somewhere between "painful" and
-"[garden-weasel][]ing your face" on the difficulty scale.
-
-I tried adding some unit tests to [Gundo][], but even after looking at a number of
-frameworks I was spending hours simply trying to get my tests to function.
-
-I didn't even bother trying to add tests to [Threesome][] because for every hour
-I would have spent fighting Vim to create tests I could have cleaned up the code and
-fixed bugs instead.
-
-I'll gladly change my opinion on the subject if someone writes a unit testing
-framework for Vim that's as easy to use as [Cram][].  In fact, I'll even buy the
-author a $100 bottle of scotch (or whatever they prefer).
-
-Until that happens I personally don't think it's worth your time to unit test Vim
-plugins.  Spend your extra hours reading documentation, testing things manually with
-a variety of settings, and thinking hard about your code instead.
-
-[garden-weasel]: http://www.amazon.com/Garden-Weasel-90206/dp/B002ECYRH4 
-[Cram]: https://bitheap.org/cram/
-
-TL;DR
------
-
-Writing Vim plugins is tricky.  Vimscript is a rabbit hole of sadness and despair,
-and trying to please all your users while maintaining backwards compatibility is
-a monumental task.
-
-With that said, creating something that people use every day to help them make
-beautiful software projects is extremely rewarding.  Even if your plugin doesn't get
-many users, being able to use a tool *you wrote* is very satisfying.
-
-So if you've got an idea for a plugin that would make Vim better just sit down, learn
-about Vimscript, create it, and release it so we can all benefit.
-
-If you have any questions or comments feel free to hit me up [on
-Twitter][@stevelosh].  You might also enjoy following [@dotvimrc][] where I try to
-tweet random, bite-sized lines you might like to put in your `.vimrc` file.
-
-[@stevelosh]: http://twitter.com/stevelosh
-[@dotvimrc]: http://twitter.com/dotvimrc
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2011/09/writing-vim-plugins.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,604 @@
++++
+title = "Writing Vim Plugins"
+snip = "It's pretty much black magic."
+date = 2011-09-06T09:13:00Z
+draft = false
+
++++
+
+
+A while ago I wrote a [post][vimpost] about switching back to [Vim][].  Since then
+I've written two plugins for Vim, one of which has been officially "released".
+
+A couple of people have asked me if I'd write a guide to creating Vim plugins.
+I don't feel confident enough to write an official "guide", but I do have some advice
+for Vim plugin authors that might be useful.
+
+[vimpost]: http://stevelosh.com/blog/2010/09/coming-home-to-vim/
+[Vim]: http://www.vim.org/
+
+{{% toc %}}
+
+Other People Who Know More Than I Do
+------------------------------------
+
+Writing two decently-sized Vim plugins has given me some experience, but there are
+a lot of people that know far more than I do.  There are two in particular that come
+to mind.  I'd love for them to write some guides (or even books) about modern-day Vim
+scripting.
+
+### Tim Pope
+
+The first is [Tim Pope][].  He's written a ton of Vim plugins like [Pathogen][],
+[Surround][], [Repeat][], [Speeddating][] and [Fugitive][].  Each of those is clear,
+focused and polished.
+
+It would be awesome to read a guide on the ins and outs of Vim scripting by him.
+
+[Tim Pope]: http://tpo.pe/
+[Pathogen]: https://github.com/tpope/vim-pathogen
+[Surround]: https://github.com/tpope/vim-surround
+[Repeat]: https://github.com/tpope/vim-repeat
+[Speeddating]: https://github.com/tpope/vim-speeddating
+[Fugitive]: https://github.com/tpope/vim-fugitive
+
+### Scrooloose
+
+The other person that comes to mind is [Scrooloose][], author of [NERDTree][],
+[NERDCommenter][] and [Syntastic][].
+
+His plugins are large and full-featured but work incredibly well, considering how
+tricky and painful Vimscript is to work with.  I'd love to read a guide on writing
+large-scale Vim plugins by him.
+
+[Scrooloose]: http://got-ravings.blogspot.com/
+[NERDTree]: https://github.com/scrooloose/nerdtree
+[NERDCommenter]: https://github.com/scrooloose/nerdcommenter
+[Syntastic]: https://github.com/scrooloose/syntastic
+
+Be Pathogen-Compatible
+----------------------
+
+It's 2011.  When writing your plugin, *please* make its source compatible with
+[Pathogen][].  It's very easy to do this — just set up your project's files like
+this:
+
+```text
+yourplugin/
+    doc/
+        yourplugin.txt
+    plugin/
+        yourplugin.vim
+    ...
+    README
+    LICENSE
+```
+
+This will let users use Pathogen (or [Vundle][]) to install and use your plugin.
+
+The days of "unzip and drag the files into the right directories" and the horror of
+Vimballs are over.  Pathogen and Vundle are the right way to manage plugins, so let
+your users use them.
+
+[Vundle]: https://github.com/gmarik/vundle
+
+Please, For the Love of God, Use normal!
+----------------------------------------
+
+My first piece of actual scripting advice is something simple but important.  If
+you're writing a Vim plugin and need to perform some actions, you might be tempted to
+use `normal`.  Don't.  Instead, you need to use `normal!`.
+
+`normal!` is like `normal`, but ignores mappings the user has set up.  If you use
+plain old `normal dd` and I've remapped `dd` to do something else, the call will use
+my mapping and probably not do what your plugin expects.  Using `normal!` ensures
+that the call will do what you expect no matter what the user has mapped.
+
+This is a single instance of a more general theme. Vim is very customizable and users
+will do lots of crazy things in their `.vimrc` files.  If a key can be mapped or
+a setting changed, you *have* to assume that some user of your plugin will have
+mapped or changed it.
+
+Mapping Keys the Right Way
+--------------------------
+
+Most plugins add key mappings to make them easier to use.  Unfortunately this can be
+tricky to get right.  You can never tell what keys your users have already mapped
+themselves, and shadowing someone's favorite key mapping will break their muscle
+memory and annoy them to no end.
+
+### When to Map Keys
+
+The first question to ask is whether your plugin needs to map keys itself at all.
+
+My [Gundo][] plugin has only one feature that needs to be mapped to a key in order to
+make it useful: the "toggle Gundo" action.
+
+Gundo doesn't map this key itself, because no matter what "default" mapping I pick
+someone will have already mapped it.  Instead I added a section right in the README
+file that shows how a user can map the key themselves:
+
+```vim
+nnoremap <F5> :GundoToggle<CR>
+```
+
+By making users add this line to their `.vimrc` themselves it shows them which key is
+used to toggle Gundo (which they would have to know anyway) and also makes it obvious
+how to change it to suit their taste.
+
+[Gundo]: http://sjl.bitbucket.org/gundo.vim/
+
+### imap and nmap are Pure Evil
+
+Sometimes forcing the user to map their own keys won't work.  Perhaps your plugin has
+many mappings that would be tedious for a user to set up manually (like my
+[Threesome][] plugin), or its mappings are mnemonic and wouldn't really make sense if
+mapped to other keys.
+
+I'll talk more about how to deal with this in a moment, but the most important thing
+to remember when mapping your own keys is that you must always, *always*,
+***always*** use the `noremap` forms of the various `map` commands.
+
+If you map a key with `nmap` and the user has remapped a key that your mapping uses,
+your mapped key will almost certainly not do what you want.  Using `nnoremap` will
+ignore user mappings and do what you expect.
+
+This is the same principle as `normal` and `normal!`: *never* trust your users'
+configurations.
+
+[Threesome]: http://sjl.bitbucket.org/threesome.vim
+
+### Let Me Configure Mappings
+
+If you feel that your plugin must map some keys, please make those mappings
+configurable in some way.
+
+There are a number of ways to do this.  The easiest way is to provide a configuration
+option that disables all mappings.  The user can them remap the keys as they see fit.
+For example:
+
+```vim
+if !exists('g:yourplugin_map_keys')
+    let g:yourplugin_map_keys = 1
+endif
+
+if g:yourplugin_map_keys
+    nnoremap <leader>d :call <sid>YourPluginDelete()<CR>
+endif
+```
+
+Normal users will get the mappings automatically set up for them, and power users can
+remap the keys to whatever they wish to avoid shadowing their own mappings.
+
+If your plugin's mappings all start with a common prefix (like `<leader>` or
+`<localleader>`) you have another option: allow users to configure this prefix.  This
+is the approach I've used in [Threesome][].  It works like this:
+
+```vim
+if !exists('g:yourplugin_map_prefix')
+    let g:yourplugin_map_prefix = '<leader>'
+endif
+
+execute "nnoremap"  g:yourplugin_map_prefix."d"  ":call <sid>YourPluginDelete()<CR>"
+```
+
+The `execute` command lets you build the mapping string dynamically so your users can
+change the mapping prefix.
+
+There is a third option for solving this problem: the `hasmapto()` Vim function.
+Some plugins will use this to map a command to a key *unless* the user has already
+mapped that command to something else.  I don't personally like this option because
+it feels less clear to me, but I know other people feel differently so I wanted to
+mention it.
+
+Localize Mappings and Settings
+------------------------------
+
+The next step in being a good Vim plugin author is to try to minimize the effects of
+your key mappings and setting changes.  Some plugins will need to have global
+effects but others will not.
+
+For example: if you're writing a plugin for working with Python files it should only
+take effect for Python buffers, not all buffers.
+
+### Localizing Mappings
+
+Key binding are easy to localize to single buffers.  All of the `noremap` commands
+can take an extra `<buffer>` argument that will localize the mapping to the current
+buffer.
+
+```vim
+" Remaps <leader>z globally
+nnoremap <leader>z :YourPluginFoo<cr>
+
+" Remaps <leader>z only in the current buffer
+nnoremap <buffer> <leader>z :YourPluginFoo<cr>
+```
+
+However, the problem is that you need to run this command in every buffer you want
+the mapping active.  To do this your plugin can use an `autocommand`.  Here's a full
+example, using this concept plus the previously mentioned configuration options:
+
+    if !exists('g:yourplugin_map_keys')
+        let g:yourplugin_map_keys = 1
+    endif
+
+    if !exists('g:yourplugin_map_prefix')
+        let g:yourplugin_map_prefix = '<leader>'
+    endif
+
+    if g:yourplugin_map_keys
+        execute "autocommand FileType python" "nnoremap <buffer>" g:yourplugin_map_prefix."d"  ":call <sid>YourPluginDelete()<CR>"
+    endif
+
+Now your plugin will define a key mapping only for Python buffers, and your users can
+disable or customize this mapping as they see fit.
+
+This mapping command is quite ugly.  Unfortunately that's the price of using
+Vimscript and trying to make a plugin that will work for many users.  Later I'll talk
+about one possible solution to this ugliness.
+
+### Localizing Settings
+
+Just as you should make mappings local to buffers when appropriate, you should do the
+same with settings like `foldmethod`, `foldmarker` and `shiftwidth`.  Not all
+settings can be set locally in a buffer.  You can read `:help <settingname>` to see
+if it's possible.
+
+You can use `setlocal` instead of `set` to localize settings to individual buffers.
+Like with mappings you'll need to use an autocommand to run the `setlocal` command
+every time the users opens a new buffer.
+
+Autoload is Your Friend
+-----------------------
+
+If your plugin is something that users will be using all the time you can skip this
+section.
+
+If you're writing something that will only be used in specific cases, you can help
+your users by using Vim's `autoload` functionality to delay loading its code until
+the user actually tries to use it.
+
+The way `autoload` works is fairly simple.  Normally you would bind a key to call one of your
+plugin's functions with something like this:
+
+```vim
+nnoremap <leader>z :call YourPluginFunction()<CR>
+```
+
+You can use autoloading by prepending `yourplugin#` to the name of the function:
+
+```vim
+nnoremap <leader>z :call yourplugin#YourPluginFunction()<CR>
+```
+
+When this mapping is run, Vim will do the following:
+
+1. Check to see if `YourPluginFunction` is already defined.  If so, call it.
+2. Otherwise, look in `~/.vim/autoload/` for a file named `yourplugin.vim`.
+3. If it exists, parse and load the file (which presumably defines
+  `YourPluginFunction` somewhere inside of it).
+4. Call the function.
+
+This means that instead of putting all of your plugin's code in
+`plugin/yourplugin.vim` you can put just the key mapping code there and pull the rest
+out into `autoload/yourplugin.vim`.
+
+If your plugin has a decent amount of code this can reduce the startup time of Vim by
+a significant amount.
+
+Check out the full documentation of `autoload` by running `:help autoload` to learn
+much more.
+
+Backwards Compatibility is a Big Deal
+-------------------------------------
+
+Once you've written your Vim plugin and released it into the wild, you have to
+maintain it.  Users will find bugs and ask for new features.
+
+Part of being a responsible developer of any kind, including a Vim plugin author, is
+maintaining backwards compatibility, *especially* for tools that users will use every
+day and burn into their muscle memory.  Users rely on tools to work, and tools that
+break backwards compatibility will quickly lose users' trust.
+
+Maintaining backwards compatibility will cause your plugin's code to get crufty in
+spots, but it's the price of maintaining your users' happiness.
+
+### What Matters for Backards Compatibility?
+
+For a Vim plugin the most important part of staying backwards compatible is ensuring
+that key mappings, customized or not, continue to do what users expect.
+
+If your plugin maps key `X` to do `Y`, then pressing `X` should *always* do `Y`, even
+if you change how `Y` is called by renaming `Y` to `Z`.  This may mean changing `Y`
+into a wrapper function which simply calls `Z`.
+
+There are many other aspects of backwards compatibility that you will have to
+consider, depending on the purpose of your plugin.  The rule of thumb you should
+follow is: if a user uses this plugin on a daily basis and has its usage burned into
+their muscle memory, updating the plugin should not make them relearn anything.
+
+### Use Semantic Versioning So I Can Stay Sane
+
+A fast, simple, easy way to document your plugin's state is to use [semantic
+versioning][].
+
+Semantic versioning is simply the idea that instead of picking arbitrary version
+numbers for releases of your project, you use version numbers that describe the
+backwards-compatible state in a meaningful way.
+
+In a nutshell, these rules describe how you should select version numbers for new
+releases:
+
+* Version numbers have three components: `major.minor.bugfix`.  For example: `1.2.4`
+  or `2.13.0`.
+* Versions with a major version of 0 (e.g. `0.2.3`) make no guarantees about
+  backwards compatibility.  You are free to break anything you want.  It's only after
+  you release `1.0.0` that you begin making promises.
+* If a release introduces backwards-incompatible changes, increment the major version
+  number.
+* If a release is backwards-compatible, but adds *new* features, increment the minor
+  version number.
+* If a release simply fixes bugs, refactors code, or improves performance, increment
+  the bugfix version number.
+
+This simple scheme makes it easy for users to tell (in a broad sense) what has
+changed when they update your project.
+
+If only the bugfix number has changed they can update without fear and continue on
+without worrying about changes unless they're curious.
+
+If the minor version number has changed they might want to look at the changelog to
+see what new features they may want to take advantage of, but if they're busy they
+can simply update and move on.
+
+If the major version number has changed it's a major red flag, and they'll want to
+read the changelog carefully to see what is different.
+
+Some people don't like semantic versioning for the following reason:
+
+> If I have to increment the major version number every time I make
+> backwards-incompatible changes, I'll quickly be at ugly versions like 24.1.2!
+
+To this I say: "Yes, but if that happens you're doing things wrong in the first
+place."
+
+Keep your project in "beta" (i.e. version `0.*.*`) for as long as you need to
+experiment freely.  *Take your time* and make sure you've gotten things (mostly)
+right.  Once you release `1.0.0` it's time to start being responsible and caring
+about backwards compatibility.
+
+Breaking functionality all the time harms your users by reducing their productivity
+and frustrating them.  Yes, it means adding some cruft to your code over time, but
+it's the price of not being evil.
+
+[semantic versioning]: http://semver.org/
+
+Document Everything
+-------------------
+
+A critical part of releasing a Vim plugin to the world is writing documentation for
+it.  Vim has fantastic documentation itself, so your plugins should follow in its
+footsteps and provide thorough docs.
+
+### Pick Some Requirements and Stick to Them
+
+The most important part of your documentation is telling users what they need to have
+in order to use your plugin.  Vim runs on nearly every system imaginable and can be
+compiled in many different ways, so being specific about your plugin's requirements
+will save users a lot of trial and error.
+
+* Does your plugin only work with Vim version X.Y or later?
+* Does it require Python/Ruby/etc support compiled in?  Which version?
+* Does it not work on Windows?
+* Does it rely on an external tool?
+
+If the answer to any of those questions is "yes", you *must* mention it in the
+documentation.
+
+### Write a README
+
+The first step to documenting your plugin is to write a README file for the
+repository.  You can also use the text of this file as the description if you upload
+your plugin to the [vim website][], or the content of your plugin's website if you
+create one for it.
+
+Some examples of things to include in your README are:
+
+* An overview of what the plugin does.
+* Screenshots, if possible.
+* Requirements.
+* Installation instructions.
+* Common configuration options that many users will want to know.
+* Links to:
+    * A canonical web address to find the plugin.
+    * The bug tracker for the plugin.
+    * The source code or repository of the plugin.
+
+[vim website]: http://www.vim.org/
+
+### Create a Simple Website
+
+This isn't strictly necessary, but having a simple website for your plugin is an
+extra touch that makes it seem more polished.
+
+It also gives you a canonical URL that people can visit to get the latest information
+about your plugin.
+
+I've made simple sites for both of my plugins: [Gundo][] and [Threesome][].  Feel
+free to use them as an example or even take their code and use it for your own plugin
+sites if you like.
+
+### Write a Vim Help Document
+
+The bulk of your plugin's documentation should be in the form of a Vim help document.
+Users are used to using Vim's `:help` and they'll expect to be able to use it to
+learn about your plugin.
+
+Creating a help document is as easy as creating a `doc/yourplugin.txt` file in your
+project.  It will be indexed automatically by `pathogen#helptags()` so your users
+will have the docs at their fingertips.
+
+Two easy ways to learn the syntax of help files are by reading `:help help-writing`
+and using an existing plugin's help file as an example.
+
+Take your time and craft a beautiful help file you can be proud of.  Don't be afraid
+to add a bit of personality to your docs to break the dryness.  The [syntastic help
+file][syntastic help] is a great example (especially the `About` section).
+
+Things to include in your documentation:
+
+* A brief overview of the plugin.
+* A more in-depth description of how the plugin is used.
+* Every single key mapping the plugin creates.
+* Ways to extend the plugin, if applicable.
+* All configuration variables (including their default values!).
+* The plugin's changelog.
+* The plugin's license.
+* Links to the plugin's repository and bug tracker.
+
+In a nutshell: your help file should contain *anything* a user would ever need to know
+about your plugin.
+
+[syntastic help]: https://github.com/scrooloose/syntastic/blob/master/doc/syntastic.txt
+
+### Keep a Changelog
+
+The last part of documenting your project is keeping a changelog.  You can skip this
+while your project is still in "beta" (i.e. less than version `1.0.0`) but once you
+officially release a real version you need to keep your users informed about what has
+changed between releases.
+
+I like to include this log in the README, the plugin's website, and the
+documentation to make it as easy as possible for users to see what's changed.
+
+Try to keep the language of the changelog at a high enough level for your users to
+understand without knowing anything about the implementation of your plugin.  Things
+like "added feature X" and "fixed bug Y" are great, while things like "refactored the
+inner workings of utility function Z" are best left in commit messages.
+
+Making Vimscript Palatable
+--------------------------
+
+The worst part about writing Vim plugins is, without a doubt, dealing with Vimscript.
+It's an esoteric language that's grown organically over the years seemingly without
+any strong design direction.
+
+Features are added to Vim, then Vimscript features are added to control those
+features, then hacky workarounds are added for flexibility.
+
+The syntax is terse, ugly and inconsistent.  Is `" foo` a comment?  Sometimes.
+
+Much of the time you'll spend writing your first plugin will be learning how to do
+things in Vimscript.  The help documentation on all of its features is thorough, but
+it can be hard to find what you're looking for if you don't know the exact name.
+Looking through other plugins is often very helpful in pointing you toward what you
+need.
+
+There are a couple of ways to ease the pain of Vimscript, and I'll briefly talk about
+two of them here.
+
+### Wrap. Everything.
+
+The first piece of advice I have is this: if you want to make your plugins readable
+and maintainable then you need to wrap up functionality even more than you would in
+other languages.
+
+For example, my [Gundo][] plugin has a few utility functions that look like this:
+
+```vim
+function! s:GundoGoToWindowForBufferName(name)"{{{
+    if bufwinnr(bufnr(a:name)) != -1
+        exe bufwinnr(bufnr(a:name)) . "wincmd w"
+        return 1
+    else
+        return 0
+    endif
+endfunction"}}}
+```
+
+This function will go to the window for the given buffer name and gracefully handle
+the case where the buffer/window does not exist.  It's verbose but much more readable
+than the alternative of using that `if` statement in every place I need to switch
+windows.
+
+As you write your plugin you'll "grow" a number of these utility functions.  Any time
+you duplicate code you should think about creating one, but you should also do so any
+time you write a particularly hairy line of Vimscript.  Pulling complex lines out
+into named functions will save you a lot of reviewing and rethinking down the line.
+
+### Scripting Vim with Other Languages
+
+Another option for making Vimscript less painful is to simply not use it much at all.
+Vim includes support for creating plugins in a number of other languages like Python
+and Ruby.  Many plugin authors choose to move nearly all of their code into another
+language, using a small Vimscript "wrapper" to expose it to the user.
+
+I decided to try this approach with [Threesome][] after seeing it used in the
+[vim-orgmode][] plugin to great effect.  Overall I consider it to be a good idea,
+with a few caveats.
+
+First, using another language will requires your plugin's users to use a version of
+Vim compiled with support for that version.  In this day and age it's usually not
+a problem, but if you want your plugin to run everywhere then it's not an option.
+
+Using another language adds overhead.  You need to not only learn Vimscript but also
+the interface between Vim and the language.  For small plugins this can add more
+complexity to the project than it saves, but for larger plugins it can pay for
+itself.  It's up to you to decide whether it's worth it.
+
+Finally, using another language does not entirely insulate you from the
+eccentricities of Vimscript.  You still need to learn how to do most things in
+Vimscript — using another language simply lets you wrap most of this up more neatly
+than you otherwise could.
+
+[vim-orgmode]: https://github.com/jceb/vim-orgmode
+
+### Unit Testing Will Make You Drink
+
+Unit testing (and other types of testing) is becoming more and more popular today.
+In particular the Python and Ruby communities seem to be getting more and more
+excited about it as time goes on.
+
+Unfortunately, unit testing Vim plugins lies somewhere between "painful" and
+"[garden-weasel][]ing your face" on the difficulty scale.
+
+I tried adding some unit tests to [Gundo][], but even after looking at a number of
+frameworks I was spending hours simply trying to get my tests to function.
+
+I didn't even bother trying to add tests to [Threesome][] because for every hour
+I would have spent fighting Vim to create tests I could have cleaned up the code and
+fixed bugs instead.
+
+I'll gladly change my opinion on the subject if someone writes a unit testing
+framework for Vim that's as easy to use as [Cram][].  In fact, I'll even buy the
+author a $100 bottle of scotch (or whatever they prefer).
+
+Until that happens I personally don't think it's worth your time to unit test Vim
+plugins.  Spend your extra hours reading documentation, testing things manually with
+a variety of settings, and thinking hard about your code instead.
+
+[garden-weasel]: http://www.amazon.com/Garden-Weasel-90206/dp/B002ECYRH4 
+[Cram]: https://bitheap.org/cram/
+
+TL;DR
+-----
+
+Writing Vim plugins is tricky.  Vimscript is a rabbit hole of sadness and despair,
+and trying to please all your users while maintaining backwards compatibility is
+a monumental task.
+
+With that said, creating something that people use every day to help them make
+beautiful software projects is extremely rewarding.  Even if your plugin doesn't get
+many users, being able to use a tool *you wrote* is very satisfying.
+
+So if you've got an idea for a plugin that would make Vim better just sit down, learn
+about Vimscript, create it, and release it so we can all benefit.
+
+If you have any questions or comments feel free to hit me up [on
+Twitter][@stevelosh].  You might also enjoy following [@dotvimrc][] where I try to
+tweet random, bite-sized lines you might like to put in your `.vimrc` file.
+
+[@stevelosh]: http://twitter.com/stevelosh
+[@dotvimrc]: http://twitter.com/dotvimrc
+
--- a/content/blog/2012/04/volatile-software.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,323 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Volatile Software"
-        snip: "Our culture is one of pain and suffering."
-        created: 2012-04-23 14:00:00
-    %}
-
-{% block article %}
-
-The following is the text of an email I sent to [The Listserve][], which was
-sent to that list on April 22, 2012.
-
-[The Listserve]: http://thelistserve.com/
-
-<hr/>
-
-I want to use my fifteen minutes of fame on The Listserve to rant about
-something that's close to my heart: the stability of the software I use.
-
-NOTE: This is written for people who create software.  If you don't do that you
-probably won't find this very interesting.  Sorry!  Maybe you could read Text
-from Dog if you haven't seen it already?  Either way, have a nice
-morning/afternoon/evening!
-
-The Situation
--------------
-
-Every time I get a new computer, I go through the same song and dance:
-
-1. Look at what programs and packages I have installed on the old computer.
-2. Install these programs on the new computer.
-3. Copy over my configuration files from the old computer to the new one.
-4. Spend the rest of my day fixing all the things that broke because I'm using
-   a newer version of program X.
-
-Step 4 is always the most painful part of getting a new machine.  Always.
-
-Without fail I spend several hours tweaking configuration files, adjusting my
-workflow, and so on because I've upgraded to a new version of foo which doesn't
-support option X any more or requires library Y version N+1 now.
-
-Getting a new computer should be a *pleasant* experience!  The unboxing from the
-sleek packaging, that "new laptop" smell, the nostalgia of the default desktop
-image.  Why does this horrible step 4 have to exist and how can we get rid of
-it?
-
-The Divide
-----------
-
-I've noticed something interesting lately: I can categorize almost *all* of the
-software I use into two distinct groups:
-
-* Software that breaks pretty much *every* time I update it (e.g. weechat,
-  offlineimap, Clojure, many Python packages, Skype).
-* Software that almost *never* breaks when I update it (e.g. Mercurial, git,
-  tmux, Python, ack, zsh, Vim, Dropbox).
-
-Software that falls in between these two extremes is surprisingly rare.  There
-seems to be a pretty clean divide between the two groups.
-
-This makes me think that there's some special attribute or quality of the
-second group (or its authors) which the first one lacks.
-
-Brokenness
-----------
-
-I think it's important that I nail down what I mean by "breaks" or "is broken".
-I don't necessarily just mean the introduction of "new bugs".
-
-When I say that a program "breaks", I mean:
-
-* When I update from version X to version Y of a program, library, or language...
-* Without changing my configuration files, source code, etc...
-* The resulting combination doesn't work properly
-
-In effect, I'm saying that "breaking backwards compatibility" means "the program
-is broken"!
-
-This may be a strong statement, but I stand by it in most cases.
-
-Backwards compatibility matters!  Every time someone makes a backwards
-incompatible change in a program or library, they cost the world the following
-amount of time:
-
-    Number of people         Time it takes each person
-    using that part of   X   to figure out what changed
-    the program              and how to fix it
-
-Often this can be a significant amount of time!
-
-The Process of Updating
------------------------
-
-When pointing out a backwards incompatible change to someone, you'll often get
-a response similar to this:
-
-> "Well, I mentioned that backwards incompatibility in the changelog, so what
-> the hell, man!"
-
-This is not a satisfactory answer.
-
-When I'm updating a piece of software there's a good chance it's not because I'm
-specifically updating *that program*.  I might be:
-
-* Moving to a new computer.
-* Running a "$PACKAGE\_MANAGER update" command.
-* Moving a website to a bigger VPS and reinstalling all the libraries.
-
-In those cases (and many others) I'm not reading the release notes for
-a specific program or library.  I'm not going to find out about the brokenness
-until I try to use the program the next time.
-
-If I'm lucky the program will have a "this feature is now deprecated, read the
-docs" error message.  That's still a pain, but at least it's less confusing than
-just getting a traceback, or worst of all: silently changing the behavior of
-a feature.
-
-Progress
---------
-
-I completely understand that when moving *backwards* to an older version
-I should expect problems.  The older version hasn't had the benefit of the extra
-work done on the new version, so of course it should be less stable.
-
-But when I'm *updating* to a higher version number the software should be
-*better* and *more stable*!  It has had more work done on it, and I assume no
-one is actively trying to make software worse, so why does something that
-previously worked no longer work?
-
-We're supposed to be making *progress* as we move forward.  The software has had
-*more* work done on it, why does it not function correctly *now* when it
-functioned correctly *before*?
-
-Yes, this means developers will need to add extra code to handle old
-input/configuration.  Yes, this is a pain in the ass, but *the entire point of
-most software is to save people time by automating things*.  Again, every
-backwards-incompatible change costs the world an amount of time:
-
-    Number of people         Time it takes each person
-    using that part of   X   to figure out what changed
-    the program              and how to fix it
-
-If our goal is to *save time* then we should not make changes that *cost time*.
-Or at least we should not make such changes lightly.
-
-A Culture of Sadness
---------------------
-
-Proof that this is a real issue can be found in the tools we use every day.  As
-programmers we've invented elaborate dependency systems to deal with it.
-
-We say `pip install django==1.3` or put `[clojure "1.2"]` in our Leiningen
-project.clj files to avoid using the newest versions because they'll break.
-
-Step back and look at this for a second.
-
-What the hell?
-
-What the *hell*?
-
-We have invented software with features designed to help us use *old* versions
-of other software!
-
-We have *written code* to *avoid* using the "latest and greatest" software!
-
-Obviously this is not entirely bad, but the fact that manually specifying
-version numbers to avoid running *newer* code is commonplace, expected, and
-a "best practice" horrifies me.
-
-I would *love* to be able to say something like this in my requirements.txt and
-project.clj files:
-
-> Of *course* I want the latest version of library X!  I want *all* the newest
-> bug fixes and improvements!
-
-Unfortunately I can't do that right now because so many projects make backwards
-incompatible changes all the time.
-
-The moment I try to build the project at some point in the future I'll be sent
-on a wild goose chase to figure out what function moved into what other
-namespace and what other function was split into its own library and dammit the
-documentation on the project's website is autogenerated from the tip of its git
-repo and so it doesn't apply to the latest actual version and jesus christ
-I think I'll just quit programming and teach dance full time instead even though
-I'll go hungry.
-
-The Tradeoff
-------------
-
-One could argue that sometimes backwards incompatible changes cost time up front
-but save time in the long run by making the software more "elegant" and "lean".
-
-While I'm sure there are cases where this is true, I feel like it's a cop out
-most of the time.  Allow me to illustrate this with a helpful Venn diagram:
-
-    :::text
-                          -------
-                         /3333333\
-                        |333333333|
-                         \3333333/
-                          -------
-
-    11 -> People who give a shit what a program's codebase
-    11    looks like.
-
-    22 -> The authors of said program.
-    22
-
-For libraries where the author is the only user, none of this rant applies.
-You're free!  Break as much as you like!
-
-For the majority of libraries, however, there are probably vastly more "users"
-than "authors".  Saving a few hours of the authors' own time has to be weighed
-against the 10 minutes each that the hundreds of users will have to spend
-figuring out what happened and working around it.
-
-I want to be clear: being backwards compatible *doesn't* mean sacrificing new
-features!  New features can still be added!  Refactoring can still happen!
-
-In most cases keeping backwards compatibility simply means maintaining a bit of
-wrapper code to support people using the previous version.
-
-For example: in Python, if we moved the public foo() function to a new module,
-we'd put the following line in the original module:
-
-    :::python
-    from newmodule import new_foo as foo
-
-Is it pretty?  Hell no!  But this single line of code will probably save more
-people more time than most of the other lines in the project!
-
-This may just be an artifact of how my brain is wired, but I actually get
-a sense of satisfaction from writing code that bridges the gap between older
-versions and new.
-
-I can almost hear a little voice in my head saying:
-
-> "Mwahaha, I'll slip this refactoring past them and they'll never even know it
-> happened!"
-
-Maybe it's just me, but I think that "glue" code can be clever and beautiful in
-its own right.
-
-It may not bring a smile to anyone's face like a shiny new feature, but it
-prevents many frowns instead, and preventing a frown makes the world a happier
-place just as much as creating a smile!
-
-Exceptions
-----------
-
-One case where I feel the backwards incompatibility tradeoff *is* worth it is
-security.
-
-A good example of this is Django's change which made AJAX requests no longer be
-exempt from CSRF checks.  It was backwards incompatible and I'm sure it broke
-some people's projects, but I think it was the right thing to do because it
-improved security.
-
-I also think it's unreasonable to expect all software to be perfectly ready from
-its first day.
-
-Sometimes software needs to get poked and prodded in the real world before it's
-fully baked, and until then requiring strict backwards compatibility will do
-more harm than good.
-
-By all means, backwards compatibility should be thrown to the wind in the first
-stage of a project's life.  At the beginning it needs to find its legs, like
-a baby gazelle on the Serengeti.  But at some point the project needs to get its
-balance, grow up, and start concerning itself with backwards compatibility.
-
-But when should that happen?
-
-A Solution
-----------
-
-I think there's a simple, intuitive way to mark the transition of a piece of
-software from "volatile" to "stable":
-
-**Version 1.0**
-
-Before version 1, software can change and evolve rapidly with no regards for
-breaking, but once that first number becomes "greater than or equal to 1" it's
-time to be a responsible member of the software community and start thinking
-about the real humans whose time gets wasted for every breaking change.
-
-This is the approach semantic versioning takes, and I think it's the right one.
-
-I know a lot of people dislike semantic versioning.  They hate how requires
-incrementing the major version number every time a breaking change is made.
-
-I consider it to be a *good* thing.
-
-You *should* pause and carefully consider making a change that will break
-people's current code.
-
-You *should* be ashamed if your project is at version 43.0.0 because you've made
-42 breaking changes.  That's 43 times you've disregarded your users' time!
-That's a bad thing!
-
-As programmers we need to start caring about the people we write software for.
-
-Before making a change that's going to cause other people pain, we should ask
-ourselves if it's really worth the cost.  Sometimes it is, but many times it's
-not, and we can wrap the change up so it doesn't hurt anyone.
-
-So please, before you make that backwards incompatible change, think of the
-other human beings who are going to smack their monitors when your software
-breaks.
-
-Further Reading
----------------
-
-I'm certainly not the only person to notice this problem.  Many smarter people
-than me have talked about it.  If you want to read more you might want to look
-up some or all of the following (Google is your friend):
-
-* The Semantic Versioning spec (the specific numbering details don't matter as
-  much as the philosophy).
-* Anything Matt Mackall has written on the Mercurial mailing list (especially
-  the mails where he sounds especially grouchy).
-* Anything about "software rot" or "code rot".
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/04/volatile-software.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,322 @@
++++
+title = "Volatile Software"
+snip = "Our culture is one of pain and suffering."
+date = 2012-04-23T14:00:00Z
+draft = false
+
++++
+
+The following is the text of an email I sent to [The Listserve][], which was
+sent to that list on April 22, 2012.
+
+[The Listserve]: http://thelistserve.com/
+
+<hr/>
+
+I want to use my fifteen minutes of fame on The Listserve to rant about
+something that's close to my heart: the stability of the software I use.
+
+NOTE: This is written for people who create software.  If you don't do that you
+probably won't find this very interesting.  Sorry!  Maybe you could read Text
+from Dog if you haven't seen it already?  Either way, have a nice
+morning/afternoon/evening!
+
+The Situation
+-------------
+
+Every time I get a new computer, I go through the same song and dance:
+
+1. Look at what programs and packages I have installed on the old computer.
+2. Install these programs on the new computer.
+3. Copy over my configuration files from the old computer to the new one.
+4. Spend the rest of my day fixing all the things that broke because I'm using
+   a newer version of program X.
+
+Step 4 is always the most painful part of getting a new machine.  Always.
+
+Without fail I spend several hours tweaking configuration files, adjusting my
+workflow, and so on because I've upgraded to a new version of foo which doesn't
+support option X any more or requires library Y version N+1 now.
+
+Getting a new computer should be a *pleasant* experience!  The unboxing from the
+sleek packaging, that "new laptop" smell, the nostalgia of the default desktop
+image.  Why does this horrible step 4 have to exist and how can we get rid of
+it?
+
+The Divide
+----------
+
+I've noticed something interesting lately: I can categorize almost *all* of the
+software I use into two distinct groups:
+
+* Software that breaks pretty much *every* time I update it (e.g. weechat,
+  offlineimap, Clojure, many Python packages, Skype).
+* Software that almost *never* breaks when I update it (e.g. Mercurial, git,
+  tmux, Python, ack, zsh, Vim, Dropbox).
+
+Software that falls in between these two extremes is surprisingly rare.  There
+seems to be a pretty clean divide between the two groups.
+
+This makes me think that there's some special attribute or quality of the
+second group (or its authors) which the first one lacks.
+
+Brokenness
+----------
+
+I think it's important that I nail down what I mean by "breaks" or "is broken".
+I don't necessarily just mean the introduction of "new bugs".
+
+When I say that a program "breaks", I mean:
+
+* When I update from version X to version Y of a program, library, or language...
+* Without changing my configuration files, source code, etc...
+* The resulting combination doesn't work properly
+
+In effect, I'm saying that "breaking backwards compatibility" means "the program
+is broken"!
+
+This may be a strong statement, but I stand by it in most cases.
+
+Backwards compatibility matters!  Every time someone makes a backwards
+incompatible change in a program or library, they cost the world the following
+amount of time:
+
+    Number of people         Time it takes each person
+    using that part of   X   to figure out what changed
+    the program              and how to fix it
+
+Often this can be a significant amount of time!
+
+The Process of Updating
+-----------------------
+
+When pointing out a backwards incompatible change to someone, you'll often get
+a response similar to this:
+
+> "Well, I mentioned that backwards incompatibility in the changelog, so what
+> the hell, man!"
+
+This is not a satisfactory answer.
+
+When I'm updating a piece of software there's a good chance it's not because I'm
+specifically updating *that program*.  I might be:
+
+* Moving to a new computer.
+* Running a "$PACKAGE\_MANAGER update" command.
+* Moving a website to a bigger VPS and reinstalling all the libraries.
+
+In those cases (and many others) I'm not reading the release notes for
+a specific program or library.  I'm not going to find out about the brokenness
+until I try to use the program the next time.
+
+If I'm lucky the program will have a "this feature is now deprecated, read the
+docs" error message.  That's still a pain, but at least it's less confusing than
+just getting a traceback, or worst of all: silently changing the behavior of
+a feature.
+
+Progress
+--------
+
+I completely understand that when moving *backwards* to an older version
+I should expect problems.  The older version hasn't had the benefit of the extra
+work done on the new version, so of course it should be less stable.
+
+But when I'm *updating* to a higher version number the software should be
+*better* and *more stable*!  It has had more work done on it, and I assume no
+one is actively trying to make software worse, so why does something that
+previously worked no longer work?
+
+We're supposed to be making *progress* as we move forward.  The software has had
+*more* work done on it, why does it not function correctly *now* when it
+functioned correctly *before*?
+
+Yes, this means developers will need to add extra code to handle old
+input/configuration.  Yes, this is a pain in the ass, but *the entire point of
+most software is to save people time by automating things*.  Again, every
+backwards-incompatible change costs the world an amount of time:
+
+    Number of people         Time it takes each person
+    using that part of   X   to figure out what changed
+    the program              and how to fix it
+
+If our goal is to *save time* then we should not make changes that *cost time*.
+Or at least we should not make such changes lightly.
+
+A Culture of Sadness
+--------------------
+
+Proof that this is a real issue can be found in the tools we use every day.  As
+programmers we've invented elaborate dependency systems to deal with it.
+
+We say `pip install django==1.3` or put `[clojure "1.2"]` in our Leiningen
+project.clj files to avoid using the newest versions because they'll break.
+
+Step back and look at this for a second.
+
+What the hell?
+
+What the *hell*?
+
+We have invented software with features designed to help us use *old* versions
+of other software!
+
+We have *written code* to *avoid* using the "latest and greatest" software!
+
+Obviously this is not entirely bad, but the fact that manually specifying
+version numbers to avoid running *newer* code is commonplace, expected, and
+a "best practice" horrifies me.
+
+I would *love* to be able to say something like this in my requirements.txt and
+project.clj files:
+
+> Of *course* I want the latest version of library X!  I want *all* the newest
+> bug fixes and improvements!
+
+Unfortunately I can't do that right now because so many projects make backwards
+incompatible changes all the time.
+
+The moment I try to build the project at some point in the future I'll be sent
+on a wild goose chase to figure out what function moved into what other
+namespace and what other function was split into its own library and dammit the
+documentation on the project's website is autogenerated from the tip of its git
+repo and so it doesn't apply to the latest actual version and jesus christ
+I think I'll just quit programming and teach dance full time instead even though
+I'll go hungry.
+
+The Tradeoff
+------------
+
+One could argue that sometimes backwards incompatible changes cost time up front
+but save time in the long run by making the software more "elegant" and "lean".
+
+While I'm sure there are cases where this is true, I feel like it's a cop out
+most of the time.  Allow me to illustrate this with a helpful Venn diagram:
+
+```text
+                      -------
+                     /3333333\
+                    |333333333|
+                     \3333333/
+                      -------
+
+11 -> People who give a shit what a program's codebase
+11    looks like.
+
+22 -> The authors of said program.
+22
+```
+
+For libraries where the author is the only user, none of this rant applies.
+You're free!  Break as much as you like!
+
+For the majority of libraries, however, there are probably vastly more "users"
+than "authors".  Saving a few hours of the authors' own time has to be weighed
+against the 10 minutes each that the hundreds of users will have to spend
+figuring out what happened and working around it.
+
+I want to be clear: being backwards compatible *doesn't* mean sacrificing new
+features!  New features can still be added!  Refactoring can still happen!
+
+In most cases keeping backwards compatibility simply means maintaining a bit of
+wrapper code to support people using the previous version.
+
+For example: in Python, if we moved the public foo() function to a new module,
+we'd put the following line in the original module:
+
+```python
+from newmodule import new_foo as foo
+```
+
+Is it pretty?  Hell no!  But this single line of code will probably save more
+people more time than most of the other lines in the project!
+
+This may just be an artifact of how my brain is wired, but I actually get
+a sense of satisfaction from writing code that bridges the gap between older
+versions and new.
+
+I can almost hear a little voice in my head saying:
+
+> "Mwahaha, I'll slip this refactoring past them and they'll never even know it
+> happened!"
+
+Maybe it's just me, but I think that "glue" code can be clever and beautiful in
+its own right.
+
+It may not bring a smile to anyone's face like a shiny new feature, but it
+prevents many frowns instead, and preventing a frown makes the world a happier
+place just as much as creating a smile!
+
+Exceptions
+----------
+
+One case where I feel the backwards incompatibility tradeoff *is* worth it is
+security.
+
+A good example of this is Django's change which made AJAX requests no longer be
+exempt from CSRF checks.  It was backwards incompatible and I'm sure it broke
+some people's projects, but I think it was the right thing to do because it
+improved security.
+
+I also think it's unreasonable to expect all software to be perfectly ready from
+its first day.
+
+Sometimes software needs to get poked and prodded in the real world before it's
+fully baked, and until then requiring strict backwards compatibility will do
+more harm than good.
+
+By all means, backwards compatibility should be thrown to the wind in the first
+stage of a project's life.  At the beginning it needs to find its legs, like
+a baby gazelle on the Serengeti.  But at some point the project needs to get its
+balance, grow up, and start concerning itself with backwards compatibility.
+
+But when should that happen?
+
+A Solution
+----------
+
+I think there's a simple, intuitive way to mark the transition of a piece of
+software from "volatile" to "stable":
+
+**Version 1.0**
+
+Before version 1, software can change and evolve rapidly with no regards for
+breaking, but once that first number becomes "greater than or equal to 1" it's
+time to be a responsible member of the software community and start thinking
+about the real humans whose time gets wasted for every breaking change.
+
+This is the approach semantic versioning takes, and I think it's the right one.
+
+I know a lot of people dislike semantic versioning.  They hate how requires
+incrementing the major version number every time a breaking change is made.
+
+I consider it to be a *good* thing.
+
+You *should* pause and carefully consider making a change that will break
+people's current code.
+
+You *should* be ashamed if your project is at version 43.0.0 because you've made
+42 breaking changes.  That's 43 times you've disregarded your users' time!
+That's a bad thing!
+
+As programmers we need to start caring about the people we write software for.
+
+Before making a change that's going to cause other people pain, we should ask
+ourselves if it's really worth the cost.  Sometimes it is, but many times it's
+not, and we can wrap the change up so it doesn't hurt anyone.
+
+So please, before you make that backwards incompatible change, think of the
+other human beings who are going to smack their monitors when your software
+breaks.
+
+Further Reading
+---------------
+
+I'm certainly not the only person to notice this problem.  Many smarter people
+than me have talked about it.  If you want to read more you might want to look
+up some or all of the following (Google is your friend):
+
+* The Semantic Versioning spec (the specific numbering details don't matter as
+  much as the philosophy).
+* Anything Matt Mackall has written on the Mercurial mailing list (especially
+  the mails where he sounds especially grouchy).
+* Anything about "software rot" or "code rot".
--- a/content/blog/2012/07/caves-of-clojure-01.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 1"
-        snip: "Getting a Roguelike up and running."
-        created: 2012-07-07 17:00:00
-    %}
-
-{% block article %}
-
-Lately I've had an urge to start playing a few games again, namely [Nethack][]
-and [Dwarf Fortress][] (the latter being triggered by [this book][df-book]).
-Aside from being incredibly fun, they also made me want to play around with
-writing a [roguelike][] game of my own.
-
-[Nethack]: http://www.nethack.org/
-[Dwarf Fortress]: http://www.bay12games.com/dwarves/
-[df-book]: http://www.amazon.com/gp/product/1449314945/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1449314945&linkCode=as2&tag=stelos-20
-[roguelike]: https://en.wikipedia.org/wiki/Roguelike
-
-I could write them in Python, but lately I've been falling out of love with the
-language.  It's a solid workhorse that's not exciting or beautiful to me at all
-any more.  My affection has shifted more toward Clojure.  Despite its Rubyesque
-culture of brokenness, rampant lack of documentation, and warty JVM interop it's
-still a wonderful language that's captured me (for now).
-
-I've had the idea of writing a few roguelike games for a while, but the other
-day I stumbled on [Trystan Spangler's blog][trystan] and his [series of
-articles][trystan-tut] that walk through writing a roguelike game in Java.
-
-[trystan]: http://trystans.blogspot.com/
-[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-01-java-eclipse.html
-
-I'm going to do a series of blog posts, each corresponding roughly to one of
-Trystan's posts, as I work my way through writing a roguelike in Clojure.  I may
-or may not get all of the way through his twenty-post series.  We'll see.
-
-I'll assume you know Clojure during this series and won't be explaining every
-single thing.
-
-If you want to follow along, the code for this series is [on Bitbucket][bb] and
-[on GitHub][gh].  There are tags like `entry-01` in the repo which you can
-update to and see the code as it stood at the end of that entry.
-
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-Let's jump in.  This entry corresponds to [post one in Trystan's
-tutorial][trystan-tut].
-
-[TOC]
-
-Summary
--------
-
-The first thing to do is to bootstrap an environment for development.  I'll be
-using Clojure 1.4, Leiningen 2, and [clojure-lanterna][] 0.9.0.
-
-Trystan used Eclipse but I'll be using Vim and my fork of SLIMV.
-
-[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
-
-project.clj
------------
-
-I'm starting with a fairly simple `project.clj` file:
-
-    :::clojure
-    (defproject caves "0.1.0-SNAPSHOT"
-      :description "The Caves of Clojure"
-      :url "http://stevelosh.com/blog/2012/07/caves-of-clojure-01/"
-      :license {:name "MIT/X11"}
-      :dependencies [[org.clojure/clojure "1.4.0"]
-                     [clojure-lanterna "0.9.0"]]
-      :main caves.core)
-
-Nothing particularly crazy here.
-
-clojure-lanterna
-----------------
-
-Trystan used his own library called AsciiPanel to handle the drawing of
-characters to the screen.  I'm going to use my own library [clojure-lanterna][],
-which is a wrapper around the [Lanterna][] Java library.
-
-I chose Lanterna because it supports drawing to a Swing-based "terminal" and to
-the actual console.  But unlike some other libraries, it doesn't actually link
-against native code (it's pure Java) so it's more portable.
-
-Being able to output to either a console or a GUI means that I can develop
-through Swank really easily with the Swing terminal, but actuall play the
-finished product in a terminal like God intended.
-
-[Lanterna]: https://code.google.com/p/lanterna/
-
-core.clj
---------
-
-The full `core.clj` file I came up with was this:
-
-    :::clojure
-    (ns caves.core
-      (:require [lanterna.screen :as s]))
-
-
-    (defn main [screen-type]
-      (let [screen (s/get-screen screen-type)]
-        (s/in-screen screen
-                     (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
-                     (s/put-string screen 0 1 "Press any key to exit...")
-                     (s/redraw screen)
-                     (s/get-key-blocking screen))))
-
-
-    (defn -main [& args]
-      (let [args (set args)
-            screen-type (cond
-                          (args ":swing") :swing
-                          (args ":text")  :text
-                          :else           :auto)]
-        (main screen-type)))
-
-We're very much just bootstrapping things for now.  The `-main` function parses
-the command line arguments to figure out what type of terminal we should use,
-and then passes that along to `main`.
-
-For now, `main` simply:
-
-* Gets an appropriately-typed terminal.
-* Outputs a simple message.
-* Redraws the screen (clojure-lanterna's screen layer buffers output until you
-  tell it to redraw).
-* Waits for the user to press a key.
-* Exits.
-
-I chose to split the meat of the setup into a `main` function instead of just
-putting everything in `-main` because that will make it easy for me to work
-through Swank instead of the command line as we'll see in a moment.
-
-Running
--------
-
-There are two main ways to actually make this thing work.
-
-First, we can run it as a standalone program with `lein trampoline run` at the
-command line.  I can pass a parameter to specify what type of terminal to use,
-like `lein trampoline run :swing`.
-
-We can also run it from a REPL, or a SLIME/Swank environment by simply
-evaluating `(main :swing)` in the namespace.  This is why I split out everything
-but the command line argument parsing into a separate function.
-
-Either way, once you run it you get something like this:
-
-![Screenshot](/media/images{{ parent_url }}/caves-01-01.png)
-
-This is the Swing terminal which I happened to start from swank.  Press a key
-and it will go away.
-
-It doesn't look like much, but it's a [black triangle][].  In the next entry
-we'll start doing more interesting things.
-
-[black triangle]: http://rampantgames.com/blog/2004/10/black-triangle.html
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-01.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,164 @@
++++
+title = "The Caves of Clojure: Part 1"
+snip = "Getting a Roguelike up and running."
+date = 2012-07-07T17:00:00Z
+draft = false
+
++++
+
+Lately I've had an urge to start playing a few games again, namely [Nethack][]
+and [Dwarf Fortress][] (the latter being triggered by [this book][df-book]).
+Aside from being incredibly fun, they also made me want to play around with
+writing a [roguelike][] game of my own.
+
+[Nethack]: http://www.nethack.org/
+[Dwarf Fortress]: http://www.bay12games.com/dwarves/
+[df-book]: http://www.amazon.com/gp/product/1449314945/ref=as_li_ss_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=1449314945&linkCode=as2&tag=stelos-20
+[roguelike]: https://en.wikipedia.org/wiki/Roguelike
+
+I could write them in Python, but lately I've been falling out of love with the
+language.  It's a solid workhorse that's not exciting or beautiful to me at all
+any more.  My affection has shifted more toward Clojure.  Despite its Rubyesque
+culture of brokenness, rampant lack of documentation, and warty JVM interop it's
+still a wonderful language that's captured me (for now).
+
+I've had the idea of writing a few roguelike games for a while, but the other
+day I stumbled on [Trystan Spangler's blog][trystan] and his [series of
+articles][trystan-tut] that walk through writing a roguelike game in Java.
+
+[trystan]: http://trystans.blogspot.com/
+[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-01-java-eclipse.html
+
+I'm going to do a series of blog posts, each corresponding roughly to one of
+Trystan's posts, as I work my way through writing a roguelike in Clojure.  I may
+or may not get all of the way through his twenty-post series.  We'll see.
+
+I'll assume you know Clojure during this series and won't be explaining every
+single thing.
+
+If you want to follow along, the code for this series is [on Bitbucket][bb] and
+[on GitHub][gh].  There are tags like `entry-01` in the repo which you can
+update to and see the code as it stood at the end of that entry.
+
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+Let's jump in.  This entry corresponds to [post one in Trystan's
+tutorial][trystan-tut].
+
+{{% toc %}}
+
+Summary
+-------
+
+The first thing to do is to bootstrap an environment for development.  I'll be
+using Clojure 1.4, Leiningen 2, and [clojure-lanterna][] 0.9.0.
+
+Trystan used Eclipse but I'll be using Vim and my fork of SLIMV.
+
+[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
+
+project.clj
+-----------
+
+I'm starting with a fairly simple `project.clj` file:
+
+```clojure
+(defproject caves "0.1.0-SNAPSHOT"
+  :description "The Caves of Clojure"
+  :url "http://stevelosh.com/blog/2012/07/caves-of-clojure-01/"
+  :license {:name "MIT/X11"}
+  :dependencies [[org.clojure/clojure "1.4.0"]
+                 [clojure-lanterna "0.9.0"]]
+  :main caves.core)
+```
+
+Nothing particularly crazy here.
+
+clojure-lanterna
+----------------
+
+Trystan used his own library called AsciiPanel to handle the drawing of
+characters to the screen.  I'm going to use my own library [clojure-lanterna][],
+which is a wrapper around the [Lanterna][] Java library.
+
+I chose Lanterna because it supports drawing to a Swing-based "terminal" and to
+the actual console.  But unlike some other libraries, it doesn't actually link
+against native code (it's pure Java) so it's more portable.
+
+Being able to output to either a console or a GUI means that I can develop
+through Swank really easily with the Swing terminal, but actuall play the
+finished product in a terminal like God intended.
+
+[Lanterna]: https://code.google.com/p/lanterna/
+
+core.clj
+--------
+
+The full `core.clj` file I came up with was this:
+
+```clojure
+(ns caves.core
+  (:require [lanterna.screen :as s]))
+
+
+(defn main [screen-type]
+  (let [screen (s/get-screen screen-type)]
+    (s/in-screen screen
+                 (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
+                 (s/put-string screen 0 1 "Press any key to exit...")
+                 (s/redraw screen)
+                 (s/get-key-blocking screen))))
+
+
+(defn -main [& args]
+  (let [args (set args)
+        screen-type (cond
+                      (args ":swing") :swing
+                      (args ":text")  :text
+                      :else           :auto)]
+    (main screen-type)))
+```
+
+We're very much just bootstrapping things for now.  The `-main` function parses
+the command line arguments to figure out what type of terminal we should use,
+and then passes that along to `main`.
+
+For now, `main` simply:
+
+* Gets an appropriately-typed terminal.
+* Outputs a simple message.
+* Redraws the screen (clojure-lanterna's screen layer buffers output until you
+  tell it to redraw).
+* Waits for the user to press a key.
+* Exits.
+
+I chose to split the meat of the setup into a `main` function instead of just
+putting everything in `-main` because that will make it easy for me to work
+through Swank instead of the command line as we'll see in a moment.
+
+Running
+-------
+
+There are two main ways to actually make this thing work.
+
+First, we can run it as a standalone program with `lein trampoline run` at the
+command line.  I can pass a parameter to specify what type of terminal to use,
+like `lein trampoline run :swing`.
+
+We can also run it from a REPL, or a SLIME/Swank environment by simply
+evaluating `(main :swing)` in the namespace.  This is why I split out everything
+but the command line argument parsing into a separate function.
+
+Either way, once you run it you get something like this:
+
+![Screenshot](/media/images/blog/2012/07/caves-01-01.png)
+
+This is the Swing terminal which I happened to start from swank.  Press a key
+and it will go away.
+
+It doesn't look like much, but it's a [black triangle][].  In the next entry
+we'll start doing more interesting things.
+
+[black triangle]: http://rampantgames.com/blog/2004/10/black-triangle.html
+
--- a/content/blog/2012/07/caves-of-clojure-02.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,581 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 2"
-        snip: "Dealing with state."
-        created: 2012-07-08 9:26:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry corresponds to [post two in Trystan's tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `entry-02` tag to see the code as it stands
-after this post.
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-02-input-output.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-In Trystan's second post he introduces the concept of the game loop, as well as
-what he calls "screens": objects that handle drawing the interface and
-processing user input.
-
-I could try to port his design directly over to Clojure, but instead I wanted to
-step back and see if I could find a way to make things more functional.
-
-I think I've figured out a way to make it work, so I'm going to implement that.
-
-State
------
-
-When I first started thinking about how to model the game's state and the main
-game loop I had lots of crazy ideas bouncing around in my head.  Most of them
-involved an immutable world (immutable! good!) and agents representing Trystan's
-"screens".
-
-The more I thought about it, though, the more it looked like the agents would
-wind up being a tangled mess.  I put down the keyboard, took a shower, had
-dinner with a friend, and let the problem roll around in my head for a bit.
-
-At some point the following train of thought happened somewhere in my brain:
-
-* The immutable "state" that I keep should contain *everything* needed to render
-  the game on the user's screen.
-* I originally thought I'd need to track the "world" as the state, but the world
-  isn't enough!
-* In addition to the world, the user interface (menus, stats, etc) is also
-  rendered.
-
-So instead of keeping a "world" as my state, I'm going to keep a "game".
-
-The User Interface
-------------------
-
-If I'm going to keep track of the user interface in the "game" state, I need
-a way to represent it.
-
-There are two halves to the user interface: "input" and "output".  First let's
-consider output.
-
-Trystan's screens are objects that handle their own drawing.  At any given time
-there's one "active" screen object, which gets asked to draw itself.  If you
-peek ahead in his tutorial you'll see that he ends up introducing a "subscreen"
-concept to get screens layered on top of each other.
-
-Instead of having a single active screen with subscreens, I decided to keep
-a flat vector of screens.  The last screen in the vector is the "active" one,
-and is effectively a subscreen of the one that comes before it.
-
-At this point I'm going to switch terms.  Unfortunately Lanterna uses the word
-"screen" to mean something and I didn't want to try to keep two separate
-concepts under the same word, so in the code I called screens "UIs", and from
-now on I'll be using that word.
-
-So what *is* a UI in the code?  Well, it's basically just a map with a `:kind`
-mapping specifying what kind of UI it is!  It also might have some extra keys
-and values to represent its state too.
-
-For example, at some point I expect to have a UI stack that looks something like
-this:
-
-    :::clojure
-    [{:kind :play}
-     {:kind :throw}
-     {:kind :inventory-select}]
-
-This would be the UI stack when you were throwing something in your inventory at
-a monster and were choosing what to throw.  Once you pick an item you'd need to
-target a monster, so the stack would become:
-
-    :::clojure
-    [{:kind :play}
-     {:kind :throw :item foo}
-     {:kind :target}]
-
-Now the last (i.e.: "active") UI is the targetting UI, but also notice that the
-throwing UI has a bit of state attached to it now (the item the user picked).
-We'll talk about how that got there a bit later.
-
-As I said before, the "state" for our game is going to be a "game", which
-consists of the world and the user interface.  So our "game" object is going to
-be a map that looks something like this:
-
-    :::clojure
-    {:world {}
-     :uis [,,,]}
-
-For now the `:world` is empty.  In the future it'll contain stuff like the tiles
-of the map, the monsters, the player, and lots of other stuff.  The `:uis` is
-the UI stack.
-
-Between the two I have enough information to draw the game fully to the user's
-terminal by doing something like: `(map #(draw-ui ui game) (:uis game))`.  We'll
-see the real code shortly, but that's actually pretty close.
-
-User Input
-----------
-
-In an imperative programming style our game loop would look something like this:
-
-1. Draw the screen.
-2. Get some input from the user.
-3. Process that input, modifying the world.
-4. GOTO 1.
-
-In this functional loop, I want it to look more like this:
-
-1. Draw the screen.
-2. Get some user input.
-3. Process the input and the game to get a new game.
-4. Recur with this new game.
-
-How do I handle user input?  Well it depends on the current UI -- pressing `d`
-at the main screen will do something different than pressing it in an inventory
-selection screen, for example.
-
-So the UIs need to know how to handle input.  There are a number of different
-ways I can do that.  One option might be to have `:handle-input (fn ...)` as
-part of the UI.  I chose a different route which you'll see below, but that's
-not important for now.
-
-The important part is that one I glossed over in the last section.  How do I go
-from this:
-
-    :::clojure
-    [{:kind :play}
-     {:kind :throw}
-     {:kind :inventory-select}]
-
-to this:
-
-    :::clojure
-    [{:kind :play}
-     {:kind :throw :item foo}
-     {:kind :target}]
-
-Let's follow the proposed game loop and see what happens.
-
-1. Draw the play UI, then the throw UI, then the inventory UI.
-2. Get a keypress from the user.
-3. Give that keypress and the game itself to the UI input handling function to
-   get a new game.
-4. Recur with this new game.
-
-Step three is the tricky part.  What does the inventory handler need to do to
-give back a new game?
-
-It would need to pop itself off the UI stack (which is okay), put the selected
-item in the previous UI (a bit scary, but probably not a problem in practice),
-and create the targeting UI.
-
-This last part is a deal breaker.  The inventory selection UI shouldn't know
-anything about the targeting UI, because then I won't be able to reuse it for
-other functions (like equipping items, eating food, etc)!
-
-The throw UI is the one that should know about the inventory and targeting
-UIs.  Ideally it would set them up, get their "return values" and process those.
-How can I send back the values?
-
-There's actually a really elegant way I came up with for this.  At least
-I *think* it's elegant.  I may end up immuting myself into a corner and
-ragequitting this blog series.  We'll see.
-
-Anyway, here's the solution:
-
-* Make "input" part of the game state.
-* Update the game input when you want to return a value from a UI.
-
-And I can change the game loop to look like this:
-
-1. Draw the screen.
-2. If the game's input is empty, get some from the user to fill it.
-3. Process the game to get a new game.  The input is now part of the game and
-   gets processed along with it.
-4. Recur with this new game.
-
-From what little I've used it so far, this method seems very promising.
-
-Enough design talk.  Let's look at the code.
-
-Implementation
---------------
-
-In Trystan's tutorial he had three "screens": start, win, and lose.  The user
-presses keys to transition between them.  Not a very fun game, but it lets you
-get the game loop up and running before diving into gameplay.
-
-I did the same thing.  Right now everything is in one file because I tend to
-code like that until I feel like something needs to be pulled out into its own
-namespace.  The file is still under a hundred lines of code, so that's not too
-bad.
-
-Let's walk through the code piece by piece.  First the namespace:
-
-    :::clojure
-    (ns caves.core
-      (:require [lanterna.screen :as s]))
-
-Next I define some basic data structures:
-
-    :::clojure
-    (defrecord UI [kind])
-    (defrecord World [])
-    (defrecord Game [world uis input])
-
-I used Clojure's records here because I feel like they add a bit of helpful
-structure to the code.  They're also a bit faster, but that probably won't be
-noticeable.  You could skip these and just use plain maps if you wanted to, it's
-really a personal preference.
-
-Next is a helper function:
-
-    :::clojure
-    (defn clear-screen [screen]
-      (let [blank (apply str (repeat 80 \space))]
-        (doseq [row (range 24)]
-          (s/put-string screen 0 row blank))))
-
-Unfortunately Lanterna doesn't provide a method for clearing the screen, so
-I wrote my own little hacky one that just overwrites everything with spaces.  It
-assumes the terminal is 80 by 24 characters for now.
-
-I'll be adding a feature request in the Lanterna issue tracker for this, so
-hopefully I'll be able to delete this function in a later post.
-
-Now to the meaty bits:
-
-    :::clojure
-    (defmulti draw-ui
-      (fn [ui game screen]
-        (:kind ui)))
-
-    (defmethod draw-ui :start [ui game screen]
-      (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
-      (s/put-string screen 0 1 "Press enter to win, anything else to lose."))
-
-    (defmethod draw-ui :win [ui game screen]
-      (s/put-string screen 0 0 "Congratulations, you win!")
-      (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
-
-    (defmethod draw-ui :lose [ui game screen]
-      (s/put-string screen 0 0 "Sorry, better luck next time.")
-      (s/put-string screen 0 1 "Press escape to exit, anything else to go."))
-
-    (defn draw-game [game screen]
-      (clear-screen screen)
-      (doseq [ui (:uis game)]
-        (draw-ui ui game screen))
-      (s/redraw screen))
-
-Here we have the drawing code.
-
-The UIs are very simple for now.  They each just output a couple of lines of
-text.  None of them actually look at the game state at all, but in the future
-some of them will need to do that (e.g.: when showing the list of items in the
-player's inventory).
-
-I made the `draw-ui` function a multimethod to make it easy to define the logic
-for each UI separately.  Each definition could even live in its own file if
-I wanted it to.  There are other ways to do this, but I like the concision and
-simplicity of this one.
-
-The `draw-game` function takes the immutable game object and draws some text to
-the user's terminal.  It's fairly simple.  The `redraw` call is needed because
-Lanterna [double buffers][] the output.  Check out the [clojure-lanterna
-documentation][clojure-lanterna] for more information if you're curious.
-
-[double buffers]: https://en.wikipedia.org/wiki/Multiple_buffering#Double_buffering_in_computer_graphics
-[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
-
-    :::clojure
-    (defmulti process-input
-      (fn [game input]
-        (:kind (last (:uis game)))))
-
-    (defmethod process-input :start [game input]
-      (if (= input :enter)
-        (assoc game :uis [(new UI :win)])
-        (assoc game :uis [(new UI :lose)])))
-
-    (defmethod process-input :win [game input]
-      (if (= input :escape)
-        (assoc game :uis [])
-        (assoc game :uis [(new UI :start)])))
-
-    (defmethod process-input :lose [game input]
-      (if (= input :escape)
-        (assoc game :uis [])
-        (assoc game :uis [(new UI :start)])))
-
-    (defn get-input [game screen]
-      (assoc game :input (s/get-key-blocking screen)))
-
-UIs need to know how to process their input.  I used a multimethod for this too.
-
-The method takes the game and the input as parameters and returns a modified
-copy of the game object that represents the new state.  Currently none of them
-use the "returning as input" trick, but we'll see that in one of the next few
-posts.
-
-Notice how the UIs all simply replace the UI stack in the game they return?
-This is fine for now, but in the future they'll be more likely to just pop off
-the last one (themselves) rather than replace the entire stack.
-
-An empty UI stack means "quit the game", as we'll see in a moment.
-
-You'll also see why the input is separate from the game soon.
-
-The `get-input` function gets a keypress from the user and sticks it into the
-game object.  Nothing crazy there.
-
-And now, the game loop:
-
-    :::clojure
-    (defn run-game [game screen]
-      (loop [{:keys [input uis] :as game} game]
-        (when-not (empty? uis)
-          (draw-game game screen)
-          (if (nil? input)
-            (recur (get-input game screen))
-            (recur (process-input (dissoc game :input) input))))))
-
-Here we go.  The `run-game` function `loop`s on a game object each time.
-
-First: if there are no UIs, we're done and can drop out.  Cool.
-
-If there are UIs, draw the game to the user's terminal.
-
-Then it checks if it needs to get a keypress from the user.  If so, do that,
-update the game object, and start again.
-
-I could make this a bit more efficient by continuing on to process the input
-without another round through the loop, but performance probably isn't a concern
-at the moment.  I'll revisit this in the future if it becomes an issue, but for
-now I like this structure.
-
-Anyway, if we *do* have input (i.e.: either we grabbed a keypress or a UI
-returned something the last time through the loop), process it.  Remember that
-the `process-input` function is a multimethod that dispatches on the `:kind` of
-the last UI in the stack.
-
-Here your can see why `process-input` takes the game and input separately.  I
-*could* just pass the game and pull out the `:input` value, but then I'd also
-need to `dissoc` the input from the modified game object in every UI that didn't
-return a value.
-
-If I didn't `dissoc` the input, the input would always be present and would
-cause an infinite loop.  You can play around with this by replacing `(dissoc
-game :input)` with `game` and watching what happens.
-
-Next is a simple helper function:
-
-    :::clojure
-    (defn new-game []
-      (new Game
-           (new World)
-           [(new UI :start)]
-           nil))
-
-Nothing fancy.  You could just inline that body into the next function if you
-wanted, but I'm thinking ahead to when I'm going to want to generate a random
-world.
-
-Finally, the bootstrapping:
-
-    :::clojure
-    (defn main
-      ([screen-type] (main screen-type false))
-      ([screen-type block?]
-       (letfn [(go []
-                 (let [screen (s/get-screen screen-type)]
-                   (s/in-screen screen
-                                (run-game (new-game) screen))))]
-         (if block?
-           (go)
-           (future (go))))))
-
-    (defn -main [& args]
-      (let [args (set args)
-            screen-type (cond
-                          (args ":swing") :swing
-                          (args ":text")  :text
-                          :else           :auto)]
-        (main screen-type true)))
-
-`-main` looks almost the same as before, but `main` has changed quite a bit.
-What happened?
-
-The short answer is that most of the change is to work around some Clojure/JVM
-silliness.  The important bit is that I now create a fresh game object and fire
-up the game loop with `(run-game (new-game) screen)`.
-
-If you're curious about the rest, read [this Clojure bug report][bug].  I wanted
-to be able to run the game from the command line as normal, but from a REPL
-without blocking the REPL itself, so I could play around with things.
-
-[bug]: http://dev.clojure.org/jira/browse/CLJ-959
-
-That's it!  It clocks in at 98 lines of code.  Here's the whole file at once:
-
-    :::clojure
-    (ns caves.core
-      (:require [lanterna.screen :as s]))
-
-
-    ; Data Structures -------------------------------------------------------------
-    (defrecord UI [kind])
-    (defrecord World [])
-    (defrecord Game [world uis input])
-
-    ; Utility Functions -----------------------------------------------------------
-    (defn clear-screen [screen]
-      (let [blank (apply str (repeat 80 \space))]
-        (doseq [row (range 24)]
-          (s/put-string screen 0 row blank))))
-
-
-    ; Drawing ---------------------------------------------------------------------
-    (defmulti draw-ui
-      (fn [ui game screen]
-        (:kind ui)))
-
-    (defmethod draw-ui :start [ui game screen]
-      (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
-      (s/put-string screen 0 1 "Press enter to win, anything else to lose."))
-
-    (defmethod draw-ui :win [ui game screen]
-      (s/put-string screen 0 0 "Congratulations, you win!")
-      (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
-
-    (defmethod draw-ui :lose [ui game screen]
-      (s/put-string screen 0 0 "Sorry, better luck next time.")
-      (s/put-string screen 0 1 "Press escape to exit, anything else to go."))
-
-    (defn draw-game [game screen]
-      (clear-screen screen)
-      (doseq [ui (:uis game)]
-        (draw-ui ui game screen))
-      (s/redraw screen))
-
-
-    ; Input -----------------------------------------------------------------------
-    (defmulti process-input
-      (fn [game input]
-        (:kind (last (:uis game)))))
-
-    (defmethod process-input :start [game input]
-      (if (= input :enter)
-        (assoc game :uis [(new UI :win)])
-        (assoc game :uis [(new UI :lose)])))
-
-    (defmethod process-input :win [game input]
-      (if (= input :escape)
-        (assoc game :uis [])
-        (assoc game :uis [(new UI :start)])))
-
-    (defmethod process-input :lose [game input]
-      (if (= input :escape)
-        (assoc game :uis [])
-        (assoc game :uis [(new UI :start)])))
-
-    (defn get-input [game screen]
-      (assoc game :input (s/get-key-blocking screen)))
-
-
-    ; Main ------------------------------------------------------------------------
-    (defn run-game [game screen]
-      (loop [{:keys [input uis] :as game} game]
-        (when-not (empty? uis)
-          (draw-game game screen)
-          (if (nil? input)
-            (recur (get-input game screen))
-            (recur (process-input (dissoc game :input) input))))))
-
-    (defn new-game []
-      (new Game
-           (new World)
-           [(new UI :start)]
-           nil))
-
-    (defn main
-      ([screen-type] (main screen-type false))
-      ([screen-type block?]
-       (letfn [(go []
-                 (let [screen (s/get-screen screen-type)]
-                   (s/in-screen screen
-                                (run-game (new-game) screen))))]
-         (if block?
-           (go)
-           (future (go))))))
-
-
-    (defn -main [& args]
-      (let [args (set args)
-            screen-type (cond
-                          (args ":swing") :swing
-                          (args ":text")  :text
-                          :else           :auto)]
-        (main screen-type true)))
-
-And here are some screenshots:
-
-![Screenshot](/media/images{{ parent_url }}/caves-02-01.png)
-
-![Screenshot](/media/images{{ parent_url }}/caves-02-02.png)
-
-![Screenshot](/media/images{{ parent_url }}/caves-02-03.png)
-
-It's not a very exciting game yet, but it all works, and I've managed to use an
-immutable data structure of basic maps and records to represent everything
-I need.
-
-The drawing functions aren't "pure" in the "no I/O" sense, but they're kind of
-pure in another way -- they take an immutable data structure and draw something
-to the screen based solely on that.  I think this is going to make things easy
-to work with down the line.
-
-Testing
--------
-
-I'll leave you with one final tidbit to read through if you want more.
-
-Encapsulating the game state as an immutable objects means I can test actions
-and their effects on the world individually, without a game loop:
-
-    :::clojure
-    (ns caves.core-test
-      (:import [caves.core UI World Game])
-      (:use clojure.test
-            caves.core))
-
-    (defn current-ui [game]
-      (:kind (last (:uis game))))
-
-
-    (deftest test-start
-      (let [game (new Game nil [(new UI :start)] nil)]
-
-        (testing "Enter wins at the starting screen."
-          (let [result (process-input game :enter)]
-            (is (= (current-ui result) :win))))
-
-        (testing "Other keys lose at the starting screen."
-          (let [results (map (partial process-input game)
-                             [\space \a \A :escape :up :backspace])]
-            (doseq [result results]
-              (is (= (current-ui result) :lose)))))))
-
-That's pretty cool!
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-02.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,593 @@
++++
+title = "The Caves of Clojure: Part 2"
+snip = "Dealing with state."
+date = 2012-07-08T9:26:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry corresponds to [post two in Trystan's tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `entry-02` tag to see the code as it stands
+after this post.
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-02-input-output.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+In Trystan's second post he introduces the concept of the game loop, as well as
+what he calls "screens": objects that handle drawing the interface and
+processing user input.
+
+I could try to port his design directly over to Clojure, but instead I wanted to
+step back and see if I could find a way to make things more functional.
+
+I think I've figured out a way to make it work, so I'm going to implement that.
+
+State
+-----
+
+When I first started thinking about how to model the game's state and the main
+game loop I had lots of crazy ideas bouncing around in my head.  Most of them
+involved an immutable world (immutable! good!) and agents representing Trystan's
+"screens".
+
+The more I thought about it, though, the more it looked like the agents would
+wind up being a tangled mess.  I put down the keyboard, took a shower, had
+dinner with a friend, and let the problem roll around in my head for a bit.
+
+At some point the following train of thought happened somewhere in my brain:
+
+* The immutable "state" that I keep should contain *everything* needed to render
+  the game on the user's screen.
+* I originally thought I'd need to track the "world" as the state, but the world
+  isn't enough!
+* In addition to the world, the user interface (menus, stats, etc) is also
+  rendered.
+
+So instead of keeping a "world" as my state, I'm going to keep a "game".
+
+The User Interface
+------------------
+
+If I'm going to keep track of the user interface in the "game" state, I need
+a way to represent it.
+
+There are two halves to the user interface: "input" and "output".  First let's
+consider output.
+
+Trystan's screens are objects that handle their own drawing.  At any given time
+there's one "active" screen object, which gets asked to draw itself.  If you
+peek ahead in his tutorial you'll see that he ends up introducing a "subscreen"
+concept to get screens layered on top of each other.
+
+Instead of having a single active screen with subscreens, I decided to keep
+a flat vector of screens.  The last screen in the vector is the "active" one,
+and is effectively a subscreen of the one that comes before it.
+
+At this point I'm going to switch terms.  Unfortunately Lanterna uses the word
+"screen" to mean something and I didn't want to try to keep two separate
+concepts under the same word, so in the code I called screens "UIs", and from
+now on I'll be using that word.
+
+So what *is* a UI in the code?  Well, it's basically just a map with a `:kind`
+mapping specifying what kind of UI it is!  It also might have some extra keys
+and values to represent its state too.
+
+For example, at some point I expect to have a UI stack that looks something like
+this:
+
+```clojure
+[{:kind :play}
+ {:kind :throw}
+ {:kind :inventory-select}]
+```
+
+This would be the UI stack when you were throwing something in your inventory at
+a monster and were choosing what to throw.  Once you pick an item you'd need to
+target a monster, so the stack would become:
+
+```clojure
+[{:kind :play}
+ {:kind :throw :item foo}
+ {:kind :target}]
+```
+
+Now the last (i.e.: "active") UI is the targetting UI, but also notice that the
+throwing UI has a bit of state attached to it now (the item the user picked).
+We'll talk about how that got there a bit later.
+
+As I said before, the "state" for our game is going to be a "game", which
+consists of the world and the user interface.  So our "game" object is going to
+be a map that looks something like this:
+
+```clojure
+{:world {}
+ :uis [,,,]}
+```
+
+For now the `:world` is empty.  In the future it'll contain stuff like the tiles
+of the map, the monsters, the player, and lots of other stuff.  The `:uis` is
+the UI stack.
+
+Between the two I have enough information to draw the game fully to the user's
+terminal by doing something like: `(map #(draw-ui ui game) (:uis game))`.  We'll
+see the real code shortly, but that's actually pretty close.
+
+User Input
+----------
+
+In an imperative programming style our game loop would look something like this:
+
+1. Draw the screen.
+2. Get some input from the user.
+3. Process that input, modifying the world.
+4. GOTO 1.
+
+In this functional loop, I want it to look more like this:
+
+1. Draw the screen.
+2. Get some user input.
+3. Process the input and the game to get a new game.
+4. Recur with this new game.
+
+How do I handle user input?  Well it depends on the current UI — pressing `d`
+at the main screen will do something different than pressing it in an inventory
+selection screen, for example.
+
+So the UIs need to know how to handle input.  There are a number of different
+ways I can do that.  One option might be to have `:handle-input (fn ...)` as
+part of the UI.  I chose a different route which you'll see below, but that's
+not important for now.
+
+The important part is that one I glossed over in the last section.  How do I go
+from this:
+
+```clojure
+[{:kind :play}
+ {:kind :throw}
+ {:kind :inventory-select}]
+```
+
+to this:
+
+```clojure
+[{:kind :play}
+ {:kind :throw :item foo}
+ {:kind :target}]
+```
+
+Let's follow the proposed game loop and see what happens.
+
+1. Draw the play UI, then the throw UI, then the inventory UI.
+2. Get a keypress from the user.
+3. Give that keypress and the game itself to the UI input handling function to
+   get a new game.
+4. Recur with this new game.
+
+Step three is the tricky part.  What does the inventory handler need to do to
+give back a new game?
+
+It would need to pop itself off the UI stack (which is okay), put the selected
+item in the previous UI (a bit scary, but probably not a problem in practice),
+and create the targeting UI.
+
+This last part is a deal breaker.  The inventory selection UI shouldn't know
+anything about the targeting UI, because then I won't be able to reuse it for
+other functions (like equipping items, eating food, etc)!
+
+The throw UI is the one that should know about the inventory and targeting
+UIs.  Ideally it would set them up, get their "return values" and process those.
+How can I send back the values?
+
+There's actually a really elegant way I came up with for this.  At least
+I *think* it's elegant.  I may end up immuting myself into a corner and
+ragequitting this blog series.  We'll see.
+
+Anyway, here's the solution:
+
+* Make "input" part of the game state.
+* Update the game input when you want to return a value from a UI.
+
+And I can change the game loop to look like this:
+
+1. Draw the screen.
+2. If the game's input is empty, get some from the user to fill it.
+3. Process the game to get a new game.  The input is now part of the game and
+   gets processed along with it.
+4. Recur with this new game.
+
+From what little I've used it so far, this method seems very promising.
+
+Enough design talk.  Let's look at the code.
+
+Implementation
+--------------
+
+In Trystan's tutorial he had three "screens": start, win, and lose.  The user
+presses keys to transition between them.  Not a very fun game, but it lets you
+get the game loop up and running before diving into gameplay.
+
+I did the same thing.  Right now everything is in one file because I tend to
+code like that until I feel like something needs to be pulled out into its own
+namespace.  The file is still under a hundred lines of code, so that's not too
+bad.
+
+Let's walk through the code piece by piece.  First the namespace:
+
+```clojure
+(ns caves.core
+  (:require [lanterna.screen :as s]))
+```
+
+Next I define some basic data structures:
+
+```clojure
+(defrecord UI [kind])
+(defrecord World [])
+(defrecord Game [world uis input])
+```
+
+I used Clojure's records here because I feel like they add a bit of helpful
+structure to the code.  They're also a bit faster, but that probably won't be
+noticeable.  You could skip these and just use plain maps if you wanted to, it's
+really a personal preference.
+
+Next is a helper function:
+
+```clojure
+(defn clear-screen [screen]
+  (let [blank (apply str (repeat 80 \space))]
+    (doseq [row (range 24)]
+      (s/put-string screen 0 row blank))))
+```
+
+Unfortunately Lanterna doesn't provide a method for clearing the screen, so
+I wrote my own little hacky one that just overwrites everything with spaces.  It
+assumes the terminal is 80 by 24 characters for now.
+
+I'll be adding a feature request in the Lanterna issue tracker for this, so
+hopefully I'll be able to delete this function in a later post.
+
+Now to the meaty bits:
+
+```clojure
+(defmulti draw-ui
+  (fn [ui game screen]
+    (:kind ui)))
+
+(defmethod draw-ui :start [ui game screen]
+  (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
+  (s/put-string screen 0 1 "Press enter to win, anything else to lose."))
+
+(defmethod draw-ui :win [ui game screen]
+  (s/put-string screen 0 0 "Congratulations, you win!")
+  (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
+
+(defmethod draw-ui :lose [ui game screen]
+  (s/put-string screen 0 0 "Sorry, better luck next time.")
+  (s/put-string screen 0 1 "Press escape to exit, anything else to go."))
+
+(defn draw-game [game screen]
+  (clear-screen screen)
+  (doseq [ui (:uis game)]
+    (draw-ui ui game screen))
+  (s/redraw screen))
+```
+
+Here we have the drawing code.
+
+The UIs are very simple for now.  They each just output a couple of lines of
+text.  None of them actually look at the game state at all, but in the future
+some of them will need to do that (e.g.: when showing the list of items in the
+player's inventory).
+
+I made the `draw-ui` function a multimethod to make it easy to define the logic
+for each UI separately.  Each definition could even live in its own file if
+I wanted it to.  There are other ways to do this, but I like the concision and
+simplicity of this one.
+
+The `draw-game` function takes the immutable game object and draws some text to
+the user's terminal.  It's fairly simple.  The `redraw` call is needed because
+Lanterna [double buffers][] the output.  Check out the [clojure-lanterna
+documentation][clojure-lanterna] for more information if you're curious.
+
+[double buffers]: https://en.wikipedia.org/wiki/Multiple_buffering#Double_buffering_in_computer_graphics
+[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
+
+```clojure
+(defmulti process-input
+  (fn [game input]
+    (:kind (last (:uis game)))))
+
+(defmethod process-input :start [game input]
+  (if (= input :enter)
+    (assoc game :uis [(new UI :win)])
+    (assoc game :uis [(new UI :lose)])))
+
+(defmethod process-input :win [game input]
+  (if (= input :escape)
+    (assoc game :uis [])
+    (assoc game :uis [(new UI :start)])))
+
+(defmethod process-input :lose [game input]
+  (if (= input :escape)
+    (assoc game :uis [])
+    (assoc game :uis [(new UI :start)])))
+
+(defn get-input [game screen]
+  (assoc game :input (s/get-key-blocking screen)))
+```
+
+UIs need to know how to process their input.  I used a multimethod for this too.
+
+The method takes the game and the input as parameters and returns a modified
+copy of the game object that represents the new state.  Currently none of them
+use the "returning as input" trick, but we'll see that in one of the next few
+posts.
+
+Notice how the UIs all simply replace the UI stack in the game they return?
+This is fine for now, but in the future they'll be more likely to just pop off
+the last one (themselves) rather than replace the entire stack.
+
+An empty UI stack means "quit the game", as we'll see in a moment.
+
+You'll also see why the input is separate from the game soon.
+
+The `get-input` function gets a keypress from the user and sticks it into the
+game object.  Nothing crazy there.
+
+And now, the game loop:
+
+```clojure
+(defn run-game [game screen]
+  (loop [{:keys [input uis] :as game} game]
+    (when-not (empty? uis)
+      (draw-game game screen)
+      (if (nil? input)
+        (recur (get-input game screen))
+        (recur (process-input (dissoc game :input) input))))))
+```
+
+Here we go.  The `run-game` function `loop`s on a game object each time.
+
+First: if there are no UIs, we're done and can drop out.  Cool.
+
+If there are UIs, draw the game to the user's terminal.
+
+Then it checks if it needs to get a keypress from the user.  If so, do that,
+update the game object, and start again.
+
+I could make this a bit more efficient by continuing on to process the input
+without another round through the loop, but performance probably isn't a concern
+at the moment.  I'll revisit this in the future if it becomes an issue, but for
+now I like this structure.
+
+Anyway, if we *do* have input (i.e.: either we grabbed a keypress or a UI
+returned something the last time through the loop), process it.  Remember that
+the `process-input` function is a multimethod that dispatches on the `:kind` of
+the last UI in the stack.
+
+Here your can see why `process-input` takes the game and input separately.  I
+*could* just pass the game and pull out the `:input` value, but then I'd also
+need to `dissoc` the input from the modified game object in every UI that didn't
+return a value.
+
+If I didn't `dissoc` the input, the input would always be present and would
+cause an infinite loop.  You can play around with this by replacing `(dissoc
+game :input)` with `game` and watching what happens.
+
+Next is a simple helper function:
+
+```clojure
+(defn new-game []
+  (new Game
+       (new World)
+       [(new UI :start)]
+       nil))
+```
+
+Nothing fancy.  You could just inline that body into the next function if you
+wanted, but I'm thinking ahead to when I'm going to want to generate a random
+world.
+
+Finally, the bootstrapping:
+
+```clojure
+(defn main
+  ([screen-type] (main screen-type false))
+  ([screen-type block?]
+   (letfn [(go []
+             (let [screen (s/get-screen screen-type)]
+               (s/in-screen screen
+                            (run-game (new-game) screen))))]
+     (if block?
+       (go)
+       (future (go))))))
+
+(defn -main [& args]
+  (let [args (set args)
+        screen-type (cond
+                      (args ":swing") :swing
+                      (args ":text")  :text
+                      :else           :auto)]
+    (main screen-type true)))
+```
+
+`-main` looks almost the same as before, but `main` has changed quite a bit.
+What happened?
+
+The short answer is that most of the change is to work around some Clojure/JVM
+silliness.  The important bit is that I now create a fresh game object and fire
+up the game loop with `(run-game (new-game) screen)`.
+
+If you're curious about the rest, read [this Clojure bug report][bug].  I wanted
+to be able to run the game from the command line as normal, but from a REPL
+without blocking the REPL itself, so I could play around with things.
+
+[bug]: http://dev.clojure.org/jira/browse/CLJ-959
+
+That's it!  It clocks in at 98 lines of code.  Here's the whole file at once:
+
+```clojure
+(ns caves.core
+  (:require [lanterna.screen :as s]))
+
+
+; Data Structures -------------------------------------------------------------
+(defrecord UI [kind])
+(defrecord World [])
+(defrecord Game [world uis input])
+
+; Utility Functions -----------------------------------------------------------
+(defn clear-screen [screen]
+  (let [blank (apply str (repeat 80 \space))]
+    (doseq [row (range 24)]
+      (s/put-string screen 0 row blank))))
+
+
+; Drawing ---------------------------------------------------------------------
+(defmulti draw-ui
+  (fn [ui game screen]
+    (:kind ui)))
+
+(defmethod draw-ui :start [ui game screen]
+  (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
+  (s/put-string screen 0 1 "Press enter to win, anything else to lose."))
+
+(defmethod draw-ui :win [ui game screen]
+  (s/put-string screen 0 0 "Congratulations, you win!")
+  (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
+
+(defmethod draw-ui :lose [ui game screen]
+  (s/put-string screen 0 0 "Sorry, better luck next time.")
+  (s/put-string screen 0 1 "Press escape to exit, anything else to go."))
+
+(defn draw-game [game screen]
+  (clear-screen screen)
+  (doseq [ui (:uis game)]
+    (draw-ui ui game screen))
+  (s/redraw screen))
+
+
+; Input -----------------------------------------------------------------------
+(defmulti process-input
+  (fn [game input]
+    (:kind (last (:uis game)))))
+
+(defmethod process-input :start [game input]
+  (if (= input :enter)
+    (assoc game :uis [(new UI :win)])
+    (assoc game :uis [(new UI :lose)])))
+
+(defmethod process-input :win [game input]
+  (if (= input :escape)
+    (assoc game :uis [])
+    (assoc game :uis [(new UI :start)])))
+
+(defmethod process-input :lose [game input]
+  (if (= input :escape)
+    (assoc game :uis [])
+    (assoc game :uis [(new UI :start)])))
+
+(defn get-input [game screen]
+  (assoc game :input (s/get-key-blocking screen)))
+
+
+; Main ------------------------------------------------------------------------
+(defn run-game [game screen]
+  (loop [{:keys [input uis] :as game} game]
+    (when-not (empty? uis)
+      (draw-game game screen)
+      (if (nil? input)
+        (recur (get-input game screen))
+        (recur (process-input (dissoc game :input) input))))))
+
+(defn new-game []
+  (new Game
+       (new World)
+       [(new UI :start)]
+       nil))
+
+(defn main
+  ([screen-type] (main screen-type false))
+  ([screen-type block?]
+   (letfn [(go []
+             (let [screen (s/get-screen screen-type)]
+               (s/in-screen screen
+                            (run-game (new-game) screen))))]
+     (if block?
+       (go)
+       (future (go))))))
+
+
+(defn -main [& args]
+  (let [args (set args)
+        screen-type (cond
+                      (args ":swing") :swing
+                      (args ":text")  :text
+                      :else           :auto)]
+    (main screen-type true)))
+```
+
+And here are some screenshots:
+
+![Screenshot](/media/images/blog/2012/07/caves-02-01.png)
+
+![Screenshot](/media/images/blog/2012/07/caves-02-02.png)
+
+![Screenshot](/media/images/blog/2012/07/caves-02-03.png)
+
+It's not a very exciting game yet, but it all works, and I've managed to use an
+immutable data structure of basic maps and records to represent everything
+I need.
+
+The drawing functions aren't "pure" in the "no I/O" sense, but they're kind of
+pure in another way — they take an immutable data structure and draw something
+to the screen based solely on that.  I think this is going to make things easy
+to work with down the line.
+
+Testing
+-------
+
+I'll leave you with one final tidbit to read through if you want more.
+
+Encapsulating the game state as an immutable objects means I can test actions
+and their effects on the world individually, without a game loop:
+
+```clojure
+(ns caves.core-test
+  (:import [caves.core UI World Game])
+  (:use clojure.test
+        caves.core))
+
+(defn current-ui [game]
+  (:kind (last (:uis game))))
+
+
+(deftest test-start
+  (let [game (new Game nil [(new UI :start)] nil)]
+
+    (testing "Enter wins at the starting screen."
+      (let [result (process-input game :enter)]
+        (is (= (current-ui result) :win))))
+
+    (testing "Other keys lose at the starting screen."
+      (let [results (map (partial process-input game)
+                         [\space \a \A :escape :up :backspace])]
+        (doseq [result results]
+          (is (= (current-ui result) :lose)))))))
+```
+
+That's pretty cool!
+
--- a/content/blog/2012/07/caves-of-clojure-03-1.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,363 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 3.1"
-        snip: "World generation."
-        created: 2012-07-09 9:37:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry corresponds to [post three in Trystan's tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `entry-03-1` tag to see the code as it stands
-after this post.
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-03-scrolling-through.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-In Trystan's third post he introduces three new things:
-
-* Random world generation.
-* Smoothing the world to look nicer.
-* The "play screen" and scrolling.
-
-I'm going to split this up into three separate short posts, so you can see the
-process I actually went through as I built it.  This post will deal with the
-world generation and basic displaying.  The next one will be about smoothing,
-and the one after that about scrolling around.
-
-Organization
-------------
-
-First of all, my single `core.clj` is going to get a bit crowded by the time
-we're done with this, so it's time to start splitting it apart.  I made
-a `world.clj` file alongside `core.clj`.  That'll do for now.
-
-Creating a Random World
------------------------
-
-First I set up the namespace:
-
-    :::clojure
-    (ns caves.world)
-
-Next I defined a constant for the size of the world.  I chose 160 by 50 tiles
-arbitrarily:
-
-    :::clojure
-    (def world-size [160 50])
-
-I moved the `World` record declaration out of `core.clj` and into this file:
-
-    :::clojure
-    (defrecord World [tiles])
-
-I also added the `tiles` attribute to it.  For now I'm going to store the tiles
-as a vector of rows, where each row is a vector of tiles.
-
-What is a tile?  For now it's going to be a simple record:
-
-    :::clojure
-    (defrecord Tile [kind glyph color])
-
-Tiles are immutable, so let's make a map of some of the ones we'll be needing:
-
-    :::clojure
-    (def tiles
-      {:floor (new Tile :floor "." :white)
-       :wall  (new Tile :wall  "#" :white)
-       :bound (new Tile :bound "X" :black)})
-
-The `:bound` Tile represents "out of bounds".  It will be returned if you try to
-get a tile outside the bounds of the map.  There are other ways to handle that,
-but this is the one Trystan used so I'm going to use it too.
-
-Next I created a little helper function for retrieving a specific tile:
-
-    :::clojure
-    (defn get-tile [tiles x y]
-      (get-in tiles [y x] (:bound tiles)))
-
-Remember that we're storing the tiles as a vector of rows, so when we index into
-it we need to get the y coordinate (i.e.: the row) first, then index in for the
-column with the x coordinate.
-
-This is a bit ugly, but storing the screen as rows is going to help us later as
-we draw the screen, and it gives us the opportunity to do bounds checking as
-well.
-
-The `get-in` call is a really handy way to check bounds.  No worrying about
-comparing indexes to dimensions -- just try to get it and if you fail it must be
-out of bounds.
-
-That's about it for the world structure.  Time to move to the generation:
-
-    :::clojure
-    (defn random-tiles []
-      (let [[cols rows] world-size]
-        (letfn [(random-tile []
-                  (tiles (rand-nth [:floor :wall])))
-                (random-row []
-                  (vec (repeatedly cols random-tile)))]
-          (vec (repeatedly rows random-row)))))
-
-    (defn random-world []
-      (new World (random-tiles)))
-
-Nothing too fancy happening here.  In `random-tiles` I built up a series of
-helper functions to make it easier to read.  You could save some LOC by just
-using anonymous functions instead, but to me this way is easier to read.
-Personal preference, I guess.
-
-For now we're just going to generate a world where every tile has an equal
-chance of being a wall or a floor.  I might revisit this later if I want to make
-the caves sparser or denser.
-
-That's it for the world generation.  Next we'll move on to actually displaying
-the new random worlds.
-
-Displaying
-----------
-
-Let's switch back to `core.clj`.  First I updated the namespace to pull in the
-`random-world` function:
-
-    :::clojure
-    (ns caves.core
-      (:use [caves.world :only [random-world]])
-      (:require [lanterna.screen :as s]))
-
-Before going further I decided to do a bit of cleanup.  Instead of hardcoding
-the 80 by 24 terminal size, I pulled it out into a constant:
-
-    :::clojure
-    (def screen-size [80 24])
-
-I updated `clear-screen` to use that:
-
-    :::clojure
-    (defn clear-screen [screen]
-      (let [[cols rows] screen-size
-            blank (apply str (repeat cols \space))]
-        (doseq [row (range rows)]
-          (s/put-string screen 0 row blank))))
-
-It's still not perfect (what if the user's terminal isn't 80 by 24?) but it's
-not something I care enough to fix right now.  I'll get to it later.  At least
-now the hardcoded numbers are in one spot.
-
-There's a few things I need to do to get the world on the screen.  First
-I created a `:play` UI similar to Trystan's.  I'm not a big fan of the
-generic-sounding name, but I couldn't come up with anything better in a few
-minutes of thinking.
-
-Creating a UI requires implementing the `draw-ui` and `process-input`
-multimethods from the previous post.  I'll start with the easy one: input
-processing.
-
-For now the flow of the game will go like this:
-
-1. The player is shown an introduction screen with some instructions.
-2. They press a key and see the world.
-3. Pressing enter wins the game.  Backspace loses the game.  Any other key does
-   nothing.
-4. Once they win or lose, they see a text blurb and can press escape to quit, or
-   any other key to GOTO 1.
-
-With that in mind, I wrote the `process-input` implementation for `:play` UIs:
-
-    :::clojure
-    (defmethod process-input :play [game input]
-      (case input
-        :enter     (assoc game :uis [(new UI :win)])
-        :backspace (assoc game :uis [(new UI :lose)])
-        game))
-
-I'm still replacing the entire UI stack at once.  I'm going to be throwing that
-code away later anyway so it's not a big deal.
-
-Now I need to update the `:start` UI to send the user to the `:play` UI instead
-of directly to the `:win` or `:lose` UIs.
-
-    :::clojure
-    (defmethod process-input :start [game input]
-      (-> game
-        (assoc :world (random-world))
-        (assoc :uis [(new UI :play)])))
-
-I also decided that this is where I'd generate the new random world.  It makes
-sense to put that here, because every time you restart the game you should get
-a different world.
-
-On the other hand, this means that the `process-input` function is no longer
-pure for `:start` UIs (all the other input processing functions are still pure).
-I'm not sure how I feel about that.  For now I'm going to accept it, but I may
-rethink it in the future.
-
-Now that I have the world generation in there, I can remove the `(new World)`
-call from the `new-game` helper function:
-
-    :::clojure
-    (defn new-game []
-      (new Game nil [(new UI :start)] nil))
-
-Now `new-game` does even less than before.  It just sets up a game object with
-the initial UI and `nil` world/input.
-
-Okay, on to the last piece: drawing the world.  This is some pretty dense code,
-but don't be scared -- I'll guide you through it and we'll make it together:
-
-    :::clojure
-    (defmethod draw-ui :play [ui {{:keys [tiles]} :world :as game} screen]
-      (let [[cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            start-x 0
-            start-y 0
-            end-x (+ start-x vcols)
-            end-y (+ start-y vrows)]
-        (doseq [[vrow-idx mrow-idx] (map vector
-                                         (range 0 vrows)
-                                         (range start-y end-y))
-                :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
-          (doseq [vcol-idx (range vcols)
-                  :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
-            (s/put-string screen vcol-idx vrow-idx glyph {:fg color})))))
-
-Let's look at this beast line-by-line.  First we pull the tile vector out of the
-game object with Clojure's destructuring:
-
-    :::clojure
-    {{:keys [tiles]} :world :as game}
-
-This seems a bit hard to read to me, so I might move it into the `let` statement
-with a `get-in` call later.  Maybe.
-
-Next I bind a bunch of symbols I'll be using:
-
-    :::clojure
-    (let [[cols rows] screen-size
-          vcols cols
-          vrows (dec rows)
-          start-x 0
-          start-y 0
-          end-x (+ start-x vcols)
-          end-y (+ start-y vrows)]
-      ,,,)
-
-`cols` and `rows` are the dimensions of the screen (hardcoded at 80 by 24 for
-the moment).
-
-`vcols` and `vrows` are the "viewport columns" and "viewport rows".  The
-"viewport" is what I'm calling the part of the screen that's actually showing
-the world.  I'm reserving one row at the bottom of the screen to use for
-displaying the player's hit points, score, and so on.  It would be trivial to
-increase that to two rows if I need more later.
-
-`start-x` and `start-y` are the coordinates of the upper-left corner of the
-viewport in the full map, and `end-x` and `end-y` are the coordinates of the
-lower-right corner.  For now I'm just displaying the upper-left section of the
-map.  In the entry after the next one I'll add the ability to scroll around.
-
-It's easier to explain with a diagram.  Imagine I reduced the size of the world
-to 10 by 10 and the terminal to 5 by 3, and the user was standing near the
-middle of the map:
-
-    :::text
-          columns (x)
-          0123456789
-    rows 0..........
-    (y)  1..........
-         2..........
-         3..VVVVV...
-         4..VVVVV...
-         5..VVVVV...
-         6..........
-         7..........
-         8..........
-         9..........
-
-Here `V` represents the portion of the map the viewport can show (which is what
-we'll be drawing to the user's terminal).  In this example `start-x` would
-be `2`, `start-y` would be `3`, `end-x` would be `6`, and `end-y` would be `5`.
-
-Okay, so I've calculated the part of the map that needs to be drawn.  Now
-I loop through the rows:
-
-    :::clojure
-    (doseq [[vrow-idx mrow-idx] (map vector
-                                     (range 0 vrows)
-                                     (range start-y end-y))
-            :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
-      ,,,)
-
-This is a bit obtuse, but basically the `map` call pairs up the viewport row and
-map row indices.  In our example it would result in this:
-
-    :::clojure
-    [[0 3]
-     [1 4]
-     [2 5]]
-
-So viewport row `1` corresponds to map row `4`.  There's probably a less
-"clever" way to do this that I should use instead.
-
-For each row, I grab the tiles we're going to draw and store them in a vector
-called `row-tiles` by grabbing the row of tiles from the world and taking
-a slice of it.
-
-Almost there!  Next I loop through each column in the row:
-
-    :::clojure
-    (doseq [vcol-idx (range vcols)
-            :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
-      ,,,)
-
-For each column I grab the appropriate tile and figure out what glyph and color
-to draw (remember the definition of `Tile`: `(defrecord Tile [kind glyph
-color])`).
-
-Finally I can actually draw the tile to the screen at the appropriate place:
-
-    :::clojure
-    (s/put-string screen vcol-idx vrow-idx glyph {:fg color})
-
-Whew!  If that seemed painful and fiddly to you, trust me, I agree.  I'm open to
-suggestions on making it easier to read.
-
-Results
--------
-
-Now that the `:play` UI knows how to draw itself and process its input, and is
-properly hooked up by the `:start` UI, it's time to give it a shot!
-
-![Screenshot](/media/images{{ parent_url }}/caves-03-1-01.png)
-
-![Screenshot](/media/images{{ parent_url }}/caves-03-1-02.png)
-
-![Screenshot](/media/images{{ parent_url }}/caves-03-1-03.png)
-
-Each time we start we get a different random world.  Great!
-
-The code is getting a bit big to include in its entirety, but you can view it
-[on GitHub][result-code].
-
-[result-code]: https://github.com/sjl/caves/tree/entry-03-1/src/caves
-
-That covers the first part of Trystan's third post.  Aside from the painful
-`draw-ui` function it was pretty easy to add.  In the next post I'll add the
-smoothing code to make the caves look a bit nicer.
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-03-1.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,381 @@
++++
+title = "The Caves of Clojure: Part 3.1"
+snip = "World generation."
+date = 2012-07-09T9:37:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry corresponds to [post three in Trystan's tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `entry-03-1` tag to see the code as it stands
+after this post.
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-03-scrolling-through.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+In Trystan's third post he introduces three new things:
+
+* Random world generation.
+* Smoothing the world to look nicer.
+* The "play screen" and scrolling.
+
+I'm going to split this up into three separate short posts, so you can see the
+process I actually went through as I built it.  This post will deal with the
+world generation and basic displaying.  The next one will be about smoothing,
+and the one after that about scrolling around.
+
+Organization
+------------
+
+First of all, my single `core.clj` is going to get a bit crowded by the time
+we're done with this, so it's time to start splitting it apart.  I made
+a `world.clj` file alongside `core.clj`.  That'll do for now.
+
+Creating a Random World
+-----------------------
+
+First I set up the namespace:
+
+```clojure
+(ns caves.world)
+```
+
+Next I defined a constant for the size of the world.  I chose 160 by 50 tiles
+arbitrarily:
+
+```clojure
+(def world-size [160 50])
+```
+
+I moved the `World` record declaration out of `core.clj` and into this file:
+
+```clojure
+(defrecord World [tiles])
+```
+
+I also added the `tiles` attribute to it.  For now I'm going to store the tiles
+as a vector of rows, where each row is a vector of tiles.
+
+What is a tile?  For now it's going to be a simple record:
+
+```clojure
+(defrecord Tile [kind glyph color])
+```
+
+Tiles are immutable, so let's make a map of some of the ones we'll be needing:
+
+```clojure
+(def tiles
+  {:floor (new Tile :floor "." :white)
+   :wall  (new Tile :wall  "#" :white)
+   :bound (new Tile :bound "X" :black)})
+```
+
+The `:bound` Tile represents "out of bounds".  It will be returned if you try to
+get a tile outside the bounds of the map.  There are other ways to handle that,
+but this is the one Trystan used so I'm going to use it too.
+
+Next I created a little helper function for retrieving a specific tile:
+
+```clojure
+(defn get-tile [tiles x y]
+  (get-in tiles [y x] (:bound tiles)))
+```
+
+Remember that we're storing the tiles as a vector of rows, so when we index into
+it we need to get the y coordinate (i.e.: the row) first, then index in for the
+column with the x coordinate.
+
+This is a bit ugly, but storing the screen as rows is going to help us later as
+we draw the screen, and it gives us the opportunity to do bounds checking as
+well.
+
+The `get-in` call is a really handy way to check bounds.  No worrying about
+comparing indexes to dimensions — just try to get it and if you fail it must be
+out of bounds.
+
+That's about it for the world structure.  Time to move to the generation:
+
+```clojure
+(defn random-tiles []
+  (let [[cols rows] world-size]
+    (letfn [(random-tile []
+              (tiles (rand-nth [:floor :wall])))
+            (random-row []
+              (vec (repeatedly cols random-tile)))]
+      (vec (repeatedly rows random-row)))))
+
+(defn random-world []
+  (new World (random-tiles)))
+```
+
+Nothing too fancy happening here.  In `random-tiles` I built up a series of
+helper functions to make it easier to read.  You could save some LOC by just
+using anonymous functions instead, but to me this way is easier to read.
+Personal preference, I guess.
+
+For now we're just going to generate a world where every tile has an equal
+chance of being a wall or a floor.  I might revisit this later if I want to make
+the caves sparser or denser.
+
+That's it for the world generation.  Next we'll move on to actually displaying
+the new random worlds.
+
+Displaying
+----------
+
+Let's switch back to `core.clj`.  First I updated the namespace to pull in the
+`random-world` function:
+
+```clojure
+(ns caves.core
+  (:use [caves.world :only [random-world]])
+  (:require [lanterna.screen :as s]))
+```
+
+Before going further I decided to do a bit of cleanup.  Instead of hardcoding
+the 80 by 24 terminal size, I pulled it out into a constant:
+
+```clojure
+(def screen-size [80 24])
+```
+
+I updated `clear-screen` to use that:
+
+```clojure
+(defn clear-screen [screen]
+  (let [[cols rows] screen-size
+        blank (apply str (repeat cols \space))]
+    (doseq [row (range rows)]
+      (s/put-string screen 0 row blank))))
+```
+
+It's still not perfect (what if the user's terminal isn't 80 by 24?) but it's
+not something I care enough to fix right now.  I'll get to it later.  At least
+now the hardcoded numbers are in one spot.
+
+There's a few things I need to do to get the world on the screen.  First
+I created a `:play` UI similar to Trystan's.  I'm not a big fan of the
+generic-sounding name, but I couldn't come up with anything better in a few
+minutes of thinking.
+
+Creating a UI requires implementing the `draw-ui` and `process-input`
+multimethods from the previous post.  I'll start with the easy one: input
+processing.
+
+For now the flow of the game will go like this:
+
+1. The player is shown an introduction screen with some instructions.
+2. They press a key and see the world.
+3. Pressing enter wins the game.  Backspace loses the game.  Any other key does
+   nothing.
+4. Once they win or lose, they see a text blurb and can press escape to quit, or
+   any other key to GOTO 1.
+
+With that in mind, I wrote the `process-input` implementation for `:play` UIs:
+
+```clojure
+(defmethod process-input :play [game input]
+  (case input
+    :enter     (assoc game :uis [(new UI :win)])
+    :backspace (assoc game :uis [(new UI :lose)])
+    game))
+```
+
+I'm still replacing the entire UI stack at once.  I'm going to be throwing that
+code away later anyway so it's not a big deal.
+
+Now I need to update the `:start` UI to send the user to the `:play` UI instead
+of directly to the `:win` or `:lose` UIs.
+
+```clojure
+(defmethod process-input :start [game input]
+  (-> game
+    (assoc :world (random-world))
+    (assoc :uis [(new UI :play)])))
+```
+
+I also decided that this is where I'd generate the new random world.  It makes
+sense to put that here, because every time you restart the game you should get
+a different world.
+
+On the other hand, this means that the `process-input` function is no longer
+pure for `:start` UIs (all the other input processing functions are still pure).
+I'm not sure how I feel about that.  For now I'm going to accept it, but I may
+rethink it in the future.
+
+Now that I have the world generation in there, I can remove the `(new World)`
+call from the `new-game` helper function:
+
+```clojure
+(defn new-game []
+  (new Game nil [(new UI :start)] nil))
+```
+
+Now `new-game` does even less than before.  It just sets up a game object with
+the initial UI and `nil` world/input.
+
+Okay, on to the last piece: drawing the world.  This is some pretty dense code,
+but don't be scared — I'll guide you through it and we'll make it together:
+
+```clojure
+(defmethod draw-ui :play [ui {{:keys [tiles]} :world :as game} screen]
+  (let [[cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        start-x 0
+        start-y 0
+        end-x (+ start-x vcols)
+        end-y (+ start-y vrows)]
+    (doseq [[vrow-idx mrow-idx] (map vector
+                                     (range 0 vrows)
+                                     (range start-y end-y))
+            :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
+      (doseq [vcol-idx (range vcols)
+              :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
+        (s/put-string screen vcol-idx vrow-idx glyph {:fg color})))))
+```
+
+Let's look at this beast line-by-line.  First we pull the tile vector out of the
+game object with Clojure's destructuring:
+
+```clojure
+{{:keys [tiles]} :world :as game}
+```
+
+This seems a bit hard to read to me, so I might move it into the `let` statement
+with a `get-in` call later.  Maybe.
+
+Next I bind a bunch of symbols I'll be using:
+
+```clojure
+(let [[cols rows] screen-size
+      vcols cols
+      vrows (dec rows)
+      start-x 0
+      start-y 0
+      end-x (+ start-x vcols)
+      end-y (+ start-y vrows)]
+  ,,,)
+```
+
+`cols` and `rows` are the dimensions of the screen (hardcoded at 80 by 24 for
+the moment).
+
+`vcols` and `vrows` are the "viewport columns" and "viewport rows".  The
+"viewport" is what I'm calling the part of the screen that's actually showing
+the world.  I'm reserving one row at the bottom of the screen to use for
+displaying the player's hit points, score, and so on.  It would be trivial to
+increase that to two rows if I need more later.
+
+`start-x` and `start-y` are the coordinates of the upper-left corner of the
+viewport in the full map, and `end-x` and `end-y` are the coordinates of the
+lower-right corner.  For now I'm just displaying the upper-left section of the
+map.  In the entry after the next one I'll add the ability to scroll around.
+
+It's easier to explain with a diagram.  Imagine I reduced the size of the world
+to 10 by 10 and the terminal to 5 by 3, and the user was standing near the
+middle of the map:
+
+```text
+      columns (x)
+      0123456789
+rows 0..........
+(y)  1..........
+     2..........
+     3..VVVVV...
+     4..VVVVV...
+     5..VVVVV...
+     6..........
+     7..........
+     8..........
+     9..........
+```
+
+Here `V` represents the portion of the map the viewport can show (which is what
+we'll be drawing to the user's terminal).  In this example `start-x` would
+be `2`, `start-y` would be `3`, `end-x` would be `6`, and `end-y` would be `5`.
+
+Okay, so I've calculated the part of the map that needs to be drawn.  Now
+I loop through the rows:
+
+```clojure
+(doseq [[vrow-idx mrow-idx] (map vector
+                                 (range 0 vrows)
+                                 (range start-y end-y))
+        :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
+  ,,,)
+```
+
+This is a bit obtuse, but basically the `map` call pairs up the viewport row and
+map row indices.  In our example it would result in this:
+
+```clojure
+[[0 3]
+ [1 4]
+ [2 5]]
+```
+
+So viewport row `1` corresponds to map row `4`.  There's probably a less
+"clever" way to do this that I should use instead.
+
+For each row, I grab the tiles we're going to draw and store them in a vector
+called `row-tiles` by grabbing the row of tiles from the world and taking
+a slice of it.
+
+Almost there!  Next I loop through each column in the row:
+
+```clojure
+(doseq [vcol-idx (range vcols)
+        :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
+  ,,,)
+```
+
+For each column I grab the appropriate tile and figure out what glyph and color
+to draw (remember the definition of `Tile`: `(defrecord Tile [kind glyph
+color])`).
+
+Finally I can actually draw the tile to the screen at the appropriate place:
+
+```clojure
+(s/put-string screen vcol-idx vrow-idx glyph {:fg color})
+```
+
+Whew!  If that seemed painful and fiddly to you, trust me, I agree.  I'm open to
+suggestions on making it easier to read.
+
+Results
+-------
+
+Now that the `:play` UI knows how to draw itself and process its input, and is
+properly hooked up by the `:start` UI, it's time to give it a shot!
+
+![Screenshot](/media/images/blog/2012/07/caves-03-1-01.png)
+
+![Screenshot](/media/images/blog/2012/07/caves-03-1-02.png)
+
+![Screenshot](/media/images/blog/2012/07/caves-03-1-03.png)
+
+Each time we start we get a different random world.  Great!
+
+The code is getting a bit big to include in its entirety, but you can view it
+[on GitHub][result-code].
+
+[result-code]: https://github.com/sjl/caves/tree/entry-03-1/src/caves
+
+That covers the first part of Trystan's third post.  Aside from the painful
+`draw-ui` function it was pretty easy to add.  In the next post I'll add the
+smoothing code to make the caves look a bit nicer.
+
--- a/content/blog/2012/07/caves-of-clojure-03-2.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,285 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 3.2"
-        snip: "World smoothing."
-        created: 2012-07-10 10:04:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry corresponds to [post three in Trystan's tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `entry-03-2` tag to see the code as it stands
-after this post.
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-03-scrolling-through.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-When the last post left off I had a random world generated, but it wasn't very
-pretty.  Every tile had an equal chance of being a wall or a floor, which
-results in an uninteresting "white noise" of rock.  Not a very nice setting for
-a roguelike.
-
-This post is going to show how I added Trystan's world smoothing to make
-nicer-looking caves.  He uses a [cellular automata-based world-smoothing
-algorithm][ca-wiki] that I think is really cool, so I'm going to do pretty much
-the same thing.
-
-Debugging
----------
-
-Let's jump right in.  The world smoothing code is going to go in `world.clj`.
-
-Before I start writing the actual smoothing code, I added two helper functions
-to print worlds to the console so I could see what I was doing:
-
-    :::clojure
-    (defn print-row [row]
-      (println (apply str (map :glyph row))))
-
-    (defn print-world [world]
-      (dorun (map print-row (:tiles world))))
-
-Simple, but very helpful because `(:tiles world)` contains `Tile` records
-instead of just the raw glyphs, so printing it without these helpers makes it
-impossible to read.
-
-Smoothing
----------
-
-Okay, on to the real code.  I'll go through it from the bottom up this time
-because I think it's easier to understand that way.
-
-First I added a `smooth-world` function that will be what I eventually need to
-call repeatedly to smooth out the terrain:
-
-    :::clojure
-    (defn smooth-world [{:keys [tiles] :as world}]
-      (assoc world :tiles (get-smoothed-tiles tiles)))
-
-It's pretty much a helper function that handles getting the tile map in and out
-of the world object.  The smoothing process only cares about the tile map, not
-anything else the world might later contain.
-
-Next up:
-
-    :::clojure
-    (defn get-smoothed-tiles [tiles]
-      (mapv (fn [y]
-              (get-smoothed-row tiles y))
-            (range (count tiles))))
-
-I use Clojure 1.4's new `mapv` function, which is basically a version of `map`
-that creates a vector as the end product instead of a lazy sequence.  Our
-`:tiles` object is a vector of vectors going in, so it should be the same coming
-out.
-
-I loop map over the row indices.  For each row number I get the result of
-`get-smoothed-row`, and the `mapv` concatenates all of those into a vector for
-me, so I end up with `[[smoothed row], [smoothed row], ...]`.
-
-You might notice that I'm using an index-based approach here.  Isn't that a bad
-idea in Clojure?  Shouldn't I be using sequenced-based things instead?
-
-I spent about twenty minutes trying to get the sequence-based approach in the
-Programming Clojure book to work and eventually gave up.  It sounds like
-a beautiful idea but I couldn't deal with it for a number of reasons:
-
-* Harder to debug, with infinite padding sequences making some intermediate
-  steps unprintable.
-* Very general, which sounds good, but makes it harder to understand because we
-  can't talk about "the row of tiles" any more but now talk about stuff like
-  "the sequence of row triples".
-* In general just very alien and hard to use for what should be a
-  straightforward, 10 minute task.
-
-Here's an example of a few of the functions from the book I would have been
-using if I had gone that route:
-
-    :::clojure
-    (defn window
-      "Returns a lazy sequence of 3-item windows centered
-      around each item of coll, padded as necessary with
-      pad or nil."
-      ([coll] (window nil coll))
-      ([pad coll]
-        (partition 3 1 (concat [pad] coll [pad]))))
-
-    (defn cell-block
-      "Creates a sequences of 3x3 windows from a triple of 3 sequences."
-      [[left mid right]]
-      (window (map vector left mid right)))
-
-I personally find it easier to read things like `(get-smoothed-row tiles y)`
-than `(map vector left right mid)`.  You might feel differently, but this was
-what I ended up with because I didn't want to spend a ton of time on the
-smoothing process.
-
-Anyway, back to the code.  Now I need a way to smooth a single row:
-
-    :::clojure
-    (defn get-smoothed-row [tiles y]
-      (mapv (fn [x]
-              (get-smoothed-tile (get-block tiles x y)))
-            (range (count (first tiles)))))
-
-Once again I use `mapv` because a row needs to be a vector.  This time I'm
-mapping over the column indices, but for the most part it's very similar to the
-previous function.
-
-I need a function to smooth a tile, but first I need a way to get a "block" of
-tiles.
-
-The basic rule I'm using for the smoothing comes from the [page about cellular
-automata smoothing on RogueBasin][ca-wiki]:
-
-[ca-wiki]: http://roguebasin.roguelikedevelopment.org/index.php?title=Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels
-
-A tile will become a floor tile if and only if the 3 by 3 square of tiles
-centered on it contains 5 or more floor tiles.
-
-This means I need a way to get the 3 by 3 block of tiles centered on any given
-tile:
-
-    :::clojure
-    (defn block-coords [x y]
-      (for [dx [-1 0 1]
-            dy [-1 0 1]]
-        [(+ x dx) (+ y dy)]))
-
-    (defn get-block [tiles x y]
-      (map (fn [[x y]]
-             (get-tile tiles x y))
-           (block-coords x y)))
-
-First we have a helper function that returns the coordinates of all the tiles
-we're going to look at.  For example, if you pass it `[22 30]` it will return:
-
-    :::clojure
-    [[21 29] [22 29] [23 29]
-     [21 30] [22 30] [23 30]
-     [21 31] [22 31] [23 31]]
-
-Note that `get-block` doesn't do any bounds checking, so passing it `[0 0]` will
-happily return coordinates like `[-1 -1]`, which are off the edge of the map.
-
-This isn't a problem because our `get-tile` method will return `:bound` tiles
-for those coordinates, which are not `:floor` tiles and so are effectively walls
-for the purposes of this algorithm.
-
-`get-block` itself is just a glue function that gets coordinates from
-`block-coords` and maps `get-tile` over them.
-
-So now I have a way to get a sequence of all the tiles in a block centered
-around a target.  The last step is actually figuring out what the resulting
-block for that target should be:
-
-    :::clojure
-    (defn get-smoothed-tile [block]
-      (let [tile-counts (frequencies (map :kind block))
-            floor-threshold 5
-            floor-count (get tile-counts :floor 0)
-            result (if (>= floor-count floor-threshold)
-                     :floor
-                     :wall)]
-        (tiles result)))
-
-This looks long, but that's mostly because I like using named intermediate
-variables to make it more readable.  It should be pretty easy to understand,
-just go ahead and read through it.
-
-So now the `smooth-world` function has all the machinery it needs to smooth
-a world.  The last step is to actually *use* it.  I changed the `random-world`
-function to look like this:
-
-    :::clojure
-    (defn random-world []
-      (let [world (new World (random-tiles))
-            world (nth (iterate smooth-world world) 0)]
-        world))
-
-At the moment it takes the zeroth iteration, which actually means the unsmoothed
-world.  What gives?
-
-Interactive Development
------------------------
-
-I wasn't sure right away how much smoothing would look good, so I wanted to try
-out a bunch of levels and see how they behaved.  I could have done it by
-printing to the console, but it's a pain to compare the multiple hunks of text.
-
-I decided to just add it to the game itself for now to make it easy to see how
-the smoothing behaves.  Back in `core.clj` I pulled in the `smooth-world`
-function:
-
-    :::clojure
-    (ns caves.core
-      (:use [caves.world :only [random-world smooth-world]])
-      (:require [lanterna.screen :as s]))
-
-Next I added another command to the `:play` UI: pressing `s` will smooth the
-current world by one more level:
-
-
-    :::clojure
-    (defmethod process-input :play [game input]
-      (case input
-        :enter     (assoc game :uis [(new UI :win)])
-        :backspace (assoc game :uis [(new UI :lose)])
-        \s         (assoc game :world (smooth-world (:world game)))
-        game))
-
-Yes, it only took one line to add that.  I simply replace the world with the
-smooth(er) world and return the resulting game.  I don't need to touch the UI
-stack because I want to remain at the play UI for subsequent commands.
-
-I'm really liking this immutable game structure so far!
-
-Results
--------
-
-Once you fire up the game and press a key to begin, you're presented with the
-white-noise map from the last entry:
-
-![Screenshot](/media/images{{ parent_url }}/caves-03-2-01.png)
-
-But now you can press `s` and the caves will smooth out a bit:
-
-![Screenshot](/media/images{{ parent_url }}/caves-03-2-02.png)
-
-Another press of `s` smooths them further:
-
-![Screenshot](/media/images{{ parent_url }}/caves-03-2-03.png)
-
-You can use enter or backspace to win or lose, then any key to go back to the
-start screen and get a new world to play with.
-
-Screenshots really don't do this justice, because seeing the world change before
-your eyes is *really* cool.  I made a 30-second [screencast][] that demonstrates
-the effect if you don't want to actually run it locally.
-
-[screencast]: http://www.screenr.com/FSk8
-
-I still haven't decided exactly how smooth I want to make the caves, so I'll
-leave that `0` in the `nth` call for now and figure it out later.
-
-You can view the code [on GitHub][result-code] if you want to see it all at
-once.
-
-[result-code]: https://github.com/sjl/caves/tree/entry-03-2/src/caves
-
-Next post: scrolling!
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-03-2.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,293 @@
++++
+title = "The Caves of Clojure: Part 3.2"
+snip = "World smoothing."
+date = 2012-07-10T10:04:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry corresponds to [post three in Trystan's tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `entry-03-2` tag to see the code as it stands
+after this post.
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-03-scrolling-through.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+When the last post left off I had a random world generated, but it wasn't very
+pretty.  Every tile had an equal chance of being a wall or a floor, which
+results in an uninteresting "white noise" of rock.  Not a very nice setting for
+a roguelike.
+
+This post is going to show how I added Trystan's world smoothing to make
+nicer-looking caves.  He uses a [cellular automata-based world-smoothing
+algorithm][ca-wiki] that I think is really cool, so I'm going to do pretty much
+the same thing.
+
+Debugging
+---------
+
+Let's jump right in.  The world smoothing code is going to go in `world.clj`.
+
+Before I start writing the actual smoothing code, I added two helper functions
+to print worlds to the console so I could see what I was doing:
+
+```clojure
+(defn print-row [row]
+  (println (apply str (map :glyph row))))
+
+(defn print-world [world]
+  (dorun (map print-row (:tiles world))))
+```
+
+Simple, but very helpful because `(:tiles world)` contains `Tile` records
+instead of just the raw glyphs, so printing it without these helpers makes it
+impossible to read.
+
+Smoothing
+---------
+
+Okay, on to the real code.  I'll go through it from the bottom up this time
+because I think it's easier to understand that way.
+
+First I added a `smooth-world` function that will be what I eventually need to
+call repeatedly to smooth out the terrain:
+
+```clojure
+(defn smooth-world [{:keys [tiles] :as world}]
+  (assoc world :tiles (get-smoothed-tiles tiles)))
+```
+
+It's pretty much a helper function that handles getting the tile map in and out
+of the world object.  The smoothing process only cares about the tile map, not
+anything else the world might later contain.
+
+Next up:
+
+```clojure
+(defn get-smoothed-tiles [tiles]
+  (mapv (fn [y]
+          (get-smoothed-row tiles y))
+        (range (count tiles))))
+```
+
+I use Clojure 1.4's new `mapv` function, which is basically a version of `map`
+that creates a vector as the end product instead of a lazy sequence.  Our
+`:tiles` object is a vector of vectors going in, so it should be the same coming
+out.
+
+I loop map over the row indices.  For each row number I get the result of
+`get-smoothed-row`, and the `mapv` concatenates all of those into a vector for
+me, so I end up with `[[smoothed row], [smoothed row], ...]`.
+
+You might notice that I'm using an index-based approach here.  Isn't that a bad
+idea in Clojure?  Shouldn't I be using sequenced-based things instead?
+
+I spent about twenty minutes trying to get the sequence-based approach in the
+Programming Clojure book to work and eventually gave up.  It sounds like
+a beautiful idea but I couldn't deal with it for a number of reasons:
+
+* Harder to debug, with infinite padding sequences making some intermediate
+  steps unprintable.
+* Very general, which sounds good, but makes it harder to understand because we
+  can't talk about "the row of tiles" any more but now talk about stuff like
+  "the sequence of row triples".
+* In general just very alien and hard to use for what should be a
+  straightforward, 10 minute task.
+
+Here's an example of a few of the functions from the book I would have been
+using if I had gone that route:
+
+```clojure
+(defn window
+  "Returns a lazy sequence of 3-item windows centered
+  around each item of coll, padded as necessary with
+  pad or nil."
+  ([coll] (window nil coll))
+  ([pad coll]
+    (partition 3 1 (concat [pad] coll [pad]))))
+
+(defn cell-block
+  "Creates a sequences of 3x3 windows from a triple of 3 sequences."
+  [[left mid right]]
+  (window (map vector left mid right)))
+```
+
+I personally find it easier to read things like `(get-smoothed-row tiles y)`
+than `(map vector left right mid)`.  You might feel differently, but this was
+what I ended up with because I didn't want to spend a ton of time on the
+smoothing process.
+
+Anyway, back to the code.  Now I need a way to smooth a single row:
+
+```clojure
+(defn get-smoothed-row [tiles y]
+  (mapv (fn [x]
+          (get-smoothed-tile (get-block tiles x y)))
+        (range (count (first tiles)))))
+```
+
+Once again I use `mapv` because a row needs to be a vector.  This time I'm
+mapping over the column indices, but for the most part it's very similar to the
+previous function.
+
+I need a function to smooth a tile, but first I need a way to get a "block" of
+tiles.
+
+The basic rule I'm using for the smoothing comes from the [page about cellular
+automata smoothing on RogueBasin][ca-wiki]:
+
+[ca-wiki]: http://roguebasin.roguelikedevelopment.org/index.php?title=Cellular_Automata_Method_for_Generating_Random_Cave-Like_Levels
+
+A tile will become a floor tile if and only if the 3 by 3 square of tiles
+centered on it contains 5 or more floor tiles.
+
+This means I need a way to get the 3 by 3 block of tiles centered on any given
+tile:
+
+```clojure
+(defn block-coords [x y]
+  (for [dx [-1 0 1]
+        dy [-1 0 1]]
+    [(+ x dx) (+ y dy)]))
+
+(defn get-block [tiles x y]
+  (map (fn [[x y]]
+         (get-tile tiles x y))
+       (block-coords x y)))
+```
+
+First we have a helper function that returns the coordinates of all the tiles
+we're going to look at.  For example, if you pass it `[22 30]` it will return:
+
+```clojure
+[[21 29] [22 29] [23 29]
+ [21 30] [22 30] [23 30]
+ [21 31] [22 31] [23 31]]
+```
+
+Note that `get-block` doesn't do any bounds checking, so passing it `[0 0]` will
+happily return coordinates like `[-1 -1]`, which are off the edge of the map.
+
+This isn't a problem because our `get-tile` method will return `:bound` tiles
+for those coordinates, which are not `:floor` tiles and so are effectively walls
+for the purposes of this algorithm.
+
+`get-block` itself is just a glue function that gets coordinates from
+`block-coords` and maps `get-tile` over them.
+
+So now I have a way to get a sequence of all the tiles in a block centered
+around a target.  The last step is actually figuring out what the resulting
+block for that target should be:
+
+```clojure
+(defn get-smoothed-tile [block]
+  (let [tile-counts (frequencies (map :kind block))
+        floor-threshold 5
+        floor-count (get tile-counts :floor 0)
+        result (if (>= floor-count floor-threshold)
+                 :floor
+                 :wall)]
+    (tiles result)))
+```
+
+This looks long, but that's mostly because I like using named intermediate
+variables to make it more readable.  It should be pretty easy to understand,
+just go ahead and read through it.
+
+So now the `smooth-world` function has all the machinery it needs to smooth
+a world.  The last step is to actually *use* it.  I changed the `random-world`
+function to look like this:
+
+```clojure
+(defn random-world []
+  (let [world (new World (random-tiles))
+        world (nth (iterate smooth-world world) 0)]
+    world))
+```
+
+At the moment it takes the zeroth iteration, which actually means the unsmoothed
+world.  What gives?
+
+Interactive Development
+-----------------------
+
+I wasn't sure right away how much smoothing would look good, so I wanted to try
+out a bunch of levels and see how they behaved.  I could have done it by
+printing to the console, but it's a pain to compare the multiple hunks of text.
+
+I decided to just add it to the game itself for now to make it easy to see how
+the smoothing behaves.  Back in `core.clj` I pulled in the `smooth-world`
+function:
+
+```clojure
+(ns caves.core
+  (:use [caves.world :only [random-world smooth-world]])
+  (:require [lanterna.screen :as s]))
+```
+
+Next I added another command to the `:play` UI: pressing `s` will smooth the
+current world by one more level:
+
+
+```clojure
+(defmethod process-input :play [game input]
+  (case input
+    :enter     (assoc game :uis [(new UI :win)])
+    :backspace (assoc game :uis [(new UI :lose)])
+    \s         (assoc game :world (smooth-world (:world game)))
+    game))
+```
+
+Yes, it only took one line to add that.  I simply replace the world with the
+smooth(er) world and return the resulting game.  I don't need to touch the UI
+stack because I want to remain at the play UI for subsequent commands.
+
+I'm really liking this immutable game structure so far!
+
+Results
+-------
+
+Once you fire up the game and press a key to begin, you're presented with the
+white-noise map from the last entry:
+
+![Screenshot](/media/images/blog/2012/07/caves-03-2-01.png)
+
+But now you can press `s` and the caves will smooth out a bit:
+
+![Screenshot](/media/images/blog/2012/07/caves-03-2-02.png)
+
+Another press of `s` smooths them further:
+
+![Screenshot](/media/images/blog/2012/07/caves-03-2-03.png)
+
+You can use enter or backspace to win or lose, then any key to go back to the
+start screen and get a new world to play with.
+
+Screenshots really don't do this justice, because seeing the world change before
+your eyes is *really* cool.  I made a 30-second [screencast][] that demonstrates
+the effect if you don't want to actually run it locally.
+
+[screencast]: http://www.screenr.com/FSk8
+
+I still haven't decided exactly how smooth I want to make the caves, so I'll
+leave that `0` in the `nth` call for now and figure it out later.
+
+You can view the code [on GitHub][result-code] if you want to see it all at
+once.
+
+[result-code]: https://github.com/sjl/caves/tree/entry-03-2/src/caves
+
+Next post: scrolling!
+
--- a/content/blog/2012/07/caves-of-clojure-03-3.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,399 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 3.3"
-        snip: "Scrolling."
-        created: 2012-07-11 9:25:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry corresponds to [post three in Trystan's tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `entry-03-3` tag to see the code as it stands
-after this post.
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-03-scrolling-through.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-When the last post left off I had a random world generated and smoothed to
-create some nice looking caves.  The world was displayed on the screen, but it
-would only display the upper left corner of the map.
-
-This post is going to be about scrolling the viewport so we can view the entire
-map.  It's the last remaining piece of Trystan's third post that I still need to
-implement.
-
-Refactoring
------------
-
-This is going to involve changing the worst function in the code so far
-(`draw-ui` for `:player` UIs), so before I start hacking away I want to factor
-out a bit of functionality to clean things up.
-
-Right now that `draw-ui` function in `core.clj` looks like this:
-
-    :::clojure
-    (defmethod draw-ui :play [ui {{:keys [tiles]} :world :as game} screen]
-      (let [[cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            start-x 0
-            start-y 0
-            end-x (+ start-x vcols)
-            end-y (+ start-y vrows)]
-        (doseq [[vrow-idx mrow-idx] (map vector
-                                         (range 0 vrows)
-                                         (range start-y end-y))
-                :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
-          (doseq [vcol-idx (range vcols)
-                  :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
-            (s/put-string screen vcol-idx vrow-idx glyph {:fg color})))))
-
-I pulled out the guts of that function into a helper function:
-
-    :::clojure
-    (defn draw-world [screen vrows vcols start-x start-y end-x end-y tiles]
-      (doseq [[vrow-idx mrow-idx] (map vector
-                                       (range 0 vrows)
-                                       (range start-y end-y))
-              :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
-        (doseq [vcol-idx (range vcols)
-                :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
-          (s/put-string screen vcol-idx vrow-idx glyph {:fg color}))))
-
-    (defmethod draw-ui :play [ui {{:keys [tiles]} :world :as game} screen]
-      (let [[cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            start-x 0
-            start-y 0
-            end-x (+ start-x vcols)
-            end-y (+ start-y vrows)]
-        (draw-world screen vrows vcols start-x start-y end-x end-y tiles)))
-
-No functionality has changed, I just pulled the body out into its own function.
-This will make things cleaner as we add more functionality.
-
-As I mentioned in the last post, I don't like the distructuring in the argument
-list here.  Let's remove that:
-
-    :::clojure
-    (defmethod draw-ui :play [ui game screen]
-      (let [world (:world game)
-            tiles (:tiles world)
-            [cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            start-x 0
-            start-y 0
-            end-x (+ start-x vcols)
-            end-y (+ start-y vrows)]
-        (draw-world screen vrows vcols start-x start-y end-x end-y tiles)))
-
-It's a few more lines of code but I find it more readable.  If you prefer the
-more concise syntax feel free to use the destructuring -- it's not really that
-important either way.
-
-Crosshairs
-----------
-
-Trystan draws an `X` as a kind of crosshair to take the place of the traditional
-roguelike `@` (since there's no player yet), so let's do that.  I made
-a separate function to draw the crosshair as a red `X` in the center of the
-screen:
-
-    :::clojure
-    (defn draw-crosshairs [screen vcols vrows]
-      (let [crosshair-x (int (/ vcols 2))
-            crosshair-y (int (/ vrows 2))]
-          (s/put-string screen crosshair-x crosshair-y "X" {:fg :red})
-          (s/move-cursor screen crosshair-x crosshair-y)))
-
-This function seems pretty straightforward.  It finds the x and y coordinates of
-the viewport where the `X` should go and puts it there.  It also moves the
-cursor on top of it because I like how that looks.
-
-Yeah, it might not actually end up in the exact center of the screen because the
-`int` will truncate if we've got an odd number of rows or columns.  Honestly,
-I'm going to be throwing away this crosshair once we've got a player on the
-screen, so it's not worth fixing.
-
-I need to call `draw-crosshairs` that in the `:play` UI-drawing function:
-
-    :::clojure
-    (defmethod draw-ui :play [ui game screen]
-      (let [world (:world game)
-            tiles (:tiles world)
-            [cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            start-x 0
-            start-y 0
-            end-x (+ start-x vcols)
-            end-y (+ start-y vrows)]
-        (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
-        (draw-crosshairs screen vcols vrows)))
-
-The only change here is the `(draw-crosshairs screen vcols vrows)` after I draw
-the world.  This draws the crosshair `X` on top of the world, which isn't an
-issue because Lanterna's double buffering will ensure that the user never sees
-an intermediate render that's missing the `X`.
-
-Now there's a red `X` in the center of the screen.  Great, but we still need to
-add the main point of this post: scrolling.
-
-Scrolling
----------
-
-Right now the `start-x` and `start-y` in the `draw-ui` function are hardcoded at
-`0`.  All I need to do is change those to modify which part of the map the
-viewport draws, and I'll have scrolling!
-
-First of all, I need a way to keep track of where the viewport should be
-centered.  This will get thrown away once we have a player (the player will be
-the center of the viewport), so I'll just slap it right in the `game` object for
-now:
-
-    :::clojure
-    (defn new-game []
-      (assoc (new Game nil [(new UI :start)] nil)
-             :location [40 20]))
-
-The `new-game` function now `assoc`s a `:location` into the `game` before
-returning it.
-
-I *could* have modified the `(defrecord Game [world uis input])` to add the
-location as a proper field.  But I know I'm going to be removing this soon
-anyway, so I may as well take advantage of the fact that Clojure's record can
-have extra fields `assoc`ed onto them on the fly.
-
-`[40 20]` is an arbitrary location.  It's kind of in the middleish area of the
-map.  Good enough.
-
-Okay, now I need to actually display the correct area of the map in the
-viewport.  I'm going to need to modify `draw-ui` again, which, just as
-a reminder, looks like this:
-
-    :::clojure
-    (defmethod draw-ui :play [ui game screen]
-      (let [world (:world game)
-            tiles (:tiles world)
-            [cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            start-x 0
-            start-y 0
-            end-x (+ start-x vcols)
-            end-y (+ start-y vrows)]
-        (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
-        (draw-crosshairs screen vcols vrows)))
-
-I had a feeling this is going to get a bit gross, so I pulled out the code for
-getting the viewport coordinates into its own helper function:
-
-    :::clojure
-    (defn get-viewport-coords [game vcols vrows]
-      (let [start-x 0
-            start-y 0
-            end-x (+ start-x vcols)
-            end-y (+ start-y vrows)]]
-        [start-x start-y end-x end-y]))
-
-    (defmethod draw-ui :play [ui game screen]
-      (let [world (:world game)
-            tiles (:tiles world)
-            [cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            [start-x start-y end-x end-y] (get-viewport-coords game vcols vrows)]]
-        (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
-        (draw-crosshairs screen vcols vrows)))
-
-No functionality changed, I just shuffled a bit of code out of that ugly
-`draw-ui` function.  As a bonus, the `get-viewport-coords` function is now pure.
-It'll be easy to add unit tests for it later if I want.  Cool.
-
-Now that the viewport coordinates are isolated, it's time to calculate them
-correctly instead of hardcoding them at `0`:
-
-    :::clojure
-    (defn get-viewport-coords [game vcols vrows]
-      (let [location (:location game)
-            [center-x center-y] location
-
-            tiles (:tiles (:world game))
-
-            map-rows (count tiles)
-            map-cols (count (first tiles))
-
-            start-x (max 0 (- center-x (int (/ vcols 2))))
-            start-y (max 0 (- center-y (int (/ vrows 2))))
-
-            end-x (+ start-x vcols)
-            end-x (min end-x map-cols)
-
-            end-y (+ start-y vrows)
-            end-y (min end-y map-rows)
-
-            start-x (- end-x vcols)
-            start-y (- end-y vrows)]
-        [start-x start-y end-x end-y]))
-
-This is long, but very straightforward.  I use the fact that `let` doesn't care
-if you rebind variables many times in the same binding vector to write
-imperative code.  There may be a more "clever" way to do this, but I like the
-clarity.
-
-First it finds the location of the crosshair (which will be `[40 20]` from
-`new-game` at the moment).  It calls that `center-x` and `center-y`.
-
-It also pulls the tile vector out of the `game` object and uses it to
-determine the full dimensions of the map.  I'm thinking of having a `map-size`
-constant somewhere instead of doing it this way.  I may do that in a later post.
-
-Next come these scary lines:
-
-    :::clojure
-    start-x (max 0 (- center-x (int (/ vcols 2))))
-    start-y (max 0 (- center-y (int (/ vrows 2))))
-
-They're not as scary as they look.  Both are exactly the same except for which
-dimension they're working on.  First I subtract half the viewport size from the
-center coordinate.  This should give me either the topmost or leftmost
-coordinate we're going to be drawing.
-
-Then I use `max` to make sure that if the starting coordinate would be less than
-zero (i.e.: off of the map) I just use 0 instead.
-
-Okay, so now I've got the coordinates of the top left point I need to draw, and
-I'm sure that it doesn't fall off the top or left edge of the map.  Cool.  Time
-to get the bottom right coordinate.
-
-    :::clojure
-    end-x (+ start-x vcols)
-    end-x (min end-x map-cols)
-
-    end-y (+ start-y vrows)
-    end-y (min end-y map-rows)
-
-This is similar to how we get the starting coordinates.  We calculate a "naive
-end x" by adding the viewport size to the start, and then make sure the end
-doesn't fall off the map.
-
-I did this all in one line for the start coordinates, but split it into two for
-the end coordinates.  I'm not sure why I did it like that -- I just noticed it
-now.  I'm going to go ahead and change the start to be the expanded, two-line
-form.  I think it's clearer.
-
-Okay, so now I've ensured that the end coordinate doesn't fall off the map.  I'm
-done, right?
-
-Well, not quite.  If I truncated the end coordinate here I'll have ended up with
-a smaller-than-normal viewport.  To fix that I'll reset the start coordinates
-one more time:
-
-    :::clojure
-    start-x (- end-x vcols)
-    start-y (- end-y vrows)
-
-This time I don't need to check any bounds.  I know the end coordinate is good
-because it was based on a known start coordinate (the top/left side is good) and
-I corrected the bottom/right side.  So I simply use this known-good end
-coordinate to get a known-good start coordinate and I'm done.
-
-If the map is smaller than the viewport size this is probably going to explode.
-I'm going to ignore that for now.  I may revisit it later, or I may just stick
-with an 80 by 24 viewport for all time like Nethack.
-
-That was a lot of work, but the only thing that's changed is I'm now displaying
-a section of the map near the middle instead of at the upper left.  The last
-piece is to add the ability to adjust the `:location` in the `game` object on
-the fly.
-
-The player should be able to scroll around when they're at the `:play` UI, so
-let's add the appropriate input handling:
-
-    :::clojure
-    (defn move [[x y] [dx dy]]
-      [(+ x dx) (+ y dy)])
-
-    (defmethod process-input :play [game input]
-      (case input
-        :enter     (assoc game :uis [(new UI :win)])
-        :backspace (assoc game :uis [(new UI :lose)])
-        \q         (assoc game :uis [])
-
-        \s (assoc game :world (smooth-world (:world game)))
-
-        \h (update-in game [:location] move [-1 0])
-        \j (update-in game [:location] move [0 1])
-        \k (update-in game [:location] move [0 -1])
-        \l (update-in game [:location] move [1 0])
-
-        \H (update-in game [:location] move [-5 0])
-        \J (update-in game [:location] move [0 5])
-        \K (update-in game [:location] move [0 -5])
-        \L (update-in game [:location] move [5 0])
-
-        game))
-
-I did a few things here.  First I added the `q` key mapping to quit the game
-without going through the win or lose screens, just to same myself some time.
-Enter and backspace still win and lose the game respectively.
-
-`s` still smooths the world map for now.  No reason to remove that yet.
-
-To handle the movement inputs I first made a `move` helper function which takes
-a coordinate and an amount to move by and returns the new coordinate.
-
-The `process-input` function uses this to get the new coordiate when it gets an
-`h`, `j`, `k`, or `l` keypress.  I also added the shifted versions of the
-letters as "fast movement" keys for convenience.
-
-Right now there's no bounds checking here, so it's possible for your `:location`
-to get scrolled off the edge of the map.  This won't be a problem for the
-display (it will just snap the viewport to the edge of the map), but will make
-the input a bit weird.
-
-For example, if you scroll to the right edge of the map and press right 10 more
-times, you'll need to press left 10 times before it will actually start
-scrolling left again.
-
-This is a bug, but not one I care to fix right now.  I'll be replacing this code
-with player-based code soon enough, so it's just going to get thrown out anyway.
-
-Results
--------
-
-That's it!  Running the game, I can now scroll around the map and/or smooth it
-whenever I like:
-
-![Screenshot](/media/images{{ parent_url }}/caves-03-3-01.png)
-
-![Screenshot](/media/images{{ parent_url }}/caves-03-3-02.png)
-
-This doesn't look much different in pictures, but I can scroll through the world
-with `hjkl`.  Here's a screencast showing what that looks like:
-<http://www.screenr.com/T1k8>
-
-As always, you can view the code [on GitHub][result-code] if you want to see it
-all at once.
-
-[result-code]: https://github.com/sjl/caves/tree/entry-03-3/src/caves
-
-That's it for Trystan's third post.  Next time I'll tackle his fourth (adding
-an actual player).
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-03-3.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,409 @@
++++
+title = "The Caves of Clojure: Part 3.3"
+snip = "Scrolling."
+date = 2012-07-11T9:25:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry corresponds to [post three in Trystan's tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `entry-03-3` tag to see the code as it stands
+after this post.
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-03-scrolling-through.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+When the last post left off I had a random world generated and smoothed to
+create some nice looking caves.  The world was displayed on the screen, but it
+would only display the upper left corner of the map.
+
+This post is going to be about scrolling the viewport so we can view the entire
+map.  It's the last remaining piece of Trystan's third post that I still need to
+implement.
+
+Refactoring
+-----------
+
+This is going to involve changing the worst function in the code so far
+(`draw-ui` for `:player` UIs), so before I start hacking away I want to factor
+out a bit of functionality to clean things up.
+
+Right now that `draw-ui` function in `core.clj` looks like this:
+
+```clojure
+(defmethod draw-ui :play [ui {{:keys [tiles]} :world :as game} screen]
+  (let [[cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        start-x 0
+        start-y 0
+        end-x (+ start-x vcols)
+        end-y (+ start-y vrows)]
+    (doseq [[vrow-idx mrow-idx] (map vector
+                                     (range 0 vrows)
+                                     (range start-y end-y))
+            :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
+      (doseq [vcol-idx (range vcols)
+              :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
+        (s/put-string screen vcol-idx vrow-idx glyph {:fg color})))))
+```
+
+I pulled out the guts of that function into a helper function:
+
+```clojure
+(defn draw-world [screen vrows vcols start-x start-y end-x end-y tiles]
+  (doseq [[vrow-idx mrow-idx] (map vector
+                                   (range 0 vrows)
+                                   (range start-y end-y))
+          :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
+    (doseq [vcol-idx (range vcols)
+            :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
+      (s/put-string screen vcol-idx vrow-idx glyph {:fg color}))))
+
+(defmethod draw-ui :play [ui {{:keys [tiles]} :world :as game} screen]
+  (let [[cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        start-x 0
+        start-y 0
+        end-x (+ start-x vcols)
+        end-y (+ start-y vrows)]
+    (draw-world screen vrows vcols start-x start-y end-x end-y tiles)))
+```
+
+No functionality has changed, I just pulled the body out into its own function.
+This will make things cleaner as we add more functionality.
+
+As I mentioned in the last post, I don't like the distructuring in the argument
+list here.  Let's remove that:
+
+```clojure
+(defmethod draw-ui :play [ui game screen]
+  (let [world (:world game)
+        tiles (:tiles world)
+        [cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        start-x 0
+        start-y 0
+        end-x (+ start-x vcols)
+        end-y (+ start-y vrows)]
+    (draw-world screen vrows vcols start-x start-y end-x end-y tiles)))
+```
+
+It's a few more lines of code but I find it more readable.  If you prefer the
+more concise syntax feel free to use the destructuring — it's not really that
+important either way.
+
+Crosshairs
+----------
+
+Trystan draws an `X` as a kind of crosshair to take the place of the traditional
+roguelike `@` (since there's no player yet), so let's do that.  I made
+a separate function to draw the crosshair as a red `X` in the center of the
+screen:
+
+```clojure
+(defn draw-crosshairs [screen vcols vrows]
+  (let [crosshair-x (int (/ vcols 2))
+        crosshair-y (int (/ vrows 2))]
+      (s/put-string screen crosshair-x crosshair-y "X" {:fg :red})
+      (s/move-cursor screen crosshair-x crosshair-y)))
+```
+
+This function seems pretty straightforward.  It finds the x and y coordinates of
+the viewport where the `X` should go and puts it there.  It also moves the
+cursor on top of it because I like how that looks.
+
+Yeah, it might not actually end up in the exact center of the screen because the
+`int` will truncate if we've got an odd number of rows or columns.  Honestly,
+I'm going to be throwing away this crosshair once we've got a player on the
+screen, so it's not worth fixing.
+
+I need to call `draw-crosshairs` that in the `:play` UI-drawing function:
+
+```clojure
+(defmethod draw-ui :play [ui game screen]
+  (let [world (:world game)
+        tiles (:tiles world)
+        [cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        start-x 0
+        start-y 0
+        end-x (+ start-x vcols)
+        end-y (+ start-y vrows)]
+    (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
+    (draw-crosshairs screen vcols vrows)))
+```
+
+The only change here is the `(draw-crosshairs screen vcols vrows)` after I draw
+the world.  This draws the crosshair `X` on top of the world, which isn't an
+issue because Lanterna's double buffering will ensure that the user never sees
+an intermediate render that's missing the `X`.
+
+Now there's a red `X` in the center of the screen.  Great, but we still need to
+add the main point of this post: scrolling.
+
+Scrolling
+---------
+
+Right now the `start-x` and `start-y` in the `draw-ui` function are hardcoded at
+`0`.  All I need to do is change those to modify which part of the map the
+viewport draws, and I'll have scrolling!
+
+First of all, I need a way to keep track of where the viewport should be
+centered.  This will get thrown away once we have a player (the player will be
+the center of the viewport), so I'll just slap it right in the `game` object for
+now:
+
+```clojure
+(defn new-game []
+  (assoc (new Game nil [(new UI :start)] nil)
+         :location [40 20]))
+```
+
+The `new-game` function now `assoc`s a `:location` into the `game` before
+returning it.
+
+I *could* have modified the `(defrecord Game [world uis input])` to add the
+location as a proper field.  But I know I'm going to be removing this soon
+anyway, so I may as well take advantage of the fact that Clojure's record can
+have extra fields `assoc`ed onto them on the fly.
+
+`[40 20]` is an arbitrary location.  It's kind of in the middleish area of the
+map.  Good enough.
+
+Okay, now I need to actually display the correct area of the map in the
+viewport.  I'm going to need to modify `draw-ui` again, which, just as
+a reminder, looks like this:
+
+```clojure
+(defmethod draw-ui :play [ui game screen]
+  (let [world (:world game)
+        tiles (:tiles world)
+        [cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        start-x 0
+        start-y 0
+        end-x (+ start-x vcols)
+        end-y (+ start-y vrows)]
+    (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
+    (draw-crosshairs screen vcols vrows)))
+```
+
+I had a feeling this is going to get a bit gross, so I pulled out the code for
+getting the viewport coordinates into its own helper function:
+
+```clojure
+(defn get-viewport-coords [game vcols vrows]
+  (let [start-x 0
+        start-y 0
+        end-x (+ start-x vcols)
+        end-y (+ start-y vrows)]]
+    [start-x start-y end-x end-y]))
+
+(defmethod draw-ui :play [ui game screen]
+  (let [world (:world game)
+        tiles (:tiles world)
+        [cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        [start-x start-y end-x end-y] (get-viewport-coords game vcols vrows)]]
+    (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
+    (draw-crosshairs screen vcols vrows)))
+```
+
+No functionality changed, I just shuffled a bit of code out of that ugly
+`draw-ui` function.  As a bonus, the `get-viewport-coords` function is now pure.
+It'll be easy to add unit tests for it later if I want.  Cool.
+
+Now that the viewport coordinates are isolated, it's time to calculate them
+correctly instead of hardcoding them at `0`:
+
+```clojure
+(defn get-viewport-coords [game vcols vrows]
+  (let [location (:location game)
+        [center-x center-y] location
+
+        tiles (:tiles (:world game))
+
+        map-rows (count tiles)
+        map-cols (count (first tiles))
+
+        start-x (max 0 (- center-x (int (/ vcols 2))))
+        start-y (max 0 (- center-y (int (/ vrows 2))))
+
+        end-x (+ start-x vcols)
+        end-x (min end-x map-cols)
+
+        end-y (+ start-y vrows)
+        end-y (min end-y map-rows)
+
+        start-x (- end-x vcols)
+        start-y (- end-y vrows)]
+    [start-x start-y end-x end-y]))
+```
+
+This is long, but very straightforward.  I use the fact that `let` doesn't care
+if you rebind variables many times in the same binding vector to write
+imperative code.  There may be a more "clever" way to do this, but I like the
+clarity.
+
+First it finds the location of the crosshair (which will be `[40 20]` from
+`new-game` at the moment).  It calls that `center-x` and `center-y`.
+
+It also pulls the tile vector out of the `game` object and uses it to
+determine the full dimensions of the map.  I'm thinking of having a `map-size`
+constant somewhere instead of doing it this way.  I may do that in a later post.
+
+Next come these scary lines:
+
+```clojure
+start-x (max 0 (- center-x (int (/ vcols 2))))
+start-y (max 0 (- center-y (int (/ vrows 2))))
+```
+
+They're not as scary as they look.  Both are exactly the same except for which
+dimension they're working on.  First I subtract half the viewport size from the
+center coordinate.  This should give me either the topmost or leftmost
+coordinate we're going to be drawing.
+
+Then I use `max` to make sure that if the starting coordinate would be less than
+zero (i.e.: off of the map) I just use 0 instead.
+
+Okay, so now I've got the coordinates of the top left point I need to draw, and
+I'm sure that it doesn't fall off the top or left edge of the map.  Cool.  Time
+to get the bottom right coordinate.
+
+```clojure
+end-x (+ start-x vcols)
+end-x (min end-x map-cols)
+
+end-y (+ start-y vrows)
+end-y (min end-y map-rows)
+```
+
+This is similar to how we get the starting coordinates.  We calculate a "naive
+end x" by adding the viewport size to the start, and then make sure the end
+doesn't fall off the map.
+
+I did this all in one line for the start coordinates, but split it into two for
+the end coordinates.  I'm not sure why I did it like that — I just noticed it
+now.  I'm going to go ahead and change the start to be the expanded, two-line
+form.  I think it's clearer.
+
+Okay, so now I've ensured that the end coordinate doesn't fall off the map.  I'm
+done, right?
+
+Well, not quite.  If I truncated the end coordinate here I'll have ended up with
+a smaller-than-normal viewport.  To fix that I'll reset the start coordinates
+one more time:
+
+```clojure
+start-x (- end-x vcols)
+start-y (- end-y vrows)
+```
+
+This time I don't need to check any bounds.  I know the end coordinate is good
+because it was based on a known start coordinate (the top/left side is good) and
+I corrected the bottom/right side.  So I simply use this known-good end
+coordinate to get a known-good start coordinate and I'm done.
+
+If the map is smaller than the viewport size this is probably going to explode.
+I'm going to ignore that for now.  I may revisit it later, or I may just stick
+with an 80 by 24 viewport for all time like Nethack.
+
+That was a lot of work, but the only thing that's changed is I'm now displaying
+a section of the map near the middle instead of at the upper left.  The last
+piece is to add the ability to adjust the `:location` in the `game` object on
+the fly.
+
+The player should be able to scroll around when they're at the `:play` UI, so
+let's add the appropriate input handling:
+
+```clojure
+(defn move [[x y] [dx dy]]
+  [(+ x dx) (+ y dy)])
+
+(defmethod process-input :play [game input]
+  (case input
+    :enter     (assoc game :uis [(new UI :win)])
+    :backspace (assoc game :uis [(new UI :lose)])
+    \q         (assoc game :uis [])
+
+    \s (assoc game :world (smooth-world (:world game)))
+
+    \h (update-in game [:location] move [-1 0])
+    \j (update-in game [:location] move [0 1])
+    \k (update-in game [:location] move [0 -1])
+    \l (update-in game [:location] move [1 0])
+
+    \H (update-in game [:location] move [-5 0])
+    \J (update-in game [:location] move [0 5])
+    \K (update-in game [:location] move [0 -5])
+    \L (update-in game [:location] move [5 0])
+
+    game))
+```
+
+I did a few things here.  First I added the `q` key mapping to quit the game
+without going through the win or lose screens, just to same myself some time.
+Enter and backspace still win and lose the game respectively.
+
+`s` still smooths the world map for now.  No reason to remove that yet.
+
+To handle the movement inputs I first made a `move` helper function which takes
+a coordinate and an amount to move by and returns the new coordinate.
+
+The `process-input` function uses this to get the new coordiate when it gets an
+`h`, `j`, `k`, or `l` keypress.  I also added the shifted versions of the
+letters as "fast movement" keys for convenience.
+
+Right now there's no bounds checking here, so it's possible for your `:location`
+to get scrolled off the edge of the map.  This won't be a problem for the
+display (it will just snap the viewport to the edge of the map), but will make
+the input a bit weird.
+
+For example, if you scroll to the right edge of the map and press right 10 more
+times, you'll need to press left 10 times before it will actually start
+scrolling left again.
+
+This is a bug, but not one I care to fix right now.  I'll be replacing this code
+with player-based code soon enough, so it's just going to get thrown out anyway.
+
+Results
+-------
+
+That's it!  Running the game, I can now scroll around the map and/or smooth it
+whenever I like:
+
+![Screenshot](/media/images/blog/2012/07/caves-03-3-01.png)
+
+![Screenshot](/media/images/blog/2012/07/caves-03-3-02.png)
+
+This doesn't look much different in pictures, but I can scroll through the world
+with `hjkl`.  Here's a screencast showing what that looks like:
+<http://www.screenr.com/T1k8>
+
+As always, you can view the code [on GitHub][result-code] if you want to see it
+all at once.
+
+[result-code]: https://github.com/sjl/caves/tree/entry-03-3/src/caves
+
+That's it for Trystan's third post.  Next time I'll tackle his fourth (adding
+an actual player).
+
--- a/content/blog/2012/07/caves-of-clojure-03-4.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,336 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 3.4"
-        snip: "Refactoring."
-        created: 2012-07-11 12:02:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry (kind of) corresponds to [post three in Trystan's
-tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `entry-03-4` tag to see the code as it stands
-after this post.
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-03-scrolling-through.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-In the last post I said that the next post would be about Trystan's fourth
-entry.  I lied.  I'm going to do a short entry about refactoring before I move
-on, because I don't want to clutter up later ones with this stuff.
-
-Record Creation
----------------
-
-Hacker News user bitsai [told me about][hn] a new syntax for creating records in
-Clojure 1.3, so I updated all the `(new Foo)` calls to use that.
-
-One example is the `new-game` function.  Before:
-
-[hn]: https://news.ycombinator.com/item?id=4220141
-
-    :::clojure
-    (defn new-game []
-      (assoc (new Game nil [(new UI :start)] nil)
-              :location [40 20]))
-
-After:
-
-    :::clojure
-    (defn new-game []
-      (assoc (->Game nil [(->UI :start)] nil)
-              :location [40 20]))
-
-It's certainly not too impressive from a "characters saved" point of view.  But
-this little change matters more than it might appear at first glance.
-
-Imagine you define a record in Clojure:
-
-    :::clojure
-    (ns a)
-
-    (defrecord Foo [])
-
-And then in another namespace you want to use it:
-
-    :::clojure
-    (ns b
-      (:use a))
-
-    (new Foo)
-
-This will explode, because `Foo` is actually a Java class, so you need to import
-it:
-
-    :::clojure
-    (ns b
-      (:import a.Foo)
-      (:use a))
-
-    (new Foo)
-
-This is one example of Clojure's Java underpinnings leaking through.
-
-In Clojure 1.3, `defrecord` will automatically generate a "factory function"
-that creates the record, and you can `require` or `use` *that* like any other
-function, so you don't need to screw around with a Java interop feature
-(`import`) to use a pure Clojure feature.
-
-This is a good thing.  It means that progress is being made toward patching the
-places that Java leaks into Clojure.  It gives me hope that some day I'll feel
-okay recommending Clojure to people without Java experience.
-
-I updated all the `(new ...)` calls to use the new-style factory functions.
-I won't paste them all here, but if you're following along you'll want to `grep
--R 'new ' .` and update the rest now.
-
-update-in
----------
-
-Next is a tiny change that's just a bit cleaner.  Alan Malloy [told me][] about
-it.  In the `process-input` function for the `:play` UI, the code to handle
-smoothing the world looked like this:
-
-[told me]: https://twitter.com/alanmalloy/status/222748536595423232
-
-    :::clojure
-    \s (assoc game :world (smooth-world (:world game)))
-
-This can be done much more cleanly using `update-in`:
-
-    :::clojure
-    \s (update-in game [:world] smooth-world)
-
-Nice.
-
-Namespaces
-----------
-
-I said in an earlier post that I tend to leave things in one file until I feel
-like they need to be pulled out.  Well, that time has come.
-
-First I pulled the UI drawing code into its own file: `ui/drawing.clj`.  It
-looks like this (nothing has changed, it's just in a file of its own now):
-
-    :::clojure
-    (ns caves.ui.drawing
-      (:require [lanterna.screen :as s]))
-
-
-    (def screen-size [80 24])
-
-    (defn clear-screen [screen]
-      (let [[cols rows] screen-size
-            blank (apply str (repeat cols \space))]
-        (doseq [row (range rows)]
-          (s/put-string screen 0 row blank))))
-
-
-    (defmulti draw-ui
-      (fn [ui game screen]
-        (:kind ui)))
-
-
-    (defmethod draw-ui :start [ui game screen]
-      (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
-      (s/put-string screen 0 1 "Press any key to continue.")
-      (s/put-string screen 0 2 "")
-      (s/put-string screen 0 3 "Once in the game, you can use enter to win,")
-      (s/put-string screen 0 4 "and backspace to lose."))
-
-
-    (defmethod draw-ui :win [ui game screen]
-      (s/put-string screen 0 0 "Congratulations, you win!")
-      (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
-
-
-    (defmethod draw-ui :lose [ui game screen]
-      (s/put-string screen 0 0 "Sorry, better luck next time.")
-      (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
-
-
-    (defn get-viewport-coords [game vcols vrows]
-      (let [location (:location game)
-            [center-x center-y] location
-
-            tiles (:tiles (:world game))
-
-            map-rows (count tiles)
-            map-cols (count (first tiles))
-
-            start-x (- center-x (int (/ vcols 2)))
-            start-x (max 0 start-x)
-
-            start-y (- center-y (int (/ vrows 2)))
-            start-y (max 0 start-y)
-
-            end-x (+ start-x vcols)
-            end-x (min end-x map-cols)
-
-            end-y (+ start-y vrows)
-            end-y (min end-y map-rows)
-
-            start-x (- end-x vcols)
-            start-y (- end-y vrows)]
-        [start-x start-y end-x end-y]))
-
-    (defn draw-crosshairs [screen vcols vrows]
-      (let [crosshair-x (int (/ vcols 2))
-              crosshair-y (int (/ vrows 2))]
-          (s/put-string screen crosshair-x crosshair-y "X" {:fg :red})
-          (s/move-cursor screen crosshair-x crosshair-y)))
-
-    (defn draw-world [screen vrows vcols start-x start-y end-x end-y tiles]
-      (doseq [[vrow-idx mrow-idx] (map vector
-                                       (range 0 vrows)
-                                       (range start-y end-y))
-              :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
-        (doseq [vcol-idx (range vcols)
-                :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
-          (s/put-string screen vcol-idx vrow-idx glyph {:fg color}))))
-
-    (defmethod draw-ui :play [ui game screen]
-      (let [world (:world game)
-            tiles (:tiles world)
-            [cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            [start-x start-y end-x end-y] (get-viewport-coords game vcols vrows)]
-        (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
-        (draw-crosshairs screen vcols vrows)))
-
-
-    (defn draw-game [game screen]
-      (clear-screen screen)
-      (doseq [ui (:uis game)]
-        (draw-ui ui game screen))
-      (s/redraw screen))
-
-And now I need to `use` the `draw-game` function back in `core.clj`:
-
-    :::clojure
-    (ns caves.core
-      (:use [caves.world :only [random-world smooth-world]]
-            [caves.ui.drawing :only [draw-game]])
-      (:require [lanterna.screen :as s]))
-
-The fact that I moved eleven top-level symbols into a new namespace and only had
-to bring one of them back into the original is a pretty clear sign that this
-chunk of code was ready to be moved into its own file.
-
-I also did the same for the input processing code, moving it into
-`ui/input.clj`:
-
-    :::clojure
-    (ns caves.ui.input
-      (:use [caves.world :only [random-world smooth-world]])
-      (:require [lanterna.screen :as s]))
-
-
-    (defmulti process-input
-      (fn [game input]
-        (:kind (last (:uis game)))))
-
-    (defmethod process-input :start [game input]
-      (-> game
-        (assoc :world (random-world))
-        (assoc :uis [(->UI :play)])))
-
-
-    (defn move [[x y] [dx dy]]
-      [(+ x dx) (+ y dy)])
-
-    (defmethod process-input :play [game input]
-      (case input
-        :enter     (assoc game :uis [(->UI :win)])
-        :backspace (assoc game :uis [(->UI :lose)])
-        \q         (assoc game :uis [])
-
-        \s (update-in game [:world] smooth-world)
-
-        \h (update-in game [:location] move [-1 0])
-        \j (update-in game [:location] move [0 1])
-        \k (update-in game [:location] move [0 -1])
-        \l (update-in game [:location] move [1 0])
-
-        \H (update-in game [:location] move [-5 0])
-        \J (update-in game [:location] move [0 5])
-        \K (update-in game [:location] move [0 -5])
-        \L (update-in game [:location] move [5 0])
-
-        game))
-
-    (defmethod process-input :win [game input]
-      (if (= input :escape)
-        (assoc game :uis [])
-        (assoc game :uis [(->UI :start)])))
-
-    (defmethod process-input :lose [game input]
-      (if (= input :escape)
-        (assoc game :uis [])
-        (assoc game :uis [(->UI :start)])))
-
-
-    (defn get-input [game screen]
-      (assoc game :input (s/get-key-blocking screen)))
-
-This isn't quite functional yet, because it needs the `->UI` factory function,
-which is created by the `(defrecord UI [...])` that's still in `core.clj`.
-I can't just `use` that in this file, because `core` is going to need to `use`
-some functions from this, so I'd have circular imports.
-
-The solution is to move the `(defrecord UI [...])` into a separate file.
-I chose to put it in `ui/core.clj`:
-
-    :::clojure
-    (ns caves.ui.core)
-
-    (defrecord UI [kind])
-
-And now I can pull its creation function back into the `input` namespace:
-
-    :::clojure
-    (ns caves.ui.input
-      (:use [caves.world :only [random-world smooth-world]]
-            [caves.ui.core :only [->UI]])
-      (:require [lanterna.screen :as s]))
-
-Finally I can update the `ns` back in the original `core.clj` to pull in the
-functions I need, and remove the ones I don't:
-
-    :::clojure
-    (ns caves.core
-      (:use [caves.ui.core :only [->UI]]
-            [caves.ui.drawing :only [draw-game]]
-            [caves.ui.input :only [get-input process-input]])
-      (:require [lanterna.screen :as s]))
-
-Whew!
-
-Results
--------
-
-That was a lot of shuffling around, but now I've got five separate files, each
-pertaining to one specific thing, instead of one big pile of code.
-
-You can view the code [on GitHub][result-code] if you want to see the end
-result.
-
-[result-code]: https://github.com/sjl/caves/tree/entry-03-4/src/caves
-
-Next post I swear I'll add the player so we'll have an actual game!
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-03-4.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,346 @@
++++
+title = "The Caves of Clojure: Part 3.4"
+snip = "Refactoring."
+date = 2012-07-11T12:02:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry (kind of) corresponds to [post three in Trystan's
+tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `entry-03-4` tag to see the code as it stands
+after this post.
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-03-scrolling-through.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+In the last post I said that the next post would be about Trystan's fourth
+entry.  I lied.  I'm going to do a short entry about refactoring before I move
+on, because I don't want to clutter up later ones with this stuff.
+
+Record Creation
+---------------
+
+Hacker News user bitsai [told me about][hn] a new syntax for creating records in
+Clojure 1.3, so I updated all the `(new Foo)` calls to use that.
+
+One example is the `new-game` function.  Before:
+
+[hn]: https://news.ycombinator.com/item?id=4220141
+
+```clojure
+(defn new-game []
+  (assoc (new Game nil [(new UI :start)] nil)
+          :location [40 20]))
+```
+
+After:
+
+```clojure
+(defn new-game []
+  (assoc (->Game nil [(->UI :start)] nil)
+          :location [40 20]))
+```
+
+It's certainly not too impressive from a "characters saved" point of view.  But
+this little change matters more than it might appear at first glance.
+
+Imagine you define a record in Clojure:
+
+```clojure
+(ns a)
+
+(defrecord Foo [])
+```
+
+And then in another namespace you want to use it:
+
+```clojure
+(ns b
+  (:use a))
+
+(new Foo)
+```
+
+This will explode, because `Foo` is actually a Java class, so you need to import
+it:
+
+```clojure
+(ns b
+  (:import a.Foo)
+  (:use a))
+
+(new Foo)
+```
+
+This is one example of Clojure's Java underpinnings leaking through.
+
+In Clojure 1.3, `defrecord` will automatically generate a "factory function"
+that creates the record, and you can `require` or `use` *that* like any other
+function, so you don't need to screw around with a Java interop feature
+(`import`) to use a pure Clojure feature.
+
+This is a good thing.  It means that progress is being made toward patching the
+places that Java leaks into Clojure.  It gives me hope that some day I'll feel
+okay recommending Clojure to people without Java experience.
+
+I updated all the `(new ...)` calls to use the new-style factory functions.
+I won't paste them all here, but if you're following along you'll want to `grep
+-R 'new ' .` and update the rest now.
+
+update-in
+---------
+
+Next is a tiny change that's just a bit cleaner.  Alan Malloy [told me][] about
+it.  In the `process-input` function for the `:play` UI, the code to handle
+smoothing the world looked like this:
+
+[told me]: https://twitter.com/alanmalloy/status/222748536595423232
+
+```clojure
+\s (assoc game :world (smooth-world (:world game)))
+```
+
+This can be done much more cleanly using `update-in`:
+
+```clojure
+\s (update-in game [:world] smooth-world)
+```
+
+Nice.
+
+Namespaces
+----------
+
+I said in an earlier post that I tend to leave things in one file until I feel
+like they need to be pulled out.  Well, that time has come.
+
+First I pulled the UI drawing code into its own file: `ui/drawing.clj`.  It
+looks like this (nothing has changed, it's just in a file of its own now):
+
+```clojure
+(ns caves.ui.drawing
+  (:require [lanterna.screen :as s]))
+
+
+(def screen-size [80 24])
+
+(defn clear-screen [screen]
+  (let [[cols rows] screen-size
+        blank (apply str (repeat cols \space))]
+    (doseq [row (range rows)]
+      (s/put-string screen 0 row blank))))
+
+
+(defmulti draw-ui
+  (fn [ui game screen]
+    (:kind ui)))
+
+
+(defmethod draw-ui :start [ui game screen]
+  (s/put-string screen 0 0 "Welcome to the Caves of Clojure!")
+  (s/put-string screen 0 1 "Press any key to continue.")
+  (s/put-string screen 0 2 "")
+  (s/put-string screen 0 3 "Once in the game, you can use enter to win,")
+  (s/put-string screen 0 4 "and backspace to lose."))
+
+
+(defmethod draw-ui :win [ui game screen]
+  (s/put-string screen 0 0 "Congratulations, you win!")
+  (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
+
+
+(defmethod draw-ui :lose [ui game screen]
+  (s/put-string screen 0 0 "Sorry, better luck next time.")
+  (s/put-string screen 0 1 "Press escape to exit, anything else to restart."))
+
+
+(defn get-viewport-coords [game vcols vrows]
+  (let [location (:location game)
+        [center-x center-y] location
+
+        tiles (:tiles (:world game))
+
+        map-rows (count tiles)
+        map-cols (count (first tiles))
+
+        start-x (- center-x (int (/ vcols 2)))
+        start-x (max 0 start-x)
+
+        start-y (- center-y (int (/ vrows 2)))
+        start-y (max 0 start-y)
+
+        end-x (+ start-x vcols)
+        end-x (min end-x map-cols)
+
+        end-y (+ start-y vrows)
+        end-y (min end-y map-rows)
+
+        start-x (- end-x vcols)
+        start-y (- end-y vrows)]
+    [start-x start-y end-x end-y]))
+
+(defn draw-crosshairs [screen vcols vrows]
+  (let [crosshair-x (int (/ vcols 2))
+          crosshair-y (int (/ vrows 2))]
+      (s/put-string screen crosshair-x crosshair-y "X" {:fg :red})
+      (s/move-cursor screen crosshair-x crosshair-y)))
+
+(defn draw-world [screen vrows vcols start-x start-y end-x end-y tiles]
+  (doseq [[vrow-idx mrow-idx] (map vector
+                                   (range 0 vrows)
+                                   (range start-y end-y))
+          :let [row-tiles (subvec (tiles mrow-idx) start-x end-x)]]
+    (doseq [vcol-idx (range vcols)
+            :let [{:keys [glyph color]} (row-tiles vcol-idx)]]
+      (s/put-string screen vcol-idx vrow-idx glyph {:fg color}))))
+
+(defmethod draw-ui :play [ui game screen]
+  (let [world (:world game)
+        tiles (:tiles world)
+        [cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        [start-x start-y end-x end-y] (get-viewport-coords game vcols vrows)]
+    (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
+    (draw-crosshairs screen vcols vrows)))
+
+
+(defn draw-game [game screen]
+  (clear-screen screen)
+  (doseq [ui (:uis game)]
+    (draw-ui ui game screen))
+  (s/redraw screen))
+```
+
+And now I need to `use` the `draw-game` function back in `core.clj`:
+
+```clojure
+(ns caves.core
+  (:use [caves.world :only [random-world smooth-world]]
+        [caves.ui.drawing :only [draw-game]])
+  (:require [lanterna.screen :as s]))
+```
+
+The fact that I moved eleven top-level symbols into a new namespace and only had
+to bring one of them back into the original is a pretty clear sign that this
+chunk of code was ready to be moved into its own file.
+
+I also did the same for the input processing code, moving it into
+`ui/input.clj`:
+
+```clojure
+(ns caves.ui.input
+  (:use [caves.world :only [random-world smooth-world]])
+  (:require [lanterna.screen :as s]))
+
+
+(defmulti process-input
+  (fn [game input]
+    (:kind (last (:uis game)))))
+
+(defmethod process-input :start [game input]
+  (-> game
+    (assoc :world (random-world))
+    (assoc :uis [(->UI :play)])))
+
+
+(defn move [[x y] [dx dy]]
+  [(+ x dx) (+ y dy)])
+
+(defmethod process-input :play [game input]
+  (case input
+    :enter     (assoc game :uis [(->UI :win)])
+    :backspace (assoc game :uis [(->UI :lose)])
+    \q         (assoc game :uis [])
+
+    \s (update-in game [:world] smooth-world)
+
+    \h (update-in game [:location] move [-1 0])
+    \j (update-in game [:location] move [0 1])
+    \k (update-in game [:location] move [0 -1])
+    \l (update-in game [:location] move [1 0])
+
+    \H (update-in game [:location] move [-5 0])
+    \J (update-in game [:location] move [0 5])
+    \K (update-in game [:location] move [0 -5])
+    \L (update-in game [:location] move [5 0])
+
+    game))
+
+(defmethod process-input :win [game input]
+  (if (= input :escape)
+    (assoc game :uis [])
+    (assoc game :uis [(->UI :start)])))
+
+(defmethod process-input :lose [game input]
+  (if (= input :escape)
+    (assoc game :uis [])
+    (assoc game :uis [(->UI :start)])))
+
+
+(defn get-input [game screen]
+  (assoc game :input (s/get-key-blocking screen)))
+```
+
+This isn't quite functional yet, because it needs the `->UI` factory function,
+which is created by the `(defrecord UI [...])` that's still in `core.clj`.
+I can't just `use` that in this file, because `core` is going to need to `use`
+some functions from this, so I'd have circular imports.
+
+The solution is to move the `(defrecord UI [...])` into a separate file.
+I chose to put it in `ui/core.clj`:
+
+```clojure
+(ns caves.ui.core)
+
+(defrecord UI [kind])
+```
+
+And now I can pull its creation function back into the `input` namespace:
+
+```clojure
+(ns caves.ui.input
+  (:use [caves.world :only [random-world smooth-world]]
+        [caves.ui.core :only [->UI]])
+  (:require [lanterna.screen :as s]))
+```
+
+Finally I can update the `ns` back in the original `core.clj` to pull in the
+functions I need, and remove the ones I don't:
+
+```clojure
+(ns caves.core
+  (:use [caves.ui.core :only [->UI]]
+        [caves.ui.drawing :only [draw-game]]
+        [caves.ui.input :only [get-input process-input]])
+  (:require [lanterna.screen :as s]))
+```
+
+Whew!
+
+Results
+-------
+
+That was a lot of shuffling around, but now I've got five separate files, each
+pertaining to one specific thing, instead of one big pile of code.
+
+You can view the code [on GitHub][result-code] if you want to see the end
+result.
+
+[result-code]: https://github.com/sjl/caves/tree/entry-03-4/src/caves
+
+Next post I swear I'll add the player so we'll have an actual game!
+
--- a/content/blog/2012/07/caves-of-clojure-04.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,623 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 4"
-        snip: "A player!"
-        created: 2012-07-12 09:42:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry corresponds to [post four in Trystan's tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `entry-04` tag to see the code as it stands
-after this post.
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-04-player.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-In Trystan's fourth post he adds three main things:
-
-* A player
-* Player movement
-* Digging
-
-I'm going to add all three of those, but I'm going to do things very differently
-than he did.
-
-My goal is to play around with some Clojurey concepts and see how far I can
-stretch them.  I have a feeling that it's going to let me do some very cool
-things in the future.
-
-Refactoring
------------
-
-Before I started I wanted to clean up the `world` namespace a bit.  I'm not
-going to go in depth -- I'll just post the code and you can read over it or skip
-it if you trust me.
-
-First I created `coords.clj`:
-
-    :::clojure
-    (ns caves.coords)
-
-
-    (defn offset-coords
-      "Offset the starting coordinate by the given amount, returning the result coordinate."
-      [[x y] [dx dy]]
-      [(+ x dx) (+ y dy)])
-
-    (defn dir-to-offset
-      "Convert a direction to the offset for moving 1 in that direction."
-      [dir]
-      (case dir
-        :w  [-1 0]
-        :e  [1 0]
-        :n  [0 -1]
-        :s  [0 1]
-        :nw [-1 -1]
-        :ne [1 -1]
-        :sw [-1 1]
-        :se [1 1]))
-
-    (defn destination-coords
-      "Take an origin's coords and a direction and return the destination's coords."
-      [origin dir]
-      (offset-coords origin (dir-to-offset dir)))
-
-Then I cleaned up `world.clj`:
-
-    :::clojure
-    (ns caves.world)
-
-
-    ; Constants -------------------------------------------------------------------
-    (def world-size [160 50])
-
-    ; Data structures -------------------------------------------------------------
-    (defrecord World [tiles])
-    (defrecord Tile [kind glyph color])
-
-    (def tiles
-      {:floor (->Tile :floor "." :white)
-       :wall  (->Tile :wall  "#" :white)
-       :bound (->Tile :bound "X" :black)})
-
-
-    ; Convenience functions -------------------------------------------------------
-    (defn get-tile-from-tiles [tiles [x y]]
-      (get-in tiles [y x] (:bound tiles)))
-
-    (defn random-coordinate []
-      (let [[cols rows] world-size]
-        [(rand-int cols) (rand-int rows)]))
-
-
-    ; World generation ------------------------------------------------------------
-    (defn random-tiles []
-      (let [[cols rows] world-size]
-        (letfn [(random-tile []
-                  (tiles (rand-nth [:floor :wall])))
-                (random-row []
-                  (vec (repeatedly cols random-tile)))]
-          (vec (repeatedly rows random-row)))))
-
-
-    (defn get-smoothed-tile [block]
-      (let [tile-counts (frequencies (map :kind block))
-            floor-threshold 5
-            floor-count (get tile-counts :floor 0)
-            result (if (>= floor-count floor-threshold)
-                     :floor
-                     :wall)]
-        (tiles result)))
-
-    (defn block-coords [x y]
-      (for [dx [-1 0 1]
-            dy [-1 0 1]]
-        [(+ x dx) (+ y dy)]))
-
-    (defn get-block [tiles x y]
-      (map (partial get-tile-from-tiles tiles)
-           (block-coords x y)))
-
-    (defn get-smoothed-row [tiles y]
-      (mapv (fn [x]
-              (get-smoothed-tile (get-block tiles x y)))
-            (range (count (first tiles)))))
-
-    (defn get-smoothed-tiles [tiles]
-      (mapv (fn [y]
-              (get-smoothed-row tiles y))
-            (range (count tiles))))
-
-    (defn smooth-world [{:keys [tiles] :as world}]
-      (assoc world :tiles (get-smoothed-tiles tiles)))
-
-
-    (defn random-world []
-      (let [world (->World (random-tiles))
-            world (nth (iterate smooth-world world) 3)]
-        world))
-
-The changes were mostly centered around removing debugging functions and making
-all the world functions take an `[x y]` coordinate vector in place of two
-separate `x` and `y` arguments.
-
-Read through the code if you're curious, it's only about 100 total lines.
-
-Entities
---------
-
-Now it's time to add a player.  Rather than take the approach Trystan used of
-creating a `Creature` class and `Player` subclass, I went with something a bit
-different.
-
-In Minecraft's network protocol, when you get a list of "things in the world"
-it's not just creatures -- the list includes both creatures and items.  It uses
-the word "entity" to refer to them.  I'm sure it's not the first game to do
-that, but it's the first time I've run across it because I'm not hugely into
-game programming.
-
-That got me thinking: are items and creatures really so different that I need to
-represent them as two completely separate ideas?
-
-Both have a location in the world.  Both have a "glyph" that I'll be using to
-display them to the player.  Both will have some kind of "id" so I can use them
-in mappings efficiently.
-
-On the other hand, there are definitely some differences.  Creatures move
-around, eat things, attack things, can be attacked (and killed), have an AI to
-decide what to do, and so on.
-
-Items can be picked up and dropped, can contain other items, can be eaten or
-quaffed, can rot over time (e.g.: corpses), can be used as weapons or armor, et
-cetera.
-
-But wait a second: are things really so clear?  The bag of tricks in Nethack can
-attack the player.  Cockatrice corpses can be wielded and used as
-petrification-inducing clubs.  In Dwarf Fortress discarded pieces from
-slaughtered animals can come alive if a necromancer sieges your fortress.
-
-I can think of a lot of cool things I could do when I eliminate the distinction
-between items and creatures.
-
-Maybe there's a "pixie" creature that wanders around and does normal creaturey
-things, but if you attack it while wielding a butterfly net you "catch" it and
-it gets picked up and put in your inventory like an item.
-
-Once you've got one you could "apply" it (maybe that means "setting it free") to
-heal yourself, or quaff it to restore mana (mmm, delicious pixie blood).
-
-Oh, and it still has an AI so maybe every 100 turns it has a chance of escaping
-from your inventory.  Unless you put it in a jar.
-
-I can think of tons of interesting things to do with a unified "entity" system.
-A bag that eat things, where you need to remember to "feed" it normal food or
-it'll start digesting the other items!  Giant venus fly traps that eat unwary
-pixies!  Potions that evaporate over time if you don't use them!
-
-The possibilities are really exciting.  But how can I actually *code* all this
-crazy stuff without special-casing *everything*?
-
-Protocols
----------
-
-After thinking about this problem for a while, I came up with a solution that
-I think has some real promise.
-
-Individual types of entity ("pixie", "player", "goblin", "steel helmet") will be
-defined with simple `(defrecord)`s.  Each should have an `:id`, `:glyph`, and
-`:location`, but beyond that the rest of their state is flexible.
-
-I'm going to create an `Entity` protocol that such records will implement.  That
-protocol will have a single `tick` function that they need to define.  This will
-be called once per game "tick" and will be how the various types of entity
-decide what to do over time.  They may define a `tick` that does nothing if they
-don't change over time.
-
-On its own an entity record can't do anything except exist, be displayed on
-the map, and update itself every tick.  To actually *do* something during
-a tick (or have things done to them) they'll implement what I'm calling
-"aspects".
-
-An "aspect" is a protocol that defines a group of related functions, probably
-all having to do with a simple gameplay mechanic.  Here are a few rough examples
-from the top of my head:
-
-    :::clojure
-    (defprotocol Edible
-      (can-be-eaten? [this eater world])
-      (nutrition-value [this world])
-      (eat [this eater world]))
-
-    (defprotocol Eater
-      (can-eat? [this food world])
-      (eat [this food world]))
-
-    (defprotocol Item
-      (can-be-contained-in? [this container world])
-      (insert-into [this container world])
-      (remove-from [this container world]))
-
-    (defprotocol Container
-      (get-contained [this world])
-      (can-contain? [this item world])
-      (insert [this item world])
-      (remove [this item world]))
-
-As you can see, many aspects will be paired up.  Some entities can have things
-done to them by other entities, which will actually do those things.  Both will
-have the opportunity to override the default method implementations to customize
-the behavior.
-
-Anyway, I think this way of adding in functionality (basically mixin-style, but
-decoupled from the entity class declaration and without namespace clashes)
-could be very cool.  I'm going to give it a shot and see how it works.
-
-The Player
-----------
-
-Let's start with the first and most important entity: the player.  This game
-isn't going to be much fun without one of those.
-
-First I added a new file: `entities/core.clj`.  It'll contain the basic `Entity`
-definition:
-
-    :::clojure
-    (ns caves.entities.core)
-
-
-    (defprotocol Entity
-      (tick [this world]
-            "Update the world to handle the passing of a tick for this entity."))
-
-Simple enough.  `tick`ing an entity will return a new immutable world that
-accounts for whatever the entity decides to do during that tick.
-
-Now to add a player!
-
-    :::clojure
-    (ns caves.entities.player
-      (:use [caves.entities.core :only [Entity]]))
-
-
-    (defrecord Player [id glyph location])
-
-    (extend-type Player Entity
-      (tick [this world]
-        world))
-
-Right now the player doesn't do anything during a tick -- the world will remain
-unchanged.
-
-We'll need to actually place the player somewhere in the world to start, so I'll
-make a helper function like Trystan's to find an empty spot for them in
-`world.clj`:
-
-    :::clojure
-    (defn find-empty-tile [world]
-      (loop [coord (random-coordinate)]
-        (if (#{:floor} (get-tile-kind world coord))
-          coord
-          (recur (random-coordinate)))))
-
-Basically I just try a bunch of random coordinates until I find one that's
-a `:floor` tile.  Maybe not the most efficient way to do things, but it's fine
-for now.
-
-Back in `player.clj` I'll need a way to make a new player when we start a new
-game:
-
-    :::clojure
-    (defn make-player [world]
-      (->Player :player "@" (find-empty-tile world)))
-
-For now I'll use the special ID `:player` for the entity ID.  Since this is
-going to be a single player game, with no chance of ever being multiplayer, it's
-okay to special case things for the player a bit.
-
-Now to actually add the new player into the main `game` object.  Remember that
-the `:start` screen is the one that makes fresh games, so I updated that:
-
-    :::clojure
-    (defn reset-game [game]
-      (let [fresh-world (random-world)]
-        (-> game
-          (assoc :world fresh-world)
-          (assoc-in [:world :player] (make-player fresh-world))
-          (assoc :uis [(->UI :play)]))))
-
-    (defmethod process-input :start [game input]
-      (reset-game game))
-
-I pulled out the guts of the `process-input` function into a helper, which:
-
-* Creates a fresh, random world.
-* Replaces the game's world with the new one.
-* Creates a fresh player at some empty location in that world.
-* Attaches the player to the world.
-* Replaces the UI stack of the game with the main `:play` UI.
-
-I could have made a completely new `game` object instead of just overwriting
-some fields here, but this way if I decide to store configuration options on the
-`game` later they won't be lost when restarting.
-
-Displaying the Player
----------------------
-
-Now that I've got a player it's time to display them on the map as the
-traditional `@`.  I opened up `input.clj` and replaced the crosshair-drawing
-code from the last two posts with code to draw the player:
-
-    :::clojure
-    (defn draw-player [screen start-x start-y player]
-      (let [[player-x player-y] (:location player)
-            x (- player-x start-x)
-            y (- player-y start-y)]
-          (s/put-string screen x y (:glyph player) {:fg :white})
-          (s/move-cursor screen x y)))
-
-If the screen's `start-x` (i.e.: its left edge) is at 10, and the player is at
-24, then I need to draw the `@` at screen coordinate 14.  Same goes for the
-y coordinates.
-
-Now to tweak the main `draw-ui` function to account for this change:
-
-    :::clojure
-    (defmethod draw-ui :play [ui game screen]
-      (let [world (:world game)
-            {:keys [tiles player]} world
-            [cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            [start-x start-y end-x end-y] (get-viewport-coords game (:location player) vcols vrows)]
-        (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
-        (draw-player screen start-x start-y player)))
-
-Instead of a `center-x` and `center-y` that are based on an arbitrary value
-in the `game` object, I'm now basing things off of the player's coordinates.
-Otherwise not much has changed here.
-
-One more thing I decided to do is the start using that line at the bottom of the
-screen that I reserved for stats.  I added a simple function to draw it:
-
-    :::clojure
-    (defn draw-hud [screen game start-x start-y]
-      (let [hud-row (dec (second screen-size))
-            [x y] (get-in game [:world :player :location])
-            info (str "loc: [" x "-" y "]")
-            info (str info " start: [" start-x "-" start-y "]")]
-        (s/put-string screen 0 hud-row info)))
-
-And add a call for that to the `draw-ui` function.  I'm sure you can figure that
-out yourself.
-
-Now the last line of the screen will look like:
-
-    :::text
-    loc: [30-53] start: [10-34]
-
-I can now see the coordinates of the player and the top left corner of the
-screen at all times.  This was really handy when debugging display/movement
-problems later.
-
-Movement
---------
-
-Now that I'm basing the viewport on the player's location, I need a way for
-players to move around.  I could just tweak the current code, but lots of things
-are going to need to move so this sounds like a great place for my first
-"aspect".
-
-I created the `entities/aspects/mobile.clj` file and added the protocol
-representing the aspect:
-
-    :::clojure
-    (ns caves.entities.aspects.mobile)
-
-
-    (defprotocol Mobile
-      (move [this world dest]
-            "Move this entity to a new location.")
-      (can-move? [this world dest]
-                 "Return whether the entity can move to the new location."))
-
-Right now I'm just defining some simple functions.  Mobile entities must be able
-to check if they can move into a coordinate, as well as actually move themselves
-into it.
-
-Why allow entities to check for movement and move themselves instead of having
-a single movement handling chunk of code for all entities?
-
-Well this means we can customize how movement works on a per-entity basis.
-Maybe we'll have a minotaur that can move into other entities' spaces,
-displacing them.  Or a stone elemental that can walk through wall tiles.
-
-Next I made the Player entity implement Mobile back in `entities/player.clj`:
-
-    :::clojure
-    (ns caves.entities.player
-      (:use [caves.entities.core :only [Entity]]
-            [caves.entities.aspects.mobile :only [Mobile move can-move?]]
-            [caves.coords :only [destination-coords]]
-            [caves.world :only [find-empty-tile get-tile-kind]]))
-
-
-    (defrecord Player [id glyph location])
-
-    (defn check-tile
-      "Check that the tile at the destination passes the given predicate."
-      [world dest pred]
-      (pred (get-tile-kind world dest)))
-
-
-    (extend-type Player Entity
-      (tick [this world]
-        world))
-
-    (extend-type Player Mobile
-      (move [this world dest]
-        {:pre [(can-move? this world dest)]}
-        (assoc-in world [:player :location] dest))
-      (can-move? [this world dest]
-        (check-tile world dest #{:floor})))
-
-
-    (defn make-player [world]
-      (->Player :player "@" (find-empty-tile world)))
-
-    (defn move-player [world dir]
-      (let [player (:player world)
-            target (destination-coords (:location player) dir)]
-        (cond
-          (can-move? player world target) (move player world target)
-          :else world)))
-
-Notice how simple (and concise) this was to add.  I defined `can-move?` to
-simply make sure that the destination is a floor tile.
-
-`move` itself uses a Clojure function precondition to sanity-check that the
-entity isn't trying to cheat and move somewhere illegal.  If everything's okay,
-I simply update the player's location.
-
-`move-player` is an ugly helper function that most entities won't need.  Players
-are special because we're going to want to make certain keystrokes do multiple
-things, as we'll see shortly.  For now don't worry too much about that one.
-
-Before going on make sure you understand how movement is actually going to
-happen, from the point where `(move-player game :s)` is called and down.
-
-The last thing to do to actually make the player movable is handling the actual
-keystrokes from the user, so I did that next over in `ui/input.clj`:
-
-    :::clojure
-    (defmethod process-input :play [game input]
-      (case input
-        :enter     (assoc game :uis [(->UI :win)])
-        :backspace (assoc game :uis [(->UI :lose)])
-        \q         (assoc game :uis [])
-
-        \h (update-in game [:world] move-player :w)
-        \j (update-in game [:world] move-player :s)
-        \k (update-in game [:world] move-player :n)
-        \l (update-in game [:world] move-player :e)
-        \y (update-in game [:world] move-player :nw)
-        \u (update-in game [:world] move-player :ne)
-        \b (update-in game [:world] move-player :sw)
-        \n (update-in game [:world] move-player :se)
-
-        game))
-
-Each of the traditional roguelike movement keys will now move the player around
-the world.  Because the screen drawing is already updated to be based on the
-player's location, movement is pretty much complete!
-
-I added the `yubn` diagonal movement keys because as I was trying out movement
-myself it felt like I needed them.
-
-This is something that I've noticed while watching Notch's Ludum Dare recordings
-(Google for them if you want to see them).  He plays the game he's making for
-longer periods than you might think.  He doesn't just make a feature and make
-sure it works, he makes a feature and then plays the game normally for a few
-minutes to make sure it fits into the game right (and is fun)!
-
-Those `update-in` statements are a bit ugly, but not ugly enough for me to want
-to do something clever to remove them.  They can stay for now.
-
-Digging
--------
-
-As Trystan mentioned in his post, we're not doing anything special to make sure
-the caves we generate are connected.  The player may very well start in a tiny
-cave.
-
-To make this less of a problem, he added the ability for the player to dig
-through walls.
-
-Digging sounds like a great candidate for another aspect, so I added
-`entities/aspects/digger.clj`:
-
-    :::clojure
-    (ns caves.entities.aspects.digger)
-
-
-    (defprotocol Digger
-      (dig [this world target]
-           "Dig a location.")
-      (can-dig? [this world target]
-                "Return whether the entity can dig the new location."))
-
-Nothing fancy here.  Then I made the Player entity implement it:
-
-    :::clojure
-    (extend-type Player Digger
-      (dig [this world dest]
-        {:pre [(can-dig? this world dest)]}
-        (set-tile-floor world dest))
-      (can-dig? [this world dest]
-        (check-tile world dest #{:wall})))
-
-This looks very similar to the Mobile implementation, except instead of changing
-the player's location I change the map tile from a wall to a floor.
-
-Finally, I update the `move-player` function (which is called when we receive
-a keystroke):
-
-    :::clojure
-    (defn move-player [world dir]
-      (let [player (:player world)
-            target (destination-coords (:location player) dir)]
-        (cond
-          (can-move? player world target) (move player world target)
-          (can-dig? player world target) (dig player world target)
-          :else world)))
-
-Now if the space the user is telling the player to enter is open, the player
-will move there, otherwise if it's diggable the player will dig it, otherwise
-nothing will happen.
-
-This means that moving into a space that is currently a wall will take two
-keypresses: the first digs out the wall, the second moves into the newly open
-space.
-
-I like how this feels.  It takes longer to travel through rock, which makes
-sense.  If you prefer to dig and move all at once you could dig and move in the
-same action.  It's up to you.
-
-Results
--------
-
-Finally, after seven entries I've got a hero in the game!  It's taken a while,
-but I've laid the groundwork for what I think is some really cool stuff down the
-line.
-
-You can view the code [on GitHub][result-code] if you want to see the end
-result.  From now on I'm going to start moving a bit faster, not always showing
-the namespace declarations and such.  If you want the full code for each post
-look at the GitHub repository.
-
-[result-code]: https://github.com/sjl/caves/tree/entry-04/src/caves
-
-And the obligatory screenshots of our intrepid hero:
-
-![Screenshot](/media/images{{ parent_url }}/caves-04-01.png)
-
-![Screenshot](/media/images{{ parent_url }}/caves-04-02.png)
-
-![Screenshot](/media/images{{ parent_url }}/caves-04-03.png)
-
-Next time I'll be adding some monsters for the hero to slay.
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-04.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,638 @@
++++
+title = "The Caves of Clojure: Part 4"
+snip = "A player!"
+date = 2012-07-12T09:42:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry corresponds to [post four in Trystan's tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `entry-04` tag to see the code as it stands
+after this post.
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/08/roguelike-tutorial-04-player.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+In Trystan's fourth post he adds three main things:
+
+* A player
+* Player movement
+* Digging
+
+I'm going to add all three of those, but I'm going to do things very differently
+than he did.
+
+My goal is to play around with some Clojurey concepts and see how far I can
+stretch them.  I have a feeling that it's going to let me do some very cool
+things in the future.
+
+Refactoring
+-----------
+
+Before I started I wanted to clean up the `world` namespace a bit.  I'm not
+going to go in depth — I'll just post the code and you can read over it or skip
+it if you trust me.
+
+First I created `coords.clj`:
+
+```clojure
+(ns caves.coords)
+
+
+(defn offset-coords
+  "Offset the starting coordinate by the given amount, returning the result coordinate."
+  [[x y] [dx dy]]
+  [(+ x dx) (+ y dy)])
+
+(defn dir-to-offset
+  "Convert a direction to the offset for moving 1 in that direction."
+  [dir]
+  (case dir
+    :w  [-1 0]
+    :e  [1 0]
+    :n  [0 -1]
+    :s  [0 1]
+    :nw [-1 -1]
+    :ne [1 -1]
+    :sw [-1 1]
+    :se [1 1]))
+
+(defn destination-coords
+  "Take an origin's coords and a direction and return the destination's coords."
+  [origin dir]
+  (offset-coords origin (dir-to-offset dir)))
+```
+
+Then I cleaned up `world.clj`:
+
+```clojure
+(ns caves.world)
+
+
+; Constants -------------------------------------------------------------------
+(def world-size [160 50])
+
+; Data structures -------------------------------------------------------------
+(defrecord World [tiles])
+(defrecord Tile [kind glyph color])
+
+(def tiles
+  {:floor (->Tile :floor "." :white)
+   :wall  (->Tile :wall  "#" :white)
+   :bound (->Tile :bound "X" :black)})
+
+
+; Convenience functions -------------------------------------------------------
+(defn get-tile-from-tiles [tiles [x y]]
+  (get-in tiles [y x] (:bound tiles)))
+
+(defn random-coordinate []
+  (let [[cols rows] world-size]
+    [(rand-int cols) (rand-int rows)]))
+
+
+; World generation ------------------------------------------------------------
+(defn random-tiles []
+  (let [[cols rows] world-size]
+    (letfn [(random-tile []
+              (tiles (rand-nth [:floor :wall])))
+            (random-row []
+              (vec (repeatedly cols random-tile)))]
+      (vec (repeatedly rows random-row)))))
+
+
+(defn get-smoothed-tile [block]
+  (let [tile-counts (frequencies (map :kind block))
+        floor-threshold 5
+        floor-count (get tile-counts :floor 0)
+        result (if (>= floor-count floor-threshold)
+                 :floor
+                 :wall)]
+    (tiles result)))
+
+(defn block-coords [x y]
+  (for [dx [-1 0 1]
+        dy [-1 0 1]]
+    [(+ x dx) (+ y dy)]))
+
+(defn get-block [tiles x y]
+  (map (partial get-tile-from-tiles tiles)
+       (block-coords x y)))
+
+(defn get-smoothed-row [tiles y]
+  (mapv (fn [x]
+          (get-smoothed-tile (get-block tiles x y)))
+        (range (count (first tiles)))))
+
+(defn get-smoothed-tiles [tiles]
+  (mapv (fn [y]
+          (get-smoothed-row tiles y))
+        (range (count tiles))))
+
+(defn smooth-world [{:keys [tiles] :as world}]
+  (assoc world :tiles (get-smoothed-tiles tiles)))
+
+
+(defn random-world []
+  (let [world (->World (random-tiles))
+        world (nth (iterate smooth-world world) 3)]
+    world))
+```
+
+The changes were mostly centered around removing debugging functions and making
+all the world functions take an `[x y]` coordinate vector in place of two
+separate `x` and `y` arguments.
+
+Read through the code if you're curious, it's only about 100 total lines.
+
+Entities
+--------
+
+Now it's time to add a player.  Rather than take the approach Trystan used of
+creating a `Creature` class and `Player` subclass, I went with something a bit
+different.
+
+In Minecraft's network protocol, when you get a list of "things in the world"
+it's not just creatures — the list includes both creatures and items.  It uses
+the word "entity" to refer to them.  I'm sure it's not the first game to do
+that, but it's the first time I've run across it because I'm not hugely into
+game programming.
+
+That got me thinking: are items and creatures really so different that I need to
+represent them as two completely separate ideas?
+
+Both have a location in the world.  Both have a "glyph" that I'll be using to
+display them to the player.  Both will have some kind of "id" so I can use them
+in mappings efficiently.
+
+On the other hand, there are definitely some differences.  Creatures move
+around, eat things, attack things, can be attacked (and killed), have an AI to
+decide what to do, and so on.
+
+Items can be picked up and dropped, can contain other items, can be eaten or
+quaffed, can rot over time (e.g.: corpses), can be used as weapons or armor, et
+cetera.
+
+But wait a second: are things really so clear?  The bag of tricks in Nethack can
+attack the player.  Cockatrice corpses can be wielded and used as
+petrification-inducing clubs.  In Dwarf Fortress discarded pieces from
+slaughtered animals can come alive if a necromancer sieges your fortress.
+
+I can think of a lot of cool things I could do when I eliminate the distinction
+between items and creatures.
+
+Maybe there's a "pixie" creature that wanders around and does normal creaturey
+things, but if you attack it while wielding a butterfly net you "catch" it and
+it gets picked up and put in your inventory like an item.
+
+Once you've got one you could "apply" it (maybe that means "setting it free") to
+heal yourself, or quaff it to restore mana (mmm, delicious pixie blood).
+
+Oh, and it still has an AI so maybe every 100 turns it has a chance of escaping
+from your inventory.  Unless you put it in a jar.
+
+I can think of tons of interesting things to do with a unified "entity" system.
+A bag that eat things, where you need to remember to "feed" it normal food or
+it'll start digesting the other items!  Giant venus fly traps that eat unwary
+pixies!  Potions that evaporate over time if you don't use them!
+
+The possibilities are really exciting.  But how can I actually *code* all this
+crazy stuff without special-casing *everything*?
+
+Protocols
+---------
+
+After thinking about this problem for a while, I came up with a solution that
+I think has some real promise.
+
+Individual types of entity ("pixie", "player", "goblin", "steel helmet") will be
+defined with simple `(defrecord)`s.  Each should have an `:id`, `:glyph`, and
+`:location`, but beyond that the rest of their state is flexible.
+
+I'm going to create an `Entity` protocol that such records will implement.  That
+protocol will have a single `tick` function that they need to define.  This will
+be called once per game "tick" and will be how the various types of entity
+decide what to do over time.  They may define a `tick` that does nothing if they
+don't change over time.
+
+On its own an entity record can't do anything except exist, be displayed on
+the map, and update itself every tick.  To actually *do* something during
+a tick (or have things done to them) they'll implement what I'm calling
+"aspects".
+
+An "aspect" is a protocol that defines a group of related functions, probably
+all having to do with a simple gameplay mechanic.  Here are a few rough examples
+from the top of my head:
+
+```clojure
+(defprotocol Edible
+  (can-be-eaten? [this eater world])
+  (nutrition-value [this world])
+  (eat [this eater world]))
+
+(defprotocol Eater
+  (can-eat? [this food world])
+  (eat [this food world]))
+
+(defprotocol Item
+  (can-be-contained-in? [this container world])
+  (insert-into [this container world])
+  (remove-from [this container world]))
+
+(defprotocol Container
+  (get-contained [this world])
+  (can-contain? [this item world])
+  (insert [this item world])
+  (remove [this item world]))
+```
+
+As you can see, many aspects will be paired up.  Some entities can have things
+done to them by other entities, which will actually do those things.  Both will
+have the opportunity to override the default method implementations to customize
+the behavior.
+
+Anyway, I think this way of adding in functionality (basically mixin-style, but
+decoupled from the entity class declaration and without namespace clashes)
+could be very cool.  I'm going to give it a shot and see how it works.
+
+The Player
+----------
+
+Let's start with the first and most important entity: the player.  This game
+isn't going to be much fun without one of those.
+
+First I added a new file: `entities/core.clj`.  It'll contain the basic `Entity`
+definition:
+
+```clojure
+(ns caves.entities.core)
+
+
+(defprotocol Entity
+  (tick [this world]
+        "Update the world to handle the passing of a tick for this entity."))
+```
+
+Simple enough.  `tick`ing an entity will return a new immutable world that
+accounts for whatever the entity decides to do during that tick.
+
+Now to add a player!
+
+```clojure
+(ns caves.entities.player
+  (:use [caves.entities.core :only [Entity]]))
+
+
+(defrecord Player [id glyph location])
+
+(extend-type Player Entity
+  (tick [this world]
+    world))
+```
+
+Right now the player doesn't do anything during a tick — the world will remain
+unchanged.
+
+We'll need to actually place the player somewhere in the world to start, so I'll
+make a helper function like Trystan's to find an empty spot for them in
+`world.clj`:
+
+```clojure
+(defn find-empty-tile [world]
+  (loop [coord (random-coordinate)]
+    (if (#{:floor} (get-tile-kind world coord))
+      coord
+      (recur (random-coordinate)))))
+```
+
+Basically I just try a bunch of random coordinates until I find one that's
+a `:floor` tile.  Maybe not the most efficient way to do things, but it's fine
+for now.
+
+Back in `player.clj` I'll need a way to make a new player when we start a new
+game:
+
+```clojure
+(defn make-player [world]
+  (->Player :player "@" (find-empty-tile world)))
+```
+
+For now I'll use the special ID `:player` for the entity ID.  Since this is
+going to be a single player game, with no chance of ever being multiplayer, it's
+okay to special case things for the player a bit.
+
+Now to actually add the new player into the main `game` object.  Remember that
+the `:start` screen is the one that makes fresh games, so I updated that:
+
+```clojure
+(defn reset-game [game]
+  (let [fresh-world (random-world)]
+    (-> game
+      (assoc :world fresh-world)
+      (assoc-in [:world :player] (make-player fresh-world))
+      (assoc :uis [(->UI :play)]))))
+
+(defmethod process-input :start [game input]
+  (reset-game game))
+```
+
+I pulled out the guts of the `process-input` function into a helper, which:
+
+* Creates a fresh, random world.
+* Replaces the game's world with the new one.
+* Creates a fresh player at some empty location in that world.
+* Attaches the player to the world.
+* Replaces the UI stack of the game with the main `:play` UI.
+
+I could have made a completely new `game` object instead of just overwriting
+some fields here, but this way if I decide to store configuration options on the
+`game` later they won't be lost when restarting.
+
+Displaying the Player
+---------------------
+
+Now that I've got a player it's time to display them on the map as the
+traditional `@`.  I opened up `input.clj` and replaced the crosshair-drawing
+code from the last two posts with code to draw the player:
+
+```clojure
+(defn draw-player [screen start-x start-y player]
+  (let [[player-x player-y] (:location player)
+        x (- player-x start-x)
+        y (- player-y start-y)]
+      (s/put-string screen x y (:glyph player) {:fg :white})
+      (s/move-cursor screen x y)))
+```
+
+If the screen's `start-x` (i.e.: its left edge) is at 10, and the player is at
+24, then I need to draw the `@` at screen coordinate 14.  Same goes for the
+y coordinates.
+
+Now to tweak the main `draw-ui` function to account for this change:
+
+```clojure
+(defmethod draw-ui :play [ui game screen]
+  (let [world (:world game)
+        {:keys [tiles player]} world
+        [cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        [start-x start-y end-x end-y] (get-viewport-coords game (:location player) vcols vrows)]
+    (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
+    (draw-player screen start-x start-y player)))
+```
+
+Instead of a `center-x` and `center-y` that are based on an arbitrary value
+in the `game` object, I'm now basing things off of the player's coordinates.
+Otherwise not much has changed here.
+
+One more thing I decided to do is the start using that line at the bottom of the
+screen that I reserved for stats.  I added a simple function to draw it:
+
+```clojure
+(defn draw-hud [screen game start-x start-y]
+  (let [hud-row (dec (second screen-size))
+        [x y] (get-in game [:world :player :location])
+        info (str "loc: [" x "-" y "]")
+        info (str info " start: [" start-x "-" start-y "]")]
+    (s/put-string screen 0 hud-row info)))
+```
+
+And add a call for that to the `draw-ui` function.  I'm sure you can figure that
+out yourself.
+
+Now the last line of the screen will look like:
+
+```text
+loc: [30-53] start: [10-34]
+```
+
+I can now see the coordinates of the player and the top left corner of the
+screen at all times.  This was really handy when debugging display/movement
+problems later.
+
+Movement
+--------
+
+Now that I'm basing the viewport on the player's location, I need a way for
+players to move around.  I could just tweak the current code, but lots of things
+are going to need to move so this sounds like a great place for my first
+"aspect".
+
+I created the `entities/aspects/mobile.clj` file and added the protocol
+representing the aspect:
+
+```clojure
+(ns caves.entities.aspects.mobile)
+
+
+(defprotocol Mobile
+  (move [this world dest]
+        "Move this entity to a new location.")
+  (can-move? [this world dest]
+             "Return whether the entity can move to the new location."))
+```
+
+Right now I'm just defining some simple functions.  Mobile entities must be able
+to check if they can move into a coordinate, as well as actually move themselves
+into it.
+
+Why allow entities to check for movement and move themselves instead of having
+a single movement handling chunk of code for all entities?
+
+Well this means we can customize how movement works on a per-entity basis.
+Maybe we'll have a minotaur that can move into other entities' spaces,
+displacing them.  Or a stone elemental that can walk through wall tiles.
+
+Next I made the Player entity implement Mobile back in `entities/player.clj`:
+
+```clojure
+(ns caves.entities.player
+  (:use [caves.entities.core :only [Entity]]
+        [caves.entities.aspects.mobile :only [Mobile move can-move?]]
+        [caves.coords :only [destination-coords]]
+        [caves.world :only [find-empty-tile get-tile-kind]]))
+
+
+(defrecord Player [id glyph location])
+
+(defn check-tile
+  "Check that the tile at the destination passes the given predicate."
+  [world dest pred]
+  (pred (get-tile-kind world dest)))
+
+
+(extend-type Player Entity
+  (tick [this world]
+    world))
+
+(extend-type Player Mobile
+  (move [this world dest]
+    {:pre [(can-move? this world dest)]}
+    (assoc-in world [:player :location] dest))
+  (can-move? [this world dest]
+    (check-tile world dest #{:floor})))
+
+
+(defn make-player [world]
+  (->Player :player "@" (find-empty-tile world)))
+
+(defn move-player [world dir]
+  (let [player (:player world)
+        target (destination-coords (:location player) dir)]
+    (cond
+      (can-move? player world target) (move player world target)
+      :else world)))
+```
+
+Notice how simple (and concise) this was to add.  I defined `can-move?` to
+simply make sure that the destination is a floor tile.
+
+`move` itself uses a Clojure function precondition to sanity-check that the
+entity isn't trying to cheat and move somewhere illegal.  If everything's okay,
+I simply update the player's location.
+
+`move-player` is an ugly helper function that most entities won't need.  Players
+are special because we're going to want to make certain keystrokes do multiple
+things, as we'll see shortly.  For now don't worry too much about that one.
+
+Before going on make sure you understand how movement is actually going to
+happen, from the point where `(move-player game :s)` is called and down.
+
+The last thing to do to actually make the player movable is handling the actual
+keystrokes from the user, so I did that next over in `ui/input.clj`:
+
+```clojure
+(defmethod process-input :play [game input]
+  (case input
+    :enter     (assoc game :uis [(->UI :win)])
+    :backspace (assoc game :uis [(->UI :lose)])
+    \q         (assoc game :uis [])
+
+    \h (update-in game [:world] move-player :w)
+    \j (update-in game [:world] move-player :s)
+    \k (update-in game [:world] move-player :n)
+    \l (update-in game [:world] move-player :e)
+    \y (update-in game [:world] move-player :nw)
+    \u (update-in game [:world] move-player :ne)
+    \b (update-in game [:world] move-player :sw)
+    \n (update-in game [:world] move-player :se)
+
+    game))
+```
+
+Each of the traditional roguelike movement keys will now move the player around
+the world.  Because the screen drawing is already updated to be based on the
+player's location, movement is pretty much complete!
+
+I added the `yubn` diagonal movement keys because as I was trying out movement
+myself it felt like I needed them.
+
+This is something that I've noticed while watching Notch's Ludum Dare recordings
+(Google for them if you want to see them).  He plays the game he's making for
+longer periods than you might think.  He doesn't just make a feature and make
+sure it works, he makes a feature and then plays the game normally for a few
+minutes to make sure it fits into the game right (and is fun)!
+
+Those `update-in` statements are a bit ugly, but not ugly enough for me to want
+to do something clever to remove them.  They can stay for now.
+
+Digging
+-------
+
+As Trystan mentioned in his post, we're not doing anything special to make sure
+the caves we generate are connected.  The player may very well start in a tiny
+cave.
+
+To make this less of a problem, he added the ability for the player to dig
+through walls.
+
+Digging sounds like a great candidate for another aspect, so I added
+`entities/aspects/digger.clj`:
+
+```clojure
+(ns caves.entities.aspects.digger)
+
+
+(defprotocol Digger
+  (dig [this world target]
+       "Dig a location.")
+  (can-dig? [this world target]
+            "Return whether the entity can dig the new location."))
+```
+
+Nothing fancy here.  Then I made the Player entity implement it:
+
+```clojure
+(extend-type Player Digger
+  (dig [this world dest]
+    {:pre [(can-dig? this world dest)]}
+    (set-tile-floor world dest))
+  (can-dig? [this world dest]
+    (check-tile world dest #{:wall})))
+```
+
+This looks very similar to the Mobile implementation, except instead of changing
+the player's location I change the map tile from a wall to a floor.
+
+Finally, I update the `move-player` function (which is called when we receive
+a keystroke):
+
+```clojure
+(defn move-player [world dir]
+  (let [player (:player world)
+        target (destination-coords (:location player) dir)]
+    (cond
+      (can-move? player world target) (move player world target)
+      (can-dig? player world target) (dig player world target)
+      :else world)))
+```
+
+Now if the space the user is telling the player to enter is open, the player
+will move there, otherwise if it's diggable the player will dig it, otherwise
+nothing will happen.
+
+This means that moving into a space that is currently a wall will take two
+keypresses: the first digs out the wall, the second moves into the newly open
+space.
+
+I like how this feels.  It takes longer to travel through rock, which makes
+sense.  If you prefer to dig and move all at once you could dig and move in the
+same action.  It's up to you.
+
+Results
+-------
+
+Finally, after seven entries I've got a hero in the game!  It's taken a while,
+but I've laid the groundwork for what I think is some really cool stuff down the
+line.
+
+You can view the code [on GitHub][result-code] if you want to see the end
+result.  From now on I'm going to start moving a bit faster, not always showing
+the namespace declarations and such.  If you want the full code for each post
+look at the GitHub repository.
+
+[result-code]: https://github.com/sjl/caves/tree/entry-04/src/caves
+
+And the obligatory screenshots of our intrepid hero:
+
+![Screenshot](/media/images/blog/2012/07/caves-04-01.png)
+
+![Screenshot](/media/images/blog/2012/07/caves-04-02.png)
+
+![Screenshot](/media/images/blog/2012/07/caves-04-03.png)
+
+Next time I'll be adding some monsters for the hero to slay.
+
--- a/content/blog/2012/07/caves-of-clojure-05.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,480 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 5"
-        snip: "Fungus and more."
-        created: 2012-07-13 10:55:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry corresponds to [post five in Trystan's tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `entry-05` tag to see the code as it stands
-after this post.
-
-Also, I live streamed myself writing the code that this entry is based on.  You
-can view the recordings [on twitch.tv](http://www.twitch.tv/stevelosh/), though
-as I write this the video links are stuck in an infinite HTTP redirect loop.
-Perhaps they will be fixed eventually.
-
-Finally, I've started hanging out in `##cavesofclojure` on Freenode if you have
-questions.  I may or may not be around at any given point.
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/09/roguelike-tutorial-05-stationary.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-In Trystan's fifth post he adds three things:
-
-* A stationary monster
-* Attacking
-* A growing mechanic for the monster
-
-I'm going to add all three of those too, though I'll be doing it in the
-entities/aspects fashion of the previous post.
-
-Multiple Entities
------------------
-
-First thing's first: I need to change a bit of code around to account for having
-multiple entities instead of just a single player.
-
-At the end of the previous post the player was stored in the world directly,
-meaning the `game` object looked like this:
-
-    :::clojure
-    {:uis [...]
-     :world {:player {...}
-             :tiles [...]}}
-
-I decided to remove some (but not all) of the special casing for the player and
-make them an entity like any other.  The `game` object is now structured like
-this:
-
-    :::clojure
-    {:uis [...]
-     :world {:entities {:player {...}}
-             :tiles [...]}}
-
-Notice that the player has been moved into an `:entities` map, keyed by its id
-(which is still the special-cased `:player`).  I updated anywhere that needed to
-change to account for this, and made sure it still worked.  This was pretty easy
-to do by just searching for `:player`, as the codebase is still small.
-
-Lichens
--------
-
-Now it's time to actually add another type of entity.  I play a lot of Nethack,
-so naturally I decided to make it a simple lichen.  I added
-`entities/lichen.clj`:
-
-    :::clojure
-    (ns caves.entities.lichen
-      (:use [caves.entities.core :only [Entity get-id]]))
-
-
-    (defrecord Lichen [id glyph location])
-
-    (defn make-lichen [location]
-      (->Lichen (get-id) "F" location))
-
-
-    (extend-type Lichen Entity
-      (tick [this world]
-        (if (should-grow)
-          world)))
-
-Like the `Player`, `Lichen`s implement the `Entity` protocol.  For now they
-don't do anything special during a tick.
-
-You may have noticed the new `get-id` function.  Entities must have IDs so I can
-get them in and out of the entity map.  The player has a special ID of
-`:player`, but I needed a way to get a unique ID for other entities.
-
-The simplest way I could think of was to use a simple counter over in
-`entities/core.clj`:
-
-    :::clojure
-    (ns caves.entities.core)
-
-
-    (def ids (ref 0))
-
-    (defprotocol Entity
-      (tick [this world]
-            "Update the world to handle the passing of a tick for this entity."))
-
-
-    (defn get-id []
-      (dosync
-        (let [id @ids]
-          (alter ids inc)
-          id)))
-
-Not the prettiest solution, but it works.  I might switch to a UUID library or
-something in the future, but this'll do for now.
-
-Populating the World
---------------------
-
-Unlike the `make-player` function, `make-lichen` takes a location directly
-instead of trying to find an empty space for itself in the world.  I figured it
-was better to not have entities deciding where they emerge in the world all the
-time!  I went ahead and refactored `make-player` to act like this as well.
-
-During this coding session I wasn't actually running and playing the full game
-through as much as I should have been.  I think as I get more and more of the
-basic structure of the game in place I'll be able to do this more.  Up to now
-I've been doing large, sweeping refactorings that touch many different pieces of
-code and break everything until they're finished.
-
-Anyway, back to the world.  I need a way to spawn some lichens in the world, so
-I edited the `reset-game` function in `input.clj`:
-
-    :::clojure
-    (defn add-lichen [world]
-      (let [{:as lichen :keys [id]} (make-lichen (find-empty-tile world))]
-        (assoc-in world [:entities id] lichen)))
-
-    (defn populate-world [world]
-      (let [world (assoc-in world [:entities :player]
-                            (make-player (find-empty-tile world)))
-            world (nth (iterate add-lichen world) 30)]
-        world))
-
-    (defn reset-game [game]
-      (let [fresh-world (random-world)]
-        (-> game
-          (assoc :world fresh-world)
-          (update-in [:world] populate-world)
-          (assoc :uis [(->UI :play)]))))
-
-It should be pretty easy to read.  `add-lichen` adds a new lichen to an empty
-tile.  `populate-world` takes a world and adds a player, then 30 lichens.
-
-This is getting to be a bit much to keep in `input.clj`.  I'll probably pull
-this out into a separate file soon.
-
-Drawing the Entities
---------------------
-
-So now the lichens are part of the world, but I still need to draw them on the
-screen.  I split the `draw-player` function in `drawing.clj` into two separate
-functions:
-
-    :::clojure
-    (defn draw-entity [screen start-x start-y {:keys [location glyph color]}]
-      (let [[entity-x entity-y] location
-            x (- entity-x start-x)
-            y (- entity-y start-y)]
-          (s/put-string screen x y glyph {:fg color})))
-
-    (defn highlight-player [screen start-x start-y player]
-      (let [[player-x player-y] (:location player)
-            x (- player-x start-x)
-            y (- player-y start-y)]
-        (s/move-cursor screen x y)))
-
-And then I use those in the main `draw-ui` function for the `:play` UI:
-
-    :::clojure
-    (defmethod draw-ui :play [ui game screen]
-      (let [world (:world game)
-            {:keys [tiles entities]} world
-            player (:player entities)
-            [cols rows] screen-size
-            vcols cols
-            vrows (dec rows)
-            [start-x start-y end-x end-y] (get-viewport-coords game (:location player) vcols vrows)]
-        (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
-        (doseq [entity (vals entities)]
-          (draw-entity screen start-x start-y entity))
-        (draw-hud screen game start-x start-y)
-        (highlight-player screen start-x start-y player)))
-
-Long but straightforward.  I'm going to be cleaning this part of the code up
-very soon, as I've just added a bunch of really useful stuff to the
-[clojure-lanterna][] library that will let me delete a bunch of fiddly code
-here.
-
-[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
-
-If you're particularly eagle-eyed you might have noticed this new `color`
-attribute that seems to be a part of entities.  I didn't realize I had forgotten
-to specify colors until I actually wrote this bit of code.  Once I did I went
-back and added the field to the `Player` and `Lichen` records, as well as
-`make-player` and `make-lichen`.
-
-Now the lichens appear on the screen!
-
-![Screenshot](/media/images{{ parent_url }}/caves-05-01.png)
-
-Movement
---------
-
-At this point the lichens are on the screen but the player can walk straight
-through them.  I took care of that by first creating a few helper functions in
-`world.clj`:
-
-    :::clojure
-    (defn get-entity-at [world coord]
-      (first (filter #(= coord (:location %))
-                     (vals (:entities world)))))
-
-    (defn is-empty? [world coord]
-      (and (#{:floor} (get-tile-kind world coord))
-           (not (get-entity-at world coord))))
-
-They'll handle the grunt world of traversing the `world` data structure.  Then
-I updated the player's `can-move?` function:
-
-    :::clojure
-    (extend-type Player Mobile
-      (move ...)
-      (can-move? [this world dest]
-        (is-empty? world dest)))
-
-Previously `can-move` checked the world's tile itself -- now it delegates to
-a basic helper function instead.  I have a feeling a lot of things are going to
-need to use the idea of "empty tiles" so this function will probably get a lot
-of mileage.
-
-Now the player can't walk through fungus.  Great.
-
-Killing
--------
-
-It's time to give the player a way to cut the lichens into little licheny bits.
-I implemented this with another pair of aspects: `Attacker` and `Destructible`.
-
-`Attacker` should be implemented by anything that can attack other things:
-
-    :::clojure
-    (ns caves.entities.aspects.attacker)
-
-    (defprotocol Attacker
-      (attack [this world target]
-              "Attack the target."))
-
-`Destructible` should be implemented by anything that can "take damage and go
-away once it takes enough":
-
-    :::clojure
-    (ns caves.entities.aspects.destructible)
-
-    (defprotocol Destructible
-      (take-damage [this world damage]
-                   "Take the given amount of damage and update the world appropriately."))
-
-Lichens will be `Destructible` (for now the player will remain invincible):
-
-    :::clojure
-    (extend-type Lichen Destructible
-      (take-damage [{:keys [id] :as this} world damage]
-        (let [damaged-this (update-in this [:hp] - damage)]
-          (if-not (pos? (:hp damaged-this))
-            (update-in world [:entities] dissoc id)
-            (update-in world [:entities id] assoc damaged-this)))))
-
-The logic here is pretty basic.  When a `Destructible` entity takes some damage,
-first its hit points are updated.  If they wind up to be zero or fewer, the
-entity gracefully removes itself from the world.
-
-I have a feeling there's a more elegant way to write the updatey bits of that
-function.  If you've got suggestions please let me know.
-
-If I'm going to be basing damage on the entity's `:hp` attribute they'd better
-have one!  I added a simple `:hp` of `1` to lichens:
-
-    :::clojure
-    (defrecord Lichen [id glyph color location hp])
-
-    (defn make-lichen [location]
-      (->Lichen (get-id) "F" :green location 1))
-
-Next I added the corresponding implementation of `Attacker` to the `Player` (for
-now lichens can't strike back):
-
-    :::clojure
-    (extend-type Player Attacker
-      (attack [this world target]
-        {:pre [(satisfies? Destructible target)]}
-        (let [damage 1]
-          (take-damage target world damage))))
-
-Again, a very basic system for the moment: all attacks do one damage.  Lichens
-only have one hit point, so this will kill them instantly.
-
-Notice the precondition here: an attacker can attack something if and only if
-it's something that satisfies the `Destructible` protocol.
-
-Instead of doing something like checking if the target has `:hp` I simply check
-if it's `Destructible`.  This opens the door for things that don't necessarily
-use hit points, like a monster whose mana and hit points are a single number.
-
-Finally, I need to hook up the attacking functionality in the `move-player`
-helper function:
-
-    :::clojure
-    (defn move-player [world dir]
-      (let [player (get-in world [:entities :player])
-            target (destination-coords (:location player) dir)
-            entity-at-target (get-entity-at world target)]
-        (cond
-          entity-at-target (attack player world entity-at-target)
-          (can-move? player world target) (move player world target)
-          (can-dig? player world target) (dig player world target)
-          :else world)))
-
-This once again overloads the `hjkl` keys, so now the player will attack
-a monster when they try to move into it.  Otherwise the player will move or dig
-as before.
-
-Growing Lichens
----------------
-
-Now for the last part of Trystan's post.  Lichens should have a chance of
-spreading slowly every turn.  Unlike Trystan, I'm not going to limit the number
-of times the lichen can spread, so the player will need to use their newfound
-attacking ability if they want to stem the tide of invading fungus!
-
-This turned out to be surprisingly painless:
-
-    :::clojure
-    (defn should-grow []
-      (< (rand) 0.01))
-
-    (defn grow [lichen world]
-      (if-let [target (find-empty-neighbor world (:location lichen))]
-        (let [new-lichen (make-lichen target)]
-          (assoc-in world [:entities (:id new-lichen)] new-lichen))
-        world))
-
-    (extend-type Lichen Entity
-      (tick [this world]
-        (if (should-grow)
-          (grow this world)
-          world)))
-
-Every tick, the lichen has a one percent chance to spread to an empty
-neighboring tile.  If there are no empty neighboring tiles, it can't spread.
-
-The `find-empty-neighbor` function is new, and located in `world.clj`:
-
-    :::clojure
-    (defn find-empty-neighbor [world coord]
-      (let [candidates (filter #(is-empty? world %) (neighbors coord))]
-        (when (seq candidates)
-          (rand-nth candidates))))
-
-It uses `neighbors`, which is another function I created after a quick refactor
-of `coords.clj`:
-
-    :::clojure
-    (ns caves.coords)
-
-    (def directions
-      {:w  [-1 0]
-       :e  [1 0]
-       :n  [0 -1]
-       :s  [0 1]
-       :nw [-1 -1]
-       :ne [1 -1]
-       :sw [-1 1]
-       :se [1 1]})
-
-    (defn offset-coords
-      "Offset the starting coordinate by the given amount, returning the result coordinate."
-      [[x y] [dx dy]]
-      [(+ x dx) (+ y dy)])
-
-    (defn dir-to-offset
-      "Convert a direction to the offset for moving 1 in that direction."
-      [dir]
-      (directions dir))
-
-    (defn destination-coords
-      "Take an origin's coords and a direction and return the destination's coords."
-      [origin dir]
-      (offset-coords origin (dir-to-offset dir)))
-
-    (defn neighbors
-      "Return the coordinates of all neighboring squares of the given coord."
-      [origin]
-      (map offset-coords (vals directions) (repeat origin)))
-
-Nothing too crazy here.  The small, composable functions build on top of each
-other to create more interesting ones.
-
-But there's one thing left to do, which is actually `tick` entities in the main
-game loop in `core.clj`:
-
-    :::clojure
-    (defn tick-entity [world entity]
-      (tick entity world))
-
-    (defn tick-all [world]
-      (reduce tick-entity world (vals (:entities world))))
-
-    (defn run-game [game screen]
-      (loop [{:keys [input uis] :as game} game]
-        (when-not (empty? uis)
-          (draw-game game screen)
-          (if (nil? input)
-            (recur (get-input (update-in game [:world] tick-all) screen))
-            (recur (process-input (dissoc game :input) input))))))
-
-Notice how the `tick-all` function reduces over the values in the entities map.
-Maps aren't deterministically ordered (or at least they're not *guaranteed* to
-be), so this means that our entities may process their ticks in a different
-order each turn.
-
-I think I'm okay with that.  Yes, it means that ticking the world isn't going to
-be a pure function, but it won't be pure no matter what since we're going to
-have random numbers involved in attacking and damage soon enough.
-
-Results
--------
-
-All-in-all it took roughly an hour and a half to code the stuff in this entry.
-This might sound like a lot, but remember what was added:
-
-* The entire concept of "multiple entities in a map".
-* Support for drawing arbitrary entities on the map.
-* A new creature.
-* Entities blocking movement of others.
-* A rudimentary attacking gameplay mechanic.
-* A rudimentary killing mechanic.
-* Ticking entities.
-* Growing/spreading of creatures.
-* Lots of refactoring and helper functions.
-
-Not too bad!
-
-You can view the code [on GitHub][result-code] if you want to see the end
-result.
-
-[result-code]: https://github.com/sjl/caves/tree/entry-05/src/caves
-
-And now some screenshots of our hero cutting a swath through some fungus!
-
-![Screenshot](/media/images{{ parent_url }}/caves-05-02.png)
-
-![Screenshot](/media/images{{ parent_url }}/caves-05-03.png)
-
-I'll be moving on to Trystan's sixth post soon, but before that I'm going to
-have another interlude where I explain some quick refactoring and then work
-a bit of the blackest magic in Clojure: a non-trivial macro.
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-05.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,496 @@
++++
+title = "The Caves of Clojure: Part 5"
+snip = "Fungus and more."
+date = 2012-07-13T10:55:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry corresponds to [post five in Trystan's tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `entry-05` tag to see the code as it stands
+after this post.
+
+Also, I live streamed myself writing the code that this entry is based on.  You
+can view the recordings [on twitch.tv](http://www.twitch.tv/stevelosh/), though
+as I write this the video links are stuck in an infinite HTTP redirect loop.
+Perhaps they will be fixed eventually.
+
+Finally, I've started hanging out in `##cavesofclojure` on Freenode if you have
+questions.  I may or may not be around at any given point.
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/09/roguelike-tutorial-05-stationary.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+In Trystan's fifth post he adds three things:
+
+* A stationary monster
+* Attacking
+* A growing mechanic for the monster
+
+I'm going to add all three of those too, though I'll be doing it in the
+entities/aspects fashion of the previous post.
+
+Multiple Entities
+-----------------
+
+First thing's first: I need to change a bit of code around to account for having
+multiple entities instead of just a single player.
+
+At the end of the previous post the player was stored in the world directly,
+meaning the `game` object looked like this:
+
+```clojure
+{:uis [...]
+ :world {:player {...}
+         :tiles [...]}}
+```
+
+I decided to remove some (but not all) of the special casing for the player and
+make them an entity like any other.  The `game` object is now structured like
+this:
+
+```clojure
+{:uis [...]
+ :world {:entities {:player {...}}
+         :tiles [...]}}
+```
+
+Notice that the player has been moved into an `:entities` map, keyed by its id
+(which is still the special-cased `:player`).  I updated anywhere that needed to
+change to account for this, and made sure it still worked.  This was pretty easy
+to do by just searching for `:player`, as the codebase is still small.
+
+Lichens
+-------
+
+Now it's time to actually add another type of entity.  I play a lot of Nethack,
+so naturally I decided to make it a simple lichen.  I added
+`entities/lichen.clj`:
+
+```clojure
+(ns caves.entities.lichen
+  (:use [caves.entities.core :only [Entity get-id]]))
+
+
+(defrecord Lichen [id glyph location])
+
+(defn make-lichen [location]
+  (->Lichen (get-id) "F" location))
+
+
+(extend-type Lichen Entity
+  (tick [this world]
+    (if (should-grow)
+      world)))
+```
+
+Like the `Player`, `Lichen`s implement the `Entity` protocol.  For now they
+don't do anything special during a tick.
+
+You may have noticed the new `get-id` function.  Entities must have IDs so I can
+get them in and out of the entity map.  The player has a special ID of
+`:player`, but I needed a way to get a unique ID for other entities.
+
+The simplest way I could think of was to use a simple counter over in
+`entities/core.clj`:
+
+```clojure
+(ns caves.entities.core)
+
+
+(def ids (ref 0))
+
+(defprotocol Entity
+  (tick [this world]
+        "Update the world to handle the passing of a tick for this entity."))
+
+
+(defn get-id []
+  (dosync
+    (let [id @ids]
+      (alter ids inc)
+      id)))
+```
+
+Not the prettiest solution, but it works.  I might switch to a UUID library or
+something in the future, but this'll do for now.
+
+Populating the World
+--------------------
+
+Unlike the `make-player` function, `make-lichen` takes a location directly
+instead of trying to find an empty space for itself in the world.  I figured it
+was better to not have entities deciding where they emerge in the world all the
+time!  I went ahead and refactored `make-player` to act like this as well.
+
+During this coding session I wasn't actually running and playing the full game
+through as much as I should have been.  I think as I get more and more of the
+basic structure of the game in place I'll be able to do this more.  Up to now
+I've been doing large, sweeping refactorings that touch many different pieces of
+code and break everything until they're finished.
+
+Anyway, back to the world.  I need a way to spawn some lichens in the world, so
+I edited the `reset-game` function in `input.clj`:
+
+```clojure
+(defn add-lichen [world]
+  (let [{:as lichen :keys [id]} (make-lichen (find-empty-tile world))]
+    (assoc-in world [:entities id] lichen)))
+
+(defn populate-world [world]
+  (let [world (assoc-in world [:entities :player]
+                        (make-player (find-empty-tile world)))
+        world (nth (iterate add-lichen world) 30)]
+    world))
+
+(defn reset-game [game]
+  (let [fresh-world (random-world)]
+    (-> game
+      (assoc :world fresh-world)
+      (update-in [:world] populate-world)
+      (assoc :uis [(->UI :play)]))))
+```
+
+It should be pretty easy to read.  `add-lichen` adds a new lichen to an empty
+tile.  `populate-world` takes a world and adds a player, then 30 lichens.
+
+This is getting to be a bit much to keep in `input.clj`.  I'll probably pull
+this out into a separate file soon.
+
+Drawing the Entities
+--------------------
+
+So now the lichens are part of the world, but I still need to draw them on the
+screen.  I split the `draw-player` function in `drawing.clj` into two separate
+functions:
+
+```clojure
+(defn draw-entity [screen start-x start-y {:keys [location glyph color]}]
+  (let [[entity-x entity-y] location
+        x (- entity-x start-x)
+        y (- entity-y start-y)]
+      (s/put-string screen x y glyph {:fg color})))
+
+(defn highlight-player [screen start-x start-y player]
+  (let [[player-x player-y] (:location player)
+        x (- player-x start-x)
+        y (- player-y start-y)]
+    (s/move-cursor screen x y)))
+```
+
+And then I use those in the main `draw-ui` function for the `:play` UI:
+
+```clojure
+(defmethod draw-ui :play [ui game screen]
+  (let [world (:world game)
+        {:keys [tiles entities]} world
+        player (:player entities)
+        [cols rows] screen-size
+        vcols cols
+        vrows (dec rows)
+        [start-x start-y end-x end-y] (get-viewport-coords game (:location player) vcols vrows)]
+    (draw-world screen vrows vcols start-x start-y end-x end-y tiles)
+    (doseq [entity (vals entities)]
+      (draw-entity screen start-x start-y entity))
+    (draw-hud screen game start-x start-y)
+    (highlight-player screen start-x start-y player)))
+```
+
+Long but straightforward.  I'm going to be cleaning this part of the code up
+very soon, as I've just added a bunch of really useful stuff to the
+[clojure-lanterna][] library that will let me delete a bunch of fiddly code
+here.
+
+[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
+
+If you're particularly eagle-eyed you might have noticed this new `color`
+attribute that seems to be a part of entities.  I didn't realize I had forgotten
+to specify colors until I actually wrote this bit of code.  Once I did I went
+back and added the field to the `Player` and `Lichen` records, as well as
+`make-player` and `make-lichen`.
+
+Now the lichens appear on the screen!
+
+![Screenshot](/media/images/blog/2012/07/caves-05-01.png)
+
+Movement
+--------
+
+At this point the lichens are on the screen but the player can walk straight
+through them.  I took care of that by first creating a few helper functions in
+`world.clj`:
+
+```clojure
+(defn get-entity-at [world coord]
+  (first (filter #(= coord (:location %))
+                 (vals (:entities world)))))
+
+(defn is-empty? [world coord]
+  (and (#{:floor} (get-tile-kind world coord))
+       (not (get-entity-at world coord))))
+```
+
+They'll handle the grunt world of traversing the `world` data structure.  Then
+I updated the player's `can-move?` function:
+
+```clojure
+(extend-type Player Mobile
+  (move ...)
+  (can-move? [this world dest]
+    (is-empty? world dest)))
+```
+
+Previously `can-move` checked the world's tile itself — now it delegates to
+a basic helper function instead.  I have a feeling a lot of things are going to
+need to use the idea of "empty tiles" so this function will probably get a lot
+of mileage.
+
+Now the player can't walk through fungus.  Great.
+
+Killing
+-------
+
+It's time to give the player a way to cut the lichens into little licheny bits.
+I implemented this with another pair of aspects: `Attacker` and `Destructible`.
+
+`Attacker` should be implemented by anything that can attack other things:
+
+```clojure
+(ns caves.entities.aspects.attacker)
+
+(defprotocol Attacker
+  (attack [this world target]
+          "Attack the target."))
+```
+
+`Destructible` should be implemented by anything that can "take damage and go
+away once it takes enough":
+
+```clojure
+(ns caves.entities.aspects.destructible)
+
+(defprotocol Destructible
+  (take-damage [this world damage]
+               "Take the given amount of damage and update the world appropriately."))
+```
+
+Lichens will be `Destructible` (for now the player will remain invincible):
+
+```clojure
+(extend-type Lichen Destructible
+  (take-damage [{:keys [id] :as this} world damage]
+    (let [damaged-this (update-in this [:hp] - damage)]
+      (if-not (pos? (:hp damaged-this))
+        (update-in world [:entities] dissoc id)
+        (update-in world [:entities id] assoc damaged-this)))))
+```
+
+The logic here is pretty basic.  When a `Destructible` entity takes some damage,
+first its hit points are updated.  If they wind up to be zero or fewer, the
+entity gracefully removes itself from the world.
+
+I have a feeling there's a more elegant way to write the updatey bits of that
+function.  If you've got suggestions please let me know.
+
+If I'm going to be basing damage on the entity's `:hp` attribute they'd better
+have one!  I added a simple `:hp` of `1` to lichens:
+
+```clojure
+(defrecord Lichen [id glyph color location hp])
+
+(defn make-lichen [location]
+  (->Lichen (get-id) "F" :green location 1))
+```
+
+Next I added the corresponding implementation of `Attacker` to the `Player` (for
+now lichens can't strike back):
+
+```clojure
+(extend-type Player Attacker
+  (attack [this world target]
+    {:pre [(satisfies? Destructible target)]}
+    (let [damage 1]
+      (take-damage target world damage))))
+```
+
+Again, a very basic system for the moment: all attacks do one damage.  Lichens
+only have one hit point, so this will kill them instantly.
+
+Notice the precondition here: an attacker can attack something if and only if
+it's something that satisfies the `Destructible` protocol.
+
+Instead of doing something like checking if the target has `:hp` I simply check
+if it's `Destructible`.  This opens the door for things that don't necessarily
+use hit points, like a monster whose mana and hit points are a single number.
+
+Finally, I need to hook up the attacking functionality in the `move-player`
+helper function:
+
+```clojure
+(defn move-player [world dir]
+  (let [player (get-in world [:entities :player])
+        target (destination-coords (:location player) dir)
+        entity-at-target (get-entity-at world target)]
+    (cond
+      entity-at-target (attack player world entity-at-target)
+      (can-move? player world target) (move player world target)
+      (can-dig? player world target) (dig player world target)
+      :else world)))
+```
+
+This once again overloads the `hjkl` keys, so now the player will attack
+a monster when they try to move into it.  Otherwise the player will move or dig
+as before.
+
+Growing Lichens
+---------------
+
+Now for the last part of Trystan's post.  Lichens should have a chance of
+spreading slowly every turn.  Unlike Trystan, I'm not going to limit the number
+of times the lichen can spread, so the player will need to use their newfound
+attacking ability if they want to stem the tide of invading fungus!
+
+This turned out to be surprisingly painless:
+
+```clojure
+(defn should-grow []
+  (< (rand) 0.01))
+
+(defn grow [lichen world]
+  (if-let [target (find-empty-neighbor world (:location lichen))]
+    (let [new-lichen (make-lichen target)]
+      (assoc-in world [:entities (:id new-lichen)] new-lichen))
+    world))
+
+(extend-type Lichen Entity
+  (tick [this world]
+    (if (should-grow)
+      (grow this world)
+      world)))
+```
+
+Every tick, the lichen has a one percent chance to spread to an empty
+neighboring tile.  If there are no empty neighboring tiles, it can't spread.
+
+The `find-empty-neighbor` function is new, and located in `world.clj`:
+
+```clojure
+(defn find-empty-neighbor [world coord]
+  (let [candidates (filter #(is-empty? world %) (neighbors coord))]
+    (when (seq candidates)
+      (rand-nth candidates))))
+```
+
+It uses `neighbors`, which is another function I created after a quick refactor
+of `coords.clj`:
+
+```clojure
+(ns caves.coords)
+
+(def directions
+  {:w  [-1 0]
+   :e  [1 0]
+   :n  [0 -1]
+   :s  [0 1]
+   :nw [-1 -1]
+   :ne [1 -1]
+   :sw [-1 1]
+   :se [1 1]})
+
+(defn offset-coords
+  "Offset the starting coordinate by the given amount, returning the result coordinate."
+  [[x y] [dx dy]]
+  [(+ x dx) (+ y dy)])
+
+(defn dir-to-offset
+  "Convert a direction to the offset for moving 1 in that direction."
+  [dir]
+  (directions dir))
+
+(defn destination-coords
+  "Take an origin's coords and a direction and return the destination's coords."
+  [origin dir]
+  (offset-coords origin (dir-to-offset dir)))
+
+(defn neighbors
+  "Return the coordinates of all neighboring squares of the given coord."
+  [origin]
+  (map offset-coords (vals directions) (repeat origin)))
+```
+
+Nothing too crazy here.  The small, composable functions build on top of each
+other to create more interesting ones.
+
+But there's one thing left to do, which is actually `tick` entities in the main
+game loop in `core.clj`:
+
+```clojure
+(defn tick-entity [world entity]
+  (tick entity world))
+
+(defn tick-all [world]
+  (reduce tick-entity world (vals (:entities world))))
+
+(defn run-game [game screen]
+  (loop [{:keys [input uis] :as game} game]
+    (when-not (empty? uis)
+      (draw-game game screen)
+      (if (nil? input)
+        (recur (get-input (update-in game [:world] tick-all) screen))
+        (recur (process-input (dissoc game :input) input))))))
+```
+
+Notice how the `tick-all` function reduces over the values in the entities map.
+Maps aren't deterministically ordered (or at least they're not *guaranteed* to
+be), so this means that our entities may process their ticks in a different
+order each turn.
+
+I think I'm okay with that.  Yes, it means that ticking the world isn't going to
+be a pure function, but it won't be pure no matter what since we're going to
+have random numbers involved in attacking and damage soon enough.
+
+Results
+-------
+
+All-in-all it took roughly an hour and a half to code the stuff in this entry.
+This might sound like a lot, but remember what was added:
+
+* The entire concept of "multiple entities in a map".
+* Support for drawing arbitrary entities on the map.
+* A new creature.
+* Entities blocking movement of others.
+* A rudimentary attacking gameplay mechanic.
+* A rudimentary killing mechanic.
+* Ticking entities.
+* Growing/spreading of creatures.
+* Lots of refactoring and helper functions.
+
+Not too bad!
+
+You can view the code [on GitHub][result-code] if you want to see the end
+result.
+
+[result-code]: https://github.com/sjl/caves/tree/entry-05/src/caves
+
+And now some screenshots of our hero cutting a swath through some fungus!
+
+![Screenshot](/media/images/blog/2012/07/caves-05-02.png)
+
+![Screenshot](/media/images/blog/2012/07/caves-05-03.png)
+
+I'll be moving on to Trystan's sixth post soon, but before that I'm going to
+have another interlude where I explain some quick refactoring and then work
+a bit of the blackest magic in Clojure: a non-trivial macro.
+
--- a/content/blog/2012/07/caves-of-clojure-06.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,388 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 6"
-        snip: "Real combat and messages."
-        created: 2012-07-30 09:50:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry corresponds to [post six in Trystan's tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `entry-06` tag to see the code as it stands
-after this post.
-
-Sorry for the long wait for this entry.  I've been working on lots of other
-stuff and haven't had a lot of time to write.  Hopefully I can get back to it
-more often!
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/09/roguelike-tutorial-06-hitpoints-combat.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-In Trystan's sixth post he adds a combat system and messaging infrastructure.
-Once again I'm following his lead and implementing the same things, but in the
-entity/aspect way of doing things.
-
-As usual I ended up refactoring a few things, which I'll briefly cover first.
-
-Refactoring
------------
-
-So far, the functions entities implement to fulfill aspects have looked like
-this:
-
-    :::clojure
-    (defaspect Digger
-      (dig [this world dest]
-        ...)
-      (can-dig? [this world dest]
-        ...))
-
-The entity has to be the first argument, because that's how protocols work.
-I don't have any flexibility there.  I originally made the world always be the
-second argument, but it turns out that it's more convenient to make the world
-the *last* argument.
-
-To see why, imagine we want to allow players to dig and move at the same time,
-instead of forcing them to be separate actions.  Updating the world might look
-like this:
-
-    :::clojure
-    (let [new-world (dig player world dest)
-          new-world (move player world dest)]
-      new-world)
-
-You could make this one specific case a bit prettier, but in general chaining
-together world-modifying actions is going to be a pain.  If I change the aspect
-functions to take the player, then other args, and *then* the world, I can use
-`->>` to chain actions:
-
-    :::clojure
-    (->> world
-      (dig player dest)
-      (move player dest))
-
-Much cleaner!  I went ahead and switched all the aspect functions to use this
-new scheme.
-
-I also did some other minor refactoring.  You can look through the changesets if
-you're really curious.
-
-Attacking and Defending
------------------------
-
-Instead of simply killing everything in one hit, I'm now going to give some
-creatures a bit of hp.  I also added a `:max-hp` attribute, since I'll likely
-need that in the future.  Here's a sample of what the `Bunny` creation function
-looks like:
-
-    :::clojure
-    (defn make-bunny [location]
-      (map->Bunny {:id (get-id)
-                   :name "bunny"
-                   :glyph "v"
-                   :color :yellow
-                   :location location
-                   :hp 4
-                   :max-hp 4}))
-
-I started using the `map->Foo` record constructors because the `->Foo` versions
-that relied on positional arguments started getting hard to read.
-
-Bunnies have 4 hp.  It'd be trivial to randomize this in the future, but for now
-I'll stick with a simple number.
-
-Trystan uses a simple attack and defense system.  I toyed with the idea of using
-a different one (like Brogue's) but figured I should stick to his tutorial when
-there's no clear reason not to.
-
-Trystan's system needs attack and defense values, so I added functions to the
-`Attacker` and `Destructible` aspects to retrieve these:
-
-    :::clojure
-    (defaspect Attacker
-      (attack [this target world]
-        ...)
-      (attack-value [this world]
-        (get this :attack 1)))
-
-    (defaspect Destructible
-      (take-damage [this damage world]
-        ...)
-      (defense-value [this world]
-        (get this :defense 0)))
-
-The default attack value is `1`.  If an entity has an `:attack` attribute that
-will be used instead.  Or the entity could provide a completely custom version
-of `attack-value` (e.g.: werewolves could have a larger attack if there's a full
-moon in the game or something).  Defense values work the same way.
-
-Now that I'm starting to actually use HP I'll display it in the bottom row of
-info on the screen:
-
-    :::clojure
-    (defn draw-hud [screen game]
-      (let [hud-row (dec (second (s/get-size screen)))
-            player (get-in game [:world :entities :player])
-            {:keys [location hp max-hp]} player
-            [x y] location
-            info (str "hp [" hp "/" max-hp "]")
-            info (str info " loc: [" x "-" y "]")]
-        (s/put-string screen 0 hud-row info)))
-
-The bottom row of the screen now looks like: "hp [20/20] loc: [82-103]".  I'll
-probably get rid of the loc soon, but for now it won't hurt to keep it onscreen.
-
-Now for the damage calculation.  I added a little helper function to take care
-of this in `attacker.clj`:
-
-    :::clojure
-    (defn get-damage [attacker target world]
-      (let [attack (attack-value attacker world)
-            defense (defense-value target world)
-            max-damage (max 0 (- attack defense))
-            damage (inc (rand-int max-damage))]
-        damage))
-
-This matches what Trystan does.  In a nutshell, the damage done is: "If defense
-is higher than attack, then 1.  Otherwise, a random number between 1 and (attack
-- defense)."
-
-I kept it separate from the `attack` function so that an entity can override
-attack without having to reimplement this logic.
-
-The `attack` default implementation needs to use this new damage calculator:
-
-    :::clojure
-    (defaspect Attacker
-      (attack [this target world]
-        {:pre [(satisfies? Destructible target)]}
-        (let [damage (get-damage this target world)]
-          (take-damage target damage)))
-      (attack-value [this world]
-        (get this :attack 1)))
-
-`Destructible` already handles reducing HP appropriately.  The only thing left
-is to give my entities some non-1 attack, defense, and/or hp values.  For now
-I used the following values:
-
-* Bunnies have 4 HP, default defense.
-* Lichens have 6 HP, default defense.
-* Silverfish have 15 HP, default defense.
-* Players have 40 HP, 10 attack, default defense.
-
-These are really just placeholder numbers until I add the ability for monsters
-to attack back.  Once I do that I'll be able to play the game a bit and
-determine if it's too easy or hard.
-
-Messaging
----------
-
-Now the player can attack things and it may take a few swings to kill them.  The
-problem is that there's no feedback while this is going on, so it's hard to tell
-that you're actually doing damage until the monster dies.
-
-A messaging system will let me display informational messages to give the player
-some feedback.  I decided to implement this like everything else: as an aspect.
-
-An entity that implements the `Receiver` protocol will be able to receive
-messages.  Here's `entities/aspects/receiver.clj`:
-
-    :::clojure
-    (ns caves.entities.aspects.receiver
-      (:use [caves.entities.core :only [defaspect]]
-            [caves.world :only [get-entities-around]]))
-    
-    (defaspect Receiver
-      (receive-message [this message world]
-        (update-in world [:entities (:id this) :messages] conj message)))
-    
-    (defn send-message [entity message args world]
-      (if (satisfies? Receiver entity)
-        (receive-message entity (apply format message args) world)
-        world))
-
-I've got a helper function `send-message` which is what entities will use to
-send messages, instead of performing the `(satisfies? Receiver entity)` check
-themselves every time.  If the entity they're sending the message to isn't
-a `Receiver` it will simply drop the message on the floor by returning the world
-unchanged.  It also handles formatting the message string for them.
-
-The default `receive-message` simply appends the message to a `:messages`
-attribute in the entity.
-
-I have a lot of ideas about extending this system in the future, but for now
-I'll just keep it simple to match Trystan's.
-
-Now I need to send some messages.  The most obvious place to do this is when
-something attacks something else, so I updated the `Attacker` aspect once more:
-
-
-    :::clojure
-    (defaspect Attacker
-      (attack [this target world]
-        {:pre [(satisfies? Destructible target)]}
-        (let [damage (get-damage this target world)]
-          (->> world
-            (take-damage target damage)
-            (send-message this "You strike the %s for %d damage!"
-                          [(:name target) damage])
-            (send-message target "The %s strikes you for %d damage!"
-                          [(:name this) damage]))))
-      (attack-value [this world]
-        (get this :attack 1)))
-
-This is starting to get a little crowded.  If I need to do much more in here
-I'll refactor some stuff out into helper functions.  But for now it's still
-readable.
-
-Here you can see how making world-altering functions take the world as the last
-argument pays off by letting me use `->>` to chain together actions.
-
-I also added a `:name` attribute to entities so I can say "You strike the bunny"
-instead of "You strike the v".  Nothing too special there.
-
-Finally, I need a way to notify nearby entities when something happens.  Here's
-what I came up with:
-
-    :::clojure
-    (defn send-message-nearby [coord message world]
-      (let [entities (get-entities-around world coord 7)
-            sm (fn [world entity]
-                 (send-message entity message [] world))]
-        (reduce sm world entities)))
-
-First I grab all the entities within 7 squares of the message coordinate.  Then
-I create a little helper function called `sm` that wraps `send-message`.  It
-will take a world and an entity and return the modified world.  I use `reduce`
-here to iterate over the entities and send the message to each one.  It's
-a pretty way of handling that looping.
-
-The `get-entities-around` function is new:
-
-    :::clojure
-    (defn get-entities-around
-      ([world coord] (get-entities-around world coord 1))
-      ([world coord radius]
-         (filter #(<= (radial-distance coord (:location %))
-                      radius)
-                 (vals (:entities world)))))
-
-It looks through all the entities in the world and returns a sequence of those
-whose "radial" distance is less than or equal to the given radius.  The "radial
-distance" (also called the "king's move" distance by some) looks like this:
-
-    :::text
-    3333333
-    3222223
-    3211123
-    3210123
-    3211123
-    3222223
-    3333333
-
-And the function:
-
-    :::clojure
-    (defn radial-distance
-      "Return the radial distance between two points."
-      [[x1 y1] [x2 y2]]
-      (max (abs (- x1 x2))
-           (abs (- y1 y2))))
-
-I may end up needing to modify this `send-message-nearby` function to be a bit
-more powerful in the future.  Trystan's version modifies the verbs and such.
-For now this is good enough for me.
-
-Now I can make lichens notify nearby creatures when they grow:
-
-    :::clojure
-    (defn grow [{:keys [location]} world]
-      (if-let [target (find-empty-neighbor world location)]
-        (let [new-lichen (make-lichen target)
-              world (assoc-in world [:entities (:id new-lichen)] new-lichen)
-              world (send-message-nearby location "The lichen grows." world)]
-          world)
-        world))
-
-The last step is to actually display these messages to the player.  I added
-a `draw-messages` function to the `ui/drawing.clj` file:
-
-    :::clojure
-    (defn draw-messages [screen messages]
-      (doseq [[i msg] (enumerate messages)]
-        (s/put-string screen 0 i msg {:fg :black :bg :white})))
-
-And then I modified the main `draw-ui` function for `:play` UIs to draw the
-messages on top of the map:
-
-    :::clojure
-    (defmethod draw-ui :play [ui game screen]
-      (let [world (:world game)
-            {:keys [tiles entities]} world
-            player (:player entities)
-            [cols rows] (s/get-size screen)
-            vcols cols
-            vrows (dec rows)
-            origin (get-viewport-coords game (:location player) vcols vrows)]
-        (draw-world screen vrows vcols origin tiles)
-        (doseq [entity (vals entities)]
-          (draw-entity screen origin vrows vcols entity))
-        (draw-hud screen game)
-        (draw-messages screen (:messages player))
-        (highlight-player screen origin player)))
-
-This does mean that messages will cover a bit of the screen.  For now I'll live
-with that, but in the future it's something to fix.
-
-Finally we need to clear the message queue out periodically, otherwise it'll
-grow until it covers the entire screen!  I modified the main game loop in
-`core.clj`:
-
-    :::clojure
-    (defn clear-messages [game]
-      (assoc-in game [:world :entities :player :messages] nil))
-    
-    (defn run-game [game screen]
-      (loop [{:keys [input uis] :as game} game]
-        (when (seq uis)
-          (if (nil? input)
-            (let [game (update-in game [:world] tick-all)
-                  _ (draw-game game screen)
-                  game (clear-messages game)]
-              (recur (get-input game screen)))
-            (recur (process-input (dissoc game :input) input))))))
-
-Results
--------
-
-After fixing a few other bugs (you can read the changelog if you're interested)
-I've now got a working combat system, and a messaging system so I can tell
-what's going on:
-
-![Screenshot](/media/images{{ parent_url }}/caves-06-01.png)
-
-It's actually starting to feel like a real game now, instead of just a sandbox
-where you can break things.
-
-You can view the code [on GitHub][result-code] if you want to see the end
-result.
-
-[result-code]: https://github.com/sjl/caves/tree/entry-06/src/caves
-
-The next article will move on to Trystan's seventh post, which adds multiple
-z-levels to the caves.
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-06.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,403 @@
++++
+title = "The Caves of Clojure: Part 6"
+snip = "Real combat and messages."
+date = 2012-07-30T09:50:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry corresponds to [post six in Trystan's tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `entry-06` tag to see the code as it stands
+after this post.
+
+Sorry for the long wait for this entry.  I've been working on lots of other
+stuff and haven't had a lot of time to write.  Hopefully I can get back to it
+more often!
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/09/roguelike-tutorial-06-hitpoints-combat.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+In Trystan's sixth post he adds a combat system and messaging infrastructure.
+Once again I'm following his lead and implementing the same things, but in the
+entity/aspect way of doing things.
+
+As usual I ended up refactoring a few things, which I'll briefly cover first.
+
+Refactoring
+-----------
+
+So far, the functions entities implement to fulfill aspects have looked like
+this:
+
+```clojure
+(defaspect Digger
+  (dig [this world dest]
+    ...)
+  (can-dig? [this world dest]
+    ...))
+```
+
+The entity has to be the first argument, because that's how protocols work.
+I don't have any flexibility there.  I originally made the world always be the
+second argument, but it turns out that it's more convenient to make the world
+the *last* argument.
+
+To see why, imagine we want to allow players to dig and move at the same time,
+instead of forcing them to be separate actions.  Updating the world might look
+like this:
+
+```clojure
+(let [new-world (dig player world dest)
+      new-world (move player world dest)]
+  new-world)
+```
+
+You could make this one specific case a bit prettier, but in general chaining
+together world-modifying actions is going to be a pain.  If I change the aspect
+functions to take the player, then other args, and *then* the world, I can use
+`->>` to chain actions:
+
+```clojure
+(->> world
+  (dig player dest)
+  (move player dest))
+```
+
+Much cleaner!  I went ahead and switched all the aspect functions to use this
+new scheme.
+
+I also did some other minor refactoring.  You can look through the changesets if
+you're really curious.
+
+Attacking and Defending
+-----------------------
+
+Instead of simply killing everything in one hit, I'm now going to give some
+creatures a bit of hp.  I also added a `:max-hp` attribute, since I'll likely
+need that in the future.  Here's a sample of what the `Bunny` creation function
+looks like:
+
+```clojure
+(defn make-bunny [location]
+  (map->Bunny {:id (get-id)
+               :name "bunny"
+               :glyph "v"
+               :color :yellow
+               :location location
+               :hp 4
+               :max-hp 4}))
+```
+
+I started using the `map->Foo` record constructors because the `->Foo` versions
+that relied on positional arguments started getting hard to read.
+
+Bunnies have 4 hp.  It'd be trivial to randomize this in the future, but for now
+I'll stick with a simple number.
+
+Trystan uses a simple attack and defense system.  I toyed with the idea of using
+a different one (like Brogue's) but figured I should stick to his tutorial when
+there's no clear reason not to.
+
+Trystan's system needs attack and defense values, so I added functions to the
+`Attacker` and `Destructible` aspects to retrieve these:
+
+```clojure
+(defaspect Attacker
+  (attack [this target world]
+    ...)
+  (attack-value [this world]
+    (get this :attack 1)))
+
+(defaspect Destructible
+  (take-damage [this damage world]
+    ...)
+  (defense-value [this world]
+    (get this :defense 0)))
+```
+
+The default attack value is `1`.  If an entity has an `:attack` attribute that
+will be used instead.  Or the entity could provide a completely custom version
+of `attack-value` (e.g.: werewolves could have a larger attack if there's a full
+moon in the game or something).  Defense values work the same way.
+
+Now that I'm starting to actually use HP I'll display it in the bottom row of
+info on the screen:
+
+```clojure
+(defn draw-hud [screen game]
+  (let [hud-row (dec (second (s/get-size screen)))
+        player (get-in game [:world :entities :player])
+        {:keys [location hp max-hp]} player
+        [x y] location
+        info (str "hp [" hp "/" max-hp "]")
+        info (str info " loc: [" x "-" y "]")]
+    (s/put-string screen 0 hud-row info)))
+```
+
+The bottom row of the screen now looks like: "hp [20/20] loc: [82-103]".  I'll
+probably get rid of the loc soon, but for now it won't hurt to keep it onscreen.
+
+Now for the damage calculation.  I added a little helper function to take care
+of this in `attacker.clj`:
+
+```clojure
+(defn get-damage [attacker target world]
+  (let [attack (attack-value attacker world)
+        defense (defense-value target world)
+        max-damage (max 0 (- attack defense))
+        damage (inc (rand-int max-damage))]
+    damage))
+```
+
+This matches what Trystan does.  In a nutshell, the damage done is: "If defense
+is higher than attack, then 1.  Otherwise, a random number between 1 and (attack
+- defense)."
+
+I kept it separate from the `attack` function so that an entity can override
+attack without having to reimplement this logic.
+
+The `attack` default implementation needs to use this new damage calculator:
+
+```clojure
+(defaspect Attacker
+  (attack [this target world]
+    {:pre [(satisfies? Destructible target)]}
+    (let [damage (get-damage this target world)]
+      (take-damage target damage)))
+  (attack-value [this world]
+    (get this :attack 1)))
+```
+
+`Destructible` already handles reducing HP appropriately.  The only thing left
+is to give my entities some non-1 attack, defense, and/or hp values.  For now
+I used the following values:
+
+* Bunnies have 4 HP, default defense.
+* Lichens have 6 HP, default defense.
+* Silverfish have 15 HP, default defense.
+* Players have 40 HP, 10 attack, default defense.
+
+These are really just placeholder numbers until I add the ability for monsters
+to attack back.  Once I do that I'll be able to play the game a bit and
+determine if it's too easy or hard.
+
+Messaging
+---------
+
+Now the player can attack things and it may take a few swings to kill them.  The
+problem is that there's no feedback while this is going on, so it's hard to tell
+that you're actually doing damage until the monster dies.
+
+A messaging system will let me display informational messages to give the player
+some feedback.  I decided to implement this like everything else: as an aspect.
+
+An entity that implements the `Receiver` protocol will be able to receive
+messages.  Here's `entities/aspects/receiver.clj`:
+
+```clojure
+(ns caves.entities.aspects.receiver
+  (:use [caves.entities.core :only [defaspect]]
+        [caves.world :only [get-entities-around]]))
+
+(defaspect Receiver
+  (receive-message [this message world]
+    (update-in world [:entities (:id this) :messages] conj message)))
+
+(defn send-message [entity message args world]
+  (if (satisfies? Receiver entity)
+    (receive-message entity (apply format message args) world)
+    world))
+```
+
+I've got a helper function `send-message` which is what entities will use to
+send messages, instead of performing the `(satisfies? Receiver entity)` check
+themselves every time.  If the entity they're sending the message to isn't
+a `Receiver` it will simply drop the message on the floor by returning the world
+unchanged.  It also handles formatting the message string for them.
+
+The default `receive-message` simply appends the message to a `:messages`
+attribute in the entity.
+
+I have a lot of ideas about extending this system in the future, but for now
+I'll just keep it simple to match Trystan's.
+
+Now I need to send some messages.  The most obvious place to do this is when
+something attacks something else, so I updated the `Attacker` aspect once more:
+
+
+```clojure
+(defaspect Attacker
+  (attack [this target world]
+    {:pre [(satisfies? Destructible target)]}
+    (let [damage (get-damage this target world)]
+      (->> world
+        (take-damage target damage)
+        (send-message this "You strike the %s for %d damage!"
+                      [(:name target) damage])
+        (send-message target "The %s strikes you for %d damage!"
+                      [(:name this) damage]))))
+  (attack-value [this world]
+    (get this :attack 1)))
+```
+
+This is starting to get a little crowded.  If I need to do much more in here
+I'll refactor some stuff out into helper functions.  But for now it's still
+readable.
+
+Here you can see how making world-altering functions take the world as the last
+argument pays off by letting me use `->>` to chain together actions.
+
+I also added a `:name` attribute to entities so I can say "You strike the bunny"
+instead of "You strike the v".  Nothing too special there.
+
+Finally, I need a way to notify nearby entities when something happens.  Here's
+what I came up with:
+
+```clojure
+(defn send-message-nearby [coord message world]
+  (let [entities (get-entities-around world coord 7)
+        sm (fn [world entity]
+             (send-message entity message [] world))]
+    (reduce sm world entities)))
+```
+
+First I grab all the entities within 7 squares of the message coordinate.  Then
+I create a little helper function called `sm` that wraps `send-message`.  It
+will take a world and an entity and return the modified world.  I use `reduce`
+here to iterate over the entities and send the message to each one.  It's
+a pretty way of handling that looping.
+
+The `get-entities-around` function is new:
+
+```clojure
+(defn get-entities-around
+  ([world coord] (get-entities-around world coord 1))
+  ([world coord radius]
+     (filter #(<= (radial-distance coord (:location %))
+                  radius)
+             (vals (:entities world)))))
+```
+
+It looks through all the entities in the world and returns a sequence of those
+whose "radial" distance is less than or equal to the given radius.  The "radial
+distance" (also called the "king's move" distance by some) looks like this:
+
+```text
+3333333
+3222223
+3211123
+3210123
+3211123
+3222223
+3333333
+```
+
+And the function:
+
+```clojure
+(defn radial-distance
+  "Return the radial distance between two points."
+  [[x1 y1] [x2 y2]]
+  (max (abs (- x1 x2))
+       (abs (- y1 y2))))
+```
+
+I may end up needing to modify this `send-message-nearby` function to be a bit
+more powerful in the future.  Trystan's version modifies the verbs and such.
+For now this is good enough for me.
+
+Now I can make lichens notify nearby creatures when they grow:
+
+```clojure
+(defn grow [{:keys [location]} world]
+  (if-let [target (find-empty-neighbor world location)]
+    (let [new-lichen (make-lichen target)
+          world (assoc-in world [:entities (:id new-lichen)] new-lichen)
+          world (send-message-nearby location "The lichen grows." world)]
+      world)
+    world))
+```
+
+The last step is to actually display these messages to the player.  I added
+a `draw-messages` function to the `ui/drawing.clj` file:
+
+```clojure
+(defn draw-messages [screen messages]
+  (doseq [[i msg] (enumerate messages)]
+    (s/put-string screen 0 i msg {:fg :black :bg :white})))
+```
+
+And then I modified the main `draw-ui` function for `:play` UIs to draw the
+messages on top of the map:
+
+```clojure
+(defmethod draw-ui :play [ui game screen]
+  (let [world (:world game)
+        {:keys [tiles entities]} world
+        player (:player entities)
+        [cols rows] (s/get-size screen)
+        vcols cols
+        vrows (dec rows)
+        origin (get-viewport-coords game (:location player) vcols vrows)]
+    (draw-world screen vrows vcols origin tiles)
+    (doseq [entity (vals entities)]
+      (draw-entity screen origin vrows vcols entity))
+    (draw-hud screen game)
+    (draw-messages screen (:messages player))
+    (highlight-player screen origin player)))
+```
+
+This does mean that messages will cover a bit of the screen.  For now I'll live
+with that, but in the future it's something to fix.
+
+Finally we need to clear the message queue out periodically, otherwise it'll
+grow until it covers the entire screen!  I modified the main game loop in
+`core.clj`:
+
+```clojure
+(defn clear-messages [game]
+  (assoc-in game [:world :entities :player :messages] nil))
+
+(defn run-game [game screen]
+  (loop [{:keys [input uis] :as game} game]
+    (when (seq uis)
+      (if (nil? input)
+        (let [game (update-in game [:world] tick-all)
+              _ (draw-game game screen)
+              game (clear-messages game)]
+          (recur (get-input game screen)))
+        (recur (process-input (dissoc game :input) input))))))
+```
+
+Results
+-------
+
+After fixing a few other bugs (you can read the changelog if you're interested)
+I've now got a working combat system, and a messaging system so I can tell
+what's going on:
+
+![Screenshot](/media/images/blog/2012/07/caves-06-01.png)
+
+It's actually starting to feel like a real game now, instead of just a sandbox
+where you can break things.
+
+You can view the code [on GitHub][result-code] if you want to see the end
+result.
+
+[result-code]: https://github.com/sjl/caves/tree/entry-06/src/caves
+
+The next article will move on to Trystan's seventh post, which adds multiple
+z-levels to the caves.
+
--- a/content/blog/2012/07/caves-of-clojure-interlude-1.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,559 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Interlude 1"
-        snip: "Black magic."
-        created: 2012-07-14 17:06:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry is an interlude after [post five in Trystan's tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `interlude-1` tag to see the code as it stands
-after this post.
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/09/roguelike-tutorial-05-stationary.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-At the end of the last post I said that this one would be about refactoring and
-a macro, so that's what it's going to be.
-
-Refactoring
------------
-
-I don't want to bore you with lots of long chunks of refactored code, so I'll
-just outline the changes and if you want to see what happened you can look in
-the repo on GitHub.
-
-I ran [Kibit][] over the code and fixed what it complained.
-
-[jdmarble][] on GitHub pointed out a place where I was using `update-in` and
-could simplify it to `assoc-in`.  This is the kind of thing Kibit should catch,
-so I added it in and sent a pull request.
-
-[jmgimeno][] on GitHub pointed out that I could use an `atom` for the entity ID
-generation instead of a `ref`.  That cleaned up a few lines nicely.
-
-I updated the game loop and moved the call to `draw-game` so it doesn't get draw
-more times than is necessary.
-
-I added a bunch of comments and docstrings throughout the code.
-
-I added a few functions to the latest release of [clojure-lanterna][] that
-allowed me to clean up the UI drawing code.  I was able to completely remove the
-`clear-screen` function, and replaced the hardcoded screen size with a dymanic
-lookup.
-
-I also changed how the actual screen gets drawn.  Look in the repo for the full
-details -- I think it's much nicer now (though I'm still not 100% happy).
-
-I think that's about it.  On to the meat of this post.
-
-[kibit]: https://github.com/jonase/kibit/
-[jdmarble]: https://github.com/jdmarble
-[jmgimeno]: https://github.com/jmgimeno
-[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
-
-The Problem
------------
-
-Right now, the entity system in the Caves works like this:
-
-* Aspects are Clojure protocols.  They define what functions an entity must
-  implement to have that aspect.
-* Entity types use `extend-type` to add the appropriate implementations for the
-  aspects they want to be.
-
-This is all vanilla Clojure, and up until now it's been fine because there was
-no crossover between the `Lichen` aspects and the `Player` aspects.  But what's
-going to happen when I create a creature that shares behavior with one or both
-of them?
-
-To see the problem, I'm going to create a `Bunny` entity that will hop around
-the screen, and can also be destroyed (assuming the player is a terrible,
-terrible person).  So I'll create `entities/bunny.clj`:
-
-    :::clojure
-    (ns caves.entities.bunny)
-
-    (defrecord Bunny [id glyph color location hp])
-
-    (extend-type Bunny Entity
-      (tick [this world]
-        world))
-
-We'll worry about `tick` soon, but so far, so good.  Now I need to let bunnies
-move around:
-
-    :::clojure
-    (extend-type Bunny Mobile
-      (move [this world dest]
-        {:pre [(can-move? this world dest)]}
-        (assoc-in world [:entities (:id this) :location] dest))
-      (can-move? [this world dest]
-        (is-empty? world dest)))
-
-Hmm, where have we seen this code before?
-
-It's an almost exact copy of the `Player`'s implementation of the `Mobile`
-protocol!
-
-When you think about it, this makes sense.  Most of the entities in the game
-will have the same implementation for most aspects.  The flexibility of Clojure
-protocols means I have the power to customize behavior for every one of them,
-but it also means that I have to redefine the same behavior over and over.
-
-Or do I?
-
-The Not-Quite Solutions
------------------------
-
-There are a number of ways I could try to get around this duplication.
-
-First, I could define the "default" implementations as separate, normal
-functions, and then the entity-specific implementations could just call those.
-
-This would work, absolutely.  It would isolate the generic functionality in one
-place successfully.  But it means I'd have to manually type out the calls to
-those generic functions all the time.  This is a Lisp -- I can do better.
-
-The next idea is to make `Object` implement every aspect (with the default
-implementations).  This isn't ideal for two reasons.
-
-First, it means that the type of an entity is no longer useful.  If `Object`
-implements `Mobile` to provide the default functionality, it means *every*
-entity will effectively be `Mobile` even if it shouldn't be!
-
-Second, it doesn't even give me everything I want.  Observe:
-
-    :::clojure
-    (defprotocol Foo
-     (hello [this])
-     (world [this]))
-
-    (defrecord A [])
-
-    (extend-type Object Foo
-     (hello [this] :hello-object)
-     (world [this] :world-object))
-
-    (extend-type A Foo
-     (hello [this] :hello-a))
-
-    (def a (->A))
-
-    (hello a) ; Works
-    (world a) ; Doesn't work
-
-In this example, the `Foo` object doesn't get the benefit of the default
-implementation because it implements the protocol itself.  So when figuring out
-what `world` function to call Clojure asks "Hmm, does A implement Foo?  Oh, it
-does?  Okay, I'll use A's implementations then".
-
-So the entities would either have to implement all of the aspect functions
-(resulting in the duplication of the ones they don't need to change) or none of
-them (which *would* give them the defaults).
-
-So this isn't ideal.  I could also have used multimethods here, because they
-*do* support default implementations.  But multimethods don't give me a nice
-way to group related functions together like protocols.
-
-Protocols also interact with the type system to give me handy functionality
-like:
-
-    :::clojure
-    (defn find-targets
-      "Find potential things to kill!"
-      [world]
-      (filter #(satisfies? Destructible %)
-              (vals (:entities world))))
-
-The concept of "bunnies are destructible" is a useful one, and I'd lose it if
-I used multimethods.
-
-The Macro
----------
-
-Macros are not something you should reach for right away.  They're tricky and
-much harder to understand than a normal function.  But when all else fails,
-they're there as a last resort.
-
-I couldn't figure out a way to do this without macros, so it's time to roll up
-my sleeves and work some dark Lispy magic to get a nice syntax.
-
-When I'm writing a macro, my first step is usually to start at the end by
-writing out what I want its ultimate usage to be.  For this functionality I'm
-actually going to need a pair of macros.
-
-First, `defaspect` will replace `defprotocol` and allow me to define a protocol
-*and* provide the default implementations:
-
-    :::clojure
-    (defaspect Mobile
-      (move [this world dest]
-        {:pre [(can-move? this world dest)]}
-        (assoc-in world [:entities (:id this) :location] dest))
-      (can-move? [this world dest]
-        (is-empty? world dest)))
-
-Those implementations are generic enough (moving moves an entity from their
-current space into an empty one) that many entities will probably be able to use
-them unchanged.
-
-I'll also need a macro to replace `extend-type`.  I decided to call it
-`add-aspect`:
-
-    :::clojure
-    (add-aspect EarthElemental Mobile
-      (can-move? [this world]
-        (entity-at? world dest)))
-
-In this example the `EarthElemental` entity is implementing `Mobile`.  It will
-use the default `move` implementation (which just changes its location), but it
-overrides `can-move?`.  Earth elementals can't walk through other entities, but
-they *can* walk through the rock walls of the Caves.
-
-So I've got my examples of usage, now it's time to implement the macros.  I'll
-start with `defaspect`.
-
-My second step when writing a macro is writing out what the usage should be
-expanded into.  After a bit of thinking I came up with this:
-
-    :::clojure
-    (defaspect Mobile
-      (move [this world dest]
-        {:pre [(can-move? this world dest)]}
-        (assoc-in world [:entities (:id this) :location] dest))
-      (can-move? [this world dest]
-        (is-empty? world dest)))
-
-    ; should expand into
-
-    (do
-      (defprotocol Mobile
-        (move [this world dest])
-        (can-move? [this world dest]))
-      (def Mobile
-        (with-meta Mobile
-                   {:defaults
-                    {:move (fn [this world dest]
-                             {:pre [(can-move? this world dest)]}
-                             (assoc-in world [:entities (:id this) :location] dest))
-                     :can-move? (fn [this world dest]
-                                  (is-empty? world dest))}})))
-
-This looks a bit complicated because of the method implementations, which aren't
-really important when writing the macro, so let's remove those:
-
-    :::clojure
-    (defaspect Mobile
-      (move [this world dest]
-        {:pre [(can-move? this world dest)]}
-        (assoc-in world [:entities (:id this) :location] dest))
-      (can-move? [this world dest]
-        (is-empty? world dest)))
-
-    ; should expand into
-
-    (do
-      (defprotocol Mobile
-        (move [this world dest])
-        (can-move? [this world dest]))
-      (def Mobile
-        (with-meta Mobile
-                   {:defaults
-                    {:move (fn [this world dest] ...)
-                     :can-move? (fn [this world dest] ...)}})))
-
-That's a bit easier to read.  The `defaspect` macro is going to take all the
-forms I give it and expand into a `do` form with two actions: defining the
-protocol as before, and attaching a map to the Protocol itself with Clojure's
-metadata feature.
-
-This map will contain the default implementations.  For now just trust me that
-I'm going to need them in a map later.
-
-Now to write the actual macro!  It'll go in `entities/core.clj` for the moment.
-I'll start with a skeleton:
-
-    :::clojure
-    (defmacro defaspect [label & fns]
-      (let [fnmap (make-fnmap fns)
-            fnheads (make-fnheads fns)]
-        `(do
-           (defprotocol ~label
-             ~@fnheads)
-           (def ~label
-             (with-meta ~label {:defaults ~fnmap})))))
-
-If you've used macros before, this should be pretty easy to read.  I've pulled
-as much functionality as possible into two helper functions.  Let's look at
-those:
-
-    :::clojure
-    (defn make-fnmap
-      "Make a function map out of the given sequence of fnspecs.
-
-      A function map is a map of functions that you'd pass to extend.  For example,
-      this sequence of fnspecs:
-
-      ((foo [a] (println a)
-       (bar [a b] (+ a b)))
-
-      Would be turned into this fnmap:
-
-      {:foo (fn [a] (println a))
-       :bar (fn [a b] (+ a b))}
-
-      "
-      [fns]
-      (into {} (for [[label fntail] (map (juxt first rest) fns)]
-                 [(keyword label)
-                  `(fn ~@fntail)])))
-
-    (defn make-fnheads
-      "Make a sequence of fnheads of of the given sequence of fnspecs.
-
-      A fnhead is a sequence of (name args) like you'd pass to defprotocol.  For
-      example, this sequence of fnspecs:
-
-      ((foo [a] (println a))
-       (bar [a b] (+ a b)))
-
-      Would be turned into this sequence of fnheads:
-
-      ((foo [a])
-       (bar [a b]))
-
-      "
-      [fns]
-      (map #(take 2 %) fns))
-
-Hopefully the docstrings will make them pretty clear.  If you have questions let
-me know (or play around with them in a REPL to see how they behave).
-
-And with that, `defaspect` is complete!  I now have a way to define a protocol
-and attach some default implementations to it in one easy, beautiful call.
-
-The other macro, `add-aspect`, is a piece of cake now that I've got the helper
-functions:
-
-    :::clojure
-    (defmacro add-aspect [entity aspect & fns]
-      (let [fnmap (make-fnmap fns)]
-        `(extend ~entity ~aspect (merge (:defaults (meta ~aspect))
-                                        ~fnmap))))
-
-The important thing in understanding this macro is `extend`.  `extend` is what
-`extend-type` and `extend-protocol` sugar over.  It takes a type, a protocol,
-and a map of the implementations of that protocol's functions.
-
-The key word there is "map", which really does mean a plain old Clojure map.  So
-this macro will expand like so:
-
-    :::clojure
-    (add-aspect EarthElemental Mobile
-      (can-move? [this world dest]
-       (entity-at? world dest)))
-
-    ; should expand into
-
-    (extend EarthElemental Mobile
-      (merge (:defaults (meta Mobile))
-             {:can-move? (fn [this world dest] ...)})
-
-The `(:defaults (meta Mobile))` simply retrieves the function mapping that
-`defaspect` attached to the Protocol, so in effect I get something like:
-
-    :::clojure
-    (extend EarthElemental Mobile
-      (merge {:move (fn [this world dest] ...)
-              :can-move? (fn [this world dest] ...)}
-             {:can-move? (fn [this world dest] ...)})
-
-`merge` is just the vanilla Clojure `merge` function, so the resulting map will
-have the default implementations overridden by any custom ones given.
-
-And that's it!  Let's see it in action.
-
-Usage
------
-
-First I need to update the aspects to use `defaspect` and include their default
-implementations.  Here's `Destructible`:
-
-    :::clojure
-    (ns caves.entities.aspects.destructible
-      (:use [caves.entities.core :only [defaspect]]))
-
-
-    (defaspect Destructible
-      (take-damage [{:keys [id] :as this} world damage]
-        (let [damaged-this (update-in this [:hp] - damage)]
-          (if-not (pos? (:hp damaged-this))
-            (update-in world [:entities] dissoc id)
-            (assoc-in world [:entities id] damaged-this)))))
-
-The code is just torn out of the `Lichen` code.  Since this is how lichens will
-act, I can update them to use `add-aspect`:
-
-    :::clojure
-    (add-aspect Lichen Destructible)
-
-One line!  Nice.
-
-I'll make bunnies destructible too:
-
-    :::clojure
-    (add-aspect Bunny Destructible)
-
-Perfect.  I then updated `Mobile` to use the `defaspect` macro.  Look in the
-repository if you want to see that.  Now players and bunnies can both use the
-same default implementations for movement:
-
-    :::clojure
-    (add-aspect Bunny Mobile)
-    (add-aspect Player Mobile)
-
-Beautiful.  I then converted the remaining aspects and implementations to use
-these macros.
-
-Let's add some bunnies to the world.  First I'll need a `make-bunny` function
-similar to `make-lichen`:
-
-    :::clojure
-    (defn make-bunny [location]
-      (->Bunny (get-id) "v" :yellow location 1))
-
-I don't know why I picked yellow.  Are there yellow bunnies?  There are in
-*this* world.  I used a `v` as the glyph because it kind of looks like bunny
-ears.
-
-Then I updated the world-populating code over in `input.clj`:
-
-    :::clojure
-    (defn add-creature [world make-creature]
-      (let [creature (make-creature (find-empty-tile world))]
-        (assoc-in world [:entities (:id creature)] creature)))
-
-    (defn add-creatures [world make-creature n]
-      (nth (iterate #(add-creature % make-creature)
-                    world)
-           n))
-
-    (defn populate-world [world]
-      (let [world (assoc-in world [:entities :player]
-                            (make-player (find-empty-tile world)))]
-        (-> world
-          (add-creatures make-lichen 30)
-          (add-creatures make-bunny 20))))
-
-Bunnies will be a bit rarer than lichens for the moment (and maybe in the future
-they could eat them).
-
-Finally, let's run the game!
-
-![Screenshot](/media/images{{ parent_url }}/caves-interlude-1-01.png)
-
-Bunnies!  They're populated into the world and the player can kill them because
-they're `Destructible`.
-
-Right now they *can* move, but choose not to.  I'll fix that by updating their
-`tick` function:
-
-    :::clojure
-    (extend-type Bunny Entity
-      (tick [this world]
-        (if-let [target (find-empty-neighbor world (:location this))]
-          (move this world target)
-          world)))
-
-Now they'll move whenever they're not backed into a corner.  Obviously move
-complicated AI is possible, but this is fine for now.
-
-So this is all good, but I haven't even used the "override one function of an
-aspect but not others" part of my fancy macro.  I'll add another creature to
-show that off:
-
-
-    :::clojure
-    (ns caves.entities.silverfish
-      (:use [caves.entities.core :only [Entity get-id add-aspect]]
-            [caves.entities.aspects.destructible :only [Destructible]]
-            [caves.entities.aspects.mobile :only [Mobile move can-move?]]
-            [caves.world :only [get-entity-at]]
-            [caves.coords :only [neighbors]]))
-
-
-    (defrecord Silverfish [id glyph color location hp])
-
-    (defn make-silverfish [location]
-      (->Silverfish (get-id) "~" :white location 1))
-
-
-    (extend-type Silverfish Entity
-      (tick [this world]
-        (let [target (rand-nth (neighbors (:location this)))]
-          (if (get-entity-at world target)
-            world
-            (move this world target)))))
-
-    (add-aspect Silverfish Mobile
-      (can-move? [this world dest]
-        (not (get-entity-at world dest))))
-
-    (add-aspect Silverfish Destructible)
-
-
-Oh no!  The horrible silverfish from Minecraft!  They wormy little guys are
-`Mobile` and `Destructible`, but they can move through walls with their custom
-`can-move?` function.
-
-Notice how I didn't have to provide an implementation of `move`.  Silverfish
-move like any other mobile entity (just by updating their location), the only
-thing special is where they can go.
-
-After adding them to the world population, we can see a few wriggling their way
-though the walls in the northeast corner:
-
-![Screenshot](/media/images{{ parent_url }}/caves-interlude-1-02.png)
-
-Results
--------
-
-You can view the code [on GitHub][result-code] if you want to see the end
-result.
-
-[result-code]: https://github.com/sjl/caves/tree/interlude-1/src/caves
-
-These two macros allowed me to add a new mob, with custom movement, in about 13
-lines of code (excluding imports).  That's pretty nice!  They certainly aren't
-perfect though.
-
-For one, every aspect *has* to define default implementations for its methods.
-You can't force all entities to implement it.  This isn't a big deal for now,
-but I may want to add it in later.
-
-Second, it doesn't handle docstrings properly.  Again, not a huge problem at the
-moment but something to put on the todo list for later.
-
-Finally, defining the protocol and implementations in the same form may lead to
-some tricky circular import issues.  I can always split them into separate files
-in the future though.
-
-That about wraps it up.  If you have any questions or comments let me know!  In
-the next entry I'll get back to Trystan's tutorial.
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/07/caves-of-clojure-interlude-1.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,577 @@
++++
+title = "The Caves of Clojure: Interlude 1"
+snip = "Black magic."
+date = 2012-07-14T17:06:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry is an interlude after [post five in Trystan's tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `interlude-1` tag to see the code as it stands
+after this post.
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/09/roguelike-tutorial-05-stationary.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+At the end of the last post I said that this one would be about refactoring and
+a macro, so that's what it's going to be.
+
+Refactoring
+-----------
+
+I don't want to bore you with lots of long chunks of refactored code, so I'll
+just outline the changes and if you want to see what happened you can look in
+the repo on GitHub.
+
+I ran [Kibit][] over the code and fixed what it complained.
+
+[jdmarble][] on GitHub pointed out a place where I was using `update-in` and
+could simplify it to `assoc-in`.  This is the kind of thing Kibit should catch,
+so I added it in and sent a pull request.
+
+[jmgimeno][] on GitHub pointed out that I could use an `atom` for the entity ID
+generation instead of a `ref`.  That cleaned up a few lines nicely.
+
+I updated the game loop and moved the call to `draw-game` so it doesn't get draw
+more times than is necessary.
+
+I added a bunch of comments and docstrings throughout the code.
+
+I added a few functions to the latest release of [clojure-lanterna][] that
+allowed me to clean up the UI drawing code.  I was able to completely remove the
+`clear-screen` function, and replaced the hardcoded screen size with a dymanic
+lookup.
+
+I also changed how the actual screen gets drawn.  Look in the repo for the full
+details — I think it's much nicer now (though I'm still not 100% happy).
+
+I think that's about it.  On to the meat of this post.
+
+[kibit]: https://github.com/jonase/kibit/
+[jdmarble]: https://github.com/jdmarble
+[jmgimeno]: https://github.com/jmgimeno
+[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
+
+The Problem
+-----------
+
+Right now, the entity system in the Caves works like this:
+
+* Aspects are Clojure protocols.  They define what functions an entity must
+  implement to have that aspect.
+* Entity types use `extend-type` to add the appropriate implementations for the
+  aspects they want to be.
+
+This is all vanilla Clojure, and up until now it's been fine because there was
+no crossover between the `Lichen` aspects and the `Player` aspects.  But what's
+going to happen when I create a creature that shares behavior with one or both
+of them?
+
+To see the problem, I'm going to create a `Bunny` entity that will hop around
+the screen, and can also be destroyed (assuming the player is a terrible,
+terrible person).  So I'll create `entities/bunny.clj`:
+
+```clojure
+(ns caves.entities.bunny)
+
+(defrecord Bunny [id glyph color location hp])
+
+(extend-type Bunny Entity
+  (tick [this world]
+    world))
+```
+
+We'll worry about `tick` soon, but so far, so good.  Now I need to let bunnies
+move around:
+
+```clojure
+(extend-type Bunny Mobile
+  (move [this world dest]
+    {:pre [(can-move? this world dest)]}
+    (assoc-in world [:entities (:id this) :location] dest))
+  (can-move? [this world dest]
+    (is-empty? world dest)))
+```
+
+Hmm, where have we seen this code before?
+
+It's an almost exact copy of the `Player`'s implementation of the `Mobile`
+protocol!
+
+When you think about it, this makes sense.  Most of the entities in the game
+will have the same implementation for most aspects.  The flexibility of Clojure
+protocols means I have the power to customize behavior for every one of them,
+but it also means that I have to redefine the same behavior over and over.
+
+Or do I?
+
+The Not-Quite Solutions
+-----------------------
+
+There are a number of ways I could try to get around this duplication.
+
+First, I could define the "default" implementations as separate, normal
+functions, and then the entity-specific implementations could just call those.
+
+This would work, absolutely.  It would isolate the generic functionality in one
+place successfully.  But it means I'd have to manually type out the calls to
+those generic functions all the time.  This is a Lisp — I can do better.
+
+The next idea is to make `Object` implement every aspect (with the default
+implementations).  This isn't ideal for two reasons.
+
+First, it means that the type of an entity is no longer useful.  If `Object`
+implements `Mobile` to provide the default functionality, it means *every*
+entity will effectively be `Mobile` even if it shouldn't be!
+
+Second, it doesn't even give me everything I want.  Observe:
+
+```clojure
+(defprotocol Foo
+ (hello [this])
+ (world [this]))
+
+(defrecord A [])
+
+(extend-type Object Foo
+ (hello [this] :hello-object)
+ (world [this] :world-object))
+
+(extend-type A Foo
+ (hello [this] :hello-a))
+
+(def a (->A))
+
+(hello a) ; Works
+(world a) ; Doesn't work
+```
+
+In this example, the `Foo` object doesn't get the benefit of the default
+implementation because it implements the protocol itself.  So when figuring out
+what `world` function to call Clojure asks "Hmm, does A implement Foo?  Oh, it
+does?  Okay, I'll use A's implementations then".
+
+So the entities would either have to implement all of the aspect functions
+(resulting in the duplication of the ones they don't need to change) or none of
+them (which *would* give them the defaults).
+
+So this isn't ideal.  I could also have used multimethods here, because they
+*do* support default implementations.  But multimethods don't give me a nice
+way to group related functions together like protocols.
+
+Protocols also interact with the type system to give me handy functionality
+like:
+
+```clojure
+(defn find-targets
+  "Find potential things to kill!"
+  [world]
+  (filter #(satisfies? Destructible %)
+          (vals (:entities world))))
+```
+
+The concept of "bunnies are destructible" is a useful one, and I'd lose it if
+I used multimethods.
+
+The Macro
+---------
+
+Macros are not something you should reach for right away.  They're tricky and
+much harder to understand than a normal function.  But when all else fails,
+they're there as a last resort.
+
+I couldn't figure out a way to do this without macros, so it's time to roll up
+my sleeves and work some dark Lispy magic to get a nice syntax.
+
+When I'm writing a macro, my first step is usually to start at the end by
+writing out what I want its ultimate usage to be.  For this functionality I'm
+actually going to need a pair of macros.
+
+First, `defaspect` will replace `defprotocol` and allow me to define a protocol
+*and* provide the default implementations:
+
+```clojure
+(defaspect Mobile
+  (move [this world dest]
+    {:pre [(can-move? this world dest)]}
+    (assoc-in world [:entities (:id this) :location] dest))
+  (can-move? [this world dest]
+    (is-empty? world dest)))
+```
+
+Those implementations are generic enough (moving moves an entity from their
+current space into an empty one) that many entities will probably be able to use
+them unchanged.
+
+I'll also need a macro to replace `extend-type`.  I decided to call it
+`add-aspect`:
+
+```clojure
+(add-aspect EarthElemental Mobile
+  (can-move? [this world]
+    (entity-at? world dest)))
+```
+
+In this example the `EarthElemental` entity is implementing `Mobile`.  It will
+use the default `move` implementation (which just changes its location), but it
+overrides `can-move?`.  Earth elementals can't walk through other entities, but
+they *can* walk through the rock walls of the Caves.
+
+So I've got my examples of usage, now it's time to implement the macros.  I'll
+start with `defaspect`.
+
+My second step when writing a macro is writing out what the usage should be
+expanded into.  After a bit of thinking I came up with this:
+
+```clojure
+(defaspect Mobile
+  (move [this world dest]
+    {:pre [(can-move? this world dest)]}
+    (assoc-in world [:entities (:id this) :location] dest))
+  (can-move? [this world dest]
+    (is-empty? world dest)))
+
+; should expand into
+
+(do
+  (defprotocol Mobile
+    (move [this world dest])
+    (can-move? [this world dest]))
+  (def Mobile
+    (with-meta Mobile
+               {:defaults
+                {:move (fn [this world dest]
+                         {:pre [(can-move? this world dest)]}
+                         (assoc-in world [:entities (:id this) :location] dest))
+                 :can-move? (fn [this world dest]
+                              (is-empty? world dest))}})))
+```
+
+This looks a bit complicated because of the method implementations, which aren't
+really important when writing the macro, so let's remove those:
+
+```clojure
+(defaspect Mobile
+  (move [this world dest]
+    {:pre [(can-move? this world dest)]}
+    (assoc-in world [:entities (:id this) :location] dest))
+  (can-move? [this world dest]
+    (is-empty? world dest)))
+
+; should expand into
+
+(do
+  (defprotocol Mobile
+    (move [this world dest])
+    (can-move? [this world dest]))
+  (def Mobile
+    (with-meta Mobile
+               {:defaults
+                {:move (fn [this world dest] ...)
+                 :can-move? (fn [this world dest] ...)}})))
+```
+
+That's a bit easier to read.  The `defaspect` macro is going to take all the
+forms I give it and expand into a `do` form with two actions: defining the
+protocol as before, and attaching a map to the Protocol itself with Clojure's
+metadata feature.
+
+This map will contain the default implementations.  For now just trust me that
+I'm going to need them in a map later.
+
+Now to write the actual macro!  It'll go in `entities/core.clj` for the moment.
+I'll start with a skeleton:
+
+```clojure
+(defmacro defaspect [label & fns]
+  (let [fnmap (make-fnmap fns)
+        fnheads (make-fnheads fns)]
+    `(do
+       (defprotocol ~label
+         ~@fnheads)
+       (def ~label
+         (with-meta ~label {:defaults ~fnmap})))))
+```
+
+If you've used macros before, this should be pretty easy to read.  I've pulled
+as much functionality as possible into two helper functions.  Let's look at
+those:
+
+```clojure
+(defn make-fnmap
+  "Make a function map out of the given sequence of fnspecs.
+
+  A function map is a map of functions that you'd pass to extend.  For example,
+  this sequence of fnspecs:
+
+  ((foo [a] (println a)
+   (bar [a b] (+ a b)))
+
+  Would be turned into this fnmap:
+
+  {:foo (fn [a] (println a))
+   :bar (fn [a b] (+ a b))}
+
+  "
+  [fns]
+  (into {} (for [[label fntail] (map (juxt first rest) fns)]
+             [(keyword label)
+              `(fn ~@fntail)])))
+
+(defn make-fnheads
+  "Make a sequence of fnheads of of the given sequence of fnspecs.
+
+  A fnhead is a sequence of (name args) like you'd pass to defprotocol.  For
+  example, this sequence of fnspecs:
+
+  ((foo [a] (println a))
+   (bar [a b] (+ a b)))
+
+  Would be turned into this sequence of fnheads:
+
+  ((foo [a])
+   (bar [a b]))
+
+  "
+  [fns]
+  (map #(take 2 %) fns))
+```
+
+Hopefully the docstrings will make them pretty clear.  If you have questions let
+me know (or play around with them in a REPL to see how they behave).
+
+And with that, `defaspect` is complete!  I now have a way to define a protocol
+and attach some default implementations to it in one easy, beautiful call.
+
+The other macro, `add-aspect`, is a piece of cake now that I've got the helper
+functions:
+
+```clojure
+(defmacro add-aspect [entity aspect & fns]
+  (let [fnmap (make-fnmap fns)]
+    `(extend ~entity ~aspect (merge (:defaults (meta ~aspect))
+                                    ~fnmap))))
+```
+
+The important thing in understanding this macro is `extend`.  `extend` is what
+`extend-type` and `extend-protocol` sugar over.  It takes a type, a protocol,
+and a map of the implementations of that protocol's functions.
+
+The key word there is "map", which really does mean a plain old Clojure map.  So
+this macro will expand like so:
+
+```clojure
+(add-aspect EarthElemental Mobile
+  (can-move? [this world dest]
+   (entity-at? world dest)))
+
+; should expand into
+
+(extend EarthElemental Mobile
+  (merge (:defaults (meta Mobile))
+         {:can-move? (fn [this world dest] ...)})
+```
+
+The `(:defaults (meta Mobile))` simply retrieves the function mapping that
+`defaspect` attached to the Protocol, so in effect I get something like:
+
+```clojure
+(extend EarthElemental Mobile
+  (merge {:move (fn [this world dest] ...)
+          :can-move? (fn [this world dest] ...)}
+         {:can-move? (fn [this world dest] ...)})
+```
+
+`merge` is just the vanilla Clojure `merge` function, so the resulting map will
+have the default implementations overridden by any custom ones given.
+
+And that's it!  Let's see it in action.
+
+Usage
+-----
+
+First I need to update the aspects to use `defaspect` and include their default
+implementations.  Here's `Destructible`:
+
+```clojure
+(ns caves.entities.aspects.destructible
+  (:use [caves.entities.core :only [defaspect]]))
+
+
+(defaspect Destructible
+  (take-damage [{:keys [id] :as this} world damage]
+    (let [damaged-this (update-in this [:hp] - damage)]
+      (if-not (pos? (:hp damaged-this))
+        (update-in world [:entities] dissoc id)
+        (assoc-in world [:entities id] damaged-this)))))
+```
+
+The code is just torn out of the `Lichen` code.  Since this is how lichens will
+act, I can update them to use `add-aspect`:
+
+```clojure
+(add-aspect Lichen Destructible)
+```
+
+One line!  Nice.
+
+I'll make bunnies destructible too:
+
+```clojure
+(add-aspect Bunny Destructible)
+```
+
+Perfect.  I then updated `Mobile` to use the `defaspect` macro.  Look in the
+repository if you want to see that.  Now players and bunnies can both use the
+same default implementations for movement:
+
+```clojure
+(add-aspect Bunny Mobile)
+(add-aspect Player Mobile)
+```
+
+Beautiful.  I then converted the remaining aspects and implementations to use
+these macros.
+
+Let's add some bunnies to the world.  First I'll need a `make-bunny` function
+similar to `make-lichen`:
+
+```clojure
+(defn make-bunny [location]
+  (->Bunny (get-id) "v" :yellow location 1))
+```
+
+I don't know why I picked yellow.  Are there yellow bunnies?  There are in
+*this* world.  I used a `v` as the glyph because it kind of looks like bunny
+ears.
+
+Then I updated the world-populating code over in `input.clj`:
+
+```clojure
+(defn add-creature [world make-creature]
+  (let [creature (make-creature (find-empty-tile world))]
+    (assoc-in world [:entities (:id creature)] creature)))
+
+(defn add-creatures [world make-creature n]
+  (nth (iterate #(add-creature % make-creature)
+                world)
+       n))
+
+(defn populate-world [world]
+  (let [world (assoc-in world [:entities :player]
+                        (make-player (find-empty-tile world)))]
+    (-> world
+      (add-creatures make-lichen 30)
+      (add-creatures make-bunny 20))))
+```
+
+Bunnies will be a bit rarer than lichens for the moment (and maybe in the future
+they could eat them).
+
+Finally, let's run the game!
+
+![Screenshot](/media/images/blog/2012/07/caves-interlude-1-01.png)
+
+Bunnies!  They're populated into the world and the player can kill them because
+they're `Destructible`.
+
+Right now they *can* move, but choose not to.  I'll fix that by updating their
+`tick` function:
+
+```clojure
+(extend-type Bunny Entity
+  (tick [this world]
+    (if-let [target (find-empty-neighbor world (:location this))]
+      (move this world target)
+      world)))
+```
+
+Now they'll move whenever they're not backed into a corner.  Obviously move
+complicated AI is possible, but this is fine for now.
+
+So this is all good, but I haven't even used the "override one function of an
+aspect but not others" part of my fancy macro.  I'll add another creature to
+show that off:
+
+
+```clojure
+(ns caves.entities.silverfish
+  (:use [caves.entities.core :only [Entity get-id add-aspect]]
+        [caves.entities.aspects.destructible :only [Destructible]]
+        [caves.entities.aspects.mobile :only [Mobile move can-move?]]
+        [caves.world :only [get-entity-at]]
+        [caves.coords :only [neighbors]]))
+
+
+(defrecord Silverfish [id glyph color location hp])
+
+(defn make-silverfish [location]
+  (->Silverfish (get-id) "~" :white location 1))
+
+
+(extend-type Silverfish Entity
+  (tick [this world]
+    (let [target (rand-nth (neighbors (:location this)))]
+      (if (get-entity-at world target)
+        world
+        (move this world target)))))
+
+(add-aspect Silverfish Mobile
+  (can-move? [this world dest]
+    (not (get-entity-at world dest))))
+
+(add-aspect Silverfish Destructible)
+
+```
+
+Oh no!  The horrible silverfish from Minecraft!  They wormy little guys are
+`Mobile` and `Destructible`, but they can move through walls with their custom
+`can-move?` function.
+
+Notice how I didn't have to provide an implementation of `move`.  Silverfish
+move like any other mobile entity (just by updating their location), the only
+thing special is where they can go.
+
+After adding them to the world population, we can see a few wriggling their way
+though the walls in the northeast corner:
+
+![Screenshot](/media/images/blog/2012/07/caves-interlude-1-02.png)
+
+Results
+-------
+
+You can view the code [on GitHub][result-code] if you want to see the end
+result.
+
+[result-code]: https://github.com/sjl/caves/tree/interlude-1/src/caves
+
+These two macros allowed me to add a new mob, with custom movement, in about 13
+lines of code (excluding imports).  That's pretty nice!  They certainly aren't
+perfect though.
+
+For one, every aspect *has* to define default implementations for its methods.
+You can't force all entities to implement it.  This isn't a big deal for now,
+but I may want to add it in later.
+
+Second, it doesn't handle docstrings properly.  Again, not a huge problem at the
+moment but something to put on the todo list for later.
+
+Finally, defining the protocol and implementations in the same form may lead to
+some tricky circular import issues.  I can always split them into separate files
+in the future though.
+
+That about wraps it up.  If you have any questions or comments let me know!  In
+the next entry I'll get back to Trystan's tutorial.
+
--- a/content/blog/2012/10/a-modern-space-cadet.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1303 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "A Modern Space Cadet"
-        snip: "Emulating a legendary keyboard."
-        created: 2012-10-03 09:55:00
-    %}
-
-{% block article %}
-
-I spend a lot of my time (easily over 8 hours a day) at a keyboard.  As you
-might have guessed from my previous entries about [Vim][] and [Mutt][] I'm not
-averse to spending a few hours to improve an environment I'm going to be
-spending tens of thousands of hours in over the next few years, so it shouldn't
-be a shock that my keyboard is something I've heavily tweaked.
-
-This post is about what I've done to make my typing experience more pleasant and
-efficient.
-
-If you scoff at customization you won't enjoy this post.  What if I have to use
-someone else's machine?  I can count on one hand the number of times I've had to
-use someone else's machine ever since I got an iPhone five years ago.  I *like*
-customizing my machine to save me time.  Yes, there may be some excessive stuff
-here, but not only does it make me type faster, it's *fun*!
-
-[TOC]
-
-[Vim]: /blog/2010/09/coming-home-to-vim/
-[Mutt]: /blog/2012/10/the-homely-mutt/
-
-The Original
-------------
-
-There have been many, many keyboards produced in the world since the first ones
-emerged.  One of the most famous, at least in programming circles, is the [Space
-Cadet Keyboard][space-cadet].
-
-Originally used on Lisp machines and some other systems, it's not a keyboard for
-the minimalist.  There are four "bucky keys" (modifier keys): control, meta,
-super, and hyper (plus shift, of course).  There are also special keys that let
-you type Greek letters and mathematical symbols.
-
-The Space Cadet is an example of a keyboard for someone not afraid to invest
-some time to work faster.
-
-It's also absolutely gorgeous.  The color scheme and typography is beautiful.
-
-This is the keyboard I used (loosely) as inspiration when crafting my current
-setup.
-
-[space-cadet]: http://world.std.com/~jdostale/kbd/SpaceCadet.html
-
-Modern Hardware
----------------
-
-I've tried a number of modern keyboards in the past few years.  They're all
-high-quality and more expensive than the $20 plastic toys that come with
-desktops.  But I spend 60 or more hours a week at a keyboard and maybe one hour
-a week in my car, so I'm getting pretty good use out of the dollars I've put
-into keyboards if you compare them to the cost of my car!
-
-I'll go through the keyboards I've used in chronological order.  I'm not going
-to write too much about the basics of mechanical keyboards and switches.  If you
-want to learn about that, [this post][ch] and [this guide][mech] are good places
-to start.
-
-[ch]: http://www.codinghorror.com/blog/2010/10/the-keyboard-cult.html
-[mech]: http://www.overclock.net/t/491752/mechanical-keyboard-guide
-
-### Apple Wireless Keyboard
-
-For a long time I used [Apple wireless keyboards][apple-wireless].
-
-![Apple Wireless Keyboard](/media/images{{ parent_url }}/kb-apple.jpg)
-
-They're light and compact, but still feel extremely solid thanks to their metal
-construction.
-
-They also stay really clean because there gaps between keys are tiny, instead of
-the funnel-shaped gaps of other keyboard that send dirt straight to the bottom. 
-
-They're readily available at any Apple store, and of course they're wireless
-which is great.
-
-They also feel exactly like the keyboards on Apple's laptops, so your muscle
-memory is perfectly suited to either one if you switch between them often.
-
-Unfortunately typing on them is nowhere near as nice as the rest of the
-keyboards in this list.  Apple keyboards have (I think) only 2mm of travel, but
-you have to bottom-out the keys to register the keypresses.
-
-[apple-wireless]: http://www.apple.com/keyboard/
-
-### Das Silent Ultimate
-
-The first mechanical keyboard I got was the [Das Silent Ultimate][das-silent].
-
-![Das Silent Keyboard](/media/images{{ parent_url }}/kb-das.jpg)
-
-(This photo is actually my Das Clicky since I don't have the Silent any more,
-but they're exactly the same externally.)
-
-Compared to the Apple keyboards the switches on the Das Silent (Cherry Brown
-switches) feel far softer.  You're not smashing your fingers against metal on
-every keypress.
-
-Overall the Das Silent isn't too bad.  It's built like a tank so I have no doubt
-it'd last forever.  It also has the option of blank keys, which I prefer.
-
-I didn't stick with this keyboard for long.  First, its glossy finish looks good
-when it's in the box and terrible forever after that.  It's way too easy to get
-dirty.
-
-Something also just feels "off" about the key switches to me, especially after
-I've tried the other boards in this list.  They feel, for lack of a better term,
-"mushy" to me.
-
-[das-silent]: http://www.daskeyboard.com/model-s-ultimate-silent/
-
-### Das Clicky Ultimate
-
-The next keyboard I tried was the [Das Clicky Ultimate][das-clicky].
-
-![Das Clicky Keyboard](/media/images{{ parent_url }}/kb-das.jpg)
-
-This is exactly the same as the Das Silent except for the switches, which are
-the "clicky" Cherry Blues.  These feel *way* better to me than the browns.  The
-mushiness I described for the Silent is completely gone.
-
-They are not kidding when they say it is loud.  If you're typing a lot expect to
-have a constant background noise of clicks.  But to me the sound is soothing,
-especially once you get into a rhythm of typing for extended periods.  Your
-coworkers might disagree, so tread carefully.
-
-The Das Clicky still has that godawful glossy finish, unfortunately.  After
-a while I decided to try out what I had heard people raving about: Topre
-switches.
-
-[das-clicky]: http://www.daskeyboard.com/model-s-ultimate/
-
-### Happy Hacking Keyboard Professional 2
-
-The [Happy Hacking Keyboard][hhkb] was my next keyboard.  It's much more
-expensive than the Dases were, so it was a tough call, but I'm glad I got it.
-
-![Happy Hacking Keyboard](/media/images{{ parent_url }}/kb-hhkb.jpg)
-
-The HHKB uses Topre key switches, which to me feel like Cherry Browns done
-right.  There's no "click" like the Blues, but instead of the mush of the
-Browns you get a satisfying "thunk" or "sshhhunk" on each press.  It's a great
-balance: you have a nice satisfying sound that's less annoying for other people.
-
-The finish on this keyboard is perfect.  It is the most unassuming, elegant,
-wonderful matte finish I've seen on any keyboard.  The plastic is just textured
-enough to feel solid under your fingers (not slippery like Macbook keys) but not
-enough to feel like you're typing on sandpaper.
-
-If you're short on space, or want to carry your keyboard with you, the HHKB is
-for you.  It's *tiny*, but still feels solid and not flimsy at all.
-
-I have two main complaints about the HHKB.  First, there's two spaces on the
-bottom row where they could have put a modifier key but didn't.  The space on
-the right has the logo, which is fair enough, but the one on the left is simply
-blank for no good reason.
-
-My other complaint is the idiotic default placement of the `fn` key and the
-arrow keys.  I don't mind having to use `fn` to get to the arrows as
-a concession to a compact design, but why on earth would you place them so that
-you have to chord on a *single hand* to hit them?
-
-This problem would be completely solved if the `fn` key were moved from its
-current position (right of the right shift key) down to the empty lower-left
-corner.  Then you could use your left hand to hold `fn` while your right worked
-the arrow keys, no single-hand contortion required.
-
-So after a while with the HHKB I got sick of the arrow key problem.  I loved the
-Topre switches though, so the next choice was pretty obvious.
-
-[hhkb]: http://elitekeyboards.com/products.php?sub=pfu_keyboards,hhkbpro2&pid=pdkb400bn
-
-### Topre Realforce 103
-
-The Topre Realforce 103UB was my next keyboard, and is the one I'm
-still using to this day.
-
-![Topre Realforce Keyboard](/media/images{{ parent_url }}/kb-realforce.jpg)
-
-I believe the model I bought is now discontinued, but it's been replaced by the
-[104UB][topre] which is exactly the same except for an extra key on the right
-side.  If I could swap my current keyboard for one of those I would.  In fact,
-if anyone wants to buy my used 103UB for a bit of a discount I'd be totally
-willing to sell it to get the 104UB.
-
-Anyway, this keyboard has a few disadvantages.  First, unlike every other
-keyboard here (except the wireless Apple ones) *it is not a USB hub*.  This
-isn't a huge deal (I have external USB hubs), but it did come as a big surprise.
-
-Second, it's big.  Really big.  If you don't have *plenty* of room on your desk
-you might want to look at the [tenkeyless][topre-tenkeyless] varieties which
-ditch the number pad section to save space.  I have room and I love having
-a number pad, so I got the behemoth-sized model.
-
-Also for some reason I can't fathom there's no way to get blank, black keycaps
-for this keyboard.  You can get blank Topre keycaps in lime green, pink, yellow,
-and lots of other colors, but not a simple black!
-
-Now for the good parts.  This thing is built like a tank.  If you needed to
-defend your home from an intruder, it would make an acceptable blunt weapon with
-which to do so (and you'd probably be able to plug it right back in and start
-typing again).
-
-The finish is the same as on the HHKB (gorgeous), but I have to take a point off
-for the non-blank keycaps.  I don't need to look at the keys while I type, so
-why marr the luxurious finish with lettering?
-
-The Realforce also uses Topre switches, but it has another trick up its sleeve
-that makes typing on it even nicer than the HHKB.  The version I have is the
-"variable-weighted" one, which means that the keys under your weaker fingers
-take less force to press than the ones under your stronger fingers.  This is
-fantastic for long sessions of typing.  Instead of my pinkies getting tired my
-fingers seem to all tire out at the same rate now.  Topre does make a "uniform"
-version that doesn't have this trick, but I really like variable weight keys
-myself.
-
-[topre]: http://elitekeyboards.com/products.php?sub=topre_keyboards,rf104&pid=xf11t0
-[topre-tenkeyless]: http://elitekeyboards.com/products.php?sub=topre_keyboards,rftenkeyless
-
-### Verdict
-
-Right now I'm using the Topre Realforce for my day to day work.  I've fallen in
-love with how the Topre switches feel (I prefer them over all the others except
-*maybe* the Cherry Blues for the sound) and the Happy Hacking Keyboard is just
-too cramped.  If I were short on space the HHKB would be great, but I have
-plenty of room on my desk, so why not make use of it?
-
-Here's a photo of all the keyboards (along with a 13" Macbook Air) so you can
-see the differences in size.
-
-![Keyboard Size Comparison](/media/images{{ parent_url }}/kb-size.jpg)
-
-Modern Software
----------------
-
-Now that I've talked about the hardware it's time for the software.  I use OS
-X exclusively, so everything I say here is OS X specific.  I'm sure there are
-Windows and Linux equivalents somewhere though.
-
-I use three software programs that, together, give me just about unlimited
-flexibility in customizing how my keyboard works in OS X.
-
-### Keyboard Maestro
-
-[Keyboard Maestro][] is a utility for binding macros to keyboard shortcuts in OS
-X.  It may not have the best user interface, but it can do a *lot*, and once you
-set up your shortcuts you never have to look at it again.  It's $36.
-
-Right now I use it for application switching, with a few twists I'll cover later
-on.
-
-I switched to [Keymando][] for a while.  It was great being able to configure it
-in a programming language with a plain text file I could easily work with in
-version control, but compared to Keyboard Maestro it's far slower and far
-buggier.  I'm now back to only using Keyboard Maestro.
-
-[Keyboard Maestro]: http://www.keyboardmaestro.com/main/
-[Keymando]: http://keymando.com/
-
-### PCKeyboardHack
-
-[PCKeyboardHack][] lets you map one key on your keyboard to another at a very
-low level.  For example, you can change just the right Option key to send `F19`
-instead.  I use this for one single key which you'll see in the next section.
-It's free and [open source][pc-git].
-
-[PCKeyboardHack]: http://pqrs.org/macosx/keyremap4macbook/pckeyboardhack.html.en
-[pc-git]: https://github.com/tekezo/PCKeyboardHack
-
-### KeyRemap4MacBook
-
-[KeyRemap4MacBook][] is how I do the bulk of my keyboard customizations.  Like
-all of the other applications its user interface is horrible, but it can do damn
-near *anything* you might want.  You could probably replace Keyboard Maestro
-with it, at least for the kind of stuff I do.  It's also free and [open
-source][kr-git].
-
-The bulk of what I describe in this post is going to use KeyRemap4MacBook.  I'm
-not going to give you a tutorial in it here -- read its documentation if you
-want to learn how to use the things I'm going to show.
-
-[KeyRemap4MacBook]: http://pqrs.org/macosx/keyremap4macbook/index.html.en
-[kr-git]: https://github.com/tekezo/KeyRemap4MacBook
-
-Control/Escape
---------------
-
-These first few mappings aren't directly from the Space Cadet keyboard, but they
-were inspired by its spirit of making an efficient tool for text editing.
-
-The Capslock key on modern keyboard has become the punchline of many a joke, and
-for good reason: there's no reason to dedicate such an important key to
-a function like capslock.  Many people rebind it to a more useful key like
-Control, Option, Escape, or Backspace.  I rebound it to Control for a while and
-then realized that with KeyRemap4MacBook I could get even more mileage out of
-it.
-
-The important thing I thought of one day is that it's possible to divide keys on
-the keyboard into three groups:
-
-* Keys you hold down to change how *other* keys behave, but that (usually) don't
-  do anything if you use them on their own (like Shift and Control).
-* Keys that you press and release but don't want to "repeat" as you hold them
-  (like Escape or Insert).
-* Keys that you sometimes press and release, but sometimes want to repeat (like
-  holding Space to insert a bunch of spaces, or Backspace to kill a bunch of
-  characters).
-
-Can you see where this is heading?  The last group is pretty normal, but the
-first two groups are special.  Specifically: there are two different ways to use
-them and they're each only useful in one of those ways.
-
-This means that we can *combine* them onto a single key without losing any
-useful functionality!
-
-I'm clearly not the first one to think of this, because KR4MB includes built-in
-support for creating these kinds of mappings.
-
-First I've mapped Capslock to Control at the OS X level by going into the
-Keyboard preference pane in System Preferences, clicking the Modifier Keys
-button in the lower right, selecting the keyboard in the dropdown list (this is
-surprisingly easy to miss), and changing the Capslock setting:
-
-![Changing Capslock to Control in OS X](/media/images{{ parent_url }}/kb-caps.png)
-
-Then I've selected the following premade option in KeyRemap4MacBook:
-
-> Control\_L to Control\_L  
-> (+ when you type Control\_L only, send Escape)
-
-Now the Capslock key on the keyboard does the following:
-
-1. If held down and pressed with another key, it acts like Control.
-2. If pressed and released on its own, it acts like Escape.
-
-That's two extremely important keys (at least for Vim users) on a single key in
-one of the prime locations on the keyboard!  No more awkward stretches!
-
-If you try this and want to force yourself to learn to use it, disable the
-normal escape key.  You'll learn fast.
-
-**Update:** I forgot to mention that if you use this (and the Shift
-improvements below) you'll probably want to change the "\[Key Overlaid
-Modifier\] Timeout" setting in the KR4MB preferences:
-
-![Key Overlaid Timeout](/media/images{{ parent_url }}/kb-key-overlaid.png)
-
-This setting controls the maximum length of a keypress that will register as
-"single press".  It's easier to understand with an example.  The default is
-1000ms, which means that if you press and hold the Capslock key for 900ms and
-release it, it will count as Escape.  If you hold it for 1001ms before
-releasing, it counts as pressing and releasing Control instead.
-
-If you're finding that you're sometimes holding Control out of habit and then
-releasing it, but it's still firing as an Escape, you may want to turn this
-setting down to a lower value.  I have mine set to 300ms.
-
-This is a lot more noticeable with the Shift mappings I'll describe shortly, so
-keep it in the back of your mind if you try those out.
-
-Hyper
------
-
-Modern OS X supports four "modifier" keys: Control, Option, Command, and Shift.
-The Space Cadet keyboard had five: Control, Meta, Super, Hyper, and Shift.
-
-Shift and Control map to each other, and OS X's Option key is pretty much the
-same as Meta (in fact I think Emacs users usually use Alt as Meta).
-I arbitrarily decided that Command was the OS X equivalent of Super.  That left
-Hyper.
-
-Since OS X doesn't natively support a fifth modifier key I had to come up with
-a way to fake it.
-
-First, I realized that because I use Capslock for Control I had no use for the
-*real* left Control key.  So the first step was to remap that to something else
-distinct from the Capslock-version of Control.
-
-This required PCKeyboardHack.  I don't think there's a way to do it in
-KeyRemap4MacBook, because by the time KR4MB sees the keypress it can't tell if
-it came from the Capslock key or the real Control key (due to how they were
-changed in the previous section).  PCKeyboardHack, however, *can*, so I remapped
-left Control to keycode `80`:
-
-![Remapping Left Control in PCKeyboardHack](/media/images{{ parent_url }}/kb-pck.png)
-
-Keycode `80` is the `F19` key.  My keyboard doesn't have an `F19` key so it
-doesn't conflict with anything.  Now I can simply remap `F19` in KR4MB just like
-any other key.
-
-To create a "pseudo-Hyper" modifier, I remapped this key to be the equivalent of
-holding down *all four other modifiers* by adding the following to my
-`private.xml` KR4MB configuration file:
-
-    :::xml
-    <item>
-        <name>Remap Left Control to Hyper</name>
-        <appendix>OS X doesn't have a Hyper. This maps Left Control to Control + Shift + Option + Command.</appendix>
-
-        <identifier>space_cadet.left_control_to_hyper</identifier>
-
-        <autogen>
-            --KeyToKey--
-            KeyCode::F19,
-
-            KeyCode::COMMAND_L,
-            ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
-        </autogen>
-    </item>
-
-As far as I can tell, no keyboard shortcuts in OS X or any apps use all four
-modifier keys (how would you normally press them all, anyway?).  But many
-programs, like Keyboard Maestro, let you define your own shortcuts.  So now I've
-got an entire key as a "namespace" all to myself for my own shortcuts!
-
-This is really nice.  I don't have to worry about "shadowing" existing shortcuts
-anywhere and it's only a single modifier to press.
-
-Currently I use this "namespace" for application switching.  Instead of using
-the normal `Command-Tab` switcher, I have shortcuts for each individual app
-I use frequently.  For example, `Hyper-k` switches to Firefox, `Hyper-y`
-switches to Twitter, and so on.  This is better than `Command-Tab`ing because
-I don't have to worry about how many times I need to press it.  `Hyper-k`
-*always* goes to Firefox no matter what, so I can easily burn that into my
-muscle memory.
-
-There's one more little trick I use in Keyboard Maestro.  It's specific to how
-I work, but I'm sure some of you will still find it handy.
-
-I pretty much always keep two iTerm 2 windows open.  The first contains
-a [tmux][] session with one window split into two panes.  One pane holds
-[weechat][weechat-prog] for IRC, the other holds [Mutt][mutt-prog] for email.
-I keep this on my laptop screen at all times while I do other things on my
-external monitor.
-
-The second iTerm window is almost always fullscreened, and contains a tmux
-session with whatever I'm working on.  The number of windows and panes varies
-wildly.
-
-What I wanted was a way to bind `Hyper-i` and `Hyper-m` to directly focus my IRC
-and mail panes, and `Hyper-j` to directly focus the second, "general-purpose"
-iTerm window.
-
-The solution came in two parts.  First I configured tmux so that `prefix N`
-would select the nth pane in the current window by adding the following to
-`~/.tmux.conf`:
-
-    :::text
-    bind 1 select-pane -t 1
-    bind 2 select-pane -t 2
-    bind 3 select-pane -t 3
-    bind 4 select-pane -t 4
-    bind 5 select-pane -t 5
-    bind 6 select-pane -t 6
-    bind 7 select-pane -t 7
-    bind 8 select-pane -t 8
-    bind 9 select-pane -t 9
-
-My tmux prefix is `Control-f`, so now pressing `Control-f 1` will go to pane 1,
-and so on.  Then I configured Keyboard Maestro like so:
-
-![Keyboard Maestro IRC Config](/media/images{{ parent_url }}/kb-irc.png)
-
-This binds `Control-Shift-Option-Command-i` (which is just `Hyper-i`) to do the
-following:
-
-1. Focus iTerm 2.
-2. Send a `Command-Option-1` keystroke, which will focus the first iTerm
-   2 window (I simply make sure I always open my mail/irc window first).
-3. Send the `Control-f` keystroke.
-3. Send the `1` keystroke, which together with the previous one tells tmux to
-   switch to pane 1.
-
-The mail shortcut is similar, of course, and the general-purpose terminal one is
-even simpler.
-
-So now I've got a free modifier key that won't conflict with anything, and I've
-got some very easy-to-type shortcuts I can burn into my fingers for switching
-applications quickly.  Awesome.
-
-[tmux]: http://tmux.sourceforge.net/
-[weechat-prog]: http://www.weechat.org/
-[mutt-prog]: http://www.mutt.org/
-
-Better Shifting
----------------
-
-The Shift keys are another of those keys that are only useful with other keys,
-so it's only natural that they were also on the list of keys to optimize.
-First, however, I took a detour to correct a bad habit of mine.
-
-### Shift Key Training Wheels
-
-I've been typing for most of my life, but I never really learned to do it
-correctly.  I can touch type, of course, but sometimes I use the wrong fingers
-for certain keys.
-
-My most egregious offense was that I always used the left Shift key.  Even when
-typing `X` I'd hold the left Shift key with my left pinky and hit the `x` with
-my left index finger, which pulled my hand off the home row and generally felt
-awkward.
-
-One day I decided I was tired of doing this the wrong way and resolved to fix
-myself.  The easiest way to break a bad habit is to make it harder or impossible
-to do, so I created a custom KeyRemap4MacBook setting that *disables* the
-keypress when you use the incorrect Shift key with a letter.  Here it is in
-full:
-
-    :::xml
-    <item>
-        <name>Use the correct shift keys.</name>
-        <identifier>private.correct_shift_keys</identifier>
-
-        <autogen>--KeyToKey-- KeyCode::Q, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::W, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::E, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::R, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::T, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::A, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::S, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::D, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::F, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::G, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::Z, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::X, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::C, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::V, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
-
-        <autogen>--KeyToKey-- KeyCode::Y,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::U,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::I,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::O,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::P,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::H,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::J,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::K,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::L,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::SEMICOLON, ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::N,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::M,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::COMMA,     ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::DOT,       ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-        <autogen>--KeyToKey-- KeyCode::QUOTE,     ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
-    </item>
-
-It took me about four hours of normal computer use to unlearn over two decades
-of wrong typing.  It's amazing how fast muscle memory can adjust when you simply
-*force* it to.
-
-Once I fixed myself I disabled this setting, because it also makes you to use
-the "correct" Shift key when doing keyboard shortcuts, and sometimes those are
-easer to do with the "wrong" Shift.
-
-If you only use one Shift key I'd really encourage you to try this.  It spreads
-out the wear over both pinkies and feels much better.  Your hands will thank
-you.
-
-### Shift Parentheses
-
-Now that I was using the right Shift keys, it was time to revisit mapping
-something else onto them.  One pair of keys stood out as a perfect candidate: the
-left and right parentheses.
-
-Parentheses are common in most of the programming languages in use today (some
-more than others).  If you counted I bet you'd find them more common than square
-or curly brackets in the majority of your code, and yet they're shoved away in
-the horrible homes of `Shift-9` and `Shift-0`.
-
-I decided to try out remapping my Shift keys to work like so:
-
-* When held while pressing other keys, act like Shift.
-* When pressed and released on their own, type an opening or closing parenthesis
-  (left and right shift respectively).
-
-This means I can type parentheses with a single, unchorded keypress.  After
-using it for a while I absolutely love it.  Here's the KeyRemap4MacBook setting
-for it:
-
-    :::xml
-    <item>
-        <name>Shifts to Parentheses</name>
-        <appendix>Shifts, when pressed alone, type parentheses.  When used with other keys they're normal shifts.</appendix>
-
-        <identifier>private.shifts_to_parens</identifier>
-
-        <!-- This is the basic mapping. -->
-        <autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::NONE, KeyCode::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L</autogen>
-        <autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_L | ModifierFlag::NONE, KeyCode::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_R</autogen>
-
-        <!--
-            Remap the "rolls" of () and )( because it's too easy to hit one
-            before finishing the other, and there's no other reason to be
-            pressing both shift keys at once anyway
-        -->
-        <autogen>--KeyToKey-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_L</autogen>
-        <autogen>--KeyToKey-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_L, KeyCode::KEY_0, ModifierFlag::SHIFT_L</autogen>
-
-        <!--
-            Remap Rshift+Space to ') ', because when typing an end paren and
-            then a space I tend to hit space before I let go of rshift.
-        -->
-        <autogen>--KeyToKey-- KeyCode::SPACE, ModifierFlag::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L, KeyCode::SPACE</autogen>
-    </item>
-
-As you can see there's actually a bit more to the mapping, because I was finding
-some minor usability glitches in the bare setting.
-
-Occasionally I'll accidentally type a parenthesis when meaning to do something
-else, but it happens so infrequently and the benefits are so great that I'd
-absolutely recommend this to anyone who programs a lot.
-
-Key Layers
-----------
-
-Now we're getting to things that are directly inspired by the Space Cadet
-keyboard.  If you don't type a lot of mathematical characters you may not want
-to bother with these, but since I've been taking the [Introduction to
-Mathematical Thinking][coursera] class on Coursera these bindings have made it
-very pleasant to type out my homework.
-
-[coursera]: https://www.coursera.org/course/maththink
-
-### Greek
-
-The Space Cadet had a separate key for typing Greek letters, and I've decided to
-do the same.  I don't know *exactly* how that modifier key worked, but here's
-how my version works:
-
-* Press and release the "Greek" key to go into "Greek mode" for one character.
-* Type the appropriate Latin letter to get the Greek character for that key
-  (capital letters and lowercase are distinct).
-
-For example, typing `Greek`, then `w` results in ω (omega), while `Greek`, then
-`W` results in Ω (capital omega).
-
-If you want to actually type out full Greek words, this isn't ideal because you
-have to press the `Greek` key between every letter.  But for my purposes
-(variables in math) it's perfect.
-
-There are two parts to implementing this in KeyRemap4MacBook.  First I needed to
-pick a `Greek` key.  I never use the Command, Option, and Control keys to the
-right of Space (another bad habit I should probably fix one day), so I chose the
-right Option key for this.
-
-If you *do* use the modifiers on the right you might prefer to pick a different
-key for this, like `Insert` or `Print Screen`.
-
-Also, since I'm using the Realforce which is a PC keyboard, that key is actually
-called the `PC Application` key.  I'm sure you can figure out how to adjust the
-mapping if necessary.
-
-Here's the first part of the mapping, which binds the `Greek` key:
-
-    :::xml
-    <item>
-        <name>Greek Layer</name>
-        <appendix>Right PC Application key activates the Greek key layer.</appendix>
-
-        <identifier>space_cadet.greek_layer</identifier>
-
-        <autogen>
-            --KeyToKey--
-            KeyCode::PC_APPLICATION,
-            KeyCode::VK_STICKY_EXTRA4
-        </autogen>
-
-I use the virtual modifier key `EXTRA4`.  This key is only intelligible inside
-of KR4MB, but that's not a problem since I do all of the rest of the Greek
-mapping inside there too.
-
-I wrote a little [Python script][cadetpy] to generate the rest of the mapping
-for me.  Here's the Greek layer mapping in its entirety:
-<https://gist.github.com/3824106>
-
-What are all those `Option` modifiers doing in there?  Well there's one more
-step to making this work.  In order to use this mapping you need to switch your
-keyboard layout in OS X to the "Unicode Hex Input" layout under System
-Preferences → Language and Text → Input Sources:
-
-![Switching to Unicode Hex Input](/media/images{{ parent_url }}/kb-hex.png)
-
-As far as I can tell this is exactly like QWERTY except that it also allows you
-to type in Unicode characters directly by holding `Option` and typing in their
-Unicode code point's hex value.  That's how the mapping inserts the Unicode
-characters for the Greek letters.
-
-If you want to do this with another keyboard layout I'm not sure how you could
-do it.  If you find a way let me know and I'll post it here.
-
-However, there's a problem.  The Unicode Hex Input keyboard layout disables OS
-X's `Option-Left` and `Option-Right` keyboard shortcuts for some reason I don't
-even want to try to guess.  Luckily they can be restored with another mapping:
-
-    :::xml
-    <item>
-        <name>Restore [Shift-]Opt-(Left/Right)</name>
-        <appendix>The Unicode Hex Input keyboard layout disables these keys for some reason.</appendix>
-
-        <identifier>space_cadet.fix_opt_arrows</identifier>
-
-        <autogen>
-            --KeyToKey--
-            KeyCode::CURSOR_LEFT, VK_OPTION | VK_SHIFT,
-
-            KeyCode::B,
-            ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
-        </autogen>
-        <autogen>
-            --KeyToKey--
-            KeyCode::CURSOR_LEFT, VK_OPTION,
-
-            KeyCode::B,
-            ModifierFlag::OPTION_L | ModifierFlag::CONTROL_L
-        </autogen>
-        <autogen>
-            --KeyToKey--
-            KeyCode::CURSOR_RIGHT, VK_OPTION | VK_SHIFT,
-
-            KeyCode::F,
-            ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
-        </autogen>
-        <autogen>
-            --KeyToKey--
-            KeyCode::CURSOR_RIGHT, VK_OPTION,
-
-            KeyCode::F,
-            ModifierFlag::OPTION_L | ModifierFlag::CONTROL_L
-        </autogen>
-    </item>
-
-`Option-Delete` is also broken by Unicode Hex Input.  I haven't figured out how
-to fix this, but I don't really care about it because I have the following in my
-`~/Library/KeyBindings/DefaultKeyBinding.dict` file which lets me use
-`Control-w` just like at the command line:
-
-    :::text
-    {
-        "^w"="deleteWordBackward:";
-    }
-
-Welcome to the fiddly rabbit hole of keybinding customization!
-
-The Greek layer in my mapping pretty much matches the original Space Cadet
-mapping as far as I can tell.  Here's a table of the keys and their Greek
-counterparts:
-
-<table>
-    <thead>
-        <tr>
-            <th>Key</th>
-            <th>Alone</th>
-            <th>Shifted</th>
-            <th>Notes</th>
-        </tr>
-    </thead>
-    <tbody>
-        <tr>
-            <td>a</td>
-            <td>α</td>
-            <td>Α</td>
-            <td>Alpha</td>
-        </tr>
-        <tr>
-            <td>b</td>
-            <td>β</td>
-            <td>Β</td>
-            <td>Beta</td>
-        </tr>
-        <tr>
-            <td>c</td>
-            <td>χ</td>
-            <td>Χ</td>
-            <td>Chi</td>
-        </tr>
-        <tr>
-            <td>d</td>
-            <td>δ</td>
-            <td>Δ</td>
-            <td>Delta</td>
-        </tr>
-        <tr>
-            <td>e</td>
-            <td>ε</td>
-            <td>Ε</td>
-            <td>Epsilon</td>
-        </tr>
-        <tr>
-            <td>f</td>
-            <td>φ</td>
-            <td>Φ</td>
-            <td>Phi (p was taken and the ph sounds like an f)</td>
-        </tr>
-        <tr>
-            <td>g</td>
-            <td>γ</td>
-            <td>Γ</td>
-            <td>Gamma</td>
-        </tr>
-        <tr>
-            <td>h</td>
-            <td>η</td>
-            <td>Η</td>
-            <td>Eta</td>
-        </tr>
-        <tr>
-            <td>i</td>
-            <td>ι</td>
-            <td>Ι</td>
-            <td>Iota</td>
-        </tr>
-        <tr>
-            <td>j</td>
-            <td>ϑ</td>
-            <td>Θ</td>
-            <td>Theta (with one of the lowercase variants)</td>
-        </tr>
-        <tr>
-            <td>k</td>
-            <td>κ</td>
-            <td>Κ</td>
-            <td>Kappa</td>
-        </tr>
-        <tr>
-            <td>l</td>
-            <td>λ</td>
-            <td>Λ</td>
-            <td>Lambda (Lisp users rejoice!)</td>
-        </tr>
-        <tr>
-            <td>m</td>
-            <td>μ</td>
-            <td>Μ</td>
-            <td>Mu</td>
-        </tr>
-        <tr>
-            <td>n</td>
-            <td>ν</td>
-            <td>Ν</td>
-            <td>Nu</td>
-        </tr>
-        <tr>
-            <td>o</td>
-            <td>ο</td>
-            <td>Ο</td>
-            <td>Omicron</td>
-        </tr>
-        <tr>
-            <td>p</td>
-            <td>π</td>
-            <td>Π</td>
-            <td>Pi</td>
-        </tr>
-        <tr>
-            <td>q</td>
-            <td>θ</td>
-            <td>Θ</td>
-            <td>Theta (with the other lowercase variant)</td>
-        </tr>
-        <tr>
-            <td>r</td>
-            <td>ρ</td>
-            <td>Ρ</td>
-            <td>Rho</td>
-        </tr>
-        <tr>
-            <td>s</td>
-            <td>σ</td>
-            <td>Σ</td>
-            <td>Sigma (with one of the lowercase variants)</td>
-        </tr>
-        <tr>
-            <td>t</td>
-            <td>τ</td>
-            <td>Τ</td>
-            <td>Tau</td>
-        </tr>
-        <tr>
-            <td>u</td>
-            <td>υ</td>
-            <td>Υ</td>
-            <td>Upsilon</td>
-        </tr>
-        <tr>
-            <td>v</td>
-            <td>ς</td>
-            <td>Σ</td>
-            <td>Sigma (with the other lowercase variant)</td>
-        </tr>
-        <tr>
-            <td>w</td>
-            <td>ω</td>
-            <td>Ω</td>
-            <td>Omega (o was taken and the lowercase kind of looks like a w)</td>
-        </tr>
-        <tr>
-            <td>x</td>
-            <td>ξ</td>
-            <td>Ξ</td>
-            <td>Xi</td>
-        </tr>
-        <tr>
-            <td>y</td>
-            <td>ψ</td>
-            <td>Ψ</td>
-            <td>Psi (p was taken and it looks a bit like a y)</td>
-        </tr>
-        <tr>
-            <td>z</td>
-            <td>ζ</td>
-            <td>Ζ</td>
-            <td>Zeta</td>
-        </tr>
-    </tbody>
-</table>
-
-[cadetpy]: https://github.com/sjl/dotfiles/blob/master/keyremap4macbook/cadet.py
-
-### Math
-
-The Space Cadet also had a `Top` key for typing the symbols on the top of the
-keys, which were (I think) used in APL.  I don't use APL, but when typing out
-mathematical text it would be nice to have some symbols easily available.
-
-I've added a Math layer that functions similarly to the Greek layer.  I chose
-the right `Control` key to activate it.  I won't go into detail about how it
-works because it's the same as the Greek layer.  Here's the code for it if you
-want to use it yourself: <https://gist.github.com/3824109>
-
-I've currently only filled in the Math layer with keys I find useful, so there
-are a lot of empty keys at the moment.  I plan to add new ones as I discover
-I want them.
-
-<table>
-    <thead>
-        <tr>
-            <th>Key</th>
-            <th>Alone</th>
-            <th>Shifted</th>
-            <th>Notes</th>
-        </tr>
-    </thead>
-    <tbody>
-        <tr>
-            <td>a</td>
-            <td>∧</td>
-            <td>ℵ</td>
-            <td>And, Aleph</td>
-        </tr>
-        <tr>
-            <td>b</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>c</td>
-            <td>∘</td>
-            <td>ℂ</td>
-            <td>Composition, Complex numbers</td>
-        </tr>
-        <tr>
-            <td>d</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>e</td>
-            <td>∈</td>
-            <td>∉</td>
-            <td>Element of, Not element of</td>
-        </tr>
-        <tr>
-            <td>f</td>
-            <td>∫</td>
-            <td></td>
-            <td>Integral (i was taken and it looks like an f)</td>
-        </tr>
-        <tr>
-            <td>g</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>h</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>i</td>
-            <td>∩</td>
-            <td>∞</td>
-            <td>Intersection, Infinity</td>
-        </tr>
-        <tr>
-            <td>j</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>k</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>l</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>m</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>n</td>
-            <td></td>
-            <td>ℕ</td>
-            <td>Natural numbers</td>
-        </tr>
-        <tr>
-            <td>o</td>
-            <td>∨</td>
-            <td></td>
-            <td>Or</td>
-        </tr>
-        <tr>
-            <td>p</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>q</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>r</td>
-            <td>√</td>
-            <td>ℝ</td>
-            <td>Root, Real numbers</td>
-        </tr>
-        <tr>
-            <td>s</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>t</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>u</td>
-            <td>∪</td>
-            <td></td>
-            <td>Union</td>
-        </tr>
-        <tr>
-            <td>v</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>w</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>x</td>
-            <td>⊻</td>
-            <td></td>
-            <td>Xor</td>
-        </tr>
-        <tr>
-            <td>y</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>z</td>
-            <td></td>
-            <td>ℤ</td>
-            <td>Integers</td>
-        </tr>
-        <tr>
-            <td>-</td>
-            <td>¬</td>
-            <td></td>
-            <td>Not (looks like a minus)</td>
-        </tr>
-        <tr>
-            <td>=</td>
-            <td>≠</td>
-            <td>±</td>
-            <td>Not equal, Plus or minus (<code>Shift-=</code> is normally +)</td>
-        </tr>
-        <tr>
-            <td>/</td>
-            <td>÷</td>
-            <td></td>
-            <td>Division</td>
-        </tr>
-        <tr>
-            <td>,</td>
-            <td></td>
-            <td>≤</td>
-            <td>Less than or equal to (<code>Shift-,</code> is normally &lt;)</td>
-        </tr>
-        <tr>
-            <td>.</td>
-            <td></td>
-            <td>≥</td>
-            <td>Greater than or equal to (<code>Shift-.</code> is normally &gt;)</td>
-        </tr>
-        <tr>
-            <td>1</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>2</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>3</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>4</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>5</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>6</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>7</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>8</td>
-            <td></td>
-            <td>×</td>
-            <td>Times or cross product (<code>Shift-8</code> is normally *)</td>
-        </tr>
-        <tr>
-            <td>9</td>
-            <td></td>
-            <td></td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>0</td>
-            <td>∅</td>
-            <td></td>
-            <td>Null set</td>
-        </tr>
-        <tr>
-            <td>`</td>
-            <td></td>
-            <td>≈</td>
-            <td>Approximately equal to (<code>Shift-`</code> is normally ~)</td>
-        </tr>
-        <tr>
-            <td>[</td>
-            <td>⊂</td>
-            <td>⊄</td>
-            <td>Proper subset of, Not proper subset of</td>
-        </tr>
-        <tr>
-            <td>]</td>
-            <td>⊃</td>
-            <td>⊅</td>
-            <td>Proper superset of, Not proper superset of</td>
-        </tr>
-        <tr>
-            <td>Left</td>
-            <td>←</td>
-            <td>↚</td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>Right</td>
-            <td>→</td>
-            <td>↛</td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>Up/Down</td>
-            <td>↔</td>
-            <td>↮</td>
-            <td></td>
-        </tr>
-    </tbody>
-</table>
-
-In addition, the last five rows also support the `Control` key for more
-variants:
-
-<table>
-    <thead>
-        <tr>
-            <th>Key</th>
-            <th>Ctrl</th>
-            <th>Ctrl-Shifted</th>
-            <th>Notes</th>
-        </tr>
-    </thead>
-    <tbody>
-        <tr>
-            <td>[</td>
-            <td>⊆</td>
-            <td>⊈</td>
-            <td>Subset of, Not subset of</td>
-        </tr>
-        <tr>
-            <td>]</td>
-            <td>⊇</td>
-            <td>⊉</td>
-            <td>Superset of, Not superset of</td>
-        </tr>
-        <tr>
-            <td>Left</td>
-            <td>⇐</td>
-            <td>⇍</td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>Right</td>
-            <td>⇒</td>
-            <td>⇏</td>
-            <td></td>
-        </tr>
-        <tr>
-            <td>Up/Down</td>
-            <td>⇔</td>
-            <td>⇎</td>
-            <td></td>
-        </tr>
-    </tbody>
-</table>
-
-Conclusion
-----------
-
-If you want my full KeyRemap4MacBook configuration you can always get [the
-latest version from my dotfiles][dotkr].
-
-I've done some crazy, fiddly things to my machine.  Undoubtedly lots of people
-on Hacker News will scoff and brag about how they only use the defaults.
-I don't really care.  Given that I spend 60 hours or more a week at the keyboard
-if these things only save me 0.01% of my time they'll pay for themselves in
-a year or two.  Not to mention all the finger pain they'll prevent.  Plus,
-tinkering around and seeing how far you can push things is fun (sometimes)!
-
-I'm pretty satisfied with my hardware and layout.  My dream would be to get
-a custom keycap set with my key labels and the Space Cadet colors/typography
-that would fit on a white Realforce.  It would be absolutely beautiful, but I'm
-sure it'd be far too expensive to make a single custom set.  Oh well, maybe some
-day!
-
-[dotkr]: https://github.com/sjl/dotfiles/blob/master/keyremap4macbook/private.xml
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/10/a-modern-space-cadet.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,1307 @@
++++
+title = "A Modern Space Cadet"
+snip = "Emulating a legendary keyboard."
+date = 2012-10-03T09:55:00Z
+draft = false
+
++++
+
+I spend a lot of my time (easily over 8 hours a day) at a keyboard.  As you
+might have guessed from my previous entries about [Vim][] and [Mutt][] I'm not
+averse to spending a few hours to improve an environment I'm going to be
+spending tens of thousands of hours in over the next few years, so it shouldn't
+be a shock that my keyboard is something I've heavily tweaked.
+
+This post is about what I've done to make my typing experience more pleasant and
+efficient.
+
+If you scoff at customization you won't enjoy this post.  What if I have to use
+someone else's machine?  I can count on one hand the number of times I've had to
+use someone else's machine ever since I got an iPhone five years ago.  I *like*
+customizing my machine to save me time.  Yes, there may be some excessive stuff
+here, but not only does it make me type faster, it's *fun*!
+
+{{% toc %}}
+
+[Vim]: /blog/2010/09/coming-home-to-vim/
+[Mutt]: /blog/2012/10/the-homely-mutt/
+
+The Original
+------------
+
+There have been many, many keyboards produced in the world since the first ones
+emerged.  One of the most famous, at least in programming circles, is the [Space
+Cadet Keyboard][space-cadet].
+
+Originally used on Lisp machines and some other systems, it's not a keyboard for
+the minimalist.  There are four "bucky keys" (modifier keys): control, meta,
+super, and hyper (plus shift, of course).  There are also special keys that let
+you type Greek letters and mathematical symbols.
+
+The Space Cadet is an example of a keyboard for someone not afraid to invest
+some time to work faster.
+
+It's also absolutely gorgeous.  The color scheme and typography is beautiful.
+
+This is the keyboard I used (loosely) as inspiration when crafting my current
+setup.
+
+[space-cadet]: http://world.std.com/~jdostale/kbd/SpaceCadet.html
+
+Modern Hardware
+---------------
+
+I've tried a number of modern keyboards in the past few years.  They're all
+high-quality and more expensive than the $20 plastic toys that come with
+desktops.  But I spend 60 or more hours a week at a keyboard and maybe one hour
+a week in my car, so I'm getting pretty good use out of the dollars I've put
+into keyboards if you compare them to the cost of my car!
+
+I'll go through the keyboards I've used in chronological order.  I'm not going
+to write too much about the basics of mechanical keyboards and switches.  If you
+want to learn about that, [this post][ch] and [this guide][mech] are good places
+to start.
+
+[ch]: http://www.codinghorror.com/blog/2010/10/the-keyboard-cult.html
+[mech]: http://www.overclock.net/t/491752/mechanical-keyboard-guide
+
+### Apple Wireless Keyboard
+
+For a long time I used [Apple wireless keyboards][apple-wireless].
+
+![Apple Wireless Keyboard](/media/images/blog/2012/10/kb-apple.jpg)
+
+They're light and compact, but still feel extremely solid thanks to their metal
+construction.
+
+They also stay really clean because there gaps between keys are tiny, instead of
+the funnel-shaped gaps of other keyboard that send dirt straight to the bottom. 
+
+They're readily available at any Apple store, and of course they're wireless
+which is great.
+
+They also feel exactly like the keyboards on Apple's laptops, so your muscle
+memory is perfectly suited to either one if you switch between them often.
+
+Unfortunately typing on them is nowhere near as nice as the rest of the
+keyboards in this list.  Apple keyboards have (I think) only 2mm of travel, but
+you have to bottom-out the keys to register the keypresses.
+
+[apple-wireless]: http://www.apple.com/keyboard/
+
+### Das Silent Ultimate
+
+The first mechanical keyboard I got was the [Das Silent Ultimate][das-silent].
+
+![Das Silent Keyboard](/media/images/blog/2012/10/kb-das.jpg)
+
+(This photo is actually my Das Clicky since I don't have the Silent any more,
+but they're exactly the same externally.)
+
+Compared to the Apple keyboards the switches on the Das Silent (Cherry Brown
+switches) feel far softer.  You're not smashing your fingers against metal on
+every keypress.
+
+Overall the Das Silent isn't too bad.  It's built like a tank so I have no doubt
+it'd last forever.  It also has the option of blank keys, which I prefer.
+
+I didn't stick with this keyboard for long.  First, its glossy finish looks good
+when it's in the box and terrible forever after that.  It's way too easy to get
+dirty.
+
+Something also just feels "off" about the key switches to me, especially after
+I've tried the other boards in this list.  They feel, for lack of a better term,
+"mushy" to me.
+
+[das-silent]: http://www.daskeyboard.com/model-s-ultimate-silent/
+
+### Das Clicky Ultimate
+
+The next keyboard I tried was the [Das Clicky Ultimate][das-clicky].
+
+![Das Clicky Keyboard](/media/images/blog/2012/10/kb-das.jpg)
+
+This is exactly the same as the Das Silent except for the switches, which are
+the "clicky" Cherry Blues.  These feel *way* better to me than the browns.  The
+mushiness I described for the Silent is completely gone.
+
+They are not kidding when they say it is loud.  If you're typing a lot expect to
+have a constant background noise of clicks.  But to me the sound is soothing,
+especially once you get into a rhythm of typing for extended periods.  Your
+coworkers might disagree, so tread carefully.
+
+The Das Clicky still has that godawful glossy finish, unfortunately.  After
+a while I decided to try out what I had heard people raving about: Topre
+switches.
+
+[das-clicky]: http://www.daskeyboard.com/model-s-ultimate/
+
+### Happy Hacking Keyboard Professional 2
+
+The [Happy Hacking Keyboard][hhkb] was my next keyboard.  It's much more
+expensive than the Dases were, so it was a tough call, but I'm glad I got it.
+
+![Happy Hacking Keyboard](/media/images/blog/2012/10/kb-hhkb.jpg)
+
+The HHKB uses Topre key switches, which to me feel like Cherry Browns done
+right.  There's no "click" like the Blues, but instead of the mush of the
+Browns you get a satisfying "thunk" or "sshhhunk" on each press.  It's a great
+balance: you have a nice satisfying sound that's less annoying for other people.
+
+The finish on this keyboard is perfect.  It is the most unassuming, elegant,
+wonderful matte finish I've seen on any keyboard.  The plastic is just textured
+enough to feel solid under your fingers (not slippery like Macbook keys) but not
+enough to feel like you're typing on sandpaper.
+
+If you're short on space, or want to carry your keyboard with you, the HHKB is
+for you.  It's *tiny*, but still feels solid and not flimsy at all.
+
+I have two main complaints about the HHKB.  First, there's two spaces on the
+bottom row where they could have put a modifier key but didn't.  The space on
+the right has the logo, which is fair enough, but the one on the left is simply
+blank for no good reason.
+
+My other complaint is the idiotic default placement of the `fn` key and the
+arrow keys.  I don't mind having to use `fn` to get to the arrows as
+a concession to a compact design, but why on earth would you place them so that
+you have to chord on a *single hand* to hit them?
+
+This problem would be completely solved if the `fn` key were moved from its
+current position (right of the right shift key) down to the empty lower-left
+corner.  Then you could use your left hand to hold `fn` while your right worked
+the arrow keys, no single-hand contortion required.
+
+So after a while with the HHKB I got sick of the arrow key problem.  I loved the
+Topre switches though, so the next choice was pretty obvious.
+
+[hhkb]: http://elitekeyboards.com/products.php?sub=pfu_keyboards,hhkbpro2&pid=pdkb400bn
+
+### Topre Realforce 103
+
+The Topre Realforce 103UB was my next keyboard, and is the one I'm
+still using to this day.
+
+![Topre Realforce Keyboard](/media/images/blog/2012/10/kb-realforce.jpg)
+
+I believe the model I bought is now discontinued, but it's been replaced by the
+[104UB][topre] which is exactly the same except for an extra key on the right
+side.  If I could swap my current keyboard for one of those I would.  In fact,
+if anyone wants to buy my used 103UB for a bit of a discount I'd be totally
+willing to sell it to get the 104UB.
+
+Anyway, this keyboard has a few disadvantages.  First, unlike every other
+keyboard here (except the wireless Apple ones) *it is not a USB hub*.  This
+isn't a huge deal (I have external USB hubs), but it did come as a big surprise.
+
+Second, it's big.  Really big.  If you don't have *plenty* of room on your desk
+you might want to look at the [tenkeyless][topre-tenkeyless] varieties which
+ditch the number pad section to save space.  I have room and I love having
+a number pad, so I got the behemoth-sized model.
+
+Also for some reason I can't fathom there's no way to get blank, black keycaps
+for this keyboard.  You can get blank Topre keycaps in lime green, pink, yellow,
+and lots of other colors, but not a simple black!
+
+Now for the good parts.  This thing is built like a tank.  If you needed to
+defend your home from an intruder, it would make an acceptable blunt weapon with
+which to do so (and you'd probably be able to plug it right back in and start
+typing again).
+
+The finish is the same as on the HHKB (gorgeous), but I have to take a point off
+for the non-blank keycaps.  I don't need to look at the keys while I type, so
+why marr the luxurious finish with lettering?
+
+The Realforce also uses Topre switches, but it has another trick up its sleeve
+that makes typing on it even nicer than the HHKB.  The version I have is the
+"variable-weighted" one, which means that the keys under your weaker fingers
+take less force to press than the ones under your stronger fingers.  This is
+fantastic for long sessions of typing.  Instead of my pinkies getting tired my
+fingers seem to all tire out at the same rate now.  Topre does make a "uniform"
+version that doesn't have this trick, but I really like variable weight keys
+myself.
+
+[topre]: http://elitekeyboards.com/products.php?sub=topre_keyboards,rf104&pid=xf11t0
+[topre-tenkeyless]: http://elitekeyboards.com/products.php?sub=topre_keyboards,rftenkeyless
+
+### Verdict
+
+Right now I'm using the Topre Realforce for my day to day work.  I've fallen in
+love with how the Topre switches feel (I prefer them over all the others except
+*maybe* the Cherry Blues for the sound) and the Happy Hacking Keyboard is just
+too cramped.  If I were short on space the HHKB would be great, but I have
+plenty of room on my desk, so why not make use of it?
+
+Here's a photo of all the keyboards (along with a 13" Macbook Air) so you can
+see the differences in size.
+
+![Keyboard Size Comparison](/media/images/blog/2012/10/kb-size.jpg)
+
+Modern Software
+---------------
+
+Now that I've talked about the hardware it's time for the software.  I use OS
+X exclusively, so everything I say here is OS X specific.  I'm sure there are
+Windows and Linux equivalents somewhere though.
+
+I use three software programs that, together, give me just about unlimited
+flexibility in customizing how my keyboard works in OS X.
+
+### Keyboard Maestro
+
+[Keyboard Maestro][] is a utility for binding macros to keyboard shortcuts in OS
+X.  It may not have the best user interface, but it can do a *lot*, and once you
+set up your shortcuts you never have to look at it again.  It's $36.
+
+Right now I use it for application switching, with a few twists I'll cover later
+on.
+
+I switched to [Keymando][] for a while.  It was great being able to configure it
+in a programming language with a plain text file I could easily work with in
+version control, but compared to Keyboard Maestro it's far slower and far
+buggier.  I'm now back to only using Keyboard Maestro.
+
+[Keyboard Maestro]: http://www.keyboardmaestro.com/main/
+[Keymando]: http://keymando.com/
+
+### PCKeyboardHack
+
+[PCKeyboardHack][] lets you map one key on your keyboard to another at a very
+low level.  For example, you can change just the right Option key to send `F19`
+instead.  I use this for one single key which you'll see in the next section.
+It's free and [open source][pc-git].
+
+[PCKeyboardHack]: http://pqrs.org/macosx/keyremap4macbook/pckeyboardhack.html.en
+[pc-git]: https://github.com/tekezo/PCKeyboardHack
+
+### KeyRemap4MacBook
+
+[KeyRemap4MacBook][] is how I do the bulk of my keyboard customizations.  Like
+all of the other applications its user interface is horrible, but it can do damn
+near *anything* you might want.  You could probably replace Keyboard Maestro
+with it, at least for the kind of stuff I do.  It's also free and [open
+source][kr-git].
+
+The bulk of what I describe in this post is going to use KeyRemap4MacBook.  I'm
+not going to give you a tutorial in it here — read its documentation if you
+want to learn how to use the things I'm going to show.
+
+[KeyRemap4MacBook]: http://pqrs.org/macosx/keyremap4macbook/index.html.en
+[kr-git]: https://github.com/tekezo/KeyRemap4MacBook
+
+Control/Escape
+--------------
+
+These first few mappings aren't directly from the Space Cadet keyboard, but they
+were inspired by its spirit of making an efficient tool for text editing.
+
+The Capslock key on modern keyboard has become the punchline of many a joke, and
+for good reason: there's no reason to dedicate such an important key to
+a function like capslock.  Many people rebind it to a more useful key like
+Control, Option, Escape, or Backspace.  I rebound it to Control for a while and
+then realized that with KeyRemap4MacBook I could get even more mileage out of
+it.
+
+The important thing I thought of one day is that it's possible to divide keys on
+the keyboard into three groups:
+
+* Keys you hold down to change how *other* keys behave, but that (usually) don't
+  do anything if you use them on their own (like Shift and Control).
+* Keys that you press and release but don't want to "repeat" as you hold them
+  (like Escape or Insert).
+* Keys that you sometimes press and release, but sometimes want to repeat (like
+  holding Space to insert a bunch of spaces, or Backspace to kill a bunch of
+  characters).
+
+Can you see where this is heading?  The last group is pretty normal, but the
+first two groups are special.  Specifically: there are two different ways to use
+them and they're each only useful in one of those ways.
+
+This means that we can *combine* them onto a single key without losing any
+useful functionality!
+
+I'm clearly not the first one to think of this, because KR4MB includes built-in
+support for creating these kinds of mappings.
+
+First I've mapped Capslock to Control at the OS X level by going into the
+Keyboard preference pane in System Preferences, clicking the Modifier Keys
+button in the lower right, selecting the keyboard in the dropdown list (this is
+surprisingly easy to miss), and changing the Capslock setting:
+
+![Changing Capslock to Control in OS X](/media/images/blog/2012/10/kb-caps.png)
+
+Then I've selected the following premade option in KeyRemap4MacBook:
+
+> Control\_L to Control\_L  
+> (+ when you type Control\_L only, send Escape)
+
+Now the Capslock key on the keyboard does the following:
+
+1. If held down and pressed with another key, it acts like Control.
+2. If pressed and released on its own, it acts like Escape.
+
+That's two extremely important keys (at least for Vim users) on a single key in
+one of the prime locations on the keyboard!  No more awkward stretches!
+
+If you try this and want to force yourself to learn to use it, disable the
+normal escape key.  You'll learn fast.
+
+**Update:** I forgot to mention that if you use this (and the Shift
+improvements below) you'll probably want to change the "\[Key Overlaid
+Modifier\] Timeout" setting in the KR4MB preferences:
+
+![Key Overlaid Timeout](/media/images/blog/2012/10/kb-key-overlaid.png)
+
+This setting controls the maximum length of a keypress that will register as
+"single press".  It's easier to understand with an example.  The default is
+1000ms, which means that if you press and hold the Capslock key for 900ms and
+release it, it will count as Escape.  If you hold it for 1001ms before
+releasing, it counts as pressing and releasing Control instead.
+
+If you're finding that you're sometimes holding Control out of habit and then
+releasing it, but it's still firing as an Escape, you may want to turn this
+setting down to a lower value.  I have mine set to 300ms.
+
+This is a lot more noticeable with the Shift mappings I'll describe shortly, so
+keep it in the back of your mind if you try those out.
+
+Hyper
+-----
+
+Modern OS X supports four "modifier" keys: Control, Option, Command, and Shift.
+The Space Cadet keyboard had five: Control, Meta, Super, Hyper, and Shift.
+
+Shift and Control map to each other, and OS X's Option key is pretty much the
+same as Meta (in fact I think Emacs users usually use Alt as Meta).
+I arbitrarily decided that Command was the OS X equivalent of Super.  That left
+Hyper.
+
+Since OS X doesn't natively support a fifth modifier key I had to come up with
+a way to fake it.
+
+First, I realized that because I use Capslock for Control I had no use for the
+*real* left Control key.  So the first step was to remap that to something else
+distinct from the Capslock-version of Control.
+
+This required PCKeyboardHack.  I don't think there's a way to do it in
+KeyRemap4MacBook, because by the time KR4MB sees the keypress it can't tell if
+it came from the Capslock key or the real Control key (due to how they were
+changed in the previous section).  PCKeyboardHack, however, *can*, so I remapped
+left Control to keycode `80`:
+
+![Remapping Left Control in PCKeyboardHack](/media/images/blog/2012/10/kb-pck.png)
+
+Keycode `80` is the `F19` key.  My keyboard doesn't have an `F19` key so it
+doesn't conflict with anything.  Now I can simply remap `F19` in KR4MB just like
+any other key.
+
+To create a "pseudo-Hyper" modifier, I remapped this key to be the equivalent of
+holding down *all four other modifiers* by adding the following to my
+`private.xml` KR4MB configuration file:
+
+```xml
+<item>
+    <name>Remap Left Control to Hyper</name>
+    <appendix>OS X doesn't have a Hyper. This maps Left Control to Control + Shift + Option + Command.</appendix>
+
+    <identifier>space_cadet.left_control_to_hyper</identifier>
+
+    <autogen>
+        --KeyToKey--
+        KeyCode::F19,
+
+        KeyCode::COMMAND_L,
+        ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
+    </autogen>
+</item>
+```
+
+As far as I can tell, no keyboard shortcuts in OS X or any apps use all four
+modifier keys (how would you normally press them all, anyway?).  But many
+programs, like Keyboard Maestro, let you define your own shortcuts.  So now I've
+got an entire key as a "namespace" all to myself for my own shortcuts!
+
+This is really nice.  I don't have to worry about "shadowing" existing shortcuts
+anywhere and it's only a single modifier to press.
+
+Currently I use this "namespace" for application switching.  Instead of using
+the normal `Command-Tab` switcher, I have shortcuts for each individual app
+I use frequently.  For example, `Hyper-k` switches to Firefox, `Hyper-y`
+switches to Twitter, and so on.  This is better than `Command-Tab`ing because
+I don't have to worry about how many times I need to press it.  `Hyper-k`
+*always* goes to Firefox no matter what, so I can easily burn that into my
+muscle memory.
+
+There's one more little trick I use in Keyboard Maestro.  It's specific to how
+I work, but I'm sure some of you will still find it handy.
+
+I pretty much always keep two iTerm 2 windows open.  The first contains
+a [tmux][] session with one window split into two panes.  One pane holds
+[weechat][weechat-prog] for IRC, the other holds [Mutt][mutt-prog] for email.
+I keep this on my laptop screen at all times while I do other things on my
+external monitor.
+
+The second iTerm window is almost always fullscreened, and contains a tmux
+session with whatever I'm working on.  The number of windows and panes varies
+wildly.
+
+What I wanted was a way to bind `Hyper-i` and `Hyper-m` to directly focus my IRC
+and mail panes, and `Hyper-j` to directly focus the second, "general-purpose"
+iTerm window.
+
+The solution came in two parts.  First I configured tmux so that `prefix N`
+would select the nth pane in the current window by adding the following to
+`~/.tmux.conf`:
+
+```text
+bind 1 select-pane -t 1
+bind 2 select-pane -t 2
+bind 3 select-pane -t 3
+bind 4 select-pane -t 4
+bind 5 select-pane -t 5
+bind 6 select-pane -t 6
+bind 7 select-pane -t 7
+bind 8 select-pane -t 8
+bind 9 select-pane -t 9
+```
+
+My tmux prefix is `Control-f`, so now pressing `Control-f 1` will go to pane 1,
+and so on.  Then I configured Keyboard Maestro like so:
+
+![Keyboard Maestro IRC Config](/media/images/blog/2012/10/kb-irc.png)
+
+This binds `Control-Shift-Option-Command-i` (which is just `Hyper-i`) to do the
+following:
+
+1. Focus iTerm 2.
+2. Send a `Command-Option-1` keystroke, which will focus the first iTerm
+   2 window (I simply make sure I always open my mail/irc window first).
+3. Send the `Control-f` keystroke.
+3. Send the `1` keystroke, which together with the previous one tells tmux to
+   switch to pane 1.
+
+The mail shortcut is similar, of course, and the general-purpose terminal one is
+even simpler.
+
+So now I've got a free modifier key that won't conflict with anything, and I've
+got some very easy-to-type shortcuts I can burn into my fingers for switching
+applications quickly.  Awesome.
+
+[tmux]: http://tmux.sourceforge.net/
+[weechat-prog]: http://www.weechat.org/
+[mutt-prog]: http://www.mutt.org/
+
+Better Shifting
+---------------
+
+The Shift keys are another of those keys that are only useful with other keys,
+so it's only natural that they were also on the list of keys to optimize.
+First, however, I took a detour to correct a bad habit of mine.
+
+### Shift Key Training Wheels
+
+I've been typing for most of my life, but I never really learned to do it
+correctly.  I can touch type, of course, but sometimes I use the wrong fingers
+for certain keys.
+
+My most egregious offense was that I always used the left Shift key.  Even when
+typing `X` I'd hold the left Shift key with my left pinky and hit the `x` with
+my left index finger, which pulled my hand off the home row and generally felt
+awkward.
+
+One day I decided I was tired of doing this the wrong way and resolved to fix
+myself.  The easiest way to break a bad habit is to make it harder or impossible
+to do, so I created a custom KeyRemap4MacBook setting that *disables* the
+keypress when you use the incorrect Shift key with a letter.  Here it is in
+full:
+
+```xml
+<item>
+    <name>Use the correct shift keys.</name>
+    <identifier>private.correct_shift_keys</identifier>
+
+    <autogen>--KeyToKey-- KeyCode::Q, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::W, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::E, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::R, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::T, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::A, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::S, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::D, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::F, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::G, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::Z, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::X, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::C, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::V, ModifierFlag::SHIFT_L, KeyCode::VK_NONE</autogen>
+
+    <autogen>--KeyToKey-- KeyCode::Y,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::U,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::I,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::O,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::P,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::H,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::J,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::K,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::L,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::SEMICOLON, ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::N,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::M,         ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::COMMA,     ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::DOT,       ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+    <autogen>--KeyToKey-- KeyCode::QUOTE,     ModifierFlag::SHIFT_R, KeyCode::VK_NONE</autogen>
+</item>
+```
+
+It took me about four hours of normal computer use to unlearn over two decades
+of wrong typing.  It's amazing how fast muscle memory can adjust when you simply
+*force* it to.
+
+Once I fixed myself I disabled this setting, because it also makes you to use
+the "correct" Shift key when doing keyboard shortcuts, and sometimes those are
+easer to do with the "wrong" Shift.
+
+If you only use one Shift key I'd really encourage you to try this.  It spreads
+out the wear over both pinkies and feels much better.  Your hands will thank
+you.
+
+### Shift Parentheses
+
+Now that I was using the right Shift keys, it was time to revisit mapping
+something else onto them.  One pair of keys stood out as a perfect candidate: the
+left and right parentheses.
+
+Parentheses are common in most of the programming languages in use today (some
+more than others).  If you counted I bet you'd find them more common than square
+or curly brackets in the majority of your code, and yet they're shoved away in
+the horrible homes of `Shift-9` and `Shift-0`.
+
+I decided to try out remapping my Shift keys to work like so:
+
+* When held while pressing other keys, act like Shift.
+* When pressed and released on their own, type an opening or closing parenthesis
+  (left and right shift respectively).
+
+This means I can type parentheses with a single, unchorded keypress.  After
+using it for a while I absolutely love it.  Here's the KeyRemap4MacBook setting
+for it:
+
+```xml
+<item>
+    <name>Shifts to Parentheses</name>
+    <appendix>Shifts, when pressed alone, type parentheses.  When used with other keys they're normal shifts.</appendix>
+
+    <identifier>private.shifts_to_parens</identifier>
+
+    <!-- This is the basic mapping. -->
+    <autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_R | ModifierFlag::NONE, KeyCode::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L</autogen>
+    <autogen>--KeyOverlaidModifier-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_L | ModifierFlag::NONE, KeyCode::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_R</autogen>
+
+    <!--
+        Remap the "rolls" of () and )( because it's too easy to hit one
+        before finishing the other, and there's no other reason to be
+        pressing both shift keys at once anyway
+    -->
+    <autogen>--KeyToKey-- KeyCode::SHIFT_L, ModifierFlag::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_L</autogen>
+    <autogen>--KeyToKey-- KeyCode::SHIFT_R, ModifierFlag::SHIFT_L, KeyCode::KEY_9, ModifierFlag::SHIFT_L, KeyCode::KEY_0, ModifierFlag::SHIFT_L</autogen>
+
+    <!--
+        Remap Rshift+Space to ') ', because when typing an end paren and
+        then a space I tend to hit space before I let go of rshift.
+    -->
+    <autogen>--KeyToKey-- KeyCode::SPACE, ModifierFlag::SHIFT_R, KeyCode::KEY_0, ModifierFlag::SHIFT_L, KeyCode::SPACE</autogen>
+</item>
+```
+
+As you can see there's actually a bit more to the mapping, because I was finding
+some minor usability glitches in the bare setting.
+
+Occasionally I'll accidentally type a parenthesis when meaning to do something
+else, but it happens so infrequently and the benefits are so great that I'd
+absolutely recommend this to anyone who programs a lot.
+
+Key Layers
+----------
+
+Now we're getting to things that are directly inspired by the Space Cadet
+keyboard.  If you don't type a lot of mathematical characters you may not want
+to bother with these, but since I've been taking the [Introduction to
+Mathematical Thinking][coursera] class on Coursera these bindings have made it
+very pleasant to type out my homework.
+
+[coursera]: https://www.coursera.org/course/maththink
+
+### Greek
+
+The Space Cadet had a separate key for typing Greek letters, and I've decided to
+do the same.  I don't know *exactly* how that modifier key worked, but here's
+how my version works:
+
+* Press and release the "Greek" key to go into "Greek mode" for one character.
+* Type the appropriate Latin letter to get the Greek character for that key
+  (capital letters and lowercase are distinct).
+
+For example, typing `Greek`, then `w` results in ω (omega), while `Greek`, then
+`W` results in Ω (capital omega).
+
+If you want to actually type out full Greek words, this isn't ideal because you
+have to press the `Greek` key between every letter.  But for my purposes
+(variables in math) it's perfect.
+
+There are two parts to implementing this in KeyRemap4MacBook.  First I needed to
+pick a `Greek` key.  I never use the Command, Option, and Control keys to the
+right of Space (another bad habit I should probably fix one day), so I chose the
+right Option key for this.
+
+If you *do* use the modifiers on the right you might prefer to pick a different
+key for this, like `Insert` or `Print Screen`.
+
+Also, since I'm using the Realforce which is a PC keyboard, that key is actually
+called the `PC Application` key.  I'm sure you can figure out how to adjust the
+mapping if necessary.
+
+Here's the first part of the mapping, which binds the `Greek` key:
+
+```xml
+<item>
+    <name>Greek Layer</name>
+    <appendix>Right PC Application key activates the Greek key layer.</appendix>
+
+    <identifier>space_cadet.greek_layer</identifier>
+
+    <autogen>
+        --KeyToKey--
+        KeyCode::PC_APPLICATION,
+        KeyCode::VK_STICKY_EXTRA4
+    </autogen>
+```
+
+I use the virtual modifier key `EXTRA4`.  This key is only intelligible inside
+of KR4MB, but that's not a problem since I do all of the rest of the Greek
+mapping inside there too.
+
+I wrote a little [Python script][cadetpy] to generate the rest of the mapping
+for me.  Here's the Greek layer mapping in its entirety:
+<https://gist.github.com/3824106>
+
+What are all those `Option` modifiers doing in there?  Well there's one more
+step to making this work.  In order to use this mapping you need to switch your
+keyboard layout in OS X to the "Unicode Hex Input" layout under System
+Preferences → Language and Text → Input Sources:
+
+![Switching to Unicode Hex Input](/media/images/blog/2012/10/kb-hex.png)
+
+As far as I can tell this is exactly like QWERTY except that it also allows you
+to type in Unicode characters directly by holding `Option` and typing in their
+Unicode code point's hex value.  That's how the mapping inserts the Unicode
+characters for the Greek letters.
+
+If you want to do this with another keyboard layout I'm not sure how you could
+do it.  If you find a way let me know and I'll post it here.
+
+However, there's a problem.  The Unicode Hex Input keyboard layout disables OS
+X's `Option-Left` and `Option-Right` keyboard shortcuts for some reason I don't
+even want to try to guess.  Luckily they can be restored with another mapping:
+
+```xml
+<item>
+    <name>Restore [Shift-]Opt-(Left/Right)</name>
+    <appendix>The Unicode Hex Input keyboard layout disables these keys for some reason.</appendix>
+
+    <identifier>space_cadet.fix_opt_arrows</identifier>
+
+    <autogen>
+        --KeyToKey--
+        KeyCode::CURSOR_LEFT, VK_OPTION | VK_SHIFT,
+
+        KeyCode::B,
+        ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
+    </autogen>
+    <autogen>
+        --KeyToKey--
+        KeyCode::CURSOR_LEFT, VK_OPTION,
+
+        KeyCode::B,
+        ModifierFlag::OPTION_L | ModifierFlag::CONTROL_L
+    </autogen>
+    <autogen>
+        --KeyToKey--
+        KeyCode::CURSOR_RIGHT, VK_OPTION | VK_SHIFT,
+
+        KeyCode::F,
+        ModifierFlag::OPTION_L | ModifierFlag::SHIFT_L | ModifierFlag::CONTROL_L
+    </autogen>
+    <autogen>
+        --KeyToKey--
+        KeyCode::CURSOR_RIGHT, VK_OPTION,
+
+        KeyCode::F,
+        ModifierFlag::OPTION_L | ModifierFlag::CONTROL_L
+    </autogen>
+</item>
+```
+
+`Option-Delete` is also broken by Unicode Hex Input.  I haven't figured out how
+to fix this, but I don't really care about it because I have the following in my
+`~/Library/KeyBindings/DefaultKeyBinding.dict` file which lets me use
+`Control-w` just like at the command line:
+
+```text
+{
+    "^w"="deleteWordBackward:";
+}
+```
+
+Welcome to the fiddly rabbit hole of keybinding customization!
+
+The Greek layer in my mapping pretty much matches the original Space Cadet
+mapping as far as I can tell.  Here's a table of the keys and their Greek
+counterparts:
+
+<table>
+    <thead>
+        <tr>
+            <th>Key</th>
+            <th>Alone</th>
+            <th>Shifted</th>
+            <th>Notes</th>
+        </tr>
+    </thead>
+    <tbody>
+        <tr>
+            <td>a</td>
+            <td>α</td>
+            <td>Α</td>
+            <td>Alpha</td>
+        </tr>
+        <tr>
+            <td>b</td>
+            <td>β</td>
+            <td>Β</td>
+            <td>Beta</td>
+        </tr>
+        <tr>
+            <td>c</td>
+            <td>χ</td>
+            <td>Χ</td>
+            <td>Chi</td>
+        </tr>
+        <tr>
+            <td>d</td>
+            <td>δ</td>
+            <td>Δ</td>
+            <td>Delta</td>
+        </tr>
+        <tr>
+            <td>e</td>
+            <td>ε</td>
+            <td>Ε</td>
+            <td>Epsilon</td>
+        </tr>
+        <tr>
+            <td>f</td>
+            <td>φ</td>
+            <td>Φ</td>
+            <td>Phi (p was taken and the ph sounds like an f)</td>
+        </tr>
+        <tr>
+            <td>g</td>
+            <td>γ</td>
+            <td>Γ</td>
+            <td>Gamma</td>
+        </tr>
+        <tr>
+            <td>h</td>
+            <td>η</td>
+            <td>Η</td>
+            <td>Eta</td>
+        </tr>
+        <tr>
+            <td>i</td>
+            <td>ι</td>
+            <td>Ι</td>
+            <td>Iota</td>
+        </tr>
+        <tr>
+            <td>j</td>
+            <td>ϑ</td>
+            <td>Θ</td>
+            <td>Theta (with one of the lowercase variants)</td>
+        </tr>
+        <tr>
+            <td>k</td>
+            <td>κ</td>
+            <td>Κ</td>
+            <td>Kappa</td>
+        </tr>
+        <tr>
+            <td>l</td>
+            <td>λ</td>
+            <td>Λ</td>
+            <td>Lambda (Lisp users rejoice!)</td>
+        </tr>
+        <tr>
+            <td>m</td>
+            <td>μ</td>
+            <td>Μ</td>
+            <td>Mu</td>
+        </tr>
+        <tr>
+            <td>n</td>
+            <td>ν</td>
+            <td>Ν</td>
+            <td>Nu</td>
+        </tr>
+        <tr>
+            <td>o</td>
+            <td>ο</td>
+            <td>Ο</td>
+            <td>Omicron</td>
+        </tr>
+        <tr>
+            <td>p</td>
+            <td>π</td>
+            <td>Π</td>
+            <td>Pi</td>
+        </tr>
+        <tr>
+            <td>q</td>
+            <td>θ</td>
+            <td>Θ</td>
+            <td>Theta (with the other lowercase variant)</td>
+        </tr>
+        <tr>
+            <td>r</td>
+            <td>ρ</td>
+            <td>Ρ</td>
+            <td>Rho</td>
+        </tr>
+        <tr>
+            <td>s</td>
+            <td>σ</td>
+            <td>Σ</td>
+            <td>Sigma (with one of the lowercase variants)</td>
+        </tr>
+        <tr>
+            <td>t</td>
+            <td>τ</td>
+            <td>Τ</td>
+            <td>Tau</td>
+        </tr>
+        <tr>
+            <td>u</td>
+            <td>υ</td>
+            <td>Υ</td>
+            <td>Upsilon</td>
+        </tr>
+        <tr>
+            <td>v</td>
+            <td>ς</td>
+            <td>Σ</td>
+            <td>Sigma (with the other lowercase variant)</td>
+        </tr>
+        <tr>
+            <td>w</td>
+            <td>ω</td>
+            <td>Ω</td>
+            <td>Omega (o was taken and the lowercase kind of looks like a w)</td>
+        </tr>
+        <tr>
+            <td>x</td>
+            <td>ξ</td>
+            <td>Ξ</td>
+            <td>Xi</td>
+        </tr>
+        <tr>
+            <td>y</td>
+            <td>ψ</td>
+            <td>Ψ</td>
+            <td>Psi (p was taken and it looks a bit like a y)</td>
+        </tr>
+        <tr>
+            <td>z</td>
+            <td>ζ</td>
+            <td>Ζ</td>
+            <td>Zeta</td>
+        </tr>
+    </tbody>
+</table>
+
+[cadetpy]: https://github.com/sjl/dotfiles/blob/master/keyremap4macbook/cadet.py
+
+### Math
+
+The Space Cadet also had a `Top` key for typing the symbols on the top of the
+keys, which were (I think) used in APL.  I don't use APL, but when typing out
+mathematical text it would be nice to have some symbols easily available.
+
+I've added a Math layer that functions similarly to the Greek layer.  I chose
+the right `Control` key to activate it.  I won't go into detail about how it
+works because it's the same as the Greek layer.  Here's the code for it if you
+want to use it yourself: <https://gist.github.com/3824109>
+
+I've currently only filled in the Math layer with keys I find useful, so there
+are a lot of empty keys at the moment.  I plan to add new ones as I discover
+I want them.
+
+<table>
+    <thead>
+        <tr>
+            <th>Key</th>
+            <th>Alone</th>
+            <th>Shifted</th>
+            <th>Notes</th>
+        </tr>
+    </thead>
+    <tbody>
+        <tr>
+            <td>a</td>
+            <td>∧</td>
+            <td>ℵ</td>
+            <td>And, Aleph</td>
+        </tr>
+        <tr>
+            <td>b</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>c</td>
+            <td>∘</td>
+            <td>ℂ</td>
+            <td>Composition, Complex numbers</td>
+        </tr>
+        <tr>
+            <td>d</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>e</td>
+            <td>∈</td>
+            <td>∉</td>
+            <td>Element of, Not element of</td>
+        </tr>
+        <tr>
+            <td>f</td>
+            <td>∫</td>
+            <td></td>
+            <td>Integral (i was taken and it looks like an f)</td>
+        </tr>
+        <tr>
+            <td>g</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>h</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>i</td>
+            <td>∩</td>
+            <td>∞</td>
+            <td>Intersection, Infinity</td>
+        </tr>
+        <tr>
+            <td>j</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>k</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>l</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>m</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>n</td>
+            <td></td>
+            <td>ℕ</td>
+            <td>Natural numbers</td>
+        </tr>
+        <tr>
+            <td>o</td>
+            <td>∨</td>
+            <td></td>
+            <td>Or</td>
+        </tr>
+        <tr>
+            <td>p</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>q</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>r</td>
+            <td>√</td>
+            <td>ℝ</td>
+            <td>Root, Real numbers</td>
+        </tr>
+        <tr>
+            <td>s</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>t</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>u</td>
+            <td>∪</td>
+            <td></td>
+            <td>Union</td>
+        </tr>
+        <tr>
+            <td>v</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>w</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>x</td>
+            <td>⊻</td>
+            <td></td>
+            <td>Xor</td>
+        </tr>
+        <tr>
+            <td>y</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>z</td>
+            <td></td>
+            <td>ℤ</td>
+            <td>Integers</td>
+        </tr>
+        <tr>
+            <td>-</td>
+            <td>¬</td>
+            <td></td>
+            <td>Not (looks like a minus)</td>
+        </tr>
+        <tr>
+            <td>=</td>
+            <td>≠</td>
+            <td>±</td>
+            <td>Not equal, Plus or minus (<code>Shift-=</code> is normally +)</td>
+        </tr>
+        <tr>
+            <td>/</td>
+            <td>÷</td>
+            <td></td>
+            <td>Division</td>
+        </tr>
+        <tr>
+            <td>,</td>
+            <td></td>
+            <td>≤</td>
+            <td>Less than or equal to (<code>Shift-,</code> is normally &lt;)</td>
+        </tr>
+        <tr>
+            <td>.</td>
+            <td></td>
+            <td>≥</td>
+            <td>Greater than or equal to (<code>Shift-.</code> is normally &gt;)</td>
+        </tr>
+        <tr>
+            <td>1</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>2</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>3</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>4</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>5</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>6</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>7</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>8</td>
+            <td></td>
+            <td>×</td>
+            <td>Times or cross product (<code>Shift-8</code> is normally *)</td>
+        </tr>
+        <tr>
+            <td>9</td>
+            <td></td>
+            <td></td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>0</td>
+            <td>∅</td>
+            <td></td>
+            <td>Null set</td>
+        </tr>
+        <tr>
+            <td>`</td>
+            <td></td>
+            <td>≈</td>
+            <td>Approximately equal to (<code>Shift-`</code> is normally ~)</td>
+        </tr>
+        <tr>
+            <td>[</td>
+            <td>⊂</td>
+            <td>⊄</td>
+            <td>Proper subset of, Not proper subset of</td>
+        </tr>
+        <tr>
+            <td>]</td>
+            <td>⊃</td>
+            <td>⊅</td>
+            <td>Proper superset of, Not proper superset of</td>
+        </tr>
+        <tr>
+            <td>Left</td>
+            <td>←</td>
+            <td>↚</td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>Right</td>
+            <td>→</td>
+            <td>↛</td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>Up/Down</td>
+            <td>↔</td>
+            <td>↮</td>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+
+In addition, the last five rows also support the `Control` key for more
+variants:
+
+<table>
+    <thead>
+        <tr>
+            <th>Key</th>
+            <th>Ctrl</th>
+            <th>Ctrl-Shifted</th>
+            <th>Notes</th>
+        </tr>
+    </thead>
+    <tbody>
+        <tr>
+            <td>[</td>
+            <td>⊆</td>
+            <td>⊈</td>
+            <td>Subset of, Not subset of</td>
+        </tr>
+        <tr>
+            <td>]</td>
+            <td>⊇</td>
+            <td>⊉</td>
+            <td>Superset of, Not superset of</td>
+        </tr>
+        <tr>
+            <td>Left</td>
+            <td>⇐</td>
+            <td>⇍</td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>Right</td>
+            <td>⇒</td>
+            <td>⇏</td>
+            <td></td>
+        </tr>
+        <tr>
+            <td>Up/Down</td>
+            <td>⇔</td>
+            <td>⇎</td>
+            <td></td>
+        </tr>
+    </tbody>
+</table>
+
+Conclusion
+----------
+
+If you want my full KeyRemap4MacBook configuration you can always get [the
+latest version from my dotfiles][dotkr].
+
+I've done some crazy, fiddly things to my machine.  Undoubtedly lots of people
+on Hacker News will scoff and brag about how they only use the defaults.
+I don't really care.  Given that I spend 60 hours or more a week at the keyboard
+if these things only save me 0.01% of my time they'll pay for themselves in
+a year or two.  Not to mention all the finger pain they'll prevent.  Plus,
+tinkering around and seeing how far you can push things is fun (sometimes)!
+
+I'm pretty satisfied with my hardware and layout.  My dream would be to get
+a custom keycap set with my key labels and the Space Cadet colors/typography
+that would fit on a white Realforce.  It would be absolutely beautiful, but I'm
+sure it'd be far too expensive to make a single custom set.  Oh well, maybe some
+day!
+
+[dotkr]: https://github.com/sjl/dotfiles/blob/master/keyremap4macbook/private.xml
+
--- a/content/blog/2012/10/caves-of-clojure-07-1.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,328 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Caves of Clojure: Part 7.1"
-        snip: "Region mapping."
-        created: 2012-10-15 09:50:00
-    %}
-
-{% block article %}
-
-This post is part of an ongoing series.  If you haven't already done so, you
-should probably start at [the beginning][].
-
-This entry corresponds to the beginning of [post seven in Trystan's
-tutorial][trystan-tut].
-
-If you want to follow along, the code for the series is [on Bitbucket][bb] and
-[on GitHub][gh].  Update to the `entry-07-1` tag to see the code as it stands
-after this post.
-
-It's been a while since the last post, but I've been taking care of things and
-hopefully should be able to write a bit more now.
-
-This post is going to be short.  It'll cover a relatively self-contained but
-interesting bit of Trystan's seventh post.  The rest of it will be covered in
-the next entry.
-
-[the beginning]: /blog/2012/07/caves-of-clojure-01/
-[trystan-tut]: http://trystans.blogspot.com/2011/09/roguelike-tutorial-07-z-levels-and.html
-[bb]: http://bitbucket.org/sjl/caves/
-[gh]: http://github.com/sjl/caves/
-
-[TOC]
-
-Summary
--------
-
-In Trystan's seventh post he adds vertical levels and stairs connecting them.
-I'm going to cover the first part of that now: mapping out regions.
-
-There's been a bit of refactoring since my last post which I'm not going to
-cover.  If you want to see what changed, diff the tags in your VCS of choice.
-
-Region Mapping
---------------
-
-In order to decide where to place stairs, Trystan maps out "regions" of
-contiguous, walkable tiles after he generates and smooths the world.  I'm going
-to do the same thing.
-
-My goal is to create a "region map", which is a map of coordinates to region
-numbers.  For example, consider the following tiny world map:
-
-    :::text
-    ..##..
-    ..#...
-    ..#.##
-    ..#.#.
-
-There are three distinct regions in this map:
-
-    :::text
-    11##22
-    11#222
-    11#2##
-    11#2#3
-
-So the region map would look like:
-
-    :::clojure
-    ; x y  region
-    {[0 0] 1
-     [1 0] 1
-     [4 0] 2
-     [5 0] 2
-     ...
-     [5 3] 3}
-
-This makes it easy to tell which region a particular tile is in (if any).
-
-As usual, I'll start with a few helper functions.  These two functions are just
-for convenience and readability:
-
-    :::clojure
-    (def all-coords
-      (let [[cols rows] world-size]
-        (for [x (range cols)
-              y (range rows)]
-          [x y])))
-
-    (defn get-tile-from-level [level [x y]]
-      (get-in level [y x] (:bound tiles)))
-
-The `all-coords` function simply returns a lazy sequence of `[x y]` coordinates
-representing every coordinate in a level.
-
-`get-tile-from-level` encapsulates the act of pulling out a tile from a level
-given an `[x y]` coordinate.  This is helpful because of the way I'm storing
-tiles (note the ugly `[y x]`).
-
-Next up is a function that filters a set of coordinates to only contain those
-that are actually walkable in the given level (i.e.: those that don't contain
-a wall tile):
-
-    :::clojure
-    (defn filter-walkable
-      "Filter the given coordinates to include only walkable ones."
-      [level coords]
-      (set (filter #(tile-walkable? (get-tile-from-level level %))
-                   coords)))
-
-This uses the `get-tile-from-level` function as well as `tile-walkable?` from
-`world.core`.
-
-Next is a function to take a coordinate and return which of its neighboring
-coordinates are walkable:
-
-    :::clojure
-    (defn walkable-neighbors
-      "Return the neighboring coordinates walkable from the given coord."
-      [level coord]
-      (filter-walkable level (neighbors coord)))
-
-This one is almost trivial, but I like building up functions in small steps like
-this because it's easier for me to read.
-
-Now we come to a function with a bit more meat.  This is the core of the "flood
-fill" algorithm I'm going to use to fill in the region map.
-
-    :::clojure
-    (defn walkable-from
-      "Return all coordinates walkable from the given coord (including itself)."
-      [level coord]
-      (loop [walked #{}
-             to-walk #{coord}]
-        (if (empty? to-walk)
-          walked
-          (let [current (first to-walk)
-                walked (conj walked current)
-                to-walk (disj to-walk current)
-                candidates (walkable-neighbors level current)
-                to-walk (union to-walk (difference candidates walked))]
-            (recur walked to-walk)))))
-
-In a nutshell, this function loops over two sets: `walked` and `to-walk`.
-
-Each iteration it grabs a coordinate from `to-walk` and sticks it into the
-`walked` set.  It then finds all the coordinates it can walk to from that
-coordinate using a helper function.  It uses `clojure.set/difference` to
-determine which of those are new (i.e.: still need to be walked) and sticks them
-into the `to-walk` set.  Then it recurs.
-
-The code for this is surprisingly simple and easy to read.  It's mostly just
-shuffling things between sets.  Eventually the `to-walk` set will be empty and
-`walked` will contain all the coordinates that we want.
-
-Finally comes the function to create the region map for an entire level:
-
-    :::clojure
-    (defn get-region-map
-      [level]
-      (loop [remaining (filter-walkable level all-coords)
-             region-map {}
-             n 0]
-        (if (empty? remaining)
-          region-map
-          (let [next-coord (first remaining)
-                next-region-coords (walkable-from level next-coord)]
-            (recur (difference remaining next-region-coords)
-                   (into region-map (map vector
-                                         next-region-coords
-                                         (repeat n)))
-                   (inc n))))))
-
-This function also uses Clojure sets to its advantage.  Once again, I loop
-over a couple of variables.
-
-`remaining` is a set containing all the coordinates whose regions has not yet
-been determined.
-
-Each iteration it pulls off one of the remaining coordinates.  Note that I'm
-using `first` to do this.  `remaining` is a set, which is unordered, so `first`
-effectively could return any element in the set.  For this loop that doesn't
-matter, but it's important to be aware of if you're going to use the same
-strategy.
-
-After pulling off a coordinate, it finds all coordinates walkable from that
-coordinate with the `walkable-from` flood-fill function.  It removes all of
-those from the `remaining` set, shoves them into the region map, and increments
-the region number before recurring.
-
-Visualization
--------------
-
-I'm going to save the rest of Trystan's seventh post for another entry, but
-since this one ended up pretty short I'm also going to go over visualizing the
-region map I've just created.
-
-First I need to generate the region map when I create the world, and attach it
-to the world itself so we can access it from other places:
-
-    :::clojure
-    (defn random-world []
-      (let [world (->World (random-tiles) {})
-            world (nth (iterate smooth-world world) 3)
-            world (populate-world world)
-            world (assoc world :regions (get-region-map (:tiles world)))]
-        world))
-
-The last line in the `let` is where it gets generated.  It's pretty
-straightforward.
-
-I'd like to be able to toggle the visualization of regions off and on, so I'm
-going to introduce a new concept to the game: "debug flags".
-
-I updated the `Game` record to include a slot for these flags:
-
-    :::clojure
-    (defrecord Game [world uis input debug-flags])
-
-I then updated the `new-game` function to initialize them (currently there's
-only one) to default values:
-
-    :::clojure
-    (defn new-game []
-      (map->Game {:world nil
-                  :uis [(->UI :start)]
-                  :input nil
-                  :debug-flags {:show-regions false}}))
-
-The user needs a way to toggle them.  For now I'll just bind it to a key.  In
-the future I could make a debug UI with a nice menu.
-
-    :::clojure
-    (defmethod process-input :play [game input]
-      (case input
-        :enter     (assoc game :uis [(->UI :win)])
-        :backspace (assoc game :uis [(->UI :lose)])
-        \q         (assoc game :uis [])
-
-        \h (update-in game [:world] move-player :w)
-        \j (update-in game [:world] move-player :s)
-
-        ; ...
-
-        \R (update-in game [:debug-flags :show-regions] not)
-
-        game))
-
-Now when the user presses `R` (Shift and R) it will toggle the state of the
-`:show-regions` debug flag in the game.
-
-All that's left is to actually *draw* the regions somehow.  First, we only want
-to do this if `:show-regions` is `true`.  I edited the `:play` UI's drawing
-function to do this:
-
-    :::clojure
-    (defmethod draw-ui :play [ui game screen]
-      (let [world (:world game)
-            {:keys [tiles entities regions]} world
-            player (:player entities)
-            [cols rows] (s/get-size screen)
-            vcols cols
-            vrows (dec rows)
-            origin (get-viewport-coords game (:location player) vcols vrows)]
-        (draw-world screen vrows vcols origin tiles)
-        ; ******************
-        (when (get-in game [:debug-flags :show-regions])
-          (draw-regions screen regions vrows vcols origin))
-        ; ******************
-        (doseq [entity (vals entities)]
-          (draw-entity screen origin vrows vcols entity))
-        (draw-hud screen game)
-        (draw-messages screen (:messages player))
-        (highlight-player screen origin player)))
-
-The marked lines are the only new ones.  I'm going to draw regions after/above
-the world tiles (so they'll show up at all) but before/below the entities (so we
-can still see what's going on).
-
-Drawing the regions is fairly simple, if a bit tedious:
-
-    :::clojure
-    (defn draw-regions [screen region-map vrows vcols [ox oy]]
-      (letfn [(get-region-glyph [region-number]
-                (str
-                  (nth
-                    "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
-                    region-number)))]
-        (doseq [x (range ox (+ ox vcols))
-                y (range oy (+ oy vrows))]
-          (let [region-number (region-map [x y])]
-            (when region-number
-              (s/put-string screen (- x ox) (- y oy)
-                            (get-region-glyph region-number)
-                            {:fg :blue}))))))
-
-For now, bad things will happen if we have more than 62 regions in a single
-level.  In practice I usually end up with about 20 to 30, so it's not a big
-deal.
-
-To sum up this function: it iterates through every coordinate in the level
-that's displayed in the viewport, looks up its region number in the region map,
-and draws the appropriate letter if it has a region number.
-
-Results
--------
-
-Now that I've got a way to visualize regions it becomes much easier to check
-whether they're getting set correctly.  Here's an example of what it looks like
-when you toggle `:show-regions` with `R`:
-
-![Screenshot without Regions](/media/images{{ parent_url }}/caves-07-1-1.png)
-
-![Screenshot with Regions](/media/images{{ parent_url }}/caves-07-1-2.png)
-
-As you can see, the small, closed off areas have their own numbers, while the
-larger regions sprawl across the map.
-
-You can view the code [on GitHub][result-code] if you want to see the end
-result.
-
-[result-code]: https://github.com/sjl/caves/tree/entry-07-1/src/caves
-
-The next article will finish Trystan's seventh post by adding multiple z-levels
-to the caves.
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/10/caves-of-clojure-07-1.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,339 @@
++++
+title = "The Caves of Clojure: Part 7.1"
+snip = "Region mapping."
+date = 2012-10-15T09:50:00Z
+draft = false
+
++++
+
+This post is part of an ongoing series.  If you haven't already done so, you
+should probably start at [the beginning][].
+
+This entry corresponds to the beginning of [post seven in Trystan's
+tutorial][trystan-tut].
+
+If you want to follow along, the code for the series is [on Bitbucket][bb] and
+[on GitHub][gh].  Update to the `entry-07-1` tag to see the code as it stands
+after this post.
+
+It's been a while since the last post, but I've been taking care of things and
+hopefully should be able to write a bit more now.
+
+This post is going to be short.  It'll cover a relatively self-contained but
+interesting bit of Trystan's seventh post.  The rest of it will be covered in
+the next entry.
+
+[the beginning]: /blog/2012/07/caves-of-clojure-01/
+[trystan-tut]: http://trystans.blogspot.com/2011/09/roguelike-tutorial-07-z-levels-and.html
+[bb]: http://bitbucket.org/sjl/caves/
+[gh]: http://github.com/sjl/caves/
+
+{{% toc %}}
+
+Summary
+-------
+
+In Trystan's seventh post he adds vertical levels and stairs connecting them.
+I'm going to cover the first part of that now: mapping out regions.
+
+There's been a bit of refactoring since my last post which I'm not going to
+cover.  If you want to see what changed, diff the tags in your VCS of choice.
+
+Region Mapping
+--------------
+
+In order to decide where to place stairs, Trystan maps out "regions" of
+contiguous, walkable tiles after he generates and smooths the world.  I'm going
+to do the same thing.
+
+My goal is to create a "region map", which is a map of coordinates to region
+numbers.  For example, consider the following tiny world map:
+
+```text
+..##..
+..#...
+..#.##
+..#.#.
+```
+
+There are three distinct regions in this map:
+
+```text
+11##22
+11#222
+11#2##
+11#2#3
+```
+
+So the region map would look like:
+
+```clojure
+; x y  region
+{[0 0] 1
+ [1 0] 1
+ [4 0] 2
+ [5 0] 2
+ ...
+ [5 3] 3}
+```
+
+This makes it easy to tell which region a particular tile is in (if any).
+
+As usual, I'll start with a few helper functions.  These two functions are just
+for convenience and readability:
+
+```clojure
+(def all-coords
+  (let [[cols rows] world-size]
+    (for [x (range cols)
+          y (range rows)]
+      [x y])))
+
+(defn get-tile-from-level [level [x y]]
+  (get-in level [y x] (:bound tiles)))
+```
+
+The `all-coords` function simply returns a lazy sequence of `[x y]` coordinates
+representing every coordinate in a level.
+
+`get-tile-from-level` encapsulates the act of pulling out a tile from a level
+given an `[x y]` coordinate.  This is helpful because of the way I'm storing
+tiles (note the ugly `[y x]`).
+
+Next up is a function that filters a set of coordinates to only contain those
+that are actually walkable in the given level (i.e.: those that don't contain
+a wall tile):
+
+```clojure
+(defn filter-walkable
+  "Filter the given coordinates to include only walkable ones."
+  [level coords]
+  (set (filter #(tile-walkable? (get-tile-from-level level %))
+               coords)))
+```
+
+This uses the `get-tile-from-level` function as well as `tile-walkable?` from
+`world.core`.
+
+Next is a function to take a coordinate and return which of its neighboring
+coordinates are walkable:
+
+```clojure
+(defn walkable-neighbors
+  "Return the neighboring coordinates walkable from the given coord."
+  [level coord]
+  (filter-walkable level (neighbors coord)))
+```
+
+This one is almost trivial, but I like building up functions in small steps like
+this because it's easier for me to read.
+
+Now we come to a function with a bit more meat.  This is the core of the "flood
+fill" algorithm I'm going to use to fill in the region map.
+
+```clojure
+(defn walkable-from
+  "Return all coordinates walkable from the given coord (including itself)."
+  [level coord]
+  (loop [walked #{}
+         to-walk #{coord}]
+    (if (empty? to-walk)
+      walked
+      (let [current (first to-walk)
+            walked (conj walked current)
+            to-walk (disj to-walk current)
+            candidates (walkable-neighbors level current)
+            to-walk (union to-walk (difference candidates walked))]
+        (recur walked to-walk)))))
+```
+
+In a nutshell, this function loops over two sets: `walked` and `to-walk`.
+
+Each iteration it grabs a coordinate from `to-walk` and sticks it into the
+`walked` set.  It then finds all the coordinates it can walk to from that
+coordinate using a helper function.  It uses `clojure.set/difference` to
+determine which of those are new (i.e.: still need to be walked) and sticks them
+into the `to-walk` set.  Then it recurs.
+
+The code for this is surprisingly simple and easy to read.  It's mostly just
+shuffling things between sets.  Eventually the `to-walk` set will be empty and
+`walked` will contain all the coordinates that we want.
+
+Finally comes the function to create the region map for an entire level:
+
+```clojure
+(defn get-region-map
+  [level]
+  (loop [remaining (filter-walkable level all-coords)
+         region-map {}
+         n 0]
+    (if (empty? remaining)
+      region-map
+      (let [next-coord (first remaining)
+            next-region-coords (walkable-from level next-coord)]
+        (recur (difference remaining next-region-coords)
+               (into region-map (map vector
+                                     next-region-coords
+                                     (repeat n)))
+               (inc n))))))
+```
+
+This function also uses Clojure sets to its advantage.  Once again, I loop
+over a couple of variables.
+
+`remaining` is a set containing all the coordinates whose regions has not yet
+been determined.
+
+Each iteration it pulls off one of the remaining coordinates.  Note that I'm
+using `first` to do this.  `remaining` is a set, which is unordered, so `first`
+effectively could return any element in the set.  For this loop that doesn't
+matter, but it's important to be aware of if you're going to use the same
+strategy.
+
+After pulling off a coordinate, it finds all coordinates walkable from that
+coordinate with the `walkable-from` flood-fill function.  It removes all of
+those from the `remaining` set, shoves them into the region map, and increments
+the region number before recurring.
+
+Visualization
+-------------
+
+I'm going to save the rest of Trystan's seventh post for another entry, but
+since this one ended up pretty short I'm also going to go over visualizing the
+region map I've just created.
+
+First I need to generate the region map when I create the world, and attach it
+to the world itself so we can access it from other places:
+
+```clojure
+(defn random-world []
+  (let [world (->World (random-tiles) {})
+        world (nth (iterate smooth-world world) 3)
+        world (populate-world world)
+        world (assoc world :regions (get-region-map (:tiles world)))]
+    world))
+```
+
+The last line in the `let` is where it gets generated.  It's pretty
+straightforward.
+
+I'd like to be able to toggle the visualization of regions off and on, so I'm
+going to introduce a new concept to the game: "debug flags".
+
+I updated the `Game` record to include a slot for these flags:
+
+```clojure
+(defrecord Game [world uis input debug-flags])
+```
+
+I then updated the `new-game` function to initialize them (currently there's
+only one) to default values:
+
+```clojure
+(defn new-game []
+  (map->Game {:world nil
+              :uis [(->UI :start)]
+              :input nil
+              :debug-flags {:show-regions false}}))
+```
+
+The user needs a way to toggle them.  For now I'll just bind it to a key.  In
+the future I could make a debug UI with a nice menu.
+
+```clojure
+(defmethod process-input :play [game input]
+  (case input
+    :enter     (assoc game :uis [(->UI :win)])
+    :backspace (assoc game :uis [(->UI :lose)])
+    \q         (assoc game :uis [])
+
+    \h (update-in game [:world] move-player :w)
+    \j (update-in game [:world] move-player :s)
+
+    ; ...
+
+    \R (update-in game [:debug-flags :show-regions] not)
+
+    game))
+```
+
+Now when the user presses `R` (Shift and R) it will toggle the state of the
+`:show-regions` debug flag in the game.
+
+All that's left is to actually *draw* the regions somehow.  First, we only want
+to do this if `:show-regions` is `true`.  I edited the `:play` UI's drawing
+function to do this:
+
+```clojure
+(defmethod draw-ui :play [ui game screen]
+  (let [world (:world game)
+        {:keys [tiles entities regions]} world
+        player (:player entities)
+        [cols rows] (s/get-size screen)
+        vcols cols
+        vrows (dec rows)
+        origin (get-viewport-coords game (:location player) vcols vrows)]
+    (draw-world screen vrows vcols origin tiles)
+    ; ******************
+    (when (get-in game [:debug-flags :show-regions])
+      (draw-regions screen regions vrows vcols origin))
+    ; ******************
+    (doseq [entity (vals entities)]
+      (draw-entity screen origin vrows vcols entity))
+    (draw-hud screen game)
+    (draw-messages screen (:messages player))
+    (highlight-player screen origin player)))
+```
+
+The marked lines are the only new ones.  I'm going to draw regions after/above
+the world tiles (so they'll show up at all) but before/below the entities (so we
+can still see what's going on).
+
+Drawing the regions is fairly simple, if a bit tedious:
+
+```clojure
+(defn draw-regions [screen region-map vrows vcols [ox oy]]
+  (letfn [(get-region-glyph [region-number]
+            (str
+              (nth
+                "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                region-number)))]
+    (doseq [x (range ox (+ ox vcols))
+            y (range oy (+ oy vrows))]
+      (let [region-number (region-map [x y])]
+        (when region-number
+          (s/put-string screen (- x ox) (- y oy)
+                        (get-region-glyph region-number)
+                        {:fg :blue}))))))
+```
+
+For now, bad things will happen if we have more than 62 regions in a single
+level.  In practice I usually end up with about 20 to 30, so it's not a big
+deal.
+
+To sum up this function: it iterates through every coordinate in the level
+that's displayed in the viewport, looks up its region number in the region map,
+and draws the appropriate letter if it has a region number.
+
+Results
+-------
+
+Now that I've got a way to visualize regions it becomes much easier to check
+whether they're getting set correctly.  Here's an example of what it looks like
+when you toggle `:show-regions` with `R`:
+
+![Screenshot without Regions](/media/images/blog/2012/10/caves-07-1-1.png)
+
+![Screenshot with Regions](/media/images/blog/2012/10/caves-07-1-2.png)
+
+As you can see, the small, closed off areas have their own numbers, while the
+larger regions sprawl across the map.
+
+You can view the code [on GitHub][result-code] if you want to see the end
+result.
+
+[result-code]: https://github.com/sjl/caves/tree/entry-07-1/src/caves
+
+The next article will finish Trystan's seventh post by adding multiple z-levels
+to the caves.
+
--- a/content/blog/2012/10/the-homely-mutt.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1319 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "The Homely Mutt"
-        snip: "Sparrow's dead?  Why not try Mutt?"
-        created: 2012-10-01 10:30:00
-    %}
-
-{% block article %}
-
-Now that [Sparrow][] is [effectively dead][sparrow-dead] many of its users will
-be looking for a new email client.  If you're not afraid of the terminal you may
-want to give [Mutt][] a try.
-
-Mutt certainly isn't the prettiest email client around, and its
-setup/configuration process is one of the ugliest out there.  But once you get
-it set up it's got a lot of advantages over many other email clients.
-
-In this post I'll show you how to set up Mutt on OS X like I do.
-
-[Sparrow]: http://sparrowmailapp.com/
-[sparrow-dead]: http://www.theverge.com/2012/7/20/3172222/google-buys-sparrow-mail
-[Mutt]: http://www.mutt.org/
-
-[TOC]
-
-How I Use Email
----------------
-
-This setup is going to be specific to the way I work with email.  Notably:
-
-* I have a Google Apps account that provides my steve@stevelosh.com email
-  address.
-* I have many other email addresses, but they all simply forward to my main one.
-* All mail I send comes from steve@stevelosh.com.
-* I store my contacts in the OS X address book.
-* All email comes into my inbox (or to a folder for a specific mailing list).
-* Once I'm done with an email, I remove it from my inbox and it lives in the
-  "All Mail" archive.  I don't sort email into folders after it arrives.
-* I sometimes read email offline and mark it for deletion, then sync that
-  deletion back to the server once I get online again.
-* Sometimes I write email without an internet connection and send it once I get
-  connected again.
-
-My email setup is tailored around those requirements, so that's what it does
-best.  Mutt is very configurable though, so if you work differently you can
-probably bend it to make it do what you want.
-
-In particular, extending this setup to work with multiple email accounts
-wouldn't be too much trouble.  I used to work with two separate accounts until
-I said "screw it, I'll just use the one".
-
-Other Guides and Resources
---------------------------
-
-I've used a lot of other guides to figure out how to get this giant Rube
-Goldberg machine of an email client working.  Here are a few of them:
-
-* <http://thomas.pelletier.im/2010/10/low-memory-mail-client/>
-* <http://www.andrews-corner.org/mutt.html>
-* <http://jstorimer.com/shells/2010/01/19/using-mutt-with-gmail-on-osx.html>
-* <http://www.vijaykiran.com/2010/01/27/mutt-for-gmail-imap-on-mac-os-x/>
-* <http://hynek.me/articles/my-mutt-gmail-setup/>
-* <https://wiki.archlinux.org/index.php/Mutt>
-* <http://linsec.ca/Using_mutt_on_OS_X>
-* <http://www.mutt.org/doc/manual/manual.html>
-* <http://pbrisbin.com/posts/two_accounts_in_mutt>
-* <http://upsilon.cc/~zack/blog/posts/2011/01/how_to_use_Notmuch_with_Mutt/>
-
-Overview
---------
-
-I'm going to give it to you straight: getting this whole contraption set up is
-going to take at least an hour from start to finish, not counting the time it'll
-take to download all of your email and install stuff.  Set aside an evening if
-you're serious about this.
-
-It's an investment, and you might not want to make it.  If not, go use
-Thunderbird, er, Sparrow, er, I don't know, the Gmail web interface or
-something.
-
-Mutt on its own doesn't do very much, so we're going to combine it with a few
-other things to get the job done.  Here's a bird's eye view of what it'll look
-like when we're done:
-
-![Diagram](/media/images{{ parent_url }}/what-the-mutt.png)
-
-If this diagram doesn't make you run screaming you might just be masochistic
-enough to make it through the initial setup of Mutt.  If you do, you'll be
-rewarded with email bliss that won't go away when Google or Facebook decide to
-toss some money around.
-
-Getting Email
--------------
-
-First thing's first: we're going to pull down our email from Gmail to our local
-machine.  All of it.  It'll take a while the first time you sync, but has a few
-benefits.
-
-### Why Local Email?
-
-Having a local copy of all of your email means you've always got access to it,
-no matter where you are.  Looking for that one person's address they emailed you
-six years ago when you're trying to find their house and you don't have an
-internet connection?  No problem, it's on your hard drive.
-
-This also acts as a backup in case Google ever decides to kill your Gmail
-account.  It'll be stored in a common format that a lot of programs can read, so
-you've got a safety net.  And the email is stored as normal files, so if you use
-something like Time Machine or [Backblaze][] that's yet another free backup.
-
-In this setup **all of your email is stored as plain text**.  If you want it
-encrypted just use OS X's full-disk encryption and you're set.
-
-I use [offlineimap][] to pull email down from Gmail and get it on my hard drive.
-Offlineimap will also sync any changes you make to this local copy back up to
-Gmail.
-
-[offlineimap]: http://offlineimap.org/
-[Backblaze]: http://www.backblaze.com/partner/af3574
-
-### The Alternative
-
-You may not care as much about reading your email offline as I do.  If you can
-tolerate always needing an internet connection to read your mail, you can skip
-this painful section and follow [this guide][roma] instead.
-
-You'll probably still find the other sections of this post interesting though.
-
-[roma]: http://empt1e.blogspot.com/2009/10/using-mutt-with-gmail-imap-complete.html
-
-### Installing offlineimap
-
-I've gone through a number of laptops in the past few years, and each time
-I spend a painful half hour or so screwing around with the latest version of
-offlineimap's backwards-incompatible changes.
-
-If you're determined to run the latest version of offlineimap, you can install
-it with pip or something.  If you just want to download your fucking email and
-get on with your life, you can follow the instructions I've laid out for you
-here:
-
-    :::text
-    git clone git://github.com/spaetz/offlineimap.git
-    cd offlineimap
-    git checkout 679c491c56c981961e18aa43b31955900491d7a3
-    python setup.py install
-
-That's the version I'm using.  It works.  You can use a newer one if you want,
-but expect to spend some time figuring out how to fix the configuration in this
-post to work with whatever breaking changes have been made since then.  The last
-time I tried this I got to rewrite all my nametrans stuff.  That was fun.
-
-### Configuring offlineimap
-
-Once you've got offlineimap installed, you'll need to create
-a `~/.offlineimaprc` file.  You can keep it in your dotfiles repo and symlink it
-into place if you want.  Here's a sample to get you started:
-
-    :::text
-    [general]
-    ui = TTY.TTYUI
-    accounts = SteveLosh
-    pythonfile=~/.mutt/offlineimap.py
-    fsync = False
-
-    [Account SteveLosh]
-    localrepository = SteveLosh-Local
-    remoterepository = SteveLosh-Remote
-    status_backend = sqlite
-    postsynchook = notmuch new
-
-    [Repository SteveLosh-Local]
-    type = Maildir
-    localfolders = ~/.mail/steve-stevelosh.com
-    nametrans = lambda folder: {'drafts':  '[Gmail]/Drafts',
-                                'sent':    '[Gmail]/Sent Mail',
-                                'flagged': '[Gmail]/Starred',
-                                'trash':   '[Gmail]/Trash',
-                                'archive': '[Gmail]/All Mail',
-                                }.get(folder, folder)
-
-    [Repository SteveLosh-Remote]
-    maxconnections = 1
-    type = Gmail
-    remoteuser = steve@stevelosh.com
-    remotepasseval = get_keychain_pass(account="steve@stevelosh.com", server="imap.gmail.com")
-    realdelete = no
-    nametrans = lambda folder: {'[Gmail]/Drafts':    'drafts',
-                                '[Gmail]/Sent Mail': 'sent',
-                                '[Gmail]/Starred':   'flagged',
-                                '[Gmail]/Trash':     'trash',
-                                '[Gmail]/All Mail':  'archive',
-                                }.get(folder, folder)
-    folderfilter = lambda folder: folder not in ['[Gmail]/Trash',
-                                                 'Nagios',
-                                                 'Django',
-                                                 'Flask',
-                                                 '[Gmail]/Important',
-                                                 '[Gmail]/Spam',
-                                                 ]
-
-It's kind of long, so let's go through it line by line and see what's going on.
-
-    :::text
-    [general]
-    ui = TTY.TTYUI
-    accounts = SteveLosh
-    pythonfile=~/.mutt/offlineimap.py
-    fsync = False
-
-First we tell offlineimap to use the `TTY.TTYUI` ui.  Yes, this program that
-syncs your email has multiple user interfaces.  I guess if you can't decide what
-color the bikeshed should be you can just build a whole bunch of bikesheds
-instead.
-
-Then we specify the accounts.  There's only one because as I said before:
-I only use a single email account that all my addresses forward to.  If you
-wanted to have many, you'd change this line.
-
-The `pythonfile` is just a file that offlineimap will parse (as Python) before
-loading the rest of the config, so you can define custom helper functions more
-easily.  We'll see more of this later.
-
-We're also telling offlineimap that it doesn't need to fsync after every single
-operation.  This will speed things up, and since it's just a local copy it's
-typically not a big deal if we lose an email here and there from a crash (it'll
-just be synced the next time anyway).
-
-    :::text
-    [Account SteveLosh]
-    localrepository = SteveLosh-Local
-    remoterepository = SteveLosh-Remote
-    status_backend = sqlite
-
-This next section hooks up a few things.  First, it tells offlineimap which
-local and remote repositories to use for the account.  Manual configuration
-instead of sane defaults is a recurring theme we'll see throughout this process.
-
-Hey, I titled the entry "The *Homely* Mutt" for a reason.
-
-We're also going to use a SQLite-based cache for this account.  If you don't
-already have SQLite you'll want to get it with `brew install sqlite`.
-
-    :::text
-    [Repository SteveLosh-Local]
-    type = Maildir
-    localfolders = ~/.mail/steve-stevelosh.com
-    nametrans = lambda folder: {'drafts':  '[Gmail]/Drafts',
-                                'sent':    '[Gmail]/Sent Mail',
-                                'flagged': '[Gmail]/Starred',
-                                'trash':   '[Gmail]/Trash',
-                                'archive': '[Gmail]/All Mail',
-                                }.get(folder, folder)
-
-Now we're getting to the meat of the configuration.  This "local repository" is
-going to be the mail as it sits on our hard drive.  We're going to use the
-[Maildir format][maildir] because it plays nicely with Mutt (and tons of other
-stuff).
-
-Then we specify the path where we're going to keep the mail.  This is going to
-take a lot of space if you've got a lot of mail.  Attachments are downloaded
-too.  When I said you're getting an offline copy of all your email I meant *all*
-of it.
-
-I think offlineimap needs the `~/.mail` directory created for it.  It's been
-a while since I did this, so I might be wrong, but if it complains about not
-being able to access the mail folders just go ahead and `mkdir ~/.mail`.
-
-Next we have the craziest part of the configuration: name translation.
-
-Here's the issue: offlineimap needs to know how to translate the names of
-folders on the IMAP server to folder names on your hard drive.
-
-Also, Gmail doesn't actually use *folders* but its own concept called "labels".
-But since the IMAP protocol doesn't know about labels, it fakes them by making
-them appear to be folders.
-
-User-created labels in Gmail (like "Mercurial" or "Clients") will appear as
-folders with those names through IMAP.
-
-Built-in, special Gmail folders have names that start with `[Gmail]/`.  We need
-to turn those into something sane for our hard drive, so that's what this
-nametrans setting is for.  It's a Python function that takes the remote folder
-name and returns the name that should be used on your local hard drive.
-
-Yes, you read that right.  This is Python code embedded in the right hand side
-of an INI file's setting assignment.  I am not fucking with you, this is
-seriously how you do it.  Go ahead and crack open that beer now.
-
-So the "Sent Mail" folder in your Gmail account will be synced to
-`~/.mail/steve-stevelosh.com/sent`.  Cool.
-
-(No, I don't know what would happen if you created a label called `[Gmail]/All
-Mail` in Gmail.  If you try please let me know, but I take no responsibility if
-it ends with all your email being deleted.)
-
-[maildir]: https://en.wikipedia.org/wiki/Maildir
-
-    :::text
-    [Repository SteveLosh-Remote]
-    maxconnections = 1
-    type = Gmail
-    remoteuser = steve@stevelosh.com
-    remotepasseval = get_keychain_pass(account="steve@stevelosh.com", server="imap.gmail.com")
-    realdelete = no
-    nametrans = lambda folder: {'[Gmail]/Drafts':    'drafts',
-                                '[Gmail]/Sent Mail': 'sent',
-                                '[Gmail]/Starred':   'flagged',
-                                '[Gmail]/Trash':     'trash',
-                                '[Gmail]/All Mail':  'archive',
-                                }.get(folder, folder)
-    folderfilter = lambda folder: folder not in ['[Gmail]/Trash',
-                                                 'Nagios',
-                                                 'Django',
-                                                 'Flask',
-                                                 '[Gmail]/Important',
-                                                 '[Gmail]/Spam',
-                                                 ]
-
-Finally, the home stretch.  The last section described the folder on our local
-hard drive, and this one describes our Gmail account.
-
-First, we tell offlineimap to only ever use a single connection at a time.  You
-can try increasing this number for better performance, but in my experience
-Google is not afraid to enforce its rate limits and would cut me off fairly
-often when I tried that.  Just leave it at one if you want to be safe.
-
-Next is the type.  Luckily offlineimap provides a `Gmail` type that handles
-a lot of the craziness that is Gmail's IMAP setup.  Nice.
-
-Then we have the username.  Nothing special here, except that if you have
-a non-apps account (i.e.: an actual vanilla Gmail account) you may or may not
-need to include the `@gmail.com` in the username.  I don't know.  If one doesn't
-work, just try the other.
-
-Next we have `remotepasseval`.  This is a bit of Python code (drink!) that
-should return the password for the account.
-
-What is this `get_keychain_pass` function?  Well, remember when we saw the
-`pythonfile` setting back in the general section?  It's a function defined in
-there.  I'll talk about that in the next section, for now just accept that it
-works.
-
-Next we set `realdelete` to no.  If this is set to yes, then deleting an email
-in your inbox would actually delete it entirely.  When you set it to no, then
-deleting an email from your inbox (or any label's folder) will leave it in
-Gmail's All Mail.
-
-If you want to really delete an email, you'll need to delete it from All Mail
-(which is named archive on our local filesystem, remember?).  I feel like this
-is a good compromise.  I rarely care about actually deleting mail, given that
-I have many unused gigabytes available on Gmail.
-
-Next we have another nametrans setting.  This is a Python function (drink!) just
-like the one for the local repository, except it goes in the other direction.
-It takes the name of a local folder and returns the name of the folder on the
-IMAP server.  Knowing this, it should be easy to understand this setting.
-
-Finally, we have `folderfilter`.  This is a Python function (drink!) that takes
-a **remote** folder name and returns `True` if that folder should be synced, or
-`False` if it should **not** be synced.  I've chosen to skip syncing my Spam and
-Trash folders, as well as a few mailing list labels I don't check all that
-often.  Customize this to your own taste.
-
-### Retrieving Passwords
-
-We're almost ready, but there's one more thing we need to do, and that's
-implement a secure way for offlineimap to get access to our Gmail password.
-
-If you don't care too much about security, you *can* configure offlineimap with
-a plaintext password right in the config file.  But don't do that.  It'll only
-take a minute to do this securely.
-
-First, you need to add your Gmail password into your OS X keychain.  Open the
-Keychain Access app and press the `+` button:
-
-![Keychain 1](/media/images{{ parent_url }}/keychain-1.png)
-
-Then fill out the form.  The "Keychain Item Name" should be
-`http://imap.gmail.com`.  The "Account Name" should be your email address.  The
-password should be your password:
-
-![Keychain 2](/media/images{{ parent_url }}/keychain-2.png)
-
-Press "Add".  Now repeat the process for the SMTP server.  The "Keychain Item
-Name" should be `smtp://smtp.gmail.com`.  The "Account Name" should be your
-email address.  The password should be your password:
-
-![Keychain 3](/media/images{{ parent_url }}/keychain-3.png)
-
-Now we need to create the `offlineimap.py` file we pointed offlineimap to
-earlier.  It needs to contain the `get_keychain_pass` function, which takes an
-`account` and `server` and return the password.  Here's the file I'm using:
-
-    :::python
-    #!/usr/bin/python
-    import re, subprocess
-    def get_keychain_pass(account=None, server=None):
-        params = {
-            'security': '/usr/bin/security',
-            'command': 'find-internet-password',
-            'account': account,
-            'server': server,
-            'keychain': '/Users/sjl/Library/Keychains/login.keychain',
-        }
-        command = "sudo -u sjl %(security)s -v %(command)s -g -a %(account)s -s %(server)s %(keychain)s" % params
-        output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
-        outtext = [l for l in output.splitlines()
-                   if l.startswith('password: ')][0]
-
-        return re.match(r'password: "(.*)"', outtext).group(1)
-
-In a nutshell, it uses `/usr/bin/security` to retrieve the password.  Read
-through the code if you're curious.
-
-This is not *completely* secure, but it's better than having your password in
-a plaintext file in your home directory.
-
-Whew!  Time to actually run this thing and pull down our email!
-
-### Running offlineimap
-
-Assuming everything is in place, open a terminal and run offlineimap:
-
-    offlineimap
-
-Go read a book, because this is going to pull down all the email (with
-attachments) in any folders you didn't exclude in the config file.
-
-**If there's an error, stop and figure out what went wrong**.  Remember,
-offlineimap is a *two-way* sync, so there's always the possibility it'll eat
-your email if you seriously mess something up!  I wish it had a
-`--dont-touch-remote` option you could use as a safety net for the original
-sync, but it doesn't, so be careful!
-
-In the future you can use `offlineimap -q` to run it in "quick mode".  It'll
-perform fewer checks but will generally be much faster.
-
-If you want to set up offlineimap to run every 5 minutes or so, you can use
-`launchd`.  `cron` does not work for some reason.  I'm not entirely sure why.
-
-Personally I actually *like* having to press a key to fetch new mail.  It's less
-of a distraction than having new mail rolling in all the time.  I can get new
-email when I'm ready to actually look at it, rather than having it nagging me
-all the time.
-
-The great part about offlineimap is that once you've got it configured and it's
-successfully run once, it's pretty much rock solid from then on.  You can run it
-often, `Ctrl-c` it, put the laptop to sleep in the middle of a run, or `kill -9`
-it, and it still won't lose emails.  On the next sync it'll fix anything that's
-missing.
-
-Mutt!
------
-
-Now that you've got your email on your computer, it's finally time to start
-using Mutt itself!
-
-### Installing
-
-Mutt can be installed in a bunch of different ways, but the easiest is through
-Homebrew:
-
-    :::text
-    brew install mutt --sidebar-patch
-
-The sidebar patch is a third-party patch that adds a sidebar to Mutt.  I don't
-know why it's not in core Mutt because it's insanely useful.  Oh well, at least
-Homebrew makes it simple to get.
-
-That's pretty much it for installation, but don't get too relaxed because you're
-far from done.
-
-### Configuring
-
-Mutt is *very* configurable.  This is great once you've become a power user and
-want to mold it to your will, but terrible when you're just getting started.
-
-Mutt settings are kept in a `~/.muttrc` file.  If this file doesn't exist Mutt
-will look for `~/.mutt/muttrc` (note the lack of a dot in the filename), so you
-can put it there if you prefer.
-
-Let's start by creating a basic `~/.muttrc` piece by piece (a lot of this was
-taken from [this article][pris]).
-
-Once you've got a bit of Mutt under your belt you'll want to read [the
-documentation][muttdoc] for these settings, but for now just use them to keep
-things sane.
-
-[pris]: http://pbrisbin.com/posts/two_accounts_in_mutt
-[muttdoc]: http://www.mutt.org/doc/manual/manual-6.html
-
-    :::text
-    # Paths ----------------------------------------------
-    set folder           = ~/.mail               # mailbox location
-    set alias_file       = ~/.mutt/alias         # where to store aliases
-    set header_cache     = ~/.mutt/cache/headers # where to store headers
-    set message_cachedir = ~/.mutt/cache/bodies  # where to store bodies
-    set certificate_file = ~/.mutt/certificates  # where to store certs
-    set mailcap_path     = ~/.mutt/mailcap       # entries for filetypes
-    set tmpdir           = ~/.mutt/temp          # where to keep temp files
-    set signature        = ~/.mutt/sig           # my signature file
-
-Here we tell Mutt where to find the various folders it needs.
-
-    :::text
-    # Basic Options --------------------------------------
-    set wait_key = no        # shut up, mutt
-    set mbox_type = Maildir  # mailbox type
-    set timeout = 3          # idle time before scanning
-    set mail_check = 0       # minimum time between scans
-    unset move               # gmail does that
-    set delete               # don't ask, just do
-    unset confirmappend      # don't ask, just do!
-    set quit                 # don't ask, just do!!
-    unset mark_old           # read/new is good enough for me
-    set beep_new             # bell on new mails
-    set pipe_decode          # strip headers and eval mimes when piping
-    set thorough_search      # strip headers and eval mimes before searching
-
-These are some basic options to make Mutt behave a bit more sanely.
-
-    :::text
-    # Sidebar Patch --------------------------------------
-    set sidebar_delim   = '  │'
-    set sidebar_visible = yes
-    set sidebar_width   = 24
-    color sidebar_new color221 color233
-
-These options are specific to the sidebar patch.
-
-    :::text
-    # Status Bar -----------------------------------------
-    set status_chars  = " *%A"
-    set status_format = "───[ Folder: %f ]───[%r%m messages%?n? (%n new)?%?d? (%d to delete)?%?t? (%t tagged)? ]───%>─%?p?( %p postponed )?───"
-
-This gives us a pretty status bar with the information we care about (and none
-of the stuff we don't).
-
-    :::text
-    # Header Options -------------------------------------
-    ignore *                                # ignore all headers
-    unignore from: to: cc: date: subject:   # show only these
-    unhdr_order *                           # some distros order things by default
-    hdr_order from: to: cc: date: subject:  # and in this order
-
-These options hide some of the extra email headers we don't care about when
-viewing and composing email.
-
-Now it's time to fill on our account details:
-
-    :::text
-    # Account Settings -----------------------------------
-
-    # Default inbox.
-    set spoolfile = "+steve-stevelosh.com/INBOX"
-
-    # Alternate email addresses.
-    alternates sjl@pculture.org still\.?life@gmail.com steve@ladyluckblues.com steve@pculture.org
-
-    # Mailboxes to show in the sidebar.
-    mailboxes +steve-stevelosh.com/INBOX \
-              +steve-stevelosh.com/vim \
-              +steve-stevelosh.com/clojure \
-              +steve-stevelosh.com/python \
-              +steve-stevelosh.com/mercurial \
-              +steve-stevelosh.com/archive \
-              +steve-stevelosh.com/sent \
-              +steve-stevelosh.com/drafts \
-
-    # Other special folders.
-    set mbox      = "+steve-stevelosh.com/archive"
-    set postponed = "+steve-stevelosh.com/drafts"
-
-Most of those should be self-explanatory.  Fill in the appropriate values for
-your mail folder(s).
-
-We'll add more as we go through the next few sections, but that's enough to get
-us started.
-
-### Running
-
-Now that you've got Mutt configured you can run it:
-
-    :::sh
-    mutt
-
-I like to always be in my `~/Desktop` folder when in Mutt, so that when I save
-emails or attachments they go there by default.  I have a little shell function
-set up that `cd`s there for me before running Mutt:
-
-    :::sh
-    alias mutt 'cd ~/Desktop && mutt'
-
-If you run the [new fish shell][fish], this is going to cause problems later
-(long story, but it's related to the `read` builtin).  Do yourself a favor and
-head those confusing issues off at the pass with a fish function:
-
-    :::text
-    function mutt
-        bash --login -c 'cd ~/Desktop; /usr/local/bin/mutt' $argv;
-    end
-
-Remember that if you use another shell like this you'll want to set up any
-aliases and your `PATH` for that shell properly (probably identically to your
-main shell).
-
-[fish]: http://ridiculousfish.com/shell/
-
-Reading Email
--------------
-
-Once you start Mutt you should be looking at a list of the email in your inbox.
-If so: congratulations!  If not: stop and figure out what went wrong.
-
-### The Index
-
-When viewing a folder, Mutt presents you with a list of your email.  This view
-is called the "index":
-
-![Mutt's Index](/media/images{{ parent_url }}/mutt-index.png)
-
-This entry isn't meant be a guide to setting up Mutt on OS X.  For a full guide
-on how to *use* Mutt, you can Google around for some tutorials, or just learn as
-you go with `?`.  The `?` key will show you a list of all the keys you can use
-wherever you currently are, and what they do.
-
-Let's add a few lines to our `~/.muttrc` to make the index view behave a bit
-more nicely:
-
-    :::text
-    # Index View Options ---------------------------------
-    set date_format = "%m/%d"
-    set index_format = "[%Z]  %D  %-20.20F  %s"
-    set sort = threads                         # like gmail
-    set sort_aux = reverse-last-date-received  # like gmail
-    set uncollapse_jump                        # don't collapse on an unread message
-    set sort_re                                # thread based on regex
-    set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"
-
-I won't go into what those do here.  You can read the documentation if you're
-curious.
-
-Quit and rerun Mutt to see your changes.  Mutt is a very lightweight program so
-this should be fast.
-
-Let's also add a few key bindings in the index to make it easier to use:
-
-    :::text
-    # Index Key Bindings ---------------------------------
-    bind index gg       first-entry
-    bind index G        last-entry
-
-    bind index R        group-reply
-    bind index <tab>    sync-mailbox
-    bind index <space>  collapse-thread
-
-    # Ctrl-R to mark all as read
-    macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read"
-
-    # Sync email
-    macro index O "<shell-escape>offlineimap<enter>"           "run offlineimap to sync all mail"
-    macro index o "<shell-escape>offlineimap -qf INBOX<enter>" "run offlineimap to sync inbox"
-
-    # Saner copy/move dialogs
-    macro index C "<copy-message>?<toggle-mailboxes>" "copy a message to a mailbox"
-    macro index M "<save-message>?<toggle-mailboxes>" "move a message to a mailbox"
-
-Remember to quit and rerun Mutt for them to take effect.
-
-We're going to use `j` and `k` to move around, so we may as well support Vim
-keys like `gg` and `G` too.  We'll use `R` for reply all, since that comes in
-handy fairly often.  `Ctrl-R` will mark all messages in the current folder as
-read.
-
-Don't worry if you don't understand how all these bindings and macros work right
-now.  You can read the documentation later.
-
-The `tab` key is going to "commit" changes we've made in Mutt (like deleting an
-email) to our local Maildir folder.  Once those changes are in the Maildir
-folder offlineimap will sync them to the server the next time it runs.  This is
-nice because it lets us recover if we accidentally do something stupid like
-deleting the wrong email.
-
-**Note:** Mutt will also sync changes for a folder when you switch to
-a different folder, and when you quit Mutt, so be aware of those.
-
-The `space` key will toggle collapsing of threads, which can be convenient when
-viewing mailing lists (or any conversations with many messages).
-
-The `o` and `O` keys will run offlineimap to sync mail.  Like I said before,
-I prefer having to press a button to grab mail instead of it constantly grabbing
-and nagging me.  `o` will sync only the inbox (fast), and `O` will sync
-everything (much slower).
-
-Finally we rebind `C` and `M` to perform the same operations they usually do,
-but in a more user-friendly manner.
-
-While we're at it, let's add a way to navigate around the sidebar so we can
-switch folders:
-
-    :::text
-    # Sidebar Navigation ---------------------------------
-    bind index,pager <down>   sidebar-next
-    bind index,pager <up>     sidebar-prev
-    bind index,pager <right>  sidebar-open
-
-We're binding the `up` and `down` arrow keys to switch between folders, and
-`right` to "enter" a folder.  Give it a try.
-
-We don't need the arrows because we can navigate with `j` and `k`, but if you
-prefer to rebind them to something else feel free.
-
-Practice moving between folders and around in the list, then we'll move on to
-actually reading emails.
-
-### The Pager
-
-Press `return` in the index to open the selected email.  This view is called the
-pager:
-
-![Mutt's Pager](/media/images{{ parent_url }}/mutt-pager.png)
-
-Like before, let's add a few settings:
-
-    :::text
-    # Pager View Options ---------------------------------
-    set pager_index_lines = 10 # number of index lines to show
-    set pager_context = 3      # number of context lines to show
-    set pager_stop             # don't go to next message automatically
-    set menu_scroll            # scroll in menus
-    set tilde                  # show tildes like in vim
-    unset markers              # no ugly plus signs
-
-    set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
-    alternative_order text/plain text/enriched text/html
-
-This is a good, sane starting point.  And now for a few extra key bindings:
-
-    :::text
-    # Pager Key Bindings ---------------------------------
-    bind pager k  previous-line
-    bind pager j  next-line
-    bind pager gg top
-    bind pager G  bottom
-
-    bind pager R  group-reply
-
-    # View attachments properly.
-    bind attach <return> view-mailcap
-
-The first few make scrolling behave like it does in the index.  We're also going
-to use the same key for reply all here.  Consistency will make it easier to get
-Mutt into your fingers.
-
-Don't worry about the last one -- that's to make sure Mutt treats attachments
-properly.
-
-Go ahead and try reading some emails.  Remember that `?` will always give you
-a list of keys and their functions.
-
-### Attachments
-
-Now that we're all set for reading plain text email, it's time to deal with
-attachments.
-
-When you're in the pager view reading an email with attachments, you can press
-`v` to view a list of them:
-
-![Attachment List](/media/images{{ parent_url }}/mutt-attachments.png)
-
-Scroll through the list with `j` and `k` and press `return` to view one.  But
-first we need to tell Mutt how to view things that aren't text!
-
-For that we need to create a `~/.mutt/mailcap` file.  Here's a sample to get you
-started:
-
-    :::text
-    # MS Word documents
-    application/msword; ~/.mutt/view_attachment.sh %s "-" '/Applications/TextEdit.app'
-
-    # Images
-    image/jpg; ~/.mutt/view_attachment.sh %s jpg
-    image/jpeg; ~/.mutt/view_attachment.sh %s jpg
-    image/pjpeg; ~/.mutt/view_attachment.sh %s jpg
-    image/png; ~/.mutt/view_attachment.sh %s png
-    image/gif; ~/.mutt/view_attachment.sh %s gif
-
-    # PDFs
-    application/pdf; ~/.mutt/view_attachment.sh %s pdf
-
-    # HTML
-    text/html; ~/.mutt/view_attachment.sh %s html
-
-    # Unidentified files
-    application/octet-stream; ~/.mutt/view_attachment.sh %s "-"
-
-The `view_attachment.sh` script is from [here][attachment].  Here's a link to
-[my copy][attachment-mirror] in case that site ever goes down.  Grab the script,
-chmod it to executable, and stick it in `~/.mutt`.
-
-You can poke around and figure out how it works, or you can just not worry about
-it and get on with life.  I recommend the latter (at least for now).
-
-Now you can press `return` to open an attachment in the proper program.
-
-[attachment]: http://linsec.ca/Using_mutt_on_OS_X#mailcap
-[attachment-mirror]: https://bitbucket.org/sjl/dotfiles/src/tip/mutt/view_attachment.sh
-
-### URLs
-
-One thing you'll probably want to do while reading email is open links.  Many
-terminal programs like iTerm2 let you command-click on a link to open it, but
-this is Mutt!  We shouldn't have to use the mouse!
-
-We're going to use a small helper program called urlview to make it easy to open
-URLs in email.  First, install it with `brew install urlview`.  Then make
-a `~/.urlview` file with the following contents:
-
-    :::text
-    COMMAND open %s
-
-This tells urlview what command to use to open a URL.  We're just going to use
-the OS X `open` command to do the right thing.
-
-Next, add the following line to your `~/.muttrc`:
-
-    :::text
-    macro pager \Cu "|urlview<enter>" "call urlview to open links"
-
-Now when you're reading an email with links in it you can press `Ctrl-u` to open
-urlview.  You'll see a screen like this:
-
-![urlview screen](/media/images{{ parent_url }}/mutt-urls.png)
-
-Navigate with `j`, `k`, `gg`, `G`, or `/` and press `return` when the desired
-link is selected.  That link will be filled in at the bottom of the screen in
-case you want to edit it, and you can press `return` one more time to actually
-open it in your default browser.
-
-That about wraps it up for reading email.  Now it's time to write some!
-
-Writing Email
--------------
-
-Writing email is one of the best parts of Mutt.  First let's add a few settings
-to get things nice and sane:
-
-    :::text
-    # Compose View Options -------------------------------
-    set realname = "Steve Losh"          # who am i?
-    set envelope_from                    # which from?
-    set sig_dashes                       # dashes before sig
-    set edit_headers                     # show headers when composing
-    set fast_reply                       # skip to compose when replying
-    set askcc                            # ask for CC:
-    set fcc_attach                       # save attachments with the body
-    unset mime_forward                   # forward attachments as part of body
-    set forward_format = "Fwd: %s"       # format of subject when forwarding
-    set forward_decode                   # decode when forwarding
-    set attribution = "On %d, %n wrote:" # format of quoting header
-    set reply_to                         # reply to Reply to: field
-    set reverse_name                     # reply as whomever it was to
-    set include                          # include message in replies
-    set forward_quote                    # include message in forwards
-
-You can reply to an email with `r` in the index or pager, or start a fresh one
-with `m`.
-
-There's actually not a lot to say about writing mail, because Mutt itself
-doesn't handle it!  Mutt passes control off to the text editor of your choice.
-Just specify your editor in your `~/.muttrc`:
-
-    :::text
-    set editor = "vim"        # Use terminal Vim to compose email.
-    set editor = "mvim -f"    # Use MacVim to compose email.
-    set editor = "subl -w"    # Use Sublime Text 2 to compose email.
-
-Any command that takes a filename and doesn't return until you're done can be
-used here.
-
-This is fantastic because it means you can use an editor you're already
-comfortable and fast in to write email instead of learning yet another set of
-shortcuts.
-
-Once you save the email in your editor and close it, Mutt will present you with
-a menu that looks like this:
-
-![Sending Screen](/media/images{{ parent_url }}/mutt-send-1.png)
-
-You can press `e` to go back and edit the mail, `a` to add attachments, and so
-on (the options are listed at the top of the screen).
-
-Before we can continue we need to tell Mutt how to send email.  Press `q` to
-discard the email for now.
-
-Sending Email
--------------
-
-Mutt does have (some) built-in SMTP support, but we're going to use a separate
-program to do our sending for a few reasons.
-
-First, Mutt's SMTP support was considered "experimental" the last time
-I checked.  Sending email is kind of important, so we'll stick with something
-tried and true.
-
-Second, we want a method that won't require our password in a plaintext config
-file.
-
-Go ahead and install the `msmtp` program through Homebrew with `brew install
-msmtp`.
-
-Next we're going to need to create a `~/.msmtprc` file with the following
-contents:
-
-    :::text
-    account stevelosh
-    host smtp.gmail.com
-    port 587
-    protocol smtp
-    auth on
-    from steve@stevelosh.com
-    user steve@stevelosh.com
-    tls on
-    tls_trust_file ~/.mutt/Equifax_Secure_CA.cert
-
-    account default : stevelosh
-
-`msmtp` will look in your keychain for your SMTP password, which we added
-earlier.  No plaintext passwords!
-
-The other "interesting" bit here is the `tls_trust_file`.  We're going to be
-connecting to Gmail's SMTP server over SSL, and `msmtp` needs to know if it can
-trust the certificate that the server on the other end is sending back.
-
-Copy the following and paste it into the path `tls_trust_file` is set to:
-
-    :::text
-    -----BEGIN C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NA2zsmWLIodz2uFHdh1voqZiegDfqnc1zqcPGUIWVEX/r87yloqaKHee95
-    70+sB3c4
-    -----END CERTIFICATE-----
-
-If you're paranoid and don't trust that I'm giving you the right cert (or that
-someone has hacked my site and changed it), you can generate it yourself.  I'll
-leave that to you -- if you care enough about it you'll figure it out.
-
-Now we need to tell Mutt to use msmtp.  Add the following to your `~/.muttrc`
-file:
-
-    :::text
-    set from     = "steve@stevelosh.com"
-    set sendmail = "/usr/local/bin/msmtp -a stevelosh"
-    set sendmail_wait = 0
-    unset record
-
-The `-a stevelosh` will need to change to whatever you named your account in the
-msmtp config.
-
-The `unset record` line tells Mutt to not append a copy of every email you send
-to a file on your hard drive.  Gmail will save the emails you send in the sent
-folder, so you'll get the the next time you sync with offlineimap anyway.
-
-The `sendmail_wait` line tells Mutt to wait for the msmtp program to finish
-sending the mail before returning control, instead of running it in the
-background.  This makes it obvious if there's a problem sending a message, which
-I prefer to silent, backgrounded failures.
-
-Now you can send email!  Awesome!
-
-Once you've composed a test email and saved it you'll be presented with a screen
-like this (which we saw in the previous section):
-
-![Sending Screen](/media/images{{ parent_url }}/mutt-send-1.png)
-
-The keys you need are listed along the top.  Pressing `y` now will invoke msmtp
-and send your email!
-
-You'll see "Sending message..." at the bottom of the screen while msmtp is
-working.  If there's a problem, Mutt will tell you the error.  Figure it out
-before moving on.
-
-Postponing Drafts
------------------
-
-Sometimes I like to read and respond to email without an internet connection,
-then actually send the replies when I get back to civilization.
-
-Since all of my email is stored locally, reading it offline is trivial.
-
-To reply or compose offline, I use Mutt's "postpone" feature.  First I've added
-the following line to my `~/.muttrc`:
-
-    :::text
-    bind compose p postpone-message
-
-Now when I'm at the sending screen instead of pressing `y` to send I can press
-`p` to postpone the message.  This places the message in the drafts folder.
-
-The drafts folder in Mutt is just a normal folder of emails like any other.
-When you sync with offlineimap your postponed email will get pushed up to Gmail
-as a draft.  You can edit it in the Gmail web interface if you like, and those
-edits will sync back down too.
-
-If you want to edit your drafts (postponed messages) locally, you need to
-"recall" them.  I have the following line in my `~/.muttrc` to set the key to
-the same one as I used to postpone it in the first place:
-
-    :::text
-    bind index p recall-message
-
-You can also use `m` to start writing a new email, and mutt will prompt you if
-there are existing postponed messages.
-
-Once you hit `p` (or `m` and then select "yes") Mutt will show you a list of the
-postponed messages.  Select one and press `return` to start editing it again.
-If there's only one it will skip this step and simply open it for you
-immediately.
-
-Once you're done editing you can either postpone it again or send it as usual.
-
-Unfortunately you have to go through the "recall → edit → send" process each
-time.  As far as I know there's no way to simply run down a list of postponed
-emails sending each one with a single keystroke.  But that's not *too* bad, and
-it's great to be able to work offline like this.
-
-Once you send the postponed email (through Mutt or the Gmail web interface) it
-disappears from the drafts folder and the postponed list as you would expect.
-
-Contacts
---------
-
-Next we'll want to get Mutt to autocomplete our contacts from the OS X address
-book.  I like using the OS X address book because it automatically syncs between
-my laptops and phone, so I only need to maintain one address list.
-
-### Autocompleting
-
-Unfortunately I've got some bad news for you: you're going to need to install
-XCode.
-
-No, not the command-line developer tools.  The full XCode.  I'm sorry, but trust
-me when I say it's going to save you a lot of pain, so just grumble to yourself
-a bit and do it.
-
-Okay, now that you've got XCode you can install the `contacts` program through
-Homebrew with `brew install contacts`.
-
-`contacts` is a command-line program that you can use to query your address
-book.  To tell Mutt how to use it add the following lines to your
-`~/.mutt/muttrc`:
-
-    :::text
-    set query_command = "contacts -Sf '%eTOKEN%n' '%s' | sed -e 's/TOKEN/\t/g'"
-    bind editor <Tab> complete-query
-    bind editor ^T    complete
-
-Now when you're filling out an email address field you can type a few characters
-and hit Tab to get a screen like this:
-
-![Contacts](/media/images{{ parent_url }}/mutt-contacts-1.png)
-
-You can use `j` and `k` to select an item, press return to complete it.  Press
-`q` if you've changed your mind and want to cancel the completion.  Look at the
-top of the screen for more handy little keys you can use here.
-
-If there's only one item in the list Mutt won't bother showing you this screen
-and will just complete it right away.
-
-This completion searches more than just the email address.  It'll also search
-the names and possibly other fields from the address book entries as well.
-
-### Adding Contacts
-
-What about adding contacts to your address book?  Any contacts you add on your
-phone will automatically be synced, but what if you're reading your mail in Mutt
-and just want to add the sender as a contact without leaving your command line?
-
-For this I use a little script that [Simone Manganelli][simx] wrote for me
-called `addcontact`.  You can [get it here][addcontact] and stick it in your
-`$PATH` somewhere.  It's just a command-line utility that you can use like this:
-
-    :::text
-    $ addcontact Steve Losh steve@stevelosh.com
-    $ addcontact "Steve Losh" steve@stevelosh.com
-    $ addcontact Steve Losh work steve@pculture.org
-
-As you can see, it's pretty flexible.
-
-**Note:** This utility always adds a new contact record, so if you add someone
-that's already in there you're going to get a duplicate entry.  If that happens
-you can search for the entries in Contacts.app, select the duplicates, and use
-"Card → Merge Selected Cards" to combine them.
-
-Okay, so we can now add contacts from the command line.  You could set up a Mutt
-macro to automatically add senders without too much trouble, but I don't do
-that.  If I want to add a contact I just hit `!` and type out the shell command.
-It's not that much work, and sometimes the name in the "From:" field is in
-a weird format like "Last, First Middle" instead of "First Last", so this gives
-me a chance to clean it up before I add it.
-
-[simx]: http://simx.me/
-[addcontact]: https://bitbucket.org/sjl/dotfiles/src/tip/bin/addcontact
-
-Searching Email
----------------
-
-If you have more than a screen full of email in any given folder, you're going
-to want a way to search through it.  Mutt's built-in searching is a good start,
-but I also use another program to get a bit more power.
-
-### Vanilla Searching
-
-There are two main ways to search your email in Mutt: plain searching and
-"limiting".
-
-Plain searching is done with the `/` key.  It works similarly to Vim or less:
-you press `/`, type your query, and press enter to perform the search.  You can
-use `n` to move to the next match, and the search will loop around to the top if
-it hits the bottom.
-
-I have the following lines in my `~/.muttrc` to bind `N` to go to the *previous*
-match:
-
-    :::text
-    bind index N search-opposite
-    bind pager N search-opposite
-
-Normally the `N` key marks a message as unread (or "new").  I personally never
-want to do that.  Unread mail should be "mail that has not been read".  If you
-use that feature you'll want to rebind it to something else.
-
-Two things about queries:
-
-1. They are regular expressions (actually it's more powerful than than, see [the
-   documentation][patterns] for more information).
-2. They only search the To and Subject fields (*not* the message bodies!).
-
-I generally use this kind of searching when I see the email I want to open on
-the screen but don't feel like pressing `j` or `k` forty times to move through
-the list.  When I'm actually trying to find a message I can't already see on the
-screen I use limiting.
-
-[patterns]: http://www.mutt.org/doc/manual/manual-4.html#ss4.2
-
-### Vanilla Limiting
-
-Limiting is the other way Mutt provides for searching mail.  It's done with the
-`l` key by default.
-
-Like `/`, `l` will ask you for a pattern.  But instead of simply moving you to
-the next message that matches the pattern, Mutt will *hide* messages that don't
-match.
-
-This lets you see all the ones that match in a single list.  This list works
-just like a normal list.  You can search it with `/`, tag things, and so on as
-you normally would.  It's really quite nice once you get used to it.
-
-To remove the limiting once you're done, you can limit to the special value
-`all`.  I've added a line to my `~/.muttrc` so I can do that with a single key:
-
-    :::text
-    macro index a "<limit>all\n" "show all messages (undo limit)"
-
-**Note:** This shadows the `create-alias` function which I never use.
-
-Limit queries work exactly like search queries, so you can do powerful stuff
-like `~f arthur ~C honza ~s api` ("limit to messages from 'arthur', to or cced
-to 'honza', containing 'api' in the subject").
-
-### Full-Text Searching
-
-By now you're probably wondering how to search the full text of messages.  There
-are two ways: one simple and slow, the other complicated and fast.
-
-First is the simple, slow way.  You can use `~B` in your searches and limits to
-search inside the entire message.  If your folder only has a hundred messages
-this works great.  But once you have a few more (my archive has about 30,000 at
-the moment, and I prune it fairly often) it quickly becomes too slow to be
-usable.
-
-I use a program called [notmuch][] to index and search my email.  It's blazingly
-fast and works pretty well.
-
-First, install it with `brew install notmuch`.  Now you need
-a `~/.notmuch-config` file.  Run `notmuch setup` to generate one.  It's pretty
-straightforward.  When it asks you for the path to your archive, that's the path
-to the folder containing all your individual IMAP folders
-(`~/.mail/steve-stevelosh.com` in my setup).
-
-Now run `notmuch new` to perform the initial index.  It might take a while if
-you have a lot of folders.  Subsequent indexes will be much faster since they'll
-only reindex whatever changed since the last time.
-
-You'll want to reindex when your email changes, so add a hook in your
-`~/.offlineimaprc` to run `notmuch new` whenever offlineimap syncs your email:
-
-    :::text
-    [Account SteveLosh]
-    localrepository = SteveLosh-Local
-    remoterepository = SteveLosh-Remote
-    status_backend = sqlite
-    postsynchook = notmuch new
-
-Now you can use `notmuch search foo` to search your mail for "foo" from the
-command line.  Try a couple of queries and make sure it works.
-
-Now we need to hook notmuch into Mutt.  There are a number of different ways to
-do this, all of them hacky and ugly.  I'll describe how I do it.
-
-A quick overview of how this is going to work:
-
-1. You'll press a key in Mutt to activate searching.
-2. You'll type your query and press return.
-3. Your mail will be searched with `notmuch`.
-4. Τhe resulting messages will be symlinked into a temporary maildir folder.
-5. That temporary folder will be opened in Mutt.
-
-First get [mutt-notmuch-py][].  The original `mutt-notmuch` is a Perl script
-with many external requirements that are a pain to install, and it doesn't work
-on OS X.  `mutt-notmuch-py` is a Python script with zero external requirements.
-
-`mutt-notmuch-py` is going to handle steps 2 through 4 in the list.  Get the
-script into your `$PATH` somehow and then run it:
-
-    :::text
-    $ mutt-notmuch-py -G ~/.mail/temporary/search
-    Query: foo
-
-    $ ls ~/.mail/temporary/search
-    cur new
-
-The `-G` tells it to not perform certain Gmail-specific stuff that we don't
-need.  The path is where it will create the temporary maildir folder with the
-results.  Each time you run it this folder will be wiped clean before the new
-results are linked into it.
-
-Now we need to handle the first and last points in the list.  I have the
-following mapping in my `~/.muttrc`:
-
-    :::text
-    macro index S "<enter-command>unset wait_key<enter><shell-escape>mutt-notmuch-py ~/.mail/temporary/search<enter><change-folder-readonly>+temporary/search<enter>" "search mail (using notmuch)"
-
-That's a lot to take in, so let's see how it works piece by piece:
-
-    :::text
-    macro index S
-
-We're going to use the `S` key to perform a full search of all of our mail.
-
-    :::text
-    <enter-command>unset wait_key<enter>
-
-Unset the `wait_key` Mutt option to prevent Mutt from asking us to press a key
-after the search has finished.
-
-    :::text
-    <shell-escape>mutt-notmuch-py -G ~/.mail/temporary/search<enter>
-
-Run `mutt-notmuch-py`.  Control will pass over to that script and it will ask
-you for your query, run the search, set up the results folder, and then hand
-control back to Mutt.
-
-    :::text
-    <change-folder-readonly>+temporary/search<enter>
-
-Now we change over to the temporary folder in Mutt, and we're now looking at
-a list of search results!  Since this is a real Maildir folder like any other
-one we can use the full range of tools to interact with it (searching, limiting,
-etc).
-
-Finally, let's get this search results folder in our sidebar so we can see where
-we are visually at all times:
-
-    :::text
-    mailboxes +steve-stevelosh.com/INBOX \
-              +steve-stevelosh.com/vim \
-              +steve-stevelosh.com/clojure \
-              ...
-              +temporary/search \
-
-Now the search results folder can be navigated like any other one.  That's it
-for email searching!  Now you should have a setup that you can use in real life
-to manage your email.
-
-[notmuch]: http://notmuchmail.org/
-[mutt-notmuch-py]: https://github.com/honza/mutt-notmuch-py
-
-Conclusion
-----------
-
-Mutt is definitely a beast.  It's old, crufty, and ugly, but if you spend the
-time to set it up and learn to use it you'll be rewarded with a fast, powerful,
-customizable environment for working with your email.
-
-A wonderful trend these days is that more and more sites are including the
-ability to respond to comments and such by simply replying to their notification
-emails.  This means that often you can reply to Facebook emails, comment on
-GitHub pull requests, and respond to Bitbucket issues all without leaving the
-comfort of your finely-tuned email client.
-
-Mutt's not for everyone, but if you deal with a lot of email and have some time
-to spend you should give it a try.  You just might learn to love the old dog.
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/10/the-homely-mutt.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,1360 @@
++++
+title = "The Homely Mutt"
+snip = "Sparrow's dead?  Why not try Mutt?"
+date = 2012-10-01T10:30:00Z
+draft = false
+
++++
+
+Now that [Sparrow][] is [effectively dead][sparrow-dead] many of its users will
+be looking for a new email client.  If you're not afraid of the terminal you may
+want to give [Mutt][] a try.
+
+Mutt certainly isn't the prettiest email client around, and its
+setup/configuration process is one of the ugliest out there.  But once you get
+it set up it's got a lot of advantages over many other email clients.
+
+In this post I'll show you how to set up Mutt on OS X like I do.
+
+[Sparrow]: http://sparrowmailapp.com/
+[sparrow-dead]: http://www.theverge.com/2012/7/20/3172222/google-buys-sparrow-mail
+[Mutt]: http://www.mutt.org/
+
+{{% toc %}}
+
+How I Use Email
+---------------
+
+This setup is going to be specific to the way I work with email.  Notably:
+
+* I have a Google Apps account that provides my steve@stevelosh.com email
+  address.
+* I have many other email addresses, but they all simply forward to my main one.
+* All mail I send comes from steve@stevelosh.com.
+* I store my contacts in the OS X address book.
+* All email comes into my inbox (or to a folder for a specific mailing list).
+* Once I'm done with an email, I remove it from my inbox and it lives in the
+  "All Mail" archive.  I don't sort email into folders after it arrives.
+* I sometimes read email offline and mark it for deletion, then sync that
+  deletion back to the server once I get online again.
+* Sometimes I write email without an internet connection and send it once I get
+  connected again.
+
+My email setup is tailored around those requirements, so that's what it does
+best.  Mutt is very configurable though, so if you work differently you can
+probably bend it to make it do what you want.
+
+In particular, extending this setup to work with multiple email accounts
+wouldn't be too much trouble.  I used to work with two separate accounts until
+I said "screw it, I'll just use the one".
+
+Other Guides and Resources
+--------------------------
+
+I've used a lot of other guides to figure out how to get this giant Rube
+Goldberg machine of an email client working.  Here are a few of them:
+
+* <http://thomas.pelletier.im/2010/10/low-memory-mail-client/>
+* <http://www.andrews-corner.org/mutt.html>
+* <http://jstorimer.com/shells/2010/01/19/using-mutt-with-gmail-on-osx.html>
+* <http://www.vijaykiran.com/2010/01/27/mutt-for-gmail-imap-on-mac-os-x/>
+* <http://hynek.me/articles/my-mutt-gmail-setup/>
+* <https://wiki.archlinux.org/index.php/Mutt>
+* <http://linsec.ca/Using_mutt_on_OS_X>
+* <http://www.mutt.org/doc/manual/manual.html>
+* <http://pbrisbin.com/posts/two_accounts_in_mutt>
+* <http://upsilon.cc/~zack/blog/posts/2011/01/how_to_use_Notmuch_with_Mutt/>
+
+Overview
+--------
+
+I'm going to give it to you straight: getting this whole contraption set up is
+going to take at least an hour from start to finish, not counting the time it'll
+take to download all of your email and install stuff.  Set aside an evening if
+you're serious about this.
+
+It's an investment, and you might not want to make it.  If not, go use
+Thunderbird, er, Sparrow, er, I don't know, the Gmail web interface or
+something.
+
+Mutt on its own doesn't do very much, so we're going to combine it with a few
+other things to get the job done.  Here's a bird's eye view of what it'll look
+like when we're done:
+
+![Diagram](/media/images/blog/2012/10/what-the-mutt.png)
+
+If this diagram doesn't make you run screaming you might just be masochistic
+enough to make it through the initial setup of Mutt.  If you do, you'll be
+rewarded with email bliss that won't go away when Google or Facebook decide to
+toss some money around.
+
+Getting Email
+-------------
+
+First thing's first: we're going to pull down our email from Gmail to our local
+machine.  All of it.  It'll take a while the first time you sync, but has a few
+benefits.
+
+### Why Local Email?
+
+Having a local copy of all of your email means you've always got access to it,
+no matter where you are.  Looking for that one person's address they emailed you
+six years ago when you're trying to find their house and you don't have an
+internet connection?  No problem, it's on your hard drive.
+
+This also acts as a backup in case Google ever decides to kill your Gmail
+account.  It'll be stored in a common format that a lot of programs can read, so
+you've got a safety net.  And the email is stored as normal files, so if you use
+something like Time Machine or [Backblaze][] that's yet another free backup.
+
+In this setup **all of your email is stored as plain text**.  If you want it
+encrypted just use OS X's full-disk encryption and you're set.
+
+I use [offlineimap][] to pull email down from Gmail and get it on my hard drive.
+Offlineimap will also sync any changes you make to this local copy back up to
+Gmail.
+
+[offlineimap]: http://offlineimap.org/
+[Backblaze]: http://www.backblaze.com/partner/af3574
+
+### The Alternative
+
+You may not care as much about reading your email offline as I do.  If you can
+tolerate always needing an internet connection to read your mail, you can skip
+this painful section and follow [this guide][roma] instead.
+
+You'll probably still find the other sections of this post interesting though.
+
+[roma]: http://empt1e.blogspot.com/2009/10/using-mutt-with-gmail-imap-complete.html
+
+### Installing offlineimap
+
+I've gone through a number of laptops in the past few years, and each time
+I spend a painful half hour or so screwing around with the latest version of
+offlineimap's backwards-incompatible changes.
+
+If you're determined to run the latest version of offlineimap, you can install
+it with pip or something.  If you just want to download your fucking email and
+get on with your life, you can follow the instructions I've laid out for you
+here:
+
+```text
+git clone git://github.com/spaetz/offlineimap.git
+cd offlineimap
+git checkout 679c491c56c981961e18aa43b31955900491d7a3
+python setup.py install
+```
+
+That's the version I'm using.  It works.  You can use a newer one if you want,
+but expect to spend some time figuring out how to fix the configuration in this
+post to work with whatever breaking changes have been made since then.  The last
+time I tried this I got to rewrite all my nametrans stuff.  That was fun.
+
+### Configuring offlineimap
+
+Once you've got offlineimap installed, you'll need to create
+a `~/.offlineimaprc` file.  You can keep it in your dotfiles repo and symlink it
+into place if you want.  Here's a sample to get you started:
+
+```text
+[general]
+ui = TTY.TTYUI
+accounts = SteveLosh
+pythonfile=~/.mutt/offlineimap.py
+fsync = False
+
+[Account SteveLosh]
+localrepository = SteveLosh-Local
+remoterepository = SteveLosh-Remote
+status_backend = sqlite
+postsynchook = notmuch new
+
+[Repository SteveLosh-Local]
+type = Maildir
+localfolders = ~/.mail/steve-stevelosh.com
+nametrans = lambda folder: {'drafts':  '[Gmail]/Drafts',
+                            'sent':    '[Gmail]/Sent Mail',
+                            'flagged': '[Gmail]/Starred',
+                            'trash':   '[Gmail]/Trash',
+                            'archive': '[Gmail]/All Mail',
+                            }.get(folder, folder)
+
+[Repository SteveLosh-Remote]
+maxconnections = 1
+type = Gmail
+remoteuser = steve@stevelosh.com
+remotepasseval = get_keychain_pass(account="steve@stevelosh.com", server="imap.gmail.com")
+realdelete = no
+nametrans = lambda folder: {'[Gmail]/Drafts':    'drafts',
+                            '[Gmail]/Sent Mail': 'sent',
+                            '[Gmail]/Starred':   'flagged',
+                            '[Gmail]/Trash':     'trash',
+                            '[Gmail]/All Mail':  'archive',
+                            }.get(folder, folder)
+folderfilter = lambda folder: folder not in ['[Gmail]/Trash',
+                                             'Nagios',
+                                             'Django',
+                                             'Flask',
+                                             '[Gmail]/Important',
+                                             '[Gmail]/Spam',
+                                             ]
+```
+
+It's kind of long, so let's go through it line by line and see what's going on.
+
+```text
+[general]
+ui = TTY.TTYUI
+accounts = SteveLosh
+pythonfile=~/.mutt/offlineimap.py
+fsync = False
+```
+
+First we tell offlineimap to use the `TTY.TTYUI` ui.  Yes, this program that
+syncs your email has multiple user interfaces.  I guess if you can't decide what
+color the bikeshed should be you can just build a whole bunch of bikesheds
+instead.
+
+Then we specify the accounts.  There's only one because as I said before:
+I only use a single email account that all my addresses forward to.  If you
+wanted to have many, you'd change this line.
+
+The `pythonfile` is just a file that offlineimap will parse (as Python) before
+loading the rest of the config, so you can define custom helper functions more
+easily.  We'll see more of this later.
+
+We're also telling offlineimap that it doesn't need to fsync after every single
+operation.  This will speed things up, and since it's just a local copy it's
+typically not a big deal if we lose an email here and there from a crash (it'll
+just be synced the next time anyway).
+
+```text
+[Account SteveLosh]
+localrepository = SteveLosh-Local
+remoterepository = SteveLosh-Remote
+status_backend = sqlite
+```
+
+This next section hooks up a few things.  First, it tells offlineimap which
+local and remote repositories to use for the account.  Manual configuration
+instead of sane defaults is a recurring theme we'll see throughout this process.
+
+Hey, I titled the entry "The *Homely* Mutt" for a reason.
+
+We're also going to use a SQLite-based cache for this account.  If you don't
+already have SQLite you'll want to get it with `brew install sqlite`.
+
+```text
+[Repository SteveLosh-Local]
+type = Maildir
+localfolders = ~/.mail/steve-stevelosh.com
+nametrans = lambda folder: {'drafts':  '[Gmail]/Drafts',
+                            'sent':    '[Gmail]/Sent Mail',
+                            'flagged': '[Gmail]/Starred',
+                            'trash':   '[Gmail]/Trash',
+                            'archive': '[Gmail]/All Mail',
+                            }.get(folder, folder)
+```
+
+Now we're getting to the meat of the configuration.  This "local repository" is
+going to be the mail as it sits on our hard drive.  We're going to use the
+[Maildir format][maildir] because it plays nicely with Mutt (and tons of other
+stuff).
+
+Then we specify the path where we're going to keep the mail.  This is going to
+take a lot of space if you've got a lot of mail.  Attachments are downloaded
+too.  When I said you're getting an offline copy of all your email I meant *all*
+of it.
+
+I think offlineimap needs the `~/.mail` directory created for it.  It's been
+a while since I did this, so I might be wrong, but if it complains about not
+being able to access the mail folders just go ahead and `mkdir ~/.mail`.
+
+Next we have the craziest part of the configuration: name translation.
+
+Here's the issue: offlineimap needs to know how to translate the names of
+folders on the IMAP server to folder names on your hard drive.
+
+Also, Gmail doesn't actually use *folders* but its own concept called "labels".
+But since the IMAP protocol doesn't know about labels, it fakes them by making
+them appear to be folders.
+
+User-created labels in Gmail (like "Mercurial" or "Clients") will appear as
+folders with those names through IMAP.
+
+Built-in, special Gmail folders have names that start with `[Gmail]/`.  We need
+to turn those into something sane for our hard drive, so that's what this
+nametrans setting is for.  It's a Python function that takes the remote folder
+name and returns the name that should be used on your local hard drive.
+
+Yes, you read that right.  This is Python code embedded in the right hand side
+of an INI file's setting assignment.  I am not fucking with you, this is
+seriously how you do it.  Go ahead and crack open that beer now.
+
+So the "Sent Mail" folder in your Gmail account will be synced to
+`~/.mail/steve-stevelosh.com/sent`.  Cool.
+
+(No, I don't know what would happen if you created a label called `[Gmail]/All
+Mail` in Gmail.  If you try please let me know, but I take no responsibility if
+it ends with all your email being deleted.)
+
+[maildir]: https://en.wikipedia.org/wiki/Maildir
+
+```text
+[Repository SteveLosh-Remote]
+maxconnections = 1
+type = Gmail
+remoteuser = steve@stevelosh.com
+remotepasseval = get_keychain_pass(account="steve@stevelosh.com", server="imap.gmail.com")
+realdelete = no
+nametrans = lambda folder: {'[Gmail]/Drafts':    'drafts',
+                            '[Gmail]/Sent Mail': 'sent',
+                            '[Gmail]/Starred':   'flagged',
+                            '[Gmail]/Trash':     'trash',
+                            '[Gmail]/All Mail':  'archive',
+                            }.get(folder, folder)
+folderfilter = lambda folder: folder not in ['[Gmail]/Trash',
+                                             'Nagios',
+                                             'Django',
+                                             'Flask',
+                                             '[Gmail]/Important',
+                                             '[Gmail]/Spam',
+                                             ]
+```
+
+Finally, the home stretch.  The last section described the folder on our local
+hard drive, and this one describes our Gmail account.
+
+First, we tell offlineimap to only ever use a single connection at a time.  You
+can try increasing this number for better performance, but in my experience
+Google is not afraid to enforce its rate limits and would cut me off fairly
+often when I tried that.  Just leave it at one if you want to be safe.
+
+Next is the type.  Luckily offlineimap provides a `Gmail` type that handles
+a lot of the craziness that is Gmail's IMAP setup.  Nice.
+
+Then we have the username.  Nothing special here, except that if you have
+a non-apps account (i.e.: an actual vanilla Gmail account) you may or may not
+need to include the `@gmail.com` in the username.  I don't know.  If one doesn't
+work, just try the other.
+
+Next we have `remotepasseval`.  This is a bit of Python code (drink!) that
+should return the password for the account.
+
+What is this `get_keychain_pass` function?  Well, remember when we saw the
+`pythonfile` setting back in the general section?  It's a function defined in
+there.  I'll talk about that in the next section, for now just accept that it
+works.
+
+Next we set `realdelete` to no.  If this is set to yes, then deleting an email
+in your inbox would actually delete it entirely.  When you set it to no, then
+deleting an email from your inbox (or any label's folder) will leave it in
+Gmail's All Mail.
+
+If you want to really delete an email, you'll need to delete it from All Mail
+(which is named archive on our local filesystem, remember?).  I feel like this
+is a good compromise.  I rarely care about actually deleting mail, given that
+I have many unused gigabytes available on Gmail.
+
+Next we have another nametrans setting.  This is a Python function (drink!) just
+like the one for the local repository, except it goes in the other direction.
+It takes the name of a local folder and returns the name of the folder on the
+IMAP server.  Knowing this, it should be easy to understand this setting.
+
+Finally, we have `folderfilter`.  This is a Python function (drink!) that takes
+a **remote** folder name and returns `True` if that folder should be synced, or
+`False` if it should **not** be synced.  I've chosen to skip syncing my Spam and
+Trash folders, as well as a few mailing list labels I don't check all that
+often.  Customize this to your own taste.
+
+### Retrieving Passwords
+
+We're almost ready, but there's one more thing we need to do, and that's
+implement a secure way for offlineimap to get access to our Gmail password.
+
+If you don't care too much about security, you *can* configure offlineimap with
+a plaintext password right in the config file.  But don't do that.  It'll only
+take a minute to do this securely.
+
+First, you need to add your Gmail password into your OS X keychain.  Open the
+Keychain Access app and press the `+` button:
+
+![Keychain 1](/media/images/blog/2012/10/keychain-1.png)
+
+Then fill out the form.  The "Keychain Item Name" should be
+`http://imap.gmail.com`.  The "Account Name" should be your email address.  The
+password should be your password:
+
+![Keychain 2](/media/images/blog/2012/10/keychain-2.png)
+
+Press "Add".  Now repeat the process for the SMTP server.  The "Keychain Item
+Name" should be `smtp://smtp.gmail.com`.  The "Account Name" should be your
+email address.  The password should be your password:
+
+![Keychain 3](/media/images/blog/2012/10/keychain-3.png)
+
+Now we need to create the `offlineimap.py` file we pointed offlineimap to
+earlier.  It needs to contain the `get_keychain_pass` function, which takes an
+`account` and `server` and return the password.  Here's the file I'm using:
+
+```python
+#!/usr/bin/python
+import re, subprocess
+def get_keychain_pass(account=None, server=None):
+    params = {
+        'security': '/usr/bin/security',
+        'command': 'find-internet-password',
+        'account': account,
+        'server': server,
+        'keychain': '/Users/sjl/Library/Keychains/login.keychain',
+    }
+    command = "sudo -u sjl %(security)s -v %(command)s -g -a %(account)s -s %(server)s %(keychain)s" % params
+    output = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
+    outtext = [l for l in output.splitlines()
+               if l.startswith('password: ')][0]
+
+    return re.match(r'password: "(.*)"', outtext).group(1)
+```
+
+In a nutshell, it uses `/usr/bin/security` to retrieve the password.  Read
+through the code if you're curious.
+
+This is not *completely* secure, but it's better than having your password in
+a plaintext file in your home directory.
+
+Whew!  Time to actually run this thing and pull down our email!
+
+### Running offlineimap
+
+Assuming everything is in place, open a terminal and run offlineimap:
+
+    offlineimap
+
+Go read a book, because this is going to pull down all the email (with
+attachments) in any folders you didn't exclude in the config file.
+
+**If there's an error, stop and figure out what went wrong**.  Remember,
+offlineimap is a *two-way* sync, so there's always the possibility it'll eat
+your email if you seriously mess something up!  I wish it had a
+`--dont-touch-remote` option you could use as a safety net for the original
+sync, but it doesn't, so be careful!
+
+In the future you can use `offlineimap -q` to run it in "quick mode".  It'll
+perform fewer checks but will generally be much faster.
+
+If you want to set up offlineimap to run every 5 minutes or so, you can use
+`launchd`.  `cron` does not work for some reason.  I'm not entirely sure why.
+
+Personally I actually *like* having to press a key to fetch new mail.  It's less
+of a distraction than having new mail rolling in all the time.  I can get new
+email when I'm ready to actually look at it, rather than having it nagging me
+all the time.
+
+The great part about offlineimap is that once you've got it configured and it's
+successfully run once, it's pretty much rock solid from then on.  You can run it
+often, `Ctrl-c` it, put the laptop to sleep in the middle of a run, or `kill -9`
+it, and it still won't lose emails.  On the next sync it'll fix anything that's
+missing.
+
+Mutt!
+-----
+
+Now that you've got your email on your computer, it's finally time to start
+using Mutt itself!
+
+### Installing
+
+Mutt can be installed in a bunch of different ways, but the easiest is through
+Homebrew:
+
+```text
+brew install mutt --sidebar-patch
+```
+
+The sidebar patch is a third-party patch that adds a sidebar to Mutt.  I don't
+know why it's not in core Mutt because it's insanely useful.  Oh well, at least
+Homebrew makes it simple to get.
+
+That's pretty much it for installation, but don't get too relaxed because you're
+far from done.
+
+### Configuring
+
+Mutt is *very* configurable.  This is great once you've become a power user and
+want to mold it to your will, but terrible when you're just getting started.
+
+Mutt settings are kept in a `~/.muttrc` file.  If this file doesn't exist Mutt
+will look for `~/.mutt/muttrc` (note the lack of a dot in the filename), so you
+can put it there if you prefer.
+
+Let's start by creating a basic `~/.muttrc` piece by piece (a lot of this was
+taken from [this article][pris]).
+
+Once you've got a bit of Mutt under your belt you'll want to read [the
+documentation][muttdoc] for these settings, but for now just use them to keep
+things sane.
+
+[pris]: http://pbrisbin.com/posts/two_accounts_in_mutt
+[muttdoc]: http://www.mutt.org/doc/manual/manual-6.html
+
+```text
+# Paths ----------------------------------------------
+set folder           = ~/.mail               # mailbox location
+set alias_file       = ~/.mutt/alias         # where to store aliases
+set header_cache     = ~/.mutt/cache/headers # where to store headers
+set message_cachedir = ~/.mutt/cache/bodies  # where to store bodies
+set certificate_file = ~/.mutt/certificates  # where to store certs
+set mailcap_path     = ~/.mutt/mailcap       # entries for filetypes
+set tmpdir           = ~/.mutt/temp          # where to keep temp files
+set signature        = ~/.mutt/sig           # my signature file
+```
+
+Here we tell Mutt where to find the various folders it needs.
+
+```text
+# Basic Options --------------------------------------
+set wait_key = no        # shut up, mutt
+set mbox_type = Maildir  # mailbox type
+set timeout = 3          # idle time before scanning
+set mail_check = 0       # minimum time between scans
+unset move               # gmail does that
+set delete               # don't ask, just do
+unset confirmappend      # don't ask, just do!
+set quit                 # don't ask, just do!!
+unset mark_old           # read/new is good enough for me
+set beep_new             # bell on new mails
+set pipe_decode          # strip headers and eval mimes when piping
+set thorough_search      # strip headers and eval mimes before searching
+```
+
+These are some basic options to make Mutt behave a bit more sanely.
+
+```text
+# Sidebar Patch --------------------------------------
+set sidebar_delim   = '  │'
+set sidebar_visible = yes
+set sidebar_width   = 24
+color sidebar_new color221 color233
+```
+
+These options are specific to the sidebar patch.
+
+```text
+# Status Bar -----------------------------------------
+set status_chars  = " *%A"
+set status_format = "───[ Folder: %f ]───[%r%m messages%?n? (%n new)?%?d? (%d to delete)?%?t? (%t tagged)? ]───%>─%?p?( %p postponed )?───"
+```
+
+This gives us a pretty status bar with the information we care about (and none
+of the stuff we don't).
+
+```text
+# Header Options -------------------------------------
+ignore *                                # ignore all headers
+unignore from: to: cc: date: subject:   # show only these
+unhdr_order *                           # some distros order things by default
+hdr_order from: to: cc: date: subject:  # and in this order
+```
+
+These options hide some of the extra email headers we don't care about when
+viewing and composing email.
+
+Now it's time to fill on our account details:
+
+```text
+# Account Settings -----------------------------------
+
+# Default inbox.
+set spoolfile = "+steve-stevelosh.com/INBOX"
+
+# Alternate email addresses.
+alternates sjl@pculture.org still\.?life@gmail.com steve@ladyluckblues.com steve@pculture.org
+
+# Mailboxes to show in the sidebar.
+mailboxes +steve-stevelosh.com/INBOX \
+          +steve-stevelosh.com/vim \
+          +steve-stevelosh.com/clojure \
+          +steve-stevelosh.com/python \
+          +steve-stevelosh.com/mercurial \
+          +steve-stevelosh.com/archive \
+          +steve-stevelosh.com/sent \
+          +steve-stevelosh.com/drafts \
+
+# Other special folders.
+set mbox      = "+steve-stevelosh.com/archive"
+set postponed = "+steve-stevelosh.com/drafts"
+```
+
+Most of those should be self-explanatory.  Fill in the appropriate values for
+your mail folder(s).
+
+We'll add more as we go through the next few sections, but that's enough to get
+us started.
+
+### Running
+
+Now that you've got Mutt configured you can run it:
+
+```sh
+mutt
+```
+
+I like to always be in my `~/Desktop` folder when in Mutt, so that when I save
+emails or attachments they go there by default.  I have a little shell function
+set up that `cd`s there for me before running Mutt:
+
+```sh
+alias mutt 'cd ~/Desktop && mutt'
+```
+
+If you run the [new fish shell][fish], this is going to cause problems later
+(long story, but it's related to the `read` builtin).  Do yourself a favor and
+head those confusing issues off at the pass with a fish function:
+
+```text
+function mutt
+    bash --login -c 'cd ~/Desktop; /usr/local/bin/mutt' $argv;
+end
+```
+
+Remember that if you use another shell like this you'll want to set up any
+aliases and your `PATH` for that shell properly (probably identically to your
+main shell).
+
+[fish]: http://ridiculousfish.com/shell/
+
+Reading Email
+-------------
+
+Once you start Mutt you should be looking at a list of the email in your inbox.
+If so: congratulations!  If not: stop and figure out what went wrong.
+
+### The Index
+
+When viewing a folder, Mutt presents you with a list of your email.  This view
+is called the "index":
+
+![Mutt's Index](/media/images/blog/2012/10/mutt-index.png)
+
+This entry isn't meant be a guide to setting up Mutt on OS X.  For a full guide
+on how to *use* Mutt, you can Google around for some tutorials, or just learn as
+you go with `?`.  The `?` key will show you a list of all the keys you can use
+wherever you currently are, and what they do.
+
+Let's add a few lines to our `~/.muttrc` to make the index view behave a bit
+more nicely:
+
+```text
+# Index View Options ---------------------------------
+set date_format = "%m/%d"
+set index_format = "[%Z]  %D  %-20.20F  %s"
+set sort = threads                         # like gmail
+set sort_aux = reverse-last-date-received  # like gmail
+set uncollapse_jump                        # don't collapse on an unread message
+set sort_re                                # thread based on regex
+set reply_regexp = "^(([Rr][Ee]?(\[[0-9]+\])?: *)?(\[[^]]+\] *)?)*"
+```
+
+I won't go into what those do here.  You can read the documentation if you're
+curious.
+
+Quit and rerun Mutt to see your changes.  Mutt is a very lightweight program so
+this should be fast.
+
+Let's also add a few key bindings in the index to make it easier to use:
+
+```text
+# Index Key Bindings ---------------------------------
+bind index gg       first-entry
+bind index G        last-entry
+
+bind index R        group-reply
+bind index <tab>    sync-mailbox
+bind index <space>  collapse-thread
+
+# Ctrl-R to mark all as read
+macro index \Cr "T~U<enter><tag-prefix><clear-flag>N<untag-pattern>.<enter>" "mark all messages as read"
+
+# Sync email
+macro index O "<shell-escape>offlineimap<enter>"           "run offlineimap to sync all mail"
+macro index o "<shell-escape>offlineimap -qf INBOX<enter>" "run offlineimap to sync inbox"
+
+# Saner copy/move dialogs
+macro index C "<copy-message>?<toggle-mailboxes>" "copy a message to a mailbox"
+macro index M "<save-message>?<toggle-mailboxes>" "move a message to a mailbox"
+```
+
+Remember to quit and rerun Mutt for them to take effect.
+
+We're going to use `j` and `k` to move around, so we may as well support Vim
+keys like `gg` and `G` too.  We'll use `R` for reply all, since that comes in
+handy fairly often.  `Ctrl-R` will mark all messages in the current folder as
+read.
+
+Don't worry if you don't understand how all these bindings and macros work right
+now.  You can read the documentation later.
+
+The `tab` key is going to "commit" changes we've made in Mutt (like deleting an
+email) to our local Maildir folder.  Once those changes are in the Maildir
+folder offlineimap will sync them to the server the next time it runs.  This is
+nice because it lets us recover if we accidentally do something stupid like
+deleting the wrong email.
+
+**Note:** Mutt will also sync changes for a folder when you switch to
+a different folder, and when you quit Mutt, so be aware of those.
+
+The `space` key will toggle collapsing of threads, which can be convenient when
+viewing mailing lists (or any conversations with many messages).
+
+The `o` and `O` keys will run offlineimap to sync mail.  Like I said before,
+I prefer having to press a button to grab mail instead of it constantly grabbing
+and nagging me.  `o` will sync only the inbox (fast), and `O` will sync
+everything (much slower).
+
+Finally we rebind `C` and `M` to perform the same operations they usually do,
+but in a more user-friendly manner.
+
+While we're at it, let's add a way to navigate around the sidebar so we can
+switch folders:
+
+```text
+# Sidebar Navigation ---------------------------------
+bind index,pager <down>   sidebar-next
+bind index,pager <up>     sidebar-prev
+bind index,pager <right>  sidebar-open
+```
+
+We're binding the `up` and `down` arrow keys to switch between folders, and
+`right` to "enter" a folder.  Give it a try.
+
+We don't need the arrows because we can navigate with `j` and `k`, but if you
+prefer to rebind them to something else feel free.
+
+Practice moving between folders and around in the list, then we'll move on to
+actually reading emails.
+
+### The Pager
+
+Press `return` in the index to open the selected email.  This view is called the
+pager:
+
+![Mutt's Pager](/media/images/blog/2012/10/mutt-pager.png)
+
+Like before, let's add a few settings:
+
+```text
+# Pager View Options ---------------------------------
+set pager_index_lines = 10 # number of index lines to show
+set pager_context = 3      # number of context lines to show
+set pager_stop             # don't go to next message automatically
+set menu_scroll            # scroll in menus
+set tilde                  # show tildes like in vim
+unset markers              # no ugly plus signs
+
+set quote_regexp = "^( {0,4}[>|:#%]| {0,4}[a-z0-9]+[>|]+)+"
+alternative_order text/plain text/enriched text/html
+```
+
+This is a good, sane starting point.  And now for a few extra key bindings:
+
+```text
+# Pager Key Bindings ---------------------------------
+bind pager k  previous-line
+bind pager j  next-line
+bind pager gg top
+bind pager G  bottom
+
+bind pager R  group-reply
+
+# View attachments properly.
+bind attach <return> view-mailcap
+```
+
+The first few make scrolling behave like it does in the index.  We're also going
+to use the same key for reply all here.  Consistency will make it easier to get
+Mutt into your fingers.
+
+Don't worry about the last one — that's to make sure Mutt treats attachments
+properly.
+
+Go ahead and try reading some emails.  Remember that `?` will always give you
+a list of keys and their functions.
+
+### Attachments
+
+Now that we're all set for reading plain text email, it's time to deal with
+attachments.
+
+When you're in the pager view reading an email with attachments, you can press
+`v` to view a list of them:
+
+![Attachment List](/media/images/blog/2012/10/mutt-attachments.png)
+
+Scroll through the list with `j` and `k` and press `return` to view one.  But
+first we need to tell Mutt how to view things that aren't text!
+
+For that we need to create a `~/.mutt/mailcap` file.  Here's a sample to get you
+started:
+
+```text
+# MS Word documents
+application/msword; ~/.mutt/view_attachment.sh %s "-" '/Applications/TextEdit.app'
+
+# Images
+image/jpg; ~/.mutt/view_attachment.sh %s jpg
+image/jpeg; ~/.mutt/view_attachment.sh %s jpg
+image/pjpeg; ~/.mutt/view_attachment.sh %s jpg
+image/png; ~/.mutt/view_attachment.sh %s png
+image/gif; ~/.mutt/view_attachment.sh %s gif
+
+# PDFs
+application/pdf; ~/.mutt/view_attachment.sh %s pdf
+
+# HTML
+text/html; ~/.mutt/view_attachment.sh %s html
+
+# Unidentified files
+application/octet-stream; ~/.mutt/view_attachment.sh %s "-"
+```
+
+The `view_attachment.sh` script is from [here][attachment].  Here's a link to
+[my copy][attachment-mirror] in case that site ever goes down.  Grab the script,
+chmod it to executable, and stick it in `~/.mutt`.
+
+You can poke around and figure out how it works, or you can just not worry about
+it and get on with life.  I recommend the latter (at least for now).
+
+Now you can press `return` to open an attachment in the proper program.
+
+[attachment]: http://linsec.ca/Using_mutt_on_OS_X#mailcap
+[attachment-mirror]: https://bitbucket.org/sjl/dotfiles/src/tip/mutt/view_attachment.sh
+
+### URLs
+
+One thing you'll probably want to do while reading email is open links.  Many
+terminal programs like iTerm2 let you command-click on a link to open it, but
+this is Mutt!  We shouldn't have to use the mouse!
+
+We're going to use a small helper program called urlview to make it easy to open
+URLs in email.  First, install it with `brew install urlview`.  Then make
+a `~/.urlview` file with the following contents:
+
+```text
+COMMAND open %s
+```
+
+This tells urlview what command to use to open a URL.  We're just going to use
+the OS X `open` command to do the right thing.
+
+Next, add the following line to your `~/.muttrc`:
+
+```text
+macro pager \Cu "|urlview<enter>" "call urlview to open links"
+```
+
+Now when you're reading an email with links in it you can press `Ctrl-u` to open
+urlview.  You'll see a screen like this:
+
+![urlview screen](/media/images/blog/2012/10/mutt-urls.png)
+
+Navigate with `j`, `k`, `gg`, `G`, or `/` and press `return` when the desired
+link is selected.  That link will be filled in at the bottom of the screen in
+case you want to edit it, and you can press `return` one more time to actually
+open it in your default browser.
+
+That about wraps it up for reading email.  Now it's time to write some!
+
+Writing Email
+-------------
+
+Writing email is one of the best parts of Mutt.  First let's add a few settings
+to get things nice and sane:
+
+```text
+# Compose View Options -------------------------------
+set realname = "Steve Losh"          # who am i?
+set envelope_from                    # which from?
+set sig_dashes                       # dashes before sig
+set edit_headers                     # show headers when composing
+set fast_reply                       # skip to compose when replying
+set askcc                            # ask for CC:
+set fcc_attach                       # save attachments with the body
+unset mime_forward                   # forward attachments as part of body
+set forward_format = "Fwd: %s"       # format of subject when forwarding
+set forward_decode                   # decode when forwarding
+set attribution = "On %d, %n wrote:" # format of quoting header
+set reply_to                         # reply to Reply to: field
+set reverse_name                     # reply as whomever it was to
+set include                          # include message in replies
+set forward_quote                    # include message in forwards
+```
+
+You can reply to an email with `r` in the index or pager, or start a fresh one
+with `m`.
+
+There's actually not a lot to say about writing mail, because Mutt itself
+doesn't handle it!  Mutt passes control off to the text editor of your choice.
+Just specify your editor in your `~/.muttrc`:
+
+```text
+set editor = "vim"        # Use terminal Vim to compose email.
+set editor = "mvim -f"    # Use MacVim to compose email.
+set editor = "subl -w"    # Use Sublime Text 2 to compose email.
+```
+
+Any command that takes a filename and doesn't return until you're done can be
+used here.
+
+This is fantastic because it means you can use an editor you're already
+comfortable and fast in to write email instead of learning yet another set of
+shortcuts.
+
+Once you save the email in your editor and close it, Mutt will present you with
+a menu that looks like this:
+
+![Sending Screen](/media/images/blog/2012/10/mutt-send-1.png)
+
+You can press `e` to go back and edit the mail, `a` to add attachments, and so
+on (the options are listed at the top of the screen).
+
+Before we can continue we need to tell Mutt how to send email.  Press `q` to
+discard the email for now.
+
+Sending Email
+-------------
+
+Mutt does have (some) built-in SMTP support, but we're going to use a separate
+program to do our sending for a few reasons.
+
+First, Mutt's SMTP support was considered "experimental" the last time
+I checked.  Sending email is kind of important, so we'll stick with something
+tried and true.
+
+Second, we want a method that won't require our password in a plaintext config
+file.
+
+Go ahead and install the `msmtp` program through Homebrew with `brew install
+msmtp`.
+
+Next we're going to need to create a `~/.msmtprc` file with the following
+contents:
+
+```text
+account stevelosh
+host smtp.gmail.com
+port 587
+protocol smtp
+auth on
+from steve@stevelosh.com
+user steve@stevelosh.com
+tls on
+tls_trust_file ~/.mutt/Equifax_Secure_CA.cert
+
+account default : stevelosh
+```
+
+`msmtp` will look in your keychain for your SMTP password, which we added
+earlier.  No plaintext passwords!
+
+The other "interesting" bit here is the `tls_trust_file`.  We're going to be
+connecting to Gmail's SMTP server over SSL, and `msmtp` needs to know if it can
+trust the certificate that the server on the other end is sending back.
+
+Copy the following and paste it into the path `tls_trust_file` is set to:
+
+```text
+-----BEGIN CERTIFICATE-----
+MIIDIDCCAomgAwIBAgIENd70zzANBgkqhkiG9w0BA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-----END CERTIFICATE-----
+```
+
+If you're paranoid and don't trust that I'm giving you the right cert (or that
+someone has hacked my site and changed it), you can generate it yourself.  I'll
+leave that to you — if you care enough about it you'll figure it out.
+
+Now we need to tell Mutt to use msmtp.  Add the following to your `~/.muttrc`
+file:
+
+```text
+set from     = "steve@stevelosh.com"
+set sendmail = "/usr/local/bin/msmtp -a stevelosh"
+set sendmail_wait = 0
+unset record
+```
+
+The `-a stevelosh` will need to change to whatever you named your account in the
+msmtp config.
+
+The `unset record` line tells Mutt to not append a copy of every email you send
+to a file on your hard drive.  Gmail will save the emails you send in the sent
+folder, so you'll get the the next time you sync with offlineimap anyway.
+
+The `sendmail_wait` line tells Mutt to wait for the msmtp program to finish
+sending the mail before returning control, instead of running it in the
+background.  This makes it obvious if there's a problem sending a message, which
+I prefer to silent, backgrounded failures.
+
+Now you can send email!  Awesome!
+
+Once you've composed a test email and saved it you'll be presented with a screen
+like this (which we saw in the previous section):
+
+![Sending Screen](/media/images/blog/2012/10/mutt-send-1.png)
+
+The keys you need are listed along the top.  Pressing `y` now will invoke msmtp
+and send your email!
+
+You'll see "Sending message..." at the bottom of the screen while msmtp is
+working.  If there's a problem, Mutt will tell you the error.  Figure it out
+before moving on.
+
+Postponing Drafts
+-----------------
+
+Sometimes I like to read and respond to email without an internet connection,
+then actually send the replies when I get back to civilization.
+
+Since all of my email is stored locally, reading it offline is trivial.
+
+To reply or compose offline, I use Mutt's "postpone" feature.  First I've added
+the following line to my `~/.muttrc`:
+
+```text
+bind compose p postpone-message
+```
+
+Now when I'm at the sending screen instead of pressing `y` to send I can press
+`p` to postpone the message.  This places the message in the drafts folder.
+
+The drafts folder in Mutt is just a normal folder of emails like any other.
+When you sync with offlineimap your postponed email will get pushed up to Gmail
+as a draft.  You can edit it in the Gmail web interface if you like, and those
+edits will sync back down too.
+
+If you want to edit your drafts (postponed messages) locally, you need to
+"recall" them.  I have the following line in my `~/.muttrc` to set the key to
+the same one as I used to postpone it in the first place:
+
+```text
+bind index p recall-message
+```
+
+You can also use `m` to start writing a new email, and mutt will prompt you if
+there are existing postponed messages.
+
+Once you hit `p` (or `m` and then select "yes") Mutt will show you a list of the
+postponed messages.  Select one and press `return` to start editing it again.
+If there's only one it will skip this step and simply open it for you
+immediately.
+
+Once you're done editing you can either postpone it again or send it as usual.
+
+Unfortunately you have to go through the "recall → edit → send" process each
+time.  As far as I know there's no way to simply run down a list of postponed
+emails sending each one with a single keystroke.  But that's not *too* bad, and
+it's great to be able to work offline like this.
+
+Once you send the postponed email (through Mutt or the Gmail web interface) it
+disappears from the drafts folder and the postponed list as you would expect.
+
+Contacts
+--------
+
+Next we'll want to get Mutt to autocomplete our contacts from the OS X address
+book.  I like using the OS X address book because it automatically syncs between
+my laptops and phone, so I only need to maintain one address list.
+
+### Autocompleting
+
+Unfortunately I've got some bad news for you: you're going to need to install
+XCode.
+
+No, not the command-line developer tools.  The full XCode.  I'm sorry, but trust
+me when I say it's going to save you a lot of pain, so just grumble to yourself
+a bit and do it.
+
+Okay, now that you've got XCode you can install the `contacts` program through
+Homebrew with `brew install contacts`.
+
+`contacts` is a command-line program that you can use to query your address
+book.  To tell Mutt how to use it add the following lines to your
+`~/.mutt/muttrc`:
+
+```text
+set query_command = "contacts -Sf '%eTOKEN%n' '%s' | sed -e 's/TOKEN/\t/g'"
+bind editor <Tab> complete-query
+bind editor ^T    complete
+```
+
+Now when you're filling out an email address field you can type a few characters
+and hit Tab to get a screen like this:
+
+![Contacts](/media/images/blog/2012/10/mutt-contacts-1.png)
+
+You can use `j` and `k` to select an item, press return to complete it.  Press
+`q` if you've changed your mind and want to cancel the completion.  Look at the
+top of the screen for more handy little keys you can use here.
+
+If there's only one item in the list Mutt won't bother showing you this screen
+and will just complete it right away.
+
+This completion searches more than just the email address.  It'll also search
+the names and possibly other fields from the address book entries as well.
+
+### Adding Contacts
+
+What about adding contacts to your address book?  Any contacts you add on your
+phone will automatically be synced, but what if you're reading your mail in Mutt
+and just want to add the sender as a contact without leaving your command line?
+
+For this I use a little script that [Simone Manganelli][simx] wrote for me
+called `addcontact`.  You can [get it here][addcontact] and stick it in your
+`$PATH` somewhere.  It's just a command-line utility that you can use like this:
+
+```text
+$ addcontact Steve Losh steve@stevelosh.com
+$ addcontact "Steve Losh" steve@stevelosh.com
+$ addcontact Steve Losh work steve@pculture.org
+```
+
+As you can see, it's pretty flexible.
+
+**Note:** This utility always adds a new contact record, so if you add someone
+that's already in there you're going to get a duplicate entry.  If that happens
+you can search for the entries in Contacts.app, select the duplicates, and use
+"Card → Merge Selected Cards" to combine them.
+
+Okay, so we can now add contacts from the command line.  You could set up a Mutt
+macro to automatically add senders without too much trouble, but I don't do
+that.  If I want to add a contact I just hit `!` and type out the shell command.
+It's not that much work, and sometimes the name in the "From:" field is in
+a weird format like "Last, First Middle" instead of "First Last", so this gives
+me a chance to clean it up before I add it.
+
+[simx]: http://simx.me/
+[addcontact]: https://bitbucket.org/sjl/dotfiles/src/tip/bin/addcontact
+
+Searching Email
+---------------
+
+If you have more than a screen full of email in any given folder, you're going
+to want a way to search through it.  Mutt's built-in searching is a good start,
+but I also use another program to get a bit more power.
+
+### Vanilla Searching
+
+There are two main ways to search your email in Mutt: plain searching and
+"limiting".
+
+Plain searching is done with the `/` key.  It works similarly to Vim or less:
+you press `/`, type your query, and press enter to perform the search.  You can
+use `n` to move to the next match, and the search will loop around to the top if
+it hits the bottom.
+
+I have the following lines in my `~/.muttrc` to bind `N` to go to the *previous*
+match:
+
+```text
+bind index N search-opposite
+bind pager N search-opposite
+```
+
+Normally the `N` key marks a message as unread (or "new").  I personally never
+want to do that.  Unread mail should be "mail that has not been read".  If you
+use that feature you'll want to rebind it to something else.
+
+Two things about queries:
+
+1. They are regular expressions (actually it's more powerful than than, see [the
+   documentation][patterns] for more information).
+2. They only search the To and Subject fields (*not* the message bodies!).
+
+I generally use this kind of searching when I see the email I want to open on
+the screen but don't feel like pressing `j` or `k` forty times to move through
+the list.  When I'm actually trying to find a message I can't already see on the
+screen I use limiting.
+
+[patterns]: http://www.mutt.org/doc/manual/manual-4.html#ss4.2
+
+### Vanilla Limiting
+
+Limiting is the other way Mutt provides for searching mail.  It's done with the
+`l` key by default.
+
+Like `/`, `l` will ask you for a pattern.  But instead of simply moving you to
+the next message that matches the pattern, Mutt will *hide* messages that don't
+match.
+
+This lets you see all the ones that match in a single list.  This list works
+just like a normal list.  You can search it with `/`, tag things, and so on as
+you normally would.  It's really quite nice once you get used to it.
+
+To remove the limiting once you're done, you can limit to the special value
+`all`.  I've added a line to my `~/.muttrc` so I can do that with a single key:
+
+```text
+macro index a "<limit>all\n" "show all messages (undo limit)"
+```
+
+**Note:** This shadows the `create-alias` function which I never use.
+
+Limit queries work exactly like search queries, so you can do powerful stuff
+like `~f arthur ~C honza ~s api` ("limit to messages from 'arthur', to or cced
+to 'honza', containing 'api' in the subject").
+
+### Full-Text Searching
+
+By now you're probably wondering how to search the full text of messages.  There
+are two ways: one simple and slow, the other complicated and fast.
+
+First is the simple, slow way.  You can use `~B` in your searches and limits to
+search inside the entire message.  If your folder only has a hundred messages
+this works great.  But once you have a few more (my archive has about 30,000 at
+the moment, and I prune it fairly often) it quickly becomes too slow to be
+usable.
+
+I use a program called [notmuch][] to index and search my email.  It's blazingly
+fast and works pretty well.
+
+First, install it with `brew install notmuch`.  Now you need
+a `~/.notmuch-config` file.  Run `notmuch setup` to generate one.  It's pretty
+straightforward.  When it asks you for the path to your archive, that's the path
+to the folder containing all your individual IMAP folders
+(`~/.mail/steve-stevelosh.com` in my setup).
+
+Now run `notmuch new` to perform the initial index.  It might take a while if
+you have a lot of folders.  Subsequent indexes will be much faster since they'll
+only reindex whatever changed since the last time.
+
+You'll want to reindex when your email changes, so add a hook in your
+`~/.offlineimaprc` to run `notmuch new` whenever offlineimap syncs your email:
+
+```text
+[Account SteveLosh]
+localrepository = SteveLosh-Local
+remoterepository = SteveLosh-Remote
+status_backend = sqlite
+postsynchook = notmuch new
+```
+
+Now you can use `notmuch search foo` to search your mail for "foo" from the
+command line.  Try a couple of queries and make sure it works.
+
+Now we need to hook notmuch into Mutt.  There are a number of different ways to
+do this, all of them hacky and ugly.  I'll describe how I do it.
+
+A quick overview of how this is going to work:
+
+1. You'll press a key in Mutt to activate searching.
+2. You'll type your query and press return.
+3. Your mail will be searched with `notmuch`.
+4. Τhe resulting messages will be symlinked into a temporary maildir folder.
+5. That temporary folder will be opened in Mutt.
+
+First get [mutt-notmuch-py][].  The original `mutt-notmuch` is a Perl script
+with many external requirements that are a pain to install, and it doesn't work
+on OS X.  `mutt-notmuch-py` is a Python script with zero external requirements.
+
+`mutt-notmuch-py` is going to handle steps 2 through 4 in the list.  Get the
+script into your `$PATH` somehow and then run it:
+
+```text
+$ mutt-notmuch-py -G ~/.mail/temporary/search
+Query: foo
+
+$ ls ~/.mail/temporary/search
+cur new
+```
+
+The `-G` tells it to not perform certain Gmail-specific stuff that we don't
+need.  The path is where it will create the temporary maildir folder with the
+results.  Each time you run it this folder will be wiped clean before the new
+results are linked into it.
+
+Now we need to handle the first and last points in the list.  I have the
+following mapping in my `~/.muttrc`:
+
+```text
+macro index S "<enter-command>unset wait_key<enter><shell-escape>mutt-notmuch-py ~/.mail/temporary/search<enter><change-folder-readonly>+temporary/search<enter>" "search mail (using notmuch)"
+```
+
+That's a lot to take in, so let's see how it works piece by piece:
+
+```text
+macro index S
+```
+
+We're going to use the `S` key to perform a full search of all of our mail.
+
+```text
+<enter-command>unset wait_key<enter>
+```
+
+Unset the `wait_key` Mutt option to prevent Mutt from asking us to press a key
+after the search has finished.
+
+```text
+<shell-escape>mutt-notmuch-py -G ~/.mail/temporary/search<enter>
+```
+
+Run `mutt-notmuch-py`.  Control will pass over to that script and it will ask
+you for your query, run the search, set up the results folder, and then hand
+control back to Mutt.
+
+```text
+<change-folder-readonly>+temporary/search<enter>
+```
+
+Now we change over to the temporary folder in Mutt, and we're now looking at
+a list of search results!  Since this is a real Maildir folder like any other
+one we can use the full range of tools to interact with it (searching, limiting,
+etc).
+
+Finally, let's get this search results folder in our sidebar so we can see where
+we are visually at all times:
+
+```text
+mailboxes +steve-stevelosh.com/INBOX \
+          +steve-stevelosh.com/vim \
+          +steve-stevelosh.com/clojure \
+          ...
+          +temporary/search \
+```
+
+Now the search results folder can be navigated like any other one.  That's it
+for email searching!  Now you should have a setup that you can use in real life
+to manage your email.
+
+[notmuch]: http://notmuchmail.org/
+[mutt-notmuch-py]: https://github.com/honza/mutt-notmuch-py
+
+Conclusion
+----------
+
+Mutt is definitely a beast.  It's old, crufty, and ugly, but if you spend the
+time to set it up and learn to use it you'll be rewarded with a fast, powerful,
+customizable environment for working with your email.
+
+A wonderful trend these days is that more and more sites are including the
+ability to respond to comments and such by simply replying to their notification
+emails.  This means that often you can reply to Facebook emails, comment on
+GitHub pull requests, and respond to Bitbucket issues all without leaving the
+comfort of your finely-tuned email client.
+
+Mutt's not for everyone, but if you deal with a lot of email and have some time
+to spend you should give it a try.  You just might learn to love the old dog.
+
--- a/content/blog/2012/10/why-i-two-space.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,214 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Why I Two-Space"
-        snip: "You can pry my extra spaces from my cold, dead hands."
-        created: 2012-10-12 10:10:00
-    %}
-
-{% block article %}
-
-If you look at [the source code][source] for this blog, you might notice that
-all my blog posts (written in [Markdown][]) have two spaces after every period.
-
-Every so often [this Slate article][slate] makes the rounds and annoys me.  This
-time I figured I'd write a blog post/rant to get it off my chest once and for
-all: two-spacing is equal or superior to one-spacing in all non-trivial ways.
-
-[source]: https://bitbucket.org/sjl/stevelosh/src/tip/content/blog
-[Markdown]: http://daringfireball.net/projects/markdown/
-[slate]: http://www.slate.com/articles/technology/technology/2011/01/space_invaders.html
-
-[TOC]
-
-The Arguments for One-Spacing
------------------------------
-
-If you read the aforementioned Slate article you'll see that it presents a total
-of three arguments in favor of single-spacing after a period:
-
-1. Many professional typographers find two-spacing ugly (though they have no
-   actual evidence of its effects on readability).
-2. It's less work to press the space bar once instead of twice.
-3. It's pretty much arbitrary anyway, so *why not*?
-
-You might also infer from the article's tone that "you get to feel superior to
-those Neanderthals that use two spaces" is another argument in favor of it, but
-I'll leave that one out because it can go both ways.
-
-Let's go through these arguments one by one and see how they hold up.
-
-Effort
-------
-
-I don't think the "it's more effort to press the space bar twice" argument is at
-all compelling.  The extra space *may* account for around half a percent of the
-keystrokes you type, depending on how long your sentences tend to run (mine
-usually end up fairly long, as you can see).
-
-Not only is it not a large portion of your keystrokes, but the space bar has
-your two strongest digits dedicated solely to it!  If any fingers are going to
-wear out from typing, it won't be your thumbs.
-
-You could get pedantic and mention increased file size as a disadvantage of two
-spacing, but let's not quibble about a few bytes when I can hold 32 gigabytes on
-an SD card the size of a postage stamp.
-
-Two-Spacing is Ugly
--------------------
-
-The Slate article is correct is saying that many professional typographers think
-two-spacing is ugly.  My copy of [The Elements of Typographic Style][elements]
-agrees.  However, there's more to the issue than a single blanket rule.
-
-[elements]: http://www.amazon.com/dp/0881792063/?tag=stelos-20
-
-### Source and Presentation
-
-If you're reading this in a web browser and look closely, you'll notice that
-there's only one space between each sentence.  I said I used two, so what
-happened?
-
-Web browsers, by default, collapse successive whitespace into a single space when it
-renders the HTML.  You could put a thousand spaces between sentences in the
-source and it would still come out single-spaced.
-
-Another widely-used format, LaTeX, splits the difference and actually uses
-somewhere between one and two spaces (by default).
-
-The key idea here is that what you type and what the end user actually reads are
-two different things.  They don't need to be bound together.  It's possible to
-type two spaces but get one in your output (or in LaTeX's case: an even more
-pleasing "one and a bit").
-
-If you're using a WYSIWYG editor like Microsoft Word this may not be the case.
-For the high school students typing up papers for class: sure, go ahead and
-single-space.  But if you're still using Word to type up things like books, long
-blog posts, or technical documentation, you're doing yourself a disservice.
-Learn to use a system like LaTeX so your source and rendered output aren't
-locked together.
-
-This means that "two-spacing looks ugly" doesn't imply "you should not type two
-spaces when you write".  It *actually* implies "you should use a system that
-results in single-spacing when rendered", and most of the common ones today will
-do exactly that.
-
-### Typewriters
-
-So we've seen that the "extra spaces take more effort" argument isn't
-convincing, and that "two-spacing in the final output is ugly" doesn't prevent
-you from using two spaces in the input.
-
-But so far I haven't given you any reason *for* using two spaces.  That's the
-Slate article's third argument: "it's arbitrary anyway, so you may as well use
-one".
-
-Let's fix that by examining the common holier-than-thou put-down of "two-spacing
-was useful back when people used *typewriters*, you dinosaur!".
-
-To his credit, the Slate author correctly points out that it's not the fact that
-people used typewriters that made two-spacing popular, it was the fact that
-*typewriters used monospaced fonts*.  Most people miss that logical leap.
-
-Unfortunately he follows that up with:
-
-> Here's the thing, though: Monospaced fonts went out in the 1970s.
-
-For the average person typing up a school paper here and there, sure.  But for
-many people doing a large amount of writing for LaTeX books and papers,
-technical documentation, code comments, mailing lists, blog posts, and lots of
-other things, it's simply *wrong* for one big reason:
-
-**Text editors use monospaced fonts!**
-
-It doesn't matter what editor you use.  Vim, Emacs, TextMate, Sublime Text,
-Eclipse, Gedit, Notepad++?  *All* of them use monospaced fonts.
-
-Going back to the typewriter quip, this means that if people used two spaces
-when writing on typewriters because it looked better, then using two spaces in
-a text editor will look better.  And we know that because there's a distinction
-between source and presentation in non-WYSIWYG contexts, we can use separate
-strategies for each.
-
-We can have our cake and eat it too!  We can type two spaces after a period to
-make our text look better as we write, revise, and edit it, and then render it
-to single-spacing (or "space-and-a-half-ing") to give our readers a beautiful
-reading experience with pleasant spacing.
-
-So now two-spacing has a real advantage over single-spacing.  That's enough to
-make it preferable.  But let's look at one more advantage for power users, just
-to seal the deal.
-
-Power
------
-
-If you use [Vim][] to edit text, you're probably familiar with its "text
-objects".  Text objects are what let you move and act on whole chunks of text at
-a time.  For example, instead of deleting a word letter-by-letter you can use
-`daw` to "delete around word".
-
-Vim comes with a "sentence" text object built-in.  You can move around your
-document sentence-by-sentence with `(` and `)`, and yank/delete/change/etc
-entire sentences with `cas` ("change around sentence") and so on.
-
-You can probably guess where this is going.  If you single-space sentences Vim
-will do its best to "do the right thing", but inevitably gets tripped up when
-you've got punctuation in your sentence.  For example:
-
-    Bob started speaking. Hello, Mr. Smith! How are you today?
-                                        ^
-                                        cursor
-
-What happens when you tell Vim to "delete around sentence" now?
-
-    Bob started speaking. Hello, Mr. How are you today?
-                                      ^
-                                      cursor
-
-Well that's not right!  Vim can't easily tell the difference between the period
-after "Mr" and the end of a sentence.  What happens if you type your prose with
-two-spacing instead?
-
-    Bob started speaking.  Hello, Mr. Smith!  How are you today?
-                                         ^
-                                         cursor
-    Bob started speaking.  How are you today?
-                           ^
-                           cursor
-
-This time Vim is able to delete the sentence correctly!  Note that you'll need
-to make sure to `set cpo+=J` in your `~/.vimrc` file to tell Vim "don't worry,
-I'm using two spaces like a sane person" for this to work.
-
-Two-spacing provides more semantic information, which means that software can
-parse and work with it more easily.  I'm sure Emacs has something similar, and
-if you or someone else ever needs to parse your writing programatically they'll
-have an easier time.
-
-Final Score
------------
-
-To recap, the arguments *for* single-spacing are:
-
-1. Two-spacing is ugly in proportional fonts.
-2. It's less work to press the space bar once instead of twice.
-3. It's pretty much arbitrary anyway, so why bother with two?
-
-Number 1 is irrelevant, because writing and rendering are (except in trivial
-cases) two orthogonal activities.
-
-Number 2 isn't very convincing.
-
-Number 3 is false, because two-spacing gives you two advantages over
-one-spacing:
-
-1. It looks better in your editor.
-2. It gives you more power when editing and parsing.
-
-So the next time you see that arrogant Slate article, feel free to be arrogant
-right back.  Wield your extra spaces proudly, because they give you both comfort
-and power!
-
-[Vim]: http://www.vim.org/
-
-{% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2012/10/why-i-two-space.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,211 @@
++++
+title = "Why I Two-Space"
+snip = "You can pry my extra spaces from my cold, dead hands."
+date = 2012-10-12T10:10:00Z
+draft = false
+
++++
+
+If you look at [the source code][source] for this blog, you might notice that
+all my blog posts (written in [Markdown][]) have two spaces after every period.
+
+Every so often [this Slate article][slate] makes the rounds and annoys me.  This
+time I figured I'd write a blog post/rant to get it off my chest once and for
+all: two-spacing is equal or superior to one-spacing in all non-trivial ways.
+
+[source]: https://bitbucket.org/sjl/stevelosh/src/tip/content/blog
+[Markdown]: http://daringfireball.net/projects/markdown/
+[slate]: http://www.slate.com/articles/technology/technology/2011/01/space_invaders.html
+
+{{% toc %}}
+
+The Arguments for One-Spacing
+-----------------------------
+
+If you read the aforementioned Slate article you'll see that it presents a total
+of three arguments in favor of single-spacing after a period:
+
+1. Many professional typographers find two-spacing ugly (though they have no
+   actual evidence of its effects on readability).
+2. It's less work to press the space bar once instead of twice.
+3. It's pretty much arbitrary anyway, so *why not*?
+
+You might also infer from the article's tone that "you get to feel superior to
+those Neanderthals that use two spaces" is another argument in favor of it, but
+I'll leave that one out because it can go both ways.
+
+Let's go through these arguments one by one and see how they hold up.
+
+Effort
+------
+
+I don't think the "it's more effort to press the space bar twice" argument is at
+all compelling.  The extra space *may* account for around half a percent of the
+keystrokes you type, depending on how long your sentences tend to run (mine
+usually end up fairly long, as you can see).
+
+Not only is it not a large portion of your keystrokes, but the space bar has
+your two strongest digits dedicated solely to it!  If any fingers are going to
+wear out from typing, it won't be your thumbs.
+
+You could get pedantic and mention increased file size as a disadvantage of two
+spacing, but let's not quibble about a few bytes when I can hold 32 gigabytes on
+an SD card the size of a postage stamp.
+
+Two-Spacing is Ugly
+-------------------
+
+The Slate article is correct is saying that many professional typographers think
+two-spacing is ugly.  My copy of [The Elements of Typographic Style][elements]
+agrees.  However, there's more to the issue than a single blanket rule.
+
+[elements]: http://www.amazon.com/dp/0881792063/?tag=stelos-20
+
+### Source and Presentation
+
+If you're reading this in a web browser and look closely, you'll notice that
+there's only one space between each sentence.  I said I used two, so what
+happened?
+
+Web browsers, by default, collapse successive whitespace into a single space when it
+renders the HTML.  You could put a thousand spaces between sentences in the
+source and it would still come out single-spaced.
+
+Another widely-used format, LaTeX, splits the difference and actually uses
+somewhere between one and two spaces (by default).
+
+The key idea here is that what you type and what the end user actually reads are
+two different things.  They don't need to be bound together.  It's possible to
+type two spaces but get one in your output (or in LaTeX's case: an even more
+pleasing "one and a bit").
+
+If you're using a WYSIWYG editor like Microsoft Word this may not be the case.
+For the high school students typing up papers for class: sure, go ahead and
+single-space.  But if you're still using Word to type up things like books, long
+blog posts, or technical documentation, you're doing yourself a disservice.
+Learn to use a system like LaTeX so your source and rendered output aren't
+locked together.
+
+This means that "two-spacing looks ugly" doesn't imply "you should not type two
+spaces when you write".  It *actually* implies "you should use a system that
+results in single-spacing when rendered", and most of the common ones today will
+do exactly that.
+
+### Typewriters
+
+So we've seen that the "extra spaces take more effort" argument isn't
+convincing, and that "two-spacing in the final output is ugly" doesn't prevent
+you from using two spaces in the input.
+
+But so far I haven't given you any reason *for* using two spaces.  That's the
+Slate article's third argument: "it's arbitrary anyway, so you may as well use
+one".
+
+Let's fix that by examining the common holier-than-thou put-down of "two-spacing
+was useful back when people used *typewriters*, you dinosaur!".
+
+To his credit, the Slate author correctly points out that it's not the fact that
+people used typewriters that made two-spacing popular, it was the fact that
+*typewriters used monospaced fonts*.  Most people miss that logical leap.
+
+Unfortunately he follows that up with:
+
+> Here's the thing, though: Monospaced fonts went out in the 1970s.
+
+For the average person typing up a school paper here and there, sure.  But for
+many people doing a large amount of writing for LaTeX books and papers,
+technical documentation, code comments, mailing lists, blog posts, and lots of
+other things, it's simply *wrong* for one big reason:
+
+**Text editors use monospaced fonts!**
+
+It doesn't matter what editor you use.  Vim, Emacs, TextMate, Sublime Text,
+Eclipse, Gedit, Notepad++?  *All* of them use monospaced fonts.
+
+Going back to the typewriter quip, this means that if people used two spaces
+when writing on typewriters because it looked better, then using two spaces in
+a text editor will look better.  And we know that because there's a distinction
+between source and presentation in non-WYSIWYG contexts, we can use separate
+strategies for each.
+
+We can have our cake and eat it too!  We can type two spaces after a period to
+make our text look better as we write, revise, and edit it, and then render it
+to single-spacing (or "space-and-a-half-ing") to give our readers a beautiful
+reading experience with pleasant spacing.
+
+So now two-spacing has a real advantage over single-spacing.  That's enough to
+make it preferable.  But let's look at one more advantage for power users, just
+to seal the deal.
+
+Power
+-----
+
+If you use [Vim][] to edit text, you're probably familiar with its "text
+objects".  Text objects are what let you move and act on whole chunks of text at
+a time.  For example, instead of deleting a word letter-by-letter you can use
+`daw` to "delete around word".
+
+Vim comes with a "sentence" text object built-in.  You can move around your
+document sentence-by-sentence with `(` and `)`, and yank/delete/change/etc
+entire sentences with `cas` ("change around sentence") and so on.
+
+You can probably guess where this is going.  If you single-space sentences Vim
+will do its best to "do the right thing", but inevitably gets tripped up when
+you've got punctuation in your sentence.  For example:
+
+    Bob started speaking. Hello, Mr. Smith! How are you today?
+                                        ^
+                                        cursor
+
+What happens when you tell Vim to "delete around sentence" now?
+
+    Bob started speaking. Hello, Mr. How are you today?
+                                      ^
+                                      cursor
+
+Well that's not right!  Vim can't easily tell the difference between the period
+after "Mr" and the end of a sentence.  What happens if you type your prose with
+two-spacing instead?
+
+    Bob started speaking.  Hello, Mr. Smith!  How are you today?
+                                         ^
+                                         cursor
+    Bob started speaking.  How are you today?
+                           ^
+                           cursor
+
+This time Vim is able to delete the sentence correctly!  Note that you'll need
+to make sure to `set cpo+=J` in your `~/.vimrc` file to tell Vim "don't worry,
+I'm using two spaces like a sane person" for this to work.
+
+Two-spacing provides more semantic information, which means that software can
+parse and work with it more easily.  I'm sure Emacs has something similar, and
+if you or someone else ever needs to parse your writing programatically they'll
+have an easier time.
+
+Final Score
+-----------
+
+To recap, the arguments *for* single-spacing are:
+
+1. Two-spacing is ugly in proportional fonts.
+2. It's less work to press the space bar once instead of twice.
+3. It's pretty much arbitrary anyway, so why bother with two?
+
+Number 1 is irrelevant, because writing and rendering are (except in trivial
+cases) two orthogonal activities.
+
+Number 2 isn't very convincing.
+
+Number 3 is false, because two-spacing gives you two advantages over
+one-spacing:
+
+1. It looks better in your editor.
+2. It gives you more power when editing and parsing.
+
+So the next time you see that arrogant Slate article, feel free to be arrogant
+right back.  Wield your extra spaces proudly, because they give you both comfort
+and power!
+
+[Vim]: http://www.vim.org/
+
--- a/content/blog/2013/03/list-out-of-lambda.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1065 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "List Out of Lambda"
-        snip: "Down the rabbit hole we go!"
-        created: 2013-03-30 14:00:00
-    %}
-
-    {% block article %}
-
-If you ignore the practical issues of computers like size, weight, cost, heat,
-and so on, what do you *really* need in a programming language?  Let's play
-around with this question.
-
-To understand this post you'll need a basic understanding of how functions in
-Javascript work.  If you can look at this code and understand what it prints,
-you're good to go:
-
-    :::javascript
-    var x = 10;
-
-    var f = function(y) {
-        console.log(x);
-        console.log(y);
-    }
-
-    var g = f;
-
-    f(1);
-    g(2);
-
-This blog post is a thought exercise.  It's not something you'd ever use for
-real code.  But just like a guitarist practices scales that she won't ever play
-in a song, we programmers should be exercising our brains every so often.
-
-I'm going to use Javascript for the examples.  Any language with first class
-functions and lexical scoping (basically: closures) will work.  The examples
-would be prettier in a Lisp, but some people would be turned off by the syntax
-and miss out on some interesting ideas.  Feel free to port the code if it
-bothers you.
-
-If you've already seen this kind of thing before (maybe you've gone through [The
-Little Schemer][] or [SICP][]) you may want to just skim the code here and look
-for anything new.
-
-If you *haven't* seen anything like this, then you're in for a treat!  It's all
-going to look extremely weird the first time you see it.  Go slowly and make
-sure you understand each piece fully before moving on to the next.  These
-concepts may be unintuitive, but they're built from very simple pieces.
-
-Finally: if you get stuck, don't worry.  Tracing out the execution of a function
-on paper can be a good way to wrap your brain around it (I recommend investing
-in a good lap desk for comfy reading and writing).  If that doesn't work, just
-close the window and come back tomorrow.  Sometimes new concepts need a while to
-rattle around in your brain before they click into place.
-
-[The Little Schemer]: http://www.amazon.com/dp/0262560992/?tag=stelos-20
-[SICP]: http://www.amazon.com/dp/0070004846/?tag=stelos-20
-
-[TOC]
-
-Lists
------
-
-Let's get started.  One of the most common things we do as programmers is
-grouping data together.  Javascript has "arrays" built in to the language for
-this:
-
-    :::javascript
-    var names = ["Alice", "Bob", "Candice"];
-
-What if Javascript didn't come with arrays included?  Could we create them (or
-something like them) ourselves?
-
-To answer this, let's think about the bare minimum we'd need to "bootstrap"
-something like an array.  There are a number of ways to do this, but we're going
-to look at one in particular.
-
-We'll call our array-like thing a "list".  To make it work, we need four parts:
-
-* The concept of "the empty list".
-* A way to add an element to the front of a list.
-* A way to take a list and get the first element.
-* A way to take a list and get everything *but* the first element.
-
-If we have those four things, we can build on top of them to do anything else we
-might want.  For example: to make a list of one item, you add that item to the
-front of the empty list.
-
-Let's narrow this down further.  There are lots of ways you could implement
-those four things -- I'm going to use functions.  Let's sketch out an outline:
-
-    :::javascript
-    var empty_list = null;
-
-    var prepend = function(el, list) {
-        // ...
-    };
-
-    var head = function(list) {
-        // ...
-    };
-
-    var tail = function(list) {
-        // ...
-    };
-
-    var is_empty = function(list) {
-        // ...
-    };
-
-Here are the descriptions of each of these items.
-
-The `empty_list` is a special value that represents a list of zero elements.
-It can be anything, so for now we'll use `null` (we'll revisit this later).
-
-`prepend(1, some_list)` will return a new list that looks like the old one, but
-with `1` stuck onto the front of it.  So if we want to create a list of the
-numbers `1` and `2` we can say `prepend(1, prepend(2, empty_list))` or "prepend
-one to the result of prepending 2 to the empty list".
-
-`head(some_list)` will return the first element in the list.  Calling it on the
-empty list will be undefined, so we'll just be very careful not to do that!
-
-`tail(some_list)` will return a new list that's like the one we gave it, but
-with the first element removed.  Again, calling this on an empty list will make
-things explode.
-
-`is_empty(some_list)` will return `true` if the list given to it is the empty
-list, and `false` otherwise.
-
-Once we have those four functions (plus the special empty list value) we can
-start building on top of them, so let's figure out how to make them!
-
-### List Out of If
-
-If you haven't seen anything like this before, you might think it's time to
-start creating Javascript Objects.  That's certainly one way to do it.
-
-Since this post is a thought experiment in what we actually *need*, though,
-let's try to avoid using big language features (like Objects) unless we
-absolutely can't avoid it.
-
-So if we don't want to use other language features yet, what are we left with?
-Well so far our skeleton only has functions (and `null`), so let's try those!
-
-Here's the first working revision of the building blocks of lists:
-
-    :::javascript
-    var empty_list = null;
-
-    var prepend = function(el, list) {
-        return function(command) {
-            if (command === "head") {
-                return el;
-            } else if (command === "tail") {
-                return list;
-            }
-        }
-    };
-
-    var head = function(list) {
-        return list("head");
-    };
-
-    var tail = function(list) {
-        return list("tail");
-    };
-
-    var is_empty = function(list) {
-        return list === null;
-    };
-
-Go ahead and paste that into a browser console and play with it:
-
-    :::javascript
-    var e = empty_list;
-
-    console.log(is_empty(e));
-    // true
-
-    var names = prepend("Alice",
-                        prepend("Bob",
-                                prepend("Candice",
-                                        empty_list)));
-
-    console.log(is_empty(names));
-    // False
-
-    console.log(head(names));
-    // Alice
-
-    console.log(tail(names));
-    // Some function representing the list of ("Bob", "Candice")
-
-    console.log(head(tail(names)));
-    // Bob
-
-### But Where is the Data?
-
-Did the definitions of those functions surprise you?  Lists seem like such an
-important, object-oriented concept, but there only appear to be functions here!
-
-Let's look at how this actually works.  First of all, the "empty list" concept
-is pretty straightforward:
-
-    :::javascript
-    var empty_list = null;
-
-    var is_empty = function(list) {
-        return list === null;
-    };
-
-We could have picked any arbitrary value here.  `null` seemed appropriate, so
-I used that.
-
-Now on to the meat of things: `prepend`.
-
-    :::javascript
-    var prepend = function(el, list) {
-        return function(command) {
-            if (command === "head") {
-                return el;
-            } else if (command === "tail") {
-                return list;
-            }
-        }
-    };
-
-This is where the real magic happens.  Let's think through it.
-
-First of all, we know that when you prepend something to a list, you're going to
-get a (new) list back.  So whatever `prepend` returns must be a list.
-
-Looking at the code, we can see it returns a function.  So in our little thought
-experiment, a list is actually a Javascript function under the hood!
-
-So what do we need to do with lists (aside from empty checking, which we've
-already covered)?  Well, we need to be able to get the head and the tail.  When
-we call `prepend(h, t)`, we happen to be conveniently specifying the head and
-tail as the arguments!  So in `prepend` we return a function that knows how to
-return its own head or tail when asked.
-
-So a "list" is "a function that knows how to return its own head or tail when
-asked".  So our `head` and `tail` functions just need to ask nicely!
-
-    :::javascript
-    var head = function(list) {
-        return list("head");
-    };
-
-    var tail = function(list) {
-        return list("tail");
-    };
-
-That's it!  We've created lists in 23 lines of code without using any fancy
-things like Objects.  Before you move on, make sure you really understand why
-this works.  Write out a few examples on paper.
-
-    :::javascript
-    var empty_list = null;
-
-    var prepend = function(el, list) {
-        return function(command) {
-            if (command === "head") {
-                return el;
-            } else if (command === "tail") {
-                return list;
-            }
-        }
-    };
-
-    var head = function(list) {
-        return list("head");
-    };
-
-    var tail = function(list) {
-        return list("tail");
-    };
-
-    var is_empty = function(list) {
-        return list === null;
-    };
-
-### Building on the Foundations
-
-Now that we have lists, let's implement a few common things on top of them as
-practice.
-
-#### map
-
-A common thing to do to a list is to create a new list by looping through it and
-doing something to each item.  This is called "map":
-
-    :::javascript
-    var map = function(fn, l) {
-        if (is_empty(l)) {
-            return empty_list;
-        } else {
-            return prepend(fn(head(l)), map(fn, tail(l)));
-        }
-    };
-
-If you're not used to recursive definitions like this, you may way to take
-a few minutes and try to work out how it works.  Here's an example:
-
-    :::javascript
-    var square = function(x) {
-        return x * x;
-    }
-    var numbers = prepend(1, prepend(2, prepend(3, empty_list)));
-
-    var squared_numbers = map(square, numbers);
-    // map(square, [1, 2, 3])
-    // prepend(square(1), map(square, [1, 2, 3]))
-    // prepend(square(1), prepend(square(2), map(square, [3])))
-    // prepend(square(1), prepend(square(2), prepend(square(3), map(square, []))))
-    // prepend(square(1), prepend(square(2), prepend(square(3), [])))
-    // prepend(square(1), prepend(square(2), prepend(9, [])))
-    // prepend(square(1), prepend(square(2), [9]))
-    // prepend(square(1), prepend(4, [9]))
-    // prepend(square(1), [4, 9])
-    // prepend(1, [4, 9])
-    // [1, 4, 9]
-
-I'm using brackets here to represent lists, but remember that these aren't
-arrays, but are actually the functions that were returned by `prepend`.
-
-If you're still not sure about this, trace out every step of `map(square,
-empty_list)` on paper.  Then trace out every step of `map(square, prepend(10,
-empty_list))`.
-
-Thinking recursively like this takes some practice.  I have notebooks filled
-with [pages like this](http://i.imgur.com/kqu5jy9.jpg).  Experienced guitarists
-practice new material slowly and methodically -- there's no reason programmers
-shouldn't do the same.  Watching the function calls expand and contract on paper
-can help you feel in your gut how these things work in a way that just staring
-at the words can't.
-
-#### filter
-
-We're going to start moving a bit faster now, but you should still make sure you
-understand everything completely before moving on.  Take as much time as you
-need.  Write things out.  Run them.  Get a feel for them.
-
-The next "utility" function we'll build on top of lists is `filter`, which
-takes a function and a list, and returns a new list whose elements are those in
-the original that make the function return `true`.  Here's an example:
-
-    :::javascript
-    var numbers = prepend(1, prepend(2, prepend(3, empty_list)));
-    var is_odd = function(x) {
-        return x % 2 === 1;
-    }
-
-    filter(is_odd, numbers);
-    // [1, 3]
-
-Now let's implement `filter`:
-
-    :::javascript
-    var filter = function(fn, l) {
-        if (is_empty(l)) {
-            return empty_list;
-        } else if (fn(head(l))) {
-            return prepend(head(l), filter(fn, tail(l)));
-        } else {
-            return filter(fn, tail(l));
-        }
-    };
-
-Take your time.  Trace out some examples.  Move on when you feel it in your gut.
-
-#### and, or, not
-
-Let's take a slight detour to implement a few "helper" functions.  Τhese don't
-have anything specifically to do with lists, but we'll need them later.
-
-    :::javascript
-    var not = function(x) {
-        if (x) {
-            return false;
-        } else {
-            return true;
-        }
-    };
-
-    var and = function(a, b) {
-        if (a) {
-            if (b) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            return false;
-        }
-    };
-
-    var or = function(a, b) {
-        if (a) {
-            return true;
-        } else {
-            if (b) {
-                return true;
-            } else {
-                return false;
-            }
-        }
-    };
-
-Javascript already has these things built in as `!`, `&&`, and `||`, of course,
-but remember that in this thought exercise we're trying to avoid using extra
-language features if we don't need them.  How far can we scrape by on just
-functions and `if` statements?
-
-One small note: these functions are just normal Javascript functions, which
-means that `and(a, b)` will *not* short-circuit like `a && b` would.  For our
-purposes here that won't hurt us, but it's something to be aware of.
-
-### List Out of Lambda
-
-Now that we've had a bit more practice, let's go back to our definition of
-lists:
-
-    :::javascript
-    var empty_list = null;
-
-    var prepend = function(el, list) {
-        return function(command) {
-            if (command === "head") {
-                return el;
-            } else if (command === "tail") {
-                return list;
-            }
-        }
-    };
-
-    var head = function(list) {
-        return list("head");
-    };
-
-    var tail = function(list) {
-        return list("tail");
-    };
-
-    var is_empty = function(list) {
-        return list === null;
-    };
-
-There are a few things about this implementation that bother me.  Our goal is to
-use as few language features as possible, but we've actually used quite a few!
-I count at least five:
-
-* Functions
-* `if` statements
-* Strings
-* Booleans (the `true`/`false` result of `is_empty`)
-* Equality checking (the `===` checks)
-
-It turns out we can remove most of those things at the cost of a bit of
-readability (and more bending of our minds).
-
-Let's start by rewriting the core three functions to ditch those ugly strings,
-equality checks, and even the `if` statement:
-
-    :::javascript
-    var prepend = function(el, list) {
-        return function(selector) {
-            return selector(el, list);
-        };
-    };
-
-    var head = function(list) {
-        return list(function(h, t) {
-            return h;
-        });
-    };
-
-    var tail = function(list) {
-        return list(function(h, t) {
-            return t;
-        });
-    };
-
-You may want to get a snack before wrapping your brain around this one!  There's
-no strings, no equality checking, no `if` statements.  But we still have lists!
-
-The `prepend` functions still returns a function, just like before.  Remember
-that in the last implementation, a "list" was really a function that knew how to
-give out its head or its tail when asked for them.
-
-This time, we're inverting the "asking".  In this version, a "list" is "a
-function that will tell another function about both its head *and* its tail when
-asked".  This time the *asker* gets *both* pieces, and can decide which one they
-want to use.
-
-Let's look at the `head` function:
-
-* `head` takes a list and says `return list(...)`, which means: "Hey list,
-  I would like you to tell all of your info to this little helper function I'm
-  giving you".
-* The list says `return ...(el, list)`, which means: "Okay helper function,
-  here's my head and my tail, enjoy!"
-* The helper function that `head` originally gave was `function(h, t) { return
-  h; }`.  So when the list calls it with the head and the tail as arguments, it
-  returns the head and ignores the tail.
-* `head` takes that result and just returns it straight through back to the
-  caller.
-
-`tail` works exactly the same way, but its helper function returns the second
-argument (the tail) instead of the first.
-
-That's it!  The equality checking and `if` statements have disappeared.  Can you
-describe where they've gone?  What has taken their place?
-
-Before we move on, let's clean up the idea of the empty list.  It's still using
-`null` and equality checking.  Let's remove those and make things a little more
-uniform.
-
-To do this we'll need to change the other three functions a bit as well, but if
-you've understood everything so far it shouldn't be too bad.
-
-    :::javascript
-    var empty_list = function(selector) {
-        return selector(undefined, undefined, true);
-    };
-
-    var prepend = function(el, list) {
-        return function(selector) {
-            return selector(el, list, false);
-        };
-    };
-
-    var head = function(list) {
-        return list(function(h, t, e) {
-            return h;
-        });
-    };
-
-    var tail = function(list) {
-        return list(function(h, t, e) {
-            return t;
-        });
-    };
-
-    var is_empty = function(list) {
-        return list(function(h, t, e) {
-            return e;
-        });
-    };
-
-We've now made lists a bit smarter.  In addition to telling the helper function
-their head and tail, they also tell it "am I the empty list?".  We've modified
-the helpers `head` and `tail` to accept (and ignore) this extra argument.
-
-We then modified `is_empty` to work just like `head` and `tail`.
-
-Finally, we've redefined `empty_list` to match the rest of the lists instead of
-being a special, magic value.  The empty list is now just like a normal one:
-it's a function that takes an "asker" and tells that asker "Hey, my head and
-tail are undefined and I am the empty list".
-
-I used `undefined` here which is technically another language feature because
-it's easier to read.  Feel free to replace it with anything you want to make it
-more pure.  Since we're being very careful to never call `head` or `tail` on the
-empty list those values will never be seen anyway.
-
-So after all that, we've finally implemented the building blocks of lists with
-only two things:
-
-* Functions.
-* `true` and `false` for empty lists.
-
-If you're up for a challenge, think about whether you could remove that second
-item (and if so, are you *really* removing it, or just using certain features of
-Javascript implicitly instead of explicitly?).
-
-A Brief Intermission
---------------------
-
-Let's take a minute to reflect on all the code we've seen so far.  First, we
-have an implementation of lists that uses only functions and booleans:
-
-    :::javascript
-    var empty_list = function(selector) {
-        return selector(undefined, undefined, true);
-    };
-
-    var prepend = function(el, list) {
-        return function(selector) {
-            return selector(el, list, false);
-        };
-    };
-
-    var head = function(list) {
-        return list(function(h, t, e) {
-            return h;
-        });
-    };
-
-    var tail = function(list) {
-        return list(function(h, t, e) {
-            return t;
-        });
-    };
-
-    var is_empty = function(list) {
-        return list(function(h, t, e) {
-            return e;
-        });
-    };
-
-From this point on, we can now ignore the details of how lists are implemented.
-As long as we have `head`, `tail`, and `prepend` we don't need to worry about
-what lists actually *are* under the hood.
-
-We also built a few helper functions on top of this foundation:
-
-    :::javascript
-    var not = function(x) {
-        if (x) {
-            return false;
-        } else {
-            return true;
-        }
-    };
-
-    var and = function(a, b) {
-        if (a) {
-            if (b) {
-                return true;
-            } else {
-                return false;
-            }
-        } else {
-            return false;
-        }
-    };
-
-    var or = function(a, b) {
-        if (a) {
-            return true;
-        } else {
-            if (b) {
-                return true;
-            } else {
-                return false;
-            }
-        }
-    };
-
-    var map = function(fn, l) {
-        if (is_empty(l)) {
-            return empty_list;
-        } else {
-            return prepend(fn(head(l)), map(fn, tail(l)));
-        }
-    };
-
-    var filter = function(fn, l) {
-        if (is_empty(l)) {
-            return empty_list;
-        } else if (fn(head(l))) {
-            return prepend(head(l), filter(fn, tail(l)));
-        } else {
-            return filter(fn, tail(l));
-        }
-    };
-
-Before you move on, make sure all of this code is crystal clear.  Come back
-tomorrow if you need to let it sink in.  We're about to go a lot deeper into the
-rabbit hole, so make sure you're ready.
-
-Numbers
--------
-
-If you look at the definitions of `prepend`, `head`, and `tail`, they're pretty
-mind-bending.  However, the definitions of `map` and `filter` are much more
-straightforward.
-
-This is because we encapsulated the implementation of lists into the first four
-functions.  We did all the hard work of building lists out of almost nothing at
-all and hid it behind that simple `prepend`, `head`, and `tail` interface.
-
-The idea of creating things from simple pieces and abstracting them into "black
-boxes" is one of the most important parts of both computer science and
-programming, so let's take it a step further and get some more practice by
-implementing numbers.
-
-### What is a Number?
-
-For this blog post we're only going to concern ourselves with non-negative
-integers.  Feel free to try extending all this to include negative integers if
-you want more.
-
-How can we represent a number?  Well we could obviously use Javascript numbers
-like `14`, but that's not very fun, and we're trying to minimize the number of
-language features we use.
-
-One way to represent a number is a list whose length is the number.  So we could
-say that `[1, 1, 1]` means "three", `["cats", null]` means "two", and `[]` means
-"zero".
-
-The elements themselves don't really matter, so let's just pick something we
-already have: the empty list!  Let's write out a few to get a feel for this:
-
-    :::javascript
-    var zero = empty_list;
-    // []
-
-    var one = prepend(empty_list, empty_list);
-    // [ [] ]
-
-    var two = prepend(empty_list, prepend(empty_list, empty_list));
-    // [ [], [] ]
-
-### inc, dec
-
-We're going to want to *do* things with our numbers, so let's start writing
-things that work with this "list of things" representation of numbers.
-
-Our basic building blocks are going to be `inc` and `dec` (increment and
-decrement).
-
-    :::javascript
-    var inc = function(n) {
-        return prepend(empty_list, n);
-    };
-
-    var dec = function(n) {
-        return tail(n);
-    };
-
-To add 1 to a number, we just push another element on the list.  So
-`inc(inc(zero))` means "two".
-
-To subtract 1, we just pop off one of the elements: `dec(two)` means "one"
-(remember we're ignoring negative numbers).
-
-### is\_zero
-
-When we started working with lists we used `is_empty` a lot, so it's probably
-a good idea to create an `is_zero` function at this point:
-
-    :::javascript
-    var is_zero = function(n) {
-        return is_empty(n);
-    };
-
-Zero is just represented by the empty list, so this one is easy!
-
-### add
-
-Adding one is easy, but we're probably going to want to add arbitrary numbers
-together.  Now that we have `inc` and `dec` this is actually pretty easy:
-
-    :::javascript
-    var add = function(a, b) {
-        if (is_zero(b)) {
-            return a;
-        } else {
-            return add(inc(a), dec(b));
-        }
-    };
-
-This is another recursive definition.  When adding two numbers, there are two
-possibilities:
-
-* If `b` is zero, then anything plus zero is itself, so we can just return `a`.
-* Otherwise, adding `a + b` is the same as adding `(a + 1) + (b - 1)`.
-
-Eventually `b` will "bottom out" and return `a` (which has been steadily getting
-bigger as `b` got smaller).
-
-Notice how we didn't say anything about lists here!  The "numbers are lists
-under the hood" idea has been encapsulated behind `is_zero`, `inc`, and `dec`,
-so we can ignore it and work at the "number" level of abstraction from here on
-out.
-
-### sub
-
-Subtraction is similar to addition, but instead of *increasing* `a` as `b` gets
-smaller, we *decrease* them both together:
-
-    :::javascript
-    var sub = function(a, b) {
-        if (is_zero(b)) {
-            return a;
-        } else {
-            return sub(dec(a), dec(b));
-        }
-    };
-
-Now we can say something like `add(two, sub(three, two))` and the result will be
-a representation of "three" in our system (which, of course, is a list of three
-elements).
-
-Pause for a minute now and remember that underneath numbers are lists, and
-underneath lists there's nothing but functions.  We can add and subtract
-integers and underneath it all it's just functions shuffling around, expanding
-into other functions and contracting as they're called, and this writhing mass
-of lambdas somehow ends up representing `1 + 1 = 2`.  That's pretty cool!
-
-### mul, pow
-
-For practice let's create a way to multiply numbers:
-
-    :::javascript
-    var mul = function(a, b) {
-        if (is_zero(b)) {
-            return zero;
-        } else {
-            return add(a, mul(a, dec(b)));
-        }
-    };
-
-Building on `add` makes this pretty easy.  `3 * 4` is the same as `3
-+ 3 + 3 + 3 + 0`.  Trace out the execution on paper if things are starting to
-get away from you.  Carry on when you're ready.
-
-`pow` ("power" or exponential) follows a similar structure as `mul`, but instead
-of adding together the copies we multiply them, and our base is one instead of
-zero:
-
-    :::javascript
-    var pow = function(a, b) {
-        if (is_zero(b)) {
-            return one;
-        } else {
-            return mul(a, pow(a, dec(b)));
-        }
-    };
-
-### is\_equal
-
-A common thing to do with numbers is to check if two are equal, so let's write
-that:
-
-    :::javascript
-    var is_equal = function(n, m) {
-        if (and(is_zero(n), is_zero(m))) {
-            return true;
-        } else if (or(is_zero(n), is_zero(m))) {
-            return false;
-        } else {
-            return is_equal(dec(n), dec(m));
-        }
-    };
-
-There are three cases here:
-
-* If both numbers are zero, they are equal.
-* If only one number is zero (but not both, or the first case would have caught
-  it), then they are *not* equal.
-* Otherwise, subtract one from each and try again.
-
-When calling this function with two non-zero numbers, both will be decremented
-in tandem until one of them bottoms out at zero first, or until they bottom out
-at the same time.
-
-### less\_than, greater\_than
-
-We can take a similar approach to implementing `less_than`:
-
-    :::javascript
-    var less_than = function(a, b) {
-        if (and(is_zero(a), is_zero(b))) {
-            return false;
-        } else if (is_zero(a)) {
-            return true;
-        } else if (is_zero(b)) {
-            return false;
-        } else {
-            return less_than(dec(a), dec(b));
-        }
-    };
-
-The difference here is that we have four cases.
-
-* If both numbers are zero, then `a` is not less than `b`.
-* Otherwise if `a` is zero (and we know `b` isn't) then yes, `a` is less than
-  `b`.
-* Otherwise if `b` is zero (and we know that `a` isn't) then no, `a` cannot be
-  less than `b` (remember that we're ignoring negative numbers).
-* Otherwise decrement both and try again.
-
-Once again, both numbers race to bottom out, and the outcome is decided by which
-one bottoms out first.
-
-We could do something similar for `greater_than`, but let's do it the easy way
-instead:
-
-    :::javascript
-    var greater_than = function(a, b) {
-        return less_than(b, a);
-    };
-
-### div, mod
-
-Once we have `less_than` we're ready to implement division and remainders:
-
-    :::javascript
-    var div = function(a, b) {
-        if (less_than(a, b)) {
-            return zero;
-        } else {
-            return inc(div(sub(a, b), b));
-        }
-    };
-
-    var rem = function(a, b) {
-        if (less_than(a, b)) {
-            return a;
-        } else {
-            return rem(sub(a, b), b);
-        }
-    };
-
-This pair is a bit more complicated than the three other basic operations
-because we can't deal with negative numbers.  Make sure you understand how it
-works.
-
-Full Circle
------------
-
-At this point, we have a (very basic) working system of numbers built on top of
-lists.  Let's chase our tails a bit and implement a few more list functions that
-use numbers.
-
-### nth
-
-To get the Nth item in a list, we just pop things off of it as we decrement
-N until we hit zero:
-
-    :::javascript
-    var nth = function(l, n) {
-        if (is_zero(n)) {
-            return head(l);
-        } else {
-            return nth(tail(l), dec(n));
-        }
-    };
-
-Under the hood there are really *two* lists getting things popped off as we
-iterate, because `n` is a number, which is a list, and `dec` pops things off.
-But it's much easier to read when we've abstracted away the representation of
-numbers, don't you think?
-
-### drop, take
-
-Two handy functions for working with lists are `drop` and `take`.
-
-`drop(l, three)` will return the list with the first three elements removed.
-
-`take(l, three)` will return the list containing only the first three elements.
-
-    :::javascript
-    var drop = function(l, n) {
-        if (is_zero(n)) {
-            return l;
-        } else {
-            return drop(tail(l), dec(n));
-        }
-    };
-
-    var take = function(l, n) {
-        if (is_zero(n)) {
-            return empty_list;
-        } else {
-            return prepend(head(l), take(tail(l), dec(n)));
-        }
-    };
-
-### slice
-
-Slicing a list is easy now that we have `drop`, `take`, and the ability to
-subtract numbers:
-
-    :::javascript
-    var slice = function(l, start, end) {
-        return take(drop(l, start), sub(end, start));
-    };
-
-First we drop up to the start, then take enough to get us to the end.
-
-### length
-
-We can define `length` recursively like everything else:
-
-    :::javascript
-    var length = function(l) {
-        if (is_empty(l)) {
-            return zero;
-        } else {
-            return inc(length(tail(l)));
-        }
-    };
-
-The length of the empty list is zero, and the length of any non-empty list is
-one plus the length of its tail.
-
-If your mind isn't in knots by this point, consider the following:
-
-* Lists are made of functions.
-* Numbers are made of lists whose length represents the number.
-* `length` is a function that takes a list (which is a function) and returns
-  the length as a number (a list whose length represents the number).
-* We only just now got around to defining `length` even though we've been using
-  numbers (which use the *length* of a list to represent a number) for a while
-  now!
-
-Are you dizzy yet?  If not:
-
-    :::javascript
-    var mylist = prepend(empty_list,
-                         prepend(empty_list,
-                                 empty_list));
-    var mylistlength = length(mylist);
-
-`mylist` is a list of two empty lists.
-
-`mylistlength` is the length of `mylist`...  
-which is "two"...  
-which is represented by a list of two empty lists...  
-which is `mylist` itself!
-
-Conclusion
-----------
-
-If you liked this twisty little story, I highly recommend you check out [The
-Little Schemer][].  It was one of the first books that really changed how
-I thought about programming.  Don't be put off by the fact that it uses Scheme
--- the language doesn't really matter.
-
-I've also created [a gist][] with all the code.  Feel free to fork it and use it
-for practice.
-
-You could add some more utility functions for practice writing recursively:
-
-* `append` to add an item to the end of a list.
-* `concat` to concatenate two lists.
-* `min` and `max` which take two numbers and return the minimum/maximum one.
-* `remove`, which is like filter except it only leaves the elements that return
-  `false` for the predicate.
-* `contains_number`, which checks if a specific number is inside a list of
-  numbers.
-
-Or if you want something more challenging, try implementing bigger concepts on
-top of the current ones:
-
-* Negative numbers.
-* Non-negative rational numbers.
-* Negative rational numbers.
-* Association lists (a data structure that associates keys with values).
-
-Remember: the point is not to create something that runs well on a physical
-computer.  Instead of thinking about how to make a particular combination of
-transistors and circuits have the right voltages, think about "computing" in the
-beautiful, perfect, abstract sense.
-
-[a gist]: https://gist.github.com/sjl/5277681
-
-    {% endblock article %}
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2013/03/list-out-of-lambda.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,1097 @@
++++
+title = "List Out of Lambda"
+snip = "Down the rabbit hole we go!"
+date = 2013-03-30T14:00:00Z
+draft = false
+
++++
+
+If you ignore the practical issues of computers like size, weight, cost, heat,
+and so on, what do you *really* need in a programming language?  Let's play
+around with this question.
+
+To understand this post you'll need a basic understanding of how functions in
+Javascript work.  If you can look at this code and understand what it prints,
+you're good to go:
+
+```javascript
+var x = 10;
+
+var f = function(y) {
+    console.log(x);
+    console.log(y);
+}
+
+var g = f;
+
+f(1);
+g(2);
+```
+
+This blog post is a thought exercise.  It's not something you'd ever use for
+real code.  But just like a guitarist practices scales that she won't ever play
+in a song, we programmers should be exercising our brains every so often.
+
+I'm going to use Javascript for the examples.  Any language with first class
+functions and lexical scoping (basically: closures) will work.  The examples
+would be prettier in a Lisp, but some people would be turned off by the syntax
+and miss out on some interesting ideas.  Feel free to port the code if it
+bothers you.
+
+If you've already seen this kind of thing before (maybe you've gone through [The
+Little Schemer][] or [SICP][]) you may want to just skim the code here and look
+for anything new.
+
+If you *haven't* seen anything like this, then you're in for a treat!  It's all
+going to look extremely weird the first time you see it.  Go slowly and make
+sure you understand each piece fully before moving on to the next.  These
+concepts may be unintuitive, but they're built from very simple pieces.
+
+Finally: if you get stuck, don't worry.  Tracing out the execution of a function
+on paper can be a good way to wrap your brain around it (I recommend investing
+in a good lap desk for comfy reading and writing).  If that doesn't work, just
+close the window and come back tomorrow.  Sometimes new concepts need a while to
+rattle around in your brain before they click into place.
+
+[The Little Schemer]: http://www.amazon.com/dp/0262560992/?tag=stelos-20
+[SICP]: http://www.amazon.com/dp/0070004846/?tag=stelos-20
+
+{{% toc %}}
+
+Lists
+-----
+
+Let's get started.  One of the most common things we do as programmers is
+grouping data together.  Javascript has "arrays" built in to the language for
+this:
+
+```javascript
+var names = ["Alice", "Bob", "Candice"];
+```
+
+What if Javascript didn't come with arrays included?  Could we create them (or
+something like them) ourselves?
+
+To answer this, let's think about the bare minimum we'd need to "bootstrap"
+something like an array.  There are a number of ways to do this, but we're going
+to look at one in particular.
+
+We'll call our array-like thing a "list".  To make it work, we need four parts:
+
+* The concept of "the empty list".
+* A way to add an element to the front of a list.
+* A way to take a list and get the first element.
+* A way to take a list and get everything *but* the first element.
+
+If we have those four things, we can build on top of them to do anything else we
+might want.  For example: to make a list of one item, you add that item to the
+front of the empty list.
+
+Let's narrow this down further.  There are lots of ways you could implement
+those four things — I'm going to use functions.  Let's sketch out an outline:
+
+```javascript
+var empty_list = null;
+
+var prepend = function(el, list) {
+    // ...
+};
+
+var head = function(list) {
+    // ...
+};
+
+var tail = function(list) {
+    // ...
+};
+
+var is_empty = function(list) {
+    // ...
+};
+```
+
+Here are the descriptions of each of these items.
+
+The `empty_list` is a special value that represents a list of zero elements.
+It can be anything, so for now we'll use `null` (we'll revisit this later).
+
+`prepend(1, some_list)` will return a new list that looks like the old one, but
+with `1` stuck onto the front of it.  So if we want to create a list of the
+numbers `1` and `2` we can say `prepend(1, prepend(2, empty_list))` or "prepend
+one to the result of prepending 2 to the empty list".
+
+`head(some_list)` will return the first element in the list.  Calling it on the
+empty list will be undefined, so we'll just be very careful not to do that!
+
+`tail(some_list)` will return a new list that's like the one we gave it, but
+with the first element removed.  Again, calling this on an empty list will make
+things explode.
+
+`is_empty(some_list)` will return `true` if the list given to it is the empty
+list, and `false` otherwise.
+
+Once we have those four functions (plus the special empty list value) we can
+start building on top of them, so let's figure out how to make them!
+
+### List Out of If
+
+If you haven't seen anything like this before, you might think it's time to
+start creating Javascript Objects.  That's certainly one way to do it.
+
+Since this post is a thought experiment in what we actually *need*, though,
+let's try to avoid using big language features (like Objects) unless we
+absolutely can't avoid it.
+
+So if we don't want to use other language features yet, what are we left with?
+Well so far our skeleton only has functions (and `null`), so let's try those!
+
+Here's the first working revision of the building blocks of lists:
+
+```javascript
+var empty_list = null;
+
+var prepend = function(el, list) {
+    return function(command) {
+        if (command === "head") {
+            return el;
+        } else if (command === "tail") {
+            return list;
+        }
+    }
+};
+
+var head = function(list) {
+    return list("head");
+};
+
+var tail = function(list) {
+    return list("tail");
+};
+
+var is_empty = function(list) {
+    return list === null;
+};
+```
+
+Go ahead and paste that into a browser console and play with it:
+
+```javascript
+var e = empty_list;
+
+console.log(is_empty(e));
+// true
+
+var names = prepend("Alice",
+                    prepend("Bob",
+                            prepend("Candice",
+                                    empty_list)));
+
+console.log(is_empty(names));
+// False
+
+console.log(head(names));
+// Alice
+
+console.log(tail(names));
+// Some function representing the list of ("Bob", "Candice")
+
+console.log(head(tail(names)));
+// Bob
+```
+
+### But Where is the Data?
+
+Did the definitions of those functions surprise you?  Lists seem like such an
+important, object-oriented concept, but there only appear to be functions here!
+
+Let's look at how this actually works.  First of all, the "empty list" concept
+is pretty straightforward:
+
+```javascript
+var empty_list = null;
+
+var is_empty = function(list) {
+    return list === null;
+};
+```
+
+We could have picked any arbitrary value here.  `null` seemed appropriate, so
+I used that.
+
+Now on to the meat of things: `prepend`.
+
+```javascript
+var prepend = function(el, list) {
+    return function(command) {
+        if (command === "head") {
+            return el;
+        } else if (command === "tail") {
+            return list;
+        }
+    }
+};
+```
+
+This is where the real magic happens.  Let's think through it.
+
+First of all, we know that when you prepend something to a list, you're going to
+get a (new) list back.  So whatever `prepend` returns must be a list.
+
+Looking at the code, we can see it returns a function.  So in our little thought
+experiment, a list is actually a Javascript function under the hood!
+
+So what do we need to do with lists (aside from empty checking, which we've
+already covered)?  Well, we need to be able to get the head and the tail.  When
+we call `prepend(h, t)`, we happen to be conveniently specifying the head and
+tail as the arguments!  So in `prepend` we return a function that knows how to
+return its own head or tail when asked.
+
+So a "list" is "a function that knows how to return its own head or tail when
+asked".  So our `head` and `tail` functions just need to ask nicely!
+
+```javascript
+var head = function(list) {
+    return list("head");
+};
+
+var tail = function(list) {
+    return list("tail");
+};
+```
+
+That's it!  We've created lists in 23 lines of code without using any fancy
+things like Objects.  Before you move on, make sure you really understand why
+this works.  Write out a few examples on paper.
+
+```javascript
+var empty_list = null;
+
+var prepend = function(el, list) {
+    return function(command) {
+        if (command === "head") {
+            return el;
+        } else if (command === "tail") {
+            return list;
+        }
+    }
+};
+
+var head = function(list) {
+    return list("head");
+};
+
+var tail = function(list) {
+    return list("tail");
+};
+
+var is_empty = function(list) {
+    return list === null;
+};
+```
+
+### Building on the Foundations
+
+Now that we have lists, let's implement a few common things on top of them as
+practice.
+
+#### map
+
+A common thing to do to a list is to create a new list by looping through it and
+doing something to each item.  This is called "map":
+
+```javascript
+var map = function(fn, l) {
+    if (is_empty(l)) {
+        return empty_list;
+    } else {
+        return prepend(fn(head(l)), map(fn, tail(l)));
+    }
+};
+```
+
+If you're not used to recursive definitions like this, you may way to take
+a few minutes and try to work out how it works.  Here's an example:
+
+```javascript
+var square = function(x) {
+    return x * x;
+}
+var numbers = prepend(1, prepend(2, prepend(3, empty_list)));
+
+var squared_numbers = map(square, numbers);
+// map(square, [1, 2, 3])
+// prepend(square(1), map(square, [1, 2, 3]))
+// prepend(square(1), prepend(square(2), map(square, [3])))
+// prepend(square(1), prepend(square(2), prepend(square(3), map(square, []))))
+// prepend(square(1), prepend(square(2), prepend(square(3), [])))
+// prepend(square(1), prepend(square(2), prepend(9, [])))
+// prepend(square(1), prepend(square(2), [9]))
+// prepend(square(1), prepend(4, [9]))
+// prepend(square(1), [4, 9])
+// prepend(1, [4, 9])
+// [1, 4, 9]
+```
+
+I'm using brackets here to represent lists, but remember that these aren't
+arrays, but are actually the functions that were returned by `prepend`.
+
+If you're still not sure about this, trace out every step of `map(square,
+empty_list)` on paper.  Then trace out every step of `map(square, prepend(10,
+empty_list))`.
+
+Thinking recursively like this takes some practice.  I have notebooks filled
+with [pages like this](http://i.imgur.com/kqu5jy9.jpg).  Experienced guitarists
+practice new material slowly and methodically — there's no reason programmers
+shouldn't do the same.  Watching the function calls expand and contract on paper
+can help you feel in your gut how these things work in a way that just staring
+at the words can't.
+
+#### filter
+
+We're going to start moving a bit faster now, but you should still make sure you
+understand everything completely before moving on.  Take as much time as you
+need.  Write things out.  Run them.  Get a feel for them.
+
+The next "utility" function we'll build on top of lists is `filter`, which
+takes a function and a list, and returns a new list whose elements are those in
+the original that make the function return `true`.  Here's an example:
+
+```javascript
+var numbers = prepend(1, prepend(2, prepend(3, empty_list)));
+var is_odd = function(x) {
+    return x % 2 === 1;
+}
+
+filter(is_odd, numbers);
+// [1, 3]
+```
+
+Now let's implement `filter`:
+
+```javascript
+var filter = function(fn, l) {
+    if (is_empty(l)) {
+        return empty_list;
+    } else if (fn(head(l))) {
+        return prepend(head(l), filter(fn, tail(l)));
+    } else {
+        return filter(fn, tail(l));
+    }
+};
+```
+
+Take your time.  Trace out some examples.  Move on when you feel it in your gut.
+
+#### and, or, not
+
+Let's take a slight detour to implement a few "helper" functions.  Τhese don't
+have anything specifically to do with lists, but we'll need them later.
+
+```javascript
+var not = function(x) {
+    if (x) {
+        return false;
+    } else {
+        return true;
+    }
+};
+
+var and = function(a, b) {
+    if (a) {
+        if (b) {
+            return true;
+        } else {
+            return false;
+        }
+    } else {
+        return false;
+    }
+};
+
+var or = function(a, b) {
+    if (a) {
+        return true;
+    } else {
+        if (b) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+};
+```
+
+Javascript already has these things built in as `!`, `&&`, and `||`, of course,
+but remember that in this thought exercise we're trying to avoid using extra
+language features if we don't need them.  How far can we scrape by on just
+functions and `if` statements?
+
+One small note: these functions are just normal Javascript functions, which
+means that `and(a, b)` will *not* short-circuit like `a && b` would.  For our
+purposes here that won't hurt us, but it's something to be aware of.
+
+### List Out of Lambda
+
+Now that we've had a bit more practice, let's go back to our definition of
+lists:
+
+```javascript
+var empty_list = null;
+
+var prepend = function(el, list) {
+    return function(command) {
+        if (command === "head") {
+            return el;
+        } else if (command === "tail") {
+            return list;
+        }
+    }
+};
+
+var head = function(list) {
+    return list("head");
+};
+
+var tail = function(list) {
+    return list("tail");
+};
+
+var is_empty = function(list) {
+    return list === null;
+};
+```
+
+There are a few things about this implementation that bother me.  Our goal is to
+use as few language features as possible, but we've actually used quite a few!
+I count at least five:
+
+* Functions
+* `if` statements
+* Strings
+* Booleans (the `true`/`false` result of `is_empty`)
+* Equality checking (the `===` checks)
+
+It turns out we can remove most of those things at the cost of a bit of
+readability (and more bending of our minds).
+
+Let's start by rewriting the core three functions to ditch those ugly strings,
+equality checks, and even the `if` statement:
+
+```javascript
+var prepend = function(el, list) {
+    return function(selector) {
+        return selector(el, list);
+    };
+};
+
+var head = function(list) {
+    return list(function(h, t) {
+        return h;
+    });
+};
+
+var tail = function(list) {
+    return list(function(h, t) {
+        return t;
+    });
+};
+```
+
+You may want to get a snack before wrapping your brain around this one!  There's
+no strings, no equality checking, no `if` statements.  But we still have lists!
+
+The `prepend` functions still returns a function, just like before.  Remember
+that in the last implementation, a "list" was really a function that knew how to
+give out its head or its tail when asked for them.
+
+This time, we're inverting the "asking".  In this version, a "list" is "a
+function that will tell another function about both its head *and* its tail when
+asked".  This time the *asker* gets *both* pieces, and can decide which one they
+want to use.
+
+Let's look at the `head` function:
+
+* `head` takes a list and says `return list(...)`, which means: "Hey list,
+  I would like you to tell all of your info to this little helper function I'm
+  giving you".
+* The list says `return ...(el, list)`, which means: "Okay helper function,
+  here's my head and my tail, enjoy!"
+* The helper function that `head` originally gave was `function(h, t) { return
+  h; }`.  So when the list calls it with the head and the tail as arguments, it
+  returns the head and ignores the tail.
+* `head` takes that result and just returns it straight through back to the
+  caller.
+
+`tail` works exactly the same way, but its helper function returns the second
+argument (the tail) instead of the first.
+
+That's it!  The equality checking and `if` statements have disappeared.  Can you
+describe where they've gone?  What has taken their place?
+
+Before we move on, let's clean up the idea of the empty list.  It's still using
+`null` and equality checking.  Let's remove those and make things a little more
+uniform.
+
+To do this we'll need to change the other three functions a bit as well, but if
+you've understood everything so far it shouldn't be too bad.
+
+```javascript
+var empty_list = function(selector) {
+    return selector(undefined, undefined, true);
+};
+
+var prepend = function(el, list) {
+    return function(selector) {
+        return selector(el, list, false);
+    };
+};
+
+var head = function(list) {
+    return list(function(h, t, e) {
+        return h;
+    });
+};
+
+var tail = function(list) {
+    return list(function(h, t, e) {
+        return t;
+    });
+};
+
+var is_empty = function(list) {
+    return list(function(h, t, e) {
+        return e;
+    });
+};
+```
+
+We've now made lists a bit smarter.  In addition to telling the helper function
+their head and tail, they also tell it "am I the empty list?".  We've modified
+the helpers `head` and `tail` to accept (and ignore) this extra argument.
+
+We then modified `is_empty` to work just like `head` and `tail`.
+
+Finally, we've redefined `empty_list` to match the rest of the lists instead of
+being a special, magic value.  The empty list is now just like a normal one:
+it's a function that takes an "asker" and tells that asker "Hey, my head and
+tail are undefined and I am the empty list".
+
+I used `undefined` here which is technically another language feature because
+it's easier to read.  Feel free to replace it with anything you want to make it
+more pure.  Since we're being very careful to never call `head` or `tail` on the
+empty list those values will never be seen anyway.
+
+So after all that, we've finally implemented the building blocks of lists with
+only two things:
+
+* Functions.
+* `true` and `false` for empty lists.
+
+If you're up for a challenge, think about whether you could remove that second
+item (and if so, are you *really* removing it, or just using certain features of
+Javascript implicitly instead of explicitly?).
+
+A Brief Intermission
+--------------------
+
+Let's take a minute to reflect on all the code we've seen so far.  First, we
+have an implementation of lists that uses only functions and booleans:
+
+```javascript
+var empty_list = function(selector) {
+    return selector(undefined, undefined, true);
+};
+
+var prepend = function(el, list) {
+    return function(selector) {
+        return selector(el, list, false);
+    };
+};
+
+var head = function(list) {
+    return list(function(h, t, e) {
+        return h;
+    });
+};
+
+var tail = function(list) {
+    return list(function(h, t, e) {
+        return t;
+    });
+};
+
+var is_empty = function(list) {
+    return list(function(h, t, e) {
+        return e;
+    });
+};
+```
+
+From this point on, we can now ignore the details of how lists are implemented.
+As long as we have `head`, `tail`, and `prepend` we don't need to worry about
+what lists actually *are* under the hood.
+
+We also built a few helper functions on top of this foundation:
+
+```javascript
+var not = function(x) {
+    if (x) {
+        return false;
+    } else {
+        return true;
+    }
+};
+
+var and = function(a, b) {
+    if (a) {
+        if (b) {
+            return true;
+        } else {
+            return false;
+        }
+    } else {
+        return false;
+    }
+};
+
+var or = function(a, b) {
+    if (a) {
+        return true;
+    } else {
+        if (b) {
+            return true;
+        } else {
+            return false;
+        }
+    }
+};
+
+var map = function(fn, l) {
+    if (is_empty(l)) {
+        return empty_list;
+    } else {
+        return prepend(fn(head(l)), map(fn, tail(l)));
+    }
+};
+
+var filter = function(fn, l) {
+    if (is_empty(l)) {
+        return empty_list;
+    } else if (fn(head(l))) {
+        return prepend(head(l), filter(fn, tail(l)));
+    } else {
+        return filter(fn, tail(l));
+    }
+};
+```
+
+Before you move on, make sure all of this code is crystal clear.  Come back
+tomorrow if you need to let it sink in.  We're about to go a lot deeper into the
+rabbit hole, so make sure you're ready.
+
+Numbers
+-------
+
+If you look at the definitions of `prepend`, `head`, and `tail`, they're pretty
+mind-bending.  However, the definitions of `map` and `filter` are much more
+straightforward.
+
+This is because we encapsulated the implementation of lists into the first four
+functions.  We did all the hard work of building lists out of almost nothing at
+all and hid it behind that simple `prepend`, `head`, and `tail` interface.
+
+The idea of creating things from simple pieces and abstracting them into "black
+boxes" is one of the most important parts of both computer science and
+programming, so let's take it a step further and get some more practice by
+implementing numbers.
+
+### What is a Number?
+
+For this blog post we're only going to concern ourselves with non-negative
+integers.  Feel free to try extending all this to include negative integers if
+you want more.
+
+How can we represent a number?  Well we could obviously use Javascript numbers
+like `14`, but that's not very fun, and we're trying to minimize the number of
+language features we use.
+
+One way to represent a number is a list whose length is the number.  So we could
+say that `[1, 1, 1]` means "three", `["cats", null]` means "two", and `[]` means
+"zero".
+
+The elements themselves don't really matter, so let's just pick something we
+already have: the empty list!  Let's write out a few to get a feel for this:
+
+```javascript
+var zero = empty_list;
+// []
+
+var one = prepend(empty_list, empty_list);
+// [ [] ]
+
+var two = prepend(empty_list, prepend(empty_list, empty_list));
+// [ [], [] ]
+```
+
+### inc, dec
+
+We're going to want to *do* things with our numbers, so let's start writing
+things that work with this "list of things" representation of numbers.
+
+Our basic building blocks are going to be `inc` and `dec` (increment and
+decrement).
+
+```javascript
+var inc = function(n) {
+    return prepend(empty_list, n);
+};
+
+var dec = function(n) {
+    return tail(n);
+};
+```
+
+To add 1 to a number, we just push another element on the list.  So
+`inc(inc(zero))` means "two".
+
+To subtract 1, we just pop off one of the elements: `dec(two)` means "one"
+(remember we're ignoring negative numbers).
+
+### is\_zero
+
+When we started working with lists we used `is_empty` a lot, so it's probably
+a good idea to create an `is_zero` function at this point:
+
+```javascript
+var is_zero = function(n) {
+    return is_empty(n);
+};
+```
+
+Zero is just represented by the empty list, so this one is easy!
+
+### add
+
+Adding one is easy, but we're probably going to want to add arbitrary numbers
+together.  Now that we have `inc` and `dec` this is actually pretty easy:
+
+```javascript
+var add = function(a, b) {
+    if (is_zero(b)) {
+        return a;
+    } else {
+        return add(inc(a), dec(b));
+    }
+};
+```
+
+This is another recursive definition.  When adding two numbers, there are two
+possibilities:
+
+* If `b` is zero, then anything plus zero is itself, so we can just return `a`.
+* Otherwise, adding `a + b` is the same as adding `(a + 1) + (b - 1)`.
+
+Eventually `b` will "bottom out" and return `a` (which has been steadily getting
+bigger as `b` got smaller).
+
+Notice how we didn't say anything about lists here!  The "numbers are lists
+under the hood" idea has been encapsulated behind `is_zero`, `inc`, and `dec`,
+so we can ignore it and work at the "number" level of abstraction from here on
+out.
+
+### sub
+
+Subtraction is similar to addition, but instead of *increasing* `a` as `b` gets
+smaller, we *decrease* them both together:
+
+```javascript
+var sub = function(a, b) {
+    if (is_zero(b)) {
+        return a;
+    } else {
+        return sub(dec(a), dec(b));
+    }
+};
+```
+
+Now we can say something like `add(two, sub(three, two))` and the result will be
+a representation of "three" in our system (which, of course, is a list of three
+elements).
+
+Pause for a minute now and remember that underneath numbers are lists, and
+underneath lists there's nothing but functions.  We can add and subtract
+integers and underneath it all it's just functions shuffling around, expanding
+into other functions and contracting as they're called, and this writhing mass
+of lambdas somehow ends up representing `1 + 1 = 2`.  That's pretty cool!
+
+### mul, pow
+
+For practice let's create a way to multiply numbers:
+
+```javascript
+var mul = function(a, b) {
+    if (is_zero(b)) {
+        return zero;
+    } else {
+        return add(a, mul(a, dec(b)));
+    }
+};
+```
+
+Building on `add` makes this pretty easy.  `3 * 4` is the same as `3
++ 3 + 3 + 3 + 0`.  Trace out the execution on paper if things are starting to
+get away from you.  Carry on when you're ready.
+
+`pow` ("power" or exponential) follows a similar structure as `mul`, but instead
+of adding together the copies we multiply them, and our base is one instead of
+zero:
+
+```javascript
+var pow = function(a, b) {
+    if (is_zero(b)) {
+        return one;
+    } else {
+        return mul(a, pow(a, dec(b)));
+    }
+};
+```
+
+### is\_equal
+
+A common thing to do with numbers is to check if two are equal, so let's write
+that:
+
+```javascript
+var is_equal = function(n, m) {
+    if (and(is_zero(n), is_zero(m))) {
+        return true;
+    } else if (or(is_zero(n), is_zero(m))) {
+        return false;
+    } else {
+        return is_equal(dec(n), dec(m));
+    }
+};
+```
+
+There are three cases here:
+
+* If both numbers are zero, they are equal.
+* If only one number is zero (but not both, or the first case would have caught
+  it), then they are *not* equal.
+* Otherwise, subtract one from each and try again.
+
+When calling this function with two non-zero numbers, both will be decremented
+in tandem until one of them bottoms out at zero first, or until they bottom out
+at the same time.
+
+### less\_than, greater\_than
+
+We can take a similar approach to implementing `less_than`:
+
+```javascript
+var less_than = function(a, b) {
+    if (and(is_zero(a), is_zero(b))) {
+        return false;
+    } else if (is_zero(a)) {
+        return true;
+    } else if (is_zero(b)) {
+        return false;
+    } else {
+        return less_than(dec(a), dec(b));
+    }
+};
+```
+
+The difference here is that we have four cases.
+
+* If both numbers are zero, then `a` is not less than `b`.
+* Otherwise if `a` is zero (and we know `b` isn't) then yes, `a` is less than
+  `b`.
+* Otherwise if `b` is zero (and we know that `a` isn't) then no, `a` cannot be
+  less than `b` (remember that we're ignoring negative numbers).
+* Otherwise decrement both and try again.
+
+Once again, both numbers race to bottom out, and the outcome is decided by which
+one bottoms out first.
+
+We could do something similar for `greater_than`, but let's do it the easy way
+instead:
+
+```javascript
+var greater_than = function(a, b) {
+    return less_than(b, a);
+};
+```
+
+### div, mod
+
+Once we have `less_than` we're ready to implement division and remainders:
+
+```javascript
+var div = function(a, b) {
+    if (less_than(a, b)) {
+        return zero;
+    } else {
+        return inc(div(sub(a, b), b));
+    }
+};
+
+var rem = function(a, b) {
+    if (less_than(a, b)) {
+        return a;
+    } else {
+        return rem(sub(a, b), b);
+    }
+};
+```
+
+This pair is a bit more complicated than the three other basic operations
+because we can't deal with negative numbers.  Make sure you understand how it
+works.
+
+Full Circle
+-----------
+
+At this point, we have a (very basic) working system of numbers built on top of
+lists.  Let's chase our tails a bit and implement a few more list functions that
+use numbers.
+
+### nth
+
+To get the Nth item in a list, we just pop things off of it as we decrement
+N until we hit zero:
+
+```javascript
+var nth = function(l, n) {
+    if (is_zero(n)) {
+        return head(l);
+    } else {
+        return nth(tail(l), dec(n));
+    }
+};
+```
+
+Under the hood there are really *two* lists getting things popped off as we
+iterate, because `n` is a number, which is a list, and `dec` pops things off.
+But it's much easier to read when we've abstracted away the representation of
+numbers, don't you think?
+
+### drop, take
+
+Two handy functions for working with lists are `drop` and `take`.
+
+`drop(l, three)` will return the list with the first three elements removed.
+
+`take(l, three)` will return the list containing only the first three elements.
+
+```javascript
+var drop = function(l, n) {
+    if (is_zero(n)) {
+        return l;
+    } else {
+        return drop(tail(l), dec(n));
+    }
+};
+
+var take = function(l, n) {
+    if (is_zero(n)) {
+        return empty_list;
+    } else {
+        return prepend(head(l), take(tail(l), dec(n)));
+    }
+};
+```
+
+### slice
+
+Slicing a list is easy now that we have `drop`, `take`, and the ability to
+subtract numbers:
+
+```javascript
+var slice = function(l, start, end) {
+    return take(drop(l, start), sub(end, start));
+};
+```
+
+First we drop up to the start, then take enough to get us to the end.
+
+### length
+
+We can define `length` recursively like everything else:
+
+```javascript
+var length = function(l) {
+    if (is_empty(l)) {
+        return zero;
+    } else {
+        return inc(length(tail(l)));
+    }
+};
+```
+
+The length of the empty list is zero, and the length of any non-empty list is
+one plus the length of its tail.
+
+If your mind isn't in knots by this point, consider the following:
+
+* Lists are made of functions.
+* Numbers are made of lists whose length represents the number.
+* `length` is a function that takes a list (which is a function) and returns
+  the length as a number (a list whose length represents the number).
+* We only just now got around to defining `length` even though we've been using
+  numbers (which use the *length* of a list to represent a number) for a while
+  now!
+
+Are you dizzy yet?  If not:
+
+```javascript
+var mylist = prepend(empty_list,
+                     prepend(empty_list,
+                             empty_list));
+var mylistlength = length(mylist);
+```
+
+`mylist` is a list of two empty lists.
+
+`mylistlength` is the length of `mylist`...  
+which is "two"...  
+which is represented by a list of two empty lists...  
+which is `mylist` itself!
+
+Conclusion
+----------
+
+If you liked this twisty little story, I highly recommend you check out [The
+Little Schemer][].  It was one of the first books that really changed how
+I thought about programming.  Don't be put off by the fact that it uses Scheme
+-- the language doesn't really matter.
+
+I've also created [a gist][] with all the code.  Feel free to fork it and use it
+for practice.
+
+You could add some more utility functions for practice writing recursively:
+
+* `append` to add an item to the end of a list.
+* `concat` to concatenate two lists.
+* `min` and `max` which take two numbers and return the minimum/maximum one.
+* `remove`, which is like filter except it only leaves the elements that return
+  `false` for the predicate.
+* `contains_number`, which checks if a specific number is inside a list of
+  numbers.
+
+Or if you want something more challenging, try implementing bigger concepts on
+top of the current ones:
+
+* Negative numbers.
+* Non-negative rational numbers.
+* Negative rational numbers.
+* Association lists (a data structure that associates keys with values).
+
+Remember: the point is not to create something that runs well on a physical
+computer.  Instead of thinking about how to make a particular combination of
+transistors and circuits have the right voltages, think about "computing" in the
+beautiful, perfect, abstract sense.
+
+[a gist]: https://gist.github.com/sjl/5277681
+
+
--- a/content/blog/2013/04/git-koans.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Git Koans"
-        snip: "The path to enlightenment is long and arduous."
-        created: 2013-04-08 10:16:00
-    %}
-
-    {% block article %}
-
-Inspired by [Vim Koans][].
-
-[Vim Koans]: http://blog.sanctum.geek.nz/vim-koans/
-
-[TOC]
-
-Silence
--------
-
-A Python programmer handed her `~/.gitconfig` to Master Git.  Among the many
-lines were the following:
-
-    :::text
-    [alias]
-    ; Explicit is better than implicit.  If we want to merge
-    ; we should do so ourselves.
-    pull = pull --ff-only
-
-Master Git nodded.  "`git pull origin master`," said the programmer.
-
-Master Git pulled down the latest changes on `master` and automatically merged
-them with the programmer's changes.
-
-"But Master Git, did I not say to only fast-forward in my configuration?!" she
-cried.
-
-Master Git looked at her, nodded, and said nothing.
-
-"Then why did you not warn me of a problem with my configuration?" she asked.
-
-Master Git replied: "there was no problem."
-
-Months later the programmer was reading `git --help config` for a different
-reason and found enlightenment.
-
-One Thing Well
---------------
-
-A UNIX programmer was working in the cubicle farms.  As she saw Master Git
-traveling down the path, she ran to meet him.
-
-"It is an honor to meet you, Master Git!" she said.  "I have been studying the
-UNIX way of designing programs that each do one thing well.  Surely I can learn
-much from you."
-
-"Surely," replied Master Git.
-
-"How should I change to a different branch?" asked the programmer.
-
-"Use `git checkout`."
-
-"And how should I create a branch?"
-
-"Use `git checkout`."
-
-"And how should I update the contents of a single file in my working directory,
-without involving branches at all?"
-
-"Use `git checkout`."
-
-After this third answer, the programmer was enlightened.
-
-Only the Gods
--------------
-
-The great historian was trying to unravel the intricacies of an incorrect merge
-that had happened many months ago.  He made a pilgrimage to Master Git to ask
-for his help.
-
-"Master Git," said the historian, "what is the nature of history?"
-
-"History is immutable.  To rewrite it later is to tamper with the very fabric of
-existence."
-
-The historian nodded, then asked: "Is that why rebasing commits that have been
-pushed is discouraged?"
-
-"Indeed," said Master Git.
-
-"Splendid!" exclaimed the historian.  "I have a historical record of a merge
-commit with two parents.  How can I find out which branch each parent was
-originally made on?"
-
-"History is ephemeral," replied Master Git, "the knowledge you seek can be
-answered only by the gods."
-
-The historian hung his head as enlightenment crushed down upon him.
-
-The Hobgoblin
--------------
-
-A novice was learning at the feet of Master Git.  At the end of the lesson he
-looked through his notes and said, "Master, I have a few questions.  May I ask
-them?"
-
-Master Git nodded.
-
-"How can I view a list of *all* tags?"
-
-"`git tag`", replied Master Git.
-
-"How can I view a list of *all* remotes?"
-
-"`git remote -v`", replied Master Git.
-
-"How can I view a list of *all* branches?"
-
-"`git branch -a`", replied Master Git.
-
-"And how can I view the current branch?"
-
-"`git rev-parse --abbrev-ref HEAD`", replied Master Git.
-
-"How can I delete a remote?"
-
-"`git remote rm`", replied Master Git.
-
-"And how can I delete a branch?"
-
-"`git branch -d`", replied Master Git.
-
-The novice thought for a few moments, then asked: "Surely some of these could be
-made more consistent, so as to be easier to remember in the heat of coding?"
-
-Master Git snapped his fingers.  A hobgoblin entered the room and ate the novice
-alive.  In the afterlife, the novice was enlightened.
-
-The Long and Short of It
-------------------------
-
-Master Git and a novice were walking along a bridge.
-
-The novice, wanting to partake of Master Git's vast knowledge, said:
-"`git branch --help`".
-
-Master Git sat down and lectured her on the seven forms of `git branch`, and
-their many options.
-
-They resumed walking.  A few minutes later they encountered an experienced
-developer traveling in the opposite direction.  He bowed to Master Git and said
-"`git branch -h`".  Master Git tersely informed him of the most common `git
-branch` options.  The developer thanked him and continued on his way.
-
-"Master," said the novice, "what is the nature of long and short options for
-commands?  I thought they were equivalent, but when that developer used `-h` you
-said something different than when I said `--help`."
-
-"Perspective is everything," answered the Master.
-
-The novice was puzzled.  She decided to experiment and said "`git -h branch`".
-
-Master Git turned and threw himself off the railing, falling to his death on the
-rocks below.
-
-Upon seeing this, the novice was enlightened.
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2013/04/git-koans.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,165 @@
++++
+title = "Git Koans"
+snip = "The path to enlightenment is long and arduous."
+date = 2013-04-08T10:16:00Z
+draft = false
+
++++
+
+Inspired by [Vim Koans][].
+
+[Vim Koans]: http://blog.sanctum.geek.nz/vim-koans/
+
+{{% toc %}}
+
+Silence
+-------
+
+A Python programmer handed her `~/.gitconfig` to Master Git.  Among the many
+lines were the following:
+
+```text
+[alias]
+; Explicit is better than implicit.  If we want to merge
+; we should do so ourselves.
+pull = pull --ff-only
+```
+
+Master Git nodded.  "`git pull origin master`," said the programmer.
+
+Master Git pulled down the latest changes on `master` and automatically merged
+them with the programmer's changes.
+
+"But Master Git, did I not say to only fast-forward in my configuration?!" she
+cried.
+
+Master Git looked at her, nodded, and said nothing.
+
+"Then why did you not warn me of a problem with my configuration?" she asked.
+
+Master Git replied: "there was no problem."
+
+Months later the programmer was reading `git --help config` for a different
+reason and found enlightenment.
+
+One Thing Well
+--------------
+
+A UNIX programmer was working in the cubicle farms.  As she saw Master Git
+traveling down the path, she ran to meet him.
+
+"It is an honor to meet you, Master Git!" she said.  "I have been studying the
+UNIX way of designing programs that each do one thing well.  Surely I can learn
+much from you."
+
+"Surely," replied Master Git.
+
+"How should I change to a different branch?" asked the programmer.
+
+"Use `git checkout`."
+
+"And how should I create a branch?"
+
+"Use `git checkout`."
+
+"And how should I update the contents of a single file in my working directory,
+without involving branches at all?"
+
+"Use `git checkout`."
+
+After this third answer, the programmer was enlightened.
+
+Only the Gods
+-------------
+
+The great historian was trying to unravel the intricacies of an incorrect merge
+that had happened many months ago.  He made a pilgrimage to Master Git to ask
+for his help.
+
+"Master Git," said the historian, "what is the nature of history?"
+
+"History is immutable.  To rewrite it later is to tamper with the very fabric of
+existence."
+
+The historian nodded, then asked: "Is that why rebasing commits that have been
+pushed is discouraged?"
+
+"Indeed," said Master Git.
+
+"Splendid!" exclaimed the historian.  "I have a historical record of a merge
+commit with two parents.  How can I find out which branch each parent was
+originally made on?"
+
+"History is ephemeral," replied Master Git, "the knowledge you seek can be
+answered only by the gods."
+
+The historian hung his head as enlightenment crushed down upon him.
+
+The Hobgoblin
+-------------
+
+A novice was learning at the feet of Master Git.  At the end of the lesson he
+looked through his notes and said, "Master, I have a few questions.  May I ask
+them?"
+
+Master Git nodded.
+
+"How can I view a list of *all* tags?"
+
+"`git tag`", replied Master Git.
+
+"How can I view a list of *all* remotes?"
+
+"`git remote -v`", replied Master Git.
+
+"How can I view a list of *all* branches?"
+
+"`git branch -a`", replied Master Git.
+
+"And how can I view the current branch?"
+
+"`git rev-parse --abbrev-ref HEAD`", replied Master Git.
+
+"How can I delete a remote?"
+
+"`git remote rm`", replied Master Git.
+
+"And how can I delete a branch?"
+
+"`git branch -d`", replied Master Git.
+
+The novice thought for a few moments, then asked: "Surely some of these could be
+made more consistent, so as to be easier to remember in the heat of coding?"
+
+Master Git snapped his fingers.  A hobgoblin entered the room and ate the novice
+alive.  In the afterlife, the novice was enlightened.
+
+The Long and Short of It
+------------------------
+
+Master Git and a novice were walking along a bridge.
+
+The novice, wanting to partake of Master Git's vast knowledge, said:
+"`git branch --help`".
+
+Master Git sat down and lectured her on the seven forms of `git branch`, and
+their many options.
+
+They resumed walking.  A few minutes later they encountered an experienced
+developer traveling in the opposite direction.  He bowed to Master Git and said
+"`git branch -h`".  Master Git tersely informed him of the most common `git
+branch` options.  The developer thanked him and continued on his way.
+
+"Master," said the novice, "what is the nature of long and short options for
+commands?  I thought they were equivalent, but when that developer used `-h` you
+said something different than when I said `--help`."
+
+"Perspective is everything," answered the Master.
+
+The novice was puzzled.  She decided to experiment and said "`git -h branch`".
+
+Master Git turned and threw himself off the railing, falling to his death on the
+rocks below.
+
+Upon seeing this, the novice was enlightened.
+
--- a/content/blog/2013/09/teach-dont-tell.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,746 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Teach, Don't Tell"
-        snip: "Documentation Matters"
-        created: 2013-09-03 10:55:00
-        flattr: true
-    %}
-
-    {% block article %}
-
-This post is about writing technical documentation.  More specifically: it's
-about writing documentation for programming languages and libraries.
-
-I love reading great documentation.  When I have a question and the
-documentations explains the answer almost as if the author has magically
-anticipated my problem, I get a warm, fuzzy feeling inside.  I feel a connection
-with the writer that makes me smile.
-
-I also love writing documentation.  Being able to rewire the neurons in
-someone's brain so that they understand something they didn't understand before
-is extremely satisfying.  Seeing (or hearing about) the "click" when a bunch of
-concepts suddenly fall together and make sense never fails to make my day.
-
-This post is going to be about what I think good documentation is and how
-I think you should go about writing it.  I'm not perfect, so you should take
-everything with a grain of salt, but I hope you'll find it useful and
-thought-provoking even if you don't agree with me about everything.
-
-I'd like to say thanks to [Craig Zheng][cz] and [Honza Pokorny][honza] for
-proofreading this.
-
-[cz]: http://craigzheng.com/
-[honza]: http://honza.ca/
-
-[TOC]
-
-## Prior Reading
-
-Before you read this post there are two other things I think you should read
-first.
-
-The first is Jacob Kaplan-Moss' [Writing Great Documentation][] series.  He's
-certainly more qualified than I am to write about this stuff, so you should
-check that out if you haven't already.  A lot of what I say here is going to
-agree with and build on the ideas he talked about.
-
-The other thing you should read is [The Science of Scientific Writing][] by
-George Gopen and Judith Swan.  Don't be put off by the fact that it's written
-for scientists publishing papers in journals.  Everything in that article
-applies equally well to programmers writing technical docs.  Read the entire
-thing.  It's worth it.
-
-[Writing Great Documentation]: http://jacobian.org/writing/great-documentation/
-[The Science of Scientific Writing]: http://www.americanscientist.org/issues/id.877,y.0,no.,content.true,page.1,css.print/issue.aspx
-
-## Why Do We Document?
-
-Let's get started.  The first thing to nail down is *why* we're documenting
-a programming language or library in the first place.  There are many things you
-might want to accomplish, but I'm going to boil them down into a single
-statement:
-
-**The purpose of technical documentation is to take someone who has never seen
-your project, teach them to be an expert user of it, and support them once they
-become an expert.**
-
-At first glance this probably doesn't seem too controversial or interesting.
-But there's one word in there that makes *all* the difference, and it frames my
-entire perspective on documentation.
-
-## Teaching
-
-If you want to take a person who has never played the guitar and turn them into
-a virtuoso guitarist, how can you do that?
-
-You *teach* them.
-
-If you want to take a high school student and turn them into a computer
-scientist, how can you do that?
-
-You *teach* them.
-
-If you want to take a programmer who has never seen your library before and turn
-them into an expert user of it, how can you do that?
-
-You *teach* them!
-
-Guitar lessons are usually taught in person, one-on-one, with a teacher.
-Computer Science is usually taught by professors in classrooms.  Programming
-library usage is usually taught by documentation.
-
-If the goal of documentation is to turn novices into experts, then *the
-documentation must teach*.  You should think of your documentation as a lesson
-(or series of lessons) because *that's what it is*.
-
-When writing technical documentation you (usually) don't have the advantage of
-having a one-on-one dialog with the learners.  This makes it a bit more
-difficult, but not impossible as long as you're careful.  Your documentation
-needs to fill the role of both the in-person lessons *and* the textbook.
-
-The rest of this post will be almost entirely about how to apply the
-"documentation is teaching" mindset to writing programming docs.
-
-## A Play in Seven Acts
-
-I'm going to break up the content of this post with some venting about *bad*
-documentation.  If you want to skip these little rants, go ahead.
-
-Each act in our play has two characters: a teenager and a parent.  The teenager
-has just turned sixteen and would like to learn to drive so they can hang out
-with their friends without relying on their parents to drive them everywhere.
-
-Each act will demonstrate a caricature of a particularly *bad* form of
-documentation.  I hope these little metaphors will help show why certain forms
-of documentation are ineffective cop-outs and why you should write *real*
-documentation instead.
-
-## Act 1: "Read the Source"
-
-Our play starts with a son and father sitting at the breakfast table.  The son
-is munching on some cereal before school while the father reads his iPad before
-leaving for work.
-
-The son says: "Hey Dad, you said you were going to teach me how to drive after
-school today.  Are we still going to do that?"
-
-The father, without looking up from his iPad, replies: "Of course, son.  The car
-is in the garage and I laid out a set of wrenches on the workbench.  Take the
-car apart and look at each piece, then put it back together.  Once you've done
-that I'll take you to the DMV for your driving test."
-
-The son quietly continued eating his cereal.
-
-If you use many open source libraries you've undoubtedly encountered some whose
-README says something like "read the source".  Every time I see one, I die
-a little bit inside.
-
-Source code is *not* documentation.  Can you learn to be a guitarist by simply
-listening to a piece of music intently?  Can you become a painter by visiting
-a lot of museums?  Of course not!
-
-Let me be clear: I'm not trying to say that reading source code isn't a valuable
-thing to do.  It is!
-
-Looking at other artists' paintings is extremely useful *once you know how to
-paint*.  Learning how the brakes of a car are constructed can save your life,
-*once you know how to drive*.
-
-Once your library's users know how to work with it, reading its source is
-absolutely worth their time.  But you can't look at the finished product and
-understand the perspective and ideas that went into it without additional
-guidance.  That's a job for documentation.
-
-## Tools of the Trade
-
-Writing good documentation doesn't take much in the way of tools.
-
-For example: you don't need a thesaurus.  Don't try to avoid using the same
-words by substituting synonyms.  Just talk to your users like you would talk to
-another human being in real life!
-
-If you use the same word ten times in a row your readers probably won't even
-notice.  But I guarantee they're going to notice if you throw in strange,
-uncommon words for no good reason.
-
-There are two tools I *will* recommend before moving on.  The first isn't
-actually a tool, but a skill.
-
-To write great documentation, you need to be able to type.
-
-When you write docs you'll inevitably write yourself into a corner and realize
-you need to take a new direction.  If you don't type quickly, you might be
-hesitant to throw away writing that doesn't really work.  You need to learn to
-type well so you don't feel bad throwing away a chunk of a thousand words that
-don't fit.
-
-Steve Yegge's article [Programming's Dirty Little Secret][type-dammit] is
-a great rant on this topic.
-
-You should also get yourself a nice keyboard.  A good keyboard won't make you
-a good writer (just like a good guitar won't make you a good guitarist), but it
-*will* make you want to write more just for the sheer joy of using
-a well-designed piece of equipment.
-
-I started practicing guitar a lot more after I got a new guitar that was much
-nicer than my old one.  If you spend a hundred dollars, get a nice keyboard, and
-end up wanting to write more, it was worth it!
-
-Be thankful that a nice keyboard only costs $100 to $300 and not several
-thousand dollars like a nice instrument.
-
-[type-dammit]: http://steve-yegge.blogspot.com/2008/09/programmings-dirtiest-little-secret.html
-
-## Act 2: "Read the Tests"
-
-The next scene opens with a mother picking her daughter up from high school.
-
-"Hi Mom", she says, "are you still going to teach me to drive today?"
-
-"Yep!" she replies.  "Let's get going."
-
-After ten minutes of driving they arrive at the Chevrolet factory.
-
-The girl looks around, puzzled.  She asks: "What are we doing here?"
-
-The mother smiles and says: "You're in luck, honey, my friend Jim works here at
-the Chevy plant, and he's gonna let you watch a few crash tests of the new
-Malibu!  Once you see a few cars smash into each other, I'll take you down to
-the DMV for your driving test."
-
-Another common form of "documentation" is the README instructing users to "read
-the tests".
-
-Tests aren't docs.
-
-Again, let's be clear: once you already know how to use a library, reading the
-tests is *very* useful.  But you need documentation to make you an expert user
-first!
-
-You don't learn to drive by watching crash tests.  But learning how your car
-behaves during a crash can save your life *once you know how to drive*.
-
-A common argument I see goes something like this:
-
-"The tests use the library, so they're a good example of how to use it!"
-
-This is true in some very superficial sense, but completely misses the mark.
-
-Most of the tests are probably going to deal with edge cases.  Edge cases are
-things a normal user won't be encountering very often (otherwise they wouldn't
-be edge cases!).
-
-If you're lucky, you might get a test that verifies the library works correctly
-on a normal set of input.  But a "normal set of input" is what the users are
-going to be working with the majority the time!
-
-Tests simply aren't a good guide to what a user is going to be encountering on
-a day-to-day basis.  They can't teach a novice to be an expert.
-
-## How to Teach
-
-If you accept my idea that the purpose of documentation is to *teach* users, the
-next question is obviously: "How do I teach my users?"
-
-I've been lucky enough to have the chance to teach dancing semi-formally for
-around 6 or 7 years, and lots of various other things informally for a long
-time.  The only way to *really* learn how to teach is to *do it*.
-
-There's no substitute for sitting down with someone face-to-face and teaching
-them something.  **If you want to write better documentation, you need to
-practice teaching**.
-
-I'm not talking about writing out lesson plans or anything nearly so formal.  Do
-you have a hobby (not programming)?  If so, spend a couple of hours on a weekend
-teaching a friend about it.  You'll get some practice teaching and they'll get
-to learn something new.
-
-(If you don't have any non-programming hobbies, maybe you should find some.)
-
-If you like photography, teach someone the basics of exposure and composition.
-If you dance, teach them some basic steps.  If you play an instrument, teach
-them how to play a simple song.  If you like camping, teach them what all the
-gear is for.  You get the idea.
-
-Don't go overboard.  You don't need to give someone a degree, you just need to
-practice teaching a little bit.  You need to practice the art of rewiring
-someone's neurons with your words.
-
-Once you jump into teaching something (even something simple) you'll probably
-realize that although you know how to do it yourself, it's a lot harder to teach
-someone else.
-
-This is obvious when you're working face-to-face with someone.  When you tell
-them how to play a C major chord on the guitar and they only produce a strangled
-squeak, it's clear that you need to slow down and talk about how to press down
-on the strings properly.
-
-As programmers, we almost *never* get this kind of feedback about our
-documentation.  We don't see that the person on the other end of the wire is
-hopelessly confused and blundering around because they're missing something we
-thought was obvious (but wasn't).  Teaching someone in person helps you learn to
-anticipate this, which will pay off (for your users) when you're writing
-documentation.
-
-With all that said, I do want to also talk a little about the actual process of
-teaching.
-
-The best description of how to teach that I've seen so far is from the book [How
-to Solve It][].  Everyone who wants to teach should read this book.  The passage
-that really jumped out at me is right in the first page of the first chapter:
-
-> The best [way for the teacher to help their student] is to help the student
-> naturally.  The teacher should put himself in the student's place, he should
-> see the student's case, he should try to understand what is going on in the
-> student's mind, and ask a question or indicate a step that *could have
-> occurred to the student himself*.
-
-This, right here, is the core of teaching.  This is it.  This is how you do it.
-
-People don't learn by simply absorbing lots of unstructured information as it's
-thrown at them.  You can't read a Spanish dictionary to someone to teach them
-Spanish.
-
-When you want to teach someone you need to put yourself in their shoes and walk
-along the path with them.  Hold their hand, guide them around the dangerous
-obstacles and catch them when they fall.  *Don't* carry them.  *Certainly
-don't* just drive them to the destination in your car!
-
-The process needs to go something like this:
-
-1. Figure out what they already know.
-2. Figure out what you want them to know after you finish.
-3. Figure out a single idea or concept that will move state 1 a little bit
-   closer to state 2.
-4. Nudge the student in the direction of that idea.
-5. Repeat until state 1 becomes state 2.
-
-Too often I see documentation that has very carefully considered step 2, and
-then simply presents it to the reader as a pronouncement from God.  That isn't
-teaching.  That's telling.  People don't learn by being *told*, they
-learn by being *taught*.
-
-[How to Solve It]: http://www.amazon.com/dp/069111966X/?tag=stelos-20
-
-## Act 3: "Literate Programming"
-
-The third act opens with a daughter talking to her mother the day before her
-sixteenth birthday.
-
-"Hey Mom," she says, "I don't know if you got me a present yet, but if not, what
-I'd *really* like for my birthday are driving lessons."
-
-The mother smiles and says: "Don't worry, it's all taken care of.  Just wait for
-tomorrow."
-
-The next day at her birthday party she unwraps the present from her mom.  Inside
-is a DVD of the show How It's Made.  She looks quizzically at her mother.
-
-"That DVD has an episode about the factory that builds your car!  Once you watch
-the whole thing I'll take you for your driving test."
-
-A horrible trend I've noticed lately is using "literate programming" tools like
-Docco, Rocco, etc and telling users to read the results for documentation.
-
-Programming languages and libraries are tools.  Knowing how a tool was made
-doesn't mean you know how to use it.  When you take guitar lessons, you don't
-visit a luthier to watch her shape a Telecaster out of Ash wood.
-
-Knowing how your car was built can help you, *once you know how to drive*.
-
-Knowing how your guitar was built can help you, *once you know how to play*.
-
-A common theme throughout these acts/rants is that all of these things I'm
-picking on (source, tests, literate programming, and more) are good things with
-real benefits *once you have actual documentation in place to teach users*. 
-
-But until that happens, they're actually *bad* because they let you pretend
-you've written documentation and your job is done (JKM mentions this in his
-series).  Your job is not done until you've taught your users enough to become
-experts.  *Then* they can take advantage of all these extras.
-
-## The Anatomy of Good Documentation
-
-The rest of this post is going to be about the individual components that make
-up good documentation.  My views are pretty similar to JKM's, so if you haven't
-read the series I mentioned in the first section you should probably do that.
-
-In my mind I divide good documentation into roughly four parts:
-
-1. First Contact
-2. The Black Triangle
-3. The Hairball
-4. The Reference
-
-There don't necessarily have to be four separate documents for each of these.
-In fact the first two can usually be combined into a single file, while the last
-two should probably be split into many pieces.  But I think each component is
-a distinct, important part of good documentation.
-
-Let's take a look at each.
-
-## First Contact
-
-When you release a new programming language or library into the wild, the
-initial state of your "users" is going to be blank.  The things they need
-to know when they encounter your library are:
-
-1. What is this thing?
-2. Why would I care about this thing?
-3. Is it worth the effort to learn this thing?
-
-Your "first contact" documentation should explain these things to them.
-
-You don't need to explain things from first principles.  Try to put yourself in
-the shoes of your users.  When you're teaching your teenager to drive, you don't
-need to explain what a "wheel" is.  They probably have some experience with
-"things on wheels that you move around in" like lawn mowers or golf carts (or
-even video games).
-
-Likewise: if you're creating a web framework, most of the people that stumble on
-to your project are probably going to know what "HTML" is.  It's good to err
-a little bit on the side of caution and explain a little more than to assume too
-much, but you can be practical here.
-
-Your "first contact" docs should explain what, in plain words, your thing does.
-It should show someone why they should care about that.  Will it save them time?
-Will it take more time, but be more stable in exchange?  Is it just plain fun?
-
-For bonus points, you can also mention why someone might want to *not* use your
-project.  Barely anyone ever mentions the tradeoffs involved with using their
-work, so to see a project do this is refreshing.
-
-Finally, the user needs to know if it's worth spending some of their finite
-amount of time on this planet learning more about your project.  You should
-explicitly spell out things like:
-
-* What license the project uses (so they know if it's practical to use).
-* Where the bug tracker is (so they can see issues).
-* Where the source code is (so they can see if it's (relatively) recently
-  maintained).
-* Where the documentation is (so they can skim it and get an idea of the effort
-  that's going to be involved in becoming an expert).
-
-
-
-## Act 4: "Read the Docstrings"
-
-Scene four.  A father is finally making good on his promise to give his daughter
-driving lessons.
-
-"Okay Dad," she says, "I'm ready.  I've never driven a car before.  Where do we
-start?"
-
-A woman in her mid-forties walks through the door.  "Who's this?" the daughter
-asks.
-
-"This is your driving teacher, Ms. Smith." the father replies.  "She's going to
-sit in the passenger seat with you while you drive the two hour trip to visit
-grandpa.  If you have any questions about a part of the car while you're
-driving, you can ask her and she'll tell you all about that piece.  Here are
-the keys, good luck!"
-
-In languages with [docstrings][] there's a tendency to write great docstrings
-and call them documentation.  I'm sure the "doc" in the word "docstrings"
-contributes to this.
-
-Docstrings don't provide any organization or order (beyond "the namespace they
-happen to be implemented in").  Users need to somehow know the name of the
-function they need to even be able to *see* the docstring, and they can't know
-that unless you *teach* them.
-
-Again, docstrings are great *once you know the project*.  But when you're
-teaching a novice how to use your library, you need to guide them along they
-way and not sit back and answer questions when they manage to guess a magic
-word correctly.
-
-[docstrings]: https://en.wikipedia.org/wiki/Docstring
-
-## The Black Triangle
-
-The next important piece of documentation is [the "black triangle"][].  It
-should be a relatively short guide to getting your project up and running so the
-user can poke at it.
-
-This serves a couple of purposes.  First, it lets the user verify that yes, this
-collection of bytes is actually going to run and *do something* on their
-machine.  It's a quick sanity check that the project hasn't bit rotted and is
-still viable to use at that point in time.  More importantly, it lets your
-prospective user [get some paint on the canvas][paint].
-
-Imagine if you went to your first guitar lesson and the teacher said: "Okay,
-we're going to start by learning 150 different chords.  Then in about six months
-we can play some songs."  No guitar teacher does that.  They teach you three
-chords and give you a couple of cheesy pop songs to play.  It helps the student
-get a feel for what being a guitarist as a whole is going to be like, and it
-gives them something to help keep their interest.
-
-Your "black triangle" documentation should be a short guide that runs the user
-through the process of retrieving, installing, and poking your project or
-language.
-
-"Short" here is a relative word.  Some projects are going to require more setup
-to get running.  If the benefits are enough to justify the effort, that's not
-necessarily a problem.  But try to keep this as short as possible.  *Just get
-something on the screen* and move on.
-
-[the "black triangle"]: http://rampantgames.com/blog/2004/10/black-triangle.html
-[paint]: http://worrydream.com/LearnableProgramming/#react
-
-## Act 5: "Read the API Docs"
-
-Our next scene opens a year after the last, with the father from the last scene
-talking to his son.
-
-(Sadly, the daughter in that scene died in a car crash because she didn't know
-to ask Ms. Smith about seatbelts before getting on the expressway.  Ms.  Smith
-was wearing hers, of course.)
-
-"Okay son, I know you're a little scared of driving because of what happened to
-your sister, but I've fixed the problem."
-
-He hands the young man an inch-thick book.  "Asking Ms. Smith questions along
-the way clearly didn't work, so we had her write out a paragraph or two about
-each piece of your car.  Go ahead and read the entire manual cover to cover and
-then drive down to see grandpa."
-
-API documentation is like the user's manual of a car.  When something goes wrong
-and you need to replace a tire it's a godsend.  But if you're learning to drive
-it's not going to help you because *people don't learn by reading alphabetized
-lists of disconnected information*.
-
-If you actually try to teach someone to use your project face-to-face, you'll
-probably find yourself talking about things in one namespace for a while, then
-switching to another to cover something related, then switching back to the
-first.  Learning isn't a straight path through the alphabet, it's a zig-zaggy
-ramble through someone else's brain.
-
-## The Hairball
-
-This brings me to the next type of documentation: "the hairball".  By now the
-user has hopefully seen the "first contact" docs and the "black triangle" docs.
-You've got them hooked and ready to learn, but they're still novices.
-
-The "hairball" is the twisted, tangled maze of teaching that is going to take
-these novices and turn them into expert users.  It's going to mold their brains,
-one nudge at a time, until they have a pretty good understanding of how your
-project works.
-
-You'll usually want to organize the "hairball" into sections (unless this is
-a very small project).  These sections will probably *kind of* line up with
-namespaces in your project's public API, but when it makes sense to deviate you
-should do so.
-
-Don't be afraid to write.  Be concise but err on the side of explaining a bit
-too much.  Programmers are pretty good at skimming over things they already
-know, but if you forget to include a crucial connection it can leave your users
-lost and stumbling around in the woods.
-
-You should have a table of contents that lists each section of the "hairball".
-And then each section should have its own table of contents that lists the
-sections inside it.  A table of contents is a wonderful way to get a birds-eye
-view of what you're about to read, to prepare your brain for it.  And of
-course it's also handy for navigating around.
-
-This is where your hobby-teaching practice and your reading of How to Solve It
-are going to come in handy.  Put yourself in a user's brain and figure out each
-little connective leap they're going to need to make to become an expert.
-
-## Act 6: "Read the Wiki"
-
-In the penultimate scene, a mother has signed her teenage son up for an
-after-school driving class.
-
-On the first day, the teacher hands them a syllabus detailing what they're going
-to cover, talks about grading, and sends them home a bit early.
-
-On the second day, she gives them a brief overview of the various pieces of
-a car and how they work together.  She also talks about a few of the most
-important laws they'll need to be aware of.
-
-On the third day, the teacher calls in sick and they have a substitute.  He
-covers the material for half of the fifth day in the syllabus.  He has to leave
-early, so he brings in his nineteen year old daughter to finish the class.
-She covers the first half of the fourth day's material.
-
-The fourth day the students arrive to find a note on the door saying the class
-has been cancelled because the teacher is still sick and they can't find
-a substitute.  There's a note saying "TODO: we'll talk about the material
-later."
-
-The fifth day the teacher has partially recovered, so she returns and covers the
-material for the fifth day.  It's a bit hard to understand her because she's had
-half a bottle of Nyquil and is slurring most of her words and keeps saying
-"cat" instead of "car".
-
-All the students fail the driving test.
-
-Wikis are an abomination.  They are the worst form of "documentation".
-
-First of all: assuming they work as intended, they have no coherent voice.
-
-Have you ever taken a class with multiple teachers at once?  Probably not,
-because it doesn't work very well (with exceptions for things like partnered
-dancing where there are distinct lead/follow parts).
-
-Worse still: have you ever taken a class where there's one jackass in the room
-who keeps constantly raising his hand and offering his own (often incorrect)
-opinions?  Wikis are like that, except they *actively encourage* random people
-to interrupt the teacher with their own interjections.
-
-I can hear the objections now: "But putting our docs on a wiki means *anyone*
-can fix typos!"
-
-Jesus.  Christ.
-
-"It makes it easy to fix typos" is a horrible argument for using a wiki.
-
-First of all, as JKM says, you should have an editor (or at least someone to
-proofread) which will catch a lot of the typos.
-
-And even if there *are* typos, they're one of the least important things you
-need to worry about anyway.  Misspelling "their" isn't going to impact the
-effectiveness of your teaching very much.  Your lessons being a disorganized
-mess because they were written by three different people across six months *is*
-going to make them less effective.
-
-Keeping your documentation in a wiki also makes it hard or impossible to keep it
-where it belongs: in version control right alongside your code.
-
-But all that is irrelevant because aside from Wikipedia itself and video game
-wikis, *they don't fucking work*.
-
-The project maintainer sets up a wiki, sits back and pats herself on the back
-saying: "I have set up a way for other people to do this boring job of writing
-documentation for me.  Now we wait." 
-
-Maybe one or two people fix some typos.  A dude who thinks he understands
-a topic but actually doesn't writes some completely wrong docs.  Maybe they get
-reverted, maybe they don't.
-
-The project changes.  A new user reads some of the (sparse) documentation which
-is now out of date.  Eventually they discover this and complain only to be met
-with: "Well it's a wiki, fix it yourself!"
-
-It is not the responsibility of the student to fix a broken lesson plan.  For
-fuck's sake, *the entire point of having a teacher* is that they know what the
-students need to learn and the students don't!
-
-It's completely okay to ask your students for criticism so you can improve your
-lesson plan.  Asking "what parts did you find difficult?" is fine.  It's another
-thing entirely to ask them to *write your lesson plan for you*.
-
-Seriously: fuck wikis.  They are bad and terrible.  Do not use them.  Take the
-time and effort to write some real documentation instead.
-
-## The Reference
-
-The final type of documentation is "the reference".  This section is for the
-users who have traveled through the "hairball" and made it to the other side.
-They're now your experts, and the reference should support them as they use your
-project in their daily work.
-
-This section should contain things that experienced users are likely to need,
-such as:
-
-* "API documentation" for every user-facing part of your project.
-* A full changelog, with particular attention to backwards-incompatible changes
-  between versions.
-* Details about the internal implementation of the project.
-* Contribution policies (if your project accepts outside contributions).
-
-Tools like JavaDoc can produce something that looks like the first, but I share
-the same opinion as Jacob Kaplan-Moss:
-
-> Auto-generated documentation is almost worthless. At best it's a slightly
-> improved version of simply browsing through the source, but most of the time
-> it's easier just to read the source than to navigate the bullshit that these
-> autodoc tools produce. About the only thing auto-generated documentation is
-> good for is filling printed pages when contracts dictate delivery of a certain
-> number of pages of documentation. I feel a particularly deep form of rage
-> every time I click on a "documentation" link and see auto-generated
-> documentation.
-> 
-> There's no substitute for documentation written, organized, and edited by
-> hand.
-
-Yes, you can probably find a tool to read your project's source and shit out
-some HTML files with the function names in them.  Maybe it will even include the
-docstrings!
-
-I would still urge you to write your API docs by hand.  It's going to be
-a little more typing, but the results will be much better for a number of
-reasons.
-
-API docs and docstrings, while similar, serve different purposes.  Docstrings
-have to provide what you need in the heat of coding in a REPL-friendly format.
-API docs can afford the luxury of a bit more explanation, as well as links to
-other things the user might want to know while browsing them on their couch.
-API docs should also be Google-friendly.
-
-A common objection here is that you're going to be retyping a lot of words.
-Copy and paste mostly solves that problem, and learning to type makes the rest
-a non-issue.
-
-Some will say: "But copy and pasting is evil!  You're duplicating effort!  How
-will you keep the changes in the docstrings and the API docs in sync if they
-change?"
-
-My opinion here is that if your public-facing API is changing often, you're
-probably going to be making your users' lives harder when they need to
-constantly update their code to work with yours.  So the least you can do is
-make *your* life a little harder to provide them with the best documentation
-possible to help ease the pain.
-
-Auto-generated documentation has no coherent voice.  It pulls in everything in
-the code without regard for overall structure and vision.  You can *probably*
-get away with it for the API docs in your "reference" documentation, or you
-could take some pride in your work and write the best docs possible!
-
-## Act 7: "A New Hope"
-
-The final act of our play is set in a mall parking lot on a Sunday afternoon.
-A single car is in the parking lot.  Inside is a family: a mother and father who
-are teaching their son to drive.
-
-They start by driving the car into the middle of the lot, away from any
-obstacles.  The son gets into the driver's seat, and the parents explain briefly
-what the main controls do.  They let him drive around the empty lot a bit to get
-a feel for how the car works.
-
-When it's time for him to park he shifts to park and takes off his seatbelt.
-His mom reminds him of the control called a "parking brake".  He realizes that
-he should use this when parking.  A set of neurons is now linked in his brain
-and he will remember to use the parking brake properly for the rest of his life.
-
-Over time the parents take their son driving many times, always being sure that
-they're putting him into situations he can handle (but will still learn from).
-He drives on a road, then learns to parallel park, then drives on a highway.
-
-He has questions along the way.  Sometimes the parents are ready with an answer.
-Sometimes the questions reveal something else missing deeper down in his
-knowledge which the parents correct.
-
-Over time he learns more and more.  He gets his license and begins driving on
-his own.
-
-When he gets a flat tire he reads the owner's manual and fixes it.
-
-He watches the How It's Made episode about his car because he's curious how the
-brakes which saved his life at a stop sign last week actually work.
-
-His windshield wipers stop working one day.  He opens up the hood and figures
-out the problem, fixing it himself.
-
-One day he is hit by a drunk driver.  He walks away with only bruises.  He never
-saw the countless crash tests the engineers performed to create the airbag
-system, but they saved his life.
-
-In the last scene we see the son many years later.  His hair is a bit gray now,
-but otherwise he looks a lot like the teenager who forgot to use the parking
-brake.
-
-He's in a car with his teenage daughter, and he's teaching her how to drive.
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2013/09/teach-dont-tell.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,742 @@
++++
+title = "Teach, Don't Tell"
+snip = "Documentation Matters"
+date = 2013-09-03T10:55:00Z
+draft = false
+
++++
+
+This post is about writing technical documentation.  More specifically: it's
+about writing documentation for programming languages and libraries.
+
+I love reading great documentation.  When I have a question and the
+documentations explains the answer almost as if the author has magically
+anticipated my problem, I get a warm, fuzzy feeling inside.  I feel a connection
+with the writer that makes me smile.
+
+I also love writing documentation.  Being able to rewire the neurons in
+someone's brain so that they understand something they didn't understand before
+is extremely satisfying.  Seeing (or hearing about) the "click" when a bunch of
+concepts suddenly fall together and make sense never fails to make my day.
+
+This post is going to be about what I think good documentation is and how
+I think you should go about writing it.  I'm not perfect, so you should take
+everything with a grain of salt, but I hope you'll find it useful and
+thought-provoking even if you don't agree with me about everything.
+
+I'd like to say thanks to [Craig Zheng][cz] and [Honza Pokorny][honza] for
+proofreading this.
+
+[cz]: http://craigzheng.com/
+[honza]: http://honza.ca/
+
+{{% toc %}}
+
+## Prior Reading
+
+Before you read this post there are two other things I think you should read
+first.
+
+The first is Jacob Kaplan-Moss' [Writing Great Documentation][] series.  He's
+certainly more qualified than I am to write about this stuff, so you should
+check that out if you haven't already.  A lot of what I say here is going to
+agree with and build on the ideas he talked about.
+
+The other thing you should read is [The Science of Scientific Writing][] by
+George Gopen and Judith Swan.  Don't be put off by the fact that it's written
+for scientists publishing papers in journals.  Everything in that article
+applies equally well to programmers writing technical docs.  Read the entire
+thing.  It's worth it.
+
+[Writing Great Documentation]: http://jacobian.org/writing/great-documentation/
+[The Science of Scientific Writing]: http://www.americanscientist.org/issues/id.877,y.0,no.,content.true,page.1,css.print/issue.aspx
+
+## Why Do We Document?
+
+Let's get started.  The first thing to nail down is *why* we're documenting
+a programming language or library in the first place.  There are many things you
+might want to accomplish, but I'm going to boil them down into a single
+statement:
+
+**The purpose of technical documentation is to take someone who has never seen
+your project, teach them to be an expert user of it, and support them once they
+become an expert.**
+
+At first glance this probably doesn't seem too controversial or interesting.
+But there's one word in there that makes *all* the difference, and it frames my
+entire perspective on documentation.
+
+## Teaching
+
+If you want to take a person who has never played the guitar and turn them into
+a virtuoso guitarist, how can you do that?
+
+You *teach* them.
+
+If you want to take a high school student and turn them into a computer
+scientist, how can you do that?
+
+You *teach* them.
+
+If you want to take a programmer who has never seen your library before and turn
+them into an expert user of it, how can you do that?
+
+You *teach* them!
+
+Guitar lessons are usually taught in person, one-on-one, with a teacher.
+Computer Science is usually taught by professors in classrooms.  Programming
+library usage is usually taught by documentation.
+
+If the goal of documentation is to turn novices into experts, then *the
+documentation must teach*.  You should think of your documentation as a lesson
+(or series of lessons) because *that's what it is*.
+
+When writing technical documentation you (usually) don't have the advantage of
+having a one-on-one dialog with the learners.  This makes it a bit more
+difficult, but not impossible as long as you're careful.  Your documentation
+needs to fill the role of both the in-person lessons *and* the textbook.
+
+The rest of this post will be almost entirely about how to apply the
+"documentation is teaching" mindset to writing programming docs.
+
+## A Play in Seven Acts
+
+I'm going to break up the content of this post with some venting about *bad*
+documentation.  If you want to skip these little rants, go ahead.
+
+Each act in our play has two characters: a teenager and a parent.  The teenager
+has just turned sixteen and would like to learn to drive so they can hang out
+with their friends without relying on their parents to drive them everywhere.
+
+Each act will demonstrate a caricature of a particularly *bad* form of
+documentation.  I hope these little metaphors will help show why certain forms
+of documentation are ineffective cop-outs and why you should write *real*
+documentation instead.
+
+## Act 1: "Read the Source"
+
+Our play starts with a son and father sitting at the breakfast table.  The son
+is munching on some cereal before school while the father reads his iPad before
+leaving for work.
+
+The son says: "Hey Dad, you said you were going to teach me how to drive after
+school today.  Are we still going to do that?"
+
+The father, without looking up from his iPad, replies: "Of course, son.  The car
+is in the garage and I laid out a set of wrenches on the workbench.  Take the
+car apart and look at each piece, then put it back together.  Once you've done
+that I'll take you to the DMV for your driving test."
+
+The son quietly continued eating his cereal.
+
+If you use many open source libraries you've undoubtedly encountered some whose
+README says something like "read the source".  Every time I see one, I die
+a little bit inside.
+
+Source code is *not* documentation.  Can you learn to be a guitarist by simply
+listening to a piece of music intently?  Can you become a painter by visiting
+a lot of museums?  Of course not!
+
+Let me be clear: I'm not trying to say that reading source code isn't a valuable
+thing to do.  It is!
+
+Looking at other artists' paintings is extremely useful *once you know how to
+paint*.  Learning how the brakes of a car are constructed can save your life,
+*once you know how to drive*.
+
+Once your library's users know how to work with it, reading its source is
+absolutely worth their time.  But you can't look at the finished product and
+understand the perspective and ideas that went into it without additional
+guidance.  That's a job for documentation.
+
+## Tools of the Trade
+
+Writing good documentation doesn't take much in the way of tools.
+
+For example: you don't need a thesaurus.  Don't try to avoid using the same
+words by substituting synonyms.  Just talk to your users like you would talk to
+another human being in real life!
+
+If you use the same word ten times in a row your readers probably won't even
+notice.  But I guarantee they're going to notice if you throw in strange,
+uncommon words for no good reason.
+
+There are two tools I *will* recommend before moving on.  The first isn't
+actually a tool, but a skill.
+
+To write great documentation, you need to be able to type.
+
+When you write docs you'll inevitably write yourself into a corner and realize
+you need to take a new direction.  If you don't type quickly, you might be
+hesitant to throw away writing that doesn't really work.  You need to learn to
+type well so you don't feel bad throwing away a chunk of a thousand words that
+don't fit.
+
+Steve Yegge's article [Programming's Dirty Little Secret][type-dammit] is
+a great rant on this topic.
+
+You should also get yourself a nice keyboard.  A good keyboard won't make you
+a good writer (just like a good guitar won't make you a good guitarist), but it
+*will* make you want to write more just for the sheer joy of using
+a well-designed piece of equipment.
+
+I started practicing guitar a lot more after I got a new guitar that was much
+nicer than my old one.  If you spend a hundred dollars, get a nice keyboard, and
+end up wanting to write more, it was worth it!
+
+Be thankful that a nice keyboard only costs $100 to $300 and not several
+thousand dollars like a nice instrument.
+
+[type-dammit]: http://steve-yegge.blogspot.com/2008/09/programmings-dirtiest-little-secret.html
+
+## Act 2: "Read the Tests"
+
+The next scene opens with a mother picking her daughter up from high school.
+
+"Hi Mom", she says, "are you still going to teach me to drive today?"
+
+"Yep!" she replies.  "Let's get going."
+
+After ten minutes of driving they arrive at the Chevrolet factory.
+
+The girl looks around, puzzled.  She asks: "What are we doing here?"
+
+The mother smiles and says: "You're in luck, honey, my friend Jim works here at
+the Chevy plant, and he's gonna let you watch a few crash tests of the new
+Malibu!  Once you see a few cars smash into each other, I'll take you down to
+the DMV for your driving test."
+
+Another common form of "documentation" is the README instructing users to "read
+the tests".
+
+Tests aren't docs.
+
+Again, let's be clear: once you already know how to use a library, reading the
+tests is *very* useful.  But you need documentation to make you an expert user
+first!
+
+You don't learn to drive by watching crash tests.  But learning how your car
+behaves during a crash can save your life *once you know how to drive*.
+
+A common argument I see goes something like this:
+
+"The tests use the library, so they're a good example of how to use it!"
+
+This is true in some very superficial sense, but completely misses the mark.
+
+Most of the tests are probably going to deal with edge cases.  Edge cases are
+things a normal user won't be encountering very often (otherwise they wouldn't
+be edge cases!).
+
+If you're lucky, you might get a test that verifies the library works correctly
+on a normal set of input.  But a "normal set of input" is what the users are
+going to be working with the majority the time!
+
+Tests simply aren't a good guide to what a user is going to be encountering on
+a day-to-day basis.  They can't teach a novice to be an expert.
+
+## How to Teach
+
+If you accept my idea that the purpose of documentation is to *teach* users, the
+next question is obviously: "How do I teach my users?"
+
+I've been lucky enough to have the chance to teach dancing semi-formally for
+around 6 or 7 years, and lots of various other things informally for a long
+time.  The only way to *really* learn how to teach is to *do it*.
+
+There's no substitute for sitting down with someone face-to-face and teaching
+them something.  **If you want to write better documentation, you need to
+practice teaching**.
+
+I'm not talking about writing out lesson plans or anything nearly so formal.  Do
+you have a hobby (not programming)?  If so, spend a couple of hours on a weekend
+teaching a friend about it.  You'll get some practice teaching and they'll get
+to learn something new.
+
+(If you don't have any non-programming hobbies, maybe you should find some.)
+
+If you like photography, teach someone the basics of exposure and composition.
+If you dance, teach them some basic steps.  If you play an instrument, teach
+them how to play a simple song.  If you like camping, teach them what all the
+gear is for.  You get the idea.
+
+Don't go overboard.  You don't need to give someone a degree, you just need to
+practice teaching a little bit.  You need to practice the art of rewiring
+someone's neurons with your words.
+
+Once you jump into teaching something (even something simple) you'll probably
+realize that although you know how to do it yourself, it's a lot harder to teach
+someone else.
+
+This is obvious when you're working face-to-face with someone.  When you tell
+them how to play a C major chord on the guitar and they only produce a strangled
+squeak, it's clear that you need to slow down and talk about how to press down
+on the strings properly.
+
+As programmers, we almost *never* get this kind of feedback about our
+documentation.  We don't see that the person on the other end of the wire is
+hopelessly confused and blundering around because they're missing something we
+thought was obvious (but wasn't).  Teaching someone in person helps you learn to
+anticipate this, which will pay off (for your users) when you're writing
+documentation.
+
+With all that said, I do want to also talk a little about the actual process of
+teaching.
+
+The best description of how to teach that I've seen so far is from the book [How
+to Solve It][].  Everyone who wants to teach should read this book.  The passage
+that really jumped out at me is right in the first page of the first chapter:
+
+> The best [way for the teacher to help their student] is to help the student
+> naturally.  The teacher should put himself in the student's place, he should
+> see the student's case, he should try to understand what is going on in the
+> student's mind, and ask a question or indicate a step that *could have
+> occurred to the student himself*.
+
+This, right here, is the core of teaching.  This is it.  This is how you do it.
+
+People don't learn by simply absorbing lots of unstructured information as it's
+thrown at them.  You can't read a Spanish dictionary to someone to teach them
+Spanish.
+
+When you want to teach someone you need to put yourself in their shoes and walk
+along the path with them.  Hold their hand, guide them around the dangerous
+obstacles and catch them when they fall.  *Don't* carry them.  *Certainly
+don't* just drive them to the destination in your car!
+
+The process needs to go something like this:
+
+1. Figure out what they already know.
+2. Figure out what you want them to know after you finish.
+3. Figure out a single idea or concept that will move state 1 a little bit
+   closer to state 2.
+4. Nudge the student in the direction of that idea.
+5. Repeat until state 1 becomes state 2.
+
+Too often I see documentation that has very carefully considered step 2, and
+then simply presents it to the reader as a pronouncement from God.  That isn't
+teaching.  That's telling.  People don't learn by being *told*, they
+learn by being *taught*.
+
+[How to Solve It]: http://www.amazon.com/dp/069111966X/?tag=stelos-20
+
+## Act 3: "Literate Programming"
+
+The third act opens with a daughter talking to her mother the day before her
+sixteenth birthday.
+
+"Hey Mom," she says, "I don't know if you got me a present yet, but if not, what
+I'd *really* like for my birthday are driving lessons."
+
+The mother smiles and says: "Don't worry, it's all taken care of.  Just wait for
+tomorrow."
+
+The next day at her birthday party she unwraps the present from her mom.  Inside
+is a DVD of the show How It's Made.  She looks quizzically at her mother.
+
+"That DVD has an episode about the factory that builds your car!  Once you watch
+the whole thing I'll take you for your driving test."
+
+A horrible trend I've noticed lately is using "literate programming" tools like
+Docco, Rocco, etc and telling users to read the results for documentation.
+
+Programming languages and libraries are tools.  Knowing how a tool was made
+doesn't mean you know how to use it.  When you take guitar lessons, you don't
+visit a luthier to watch her shape a Telecaster out of Ash wood.
+
+Knowing how your car was built can help you, *once you know how to drive*.
+
+Knowing how your guitar was built can help you, *once you know how to play*.
+
+A common theme throughout these acts/rants is that all of these things I'm
+picking on (source, tests, literate programming, and more) are good things with
+real benefits *once you have actual documentation in place to teach users*. 
+
+But until that happens, they're actually *bad* because they let you pretend
+you've written documentation and your job is done (JKM mentions this in his
+series).  Your job is not done until you've taught your users enough to become
+experts.  *Then* they can take advantage of all these extras.
+
+## The Anatomy of Good Documentation
+
+The rest of this post is going to be about the individual components that make
+up good documentation.  My views are pretty similar to JKM's, so if you haven't
+read the series I mentioned in the first section you should probably do that.
+
+In my mind I divide good documentation into roughly four parts:
+
+1. First Contact
+2. The Black Triangle
+3. The Hairball
+4. The Reference
+
+There don't necessarily have to be four separate documents for each of these.
+In fact the first two can usually be combined into a single file, while the last
+two should probably be split into many pieces.  But I think each component is
+a distinct, important part of good documentation.
+
+Let's take a look at each.
+
+## First Contact
+
+When you release a new programming language or library into the wild, the
+initial state of your "users" is going to be blank.  The things they need
+to know when they encounter your library are:
+
+1. What is this thing?
+2. Why would I care about this thing?
+3. Is it worth the effort to learn this thing?
+
+Your "first contact" documentation should explain these things to them.
+
+You don't need to explain things from first principles.  Try to put yourself in
+the shoes of your users.  When you're teaching your teenager to drive, you don't
+need to explain what a "wheel" is.  They probably have some experience with
+"things on wheels that you move around in" like lawn mowers or golf carts (or
+even video games).
+
+Likewise: if you're creating a web framework, most of the people that stumble on
+to your project are probably going to know what "HTML" is.  It's good to err
+a little bit on the side of caution and explain a little more than to assume too
+much, but you can be practical here.
+
+Your "first contact" docs should explain what, in plain words, your thing does.
+It should show someone why they should care about that.  Will it save them time?
+Will it take more time, but be more stable in exchange?  Is it just plain fun?
+
+For bonus points, you can also mention why someone might want to *not* use your
+project.  Barely anyone ever mentions the tradeoffs involved with using their
+work, so to see a project do this is refreshing.
+
+Finally, the user needs to know if it's worth spending some of their finite
+amount of time on this planet learning more about your project.  You should
+explicitly spell out things like:
+
+* What license the project uses (so they know if it's practical to use).
+* Where the bug tracker is (so they can see issues).
+* Where the source code is (so they can see if it's (relatively) recently
+  maintained).
+* Where the documentation is (so they can skim it and get an idea of the effort
+  that's going to be involved in becoming an expert).
+
+
+
+## Act 4: "Read the Docstrings"
+
+Scene four.  A father is finally making good on his promise to give his daughter
+driving lessons.
+
+"Okay Dad," she says, "I'm ready.  I've never driven a car before.  Where do we
+start?"
+
+A woman in her mid-forties walks through the door.  "Who's this?" the daughter
+asks.
+
+"This is your driving teacher, Ms. Smith." the father replies.  "She's going to
+sit in the passenger seat with you while you drive the two hour trip to visit
+grandpa.  If you have any questions about a part of the car while you're
+driving, you can ask her and she'll tell you all about that piece.  Here are
+the keys, good luck!"
+
+In languages with [docstrings][] there's a tendency to write great docstrings
+and call them documentation.  I'm sure the "doc" in the word "docstrings"
+contributes to this.
+
+Docstrings don't provide any organization or order (beyond "the namespace they
+happen to be implemented in").  Users need to somehow know the name of the
+function they need to even be able to *see* the docstring, and they can't know
+that unless you *teach* them.
+
+Again, docstrings are great *once you know the project*.  But when you're
+teaching a novice how to use your library, you need to guide them along they
+way and not sit back and answer questions when they manage to guess a magic
+word correctly.
+
+[docstrings]: https://en.wikipedia.org/wiki/Docstring
+
+## The Black Triangle
+
+The next important piece of documentation is [the "black triangle"][].  It
+should be a relatively short guide to getting your project up and running so the
+user can poke at it.
+
+This serves a couple of purposes.  First, it lets the user verify that yes, this
+collection of bytes is actually going to run and *do something* on their
+machine.  It's a quick sanity check that the project hasn't bit rotted and is
+still viable to use at that point in time.  More importantly, it lets your
+prospective user [get some paint on the canvas][paint].
+
+Imagine if you went to your first guitar lesson and the teacher said: "Okay,
+we're going to start by learning 150 different chords.  Then in about six months
+we can play some songs."  No guitar teacher does that.  They teach you three
+chords and give you a couple of cheesy pop songs to play.  It helps the student
+get a feel for what being a guitarist as a whole is going to be like, and it
+gives them something to help keep their interest.
+
+Your "black triangle" documentation should be a short guide that runs the user
+through the process of retrieving, installing, and poking your project or
+language.
+
+"Short" here is a relative word.  Some projects are going to require more setup
+to get running.  If the benefits are enough to justify the effort, that's not
+necessarily a problem.  But try to keep this as short as possible.  *Just get
+something on the screen* and move on.
+
+[the "black triangle"]: http://rampantgames.com/blog/2004/10/black-triangle.html
+[paint]: http://worrydream.com/LearnableProgramming/#react
+
+## Act 5: "Read the API Docs"
+
+Our next scene opens a year after the last, with the father from the last scene
+talking to his son.
+
+(Sadly, the daughter in that scene died in a car crash because she didn't know
+to ask Ms. Smith about seatbelts before getting on the expressway.  Ms.  Smith
+was wearing hers, of course.)
+
+"Okay son, I know you're a little scared of driving because of what happened to
+your sister, but I've fixed the problem."
+
+He hands the young man an inch-thick book.  "Asking Ms. Smith questions along
+the way clearly didn't work, so we had her write out a paragraph or two about
+each piece of your car.  Go ahead and read the entire manual cover to cover and
+then drive down to see grandpa."
+
+API documentation is like the user's manual of a car.  When something goes wrong
+and you need to replace a tire it's a godsend.  But if you're learning to drive
+it's not going to help you because *people don't learn by reading alphabetized
+lists of disconnected information*.
+
+If you actually try to teach someone to use your project face-to-face, you'll
+probably find yourself talking about things in one namespace for a while, then
+switching to another to cover something related, then switching back to the
+first.  Learning isn't a straight path through the alphabet, it's a zig-zaggy
+ramble through someone else's brain.
+
+## The Hairball
+
+This brings me to the next type of documentation: "the hairball".  By now the
+user has hopefully seen the "first contact" docs and the "black triangle" docs.
+You've got them hooked and ready to learn, but they're still novices.
+
+The "hairball" is the twisted, tangled maze of teaching that is going to take
+these novices and turn them into expert users.  It's going to mold their brains,
+one nudge at a time, until they have a pretty good understanding of how your
+project works.
+
+You'll usually want to organize the "hairball" into sections (unless this is
+a very small project).  These sections will probably *kind of* line up with
+namespaces in your project's public API, but when it makes sense to deviate you
+should do so.
+
+Don't be afraid to write.  Be concise but err on the side of explaining a bit
+too much.  Programmers are pretty good at skimming over things they already
+know, but if you forget to include a crucial connection it can leave your users
+lost and stumbling around in the woods.
+
+You should have a table of contents that lists each section of the "hairball".
+And then each section should have its own table of contents that lists the
+sections inside it.  A table of contents is a wonderful way to get a birds-eye
+view of what you're about to read, to prepare your brain for it.  And of
+course it's also handy for navigating around.
+
+This is where your hobby-teaching practice and your reading of How to Solve It
+are going to come in handy.  Put yourself in a user's brain and figure out each
+little connective leap they're going to need to make to become an expert.
+
+## Act 6: "Read the Wiki"
+
+In the penultimate scene, a mother has signed her teenage son up for an
+after-school driving class.
+
+On the first day, the teacher hands them a syllabus detailing what they're going
+to cover, talks about grading, and sends them home a bit early.
+
+On the second day, she gives them a brief overview of the various pieces of
+a car and how they work together.  She also talks about a few of the most
+important laws they'll need to be aware of.
+
+On the third day, the teacher calls in sick and they have a substitute.  He
+covers the material for half of the fifth day in the syllabus.  He has to leave
+early, so he brings in his nineteen year old daughter to finish the class.
+She covers the first half of the fourth day's material.
+
+The fourth day the students arrive to find a note on the door saying the class
+has been cancelled because the teacher is still sick and they can't find
+a substitute.  There's a note saying "TODO: we'll talk about the material
+later."
+
+The fifth day the teacher has partially recovered, so she returns and covers the
+material for the fifth day.  It's a bit hard to understand her because she's had
+half a bottle of Nyquil and is slurring most of her words and keeps saying
+"cat" instead of "car".
+
+All the students fail the driving test.
+
+Wikis are an abomination.  They are the worst form of "documentation".
+
+First of all: assuming they work as intended, they have no coherent voice.
+
+Have you ever taken a class with multiple teachers at once?  Probably not,
+because it doesn't work very well (with exceptions for things like partnered
+dancing where there are distinct lead/follow parts).
+
+Worse still: have you ever taken a class where there's one jackass in the room
+who keeps constantly raising his hand and offering his own (often incorrect)
+opinions?  Wikis are like that, except they *actively encourage* random people
+to interrupt the teacher with their own interjections.
+
+I can hear the objections now: "But putting our docs on a wiki means *anyone*
+can fix typos!"
+
+Jesus.  Christ.
+
+"It makes it easy to fix typos" is a horrible argument for using a wiki.
+
+First of all, as JKM says, you should have an editor (or at least someone to
+proofread) which will catch a lot of the typos.
+
+And even if there *are* typos, they're one of the least important things you
+need to worry about anyway.  Misspelling "their" isn't going to impact the
+effectiveness of your teaching very much.  Your lessons being a disorganized
+mess because they were written by three different people across six months *is*
+going to make them less effective.
+
+Keeping your documentation in a wiki also makes it hard or impossible to keep it
+where it belongs: in version control right alongside your code.
+
+But all that is irrelevant because aside from Wikipedia itself and video game
+wikis, *they don't fucking work*.
+
+The project maintainer sets up a wiki, sits back and pats herself on the back
+saying: "I have set up a way for other people to do this boring job of writing
+documentation for me.  Now we wait." 
+
+Maybe one or two people fix some typos.  A dude who thinks he understands
+a topic but actually doesn't writes some completely wrong docs.  Maybe they get
+reverted, maybe they don't.
+
+The project changes.  A new user reads some of the (sparse) documentation which
+is now out of date.  Eventually they discover this and complain only to be met
+with: "Well it's a wiki, fix it yourself!"
+
+It is not the responsibility of the student to fix a broken lesson plan.  For
+fuck's sake, *the entire point of having a teacher* is that they know what the
+students need to learn and the students don't!
+
+It's completely okay to ask your students for criticism so you can improve your
+lesson plan.  Asking "what parts did you find difficult?" is fine.  It's another
+thing entirely to ask them to *write your lesson plan for you*.
+
+Seriously: fuck wikis.  They are bad and terrible.  Do not use them.  Take the
+time and effort to write some real documentation instead.
+
+## The Reference
+
+The final type of documentation is "the reference".  This section is for the
+users who have traveled through the "hairball" and made it to the other side.
+They're now your experts, and the reference should support them as they use your
+project in their daily work.
+
+This section should contain things that experienced users are likely to need,
+such as:
+
+* "API documentation" for every user-facing part of your project.
+* A full changelog, with particular attention to backwards-incompatible changes
+  between versions.
+* Details about the internal implementation of the project.
+* Contribution policies (if your project accepts outside contributions).
+
+Tools like JavaDoc can produce something that looks like the first, but I share
+the same opinion as Jacob Kaplan-Moss:
+
+> Auto-generated documentation is almost worthless. At best it's a slightly
+> improved version of simply browsing through the source, but most of the time
+> it's easier just to read the source than to navigate the bullshit that these
+> autodoc tools produce. About the only thing auto-generated documentation is
+> good for is filling printed pages when contracts dictate delivery of a certain
+> number of pages of documentation. I feel a particularly deep form of rage
+> every time I click on a "documentation" link and see auto-generated
+> documentation.
+> 
+> There's no substitute for documentation written, organized, and edited by
+> hand.
+
+Yes, you can probably find a tool to read your project's source and shit out
+some HTML files with the function names in them.  Maybe it will even include the
+docstrings!
+
+I would still urge you to write your API docs by hand.  It's going to be
+a little more typing, but the results will be much better for a number of
+reasons.
+
+API docs and docstrings, while similar, serve different purposes.  Docstrings
+have to provide what you need in the heat of coding in a REPL-friendly format.
+API docs can afford the luxury of a bit more explanation, as well as links to
+other things the user might want to know while browsing them on their couch.
+API docs should also be Google-friendly.
+
+A common objection here is that you're going to be retyping a lot of words.
+Copy and paste mostly solves that problem, and learning to type makes the rest
+a non-issue.
+
+Some will say: "But copy and pasting is evil!  You're duplicating effort!  How
+will you keep the changes in the docstrings and the API docs in sync if they
+change?"
+
+My opinion here is that if your public-facing API is changing often, you're
+probably going to be making your users' lives harder when they need to
+constantly update their code to work with yours.  So the least you can do is
+make *your* life a little harder to provide them with the best documentation
+possible to help ease the pain.
+
+Auto-generated documentation has no coherent voice.  It pulls in everything in
+the code without regard for overall structure and vision.  You can *probably*
+get away with it for the API docs in your "reference" documentation, or you
+could take some pride in your work and write the best docs possible!
+
+## Act 7: "A New Hope"
+
+The final act of our play is set in a mall parking lot on a Sunday afternoon.
+A single car is in the parking lot.  Inside is a family: a mother and father who
+are teaching their son to drive.
+
+They start by driving the car into the middle of the lot, away from any
+obstacles.  The son gets into the driver's seat, and the parents explain briefly
+what the main controls do.  They let him drive around the empty lot a bit to get
+a feel for how the car works.
+
+When it's time for him to park he shifts to park and takes off his seatbelt.
+His mom reminds him of the control called a "parking brake".  He realizes that
+he should use this when parking.  A set of neurons is now linked in his brain
+and he will remember to use the parking brake properly for the rest of his life.
+
+Over time the parents take their son driving many times, always being sure that
+they're putting him into situations he can handle (but will still learn from).
+He drives on a road, then learns to parallel park, then drives on a highway.
+
+He has questions along the way.  Sometimes the parents are ready with an answer.
+Sometimes the questions reveal something else missing deeper down in his
+knowledge which the parents correct.
+
+Over time he learns more and more.  He gets his license and begins driving on
+his own.
+
+When he gets a flat tire he reads the owner's manual and fixes it.
+
+He watches the How It's Made episode about his car because he's curious how the
+brakes which saved his life at a stop sign last week actually work.
+
+His windshield wipers stop working one day.  He opens up the hood and figures
+out the problem, fixing it himself.
+
+One day he is hit by a drunk driver.  He walks away with only bruises.  He never
+saw the countless crash tests the engineers performed to create the airbag
+system, but they saved his life.
+
+In the last scene we see the son many years later.  His hair is a bit gray now,
+but otherwise he looks a lot like the teenager who forgot to use the parking
+brake.
+
+He's in a car with his teenage daughter, and he's teaching her how to drive.
+
--- a/content/blog/2015/07/nat-geo-a2540.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,318 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Bag Review: National Geographic A2540"
-        snip: "A great little shoulder bag for holding a DSLR kit."
-        created: 2015-07-24 18:42:00
-    %}
-
-    {% block article %}
-
-I posted this review on Imgur and Reddit a few days ago, but figured I would
-blow the dust off my blog and post it here too.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-01.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-01.jpg)
-
-I got this bag a few months ago.  I've used it to shoot around town and
-flown/traveled with it a couple times.  At first I wasn't thrilled with it, but
-I've warmed up to it now and really like it.
-
-I bought it at [the Geographic Bags site][natgeo] for about $50 new.  It's
-sometimes [on Amazon][amazon] if Nat Geo is out of stock (affiliate link).
-
-I use it for two main things: a day bag for walking around town, and a "personal
-item" on a plane where I load it down with all my camera gear to save the weight
-in my carry on.
-
-[natgeo]: http://www.geographicbags.us/midi-satchel-for-personal-gear
-[amazon]: http://www.amazon.com/dp/B003WE9MGO/?tag=stelos-20
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-02.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-02.jpg)
-
-I like the branding/styling a lot.  I'm pretty sure Nat Geo licenses the
-branding to Manfrotto to actually make the bags, because when mine came the
-return address on the shipping label was a Manfrotto warehouse.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-03.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-03.jpg)
-
-The construction is really nice.  The stitching seems pretty solid, if a bit
-uneven in places, but this is meant to be a working bag, not a piece of art.
-The leather bits seem hearty.  The buckles are okay (not amazing, but good
-enough for the price).
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-04.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-04.jpg)
-
-Attachment points for the strap are solid.  The strap is not removable,
-unfortunately, but at the price I'd rather have a solid, permanent strap than
-a removable one with flimsy connections.
-
-The strap itself is fine.  It's strong and I don't see it breaking any time
-soon.  It's a little bit thin, so if you load the bag down a lot it can start to
-dig into your shoulder a bit.  Luckily...
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-05.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-05.jpg)
-
-There's an optional shoulder pad you can buy for the strap.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-06.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-06.jpg)
-
-It's got nice thick padding, and velcros around the strap.
-
-(Please excuse the cat hair in all the photos).
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-07.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-07.jpg)
-
-I use it when I've got more than a couple of pounds in the bag to save my
-shoulders.  When I'm using it as a day pack I take it off.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-08.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-08.jpg)
-
-The back handle is great for carrying it if you're wearing a backpack, yanking
-it out of places, etc.
-
-There's also a little strap on the back -- it's designed for sliding the handle
-of some rolling luggage through it so it can rest securely on top.  The
-stitching on the velcro bit on it is fraying a bit for me.  I don't really care
-because I never use it anyway.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-09.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-09.jpg)
-
-There are two small, sleek pockets on the front.  They're not huge, but they'll
-hold something wallet or small notebook-sized.
-
-I wouldn't keep a wallet in them though, because they're too easy to
-access/pickpocket.
-
-For day trips I generally use them to hold lens caps while shooting, for lens
-cleaning cloths, etc.  When I fly I use them to hold a polarizer and neutral
-density filters (77mm filters, in their plastic cases, will fit nicely (not
-pictured, sorry, I forgot)).
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-10.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-10.jpg)
-
-Once you unbuckle the top flap there's still a zipper protecting the contents.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-11.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-11.jpg)
-
-The flap has some nicely patterned fabric to break up the brown.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-12.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-12.jpg)
-
-The front pouch is good for holding some small stuff.  It's got dividers for
-holding really thin things like pens and notebooks.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-13.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-13.jpg)
-
-The inside lining is nice and bright so it's easy to find small things.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-14.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-14.jpg)
-
-The bag itself has one big main compartment.  There's one small padded divider
-flap with a velcro bit to hold it down.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-15.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-15.jpg)
-
-It doesn't hold very much, but it's enough for a Kindle or small book.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-16.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-16.jpg)
-
-The bag also comes with a padded insert included.  It's got the same pattern as
-the other bits of the bag.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-17.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-17.jpg)
-
-There's a thin handle for yanking it out of the bag if you need to.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-18.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-18.jpg)
-
-Same golden lining.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-19.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-19.jpg)
-
-There's a padded divider inside that divides the insert into roughly 1/3 and 2/3
-sections.  It's got a fold sewn in so you can fold it over a lens to protect the
-top if necessary.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-20.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-20.jpg)
-
-That divider can be removed if you want to just use the whole space of the
-insert.  I never do.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-21.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-21.jpg)
-
-Nestled inside the main bag.  It looks pretty snug...
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-22.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-22.jpg)
-
-But it doesn't take up quite all of the bag -- there's still room next to it for
-something.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-23.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-23.jpg)
-
-That's it for the bag itself.  Let's pack it!
-
-I like using this bag as my "personal item" on a plane.  It's small enough to
-fit under the seat, and if I put all my camera gear in it I save a ton of
-weight/space in my carry on (I never check bags).
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-24.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-24.jpg)
-
-I shoot with a Pentax K5 II with a battery grip and L plate.  Unfortunately this
-bag isn't large enough to hold a gripped, L-plated DSLR with a lens attached
-ready to go, so you've got to store the body separately.
-
-In practice this isn't a huge deal.  I can take out the camera and carry it with
-its strap as I shoot, and use the bag to hold the spare lenses.  Then
-I disconnect them once I'm finished shooting.  It's a bit more work, but worth
-it for the space savings.
-
-If you don't have a battery grip, the camera CAN be stored with a lens attached
-in the camera insert.
-
-If you want to keep a gripped & L-plated DSLR with a lens attached in a shoulder
-bag, the Think Tank Retro 10 is a beefy bag that will work.  It's a lot bulkier
-though, so it's best suited for non-flying.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-25.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-25.jpg)
-
-Three lenses that cover everything I need right now.  16-50mm, 50-135mm, and
-200mm, all constant f/2.8 and weather sealed like the body.
-
-Sometimes I don't bother with the 200mm, which frees up a lot more space.  Or
-sometimes I take a few primes, which also frees up space.  I just wanted to show
-the max you could cram into the bag for this review.
-
-I'll probably ditch the 50-135 and 200 once the 70-200mm comes out for more
-savings.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-26.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-26.jpg)
-
-The two big lenses go in the insert, the smaller one goes outside.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-27.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-27.jpg)
-
-Close the insert lid.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-28.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-28.jpg)
-
-I like to have just a bit of extra padding, so I grab an extra divider from
-another bag.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-29.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-29.jpg)
-
-It lays on top of the end cap of the small zoom, just for some extra cushioning.
-I'm probably just paranoid.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-30.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-30.jpg)
-
-I can't fly without headphones or I go insane.  I like keeping them in my
-personal item because it's easier to get them out once you're on the flight
-without fucking around with the overhead bin.
-
-I use Marshall Monitors.  I know they're big and bulky, but I can't stand using
-earbuds for more than an hour or so at a time.  These fold up nicely and have
-a couple of other features that are really nice, so for me they're worth the
-space.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-31.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-31.jpg)
-
-I nestle them on top of the small zoom.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-32.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-32.jpg)
-
-The body goes on top of the camera insert and big lenses.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-33.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-33.jpg)
-
-I tuck the strap (Black Rapid Metro) between the body and headphones.  I could
-store it separately, but I have the carabiner loc-tited shut so it'll never,
-ever come off.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-34.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-34.jpg)
-
-Next necessity for flying: Kindle!
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-35.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-35.jpg)
-
-I could save a bit of space by ditching the case, but I like it...
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-36.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-36.jpg)
-
-It fits well behind the divider in the main section.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-37.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-37.jpg)
-
-Main section packed!
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-38.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-38.jpg)
-
-A few other miscellaneous things.
-
-Sometimes I charge both batteries the night before and ditch the charger.  It
-depends on how long I'm traveling for.
-
-I like to have my sunglasses in my personal item to use as a makeshift sleep
-mask.  Not quite a good as a dedicated one, but since I'm bringing them
-anyway...
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-39.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-39.jpg)
-
-This is a pretty tight fit, but it does fit.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-40.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-40.jpg)
-
-Front packed!
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-41.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-41.jpg)
-
-The straps buckle (barely).
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-42.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-42.jpg)
-
-The main fabric of the bag seems like it wouldn't be too bad in the rain, but
-I bought a rain cover for a National Geographic backpack, so I figured I'd try
-it on this bag too.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-43.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-43.jpg)
-
-It fits.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-44.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-44.jpg)
-
-It's a bit loose because it's designed for a backpack, but you can cinch it up
-with the elastic cord and it does the job.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-45.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-45.jpg)
-
-It'll fit in the front pocket too.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-46.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-46.jpg)
-
-Time for the final verdict.  United's site says a personal item should fit
-within 9" x 10" x 17".
-
-We're good on the short dimension.
-
-(Cardboard boxes to prove I'm not cheating.)
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-47.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-47.jpg)
-
-About half an inch past 10".  I doubt I'll ever get called out on that
-(especially since we have room to spare in the other dimensions), but it'll
-squish a bit if absolutely necessary.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-48.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-48.jpg)
-
-Plenty of room to spare on the wide dimension.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-a2540-49.jpg)](/media/images{{ parent_url }}/full/nat-geo-a2540-49.jpg)
-
-That's it!  Obviously you can mix and match stuff as needed (swap a lens for
-a flash or water bottle, etc).
-
-I hope this was helpful!  I'm quite happy with this little bag.  It's great for
-just walking around town, or turning my personal item into a brick of camera
-gear to free up room in my carry on.
-
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2015/07/nat-geo-a2540.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,315 @@
++++
+title = "Bag Review: National Geographic A2540"
+snip = "A great little shoulder bag for holding a DSLR kit."
+date = 2015-07-24T18:42:00Z
+draft = false
+
++++
+
+I posted this review on Imgur and Reddit a few days ago, but figured I would
+blow the dust off my blog and post it here too.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-01.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-01.jpg)
+
+I got this bag a few months ago.  I've used it to shoot around town and
+flown/traveled with it a couple times.  At first I wasn't thrilled with it, but
+I've warmed up to it now and really like it.
+
+I bought it at [the Geographic Bags site][natgeo] for about $50 new.  It's
+sometimes [on Amazon][amazon] if Nat Geo is out of stock (affiliate link).
+
+I use it for two main things: a day bag for walking around town, and a "personal
+item" on a plane where I load it down with all my camera gear to save the weight
+in my carry on.
+
+[natgeo]: http://www.geographicbags.us/midi-satchel-for-personal-gear
+[amazon]: http://www.amazon.com/dp/B003WE9MGO/?tag=stelos-20
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-02.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-02.jpg)
+
+I like the branding/styling a lot.  I'm pretty sure Nat Geo licenses the
+branding to Manfrotto to actually make the bags, because when mine came the
+return address on the shipping label was a Manfrotto warehouse.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-03.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-03.jpg)
+
+The construction is really nice.  The stitching seems pretty solid, if a bit
+uneven in places, but this is meant to be a working bag, not a piece of art.
+The leather bits seem hearty.  The buckles are okay (not amazing, but good
+enough for the price).
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-04.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-04.jpg)
+
+Attachment points for the strap are solid.  The strap is not removable,
+unfortunately, but at the price I'd rather have a solid, permanent strap than
+a removable one with flimsy connections.
+
+The strap itself is fine.  It's strong and I don't see it breaking any time
+soon.  It's a little bit thin, so if you load the bag down a lot it can start to
+dig into your shoulder a bit.  Luckily...
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-05.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-05.jpg)
+
+There's an optional shoulder pad you can buy for the strap.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-06.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-06.jpg)
+
+It's got nice thick padding, and velcros around the strap.
+
+(Please excuse the cat hair in all the photos).
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-07.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-07.jpg)
+
+I use it when I've got more than a couple of pounds in the bag to save my
+shoulders.  When I'm using it as a day pack I take it off.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-08.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-08.jpg)
+
+The back handle is great for carrying it if you're wearing a backpack, yanking
+it out of places, etc.
+
+There's also a little strap on the back — it's designed for sliding the handle
+of some rolling luggage through it so it can rest securely on top.  The
+stitching on the velcro bit on it is fraying a bit for me.  I don't really care
+because I never use it anyway.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-09.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-09.jpg)
+
+There are two small, sleek pockets on the front.  They're not huge, but they'll
+hold something wallet or small notebook-sized.
+
+I wouldn't keep a wallet in them though, because they're too easy to
+access/pickpocket.
+
+For day trips I generally use them to hold lens caps while shooting, for lens
+cleaning cloths, etc.  When I fly I use them to hold a polarizer and neutral
+density filters (77mm filters, in their plastic cases, will fit nicely (not
+pictured, sorry, I forgot)).
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-10.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-10.jpg)
+
+Once you unbuckle the top flap there's still a zipper protecting the contents.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-11.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-11.jpg)
+
+The flap has some nicely patterned fabric to break up the brown.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-12.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-12.jpg)
+
+The front pouch is good for holding some small stuff.  It's got dividers for
+holding really thin things like pens and notebooks.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-13.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-13.jpg)
+
+The inside lining is nice and bright so it's easy to find small things.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-14.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-14.jpg)
+
+The bag itself has one big main compartment.  There's one small padded divider
+flap with a velcro bit to hold it down.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-15.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-15.jpg)
+
+It doesn't hold very much, but it's enough for a Kindle or small book.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-16.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-16.jpg)
+
+The bag also comes with a padded insert included.  It's got the same pattern as
+the other bits of the bag.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-17.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-17.jpg)
+
+There's a thin handle for yanking it out of the bag if you need to.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-18.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-18.jpg)
+
+Same golden lining.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-19.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-19.jpg)
+
+There's a padded divider inside that divides the insert into roughly 1/3 and 2/3
+sections.  It's got a fold sewn in so you can fold it over a lens to protect the
+top if necessary.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-20.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-20.jpg)
+
+That divider can be removed if you want to just use the whole space of the
+insert.  I never do.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-21.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-21.jpg)
+
+Nestled inside the main bag.  It looks pretty snug...
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-22.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-22.jpg)
+
+But it doesn't take up quite all of the bag — there's still room next to it for
+something.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-23.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-23.jpg)
+
+That's it for the bag itself.  Let's pack it!
+
+I like using this bag as my "personal item" on a plane.  It's small enough to
+fit under the seat, and if I put all my camera gear in it I save a ton of
+weight/space in my carry on (I never check bags).
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-24.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-24.jpg)
+
+I shoot with a Pentax K5 II with a battery grip and L plate.  Unfortunately this
+bag isn't large enough to hold a gripped, L-plated DSLR with a lens attached
+ready to go, so you've got to store the body separately.
+
+In practice this isn't a huge deal.  I can take out the camera and carry it with
+its strap as I shoot, and use the bag to hold the spare lenses.  Then
+I disconnect them once I'm finished shooting.  It's a bit more work, but worth
+it for the space savings.
+
+If you don't have a battery grip, the camera CAN be stored with a lens attached
+in the camera insert.
+
+If you want to keep a gripped & L-plated DSLR with a lens attached in a shoulder
+bag, the Think Tank Retro 10 is a beefy bag that will work.  It's a lot bulkier
+though, so it's best suited for non-flying.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-25.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-25.jpg)
+
+Three lenses that cover everything I need right now.  16-50mm, 50-135mm, and
+200mm, all constant f/2.8 and weather sealed like the body.
+
+Sometimes I don't bother with the 200mm, which frees up a lot more space.  Or
+sometimes I take a few primes, which also frees up space.  I just wanted to show
+the max you could cram into the bag for this review.
+
+I'll probably ditch the 50-135 and 200 once the 70-200mm comes out for more
+savings.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-26.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-26.jpg)
+
+The two big lenses go in the insert, the smaller one goes outside.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-27.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-27.jpg)
+
+Close the insert lid.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-28.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-28.jpg)
+
+I like to have just a bit of extra padding, so I grab an extra divider from
+another bag.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-29.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-29.jpg)
+
+It lays on top of the end cap of the small zoom, just for some extra cushioning.
+I'm probably just paranoid.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-30.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-30.jpg)
+
+I can't fly without headphones or I go insane.  I like keeping them in my
+personal item because it's easier to get them out once you're on the flight
+without fucking around with the overhead bin.
+
+I use Marshall Monitors.  I know they're big and bulky, but I can't stand using
+earbuds for more than an hour or so at a time.  These fold up nicely and have
+a couple of other features that are really nice, so for me they're worth the
+space.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-31.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-31.jpg)
+
+I nestle them on top of the small zoom.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-32.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-32.jpg)
+
+The body goes on top of the camera insert and big lenses.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-33.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-33.jpg)
+
+I tuck the strap (Black Rapid Metro) between the body and headphones.  I could
+store it separately, but I have the carabiner loc-tited shut so it'll never,
+ever come off.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-34.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-34.jpg)
+
+Next necessity for flying: Kindle!
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-35.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-35.jpg)
+
+I could save a bit of space by ditching the case, but I like it...
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-36.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-36.jpg)
+
+It fits well behind the divider in the main section.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-37.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-37.jpg)
+
+Main section packed!
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-38.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-38.jpg)
+
+A few other miscellaneous things.
+
+Sometimes I charge both batteries the night before and ditch the charger.  It
+depends on how long I'm traveling for.
+
+I like to have my sunglasses in my personal item to use as a makeshift sleep
+mask.  Not quite a good as a dedicated one, but since I'm bringing them
+anyway...
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-39.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-39.jpg)
+
+This is a pretty tight fit, but it does fit.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-40.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-40.jpg)
+
+Front packed!
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-41.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-41.jpg)
+
+The straps buckle (barely).
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-42.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-42.jpg)
+
+The main fabric of the bag seems like it wouldn't be too bad in the rain, but
+I bought a rain cover for a National Geographic backpack, so I figured I'd try
+it on this bag too.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-43.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-43.jpg)
+
+It fits.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-44.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-44.jpg)
+
+It's a bit loose because it's designed for a backpack, but you can cinch it up
+with the elastic cord and it does the job.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-45.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-45.jpg)
+
+It'll fit in the front pocket too.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-46.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-46.jpg)
+
+Time for the final verdict.  United's site says a personal item should fit
+within 9" x 10" x 17".
+
+We're good on the short dimension.
+
+(Cardboard boxes to prove I'm not cheating.)
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-47.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-47.jpg)
+
+About half an inch past 10".  I doubt I'll ever get called out on that
+(especially since we have room to spare in the other dimensions), but it'll
+squish a bit if absolutely necessary.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-48.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-48.jpg)
+
+Plenty of room to spare on the wide dimension.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-a2540-49.jpg)](/media/images/blog/2015/07/full/nat-geo-a2540-49.jpg)
+
+That's it!  Obviously you can mix and match stuff as needed (swap a lens for
+a flash or water bottle, etc).
+
+I hope this was helpful!  I'm quite happy with this little bag.  It's great for
+just walking around town, or turning my personal item into a brick of camera
+gear to free up room in my carry on.
+
+
--- a/content/blog/2015/07/nat-geo-mc5350.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,470 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Bag Review: National Geographic MC5350"
-        snip: "Almost perfect weekend travel and DSLR kit bag."
-        created: 2015-07-26 13:35:00
-    %}
-
-    {% block article %}
-
-Since I've got a bit of downtime before I move, the bag reviews will continue.
-Next up is the National Geographic "Medium Backpack" from the Mediterranean line
-(model MG5350).
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-01.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-01.jpg)
-
-I got this backpack a few months ago from [the Geographic Bags site][natgeo] and
-have been using it a lot.  If it's out of stock there you can find it [on
-Amazon][amazon] (affiliate link).
-
-I mostly use it for two things:
-
-* Day hikes where I want to bring a DSLR for landscape photos.
-* A weekend bag to fly with as a one-bag carry on.
-
-It's been almost perfect for these two things, with just a couple of tiny
-hitches.  Let's dig in!
-
-[natgeo]: http://www.geographicbags.us/product/85657.1115885.0.0.0/NG%2BMC%2B5350/_/Medium_Backpack_fo_Personal_gear%2C_Laptop%2C_DSLR%2C_acc.%2C
-[amazon]: http://www.amazon.com/dp/B00VQT8FYM/?tag=stelos-20
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-02.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-02.jpg)
-
-This line (the Mediterranean series) has a much different look than their
-others.  The branding is straightforward but not over the top.  Once again, I'm
-pretty sure Nat Geo is licensing the name to Manfrotto to actually make the
-bags.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-03.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-03.jpg)
-
-The stripes are a nice touch that give it some visual interest without being
-obnoxious.  They remind me of piano keys a bit.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-04.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-04.jpg)
-
-The front flap has a pocket for small stuff.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-05.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-05.jpg)
-
-The metal zipper pulls are hefty, and have the logo nicely embossed.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-06.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-06.jpg)
-
-Some of the zipper pulls are chunky leather.  I'm not sure why some are metal
-and some are leather, but it works.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-07.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-07.jpg)
-
-The straps are medium-width, very padded, and not detachable.  There's plenty of
-room for length adjustments if you're a tall person.  Unfortunately there are no
-load lifter straps.
-
-There's no internal frame, but the back of the bag has a lot of padding sewn
-into it.  The inset compass design gives you a bit of ventilation.  It feels
-nice when wearing, but also means you can't fold or roll this bag up to stuff it
-in a bigger bag to use as a day pack.
-
-[lx]: http://www.amazon.com/dp/B00GORMJTI/?tag=stelos-20
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-08.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-08.jpg)
-
-There's a top handle for yanking it of overhead bins.  Also the thin strip on
-the back can be pulled out a bit to slip over the handle of some roller luggage,
-if you like.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-09.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-09.jpg)
-
-Handle stitching is nice and sturdy.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-10.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-10.jpg)
-
-There are a couple of rings on the front of the straps for you to clip things
-to.  I like using a small carabiner to clip my [Panasonic LX100][lx] to the
-right one so I can easily take photos when hiking.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-11.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-11.jpg)
-
-There's a loop on one of the sides with a small lashing strap.  We'll see it in
-action later (though I don't tend to use it much).
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-12.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-12.jpg)
-
-The sternum strap is a simple strap with two D-rings as a buckle.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-13.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-13.jpg)
-
-It's simple and will never break, but it's a little bit annoying to have to
-thread the strap through instead of just using a plastic clip like many other
-bags do.
-
-There's no waist strap on this backpack.  It's too short for a waist belt that
-would bear load, but it would have been nice to have an optional one to just
-secure things a bit better.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-14.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-14.jpg)
-
-The buckles on the straps bite nicely into the fabric and don't slip.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-15.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-15.jpg)
-
-Once you open it up, you can see the opening cinches closed with a simple cord.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-16.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-16.jpg)
-
-Leather bit to keep it closed(ish).
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-17.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-17.jpg)
-
-Metal to reinforce where the strap holds the fabric.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-18.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-18.jpg)
-
-The underside of the flap has the same striped pattern.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-19.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-19.jpg)
-
-The bag is divided into two sections of roughly equal size.  The top section has
-a few flaps and pockets for minor organization.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-20.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-20.jpg)
-
-Zipper pouch.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-21.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-21.jpg)
-
-The flaps don't open very much.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-22.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-22.jpg)
-
-Anything you put in the would need to be pretty flat (e.g.: a Kindle).
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-23.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-23.jpg)
-
-The side pockets stick out from the body of the bag.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-24.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-24.jpg)
-
-A few example objects for scale.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-25.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-25.jpg)
-
-They're about a big as a standard-sized coffee mug.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-26.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-26.jpg)
-
-They'll just barely hold a folding set of [Marshall Monitor
-headphones][monitor].
-
-[monitor]: http://www.amazon.com/dp/B00D3ITOHG/?tag=stelos-20
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-27.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-27.jpg)
-
-They'll hold a water bottle, though if it's tall it can be a bit precarious.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-28.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-28.jpg)
-
-They do work well for holding a monopod, in conjunction with the lashing strap.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-29.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-29.jpg)
-
-Unfortunately this backpack really can't handle a decent tripod.  It's too tall
-for the side, and there's no attachment rings you could use to lash it to the
-bottom or back.
-
-This is one thing that does bother me about the bag.  A couple of extra D rings
-on the side and bottom would solve the tripod carrying problem.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-30.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-30.jpg)
-
-On to the bottom compartment.  This is designed as a DSLR bag, so the bottom is
-padded and has dividers like any typical camera backpack.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-31.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-31.jpg)
-
-It comes with two big, fluffy, padded inserts that are velcroed in.
-
-It may have come with a third divider that I removed, but if so it's mixed in
-with all my other spare dividers and I can't remember.  Sorry.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-32.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-32.jpg)
-
-The camera dividers are actually Manfrotto-braded.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-33.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-33.jpg)
-
-If you're not a photographer (or just aren't bringing a DSLR), the entire camera
-padding bit can come out of the bag.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-34.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-34.jpg)
-
-It's just held in by a few strips of velcro at the bottom (and a lot of
-squishing).  So you can have two separate sections for all your stuff.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-35.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-35.jpg)
-
-But wait: once you take out the camera divider there seems to be a zipper...
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-36.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-36.jpg)
-
-You can unzip the middle divider and turn the bag into one big space, like
-a normal backpack, if you need to carry something big and bulky.  I don't do
-this much, but it's great to have the option!
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-37.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-37.jpg)
-
-That's about it for the bag itself.  Let's pack it!
-
-I'm going to pack **a lot** of stuff into it here to give you an idea of the
-maximum the bag will hold.  I wouldn't normally take all this on a weekend trip,
-but if you're a packrat this bag will let you cram a surprising amount into it.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-38.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-38.jpg)
-
-We'll start with a laptop.  There's a separate section for a laptop right
-against your back.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-39.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-39.jpg)
-
-15" Retina Macbook Pro.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-40.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-40.jpg)
-
-Fits in the laptop pocket with plenty of room to spare.  Nat Geo says this bag
-will hold a 17" laptop and I believe it.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-41.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-41.jpg)
-
-The laptop pocket is nicely padded, but if you want even more protection you
-could use a laptop sleeve as well.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-42.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-42.jpg)
-
-Sleeved Macbook will fit.  I generally don't bother -- the pocket has enough
-padding for me.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-43.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-43.jpg)
-
-Let's load the DSLR.  My full kit is usually a gripped, L-plated Pentax K5 II
-and three lenses: 16-50mm, 50-135mm, and 200mm, all f/2.8 and weather-sealed.
-
-I often leave the 200mm at home to save weight and space.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-44.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-44.jpg)
-
-It all fits snugly, with one lens attached to the camera.  I'm really happy with
-this bag because most camera backpacks are either:
-
-* Designed for Football Dad with a Canon Rebel and kit lens, and don't even come
-  close to accommodating a DSLR with a battery grip.
-* Designed for [Chase Jarvis](http://i.imgur.com/aKeu50l.jpg) with two bodies,
-  six lenses, and no room for anything else like clothing.
-
-I really like that this bag lets me carry enough camera for my amateur self, and
-then lets me carry other stuff (clothes, rain gear, etc) in the rest of the bag.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-45.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-45.jpg)
-
-Zips closed nicely.  The top prism of the camera produces a bit of a bump (can't
-really see it in the photos) but it's not a big deal.  If I'm not going to be
-using a tripod or monopod I'll remove the L-plate and the bump goes away.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-46.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-46.jpg)
-
-Time for the rest of the bag!  I'll show an example of stuff I'd take on
-a weekend trip (though again: I'll lean towards packing too much to show you the
-limits of the bag).
-
-First off: two shirts, two pairs of socks, two pairs of underwear, and hiking
-pants.  Together with the stuff I wear, that's enough for a weekend.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-47.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-47.jpg)
-
-I've drank the packing cube Kool-Aid.  I use the [Eagle Creek packing
-cubes][eagle] and they work pretty well.  The smaller two of the set fit well
-into this bag -- the large one is too big for it.
-
-[eagle]: http://www.amazon.com/dp/B00F9S85CS/?tag=stelos-20
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-48.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-48.jpg)
-
-Small cube packed with socks and underwear.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-49.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-49.jpg)
-
-Large cube packed with shirts and pants, with a bit of room left over.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-50.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-50.jpg)
-
-Add a towel if you're staying in a hostel.  This is the [Extra Large Packtowl
-Original][towel] which has served me well.  I may replace it with their
-Ultralight version sometime in the future.
-
-[towel]: http://www.amazon.com/dp/B0075JJ29E/?tag=stelos-20
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-51.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-51.jpg)
-
-Large cube all packed.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-52.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-52.jpg)
-
-Large cube in the top section of the bag.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-53.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-53.jpg)
-
-Small cube fits to the side nicely.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-54.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-54.jpg)
-
-I can't fly without headphones, so they get their own side pocket.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-55.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-55.jpg)
-
-Easy access once on the plane.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-56.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-56.jpg)
-
-One thing to watch out for: the side pocket zippers have large, sharp metal
-teeth.  I could see them ripping fabric if you're not careful.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-57.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-57.jpg)
-
-On a whim I grabbed this [Utility Kit][kit] when I got the bag and it's proved
-to be a handy little organizer.
-
-[kit]: http://www.geographicbags.us/utility-kit-for-media-accessories-or-travel-items
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-58.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-58.jpg)
-
-The fabric is thin, but water-resistant.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-59.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-59.jpg)
-
-It will accommodate quite a bit.  For this demo:
-
-* Rain cover for the backpack
-* Cell phone charger
-* Toothbrush
-* Sleeping mask
-* Camera charger
-* 77mm polarizer
-* Lens cleaning supplies
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-60.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-60.jpg)
-
-All packed in.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-61.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-61.jpg)
-
-The center section holds a lot.  My friend has fit a travel hair dryer in it.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-62.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-62.jpg)
-
-The mesh bags are good for small stuff.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-63.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-63.jpg)
-
-Bottom mesh bit.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-64.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-64.jpg)
-
-It has a hanger to hang once you're in a hotel room, and also helps hold it
-shut.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-65.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-65.jpg)
-
-Fits snugly on top of the large packing cube.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-66.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-66.jpg)
-
-Since we've got a rain cover for the backpack, let's add one for ourselves.
-I use a [Marmot PreCip][jacket] for hiking (it will also add some warmth in
-a pinch).
-
-[jacket]: http://www.amazon.com/dp/B00I2ZCXQO/?tag=stelos-20
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-67.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-67.jpg)
-
-Rolls up nice and small.  Apparently I'm out of rubber bands in my house, so
-I used the end of an old guitar strap here.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-68.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-68.jpg)
-
-It will fit (barely) in the other side pocket.  Again, mind the zipper teeth as
-they feel like they would tear through the thin fabric if you're not careful.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-69.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-69.jpg)
-
-Just about fully loaded!
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-70.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-70.jpg)
-
-The cord cinches the top of the bag loosely.  It can't close completely though,
-so if you're worried about pickpockets...
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-71.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-71.jpg)
-
-You can loop the strap up...
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-72.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-72.jpg)
-
-And around, to provide a bit of extra protection.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-73.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-73.jpg)
-
-Front view.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-74.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-74.jpg)
-
-The snap on the front is also one of the things I don't like about the bag.
-It's magnetic so it snaps itself into place (which is nice), but it's very small
-and shallow so it doesn't have a lot of strength.  If you pack the bag really
-full like this you'll find it coming unsnapped from the strain as you walk.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-75.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-75.jpg)
-
-A couple of odds and ends for the front pocket.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-76.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-76.jpg)
-
-Easy access.  Don't keep anything important in here.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-77.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-77.jpg)
-
-Time for the final measurements!  This is definitely too big to quality as
-a "personal item" but will easy make it as a carry on.  United's website says
-a carry on should be 22" by 14" by 9".
-
-We're at 17" wide, which is a bit over 14".  You probably won't get called on
-it, but if you remove the stuff from the side pockets it collapses down to 13".
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-78.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-78.jpg)
-
-Thickness-wise we're at 9.5".  You can save an inch by taking the laptop out.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-79.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-79.jpg)
-
-And we're well under the long dimension.
-
-[![Photo](/media/images{{ parent_url }}/nat-geo-mc5350-80.jpg)](/media/images{{ parent_url }}/full/nat-geo-mc5350-80.jpg)
-
-That's it!
-
-All this stuff clocks in at a hefty 24 pounds.  Like I said, this was an example
-of stuffing the bag to bursting.  On a real trip I'd probably leave behind the
-computer and charger, camera charger, 200mm lens, and the rain gear.
-
-After using this on a couple of day hikes and weekend trips I'm really happy
-with it.  I really like the hybrid "reasonable DSLR kit plus weekend supplies"
-style they've taken here.  My only nitpicks are:
-
-* Weak front clasp
-* Sharp teeth on the side pouch zippers
-* No load lifter straps
-* No waist strap
-* No D rings to lash things to the bottom or back
-
-Those are all pretty minor though.  I'd definitely recommend this bag if you're
-looking for a small, versatile camera backpack.
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2015/07/nat-geo-mc5350.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,467 @@
++++
+title = "Bag Review: National Geographic MC5350"
+snip = "Almost perfect weekend travel and DSLR kit bag."
+date = 2015-07-26T13:35:00Z
+draft = false
+
++++
+
+Since I've got a bit of downtime before I move, the bag reviews will continue.
+Next up is the National Geographic "Medium Backpack" from the Mediterranean line
+(model MG5350).
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-01.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-01.jpg)
+
+I got this backpack a few months ago from [the Geographic Bags site][natgeo] and
+have been using it a lot.  If it's out of stock there you can find it [on
+Amazon][amazon] (affiliate link).
+
+I mostly use it for two things:
+
+* Day hikes where I want to bring a DSLR for landscape photos.
+* A weekend bag to fly with as a one-bag carry on.
+
+It's been almost perfect for these two things, with just a couple of tiny
+hitches.  Let's dig in!
+
+[natgeo]: http://www.geographicbags.us/product/85657.1115885.0.0.0/NG%2BMC%2B5350/_/Medium_Backpack_fo_Personal_gear%2C_Laptop%2C_DSLR%2C_acc.%2C
+[amazon]: http://www.amazon.com/dp/B00VQT8FYM/?tag=stelos-20
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-02.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-02.jpg)
+
+This line (the Mediterranean series) has a much different look than their
+others.  The branding is straightforward but not over the top.  Once again, I'm
+pretty sure Nat Geo is licensing the name to Manfrotto to actually make the
+bags.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-03.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-03.jpg)
+
+The stripes are a nice touch that give it some visual interest without being
+obnoxious.  They remind me of piano keys a bit.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-04.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-04.jpg)
+
+The front flap has a pocket for small stuff.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-05.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-05.jpg)
+
+The metal zipper pulls are hefty, and have the logo nicely embossed.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-06.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-06.jpg)
+
+Some of the zipper pulls are chunky leather.  I'm not sure why some are metal
+and some are leather, but it works.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-07.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-07.jpg)
+
+The straps are medium-width, very padded, and not detachable.  There's plenty of
+room for length adjustments if you're a tall person.  Unfortunately there are no
+load lifter straps.
+
+There's no internal frame, but the back of the bag has a lot of padding sewn
+into it.  The inset compass design gives you a bit of ventilation.  It feels
+nice when wearing, but also means you can't fold or roll this bag up to stuff it
+in a bigger bag to use as a day pack.
+
+[lx]: http://www.amazon.com/dp/B00GORMJTI/?tag=stelos-20
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-08.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-08.jpg)
+
+There's a top handle for yanking it of overhead bins.  Also the thin strip on
+the back can be pulled out a bit to slip over the handle of some roller luggage,
+if you like.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-09.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-09.jpg)
+
+Handle stitching is nice and sturdy.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-10.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-10.jpg)
+
+There are a couple of rings on the front of the straps for you to clip things
+to.  I like using a small carabiner to clip my [Panasonic LX100][lx] to the
+right one so I can easily take photos when hiking.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-11.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-11.jpg)
+
+There's a loop on one of the sides with a small lashing strap.  We'll see it in
+action later (though I don't tend to use it much).
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-12.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-12.jpg)
+
+The sternum strap is a simple strap with two D-rings as a buckle.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-13.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-13.jpg)
+
+It's simple and will never break, but it's a little bit annoying to have to
+thread the strap through instead of just using a plastic clip like many other
+bags do.
+
+There's no waist strap on this backpack.  It's too short for a waist belt that
+would bear load, but it would have been nice to have an optional one to just
+secure things a bit better.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-14.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-14.jpg)
+
+The buckles on the straps bite nicely into the fabric and don't slip.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-15.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-15.jpg)
+
+Once you open it up, you can see the opening cinches closed with a simple cord.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-16.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-16.jpg)
+
+Leather bit to keep it closed(ish).
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-17.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-17.jpg)
+
+Metal to reinforce where the strap holds the fabric.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-18.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-18.jpg)
+
+The underside of the flap has the same striped pattern.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-19.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-19.jpg)
+
+The bag is divided into two sections of roughly equal size.  The top section has
+a few flaps and pockets for minor organization.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-20.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-20.jpg)
+
+Zipper pouch.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-21.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-21.jpg)
+
+The flaps don't open very much.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-22.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-22.jpg)
+
+Anything you put in the would need to be pretty flat (e.g.: a Kindle).
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-23.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-23.jpg)
+
+The side pockets stick out from the body of the bag.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-24.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-24.jpg)
+
+A few example objects for scale.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-25.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-25.jpg)
+
+They're about a big as a standard-sized coffee mug.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-26.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-26.jpg)
+
+They'll just barely hold a folding set of [Marshall Monitor
+headphones][monitor].
+
+[monitor]: http://www.amazon.com/dp/B00D3ITOHG/?tag=stelos-20
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-27.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-27.jpg)
+
+They'll hold a water bottle, though if it's tall it can be a bit precarious.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-28.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-28.jpg)
+
+They do work well for holding a monopod, in conjunction with the lashing strap.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-29.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-29.jpg)
+
+Unfortunately this backpack really can't handle a decent tripod.  It's too tall
+for the side, and there's no attachment rings you could use to lash it to the
+bottom or back.
+
+This is one thing that does bother me about the bag.  A couple of extra D rings
+on the side and bottom would solve the tripod carrying problem.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-30.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-30.jpg)
+
+On to the bottom compartment.  This is designed as a DSLR bag, so the bottom is
+padded and has dividers like any typical camera backpack.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-31.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-31.jpg)
+
+It comes with two big, fluffy, padded inserts that are velcroed in.
+
+It may have come with a third divider that I removed, but if so it's mixed in
+with all my other spare dividers and I can't remember.  Sorry.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-32.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-32.jpg)
+
+The camera dividers are actually Manfrotto-braded.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-33.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-33.jpg)
+
+If you're not a photographer (or just aren't bringing a DSLR), the entire camera
+padding bit can come out of the bag.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-34.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-34.jpg)
+
+It's just held in by a few strips of velcro at the bottom (and a lot of
+squishing).  So you can have two separate sections for all your stuff.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-35.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-35.jpg)
+
+But wait: once you take out the camera divider there seems to be a zipper...
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-36.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-36.jpg)
+
+You can unzip the middle divider and turn the bag into one big space, like
+a normal backpack, if you need to carry something big and bulky.  I don't do
+this much, but it's great to have the option!
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-37.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-37.jpg)
+
+That's about it for the bag itself.  Let's pack it!
+
+I'm going to pack **a lot** of stuff into it here to give you an idea of the
+maximum the bag will hold.  I wouldn't normally take all this on a weekend trip,
+but if you're a packrat this bag will let you cram a surprising amount into it.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-38.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-38.jpg)
+
+We'll start with a laptop.  There's a separate section for a laptop right
+against your back.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-39.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-39.jpg)
+
+15" Retina Macbook Pro.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-40.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-40.jpg)
+
+Fits in the laptop pocket with plenty of room to spare.  Nat Geo says this bag
+will hold a 17" laptop and I believe it.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-41.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-41.jpg)
+
+The laptop pocket is nicely padded, but if you want even more protection you
+could use a laptop sleeve as well.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-42.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-42.jpg)
+
+Sleeved Macbook will fit.  I generally don't bother — the pocket has enough
+padding for me.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-43.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-43.jpg)
+
+Let's load the DSLR.  My full kit is usually a gripped, L-plated Pentax K5 II
+and three lenses: 16-50mm, 50-135mm, and 200mm, all f/2.8 and weather-sealed.
+
+I often leave the 200mm at home to save weight and space.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-44.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-44.jpg)
+
+It all fits snugly, with one lens attached to the camera.  I'm really happy with
+this bag because most camera backpacks are either:
+
+* Designed for Football Dad with a Canon Rebel and kit lens, and don't even come
+  close to accommodating a DSLR with a battery grip.
+* Designed for [Chase Jarvis](http://i.imgur.com/aKeu50l.jpg) with two bodies,
+  six lenses, and no room for anything else like clothing.
+
+I really like that this bag lets me carry enough camera for my amateur self, and
+then lets me carry other stuff (clothes, rain gear, etc) in the rest of the bag.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-45.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-45.jpg)
+
+Zips closed nicely.  The top prism of the camera produces a bit of a bump (can't
+really see it in the photos) but it's not a big deal.  If I'm not going to be
+using a tripod or monopod I'll remove the L-plate and the bump goes away.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-46.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-46.jpg)
+
+Time for the rest of the bag!  I'll show an example of stuff I'd take on
+a weekend trip (though again: I'll lean towards packing too much to show you the
+limits of the bag).
+
+First off: two shirts, two pairs of socks, two pairs of underwear, and hiking
+pants.  Together with the stuff I wear, that's enough for a weekend.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-47.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-47.jpg)
+
+I've drank the packing cube Kool-Aid.  I use the [Eagle Creek packing
+cubes][eagle] and they work pretty well.  The smaller two of the set fit well
+into this bag — the large one is too big for it.
+
+[eagle]: http://www.amazon.com/dp/B00F9S85CS/?tag=stelos-20
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-48.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-48.jpg)
+
+Small cube packed with socks and underwear.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-49.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-49.jpg)
+
+Large cube packed with shirts and pants, with a bit of room left over.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-50.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-50.jpg)
+
+Add a towel if you're staying in a hostel.  This is the [Extra Large Packtowl
+Original][towel] which has served me well.  I may replace it with their
+Ultralight version sometime in the future.
+
+[towel]: http://www.amazon.com/dp/B0075JJ29E/?tag=stelos-20
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-51.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-51.jpg)
+
+Large cube all packed.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-52.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-52.jpg)
+
+Large cube in the top section of the bag.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-53.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-53.jpg)
+
+Small cube fits to the side nicely.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-54.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-54.jpg)
+
+I can't fly without headphones, so they get their own side pocket.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-55.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-55.jpg)
+
+Easy access once on the plane.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-56.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-56.jpg)
+
+One thing to watch out for: the side pocket zippers have large, sharp metal
+teeth.  I could see them ripping fabric if you're not careful.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-57.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-57.jpg)
+
+On a whim I grabbed this [Utility Kit][kit] when I got the bag and it's proved
+to be a handy little organizer.
+
+[kit]: http://www.geographicbags.us/utility-kit-for-media-accessories-or-travel-items
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-58.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-58.jpg)
+
+The fabric is thin, but water-resistant.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-59.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-59.jpg)
+
+It will accommodate quite a bit.  For this demo:
+
+* Rain cover for the backpack
+* Cell phone charger
+* Toothbrush
+* Sleeping mask
+* Camera charger
+* 77mm polarizer
+* Lens cleaning supplies
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-60.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-60.jpg)
+
+All packed in.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-61.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-61.jpg)
+
+The center section holds a lot.  My friend has fit a travel hair dryer in it.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-62.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-62.jpg)
+
+The mesh bags are good for small stuff.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-63.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-63.jpg)
+
+Bottom mesh bit.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-64.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-64.jpg)
+
+It has a hanger to hang once you're in a hotel room, and also helps hold it
+shut.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-65.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-65.jpg)
+
+Fits snugly on top of the large packing cube.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-66.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-66.jpg)
+
+Since we've got a rain cover for the backpack, let's add one for ourselves.
+I use a [Marmot PreCip][jacket] for hiking (it will also add some warmth in
+a pinch).
+
+[jacket]: http://www.amazon.com/dp/B00I2ZCXQO/?tag=stelos-20
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-67.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-67.jpg)
+
+Rolls up nice and small.  Apparently I'm out of rubber bands in my house, so
+I used the end of an old guitar strap here.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-68.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-68.jpg)
+
+It will fit (barely) in the other side pocket.  Again, mind the zipper teeth as
+they feel like they would tear through the thin fabric if you're not careful.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-69.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-69.jpg)
+
+Just about fully loaded!
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-70.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-70.jpg)
+
+The cord cinches the top of the bag loosely.  It can't close completely though,
+so if you're worried about pickpockets...
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-71.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-71.jpg)
+
+You can loop the strap up...
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-72.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-72.jpg)
+
+And around, to provide a bit of extra protection.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-73.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-73.jpg)
+
+Front view.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-74.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-74.jpg)
+
+The snap on the front is also one of the things I don't like about the bag.
+It's magnetic so it snaps itself into place (which is nice), but it's very small
+and shallow so it doesn't have a lot of strength.  If you pack the bag really
+full like this you'll find it coming unsnapped from the strain as you walk.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-75.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-75.jpg)
+
+A couple of odds and ends for the front pocket.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-76.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-76.jpg)
+
+Easy access.  Don't keep anything important in here.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-77.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-77.jpg)
+
+Time for the final measurements!  This is definitely too big to quality as
+a "personal item" but will easy make it as a carry on.  United's website says
+a carry on should be 22" by 14" by 9".
+
+We're at 17" wide, which is a bit over 14".  You probably won't get called on
+it, but if you remove the stuff from the side pockets it collapses down to 13".
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-78.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-78.jpg)
+
+Thickness-wise we're at 9.5".  You can save an inch by taking the laptop out.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-79.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-79.jpg)
+
+And we're well under the long dimension.
+
+[![Photo](/media/images/blog/2015/07/nat-geo-mc5350-80.jpg)](/media/images/blog/2015/07/full/nat-geo-mc5350-80.jpg)
+
+That's it!
+
+All this stuff clocks in at a hefty 24 pounds.  Like I said, this was an example
+of stuffing the bag to bursting.  On a real trip I'd probably leave behind the
+computer and charger, camera charger, 200mm lens, and the rain gear.
+
+After using this on a couple of day hikes and weekend trips I'm really happy
+with it.  I really like the hybrid "reasonable DSLR kit plus weekend supplies"
+style they've taken here.  My only nitpicks are:
+
+* Weak front clasp
+* Sharp teeth on the side pouch zippers
+* No load lifter straps
+* No waist strap
+* No D rings to lash things to the bottom or back
+
+Those are all pretty minor though.  I'd definitely recommend this bag if you're
+looking for a small, versatile camera backpack.
+
--- a/content/blog/2015/11/beat-the-data.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,271 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Just Beat the Data Out of It"
-        snip: "Round two of the Bob Ross Twitch chat analysis."
-        created: 2015-11-30 16:10:00
-    %}
-
-    {% block article %}
-
-[Last week][last-week] we played around with a transcript of the Bob Ross Twitch
-chat during the Season 2 marathon.  I scraped the chat again last Monday to get
-the transcript for the Season 3 marathon, so let's pick up where we left off.
-
-[last-week]: blog/2015/11/happy-little-words/
-
-[TOC]
-
-## Volume Comparison
-
-Was this week busier or quieter than last week?
-
-[![Season 2 and 3 chat volume comparison](/media/images{{ parent_url }}/btd-volume-comparison.png)](/media/images{{ parent_url }}/btd-volume-comparison-large.png)
-
-Note the separate x axes to line up the start and end times of the logs.  Also
-two-minute buckets were used to make things a bit cleaner to look at on this
-crowded graph (see the y axis label).
-
-Seems like this was a bit quieter than last week.  It's encouraging that the
-basic structure looks the same -- this hints that there are some patterns
-waiting to be discovered.
-
-## Spiky N-grams
-
-Last week we looked at graphs of various ngrams and saw that some of them show
-pretty clear patterns.  The end of each episode brings a flood of `gg`, and when
-Bob's son Steve comes on the show we get a big spike in `steve`:
-
-[![Plot of "gg" and "steve" unigrams in Season 2](/media/images{{ parent_url }}/btd-s2-ggsteve.png)](/media/images{{ parent_url }}/btd-s2-ggsteve-large.png)
-
-It's reasonable to expect the same behavior this week.  What did we get?
-
-[![Plot of "gg" and "steve" unigrams in Season 3](/media/images{{ parent_url }}/btd-s3-ggsteve.png)](/media/images{{ parent_url }}/btd-s3-ggsteve-large.png)
-
-Looks pretty similar!  In fact the `steve` plot is even more obvious this week.
-And in both cases the second streaming of the season repeats the pattern seen
-in the first.
-
-Each week between the two seasons the channel "hosts" another painter.  This
-just means that it "pipes through" another streamer's channel so people don't
-get bored.
-
-This week whoever is in charge of picking the guest stream did a shitty job.
-After the first showing ended viewers were assaulted with the most loud,
-obnoxious manchild on the planet.
-
-The chat was not pleased:
-
-[![The Douche-o-Meter™](/media/images{{ parent_url }}/btd-s3-douche.png)](/media/images{{ parent_url }}/btd-s3-douche-large.png)
-
-Thankfully whoever manages Bob's channel mercy-killed the hosting after 10
-minutes or so, and we enjoyed the blissful silence.
-
-So we've seen that the rate of certain n-grams have clear patterns.  If we're
-interested in a particular n-gram that's great -- we can graph it and take
-a look.  But what if we want to *find* interesting n-grams to look at, without
-having to watch the whole marathon (or comb through the logs)?
-
-## Percentiles
-
-[Percentiles][] are a really useful measurement in a lot of fields, so let's
-take a look at them here.  We'll start with a relatively common n-gram like
-"the":
-
-[![Percentile graph of "the" in Season 3](/media/images{{ parent_url }}/btd-s3-percentile-the.png)](/media/images{{ parent_url }}/btd-s3-percentile-the-large.png)
-
-Here we've got a pretty smooth gradation from the lower percentiles up to the
-higher ones.  Note that these are rates of `the` per minute, so the value `11`
-at `50` means that half of all 2-minute bins recorded had eleven or fewer
-instances of `the`.  This seems low for English text, but a lot of the messages
-in the Bob Ross chat are one or two-word slang -- full sentences are rare.
-
-If we go back to the normal n-gram plot of `the` we can see that it's not a very
-"spiky" word:
-
-[![Plot of "the" unigram in Season 3](/media/images{{ parent_url }}/btd-s3-the.png)](/media/images{{ parent_url }}/btd-s3-the-large.png)
-
-Let's look at another common word, `bob`:
-
-[![Percentile graph of "bob"](/media/images{{ parent_url }}/btd-s3-percentile-bob.png)](/media/images{{ parent_url }}/btd-s3-percentile-bob-large.png)
-
-Pretty smooth, though it's a little bit steeper at the end (probably because of
-the deluge of `hi bob` when an episode starts).  N-gram plot for comparison:
-
-[![Plot of "bob" unigram in Season 3](/media/images{{ parent_url }}/btd-s3-bob.png)](/media/images{{ parent_url }}/btd-s3-bob-large.png)
-
-What about an n-gram we *know* represents a mostly-unique event, like `steve`?
-We would expect the graph of percentiles to look steeper, because the lower and
-middle percentiles would be very low and the highest few would skyrocket.
-
-[![Percentile graph of "steve" in Season 3](/media/images{{ parent_url }}/btd-s3-percentile-steve.png)](/media/images{{ parent_url }}/btd-s3-percentile-steve-large.png)
-
-[![Plot of "steve" unigram in Season 3](/media/images{{ parent_url }}/btd-s3-steve.png)](/media/images{{ parent_url }}/btd-s3-steve-large.png)
-
-We've tentatively identified another pattern in the data, but how can it help us
-find new interesting terms?
-
-[percentiles]: https://en.wikipedia.org/wiki/Percentile
-
-## Spikiness Scores
-
-If we look at the percentiles for a few known-spiky terms we can see a pattern:
-
-[![Percentile graph of "steve" in Season 3](/media/images{{ parent_url }}/btd-s3-percentile-steve.png)](/media/images{{ parent_url }}/btd-s3-percentile-steve-large.png)
-
-[![Percentile graph of "drugs" in Season 3](/media/images{{ parent_url }}/btd-s3-percentile-drugs.png)](/media/images{{ parent_url }}/btd-s3-percentile-drugs-large.png)
-
-[![Percentile graph of "cringe" in Season 3](/media/images{{ parent_url }}/btd-s3-percentile-cringe.png)](/media/images{{ parent_url }}/btd-s3-percentile-cringe-large.png)
-
-The top percentile or two have some volume, but it quickly drops away to
-nothingness within five or ten percent.  So let's try to define a really basic
-"spikiness score" that we can work out for all n-grams:
-
-$$ {\text{Spikiness}}(w) = \frac{P_{100}(w)}{P_{95}(w) + 0.1} $$
-
-We'll start by saying that the spikiness score of a word is the value of the
-100th percentile for that word, divided by the 95th percentile (plus a small
-smoothing factor to avoid division by zero).  Let's try some words:
-
-    :::text
-    the     1.78
-    bob     2.39
-    steve   4.67
-    drugs  30.00
-    cringe 60.00
-
-This doesn't look too terrible.  The words we consider spiky are all scored
-higher than the non-spiky ones, but it's not quite there yet.  `steve` is rated
-pretty low even though we consider it to be spiky.
-
-When we made our initial formula we arbitrarily picked the 100th and 95th
-percentiles out of thin air.  What if we choose the 99th and 90th instead?
-
-$$ {\text{Spikiness}}(w) = \frac{P_{99}(w)}{P_{90}(w) + 0.1} $$
-
-    :::text
-    bob     3.56
-    the     1.42
-    steve  77.27
-    cringe 20.00
-    drugs  10.00
-
-This has changed the scores quite a bit, and now they're more like what we want.
-But again, we just picked the two percentiles out of thin air.  It would be nice
-if we could get a feel for how the choice of percentiles affects our spikiness
-scores.  Once again, let's turn to gnuplot.  We'll generalize our function:
-
-$$ {\text{Spikiness}}(w, L, U) = \frac{P_{U}(w)}{P_{L}(w) + 0.1} $$
-
-And graph it for all the combinations of percentiles for a couple of words we
-know:
-
-[![Spikiness percentile sensitivity plot for "the"](/media/images{{ parent_url }}/btd-ssp-the.png)](/media/images{{ parent_url }}/btd-ssp-the-large.png)
-
-[![Spikiness percentile sensitivity plot for "bob"](/media/images{{ parent_url }}/btd-ssp-bob.png)](/media/images{{ parent_url }}/btd-ssp-bob-large.png)
-
-[![Spikiness percentile sensitivity plot for "steve"](/media/images{{ parent_url }}/btd-ssp-steve.png)](/media/images{{ parent_url }}/btd-ssp-steve-large.png)
-
-[![Spikiness percentile sensitivity plot for "rip devil"](/media/images{{ parent_url }}/btd-ssp-rip__devil.png)](/media/images{{ parent_url }}/btd-ssp-rip__devil-large.png)
-
-These graphs are approaching the point of being impossible to read, but we can
-definitely see a pattern.  In the first two graphs (common words) the only way
-to get a high spikiness score is to choose our formula's lower percentile to be
-*really* low (15th percentile or lower).
-
-In the second two graphs (spiky words) we can see that the score is high when
-the upper percentile is 99th or 100th, and the lower percentile is beneath the
-90th (or thereabouts).
-
-Now that we have a hypothesis let's try a couple more plots to see if it still
-holds:
-
-[![Spikiness percentile sensitivity plot for "gg"](/media/images{{ parent_url }}/btd-ssp-gg.png)](/media/images{{ parent_url }}/btd-ssp-gg-large.png)
-
-`gg` does come in spikes, but it happens so often that we need to select
-a smaller lower percentile if we want it to be considered spiky.  Whether we
-want to depends on what we're looking for -- if we want *rare* events then we
-probably want to exclude it.
-
-`ruined` get spammed so much that it's certainly not rare, and isn't even
-particularly spiky in any way:
-
-[![Spikiness percentile sensitivity plot for "ruined"](/media/images{{ parent_url }}/btd-ssp-ruined.png)](/media/images{{ parent_url }}/btd-ssp-ruined-large.png)
-
-[![Plot of "ruined" unigram in Season 3](/media/images{{ parent_url }}/btd-s3-ruined.png)](/media/images{{ parent_url }}/btd-s3-ruined-large.png)
-
-So it looks like we're at least on a reasonable track here.  Let's settle the
-100th and 90th for now and see where they lead.
-
-There's one other addition to our spikiness formula we should make before moving
-on: if the 100th percentile of a term is small (e.g. less than 5) then while it
-might technically be spiky, we probably don't care about it.  So we'll just drop
-those on the floor and not really worry about them.
-
-$$ {\text{Spikiness}}(w) = \begin{cases} 0&amp; {\text{if}}\ P_{100}(w) &lt; 5 &#92;&#92; \frac{P_{100}(w)}{P_{90}(w) + 0.1}&amp; {\text{otherwise}} \end{cases} $$ <!-- ._ fuckin markdown -->
-
-## Results
-
-Now that we've got a way to measure a term's spikiness, we can calculate it for
-all n-grams and sort to find some interesting ones.  Let's try it with bigrams:
-
-    :::text
-    mouth__noises 680.00
-    (__mouth 520.00
-    soft__music 480.00
-    elevator__music 480.00
-    noises__) 470.00
-    believe__biblethump 460.00
-    cool__elevator 450.00
-    soft__rock 390.00
-    smooth__soft 390.00
-    smooth__jazz 380.00
-    relaxing__guitar 360.00
-    guitar__music 360.00
-    son__of 330.00
-    music__) 330.00
-    (__soft 330.00
-    a__gun 320.00
-    (__relaxing 320.00
-    big__shaft 300.00
-    super__steve 290.00
-    jazz__music 280.00
-    crazy__day 280.00
-    zoop__zoop 270.00
-    the__heck 270.00
-    (__smooth 260.00
-    flat__trees 240.00
-    steve__! 220.00
-    hi__steve 220.00
-    ...
-
-We can get similar results for unigrams, trigrams, etc.  Let's graph a couple of
-these highly-spiky terms.  Twitch chat definitely loves innuendo:
-
-[![Plot of vaguely sexual n-grams in Season 3](/media/images{{ parent_url }}/btd-s3-innuendo.png)](/media/images{{ parent_url }}/btd-s3-innuendo-large.png)
-
-Something new this week was the addition of captions, which sometimes included
-things like `(soft music)` and `(mouth noises)`.  The chat liked to poke fun at
-those:
-
-[![Plot of "soft music" and "mouth noises" bigrams in Season 3](/media/images{{ parent_url }}/btd-s3-mouthnoises.png)](/media/images{{ parent_url }}/btd-s3-mouthnoises-large.png)
-
-We can also see some particular elements of paintings:
-
-[![Plot of subject n-grams in Season 3](/media/images{{ parent_url }}/btd-s3-subjects.png)](/media/images{{ parent_url }}/btd-s3-subjects-large.png)
-
-The lists aren't perfect.  They contain a lot of redundant stuff (e.g. `(soft
-music)` produces 3 separate bigrams that are all equally spiky), and there's
-a bunch of stuff we don't care about as much.  But if you're looking to find
-some interesting terms they can at least give you a starting point.
-
-## Join the Fun
-
-I'm posting this right as the Season 4 marathon is going live on [the Bob Ross
-Twitch channel][brtwitch]  If you've got some time feel free to pull up your
-comfy computer chair and join a few thousand other people for a relaxing evening
-with Bob!
-
-[brtwitch]: http://twitch.tv/BobRoss
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2015/11/beat-the-data.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,273 @@
++++
+title = "Just Beat the Data Out of It"
+snip = "Round two of the Bob Ross Twitch chat analysis."
+date = 2015-11-30T16:10:00Z
+draft = false
+
++++
+
+[Last week][last-week] we played around with a transcript of the Bob Ross Twitch
+chat during the Season 2 marathon.  I scraped the chat again last Monday to get
+the transcript for the Season 3 marathon, so let's pick up where we left off.
+
+[last-week]: blog/2015/11/happy-little-words/
+
+{{% toc %}}
+
+## Volume Comparison
+
+Was this week busier or quieter than last week?
+
+[![Season 2 and 3 chat volume comparison](/media/images/blog/2015/11/btd-volume-comparison.png)](/media/images/blog/2015/11/btd-volume-comparison-large.png)
+
+Note the separate x axes to line up the start and end times of the logs.  Also
+two-minute buckets were used to make things a bit cleaner to look at on this
+crowded graph (see the y axis label).
+
+Seems like this was a bit quieter than last week.  It's encouraging that the
+basic structure looks the same — this hints that there are some patterns
+waiting to be discovered.
+
+## Spiky N-grams
+
+Last week we looked at graphs of various ngrams and saw that some of them show
+pretty clear patterns.  The end of each episode brings a flood of `gg`, and when
+Bob's son Steve comes on the show we get a big spike in `steve`:
+
+[![Plot of "gg" and "steve" unigrams in Season 2](/media/images/blog/2015/11/btd-s2-ggsteve.png)](/media/images/blog/2015/11/btd-s2-ggsteve-large.png)
+
+It's reasonable to expect the same behavior this week.  What did we get?
+
+[![Plot of "gg" and "steve" unigrams in Season 3](/media/images/blog/2015/11/btd-s3-ggsteve.png)](/media/images/blog/2015/11/btd-s3-ggsteve-large.png)
+
+Looks pretty similar!  In fact the `steve` plot is even more obvious this week.
+And in both cases the second streaming of the season repeats the pattern seen
+in the first.
+
+Each week between the two seasons the channel "hosts" another painter.  This
+just means that it "pipes through" another streamer's channel so people don't
+get bored.
+
+This week whoever is in charge of picking the guest stream did a shitty job.
+After the first showing ended viewers were assaulted with the most loud,
+obnoxious manchild on the planet.
+
+The chat was not pleased:
+
+[![The Douche-o-Meter™](/media/images/blog/2015/11/btd-s3-douche.png)](/media/images/blog/2015/11/btd-s3-douche-large.png)
+
+Thankfully whoever manages Bob's channel mercy-killed the hosting after 10
+minutes or so, and we enjoyed the blissful silence.
+
+So we've seen that the rate of certain n-grams have clear patterns.  If we're
+interested in a particular n-gram that's great — we can graph it and take
+a look.  But what if we want to *find* interesting n-grams to look at, without
+having to watch the whole marathon (or comb through the logs)?
+
+## Percentiles
+
+[Percentiles][] are a really useful measurement in a lot of fields, so let's
+take a look at them here.  We'll start with a relatively common n-gram like
+"the":
+
+[![Percentile graph of "the" in Season 3](/media/images/blog/2015/11/btd-s3-percentile-the.png)](/media/images/blog/2015/11/btd-s3-percentile-the-large.png)
+
+Here we've got a pretty smooth gradation from the lower percentiles up to the
+higher ones.  Note that these are rates of `the` per minute, so the value `11`
+at `50` means that half of all 2-minute bins recorded had eleven or fewer
+instances of `the`.  This seems low for English text, but a lot of the messages
+in the Bob Ross chat are one or two-word slang — full sentences are rare.
+
+If we go back to the normal n-gram plot of `the` we can see that it's not a very
+"spiky" word:
+
+[![Plot of "the" unigram in Season 3](/media/images/blog/2015/11/btd-s3-the.png)](/media/images/blog/2015/11/btd-s3-the-large.png)
+
+Let's look at another common word, `bob`:
+
+[![Percentile graph of "bob"](/media/images/blog/2015/11/btd-s3-percentile-bob.png)](/media/images/blog/2015/11/btd-s3-percentile-bob-large.png)
+
+Pretty smooth, though it's a little bit steeper at the end (probably because of
+the deluge of `hi bob` when an episode starts).  N-gram plot for comparison:
+
+[![Plot of "bob" unigram in Season 3](/media/images/blog/2015/11/btd-s3-bob.png)](/media/images/blog/2015/11/btd-s3-bob-large.png)
+
+What about an n-gram we *know* represents a mostly-unique event, like `steve`?
+We would expect the graph of percentiles to look steeper, because the lower and
+middle percentiles would be very low and the highest few would skyrocket.
+
+[![Percentile graph of "steve" in Season 3](/media/images/blog/2015/11/btd-s3-percentile-steve.png)](/media/images/blog/2015/11/btd-s3-percentile-steve-large.png)
+
+[![Plot of "steve" unigram in Season 3](/media/images/blog/2015/11/btd-s3-steve.png)](/media/images/blog/2015/11/btd-s3-steve-large.png)
+
+We've tentatively identified another pattern in the data, but how can it help us
+find new interesting terms?
+
+[percentiles]: https://en.wikipedia.org/wiki/Percentile
+
+## Spikiness Scores
+
+If we look at the percentiles for a few known-spiky terms we can see a pattern:
+
+[![Percentile graph of "steve" in Season 3](/media/images/blog/2015/11/btd-s3-percentile-steve.png)](/media/images/blog/2015/11/btd-s3-percentile-steve-large.png)
+
+[![Percentile graph of "drugs" in Season 3](/media/images/blog/2015/11/btd-s3-percentile-drugs.png)](/media/images/blog/2015/11/btd-s3-percentile-drugs-large.png)
+
+[![Percentile graph of "cringe" in Season 3](/media/images/blog/2015/11/btd-s3-percentile-cringe.png)](/media/images/blog/2015/11/btd-s3-percentile-cringe-large.png)
+
+The top percentile or two have some volume, but it quickly drops away to
+nothingness within five or ten percent.  So let's try to define a really basic
+"spikiness score" that we can work out for all n-grams:
+
+<div>$$ {\text{Spikiness}}(w) = \frac{P_{100}(w)}{P_{95}(w) + 0.1} $$</div>
+
+We'll start by saying that the spikiness score of a word is the value of the
+100th percentile for that word, divided by the 95th percentile (plus a small
+smoothing factor to avoid division by zero).  Let's try some words:
+
+```text
+the     1.78
+bob     2.39
+steve   4.67
+drugs  30.00
+cringe 60.00
+```
+
+This doesn't look too terrible.  The words we consider spiky are all scored
+higher than the non-spiky ones, but it's not quite there yet.  `steve` is rated
+pretty low even though we consider it to be spiky.
+
+When we made our initial formula we arbitrarily picked the 100th and 95th
+percentiles out of thin air.  What if we choose the 99th and 90th instead?
+
+<div>$$ {\text{Spikiness}}(w) = \frac{P_{99}(w)}{P_{90}(w) + 0.1} $$</div>
+
+```text
+bob     3.56
+the     1.42
+steve  77.27
+cringe 20.00
+drugs  10.00
+```
+
+This has changed the scores quite a bit, and now they're more like what we want.
+But again, we just picked the two percentiles out of thin air.  It would be nice
+if we could get a feel for how the choice of percentiles affects our spikiness
+scores.  Once again, let's turn to gnuplot.  We'll generalize our function:
+
+<div>$$ {\text{Spikiness}}(w, L, U) = \frac{P_{U}(w)}{P_{L}(w) + 0.1} $$</div>
+
+And graph it for all the combinations of percentiles for a couple of words we
+know:
+
+[![Spikiness percentile sensitivity plot for "the"](/media/images/blog/2015/11/btd-ssp-the.png)](/media/images/blog/2015/11/btd-ssp-the-large.png)
+
+[![Spikiness percentile sensitivity plot for "bob"](/media/images/blog/2015/11/btd-ssp-bob.png)](/media/images/blog/2015/11/btd-ssp-bob-large.png)
+
+[![Spikiness percentile sensitivity plot for "steve"](/media/images/blog/2015/11/btd-ssp-steve.png)](/media/images/blog/2015/11/btd-ssp-steve-large.png)
+
+[![Spikiness percentile sensitivity plot for "rip devil"](/media/images/blog/2015/11/btd-ssp-rip__devil.png)](/media/images/blog/2015/11/btd-ssp-rip__devil-large.png)
+
+These graphs are approaching the point of being impossible to read, but we can
+definitely see a pattern.  In the first two graphs (common words) the only way
+to get a high spikiness score is to choose our formula's lower percentile to be
+*really* low (15th percentile or lower).
+
+In the second two graphs (spiky words) we can see that the score is high when
+the upper percentile is 99th or 100th, and the lower percentile is beneath the
+90th (or thereabouts).
+
+Now that we have a hypothesis let's try a couple more plots to see if it still
+holds:
+
+[![Spikiness percentile sensitivity plot for "gg"](/media/images/blog/2015/11/btd-ssp-gg.png)](/media/images/blog/2015/11/btd-ssp-gg-large.png)
+
+`gg` does come in spikes, but it happens so often that we need to select
+a smaller lower percentile if we want it to be considered spiky.  Whether we
+want to depends on what we're looking for — if we want *rare* events then we
+probably want to exclude it.
+
+`ruined` get spammed so much that it's certainly not rare, and isn't even
+particularly spiky in any way:
+
+[![Spikiness percentile sensitivity plot for "ruined"](/media/images/blog/2015/11/btd-ssp-ruined.png)](/media/images/blog/2015/11/btd-ssp-ruined-large.png)
+
+[![Plot of "ruined" unigram in Season 3](/media/images/blog/2015/11/btd-s3-ruined.png)](/media/images/blog/2015/11/btd-s3-ruined-large.png)
+
+So it looks like we're at least on a reasonable track here.  Let's settle the
+100th and 90th for now and see where they lead.
+
+There's one other addition to our spikiness formula we should make before moving
+on: if the 100th percentile of a term is small (e.g. less than 5) then while it
+might technically be spiky, we probably don't care about it.  So we'll just drop
+those on the floor and not really worry about them.
+
+<div>$$
+    {\text{Spikiness}}(w) = \begin{cases} 0&amp; {\text{if}}\ P_{100}(w) &lt; 5 &#92;&#92; \frac{P_{100}(w)}{P_{90}(w) + 0.1}&amp; {\text{otherwise}} \end{cases}
+$$</div>
+
+## Results
+
+Now that we've got a way to measure a term's spikiness, we can calculate it for
+all n-grams and sort to find some interesting ones.  Let's try it with bigrams:
+
+```text
+mouth__noises 680.00
+(__mouth 520.00
+soft__music 480.00
+elevator__music 480.00
+noises__) 470.00
+believe__biblethump 460.00
+cool__elevator 450.00
+soft__rock 390.00
+smooth__soft 390.00
+smooth__jazz 380.00
+relaxing__guitar 360.00
+guitar__music 360.00
+son__of 330.00
+music__) 330.00
+(__soft 330.00
+a__gun 320.00
+(__relaxing 320.00
+big__shaft 300.00
+super__steve 290.00
+jazz__music 280.00
+crazy__day 280.00
+zoop__zoop 270.00
+the__heck 270.00
+(__smooth 260.00
+flat__trees 240.00
+steve__! 220.00
+hi__steve 220.00
+...
+```
+
+We can get similar results for unigrams, trigrams, etc.  Let's graph a couple of
+these highly-spiky terms.  Twitch chat definitely loves innuendo:
+
+[![Plot of vaguely sexual n-grams in Season 3](/media/images/blog/2015/11/btd-s3-innuendo.png)](/media/images/blog/2015/11/btd-s3-innuendo-large.png)
+
+Something new this week was the addition of captions, which sometimes included
+things like `(soft music)` and `(mouth noises)`.  The chat liked to poke fun at
+those:
+
+[![Plot of "soft music" and "mouth noises" bigrams in Season 3](/media/images/blog/2015/11/btd-s3-mouthnoises.png)](/media/images/blog/2015/11/btd-s3-mouthnoises-large.png)
+
+We can also see some particular elements of paintings:
+
+[![Plot of subject n-grams in Season 3](/media/images/blog/2015/11/btd-s3-subjects.png)](/media/images/blog/2015/11/btd-s3-subjects-large.png)
+
+The lists aren't perfect.  They contain a lot of redundant stuff (e.g. `(soft
+music)` produces 3 separate bigrams that are all equally spiky), and there's
+a bunch of stuff we don't care about as much.  But if you're looking to find
+some interesting terms they can at least give you a starting point.
+
+## Join the Fun
+
+I'm posting this right as the Season 4 marathon is going live on [the Bob Ross
+Twitch channel][brtwitch]  If you've got some time feel free to pull up your
+comfy computer chair and join a few thousand other people for a relaxing evening
+with Bob!
+
+[brtwitch]: http://twitch.tv/BobRoss
+
--- a/content/blog/2015/11/happy-little-words.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,314 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Happy Little Words"
-        snip: "Analyzing the Bob Ross Twitch chat."
-        created: 2015-11-20 18:43:00
-    %}
-
-    {% block article %}
-
-In late October the video game streaming site Twitch.tv [launched "Twitch
-Creative"][twitch-creative], essentially giving people permission to stream
-non-video game related creative content on the site.  To celebrate the launch
-they streamed all 403 episodes of [The Joy of Painting with Bob Ross][joy] in
-a giant marathon.
-
-The Bob Ross channel has its own chat room, and it quickly became packed with
-folks watching Bob paint.  The chat spawned its own memes and conventions within
-days, mostly taking gamer slang (e.g. "gg" for "good game") and applying it to
-the show (people spam "gg" in the chat whenever Bob finishes a painting).
-
-Sadly that marathon has ended, but they've kept the dream alive by having ["Bob
-Ross Night" on Mondays][mondays].  Every Monday they're going to stream a season
-of the show twice (once at a Europe-friendly time and again for American folks).
-Last Monday I scraped the Twitch chat during the marathon(s) of Season 2 and
-decided to have some fun poking around at the data.
-
-[twitch-creative]: http://blog.twitch.tv/2015/10/introducing-twitch-creative/
-[joy]: https://en.wikipedia.org/wiki/The_Joy_of_Painting
-[mondays]: http://blog.twitch.tv/2015/11/monday-night-is-bob-ross-night/
-
-[TOC]
-
-## Scraping
-
-Scraping the chat was pretty easy.  Twitch has an IRC gateway for chats, so
-I just ran an IRC client ([weechat][]) on a VPS and had it log the channel like
-any other.  Once the marathon finished I just `scp`'ed down the 8mb log and
-started working with it.
-
-First I trimmed both ends to only leave messages from about an hour and a half
-before and after the marathons started and ended.  So the data I'm going to work
-with runs from 2015-11-16 14:30 to 2015-11-17 07:30 (all times are in UTC),
-or 17 hours.
-
-Then I cleaned it up to
-remove some of the cruft (status messages from the client and such) and
-lowercase everything:
-
-    cat data/raw | grep -E '^[^\t]+\t <' | gsed -e 's/./\L\0/g' > data/log
-
-Then I made an ugly little Python script to massage the data into something
-a bit easier to work with later:
-
-    :::python
-    import datetime, sys, time
-
-    def datetime_to_epoch(dt):
-        return int(time.mktime(dt.timetuple()))
-
-    for line in sys.stdin:
-        timestamp, nick, msg = (s.strip() for s in line.split('\t', 2))
-
-        timestamp = datetime_to_epoch(
-            datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S'))
-
-        # strip off <>'s
-        nick = nick[1:-1]
-
-        print(timestamp, nick, msg)
-
-This results in a file with one message per line, in the format:
-
-    timestamp nick message goes here...
-
-On a side note: I tried out [Mosh][] for persisting a connection to the server
-(instead of using tmux or screen to persist a session) and it worked pretty
-well.  I might start using it more often.
-
-[weechat]: https://weechat.org/
-[Mosh]: https://mosh.mit.edu/
-
-## Volume
-
-Now that we've got a nice clean corpus, let's start playing with it!
-
-The obvious first question: how many messages did people send in total?
-
-     ><((°> cat data/messages | wc -l
-      165368
-
-That's almost 10,000 messages per hour!  And since there were periods of almost
-no activity before, between, and after the two marathons it means the rate
-*during* them was well over that!
-
-Who talked the most?
-
-    ><((°> cat data/messages | cuts -f 2 | sort | uniq -c | sort -nr | head -5
-     269 fuscia13
-     259 almightypainter
-     239 sabrinamywaifu
-     235 roudydogg1
-     201 ionone
-
-Some talkative folks (though honestly I expected a bit higher numbers here).
-[cuts][] is "**cut** on **s**paces" -- a little function I use so I don't have
-to type `-d ' '` all the time.
-
-[cuts]: https://bitbucket.org/sjl/dotfiles/src/default/fish/functions/cuts.fish
-
-## N-grams
-
-The chat has spawned a bunch of its own memes and jargon.  I made another ugly
-Python script to split up messages into [n-grams] so we can analyze them more
-easily:
-
-    :::python
-    import sys
-    import nltk
-
-    def window(coll, size):
-        '''Generate a "sliding window" of tuples of size l over coll.
-
-        coll must be sliceable and have a fixed len.
-
-        '''
-        coll_len = len(coll)
-        for i in range(coll_len):
-            if i + size > coll_len:
-                break
-            else:
-                yield tuple(coll[i:i+size])
-
-    for line in sys.stdin:
-        timestamp, nick, msg = line.split(' ', 2)
-
-        n = int(sys.argv[1])
-
-        for ngram in set(window(nltk.word_tokenize(msg), n)):
-            print(timestamp, nick, '__'.join(ngram))
-
-This lets us easily split a message into unigrams:
-
-    ><((°> echo "1447680000 sjl beat the devil out of it" | python src/split.py 1
-    1447680000 sjl it
-    1447680000 sjl the
-    1447680000 sjl beat
-    1447680000 sjl of
-    1447680000 sjl out
-    1447680000 sjl devil
-
-The order of n-grams within a message isn't preserved because the splitting
-script uses a `set` to remove duplicate n-grams.  I wanted to remove dupes
-because it turns out people frequently copy and paste the same word many times
-in a single message and I didn't want that to throw off the numbers.
-
-Bigrams are just as easy -- just change the parameter to `split.py`:
-
-    ><((°> echo "1447680000 sjl beat the devil out of it" | python src/split.py 2
-    1447680000 sjl of__it
-    1447680000 sjl the__devil
-    1447680000 sjl beat__the
-    1447680000 sjl devil__out
-    1447680000 sjl out__of
-
-N-grams are joined with double underscores to make them easier to plot later.
-
-So what are the most frequent unigrams?
-
-    ><((°> cat data/words | cuts -f3 | sort | uniq -c | sort -nr | head -15
-    19523 bob
-    14367 ruined
-    11961 kappaross
-    11331 !
-    10989 gg
-    7666 is
-    6592 the
-    6305 ?
-    6090 i
-    5376 biblethump
-    5240 devil
-    5122 saved
-    5075 rip
-    4813 it
-    4727 a
-
-Some of these are expected, like "Bob" and stopwords like "is" and "the".
-
-The chat loves to spam "RUINED" whenever Bob makes a drastic change to the
-painting that looks awful at first, and then spam "SAVED" once he applies a bit
-more paint and it looks beautiful.  This happens frequently with mountains.
-
-"KappaRoss" and "BibleThump" are [Twitch emotes][kappa] that produce small
-images in the chat.
-
-When Bob cleans his brush he beats it against the leg of the easel to remove the
-paint thinner, and he often smiles and says "just beat the devil out of it".  It
-didn't take long before chat started spamming "RIP DEVIL" every time he cleans
-the brush.
-
-How about the most frequent bigrams and trigrams?
-
-    ><((°> cat data/bigrams | cuts -f3 | sort | uniq -c | sort -nr | head -15
-    3731 rip__devil
-    3153 !__!
-    2660 bob__ross
-    2490 hi__bob
-    1844 <__3
-    1838 kappaross__kappaross
-    1533 bob__is
-    1409 bob__!
-    1389 god__bless
-    1324 happy__little
-    1181 van__dyke
-    1093 gg__wp
-    1024 is__back
-    908 i__believe
-    895 ?__?
-
-    ><((°> cat data/trigrams | cuts -f3 | sort | uniq -c | sort -nr | head -15
-    2130 !__!__!
-    1368 kappaross__kappaross__kappaross
-    678 van__dyke__brown
-    617 bob__is__back
-    548 ?__?__?
-    503 biblethump__biblethump__biblethump
-    401 bob__ross__is
-    377 hi__bob__!
-    376 beat__the__devil
-    361 bob__!__!
-    331 bob__<__3
-    324 <__3__<
-    324 3__<__3
-    303 i__love__you
-    302 son__of__a
-
-Looks like lots of love for Bob and no sympathy for the devil.  It also seems
-like [Van Dyke Brown][vdb] is Twitch chat's favorite color by a landslide.
-
-Note that the exact n-grams depend on the tokenization method.  I used NLTK's
-`word_tokenize` because it was easy and worked pretty well.
-`wordpunct_tokenize` also works, but it splits up basic punctuation a bit too
-much for my liking (e.g. it turns `bob's` into three tokens `bob`, `'`, and `s`,
-where `word_tokenize` produces just `bob` and `'s`).
-
-[n-grams]: https://en.wikipedia.org/wiki/N-gram
-[kappa]: https://fivethirtyeight.com/features/why-a-former-twitch-employee-has-one-of-the-most-reproduced-faces-ever/
-[vdb]: https://www.bobross.com/ProductDetails.asp?ProductCode=VanDykeBrown
-
-## Graphing
-
-Pure numbers are interesting, but [can be misleading][aq].  Let's make some
-graphs to get a sense of what the data feels like.  I'm using [gnuplot][] to
-make the graphs.
-
-What does the overall volume look like?  We'll use minute-wide buckets in the
-x axis to make the graph a bit easier to read.
-
-[![Photo](/media/images{{ parent_url }}/hlw-total.png)](/media/images{{ parent_url }}/hlw-total-large.png)
-
-Can you tell where the two marathons start and end?
-
-Let's try to identify where episodes start and finish.  Chat usually spams "hi
-bob" when an episode starts and "gg" when it finishes, so let's plot those.
-We'll use 30-second x buckets here because a minute isn't a fine enough
-resolution for the events we're looking for.  To make it easier to read we'll
-just look at the first half of the first marathon.
-
-[![Photo](/media/images{{ parent_url }}/hlw-higg.png)](/media/images{{ parent_url }}/hlw-higg-large.png)
-
-This works pretty well!  The graph starts with a big spike of "hi bob", then as
-each episode finishes we see a (huge) spike of "gg", followed immediately by
-a round of "hi bob" as the next episode starts.
-
-Can we find all the times Bob cleaned his brush?
-
-[![Photo](/media/images{{ parent_url }}/hlw-ripdevil.png)](/media/images{{ parent_url }}/hlw-ripdevil-large.png)
-
-Looks like the devil isn't having a very good time.  It's encouraging that the
-two seasons have roughly the same structure (three main clusters of peaks).
-
-Note that there are a couple of smaller peaks between the two showings.  Twitch
-showed another streamer painting between the two marathons, so it's likely that
-she cleaned her brush a couple of times and the chat responded.  Fewer people
-were watching the stream during the break, hence the smaller peaks.
-
-When did Bob get the most love?  We'll use 5-minute x bins here because we just
-want a general idea.
-
-[![Photo](/media/images{{ parent_url }}/hlw-love.png)](/media/images{{ parent_url }}/hlw-love-large.png)
-
-Lots of love all around, but especially as he signed off at the end.
-
-One of my favorite moments was when Bob said something about "changing your mind
-in mid **stream**" and the chat started spamming conspiracy theories about how
-he somehow knew about the stream 30 years in the past:
-
-[![Photo](/media/images{{ parent_url }}/hlw-heknew.png)](/media/images{{ parent_url }}/hlw-heknew-large.png)
-
-[aq]: https://en.wikipedia.org/wiki/Anscombe%27s_quartet
-[gnuplot]: http://www.gnuplot.info/
-
-## Up Next
-
-Poking around at this chat corpus was a lot of fun (and *definitely* counts as
-studying for my NLP final, *definitely*).  I'll probably record the chat during
-next week's marathon and do some more poking, specifically around finding unique
-events (e.g. his son Steve coming on the show) by comparing rate percentiles.
-
-If you've got other ideas for things I should graph, [let me know][twitter].
-
-[twitter]: http://twitter.com/stevelosh
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2015/11/happy-little-words.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,313 @@
++++
+title = "Happy Little Words"
+snip = "Analyzing the Bob Ross Twitch chat."
+date = 2015-11-20T18:43:00Z
+draft = false
+
++++
+
+In late October the video game streaming site Twitch.tv [launched "Twitch
+Creative"][twitch-creative], essentially giving people permission to stream
+non-video game related creative content on the site.  To celebrate the launch
+they streamed all 403 episodes of [The Joy of Painting with Bob Ross][joy] in
+a giant marathon.
+
+The Bob Ross channel has its own chat room, and it quickly became packed with
+folks watching Bob paint.  The chat spawned its own memes and conventions within
+days, mostly taking gamer slang (e.g. "gg" for "good game") and applying it to
+the show (people spam "gg" in the chat whenever Bob finishes a painting).
+
+Sadly that marathon has ended, but they've kept the dream alive by having ["Bob
+Ross Night" on Mondays][mondays].  Every Monday they're going to stream a season
+of the show twice (once at a Europe-friendly time and again for American folks).
+Last Monday I scraped the Twitch chat during the marathon(s) of Season 2 and
+decided to have some fun poking around at the data.
+
+[twitch-creative]: http://blog.twitch.tv/2015/10/introducing-twitch-creative/
+[joy]: https://en.wikipedia.org/wiki/The_Joy_of_Painting
+[mondays]: http://blog.twitch.tv/2015/11/monday-night-is-bob-ross-night/
+
+{{% toc %}}
+
+## Scraping
+
+Scraping the chat was pretty easy.  Twitch has an IRC gateway for chats, so
+I just ran an IRC client ([weechat][]) on a VPS and had it log the channel like
+any other.  Once the marathon finished I just `scp`'ed down the 8mb log and
+started working with it.
+
+First I trimmed both ends to only leave messages from about an hour and a half
+before and after the marathons started and ended.  So the data I'm going to work
+with runs from 2015-11-16 14:30 to 2015-11-17 07:30 (all times are in UTC),
+or 17 hours.
+
+Then I cleaned it up to
+remove some of the cruft (status messages from the client and such) and
+lowercase everything:
+
+    cat data/raw | grep -E '^[^\t]+\t <' | gsed -e 's/./\L\0/g' > data/log
+
+Then I made an ugly little Python script to massage the data into something
+a bit easier to work with later:
+
+```python
+import datetime, sys, time
+
+def datetime_to_epoch(dt):
+    return int(time.mktime(dt.timetuple()))
+
+for line in sys.stdin:
+    timestamp, nick, msg = (s.strip() for s in line.split('\t', 2))
+
+    timestamp = datetime_to_epoch(
+        datetime.datetime.strptime(timestamp, '%Y-%m-%d %H:%M:%S'))
+
+    # strip off <>'s
+    nick = nick[1:-1]
+
+    print(timestamp, nick, msg)
+```
+
+This results in a file with one message per line, in the format:
+
+    timestamp nick message goes here...
+
+On a side note: I tried out [Mosh][] for persisting a connection to the server
+(instead of using tmux or screen to persist a session) and it worked pretty
+well.  I might start using it more often.
+
+[weechat]: https://weechat.org/
+[Mosh]: https://mosh.mit.edu/
+
+## Volume
+
+Now that we've got a nice clean corpus, let's start playing with it!
+
+The obvious first question: how many messages did people send in total?
+
+     ><((°> cat data/messages | wc -l
+      165368
+
+That's almost 10,000 messages per hour!  And since there were periods of almost
+no activity before, between, and after the two marathons it means the rate
+*during* them was well over that!
+
+Who talked the most?
+
+    ><((°> cat data/messages | cuts -f 2 | sort | uniq -c | sort -nr | head -5
+     269 fuscia13
+     259 almightypainter
+     239 sabrinamywaifu
+     235 roudydogg1
+     201 ionone
+
+Some talkative folks (though honestly I expected a bit higher numbers here).
+[cuts][] is "**cut** on **s**paces" — a little function I use so I don't have
+to type `-d ' '` all the time.
+
+[cuts]: https://bitbucket.org/sjl/dotfiles/src/default/fish/functions/cuts.fish
+
+## N-grams
+
+The chat has spawned a bunch of its own memes and jargon.  I made another ugly
+Python script to split up messages into [n-grams] so we can analyze them more
+easily:
+
+```python
+import sys
+import nltk
+
+def window(coll, size):
+    '''Generate a "sliding window" of tuples of size l over coll.
+
+    coll must be sliceable and have a fixed len.
+
+    '''
+    coll_len = len(coll)
+    for i in range(coll_len):
+        if i + size > coll_len:
+            break
+        else:
+            yield tuple(coll[i:i+size])
+
+for line in sys.stdin:
+    timestamp, nick, msg = line.split(' ', 2)
+
+    n = int(sys.argv[1])
+
+    for ngram in set(window(nltk.word_tokenize(msg), n)):
+        print(timestamp, nick, '__'.join(ngram))
+```
+
+This lets us easily split a message into unigrams:
+
+    ><((°> echo "1447680000 sjl beat the devil out of it" | python src/split.py 1
+    1447680000 sjl it
+    1447680000 sjl the
+    1447680000 sjl beat
+    1447680000 sjl of
+    1447680000 sjl out
+    1447680000 sjl devil
+
+The order of n-grams within a message isn't preserved because the splitting
+script uses a `set` to remove duplicate n-grams.  I wanted to remove dupes
+because it turns out people frequently copy and paste the same word many times
+in a single message and I didn't want that to throw off the numbers.
+
+Bigrams are just as easy — just change the parameter to `split.py`:
+
+    ><((°> echo "1447680000 sjl beat the devil out of it" | python src/split.py 2
+    1447680000 sjl of__it
+    1447680000 sjl the__devil
+    1447680000 sjl beat__the
+    1447680000 sjl devil__out
+    1447680000 sjl out__of
+
+N-grams are joined with double underscores to make them easier to plot later.
+
+So what are the most frequent unigrams?
+
+    ><((°> cat data/words | cuts -f3 | sort | uniq -c | sort -nr | head -15
+    19523 bob
+    14367 ruined
+    11961 kappaross
+    11331 !
+    10989 gg
+    7666 is
+    6592 the
+    6305 ?
+    6090 i
+    5376 biblethump
+    5240 devil
+    5122 saved
+    5075 rip
+    4813 it
+    4727 a
+
+Some of these are expected, like "Bob" and stopwords like "is" and "the".
+
+The chat loves to spam "RUINED" whenever Bob makes a drastic change to the
+painting that looks awful at first, and then spam "SAVED" once he applies a bit
+more paint and it looks beautiful.  This happens frequently with mountains.
+
+"KappaRoss" and "BibleThump" are [Twitch emotes][kappa] that produce small
+images in the chat.
+
+When Bob cleans his brush he beats it against the leg of the easel to remove the
+paint thinner, and he often smiles and says "just beat the devil out of it".  It
+didn't take long before chat started spamming "RIP DEVIL" every time he cleans
+the brush.
+
+How about the most frequent bigrams and trigrams?
+
+    ><((°> cat data/bigrams | cuts -f3 | sort | uniq -c | sort -nr | head -15
+    3731 rip__devil
+    3153 !__!
+    2660 bob__ross
+    2490 hi__bob
+    1844 <__3
+    1838 kappaross__kappaross
+    1533 bob__is
+    1409 bob__!
+    1389 god__bless
+    1324 happy__little
+    1181 van__dyke
+    1093 gg__wp
+    1024 is__back
+    908 i__believe
+    895 ?__?
+
+    ><((°> cat data/trigrams | cuts -f3 | sort | uniq -c | sort -nr | head -15
+    2130 !__!__!
+    1368 kappaross__kappaross__kappaross
+    678 van__dyke__brown
+    617 bob__is__back
+    548 ?__?__?
+    503 biblethump__biblethump__biblethump
+    401 bob__ross__is
+    377 hi__bob__!
+    376 beat__the__devil
+    361 bob__!__!
+    331 bob__<__3
+    324 <__3__<
+    324 3__<__3
+    303 i__love__you
+    302 son__of__a
+
+Looks like lots of love for Bob and no sympathy for the devil.  It also seems
+like [Van Dyke Brown][vdb] is Twitch chat's favorite color by a landslide.
+
+Note that the exact n-grams depend on the tokenization method.  I used NLTK's
+`word_tokenize` because it was easy and worked pretty well.
+`wordpunct_tokenize` also works, but it splits up basic punctuation a bit too
+much for my liking (e.g. it turns `bob's` into three tokens `bob`, `'`, and `s`,
+where `word_tokenize` produces just `bob` and `'s`).
+
+[n-grams]: https://en.wikipedia.org/wiki/N-gram
+[kappa]: https://fivethirtyeight.com/features/why-a-former-twitch-employee-has-one-of-the-most-reproduced-faces-ever/
+[vdb]: https://www.bobross.com/ProductDetails.asp?ProductCode=VanDykeBrown
+
+## Graphing
+
+Pure numbers are interesting, but [can be misleading][aq].  Let's make some
+graphs to get a sense of what the data feels like.  I'm using [gnuplot][] to
+make the graphs.
+
+What does the overall volume look like?  We'll use minute-wide buckets in the
+x axis to make the graph a bit easier to read.
+
+[![Photo](/media/images/blog/2015/11/hlw-total.png)](/media/images/blog/2015/11/hlw-total-large.png)
+
+Can you tell where the two marathons start and end?
+
+Let's try to identify where episodes start and finish.  Chat usually spams "hi
+bob" when an episode starts and "gg" when it finishes, so let's plot those.
+We'll use 30-second x buckets here because a minute isn't a fine enough
+resolution for the events we're looking for.  To make it easier to read we'll
+just look at the first half of the first marathon.
+
+[![Photo](/media/images/blog/2015/11/hlw-higg.png)](/media/images/blog/2015/11/hlw-higg-large.png)
+
+This works pretty well!  The graph starts with a big spike of "hi bob", then as
+each episode finishes we see a (huge) spike of "gg", followed immediately by
+a round of "hi bob" as the next episode starts.
+
+Can we find all the times Bob cleaned his brush?
+
+[![Photo](/media/images/blog/2015/11/hlw-ripdevil.png)](/media/images/blog/2015/11/hlw-ripdevil-large.png)
+
+Looks like the devil isn't having a very good time.  It's encouraging that the
+two seasons have roughly the same structure (three main clusters of peaks).
+
+Note that there are a couple of smaller peaks between the two showings.  Twitch
+showed another streamer painting between the two marathons, so it's likely that
+she cleaned her brush a couple of times and the chat responded.  Fewer people
+were watching the stream during the break, hence the smaller peaks.
+
+When did Bob get the most love?  We'll use 5-minute x bins here because we just
+want a general idea.
+
+[![Photo](/media/images/blog/2015/11/hlw-love.png)](/media/images/blog/2015/11/hlw-love-large.png)
+
+Lots of love all around, but especially as he signed off at the end.
+
+One of my favorite moments was when Bob said something about "changing your mind
+in mid **stream**" and the chat started spamming conspiracy theories about how
+he somehow knew about the stream 30 years in the past:
+
+[![Photo](/media/images/blog/2015/11/hlw-heknew.png)](/media/images/blog/2015/11/hlw-heknew-large.png)
+
+[aq]: https://en.wikipedia.org/wiki/Anscombe%27s_quartet
+[gnuplot]: http://www.gnuplot.info/
+
+## Up Next
+
+Poking around at this chat corpus was a lot of fun (and *definitely* counts as
+studying for my NLP final, *definitely*).  I'll probably record the chat during
+next week's marathon and do some more poking, specifically around finding unique
+events (e.g. his son Steve coming on the show) by comparing rate percentiles.
+
+If you've got other ideas for things I should graph, [let me know][twitter].
+
+[twitter]: http://twitter.com/stevelosh
+
--- a/content/blog/2015/12/ludum-dare-34.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,492 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Ludum Dare 34 Postmortem"
-        snip: 'I made a "game"!'
-        created: 2015-12-15 16:30:00
-    %}
-
-    {% block article %}
-
-This past weekend was [Ludum Dare 34][].  Ludum Dare is a thrice-a-year event
-where a theme is chosen and people have 48 hours (for the competition) or 72
-hours (for the "casual" jam) to create a game based on a theme.
-
-I actually managed to have some free time for a change, so I decided to give it
-a go.  I've got a lot of experience programming and a little bit in "sprinting"
-like this (my team [placed second in Django Dash][Django Dash] a few years ago),
-but I haven't made very many games.  Still, by the end of the jam I managed to
-make something that's not quite a game but *is* pretty fun to play around with.
-I figured I'd write about the process while it's all still fresh in my mind.
-
-[Ludum Dare 34]: http://ludumdare.com/compo/
-[Django Dash]: http://djangodash.com/judging/c2/results/team/49/
-
-[TOC]
-
-## My Game
-
-The theme this year was actually *tied* in voting, so there were two:
-
-* Growing
-* Two Button Controls
-
-### Language & Code
-
-I knew going in that I wanted to make something with ASCII graphics with Clojure
-and [clojure-lanterna][].  Once I thought about the themes I decided to make
-a simulation of a world with plants and animals.  I settled on the name "Silt"
-(the stuff at the bottom of riverbeds that slowly accumulates and reshapes the
-world) and got to work.
-
-You can get the source for the game [on BitBucket][bitbucket].  There's also
-a mirror on GitHub if you prefer git.
-
-### Play
-
-There's a prebuilt jar file [on BitBucket][bitbucket] if you want to play the
-game on your computer.
-
-If you don't want to run some random code on your machine, I understand.  I've
-spun up a server you can telnet into to play:
-
-    telnet silt.stevelosh.com
-
-For best results use a terminal with a dark background.  If there are a bunch of
-people playing the server may be slow, or fail entirely with out-of-memory
-errors.  Sorry, it's just an 8gb Linode I'm funding out of my own pocket.
-
-### Gameplay
-
-You are the god of a [toroidal][] world.  Initially it's inhabited by a small
-population of four hundred and one creatures.  Time ticks by at a few ticks per
-second.
-
-[![Silt Initial World](/media/images{{ parent_url }}/silt-initial.gif)](/media/images{{ parent_url }}/silt-initial.gif)
-
-The creatures need energy to survive.  They can get energy by eating fruit from
-shrubs or being near water.
-
-If a creature has enough energy it might reproduce by splitting off a clone of
-itself.  The clone will be identical to its parent (sibling?), though there is
-a slight chance of mutation.
-
-The ideal body temperature for a creature is 0 degrees.  The world starts at
-that temperature, creating a paradise.  As the god of the world, the only way
-you can interact with it is to increase or decrease the temperature.
-
-If the temperature of the world is different than the temperature of a creature,
-they will need to spend more energy to maintain their body heat.  This makes it
-more difficult to survive.  Swinging the temperature in large increments quickly
-is a sure way to kill off the population.
-
-The creatures are not entirely at the mercy of the climate, however.  Creatures
-have an "insulation" score that represents fur or skin.  More insulation
-protects the creature from the outside climate, at the expense of a small amount
-of energy.
-
-The mechanics of temperature/insulation and reproduction/mutation interact to
-cause evolution.  If you slowly increase the temperature of the world over a few
-thousand ticks, children with more insulation are more likely to survive, and so
-your creatures will tend to evolve more insulation over time.
-
-Creatures' movement patterns are also affected by mutation.  Over time your
-creatures will likely evolve to wander instead of staying stationary, because
-fruit takes time to grow and so it's more effective to keep moving and
-gathering.
-
-Creatures can also change their colors and glyphs through mutation, but this is
-much rarer.  After letting the game run for a while you'll probably notice
-"gangs" of creatures with similar characteristics, all descended from a single
-parent.
-
-[![Silt Later World](/media/images{{ parent_url }}/silt-later.gif)](/media/images{{ parent_url }}/silt-later.gif)
-
-Finally, there are eight mysterious objects scattered throughout the landscape.
-Each one does something, but discovering exactly *what* will be difficult
-(unless you read the source).
-
-### Controls
-
-The controls are pretty basic:
-
-* **`arrow keys`** to move your view of the world.
-* **`R`** to reset the world.
-* **`escape`** to quit the game.
-
-Put your cursor over a creature to see their stats:
-
-* **`hjkl`** or **`wasd`** to move your cursor.
-
-The world ticks along, but you can freeze time:
-
-* **`space`** to pause/unpause time.
-
-Those are the basic controls.  To actually *interact* with the world you have
-only two options (in accordance with the "Two Button Controls" theme):
-
-* **`+`** to make the world one degree hotter.
-* **`-`** to make the world one degree colder.
-
-[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna
-[bitbucket]: https://bitbucket.org/sjl/silt
-[toroidal]: https://en.wikipedia.org/wiki/Torus
-
-## Good Choices
-
-I managed to make a working, fairly interesting game within the time limit, so
-I'm pretty happy with most of my choices.
-
-### Familiar Environment
-
-I decided to make Silt in Clojure.  If you follow me on [Twitch][] you might
-have noticed I've been getting more into Common Lisp these days.  I don't really
-like writing in Clojure any more, but I used it for the jam because I wanted an
-environment I was familiar with.
-
-This was a good decision.  I wouldn't have finished if I tried to use Common
-Lisp -- I'd probably still be struggling with whatever its Curses library is.
-
-A 72-hour jam is not the time to be trying out a new language or framework
-you've never used before if you want to have a finished product at the end.
-Pick something you know well so you don't spend 30% of your time trying to
-Google things.
-
-[Twitch]: http://twitch.tv/stevelosh
-
-### Streaming and Talking
-
-I streamed a bit of the coding process a couple times over the weekend (look in
-past broadcasts and they might still be there).  I didn't have a ton of viewers,
-but it was good to talk things out.  Sometimes the stream was my [rubber duck][]
-and it helped a bunch.
-
-[rubber duck]: https://en.wikipedia.org/wiki/Rubber_duck_debugging
-
-### Releasing Before the End
-
-Ludum Dare ends at a certain time, but there's a "release hour" afterword when
-you can take an hour to package up the final version of your game.  I think it's
-better if you don't leave it until then to run through your packaging/release
-process at least once, though.  Once I had the game in a runnable (if not yet
-very fun) state, I made it into a jar to make sure that everything works.
-
-You don't want to find out your build
-process is fucked when you only have 40 minutes left, so do a dry run early and
-discover any snags while you have lots of time to fix them.
-
-### Getting Feedback
-
-Once I had a playable game I asked my friend [Hafdís][] to see if it would run
-on Windows.  Luckily it did -- Java and Lanterna are pretty nicely
-cross-platform.
-
-She ran the game in the background for a while and showed me the results later.
-It's really helpful to get a second opinion about your game (or website or
-whatever you're making) as you're working on it.  It's too easy to get too close
-to your own game and not realize what's fun or painful about it any more.
-
-Asking in the IRC channel can work, but generally everyone there is busy working
-on their own games so you won't get a ton of takers.  You can ask someone
-online, but I think in-person is better if at all possible.  Seeing someone else
-enjoy something you've made is a big morale boost, which can be important when
-you're dealing with tricky bugs later.
-
-[Hafdís]: http://havethis.info/
-
-### Profiling and Performance
-
-During the last day I spent an hour or so using a profiler to identify the
-hottest spots in the code and improving performance.  I didn't focus too much on
-speed, but a little bit of attention can go a long way.
-
-### Ruthless Simplicity
-
-One of the main reasons I managed to finish despite my lack of experience making
-games was being ruthless about making the game as simple as possible.  I have
-a ton of ideas that I could potentially do, but cramming them all into the game
-would take far too long and would probably create a giant mess.
-
-Focusing on one core mechanic (temperature) and building the things that
-interact with it got me pretty far.  The fact that the theme was "Two Button
-Controls" really helped me a lot with this, because it forced me to come up with
-a mechanic simple enough to encode in two buttons.
-
-### Sleeping
-
-I was hanging out in the official IRC channel over the weekend and noticed
-a bunch of people talking about how tired they were and how little sleep they
-were getting.
-
-Because the time frame is so short there's a tendency to want to stay awake for
-as much time as possible to use as many hours as you can.  I think this is
-usually a mistake.  During this weekend, and also for the Django Dash weekend,
-I stuck to my normal sleeping/waking schedule and I think it was the right
-choice.  You may get *more* hours of work in if you don't sleep, but you get
-*better* hours of work if you're rested, fed, and showered.
-
-This is especially tricky if your timezone is offset with the event.  The themes
-were announced at 2 AM my time, and while I would have loved to be awake and
-dive in right away I chose to go to sleep instead and just get started the next
-day.  A screwed up sleep schedule is almost as bad as not enough sleep (for me
-at least).
-
-## Bad Choices
-
-I made a few mistakes along the way too (luckily none of them prevented me from
-finishing).
-
-### Clinging to Failed Mechanics
-
-One of the first mechanics I added to the game was aging -- creatures would age
-over time and eventually die of old age.  Immediately I had trouble balancing
-this against reproduction to avoid population explosions and extinctions, but
-I stuck with it for quite a while trying to make it work.
-
-Eventually I tore the entire aging mechanic out and replaced it with hunger,
-which ended up working far, far better.  In hindsight I should have abandoned
-aging much sooner, as soon as it was obvious that it was making things painful
-and unfun.
-
-### Last-Minute Additions
-
-I added a couple of mysterious objects right before I packaged up the final
-version of the game and I didn't have time to playtest them very much.  I tested
-that they didn't crash the game, but I assumed their effects would be minor
-curiosities and didn't worry too much.
-
-Now that I've tested it a bit more, they have a bigger effect than I thought
-and drastically affect the world.  I should have either tested them more or held
-off on them until I had time to test.
-
-### Working Alone
-
-This one was unavoidable for me this time, but I'm sure Silt could have been
-a lot more interesting if I had worked with another programmer, an artist, or
-a sound designer.
-
-## Clojure
-
-I'll end with a few notes on the experience of writing Silt in Clojure.  Like
-I said earlier: I don't particularly like Clojure any more, but it was familiar
-so I ran with it.  After doing a bunch of Common Lisp lately a few things jumped
-out at me about writing in Clojure, so I wanted to get them down on paper before
-I forget.
-
-### Destructuring is Nice
-
-Clojure's ubiquitous destructuring is really nice.  Common Lisp has
-`destructuring-bind` but it's not as powerful as it is in Clojure, and it's
-certainly not threaded through the language nearly as much.
-
-Destructuring in function arguments is *really* handy -- I almost want to write
-a `defun-destructured` macro that will let me do it in CL.
-
-### Fewer Superfluous Parentheses
-
-In Clojure's syntax there seems to be a general theme of using fewer
-parentheses.  I don't just mean using brackets and curly braces for other
-literals either.  Take the humble `let` in Clojure:
-
-    :::text
-    (let [x (foo)
-          y (bar)]
-      (+ x y))
-
-If you translate the vector literal to a Common Lisp list, it would look like
-this:
-
-    :::text
-    (let (x (foo)
-          y (bar))
-      (+ x y))
-
-But Common Lisp actually makes you surround the binding pairs with *another* set
-of parentheses:
-
-    :::text
-    (let ((x (foo))
-          (y (bar)))
-      (+ x y))
-
-This is annoying.  There are always going to be pairs of binding forms, why do
-I need to wrap them in extra parens?  Clojure's way is cleaner.
-
-### The Tooling is Good
-
-Jvisualvm's statistical profiler is a bit homely, but it gets the job done.
-It's nice to have mature tools to introspect what your code is doing at runtime.
-
-`lein uberjar` just worked and produced a jar that runs fine on Windows and OS
-X.  This was a great relief.  I haven't looked at packaging up a Common Lisp app
-but I am not optimistic.
-
-### But the Compiler Is Not Helpful
-
-SBCL warns me when I'm doing something stupid:
-
-    :::lisp
-    CL-USER> (defun square (x) (* x x))
-
-    SQUARE
-    CL-USER> (defun bad (x y)
-    (+ x (square y y)))
-    ; in: DEFUN BAD
-    ;     (SQUARE Y Y)
-    ;
-    ; caught STYLE-WARNING:
-    ;   The function was called with two arguments, but wants exactly one.
-    ;
-    ; compilation unit finished
-    ;   caught 1 STYLE-WARNING condition
-
-    BAD
-    CL-USER>
-
-Clojure happily lets me be stupid without a peep:
-
-    :::clojure
-    user=> (defn square [x] (* x x))
-    #'user/square
-    user=> (defn bad [x y]
-      #_=> (+ x (square y y)))
-    #'user/bad
-    user=>
-
-I'm often stupid, so I prefer a compiler that helps prevent it.
-
-### Errors are Still Terrible
-
-Clojure stack traces have historically been awful.  When I ran into my first
-error this time I noticed that the stack trace was... nonexistent?
-
-    :::clojure
-    user=> (defn foo [] (/ 1 0))
-    #'user/foo
-    user=> (foo)
-
-    ArithmeticException Divide by zero  clojure.lang.Numbers.divide (Numbers.java:158)
-    user=>
-
-I guess they got tired of people complaining about how the stack traces look
-like shit, so they just... removed them?  You can get them back with a bit of
-work:
-
-    :::clojure
-    user=> (use '[clojure.stacktrace :only [print-stack-trace]])
-    user=> (print-stack-trace *e)
-    java.lang.ArithmeticException: Divide by zero
-     at clojure.lang.Numbers.divide (Numbers.java:158)
-        clojure.lang.Numbers.divide (Numbers.java:3808)
-        user$foo.invoke (form-init5869611501548592997.clj:1)
-        user$eval1219.invoke (form-init5869611501548592997.clj:1)
-        clojure.lang.Compiler.eval (Compiler.java:6782)
-        clojure.lang.Compiler.eval (Compiler.java:6745)
-        clojure.core$eval.invoke (core.clj:3081)
-        clojure.main$repl$read_eval_print__7099$fn__7102.invoke (main.clj:240)
-        clojure.main$repl$read_eval_print__7099.invoke (main.clj:240)
-        clojure.main$repl$fn__7108.invoke (main.clj:258)
-        clojure.main$repl.doInvoke (main.clj:258)
-        clojure.lang.RestFn.invoke (RestFn.java:1523)
-        clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__623.invoke (interruptible_eval.clj:58)
-        clojure.lang.AFn.applyToHelper (AFn.java:152)
-        clojure.lang.AFn.applyTo (AFn.java:144)
-        clojure.core$apply.invoke (core.clj:630)
-        clojure.core$with_bindings_STAR_.doInvoke (core.clj:1868)
-        clojure.lang.RestFn.invoke (RestFn.java:425)
-        clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:56)
-        clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__665$fn__668.invoke (interruptible_eval.clj:191)
-        clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__660.invoke (interruptible_eval.clj:159)
-        clojure.lang.AFn.run (AFn.java:22)
-        java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
-        java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
-        java.lang.Thread.run (Thread.java:745)
-
-Oh yeah, *there's* the garbagepile I remember.
-
-Lisp also hides the traceback at first, but it's easier to get at, and once you
-do it's actually *helpful*:
-
-    :::lisp
-    CL-USER> (declaim (optimize (debug 3)))
-
-    NIL
-    CL-USER> (defun foo () (/ 1 0))
-    ; in: DEFUN FOO
-    ;     (/ 1 0)
-    ;
-    ; caught STYLE-WARNING:
-    ;   Lisp error during constant folding:
-    ;   arithmetic error DIVISION-BY-ZERO signalled
-    ;   Operation was /, operands (1 0).
-    ;
-    ; compilation unit finished
-    ;   caught 1 STYLE-WARNING condition
-
-    FOO
-    CL-USER> (foo)
-
-    debugger invoked on a DIVISION-BY-ZERO in thread
-    #<THREAD "main thread" RUNNING {1002C74703}>:
-      arithmetic error DIVISION-BY-ZERO signalled
-    Operation was /, operands (1 0).
-
-    Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
-
-    restarts (invokable by number or by possibly-abbreviated name):
-      0: [ABORT] Exit debugger, returning to top level.
-
-    (SB-KERNEL::INTEGER-/-INTEGER 1 0)
-    0] backtrace
-
-    Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1002C74703}>
-    0: (SB-KERNEL::INTEGER-/-INTEGER 1 0)
-    1: (/ 1 0)
-    2: (FOO)
-    3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (FOO) #<NULL-LEXENV>)
-    4: (EVAL (FOO))
-    5: (INTERACTIVE-EVAL (FOO) :EVAL NIL)
-    6: (SB-IMPL::REPL-FUN NIL)
-    7: ((LAMBDA NIL :IN SB-IMPL::TOPLEVEL-REPL))
-    8: (SB-IMPL::%WITH-REBOUND-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-IMPL::TOPLEVEL-REPL) {1004A790FB}>)
-    9: (SB-IMPL::TOPLEVEL-REPL NIL)
-    10: (SB-IMPL::TOPLEVEL-INIT)
-    11: ((FLET #:WITHOUT-INTERRUPTS-BODY-86 :IN SAVE-LISP-AND-DIE))
-    12: ((LABELS SB-IMPL::RESTART-LISP :IN SAVE-LISP-AND-DIE))
-
-Notice how it actually warns me *at compile time* about the error, whereas
-Clojure merrily compiles it without a peep.  Also notice how the SBCL backtrace
-gives me actual forms and arguments, instead of a line number (which is probably
-inaccurate if you've been editing and eval'ing a file piecemeal).
-
-### Old Bugs
-
-Running into [four-year old bugs][clj-700] was fun.
-
-### RIP Your Heap
-
-Clojure's data structures and STM system make it pretty easy to write code that
-both:
-
-* Runs correctly
-* Generates enormous mountains of garbage
-
-This can be a good or bad thing, depending on how you look at it and what your
-needs are.
-
-Common Lisp has immutable data structures (via fset) and STM if you want them,
-but it also lets you use efficient mutable things just as easily if you want.
-It doesn't really encourage one specific way of doing things.
-
-[clj-700]: http://dev.clojure.org/jira/browse/CLJ-700
-
-## Conclusion
-
-Ludum Dare 34 was a lot of fun.  I'm definitely going to mark my calendar and do
-the next one too.
-
-If making a game sounds interesting, you should do it too!  You don't need a ton
-of programming experience, artistic skills, or anything but a love of video
-games and a free weekend.  Get out there and make a game!
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2015/12/ludum-dare-34.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,497 @@
++++
+title = "Ludum Dare 34 Postmortem"
+snip = 'I made a "game"!'
+date = 2015-12-15T16:30:00Z
+draft = false
+
++++
+
+This past weekend was [Ludum Dare 34][].  Ludum Dare is a thrice-a-year event
+where a theme is chosen and people have 48 hours (for the competition) or 72
+hours (for the "casual" jam) to create a game based on a theme.
+
+I actually managed to have some free time for a change, so I decided to give it
+a go.  I've got a lot of experience programming and a little bit in "sprinting"
+like this (my team [placed second in Django Dash][Django Dash] a few years ago),
+but I haven't made very many games.  Still, by the end of the jam I managed to
+make something that's not quite a game but *is* pretty fun to play around with.
+I figured I'd write about the process while it's all still fresh in my mind.
+
+[Ludum Dare 34]: http://ludumdare.com/compo/
+[Django Dash]: http://djangodash.com/judging/c2/results/team/49/
+
+{{% toc %}}
+
+## My Game
+
+The theme this year was actually *tied* in voting, so there were two:
+
+* Growing
+* Two Button Controls
+
+### Language & Code
+
+I knew going in that I wanted to make something with ASCII graphics with Clojure
+and [clojure-lanterna][].  Once I thought about the themes I decided to make
+a simulation of a world with plants and animals.  I settled on the name "Silt"
+(the stuff at the bottom of riverbeds that slowly accumulates and reshapes the
+world) and got to work.
+
+You can get the source for the game [on BitBucket][bitbucket].  There's also
+a mirror on GitHub if you prefer git.
+
+### Play
+
+There's a prebuilt jar file [on BitBucket][bitbucket] if you want to play the
+game on your computer.
+
+If you don't want to run some random code on your machine, I understand.  I've
+spun up a server you can telnet into to play:
+
+    telnet silt.stevelosh.com
+
+For best results use a terminal with a dark background.  If there are a bunch of
+people playing the server may be slow, or fail entirely with out-of-memory
+errors.  Sorry, it's just an 8gb Linode I'm funding out of my own pocket.
+
+### Gameplay
+
+You are the god of a [toroidal][] world.  Initially it's inhabited by a small
+population of four hundred and one creatures.  Time ticks by at a few ticks per
+second.
+
+[![Silt Initial World](/media/images/blog/2015/12/silt-initial.gif)](/media/images/blog/2015/12/silt-initial.gif)
+
+The creatures need energy to survive.  They can get energy by eating fruit from
+shrubs or being near water.
+
+If a creature has enough energy it might reproduce by splitting off a clone of
+itself.  The clone will be identical to its parent (sibling?), though there is
+a slight chance of mutation.
+
+The ideal body temperature for a creature is 0 degrees.  The world starts at
+that temperature, creating a paradise.  As the god of the world, the only way
+you can interact with it is to increase or decrease the temperature.
+
+If the temperature of the world is different than the temperature of a creature,
+they will need to spend more energy to maintain their body heat.  This makes it
+more difficult to survive.  Swinging the temperature in large increments quickly
+is a sure way to kill off the population.
+
+The creatures are not entirely at the mercy of the climate, however.  Creatures
+have an "insulation" score that represents fur or skin.  More insulation
+protects the creature from the outside climate, at the expense of a small amount
+of energy.
+
+The mechanics of temperature/insulation and reproduction/mutation interact to
+cause evolution.  If you slowly increase the temperature of the world over a few
+thousand ticks, children with more insulation are more likely to survive, and so
+your creatures will tend to evolve more insulation over time.
+
+Creatures' movement patterns are also affected by mutation.  Over time your
+creatures will likely evolve to wander instead of staying stationary, because
+fruit takes time to grow and so it's more effective to keep moving and
+gathering.
+
+Creatures can also change their colors and glyphs through mutation, but this is
+much rarer.  After letting the game run for a while you'll probably notice
+"gangs" of creatures with similar characteristics, all descended from a single
+parent.
+
+[![Silt Later World](/media/images/blog/2015/12/silt-later.gif)](/media/images/blog/2015/12/silt-later.gif)
+
+Finally, there are eight mysterious objects scattered throughout the landscape.
+Each one does something, but discovering exactly *what* will be difficult
+(unless you read the source).
+
+### Controls
+
+The controls are pretty basic:
+
+* **`arrow keys`** to move your view of the world.
+* **`R`** to reset the world.
+* **`escape`** to quit the game.
+
+Put your cursor over a creature to see their stats:
+
+* **`hjkl`** or **`wasd`** to move your cursor.
+
+The world ticks along, but you can freeze time:
+
+* **`space`** to pause/unpause time.
+
+Those are the basic controls.  To actually *interact* with the world you have
+only two options (in accordance with the "Two Button Controls" theme):
+
+* **`+`** to make the world one degree hotter.
+* **`-`** to make the world one degree colder.
+
+[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna
+[bitbucket]: https://bitbucket.org/sjl/silt
+[toroidal]: https://en.wikipedia.org/wiki/Torus
+
+## Good Choices
+
+I managed to make a working, fairly interesting game within the time limit, so
+I'm pretty happy with most of my choices.
+
+### Familiar Environment
+
+I decided to make Silt in Clojure.  If you follow me on [Twitch][] you might
+have noticed I've been getting more into Common Lisp these days.  I don't really
+like writing in Clojure any more, but I used it for the jam because I wanted an
+environment I was familiar with.
+
+This was a good decision.  I wouldn't have finished if I tried to use Common
+Lisp — I'd probably still be struggling with whatever its Curses library is.
+
+A 72-hour jam is not the time to be trying out a new language or framework
+you've never used before if you want to have a finished product at the end.
+Pick something you know well so you don't spend 30% of your time trying to
+Google things.
+
+[Twitch]: http://twitch.tv/stevelosh
+
+### Streaming and Talking
+
+I streamed a bit of the coding process a couple times over the weekend (look in
+past broadcasts and they might still be there).  I didn't have a ton of viewers,
+but it was good to talk things out.  Sometimes the stream was my [rubber duck][]
+and it helped a bunch.
+
+[rubber duck]: https://en.wikipedia.org/wiki/Rubber_duck_debugging
+
+### Releasing Before the End
+
+Ludum Dare ends at a certain time, but there's a "release hour" afterword when
+you can take an hour to package up the final version of your game.  I think it's
+better if you don't leave it until then to run through your packaging/release
+process at least once, though.  Once I had the game in a runnable (if not yet
+very fun) state, I made it into a jar to make sure that everything works.
+
+You don't want to find out your build
+process is fucked when you only have 40 minutes left, so do a dry run early and
+discover any snags while you have lots of time to fix them.
+
+### Getting Feedback
+
+Once I had a playable game I asked my friend [Hafdís][] to see if it would run
+on Windows.  Luckily it did — Java and Lanterna are pretty nicely
+cross-platform.
+
+She ran the game in the background for a while and showed me the results later.
+It's really helpful to get a second opinion about your game (or website or
+whatever you're making) as you're working on it.  It's too easy to get too close
+to your own game and not realize what's fun or painful about it any more.
+
+Asking in the IRC channel can work, but generally everyone there is busy working
+on their own games so you won't get a ton of takers.  You can ask someone
+online, but I think in-person is better if at all possible.  Seeing someone else
+enjoy something you've made is a big morale boost, which can be important when
+you're dealing with tricky bugs later.
+
+[Hafdís]: http://havethis.info/
+
+### Profiling and Performance
+
+During the last day I spent an hour or so using a profiler to identify the
+hottest spots in the code and improving performance.  I didn't focus too much on
+speed, but a little bit of attention can go a long way.
+
+### Ruthless Simplicity
+
+One of the main reasons I managed to finish despite my lack of experience making
+games was being ruthless about making the game as simple as possible.  I have
+a ton of ideas that I could potentially do, but cramming them all into the game
+would take far too long and would probably create a giant mess.
+
+Focusing on one core mechanic (temperature) and building the things that
+interact with it got me pretty far.  The fact that the theme was "Two Button
+Controls" really helped me a lot with this, because it forced me to come up with
+a mechanic simple enough to encode in two buttons.
+
+### Sleeping
+
+I was hanging out in the official IRC channel over the weekend and noticed
+a bunch of people talking about how tired they were and how little sleep they
+were getting.
+
+Because the time frame is so short there's a tendency to want to stay awake for
+as much time as possible to use as many hours as you can.  I think this is
+usually a mistake.  During this weekend, and also for the Django Dash weekend,
+I stuck to my normal sleeping/waking schedule and I think it was the right
+choice.  You may get *more* hours of work in if you don't sleep, but you get
+*better* hours of work if you're rested, fed, and showered.
+
+This is especially tricky if your timezone is offset with the event.  The themes
+were announced at 2 AM my time, and while I would have loved to be awake and
+dive in right away I chose to go to sleep instead and just get started the next
+day.  A screwed up sleep schedule is almost as bad as not enough sleep (for me
+at least).
+
+## Bad Choices
+
+I made a few mistakes along the way too (luckily none of them prevented me from
+finishing).
+
+### Clinging to Failed Mechanics
+
+One of the first mechanics I added to the game was aging — creatures would age
+over time and eventually die of old age.  Immediately I had trouble balancing
+this against reproduction to avoid population explosions and extinctions, but
+I stuck with it for quite a while trying to make it work.
+
+Eventually I tore the entire aging mechanic out and replaced it with hunger,
+which ended up working far, far better.  In hindsight I should have abandoned
+aging much sooner, as soon as it was obvious that it was making things painful
+and unfun.
+
+### Last-Minute Additions
+
+I added a couple of mysterious objects right before I packaged up the final
+version of the game and I didn't have time to playtest them very much.  I tested
+that they didn't crash the game, but I assumed their effects would be minor
+curiosities and didn't worry too much.
+
+Now that I've tested it a bit more, they have a bigger effect than I thought
+and drastically affect the world.  I should have either tested them more or held
+off on them until I had time to test.
+
+### Working Alone
+
+This one was unavoidable for me this time, but I'm sure Silt could have been
+a lot more interesting if I had worked with another programmer, an artist, or
+a sound designer.
+
+## Clojure
+
+I'll end with a few notes on the experience of writing Silt in Clojure.  Like
+I said earlier: I don't particularly like Clojure any more, but it was familiar
+so I ran with it.  After doing a bunch of Common Lisp lately a few things jumped
+out at me about writing in Clojure, so I wanted to get them down on paper before
+I forget.
+
+### Destructuring is Nice
+
+Clojure's ubiquitous destructuring is really nice.  Common Lisp has
+`destructuring-bind` but it's not as powerful as it is in Clojure, and it's
+certainly not threaded through the language nearly as much.
+
+Destructuring in function arguments is *really* handy — I almost want to write
+a `defun-destructured` macro that will let me do it in CL.
+
+### Fewer Superfluous Parentheses
+
+In Clojure's syntax there seems to be a general theme of using fewer
+parentheses.  I don't just mean using brackets and curly braces for other
+literals either.  Take the humble `let` in Clojure:
+
+```text
+(let [x (foo)
+      y (bar)]
+  (+ x y))
+```
+
+If you translate the vector literal to a Common Lisp list, it would look like
+this:
+
+```text
+(let (x (foo)
+      y (bar))
+  (+ x y))
+```
+
+But Common Lisp actually makes you surround the binding pairs with *another* set
+of parentheses:
+
+```text
+(let ((x (foo))
+      (y (bar)))
+  (+ x y))
+```
+
+This is annoying.  There are always going to be pairs of binding forms, why do
+I need to wrap them in extra parens?  Clojure's way is cleaner.
+
+### The Tooling is Good
+
+Jvisualvm's statistical profiler is a bit homely, but it gets the job done.
+It's nice to have mature tools to introspect what your code is doing at runtime.
+
+`lein uberjar` just worked and produced a jar that runs fine on Windows and OS
+X.  This was a great relief.  I haven't looked at packaging up a Common Lisp app
+but I am not optimistic.
+
+### But the Compiler Is Not Helpful
+
+SBCL warns me when I'm doing something stupid:
+
+```lisp
+CL-USER> (defun square (x) (* x x))
+
+SQUARE
+CL-USER> (defun bad (x y)
+(+ x (square y y)))
+; in: DEFUN BAD
+;     (SQUARE Y Y)
+;
+; caught STYLE-WARNING:
+;   The function was called with two arguments, but wants exactly one.
+;
+; compilation unit finished
+;   caught 1 STYLE-WARNING condition
+
+BAD
+CL-USER>
+```
+
+Clojure happily lets me be stupid without a peep:
+
+```clojure
+user=> (defn square [x] (* x x))
+#'user/square
+user=> (defn bad [x y]
+  #_=> (+ x (square y y)))
+#'user/bad
+user=>
+```
+
+I'm often stupid, so I prefer a compiler that helps prevent it.
+
+### Errors are Still Terrible
+
+Clojure stack traces have historically been awful.  When I ran into my first
+error this time I noticed that the stack trace was... nonexistent?
+
+```clojure
+user=> (defn foo [] (/ 1 0))
+#'user/foo
+user=> (foo)
+
+ArithmeticException Divide by zero  clojure.lang.Numbers.divide (Numbers.java:158)
+user=>
+```
+
+I guess they got tired of people complaining about how the stack traces look
+like shit, so they just... removed them?  You can get them back with a bit of
+work:
+
+```clojure
+user=> (use '[clojure.stacktrace :only [print-stack-trace]])
+user=> (print-stack-trace *e)
+java.lang.ArithmeticException: Divide by zero
+ at clojure.lang.Numbers.divide (Numbers.java:158)
+    clojure.lang.Numbers.divide (Numbers.java:3808)
+    user$foo.invoke (form-init5869611501548592997.clj:1)
+    user$eval1219.invoke (form-init5869611501548592997.clj:1)
+    clojure.lang.Compiler.eval (Compiler.java:6782)
+    clojure.lang.Compiler.eval (Compiler.java:6745)
+    clojure.core$eval.invoke (core.clj:3081)
+    clojure.main$repl$read_eval_print__7099$fn__7102.invoke (main.clj:240)
+    clojure.main$repl$read_eval_print__7099.invoke (main.clj:240)
+    clojure.main$repl$fn__7108.invoke (main.clj:258)
+    clojure.main$repl.doInvoke (main.clj:258)
+    clojure.lang.RestFn.invoke (RestFn.java:1523)
+    clojure.tools.nrepl.middleware.interruptible_eval$evaluate$fn__623.invoke (interruptible_eval.clj:58)
+    clojure.lang.AFn.applyToHelper (AFn.java:152)
+    clojure.lang.AFn.applyTo (AFn.java:144)
+    clojure.core$apply.invoke (core.clj:630)
+    clojure.core$with_bindings_STAR_.doInvoke (core.clj:1868)
+    clojure.lang.RestFn.invoke (RestFn.java:425)
+    clojure.tools.nrepl.middleware.interruptible_eval$evaluate.invoke (interruptible_eval.clj:56)
+    clojure.tools.nrepl.middleware.interruptible_eval$interruptible_eval$fn__665$fn__668.invoke (interruptible_eval.clj:191)
+    clojure.tools.nrepl.middleware.interruptible_eval$run_next$fn__660.invoke (interruptible_eval.clj:159)
+    clojure.lang.AFn.run (AFn.java:22)
+    java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
+    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
+    java.lang.Thread.run (Thread.java:745)
+```
+
+Oh yeah, *there's* the garbagepile I remember.
+
+Lisp also hides the traceback at first, but it's easier to get at, and once you
+do it's actually *helpful*:
+
+```lisp
+CL-USER> (declaim (optimize (debug 3)))
+
+NIL
+CL-USER> (defun foo () (/ 1 0))
+; in: DEFUN FOO
+;     (/ 1 0)
+;
+; caught STYLE-WARNING:
+;   Lisp error during constant folding:
+;   arithmetic error DIVISION-BY-ZERO signalled
+;   Operation was /, operands (1 0).
+;
+; compilation unit finished
+;   caught 1 STYLE-WARNING condition
+
+FOO
+CL-USER> (foo)
+
+debugger invoked on a DIVISION-BY-ZERO in thread
+#<THREAD "main thread" RUNNING {1002C74703}>:
+  arithmetic error DIVISION-BY-ZERO signalled
+Operation was /, operands (1 0).
+
+Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
+
+restarts (invokable by number or by possibly-abbreviated name):
+  0: [ABORT] Exit debugger, returning to top level.
+
+(SB-KERNEL::INTEGER-/-INTEGER 1 0)
+0] backtrace
+
+Backtrace for: #<SB-THREAD:THREAD "main thread" RUNNING {1002C74703}>
+0: (SB-KERNEL::INTEGER-/-INTEGER 1 0)
+1: (/ 1 0)
+2: (FOO)
+3: (SB-INT:SIMPLE-EVAL-IN-LEXENV (FOO) #<NULL-LEXENV>)
+4: (EVAL (FOO))
+5: (INTERACTIVE-EVAL (FOO) :EVAL NIL)
+6: (SB-IMPL::REPL-FUN NIL)
+7: ((LAMBDA NIL :IN SB-IMPL::TOPLEVEL-REPL))
+8: (SB-IMPL::%WITH-REBOUND-IO-SYNTAX #<CLOSURE (LAMBDA NIL :IN SB-IMPL::TOPLEVEL-REPL) {1004A790FB}>)
+9: (SB-IMPL::TOPLEVEL-REPL NIL)
+10: (SB-IMPL::TOPLEVEL-INIT)
+11: ((FLET #:WITHOUT-INTERRUPTS-BODY-86 :IN SAVE-LISP-AND-DIE))
+12: ((LABELS SB-IMPL::RESTART-LISP :IN SAVE-LISP-AND-DIE))
+```
+
+Notice how it actually warns me *at compile time* about the error, whereas
+Clojure merrily compiles it without a peep.  Also notice how the SBCL backtrace
+gives me actual forms and arguments, instead of a line number (which is probably
+inaccurate if you've been editing and eval'ing a file piecemeal).
+
+### Old Bugs
+
+Running into [four-year old bugs][clj-700] was fun.
+
+### RIP Your Heap
+
+Clojure's data structures and STM system make it pretty easy to write code that
+both:
+
+* Runs correctly
+* Generates enormous mountains of garbage
+
+This can be a good or bad thing, depending on how you look at it and what your
+needs are.
+
+Common Lisp has immutable data structures (via fset) and STM if you want them,
+but it also lets you use efficient mutable things just as easily if you want.
+It doesn't really encourage one specific way of doing things.
+
+[clj-700]: http://dev.clojure.org/jira/browse/CLJ-700
+
+## Conclusion
+
+Ludum Dare 34 was a lot of fun.  I'm definitely going to mark my calendar and do
+the next one too.
+
+If making a game sounds interesting, you should do it too!  You don't need a ton
+of programming experience, artistic skills, or anything but a love of video
+games and a free weekend.  Get out there and make a game!
+
--- a/content/blog/2015/12/permutation-patterns.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,349 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% load mathjax %}
-
-    {% hyde
-        title: "What the Hell are Permutation Patterns?"
-        snip: "A short introduction."
-        created: 2015-12-10 19:55:00
-    %}
-
-    {% block article %}
-
-I'm currently in the Mathematical Programming class at Reykjavík University and
-we're working with permutations and patterns.  They're really simple to
-understand once they're explained to you, but after searching around online
-I haven't found a nice explanation for humans, so here you go.
-
-None of this is new research, I just want to summarize things so other people
-can understand it without having to shovel through the internet trying to piece
-together a bunch of terse definitions.  All of this is covered in more detail on
-Wikipedia, as well as in [Combinatorics of Permutations][book] by Miklós Bóna
-(and many other places).
-
-[book]: http://www.amazon.com/dp/1439850518/?tag=stelos-20
-
-[TOC]
-
-## Permutations (Non-Mathy)
-
-If you've used permutations in a programming language you can probably skip this
-section.
-
-If you're interested in programming and/or math you've probably heard the term
-"permutations" before.  It's typically explained to be something like "different
-ways to order a collection of objects".
-
-The key word here is "order" -- permutations are all about ordering.
-
-### Basics
-
-Let's look at an example.  If you have a list of three cats:
-
-* Scruffy
-* Boots
-* Patches
-
-How many different ways can you list them out?  Order matters, and you're also
-not allowed to repeat a cat (no cloning here).
-
-    1         2         3         4         5         6
-    Scruffy   Scruffy   Patches   Patches   Boots     Boots
-    Boots     Patches   Scruffy   Boots     Scruffy   Patches
-    Patches   Boots     Boots     Scruffy   Patches   Scruffy
-
-
-So there are six permutations.  Simple enough.  Let's think about the edge
-cases.  How many ways can you permute one cat?  Just one:
-
-    1
-    Scruffy
-
-Something a bit tougher: how many ways can you permute *zero* cats?  This seems
-a bit weird, but if you phrase it as "how many ways can you order a list of zero
-objects" you can convince yourself the answer is one as well (the single
-permutation is "the empty list").
-
-We don't want to have to count out the number of permutations by hand every
-time, so it would be nice to have a formula.  If we have a list of *n* things,
-how many different permutations can we come up with?
-
-We can start by filling the first slot with any item we want, so we have \\(n\\)
-options.  Then for each of those choices we pick something to go in the next
-slot from the \\(n - 1\\) things that are left.  We can keep going all the way
-down until we're at the last slot, by which point we've only got one thing left,
-so we get:
-
-{% filter mathjax %}
-    (n)(n - 1)(n - 2)...(1)
-{% endfilter %}
-
-Which is just the [factorial][] of \\(n\\).  For our three cats we have:
-
-{% filter mathjax %}
-    (3)(3 - 1)(3 - 2) = 3 \cdot 2 \cdot 1 = 6
-{% endfilter %}
-
-So now we know that:
-
-{% filter mathjax %}
-    \operatorname{number-of-permutations}(\mathit{items}) =
-    \mathit{items}!
-{% endfilter %}
-
-[factorial]: https://en.wikipedia.org/wiki/Factorial
-
-### Restricting Slots
-
-Things start to get more interesting when we start to restrict the number of
-slots.  For example, we can ask "how many different lists of three items can we
-take from a group of five items?"
-
-I'm going to stop using cat names now because it's getting painful to type, so
-let's just use letters.  Our five items will be:
-
-    a, b, c, d, e
-
-How many different three-length lists can we produce?
-
-    (a, b, c) (a, b, d) (a, b, e) (a, c, b) (a, c, d) (a, c, e)
-    (a, d, b) (a, d, c) (a, d, e) (a, e, b) (a, e, c) (a, e, d)
-
-    (b, a, c) (b, a, d) (b, a, e) (b, c, a) (b, c, d) (b, c, e)
-    (b, d, a) (b, d, c) (b, d, e) (b, e, a) (b, e, c) (b, e, d)
-
-    (c, a, b) (c, a, d) (c, a, e) (c, b, a) (c, b, d) (c, b, e)
-    (c, d, a) (c, d, b) (c, d, e) (c, e, a) (c, e, b) (c, e, d)
-
-    (d, a, b) (d, a, c) (d, a, e) (d, b, a) (d, b, c) (d, b, e)
-    (d, c, a) (d, c, b) (d, c, e) (d, e, a) (d, e, b) (d, e, c)
-
-    (e, a, b) (e, a, c) (e, a, d) (e, b, a) (e, b, c) (e, b, d)
-    (e, c, a) (e, c, b) (e, c, d) (e, d, a) (e, d, b) (e, d, c)
-
-You can see how working with numerical formulas would be a lot nicer than
-listing all those out by hand and counting them.  The formula to tell us the
-number is:
-
-{% filter mathjax %}
-    \operatorname{number-of-permutations}(\mathit{items}, \mathit{slots}) =
-    \frac
-    {\mathit{items}!}
-    {(\mathit{items} - \mathit{slots})!}
-{% endfilter %}
-
-So in this example we have:
-
-{% filter mathjax %}
-    \frac
-    {\mathit{items}!}
-    {(\mathit{items} - \mathit{slots})!}
-    =
-    \frac{5!}{(5 - 3)!} =
-    \frac{5!}{2!} =
-    \frac{5 \cdot 4 \cdot 3 \cdot 2 \cdot 1}{2 \cdot 1} =
-    \frac{120}{2} =
-    60
-{% endfilter %}
-
-Which is correct (feel free to count them by hand if you're skeptical).
-
-This formula continues to work when the number slots is equal to the number of
-elements (like in our cat example).  If \\(n = slots = items\\) then:
-
-{% filter mathjax %}
-    \frac
-    {\mathit{items}!}
-    {(\mathit{items} - \mathit{slots})!}
-    =
-    \frac
-    {\mathit{n}!}
-    {(\mathit{n} - \mathit{n})!}
-    =
-    \frac
-    {\mathit{n}!}
-    {0!}
-    =
-    \frac
-    {\mathit{n}!}
-    {1}
-    =
-    \mathit{n}!
-{% endfilter %}
-
-Remember that \\(0!\\) is 1, not 0 as you might first expect.  Feel free to plug
-in the edge cases we talked about before (zero- and one-length permutations) and
-make sure they work.
-
-## Permutations (Mathy)
-
-That was a pretty standard introduction to permutations, and it's about as far
-as most basic programming/math books go at first (they'll also talk about
-"combinations", which are something else that we don't care about right now).
-But if we want to start looking at permutations more closely we need to add
-a few additional rules.
-
-So far we've been talking about permutations of arbitrary objects, like cats,
-letters, or playing cards.  From here on out we're going to restrict ourselves
-a bit more: we'll only consider lists of positive integers.  This is important
-because integers can be compared.  We can't say that Scruffy is "less than" or
-"greater than" Boots, but we *can* say that 15 is less than 16.
-
-Notice that we're not including the number zero.  When we say "show me all
-standard permutations of length 3" we mean:
-
-    1 2 3
-    1 3 2
-    2 1 3
-    2 3 1
-    3 1 1
-    3 2 1
-
-Sorry programmers, permutation people like to count from one.
-
-You'll notice that I wrote out the permutations above each on their own line,
-with the numbers just listed out.  This is called "one-line notation".
-Sometimes people drop the spaces in between the numbers (e.g. `1 2 3` becomes
-`123`) if all the numbers are single digits and they feel like being annoying.
-
-There's also a "two-line notation" that we won't use here, check out the
-Wikipedia page at the end of the post for more.
-
-### Standard/Classical Permutations
-
-Another term we'll use is "standard permutations" or "classical patterns" (don't
-worry about the word "patterns" too much yet).  This just means they contain all
-the numbers 1 to \\(n\\) with no missing numbers.  So `3 2 4 1` is a standard
-permutation (of length 4), but `1 902 23232 5` is not.
-
-### Subwords/Subsequences
-
-One more bit of terminology before we get to the meat of the post.  A "subword"
-of a permutation is all the different lists we can get by dropping none, some,
-or all of the items, *without changing the order*.  For example, the sublists of
-`9 3 1 4` are:
-
-    dropping no items
-    (9 3 1 4)
-
-    dropping one item
-    (  3 1 4)
-    (9   1 4)
-    (9 3   4)
-    (9 3 1  )
-
-    dropping two items
-    (    1 4)
-    (9     4)
-    (9 3    )
-    (  3   4)
-    (9   1  )
-    (  3 1  )
-
-    dropping three items
-    (9      )
-    (  3    )
-    (    1  )
-    (      4)
-
-    dropping four items
-    (       )
-
-You will also hear these called "subsequences", but this is way too confusing
-because `subsequence` in a programming language almost always means
-a *consecutive* portion of a list, so I'm going to stick with "subwords".
-
-## Permutation Patterns
-
-Hold onto your hats, things are about to get intense.
-
-We say that one permutation X **contains** another permutation Y if one of the
-subwords of X has **the same length and relative order** as Y.  I know that's
-confusing and not at all clear, so let's take an example.
-
-Let X be the permutation `1 4 3 2`.  Let Y be `1 2`.  Does X contain Y?
-
-If we look at Y's elements, we see that it starts with the lowest element and
-then goes to the highest element.  Is there some subword of X, of length 2, that
-does the same thing?  Sure: `1 4` is a subword of X, has length 2, and starts at
-the lowest element then goes to the highest.
-
-Note that our subword has a `4` in it, but Y only has `1` and `2`.  This is the
-most confusing part about permutation patterns: we don't care about the actual
-numbers themselves -- we only care about the relationships between the numbers.
-
-Another example.  Let X be `1 4 3 2`.  Let Y be `2 1`.  Does X contain Y? Try
-this one on your own before reading on.
-
-Y is still two elements long, but now it starts at the highest element and goes
-the lowest.  The subword we used in the last example (`1 4`) doesn't work here,
-because it starts low and goes high (the opposite of what we want).  But `4 3`
-is another subword of X, and that *does* match, so X does contain Y.  Note that
-`4 2` would also fit here (remember: subwords don't have to be consecutive!).
-
-Let's try something more interesting.  Let X still be `1 4 3 2`, but let's make
-Y `1 2 3`.  Does X contain Y?
-
-This one is a little trickier.  The order of Y is that it starts at the lowest
-element, then it goes to the middle one, then finally it goes to the highest
-element.  Let's look at the subwords of X that are length 3:
-
-    1 4 3
-    1 4 2
-    1 3 2
-    4 3 2
-
-Do any of those have the same relative ordering as Y?  No!  None of them start
-at the lowest, go to the middle, then go to the highest.  So this time X does
-not contain Y, so we say that X **avoids** Y.
-
-## So What?
-
-So now that we know what "X contains Y" and "X avoids Y" mean, what can we use
-this stuff for?  I'm not an expert, but I can give you a few examples to whet
-your apetite.
-
-Consider a permutation X that avoids `2 1`.  What might X look like?
-
-Well the empty permutation and any permutation with only one element certainly
-avoid `2 1` (they don't have any subwords of the correct length at all).  What
-about longer ones?
-
-If X avoids `2 1`, then for any two elements in it, the leftmost element must be
-smaller than the rightmost one (otherwise it would *contain* `2 1`).  This means
-that all the elements must be getting bigger as you go to the right, or to put
-it another way: the permutation must be in sorted order!
-
-Similarly, if X avoids `1 2` then it must be in *reverse* sorted order.  Poke at
-this for a minute and convince yourself it must be true.  Make sure to consider
-edge cases like the empty permutation and single-element permutations.
-
-Another example comes from Knuth: if a permutation contains `2 3 1` it cannot be
-sorted by a stack in a single pass.  Remember: the numbers in the matching
-subword don't have to be consecutive, and they don't have to match the exact
-numerals, only the relative order matters.  `66 1 99 2 33` contains `2 3 1`
-because the subword `66 99 33` has the same relative order (and so `66 1 99
-2 33` cannot be sorted by a stack in a single pass).  This is probably not
-intuitively obvious, so for further explanation check out Wikipedia, or [this
-paper][paper] coincidentally by my professor, or even Knuth's [book][taocp]
-itself.
-
-[paper]: http://www.dmtcs.org/pdfpapers/dmAR0153.pdf
-[taocp]: http://www.amazon.com/dp/0201896834/?tag=stelos-20
-
-## Further Information
-
-This was a really quick introduction.  I glossed over a bunch of things (like
-defining a permutation as a mapping of elements of a set to themselves, the
-identity permutation, etc).  If you want to dive in more, you can check out
-Wikipedia:
-
-* [Permutations](https://en.wikipedia.org/wiki/Permutation)
-* [Permutation Patterns](https://en.wikipedia.org/wiki/Permutation_pattern)
-
-Or go all-in and grab a copy of [Combinatorics of Permutations][book].
-
-I'm also planning on doing another post like this about mesh patterns, which are
-a slightly more general/powerful version of these basic patterns.
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2015/12/permutation-patterns.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,344 @@
++++
+title = "What the Hell are Permutation Patterns?"
+snip = "A short introduction."
+date = 2015-12-10T19:55:00Z
+draft = false
+
++++
+
+I'm currently in the Mathematical Programming class at Reykjavík University and
+we're working with permutations and patterns.  They're really simple to
+understand once they're explained to you, but after searching around online
+I haven't found a nice explanation for humans, so here you go.
+
+None of this is new research, I just want to summarize things so other people
+can understand it without having to shovel through the internet trying to piece
+together a bunch of terse definitions.  All of this is covered in more detail on
+Wikipedia, as well as in [Combinatorics of Permutations][book] by Miklós Bóna
+(and many other places).
+
+[book]: http://www.amazon.com/dp/1439850518/?tag=stelos-20
+
+{{% toc %}}
+
+## Permutations (Non-Mathy)
+
+If you've used permutations in a programming language you can probably skip this
+section.
+
+If you're interested in programming and/or math you've probably heard the term
+"permutations" before.  It's typically explained to be something like "different
+ways to order a collection of objects".
+
+The key word here is "order" — permutations are all about ordering.
+
+### Basics
+
+Let's look at an example.  If you have a list of three cats:
+
+* Scruffy
+* Boots
+* Patches
+
+How many different ways can you list them out?  Order matters, and you're also
+not allowed to repeat a cat (no cloning here).
+
+    1         2         3         4         5         6
+    Scruffy   Scruffy   Patches   Patches   Boots     Boots
+    Boots     Patches   Scruffy   Boots     Scruffy   Patches
+    Patches   Boots     Boots     Scruffy   Patches   Scruffy
+
+
+So there are six permutations.  Simple enough.  Let's think about the edge
+cases.  How many ways can you permute one cat?  Just one:
+
+    1
+    Scruffy
+
+Something a bit tougher: how many ways can you permute *zero* cats?  This seems
+a bit weird, but if you phrase it as "how many ways can you order a list of zero
+objects" you can convince yourself the answer is one as well (the single
+permutation is "the empty list").
+
+We don't want to have to count out the number of permutations by hand every
+time, so it would be nice to have a formula.  If we have a list of *n* things,
+how many different permutations can we come up with?
+
+We can start by filling the first slot with any item we want, so we have \\(n\\)
+options.  Then for each of those choices we pick something to go in the next
+slot from the \\(n - 1\\) things that are left.  We can keep going all the way
+down until we're at the last slot, by which point we've only got one thing left,
+so we get:
+
+<div>$$
+    (n)(n - 1)(n - 2)...(1)
+$$</div>
+
+Which is just the [factorial][] of \\(n\\).  For our three cats we have:
+
+<div>$$
+    (3)(3 - 1)(3 - 2) = 3 \cdot 2 \cdot 1 = 6
+$$</div>
+
+So now we know that:
+
+<div>$$
+    \operatorname{number-of-permutations}(\mathit{items}) =
+    \mathit{items}!
+$$</div>
+
+[factorial]: https://en.wikipedia.org/wiki/Factorial
+
+### Restricting Slots
+
+Things start to get more interesting when we start to restrict the number of
+slots.  For example, we can ask "how many different lists of three items can we
+take from a group of five items?"
+
+I'm going to stop using cat names now because it's getting painful to type, so
+let's just use letters.  Our five items will be:
+
+    a, b, c, d, e
+
+How many different three-length lists can we produce?
+
+    (a, b, c) (a, b, d) (a, b, e) (a, c, b) (a, c, d) (a, c, e)
+    (a, d, b) (a, d, c) (a, d, e) (a, e, b) (a, e, c) (a, e, d)
+
+    (b, a, c) (b, a, d) (b, a, e) (b, c, a) (b, c, d) (b, c, e)
+    (b, d, a) (b, d, c) (b, d, e) (b, e, a) (b, e, c) (b, e, d)
+
+    (c, a, b) (c, a, d) (c, a, e) (c, b, a) (c, b, d) (c, b, e)
+    (c, d, a) (c, d, b) (c, d, e) (c, e, a) (c, e, b) (c, e, d)
+
+    (d, a, b) (d, a, c) (d, a, e) (d, b, a) (d, b, c) (d, b, e)
+    (d, c, a) (d, c, b) (d, c, e) (d, e, a) (d, e, b) (d, e, c)
+
+    (e, a, b) (e, a, c) (e, a, d) (e, b, a) (e, b, c) (e, b, d)
+    (e, c, a) (e, c, b) (e, c, d) (e, d, a) (e, d, b) (e, d, c)
+
+You can see how working with numerical formulas would be a lot nicer than
+listing all those out by hand and counting them.  The formula to tell us the
+number is:
+
+<div>$$
+    \operatorname{number-of-permutations}(\mathit{items}, \mathit{slots}) =
+    \frac
+    {\mathit{items}!}
+    {(\mathit{items} - \mathit{slots})!}
+$$</div>
+
+So in this example we have:
+
+<div>$$
+    \frac
+    {\mathit{items}!}
+    {(\mathit{items} - \mathit{slots})!}
+    =
+    \frac{5!}{(5 - 3)!} =
+    \frac{5!}{2!} =
+    \frac{5 \cdot 4 \cdot 3 \cdot 2 \cdot 1}{2 \cdot 1} =
+    \frac{120}{2} =
+    60
+$$</div>
+
+Which is correct (feel free to count them by hand if you're skeptical).
+
+This formula continues to work when the number slots is equal to the number of
+elements (like in our cat example).  If \\(n = slots = items\\) then:
+
+<div>$$
+    \frac
+    {\mathit{items}!}
+    {(\mathit{items} - \mathit{slots})!}
+    =
+    \frac
+    {\mathit{n}!}
+    {(\mathit{n} - \mathit{n})!}
+    =
+    \frac
+    {\mathit{n}!}
+    {0!}
+    =
+    \frac
+    {\mathit{n}!}
+    {1}
+    =
+    \mathit{n}!
+$$</div>
+
+Remember that \\(0!\\) is 1, not 0 as you might first expect.  Feel free to plug
+in the edge cases we talked about before (zero- and one-length permutations) and
+make sure they work.
+
+## Permutations (Mathy)
+
+That was a pretty standard introduction to permutations, and it's about as far
+as most basic programming/math books go at first (they'll also talk about
+"combinations", which are something else that we don't care about right now).
+But if we want to start looking at permutations more closely we need to add
+a few additional rules.
+
+So far we've been talking about permutations of arbitrary objects, like cats,
+letters, or playing cards.  From here on out we're going to restrict ourselves
+a bit more: we'll only consider lists of positive integers.  This is important
+because integers can be compared.  We can't say that Scruffy is "less than" or
+"greater than" Boots, but we *can* say that 15 is less than 16.
+
+Notice that we're not including the number zero.  When we say "show me all
+standard permutations of length 3" we mean:
+
+    1 2 3
+    1 3 2
+    2 1 3
+    2 3 1
+    3 1 1
+    3 2 1
+
+Sorry programmers, permutation people like to count from one.
+
+You'll notice that I wrote out the permutations above each on their own line,
+with the numbers just listed out.  This is called "one-line notation".
+Sometimes people drop the spaces in between the numbers (e.g. `1 2 3` becomes
+`123`) if all the numbers are single digits and they feel like being annoying.
+
+There's also a "two-line notation" that we won't use here, check out the
+Wikipedia page at the end of the post for more.
+
+### Standard/Classical Permutations
+
+Another term we'll use is "standard permutations" or "classical patterns" (don't
+worry about the word "patterns" too much yet).  This just means they contain all
+the numbers 1 to \\(n\\) with no missing numbers.  So `3 2 4 1` is a standard
+permutation (of length 4), but `1 902 23232 5` is not.
+
+### Subwords/Subsequences
+
+One more bit of terminology before we get to the meat of the post.  A "subword"
+of a permutation is all the different lists we can get by dropping none, some,
+or all of the items, *without changing the order*.  For example, the sublists of
+`9 3 1 4` are:
+
+    dropping no items
+    (9 3 1 4)
+
+    dropping one item
+    (  3 1 4)
+    (9   1 4)
+    (9 3   4)
+    (9 3 1  )
+
+    dropping two items
+    (    1 4)
+    (9     4)
+    (9 3    )
+    (  3   4)
+    (9   1  )
+    (  3 1  )
+
+    dropping three items
+    (9      )
+    (  3    )
+    (    1  )
+    (      4)
+
+    dropping four items
+    (       )
+
+You will also hear these called "subsequences", but this is way too confusing
+because `subsequence` in a programming language almost always means
+a *consecutive* portion of a list, so I'm going to stick with "subwords".
+
+## Permutation Patterns
+
+Hold onto your hats, things are about to get intense.
+
+We say that one permutation X **contains** another permutation Y if one of the
+subwords of X has **the same length and relative order** as Y.  I know that's
+confusing and not at all clear, so let's take an example.
+
+Let X be the permutation `1 4 3 2`.  Let Y be `1 2`.  Does X contain Y?
+
+If we look at Y's elements, we see that it starts with the lowest element and
+then goes to the highest element.  Is there some subword of X, of length 2, that
+does the same thing?  Sure: `1 4` is a subword of X, has length 2, and starts at
+the lowest element then goes to the highest.
+
+Note that our subword has a `4` in it, but Y only has `1` and `2`.  This is the
+most confusing part about permutation patterns: we don't care about the actual
+numbers themselves — we only care about the relationships between the numbers.
+
+Another example.  Let X be `1 4 3 2`.  Let Y be `2 1`.  Does X contain Y? Try
+this one on your own before reading on.
+
+Y is still two elements long, but now it starts at the highest element and goes
+the lowest.  The subword we used in the last example (`1 4`) doesn't work here,
+because it starts low and goes high (the opposite of what we want).  But `4 3`
+is another subword of X, and that *does* match, so X does contain Y.  Note that
+`4 2` would also fit here (remember: subwords don't have to be consecutive!).
+
+Let's try something more interesting.  Let X still be `1 4 3 2`, but let's make
+Y `1 2 3`.  Does X contain Y?
+
+This one is a little trickier.  The order of Y is that it starts at the lowest
+element, then it goes to the middle one, then finally it goes to the highest
+element.  Let's look at the subwords of X that are length 3:
+
+    1 4 3
+    1 4 2
+    1 3 2
+    4 3 2
+
+Do any of those have the same relative ordering as Y?  No!  None of them start
+at the lowest, go to the middle, then go to the highest.  So this time X does
+not contain Y, so we say that X **avoids** Y.
+
+## So What?
+
+So now that we know what "X contains Y" and "X avoids Y" mean, what can we use
+this stuff for?  I'm not an expert, but I can give you a few examples to whet
+your apetite.
+
+Consider a permutation X that avoids `2 1`.  What might X look like?
+
+Well the empty permutation and any permutation with only one element certainly
+avoid `2 1` (they don't have any subwords of the correct length at all).  What
+about longer ones?
+
+If X avoids `2 1`, then for any two elements in it, the leftmost element must be
+smaller than the rightmost one (otherwise it would *contain* `2 1`).  This means
+that all the elements must be getting bigger as you go to the right, or to put
+it another way: the permutation must be in sorted order!
+
+Similarly, if X avoids `1 2` then it must be in *reverse* sorted order.  Poke at
+this for a minute and convince yourself it must be true.  Make sure to consider
+edge cases like the empty permutation and single-element permutations.
+
+Another example comes from Knuth: if a permutation contains `2 3 1` it cannot be
+sorted by a stack in a single pass.  Remember: the numbers in the matching
+subword don't have to be consecutive, and they don't have to match the exact
+numerals, only the relative order matters.  `66 1 99 2 33` contains `2 3 1`
+because the subword `66 99 33` has the same relative order (and so `66 1 99
+2 33` cannot be sorted by a stack in a single pass).  This is probably not
+intuitively obvious, so for further explanation check out Wikipedia, or [this
+paper][paper] coincidentally by my professor, or even Knuth's [book][taocp]
+itself.
+
+[paper]: http://www.dmtcs.org/pdfpapers/dmAR0153.pdf
+[taocp]: http://www.amazon.com/dp/0201896834/?tag=stelos-20
+
+## Further Information
+
+This was a really quick introduction.  I glossed over a bunch of things (like
+defining a permutation as a mapping of elements of a set to themselves, the
+identity permutation, etc).  If you want to dive in more, you can check out
+Wikipedia:
+
+* [Permutations](https://en.wikipedia.org/wiki/Permutation)
+* [Permutation Patterns](https://en.wikipedia.org/wiki/Permutation_pattern)
+
+Or go all-in and grab a copy of [Combinatorics of Permutations][book].
+
+I'm also planning on doing another post like this about mesh patterns, which are
+a slightly more general/powerful version of these basic patterns.
+
--- a/content/blog/2016/02/midpoint-displacement.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,870 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% load mathjax %}
-
-    {% hyde
-        title: "Terrain Generation with Midpoint Displacement"
-        snip: "A first step toward growing worlds with computers."
-        created: 2016-02-19 19:45:00
-    %}
-
-    {% block extra_js %}
-        <script data-cfasync="false" src="/media/js/three.min.js"></script>
-        <script data-cfasync="false" src="/media/js/TrackballControls.js"></script>
-
-        <script data-cfasync="false" src="/media/js/terrain1.js"></script>
-    {% endblock extra_js %}
-
-    {% block article %}
-
-I'm taking the Game Engine Architecture class at Reykjavík University.  My group
-just finished our midterm [project][] where we played around with procedural
-terrain generation in [Unity][].  It was a lot of fun and I really enjoyed
-creating terrain out of numbers, so I thought I'd write up a little introduction
-to a few of the algorithms.
-
-In this post we'll be looking at Midpoint Displacement.
-
-The full series of posts so far:
-
-* [Midpoint Displacement](/blog/2016/02/midpoint-displacement/)
-* [Recursive Midpoint Displacement](/blog/2016/03/recursive-midpoint-displacement/)
-* [Diamond Square](/blog/2016/06/diamond-square/)
-
-[project]: https://www.youtube.com/watch?v=G5u79w4qiAA
-[Unity]: http://unity3d.com/
-
-[TOC]
-
-## Terrain Generation
-
-Procedural generation is a pretty big field. The [Wikipedia
-article][wikipedia-pg] gives a pretty brief overview.  The [Procedural Content
-Generation Wiki][pcg-wiki] is an entire wiki devoted to procedural generation.
-There's also a small but active [subreddit][r-pg] for interested folks.
-
-Today we're just going to look at a single algorithm for generating
-realistic-looking terrain called "Midpoint Displacement".  It's relatively
-simple (compared to other algorithms) but it produces terrain that actually
-looks kind of cool.
-
-[wikipedia-pg]: https://en.wikipedia.org/wiki/Procedural_generation
-[pcg-wiki]: http://pcg.wikidot.com/
-[r-pg]: https://www.reddit.com/r/proceduralgeneration/
-
-## Resources, Code, and Examples
-
-There are a lot of resources for learning how terrain generation algorithms
-work.  For midpoint displacement I used the [Wikipedia article][wikipedia-ds],
-the [PCG Wiki article][pcgw-midpoint], and academic papers like [this
-one][paper].
-
-Unfortunately, while there are a *lot* of places that describe algorithms like
-this, there are relatively few that explain it *thoroughly*.  Academic papers in
-particular tend to have a really bad case of
-[draw-the-rest-of-the-fucking-owl-syndrome][owl].  They tend to slap an equation
-or two on the page and move on without showing any code.
-
-As anyone who's done much programming knows, there's a big difference between
-saying something like "set the midpoints of the diamonds to the average of the
-corners" and making a computer actually *do* that.  How do we iterate over the
-array (row-major or column-major)?  Does it matter (yes: if you care about cache
-coherency)?  What about the edges where there are fewer corners?  How random
-(and how fast) is our random number generator (and how much do we care)?  How do
-we write all this code so we can actually read it six months later?
-
-So I'm going to try to do my part to improve the situation by not just
-describing the algorithm, but showing *actual code* that runs and generates
-a terrain.
-
-The full code is [here][code], but we'll be going through the important parts
-below.
-
-[wikipedia-ds]: https://en.wikipedia.org/wiki/Diamond-square_algorithm
-[pcgw-midpoint]: http://pcg.wikidot.com/pcg-algorithm:midpoint-displacement-algorithm
-[paper]: http://micsymposium.org/mics_2011_proceedings/mics2011_submission_30.pdf
-[owl]: https://i.imgur.com/RadSf.jpg
-[code]: https://bitbucket.org/sjl/stevelosh/src/default/media/js/terrain1.wisp
-
-### Wisp
-
-I'm using a language called [Wisp][wisp].  It's a small, Clojure-inspired
-dialect of Lisp that compiles down to vanilla Javascript.
-
-I went with Javascript because it means I can actually put demos inline in this
-post.  Sometimes it's so much easier to understand something when you can
-actually see it running.
-
-I've tried to write the code so that it's readable even if you don't know Lisp.
-The point of me showing you this code is not to give you something to copy and
-paste.  The point is that until you *actually write and run* the code, you don't
-know all the edge cases and problems that can happen.  So by making examples
-that actually run I feel a bit more confident that I'm explaining things enough.
-
-I haven't focused on performance at all.  If you want a fast implementation of
-this, you'll probably want to use a language with real arrays (i.e. contiguous
-chunks of memory holding a bunch of unboxed floats or integers).
-
-[wisp]: https://github.com/Gozala/wisp
-
-### Three.js
-
-[Three.js][three.js] is a Javascript library for 3D rendering.  I'm using it
-here to get something on the screen you can play with.  I'm not going to cover
-the code to put the terrains on the screen because it's really an entirely
-separate problem to *generating* the terrain, and it's mostly uninteresting
-boilerplate for these little demos.
-
-I haven't been able to get these demos working on my iPhone.  Sorry about that,
-but I'm not much of a frontend developer.  You'll have to use a computer to see
-them.  [Pull requests][slc] are welcome.
-
-[slc]: http://bitbucket.org/sjl/stevelosh/
-[three.js]: http://threejs.org/
-
-## Heightmaps
-
-Let's get started.  The main data structure we're going to be using is
-a [heightmap][].
-
-### Overview
-
-Heightmaps are essentially just big two-dimensional arrays of numbers in a given
-range that represent the height of the ground at a given point.  For example,
-a heightmap with a small "mountain" in the middle might look like:
-
-    :::text
-    [[0, 0, 2, 0, 0],
-     [0, 2, 5, 1, 0],
-     [2, 5, 9, 4, 1],
-     [0, 1, 4, 1, 0],
-     [0, 0, 1, 0, 0]]
-
-In practice, heightmaps are often represented as a single-dimensional array
-instead to ensure that all the data is together in one big hunk of memory:
-
-    :::text
-    [0, 0, 2, 0, 0,
-     0, 2, 5, 1, 0,
-     2, 5, 9, 4, 1,
-     0, 1, 4, 1, 0,
-     0, 0, 1, 0, 0]
-
-The type and range of the numbers in the map varies by program and programmer.
-Some programs use nonzero integers, some use all the integers, some use floating
-point, etc.
-
-The heightmaps in this post will contain floats from `0.0` to `1.0`.  I like
-using floats between zero and one because it's easy to roughly visualize them in
-your head (e.g. `0.1` is ten percent of the maximum height).
-
-One common way to visualize heightmaps is by turning them into greyscale images
-with one pixel per number, with black pixels for lowest value in the map's range
-and white for the highest.  The [Wikipedia article][heightmap] has an example of
-this.  This is handy because you can also write some code to *read* images, and
-then you can use any image editor to draw your own heightmaps by hand.
-
-We're going to visualize the heightmaps in 3D.  It's a lot more fun, and they
-start to actually look like real terrains.
-
-[heightmap]: https://en.wikipedia.org/wiki/Heightmap
-
-### Code
-
-We're going to start by writing a few functions that will hide away the internal
-details of how our heightmaps are implemented, so we can talk about them in
-nice high-level terms for the rest of the program.  We'll also need a couple of
-helper functions along the way.
-
-We'll start with something to create a heightmap:
-
-    :::clojure
-    (defn make-heightmap [exponent]
-      (let [resolution (+ 1 (Math.pow 2 exponent))]
-        (l (+ "Creating " resolution " by " resolution " heightmap..."))
-        (def heightmap
-          (new Array (* resolution resolution)))
-        (set! heightmap.resolution resolution)
-        (set! heightmap.exponent exponent)
-        (set! heightmap.last (- resolution 1))
-        (zero-heightmap heightmap)))
-
-`make-heightmap` takes an exponent and creates a heightmap.  For reasons that
-will become clear later, all of our heightmaps must be square, and they'll need
-to have \\(2^n + 1\\) rows and columns.  This means we can make heightmaps of
-sizes like 3x3, 5x5, 9x9, 17x17, 33x33, etc.  So our function just takes the
-\\(n\\) to use and creates a correctly-sized array.
-
-(If you've ever poked around with Unity's Terrain objects you might recognize
-these "powers of two plus one".)
-
-We create a new array (1-dimensional) and store a few pieces of extra data on it
-for later use.  `last` is the index of the last row/column, so for a 3x3 array
-it would be `2`.
-
-`l` is just a simple little logging function:
-
-    :::clojure
-    (defn l [v]
-      (console.log v))
-
-We'll need to zero out the heightmap as well:
-
-    :::clojure
-    (defn zero-heightmap [heightmap]
-      (do-times i heightmap.length
-        (set! (aget heightmap i) 0.0))
-      heightmap)
-
-`zero-heightmap` just iterates from `0` to `heightmap.length` and sets each
-element to `0.0`.  Wisp doesn't have syntax to loop from 0 to some number, but
-it's a Lisp, so we can make some:
-
-    :::clojure
-    (defmacro when [condition & body]
-      `(if ~condition
-         (do ~@body)))
-
-    (defmacro do-times [varname limit & body]
-      (let [end (gensym)]
-        `(let [~end ~limit]
-           (loop [~varname 0]
-             (when (< ~varname ~end)
-               ~@body
-               (recur (+ 1 ~varname)))))))
-
-If you're not a Lisp person, don't sweat this too much.  Just trust me that
-`(do-times i 10 (console.log i))` will print the numbers `0` to `9`.
-
-Now that we can create a heightmap, we'll probably want to be able to read its
-elements:
-
-    :::clojure
-    (defmacro heightmap-get [hm x y]
-      `(aget ~hm (+ (* ~y (.-resolution ~hm)) ~x)))
-
-    (defn heightmap-get-safe [hm x y]
-      (when (and (<= 0 x hm.last)
-                 (<= 0 y hm.last))
-        (heightmap-get hm x y)))
-
-`heightmap-get` handles the nasty business of translating our human-thinkable
-`x` and `y` coordinates into an index into the single-dimensional array.  It's
-not particularly fast (especially if the compiler won't inline it), but we're
-not worried about speed for this post.
-
-`heightmap-get-safe` is a version of `heightmap-get` that will do bounds
-checking for us and return `nil` if we ask for something out of range.
-Javascript will return `undefined` if you ask for a non-existent index, but
-because we're storing the array as one big line of data, using a `y` value
-that's too big will actually "wrap around" to the next row, so it's safer to
-just check it explicitly.
-
-Of course we'll also want to be able to set values in our heightmap:
-
-    :::clojure
-    (defmacro heightmap-set! [hm x y val]
-      `(set! (heightmap-get ~hm ~x ~y) ~val))
-
-
-And finally, we'll want to be able to "normalize" our array.  During the course
-of running our algorithm, it's possible for the values to become less than `0.0`
-or greater than `1.0`.  We want our heightmaps to contain only values between
-zero and one, so rather than change the algorithm we can just loop through the
-array at the end and "squeeze" the range down to 0 and 1 (or "stretch" it if
-it ends up smaller):
-
-    :::clojure
-    (defn normalize [hm]
-      (let [max (- Infinity)
-            min Infinity]
-        (do-times i hm.length
-          (let [el (aget hm i)]
-            (when (< max el) (set! max el))
-            (when (> min el) (set! min el))))
-        (let [span (- max min)]
-          (do-times i hm.length
-            (set! (aget hm i)
-              (/ (- (aget hm i) min)
-                 span))))))
-
-## Random Noise
-
-Now that we've got a nice little interface to heightmaps we can move on to
-actually making some terrain!  Before we dive into midpoint displacement, let's
-get a [black triangle][] on the screen.  We'll start by just setting every point
-in the heightmap to a completely random value.
-
-    :::clojure
-    (defn rand []
-      (Math.random))
-
-    (defn rand-around-zero [spread]
-      (- (* spread (rand) 2) spread))
-
-    (defn random-noise [heightmap]
-      (do-times i heightmap.length
-        (set! (aget heightmap i) (rand))))
-
-Let's see it!  Hit the "refresh" button to create and render the terrain.  You
-can keep hitting it to get fresh terrains.
-
-<div id="demo-random" class="threejs"></div>
-
-Not really a very fun landscape to explore, but at least we've got something
-running.  Onward to the real algorithm.
-
-[black triangle]: http://rampantgames.com/blog/?p=7745
-
-## Midpoint Displacement
-
-Midpoint displacement is a simple, fast way to generate decent-looking terrain.
-It's not perfect (you'll notice patterns once you start viewing the mesh from
-different angles) but it's a good place to start.
-
-The general process goes like this:
-
-1. Initialize the four corners of the heightmap to random values.
-2. Set the midpoints of each edge to the average of the two corners it's
-   between, plus or minus a random amount.
-3. Set the center of the square to the average of those edge midpoints you just
-   set, again with a random jitter.
-4. Recurse on the four squares inside this one, reducing the jitter.
-
-That's the standard description.  Now let's draw the fucking owl.
-
-### Initialize the Corners
-
-The first step is pretty easy: we just need to take our heightmap:
-
-<pre class="lineart">
-               Column
-          0   1   2   3   4
-        ┌───┬───┬───┬───┬───┐
-      0 │   │   │   │   │   │
-        ├───┼───┼───┼───┼───┤
-      1 │   │   │   │   │   │
-    R   ├───┼───┼───┼───┼───┤
-    o 2 │   │   │   │   │   │
-    w   ├───┼───┼───┼───┼───┤
-      3 │   │   │   │   │   │
-        ├───┼───┼───┼───┼───┤
-      4 │   │   │   │   │   │
-        └───┴───┴───┴───┴───┘
-</pre>
-
-Find the corners:
-
-<pre class="lineart">
-               Column
-          0   1   2   3   4
-        ┌───┬───┬───┬───┬───┐
-      0 │ ◉ │   │   │   │ ◉ │
-        ├───┼───┼───┼───┼───┤
-      1 │   │   │   │   │   │
-    R   ├───┼───┼───┼───┼───┤
-    o 2 │   │   │   │   │   │
-    w   ├───┼───┼───┼───┼───┤
-      3 │   │   │   │   │   │
-        ├───┼───┼───┼───┼───┤
-      4 │ ◉ │   │   │   │ ◉ │
-        └───┴───┴───┴───┴───┘
-</pre>
-
-And shove random values in them:
-
-<pre class="lineart">
-               Column
-          0   1   2   3   4
-        ┌───┬───┬───┬───┬───┐
-      0 │ 2 │   │   │   │ 8 │
-        ├───┼───┼───┼───┼───┤
-      1 │   │   │   │   │   │
-    R   ├───┼───┼───┼───┼───┤
-    o 2 │   │   │   │   │   │
-    w   ├───┼───┼───┼───┼───┤
-      3 │   │   │   │   │   │
-        ├───┼───┼───┼───┼───┤
-      4 │ 0 │   │   │   │ 3 │
-        └───┴───┴───┴───┴───┘
-</pre>
-
-(I'm using 0 to 10 instead of 0 to 1 because it's easier to read in the
-ASCII-art diagrams.)
-
-The code is about what you'd expect:
-
-    :::clojure
-    (defn mpd-init-corners [heightmap]
-      (heightmap-set! heightmap 0 0 (rand))
-      (heightmap-set! heightmap 0 heightmap.last (rand))
-      (heightmap-set! heightmap heightmap.last 0 (rand))
-      (heightmap-set! heightmap heightmap.last heightmap.last (rand)))
-
-    (defn midpoint-displacement-d1 [heightmap]
-      (mpd-init-corners heightmap))
-
-That was easy.
-
-<div id="demo-mpd-1" class="threejs"></div>
-
-### Set the Edges
-
-For the next step, we need to take our square heightmap with filled-in corners
-and use the corners to fill in the middle element of each edge:
-
-<pre class="lineart">
-               Column
-          0   1   2   3   4
-        ┌───┬───┬───┬───┬───┐
-      0 │ 2 │   │ ◉ │   │ 8 │
-        ├───┼───┼───┼───┼───┤
-      1 │   │   │   │   │   │
-    R   ├───┼───┼───┼───┼───┤
-    o 2 │ ◉ │   │   │   │ ◉ │
-    w   ├───┼───┼───┼───┼───┤
-      3 │   │   │   │   │   │
-        ├───┼───┼───┼───┼───┤
-      4 │ 0 │   │ ◉ │   │ 3 │
-        └───┴───┴───┴───┴───┘
-
-
-
-               Column
-          0   1   2   3   4
-        ┌───┬───┬───┬───┬───┐
-      0 │ 2 ├───▶ ◉ ◀───┤ 8 │
-        ├─┬─┼───┼───┼───┼─┬─┤
-      1 │ │ │   │   │   │ │ │
-    R   ├─▼─┼───┼───┼───┼─▼─┤
-    o 2 │ ◉ │   │   │   │ ◉ │
-    w   ├─▲─┼───┼───┼───┼─▲─┤
-      3 │ │ │   │   │   │ │ │
-        ├─┴─┼───┼───┼───┼─┴─┤
-      4 │ 0 ├───▶ ◉ ◀───┤ 3 │
-        └───┴───┴───┴───┴───┘
-
-
-               Column
-          0   1   2   3   4
-        ┌───┬───┬───┬───┬───┐
-      0 │ 2 ├───▶ 5 ◀───┤ 8 │
-        ├─┬─┼───┼───┼───┼─┬─┤
-      1 │ │ │   │   │   │ │ │
-    R   ├─▼─┼───┼───┼───┼─▼─┤
-    o 2 │ 1 │   │   │   │5.5│
-    w   ├─▲─┼───┼───┼───┼─▲─┤
-      3 │ │ │   │   │   │ │ │
-        ├─┴─┼───┼───┼───┼─┴─┤
-      4 │ 0 ├───▶1.5◀───┤ 3 │
-        └───┴───┴───┴───┴───┘
-</pre>
-
-This is why the size of the heightmap has to be \\(2^n + 1\\) -- the \\(+ 1\\)
-ensures that the sides are odd lengths, which makes sure they *have* a middle
-element for us to set.
-
-Let's make a couple of helper functions:
-
-    :::clojure
-    (defn jitter [value spread]
-      (+ value (rand-around-zero spread)))
-
-    (defn midpoint [a b]
-      (/ (+ a b) 2))
-
-    (defn average2 [a b]
-      (/ (+ a b) 2))
-
-    (defn average4 [a b c d]
-      (/ (+ a b c d) 4))
-
-`jitter` is just a nice way of saying "take this point and move it a random
-amount up or down".
-
-The other three functions are pretty self-explanatory.  Also, two of them are
-exactly the same function!  There's a reason for this.
-
-Lately I've started digging into [SICP][] again and watching the [lectures][].
-Abelson and Sussman practice a style of programming that's more about "growing"
-a language to talk about a problem you're trying to solve.  So you start with
-the base programming language, and then define new terms/syntax that let you
-talk about your problem at the appropriate level of detail.
-
-So in this case, we've got two functions for conceptually different tasks:
-
-* `midpoint` finds the middle point between two points (indexes in an array in
-  this case).
-* `average2` finds the average of two values (floating point height values
-  here).
-
-They happen to be implemented in the same way, but I think giving them different
-names makes them easier to talk about and easier to keep straight in your head.
-
-    :::clojure
-    (defn mpd-displace [heightmap lx rx by ty spread]
-      (let [cx (midpoint lx rx)
-            cy (midpoint by ty)
-
-            bottom-left (heightmap-get heightmap lx by)
-            bottom-right (heightmap-get heightmap rx by)
-            top-left (heightmap-get heightmap lx ty)
-            top-right (heightmap-get heightmap rx ty)
-
-            top (average2 top-left top-right)
-            left (average2 bottom-left top-left)
-            bottom (average2 bottom-left bottom-right)
-            right (average2 bottom-right top-right)]
-        (heightmap-set! heightmap cx by (jitter bottom spread))
-        (heightmap-set! heightmap cx ty (jitter top spread))
-        (heightmap-set! heightmap lx cy (jitter left spread))
-        (heightmap-set! heightmap rx cy (jitter right spread))))
-
-    (defn midpoint-displacement-d2 [heightmap]
-      (mpd-init-corners heightmap)
-      (mpd-displace heightmap
-                    0 heightmap.last
-                    0 heightmap.last
-                    0.1))
-
-`mpd-displace` is the meat of the algorithm.  It takes a heightmap, the spread
-(how much random "jitter" to apply after averaging the values), and four values
-to define the square we're working on in the heightmap:
-
-* `lx`: the x coordinate for the left-hand corners
-* `rx`: the x coordinate for the right-hand corners
-* `by`: the y coordinate for the bottom corners
-* `ty`: the y coordinate for the top corners
-
-For the first iteration we want to work on the entire heightmap, so we pass in
-`0` and `heightmap.last` for the left/right and top/bottom indices.
-
-Run the demo a few times and watch how the midpoints fall between the corner
-points because they're averaged (with a little bit of jitter thrown in).
-
-<div id="demo-mpd-2" class="threejs"></div>
-
-[SICP]: http://www.amazon.com/dp/0262510871/?tag=stelos-20
-[lectures]: https://youtu.be/2Op3QLzMgSY
-
-### Set the Center
-
-The next step is to set the center element of the square to the average of those
-midpoints we just set, plus a bit of jitter:
-
-<pre class="lineart">
-               Column
-          0   1   2   3   4
-        ┌───┬───┬───┬───┬───┐
-      0 │ 2 │   │ 5 │   │ 8 │
-        ├───┼───┼───┼───┼───┤
-      1 │   │   │   │   │   │
-    R   ├───┼───┼───┼───┼───┤
-    o 2 │ 1 │   │ ◉ │   │5.5│
-    w   ├───┼───┼───┼───┼───┤
-      3 │   │   │   │   │   │
-        ├───┼───┼───┼───┼───┤
-      4 │ 0 │   │1.5│   │ 3 │
-        └───┴───┴───┴───┴───┘
-
-
-               Column
-          0   1   2   3   4
-        ┌───┬───┬───┬───┬───┐
-      0 │ 2 │   │ 5 │   │ 8 │
-        ├───┼───┼─┬─┼───┼───┤
-      1 │   │   │ │ │   │   │
-    R   ├───┼───┼─▼─┼───┼───┤
-    o 2 │ 1 ├───▶ ◉ ◀───┤5.5│
-    w   ├───┼───┼─▲─┼───┼───┤
-      3 │   │   │ │ │   │   │
-        ├───┼───┼─┴─┼───┼───┤
-      4 │ 0 │   │1.5│   │ 3 │
-        └───┴───┴───┴───┴───┘
-
-
-               Column
-          0   1   2   3   4
-        ┌───┬───┬───┬───┬───┐
-      0 │ 2 │   │ 5 │   │ 8 │
-        ├───┼───┼─┬─┼───┼───┤
-      1 │   │   │ │ │   │   │
-    R   ├───┼───┼─▼─┼───┼───┤
-    o 2 │ 1 ├───▶3.3◀───┤5.5│
-    w   ├───┼───┼─▲─┼───┼───┤
-      3 │   │   │ │ │   │   │
-        ├───┼───┼─┴─┼───┼───┤
-      4 │ 0 │   │1.5│   │ 3 │
-        └───┴───┴───┴───┴───┘
-</pre>
-
-We can add this to the displacement function pretty easily:
-
-    :::clojure
-    (defn mpd-displace [heightmap lx rx by ty spread]
-      (let [cx (midpoint lx rx)
-            cy (midpoint by ty)
-
-            bottom-left (heightmap-get heightmap lx by)
-            bottom-right (heightmap-get heightmap rx by)
-            top-left (heightmap-get heightmap lx ty)
-            top-right (heightmap-get heightmap rx ty)
-
-            top (average2 top-left top-right)
-            left (average2 bottom-left top-left)
-            bottom (average2 bottom-left bottom-right)
-            right (average2 bottom-right top-right)
-            center (average4 top left bottom right)]
-        (heightmap-set! heightmap cx by (jitter bottom spread))
-        (heightmap-set! heightmap cx ty (jitter top spread))
-        (heightmap-set! heightmap lx cy (jitter left spread))
-        (heightmap-set! heightmap rx cy (jitter right spread))
-        (heightmap-set! heightmap cx cy (jitter center spread))))
-
-And now our center is ready to go:
-
-<div id="demo-mpd-3" class="threejs"></div>
-
-### Iterate
-
-To finish things off, we need to iterate so that we can fill in the rest of the
-values in progressively smaller squares.
-
-A 3x3 square is the base case, because its corners will be filled in to start,
-and the edges and midpoint get filled in.  We just call our displacement
-function with the top/bottom/left/right values defining the square and we're
-done.
-
-A 5x5 starts with one iteration that displaces the whole map.  Then it does
-another "pass" that displaces each of the 3x3 "sub-squares":
-
-<pre class="lineart">
-    ╔═══════════╗───┬───┐      ┌───┬───╔═══════════╗
-    ║ 2 │   │ 5 ║   │ 8 │      │ 2 │   ║ 5 │   │ 8 ║
-    ║───┼───┼───║───┼───┤      ├───┼───║───┼───┼───║
-    ║   │   │   ║   │   │      │   │   ║   │   │   ║
-    ║───┼───┼───║───┼───┤      ├───┼───║───┼───┼───║
-    ║ 1 │   │3.3║   │5.5│      │ 1 │   ║3.3│   │5.5║
-    ╚═══════════╝───┼───┤      ├───┼───╚═══════════╝
-    │   │   │   │   │   │      │   │   │   │   │   │
-    ├───┼───┼───┼───┼───┤      ├───┼───┼───┼───┼───┤
-    │ 0 │   │1.5│   │ 3 │      │ 0 │   │1.5│   │ 3 │
-    └───┴───┴───┴───┴───┘      └───┴───┴───┴───┴───┘
-
-
-    ┌───┬───┬───┬───┬───┐      ┌───┬───┬───┬───┬───┐
-    │ 2 │   │ 5 │   │ 8 │      │ 2 │   │ 5 │   │ 8 │
-    ├───┼───┼───┼───┼───┤      ├───┼───┼───┼───┼───┤
-    │   │   │   │   │   │      │   │   │   │   │   │
-    ╔═══════════╗───┼───┤      ├───┼───╔═══════════╗
-    ║ 1 │   │3.3║   │5.5│      │ 1 │   ║3.3│   │5.5║
-    ║───┼───┼───║───┼───┤      ├───┼───║───┼───┼───║
-    ║   │   │   ║   │   │      │   │   ║   │   │   ║
-    ║───┼───┼───║───┼───┤      ├───┼───║───┼───┼───║
-    ║ 0 │   │1.5║   │ 3 │      │ 0 │   ║1.5│   │ 3 ║
-    ╚═══════════╝───┴───┘      └───┴───╚═══════════╝
-</pre>
-
-If we have a bigger heightmap (e.g. 9x9) we'll need three passes:
-
-<pre class="lineart">
-     Pass 1
-    ▩▩▩▩▩▩▩▩▩
-    ▩▩▩▩▩▩▩▩▩
-    ▩▩▩▩▩▩▩▩▩
-    ▩▩▩▩▩▩▩▩▩
-    ▩▩▩▩▩▩▩▩▩
-    ▩▩▩▩▩▩▩▩▩
-    ▩▩▩▩▩▩▩▩▩
-    ▩▩▩▩▩▩▩▩▩
-    ▩▩▩▩▩▩▩▩▩
-
-
-     Pass 2
-    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
-
-
-     Pass 3
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
-</pre>
-
-Let's think about what's happening here.
-
-* On pass `0`, we break up the grid into a 1x1 set of chunks and displace them (well, "it").
-* On pass `1`, we break up the grid into a 2x2 set of chunks and displace them.
-* On pass `2`, we break up the grid into a 4x4 set of chunks and displace them.
-
-This 9x9 heightmap was made with an exponent of 3 (\\(2^3 + 1 = 9\\)) and we
-need 3 "passes" to finish it.  This isn't a coincidence -- it's the reason we
-chose our heightmap resolutions to be \\(2^n + 1\\).
-
-So at iteration \\(i\\), we need to displace a \\(2^i\\)x\\(2^i\\) collection of
-squares.  Let's go:
-
-    :::clojure
-    (defn midpoint-displacement [heightmap]
-      (mpd-init-corners heightmap)
-      (loop [iter 0
-             spread 0.3]
-        (when (< iter heightmap.exponent)
-          (let [chunks (Math.pow 2 iter)
-                chunk-width (/ (- heightmap.resolution 1) chunks)]
-            (do-nested xchunk ychunk chunks
-              (let [left-x (* chunk-width xchunk)
-                    right-x (+ left-x chunk-width)
-                    bottom-y (* chunk-width ychunk)
-                    top-y (+ bottom-y chunk-width)]
-                    (mpd-displace heightmap
-                                  left-x right-x bottom-y top-y
-                                  spread))))
-          (recur (+ 1 iter) (* spread 0.5))))
-      (normalize heightmap))
-
-That's a lot to take in.  Let's break it down:
-
-    :::clojure
-    (defn midpoint-displacement [heightmap]
-      (mpd-init-corners heightmap)
-      (loop [iter 0
-             spread 0.3]
-        (when (< iter heightmap.exponent)
-          ; Process the chunks at this iteration
-          (recur (+ 1 iter) (* spread 0.5))))
-      (normalize heightmap))
-
-We initialize the corners at the beginning and normalize the heightmap at the
-end.  Then we loop a number of times equal to the exponent we used to make the
-heightmap, as described above.  Each time through the loop we increment `iter`
-and cut the `spread` for those points in half.
-
-For each pass, we figure out what we're going to need to do:
-
-    :::clojure
-    (let [chunks (Math.pow 2 iter)
-          chunk-width (/ (- heightmap.resolution 1) chunks)]
-      ; Actually do it...
-      )
-
-Let's make a quick "nested for loop" syntax.  It'll make things easier to read
-in the main function and we'll need it for later algorithms too:
-
-    :::clojure
-    (defmacro do-nested [xname yname width & body]
-      (let [iterations (gensym)]
-        `(let [~iterations ~width]
-           (do-times ~xname ~iterations
-             (do-times ~yname ~iterations
-               ~@body)))))
-
-This lets us say something like `(do-nested x y 5 (console.log [x y]))` to mean:
-
-    :::javascript
-    for (x = 0; x < 5; x++) {
-        for (y = 0; y < 5; y++) {
-            console.log([x, y]);
-        }
-    }
-
-And now we can see how we process the chunks:
-
-    :::clojure
-    (let [chunks (Math.pow 2 iter)
-          chunk-width (/ (- heightmap.resolution 1) chunks)]
-      (do-nested xchunk ychunk chunks
-        (let [left-x (* chunk-width xchunk)
-              right-x (+ left-x chunk-width)
-              bottom-y (* chunk-width ychunk)
-              top-y (+ bottom-y chunk-width)]
-              (mpd-displace heightmap
-                            left-x right-x bottom-y top-y
-                            spread))))
-
-We loop over the indices of the chunks, calculate the bounds for each one, and
-displace it.  Simple enough, but a bit fiddly to get right.  And now we've
-finished displacing all the points!
-
-We could have done this recursively, but I was in an iterative mood when I wrote
-this.  Feel free to play around with it.
-
-<div id="demo-mpd-4" class="threejs"></div>
-
-## Result
-
-Now that we've got a working algorithm we can play around with the values and
-see what effect they have on the resulting terrain.
-
-**Warning**: don't set the exponent higher than 8 unless you want to crash this
-browser tab.  An exponent of `8` results in a heightmap with `66049` elements.
-Going to `9` is `263169`, which most browsers seem to... dislike.
-
-<div id="demo-final" class="threejs"></div>
-<div id="demo-final-controls">
-    <p>
-        <label>Exponent
-            <input type="number" id="input-exponent" value="5"></input>
-        </label>
-        <br/>
-        <label>Starting Spread
-            <input type="number" id="input-starting-spread" value="0.3"></input>
-        </label>
-        <br/>
-        <label>Spread Reduction Constant
-            <input type="number" id="input-spread-reduction" value="0.5"></input>
-        </label>
-    </p>
-</div>
-
-And that's it, we've grown some mountains!
-
-Now that we've got some of the boilerplate down I'm planning on doing a couple
-more posts like this looking at other noise algorithms, and maybe some erosion
-algorithms to simulate weathering.  Let me know if you've got any specific
-requests!
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2016/02/midpoint-displacement.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,882 @@
++++
+title = "Terrain Generation with Midpoint Displacement"
+snip = "A first step toward growing worlds with computers."
+date = 2016-02-19T19:45:00Z
+draft = false
+
++++
+
+<script data-cfasync="false" src="/media/js/three.min.js"></script>
+<script data-cfasync="false" src="/media/js/TrackballControls.js"></script>
+<script data-cfasync="false" src="/media/js/terrain1.js"></script>
+
+I'm taking the Game Engine Architecture class at Reykjavík University.  My group
+just finished our midterm [project][] where we played around with procedural
+terrain generation in [Unity][].  It was a lot of fun and I really enjoyed
+creating terrain out of numbers, so I thought I'd write up a little introduction
+to a few of the algorithms.
+
+In this post we'll be looking at Midpoint Displacement.
+
+The full series of posts so far:
+
+* [Midpoint Displacement](/blog/2016/02/midpoint-displacement/)
+* [Recursive Midpoint Displacement](/blog/2016/03/recursive-midpoint-displacement/)
+* [Diamond Square](/blog/2016/06/diamond-square/)
+
+[project]: https://www.youtube.com/watch?v=G5u79w4qiAA
+[Unity]: http://unity3d.com/
+
+{{% toc %}}
+
+## Terrain Generation
+
+Procedural generation is a pretty big field. The [Wikipedia
+article][wikipedia-pg] gives a pretty brief overview.  The [Procedural Content
+Generation Wiki][pcg-wiki] is an entire wiki devoted to procedural generation.
+There's also a small but active [subreddit][r-pg] for interested folks.
+
+Today we're just going to look at a single algorithm for generating
+realistic-looking terrain called "Midpoint Displacement".  It's relatively
+simple (compared to other algorithms) but it produces terrain that actually
+looks kind of cool.
+
+[wikipedia-pg]: https://en.wikipedia.org/wiki/Procedural_generation
+[pcg-wiki]: http://pcg.wikidot.com/
+[r-pg]: https://www.reddit.com/r/proceduralgeneration/
+
+## Resources, Code, and Examples
+
+There are a lot of resources for learning how terrain generation algorithms
+work.  For midpoint displacement I used the [Wikipedia article][wikipedia-ds],
+the [PCG Wiki article][pcgw-midpoint], and academic papers like [this
+one][paper].
+
+Unfortunately, while there are a *lot* of places that describe algorithms like
+this, there are relatively few that explain it *thoroughly*.  Academic papers in
+particular tend to have a really bad case of
+[draw-the-rest-of-the-fucking-owl-syndrome][owl].  They tend to slap an equation
+or two on the page and move on without showing any code.
+
+As anyone who's done much programming knows, there's a big difference between
+saying something like "set the midpoints of the diamonds to the average of the
+corners" and making a computer actually *do* that.  How do we iterate over the
+array (row-major or column-major)?  Does it matter (yes: if you care about cache
+coherency)?  What about the edges where there are fewer corners?  How random
+(and how fast) is our random number generator (and how much do we care)?  How do
+we write all this code so we can actually read it six months later?
+
+So I'm going to try to do my part to improve the situation by not just
+describing the algorithm, but showing *actual code* that runs and generates
+a terrain.
+
+The full code is [here][code], but we'll be going through the important parts
+below.
+
+[wikipedia-ds]: https://en.wikipedia.org/wiki/Diamond-square_algorithm
+[pcgw-midpoint]: http://pcg.wikidot.com/pcg-algorithm:midpoint-displacement-algorithm
+[paper]: http://micsymposium.org/mics_2011_proceedings/mics2011_submission_30.pdf
+[owl]: https://i.imgur.com/RadSf.jpg
+[code]: https://bitbucket.org/sjl/stevelosh/src/default/media/js/terrain1.wisp
+
+### Wisp
+
+I'm using a language called [Wisp][wisp].  It's a small, Clojure-inspired
+dialect of Lisp that compiles down to vanilla Javascript.
+
+I went with Javascript because it means I can actually put demos inline in this
+post.  Sometimes it's so much easier to understand something when you can
+actually see it running.
+
+I've tried to write the code so that it's readable even if you don't know Lisp.
+The point of me showing you this code is not to give you something to copy and
+paste.  The point is that until you *actually write and run* the code, you don't
+know all the edge cases and problems that can happen.  So by making examples
+that actually run I feel a bit more confident that I'm explaining things enough.
+
+I haven't focused on performance at all.  If you want a fast implementation of
+this, you'll probably want to use a language with real arrays (i.e. contiguous
+chunks of memory holding a bunch of unboxed floats or integers).
+
+[wisp]: https://github.com/Gozala/wisp
+
+### Three.js
+
+[Three.js][three.js] is a Javascript library for 3D rendering.  I'm using it
+here to get something on the screen you can play with.  I'm not going to cover
+the code to put the terrains on the screen because it's really an entirely
+separate problem to *generating* the terrain, and it's mostly uninteresting
+boilerplate for these little demos.
+
+I haven't been able to get these demos working on my iPhone.  Sorry about that,
+but I'm not much of a frontend developer.  You'll have to use a computer to see
+them.  [Pull requests][slc] are welcome.
+
+[slc]: http://bitbucket.org/sjl/stevelosh/
+[three.js]: http://threejs.org/
+
+## Heightmaps
+
+Let's get started.  The main data structure we're going to be using is
+a [heightmap][].
+
+### Overview
+
+Heightmaps are essentially just big two-dimensional arrays of numbers in a given
+range that represent the height of the ground at a given point.  For example,
+a heightmap with a small "mountain" in the middle might look like:
+
+```text
+[[0, 0, 2, 0, 0],
+ [0, 2, 5, 1, 0],
+ [2, 5, 9, 4, 1],
+ [0, 1, 4, 1, 0],
+ [0, 0, 1, 0, 0]]
+```
+
+In practice, heightmaps are often represented as a single-dimensional array
+instead to ensure that all the data is together in one big hunk of memory:
+
+```text
+[0, 0, 2, 0, 0,
+ 0, 2, 5, 1, 0,
+ 2, 5, 9, 4, 1,
+ 0, 1, 4, 1, 0,
+ 0, 0, 1, 0, 0]
+```
+
+The type and range of the numbers in the map varies by program and programmer.
+Some programs use nonzero integers, some use all the integers, some use floating
+point, etc.
+
+The heightmaps in this post will contain floats from `0.0` to `1.0`.  I like
+using floats between zero and one because it's easy to roughly visualize them in
+your head (e.g. `0.1` is ten percent of the maximum height).
+
+One common way to visualize heightmaps is by turning them into greyscale images
+with one pixel per number, with black pixels for lowest value in the map's range
+and white for the highest.  The [Wikipedia article][heightmap] has an example of
+this.  This is handy because you can also write some code to *read* images, and
+then you can use any image editor to draw your own heightmaps by hand.
+
+We're going to visualize the heightmaps in 3D.  It's a lot more fun, and they
+start to actually look like real terrains.
+
+[heightmap]: https://en.wikipedia.org/wiki/Heightmap
+
+### Code
+
+We're going to start by writing a few functions that will hide away the internal
+details of how our heightmaps are implemented, so we can talk about them in
+nice high-level terms for the rest of the program.  We'll also need a couple of
+helper functions along the way.
+
+We'll start with something to create a heightmap:
+
+```clojure
+(defn make-heightmap [exponent]
+  (let [resolution (+ 1 (Math.pow 2 exponent))]
+    (l (+ "Creating " resolution " by " resolution " heightmap..."))
+    (def heightmap
+      (new Array (* resolution resolution)))
+    (set! heightmap.resolution resolution)
+    (set! heightmap.exponent exponent)
+    (set! heightmap.last (- resolution 1))
+    (zero-heightmap heightmap)))
+```
+
+`make-heightmap` takes an exponent and creates a heightmap.  For reasons that
+will become clear later, all of our heightmaps must be square, and they'll need
+to have \\(2^n + 1\\) rows and columns.  This means we can make heightmaps of
+sizes like 3x3, 5x5, 9x9, 17x17, 33x33, etc.  So our function just takes the
+\\(n\\) to use and creates a correctly-sized array.
+
+(If you've ever poked around with Unity's Terrain objects you might recognize
+these "powers of two plus one".)
+
+We create a new array (1-dimensional) and store a few pieces of extra data on it
+for later use.  `last` is the index of the last row/column, so for a 3x3 array
+it would be `2`.
+
+`l` is just a simple little logging function:
+
+```clojure
+(defn l [v]
+  (console.log v))
+```
+
+We'll need to zero out the heightmap as well:
+
+```clojure
+(defn zero-heightmap [heightmap]
+  (do-times i heightmap.length
+    (set! (aget heightmap i) 0.0))
+  heightmap)
+```
+
+`zero-heightmap` just iterates from `0` to `heightmap.length` and sets each
+element to `0.0`.  Wisp doesn't have syntax to loop from 0 to some number, but
+it's a Lisp, so we can make some:
+
+```clojure
+(defmacro when [condition & body]
+  `(if ~condition
+     (do ~@body)))
+
+(defmacro do-times [varname limit & body]
+  (let [end (gensym)]
+    `(let [~end ~limit]
+       (loop [~varname 0]
+         (when (< ~varname ~end)
+           ~@body
+           (recur (+ 1 ~varname)))))))
+```
+
+If you're not a Lisp person, don't sweat this too much.  Just trust me that
+`(do-times i 10 (console.log i))` will print the numbers `0` to `9`.
+
+Now that we can create a heightmap, we'll probably want to be able to read its
+elements:
+
+```clojure
+(defmacro heightmap-get [hm x y]
+  `(aget ~hm (+ (* ~y (.-resolution ~hm)) ~x)))
+
+(defn heightmap-get-safe [hm x y]
+  (when (and (<= 0 x hm.last)
+             (<= 0 y hm.last))
+    (heightmap-get hm x y)))
+```
+
+`heightmap-get` handles the nasty business of translating our human-thinkable
+`x` and `y` coordinates into an index into the single-dimensional array.  It's
+not particularly fast (especially if the compiler won't inline it), but we're
+not worried about speed for this post.
+
+`heightmap-get-safe` is a version of `heightmap-get` that will do bounds
+checking for us and return `nil` if we ask for something out of range.
+Javascript will return `undefined` if you ask for a non-existent index, but
+because we're storing the array as one big line of data, using a `y` value
+that's too big will actually "wrap around" to the next row, so it's safer to
+just check it explicitly.
+
+Of course we'll also want to be able to set values in our heightmap:
+
+```clojure
+(defmacro heightmap-set! [hm x y val]
+  `(set! (heightmap-get ~hm ~x ~y) ~val))
+
+```
+
+And finally, we'll want to be able to "normalize" our array.  During the course
+of running our algorithm, it's possible for the values to become less than `0.0`
+or greater than `1.0`.  We want our heightmaps to contain only values between
+zero and one, so rather than change the algorithm we can just loop through the
+array at the end and "squeeze" the range down to 0 and 1 (or "stretch" it if
+it ends up smaller):
+
+```clojure
+(defn normalize [hm]
+  (let [max (- Infinity)
+        min Infinity]
+    (do-times i hm.length
+      (let [el (aget hm i)]
+        (when (< max el) (set! max el))
+        (when (> min el) (set! min el))))
+    (let [span (- max min)]
+      (do-times i hm.length
+        (set! (aget hm i)
+          (/ (- (aget hm i) min)
+             span))))))
+```
+
+## Random Noise
+
+Now that we've got a nice little interface to heightmaps we can move on to
+actually making some terrain!  Before we dive into midpoint displacement, let's
+get a [black triangle][] on the screen.  We'll start by just setting every point
+in the heightmap to a completely random value.
+
+```clojure
+(defn rand []
+  (Math.random))
+
+(defn rand-around-zero [spread]
+  (- (* spread (rand) 2) spread))
+
+(defn random-noise [heightmap]
+  (do-times i heightmap.length
+    (set! (aget heightmap i) (rand))))
+```
+
+Let's see it!  Hit the "refresh" button to create and render the terrain.  You
+can keep hitting it to get fresh terrains.
+
+<div id="demo-random" class="threejs"></div>
+
+Not really a very fun landscape to explore, but at least we've got something
+running.  Onward to the real algorithm.
+
+[black triangle]: http://rampantgames.com/blog/?p=7745
+
+## Midpoint Displacement
+
+Midpoint displacement is a simple, fast way to generate decent-looking terrain.
+It's not perfect (you'll notice patterns once you start viewing the mesh from
+different angles) but it's a good place to start.
+
+The general process goes like this:
+
+1. Initialize the four corners of the heightmap to random values.
+2. Set the midpoints of each edge to the average of the two corners it's
+   between, plus or minus a random amount.
+3. Set the center of the square to the average of those edge midpoints you just
+   set, again with a random jitter.
+4. Recurse on the four squares inside this one, reducing the jitter.
+
+That's the standard description.  Now let's draw the fucking owl.
+
+### Initialize the Corners
+
+The first step is pretty easy: we just need to take our heightmap:
+
+<pre class="lineart">
+               Column
+          0   1   2   3   4
+        ┌───┬───┬───┬───┬───┐
+      0 │   │   │   │   │   │
+        ├───┼───┼───┼───┼───┤
+      1 │   │   │   │   │   │
+    R   ├───┼───┼───┼───┼───┤
+    o 2 │   │   │   │   │   │
+    w   ├───┼───┼───┼───┼───┤
+      3 │   │   │   │   │   │
+        ├───┼───┼───┼───┼───┤
+      4 │   │   │   │   │   │
+        └───┴───┴───┴───┴───┘
+</pre>
+
+Find the corners:
+
+<pre class="lineart">
+               Column
+          0   1   2   3   4
+        ┌───┬───┬───┬───┬───┐
+      0 │ ◉ │   │   │   │ ◉ │
+        ├───┼───┼───┼───┼───┤
+      1 │   │   │   │   │   │
+    R   ├───┼───┼───┼───┼───┤
+    o 2 │   │   │   │   │   │
+    w   ├───┼───┼───┼───┼───┤
+      3 │   │   │   │   │   │
+        ├───┼───┼───┼───┼───┤
+      4 │ ◉ │   │   │   │ ◉ │
+        └───┴───┴───┴───┴───┘
+</pre>
+
+And shove random values in them:
+
+<pre class="lineart">
+               Column
+          0   1   2   3   4
+        ┌───┬───┬───┬───┬───┐
+      0 │ 2 │   │   │   │ 8 │
+        ├───┼───┼───┼───┼───┤
+      1 │   │   │   │   │   │
+    R   ├───┼───┼───┼───┼───┤
+    o 2 │   │   │   │   │   │
+    w   ├───┼───┼───┼───┼───┤
+      3 │   │   │   │   │   │
+        ├───┼───┼───┼───┼───┤
+      4 │ 0 │   │   │   │ 3 │
+        └───┴───┴───┴───┴───┘
+</pre>
+
+(I'm using 0 to 10 instead of 0 to 1 because it's easier to read in the
+ASCII-art diagrams.)
+
+The code is about what you'd expect:
+
+```clojure
+(defn mpd-init-corners [heightmap]
+  (heightmap-set! heightmap 0 0 (rand))
+  (heightmap-set! heightmap 0 heightmap.last (rand))
+  (heightmap-set! heightmap heightmap.last 0 (rand))
+  (heightmap-set! heightmap heightmap.last heightmap.last (rand)))
+
+(defn midpoint-displacement-d1 [heightmap]
+  (mpd-init-corners heightmap))
+```
+
+That was easy.
+
+<div id="demo-mpd-1" class="threejs"></div>
+
+### Set the Edges
+
+For the next step, we need to take our square heightmap with filled-in corners
+and use the corners to fill in the middle element of each edge:
+
+<pre class="lineart">
+               Column
+          0   1   2   3   4
+        ┌───┬───┬───┬───┬───┐
+      0 │ 2 │   │ ◉ │   │ 8 │
+        ├───┼───┼───┼───┼───┤
+      1 │   │   │   │   │   │
+    R   ├───┼───┼───┼───┼───┤
+    o 2 │ ◉ │   │   │   │ ◉ │
+    w   ├───┼───┼───┼───┼───┤
+      3 │   │   │   │   │   │
+        ├───┼───┼───┼───┼───┤
+      4 │ 0 │   │ ◉ │   │ 3 │
+        └───┴───┴───┴───┴───┘
+
+
+
+               Column
+          0   1   2   3   4
+        ┌───┬───┬───┬───┬───┐
+      0 │ 2 ├───▶ ◉ ◀───┤ 8 │
+        ├─┬─┼───┼───┼───┼─┬─┤
+      1 │ │ │   │   │   │ │ │
+    R   ├─▼─┼───┼───┼───┼─▼─┤
+    o 2 │ ◉ │   │   │   │ ◉ │
+    w   ├─▲─┼───┼───┼───┼─▲─┤
+      3 │ │ │   │   │   │ │ │
+        ├─┴─┼───┼───┼───┼─┴─┤
+      4 │ 0 ├───▶ ◉ ◀───┤ 3 │
+        └───┴───┴───┴───┴───┘
+
+
+               Column
+          0   1   2   3   4
+        ┌───┬───┬───┬───┬───┐
+      0 │ 2 ├───▶ 5 ◀───┤ 8 │
+        ├─┬─┼───┼───┼───┼─┬─┤
+      1 │ │ │   │   │   │ │ │
+    R   ├─▼─┼───┼───┼───┼─▼─┤
+    o 2 │ 1 │   │   │   │5.5│
+    w   ├─▲─┼───┼───┼───┼─▲─┤
+      3 │ │ │   │   │   │ │ │
+        ├─┴─┼───┼───┼───┼─┴─┤
+      4 │ 0 ├───▶1.5◀───┤ 3 │
+        └───┴───┴───┴───┴───┘
+</pre>
+
+This is why the size of the heightmap has to be \\(2^n + 1\\) — the \\(+ 1\\)
+ensures that the sides are odd lengths, which makes sure they *have* a middle
+element for us to set.
+
+Let's make a couple of helper functions:
+
+```clojure
+(defn jitter [value spread]
+  (+ value (rand-around-zero spread)))
+
+(defn midpoint [a b]
+  (/ (+ a b) 2))
+
+(defn average2 [a b]
+  (/ (+ a b) 2))
+
+(defn average4 [a b c d]
+  (/ (+ a b c d) 4))
+```
+
+`jitter` is just a nice way of saying "take this point and move it a random
+amount up or down".
+
+The other three functions are pretty self-explanatory.  Also, two of them are
+exactly the same function!  There's a reason for this.
+
+Lately I've started digging into [SICP][] again and watching the [lectures][].
+Abelson and Sussman practice a style of programming that's more about "growing"
+a language to talk about a problem you're trying to solve.  So you start with
+the base programming language, and then define new terms/syntax that let you
+talk about your problem at the appropriate level of detail.
+
+So in this case, we've got two functions for conceptually different tasks:
+
+* `midpoint` finds the middle point between two points (indexes in an array in
+  this case).
+* `average2` finds the average of two values (floating point height values
+  here).
+
+They happen to be implemented in the same way, but I think giving them different
+names makes them easier to talk about and easier to keep straight in your head.
+
+```clojure
+(defn mpd-displace [heightmap lx rx by ty spread]
+  (let [cx (midpoint lx rx)
+        cy (midpoint by ty)
+
+        bottom-left (heightmap-get heightmap lx by)
+        bottom-right (heightmap-get heightmap rx by)
+        top-left (heightmap-get heightmap lx ty)
+        top-right (heightmap-get heightmap rx ty)
+
+        top (average2 top-left top-right)
+        left (average2 bottom-left top-left)
+        bottom (average2 bottom-left bottom-right)
+        right (average2 bottom-right top-right)]
+    (heightmap-set! heightmap cx by (jitter bottom spread))
+    (heightmap-set! heightmap cx ty (jitter top spread))
+    (heightmap-set! heightmap lx cy (jitter left spread))
+    (heightmap-set! heightmap rx cy (jitter right spread))))
+
+(defn midpoint-displacement-d2 [heightmap]
+  (mpd-init-corners heightmap)
+  (mpd-displace heightmap
+                0 heightmap.last
+                0 heightmap.last
+                0.1))
+```
+
+`mpd-displace` is the meat of the algorithm.  It takes a heightmap, the spread
+(how much random "jitter" to apply after averaging the values), and four values
+to define the square we're working on in the heightmap:
+
+* `lx`: the x coordinate for the left-hand corners
+* `rx`: the x coordinate for the right-hand corners
+* `by`: the y coordinate for the bottom corners
+* `ty`: the y coordinate for the top corners
+
+For the first iteration we want to work on the entire heightmap, so we pass in
+`0` and `heightmap.last` for the left/right and top/bottom indices.
+
+Run the demo a few times and watch how the midpoints fall between the corner
+points because they're averaged (with a little bit of jitter thrown in).
+
+<div id="demo-mpd-2" class="threejs"></div>
+
+[SICP]: http://www.amazon.com/dp/0262510871/?tag=stelos-20
+[lectures]: https://youtu.be/2Op3QLzMgSY
+
+### Set the Center
+
+The next step is to set the center element of the square to the average of those
+midpoints we just set, plus a bit of jitter:
+
+<pre class="lineart">
+               Column
+          0   1   2   3   4
+        ┌───┬───┬───┬───┬───┐
+      0 │ 2 │   │ 5 │   │ 8 │
+        ├───┼───┼───┼───┼───┤
+      1 │   │   │   │   │   │
+    R   ├───┼───┼───┼───┼───┤
+    o 2 │ 1 │   │ ◉ │   │5.5│
+    w   ├───┼───┼───┼───┼───┤
+      3 │   │   │   │   │   │
+        ├───┼───┼───┼───┼───┤
+      4 │ 0 │   │1.5│   │ 3 │
+        └───┴───┴───┴───┴───┘
+
+
+               Column
+          0   1   2   3   4
+        ┌───┬───┬───┬───┬───┐
+      0 │ 2 │   │ 5 │   │ 8 │
+        ├───┼───┼─┬─┼───┼───┤
+      1 │   │   │ │ │   │   │
+    R   ├───┼───┼─▼─┼───┼───┤
+    o 2 │ 1 ├───▶ ◉ ◀───┤5.5│
+    w   ├───┼───┼─▲─┼───┼───┤
+      3 │   │   │ │ │   │   │
+        ├───┼───┼─┴─┼───┼───┤
+      4 │ 0 │   │1.5│   │ 3 │
+        └───┴───┴───┴───┴───┘
+
+
+               Column
+          0   1   2   3   4
+        ┌───┬───┬───┬───┬───┐
+      0 │ 2 │   │ 5 │   │ 8 │
+        ├───┼───┼─┬─┼───┼───┤
+      1 │   │   │ │ │   │   │
+    R   ├───┼───┼─▼─┼───┼───┤
+    o 2 │ 1 ├───▶3.3◀───┤5.5│
+    w   ├───┼───┼─▲─┼───┼───┤
+      3 │   │   │ │ │   │   │
+        ├───┼───┼─┴─┼───┼───┤
+      4 │ 0 │   │1.5│   │ 3 │
+        └───┴───┴───┴───┴───┘
+</pre>
+
+We can add this to the displacement function pretty easily:
+
+```clojure
+(defn mpd-displace [heightmap lx rx by ty spread]
+  (let [cx (midpoint lx rx)
+        cy (midpoint by ty)
+
+        bottom-left (heightmap-get heightmap lx by)
+        bottom-right (heightmap-get heightmap rx by)
+        top-left (heightmap-get heightmap lx ty)
+        top-right (heightmap-get heightmap rx ty)
+
+        top (average2 top-left top-right)
+        left (average2 bottom-left top-left)
+        bottom (average2 bottom-left bottom-right)
+        right (average2 bottom-right top-right)
+        center (average4 top left bottom right)]
+    (heightmap-set! heightmap cx by (jitter bottom spread))
+    (heightmap-set! heightmap cx ty (jitter top spread))
+    (heightmap-set! heightmap lx cy (jitter left spread))
+    (heightmap-set! heightmap rx cy (jitter right spread))
+    (heightmap-set! heightmap cx cy (jitter center spread))))
+```
+
+And now our center is ready to go:
+
+<div id="demo-mpd-3" class="threejs"></div>
+
+### Iterate
+
+To finish things off, we need to iterate so that we can fill in the rest of the
+values in progressively smaller squares.
+
+A 3x3 square is the base case, because its corners will be filled in to start,
+and the edges and midpoint get filled in.  We just call our displacement
+function with the top/bottom/left/right values defining the square and we're
+done.
+
+A 5x5 starts with one iteration that displaces the whole map.  Then it does
+another "pass" that displaces each of the 3x3 "sub-squares":
+
+<pre class="lineart">
+    ╔═══════════╗───┬───┐      ┌───┬───╔═══════════╗
+    ║ 2 │   │ 5 ║   │ 8 │      │ 2 │   ║ 5 │   │ 8 ║
+    ║───┼───┼───║───┼───┤      ├───┼───║───┼───┼───║
+    ║   │   │   ║   │   │      │   │   ║   │   │   ║
+    ║───┼───┼───║───┼───┤      ├───┼───║───┼───┼───║
+    ║ 1 │   │3.3║   │5.5│      │ 1 │   ║3.3│   │5.5║
+    ╚═══════════╝───┼───┤      ├───┼───╚═══════════╝
+    │   │   │   │   │   │      │   │   │   │   │   │
+    ├───┼───┼───┼───┼───┤      ├───┼───┼───┼───┼───┤
+    │ 0 │   │1.5│   │ 3 │      │ 0 │   │1.5│   │ 3 │
+    └───┴───┴───┴───┴───┘      └───┴───┴───┴───┴───┘
+
+
+    ┌───┬───┬───┬───┬───┐      ┌───┬───┬───┬───┬───┐
+    │ 2 │   │ 5 │   │ 8 │      │ 2 │   │ 5 │   │ 8 │
+    ├───┼───┼───┼───┼───┤      ├───┼───┼───┼───┼───┤
+    │   │   │   │   │   │      │   │   │   │   │   │
+    ╔═══════════╗───┼───┤      ├───┼───╔═══════════╗
+    ║ 1 │   │3.3║   │5.5│      │ 1 │   ║3.3│   │5.5║
+    ║───┼───┼───║───┼───┤      ├───┼───║───┼───┼───║
+    ║   │   │   ║   │   │      │   │   ║   │   │   ║
+    ║───┼───┼───║───┼───┤      ├───┼───║───┼───┼───║
+    ║ 0 │   │1.5║   │ 3 │      │ 0 │   ║1.5│   │ 3 ║
+    ╚═══════════╝───┴───┘      └───┴───╚═══════════╝
+</pre>
+
+If we have a bigger heightmap (e.g. 9x9) we'll need three passes:
+
+<pre class="lineart">
+     Pass 1
+    ▩▩▩▩▩▩▩▩▩
+    ▩▩▩▩▩▩▩▩▩
+    ▩▩▩▩▩▩▩▩▩
+    ▩▩▩▩▩▩▩▩▩
+    ▩▩▩▩▩▩▩▩▩
+    ▩▩▩▩▩▩▩▩▩
+    ▩▩▩▩▩▩▩▩▩
+    ▩▩▩▩▩▩▩▩▩
+    ▩▩▩▩▩▩▩▩▩
+
+
+     Pass 2
+    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▩▩▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▩▩
+
+
+     Pass 3
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢  ▢▢▢▢▢▢▢▢▢
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+    ▩▩▩▢▢▢▢▢▢  ▢▢▩▩▩▢▢▢▢  ▢▢▢▢▩▩▩▢▢  ▢▢▢▢▢▢▩▩▩
+</pre>
+
+Let's think about what's happening here.
+
+* On pass `0`, we break up the grid into a 1x1 set of chunks and displace them (well, "it").
+* On pass `1`, we break up the grid into a 2x2 set of chunks and displace them.
+* On pass `2`, we break up the grid into a 4x4 set of chunks and displace them.
+
+This 9x9 heightmap was made with an exponent of 3 (\\(2^3 + 1 = 9\\)) and we
+need 3 "passes" to finish it.  This isn't a coincidence — it's the reason we
+chose our heightmap resolutions to be \\(2^n + 1\\).
+
+So at iteration \\(i\\), we need to displace a \\(2^i\\)x\\(2^i\\) collection of
+squares.  Let's go:
+
+```clojure
+(defn midpoint-displacement [heightmap]
+  (mpd-init-corners heightmap)
+  (loop [iter 0
+         spread 0.3]
+    (when (< iter heightmap.exponent)
+      (let [chunks (Math.pow 2 iter)
+            chunk-width (/ (- heightmap.resolution 1) chunks)]
+        (do-nested xchunk ychunk chunks
+          (let [left-x (* chunk-width xchunk)
+                right-x (+ left-x chunk-width)
+                bottom-y (* chunk-width ychunk)
+                top-y (+ bottom-y chunk-width)]
+                (mpd-displace heightmap
+                              left-x right-x bottom-y top-y
+                              spread))))
+      (recur (+ 1 iter) (* spread 0.5))))
+  (normalize heightmap))
+```
+
+That's a lot to take in.  Let's break it down:
+
+```clojure
+(defn midpoint-displacement [heightmap]
+  (mpd-init-corners heightmap)
+  (loop [iter 0
+         spread 0.3]
+    (when (< iter heightmap.exponent)
+      ; Process the chunks at this iteration
+      (recur (+ 1 iter) (* spread 0.5))))
+  (normalize heightmap))
+```
+
+We initialize the corners at the beginning and normalize the heightmap at the
+end.  Then we loop a number of times equal to the exponent we used to make the
+heightmap, as described above.  Each time through the loop we increment `iter`
+and cut the `spread` for those points in half.
+
+For each pass, we figure out what we're going to need to do:
+
+```clojure
+(let [chunks (Math.pow 2 iter)
+      chunk-width (/ (- heightmap.resolution 1) chunks)]
+  ; Actually do it...
+  )
+```
+
+Let's make a quick "nested for loop" syntax.  It'll make things easier to read
+in the main function and we'll need it for later algorithms too:
+
+```clojure
+(defmacro do-nested [xname yname width & body]
+  (let [iterations (gensym)]
+    `(let [~iterations ~width]
+       (do-times ~xname ~iterations
+         (do-times ~yname ~iterations
+           ~@body)))))
+```
+
+This lets us say something like `(do-nested x y 5 (console.log [x y]))` to mean:
+
+```javascript
+for (x = 0; x < 5; x++) {
+    for (y = 0; y < 5; y++) {
+        console.log([x, y]);
+    }
+}
+```
+
+And now we can see how we process the chunks:
+
+```clojure
+(let [chunks (Math.pow 2 iter)
+      chunk-width (/ (- heightmap.resolution 1) chunks)]
+  (do-nested xchunk ychunk chunks
+    (let [left-x (* chunk-width xchunk)
+          right-x (+ left-x chunk-width)
+          bottom-y (* chunk-width ychunk)
+          top-y (+ bottom-y chunk-width)]
+          (mpd-displace heightmap
+                        left-x right-x bottom-y top-y
+                        spread))))
+```
+
+We loop over the indices of the chunks, calculate the bounds for each one, and
+displace it.  Simple enough, but a bit fiddly to get right.  And now we've
+finished displacing all the points!
+
+We could have done this recursively, but I was in an iterative mood when I wrote
+this.  Feel free to play around with it.
+
+<div id="demo-mpd-4" class="threejs"></div>
+
+## Result
+
+Now that we've got a working algorithm we can play around with the values and
+see what effect they have on the resulting terrain.
+
+**Warning**: don't set the exponent higher than 8 unless you want to crash this
+browser tab.  An exponent of `8` results in a heightmap with `66049` elements.
+Going to `9` is `263169`, which most browsers seem to... dislike.
+
+<div id="demo-final" class="threejs"></div>
+<div id="demo-final-controls">
+    <p>
+        <label>Exponent
+            <input type="number" id="input-exponent" value="5"></input>
+        </label>
+        <br/>
+        <label>Starting Spread
+            <input type="number" id="input-starting-spread" value="0.3"></input>
+        </label>
+        <br/>
+        <label>Spread Reduction Constant
+            <input type="number" id="input-spread-reduction" value="0.5"></input>
+        </label>
+    </p>
+</div>
+
+And that's it, we've grown some mountains!
+
+Now that we've got some of the boilerplate down I'm planning on doing a couple
+more posts like this looking at other noise algorithms, and maybe some erosion
+algorithms to simulate weathering.  Let me know if you've got any specific
+requests!
+
--- a/content/blog/2016/03/recursive-midpoint-displacement.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,274 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% load mathjax %}
-
-    {% hyde
-        title: "Recursive Midpoint Displacement"
-        snip: "A cleaner version."
-        created: 2016-03-07 13:45:00
-    %}
-
-    {% block extra_js %}
-        <script data-cfasync="false" src="/media/js/three.min.js"></script>
-        <script data-cfasync="false" src="/media/js/TrackballControls.js"></script>
-
-        <script data-cfasync="false" src="/media/js/terrain2.js"></script>
-    {% endblock extra_js %}
-
-    {% block article %}
-
-In the [last post][mpd] we looked at implementing the Midpoint Displacement
-algorithm.  I ended up doing the last step iteratively, which works, but isn't
-the cleanest way to do it.  Before moving on to other algorithms I wanted to
-clean things up by using a handy library.
-
-The full series of posts so far:
-
-* [Midpoint Displacement](/blog/2016/02/midpoint-displacement/)
-* [Recursive Midpoint Displacement](/blog/2016/03/recursive-midpoint-displacement/)
-* [Diamond Square](/blog/2016/06/diamond-square/)
-
-[mpd]: /blog/2016/02/midpoint-displacement/
-
-[TOC]
-
-## Multi-Dimensional Arrays
-
-Last week when looking at something unrelated I came across the [ndarray][]
-library ("nd" stands for "n-dimensional").  This is a little wrapper around
-standard Javascript arrays to add easy multi-dimensional indexing.  We're going
-to to use `Float64Array` objects as the underlying storage because they're much
-more efficient than the vanilla Javascript arrays and they're fairly well
-supported.
-
-It also adds [slicing][], which is a lot like Common Lisp's [displaced
-arrays][disp-arr].  It lets you create a new "array" object with a different
-"shape" that doesn't have any actual storage of its own, but instead refers back
-to the original array's data.  This is perfect for implementing Midpoint
-Displacement with recursion.
-
-[ndarray]: https://github.com/scijs/ndarray
-[slicing]: https://github.com/scijs/ndarray#slicing
-[disp-arr]: http://clhs.lisp.se/Body/26_glo_d.htm#displaced_array
-
-## Iteration
-
-We're still going to need to iterate over ndarrays at certain points (e.g. when
-normalizing them) so let's make some helpful macros to do the annoying busywork
-for us:
-
-    :::clojure
-    (defmacro do-ndarray [vars array-form & body]
-      (let [array-var (gensym "array")
-            build
-            (fn build [vars n]
-              (if (empty? vars)
-                `(do ~@body)
-                `(do-times ~(first vars) (aget (.-shape ~array-var) ~n)
-                   ~(build (rest vars) (inc n)))))]
-        `(let [~array-var ~array-form]
-           ~(build vars 0))))
-
-    (defmacro do-ndarray-el [element array-form & body]
-      (let [index (gensym "index")
-            array (gensym "array")]
-        `(let [~array ~array-form]
-           (do-times ~index (.-length (.-data ~array))
-             (let [~element (aget (.-data ~array) ~index)]
-               ~@body)))))
-
-Now we can easily iterate over the indices:
-
-    :::clojure
-    (do-ndarray [x y] my-ndarray
-      (console.log "Array[" x "][" y "] is: "
-                   (.get my-ndarray x y)))
-
-Or just over the items if we don't need their indices:
-
-    :::clojure
-    (do-ndarray-el item my-ndarray
-      (console.log item))
-
-These macros should work for ndarrays of any number of dimensions, and will
-compile into ugly but fast Javascript `for` loops.
-
-## Updating the Heightmaps
-
-To start we'll need to update the heightmap functions to work with ndarrays
-instead of the normal JS arrays.
-
-Start with a few functions to calculate sizes/incides:
-
-    :::clojure
-    (defn heightmap-resolution [heightmap]
-      (aget heightmap.shape 0))
-
-    (defn heightmap-last-index [heightmap]
-      (dec (heightmap-resolution heightmap)))
-
-    (defn heightmap-center-index [heightmap]
-      (midpoint 0 (heightmap-last-index heightmap)))
-
-Support for reading/writing:
-
-    :::clojure
-    (defn heightmap-get [heightmap x y]
-      (.get heightmap x y))
-
-    (defn heightmap-get-safe [heightmap x y]
-      (let [last (heightmap-last-index heightmap)]
-        (when (and (<= 0 x last)
-                   (<= 0 y last))
-          (heightmap-get heightmap x y))))
-
-    (defn heightmap-set! [heightmap x y val]
-      (.set heightmap x y val))
-
-    (defn heightmap-set-if-unset! [heightmap x y val]
-      (when (== 0 (heightmap-get heightmap x y))
-        (heightmap-set! heightmap x y val)))
-
-Normalization:
-
-    :::clojure
-    (defn normalize [heightmap]
-      (let [max (- Infinity)
-            min Infinity]
-        (do-ndarray-el el heightmap
-          (when (< max el) (set! max el))
-          (when (> min el) (set! min el)))
-        (let [span (- max min)]
-          (do-ndarray [x y] heightmap
-            (heightmap-set! heightmap x y
-                            (/ (- (heightmap-get heightmap x y) min)
-                               span))))))
-
-Creation:
-
-    :::clojure
-    (defn make-heightmap [exponent]
-      (let [resolution (+ (Math.pow 2 exponent) 1)]
-        (let [heightmap (ndarray (new Float64Array (* resolution resolution))
-                                 [resolution resolution])]
-          (set! heightmap.exponent exponent)
-          (set! heightmap.resolution resolution)
-          (set! heightmap.last (dec resolution))
-          heightmap)))
-
-I'm not going to go through all the code here line-by-line because it's mostly
-just a simple update of the last post.
-
-## Slicing Heightmaps
-
-Part of the Midpoint Displacement is "repeat the process on the four corner
-squares of this one", and with ndarray we can make getting those corners much
-simpler:
-
-    :::clojure
-    (defn top-left-corner [heightmap]
-      (let [center (heightmap-center-index heightmap)]
-        (-> heightmap
-          (.lo 0 0)
-          (.hi (inc center) (inc center)))))
-
-    (defn top-right-corner [heightmap]
-      (let [center (heightmap-center-index heightmap)]
-        (-> heightmap
-          (.lo center 0)
-          (.hi (inc center) (inc center)))))
-
-    (defn bottom-left-corner [heightmap]
-      (let [center (heightmap-center-index heightmap)]
-        (-> heightmap
-          (.lo 0 center)
-          (.hi (inc center) (inc center)))))
-
-    (defn bottom-right-corner [heightmap]
-      (let [center (heightmap-center-index heightmap)]
-        (-> heightmap
-          (.lo center center)
-          (.hi (inc center) (inc center)))))
-
-Each of these will return a "slice" of the underlying ndarray that looks and
-acts like a fresh array (e.g. its indices start at `0`, `0`), but that uses the
-appropriate part of the original array as the data storage.
-
-## Updating the Algorithm
-
-Now we can turn the algorithm into a recursive version.  With the slicing
-functions it's pretty simple.  Initializing the corners is still trivial:
-
-    :::clojure
-    (defn mpd-init-corners [heightmap]
-      (let [last (heightmap-last-index heightmap)]
-        (heightmap-set! heightmap 0    0    (rand))
-        (heightmap-set! heightmap 0    last (rand))
-        (heightmap-set! heightmap last 0    (rand))
-        (heightmap-set! heightmap last last (rand))))
-
-The meat of the algorithm looks long, but is mostly just calculating all the
-appropriate numbers with readable names:
-
-    :::clojure
-    (defn mpd-displace [heightmap spread spread-reduction]
-      (let [last (heightmap-last-index heightmap)
-            c (midpoint 0 last)
-
-            ; Get the values of the corners
-            bottom-left  (heightmap-get heightmap 0    0)
-            bottom-right (heightmap-get heightmap last 0)
-            top-left     (heightmap-get heightmap 0    last)
-            top-right    (heightmap-get heightmap last last)
-
-            ; Calculate the averages for the points we're going to fill
-            top    (average2 top-left top-right)
-            left   (average2 bottom-left top-left)
-            bottom (average2 bottom-left bottom-right)
-            right  (average2 bottom-right top-right)
-            center (average4 top left bottom right)
-
-            next-spread (* spread spread-reduction)]
-        ; Set the four edge midpoint values
-        (heightmap-set-if-unset! heightmap c    0    (jitter bottom spread))
-        (heightmap-set-if-unset! heightmap c    last (jitter top spread))
-        (heightmap-set-if-unset! heightmap 0    c    (jitter left spread))
-        (heightmap-set-if-unset! heightmap last c    (jitter right spread))
-
-        ; Set the center value
-        (heightmap-set-if-unset! heightmap c    c    (jitter center spread))
-
-        ; Recurse on the four corners if necessary (3x3 is the base case)
-        (when-not (== 3 (heightmap-resolution heightmap))
-          (mpd-displace (top-left-corner heightmap) next-spread spread-reduction)
-          (mpd-displace (top-right-corner heightmap) next-spread spread-reduction)
-          (mpd-displace (bottom-left-corner heightmap) next-spread spread-reduction)
-          (mpd-displace (bottom-right-corner heightmap) next-spread spread-reduction))))
-
-The main wrapper function is simple:
-
-    :::clojure
-    (defn midpoint-displacement [heightmap]
-      (let [initial-spread 0.3
-            spread-reduction 0.55]
-        (mpd-init-corners heightmap)
-        (mpd-displace heightmap initial-spread spread-reduction)
-        (normalize heightmap)))
-
-## Result
-
-The result looks the same as before, but will generate the heightmaps a lot
-faster because it's operating on a `Float64Array` instead of a vanilla JS array.
-
-<div id="demo-final" class="threejs"></div>
-
-The code for these blog posts is a bit of a mess because I've been copy/pasting
-to show the partially-completed demos.  To fix that I've created a little
-[single-page demo][ymir] with completed versions of the various algorithms you
-can play with.  [The code for that][ymir-code] should be a lot more readable
-than the hacky code for these posts.
-
-[ymir]: http://ymir.stevelosh.com/
-[ymir-code]: http://bitbucket.org/sjl/ymir/
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2016/03/recursive-midpoint-displacement.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,278 @@
++++
+title = "Recursive Midpoint Displacement"
+snip = "A cleaner version."
+date = 2016-03-07T13:45:00Z
+draft = false
+
++++
+
+<script data-cfasync="false" src="/media/js/three.min.js"></script>
+<script data-cfasync="false" src="/media/js/TrackballControls.js"></script>
+
+<script data-cfasync="false" src="/media/js/terrain2.js"></script>
+
+In the [last post][mpd] we looked at implementing the Midpoint Displacement
+algorithm.  I ended up doing the last step iteratively, which works, but isn't
+the cleanest way to do it.  Before moving on to other algorithms I wanted to
+clean things up by using a handy library.
+
+The full series of posts so far:
+
+* [Midpoint Displacement](/blog/2016/02/midpoint-displacement/)
+* [Recursive Midpoint Displacement](/blog/2016/03/recursive-midpoint-displacement/)
+* [Diamond Square](/blog/2016/06/diamond-square/)
+
+[mpd]: /blog/2016/02/midpoint-displacement/
+
+{{% toc %}}
+
+## Multi-Dimensional Arrays
+
+Last week when looking at something unrelated I came across the [ndarray][]
+library ("nd" stands for "n-dimensional").  This is a little wrapper around
+standard Javascript arrays to add easy multi-dimensional indexing.  We're going
+to to use `Float64Array` objects as the underlying storage because they're much
+more efficient than the vanilla Javascript arrays and they're fairly well
+supported.
+
+It also adds [slicing][], which is a lot like Common Lisp's [displaced
+arrays][disp-arr].  It lets you create a new "array" object with a different
+"shape" that doesn't have any actual storage of its own, but instead refers back
+to the original array's data.  This is perfect for implementing Midpoint
+Displacement with recursion.
+
+[ndarray]: https://github.com/scijs/ndarray
+[slicing]: https://github.com/scijs/ndarray#slicing
+[disp-arr]: http://clhs.lisp.se/Body/26_glo_d.htm#displaced_array
+
+## Iteration
+
+We're still going to need to iterate over ndarrays at certain points (e.g. when
+normalizing them) so let's make some helpful macros to do the annoying busywork
+for us:
+
+```clojure
+(defmacro do-ndarray [vars array-form & body]
+  (let [array-var (gensym "array")
+        build
+        (fn build [vars n]
+          (if (empty? vars)
+            `(do ~@body)
+            `(do-times ~(first vars) (aget (.-shape ~array-var) ~n)
+               ~(build (rest vars) (inc n)))))]
+    `(let [~array-var ~array-form]
+       ~(build vars 0))))
+
+(defmacro do-ndarray-el [element array-form & body]
+  (let [index (gensym "index")
+        array (gensym "array")]
+    `(let [~array ~array-form]
+       (do-times ~index (.-length (.-data ~array))
+         (let [~element (aget (.-data ~array) ~index)]
+           ~@body)))))
+```
+
+Now we can easily iterate over the indices:
+
+```clojure
+(do-ndarray [x y] my-ndarray
+  (console.log "Array[" x "][" y "] is: "
+               (.get my-ndarray x y)))
+```
+
+Or just over the items if we don't need their indices:
+
+```clojure
+(do-ndarray-el item my-ndarray
+  (console.log item))
+```
+
+These macros should work for ndarrays of any number of dimensions, and will
+compile into ugly but fast Javascript `for` loops.
+
+## Updating the Heightmaps
+
+To start we'll need to update the heightmap functions to work with ndarrays
+instead of the normal JS arrays.
+
+Start with a few functions to calculate sizes/incides:
+
+```clojure
+(defn heightmap-resolution [heightmap]
+  (aget heightmap.shape 0))
+
+(defn heightmap-last-index [heightmap]
+  (dec (heightmap-resolution heightmap)))
+
+(defn heightmap-center-index [heightmap]
+  (midpoint 0 (heightmap-last-index heightmap)))
+```
+
+Support for reading/writing:
+
+```clojure
+(defn heightmap-get [heightmap x y]
+  (.get heightmap x y))
+
+(defn heightmap-get-safe [heightmap x y]
+  (let [last (heightmap-last-index heightmap)]
+    (when (and (<= 0 x last)
+               (<= 0 y last))
+      (heightmap-get heightmap x y))))
+
+(defn heightmap-set! [heightmap x y val]
+  (.set heightmap x y val))
+
+(defn heightmap-set-if-unset! [heightmap x y val]
+  (when (== 0 (heightmap-get heightmap x y))
+    (heightmap-set! heightmap x y val)))
+```
+
+Normalization:
+
+```clojure
+(defn normalize [heightmap]
+  (let [max (- Infinity)
+        min Infinity]
+    (do-ndarray-el el heightmap
+      (when (< max el) (set! max el))
+      (when (> min el) (set! min el)))
+    (let [span (- max min)]
+      (do-ndarray [x y] heightmap
+        (heightmap-set! heightmap x y
+                        (/ (- (heightmap-get heightmap x y) min)
+                           span))))))
+```
+
+Creation:
+
+```clojure
+(defn make-heightmap [exponent]
+  (let [resolution (+ (Math.pow 2 exponent) 1)]
+    (let [heightmap (ndarray (new Float64Array (* resolution resolution))
+                             [resolution resolution])]
+      (set! heightmap.exponent exponent)
+      (set! heightmap.resolution resolution)
+      (set! heightmap.last (dec resolution))
+      heightmap)))
+```
+
+I'm not going to go through all the code here line-by-line because it's mostly
+just a simple update of the last post.
+
+## Slicing Heightmaps
+
+Part of the Midpoint Displacement is "repeat the process on the four corner
+squares of this one", and with ndarray we can make getting those corners much
+simpler:
+
+```clojure
+(defn top-left-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo 0 0)
+      (.hi (inc center) (inc center)))))
+
+(defn top-right-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo center 0)
+      (.hi (inc center) (inc center)))))
+
+(defn bottom-left-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo 0 center)
+      (.hi (inc center) (inc center)))))
+
+(defn bottom-right-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo center center)
+      (.hi (inc center) (inc center)))))
+```
+
+Each of these will return a "slice" of the underlying ndarray that looks and
+acts like a fresh array (e.g. its indices start at `0`, `0`), but that uses the
+appropriate part of the original array as the data storage.
+
+## Updating the Algorithm
+
+Now we can turn the algorithm into a recursive version.  With the slicing
+functions it's pretty simple.  Initializing the corners is still trivial:
+
+```clojure
+(defn mpd-init-corners [heightmap]
+  (let [last (heightmap-last-index heightmap)]
+    (heightmap-set! heightmap 0    0    (rand))
+    (heightmap-set! heightmap 0    last (rand))
+    (heightmap-set! heightmap last 0    (rand))
+    (heightmap-set! heightmap last last (rand))))
+```
+
+The meat of the algorithm looks long, but is mostly just calculating all the
+appropriate numbers with readable names:
+
+```clojure
+(defn mpd-displace [heightmap spread spread-reduction]
+  (let [last (heightmap-last-index heightmap)
+        c (midpoint 0 last)
+
+        ; Get the values of the corners
+        bottom-left  (heightmap-get heightmap 0    0)
+        bottom-right (heightmap-get heightmap last 0)
+        top-left     (heightmap-get heightmap 0    last)
+        top-right    (heightmap-get heightmap last last)
+
+        ; Calculate the averages for the points we're going to fill
+        top    (average2 top-left top-right)
+        left   (average2 bottom-left top-left)
+        bottom (average2 bottom-left bottom-right)
+        right  (average2 bottom-right top-right)
+        center (average4 top left bottom right)
+
+        next-spread (* spread spread-reduction)]
+    ; Set the four edge midpoint values
+    (heightmap-set-if-unset! heightmap c    0    (jitter bottom spread))
+    (heightmap-set-if-unset! heightmap c    last (jitter top spread))
+    (heightmap-set-if-unset! heightmap 0    c    (jitter left spread))
+    (heightmap-set-if-unset! heightmap last c    (jitter right spread))
+
+    ; Set the center value
+    (heightmap-set-if-unset! heightmap c    c    (jitter center spread))
+
+    ; Recurse on the four corners if necessary (3x3 is the base case)
+    (when-not (== 3 (heightmap-resolution heightmap))
+      (mpd-displace (top-left-corner heightmap) next-spread spread-reduction)
+      (mpd-displace (top-right-corner heightmap) next-spread spread-reduction)
+      (mpd-displace (bottom-left-corner heightmap) next-spread spread-reduction)
+      (mpd-displace (bottom-right-corner heightmap) next-spread spread-reduction))))
+```
+
+The main wrapper function is simple:
+
+```clojure
+(defn midpoint-displacement [heightmap]
+  (let [initial-spread 0.3
+        spread-reduction 0.55]
+    (mpd-init-corners heightmap)
+    (mpd-displace heightmap initial-spread spread-reduction)
+    (normalize heightmap)))
+```
+
+## Result
+
+The result looks the same as before, but will generate the heightmaps a lot
+faster because it's operating on a `Float64Array` instead of a vanilla JS array.
+
+<div id="demo-final" class="threejs"></div>
+
+The code for these blog posts is a bit of a mess because I've been copy/pasting
+to show the partially-completed demos.  To fix that I've created a little
+[single-page demo][ymir] with completed versions of the various algorithms you
+can play with.  [The code for that][ymir-code] should be a lot more readable
+than the hacky code for these posts.
+
+[ymir]: http://ymir.stevelosh.com/
+[ymir-code]: http://bitbucket.org/sjl/ymir/
+
--- a/content/blog/2016/06/diamond-square.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,476 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% load mathjax %}
-
-    {% hyde
-        title: "Terrain Generation with Diamond Square"
-        snip: "Improving on Midpoint Displacement."
-        created: 2016-06-27 13:35:00
-    %}
-
-    {% block extra_js %}
-        <script data-cfasync="false" src="/media/js/three.min.js"></script>
-        <script data-cfasync="false" src="/media/js/TrackballControls.js"></script>
-        <script data-cfasync="false" src="/media/js/terrain3.js"></script>
-    {% endblock extra_js %}
-
-    {% block article %}
-
-In the last two posts we looked at implementing the Midpoint Displacement
-algorithm for procedurally generating terrain.  Today we're going to look at
-a similar algorithm called Diamond Square that fixes some problems with Midpoint
-Displacement.
-
-The full series of posts so far:
-
-* [Midpoint Displacement](/blog/2016/02/midpoint-displacement/)
-* [Recursive Midpoint Displacement](/blog/2016/03/recursive-midpoint-displacement/)
-* [Diamond Square](/blog/2016/06/diamond-square/)
-
-Midpoint Displacement is simple and fast, but it has some flaws.  If you look at
-the end result you'll probably start to notice "seams" in the terrain that
-appear on perfectly square chunks.  This happens because when you're calculating
-the midpoints of the edges of each square you're only averaging two sources of
-information.
-
-[Diamond Square][] is an algorithm that works a lot like Midpoint Displacement,
-but it adds an extra step to ensure that (almost) every point uses *four*
-sources of data.  This reduces the visual artifacts a lot without much extra
-effort.
-
-Let's [draw the owl][owl].
-
-[Diamond Square]: https://en.wikipedia.org/wiki/Diamond-square_algorithm
-[owl]: https://i.imgur.com/RadSf.jpg
-
-[TOC]
-
-## Overview
-
-The high-level description of Diamond Square goes something like this:
-
-1. Initialize the corners to random values.
-2. Set the center of the heightmap to the average of the corners (plus jitter).
-3. Set the midpoints of the edges of the heightmap to the average of the four
-   points on the "diamond" around them (plus jitter).
-4. Repeat steps 2-4 on successively smaller chunks of the heightmap until you
-   bottom out at 3x3 chunks.
-
-## Initialization
-
-Initialization is pretty simple:
-
-    :::clojure
-    (defn ds-init-corners [heightmap]
-      (let [last (heightmap-last-index heightmap)]
-        (heightmap-set! heightmap 0    0    (rand))
-        (heightmap-set! heightmap 0    last (rand))
-        (heightmap-set! heightmap last 0    (rand))
-        (heightmap-set! heightmap last last (rand))))
-
-Just set the corners to random values, exactly like we did in Midpoint
-Displacement.
-
-<div id="demo-1" class="threejs"></div>
-
-## Square
-
-In the "square" step of Diamond Square, we take a square region of the heightmap
-and set the center of it to the average of the four corners (plus jitter).
-
-<pre class="lineart">
-           Column
-         0 1 2 3 4         0 1 2 3 4         0 1 2 3 4
-        ┌─┬─┬─┬─┬─┐       ┌─┬─┬─┬─┬─┐       ┌─┬─┬─┬─┬─┐
-      0 │1│ │ │ │8│     0 │1│ │ │ │8│     0 │1│ │ │ │8│
-        ├─┼─┼─┼─┼─┤       ├─╲─┼─┼─╱─┤       ├─╲─┼─┼─╱─┤
-      1 │ │ │ │ │ │     1 │ │╲│ │╱│ │     1 │ │╲│ │╱│ │
-    R   ├─┼─┼─┼─┼─┤       ├─┼─◢─◣─┼─┤       ├─┼─◢─◣─┼─┤
-    o 2 │ │ │◉│ │ │     2 │ │ │◉│ │ │     2 │ │ │3│ │ │
-    w   ├─┼─┼─┼─┼─┤       ├─┼─◥─◤─┼─┤       ├─┼─◥─◤─┼─┤
-      3 │ │ │ │ │ │     3 │ │╱│ │╲│ │     3 │ │╱│ │╲│ │
-        ├─┼─┼─┼─┼─┤       ├─╱─┼─┼─╲─┤       ├─╱─┼─┼─╲─┤
-      4 │0│ │ │ │3│     4 │0│ │ │ │3│     4 │0│ │ │ │3│
-        └─┴─┴─┴─┴─┘       └─┴─┴─┴─┴─┘       └─┴─┴─┴─┴─┘
-</pre>
-
-The Wikipedia article calls this the "diamond" step, but that seems backwards to
-me.  We're operating on a *square* region of the heightmap, so this should be
-the *square* step.
-
-Since we're no longer working with heightmap "slices" like we were in the
-previous post, we'll need a way to specify the square chunk of the heightmap
-we're working on.  I chose to use a center point (`x` and `y` coordinates) and
-a radius:
-
-    :::clojure
-    (defn ds-square [heightmap x y radius spread]
-      (let [new-height
-            (jitter
-              (average4
-                (heightmap-get heightmap (- x radius) (- y radius))
-                (heightmap-get heightmap (- x radius) (+ y radius))
-                (heightmap-get heightmap (+ x radius) (- y radius))
-                (heightmap-get heightmap (+ x radius) (+ y radius)))
-              spread)]
-        (heightmap-set! heightmap x y new-height)))
-
-<div id="demo-2" class="threejs"></div>
-
-## Diamond
-
-In the "diamond" step of Diamond Square, we take a diamond-shaped region and set
-the center of it to the average of the four corners:
-
-<pre class="lineart">
-               Column
-         0 1 2 3 4 5 6 7 8        0 1 2 3 4 5 6 7 8
-        ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐
-      0 │1│ │ │ │3│ │ │ │3│    0 │1│ │ │ │3│ │ │ │3│
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─╱─╲─┼─┼─┼─┤
-      1 │ │ │ │ │ │ │ │ │ │    1 │ │ │ │╱│ │╲│ │ │ │
-    R   ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─╱─┼─┼─╲─┼─┼─┤
-    o 2 │ │ │3│ │ │ │4│ │ │    2 │ │ │3│ │◉│ │4│ │ │
-    w   ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─╲─┼─┼─╱─┼─┼─┤
-      3 │ │ │ │ │ │ │ │ │ │    3 │ │ │ │╲│ │╱│ │ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─╲─╱─┼─┼─┼─┤
-      4 │5│ │ │ │5│ │ │ │5│    4 │5│ │ │ │5│ │ │ │5│
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      5 │ │ │ │ │ │ │ │ │ │    5 │ │ │ │ │ │ │ │ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      6 │ │ │7│ │ │ │6│ │ │    6 │ │ │7│ │ │ │6│ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      7 │ │ │ │ │ │ │ │ │ │    7 │ │ │ │ │ │ │ │ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      8 │9│ │ │ │7│ │ │ │7│    8 │9│ │ │ │7│ │ │ │7│
-        └─┴─┴─┴─┴─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┴─┴─┴─┴─┘
-
-               Column
-         0 1 2 3 4 5 6 7 8        0 1 2 3 4 5 6 7 8
-        ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐
-      0 │1│ │ │ │3│ │ │ │3│    0 │1│ │ │ │3│ │ │ │3│
-        ├─┼─┼─┼─╱┬╲─┼─┼─┼─┤      ├─┼─┼─┼─╱┬╲─┼─┼─┼─┤
-      1 │ │ │ │╱│││╲│ │ │ │    1 │ │ │ │╱│││╲│ │ │ │
-    R   ├─┼─┼─╱─┼▼┼─╲─┼─┼─┤      ├─┼─┼─╱─┼▼┼─╲─┼─┼─┤
-    o 2 │ │ │3├─▶◉◀─┤4│ │ │    2 │ │ │3├─▶4◀─┤4│ │ │
-    w   ├─┼─┼─╲─┼▲┼─╱─┼─┼─┤      ├─┼─┼─╲─┼▲┼─╱─┼─┼─┤
-      3 │ │ │ │╲│││╱│ │ │ │    3 │ │ │ │╲│││╱│ │ │ │
-        ├─┼─┼─┼─╲┴╱─┼─┼─┼─┤      ├─┼─┼─┼─╲┴╱─┼─┼─┼─┤
-      4 │5│ │ │ │5│ │ │ │5│    4 │5│ │ │ │5│ │ │ │5│
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      5 │ │ │ │ │ │ │ │ │ │    5 │ │ │ │ │ │ │ │ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      6 │ │ │7│ │ │ │6│ │ │    6 │ │ │7│ │ │ │6│ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      7 │ │ │ │ │ │ │ │ │ │    7 │ │ │ │ │ │ │ │ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      8 │9│ │ │ │7│ │ │ │7│    8 │9│ │ │ │7│ │ │ │7│
-        └─┴─┴─┴─┴─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┴─┴─┴─┴─┘
-</pre>
-
-Once again we'll use a center point and radius to specify the region inside the
-heightmap:
-
-    :::clojure
-    (defn ds-diamond [heightmap x y radius spread]
-      (let [new-height
-            (jitter
-              (safe-average
-                (heightmap-get-safe heightmap (- x radius) y)
-                (heightmap-get-safe heightmap (+ x radius) y)
-                (heightmap-get-safe heightmap x (- y radius))
-                (heightmap-get-safe heightmap x (+ y radius)))
-              spread)]
-        (heightmap-set! heightmap x y new-height)))
-
-<div id="demo-3" class="threejs"></div>
-
-## Edge Cases
-
-You might have noticed that we used `heightmap-get-safe` and `safe-average` in
-the `ds-diamond` code.  This is to handle the diamonds on the edge of the
-heightmap.  Those diamonds only have three points to average:
-
-<pre class="lineart">
-           Column
-         0 1 2 3 4        0 1 2 3 4
-        ┌─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┐
-      0 │1│ │ │ │8│    0 │1│ │ │ │8│
-        ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─╱┬╲
-      1 │ │ │ │ │ │    1 │ │ │ │╱│││╲
-    R   ├─┼─┼─┼─┼─┤      ├─┼─┼─╱─┼▼┤ ╲
-    o 2 │ │ │3│ │ │    2 │ │ │3├─▶◉◀──?
-    w   ├─┼─┼─┼─┼─┤      ├─┼─┼─╲─┼▲┤ ╱
-      3 │ │ │ │ │ │    3 │ │ │ │╲│││╱
-        ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─╲┴╱
-      4 │0│ │ │ │3│    4 │0│ │ │ │3│
-        └─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┘
-</pre>
-
-So we just ignore the missing point:
-
-    :::clojure
-    (defn safe-average [a b c d]
-      (let [total 0 count 0]
-        (when a (add! total a) (inc! count))
-        (when b (add! total b) (inc! count))
-        (when c (add! total c) (inc! count))
-        (when d (add! total d) (inc! count))
-        (/ total count)))
-
-    (defn heightmap-get-safe [heightmap x y]
-      (let [last (heightmap-last-index heightmap)]
-        (when (and (<= 0 x last)
-                   (<= 0 y last))
-          (heightmap-get heightmap x y))))
-
-Technically this means they have less information to work with than the rest of
-the points, and you might see some slight artifacts.  But in practice it's not
-too bad, and it's a lot nicer than midpoint displacement where *every* line step
-uses only *two* points.
-
-Another way to handle this is to also wrap those edge coordinates around and
-pull the point from the other side of the heightmap.  This is a bit more work
-but gives you an extra benefit: the heightmap will be tileable (**update**: like
-everything where someone doesn't show you running code, it's [not actually that
-simple](/blog/2016/08/lisp-jam-postmortem/#tiling-diamond-square)).
-
-## Iteration
-
-Unfortunately we can't use recursion to iterate for Diamond Square like we did
-for Midpoint Displacement.  We have to interleave the diamond and square steps,
-performing each round of squares on the *entire* map before moving on to a round
-of diamonds.  If we don't, bad things will happen.
-
-Let's look at an example to see why.  First we perform the initial square step:
-
-<pre class="lineart">
-           Column
-         0 1 2 3 4        0 1 2 3 4
-        ┌─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┐
-      0 │1│ │ │ │8│    0 │1│ │ │ │8│
-        ├─┼─┼─┼─┼─┤      ├─╲─┼─┼─╱─┤
-      1 │ │ │ │ │ │    1 │ │╲│ │╱│ │
-    R   ├─┼─┼─┼─┼─┤      ├─┼─◢─◣─┼─┤
-    o 2 │ │ │ │ │ │    2 │ │ │3│ │ │
-    w   ├─┼─┼─┼─┼─┤      ├─┼─◥─◤─┼─┤
-      3 │ │ │ │ │ │    3 │ │╱│ │╲│ │
-        ├─┼─┼─┼─┼─┤      ├─╱─┼─┼─╲─┤
-      4 │0│ │ │ │3│    4 │0│ │ │ │3│
-        └─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┘
-</pre>
-
-That's fine.  Then we recurse into the first of the four diamonds:
-
-<pre class="lineart">
-           Column
-         0 1 2 3 4        0 1 2 3 4
-        ┌─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┐
-      0 │1│ │ │ │8│    0 │1├─▶4◀─┤8│
-        ├─┼─┼─┼─┼─┤      ├─╲─┼▲┼─╱─┤
-      1 │ │ │ │ │ │    1 │ │╲│││╱│ │
-    R   ├─┼─┼─┼─┼─┤      ├─┼─╲┴╱─┼─┤
-    o 2 │ │ │3│ │ │    2 │ │ │3│ │ │
-    w   ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┤
-      3 │ │ │ │ │ │    3 │ │ │ │ │ │
-        ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┤
-      4 │0│ │ │ │3│    4 │0│ │ │ │3│
-        └─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┘
-</pre>
-
-Everything's still good.  Then we recurse into the square:
-
-<pre class="lineart">
-            Column
-         0 1 2 3 4        0 1 2 3 4
-        ┌─┬─┬─┬─┬─┐      ╔═════╗─┬─┐
-      0 │1│ │4│ │8│    0 ║1│ │4║ │8│
-        ├─┼─┼─┼─┼─┤      ║─◢─◣─║─┼─┤
-      1 │ │ │ │ │ │    1 ║ │ │ ║ │ │
-    R   ├─┼─┼─┼─┼─┤      ║─◥─◤─║─┼─┤
-    o 2 │ │ │3│ │ │    2 ║?│ │3║ │ │
-    w   ├─┼─┼─┼─┼─┤      ╚═════╝─┼─┤
-      3 │ │ │ │ │ │    3 │ │ │ │ │ │
-        ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┤
-      4 │0│ │ │ │3│    4 │0│ │ │ │3│
-        └─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┘
-</pre>
-
-But wait, there's a corner missing!  We needed to complete that left-hand
-diamond step to get it, but that's still waiting on the stack for this line of
-recursion to bottom out.
-
-### A "Strided" Iteration Construct
-
-So we need to use normal iteration.  We can start by writing the code to do
-a single round of diamonds or squares on the heightmap.  First we'll make a nice
-looping construct called `do-stride`:
-
-    :::clojure
-    (defmacro do-stride
-        [varnames start-form end-form stride-form & body]
-      (let [stride (gensym "stride")
-            start (gensym "start")
-            end (gensym "end")
-            build (fn build [vars]
-                    (if (empty? vars)
-                      `(do ~@body)
-                      (let [varname (first vars)]
-                        `(loop [~varname ~start]
-                           (when (< ~varname ~end)
-                             ~(build (rest vars))
-                             (recur (+ ~varname ~stride)))))))]
-        ; Fix the numbers once outside the nested loops,
-        ; and then build the guts.
-        `(let [~start ~start-form
-               ~end ~end-form
-               ~stride ~stride-form]
-           ~(build varnames))))
-
-This scary-looking macro builds the nested looping structure we'll need to
-perform the iteration for our diamonds and squares.  It abstracts away the
-tedium of writing out nested `for` loops so we can focus on the rest of the
-algorithm.
-
-`do-stride` takes a list of variables to bind, a number to start at, a number to
-end before, and a body.  For each variable it starts at `start`, runs `body`,
-increments by `stride`, and loops until the value is at or above `end`.  For
-example:
-
-* `(do-stride [x] 0 5 1 (console.log x))` will log `0 1 2 3 4`.
-* `(do-stride [x] 0 5 2 (console.log x))` will log `0 2 4`.
-* `(do-stride [x y] 0 3 2 (console.log [x y]))` will log `[0, 0] [0, 2] [2, 0]
-  [2, 2]`.
-
-### Square Iteration
-
-Now that we've got this, we can iterate our square step over the heightmap for
-a specific radius:
-
-    :::clojure
-    (defn ds-squares [heightmap radius spread]
-      (do-stride [x y] radius (heightmap-resolution heightmap) (* 2 radius)
-        (ds-square heightmap x y radius spread)))
-
-We use `do-stride` to start at the radius and loop until we fall off the
-heightmap, stepping by *twice* the radius each time.
-
-Because our heightmaps are always square we can use the same values for both
-dimensions.  `do-stride` can take zero or more variables and will just do the
-right thing, so we don't need to worry about it.
-
-The stride is double the radius because as we step between squares we move over
-the right half of the first *and* the left half of the next:
-
-<pre class="lineart">
-               Column
-          0 1 2 3 4 5 6 7 8        0 1 2 3 4 5 6 7 8
-         ╔═════════╗─┬─┬─┬─┐      ╔═════════╗─┬─┬─┬─┐
-       0 ║1│ │ │ │3║ │ │ │3│    0 ║1│ │ │ │3║ │ │ │3│
-         ║─┼─┼─┼─┼─║─┼─┼─┼─┤      ║─┼─┼─┼─┼─║─┼─┼─┼─┤
-       1 ║ │ │ │ │ ║ │ │ │ │    1 ║ │ │ │ │ ║ │ │ │ │
-    R    ║─┼─┼─┼─┼─║─┼─┼─┼─┤     radius ┼─┼─║─┼─┼─┼─┤
-    o  2 ║ │ │◉│ │ ║ │◉│ │ │    2 ║◀━━▶◉◀━━━━━▶◉│ │ │
-    w    ║─┼─┼─┼─┼─║─┼─┼─┼─┤      ║─┼─┼─ stride ┼─┼─┤
-       3 ║ │ │ │ │ ║ │ │ │ │    3 ║ │ │ │ │ ║ │ │ │ │
-         ║─┼─┼─┼─┼─║─┼─┼─┼─┤      ║─┼─┼─┼─┼─║─┼─┼─┼─┤
-       4 ║5│ │ │ │5║ │ │ │5│    4 ║5│ │ │ │5║ │ │ │5│
-         ╚═════════╝─┼─┼─┼─┤      ╚═════════╝─┼─┼─┼─┤
-       5 │ │ │ │ │ │ │ │ │ │    5 │ │ │ │ │ │ │ │ │ │
-         ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-       6 │ │ │◉│ │ │ │◉│ │ │    6 │ │ │◉│ │ │ │◉│ │ │
-         ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-       7 │ │ │ │ │ │ │ │ │ │    7 │ │ │ │ │ │ │ │ │ │
-         ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-       8 │9│ │ │ │7│ │ │ │7│    8 │9│ │ │ │7│ │ │ │7│
-         └─┴─┴─┴─┴─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┴─┴─┴─┴─┘
-</pre>
-
-### Diamond Iteration
-
-The diamonds are a little more complicated.
-
-First of all, in the `y` dimension we need to start at `0` instead of `radius`
-(these will be the top and bottom edge cases we looked at).  Also, in the `x`
-direction all the even iterations need to start at `radius`, while the odd
-iterations should start at `0`.
-
-Hopefully a picture will make it a bit more clear:
-
-<pre class="lineart">
-               Column
-         0 1 2 3 4 5 6 7 8
-        ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐
-      0 │1│ │◉│ │3│ │◉│ │3│ y iteration: 0, start at x = radius
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      1 │ │ │ │ │ │ │ │ │ │
-    R   ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-    o 2 │◉│ │3│ │◉│ │4│ │◉│ y iteration: 1, start at x = 0
-    w   ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      3 │ │ │ │ │ │ │ │ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      4 │5│ │◉│ │5│ │◉│ │5│ y iteration: 2, start at x = radius
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      5 │ │ │ │ │ │ │ │ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      6 │◉│ │7│ │◉│ │6│ │◉│ y iteration: 3, start at x = 0
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      7 │ │ │ │ │ │ │ │ │ │
-        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
-      8 │9│ │◉│ │7│ │◉│ │7│ y iteration: 4, start at x = radius
-        └─┴─┴─┴─┴─┴─┴─┴─┴─┘
-</pre>
-
-The code for the diamonds is the hairiest bit of the algorithm.  Make sure you
-understand it before moving on.  `shift` will be `radius` for even iterations
-and `0` for odd ones:
-
-    :::clojure
-    (defn ds-diamonds [heightmap radius spread]
-      (let [size (heightmap-resolution heightmap)]
-        (do-stride [y] 0 size radius
-          (let [shift (if (even? (/ y radius)) radius 0)]
-            (do-stride [x] shift size (* 2 radius)
-              (ds-diamond heightmap x y radius spread))))))
-
-### Top-Level Iteration
-
-Finally we can put it all together.  We initialize the corners and starting
-values, then loop over smaller and smaller radii and just call `ds-squares` and
-`ds-diamonds` to do the heavy lifting:
-
-    :::clojure
-    (defn diamond-square [heightmap]
-      (let [initial-spread 0.3
-            spread-reduction 0.5
-            center (heightmap-center-index heightmap)
-            size (aget heightmap.shape 0)]
-        (ds-init-corners heightmap)
-        (loop [radius center
-               spread initial-spread]
-          (when (>= radius 1)
-            (ds-squares heightmap radius spread)
-            (ds-diamonds heightmap radius spread)
-            (recur (/ radius 2)
-                   (* spread spread-reduction))))
-        (sanitize heightmap)))
-
-## Result
-
-The end result looks like this:
-
-<div id="demo-final" class="threejs"></div>
-
-It looks a lot like the result from Midpoint Displacement, but without the ugly
-seams around the square chunks.
-
-The code for these blog posts is a bit of a mess because I've been copy/pasting
-to show the partially-completed demos after each step.  I've created a little
-[single-page demo][ymir] with completed versions of the various algorithms you
-can play with, and [that code][ymir-code] should be a lot more readable than the
-hacky code for these posts.
-
-[ymir]: http://ymir.stevelosh.com/
-[ymir-code]: http://bitbucket.org/sjl/ymir/
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2016/06/diamond-square.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,477 @@
++++
+title = "Terrain Generation with Diamond Square"
+snip = "Improving on Midpoint Displacement."
+date = 2016-06-27T13:35:00Z
+draft = false
+
++++
+
+<script data-cfasync="false" src="/media/js/three.min.js"></script>
+<script data-cfasync="false" src="/media/js/TrackballControls.js"></script>
+<script data-cfasync="false" src="/media/js/terrain3.js"></script>
+
+In the last two posts we looked at implementing the Midpoint Displacement
+algorithm for procedurally generating terrain.  Today we're going to look at
+a similar algorithm called Diamond Square that fixes some problems with Midpoint
+Displacement.
+
+The full series of posts so far:
+
+* [Midpoint Displacement](/blog/2016/02/midpoint-displacement/)
+* [Recursive Midpoint Displacement](/blog/2016/03/recursive-midpoint-displacement/)
+* [Diamond Square](/blog/2016/06/diamond-square/)
+
+Midpoint Displacement is simple and fast, but it has some flaws.  If you look at
+the end result you'll probably start to notice "seams" in the terrain that
+appear on perfectly square chunks.  This happens because when you're calculating
+the midpoints of the edges of each square you're only averaging two sources of
+information.
+
+[Diamond Square][] is an algorithm that works a lot like Midpoint Displacement,
+but it adds an extra step to ensure that (almost) every point uses *four*
+sources of data.  This reduces the visual artifacts a lot without much extra
+effort.
+
+Let's [draw the owl][owl].
+
+[Diamond Square]: https://en.wikipedia.org/wiki/Diamond-square_algorithm
+[owl]: https://i.imgur.com/RadSf.jpg
+
+{{% toc %}}
+
+## Overview
+
+The high-level description of Diamond Square goes something like this:
+
+1. Initialize the corners to random values.
+2. Set the center of the heightmap to the average of the corners (plus jitter).
+3. Set the midpoints of the edges of the heightmap to the average of the four
+   points on the "diamond" around them (plus jitter).
+4. Repeat steps 2-4 on successively smaller chunks of the heightmap until you
+   bottom out at 3x3 chunks.
+
+## Initialization
+
+Initialization is pretty simple:
+
+```clojure
+(defn ds-init-corners [heightmap]
+  (let [last (heightmap-last-index heightmap)]
+    (heightmap-set! heightmap 0    0    (rand))
+    (heightmap-set! heightmap 0    last (rand))
+    (heightmap-set! heightmap last 0    (rand))
+    (heightmap-set! heightmap last last (rand))))
+```
+
+Just set the corners to random values, exactly like we did in Midpoint
+Displacement.
+
+<div id="demo-1" class="threejs"></div>
+
+## Square
+
+In the "square" step of Diamond Square, we take a square region of the heightmap
+and set the center of it to the average of the four corners (plus jitter).
+
+<pre class="lineart">
+           Column
+         0 1 2 3 4         0 1 2 3 4         0 1 2 3 4
+        ┌─┬─┬─┬─┬─┐       ┌─┬─┬─┬─┬─┐       ┌─┬─┬─┬─┬─┐
+      0 │1│ │ │ │8│     0 │1│ │ │ │8│     0 │1│ │ │ │8│
+        ├─┼─┼─┼─┼─┤       ├─╲─┼─┼─╱─┤       ├─╲─┼─┼─╱─┤
+      1 │ │ │ │ │ │     1 │ │╲│ │╱│ │     1 │ │╲│ │╱│ │
+    R   ├─┼─┼─┼─┼─┤       ├─┼─◢─◣─┼─┤       ├─┼─◢─◣─┼─┤
+    o 2 │ │ │◉│ │ │     2 │ │ │◉│ │ │     2 │ │ │3│ │ │
+    w   ├─┼─┼─┼─┼─┤       ├─┼─◥─◤─┼─┤       ├─┼─◥─◤─┼─┤
+      3 │ │ │ │ │ │     3 │ │╱│ │╲│ │     3 │ │╱│ │╲│ │
+        ├─┼─┼─┼─┼─┤       ├─╱─┼─┼─╲─┤       ├─╱─┼─┼─╲─┤
+      4 │0│ │ │ │3│     4 │0│ │ │ │3│     4 │0│ │ │ │3│
+        └─┴─┴─┴─┴─┘       └─┴─┴─┴─┴─┘       └─┴─┴─┴─┴─┘
+</pre>
+
+The Wikipedia article calls this the "diamond" step, but that seems backwards to
+me.  We're operating on a *square* region of the heightmap, so this should be
+the *square* step.
+
+Since we're no longer working with heightmap "slices" like we were in the
+previous post, we'll need a way to specify the square chunk of the heightmap
+we're working on.  I chose to use a center point (`x` and `y` coordinates) and
+a radius:
+
+```clojure
+(defn ds-square [heightmap x y radius spread]
+  (let [new-height
+        (jitter
+          (average4
+            (heightmap-get heightmap (- x radius) (- y radius))
+            (heightmap-get heightmap (- x radius) (+ y radius))
+            (heightmap-get heightmap (+ x radius) (- y radius))
+            (heightmap-get heightmap (+ x radius) (+ y radius)))
+          spread)]
+    (heightmap-set! heightmap x y new-height)))
+```
+
+<div id="demo-2" class="threejs"></div>
+
+## Diamond
+
+In the "diamond" step of Diamond Square, we take a diamond-shaped region and set
+the center of it to the average of the four corners:
+
+<pre class="lineart">
+               Column
+         0 1 2 3 4 5 6 7 8        0 1 2 3 4 5 6 7 8
+        ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐
+      0 │1│ │ │ │3│ │ │ │3│    0 │1│ │ │ │3│ │ │ │3│
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─╱─╲─┼─┼─┼─┤
+      1 │ │ │ │ │ │ │ │ │ │    1 │ │ │ │╱│ │╲│ │ │ │
+    R   ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─╱─┼─┼─╲─┼─┼─┤
+    o 2 │ │ │3│ │ │ │4│ │ │    2 │ │ │3│ │◉│ │4│ │ │
+    w   ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─╲─┼─┼─╱─┼─┼─┤
+      3 │ │ │ │ │ │ │ │ │ │    3 │ │ │ │╲│ │╱│ │ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─╲─╱─┼─┼─┼─┤
+      4 │5│ │ │ │5│ │ │ │5│    4 │5│ │ │ │5│ │ │ │5│
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      5 │ │ │ │ │ │ │ │ │ │    5 │ │ │ │ │ │ │ │ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      6 │ │ │7│ │ │ │6│ │ │    6 │ │ │7│ │ │ │6│ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      7 │ │ │ │ │ │ │ │ │ │    7 │ │ │ │ │ │ │ │ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      8 │9│ │ │ │7│ │ │ │7│    8 │9│ │ │ │7│ │ │ │7│
+        └─┴─┴─┴─┴─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┴─┴─┴─┴─┘
+
+               Column
+         0 1 2 3 4 5 6 7 8        0 1 2 3 4 5 6 7 8
+        ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐
+      0 │1│ │ │ │3│ │ │ │3│    0 │1│ │ │ │3│ │ │ │3│
+        ├─┼─┼─┼─╱┬╲─┼─┼─┼─┤      ├─┼─┼─┼─╱┬╲─┼─┼─┼─┤
+      1 │ │ │ │╱│││╲│ │ │ │    1 │ │ │ │╱│││╲│ │ │ │
+    R   ├─┼─┼─╱─┼▼┼─╲─┼─┼─┤      ├─┼─┼─╱─┼▼┼─╲─┼─┼─┤
+    o 2 │ │ │3├─▶◉◀─┤4│ │ │    2 │ │ │3├─▶4◀─┤4│ │ │
+    w   ├─┼─┼─╲─┼▲┼─╱─┼─┼─┤      ├─┼─┼─╲─┼▲┼─╱─┼─┼─┤
+      3 │ │ │ │╲│││╱│ │ │ │    3 │ │ │ │╲│││╱│ │ │ │
+        ├─┼─┼─┼─╲┴╱─┼─┼─┼─┤      ├─┼─┼─┼─╲┴╱─┼─┼─┼─┤
+      4 │5│ │ │ │5│ │ │ │5│    4 │5│ │ │ │5│ │ │ │5│
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      5 │ │ │ │ │ │ │ │ │ │    5 │ │ │ │ │ │ │ │ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      6 │ │ │7│ │ │ │6│ │ │    6 │ │ │7│ │ │ │6│ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      7 │ │ │ │ │ │ │ │ │ │    7 │ │ │ │ │ │ │ │ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      8 │9│ │ │ │7│ │ │ │7│    8 │9│ │ │ │7│ │ │ │7│
+        └─┴─┴─┴─┴─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┴─┴─┴─┴─┘
+</pre>
+
+Once again we'll use a center point and radius to specify the region inside the
+heightmap:
+
+```clojure
+(defn ds-diamond [heightmap x y radius spread]
+  (let [new-height
+        (jitter
+          (safe-average
+            (heightmap-get-safe heightmap (- x radius) y)
+            (heightmap-get-safe heightmap (+ x radius) y)
+            (heightmap-get-safe heightmap x (- y radius))
+            (heightmap-get-safe heightmap x (+ y radius)))
+          spread)]
+    (heightmap-set! heightmap x y new-height)))
+```
+
+<div id="demo-3" class="threejs"></div>
+
+## Edge Cases
+
+You might have noticed that we used `heightmap-get-safe` and `safe-average` in
+the `ds-diamond` code.  This is to handle the diamonds on the edge of the
+heightmap.  Those diamonds only have three points to average:
+
+<pre class="lineart">
+           Column
+         0 1 2 3 4        0 1 2 3 4
+        ┌─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┐
+      0 │1│ │ │ │8│    0 │1│ │ │ │8│
+        ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─╱┬╲
+      1 │ │ │ │ │ │    1 │ │ │ │╱│││╲
+    R   ├─┼─┼─┼─┼─┤      ├─┼─┼─╱─┼▼┤ ╲
+    o 2 │ │ │3│ │ │    2 │ │ │3├─▶◉◀──?
+    w   ├─┼─┼─┼─┼─┤      ├─┼─┼─╲─┼▲┤ ╱
+      3 │ │ │ │ │ │    3 │ │ │ │╲│││╱
+        ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─╲┴╱
+      4 │0│ │ │ │3│    4 │0│ │ │ │3│
+        └─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┘
+</pre>
+
+So we just ignore the missing point:
+
+```clojure
+(defn safe-average [a b c d]
+  (let [total 0 count 0]
+    (when a (add! total a) (inc! count))
+    (when b (add! total b) (inc! count))
+    (when c (add! total c) (inc! count))
+    (when d (add! total d) (inc! count))
+    (/ total count)))
+
+(defn heightmap-get-safe [heightmap x y]
+  (let [last (heightmap-last-index heightmap)]
+    (when (and (<= 0 x last)
+               (<= 0 y last))
+      (heightmap-get heightmap x y))))
+```
+
+Technically this means they have less information to work with than the rest of
+the points, and you might see some slight artifacts.  But in practice it's not
+too bad, and it's a lot nicer than midpoint displacement where *every* line step
+uses only *two* points.
+
+Another way to handle this is to also wrap those edge coordinates around and
+pull the point from the other side of the heightmap.  This is a bit more work
+but gives you an extra benefit: the heightmap will be tileable (**update**: like
+everything where someone doesn't show you running code, it's [not actually that
+simple](/blog/2016/08/lisp-jam-postmortem/#tiling-diamond-square)).
+
+## Iteration
+
+Unfortunately we can't use recursion to iterate for Diamond Square like we did
+for Midpoint Displacement.  We have to interleave the diamond and square steps,
+performing each round of squares on the *entire* map before moving on to a round
+of diamonds.  If we don't, bad things will happen.
+
+Let's look at an example to see why.  First we perform the initial square step:
+
+<pre class="lineart">
+           Column
+         0 1 2 3 4        0 1 2 3 4
+        ┌─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┐
+      0 │1│ │ │ │8│    0 │1│ │ │ │8│
+        ├─┼─┼─┼─┼─┤      ├─╲─┼─┼─╱─┤
+      1 │ │ │ │ │ │    1 │ │╲│ │╱│ │
+    R   ├─┼─┼─┼─┼─┤      ├─┼─◢─◣─┼─┤
+    o 2 │ │ │ │ │ │    2 │ │ │3│ │ │
+    w   ├─┼─┼─┼─┼─┤      ├─┼─◥─◤─┼─┤
+      3 │ │ │ │ │ │    3 │ │╱│ │╲│ │
+        ├─┼─┼─┼─┼─┤      ├─╱─┼─┼─╲─┤
+      4 │0│ │ │ │3│    4 │0│ │ │ │3│
+        └─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┘
+</pre>
+
+That's fine.  Then we recurse into the first of the four diamonds:
+
+<pre class="lineart">
+           Column
+         0 1 2 3 4        0 1 2 3 4
+        ┌─┬─┬─┬─┬─┐      ┌─┬─┬─┬─┬─┐
+      0 │1│ │ │ │8│    0 │1├─▶4◀─┤8│
+        ├─┼─┼─┼─┼─┤      ├─╲─┼▲┼─╱─┤
+      1 │ │ │ │ │ │    1 │ │╲│││╱│ │
+    R   ├─┼─┼─┼─┼─┤      ├─┼─╲┴╱─┼─┤
+    o 2 │ │ │3│ │ │    2 │ │ │3│ │ │
+    w   ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┤
+      3 │ │ │ │ │ │    3 │ │ │ │ │ │
+        ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┤
+      4 │0│ │ │ │3│    4 │0│ │ │ │3│
+        └─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┘
+</pre>
+
+Everything's still good.  Then we recurse into the square:
+
+<pre class="lineart">
+            Column
+         0 1 2 3 4        0 1 2 3 4
+        ┌─┬─┬─┬─┬─┐      ╔═════╗─┬─┐
+      0 │1│ │4│ │8│    0 ║1│ │4║ │8│
+        ├─┼─┼─┼─┼─┤      ║─◢─◣─║─┼─┤
+      1 │ │ │ │ │ │    1 ║ │ │ ║ │ │
+    R   ├─┼─┼─┼─┼─┤      ║─◥─◤─║─┼─┤
+    o 2 │ │ │3│ │ │    2 ║?│ │3║ │ │
+    w   ├─┼─┼─┼─┼─┤      ╚═════╝─┼─┤
+      3 │ │ │ │ │ │    3 │ │ │ │ │ │
+        ├─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┤
+      4 │0│ │ │ │3│    4 │0│ │ │ │3│
+        └─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┘
+</pre>
+
+But wait, there's a corner missing!  We needed to complete that left-hand
+diamond step to get it, but that's still waiting on the stack for this line of
+recursion to bottom out.
+
+### A "Strided" Iteration Construct
+
+So we need to use normal iteration.  We can start by writing the code to do
+a single round of diamonds or squares on the heightmap.  First we'll make a nice
+looping construct called `do-stride`:
+
+```clojure
+(defmacro do-stride
+    [varnames start-form end-form stride-form & body]
+  (let [stride (gensym "stride")
+        start (gensym "start")
+        end (gensym "end")
+        build (fn build [vars]
+                (if (empty? vars)
+                  `(do ~@body)
+                  (let [varname (first vars)]
+                    `(loop [~varname ~start]
+                       (when (< ~varname ~end)
+                         ~(build (rest vars))
+                         (recur (+ ~varname ~stride)))))))]
+    ; Fix the numbers once outside the nested loops,
+    ; and then build the guts.
+    `(let [~start ~start-form
+           ~end ~end-form
+           ~stride ~stride-form]
+       ~(build varnames))))
+```
+
+This scary-looking macro builds the nested looping structure we'll need to
+perform the iteration for our diamonds and squares.  It abstracts away the
+tedium of writing out nested `for` loops so we can focus on the rest of the
+algorithm.
+
+`do-stride` takes a list of variables to bind, a number to start at, a number to
+end before, and a body.  For each variable it starts at `start`, runs `body`,
+increments by `stride`, and loops until the value is at or above `end`.  For
+example:
+
+* `(do-stride [x] 0 5 1 (console.log x))` will log `0 1 2 3 4`.
+* `(do-stride [x] 0 5 2 (console.log x))` will log `0 2 4`.
+* `(do-stride [x y] 0 3 2 (console.log [x y]))` will log `[0, 0] [0, 2] [2, 0]
+  [2, 2]`.
+
+### Square Iteration
+
+Now that we've got this, we can iterate our square step over the heightmap for
+a specific radius:
+
+```clojure
+(defn ds-squares [heightmap radius spread]
+  (do-stride [x y] radius (heightmap-resolution heightmap) (* 2 radius)
+    (ds-square heightmap x y radius spread)))
+```
+
+We use `do-stride` to start at the radius and loop until we fall off the
+heightmap, stepping by *twice* the radius each time.
+
+Because our heightmaps are always square we can use the same values for both
+dimensions.  `do-stride` can take zero or more variables and will just do the
+right thing, so we don't need to worry about it.
+
+The stride is double the radius because as we step between squares we move over
+the right half of the first *and* the left half of the next:
+
+<pre class="lineart">
+               Column
+          0 1 2 3 4 5 6 7 8        0 1 2 3 4 5 6 7 8
+         ╔═════════╗─┬─┬─┬─┐      ╔═════════╗─┬─┬─┬─┐
+       0 ║1│ │ │ │3║ │ │ │3│    0 ║1│ │ │ │3║ │ │ │3│
+         ║─┼─┼─┼─┼─║─┼─┼─┼─┤      ║─┼─┼─┼─┼─║─┼─┼─┼─┤
+       1 ║ │ │ │ │ ║ │ │ │ │    1 ║ │ │ │ │ ║ │ │ │ │
+    R    ║─┼─┼─┼─┼─║─┼─┼─┼─┤     radius ┼─┼─║─┼─┼─┼─┤
+    o  2 ║ │ │◉│ │ ║ │◉│ │ │    2 ║◀━━▶◉◀━━━━━▶◉│ │ │
+    w    ║─┼─┼─┼─┼─║─┼─┼─┼─┤      ║─┼─┼─ stride ┼─┼─┤
+       3 ║ │ │ │ │ ║ │ │ │ │    3 ║ │ │ │ │ ║ │ │ │ │
+         ║─┼─┼─┼─┼─║─┼─┼─┼─┤      ║─┼─┼─┼─┼─║─┼─┼─┼─┤
+       4 ║5│ │ │ │5║ │ │ │5│    4 ║5│ │ │ │5║ │ │ │5│
+         ╚═════════╝─┼─┼─┼─┤      ╚═════════╝─┼─┼─┼─┤
+       5 │ │ │ │ │ │ │ │ │ │    5 │ │ │ │ │ │ │ │ │ │
+         ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+       6 │ │ │◉│ │ │ │◉│ │ │    6 │ │ │◉│ │ │ │◉│ │ │
+         ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+       7 │ │ │ │ │ │ │ │ │ │    7 │ │ │ │ │ │ │ │ │ │
+         ├─┼─┼─┼─┼─┼─┼─┼─┼─┤      ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+       8 │9│ │ │ │7│ │ │ │7│    8 │9│ │ │ │7│ │ │ │7│
+         └─┴─┴─┴─┴─┴─┴─┴─┴─┘      └─┴─┴─┴─┴─┴─┴─┴─┴─┘
+</pre>
+
+### Diamond Iteration
+
+The diamonds are a little more complicated.
+
+First of all, in the `y` dimension we need to start at `0` instead of `radius`
+(these will be the top and bottom edge cases we looked at).  Also, in the `x`
+direction all the even iterations need to start at `radius`, while the odd
+iterations should start at `0`.
+
+Hopefully a picture will make it a bit more clear:
+
+<pre class="lineart">
+               Column
+         0 1 2 3 4 5 6 7 8
+        ┌─┬─┬─┬─┬─┬─┬─┬─┬─┐
+      0 │1│ │◉│ │3│ │◉│ │3│ y iteration: 0, start at x = radius
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      1 │ │ │ │ │ │ │ │ │ │
+    R   ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+    o 2 │◉│ │3│ │◉│ │4│ │◉│ y iteration: 1, start at x = 0
+    w   ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      3 │ │ │ │ │ │ │ │ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      4 │5│ │◉│ │5│ │◉│ │5│ y iteration: 2, start at x = radius
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      5 │ │ │ │ │ │ │ │ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      6 │◉│ │7│ │◉│ │6│ │◉│ y iteration: 3, start at x = 0
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      7 │ │ │ │ │ │ │ │ │ │
+        ├─┼─┼─┼─┼─┼─┼─┼─┼─┤
+      8 │9│ │◉│ │7│ │◉│ │7│ y iteration: 4, start at x = radius
+        └─┴─┴─┴─┴─┴─┴─┴─┴─┘
+</pre>
+
+The code for the diamonds is the hairiest bit of the algorithm.  Make sure you
+understand it before moving on.  `shift` will be `radius` for even iterations
+and `0` for odd ones:
+
+```clojure
+(defn ds-diamonds [heightmap radius spread]
+  (let [size (heightmap-resolution heightmap)]
+    (do-stride [y] 0 size radius
+      (let [shift (if (even? (/ y radius)) radius 0)]
+        (do-stride [x] shift size (* 2 radius)
+          (ds-diamond heightmap x y radius spread))))))
+```
+
+### Top-Level Iteration
+
+Finally we can put it all together.  We initialize the corners and starting
+values, then loop over smaller and smaller radii and just call `ds-squares` and
+`ds-diamonds` to do the heavy lifting:
+
+```clojure
+(defn diamond-square [heightmap]
+  (let [initial-spread 0.3
+        spread-reduction 0.5
+        center (heightmap-center-index heightmap)
+        size (aget heightmap.shape 0)]
+    (ds-init-corners heightmap)
+    (loop [radius center
+           spread initial-spread]
+      (when (>= radius 1)
+        (ds-squares heightmap radius spread)
+        (ds-diamonds heightmap radius spread)
+        (recur (/ radius 2)
+               (* spread spread-reduction))))
+    (sanitize heightmap)))
+```
+
+## Result
+
+The end result looks like this:
+
+<div id="demo-final" class="threejs"></div>
+
+It looks a lot like the result from Midpoint Displacement, but without the ugly
+seams around the square chunks.
+
+The code for these blog posts is a bit of a mess because I've been copy/pasting
+to show the partially-completed demos after each step.  I've created a little
+[single-page demo][ymir] with completed versions of the various algorithms you
+can play with, and [that code][ymir-code] should be a lot more readable than the
+hacky code for these posts.
+
+[ymir]: http://ymir.stevelosh.com/
+[ymir-code]: http://bitbucket.org/sjl/ymir/
+
--- a/content/blog/2016/06/symbolic-computation.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,868 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "What the Hell is Symbolic Computation?"
-        snip: "Symbols, REPLs, and Quoting -- Oh My!"
-        created: 2016-06-29 13:30:00
-    %}
-
-    {% block article %}
-
-I've been reading a lot of Lisp books lately, some more advanced than others.
-All of the introductory books I've seen cover the idea of symbolic computation,
-but most of them breeze past it with just a few pages about "symbols" and
-"quoting".  For many programmers coming from non-Lisp languages these are new,
-foreign concepts that don't really map back to anything in their previous
-experience.  But the books seem to expect you to understand this things after
-just a couple of paragraphs.
-
-One book that *does* spend more time on this is the appropriately-named [Common
-Lisp: A Gentle Introduction to Symbolic Computation][gentle].  If you're looking
-for a good introductory Lisp book, that's the one I'd recommend.  However, it's
-quite a long book and starts at the *very* basics (you don't even write code for
-the first few chapters -- you program with drawings).  If you already know the
-some Lisp then you might find yourself bored if you go through the entire thing
-just for the symbolic computation bits.
-
-This post is an attempt to explain what symbols *actually are* and what quoting
-does.  You'll get the most out of it if you're already familiar with the basics
-of Lisp (i.e. you aren't scared by the parentheses).  But if you already know
-what something like this would print, you'll probably be bored:
-
-    :::text
-    (let ((foo ''a))
-      (print foo)
-      (print 'foo)
-      (print (car foo))
-      (print (cdr foo)))
-
-[gentle]: http://www.amazon.com/dp/0486498204/?tag=stelos-20
-
-[TOC]
-
-## Disclaimer
-
-Before we start I'll get this warning out of the way: I'm going to gloss over
-a lot of gory details to get at the important core ideas.
-
-When I say "this thing is implemented like so" it's safe to assume that in
-reality things are messier and more complicated and will vary between
-implementations and dialects.  My goal is to give you some intuition for the
-basic ideas, not to exhaustively cover how a particular implementation works.
-
-I'll be using Common Lisp for the examples, but the concepts apply equally to
-Scheme, Clojure, and other Lisps too.
-
-With that out of the way, let's dive in!
-
-## The REPL
-
-The Read-Eval-Print-Loop that so many languages these days have built-in is
-a good place to start in our exploration.  You're probably familiar with the
-idea of a REPL from languages like Python, Ruby, Javascript, etc.  In Python it
-looks like this:
-
-    :::text
-    $ python
-    >>> if True:
-    ...     print "Yes"
-    ... else:
-    ...     print "No"
-    ...
-    Yes
-
-A handwavey definition of a REPL could be something like this:
-
-> A REPL is a program that lets you type in code.  It runs that code, prints out
-> the result, and loops back to the beginning to let you type in more.
-
-This is a good first start, but to understand symbols we're going to need to get
-a much clearer, more precise handle on what exactly each letter in "REPL" means.
-We'll start backwards and outside-in with the simplest component.
-
-## Loop
-
-The "L" in "REPL" stands for "Loop", and it's the easiest part to understand.
-A REPL doesn't just process one bit of code and then exit, it loops forever (or
-until you tell it to quit).
-
-There's not a lot to say here, except that we'll go ahead and lump together the
-extra busywork a REPL needs to do into this step so we can ignore it for the
-rest of the post.  This includes things like:
-
-* Printing the nice prompt at the beginning (`>>>` or `...` in Python).
-* Checking for `Ctrl-D` to quit.
-* Handling exceptions (so they don't kill the process).
-
-## Print
-
-The next letter is "P" for "Print".  Like `loop` this should be familiar
-territory, but let's nail down *exactly* what it does.  The job of the `print`
-function is to:
-
-* Take as input some kind of object/data structure in memory.
-* Produce some series of characters (a string) that represent this object.
-* Write those characters somewhere (standard output, a text panel in a GUI, etc).
-
-For example: if we give the integer `1` to Python's `print`, it produces
-a string of two characters (the digit `1` and a newline) and writes it to the
-terminal.  There are a lot of little details that aren't important here (line
-endings, string encoding, where the output actually goes, etc).  The important
-part that you should fix in your mind is this:
-
-**`print` takes an object, converts it into a string, and outputs it.**
-
-Note: I've called `print` a function here, and I'll do the same for `read` and
-`eval` later on.  This is correct for Common Lisp, but not necessarily for
-languages like Python or Javascript.  For the purposes of this post you can just
-imagine them as functions and realize that in the real world they're more like
-"phases" that have a lot more complex machinery under them.
-
-## Read
-
-We'll jump over to the other side of the acronym now.  "R" is for "Read", and
-this is where things start to get tricky.
-
-In most non-Lisp languages the "read" and "eval" phases of the REPL tend to get
-blurred together, but if you want to understand symbolic computation in Lisp you
-absolutely *must* keep these two parts cleanly separated in your mind.
-
-We can define `read` as almost the polar opposite of `print`.  `read` is
-a function whose job is to:
-
-* Take as input a string of characters from some source.
-* "Decode" that string and produce some kind of object in memory.
-* Return that object.
-
-Notice how this mirrors `print`:
-
-* `print`: Object → Characters
-* `read`: Characters → Object
-
-This is the second definition you need to fix in your brain:
-
-**`print` takes an object, converts it into a string, and outputs it.**  
-**`read` takes a string, converts it into an object, and returns it.**
-
-If we `read` in the string `1.0` (that's three ASCII characters), we'll get some
-kind of floating point number object back.  Sometimes there are many ways to
-represent the same object in memory.  For example: `read`ing the strings `1.0`
-and `1.0000` will both produce equivalent floating point objects representing
-the number "one".
-
-Side note (if you're not feeling pedantic feel free to skip this): the word
-"equivalent" here is a bit tricky.  When you `read` two strings like `1.0` and
-`1.000` you might get back two pointers to the same hunk of memory, or you might
-get back two pointers to two separate hunks of memory, or even just a machine
-word representing the floating point number directly.  It depends on the
-language (and even the implementation).  What I mean by "equivalent" is that
-there's no way to tell which value came from which input.  You can't say "this
-hunk of memory must have come from the string `1.000`" because `read` has
-"sanitized" the input by that point.
-
-## The RPL
-
-So now we've got `read`, `print`, and `loop`.  `read` takes characters from
-a stream and produces objects, and `print` takes objects and produces characters
-and writes them to a stream.  We're still missing a letter, but what would
-happen if we just hook these three up together right now?
-
-    :::text
-    CL-USER> (loop (print (read)))
-    > 1
-    1
-    >    1.0
-    1.0
-    > 1.00000
-    1.0
-
-I've added a little `>` prompt to the output here to make it clear where I'm
-typing.
-
-Essentially what we've got here is a little pretty-printer!  Notice how things
-like extra whitespace and useless zeroes got stripped out.  This isn't terribly
-useful, but at least it's doing *something*.
-
-However, it's important to realize where the "prettifying" actually happened:
-`read` actually did the hard work!  By the time `print` got its grubby little
-paws on those one-point-zeroes the extra whitespace and digits were long gone.
-Maybe we should give credit where it's due and call this a "pretty-reader"
-instead.
-
-## Reading Other Data
-
-Up to this point I've been using numbers as examples because they're simple, but
-of course we can read and print lots of other kinds of things.  Lists and
-strings (and lists *of* strings!) are some common examples:
-
-    :::text
-    CL-USER> (print (read))
-    > ("hello"       "world")
-    ("hello" "world")
-
-    $ python
-    >>> [    "hello"  , "world"]
-    ['hello', 'world']
-
-There are lots of other kinds of things you can read and print, depending on the
-particular language.  What's important here is the strict separation of `read`
-and `print`.
-
-## Readable Printing
-
-Before we move on, one thing we should talk about is the idea of "readable
-printing".  This idea becomes clear almost immediately when you work at the
-Python REPL:
-
-    :::text
-    $ python
-    >>> "foo\nbar"
-    'foo\nbar'
-    >>> print "foo\nbar"
-    foo
-    bar
-
-Why was the first string printed with quotes and an escaped newline, and the
-second without quotes and an actual newline?
-
-When we defined `print` earlier, one of the steps was:
-
-* Produce some series of characters (a string) that represent this object.
-
-Much like there are many character strings that result in the same object (e.g.
-`1.0` and `1.000`) there are often many ways we can represent a particular
-object as a series of characters.  For example: we can represent the number two
-as `2`, or `10` in binary, or `two` in English.  We can represent a string as
-the actual characters in it, or we could represent it "escaped" like Python does
-in the first line.
-
-The core idea here is that of **"readable printing": printing the characters you
-would need to give to `read` to produce this object**.
-
-This is different from what I'll call **"aesthetic printing": printing
-characters for this object which look nice to a human**.
-
-In Python these two kinds of printing are seen in the separate [`__str__` and
-`__repr__` methods][str_repr].  In Common Lisp it's controlled by the
-[`*print-readably*` variable][print-readably].  Other languages have different
-mechanisms.
-
-[str_repr]: https://brennerm.github.io/posts/python-str-vs-repr.html
-[print-readably]: http://clhs.lisp.se/Body/v_pr_rda.htm
-
-## Reading Non-Lisp
-
-So we know how reading and printing *data* works, but you can do more than that
-at a typical REPL.  Let's revisit the first Python example:
-
-    :::text
-    $ python
-    >>> if True:
-    ...     print "Yes"
-    ... else:
-    ...     print "No"
-    ...
-    Yes
-
-We know that `read` takes a series of characters and turns them into an object.
-When we `read` this series of characters, what comes out the other end?  For
-most languages (Python, Ruby, Javascript, Scala, etc) the answer is some kind of
-[abstract syntax tree][] represented as a data structure.  You might imagine
-something like this buried deep within the guts of the Python interpreter:
-
-    :::python
-    class IfStatement(ASTNode):
-        def __init__(self, test_node, then_node, else_node):
-            self.test_node = test_node
-            self.then_node = then_node
-            self.else_node = else_node
-
-The details would surely be a lot hairier in the real world, but the general
-idea is that the stream of characters representing your code gets read in and
-parsed into some kind of data structure in memory.
-
-This is all well and good, but our example printed "Yes", which certainly isn't
-a representation of an AST node.  Where did that come from?  To answer that
-we'll need the final letter in the acronym.
-
-[abstract syntax tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
-
-## Evaluating Non-Lisp
-
-The "E" in REPL stands for "Eval".
-
-This is the last time we'll consider Python in this post, because we're about to
-move past it to more powerful ideas.  In Python, the purpose of the `eval` phase
-of the REPL is to:
-
-* Take an AST node (or simple data) as input.
-* Run the code (also known as *evaluating* it).
-* Return the result (if any).
-
-This is fairly straightforward, at least for our simple `if` statement.  Python
-will evaluate the `test_node` part of the `if`, and then evaluate one of the
-other parts depending on whether the test was truthy or falsey.
-
-Of course the actual process of evaluating real-life Python code is much more
-complicated than I've glossed over here, but this is good enough for us to use
-as a springboard to dive into the beautiful world of Lisp.
-
-## Reading Lisp
-
-When we talked about reading the Python `if` statement I said that Python would
-parse it into some kind of data structure representing an AST node.  I didn't
-point you at the *actual* data structure in the Python source code because
-I have no idea where it actually *is*, and it's probably not nearly as simple as
-the one I sketched out.
-
-Now that we're talking about Lisp, however, I *really can* show you exactly what
-an `if` statement in Lisp reads as!  I'll use `read-from-string` to make it
-a bit easier to see what's input and what's output, but it would work the same
-way with just plain old `read` and input from standard in.  Here we go:
-
-    :::text
-    CL-USER> (print
-               (read-from-string "(if t (print 1) (print 2))"))
-
-    (IF T (PRINT 1) (PRINT 2))
-
-    CL-USER> (type-of
-               (read-from-string "(if t (print 1) (print 2))"))
-
-    CONS
-
-Instead of some kind of AST node data structure buried deep within the heart of
-our implementation we get... a list!  An ordinary, garden-variety, vanilla list
-made of good old trusty cons cells!
-
-The list we get contains four elements, two of which are themselves lists.  But
-what do these lists actually *contain*?
-
-The numbers are simple enough -- we saw them earlier.  `read` turns a series of
-digits into a number somewhere in memory, and `print` spits out a series of
-characters that represent the number:
-
-    :::text
-    CL-USER> (type-of (read-from-string "100"))
-
-    (INTEGER 0 4611686018427387903)
-
-The string `100` does indeed represent an integer between zero and four
-squillion-something.
-
-But what are those *other* things in our list?  The `if` and `t` and `print`?
-Are they some magic keywords internal to the guts of our Lisp that `print` is
-just outputting nicely for our benefit?
-
-    :::text
-    CL-USER> (type-of (read-from-string "if"))
-
-    SYMBOL
-
-Buckle up -- it's time to learn about symbols.
-
-## Symbols
-
-A symbol in Lisp is [a simple data structure][clhs-symbol] that turns out to be
-*extremely* useful.  You can imagine it being defined something like this:
-
-    :::text
-    (defstruct symbol
-      name
-      function
-      value
-      property-list
-      package)
-
-The `name` of a symbol is a string of characters representing the symbol's name:
-
-    :::text
-    CL-USER> (type-of (read-from-string "if"))
-
-    SYMBOL
-
-    CL-USER> (symbol-name (read-from-string "if"))
-
-    "IF"
-
-Symbols get created (usually) when they are `read` for the first time.  If you
-`read` a sequence of characters that matches the name of an existing symbol
-(let's ignore the lowercase/uppercase thing for now), `read` just returns that
-existing symbol:
-
-    :::text
-    CL-USER> (eq (read-from-string "cats")
-                 (read-from-string "cats"))
-
-    T
-
-Here `read` saw the string `cats` and created a new symbol somewhere in memory
-with `CATS` as its `name`.  The second call to `read-from-string` read in the
-string `cats`, saw an existing symbol with the matching name, and just returned
-it straight away.  That's why `eq` returned true -- the two `read` calls
-returned pointers to the exact same hunk of memory.
-
-(`read` also "interned" the symbol into the current package.  We're going to
-ignore the package system for this post -- it's not important to the core
-topic.  We'll also ignore the property list.)
-
-So to recap:
-
-* `read` is a function that takes characters and turns them into objects.
-* When you feed `read` certain strings of characters (i.e. without special
-  characters), it returns a symbol object whose name matches those characters
-  (creating it if necessary).
-* Symbols are just normal Lisp data structures with a few specific fields.
-
-So what does `print` do with a symbol?  It just prints the `name`!
-
-    :::text
-    CL-USER> (print (read-from-string "cats"))
-
-    CATS
-
-Simple enough.  Note that this is *readably printed* -- if we feed it back to
-`read` we'll get an equivalent symbol back (the *exact same* symbol, in fact).
-
-But wait!  If we `read` symbols in and they're just normal vanilla structures,
-then how do we actually *do* anything in Lisp?  How does anything actually
-*run*?
-
-[clhs-symbol]: http://www.lispworks.com/documentation/lw70/CLHS/Body/t_symbol.htm
-
-## Evaluating Lisp
-
-Now we need to go back to `eval`.  In the Python example I handwaved a bit and
-said that `eval` "ran the code" but didn't really explain how that happened.
-Now that we're in the warm embrace of Lisp we can nail things down a lot more
-cleanly.
-
-`eval` (in Lisp) is a function whose job is to:
-
-* Take an object.
-* Do something useful with it to get another object.
-* Return the resulting object.
-
-I know, I know, that seems as clear as a brick.  But if we can actually define
-what "something useful" means it will be a lot more helpful.  Lisp's `eval`
-follows a few simple rules to produce its output.
-
-### Strings and Numbers
-
-First of all, `eval` will just pass numbers and strings straight through without
-touching them at all:
-
-    :::lisp
-    (defun eval (thing)
-      (cond
-        ((numberp thing) thing)
-        ((stringp thing) thing)
-        ; ...
-        (t (error "What the hell is this?"))))
-
-This makes sense because there's not a lot more useful stuff you can do with
-a number or a string on its own.  I suppose you could write a language where the
-evaluation phase ran all numbers through the absolute value function because you
-wanted to remove all negativity from programming or something, but that seems
-a bit esoteric.
-
-### Basic Lists
-
-What about lists, like our friend the `if` statement (a list of four things)?
-Well the first thing anyone learns about Lisp is the funny syntax.  In most
-cases, when passed a list `eval` treats the first element as the name of
-a function, and the rest as the arguments.  It will evaluate the arguments and
-call the function with them:
-
-    :::lisp
-    (defun eval (thing)
-      (cond
-        ((numberp thing) thing)
-        ((stringp thing) thing)
-        ((typep thing 'list)
-         (destructuring-bind (head . arguments) thing
-           (apply (symbol-function head)
-                  (mapcar #'eval arguments))))
-        ; ...
-        (t (error "What the hell is this?"))))
-
-At this point we know enough to understand exactly what happens when we say
-something like `(+ 1 2)` at a Lisp REPL!
-
-* Lisp `read`s the seven characters we gave it, which becomes a list of three
-  objects: the symbol `+`, the integer `1`, and the integer `2`.
-* Lisp passes that three-object list to `eval`.
-* `eval` looks up what is in the `function` slot of the symbol at the front of
-  the list (that symbol is `+`).
-* The symbol `+` was helpfully given a function by the Lisp implementation (run
-  `(symbol-function (read-from-string "+"))` to confirm that I'm not lying to
-  you).
-* Lisp evaluates each item in the rest of the list.  In this case they're each
-  a number, so each one evaluates to itself.
-* Lisp calls the function with the evaluated arguments to get a result (in this
-  case: the integer `3`).
-* Lisp passes the result to `print`, which turns it into a string of characters
-  (one character, in this case) and prints it to standard out.
-
-Whew!  That seems like a lot, but each piece is pretty small.  Go slowly through
-it and make sure you *really* understand each step in the preceding list before
-you move on.
-
-If you don't believe me that this is really how it works, try this:
-
-    :::text
-    CL-USER> (setf (symbol-function (read-from-string "square"))
-                   (lambda (x) (* x x)))
-
-    #<FUNCTION (LAMBDA (X)) {1005DCF2FB}>
-
-    CL-USER> (square 4)
-
-    16
-
-We set the `function` slot of the symbol `square` to be a function that squares
-its argument, and then we can run it like any other function.
-
-Trace through the evaluation of that last `(square 4)` call before moving on.
-
-### Variables
-
-What about symbols that *aren't* at the front of a list?  For example:
-
-    :::text
-    CL-USER> (defvar ten 10)
-
-    10
-
-    CL-USER> (square ten)
-
-    100
-
-In this case, everything proceeds as it did before until the recursive call to
-`eval` the argument to `square`.  The argument is just a bare symbol (not
-a number or a list or a string), so we need another rule in our `eval` function:
-
-    :::lisp
-    (defun eval (thing)
-      (cond
-        ((numberp thing) thing)
-        ((stringp thing) thing)
-        ((symbolp thing) (symbol-value thing)) ; NEW
-        ((listp thing)
-         (destructuring-bind (head . arguments)
-           (apply (symbol-function head)
-                  (mapcar #'eval arguments))))
-        ; ...
-        (t (error "What the hell is this?"))))
-
-If `eval` sees a symbol on its own, it will just return whatever is in the
-`value` slot of the symbol data structure.  Simple enough!
-
-### Special Forms
-If course there are a few things we haven't talked about yet.  First of all:
-there are some "magic" symbols that aren't functions, but are hardcoded into the
-evaluation function to do certain things.  In Common Lisp they're called
-["special operators"][special-operators] and there are twenty-five of them.
-
-Let's add a special rule to our `eval` function to handle one of them (our old
-friend `if`):
-
-    :::lisp
-    (defun eval (thing)
-      (cond
-        ((numberp thing) thing)
-        ((stringp thing) thing)
-        ((symbolp thing) (symbol-value thing))
-        ((listp thing)
-         (destructuring-bind (head . arguments) thing
-           (cond
-             ((eq head (read-from-string "if")) ; NEW
-              (destructuring-bind (test then else) arguments
-                (if (eval test)
-                  (eval then)
-                  (eval else))))
-             (t
-              (apply (symbol-function head)
-                     (mapcar #'eval arguments))))))
-        ; ...
-        (t (error "What the hell is this?"))))
-
-At this point your head might be starting to hurt.  How have we just used `if`
-to define itself?  Is anything here actually *real*, or is Lisp just a serpent
-eating its own tail forever?
-
-### An Ouroborromean Paradox?
-
-If the "metacircularity" (god, I hate that word) of what we've just done bothers
-you, remember that this `eval` function here is just a sample of how you *can*
-write it in Lisp.  You could also write it in some other language, like C or
-Java (see: [ABCL][]) or really anything.  That would let you "bottom out" to
-something that's not Lisp.
-
-But really, is that any *less* circular?  You still need *some* language to run
-the thing!  Why does an `eval` written in C seem less "cheaty" than one written
-in Lisp?  Because it compiles to machine code?  Try
-`(disassemble #'sb-impl::simple-eval-in-lexenv)` in SBCL and you'll get a few
-thousand bytes of x86 assembly that was [originally some Lisp code much like
-ours][sbcl-eval].
-
-My advice is to just let it flow over you, even if you feel a bit uneasy at the
-sight of something like this.  Eventually as you become more at home in your
-chosen Lisp, writing high-level code one moment and `disassemble`ing a function
-the next, you'll make peace with the serpent.
-
-### Exercises
-
-There are quite a few things in `eval` that we haven't covered here, like the
-other twenty-four special operators, lexical variables, lambda forms, and more.
-But this should be enough for you to wrap your head around symbols and how
-they're used in Lisp.
-
-Before we move on to the final part of this story, make sure you can figure out
-the answers to these questions:
-
-1. What does the single character `1` read as?  What does it evaluate to?
-2. What do the characters `"hello\"world"` read as?  What do they evaluate to?
-   How would the result be printed readably?  How would the result be printed
-   aesthetically?
-3. What do the characters `(list (+ 1 2) ten)` read as?  What does it evaluate
-   to?  How does each step of the evaluation work?  Trace out each of the calls
-   to `eval` on paper, with their arguments and their results.  What does the
-   final result print as?
-4. Use `symbol-function` to see what's in the function slot of the symbol `car`.
-   How does your Lisp print that thing?
-5. Try to look up the function slot of a symbol without a function.  What
-   happens?
-4. Use `symbol-function` to see what's in the function slot of the symbol `if`.
-   What happens?  Does that seem right?  If so, why?
-5. Go to the [HyperSpec page for `symbol`][clhs-symbol] and search for
-   "the consequences are undefined if".  Try all of those things and find out
-   what interesting things break in your Lisp.
-
-If you're not using Common Lisp, port these exercises to your language.
-
-[special-operators]: http://www.lispworks.com/documentation/HyperSpec/Body/03_ababa.htm
-[ABCL]: https://common-lisp.net/project/armedbear/
-[sbcl-eval]: https://github.com/sbcl/sbcl/blob/fdc4e9fa86b5eaaf8939f004a66e4be075069aa8/src/code/eval.lisp#L131-L272
-
-## Quote
-
-Up to now we've been using the clumsy `(read-from-string "foo")` form to get
-ahold of symbols, but there's an easier way called "quoting".
-
-Quoting often confuses new Lisp programmers, and they'll end up randomly
-adding/removing quotes to something until it appears to do what they want.  Now
-that you've got `read`, `eval`, and `print` firmly separated in your mind,
-`quote` will be much easier to understand.
-
-### The Special Operator
-
-Quoting actually has two distinct components: one that affects `read` and one
-that affects `eval`.  In most books the distinction between these two only gets
-barely a sentence or two, which is probably why beginners are so confused.
-Let's look at the `eval` side of things first.
-
-`quote` is one of the twenty-five special operators.  All it does it pass its
-(single) argument back from `eval` *untouched*.  Normally the argument itself
-would have been evaluated, but `quote` prevents that:
-
-    :::lisp
-    (defun eval (thing)
-      (cond
-        ((numberp thing) thing)
-        ((stringp thing) thing)
-        ((symbolp thing) (symbol-value thing))
-        ((listp thing)
-         (destructuring-bind (head . arguments) thing
-           (cond
-             ((eq head (read-from-string "if"))
-              (destructuring-bind (test then else) arguments
-                (if (eval test)
-                  (eval then)
-                  (eval else))))
-             ((eq head (read-from-string "quote")) ; NEW
-              (first arguments))
-             (t
-              (apply (symbol-function head)
-                     (mapcar #'eval arguments))))))
-        ; ...
-        (t (error "What the hell is this?"))))
-
-I know that seems strange, but let's look at it in action:
-
-    :::text
-    CL-USER> (+ 1 2)
-
-    3
-
-    CL-USER> (quote (+ 1 2))
-
-    (+ 1 2)
-
-Our first example is the same one we used in the previous section:
-
-* `read` takes in seven characters and returns a list of three items: the symbol
-  `+` and two numbers.
-* `eval` gets the three-element list, looks up the function for the symbol `+`,
-  recursively evaluates the arguments (which evaluate to themselves), and
-  applies the function.
-* `print` gets the integer `3`, turns it into ASCII, and writes it to the
-  terminal.
-
-The second example uses `quote`:
-
-* `read` takes in fifteen characters and returns a list of two items: the symbol
-  `quote` and a list of three items (the symbol `+` and two numbers).
-* `eval` gets the three element list and notices that the first element is the
-  special operator `quote`.  It simply returns the second element in the list
-  untouched, which in this case is a list of three items.
-* `print` gets that three element list, turns it into seven characters, and
-  writes it to the terminal.
-
-Just for fun, let's ride the serpent and use `quote` in the definition of
-itself inside `eval` to clean things up a bit:
-
-    :::lisp
-    (defun eval (thing)
-      (cond
-        ((numberp thing) thing)
-        ((stringp thing) thing)
-        ((symbolp thing) (symbol-value thing))
-        ((listp thing)
-         (destructuring-bind (head . arguments) thing
-           (cond
-             ((eq head (quote if))
-              (destructuring-bind (test then else) arguments
-                (if (eval test)
-                  (eval then)
-                  (eval else))))
-             ((eq head (quote quote)) ; WHAT IN THE
-              (first arguments))
-             (t
-              (apply (symbol-function head)
-                     (mapcar #'eval arguments))))))
-        ; ...
-        (t (error "What the hell is this?"))))
-
-That `(quote quote)` looks just completely bonkers, right?  Step through it
-piece by piece to figure it out:
-
-* What do the five characters `quote` read as?  What do they evaluate to?
-* What do the thirteen (spooky!) characters `(quote quote)` read as?  When
-  `eval` gets its hands on that, what clause in the `cond` does it hit?  What
-  does that return?
-
-Try these in a Lisp REPL if you're not 100% sure of the answers.  The functions
-`read-from-string`, `eval`, and `type-of` will come in handy.
-
-### The Read Macro
-
-Now let's look at the final piece of the puzzle.  `'` (that's a single ASCII
-quote character) is a [read macro][].  Don't worry if you don't know exactly
-what that means right now.  The important part is that when `read` sees a quote
-character, it returns a two-element list containing the symbol `quote` and the
-next form, which is read normally.
-
-The four characters `'foo` go into `read` and come out as a two-element list
-containing: the symbol `quote` and the symbol `foo`.  Again, because it's
-important: this happens *at read time*.  By the time `eval` sees anything it's
-already been turned into that two-element list.
-
-It can be a bit slippery to get a grip on this, because `print` will "helpfully"
-print a list of `(quote whatever)` as `'whatever`!  But we can use trusty old
-`car` and `cdr` to see what's really going on:
-
-    :::lisp
-    CL-USER> (read-from-string "'foo")
-
-    'FOO
-
-    CL-USER> (type-of (read-from-string "'foo"))
-
-    CONS
-
-    CL-USER> (car (read-from-string "'foo"))
-
-    QUOTE
-
-    CL-USER> (cdr (read-from-string "'foo"))
-
-    (FOO)
-
-That's really all there is to it: `'form` is returned by `read` as `(quote
-form)`.  Then that gets passed along to `eval`, which sees the `quote` special
-operator and passes the argument back untouched.
-
-Note that `form` doesn't have to be a symbol:
-
-* `'(1 2 (4 5))` reads as `(quote (1 2 (4 5)))`
-* `'150` reads as `(quote 150)`
-* `'"hello"` reads as `(quote "hello")`
-* `'(if if if if)` reads as `(quote (if if if if))`
-
-[read macro]: https://gist.github.com/chaitanyagupta/9324402
-
-### Exercises
-
-That pretty much wraps up `quote`.  Once you've cleanly separated `read`,
-`eval`, and `print` in your mind it becomes a lot less mystical (or perhaps
-*more*, depending on your point of view).
-
-If you want to twist your brain just a bit more, try these exercises:
-
-1. What do the characters `foo` read in as?  What do they evaluate to?  How does it print?
-2. What do the characters `'foo` read in as?  What do they evaluate to?  How does it print?
-3. What do the characters `''foo` read in as?  What do they evaluate to?  How does it print?
-4. What do the characters `'1.0` read in as?  What do they evaluate to?  How does it print?
-5. What do the characters `'(1 2 3)` read in as?  How many elements are in the list?  What does it evaluate to?  How many elements are in *that* list?
-6. Update our implementation of `eval` to use the `'` read macro instead of `quote`.
-7. Certain symbols like `t` and `nil` are special -- they evaluate to themselves like numbers or strings.  Add this to `eval`.
-8. What do the characters `nil` read in as?  What is the type of that object?  What do they evaluate to?  What type is that result?
-9. What do the characters `'nil` read in as?  What is the type of that object?  What do they evaluate to?  What type is that result?
-10. What do the characters `''nil` read in as?  What is the type of that object?  What do they evaluate to?  What type is that result?
-
-## A Quick Recap
-
-If you've gotten this far and understood everything, you should have a good
-grasp of how symbolic computation works.  Here are the main things I hope you've
-taken away from this post:
-
-* `read`, `eval`, and `print` are three separate, distinct functions/phases in
-  the interpretation of Lisp (and really *all* (okay, *most*)) code.
-* Keeping these three phases *clearly separated* in your mind will make it
-  easier to understand symbols and quoting in Lisp.
-* Symbols are nothing magic, they're just a particular data structure with
-  a couple of fields.
-* The important thing is how `read` and `eval` *treat* symbols.  That's where
-  the magic happens.
-* `quote` is just a "short-circuit" in `eval` that turns out to be really
-  useful.
-* `'` is just a lazier way of writing `(quote ...)`.
-
-## Where to Go From Here
-
-Now that you've got a firmer grasp on what the hell symbols actually *are*,
-there are a lot of cool things you might want to check out that will show you
-what you can do with them:
-
-* Reread some of your introductory Lisp books again, seeing if things seem to
-  make a bit more sense now.
-* Read about backquote/quasiquote.  How does it compare to the `quote` we
-  explored here?
-* Read [Paradigms of Artificial Intelligence Programming][PAIP] and pay
-  attention to how Norvig uses symbols for various tasks.  Also pay attention to
-  what he says about property lists, because we skipped them here.
-* Read the [guide to the Common Lisp package system][packaging] to learn all the
-  stuff I left out about the Common Lisp package system.
-* Gaze upon [this macro][symbolicate] in wonder (or horror).
-* Read the HyperSpec pages for things like `symbol` and `quote`.
-* Find and read your Lisp implementation's `eval` function.
-* Find and read *another* Lisp implementation's `eval` function.
-* Watch the [SICP Lectures][SICP] on YouTube.
-
-[PAIP]: http://www.amazon.com/dp/1558601910/?tag=stelos-20
-[symbolicate]: https://github.com/zkat/squirl/blob/f0dc57dfee728df94b2a35956e18e143e8b8d275/src/vec.lisp#L28-L38
-[packaging]: https://www-fourier.ujf-grenoble.fr/~sergerar/Papers/Packaging.pdf
-[SICP]: http://www.amazon.com/dp/0262510871/?tag=stelos-20
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2016/06/symbolic-computation.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,889 @@
++++
+title = "What the Hell is Symbolic Computation?"
+snip = "Symbols, REPLs, and Quoting — Oh My!"
+date = 2016-06-29T13:30:00Z
+draft = false
+
++++
+
+I've been reading a lot of Lisp books lately, some more advanced than others.
+All of the introductory books I've seen cover the idea of symbolic computation,
+but most of them breeze past it with just a few pages about "symbols" and
+"quoting".  For many programmers coming from non-Lisp languages these are new,
+foreign concepts that don't really map back to anything in their previous
+experience.  But the books seem to expect you to understand this things after
+just a couple of paragraphs.
+
+One book that *does* spend more time on this is the appropriately-named [Common
+Lisp: A Gentle Introduction to Symbolic Computation][gentle].  If you're looking
+for a good introductory Lisp book, that's the one I'd recommend.  However, it's
+quite a long book and starts at the *very* basics (you don't even write code for
+the first few chapters — you program with drawings).  If you already know the
+some Lisp then you might find yourself bored if you go through the entire thing
+just for the symbolic computation bits.
+
+This post is an attempt to explain what symbols *actually are* and what quoting
+does.  You'll get the most out of it if you're already familiar with the basics
+of Lisp (i.e. you aren't scared by the parentheses).  But if you already know
+what something like this would print, you'll probably be bored:
+
+```text
+(let ((foo ''a))
+  (print foo)
+  (print 'foo)
+  (print (car foo))
+  (print (cdr foo)))
+```
+
+[gentle]: http://www.amazon.com/dp/0486498204/?tag=stelos-20
+
+{{% toc %}}
+
+## Disclaimer
+
+Before we start I'll get this warning out of the way: I'm going to gloss over
+a lot of gory details to get at the important core ideas.
+
+When I say "this thing is implemented like so" it's safe to assume that in
+reality things are messier and more complicated and will vary between
+implementations and dialects.  My goal is to give you some intuition for the
+basic ideas, not to exhaustively cover how a particular implementation works.
+
+I'll be using Common Lisp for the examples, but the concepts apply equally to
+Scheme, Clojure, and other Lisps too.
+
+With that out of the way, let's dive in!
+
+## The REPL
+
+The Read-Eval-Print-Loop that so many languages these days have built-in is
+a good place to start in our exploration.  You're probably familiar with the
+idea of a REPL from languages like Python, Ruby, Javascript, etc.  In Python it
+looks like this:
+
+```text
+$ python
+>>> if True:
+...     print "Yes"
+... else:
+...     print "No"
+...
+Yes
+```
+
+A handwavey definition of a REPL could be something like this:
+
+> A REPL is a program that lets you type in code.  It runs that code, prints out
+> the result, and loops back to the beginning to let you type in more.
+
+This is a good first start, but to understand symbols we're going to need to get
+a much clearer, more precise handle on what exactly each letter in "REPL" means.
+We'll start backwards and outside-in with the simplest component.
+
+## Loop
+
+The "L" in "REPL" stands for "Loop", and it's the easiest part to understand.
+A REPL doesn't just process one bit of code and then exit, it loops forever (or
+until you tell it to quit).
+
+There's not a lot to say here, except that we'll go ahead and lump together the
+extra busywork a REPL needs to do into this step so we can ignore it for the
+rest of the post.  This includes things like:
+
+* Printing the nice prompt at the beginning (`>>>` or `...` in Python).
+* Checking for `Ctrl-D` to quit.
+* Handling exceptions (so they don't kill the process).
+
+## Print
+
+The next letter is "P" for "Print".  Like `loop` this should be familiar
+territory, but let's nail down *exactly* what it does.  The job of the `print`
+function is to:
+
+* Take as input some kind of object/data structure in memory.
+* Produce some series of characters (a string) that represent this object.
+* Write those characters somewhere (standard output, a text panel in a GUI, etc).
+
+For example: if we give the integer `1` to Python's `print`, it produces
+a string of two characters (the digit `1` and a newline) and writes it to the
+terminal.  There are a lot of little details that aren't important here (line
+endings, string encoding, where the output actually goes, etc).  The important
+part that you should fix in your mind is this:
+
+**`print` takes an object, converts it into a string, and outputs it.**
+
+Note: I've called `print` a function here, and I'll do the same for `read` and
+`eval` later on.  This is correct for Common Lisp, but not necessarily for
+languages like Python or Javascript.  For the purposes of this post you can just
+imagine them as functions and realize that in the real world they're more like
+"phases" that have a lot more complex machinery under them.
+
+## Read
+
+We'll jump over to the other side of the acronym now.  "R" is for "Read", and
+this is where things start to get tricky.
+
+In most non-Lisp languages the "read" and "eval" phases of the REPL tend to get
+blurred together, but if you want to understand symbolic computation in Lisp you
+absolutely *must* keep these two parts cleanly separated in your mind.
+
+We can define `read` as almost the polar opposite of `print`.  `read` is
+a function whose job is to:
+
+* Take as input a string of characters from some source.
+* "Decode" that string and produce some kind of object in memory.
+* Return that object.
+
+Notice how this mirrors `print`:
+
+* `print`: Object → Characters
+* `read`: Characters → Object
+
+This is the second definition you need to fix in your brain:
+
+**`print` takes an object, converts it into a string, and outputs it.**  
+**`read` takes a string, converts it into an object, and returns it.**
+
+If we `read` in the string `1.0` (that's three ASCII characters), we'll get some
+kind of floating point number object back.  Sometimes there are many ways to
+represent the same object in memory.  For example: `read`ing the strings `1.0`
+and `1.0000` will both produce equivalent floating point objects representing
+the number "one".
+
+Side note (if you're not feeling pedantic feel free to skip this): the word
+"equivalent" here is a bit tricky.  When you `read` two strings like `1.0` and
+`1.000` you might get back two pointers to the same hunk of memory, or you might
+get back two pointers to two separate hunks of memory, or even just a machine
+word representing the floating point number directly.  It depends on the
+language (and even the implementation).  What I mean by "equivalent" is that
+there's no way to tell which value came from which input.  You can't say "this
+hunk of memory must have come from the string `1.000`" because `read` has
+"sanitized" the input by that point.
+
+## The RPL
+
+So now we've got `read`, `print`, and `loop`.  `read` takes characters from
+a stream and produces objects, and `print` takes objects and produces characters
+and writes them to a stream.  We're still missing a letter, but what would
+happen if we just hook these three up together right now?
+
+```text
+CL-USER> (loop (print (read)))
+> 1
+1
+>    1.0
+1.0
+> 1.00000
+1.0
+```
+
+I've added a little `>` prompt to the output here to make it clear where I'm
+typing.
+
+Essentially what we've got here is a little pretty-printer!  Notice how things
+like extra whitespace and useless zeroes got stripped out.  This isn't terribly
+useful, but at least it's doing *something*.
+
+However, it's important to realize where the "prettifying" actually happened:
+`read` actually did the hard work!  By the time `print` got its grubby little
+paws on those one-point-zeroes the extra whitespace and digits were long gone.
+Maybe we should give credit where it's due and call this a "pretty-reader"
+instead.
+
+## Reading Other Data
+
+Up to this point I've been using numbers as examples because they're simple, but
+of course we can read and print lots of other kinds of things.  Lists and
+strings (and lists *of* strings!) are some common examples:
+
+```text
+CL-USER> (print (read))
+> ("hello"       "world")
+("hello" "world")
+
+$ python
+>>> [    "hello"  , "world"]
+['hello', 'world']
+```
+
+There are lots of other kinds of things you can read and print, depending on the
+particular language.  What's important here is the strict separation of `read`
+and `print`.
+
+## Readable Printing
+
+Before we move on, one thing we should talk about is the idea of "readable
+printing".  This idea becomes clear almost immediately when you work at the
+Python REPL:
+
+```text
+$ python
+>>> "foo\nbar"
+'foo\nbar'
+>>> print "foo\nbar"
+foo
+bar
+```
+
+Why was the first string printed with quotes and an escaped newline, and the
+second without quotes and an actual newline?
+
+When we defined `print` earlier, one of the steps was:
+
+* Produce some series of characters (a string) that represent this object.
+
+Much like there are many character strings that result in the same object (e.g.
+`1.0` and `1.000`) there are often many ways we can represent a particular
+object as a series of characters.  For example: we can represent the number two
+as `2`, or `10` in binary, or `two` in English.  We can represent a string as
+the actual characters in it, or we could represent it "escaped" like Python does
+in the first line.
+
+The core idea here is that of **"readable printing": printing the characters you
+would need to give to `read` to produce this object**.
+
+This is different from what I'll call **"aesthetic printing": printing
+characters for this object which look nice to a human**.
+
+In Python these two kinds of printing are seen in the separate [`__str__` and
+`__repr__` methods][str_repr].  In Common Lisp it's controlled by the
+[`*print-readably*` variable][print-readably].  Other languages have different
+mechanisms.
+
+[str_repr]: https://brennerm.github.io/posts/python-str-vs-repr.html
+[print-readably]: http://clhs.lisp.se/Body/v_pr_rda.htm
+
+## Reading Non-Lisp
+
+So we know how reading and printing *data* works, but you can do more than that
+at a typical REPL.  Let's revisit the first Python example:
+
+```text
+$ python
+>>> if True:
+...     print "Yes"
+... else:
+...     print "No"
+...
+Yes
+```
+
+We know that `read` takes a series of characters and turns them into an object.
+When we `read` this series of characters, what comes out the other end?  For
+most languages (Python, Ruby, Javascript, Scala, etc) the answer is some kind of
+[abstract syntax tree][] represented as a data structure.  You might imagine
+something like this buried deep within the guts of the Python interpreter:
+
+```python
+class IfStatement(ASTNode):
+    def __init__(self, test_node, then_node, else_node):
+        self.test_node = test_node
+        self.then_node = then_node
+        self.else_node = else_node
+```
+
+The details would surely be a lot hairier in the real world, but the general
+idea is that the stream of characters representing your code gets read in and
+parsed into some kind of data structure in memory.
+
+This is all well and good, but our example printed "Yes", which certainly isn't
+a representation of an AST node.  Where did that come from?  To answer that
+we'll need the final letter in the acronym.
+
+[abstract syntax tree]: https://en.wikipedia.org/wiki/Abstract_syntax_tree
+
+## Evaluating Non-Lisp
+
+The "E" in REPL stands for "Eval".
+
+This is the last time we'll consider Python in this post, because we're about to
+move past it to more powerful ideas.  In Python, the purpose of the `eval` phase
+of the REPL is to:
+
+* Take an AST node (or simple data) as input.
+* Run the code (also known as *evaluating* it).
+* Return the result (if any).
+
+This is fairly straightforward, at least for our simple `if` statement.  Python
+will evaluate the `test_node` part of the `if`, and then evaluate one of the
+other parts depending on whether the test was truthy or falsey.
+
+Of course the actual process of evaluating real-life Python code is much more
+complicated than I've glossed over here, but this is good enough for us to use
+as a springboard to dive into the beautiful world of Lisp.
+
+## Reading Lisp
+
+When we talked about reading the Python `if` statement I said that Python would
+parse it into some kind of data structure representing an AST node.  I didn't
+point you at the *actual* data structure in the Python source code because
+I have no idea where it actually *is*, and it's probably not nearly as simple as
+the one I sketched out.
+
+Now that we're talking about Lisp, however, I *really can* show you exactly what
+an `if` statement in Lisp reads as!  I'll use `read-from-string` to make it
+a bit easier to see what's input and what's output, but it would work the same
+way with just plain old `read` and input from standard in.  Here we go:
+
+```text
+CL-USER> (print
+           (read-from-string "(if t (print 1) (print 2))"))
+
+(IF T (PRINT 1) (PRINT 2))
+
+CL-USER> (type-of
+           (read-from-string "(if t (print 1) (print 2))"))
+
+CONS
+```
+
+Instead of some kind of AST node data structure buried deep within the heart of
+our implementation we get... a list!  An ordinary, garden-variety, vanilla list
+made of good old trusty cons cells!
+
+The list we get contains four elements, two of which are themselves lists.  But
+what do these lists actually *contain*?
+
+The numbers are simple enough — we saw them earlier.  `read` turns a series of
+digits into a number somewhere in memory, and `print` spits out a series of
+characters that represent the number:
+
+```text
+CL-USER> (type-of (read-from-string "100"))
+
+(INTEGER 0 4611686018427387903)
+```
+
+The string `100` does indeed represent an integer between zero and four
+squillion-something.
+
+But what are those *other* things in our list?  The `if` and `t` and `print`?
+Are they some magic keywords internal to the guts of our Lisp that `print` is
+just outputting nicely for our benefit?
+
+```text
+CL-USER> (type-of (read-from-string "if"))
+
+SYMBOL
+```
+
+Buckle up — it's time to learn about symbols.
+
+## Symbols
+
+A symbol in Lisp is [a simple data structure][clhs-symbol] that turns out to be
+*extremely* useful.  You can imagine it being defined something like this:
+
+```text
+(defstruct symbol
+  name
+  function
+  value
+  property-list
+  package)
+```
+
+The `name` of a symbol is a string of characters representing the symbol's name:
+
+```text
+CL-USER> (type-of (read-from-string "if"))
+
+SYMBOL
+
+CL-USER> (symbol-name (read-from-string "if"))
+
+"IF"
+```
+
+Symbols get created (usually) when they are `read` for the first time.  If you
+`read` a sequence of characters that matches the name of an existing symbol
+(let's ignore the lowercase/uppercase thing for now), `read` just returns that
+existing symbol:
+
+```text
+CL-USER> (eq (read-from-string "cats")
+             (read-from-string "cats"))
+
+T
+```
+
+Here `read` saw the string `cats` and created a new symbol somewhere in memory
+with `CATS` as its `name`.  The second call to `read-from-string` read in the
+string `cats`, saw an existing symbol with the matching name, and just returned
+it straight away.  That's why `eq` returned true — the two `read` calls
+returned pointers to the exact same hunk of memory.
+
+(`read` also "interned" the symbol into the current package.  We're going to
+ignore the package system for this post — it's not important to the core
+topic.  We'll also ignore the property list.)
+
+So to recap:
+
+* `read` is a function that takes characters and turns them into objects.
+* When you feed `read` certain strings of characters (i.e. without special
+  characters), it returns a symbol object whose name matches those characters
+  (creating it if necessary).
+* Symbols are just normal Lisp data structures with a few specific fields.
+
+So what does `print` do with a symbol?  It just prints the `name`!
+
+```text
+CL-USER> (print (read-from-string "cats"))
+
+CATS
+```
+
+Simple enough.  Note that this is *readably printed* — if we feed it back to
+`read` we'll get an equivalent symbol back (the *exact same* symbol, in fact).
+
+But wait!  If we `read` symbols in and they're just normal vanilla structures,
+then how do we actually *do* anything in Lisp?  How does anything actually
+*run*?
+
+[clhs-symbol]: http://www.lispworks.com/documentation/lw70/CLHS/Body/t_symbol.htm
+
+## Evaluating Lisp
+
+Now we need to go back to `eval`.  In the Python example I handwaved a bit and
+said that `eval` "ran the code" but didn't really explain how that happened.
+Now that we're in the warm embrace of Lisp we can nail things down a lot more
+cleanly.
+
+`eval` (in Lisp) is a function whose job is to:
+
+* Take an object.
+* Do something useful with it to get another object.
+* Return the resulting object.
+
+I know, I know, that seems as clear as a brick.  But if we can actually define
+what "something useful" means it will be a lot more helpful.  Lisp's `eval`
+follows a few simple rules to produce its output.
+
+### Strings and Numbers
+
+First of all, `eval` will just pass numbers and strings straight through without
+touching them at all:
+
+```lisp
+(defun eval (thing)
+  (cond
+    ((numberp thing) thing)
+    ((stringp thing) thing)
+    ; ...
+    (t (error "What the hell is this?"))))
+```
+
+This makes sense because there's not a lot more useful stuff you can do with
+a number or a string on its own.  I suppose you could write a language where the
+evaluation phase ran all numbers through the absolute value function because you
+wanted to remove all negativity from programming or something, but that seems
+a bit esoteric.
+
+### Basic Lists
+
+What about lists, like our friend the `if` statement (a list of four things)?
+Well the first thing anyone learns about Lisp is the funny syntax.  In most
+cases, when passed a list `eval` treats the first element as the name of
+a function, and the rest as the arguments.  It will evaluate the arguments and
+call the function with them:
+
+```lisp
+(defun eval (thing)
+  (cond
+    ((numberp thing) thing)
+    ((stringp thing) thing)
+    ((typep thing 'list)
+     (destructuring-bind (head . arguments) thing
+       (apply (symbol-function head)
+              (mapcar #'eval arguments))))
+    ; ...
+    (t (error "What the hell is this?"))))
+```
+
+At this point we know enough to understand exactly what happens when we say
+something like `(+ 1 2)` at a Lisp REPL!
+
+* Lisp `read`s the seven characters we gave it, which becomes a list of three
+  objects: the symbol `+`, the integer `1`, and the integer `2`.
+* Lisp passes that three-object list to `eval`.
+* `eval` looks up what is in the `function` slot of the symbol at the front of
+  the list (that symbol is `+`).
+* The symbol `+` was helpfully given a function by the Lisp implementation (run
+  `(symbol-function (read-from-string "+"))` to confirm that I'm not lying to
+  you).
+* Lisp evaluates each item in the rest of the list.  In this case they're each
+  a number, so each one evaluates to itself.
+* Lisp calls the function with the evaluated arguments to get a result (in this
+  case: the integer `3`).
+* Lisp passes the result to `print`, which turns it into a string of characters
+  (one character, in this case) and prints it to standard out.
+
+Whew!  That seems like a lot, but each piece is pretty small.  Go slowly through
+it and make sure you *really* understand each step in the preceding list before
+you move on.
+
+If you don't believe me that this is really how it works, try this:
+
+```text
+CL-USER> (setf (symbol-function (read-from-string "square"))
+               (lambda (x) (* x x)))
+
+#<FUNCTION (LAMBDA (X)) {1005DCF2FB}>
+
+CL-USER> (square 4)
+
+16
+```
+
+We set the `function` slot of the symbol `square` to be a function that squares
+its argument, and then we can run it like any other function.
+
+Trace through the evaluation of that last `(square 4)` call before moving on.
+
+### Variables
+
+What about symbols that *aren't* at the front of a list?  For example:
+
+```text
+CL-USER> (defvar ten 10)
+
+10
+
+CL-USER> (square ten)
+
+100
+```
+
+In this case, everything proceeds as it did before until the recursive call to
+`eval` the argument to `square`.  The argument is just a bare symbol (not
+a number or a list or a string), so we need another rule in our `eval` function:
+
+```lisp
+(defun eval (thing)
+  (cond
+    ((numberp thing) thing)
+    ((stringp thing) thing)
+    ((symbolp thing) (symbol-value thing)) ; NEW
+    ((listp thing)
+     (destructuring-bind (head . arguments)
+       (apply (symbol-function head)
+              (mapcar #'eval arguments))))
+    ; ...
+    (t (error "What the hell is this?"))))
+```
+
+If `eval` sees a symbol on its own, it will just return whatever is in the
+`value` slot of the symbol data structure.  Simple enough!
+
+### Special Forms
+If course there are a few things we haven't talked about yet.  First of all:
+there are some "magic" symbols that aren't functions, but are hardcoded into the
+evaluation function to do certain things.  In Common Lisp they're called
+["special operators"][special-operators] and there are twenty-five of them.
+
+Let's add a special rule to our `eval` function to handle one of them (our old
+friend `if`):
+
+```lisp
+(defun eval (thing)
+  (cond
+    ((numberp thing) thing)
+    ((stringp thing) thing)
+    ((symbolp thing) (symbol-value thing))
+    ((listp thing)
+     (destructuring-bind (head . arguments) thing
+       (cond
+         ((eq head (read-from-string "if")) ; NEW
+          (destructuring-bind (test then else) arguments
+            (if (eval test)
+              (eval then)
+              (eval else))))
+         (t
+          (apply (symbol-function head)
+                 (mapcar #'eval arguments))))))
+    ; ...
+    (t (error "What the hell is this?"))))
+```
+
+At this point your head might be starting to hurt.  How have we just used `if`
+to define itself?  Is anything here actually *real*, or is Lisp just a serpent
+eating its own tail forever?
+
+### An Ouroborromean Paradox?
+
+If the "metacircularity" (god, I hate that word) of what we've just done bothers
+you, remember that this `eval` function here is just a sample of how you *can*
+write it in Lisp.  You could also write it in some other language, like C or
+Java (see: [ABCL][]) or really anything.  That would let you "bottom out" to
+something that's not Lisp.
+
+But really, is that any *less* circular?  You still need *some* language to run
+the thing!  Why does an `eval` written in C seem less "cheaty" than one written
+in Lisp?  Because it compiles to machine code?  Try
+`(disassemble #'sb-impl::simple-eval-in-lexenv)` in SBCL and you'll get a few
+thousand bytes of x86 assembly that was [originally some Lisp code much like
+ours][sbcl-eval].
+
+My advice is to just let it flow over you, even if you feel a bit uneasy at the
+sight of something like this.  Eventually as you become more at home in your
+chosen Lisp, writing high-level code one moment and `disassemble`ing a function
+the next, you'll make peace with the serpent.
+
+### Exercises
+
+There are quite a few things in `eval` that we haven't covered here, like the
+other twenty-four special operators, lexical variables, lambda forms, and more.
+But this should be enough for you to wrap your head around symbols and how
+they're used in Lisp.
+
+Before we move on to the final part of this story, make sure you can figure out
+the answers to these questions:
+
+1. What does the single character `1` read as?  What does it evaluate to?
+2. What do the characters `"hello\"world"` read as?  What do they evaluate to?
+   How would the result be printed readably?  How would the result be printed
+   aesthetically?
+3. What do the characters `(list (+ 1 2) ten)` read as?  What does it evaluate
+   to?  How does each step of the evaluation work?  Trace out each of the calls
+   to `eval` on paper, with their arguments and their results.  What does the
+   final result print as?
+4. Use `symbol-function` to see what's in the function slot of the symbol `car`.
+   How does your Lisp print that thing?
+5. Try to look up the function slot of a symbol without a function.  What
+   happens?
+4. Use `symbol-function` to see what's in the function slot of the symbol `if`.
+   What happens?  Does that seem right?  If so, why?
+5. Go to the [HyperSpec page for `symbol`][clhs-symbol] and search for
+   "the consequences are undefined if".  Try all of those things and find out
+   what interesting things break in your Lisp.
+
+If you're not using Common Lisp, port these exercises to your language.
+
+[special-operators]: http://www.lispworks.com/documentation/HyperSpec/Body/03_ababa.htm
+[ABCL]: https://common-lisp.net/project/armedbear/
+[sbcl-eval]: https://github.com/sbcl/sbcl/blob/fdc4e9fa86b5eaaf8939f004a66e4be075069aa8/src/code/eval.lisp#L131-L272
+
+## Quote
+
+Up to now we've been using the clumsy `(read-from-string "foo")` form to get
+ahold of symbols, but there's an easier way called "quoting".
+
+Quoting often confuses new Lisp programmers, and they'll end up randomly
+adding/removing quotes to something until it appears to do what they want.  Now
+that you've got `read`, `eval`, and `print` firmly separated in your mind,
+`quote` will be much easier to understand.
+
+### The Special Operator
+
+Quoting actually has two distinct components: one that affects `read` and one
+that affects `eval`.  In most books the distinction between these two only gets
+barely a sentence or two, which is probably why beginners are so confused.
+Let's look at the `eval` side of things first.
+
+`quote` is one of the twenty-five special operators.  All it does it pass its
+(single) argument back from `eval` *untouched*.  Normally the argument itself
+would have been evaluated, but `quote` prevents that:
+
+```lisp
+(defun eval (thing)
+  (cond
+    ((numberp thing) thing)
+    ((stringp thing) thing)
+    ((symbolp thing) (symbol-value thing))
+    ((listp thing)
+     (destructuring-bind (head . arguments) thing
+       (cond
+         ((eq head (read-from-string "if"))
+          (destructuring-bind (test then else) arguments
+            (if (eval test)
+              (eval then)
+              (eval else))))
+         ((eq head (read-from-string "quote")) ; NEW
+          (first arguments))
+         (t
+          (apply (symbol-function head)
+                 (mapcar #'eval arguments))))))
+    ; ...
+    (t (error "What the hell is this?"))))
+```
+
+I know that seems strange, but let's look at it in action:
+
+```text
+CL-USER> (+ 1 2)
+
+3
+
+CL-USER> (quote (+ 1 2))
+
+(+ 1 2)
+```
+
+Our first example is the same one we used in the previous section:
+
+* `read` takes in seven characters and returns a list of three items: the symbol
+  `+` and two numbers.
+* `eval` gets the three-element list, looks up the function for the symbol `+`,
+  recursively evaluates the arguments (which evaluate to themselves), and
+  applies the function.
+* `print` gets the integer `3`, turns it into ASCII, and writes it to the
+  terminal.
+
+The second example uses `quote`:
+
+* `read` takes in fifteen characters and returns a list of two items: the symbol
+  `quote` and a list of three items (the symbol `+` and two numbers).
+* `eval` gets the three element list and notices that the first element is the
+  special operator `quote`.  It simply returns the second element in the list
+  untouched, which in this case is a list of three items.
+* `print` gets that three element list, turns it into seven characters, and
+  writes it to the terminal.
+
+Just for fun, let's ride the serpent and use `quote` in the definition of
+itself inside `eval` to clean things up a bit:
+
+```lisp
+(defun eval (thing)
+  (cond
+    ((numberp thing) thing)
+    ((stringp thing) thing)
+    ((symbolp thing) (symbol-value thing))
+    ((listp thing)
+     (destructuring-bind (head . arguments) thing
+       (cond
+         ((eq head (quote if))
+          (destructuring-bind (test then else) arguments
+            (if (eval test)
+              (eval then)
+              (eval else))))
+         ((eq head (quote quote)) ; WHAT IN THE
+          (first arguments))
+         (t
+          (apply (symbol-function head)
+                 (mapcar #'eval arguments))))))
+    ; ...
+    (t (error "What the hell is this?"))))
+```
+
+That `(quote quote)` looks just completely bonkers, right?  Step through it
+piece by piece to figure it out:
+
+* What do the five characters `quote` read as?  What do they evaluate to?
+* What do the thirteen (spooky!) characters `(quote quote)` read as?  When
+  `eval` gets its hands on that, what clause in the `cond` does it hit?  What
+  does that return?
+
+Try these in a Lisp REPL if you're not 100% sure of the answers.  The functions
+`read-from-string`, `eval`, and `type-of` will come in handy.
+
+### The Read Macro
+
+Now let's look at the final piece of the puzzle.  `'` (that's a single ASCII
+quote character) is a [read macro][].  Don't worry if you don't know exactly
+what that means right now.  The important part is that when `read` sees a quote
+character, it returns a two-element list containing the symbol `quote` and the
+next form, which is read normally.
+
+The four characters `'foo` go into `read` and come out as a two-element list
+containing: the symbol `quote` and the symbol `foo`.  Again, because it's
+important: this happens *at read time*.  By the time `eval` sees anything it's
+already been turned into that two-element list.
+
+It can be a bit slippery to get a grip on this, because `print` will "helpfully"
+print a list of `(quote whatever)` as `'whatever`!  But we can use trusty old
+`car` and `cdr` to see what's really going on:
+
+```lisp
+CL-USER> (read-from-string "'foo")
+
+'FOO
+
+CL-USER> (type-of (read-from-string "'foo"))
+
+CONS
+
+CL-USER> (car (read-from-string "'foo"))
+
+QUOTE
+
+CL-USER> (cdr (read-from-string "'foo"))
+
+(FOO)
+```
+
+That's really all there is to it: `'form` is returned by `read` as `(quote
+form)`.  Then that gets passed along to `eval`, which sees the `quote` special
+operator and passes the argument back untouched.
+
+Note that `form` doesn't have to be a symbol:
+
+* `'(1 2 (4 5))` reads as `(quote (1 2 (4 5)))`
+* `'150` reads as `(quote 150)`
+* `'"hello"` reads as `(quote "hello")`
+* `'(if if if if)` reads as `(quote (if if if if))`
+
+[read macro]: https://gist.github.com/chaitanyagupta/9324402
+
+### Exercises
+
+That pretty much wraps up `quote`.  Once you've cleanly separated `read`,
+`eval`, and `print` in your mind it becomes a lot less mystical (or perhaps
+*more*, depending on your point of view).
+
+If you want to twist your brain just a bit more, try these exercises:
+
+1. What do the characters `foo` read in as?  What do they evaluate to?  How does it print?
+2. What do the characters `'foo` read in as?  What do they evaluate to?  How does it print?
+3. What do the characters `''foo` read in as?  What do they evaluate to?  How does it print?
+4. What do the characters `'1.0` read in as?  What do they evaluate to?  How does it print?
+5. What do the characters `'(1 2 3)` read in as?  How many elements are in the list?  What does it evaluate to?  How many elements are in *that* list?
+6. Update our implementation of `eval` to use the `'` read macro instead of `quote`.
+7. Certain symbols like `t` and `nil` are special — they evaluate to themselves like numbers or strings.  Add this to `eval`.
+8. What do the characters `nil` read in as?  What is the type of that object?  What do they evaluate to?  What type is that result?
+9. What do the characters `'nil` read in as?  What is the type of that object?  What do they evaluate to?  What type is that result?
+10. What do the characters `''nil` read in as?  What is the type of that object?  What do they evaluate to?  What type is that result?
+
+## A Quick Recap
+
+If you've gotten this far and understood everything, you should have a good
+grasp of how symbolic computation works.  Here are the main things I hope you've
+taken away from this post:
+
+* `read`, `eval`, and `print` are three separate, distinct functions/phases in
+  the interpretation of Lisp (and really *all* (okay, *most*)) code.
+* Keeping these three phases *clearly separated* in your mind will make it
+  easier to understand symbols and quoting in Lisp.
+* Symbols are nothing magic, they're just a particular data structure with
+  a couple of fields.
+* The important thing is how `read` and `eval` *treat* symbols.  That's where
+  the magic happens.
+* `quote` is just a "short-circuit" in `eval` that turns out to be really
+  useful.
+* `'` is just a lazier way of writing `(quote ...)`.
+
+## Where to Go From Here
+
+Now that you've got a firmer grasp on what the hell symbols actually *are*,
+there are a lot of cool things you might want to check out that will show you
+what you can do with them:
+
+* Reread some of your introductory Lisp books again, seeing if things seem to
+  make a bit more sense now.
+* Read about backquote/quasiquote.  How does it compare to the `quote` we
+  explored here?
+* Read [Paradigms of Artificial Intelligence Programming][PAIP] and pay
+  attention to how Norvig uses symbols for various tasks.  Also pay attention to
+  what he says about property lists, because we skipped them here.
+* Read the [guide to the Common Lisp package system][packaging] to learn all the
+  stuff I left out about the Common Lisp package system.
+* Gaze upon [this macro][symbolicate] in wonder (or horror).
+* Read the HyperSpec pages for things like `symbol` and `quote`.
+* Find and read your Lisp implementation's `eval` function.
+* Find and read *another* Lisp implementation's `eval` function.
+* Watch the [SICP Lectures][SICP] on YouTube.
+
+[PAIP]: http://www.amazon.com/dp/1558601910/?tag=stelos-20
+[symbolicate]: https://github.com/zkat/squirl/blob/f0dc57dfee728df94b2a35956e18e143e8b8d275/src/vec.lisp#L28-L38
+[packaging]: https://www-fourier.ujf-grenoble.fr/~sergerar/Papers/Packaging.pdf
+[SICP]: http://www.amazon.com/dp/0262510871/?tag=stelos-20
+
--- a/content/blog/2016/08/lisp-jam-postmortem.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,981 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% load mathjax %}
-
-    {% hyde
-        title: "August 2016 Lisp Game Jam Postmortem"
-        snip: "Porting a game from Clojure to Common Lisp."
-        created: 2016-08-15 13:45:00
-    %}
-
-    {% block article %}
-
-The [August 2016 Lisp Game Jam][] just wrapped up at the end of last week.
-I had some free time so I decided to take part, but I did something a bit
-different.  Instead of making a new game I ported an existing one ([Silt][]) to
-Common Lisp.
-
-I once read somewhere that when trying to build things and learn programming
-languages you should either build something you know in a language you're
-learning, or build something new in a language you already know, but *not* try
-to do both at the same time.  I've been getting into Common Lisp over the past
-year, so for this game jam I decided to port my [Ludum Dare 34 game][] from
-Clojure to Common Lisp.
-
-The game jam was ten days long.  I didn't work on the game every day, but I did
-manage to finish porting it over.  I improved and polished a few mechanics along
-the way, learned a lot, and ended up with a nice little library that sprung out
-of the code.  I'm happy with the result.
-
-The code is [on Bitbucket][Silt 2].  You can play the game over telnet if you
-want to try it out: `telnet silt.stevelosh.com`.  In this post I'm just going to
-jot down a few things I found interesting.
-
-Disclaimer: I'm going to simplify some of the code snippets to make them easier
-to read.  If you want the full details you can read the actual code.
-
-[August 2016 Lisp Game Jam]: https://itch.io/jam/august-2016-lisp-game-jam
-[Ludum Dare 34 game]: /blog/2015/12/ludum-dare-34/
-[Silt]: http://bitbucket.org/sjl/silt/
-[Silt 2]: http://bitbucket.org/sjl/silt2/
-
-[TOC]
-
-## Development
-
-[Silt 2][] is written in Common Lisp.  It uses [cl-charms][] (a wrapper around
-[ncurses][]) to handle drawing to the terminal, and a few other Common Lisp
-libraries like [iterate][] and [cl-arrows][].
-
-I developed it on [SBCL][] and OS X, and the telnet server is running Debian so
-it works there too.  It almost runs in [ClozureCL][], but something
-Unicode-related is broken with ncurses under CCL and I didn't bother debugging
-it.
-
-I used [Roswell][] to build a standalone binary for "releases".  This binary
-starts up much faster than loading everything from scratch.
-
-I use [Neovim][] and was pleasantly surprised when running ncurses inside
-Neovim's terminal emulator Just Worked (especially since the cl-charms `README`
-specifically says you *can't* run it in emacs' terminal!).  It was really nice to
-have the actual game running inside my text editor.
-
-[iterate]: https://common-lisp.net/project/iterate/
-[cl-arrows]: https://github.com/nightfly19/cl-arrows
-[cl-charms]: https://github.com/HiTECNOLOGYs/cl-charms
-[ncurses]: https://en.wikipedia.org/wiki/Ncurses
-[SBCL]: http://www.sbcl.org/
-[ClozureCL]: http://ccl.clozure.com/
-[Roswell]: https://github.com/roswell/roswell
-[Neovim]: https://neovim.io/
-
-## ncurses and cl-charms
-
-[cl-charms][] is a wrapper around [ncurses][] that I used to handle drawing the
-game to the terminal.  The original Clojure version used [clojure-lanterna][].
-
-The game's drawing code is pretty simple, so there's not a whole lot to say
-here.  I loop over the screen, drawing the contents of each world coordinate at
-each screen coordinate, and refresh the window.
-
-cl-charms mostly worked out great.  It's a bit wordy at times (always having to
-pass `charms:*standard-window*` to everything), but you can wrap it up pretty
-easily.  I'd recommend it if you need to do console drawing in Common Lisp.
-
-cl-charms has a low-level interface that's just an FFI wrapper around ncurses,
-and a high-level interface that abstracts some of the Cishness away for you.
-I mostly used the high-level interface, but one big thing that's missing is
-support for colors.  Working with colors in ncurses is a bit tedious, but this
-is Lisp so I can just abstract away all the boring stuff:
-
-    :::text
-    (defmacro defcolors (&rest colors)
-      `(progn
-        ,@(iterate (for n :from 0)
-                   (for (constant nil nil) :in colors)
-                   (collect `(define-constant ,constant ,n)))
-        (defun init-colors ()
-          ,@(iterate
-              (for (constant fg bg) :in colors)
-              (collect `(charms/ll:init-pair ,constant ,fg ,bg))))))
-
-    (defcolors
-      (+color-white-black+  charms/ll:COLOR_WHITE   charms/ll:COLOR_BLACK)
-      (+color-blue-black+   charms/ll:COLOR_BLUE    charms/ll:COLOR_BLACK)
-      (+color-cyan-black+   charms/ll:COLOR_CYAN    charms/ll:COLOR_BLACK)
-      (+color-yellow-black+ charms/ll:COLOR_YELLOW  charms/ll:COLOR_BLACK)
-      (+color-green-black+  charms/ll:COLOR_GREEN   charms/ll:COLOR_BLACK)
-      (+color-pink-black+   charms/ll:COLOR_MAGENTA charms/ll:COLOR_BLACK)
-
-      (+color-black-white+  charms/ll:COLOR_BLACK charms/ll:COLOR_WHITE)
-      (+color-black-yellow+ charms/ll:COLOR_BLACK charms/ll:COLOR_YELLOW)
-
-      (+color-white-blue+   charms/ll:COLOR_WHITE charms/ll:COLOR_BLUE)
-
-      (+color-white-red+    charms/ll:COLOR_WHITE charms/ll:COLOR_RED)
-
-      (+color-white-green+  charms/ll:COLOR_WHITE charms/ll:COLOR_GREEN))
-
-    (defmacro with-color (color &body body)
-      (once-only (color)
-        `(unwind-protect
-          (progn
-            (charms/ll:attron (charms/ll:color-pair ,color))
-            ,@body)
-          (charms/ll:attroff (charms/ll:color-pair ,color)))))
-
-
-[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
-
-## Using a State Machine as the Game Loop
-
-One thing many games have in common is a [game loop][].  The original version of
-Silt had one, but for the rewrite I decided to structure the main flow of the
-game as a state machine instead.  This worked out really well and I'm glad I did
-it.
-
-At first I looked around and tried to find a state machine library for Common
-Lisp, but then I realized I was being ridiculous and could just model a state
-machine with vanilla Lisp functions:
-
-    :::text
-    (defun state-title ()
-      (render-title)
-      (press-any-key)
-      (state-intro))
-
-    (defun state-intro ()
-      (render-intro)
-      (press-any-key)
-      (state-generate))
-
-    (defun state-generate ()
-      (render-generate)
-      (reset-world)
-      (generate-world)
-      (state-map))
-
-    (defun state-map ()
-      (charms:enable-non-blocking-mode charms:*standard-window*)
-      (state-map-loop))
-
-    (defun state-map-loop ()
-      (case (handle-input-map)
-        ((:quit) (state-quit))
-        ((:regen) (state-generate))
-        ((:help) (state-help))
-        (t (progn
-             (unless *paused*
-               (iterate (repeat *frame-skip*)
-                        (tick-world)
-                        (tick-log)))
-             (render-map)
-             (when *sleep*
-               (sleep 0.05))
-             (state-map-loop)))))
-
-    (defun state-help ()
-      (render-help)
-      (press-any-key)
-      (state-map))
-
-    (defun state-quit ()
-      'goodbye)
-
-This worked especially well with cl-charms and ncurses because for states like
-the title and help screens there's no point in looping to redraw the screen over
-and over again while waiting for input.  I just flipped ncurses into
-block-while-awaiting-input mode and let it free up the CPU while waiting for the
-user to continue.
-
-In hindsight I probably should have split out the pause state into a separate
-state, which would have let me use blocking input there too.
-
-Using functions for states like this is only possible because SBCL (and CCL)
-perform [last call optimization][], so the stack doesn't get blown by all the
-recursion happening.
-
-[game loop]: https://en.wikipedia.org/wiki/Game_programming#Game_structure
-[last call optimization]: https://en.wikipedia.org/wiki/Tail_call
-
-## Terrain Generation
-
-The original Silt was made for Ludum Dare 34 in 72 hours, so I didn't spend too
-much time on terrain.  I just created an empty world and scattered some lakes
-around it, which looked like this:
-
-[![Screenshot of terrain in the original game](/media/images{{ parent_url }}/silt1-terrain.png)](/media/images{{ parent_url }}/silt1-terrain.png)
-
-This worked and was quick, but is pretty boring and ugly.  In the past few
-months I've learned a lot more about terrain generation, so I fleshed things out
-a bit more for the new port:
-
-[![Screenshot of terrain in the new version](/media/images{{ parent_url }}/silt2-terrain.png)](/media/images{{ parent_url }}/silt2-terrain.png)
-
-Now I've got oceans and mountains for the creatures to explore.
-
-### Tiling Diamond Square
-
-My initial impulse was to use [Perlin Noise][] or [Simplex Noise][] to generate
-the heightmap for the world, but I ran into a problem.  I wanted the world to be
-a torus, just like in the original game, so I needed a terrain generation
-algorithm that would generate tileable/wrappable heightmaps.
-
-One way to do this is to use higher-dimensional noise to get 2D noise that
-tiles.  If you want to get a 2D heightmap that's tileable in one direction, you
-can use 3D noise and take a cylindrical slice of it.  To get a heightmap that
-tiles both ways you need to use 4D noise.  [This article][ron-noise] gives
-a really nice overview of the process.
-
-Unfortunately I couldn't find an implementation of 4D Simplex Noise in Common
-Lisp.  [black-tie][] and [noise][] both only offer up to 3D noise, and I don't
-feel confident enough to implement it myself, even after skimming the simplex
-noise paper.
-
-So I decided to try a different approach and figure out how to modify [Diamond
-Square][] to tile.  The [Wikipedia article for Diamond Square][ds-wiki] says:
-
-> Another option [for the diamond step] is to 'wrap around', taking the fourth
-> value from the other side of the array. When used with consistent initial
-> corner values this method also allows generated fractals to be stitched
-> together without discontinuities.
-
-This sounded great, but after thinking about it for a bit it's obviously not
-correct.  If we have a heightmap and do what the article says, it will seem to
-work at first:
-
-<pre class="lineart">
-                      ╔══════════════════╗
-    ┌─┬─┬─┬─┬─┐       ║   ┌─┬─┬─┬─┬─┐    ║
-    │5│ │ │ │5│       ║   │5│ │ │ │5│    ║
-    ├─┼─┼─┼─╱┬╲       ║   ├─┼─┼─┼─╱┬╲    ║
-    │ │ │ │╱│││╲      ║   │ │ │ │╱│││╲   ║
-    ├─┼─┼─╱─┼▼┤ ╲     ║   ├─┼─┼─╱─┼▼┤ ╲  ║
-    │ │ │3├─▶◉◀──?    ╚═══════│3├─▶◉◀════╝
-    ├─┼─┼─╲─┼▲┤ ╱         ├─┼─┼─╲─┼▲┤ ╱
-    │ │ │ │╲│││╱          │ │ │ │╲│││╱
-    ├─┼─┼─┼─╲┴╱           ├─┼─┼─┼─╲┴╱
-    │5│ │ │ │5│           │5│ │ │ │5│
-    └─┴─┴─┴─┴─┘           └─┴─┴─┴─┴─┘
-</pre>
-
-Wrapping like this will indeed make sure that the averages match up, but there's
-two problems.
-
-First: the corners are all the same value, which means that when you put four
-heightmaps next to each other there's an unnatural flat area of four identical
-height values next to each other.  This probably wouldn't be noticeable in
-practice, but if you want to do things *right* it won't be acceptable.
-
-But the *real* problem is the jitter.  If the jitter on one side of the map
-happens to be large and positive and the jitter on the other side happens to be
-large and negative, you'll get a jarring "cliff" when you try to tile them:
-
-[![Example of poorly-tiling diamond square](/media/images{{ parent_url }}/bad-tiling-ds.png)](/media/images{{ parent_url }}/bad-tiling-ds.png)
-
-The solution I came up with is to reduce the size of the heightmap by 1.
-Instead of the heightmap being \\(2^n + 1\\) in each dimension we can make it
-\\(2^n\\) and adjust the coordinate-wrapping function appropriately.
-Importantly, we *don't* change the calculation of the radius values as we
-iterate over the array, so this means quite often we'll be "reaching" for that
-final row/column:
-
-<pre class="lineart">
-     ?       ?
-    ┌─╲─┬─┬─╱
-    │ │╲│ │╱│
-    ├─┼─◢─◣─┤
-    │ │ │◉│ │
-    ├─┼─◥─◤─┤
-    │ │╱│ │╲│
-    ├─╱─┼─┼─╲
-    │5│ │ │ │?
-    └─┴─┴─┴─┘
-</pre>
-
-When we try to access that nonexistent coordinate we just wrap around back to
-zero.  Notice that we also only need to initialize a single corner cell now.
-
-It's a simple change, but the result is *much* nicer:
-
-[![Example of nicely-tiling diamond square](/media/images{{ parent_url }}/good-tiling-ds.png)](/media/images{{ parent_url }}/good-tiling-ds.png)
-
-[Perlin Noise]: https://en.wikipedia.org/wiki/Perlin_noise
-[Simplex Noise]: https://en.wikipedia.org/wiki/Simplex_noise
-[ron-noise]: http://ronvalstar.nl/creating-tileable-noise-maps
-[black-tie]: https://github.com/aerique/black-tie
-[noise]: https://github.com/sebity/noise
-[Diamond Square]: /blog/2016/06/diamond-square/
-[ds-wiki]: https://en.wikipedia.org/wiki/Diamond-square_algorithm
-
-## Entity, Aspects, and Systems
-
-Terrain generation is pretty, but the next step in the port was to add some
-plants, creatures, and artifacts.  In the original game I just represented
-things in the world as vanilla Clojure maps, but that was getting kind of messy
-and I wanted to try a different approach this time.
-
-Recently I read through [Game Engine Architecture][] (a *fantastic* book) and
-made a few games in [Unity][], which together made me want to try using an
-[Entity/Component System][] this time around.  There are a couple of ECS
-libraries out there for Common Lisp like [cl-ecs][] and [ecstasy][], but in true
-Lisp fashion I ended up not being quite satisfied with any of them and writing
-Yet Another God Damn Library.
-
-It's called [Beast][].  It's subtly different than the others in that it prefers
-to be a really thin layer over CLOS and uses inheritance instead of composition.
-It uses the word "aspect" instead of "component" to try to overload that word
-a bit less, so it's the "Basic Entity/Aspect/System Toolkit".  It ended up being
-about 150 lines of code (not including docstrings), so I managed to avoid going
-down too much of a rabbit hole during the jam.
-
-If you want to know all the details, check out its documentation (it has
-*actual* documentation).  But here I'll just talk about a couple of the
-particular bits of Silt that I used it for.
-
-[Unity]: https://unity3d.com/
-[Game Engine Architecture]: http://www.amazon.com/dp/1466560010/?tag=stelos-20
-[Entity/Component System]: https://en.wikipedia.org/wiki/Entity_component_system
-[cl-ecs]: https://github.com/lispgames/cl-ecs
-[ecstasy]: https://github.com/mfiano/ecstasy
-[beast]: http://sjl.bitbucket.org/beast/overview/
-
-### Coordinates
-
-The first thing I needed was a way to keep track of where things are in the
-world.
-
-If the world space were continuous a [quadtree][] would have been my first
-choice, but in Silt the world is split into discrete integer coordinates.
-Creatures move directly from \\((x, y)\\) to \\((x+1, y+1)\\).  I decided to use
-a simple array of lists to represent this:
-
-    :::text
-    (defparameter *coords-contents*
-      (make-array (list +world-size+ +world-size+)
-                  :initial-element nil))
-
-Each value in the array is a list of the entities that are currently there.
-This means looking up what things are at a given coordinate is a single fast
-`aref`.
-
-I tried using a hash table instead of an array at first, thinking that if the
-world were fairly sparse it would be wasteful to allocate an array with a ton
-of `nil` values in it.  But the array method is much faster for looking things
-up (which happens a lot) and memory is cheap, so I decided against the hash
-tables.  It worked great in the end.
-
-Entities need to know where they are in the world, so I defined a Beast aspect
-for that:
-
-    :::text
-    (define-aspect coords x y)
-
-Then I defined a few functions to handle moving entities into, out of, and
-around the world:
-
-    :::text
-    (defun coords-insert-entity (e)
-      (push e (aref *coords-contents* (coords/x e) (coords/y e))))
-
-    (defun coords-remove-entity (e)
-      (zap% (aref *coords-contents* (coords/x e) (coords/y e))
-            #'delete e %))
-
-    (defun coords-move-entity (e new-x new-y)
-      (coords-remove-entity e)
-      (setf (coords/x e) (wrap new-x)
-            (coords/y e) (wrap new-y))
-      (coords-insert-entity e))
-
-    (defun coords-lookup (x y)
-      (aref *coords-contents* (wrap x) (wrap y)))
-
-Entities might also like to know what's near them:
-
-    :::text
-    (defun nearby (entity &optional (radius 1))
-      (remove entity
-              (iterate
-                outer
-                (with x = (coords/x entity))
-                (with y = (coords/y entity))
-                (for dx :from (- radius) :to radius)
-                (iterate
-                  (for dy :from (- radius) :to radius)
-                  (in outer
-                      (appending (coords-lookup (+ x dx)
-                                                (+ y dy))))))))
-
-This ends up compiling down to a nice tight loop of \\((2 * radius + 1)^2\\)
-`aref`s.  I only wish iterate had a nicer syntax for looping over nested
-indices like this.  I'm sure it's possible to write an iterate driver for it --
-maybe someday I'll try making one.
-
-I also needed a way to get entities into the world array when they're created
-and remove them when they die.  Beast (well, actually CLOS) makes this trivially
-easy with auxiliary methods:
-
-    :::text
-    (defmethod entity-created :after ((entity coords))
-      (coords-insert-entity entity))
-
-    (defmethod entity-destroyed :after ((entity coords))
-      (coords-remove-entity entity))
-
-[quadtree]: https://en.wikipedia.org/wiki/Quadtree
-
-### User Interface
-
-Once I had a way of know where things are, the next step was to display them on
-the screen.  I broke this into a few separate aspects.
-
-#### Visible
-
-The `visible` aspect is for things that are drawn on the screen with
-a particular glyph and color:
-
-    :::text
-    (define-aspect visible glyph color)
-
-    ;; ...
-
-    (define-entity tree (coords visible ...))
-
-    (defun make-tree (x y)
-      (create-entity 'tree
-                     :coords/x x
-                     :coords/y y
-                     :visible/glyph "T"
-                     :visible/color +color-green-black+
-                     ;; ...
-                     ))
-
-
-The drawing code can then figure out what to draw for each screen coordinate:
-
-    :::text
-    (defun draw-map ()
-      (iterate
-        (for sx :from 0 :below *screen-width*)
-        (for wx :from *view-x*)
-        (iterate
-          (for sy :from 0 :below *screen-height*)
-          (for wy :from *view-y*)
-          (for entity = (find-if #'visible? (coords-lookup wx wy)))
-          (if entity
-            (with-color (visible/color entity)
-              (write-string-at (visible/glyph entity) sx sy))
-            ;;; otherwise draw the terrain
-            (...)))))
-
-Again: my kingdom for a `(for-nested ...)` iterate driver!  But the core is just
-using `(find-if #'visible? (coords-lookup wx wy))` to find the first visible
-thing and then drawing it:
-
-[![Screenshot of entities with the visible aspect](/media/images{{ parent_url }}/aspect-visible.png)](/media/images{{ parent_url }}/aspect-visible.png)
-
-I used `find-if` instead of `remove-if-not` because we can only draw one
-character to a given position in the terminal anyway, so I just pick the first
-thing that happens to be in the list.
-
-#### Flavor
-
-The `flavor` aspect is for adding [flavor text][] that appears when the user
-puts their cursor over an entity:
-
-    :::text
-    (define-aspect flavor text)
-
-    ;; ...
-
-    (define-entity tree (coords visible flavor ...))
-
-    (defun make-tree (x y)
-      (create-entity 'tree
-                     :coords/x x
-                     :coords/y y
-                     :visible/glyph "T"
-                     :visible/color +color-green-black+
-                     :flavor/text
-                     '("A tree sways gently in the wind.")))
-
-Then when the user's cursor is at a certain position I can find all the entities
-there and draw the flavor text for any that have the `flavor` aspect:
-
-    :::text
-    (defun draw-selected ()
-      (write-left
-        (iterate
-          (for entity :in (multiple-value-call #'coords-lookup
-                            (screen-to-world *cursor-x* *cursor-y*)))
-          (when (typep entity 'flavor)
-            (appending (flavor/text entity) :into text)
-
-            ;; ...
-
-            (collecting "" :into text))
-          (finally (return text)))
-        1 1 :pad t))
-
-Which looks like this:
-
-[![Screenshot of flavor text](/media/images{{ parent_url }}/aspect-flavor.png)](/media/images{{ parent_url }}/aspect-flavor.png)
-
-Of course the flavor text doesn't have to be a constant:
-
-    :::text
-    (defun make-creature (x y &key
-                          (color +color-white-black+)
-                          (glyph "@"))
-      (let ((name (random-name)))
-        (create-entity 'creature
-          :name name
-          :coords/x x
-          :coords/y y
-          :visible/color color
-          :visible/glyph glyph
-          :flavor/text
-          (list (format nil "A creature named ~A is here." name)
-                "It likes food."))))
-
-[flavor text]: https://en.wikipedia.org/wiki/Flavor_text
-
-#### Inspectable
-
-The last thing I wanted was an easy way to show attributes of entities in the
-main game UI.  The original Clojure game just dumped the entire object to the
-screen:
-
-[![Screenshot of creature inspection in the original game](/media/images{{ parent_url }}/silt1-inspect.png)](/media/images{{ parent_url }}/silt1-inspect.png)
-
-But this time I wanted a bit more control.  The `inspectable` aspect has a list
-of things that should be displayed.  These can be symbols (which denote CLOS
-slot names) or functions that return `(label . text)` conses:
-
-    :::text
-    (define-aspect inspectable
-      (slots :initform nil))
-
-    (defun inspectable-get (entity slot)
-      (etypecase slot
-        (symbol (cons slot (slot-value entity slot)))
-        (function (funcall slot entity))))
-
-When creating an entity I can just list out the slots I want to be displayed on
-the screen, or use a little `lambda` if I want to show something that's not an
-actual slot:
-
-    :::text
-    (defun make-fruit (x y)
-      (create-entity 'fruit
-        ;; ...
-        :inspectable/slots '(edible/energy)))
-
-    (defun make-creature (x y &key ...)
-      (let ((name (random-name)))
-        (create-entity 'creature
-          ;; ...
-          :inspectable/slots
-          (list 'name
-                (lambda (c) (cons 'directions ...))
-                'metabolizing/energy
-                'metabolizing/insulation
-                'aging/birthtick
-                'aging/age))))
-
-Then I just append some extra text for `inspectable` entities when drawing
-descriptions of things at the cursor position:
-
-    :::text
-    (defun draw-selected ()
-      (write-left
-        (iterate
-          (for entity :in (multiple-value-call #'coords-lookup
-                            (screen-to-world *cursor-x* *cursor-y*)))
-          (when (typep entity 'flavor)
-            ;; ...
-            (when (typep entity 'inspectable)
-              (appending
-                (indent
-                  (iterate
-                    (with slots = (mapcar (curry #'inspectable-get entity)
-                                          (inspectable/slots entity)))
-                    (with width = (apply #'max
-                                         (mapcar (compose #'length #'symbol-name #'car)
-                                                 slots)))
-                    (for (label . contents) :in slots)
-                    (collect
-                      (let ((*print-pretty* nil))
-                        (format nil "~vA ~A" width label contents)))))
-                :into text))
-
-            (collecting "" :into text))
-          (finally (return text)))
-        1 1 :pad t))
-
-This is pretty ugly because I wanted to justify and indent things nicely, but
-the result looks much nicer than the original game:
-
-[![Screenshot of creature inspection in the new version](/media/images{{ parent_url }}/silt2-inspect.png)](/media/images{{ parent_url }}/silt2-inspect.png)
-
-### Food
-
-Seeing the world is nice, but we also want the things in it to actually *do*
-something.  The world revolves heavily around food and energy, so I defined
-a few aspects to handle things:
-
-    :::text
-    (define-aspect edible
-      energy
-      original-energy)
-
-    (define-aspect decomposing
-      rate
-      (remaining :initform 1.0))
-
-    (define-aspect fruiting
-      chance)
-
-    (defmethod initialize-instance :after ((e edible) &key)
-      (setf (edible/original-energy e)
-            (edible/energy e)))
-
-I do wish there was a slightly less wordy way to default the value of one slot
-to another one, but oh well.
-
-Then I just added the aspects to the appropriate entities:
-
-    :::text
-    (define-entity tree (coords visible fruiting flavor))
-    (define-entity fruit (coords visible edible flavor decomposing inspectable))
-    (define-entity algae (coords visible edible decomposing))
-    (define-entity grass (coords visible edible decomposing))
-    (define-entity corpse (coords visible flavor decomposing))
-
-Trees can grow fruit, so they have the `fruiting` aspect.  The `grow-fruit`
-Beast system handles growing some each tick:
-
-    :::text
-    (define-system grow-fruit ((entity fruiting coords))
-      (when (randomp (fruiting/chance entity))
-        (make-fruit (wrap (random-around (coords/x entity) 2))
-                    (wrap (random-around (coords/y entity) 2)))))
-
-Fruit is `edible`, but also decomposes over time.  It's got `flavor` and
-`inspectable` aspects so you can see how much energy is left.
-
-I added algae and grass as secondary food sources to spread out the food supply
-a bit more and make the creatures a bit less dependent on the trees.  I didn't
-give these flavor text to avoid cluttering up the UI too much.
-
-I considered making corpses edible too, but figured that might be a bit too
-gruesome.  So corpses decompose, but the critters aren't cannibals.
-
-I made a couple of Beast systems to handle the process of decomposing things
-every game tick:
-
-    :::text
-    (define-system rot ((entity decomposing))
-      (when (minusp (decf (decomposing/remaining entity)
-                          (decomposing/rate entity)))
-        (destroy-entity entity)))
-
-    (define-system rot-food ((entity decomposing edible))
-      (setf (edible/energy entity)
-            (lerp 0.0 (edible/original-energy entity)
-                  (decomposing/remaining entity))))
-
-`rot` runs on everything with the `decomposing` aspect.  It ticks along the
-progress of an entity's decomposition, and destroys it once it's finished.
-
-`rot-food` runs on every entity that's both `decomposing` *and* `edible`.  It
-reduces the energy value of the food over time, because rotten food is less
-healthy.  I'm pretty happy with how easy Beast makes this kind of thing.
-
-### Creatures and Mysteries
-
-The final pieces of the world are the creatures and artifacts.
-
-#### Energy
-Creatures need food (energy) to survive.  I modeled this with a `metabolizing`
-aspect and `consume-energy` system:
-
-    :::text
-    (define-aspect metabolizing insulation energy)
-
-    (defmethod starve ((entity entity))
-      (destroy-entity entity))
-
-    (defmethod calculate-energy-cost ((entity metabolizing))
-      (let* ((insulation (metabolizing/insulation entity))
-             (base-cost 1.0)
-             (temperature-cost (max 0 (* 0.2 (- (abs *temperature*) insulation))))
-             (insulation-cost (* 0.1 insulation)))
-        (+ base-cost temperature-cost insulation-cost)))
-
-    (define-system consume-energy ((entity metabolizing))
-      (when (minusp (decf (metabolizing/energy entity)
-                          (calculate-energy-cost entity)))
-        (starve entity)))
-
-I made `starve` and `calculate-energy-cost` generic functions because I thought
-I might eventually have different metabolizing things in the world and might
-want to override them.  I didn't end up doing this in the end (creatures are the
-only things that burn energy) so these could have been normal functions.
-
-The energy mechanic works similarly to the original game:
-
-* Creatures spend a bit of energy each tick to stay alive.
-* When you make the temperature hotter or colder, it costs additional energy per
-  tick for the creatures to live.
-* Creatures sometimes gain/lose insulation during reproduction, which mitigates
-  the energy cost of the temperature difference.
-* Insulation itself costs a little bit of energy every tick.
-
-The effect is that if you change the temperature gradually over time, the
-population will evolve higher insulation values (because the children with more
-insulation are more likely to survive longer).  If you then set the temperature
-back to zero (the ideal) the population will eventually evolve to shed the
-insulation, because it costs a little bit of energy and doesn't provide any
-benefit when the world is pleasant.  Natural selection is fun.
-
-The last piece of the puzzle is letting things actually take action.  Creatures
-and some artifacts need to take an action on every tick, while other artifacts
-only do things occasionally.  A pair of aspects and systems handles the
-bookkeeping here:
-
-    :::text
-    (define-aspect sentient function)
-    (define-aspect periodic
-      function
-      (counter :initform 1)
-      next
-      min
-      max)
-
-    (define-system sentient-act ((entity sentient))
-      (funcall (sentient/function entity) entity))
-
-    (define-system periodic-tick ((entity periodic))
-      (when (zerop (setf (periodic/counter entity)
-                         (mod (1+ (periodic/counter entity))
-                              (periodic/next entity))))
-        (setf (periodic/next entity)
-              (random-range (periodic/min entity)
-                            (periodic/max entity)))
-        (funcall (periodic/function entity) entity)))
-
-I'm not going to go over all the actual AI and actions, you can take a look at
-the code if you're curious.
-
-## Random Name Generation
-
-I wanted to add a more personal connection to the creatures this time around, so
-I decided they should have names.  I used a really simple form of
-[syllable-based name generation][namegen] to give each creature its own random
-name:
-
-    :::text
-    (defparameter *name-syllables*
-      (-> "syllables.txt"
-        slurp
-        read-from-string
-        (coerce 'vector)))
-
-    (defun random-name ()
-      (format nil "~:(~{~A~}~)"
-              (iterate (repeat (random-range 1 5))
-                       (collect (random-elt *name-syllables*)))))
-
-To get a random name I just smash together one to four random syllables.  To
-make a list of syllables I grabbed some Icelandic text and made a pair of really
-janky shell and Python scripts to print out every 3/4/5-letter chunk of every
-word, sort them by frequency, and take the top 500.
-
-They're not *really* syllables but they're okay for just a couple of lines of
-code and a few minutes work:
-
-[![Screenshot of creature names](/media/images{{ parent_url }}/silt-names.png)](/media/images{{ parent_url }}/silt-names.png)
-
-[namegen]: http://www.roguebasin.com/index.php?title=Syllable-based_name_generation
-
-## Simple Data Structures
-
-As I coded things up I wound up with a handy pair of data structures I might use
-again for other things in the future.
-
-### Weightlists
-
-Each game tick a creature needs to decide which direction to walk.  At the start
-of the game they just pick a random direction, but as they reproduce their
-children can mutate to prefer certain directions over others.
-
-The natural selection of Silt turns out to prefer creatures that wander around
-to those that stay in place.  Fruit takes time to grow, so it's more effective
-to travel around and gather it than to sit in place waiting for it to regrow.
-
-The original game just used a Clojure vector of weights and directions to
-represent how much a creature prefers each direction.  That worked, but the
-weights are only ever set/changed when a creature is born, and a random element
-is chosen every turn.  It's more efficient in the long run if we precompute
-a few things up front, so I made a little "weightlist" API:
-
-    :::text
-    (defstruct (weightlist (:constructor %make-weightlist))
-      weights sums items total)
-
-    (defun make-weightlist (items weights)
-      "Make a weightlist of the given items and weights."
-      (%make-weightlist
-        :items items
-        :weights weights
-        :sums (prefix-sums weights)
-        :total (apply #'+ weights)))
-
-    (defun weightlist-random (weightlist)
-      "Return a random item from the weightlist, taking the weights into account."
-      (iterate
-        (with n = (random (weightlist-total weightlist)))
-        (for item :in (weightlist-items weightlist))
-        (for weight :in (weightlist-sums weightlist))
-        (finding item :such-that (< n weight))))
-
-This is pretty straightforward.  Note that the weights can be integers or floats
-(or some of each!) and things will Just Work, because Common Lisp's `random` can
-take either.  Weights of zero are fine too, as long as at least one element has
-a nonzero weight.
-
-### Ticklists
-
-In a couple of places I needed some kind of list where items in it expire over
-time.  For example:
-
-* The Fountain artifact only lets creatures drink from it once every thousand
-  ticks, so I needed a way to keep track of the entities that had drank
-  recently.
-* The game log at the bottom of the screen contains messages that should be
-  shown for a certain number of ticks, then disappear.
-
-I made a simple little thing I called a "ticklist" to handle these:
-
-    :::text
-    (defun make-ticklist ()
-      nil)
-
-    (defmacro ticklist-push (ticklist value lifespan)
-      `(push (cons ,lifespan ,value) ,ticklist))
-
-    (defun ticklist-tick (ticklist)
-      (flet ((decrement (entry)
-               (decf (car entry)))
-             (dead (entry)
-               (minusp (car entry))))
-        (->> ticklist
-          (mapc #'decrement)
-          (remove-if #'dead))))
-
-    (defun ticklist-contents (ticklist)
-      (mapcar #'cdr ticklist))
-
-Internally a ticklist is just a list of `(remaining-ticks . thing)` conses, but
-the rest of my code doesn't have to care about that:
-
-    :::text
-    (defun fountain-act (f)
-      (with-slots (recent) f
-        (zapf recent #'ticklist-tick)
-        (iterate
-          (with already-drank = (ticklist-contents recent))
-          (for creature :in (remove-if-not #'creature? (nearby f)))
-          (unless (member creature already-drank)
-            (creature-mutate-appearance creature)
-            (ticklist-push recent creature 1000)
-            (log-message "~A drinks from the fountain and... changes."
-                         (creature-name creature))))))
-
-    (defun log-message (s &rest args)
-      (ticklist-push *game-log* (apply #'format nil s args) 200))
-
-    (defun state-map-loop ()
-      ;; ...
-      (unless *paused*
-        (iterate (repeat *frame-skip*)
-                 (tick-world)
-                 (zapf *game-log* #'ticklist-tick))))
-
-## Profiling and Performance
-
-When something starts slowing things down it's helpful to be able to turn on
-profiling and see what's going on.  SBCL has a nice statistical profiler, so
-I made a couple of functions to flip it on and off as needed:
-
-    :::text
-    #+sbcl
-    (defun dump-profile ()
-      (with-open-file (*standard-output* "silt.prof"
-                                         :direction :output
-                                         :if-exists :supersede)
-        (sb-sprof:report :type :graph
-                         :sort-by :cumulative-samples
-                         :sort-order :ascending)
-        (sb-sprof:report :type :flat
-                         :min-percent 0.5)))
-
-    #+sbcl
-    (defun start-profiling ()
-      (sb-sprof::reset)
-      (sb-sprof::profile-call-counts "SILT")
-      (sb-sprof::start-profiling :max-samples 50000
-                                 ; :mode :cpu
-                                 :mode :time
-                                 :sample-interval 0.01
-                                 :threads :all))
-
-    #+sbcl
-    (defun stop-profiling ()
-      (sb-sprof::stop-profiling)
-      (dump-profile))
-
-When I wanted to check performance I could just evaluate `(start-profiling)`
-over NREPL and let the game continue to run, then `(stop-profiling)` a little
-bit later and look at the results.  It came in handy once or twice when tracking
-down some slowness.
-
-## Future Improvements and Ideas
-
-This game jam was quite a bit of fun!  I'm happy with the results and feel like
-I've learned a lot along the way.
-
-I'm done with the game and don't plan on updating it any more, but I'll scribble
-down a few extra ideas for things that could be improved here, just to get them
-out of my head:
-
-* Figure out the Unicode issues with cl-charms and CCL.
-* Contribute to cl-charms to add some higher-level tools for working with color.
-* Contribute to one of the Common Lisp noise libraries to implement the 4D
-  variant of Simplex Noise.
-* Flesh out the name generation into something much nicer and more polished.
-* Implement different costs for moving over different terrain.
-* Add health, fighting, and carnivores.
-* Add more mysterious artifacts to the world.
-* Flesh out the vegetation model to let trees grow and die, algae spread, etc.
-* Improve the visuals. [Brogue][] proves you can do far more than you might
-  think with just Unicode characters.
-* Model senses like vision, providing the creatures with more information but
-  with an energy cost.
-* Give creatures "brains" by generating and mutating actual Lisp code.  This
-  would let the creatures learn strategies over time, though I'm not sure how
-  feasible it would be.
-* Improve performance by profiling much more and fixing the hottest parts of the
-  code.
-* Add saving and loading of the world.
-* Add the ability to seed the RNG and make everything deterministic, so people
-  can share interesting seeds.  Doing this for the terrain generation at least
-  should be pretty easy, the game as a whole might be slightly trickier.
-* Improve the UI a bit more, maybe using ncurses' support for windows layered on
-  top of other windows.
-
-[Brogue]: https://sites.google.com/site/broguegame/
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2016/08/lisp-jam-postmortem.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,1003 @@
++++
+title = "August 2016 Lisp Game Jam Postmortem"
+snip = "Porting a game from Clojure to Common Lisp."
+date = 2016-08-15T13:45:00Z
+draft = false
+
++++
+
+The [August 2016 Lisp Game Jam][] just wrapped up at the end of last week.
+I had some free time so I decided to take part, but I did something a bit
+different.  Instead of making a new game I ported an existing one ([Silt][]) to
+Common Lisp.
+
+I once read somewhere that when trying to build things and learn programming
+languages you should either build something you know in a language you're
+learning, or build something new in a language you already know, but *not* try
+to do both at the same time.  I've been getting into Common Lisp over the past
+year, so for this game jam I decided to port my [Ludum Dare 34 game][] from
+Clojure to Common Lisp.
+
+The game jam was ten days long.  I didn't work on the game every day, but I did
+manage to finish porting it over.  I improved and polished a few mechanics along
+the way, learned a lot, and ended up with a nice little library that sprung out
+of the code.  I'm happy with the result.
+
+The code is [on Bitbucket][Silt 2].  You can play the game over telnet if you
+want to try it out: `telnet silt.stevelosh.com`.  In this post I'm just going to
+jot down a few things I found interesting.
+
+Disclaimer: I'm going to simplify some of the code snippets to make them easier
+to read.  If you want the full details you can read the actual code.
+
+[August 2016 Lisp Game Jam]: https://itch.io/jam/august-2016-lisp-game-jam
+[Ludum Dare 34 game]: /blog/2015/12/ludum-dare-34/
+[Silt]: http://bitbucket.org/sjl/silt/
+[Silt 2]: http://bitbucket.org/sjl/silt2/
+
+{{% toc %}}
+
+
+## Development
+
+[Silt 2][] is written in Common Lisp.  It uses [cl-charms][] (a wrapper around
+[ncurses][]) to handle drawing to the terminal, and a few other Common Lisp
+libraries like [iterate][] and [cl-arrows][].
+
+I developed it on [SBCL][] and OS X, and the telnet server is running Debian so
+it works there too.  It almost runs in [ClozureCL][], but something
+Unicode-related is broken with ncurses under CCL and I didn't bother debugging
+it.
+
+I used [Roswell][] to build a standalone binary for "releases".  This binary
+starts up much faster than loading everything from scratch.
+
+I use [Neovim][] and was pleasantly surprised when running ncurses inside
+Neovim's terminal emulator Just Worked (especially since the cl-charms `README`
+specifically says you *can't* run it in emacs' terminal!).  It was really nice to
+have the actual game running inside my text editor.
+
+[iterate]: https://common-lisp.net/project/iterate/
+[cl-arrows]: https://github.com/nightfly19/cl-arrows
+[cl-charms]: https://github.com/HiTECNOLOGYs/cl-charms
+[ncurses]: https://en.wikipedia.org/wiki/Ncurses
+[SBCL]: http://www.sbcl.org/
+[ClozureCL]: http://ccl.clozure.com/
+[Roswell]: https://github.com/roswell/roswell
+[Neovim]: https://neovim.io/
+
+## ncurses and cl-charms
+
+[cl-charms][] is a wrapper around [ncurses][] that I used to handle drawing the
+game to the terminal.  The original Clojure version used [clojure-lanterna][].
+
+The game's drawing code is pretty simple, so there's not a whole lot to say
+here.  I loop over the screen, drawing the contents of each world coordinate at
+each screen coordinate, and refresh the window.
+
+cl-charms mostly worked out great.  It's a bit wordy at times (always having to
+pass `charms:*standard-window*` to everything), but you can wrap it up pretty
+easily.  I'd recommend it if you need to do console drawing in Common Lisp.
+
+cl-charms has a low-level interface that's just an FFI wrapper around ncurses,
+and a high-level interface that abstracts some of the Cishness away for you.
+I mostly used the high-level interface, but one big thing that's missing is
+support for colors.  Working with colors in ncurses is a bit tedious, but this
+is Lisp so I can just abstract away all the boring stuff:
+
+```text
+(defmacro defcolors (&rest colors)
+  `(progn
+    ,@(iterate (for n :from 0)
+               (for (constant nil nil) :in colors)
+               (collect `(define-constant ,constant ,n)))
+    (defun init-colors ()
+      ,@(iterate
+          (for (constant fg bg) :in colors)
+          (collect `(charms/ll:init-pair ,constant ,fg ,bg))))))
+
+(defcolors
+  (+color-white-black+  charms/ll:COLOR_WHITE   charms/ll:COLOR_BLACK)
+  (+color-blue-black+   charms/ll:COLOR_BLUE    charms/ll:COLOR_BLACK)
+  (+color-cyan-black+   charms/ll:COLOR_CYAN    charms/ll:COLOR_BLACK)
+  (+color-yellow-black+ charms/ll:COLOR_YELLOW  charms/ll:COLOR_BLACK)
+  (+color-green-black+  charms/ll:COLOR_GREEN   charms/ll:COLOR_BLACK)
+  (+color-pink-black+   charms/ll:COLOR_MAGENTA charms/ll:COLOR_BLACK)
+
+  (+color-black-white+  charms/ll:COLOR_BLACK charms/ll:COLOR_WHITE)
+  (+color-black-yellow+ charms/ll:COLOR_BLACK charms/ll:COLOR_YELLOW)
+
+  (+color-white-blue+   charms/ll:COLOR_WHITE charms/ll:COLOR_BLUE)
+
+  (+color-white-red+    charms/ll:COLOR_WHITE charms/ll:COLOR_RED)
+
+  (+color-white-green+  charms/ll:COLOR_WHITE charms/ll:COLOR_GREEN))
+
+(defmacro with-color (color &body body)
+  (once-only (color)
+    `(unwind-protect
+      (progn
+        (charms/ll:attron (charms/ll:color-pair ,color))
+        ,@body)
+      (charms/ll:attroff (charms/ll:color-pair ,color)))))
+
+```
+
+[clojure-lanterna]: http://sjl.bitbucket.org/clojure-lanterna/
+
+## Using a State Machine as the Game Loop
+
+One thing many games have in common is a [game loop][].  The original version of
+Silt had one, but for the rewrite I decided to structure the main flow of the
+game as a state machine instead.  This worked out really well and I'm glad I did
+it.
+
+At first I looked around and tried to find a state machine library for Common
+Lisp, but then I realized I was being ridiculous and could just model a state
+machine with vanilla Lisp functions:
+
+```text
+(defun state-title ()
+  (render-title)
+  (press-any-key)
+  (state-intro))
+
+(defun state-intro ()
+  (render-intro)
+  (press-any-key)
+  (state-generate))
+
+(defun state-generate ()
+  (render-generate)
+  (reset-world)
+  (generate-world)
+  (state-map))
+
+(defun state-map ()
+  (charms:enable-non-blocking-mode charms:*standard-window*)
+  (state-map-loop))
+
+(defun state-map-loop ()
+  (case (handle-input-map)
+    ((:quit) (state-quit))
+    ((:regen) (state-generate))
+    ((:help) (state-help))
+    (t (progn
+         (unless *paused*
+           (iterate (repeat *frame-skip*)
+                    (tick-world)
+                    (tick-log)))
+         (render-map)
+         (when *sleep*
+           (sleep 0.05))
+         (state-map-loop)))))
+
+(defun state-help ()
+  (render-help)
+  (press-any-key)
+  (state-map))
+
+(defun state-quit ()
+  'goodbye)
+```
+
+This worked especially well with cl-charms and ncurses because for states like
+the title and help screens there's no point in looping to redraw the screen over
+and over again while waiting for input.  I just flipped ncurses into
+block-while-awaiting-input mode and let it free up the CPU while waiting for the
+user to continue.
+
+In hindsight I probably should have split out the pause state into a separate
+state, which would have let me use blocking input there too.
+
+Using functions for states like this is only possible because SBCL (and CCL)
+perform [last call optimization][], so the stack doesn't get blown by all the
+recursion happening.
+
+[game loop]: https://en.wikipedia.org/wiki/Game_programming#Game_structure
+[last call optimization]: https://en.wikipedia.org/wiki/Tail_call
+
+## Terrain Generation
+
+The original Silt was made for Ludum Dare 34 in 72 hours, so I didn't spend too
+much time on terrain.  I just created an empty world and scattered some lakes
+around it, which looked like this:
+
+[![Screenshot of terrain in the original game](/media/images/blog/2016/08/silt1-terrain.png)](/media/images/blog/2016/08/silt1-terrain.png)
+
+This worked and was quick, but is pretty boring and ugly.  In the past few
+months I've learned a lot more about terrain generation, so I fleshed things out
+a bit more for the new port:
+
+[![Screenshot of terrain in the new version](/media/images/blog/2016/08/silt2-terrain.png)](/media/images/blog/2016/08/silt2-terrain.png)
+
+Now I've got oceans and mountains for the creatures to explore.
+
+### Tiling Diamond Square
+
+My initial impulse was to use [Perlin Noise][] or [Simplex Noise][] to generate
+the heightmap for the world, but I ran into a problem.  I wanted the world to be
+a torus, just like in the original game, so I needed a terrain generation
+algorithm that would generate tileable/wrappable heightmaps.
+
+One way to do this is to use higher-dimensional noise to get 2D noise that
+tiles.  If you want to get a 2D heightmap that's tileable in one direction, you
+can use 3D noise and take a cylindrical slice of it.  To get a heightmap that
+tiles both ways you need to use 4D noise.  [This article][ron-noise] gives
+a really nice overview of the process.
+
+Unfortunately I couldn't find an implementation of 4D Simplex Noise in Common
+Lisp.  [black-tie][] and [noise][] both only offer up to 3D noise, and I don't
+feel confident enough to implement it myself, even after skimming the simplex
+noise paper.
+
+So I decided to try a different approach and figure out how to modify [Diamond
+Square][] to tile.  The [Wikipedia article for Diamond Square][ds-wiki] says:
+
+> Another option [for the diamond step] is to 'wrap around', taking the fourth
+> value from the other side of the array. When used with consistent initial
+> corner values this method also allows generated fractals to be stitched
+> together without discontinuities.
+
+This sounded great, but after thinking about it for a bit it's obviously not
+correct.  If we have a heightmap and do what the article says, it will seem to
+work at first:
+
+<pre class="lineart">
+                      ╔══════════════════╗
+    ┌─┬─┬─┬─┬─┐       ║   ┌─┬─┬─┬─┬─┐    ║
+    │5│ │ │ │5│       ║   │5│ │ │ │5│    ║
+    ├─┼─┼─┼─╱┬╲       ║   ├─┼─┼─┼─╱┬╲    ║
+    │ │ │ │╱│││╲      ║   │ │ │ │╱│││╲   ║
+    ├─┼─┼─╱─┼▼┤ ╲     ║   ├─┼─┼─╱─┼▼┤ ╲  ║
+    │ │ │3├─▶◉◀──?    ╚═══════│3├─▶◉◀════╝
+    ├─┼─┼─╲─┼▲┤ ╱         ├─┼─┼─╲─┼▲┤ ╱
+    │ │ │ │╲│││╱          │ │ │ │╲│││╱
+    ├─┼─┼─┼─╲┴╱           ├─┼─┼─┼─╲┴╱
+    │5│ │ │ │5│           │5│ │ │ │5│
+    └─┴─┴─┴─┴─┘           └─┴─┴─┴─┴─┘
+</pre>
+
+Wrapping like this will indeed make sure that the averages match up, but there's
+two problems.
+
+First: the corners are all the same value, which means that when you put four
+heightmaps next to each other there's an unnatural flat area of four identical
+height values next to each other.  This probably wouldn't be noticeable in
+practice, but if you want to do things *right* it won't be acceptable.
+
+But the *real* problem is the jitter.  If the jitter on one side of the map
+happens to be large and positive and the jitter on the other side happens to be
+large and negative, you'll get a jarring "cliff" when you try to tile them:
+
+[![Example of poorly-tiling diamond square](/media/images/blog/2016/08/bad-tiling-ds.png)](/media/images/blog/2016/08/bad-tiling-ds.png)
+
+The solution I came up with is to reduce the size of the heightmap by 1.
+Instead of the heightmap being \\(2^n + 1\\) in each dimension we can make it
+\\(2^n\\) and adjust the coordinate-wrapping function appropriately.
+Importantly, we *don't* change the calculation of the radius values as we
+iterate over the array, so this means quite often we'll be "reaching" for that
+final row/column:
+
+<pre class="lineart">
+     ?       ?
+    ┌─╲─┬─┬─╱
+    │ │╲│ │╱│
+    ├─┼─◢─◣─┤
+    │ │ │◉│ │
+    ├─┼─◥─◤─┤
+    │ │╱│ │╲│
+    ├─╱─┼─┼─╲
+    │5│ │ │ │?
+    └─┴─┴─┴─┘
+</pre>
+
+When we try to access that nonexistent coordinate we just wrap around back to
+zero.  Notice that we also only need to initialize a single corner cell now.
+
+It's a simple change, but the result is *much* nicer:
+
+[![Example of nicely-tiling diamond square](/media/images/blog/2016/08/good-tiling-ds.png)](/media/images/blog/2016/08/good-tiling-ds.png)
+
+[Perlin Noise]: https://en.wikipedia.org/wiki/Perlin_noise
+[Simplex Noise]: https://en.wikipedia.org/wiki/Simplex_noise
+[ron-noise]: http://ronvalstar.nl/creating-tileable-noise-maps
+[black-tie]: https://github.com/aerique/black-tie
+[noise]: https://github.com/sebity/noise
+[Diamond Square]: /blog/2016/06/diamond-square/
+[ds-wiki]: https://en.wikipedia.org/wiki/Diamond-square_algorithm
+
+## Entity, Aspects, and Systems
+
+Terrain generation is pretty, but the next step in the port was to add some
+plants, creatures, and artifacts.  In the original game I just represented
+things in the world as vanilla Clojure maps, but that was getting kind of messy
+and I wanted to try a different approach this time.
+
+Recently I read through [Game Engine Architecture][] (a *fantastic* book) and
+made a few games in [Unity][], which together made me want to try using an
+[Entity/Component System][] this time around.  There are a couple of ECS
+libraries out there for Common Lisp like [cl-ecs][] and [ecstasy][], but in true
+Lisp fashion I ended up not being quite satisfied with any of them and writing
+Yet Another God Damn Library.
+
+It's called [Beast][].  It's subtly different than the others in that it prefers
+to be a really thin layer over CLOS and uses inheritance instead of composition.
+It uses the word "aspect" instead of "component" to try to overload that word
+a bit less, so it's the "Basic Entity/Aspect/System Toolkit".  It ended up being
+about 150 lines of code (not including docstrings), so I managed to avoid going
+down too much of a rabbit hole during the jam.
+
+If you want to know all the details, check out its documentation (it has
+*actual* documentation).  But here I'll just talk about a couple of the
+particular bits of Silt that I used it for.
+
+[Unity]: https://unity3d.com/
+[Game Engine Architecture]: http://www.amazon.com/dp/1466560010/?tag=stelos-20
+[Entity/Component System]: https://en.wikipedia.org/wiki/Entity_component_system
+[cl-ecs]: https://github.com/lispgames/cl-ecs
+[ecstasy]: https://github.com/mfiano/ecstasy
+[beast]: http://sjl.bitbucket.org/beast/overview/
+
+### Coordinates
+
+The first thing I needed was a way to keep track of where things are in the
+world.
+
+If the world space were continuous a [quadtree][] would have been my first
+choice, but in Silt the world is split into discrete integer coordinates.
+Creatures move directly from \\((x, y)\\) to \\((x+1, y+1)\\).  I decided to use
+a simple array of lists to represent this:
+
+```text
+(defparameter *coords-contents*
+  (make-array (list +world-size+ +world-size+)
+              :initial-element nil))
+```
+
+Each value in the array is a list of the entities that are currently there.
+This means looking up what things are at a given coordinate is a single fast
+`aref`.
+
+I tried using a hash table instead of an array at first, thinking that if the
+world were fairly sparse it would be wasteful to allocate an array with a ton
+of `nil` values in it.  But the array method is much faster for looking things
+up (which happens a lot) and memory is cheap, so I decided against the hash
+tables.  It worked great in the end.
+
+Entities need to know where they are in the world, so I defined a Beast aspect
+for that:
+
+```text
+(define-aspect coords x y)
+```
+
+Then I defined a few functions to handle moving entities into, out of, and
+around the world:
+
+```text
+(defun coords-insert-entity (e)
+  (push e (aref *coords-contents* (coords/x e) (coords/y e))))
+
+(defun coords-remove-entity (e)
+  (zap% (aref *coords-contents* (coords/x e) (coords/y e))
+        #'delete e %))
+
+(defun coords-move-entity (e new-x new-y)
+  (coords-remove-entity e)
+  (setf (coords/x e) (wrap new-x)
+        (coords/y e) (wrap new-y))
+  (coords-insert-entity e))
+
+(defun coords-lookup (x y)
+  (aref *coords-contents* (wrap x) (wrap y)))
+```
+
+Entities might also like to know what's near them:
+
+```text
+(defun nearby (entity &optional (radius 1))
+  (remove entity
+          (iterate
+            outer
+            (with x = (coords/x entity))
+            (with y = (coords/y entity))
+            (for dx :from (- radius) :to radius)
+            (iterate
+              (for dy :from (- radius) :to radius)
+              (in outer
+                  (appending (coords-lookup (+ x dx)
+                                            (+ y dy))))))))
+```
+
+This ends up compiling down to a nice tight loop of \\((2 * radius + 1)^2\\)
+`aref`s.  I only wish iterate had a nicer syntax for looping over nested
+indices like this.  I'm sure it's possible to write an iterate driver for it --
+maybe someday I'll try making one.
+
+I also needed a way to get entities into the world array when they're created
+and remove them when they die.  Beast (well, actually CLOS) makes this trivially
+easy with auxiliary methods:
+
+```text
+(defmethod entity-created :after ((entity coords))
+  (coords-insert-entity entity))
+
+(defmethod entity-destroyed :after ((entity coords))
+  (coords-remove-entity entity))
+```
+
+[quadtree]: https://en.wikipedia.org/wiki/Quadtree
+
+### User Interface
+
+Once I had a way of know where things are, the next step was to display them on
+the screen.  I broke this into a few separate aspects.
+
+#### Visible
+
+The `visible` aspect is for things that are drawn on the screen with
+a particular glyph and color:
+
+```text
+(define-aspect visible glyph color)
+
+;; ...
+
+(define-entity tree (coords visible ...))
+
+(defun make-tree (x y)
+  (create-entity 'tree
+                 :coords/x x
+                 :coords/y y
+                 :visible/glyph "T"
+                 :visible/color +color-green-black+
+                 ;; ...
+                 ))
+
+```
+
+The drawing code can then figure out what to draw for each screen coordinate:
+
+```text
+(defun draw-map ()
+  (iterate
+    (for sx :from 0 :below *screen-width*)
+    (for wx :from *view-x*)
+    (iterate
+      (for sy :from 0 :below *screen-height*)
+      (for wy :from *view-y*)
+      (for entity = (find-if #'visible? (coords-lookup wx wy)))
+      (if entity
+        (with-color (visible/color entity)
+          (write-string-at (visible/glyph entity) sx sy))
+        ;;; otherwise draw the terrain
+        (...)))))
+```
+
+Again: my kingdom for a `(for-nested ...)` iterate driver!  But the core is just
+using `(find-if #'visible? (coords-lookup wx wy))` to find the first visible
+thing and then drawing it:
+
+[![Screenshot of entities with the visible aspect](/media/images/blog/2016/08/aspect-visible.png)](/media/images/blog/2016/08/aspect-visible.png)
+
+I used `find-if` instead of `remove-if-not` because we can only draw one
+character to a given position in the terminal anyway, so I just pick the first
+thing that happens to be in the list.
+
+#### Flavor
+
+The `flavor` aspect is for adding [flavor text][] that appears when the user
+puts their cursor over an entity:
+
+```text
+(define-aspect flavor text)
+
+;; ...
+
+(define-entity tree (coords visible flavor ...))
+
+(defun make-tree (x y)
+  (create-entity 'tree
+                 :coords/x x
+                 :coords/y y
+                 :visible/glyph "T"
+                 :visible/color +color-green-black+
+                 :flavor/text
+                 '("A tree sways gently in the wind.")))
+```
+
+Then when the user's cursor is at a certain position I can find all the entities
+there and draw the flavor text for any that have the `flavor` aspect:
+
+```text
+(defun draw-selected ()
+  (write-left
+    (iterate
+      (for entity :in (multiple-value-call #'coords-lookup
+                        (screen-to-world *cursor-x* *cursor-y*)))
+      (when (typep entity 'flavor)
+        (appending (flavor/text entity) :into text)
+
+        ;; ...
+
+        (collecting "" :into text))
+      (finally (return text)))
+    1 1 :pad t))
+```
+
+Which looks like this:
+
+[![Screenshot of flavor text](/media/images/blog/2016/08/aspect-flavor.png)](/media/images/blog/2016/08/aspect-flavor.png)
+
+Of course the flavor text doesn't have to be a constant:
+
+```text
+(defun make-creature (x y &key
+                      (color +color-white-black+)
+                      (glyph "@"))
+  (let ((name (random-name)))
+    (create-entity 'creature
+      :name name
+      :coords/x x
+      :coords/y y
+      :visible/color color
+      :visible/glyph glyph
+      :flavor/text
+      (list (format nil "A creature named ~A is here." name)
+            "It likes food."))))
+```
+
+[flavor text]: https://en.wikipedia.org/wiki/Flavor_text
+
+#### Inspectable
+
+The last thing I wanted was an easy way to show attributes of entities in the
+main game UI.  The original Clojure game just dumped the entire object to the
+screen:
+
+[![Screenshot of creature inspection in the original game](/media/images/blog/2016/08/silt1-inspect.png)](/media/images/blog/2016/08/silt1-inspect.png)
+
+But this time I wanted a bit more control.  The `inspectable` aspect has a list
+of things that should be displayed.  These can be symbols (which denote CLOS
+slot names) or functions that return `(label . text)` conses:
+
+```text
+(define-aspect inspectable
+  (slots :initform nil))
+
+(defun inspectable-get (entity slot)
+  (etypecase slot
+    (symbol (cons slot (slot-value entity slot)))
+    (function (funcall slot entity))))
+```
+
+When creating an entity I can just list out the slots I want to be displayed on
+the screen, or use a little `lambda` if I want to show something that's not an
+actual slot:
+
+```text
+(defun make-fruit (x y)
+  (create-entity 'fruit
+    ;; ...
+    :inspectable/slots '(edible/energy)))
+
+(defun make-creature (x y &key ...)
+  (let ((name (random-name)))
+    (create-entity 'creature
+      ;; ...
+      :inspectable/slots
+      (list 'name
+            (lambda (c) (cons 'directions ...))
+            'metabolizing/energy
+            'metabolizing/insulation
+            'aging/birthtick
+            'aging/age))))
+```
+
+Then I just append some extra text for `inspectable` entities when drawing
+descriptions of things at the cursor position:
+
+```text
+(defun draw-selected ()
+  (write-left
+    (iterate
+      (for entity :in (multiple-value-call #'coords-lookup
+                        (screen-to-world *cursor-x* *cursor-y*)))
+      (when (typep entity 'flavor)
+        ;; ...
+        (when (typep entity 'inspectable)
+          (appending
+            (indent
+              (iterate
+                (with slots = (mapcar (curry #'inspectable-get entity)
+                                      (inspectable/slots entity)))
+                (with width = (apply #'max
+                                     (mapcar (compose #'length #'symbol-name #'car)
+                                             slots)))
+                (for (label . contents) :in slots)
+                (collect
+                  (let ((*print-pretty* nil))
+                    (format nil "~vA ~A" width label contents)))))
+            :into text))
+
+        (collecting "" :into text))
+      (finally (return text)))
+    1 1 :pad t))
+```
+
+This is pretty ugly because I wanted to justify and indent things nicely, but
+the result looks much nicer than the original game:
+
+[![Screenshot of creature inspection in the new version](/media/images/blog/2016/08/silt2-inspect.png)](/media/images/blog/2016/08/silt2-inspect.png)
+
+### Food
+
+Seeing the world is nice, but we also want the things in it to actually *do*
+something.  The world revolves heavily around food and energy, so I defined
+a few aspects to handle things:
+
+```text
+(define-aspect edible
+  energy
+  original-energy)
+
+(define-aspect decomposing
+  rate
+  (remaining :initform 1.0))
+
+(define-aspect fruiting
+  chance)
+
+(defmethod initialize-instance :after ((e edible) &key)
+  (setf (edible/original-energy e)
+        (edible/energy e)))
+```
+
+I do wish there was a slightly less wordy way to default the value of one slot
+to another one, but oh well.
+
+Then I just added the aspects to the appropriate entities:
+
+```text
+(define-entity tree (coords visible fruiting flavor))
+(define-entity fruit (coords visible edible flavor decomposing inspectable))
+(define-entity algae (coords visible edible decomposing))
+(define-entity grass (coords visible edible decomposing))
+(define-entity corpse (coords visible flavor decomposing))
+```
+
+Trees can grow fruit, so they have the `fruiting` aspect.  The `grow-fruit`
+Beast system handles growing some each tick:
+
+```text
+(define-system grow-fruit ((entity fruiting coords))
+  (when (randomp (fruiting/chance entity))
+    (make-fruit (wrap (random-around (coords/x entity) 2))
+                (wrap (random-around (coords/y entity) 2)))))
+```
+
+Fruit is `edible`, but also decomposes over time.  It's got `flavor` and
+`inspectable` aspects so you can see how much energy is left.
+
+I added algae and grass as secondary food sources to spread out the food supply
+a bit more and make the creatures a bit less dependent on the trees.  I didn't
+give these flavor text to avoid cluttering up the UI too much.
+
+I considered making corpses edible too, but figured that might be a bit too
+gruesome.  So corpses decompose, but the critters aren't cannibals.
+
+I made a couple of Beast systems to handle the process of decomposing things
+every game tick:
+
+```text
+(define-system rot ((entity decomposing))
+  (when (minusp (decf (decomposing/remaining entity)
+                      (decomposing/rate entity)))
+    (destroy-entity entity)))
+
+(define-system rot-food ((entity decomposing edible))
+  (setf (edible/energy entity)
+        (lerp 0.0 (edible/original-energy entity)
+              (decomposing/remaining entity))))
+```
+
+`rot` runs on everything with the `decomposing` aspect.  It ticks along the
+progress of an entity's decomposition, and destroys it once it's finished.
+
+`rot-food` runs on every entity that's both `decomposing` *and* `edible`.  It
+reduces the energy value of the food over time, because rotten food is less
+healthy.  I'm pretty happy with how easy Beast makes this kind of thing.
+
+### Creatures and Mysteries
+
+The final pieces of the world are the creatures and artifacts.
+
+#### Energy
+Creatures need food (energy) to survive.  I modeled this with a `metabolizing`
+aspect and `consume-energy` system:
+
+```text
+(define-aspect metabolizing insulation energy)
+
+(defmethod starve ((entity entity))
+  (destroy-entity entity))
+
+(defmethod calculate-energy-cost ((entity metabolizing))
+  (let* ((insulation (metabolizing/insulation entity))
+         (base-cost 1.0)
+         (temperature-cost (max 0 (* 0.2 (- (abs *temperature*) insulation))))
+         (insulation-cost (* 0.1 insulation)))
+    (+ base-cost temperature-cost insulation-cost)))
+
+(define-system consume-energy ((entity metabolizing))
+  (when (minusp (decf (metabolizing/energy entity)
+                      (calculate-energy-cost entity)))
+    (starve entity)))
+```
+
+I made `starve` and `calculate-energy-cost` generic functions because I thought
+I might eventually have different metabolizing things in the world and might
+want to override them.  I didn't end up doing this in the end (creatures are the
+only things that burn energy) so these could have been normal functions.
+
+The energy mechanic works similarly to the original game:
+
+* Creatures spend a bit of energy each tick to stay alive.
+* When you make the temperature hotter or colder, it costs additional energy per
+  tick for the creatures to live.
+* Creatures sometimes gain/lose insulation during reproduction, which mitigates
+  the energy cost of the temperature difference.
+* Insulation itself costs a little bit of energy every tick.
+
+The effect is that if you change the temperature gradually over time, the
+population will evolve higher insulation values (because the children with more
+insulation are more likely to survive longer).  If you then set the temperature
+back to zero (the ideal) the population will eventually evolve to shed the
+insulation, because it costs a little bit of energy and doesn't provide any
+benefit when the world is pleasant.  Natural selection is fun.
+
+The last piece of the puzzle is letting things actually take action.  Creatures
+and some artifacts need to take an action on every tick, while other artifacts
+only do things occasionally.  A pair of aspects and systems handles the
+bookkeeping here:
+
+```text
+(define-aspect sentient function)
+(define-aspect periodic
+  function
+  (counter :initform 1)
+  next
+  min
+  max)
+
+(define-system sentient-act ((entity sentient))
+  (funcall (sentient/function entity) entity))
+
+(define-system periodic-tick ((entity periodic))
+  (when (zerop (setf (periodic/counter entity)
+                     (mod (1+ (periodic/counter entity))
+                          (periodic/next entity))))
+    (setf (periodic/next entity)
+          (random-range (periodic/min entity)
+                        (periodic/max entity)))
+    (funcall (periodic/function entity) entity)))
+```
+
+I'm not going to go over all the actual AI and actions, you can take a look at
+the code if you're curious.
+
+## Random Name Generation
+
+I wanted to add a more personal connection to the creatures this time around, so
+I decided they should have names.  I used a really simple form of
+[syllable-based name generation][namegen] to give each creature its own random
+name:
+
+```text
+(defparameter *name-syllables*
+  (-> "syllables.txt"
+    slurp
+    read-from-string
+    (coerce 'vector)))
+
+(defun random-name ()
+  (format nil "~:(~{~A~}~)"
+          (iterate (repeat (random-range 1 5))
+                   (collect (random-elt *name-syllables*)))))
+```
+
+To get a random name I just smash together one to four random syllables.  To
+make a list of syllables I grabbed some Icelandic text and made a pair of really
+janky shell and Python scripts to print out every 3/4/5-letter chunk of every
+word, sort them by frequency, and take the top 500.
+
+They're not *really* syllables but they're okay for just a couple of lines of
+code and a few minutes work:
+
+[![Screenshot of creature names](/media/images/blog/2016/08/silt-names.png)](/media/images/blog/2016/08/silt-names.png)
+
+[namegen]: http://www.roguebasin.com/index.php?title=Syllable-based_name_generation
+
+## Simple Data Structures
+
+As I coded things up I wound up with a handy pair of data structures I might use
+again for other things in the future.
+
+### Weightlists
+
+Each game tick a creature needs to decide which direction to walk.  At the start
+of the game they just pick a random direction, but as they reproduce their
+children can mutate to prefer certain directions over others.
+
+The natural selection of Silt turns out to prefer creatures that wander around
+to those that stay in place.  Fruit takes time to grow, so it's more effective
+to travel around and gather it than to sit in place waiting for it to regrow.
+
+The original game just used a Clojure vector of weights and directions to
+represent how much a creature prefers each direction.  That worked, but the
+weights are only ever set/changed when a creature is born, and a random element
+is chosen every turn.  It's more efficient in the long run if we precompute
+a few things up front, so I made a little "weightlist" API:
+
+```text
+(defstruct (weightlist (:constructor %make-weightlist))
+  weights sums items total)
+
+(defun make-weightlist (items weights)
+  "Make a weightlist of the given items and weights."
+  (%make-weightlist
+    :items items
+    :weights weights
+    :sums (prefix-sums weights)
+    :total (apply #'+ weights)))
+
+(defun weightlist-random (weightlist)
+  "Return a random item from the weightlist, taking the weights into account."
+  (iterate
+    (with n = (random (weightlist-total weightlist)))
+    (for item :in (weightlist-items weightlist))
+    (for weight :in (weightlist-sums weightlist))
+    (finding item :such-that (< n weight))))
+```
+
+This is pretty straightforward.  Note that the weights can be integers or floats
+(or some of each!) and things will Just Work, because Common Lisp's `random` can
+take either.  Weights of zero are fine too, as long as at least one element has
+a nonzero weight.
+
+### Ticklists
+
+In a couple of places I needed some kind of list where items in it expire over
+time.  For example:
+
+* The Fountain artifact only lets creatures drink from it once every thousand
+  ticks, so I needed a way to keep track of the entities that had drank
+  recently.
+* The game log at the bottom of the screen contains messages that should be
+  shown for a certain number of ticks, then disappear.
+
+I made a simple little thing I called a "ticklist" to handle these:
+
+```text
+(defun make-ticklist ()
+  nil)
+
+(defmacro ticklist-push (ticklist value lifespan)
+  `(push (cons ,lifespan ,value) ,ticklist))
+
+(defun ticklist-tick (ticklist)
+  (flet ((decrement (entry)
+           (decf (car entry)))
+         (dead (entry)
+           (minusp (car entry))))
+    (->> ticklist
+      (mapc #'decrement)
+      (remove-if #'dead))))
+
+(defun ticklist-contents (ticklist)
+  (mapcar #'cdr ticklist))
+```
+
+Internally a ticklist is just a list of `(remaining-ticks . thing)` conses, but
+the rest of my code doesn't have to care about that:
+
+```text
+(defun fountain-act (f)
+  (with-slots (recent) f
+    (zapf recent #'ticklist-tick)
+    (iterate
+      (with already-drank = (ticklist-contents recent))
+      (for creature :in (remove-if-not #'creature? (nearby f)))
+      (unless (member creature already-drank)
+        (creature-mutate-appearance creature)
+        (ticklist-push recent creature 1000)
+        (log-message "~A drinks from the fountain and... changes."
+                     (creature-name creature))))))
+
+(defun log-message (s &rest args)
+  (ticklist-push *game-log* (apply #'format nil s args) 200))
+
+(defun state-map-loop ()
+  ;; ...
+  (unless *paused*
+    (iterate (repeat *frame-skip*)
+             (tick-world)
+             (zapf *game-log* #'ticklist-tick))))
+```
+
+## Profiling and Performance
+
+When something starts slowing things down it's helpful to be able to turn on
+profiling and see what's going on.  SBCL has a nice statistical profiler, so
+I made a couple of functions to flip it on and off as needed:
+
+```text
+#+sbcl
+(defun dump-profile ()
+  (with-open-file (*standard-output* "silt.prof"
+                                     :direction :output
+                                     :if-exists :supersede)
+    (sb-sprof:report :type :graph
+                     :sort-by :cumulative-samples
+                     :sort-order :ascending)
+    (sb-sprof:report :type :flat
+                     :min-percent 0.5)))
+
+#+sbcl
+(defun start-profiling ()
+  (sb-sprof::reset)
+  (sb-sprof::profile-call-counts "SILT")
+  (sb-sprof::start-profiling :max-samples 50000
+                             ; :mode :cpu
+                             :mode :time
+                             :sample-interval 0.01
+                             :threads :all))
+
+#+sbcl
+(defun stop-profiling ()
+  (sb-sprof::stop-profiling)
+  (dump-profile))
+```
+
+When I wanted to check performance I could just evaluate `(start-profiling)`
+over NREPL and let the game continue to run, then `(stop-profiling)` a little
+bit later and look at the results.  It came in handy once or twice when tracking
+down some slowness.
+
+## Future Improvements and Ideas
+
+This game jam was quite a bit of fun!  I'm happy with the results and feel like
+I've learned a lot along the way.
+
+I'm done with the game and don't plan on updating it any more, but I'll scribble
+down a few extra ideas for things that could be improved here, just to get them
+out of my head:
+
+* Figure out the Unicode issues with cl-charms and CCL.
+* Contribute to cl-charms to add some higher-level tools for working with color.
+* Contribute to one of the Common Lisp noise libraries to implement the 4D
+  variant of Simplex Noise.
+* Flesh out the name generation into something much nicer and more polished.
+* Implement different costs for moving over different terrain.
+* Add health, fighting, and carnivores.
+* Add more mysterious artifacts to the world.
+* Flesh out the vegetation model to let trees grow and die, algae spread, etc.
+* Improve the visuals. [Brogue][] proves you can do far more than you might
+  think with just Unicode characters.
+* Model senses like vision, providing the creatures with more information but
+  with an energy cost.
+* Give creatures "brains" by generating and mutating actual Lisp code.  This
+  would let the creatures learn strategies over time, though I'm not sure how
+  feasible it would be.
+* Improve performance by profiling much more and fixing the hottest parts of the
+  code.
+* Add saving and loading of the world.
+* Add the ability to seed the RNG and make everything deterministic, so people
+  can share interesting seeds.  Doing this for the terrain generation at least
+  should be pretty easy, the game as a whole might be slightly trickier.
+* Improve the UI a bit more, maybe using ncurses' support for windows layered on
+  top of other windows.
+
+[Brogue]: https://sites.google.com/site/broguegame/
+
--- a/content/blog/2016/08/playing-with-syntax.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,493 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Playing With Syntax"
-        snip: "Lisp lets you evolve your language."
-        created: 2016-08-19 13:15:00
-    %}
-
-    {% block article %}
-
-One of the things I love about Lisp is that it gives you the ability to change
-and mold the syntax of the language to what you need.  In this post I want to
-look at the evolution of a little macro I've been playing around with for
-a while now.
-
-Mutation is a fundamental concept in most programming languages.  Functional
-programming may be beautiful, but mutation is still useful (and fast).  In most
-languages assignment is done with an `=` or `:=` operator:
-
-    :::lisp
-    x = 10
-
-In Common Lisp the operator is named `setf` instead of `=` for historical
-reasons, and of course it's used in prefix notation:
-
-    :::lisp
-    (setf x 10)
-
-Aside from the prefix ordering, Common Lisp's syntax is already a bit more
-elegant because you can set arbitrarily many variables without repeating the
-assignment operator over and over again:
-
-    :::lisp
-    ; Have to type out `=` three times
-    x = 10
-    y = 20
-    z = 30
-
-    ; But only one `setf` required
-    (setf x 10
-          y 20
-          z 30)
-
-`setf` assigns values one-by-one, in-order.  Common Lisp also has `psetf` which
-is "parallel `setf`".  This evaluates all the values first, *then* sets all the
-variables at once:
-
-    :::lisp
-    (let ((a 10) (b 20))
-      (setf a 50
-            b (+ 1 a))   ; => (50 51)
-
-      (psetf a 90
-             b (+ 1 a))) ; => (90 52)
-
-Assignment is nice, but often you want to change the value of a variable by
-taking its *current* value and computing something with it.  If you're making
-a ball that travels across the screen you might have something like this:
-
-    :::text
-    def move_ball(ball, distance):
-        ball.x = ball.x + distance
-
-    (defun move-ball (ball distance)
-      (setf (slot-value ball 'x)
-            (+ (slot-value ball 'x)
-                distance)))
-
-If you find `slot-value` too wordy to type, you could make a macro to get rid of
-it (and save yourself a quote too).  `.` is already used for something else so
-you'd need to pick a different character:
-
-    :::lisp
-    (defmacro $ (instance slot-symbol)
-      `(slot-value ,instance ',slot-symbol))
-
-    (defun move-ball (ball distance)
-      (setf ($ ball x)
-            (+ ($ ball x)
-                distance)))
-
-In practice, though, you rarely use `slot-value`.  Instead you usually use
-accessor functions:
-
-    :::lisp
-    (defun move-ball (ball distance)
-      (setf (ball-x ball)
-            (+ (ball-x ball)
-                distance)))
-
-Anyway, back to assignment.  What we wrote above *works*, but it's a bit
-annoying to have to type the "place" that we're working with twice.  To cut down
-on this repetition many languages offer operators like `+=` and `++`:
-
-    :::text
-    x = x + 10
-    ⬇
-    x += 10
-
-    y = y + 1
-    ⬇
-    y++
-
-Common Lisp's version of these is called `incf`.
-
-    :::lisp
-    (incf x 10)
-    (incf y)
-
-Notice how the s-expression syntax means we can use the same operator for both
-of the forms, instead of needing separate `+=` and `++` operators.
-
-Other languages often have similar "in-place" operators for other numeric
-operations like `-=`, `--`, `*=`, and so on.  Common Lisp has `decf` for
-subtraction, but doesn't have versions for multiplication or division built in.
-But we can add them with a few macros:
-
-    :::lisp
-    (defmacro mulf (place factor)
-      `(setf ,place (* ,place ,factor)))
-
-    (defmacro divf (place divisor)
-      `(setf ,place (/ ,place ,divisor)))
-
-Unfortunately these are not quite right -- we've committed the cardinal
-macro-writing sin of splicing in the `place` expression multiple times.  If
-`place` has side effects they'll happen more times than expected.
-
-Luckily, Common Lisp has a macro that wraps up the boring process of handling
-this for us.  `define-modify-macro` lets us fix the problem:
-
-    :::lisp
-    (define-modify-macro mulf (factor) *)
-    (define-modify-macro divf (divisor) /)
-
-Now we've got versions of `*=` and `/=` in Common Lisp.  While we're here we
-should do things *right* and allow `divf` to be used with just a place, which
-will mean "set `place` to `1/place`":
-
-    :::lisp
-    (define-modify-macro divf (&optional divisor)
-      (lambda (value divisor)
-        (if (null divisor)
-          (/ 1 value)
-          (/ value divisor))))
-
-    (let ((x 10))
-      (divf x 2) ; => 5
-      (divf x)   ; => 1/5
-      (divf x))  ; => 5
-
-Note that we don't really need the `1` in `(/ 1 value)`, because Common Lisp's
-`/` works the same way when you call it with a single argument.  I'm not sure
-what behavior would make sense for a unary `(mulf place)`, so let's ignore that
-one and move on.
-
-So far we've been talking about the idea of setting a variable to the result of
-computing some function on its current value.  We used `define-modify-macro` to
-define some support for extra functions, but defining a mutator macro for every
-function we might possibly want to use could get tedious.  What if we generalize
-this a bit more?
-
-    :::lisp
-    (define-modify-macro callf (function)
-      (lambda (value function)
-        (funcall function value)))
-
-    (let ((x -1))
-      (callf x #'abs)   ; => 1
-      (callf x #'1+)    ; => 2
-      (callf x #'sin)   ; => 0.9092974
-      (callf x #'round) ; => 1
-      (callf x #'-))    ; => -1
-
-Now we've got something a bit higher-level.  With `callf` we can mutate
-a variable with a unary function.  But what about functions that need more
-arguments?  Again, Common Lisp does the right thing and handles `&rest`
-parameters correctly in `define-modify-macro`:
-
-    :::lisp
-    (define-modify-macro callf (function &rest args)
-      (lambda (value function &rest args)
-        (apply function value args)))
-
-    (let ((x -1))
-      (callf x #'abs)    ; => 1
-      (callf x #'+ 10)   ; => 11
-      (callf x #'* 2 4)) ; => 88
-
-    (let ((foo (list 0 1 2 3)))
-      (callf foo #'reverse)
-      ; => (3 2 1 0)
-
-      (callf foo #'append (list -1 -2 -3)))
-      ; => (3 2 1 0 -1 -2 -3)
-
-That's better.  Now we can mutate a variable by applying a function to its
-current value and some other arguments.  This might come in handy when we don't
-want to bother defining a full-blown modification macro just to use it once or
-twice.
-
-At this point we've got something similar to Michael Malis' [zap][] macro.
-A minor difference is for `zap` the order of the function and the place are
-reversed.  I believe his reason was that it makes the resulting form look more
-like the function call that is conceptually being made:
-
-    :::lisp
-    (zap     #'+  x  5)
-    ;          ↓  ↓  ↓
-    (setf x (  +  x  5  ))
-
-Unfortunately, because the place is no longer the first argument we can't use
-`define-modify-macro` to handle the single-evaluation boilerplate for us any
-more.  Instead we need to use `get-setf-expander` and work with its results.
-Malis' excellent [Getting Places][] article explains how that works, and if you
-want to fully understand the rest of the code in this post you should read that
-one first.
-
-The difference between `callf` and Malis' `zap` are just cosmetic.  But they're
-still not completely flexible.  What if we want to call a function, but we need
-the value to be an argument other than the first?  Of course we could use
-a `lambda`:
-
-    :::lisp
-    (let ((x (list :coffee :soda :tea)))
-      (callf x (lambda (l) (remove :soda l))))
-
-
-But that is *really* ugly.  It would be nice if we had a way to specify which
-argument to the function should be the current value.  This is Lisp, so we can
-pick whatever syntax we want.  What should we choose?  Often a good first step
-is to look at how other languages do things.  Clojure's anonymous function
-syntax is one possibility:
-
-    :::lisp
-    (map #(+ 10 %) [1 2 3])
-    ; => (11 12 13)
-
-Clojure uses the magic symbol `%` as a placeholder for the argument.  We can
-modify Malis' `zap` macro to do the same.  We'll call it `zapf`, and we'll swap
-the place back into the first argument like all the other modify macros, since
-the aesthetic reason no longer holds.  The changes are in bold:
-
-<div class="codehilite"><pre>
-; Original version
-(defmacro zap (fn place &rest args)
-  (multiple-value-bind
-        (temps exprs stores store-expr access-expr)
-      (get-setf-expansion place)
-    `(let* (,@(mapcar #'list temps exprs)
-            (,(car stores)
-              (funcall ,fn ,access-expr ,@args)))
-       ,store-expr)))
-
-; New version
-(defmacro <b>zapf</b> (<b>place fn</b> &rest args)
-  (multiple-value-bind
-        (temps exprs stores store-expr access-expr)
-      (get-setf-expansion place)
-    `(let* (,@(mapcar #'list temps exprs)
-            (,(car stores)
-             (funcall ,fn <b>,@(substitute access-expr '% args)</b>)))
-      ,store-expr)))
-</pre></div>
-
-And now we can use `%` to say where the place's value should go:
-
-    :::lisp
-    (let ((x (list :coffee :soda :tea)))
-      (zapf x #'remove :soda %)
-      ; => (:coffee :tea)
-
-      (zapf x #'cons :water %)
-      ; => (:water :coffee :tea)
-
-      (zapf x #'append % (list :cocoa :chai)))
-      ; => (:water :coffee :tea :cocoa :chai)
-
-Note that `substitute` will replace *all* occurrences of `%` with the access
-expression, so we can do something like `(zapf x #'append % %)` if we want.
-
-Some people will find this new version unpleasant, because it effectively
-captures the `%` variable.  It's not hygienic, by design.  I personally don't
-mind it, and I like the brevity it allows.
-
-We're almost done, but I want to push things just a *bit* further.  Let's
-revisit the original example of the ball moving across the screen:
-
-    :::text
-    def move_ball(ball, distance):
-        ball.x = ball.x + distance
-
-    (defun move-ball (ball distance)
-      (setf (ball-x ball)
-            (+ (ball-x ball) distance)))
-
-Of course we can simply use `+=` or `incf` here:
-
-    :::text
-    def move_ball(ball, distance):
-        ball.x += distance
-
-    (defun move-ball (ball distance)
-      (incf (ball-x ball) distance))
-
-Suppose we also wanted to make the ball wrap around the screen when it flies off
-one side.  We can do this using modulus:
-
-    :::text
-    def move_ball(ball, distance, screen_width):
-        ball.x += distance
-        ball.x %= screen_width
-
-    (defun move-ball (ball distance screen-width)
-      (incf (ball-x ball) distance)
-      (callf (ball-x ball) #'mod % screen-width))
-
-We could define `modf` if we wanted to make that second call a bit nicer.  But
-let's take a moment to reflect.  Notice how we're back to having to type out
-`(ball-x ball)` twice again.  It's better than typing it four times, but can we
-do better?
-
-`zapf` currently takes a place, a function, and a list of arguments.  What if we
-made it more like `setf`, and just have it take a place and an expression?  We
-could still use `%` as a placeholder, but could let it appear anywhere in the
-(possibly nested) expression form.
-
-One way to do this would be to simply replace `substitute` with `subst` in the
-`zapf` code.  (The difference between these extremely-confusingly-named
-functions is that `substitute` replaces element of a sequence, and `subst`
-replaces elements of a tree.)
-
-This, however, is the wrong strategy.  Blindly replacing `%` everywhere in the
-expression will work for many cases, but will break in edge cases like (god help
-you) nested `zapf` forms.  We could try to walk the code of the expression we
-get, but down this path lies madness and implementation-specificity.
-
-The solution is much, much simpler.  We can just use a normal `let` to capture
-`%` in the expression:
-
-<div class="codehilite"><pre>
-; Final version
-(defmacro <b>zapf</b> (<b>place expr</b>)
-  (multiple-value-bind
-        (temps exprs stores store-expr access-expr)
-      (get-setf-expansion place)
-    `(let* (,@(mapcar #'list temps exprs)
-            (,(car stores)
-             <b>(let ((% ,access-expr))
-               ,expr)</b>))
-      ,store-expr)))
-</pre></div>
-
-And now `move-ball` only requires the bare minimum of typing:
-
-    :::lisp
-    (defun move-ball (ball distance screen-width)
-      (zapf (ball-x ball)
-            (mod (+ distance %) screen-width)))
-
-For completeness it would be nice to allow `zapf` to take any number of
-place/value pairs, just like `setf`.  I'll leave this as an exercise for you to
-try if you're interested.
-
-It took me a while to arrive at this form of the macro.  I personally find it
-lovely and readable.  If you disagree, that's fine too!  Lisp is a wonderful
-substrate for building a language that fits how you think and talk about
-problems.  Play around with your own syntax and find out what feels most natural
-for you.
-
-Before we leave, let's just ponder one more thing.  Performance is often ignored
-these days, but what if we care about making the computer go fast?  The final
-`zapf` macro is handy and expressive, but what cost have we paid for this
-abstraction?
-
-First let's tell SBCL that we want to go fast and return to our original `setf`
-strategy:
-
-    :::lisp
-    (deftype nonnegative-fixnum ()
-      `(integer 0 ,most-positive-fixnum))
-
-    (deftype positive-fixnum ()
-      `(integer 1 ,most-positive-fixnum))
-
-    (defstruct ball
-      (x 0 :type nonnegative-fixnum)
-      (y 0 :type nonnegative-fixnum))
-
-    (declaim (ftype (function (ball fixnum positive-fixnum))
-                    move-ball))
-
-    (defun move-ball (ball distance screen-width)
-      (declare (optimize (speed 3) (safety 0) (debug 0)))
-      (setf (ball-x ball)
-            (mod (+ distance (ball-x ball))
-                 screen-width)))
-
-How does that turn out?
-
-    :::text
-    ; disassembly for MOVE-BALL
-    ; Size: 82 bytes. Origin: #x1005E5E12E
-    ; 2E:       488B410D         MOV RAX, [RCX+13]       ; no-arg-parsing entry point
-    ; 32:       48D1F8           SAR RAX, 1
-    ; 35:       498D3C00         LEA RDI, [R8+RAX]
-    ; 39:       488BDE           MOV RBX, RSI
-    ; 3C:       48D1FB           SAR RBX, 1
-    ; 3F:       4885DB           TEST RBX, RBX
-    ; 42:       7431             JEQ L3
-    ; 44:       488BC7           MOV RAX, RDI
-    ; 47:       4899             CQO
-    ; 49:       48F7FB           IDIV RAX, RBX
-    ; 4C:       4C8BC0           MOV R8, RAX
-    ; 4F:       488BC2           MOV RAX, RDX
-    ; 52:       48D1E0           SHL RAX, 1
-    ; 55:       4885C0           TEST RAX, RAX
-    ; 58:       7510             JNE L2
-    ; 5A: L0:   488BD8           MOV RBX, RAX
-    ; 5D: L1:   4889590D         MOV [RCX+13], RBX
-    ; 61:       488BD3           MOV RDX, RBX
-    ; 64:       488BE5           MOV RSP, RBP
-    ; 67:       F8               CLC
-    ; 68:       5D               POP RBP
-    ; 69:       C3               RET
-    ; 6A: L2:   4885FF           TEST RDI, RDI
-    ; 6D:       7DEB             JNL L0
-    ; 6F:       488D1C30         LEA RBX, [RAX+RSI]
-    ; 73:       EBE8             JMP L1
-    ; 75: L3:   0F0B0A           BREAK 10                ; error trap
-    ; 78:       07               BYTE #X07
-    ; 79:       08               BYTE #X08               ; DIVISION-BY-ZERO-ERROR
-    ; 7A:       FE9E03           BYTE #XFE, #X9E, #X03   ; RDI
-    ; 7D:       FE9E01           BYTE #XFE, #X9E, #X01   ; RBX
-
-Well that's not *too* bad.  I'm not sure why SBCL still performs a check for
-division by zero for the `mod` even though we said that `screen-width` can't
-possibly be zero.  But hey, we're at a manageable amount of assembly, which is
-pretty nice for a high-level language!
-
-Now for the `zapf` version:
-
-    :::lisp
-    (defun move-ball (ball distance screen-width)
-      (declare (optimize (speed 3) (safety 0) (debug 0)))
-      (zapf (ball-x ball)
-            (mod (+ distance %) screen-width)))
-
-Okay, let's bite the bullet.  How bad are we talking?
-
-    :::text
-    ; disassembly for MOVE-BALL
-    ; Size: 70 bytes. Origin: #x1005F47C7B
-    ; 7B:       488B410D         MOV RAX, [RCX+13]       ; no-arg-parsing entry point
-    ; 7F:       48D1F8           SAR RAX, 1
-    ; 82:       488D3C03         LEA RDI, [RBX+RAX]
-    ; 86:       4885F6           TEST RSI, RSI
-    ; 89:       742B             JEQ L2
-    ; 8B:       488BC7           MOV RAX, RDI
-    ; 8E:       4899             CQO
-    ; 90:       48F7FE           IDIV RAX, RSI
-    ; 93:       488BD8           MOV RBX, RAX
-    ; 96:       488D0412         LEA RAX, [RDX+RDX]
-    ; 9A:       4885C0           TEST RAX, RAX
-    ; 9D:       750D             JNE L1
-    ; 9F: L0:   48D1E2           SHL RDX, 1
-    ; A2:       4889510D         MOV [RCX+13], RDX
-    ; A6:       488BE5           MOV RSP, RBP
-    ; A9:       F8               CLC
-    ; AA:       5D               POP RBP
-    ; AB:       C3               RET
-    ; AC: L1:   4885FF           TEST RDI, RDI
-    ; AF:       7DEE             JNL L0
-    ; B1:       4801F2           ADD RDX, RSI
-    ; B4:       EBE9             JMP L0
-    ; B6: L2:   0F0B0A           BREAK 10                ; error trap
-    ; B9:       07               BYTE #X07
-    ; BA:       08               BYTE #X08               ; DIVISION-BY-ZERO-ERROR
-    ; BB:       FE9E03           BYTE #XFE, #X9E, #X03   ; RDI
-    ; BE:       FE1E03           BYTE #XFE, #X1E, #X03   ; RSI
-
-Wait, it's actually *shorter*?  What about all those extra variables the `zapf`
-macro expands into?  It turns out that SBCL is really quite good at optimizing
-`let` statements and local variables.
-
-This is why I love Common Lisp.  You can be rewriting the syntax of the language
-and working on a tower of abstraction one moment, and looking at X86 assembly to
-see what the hell the computer is actually *doing* the next.  It's wonderful.
-
-[Getting Places]: http://malisper.me/2015/09/22/getting-places/
-[Zap]: http://malisper.me/2015/09/29/zap/
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2016/08/playing-with-syntax.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,514 @@
++++
+title = "Playing With Syntax"
+snip = "Lisp lets you evolve your language."
+date = 2016-08-19T13:15:00Z
+draft = false
+
++++
+
+One of the things I love about Lisp is that it gives you the ability to change
+and mold the syntax of the language to what you need.  In this post I want to
+look at the evolution of a little macro I've been playing around with for
+a while now.
+
+Mutation is a fundamental concept in most programming languages.  Functional
+programming may be beautiful, but mutation is still useful (and fast).  In most
+languages assignment is done with an `=` or `:=` operator:
+
+```lisp
+x = 10
+```
+
+In Common Lisp the operator is named `setf` instead of `=` for historical
+reasons, and of course it's used in prefix notation:
+
+```lisp
+(setf x 10)
+```
+
+Aside from the prefix ordering, Common Lisp's syntax is already a bit more
+elegant because you can set arbitrarily many variables without repeating the
+assignment operator over and over again:
+
+```lisp
+; Have to type out `=` three times
+x = 10
+y = 20
+z = 30
+
+; But only one `setf` required
+(setf x 10
+      y 20
+      z 30)
+```
+
+`setf` assigns values one-by-one, in-order.  Common Lisp also has `psetf` which
+is "parallel `setf`".  This evaluates all the values first, *then* sets all the
+variables at once:
+
+```lisp
+(let ((a 10) (b 20))
+  (setf a 50
+        b (+ 1 a))   ; => (50 51)
+
+  (psetf a 90
+         b (+ 1 a))) ; => (90 52)
+```
+
+Assignment is nice, but often you want to change the value of a variable by
+taking its *current* value and computing something with it.  If you're making
+a ball that travels across the screen you might have something like this:
+
+```text
+def move_ball(ball, distance):
+    ball.x = ball.x + distance
+
+(defun move-ball (ball distance)
+  (setf (slot-value ball 'x)
+        (+ (slot-value ball 'x)
+            distance)))
+```
+
+If you find `slot-value` too wordy to type, you could make a macro to get rid of
+it (and save yourself a quote too).  `.` is already used for something else so
+you'd need to pick a different character:
+
+```lisp
+(defmacro $ (instance slot-symbol)
+  `(slot-value ,instance ',slot-symbol))
+
+(defun move-ball (ball distance)
+  (setf ($ ball x)
+        (+ ($ ball x)
+            distance)))
+```
+
+In practice, though, you rarely use `slot-value`.  Instead you usually use
+accessor functions:
+
+```lisp
+(defun move-ball (ball distance)
+  (setf (ball-x ball)
+        (+ (ball-x ball)
+            distance)))
+```
+
+Anyway, back to assignment.  What we wrote above *works*, but it's a bit
+annoying to have to type the "place" that we're working with twice.  To cut down
+on this repetition many languages offer operators like `+=` and `++`:
+
+```text
+x = x + 10
+⬇
+x += 10
+
+y = y + 1
+⬇
+y++
+```
+
+Common Lisp's version of these is called `incf`.
+
+```lisp
+(incf x 10)
+(incf y)
+```
+
+Notice how the s-expression syntax means we can use the same operator for both
+of the forms, instead of needing separate `+=` and `++` operators.
+
+Other languages often have similar "in-place" operators for other numeric
+operations like `-=`, `--`, `*=`, and so on.  Common Lisp has `decf` for
+subtraction, but doesn't have versions for multiplication or division built in.
+But we can add them with a few macros:
+
+```lisp
+(defmacro mulf (place factor)
+  `(setf ,place (* ,place ,factor)))
+
+(defmacro divf (place divisor)
+  `(setf ,place (/ ,place ,divisor)))
+```
+
+Unfortunately these are not quite right — we've committed the cardinal
+macro-writing sin of splicing in the `place` expression multiple times.  If
+`place` has side effects they'll happen more times than expected.
+
+Luckily, Common Lisp has a macro that wraps up the boring process of handling
+this for us.  `define-modify-macro` lets us fix the problem:
+
+```lisp
+(define-modify-macro mulf (factor) *)
+(define-modify-macro divf (divisor) /)
+```
+
+Now we've got versions of `*=` and `/=` in Common Lisp.  While we're here we
+should do things *right* and allow `divf` to be used with just a place, which
+will mean "set `place` to `1/place`":
+
+```lisp
+(define-modify-macro divf (&optional divisor)
+  (lambda (value divisor)
+    (if (null divisor)
+      (/ 1 value)
+      (/ value divisor))))
+
+(let ((x 10))
+  (divf x 2) ; => 5
+  (divf x)   ; => 1/5
+  (divf x))  ; => 5
+```
+
+Note that we don't really need the `1` in `(/ 1 value)`, because Common Lisp's
+`/` works the same way when you call it with a single argument.  I'm not sure
+what behavior would make sense for a unary `(mulf place)`, so let's ignore that
+one and move on.
+
+So far we've been talking about the idea of setting a variable to the result of
+computing some function on its current value.  We used `define-modify-macro` to
+define some support for extra functions, but defining a mutator macro for every
+function we might possibly want to use could get tedious.  What if we generalize
+this a bit more?
+
+```lisp
+(define-modify-macro callf (function)
+  (lambda (value function)
+    (funcall function value)))
+
+(let ((x -1))
+  (callf x #'abs)   ; => 1
+  (callf x #'1+)    ; => 2
+  (callf x #'sin)   ; => 0.9092974
+  (callf x #'round) ; => 1
+  (callf x #'-))    ; => -1
+```
+
+Now we've got something a bit higher-level.  With `callf` we can mutate
+a variable with a unary function.  But what about functions that need more
+arguments?  Again, Common Lisp does the right thing and handles `&rest`
+parameters correctly in `define-modify-macro`:
+
+```lisp
+(define-modify-macro callf (function &rest args)
+  (lambda (value function &rest args)
+    (apply function value args)))
+
+(let ((x -1))
+  (callf x #'abs)    ; => 1
+  (callf x #'+ 10)   ; => 11
+  (callf x #'* 2 4)) ; => 88
+
+(let ((foo (list 0 1 2 3)))
+  (callf foo #'reverse)
+  ; => (3 2 1 0)
+
+  (callf foo #'append (list -1 -2 -3)))
+  ; => (3 2 1 0 -1 -2 -3)
+```
+
+That's better.  Now we can mutate a variable by applying a function to its
+current value and some other arguments.  This might come in handy when we don't
+want to bother defining a full-blown modification macro just to use it once or
+twice.
+
+At this point we've got something similar to Michael Malis' [zap][] macro.
+A minor difference is for `zap` the order of the function and the place are
+reversed.  I believe his reason was that it makes the resulting form look more
+like the function call that is conceptually being made:
+
+```lisp
+(zap     #'+  x  5)
+;          ↓  ↓  ↓
+(setf x (  +  x  5  ))
+```
+
+Unfortunately, because the place is no longer the first argument we can't use
+`define-modify-macro` to handle the single-evaluation boilerplate for us any
+more.  Instead we need to use `get-setf-expander` and work with its results.
+Malis' excellent [Getting Places][] article explains how that works, and if you
+want to fully understand the rest of the code in this post you should read that
+one first.
+
+The difference between `callf` and Malis' `zap` are just cosmetic.  But they're
+still not completely flexible.  What if we want to call a function, but we need
+the value to be an argument other than the first?  Of course we could use
+a `lambda`:
+
+```lisp
+(let ((x (list :coffee :soda :tea)))
+  (callf x (lambda (l) (remove :soda l))))
+
+```
+
+But that is *really* ugly.  It would be nice if we had a way to specify which
+argument to the function should be the current value.  This is Lisp, so we can
+pick whatever syntax we want.  What should we choose?  Often a good first step
+is to look at how other languages do things.  Clojure's anonymous function
+syntax is one possibility:
+
+```lisp
+(map #(+ 10 %) [1 2 3])
+; => (11 12 13)
+```
+
+Clojure uses the magic symbol `%` as a placeholder for the argument.  We can
+modify Malis' `zap` macro to do the same.  We'll call it `zapf`, and we'll swap
+the place back into the first argument like all the other modify macros, since
+the aesthetic reason no longer holds.  The changes are in bold:
+
+<pre><code>; Original version
+(defmacro zap (fn place &rest args)
+  (multiple-value-bind
+        (temps exprs stores store-expr access-expr)
+      (get-setf-expansion place)
+    `(let* (,@(mapcar #'list temps exprs)
+            (,(car stores)
+              (funcall ,fn ,access-expr ,@args)))
+       ,store-expr)))
+
+; New version
+(defmacro <b>zapf</b> (<b>place fn</b> &rest args)
+  (multiple-value-bind
+        (temps exprs stores store-expr access-expr)
+      (get-setf-expansion place)
+    `(let* (,@(mapcar #'list temps exprs)
+            (,(car stores)
+             (funcall ,fn <b>,@(substitute access-expr '% args)</b>)))
+      ,store-expr)))
+</code></pre>
+
+And now we can use `%` to say where the place's value should go:
+
+```lisp
+(let ((x (list :coffee :soda :tea)))
+  (zapf x #'remove :soda %)
+  ; => (:coffee :tea)
+
+  (zapf x #'cons :water %)
+  ; => (:water :coffee :tea)
+
+  (zapf x #'append % (list :cocoa :chai)))
+  ; => (:water :coffee :tea :cocoa :chai)
+```
+
+Note that `substitute` will replace *all* occurrences of `%` with the access
+expression, so we can do something like `(zapf x #'append % %)` if we want.
+
+Some people will find this new version unpleasant, because it effectively
+captures the `%` variable.  It's not hygienic, by design.  I personally don't
+mind it, and I like the brevity it allows.
+
+We're almost done, but I want to push things just a *bit* further.  Let's
+revisit the original example of the ball moving across the screen:
+
+```text
+def move_ball(ball, distance):
+    ball.x = ball.x + distance
+
+(defun move-ball (ball distance)
+  (setf (ball-x ball)
+        (+ (ball-x ball) distance)))
+```
+
+Of course we can simply use `+=` or `incf` here:
+
+```text
+def move_ball(ball, distance):
+    ball.x += distance
+
+(defun move-ball (ball distance)
+  (incf (ball-x ball) distance))
+```
+
+Suppose we also wanted to make the ball wrap around the screen when it flies off
+one side.  We can do this using modulus:
+
+```text
+def move_ball(ball, distance, screen_width):
+    ball.x += distance
+    ball.x %= screen_width
+
+(defun move-ball (ball distance screen-width)
+  (incf (ball-x ball) distance)
+  (callf (ball-x ball) #'mod % screen-width))
+```
+
+We could define `modf` if we wanted to make that second call a bit nicer.  But
+let's take a moment to reflect.  Notice how we're back to having to type out
+`(ball-x ball)` twice again.  It's better than typing it four times, but can we
+do better?
+
+`zapf` currently takes a place, a function, and a list of arguments.  What if we
+made it more like `setf`, and just have it take a place and an expression?  We
+could still use `%` as a placeholder, but could let it appear anywhere in the
+(possibly nested) expression form.
+
+One way to do this would be to simply replace `substitute` with `subst` in the
+`zapf` code.  (The difference between these extremely-confusingly-named
+functions is that `substitute` replaces element of a sequence, and `subst`
+replaces elements of a tree.)
+
+This, however, is the wrong strategy.  Blindly replacing `%` everywhere in the
+expression will work for many cases, but will break in edge cases like (god help
+you) nested `zapf` forms.  We could try to walk the code of the expression we
+get, but down this path lies madness and implementation-specificity.
+
+The solution is much, much simpler.  We can just use a normal `let` to capture
+`%` in the expression:
+
+<pre><code>; Final version
+(defmacro <b>zapf</b> (<b>place expr</b>)
+  (multiple-value-bind
+        (temps exprs stores store-expr access-expr)
+      (get-setf-expansion place)
+    `(let* (,@(mapcar #'list temps exprs)
+            (,(car stores)
+             <b>(let ((% ,access-expr))
+               ,expr)</b>))
+      ,store-expr)))
+</code></pre>
+
+And now `move-ball` only requires the bare minimum of typing:
+
+```lisp
+(defun move-ball (ball distance screen-width)
+  (zapf (ball-x ball)
+        (mod (+ distance %) screen-width)))
+```
+
+For completeness it would be nice to allow `zapf` to take any number of
+place/value pairs, just like `setf`.  I'll leave this as an exercise for you to
+try if you're interested.
+
+It took me a while to arrive at this form of the macro.  I personally find it
+lovely and readable.  If you disagree, that's fine too!  Lisp is a wonderful
+substrate for building a language that fits how you think and talk about
+problems.  Play around with your own syntax and find out what feels most natural
+for you.
+
+Before we leave, let's just ponder one more thing.  Performance is often ignored
+these days, but what if we care about making the computer go fast?  The final
+`zapf` macro is handy and expressive, but what cost have we paid for this
+abstraction?
+
+First let's tell SBCL that we want to go fast and return to our original `setf`
+strategy:
+
+```lisp
+(deftype nonnegative-fixnum ()
+  `(integer 0 ,most-positive-fixnum))
+
+(deftype positive-fixnum ()
+  `(integer 1 ,most-positive-fixnum))
+
+(defstruct ball
+  (x 0 :type nonnegative-fixnum)
+  (y 0 :type nonnegative-fixnum))
+
+(declaim (ftype (function (ball fixnum positive-fixnum))
+                move-ball))
+
+(defun move-ball (ball distance screen-width)
+  (declare (optimize (speed 3) (safety 0) (debug 0)))
+  (setf (ball-x ball)
+        (mod (+ distance (ball-x ball))
+             screen-width)))
+```
+
+How does that turn out?
+
+```text
+; disassembly for MOVE-BALL
+; Size: 82 bytes. Origin: #x1005E5E12E
+; 2E:       488B410D         MOV RAX, [RCX+13]       ; no-arg-parsing entry point
+; 32:       48D1F8           SAR RAX, 1
+; 35:       498D3C00         LEA RDI, [R8+RAX]
+; 39:       488BDE           MOV RBX, RSI
+; 3C:       48D1FB           SAR RBX, 1
+; 3F:       4885DB           TEST RBX, RBX
+; 42:       7431             JEQ L3
+; 44:       488BC7           MOV RAX, RDI
+; 47:       4899             CQO
+; 49:       48F7FB           IDIV RAX, RBX
+; 4C:       4C8BC0           MOV R8, RAX
+; 4F:       488BC2           MOV RAX, RDX
+; 52:       48D1E0           SHL RAX, 1
+; 55:       4885C0           TEST RAX, RAX
+; 58:       7510             JNE L2
+; 5A: L0:   488BD8           MOV RBX, RAX
+; 5D: L1:   4889590D         MOV [RCX+13], RBX
+; 61:       488BD3           MOV RDX, RBX
+; 64:       488BE5           MOV RSP, RBP
+; 67:       F8               CLC
+; 68:       5D               POP RBP
+; 69:       C3               RET
+; 6A: L2:   4885FF           TEST RDI, RDI
+; 6D:       7DEB             JNL L0
+; 6F:       488D1C30         LEA RBX, [RAX+RSI]
+; 73:       EBE8             JMP L1
+; 75: L3:   0F0B0A           BREAK 10                ; error trap
+; 78:       07               BYTE #X07
+; 79:       08               BYTE #X08               ; DIVISION-BY-ZERO-ERROR
+; 7A:       FE9E03           BYTE #XFE, #X9E, #X03   ; RDI
+; 7D:       FE9E01           BYTE #XFE, #X9E, #X01   ; RBX
+```
+
+Well that's not *too* bad.  I'm not sure why SBCL still performs a check for
+division by zero for the `mod` even though we said that `screen-width` can't
+possibly be zero.  But hey, we're at a manageable amount of assembly, which is
+pretty nice for a high-level language!
+
+Now for the `zapf` version:
+
+```lisp
+(defun move-ball (ball distance screen-width)
+  (declare (optimize (speed 3) (safety 0) (debug 0)))
+  (zapf (ball-x ball)
+        (mod (+ distance %) screen-width)))
+```
+
+Okay, let's bite the bullet.  How bad are we talking?
+
+```text
+; disassembly for MOVE-BALL
+; Size: 70 bytes. Origin: #x1005F47C7B
+; 7B:       488B410D         MOV RAX, [RCX+13]       ; no-arg-parsing entry point
+; 7F:       48D1F8           SAR RAX, 1
+; 82:       488D3C03         LEA RDI, [RBX+RAX]
+; 86:       4885F6           TEST RSI, RSI
+; 89:       742B             JEQ L2
+; 8B:       488BC7           MOV RAX, RDI
+; 8E:       4899             CQO
+; 90:       48F7FE           IDIV RAX, RSI
+; 93:       488BD8           MOV RBX, RAX
+; 96:       488D0412         LEA RAX, [RDX+RDX]
+; 9A:       4885C0           TEST RAX, RAX
+; 9D:       750D             JNE L1
+; 9F: L0:   48D1E2           SHL RDX, 1
+; A2:       4889510D         MOV [RCX+13], RDX
+; A6:       488BE5           MOV RSP, RBP
+; A9:       F8               CLC
+; AA:       5D               POP RBP
+; AB:       C3               RET
+; AC: L1:   4885FF           TEST RDI, RDI
+; AF:       7DEE             JNL L0
+; B1:       4801F2           ADD RDX, RSI
+; B4:       EBE9             JMP L0
+; B6: L2:   0F0B0A           BREAK 10                ; error trap
+; B9:       07               BYTE #X07
+; BA:       08               BYTE #X08               ; DIVISION-BY-ZERO-ERROR
+; BB:       FE9E03           BYTE #XFE, #X9E, #X03   ; RDI
+; BE:       FE1E03           BYTE #XFE, #X1E, #X03   ; RSI
+```
+
+Wait, it's actually *shorter*?  What about all those extra variables the `zapf`
+macro expands into?  It turns out that SBCL is really quite good at optimizing
+`let` statements and local variables.
+
+This is why I love Common Lisp.  You can be rewriting the syntax of the language
+and working on a tower of abstraction one moment, and looking at X86 assembly to
+see what the hell the computer is actually *doing* the next.  It's wonderful.
+
+[Getting Places]: http://malisper.me/2015/09/22/getting-places/
+[Zap]: http://malisper.me/2015/09/29/zap/
+
--- a/content/blog/2016/09/iterate-averaging.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "Customizing Common Lisp's Iterate: Averaging"
-        snip: "Don't loop, iterate!"
-        created: 2016-09-20 14:00:00
-    %}
-
-    {% block article %}
-
-When I first started learning Common Lisp, one of the things I learned was the
-[loop macro][loop].  `loop` is powerful, but it's not extensible (at least not
-*portably*) and [some people find it ugly][lol].  The [iterate][] library was
-made to solve both of these problems.
-
-Unfortunately I haven't found many guides or resources on how to extend
-`iterate`.  The `iterate` manual describes the macros you need to use, but only
-gives a few sparse examples.  Sometimes it's helpful to see things in action.
-
-I've made a few handy extensions myself in the past couple of months, so
-I figured I'd post about them in case someone else is looking for examples of
-how to write their own `iterate` clauses and drivers.
-
-This first post will show how to make a `averaging` clause that keeps a running
-average of a given expression during the loop.  I've found it handy in a couple
-of places.
-
-[loop]: http://www.gigamonkeys.com/book/loop-for-black-belts.html
-[iterate]: https://common-lisp.net/project/iterate/
-[lol]: /media/images{{ parent_url }}/loop-macro.jpg
-
-[TOC]
-
-## End Result
-
-Before we look at the code, let's look at what we're aiming for:
-
-    :::lisp
-    (iterate (for i :in (list 20 10 10 20))
-             (averaging i))
-    ; =>
-    15
-
-    (iterate (for l :in '((10 :foo) (20 :bar) (0 :baz)))
-             (averaging (car l) :into running-average)
-             (collect running-average))
-    ; =>
-    (10 15 10)
-
-Simple enough.  The `averaging` clause takes an expression (and optionally
-a variable name) and averages its value over each iteration of the loop.
-
-## Code
-
-There's not much code to `averaging`, but it does contain a few ideas that crop
-up often when writing `iterate` extensions:
-
-    :::lisp
-    (defmacro-clause (AVERAGING expr &optional INTO var)
-      "Maintain a running average of `expr` in `var`.
-
-      If `var` is omitted the final average will be
-      returned instead.
-
-      Examples:
-
-        (iterate (for x :in '(0 10 0 10))
-                 (averaging x))
-        =>
-        5
-
-        (iterate (for x :in '(1.0 1 2 3 4))
-                 (averaging (/ x 10) :into avg)
-                 (collect avg))
-        =>
-        (0.1 0.1 0.13333334 0.17500001 0.22)
-
-      "
-      (with-gensyms (count total)
-        (let ((average (or var iterate::*result-var*)))
-          `(progn
-            (for ,count :from 1)
-            (sum ,expr :into ,total)
-            (for ,average = (/ ,total ,count))))))
-
-We use `defmacro-clause` to define the clause.  Check [the iterate manual][man]
-to learn more about the basics of that.
-
-The first thing to note is the big docstring, which describes how to use the
-clause and gives some examples.  I prefer to err on the side of providing *more*
-information in documentation rather than less.  People who don't need the
-hand-holding can quickly skim over it, but if you omit information it can leave
-people confused.  [Your monitor isn't going to run out of ink][ink] and [you
-type fast (right?)][typing] so be nice and just write the damn docs.
-
-Next up is selecting the name of the variable for the average.  The `(or var
-iterate::*result-var*)` pattern is one I use often when writing `iterate`
-clauses.  It's kind of weird that `*result-var*` isn't external in the `iterate`
-package, but this idiom is explicitly mentioned in the manual so I suppose it's
-fine to use.
-
-Finally, we *could* have written a simpler version of `averaging` that just
-returned the result from the loop:
-
-    :::lisp
-    (defmacro-clause (AVERAGING expr)
-      (with-gensyms (count total)
-        `(progn
-          (for ,count :from 1)
-          (sum ,expr :into ,total)
-          (finally (return (/ ,total ,count))))))
-
-This would work, but doesn't let us see the running average during the course of
-the loop.  `iterate`'s built-in clauses like `collect` and `sum` usually allow
-you to access the "in-progress" value, so it's good for our extensions to
-support it too.
-
-[man]: https://common-lisp.net/project/iterate/doc/Rolling-Your-Own.html#Rolling-Your-Own
-[ink]: http://www.bash.org/?105201
-[typing]: https://steve-yegge.blogspot.is/2008/09/programmings-dirtiest-little-secret.html
-
-## Debugging
-
-This clause is pretty simple, but more complicated ones can get a bit tricky.
-When writing vanilla Lisp macros I usually end up writing the macro and then
-`macroexpand-1`'ing a sample of it to make sure it's expanding to what I think
-it should.
-
-As far as I can tell there's no simple way to macroexpand an `iterate` clause on
-its own.  This is really a pain in the ass when you're trying to debug them, so
-I [hacked together][mxi] a `macroexpand-iterate` function for my own sanity.
-It's not pretty, but it gets the job done:
-
-    :::lisp
-    (macroexpand-iterate '(averaging (* 2 x)))
-    ; =>
-    (PROGN
-     (FOR #:COUNT518 :FROM 1)
-     (SUM (* 2 X) :INTO #:TOTAL519)
-     (FOR ITERATE::*RESULT-VAR* = (/ #:TOTAL519 #:COUNT518)))
-
-    (macroexpand-iterate '(averaging (* 2 x) :into foo))
-    ; =>
-    (PROGN
-     (FOR #:COUNT520 :FROM 1)
-     (SUM (* 2 X) :INTO #:TOTAL521)
-     (FOR FOO = (/ #:TOTAL521 #:COUNT520)))
-
-[mxi]: https://github.com/sjl/cl-losh/blob/55de0419a9b97a35943ce4884b598dbd99cc5670/losh.lisp#L1105-L1151
-
-    {% endblock article %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/blog/2016/09/iterate-averaging.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,152 @@
++++
+title = "Customizing Common Lisp's Iterate: Averaging"
+snip = "Don't loop, iterate!"
+date = 2016-09-20T13:45:00Z
+draft = false
+
++++
+
+When I first started learning Common Lisp, one of the things I learned was the
+[loop macro][loop].  `loop` is powerful, but it's not extensible and [some
+people find it ugly][lol].  The [iterate][] library was made to solve both of
+these problems.
+
+Unfortunately I haven't found many guides or resources on how to extend
+`iterate`.  The `iterate` manual describes the macros you need to use, but only
+gives a few sparse examples.  Sometimes it's helpful to see things in action.
+
+I've made a few handy extensions myself in the past couple of months, so
+I figured I'd post about them in case someone else is looking for examples of
+how to write their own `iterate` clauses and drivers.
+
+This first post will show how to make a `averaging` clause that keeps a running
+average of a given expression during the loop.  I've found it handy in a couple
+of places.
+
+[loop]: http://www.gigamonkeys.com/book/loop-for-black-belts.html
+[iterate]: https://common-lisp.net/project/iterate/
+[lol]: /media/images/blog/2016/09/loop-macro.jpg
+
+{{% toc %}}
+
+## End Result
+
+Before we look at the code, let's look at what we're aiming for:
+
+```lisp
+(iterate (for i :in (list 20 10 10 20))
+         (averaging i))
+; =>
+15
+
+(iterate (for l :in '((10 :foo) (20 :bar) (0 :baz)))
+         (averaging (car l) :into running-average)
+         (collect running-average))
+; =>
+(10 15 10)
+```
+
+Simple enough.  The `averaging` clause takes an expression (and optionally
+a variable name) and averages its value over each iteration of the loop.
+
+## Code
+
+There's not much code to `averaging`, but it does contain a few ideas that crop
+up often when writing `iterate` extensions:
+
+```lisp
+(defmacro-clause (AVERAGING expr &optional INTO var)
+  "Maintain a running average of `expr` in `var`.
+
+  If `var` is omitted the final average will be
+  returned instead.
+
+  Examples:
+
+    (iterate (for x :in '(0 10 0 10))
+             (averaging x))
+    =>
+    5
+
+    (iterate (for x :in '(1.0 1 2 3 4))
+             (averaging (/ x 10) :into avg)
+             (collect avg))
+    =>
+    (0.1 0.1 0.13333334 0.17500001 0.22)
+
+  "
+  (with-gensyms (count total)
+    (let ((average (or var iterate::*result-var*)))
+      `(progn
+        (for ,count :from 1)
+        (sum ,expr :into ,total)
+        (for ,average = (/ ,total ,count))))))
+```
+
+We use `defmacro-clause` to define the clause.  Check [the iterate manual][man]
+to learn more about the basics of that.
+
+The first thing to note is the big docstring, which describes how to use the
+clause and gives some examples.  I prefer to err on the side of providing *more*
+information in documentation rather than less.  People who don't need the
+hand-holding can quickly skim over it, but if you omit information it can leave
+people confused.  [Your monitor isn't going to run out of ink][ink] and [you
+type fast (right?)][typing] so be nice and just write the damn docs.
+
+Next up is selecting the name of the variable for the average.  The `(or var
+iterate::*result-var*)` pattern is one I use often when writing `iterate`
+clauses.  It's kind of weird that `*result-var*` isn't external in the `iterate`
+package, but this idiom is explicitly mentioned in the manual so I suppose it's
+fine to use.
+
+Finally, we *could* have written a simpler version of `averaging` that just
+returned the result from the loop:
+
+```lisp
+(defmacro-clause (AVERAGING expr)
+  (with-gensyms (count total)
+    `(progn
+      (for ,count :from 1)
+      (sum ,expr :into ,total)
+      (finally (return (/ ,total ,count))))))
+```
+
+This would work, but doesn't let us see the running average during the course of
+the loop.  `iterate`'s built-in clauses like `collect` and `sum` usually allow
+you to access the "in-progress" value, so it's good for our extensions to
+support it too.
+
+[man]: https://common-lisp.net/project/iterate/doc/Rolling-Your-Own.html#Rolling-Your-Own
+[ink]: http://www.bash.org/?105201
+[typing]: https://steve-yegge.blogspot.is/2008/09/programmings-dirtiest-little-secret.html
+
+## Debugging
+
+This clause is pretty simple, but more complicated ones can get a bit tricky.
+When writing vanilla Lisp macros I usually end up writing the macro and then
+`macroexpand-1`'ing a sample of it to make sure it's expanding to what I think
+it should.
+
+As far as I can tell there's no simple way to macroexpand an `iterate` clause on
+its own.  This is really a pain in the ass when you're trying to debug them, so
+I [hacked together][mxi] a `macroexpand-iterate` function for my own sanity.
+It's not pretty, but it gets the job done:
+
+```lisp
+(macroexpand-iterate '(averaging (* 2 x)))
+; =>
+(PROGN
+ (FOR #:COUNT518 :FROM 1)
+ (SUM (* 2 X) :INTO #:TOTAL519)
+ (FOR ITERATE::*RESULT-VAR* = (/ #:TOTAL519 #:COUNT518)))
+
+(macroexpand-iterate '(averaging (* 2 x) :into foo))
+; =>
+(PROGN
+ (FOR #:COUNT520 :FROM 1)
+ (SUM (* 2 X) :INTO #:TOTAL521)
+ (FOR FOO = (/ #:TOTAL521 #:COUNT520)))
+```
+
+[mxi]: https://github.com/sjl/cl-losh/blob/55de0419a9b97a35943ce4884b598dbd99cc5670/losh.lisp#L1105-L1151
+
--- a/content/blog/index.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-{% extends "skeleton/_listing.html" %}
-
-{% hyde
-    title: "Blog"
-    exclude: True
-%}
\ No newline at end of file
--- a/content/feed.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-{% extends "skeleton/_atom.xml" %}
--- a/content/index.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,5 +0,0 @@
-{% extends "_splash.html" %}
-
-{% hyde
-    title: ""
-%}
--- a/content/links.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-    {% extends "_flatpage.html" %}
-
-    {% hyde
-        title: "Links"
-    %}
-
-    {% block article %}
-
-This page is a collection of links to blogs/resources I find interesting.
-
-It's mostly just a place for me to dump links that I want to remember to check
-every now and then when I'm bored.  I figured other people might find it
-interesting too.
-
-Blogs
------
-
-* [Habrador](http://blog.habrador.com/): Various game programming-related articles.
-* [Martin O'Leary](http://mewo2.com/): Blog with some really good articles on procedural generation.
-* [Michael Malis](http://malisper.me/): Lots of Lisp stuff (usually macro-related).
-* [Paul Khuong](https://pvk.ca/): Mostly Lisp/SBCL-related stuff.
-* [Peteris Krumins' Top 100 Books](http://www.catonmat.net/blog/top-100-books-part-one/): Great list of books to read.
-* [Red Blob Games](http://www.redblobgames.com/): Wonderful blog with *really* good posts about lots of different video game-related topics.
-* [The Digital Antiquarian](http://www.filfre.net/): Immense amount of information on the history of "computer entertainment".
-
-YouTube Channels
-----------------
-
-* [3Blue1Brown](https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw): Videos on various math topics.  His series on linear algebra in particular is fantastic.
-* [Coding Math](https://www.youtube.com/user/codingmath): A series of 50ish basic math lessons aimed at the kind of math you'll used in video games.  Every lesson shows the concepts implemented in little Javascript demos, and it's *really* helpful to see how you actually *use* something once you learn the basic idea.
-* [Makin' Stuff Look Good](https://www.youtube.com/channel/UCEklP9iLcpExB8vp_fWQseg): Videos about how to make things look good in Unity.  The best part of the channel is the "shader case studies" where he looks at visual effects in various games and shows how to recreate them with a shader.
-
-Subreddits
-----------
-
-* [/r/proceduralgeneration](http://reddit.com/r/proceduralgeneration/)
-* [/r/worldbuilding](http://reddit.com/r/worldbuilding/)
-
-    {% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/links/index.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,36 @@
++++
+date = "2016-06-20T13:17:43Z"
+draft = false
+title = "Links"
+
++++
+
+This page is a collection of links to blogs/resources I find interesting.
+
+It's mostly just a place for me to dump links that I want to remember to check
+every now and then when I'm bored.  I figured other people might find it
+interesting too.
+
+Blogs
+-----
+
+* [Habrador](http://blog.habrador.com/): Various game programming-related articles.
+* [Martin O'Leary](http://mewo2.com/): Blog with some really good articles on procedural generation.
+* [Michael Malis](http://malisper.me/): Lots of Lisp stuff (usually macro-related).
+* [Paul Khuong](https://pvk.ca/): Mostly Lisp/SBCL-related stuff.
+* [Peteris Krumins' Top 100 Books](http://www.catonmat.net/blog/top-100-books-part-one/): Great list of books to read.
+* [Red Blob Games](http://www.redblobgames.com/): Wonderful blog with *really* good posts about lots of different video game-related topics.
+* [The Digital Antiquarian](http://www.filfre.net/): Immense amount of information on the history of "computer entertainment".
+
+YouTube Channels
+----------------
+
+* [3Blue1Brown](https://www.youtube.com/channel/UCYO_jab_esuFRV4b17AJtAw): Videos on various math topics.  His series on linear algebra in particular is fantastic.
+* [Coding Math](https://www.youtube.com/user/codingmath): A series of 50ish basic math lessons aimed at the kind of math you'll used in video games.  Every lesson shows the concepts implemented in little Javascript demos, and it's *really* helpful to see how you actually *use* something once you learn the basic idea.
+* [Makin' Stuff Look Good](https://www.youtube.com/channel/UCEklP9iLcpExB8vp_fWQseg): Videos about how to make things look good in Unity.  The best part of the channel is the "shader case studies" where he looks at visual effects in various games and shows how to recreate them with a shader.
+
+Subreddits
+----------
+
+* [/r/proceduralgeneration](http://reddit.com/r/proceduralgeneration/)
+* [/r/worldbuilding](http://reddit.com/r/worldbuilding/)
--- a/content/projects/badwolf.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,57 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-    title: "Bad Wolf"
-    snip: "A Vim color scheme."
-    created: 2012-02-12 15:06:01
-    exclude: False
-    %}
-
-    {% block article %}
-
-Bad Wolf is a Vim colorscheme pieced together from various colors I like.
-
-> I am the Bad Wolf. I create myself.  
-> I take the words. I scatter them in time and space.  
-> A message to lead myself here.
-
-You can [download][] the raw file, or use Pathogen with the [Mercurial
-repository][hg] or the [Git repository][git].
-
-[download]: http://bitbucket.org/sjl/badwolf/raw/tip/colors/badwolf.vim
-[hg]: http://bitbucket.org/sjl/badwolf/
-[git]: http://github.com/sjl/badwolf/
-
-Screenshots
------------
-
-These screenshots may be out of date, but they'll at least give you a taste of
-what you're in for.
-
-
-### Python
-
-<div class="screenshots">
-    <a href="http://i.imgur.com/fQGGC.png"><img src="http://i.imgur.com/fQGGC.png" alt="screenshot"></a>
-</div>
-
-### HTML (Django Templates)
-
-<div class="screenshots">
-    <a href="http://i.imgur.com/LgLar.png"><img src="http://i.imgur.com/LgLar.png" alt="screenshot"></a>
-</div>
-
-### Clojure
-
-<div class="screenshots">
-    <a href="http://i.imgur.com/THHz7.png"><img src="http://i.imgur.com/THHz7.png" alt="screenshot"></a>
-</div>
-
-### Markdown
-
-<div class="screenshots">
-    <a href="http://i.imgur.com/J56VS.png"><img src="http://i.imgur.com/J56VS.png" alt="screenshot"></a>
-</div>
-
-
-    {% endblock %}
--- a/content/projects/clam.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-title: "Clam"
-snip: "A Vim plugin for working with shell commands."
-created: 2012-04-07 20:00:01
-exclude: False
-%}
-
-{% block article %}
-
-[Clam][] is a small, lightweight Vim plugin for working with shell commands more
-easily.
-
-It's open source (MIT/X11 licensed) on [BitBucket][] and [GitHub][].
-
-<iframe src="http://www.screenr.com/embed/2Z18" width="610" height="396" frameborder="0"></iframe>
-
-[Clam]: http://vim-doc.heroku.com/view?https://raw.github.com/sjl/clam.vim/master/doc/clam.txt
-[BitBucket]: http://bitbucket.org/sjl/clam.vim/
-[GitHub]: http://github.com/sjl/clam.vim/
-
-{% endblock %}
-
-
--- a/content/projects/clojure-postmark.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-        title: "clojure-postmark"
-        snip: "Use Postmark from Clojure."
-        created: 2011-10-10 00:00:03
-        exclude: False
-    %}
-
-    {% block article %}
-
-[clojure-postmark][] lets you talk to [Postmark][] from [Clojure][].
-
-It's open source (MIT/X11 licensed) on [BitBucket][] and [GitHub][].
-
-[clojure-postmark]: http://sjl.bitbucket.org/clojure-postmark/
-[Postmark]: http://postmarkapp.com/
-[Clojure]: http://clojure.org/
-[BitBucket]: http://bitbucket.org/sjl/d/
-[GitHub]: http://github.com/sjl/d/
-
-    {% endblock %}
-
--- a/content/projects/d.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-title: "d"
-snip: "Generate documentation and get on with your life."
-created: 2012-01-23 20:00:01
-exclude: False
-%}
-
-{% block article %}
-
-[d](http://sjl.bitbucket.org/d/) generates documentation from Markdown files
-and lets you get on with your life.
-
-It's open source (MIT/X11 licensed) on [BitBucket][] and [GitHub][].
-
-[BitBucket]: http://bitbucket.org/sjl/d/
-[GitHub]: http://github.com/sjl/d/
-
-{% endblock %}
-
--- a/content/projects/django-hoptoad.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "django-hoptoad"
-    snip: "Now ponies can ride the toad too."
-    created: 2009-07-25 01:16:40
-    exclude: True
-%}
-
-{% block article %}
-
-django-hoptoad is some simple Middleware for letting [Django][]-driven
-websites report their errors to [Hoptoad][]. Now [ponies][] can ride the toad
-too.
-
-You can get it from [the repository on BitBucket][repo].
-
-Check out the [documentation][docs] to find out how to use it.
-
-[Django]: {{links.django}}
-[Hoptoad]: http://hoptoadapp.com/
-[ponies]: http://djangopony.com/
-[repo]: http://bitbucket.org/sjl/django-hoptoad/
-[docs]: http://sjl.bitbucket.org/django-hoptoad/
-
-Suggestions
------------
-
-This Middleware is a work in progress. If you have a suggestion or find a bug
-please [add an issue][issues] or find me on [Twitter][twsl] and let me know.
-
-[issues]: http://bitbucket.org/sjl/django-hoptoad/issues/?status=new&status=open
-[twsl]: {{links.twsl}}
-
-{% endblock %}
--- a/content/projects/friendly-find.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-    title: "Friendly Find"
-    snip: "A friendlier find(1)."
-    created: 2012-11-19 19:00:01
-    exclude: False
-    %}
-
-{% block article %}
-
-[Friendly Find][] is the friendly file finder.
-
-It's meant to be a more usable replacement for find(1). If you've used [ack][],
-then `ffind` is to `find` as `ack` is to `grep`.
-
-[Friendly Find]: https://github.com/sjl/friendly-find
-[ack]: http://betterthangrep.com/
-
-{% endblock %}
--- a/content/projects/fuego.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Fuego"
-    snip: "Photographs of Alex. Studio."
-    created: 2009-01-19 01:25:20
-    exclude: True
-%}
-
-{% block article %}
-
-{% spaceless %}
-
-<div class="gallery">
-    <a href="/media/images/projects/{{ page.page_name }}/Fuego-4852.jpg" rel="fuego">
-        <img src="/media/images/projects/{{ page.page_name }}/Fuego-4852-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/Fuego-4887.jpg" rel="fuego">
-        <img src="/media/images/projects/{{ page.page_name }}/Fuego-4887-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/Fuego-4919.jpg" rel="fuego">
-        <img src="/media/images/projects/{{ page.page_name }}/Fuego-4919-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/Fuego-4941.jpg" rel="fuego">
-        <img src="/media/images/projects/{{ page.page_name }}/Fuego-4941-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/Fuego-4985.jpg" rel="fuego">
-        <img src="/media/images/projects/{{ page.page_name }}/Fuego-4985-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/Fuego-5133.jpg" rel="fuego">
-        <img src="/media/images/projects/{{ page.page_name }}/Fuego-5133-thumb.jpg" />
-    </a>
-</div>
-
-{% endspaceless %}
-
-Letting go.
-
-{% endblock %}
--- a/content/projects/grabtweets.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "grabtweets"
-    snip: "A simple tool for backing up your tweets."
-    created: 2009-09-12 11:02:46
-    exclude: True
-%}
-
-{% block article %}
-
-`grabtweets` is a simple tool to backup your tweets.
-
-The code is in a [Mercurial repository][repository] on [BitBucket][].
-
-[BitBucket]: http://bitbucket.org/
-
-[TOC]
-
-Installing
-----------
-
-`grabtweets` requires [Python][] 2.6 or later.
-
-To install it, you can [download][] the latest version, or clone the Mercurial
-repository:
-
-    :::text
-    hg clone http://bitbucket.org/sjl/grabtweets/
-
-You can put it anywhere you like.
-
-Using
------
-
-`grabtweets` can back up your tweets and print tweets that it has already
-archived.
-
-### Backing Up Tweets
-
-To back up your tweets, run `grabtweets` like this:
-
-    :::console
-    $ grabtweets.py -u USERNAME FILE
-
-`grabtweets` will pull down the 200 newest tweets from USERNAME and store them
-in FILE.
-
-You probably have more than 200 tweets. However, Twitter will only let you
-pull down 200 at a time and hitting the server too fast will result in Twitter
-cutting off your access for a while.
-
-To deal with this, it's best to set up `grabtweets` as a cron/launchd job that
-runs every couple of hours. Each time it runs, it will pull down the newest
-200 tweets, plus 200 older tweets if there are any available.
-
-It will take about `NUMBER_OF_TWEETS_YOU_HAVE/200` runs to finish archiving
-your tweets. Just set it up and forget about it.
-
-### Printing Backed Up Tweets
-
-To print the tweets that `grabtweets` has already backed up, run it like this:
-
-    :::console
-    $ grabtweets.py -p FILE
-
-[Python]: {{links.python}}
-[download]: http://bitbucket.org/sjl/grabtweets/get/tip.zip
-
-Problems, Contributing, etc
----------------------------
-
-`grabtweets` was hacked together in an hour. There are probably bugs. If you
-find any, go ahead and create an issue in the [issue tracker][].
-
-Want to fix something or add a feature? Great! Fork the [repository][] and
-send me a pull request.
-
-[issue tracker]: http://bitbucket.org/sjl/grabtweets/issues/?status=new&status=open
-[repository]: http://bitbucket.org/sjl/grabtweets/
-
-{% endblock %}
--- a/content/projects/gundo.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-title: "Gundo"
-snip: "Graph your Vim undo tree."
-created: 2011-10-10 00:00:01
-exclude: False
-%}
-
-{% block article %}
-
-[Gundo](http://sjl.bitbucket.org/gundo.vim/) is a Vim plugin that graphs your
-undo tree.  Check out the site for all the information.
-
-{% endblock %}
--- a/content/projects/hg-paste.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "hg-paste"
-    snip: "Send diffs from Mercurial to various pastebin websites."
-    created: 2009-09-16 17:52:55
-    exclude: True
-%}
-
-{% block article %}
-
-hg-paste adds an `hg paste` command to Mercurial which can send diffs to
-various pastebin websites for easy sharing. You can grab the code from the
-[repository][] on BitBucket.
-
-It was inspired by [Pocoo][]'s [hgpaste][pocoopaste] extension, but is
-designed to work with public pastebin websites instead of private
-installations of [LodgeIt][].
-
-[Pocoo]: http://www.pocoo.org/
-[pocoopaste]: http://dev.pocoo.org/hg/hgpaste/
-[LodgeIt]: http://dev.pocoo.org/projects/lodgeit/
-
-[TOC]
-
-Installing
-----------
-
-Clone the repository:
-
-    :::text
-    hg clone http://bitbucket.org/sjl/hg-paste/
-
-Edit the `[extensions]` section in your `~/.hgrc` file:
-
-    :::ini
-    [extensions]
-    paste = (path to)/hg-paste/paste.py
-
-Using the Command
------------------
-
-To paste a diff of all uncommitted changes in the working directory:
-
-    :::text
-    hg paste
-
-To paste the changes that revision `REV` made:
-
-    :::text
-    hg paste -r REV
-
-To paste the changes between revisions `REV1` and `REV2`:
-
-    :::text
-    hg paste -r REV1:REV2
-
-If any files are specified only those files will be included in the diffs.
-
-Several options can be used to specify more metadata about the paste:
-
-    :::text
-    hg paste --user Steve --title 'Progress on feature X' --keep
-
-The pastebin website to use can be specified with `--dest`. Currently only
-[dpaste.com](http://dpaste.com/) and [dpaste.org](http://dpaste.org) are
-supported.
-
-Questions, Comments, Suggestions
---------------------------------
-
-If you find any bugs, please create an issue in the [issue tracker][issues].
-
-If you want to contribute (support for more pastebin websites would be great),
-fork the [repository][] on BitBucket and send a pull request.
-
-[issues]: http://bitbucket.org/sjl/hg-paste/issues/?status=new&status=open
-[repository]: http://bitbucket.org/sjl/hg-paste
-
-{% endblock %}
--- a/content/projects/hg-prompt.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "hg-prompt"
-    snip: "A Mercurial extension for adding repository info to your shell prompt."
-    created: 2009-06-19 22:25:17
-%}
-
-{% block article %}
-
-hg-prompt adds an 'hg prompt' command to Mercurial for viewing repository
-information. It's designed to be used in a shell prompt. You can grab the code
-from [the repository on BitBucket](http://bitbucket.org/sjl/hg-prompt/).
-
-Check out the [documentation][docs] to find out how to use it.
-
-Here's what it looks like:
-
-![My bash prompt while using hg-prompt.](/media/images/projects/{{ page.page_name }}/prompt.png "My bash prompt while using hg-prompt.")
-
-[docs]: http://sjl.bitbucket.org/hg-prompt/
-
-Questions, Comments, Suggestions
---------------------------------
-
-The code was kind of thrown together in one night after I got tired of
-chaining three or four hg runs together to get what I wanted. I'm sure it's
-not perfect, so if you've got a way to improve it please [add an
-issue](http://bitbucket.org/sjl/hg-prompt/issues/) and let me know.
-
-{% endblock %}
--- a/content/projects/hgtab.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,119 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "hgtab"
-    snip: "Smarter tab completion for Mercurial in bash."
-    created: 2009-03-10 20:22:44
-    exclude: True
-%}
-
-{% block article %}
-
-hgtab was created to provide smarter tab completion for Mercurial in bash.
-
-**UPDATE**: Apparently there's already [tab completion in
-Mercurial](http://www.selenic.com/hg/file/11efa41037e2/contrib/bash_completion)!
-It's way better than this, *use that*! It should probably be better documented
-though &ndash; I posted this yesterday and it's already the top four results
-for "mercurial tab completion" on Google...
-
-If I've missed something you'd really like tab completed, post an issue on the
-issue tracker and I'll do my best to implement it. My bash scripting skills
-are almost non-existent, so if you improve this (or port it to another shell)
-feel free to send a pull request!
-
-You can download hgtab from its [BitBucket
-repository](http://source.stevelosh.com/hgtab/).
-
-## Installing
-
-All you need to do to use hgtab is source it. There are three ways to do this,
-ranging from easy and ugly to slightly less easy and more elegant.
-
-### OPTION 1: Easy, Ugly
-
-Copy the contents of `hgtab-bash.sh` into your `~/.bashrc` file.
-
-### OPTION 2: Harder, Less Ugly
-
-Download `hgtab-bash.sh` and place the following line somewhere in your
-`~/.bashrc` file:
-
-    :::bash
-    source ~/path/to/hgtab/hgtab-bash.sh
-
-### OPTION 3: Hardest, Elegant
-
-Clone this repository somewhere with this command:
-
-    :::text
-    hg clone http://bitbucket.org/sjl/hgtab/
-
-Add the following line to your `~/.bashrc` file:
-
-    :::bash
-    source ~/path/to/hgtab/hgtab-bash.sh
-
-If you use this method you can update the file by pulling down the changes
-from this repository:
-
-    :::text
-    cd ~/path/to/hgtab
-    hg pull
-
-## Using
-
-Once hgtab is sourced it'll add some nifty tab completion features in your
-shell. For example, you can tab complete Mercurial commands:
-
-    :::console
-    sjl at grendel in test $  hg re<tab(s)>
-    recover  remove   rename   resolve  revert
-    sjl at grendel in test $  hg re
-
-When you're using a command that wants a revision as a parameter, hitting tab
-will complete on tags (and bookmarks) and branches.
-
-    :::console
-    sjl at grendel in test $  hg branches
-    blue                          20:f05ca6eb51a1
-    red                           16:8262f0345f41 (inactive)
-    default                       15:67f959b8deb8 (inactive)
-    sjl at grendel in test $  hg book
-     * dev-1.0                   20:f05ca6eb51a1
-    sjl at grendel in test $  hg tags
-    tip                               20:f05ca6eb51a1
-    dev-1.0                           20:f05ca6eb51a1
-    beta                              18:f3ab9bf730f7
-    alpha                             17:ca802019f04f
-    
-    sjl at grendel in test $  hg update <tab(s)>
-    alpha    beta     blue     default  dev-1.0  red      tip
-    sjl at grendel in test $  hg update b<tab(s)>
-    beta  blue  
-    sjl at grendel in test $  hg update b
-    
-    sjl at grendel in test $  hg diff -r b<tab(s)>
-    beta  blue  
-    sjl at grendel in test $  hg diff -r b
-
-It will also complete remote paths when you're pushing or pulling.
-
-    :::console
-    sjl at grendel in test $  hg paths
-    alice-dev = http://alice-dev
-    alice-stable = http://alice-stable
-    bob = http://bob
-    default = ssh://hg@bitbucket.org/sjl/hgtag/
-    
-    sjl at grendel in test $  hg push <tab(s)>
-    alice-dev     alice-stable  bob           default
-    sjl at grendel in test $  hg push
-    
-    sjl at grendel in test $  hg pull alice-<tab(s)>
-    alice-dev     alice-stable  
-    sjl at grendel in test $  hg pull alice-
-
-Enjoy!
-
-{% endblock %}
--- a/content/projects/index.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-{% extends "skeleton/_listing.html" %}
-
-{% hyde
-    title: "Projects"
-    exclude: True
-%}
\ No newline at end of file
--- a/content/projects/learnvimscriptthehardway.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-title: "Learn Vimscript the Hard Way"
-snip: "A short book about Vimscript."
-created: 2011-10-10 00:32:00
-%}
-
-{% block article %}
-
-[Learn Vimscript the Hard Way][lvsthw] is a short book for users of the Vim
-editor who want to learn how to customize Vim.
-
-It's currently a work in progress, so it's incomplete and and you should expect
-mistakes.
-
-It will always be available for free online.  Once it's finished you'll be able
-to buy paperback and eBook versions for fairly cheap.
-
-[lvsthw]: http://learnvimscriptthehardway.stevelosh.com/
-
-{% endblock %}
--- a/content/projects/lindyjam-com.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "lindyjam.com"
-    snip: "A page for a local weekly swing dance event (and more)."
-    created: 2009-01-21 18:28:35
-    exclude: True
-%}
-
-{% block article %}
-
-A few days ago I released the new [Lindy Jam][] website. Lindy Jam is a weekly
-swing dance in Rochester, NY. I wanted to create a site that was useful for
-those that attend the event but also more than just a "here's when it is and
-how to get there" page.
-
-[Lindy Jam]: http://lindyjam.com/
-
-![lindyjam.com screenshot](/media/images/projects/{{ page.page_name }}/lindyjamcom-splash.png "Screenshot of the Lindy Jam site.")
-
-Design
-------
-
-Let me preface this section by saying: "I'm not a graphic designer." Yes, I
-appreciate good design and typography, but I simply haven't studied it as much
-as I'd like. That might change in the future, but for now I'll make due with
-the knowledge I have.
-
-There are very few images used on the site; the background stripes and the
-splash page photo(s) comprise all of them. I did this for a few reasons:
-
-* It saved me time.
-* The site loads faster.
-* The site scales to larger or smaller sizes very gracefully.
-
-I tried to keep things as clean as possible while still being useful. Comments
-and error messages are displayed immediately, without reloading the page. This
-makes it easier to see what you've done (or what went wrong) right off the
-bat.
-
-I'm not 100% pleased with how it came out, but it will do until I learn more
-about design. If you have advice or suggestions about the design, please
-[email me][]!
-
-[email me]: mailto:steve@stevelosh.com
-
-Pages
------
-
-### About
-
-The most important part of the site is probably the [About][] page, because it
-tells people when and where the event happens. It's as simple and to the point
-as I could make it so people can get the information they're looking for right
-away. It's linked right from the splash page so it's easier to find.
-
-[About]: http://lindyjam.com/about/
-
-### DJ Schedule
-
-Another important piece of the site is the [DJ Schedule][] page. Every week
-someone can sign up to DJ the event. They get in for free, and we get to hear
-a wider variety of music. The schedule page makes it easy to sign up for a
-week in the near future.
-
-When you sign up to DJ you can also enter your email address or cell phone
-number (or both) if you'd like to be reminded. I know that sometimes I've
-almost forgotten to bring my laptop (and arrive right on time), so I hope that
-this feature will be useful to other DJs too.
-
-[DJ Schedule]: http://lindyjam.com/schedule/
-
-### Blog
-
-One thing I believe our Lindy Hop scene lacks is a place for people to write
-thoughtful, well-crafted articles about the scene. I hope the Lindy Jam
-[Blog][] can become such a place.
-
-It's a fairly simple blog; entries and comments are written in [Markdown][] so
-authors don't need to know HTML to make their articles look nice. Anyone can
-comment without signing up for anything, so I hope people will take advantage
-of that and discuss the articles.
-
-[Blog]: http://lindyjam.com/blog/
-[Markdown]: {{links.markdown}}
-
-### Links
-
-Most sites like this have a list of links to other sites that their viewers
-might be interested in, and this site is no different. The [Links][] page is a
-simple, clean list of links that anyone can contribute to. If someone knows of
-a great page we haven't listed, they can submit it and it will appear on the
-page as soon as it's been approved.
-
-[Links]: http://lindyjam.com/links/
-
-### Quotes
-
-Along the top of every page is a random quote. Right now there aren't very
-many, but I hope that people will submit some more by going to the [Quotes][]
-page or by text messaging them to <quotes@lindyjam.com>.
-
-I think the quotes add a more personal touch and allowing anyone to add one
-can really make it a "community" site.
-
-[Quotes]: http://lindyjam.com/quotes/
-
-### RSS
-
-We nerds love our [RSS][] feeds, so I've implemented a couple of different
-feeds that people can use to stay up to date.
-
-[RSS]: http://lindyjam.com/rss/
-
-Implementation
---------------
-
-The site was built with [Django][] because it makes it very, very easy to get
-a dynamic site like this up and running quickly. I use [Fabric][] to deploy it
-(check out [this
-entry](http://stevelosh.com/blog/entry/2009/1/15/deploying-site-fabric-and-mercurial/)
-on my personal blog for more information about that). All of the fancy effects
-use [jQuery][] so I can avoid programming them from scratch in javascript (and
-tearing my hair out).
-
-One thing I would do differently if I were to design the site all over again
-is use a CSS framework like [Blueprint][]. I used Blueprint for my personal
-site and it made things far, far easier than writing the layout in CSS from
-scratch. I definitely recommend it if you want to keep your sanity.
-
-The site itself is hosted on [WebFaction][]. I use them to host my own site
-too and they're fantastic. Setting up a Django or Rails (or any other type) of
-site is quick and easy, and they're very cheap. If you're looking for a web
-host you should check them out.
-
-The site is open source if you'd like to take a look at what makes it tick.
-You can browse or download the code from the [Mercurial repository][] on
-BitBucket.
-
-[Django]: {{links.django}}
-[Fabric]: {{links.fabric}}
-[jQuery]: http://jquery.com/
-[Blueprint]: http://www.blueprintcss.org/
-[WebFaction]: {{links.webfaction}}
-[Mercurial repository]: http://bitbucket.org/sjl/lindyjam/
-
-Feedback
---------
-
-If you have any comments or questions about the site please let me know! You
-can post them here or [email me][].
-
-{% endblock %}
--- a/content/projects/peat.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-    title: "Peat"
-    snip: "Peat repeats commands."
-    created: 2012-11-19 19:00:02
-    exclude: False
-    %}
-
-{% block article %}
-
-[Peat][] is a small utility for easily repeating a command when files change.
-
-[Peat]: https://github.com/sjl/peat
-
-{% endblock %}
--- a/content/projects/roul.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-title: "Roul"
-snip: "A tiny Clojure library for working with random numbers."
-created: 2012-04-08 15:45:01
-exclude: False
-%}
-
-{% block article %}
-
-[Roul][] is a little Clojure library that makes working with random numbers in
-Clojure less painful.
-
-It's open source (MIT/X11 licensed) on [BitBucket][] and [GitHub][].
-
-[Roul]: http://sjl.bitbucket.org/roul/
-[BitBucket]: http://bitbucket.org/sjl/roul/
-[GitHub]: http://github.com/sjl/roul/
-
-{% endblock %}
-
--- a/content/projects/splice.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-    title: "Splice"
-    snip: "A Vim plugin for resolving three-way merge conflicts."
-    created: 2011-10-10 00:00:02
-    exclude: False
-    %}
-
-    {% block article %}
-
-[Splice](http://sjl.bitbucket.org/splice.vim/) is a Vim plugin that helps
-you resolve three-way merge conflicts.  Check out the site for more information. 
-
-    {% endblock %}
-
--- a/content/projects/stevelosh-com.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "stevelosh.com"
-    snip: "This website."
-    created: 2009-01-11 15:40:26
-    exclude: True
-%}
-
-{% block article %}
-
-For a long time I used [Squarespace][] to create and host my personal website.
-It's a great service, and I highly recommend it to anyone that needs a simple,
-easy, beautiful site.
-
-Recently, however, I've started learning more and more about web design and I
-decided to completely revamp my website and build it myself from the ground
-up. This is the result.
-
-Design
-------
-
-I like simplicity. In all areas of my life (music, dancing, photography,
-programming, design, etc) I'm striving to make everything I do as simple,
-clean, and elegant as possible. That's why I went with such a minimal design
-for the site.
-
-I haven't used any graphics in the layout for a few reasons. First, I'm not
-very good at making them. Second, I want the site to load quickly, even on
-phones, and scale gracefully for accessibility. Third, I wanted the interface
-to be as uncluttered as possible so the content of the site would be front and
-center.
-
-I also stuck to a minimum of color. The only items that have any color on the
-site are any photographs that I post and the links. I did this because I'm not
-a graphic designer and so I haven't studied color enough to know how to use it
-well.
-
-One last thing I tried to keep in mind was sticking to a baseline rhythm for
-some elements of the site. The home page, blog entry list, and project list
-all line up with the links in the right sidebar. I think it gives the layout a
-more stable feel.
-
-Implementation
-------------
-
-This website was written in [Python][] using the [Django][] framework. Django
-makes it really easy to write useful web apps quickly and cleanly. I love it.
-
-[Blueprint][] kept me sane while writing the CSS. Grid layouts are no longer a
-nightmare!
-
-I rely pretty heavily on [Markdown][] throughout the site. The blog entries
-and static pages are all written in Markdown and parsed to XHTML later. This
-might not be the fastest way to do things but processor time is cheap and my
-time isn't.
-
-The Markdown-based editor and preview for commenting is the wonderful [WMD][].
-It's clean, simple, and does exactly what I want it to do. Most of the other
-Javascript magic comes from [jQuery][]. I use the [jQuery form validation
-plugin][form validation] in a couple of places to make checking input easier.
-
-For site statistics I'm relying on the fantastic [Mint][]. It's got a gorgeous
-interface and is absurdly simple to install. Plus it's hosted on my own host
-so I have control. It's also just a one time fee, unlike some other site stat
-packages that charge monthly.
-
-My development process is pretty simple. I use [TextMate][] to edit the code
-and a [Mercurial][] repository to store it and protect against accidents. To
-deploy, I push my local changes to a private repository on [Bitbucket.org][],
-and then use [Fabric][] to pull those changes down to the server and restart
-if necessary.
-
-The site is hosted by [WebFaction][]. If you're looking for a web host for
-Django or Rails sites (or any other kind, really) you should definitely
-consider them. Not only do they make installing Django or Rails very easy,
-they're absurdly cheap: 10gb disk space and 600gb/month bandwidth is less than
-$10 a month. I'd recommend them to anyone.
-
-It's Open Source, Too!
-----------------------
-
-Want to see what makes this site tick? Want to make it tick more smoothly?
-Feel free to head over to <http://bitbucket.org/sjl/stevelosh> and take a look
-at the code.
-
-[Squarespace]: http://www.squarespace.com/
-[Python]: http://python.org
-[Django]: {{links.django}}
-[Blueprint]: http://www.blueprintcss.org/
-[Markdown]: {{links.markdown}}
-[WMD]: http://wmd-editor.com/
-[jQuery]: http://jquery.com
-[form validation]: http://bassistance.de/jquery-plugins/jquery-plugin-validation/
-[TextMate]: http://macromates.com/
-[Mercurial]: {{links.mercurial}}
-[Bitbucket.org]: http://www.bitbucket.org/
-[Fabric]: {{links.fabric}}
-[Mint]: http://haveamint.com/
-[WebFaction]: {{links.webfaction}}
-
-{% endblock %}
--- a/content/projects/t.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,257 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "t"
-    snip: "A command-line todo list manager for people that want to <em>finish</em> tasks, not organize them."
-    created: 2009-09-11 19:03:29
-%}
-
-{% block article %}
-
-`t` is a command-line todo list manager for people that want to *finish*
-tasks, not organize them.
-
-The code is in a [Mercurial repository][] on [BitBucket][].
-
-[BitBucket]: http://bitbucket.org/
-
-
-![Screenshot of t](/media/images/projects/t/t-screenshot.png "Screenshot of t")
-
-[TOC]
-
-Why t?
-------
-
-Yeah, I know, *another* command-line todo list manager. Several others already
-exist ([todo.txt][] and [TaskWarrior][] come to mind), so why make another
-one?
-
-[todo.txt]: http://ginatrapani.github.com/todo.txt-cli/
-[TaskWarrior]: http://taskwarrior.org/projects/show/taskwarrior/
-
-### It Does the Simplest Thing That Could Possibly Work
-
-Todo.txt and TaskWarrior are feature-packed. They let you tag tasks, split
-them into projects, set priorities, order them, color-code them, and much
-more.
-
-**That's the problem.**
-
-It's easy to say "I'll just organize my todo list a bit" and spend 15 minutes
-tagging your tasks. In those 15 minutes you probably could have *finished* a
-couple of them.
-
-`t` was inspired by [j][]. It's simple, messy, has almost no features, and is
-extremely effective at the one thing it does. With `t` the only way to make
-your todo list prettier is to **finish some damn tasks**.
-
-[j]: http://github.com/rupa/j2/
-
-### It's Flexible
-
-`t`'s simplicity makes it extremely flexible.
-
-Want to edit a bunch of tasks at once? Open the list in a text editor.
-
-Want to view the lists on a computer that doesn't have `t` installed? Open the
-list in a text editor.
-
-Want to synchronize the list across a couple of computers? Keep your task
-lists in a [Dropbox][] folder.
-
-Want to use it as a distributed bug tracking system like [BugsEverywhere][]?
-Make the task list a `bugs` file in the project repository.
-
-[Dropbox]: https://www.getdropbox.com/
-[BugsEverywhere]: http://bugseverywhere.org/
-
-### It Plays Nice with Version Control
-
-Other systems keep your tasks in a plain text file. This is a good thing, and
-`t` follows their lead.
-
-However, some of them append new tasks to the end of the file when you create
-them. This is not good if you're using a version control system to let more
-than one person edit a todo list. If two people add a task and then try to
-merge, they'll get a conflict and have to resolve it manually.
-
-`t` uses random IDs (actually SHA1 hashes) to order the todo list files. Once
-the list has a couple of tasks in it, adding more is far less likely to cause
-a merge conflict because the list is sorted.
-
-Installing t
-------------
-
-`t` requires [Python][] 2.5 or newer, and some form of UNIX-like shell (bash
-works well). It works on Linux, OS X, and Windows (with [Cygwin][]).
-
-[Python]: {{links.python}}
-[Cygwin]: http://www.cygwin.com/
-
-Installing and setting up `t` will take about one minute.
-
-First, [download][] the newest version or clone the Mercurial repository ( `hg
-clone http://bitbucket.org/sjl/t/` ). Put it anywhere you like.
-
-[download]: http://bitbucket.org/sjl/t/get/tip.zip
-
-Next, decide where you want to keep your todo lists. I put mine in `~/tasks`.
-Create that directory:
-
-    :::text
-    mkdir ~/tasks
-
-Finally, set up an alias to run `t`. Put something like this in your
-`~/.bashrc` file:
-
-    :::bash
-    alias t='python ~/path/to/t.py --task-dir ~/tasks --list tasks'
-
-Make sure you run `source ~/.bashrc` or restart your terminal window to make
-the alias take effect.
-
-Using t
--------
-
-`t` is quick and easy to use.
-
-### Add a Task
-
-To add a task, use `t [task description]`:
-
-    :::console
-    $ t Clean the apartment.
-    $ t Write chapter 10 of the novel.
-    $ t Buy more beer.
-    $
-
-### List Your Tasks
-
-Listing your tasks is even easier -- just use `t`:
-
-    :::console
-    $ t
-    9  - Buy more beer.
-    30 - Clean the apartment.
-    31 - Write chapter 10 of the novel.
-    $
-
-`t` will list all of your unfinished tasks and their IDs.
-
-### Finish a Task
-
-After you're done with something, use `t -f ID` to finish it:
-
-    :::console
-    $ t -f 31
-    $ t
-    9  - Buy more beer.
-    30 - Clean the apartment.
-    $
-
-### Edit a Task
-
-Sometimes you might want to change the wording of a task. You can use `t -e ID
-[new description]` to do that:
-
-    :::console
-    $ t -e 30 Clean the entire apartment.
-    $ t
-    9  - Buy more beer.
-    30 - Clean the entire apartment.
-    $
-
-Yes, nerds, you can use sed-style substitution strings:
-
-    :::console
-    $ t -e 9 /more/a lot more/
-    $ t
-    9  - Buy a lot more beer.
-    30 - Clean the entire apartment.
-    $
-
-### Delete the Task List if it's Empty
-
-If you keep your task list in a visible place (like your desktop) you might
-want it to be deleted if there are no tasks in it. To do this automatically
-you can use the `--delete-if-empty` option in your alias:
-
-    :::bash
-    alias t='python ~/path/to/t.py --task-dir ~/Desktop --list todo.txt --delete-if-empty'
-
-Tips and Tricks
----------------
-
-`t` might be simple, but it can do a lot of interesting things.
-
-### Count Your Tasks
-
-Counting your tasks is simple using the `wc` program:
-
-    :::console
-    $ t | wc -l
-          2
-    $
-
-### Put Your Task Count in Your Bash Prompt
-
-Want a count of your tasks right in your prompt?  Edit your `~/.bashrc` file:
-
-    :::bash
-    export PS1="[$(t | wc -l | sed -e's/ *//')] $PS1"
-
-Now you've got a prompt that looks something like this:
-
-    :::console
-    [2] $ t -f 30
-    [1] $ t Feed the cat.
-    [2] $
-
-### Multiple Lists
-
-`t` is for people that want to *do* tasks, not organize them. With that said,
-sometimes it's useful to be able to have at least *one* level of organization.
-To split up your tasks into different lists you can add a few more aliases:
-
-    :::bash
-    alias g='python ~/path/to/t.py --task-dir ~/tasks --list groceries'
-    alias m='python ~/path/to/t.py --task-dir ~/tasks --list music-to-buy'
-    alias w='python ~/path/to/t.py --task-dir ~/tasks --list wines-to-try'
-
-### Distributed Bugtracking
-
-Like the idea of distributed bug trackers like [BugsEverywhere][], but don't
-want to use such a heavyweight system? You can use `t` instead.
-
-Add another alias to your `~/.bashrc` file:
-
-    :::bash
-    alias b='python ~/path/to/t.py --task-dir . --list bugs'
-
-Now when you're in your project directory you can use `b` to manage the list
-of bugs/tasks for that project. Add the `bugs` file to version control and
-you're all set.
-
-Even people without `t` installed can view the bug list, because it's plain
-text.
-
-Problems, Contributions, Etc
-----------------------------
-
-`t` was hacked together in a couple of nights to fit my needs. If you use it
-and find a bug, please let me know.
-
-If you want to request a feature feel free, but remember that `t` is meant to
-be simple. If you need anything beyond the basics you might want to look at
-[todo.txt][] or [TaskWarrior][] instead. They're great tools with lots of
-bells and whistles.
-
-If you want to contribute code to `t`, that's great! Fork the [Mercurial
-repository][] on BitBucket or the [git mirror][] on GitHub and send me a pull
-request.
-
-[Mercurial repository]: http://bitbucket.org/sjl/t/
-[git mirror]: http://github.com/sjl/t/
-
-{% endblock %}
--- a/content/projects/threesome.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-    {% extends "_post.html" %}
-
-    {% hyde
-    title: "Threesome"
-    snip: "A Vim plugin for resolving three-way merge conflicts."
-    created: 2011-10-10 00:00:02
-    exclude: True
-    %}
-
-    {% block article %}
-
-Threesome is now called [Splice](/projects/splice/).
-
-    {% endblock %}
-
--- a/content/projects/typkov.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-title: "Typkov"
-snip: "Create typing lessons from your own writing."
-created: 2012-01-23 00:00:01
-exclude: False
-%}
-
-{% block article %}
-
-[Typkov](http://typkov.stevelosh.com) is a simple webapp that generates typing
-lessons from your own writing.
-
-Instead of practicing random words from the dictionary you can practice with the
-kind of stuff you actually write in real life. It works surprisingly well.
-
-It's open source (MIT/X11 licensed) on [BitBucket][] and [GitHub][].
-
-I also [recorded myself][rec] as I made the initial version, so if you like
-watching programmers work you might like that (though I'm pretty new to
-Clojure/Noir).
-
-[BitBucket]: http://bitbucket.org/sjl/typkov/
-[GitHub]: http://github.com/sjl/typkov/
-[rec]: http://youtu.be/uTwnoZEw7FE
-
-{% endblock %}
--- a/content/projects/vitality.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-title: "Vitality"
-snip: "Make Vim play nicely with iTerm 2 and tmux."
-created: 2012-04-12 20:00:01
-exclude: False
-%}
-
-{% block article %}
-
-[Vitality][] is a Vim plugin that makes Vim play more nicely with iTerm 2 and tmux.
-
-It's open source (MIT/X11 licensed) on [BitBucket][] and [GitHub][].
-
-[Vitality]: http://vim-doc.heroku.com/view?https://raw.github.com/sjl/vitality.vim/master/doc/vitality.txt
-[BitBucket]: http://bitbucket.org/sjl/vitality.vim/
-[GitHub]: http://github.com/sjl/vitality.vim/
-
-{% endblock %}
-
-
--- a/content/projects/women-in-water.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-{% extends "_post.html" %}
-
-{% hyde
-    title: "Women in Water"
-    snip: "Photographs of women in Lake Ontario."
-    created: 2009-08-04 18:57:36
-    exclude: True
-%}
-
-{% block article %}
-
-<div class="gallery">
-    <a href="/media/images/projects/{{ page.page_name }}/erin-tele.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/erin-tele-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/alex-tele.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/alex-tele-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/lizza-tele.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/lizza-tele-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/leah-tele.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/leah-tele-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/anna-tele.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/anna-tele-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/erin-wide.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/erin-wide-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/alex-wide.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/alex-wide-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/lizza-wide.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/lizza-wide-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/leah-wide.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/leah-wide-thumb.jpg" />
-    </a>
-    <a href="/media/images/projects/{{ page.page_name }}/anna-wide.jpg" rel="wiw">
-        <img src="/media/images/projects/{{ page.page_name }}/anna-wide-thumb.jpg" />
-    </a>
-</div>
-
-This is still a work in progress.
-
-{% endblock %}
--- a/content/resume.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,220 +0,0 @@
-{% extends "_flatpage.html" %}
-
-{% hyde
-    title: "Résumé"
-    exclude: True
-%}
-
-{% block article %}
-
-I'm Steve. I'm a programmer from Rochester, NY. I graduated from [Rochester
-Institute of Technology][rit] in 2008 with a Bachelor's degree in [Computer
-Science][ritcs].
-
-I'm currently most interested in rapid web development, version control, and
-artificial intelligence. I'm not looking for full time work at the moment but
-I'm available for interesting freelance projects.
-
-If you'd *really* like to get to know me you should look at the [projects][]
-and [blog posts][] I've written, or cut to the chase and look at my [code][].
-
-[rit]: http://rit.edu/
-[ritcs]: http://www.cs.rit.edu/
-[projects]: /projects/
-[blog posts]: /blog/
-[code]: http://bitbucket.org/sjl/
-
-## Skills & Interests
-
-I'm passionate about programming. It may sound odd, but there are aspects of
-programming that I find beautiful (in every sense of the word).
-
-### Languages
-
-My favorite programming language at the moment is [Python][]. It's elegant,
-readable, powerful, and makes it easy to *get things done*.
-
-I've also had experience with [Java][], [C][], [C++][], [Lisp][], [SQL][] and
-[PL/SQL][], [JavaScript][], [Groovy][], and [bash scripting][]. I've used a
-number of markup and templating languages, including [XHTML][], [XML][],
-[CSS][], [JSON][], [Markdown][], [Django][]'s template system, and [Jinja2][].
-
-In my free time I'm working on learning [R][].
-
-[Python]: http://www.python.org/
-[Java]: http://java.sun.com/
-[C]: http://en.wikipedia.org/wiki/C_(programming_language)
-[C++]: http://en.wikipedia.org/wiki/C%2B%2B
-[Lisp]: http://en.wikipedia.org/wiki/Lisp_(programming_language)
-[SQL]: http://en.wikipedia.org/wiki/SQL
-[PL/SQL]: http://en.wikipedia.org/wiki/PL/SQL
-[JavaScript]: http://en.wikipedia.org/wiki/JavaScript
-[Groovy]: http://groovy.codehaus.org/
-[bash scripting]: http://www.gnu.org/software/bash/
-[XHTML]: http://www.w3.org/TR/xhtml1/
-[XML]: http://www.w3.org/XML/
-[CSS]: http://www.w3.org/TR/CSS/
-[JSON]: http://www.json.org/
-[Markdown]: {{links.markdown}}
-[Jinja2]: http://jinja.pocoo.org/2/
-[R]: http://www.r-project.org/
-
-### Web Development
-
-For web development I gravitate toward the [Django][] framework. Django bills
-itself as "The Web framework for professionals with deadlines" and this
-strikes a chord with me.
-
-I've used the [CherryPy][] framework for smaller (but still dynamic) projects
-that don't need the additional functionality of Django.
-
-I hate writing repetitive, difficult-to-maintain code. Even when writing
-completely static websites I prefer to take advantage of templating languages.
-To do that I use [Hyde][] and [Blatter][], both of which generate static HTML
-from templates.
-
-I've used several CSS frameworks including [Blueprint][], [Tripoli][] and
-[aardvark legs][]. Of these I now prefer aardvark legs because it makes
-setting up a beautiful vertical rhythm simple and doesn't impose itself on the
-horizontal layout.
-
-When writing [JavaScript][] I use [jQuery][] to eliminate a lot of the
-tediousness and create elegant code.
-
-[Django]: {{links.django}}
-[CherryPy]: {{links.cherrypy}}
-[Blueprint]: http://www.blueprintcss.org/
-[Tripoli]: http://devkick.com/lab/tripoli/
-[aardvark legs]: {{links.aardvarklegs}}
-[Hyde]: http://github.com/lakshmivyas/hyde
-[Blatter]: {{links.blatter}}
-[jQuery]: http://jquery.com/
-
-### Version Control
-
-I think version control is essential for a project of almost any size, and
-lately the concepts behind it have captured my interest.
-
-In my personal work I use [Mercurial][] (usually with [BitBucket][]). I've
-[contributed][] several minor patches to the Mercurial core and written two
-extensions: [hg-prompt][] and [hg-paste][].
-
-I know my way around [Subversion][], [CVS][], and [git][] as well.
-
-[Mercurial]: {{links.mercurial}}
-[BitBucket]: http://bitbucket.org/
-[Subversion]: http://subversion.tigris.org/
-[CVS]: http://www.nongnu.org/cvs/
-[git]: http://git-scm.com/
-[contributed]: http://selenic.com/repo/hg/log?rev=Steve+Losh
-[hg-prompt]: /projects/hg-prompt/
-[hg-paste]: /projects/hg-paste/
-
-### How I Work
-
-For my personal work I use [Mac OS X][]. I'm comfortable in [Linux][] and can
-deal with [Windows][] (though I don't enjoy it).
-
-I use [TextMate][] and [vim][] for coding, [CSSEdit][] when designing,
-[Mercurial][] for version control, [t][] to manage my personal tasks, and
-deploy through [SSH][] with [fabric][].
-
-[Mac OS X]: http://www.apple.com/macosx/
-[TextMate]: http://macromates.com/
-[SSH]: http://en.wikipedia.org/wiki/Secure_Shell
-[fabric]: {{links.fabric}}
-[Linux]: http://www.linux.org/
-[Windows]: http://www.microsoft.com/WINDOWS/
-[vim]: http://www.vim.org/
-[CSSEdit]: http://macrabbit.com/cssedit/
-[t]: /projects/t/
-
-## Personal Projects
-
-You can find some of my pet projects on the [projects][] page.
-
-Lately I've been working on a few new things that aren't quite ready for
-general use, but are getting close:
-
-* [hg-review][]: a code-review extension for Mercurial.
-* [LindyHub][]: a site like BitBucket or GitHub for dancers.
-* [gorilla][]: a packaging system for Python.
-* [tinpan][]: a language-agnostic, vcs-agnostic continuous integration system.
-
-[hg-review]: http://bitbucket.org/sjl/hg-review/
-[LindyHub]: http://test.lindyhub.com/
-[gorilla]: http://bitbucket.org/sjl/gorilla/
-[tinpan]: http://bitbucket.org/sjl/tinpan/
-
-## Full-Time Work Experience
-
-I completed two six-month [co-ops][] while at [RIT][]. Since I graduated I've
-worked full time for about a year and a half.
-
-[co-ops]: https://www.rit.edu/about/coop_careers.html
-[RIT]: http://rit.edu/
-
-### Senior Software Engineer at [Dumbwaiter Design][DWD]
-
-*Henrietta, NY since January 2010.*
-
-At [Dumbwaiter][DWD] I work with our amazing designers to create beautiful websites backed by [Django][] and [Python][].
-
-[DWD]: http://dwaiter.com/
-
-### Software Engineer at [PAETEC][]
-
-*Fairport, NY from June 2008 to January 2010.*
-
-At [PAETEC][] I maintained and implemented new features for web applications
-in [Java][] using the [Oracle E-Business Suite][oebs] and worked on underlying
-[SQL][] and [PL/SQL][] code for our databases.
-
-[PAETEC]: http://paetec.com/
-[oebs]: http://www.oracle.com/applications/e-business-suite.html
-
-### Data Architecture Co-op at [Excellus BlueCross BlueShield][]
-
-*Rochester, NY from June 2007 to November 2007.*
-
-At [Excellus][] I developed software in [Java][] to interact with and manage
-databases of customer and provider information stored on a mainframe. I also
-created and updated [JUnit][] and [Jemmy][] tests for this software.
-
-[Excellus BlueCross BlueShield]: https://www.excellusbcbs.com/
-[Excellus]: https://www.excellusbcbs.com/
-[JUnit]: http://www.junit.org/
-[Jemmy]: http://jemmy.dev.java.net/
-
-### Managed Services Programmer at [RightNow Technologies][]
-
-*Pittsford, NY from June 2006 to November 2006.*
-
-At [RightNow][] I developed a set of tools to test the effectiveness of
-voice-automated telephone systems. These tools were written in a combination
-of [bash scripting][] and [Python][]. I assisted in generating statistics
-about the effectiveness of these systems for customers.
-
-[RightNow Technologies]: http://www.rightnow.com/
-[RightNow]: http://www.rightnow.com/
-
-## Contact Me
-
-If you'd like to get in touch with me, you can use any method you like.
-
-My **email address** is: <steve@stevelosh.com>  
-My **phone number** is: (570) 417-1392  
-My **skype username** is: steve.losh  
-My **mailing address** is: 150 Park Avenue, Apartment 7, Rochester, NY 14607
-
-You can also find me on [Twitter][], [Flickr][], [BitBucket][], [GitHub][],
-[BrightKite][], or [DjangoPeople][].
-
-[Twitter]: http://twitter.com/stevelosh/
-[Flickr]: http://www.flickr.com/photos/sjl7678/
-[BitBucket]: http://bitbucket.org/sjl/
-[GitHub]: http://github.com/sjl/
-[BrightKite]: http://brightkite.com/people/stevelosh/
-[DjangoPeople]: http://djangopeople.net/stevelosh/
-
-{% endblock %}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/content/resume/index.markdown	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,216 @@
++++
+date = "2010-09-20T12:34:11Z"
+draft = false
+title = "Résumé"
+
++++
+
+I'm Steve. I'm a programmer from Rochester, NY. I graduated from [Rochester
+Institute of Technology][rit] in 2008 with a Bachelor's degree in [Computer
+Science][ritcs].
+
+I'm currently most interested in rapid web development, version control, and
+artificial intelligence. I'm not looking for full time work at the moment but
+I'm available for interesting freelance projects.
+
+If you'd *really* like to get to know me you should look at the [projects][]
+and [blog posts][] I've written, or cut to the chase and look at my [code][].
+
+[rit]: http://rit.edu/
+[ritcs]: http://www.cs.rit.edu/
+[projects]: /projects/
+[blog posts]: /blog/
+[code]: http://bitbucket.org/sjl/
+
+## Skills & Interests
+
+I'm passionate about programming. It may sound odd, but there are aspects of
+programming that I find beautiful (in every sense of the word).
+
+### Languages
+
+My favorite programming language at the moment is [Python][]. It's elegant,
+readable, powerful, and makes it easy to *get things done*.
+
+I've also had experience with [Java][], [C][], [C++][], [Lisp][], [SQL][] and
+[PL/SQL][], [JavaScript][], [Groovy][], and [bash scripting][]. I've used a
+number of markup and templating languages, including [XHTML][], [XML][],
+[CSS][], [JSON][], [Markdown][], [Django][]'s template system, and [Jinja2][].
+
+In my free time I'm working on learning [R][].
+
+[Python]: http://www.python.org/
+[Java]: http://java.sun.com/
+[C]: http://en.wikipedia.org/wiki/C_(programming_language)
+[C++]: http://en.wikipedia.org/wiki/C%2B%2B
+[Lisp]: http://en.wikipedia.org/wiki/Lisp_(programming_language)
+[SQL]: http://en.wikipedia.org/wiki/SQL
+[PL/SQL]: http://en.wikipedia.org/wiki/PL/SQL
+[JavaScript]: http://en.wikipedia.org/wiki/JavaScript
+[Groovy]: http://groovy.codehaus.org/
+[bash scripting]: http://www.gnu.org/software/bash/
+[XHTML]: http://www.w3.org/TR/xhtml1/
+[XML]: http://www.w3.org/XML/
+[CSS]: http://www.w3.org/TR/CSS/
+[JSON]: http://www.json.org/
+[Markdown]: {{links.markdown}}
+[Jinja2]: http://jinja.pocoo.org/2/
+[R]: http://www.r-project.org/
+
+### Web Development
+
+For web development I gravitate toward the [Django][] framework. Django bills
+itself as "The Web framework for professionals with deadlines" and this
+strikes a chord with me.
+
+I've used the [CherryPy][] framework for smaller (but still dynamic) projects
+that don't need the additional functionality of Django.
+
+I hate writing repetitive, difficult-to-maintain code. Even when writing
+completely static websites I prefer to take advantage of templating languages.
+To do that I use [Hyde][] and [Blatter][], both of which generate static HTML
+from templates.
+
+I've used several CSS frameworks including [Blueprint][], [Tripoli][] and
+[aardvark legs][]. Of these I now prefer aardvark legs because it makes
+setting up a beautiful vertical rhythm simple and doesn't impose itself on the
+horizontal layout.
+
+When writing [JavaScript][] I use [jQuery][] to eliminate a lot of the
+tediousness and create elegant code.
+
+[Django]: {{links.django}}
+[CherryPy]: {{links.cherrypy}}
+[Blueprint]: http://www.blueprintcss.org/
+[Tripoli]: http://devkick.com/lab/tripoli/
+[aardvark legs]: {{links.aardvarklegs}}
+[Hyde]: http://github.com/lakshmivyas/hyde
+[Blatter]: {{links.blatter}}
+[jQuery]: http://jquery.com/
+
+### Version Control
+
+I think version control is essential for a project of almost any size, and
+lately the concepts behind it have captured my interest.
+
+In my personal work I use [Mercurial][] (usually with [BitBucket][]). I've
+[contributed][] several minor patches to the Mercurial core and written two
+extensions: [hg-prompt][] and [hg-paste][].
+
+I know my way around [Subversion][], [CVS][], and [git][] as well.
+
+[Mercurial]: {{links.mercurial}}
+[BitBucket]: http://bitbucket.org/
+[Subversion]: http://subversion.tigris.org/
+[CVS]: http://www.nongnu.org/cvs/
+[git]: http://git-scm.com/
+[contributed]: http://selenic.com/repo/hg/log?rev=Steve+Losh
+[hg-prompt]: /projects/hg-prompt/
+[hg-paste]: /projects/hg-paste/
+
+### How I Work
+
+For my personal work I use [Mac OS X][]. I'm comfortable in [Linux][] and can
+deal with [Windows][] (though I don't enjoy it).
+
+I use [TextMate][] and [vim][] for coding, [CSSEdit][] when designing,
+[Mercurial][] for version control, [t][] to manage my personal tasks, and
+deploy through [SSH][] with [fabric][].
+
+[Mac OS X]: http://www.apple.com/macosx/
+[TextMate]: http://macromates.com/
+[SSH]: http://en.wikipedia.org/wiki/Secure_Shell
+[fabric]: {{links.fabric}}
+[Linux]: http://www.linux.org/
+[Windows]: http://www.microsoft.com/WINDOWS/
+[vim]: http://www.vim.org/
+[CSSEdit]: http://macrabbit.com/cssedit/
+[t]: /projects/t/
+
+## Personal Projects
+
+You can find some of my pet projects on the [projects][] page.
+
+Lately I've been working on a few new things that aren't quite ready for
+general use, but are getting close:
+
+* [hg-review][]: a code-review extension for Mercurial.
+* [LindyHub][]: a site like BitBucket or GitHub for dancers.
+* [gorilla][]: a packaging system for Python.
+* [tinpan][]: a language-agnostic, vcs-agnostic continuous integration system.
+
+[hg-review]: http://bitbucket.org/sjl/hg-review/
+[LindyHub]: http://test.lindyhub.com/
+[gorilla]: http://bitbucket.org/sjl/gorilla/
+[tinpan]: http://bitbucket.org/sjl/tinpan/
+
+## Full-Time Work Experience
+
+I completed two six-month [co-ops][] while at [RIT][]. Since I graduated I've
+worked full time for about a year and a half.
+
+[co-ops]: https://www.rit.edu/about/coop_careers.html
+[RIT]: http://rit.edu/
+
+### Senior Software Engineer at [Dumbwaiter Design][DWD]
+
+*Henrietta, NY since January 2010.*
+
+At [Dumbwaiter][DWD] I work with our amazing designers to create beautiful websites backed by [Django][] and [Python][].
+
+[DWD]: http://dwaiter.com/
+
+### Software Engineer at [PAETEC][]
+
+*Fairport, NY from June 2008 to January 2010.*
+
+At [PAETEC][] I maintained and implemented new features for web applications
+in [Java][] using the [Oracle E-Business Suite][oebs] and worked on underlying
+[SQL][] and [PL/SQL][] code for our databases.
+
+[PAETEC]: http://paetec.com/
+[oebs]: http://www.oracle.com/applications/e-business-suite.html
+
+### Data Architecture Co-op at [Excellus BlueCross BlueShield][]
+
+*Rochester, NY from June 2007 to November 2007.*
+
+At [Excellus][] I developed software in [Java][] to interact with and manage
+databases of customer and provider information stored on a mainframe. I also
+created and updated [JUnit][] and [Jemmy][] tests for this software.
+
+[Excellus BlueCross BlueShield]: https://www.excellusbcbs.com/
+[Excellus]: https://www.excellusbcbs.com/
+[JUnit]: http://www.junit.org/
+[Jemmy]: http://jemmy.dev.java.net/
+
+### Managed Services Programmer at [RightNow Technologies][]
+
+*Pittsford, NY from June 2006 to November 2006.*
+
+At [RightNow][] I developed a set of tools to test the effectiveness of
+voice-automated telephone systems. These tools were written in a combination
+of [bash scripting][] and [Python][]. I assisted in generating statistics
+about the effectiveness of these systems for customers.
+
+[RightNow Technologies]: http://www.rightnow.com/
+[RightNow]: http://www.rightnow.com/
+
+## Contact Me
+
+If you'd like to get in touch with me, you can use any method you like.
+
+My **email address** is: <steve@stevelosh.com>  
+My **phone number** is: (570) 417-1392  
+My **skype username** is: steve.losh  
+My **mailing address** is: 150 Park Avenue, Apartment 7, Rochester, NY 14607
+
+You can also find me on [Twitter][], [Flickr][], [BitBucket][], [GitHub][],
+[BrightKite][], or [DjangoPeople][].
+
+[Twitter]: http://twitter.com/stevelosh/
+[Flickr]: http://www.flickr.com/photos/sjl7678/
+[BitBucket]: http://bitbucket.org/sjl/
+[GitHub]: http://github.com/sjl/
+[BrightKite]: http://brightkite.com/people/stevelosh/
+[DjangoPeople]: http://djangopeople.net/stevelosh/
--- a/custom/processors.py	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,22 +0,0 @@
-import os
-import sys
-from django.conf import settings
-from hydeengine.file_system import File
-from subprocess import check_output, CalledProcessError
-
-class Wisp:
-    @staticmethod
-    def process(resource):
-        wisp = settings.WISP_PATH
-        if not wisp or not os.path.exists(wisp):
-            raise ValueError("Wisp cannot be found at [%s]" % wisp)
-
-        try:
-            data = check_output([wisp, "-c", resource.source_file.path]).decode('utf-8')
-        except CalledProcessError, e:
-            print 'Syntax Error when calling Wisp:', e
-            return None
-
-        out_file = File(resource.source_file.path_without_extension + ".js")
-        resource.source_file = out_file
-        resource.source_file.write(data)
--- a/custom/templatetags/mathjax.py	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,9 +0,0 @@
-from django import template
-
-register = template.Library()
-
-
-def mathjax(value):
-    return "<div>$$ " + value + " $$</div>"
-
-register.filter('mathjax', mathjax)
--- a/layout/_flatpage.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,13 +0,0 @@
-{% extends "skeleton/_base.html" %}
-
-{% block content %}
-    <div id="leaf-title"><h1>{{ page.title|safe|typogrify }}</h1></div>
-    
-    <div id="leaf-content">
-        {% filter typogrify %}
-            {% markdown toc def_list %}
-                {% block article %}{% endblock %}
-            {% endmarkdown %}
-        {% endfilter %}
-    </div>
-{% endblock %}
\ No newline at end of file
--- a/layout/_post.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-{% extends "skeleton/_base.html" %}
-
-{% block extra_css %}
-    <link rel="stylesheet"
-          href="{{ site.url }}/media/css/pygments-clean.css"
-          type="text/css" media="screen" charset="utf-8" />
-{% endblock %}
-
-{% block content %}
-    <div id="leaf-title">
-        <h1><a href="{{ page.url }}">{{ page.title|safe|typogrify }}</a></h1>
-    </div>
-
-
-    <div id="leaf-stats" class="group">
-        <p>
-            Posted
-            <span class="timeago"
-                  title="{{ page.created|date:"Y-m-d" }}T{{ page.created|date:"H:i:s" }}-0000">
-            </span>
-            on {{ page.created|date:"F j, Y" }}.
-        </p>
-    </div>
-
-    <div id="leaf-content" class="{% block article_class %}{% endblock %}">
-        {% filter typogrify %}
-            {% article %}
-                {% filter typogrify %}
-                    {% markdown toc def_list codehilite %}
-                        {% block article %}{% endblock %}
-                    {% endmarkdown %}
-                {% endfilter %}
-            {% endarticle %}
-        {% endfilter %}
-    </div>
-{% endblock %}
--- a/layout/_splash.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-{% extends "skeleton/_base.html" %}
-
-{% block title %}{{ site.name }}{% endblock %}
-
-{% block content %}
-    <div class="splash vcard">
-        {% filter typogrify %}
-            <p>
-                Hello,
-                I'm
-                <a href="{{ site.full_url }}" class="fn url">Steve<span class="last-name"> Losh</span></a>.
-            </p>
-
-            <p>
-                I'm a
-                <span class="role">programmer, photographer, dancer &amp; bassist</span>
-                currently living in
-                <span class="adr"><span class="locality">Reykjavík</span>, <span class="region">Iceland</span></span>.
-            </p>
-
-            <p>
-                If you want to get in touch with me,
-                <a class="email" href="mailto:steve@stevelosh.com">email</a>
-                is best.
-            </p>
-        {% endfilter %}
-    </div>
-{% endblock %}
--- a/layout/skeleton/_atom.xml	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-{% spaceless %}
-
-<feed xmlns="http://www.w3.org/2005/Atom">
-    <title>{% block title %}{{ site.name }}{% endblock title %}</title>
-    
-    {% block self_url %}
-        <link href="{{ page.node.full_url }}/feed/" rel="self" />
-    {% endblock %}
-    
-    {% block site_url %}
-        <link href="{{ site.full_url }}"/>
-    {% endblock %}
-    
-    {% block feed_extra %}{% endblock %}
-    
-    <updated>{{ now|xmldatetime }}</updated>
-    
-    <id>{{ site.full_url }}/</id>
-    
-    {% recent_posts recents 4 page.blog_node %}
-
-    {% for post in recents %}
-        {% if not post.listing and not post.exclude %}
-            <entry>
-                <title type="html">{{ post.title }}</title>
-                <author><name>{{ site.author }}</name></author>
-                <link href="{{ post.full_url }}"/>
-                <updated>{{ post.created|xmldatetime }}</updated>
-                <published>{{ post.created|xmldatetime }}</published>
-                <id>{{ post.full_url }}</id>
-                {% block entry_extra %}{% endblock %}
-                <content type="html">
-                    {% filter force_escape %}
-                        {% render_article post %}
-                    {% endfilter %}
-                </content>
-            </entry>
-        {% endif %}
-    {% endfor %}
-</feed>
-
-{% endspaceless %}
--- a/layout/skeleton/_base.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,98 +0,0 @@
-{% extends "skeleton/_root.html" %}
-{% block all %}
-<!DOCTYPE html>
-<html>
-    <head>
-        <link href='http://fonts.googleapis.com/css?family=OFL+Sorts+Mill+Goudy+TT:regular,italic' rel='stylesheet' type='text/css' />
-        <link rel="profile" href="http://microformats.org/profile/hcard" />
-        <meta charset="utf-8">
-
-        <title>{% block title %}{% block extra_title %}{% endblock %}{{ page.title|safe }} / {{ site.name }}{% endblock %}</title>
-
-        {% block feeds %}
-            <link href="http://feeds2.feedburner.com/stevelosh"
-                  rel="alternate" title="{{ site.name }}"
-                  type="application/atom+xml" />
-        {% endblock %}
-
-        {% block css %}
-            <link rel="stylesheet" href="/media/css/aal.css"      type="text/css" media="screen" charset="utf-8" />
-            <link rel="stylesheet" href="/media/css/sjl.css"      type="text/css" media="screen" charset="utf-8" />
-            <link rel="stylesheet" href="/media/css/print.css"    type="text/css" media="print" charset="utf-8" />
-            {% block extra_css %}{% endblock %}
-        {% endblock %}
-
-        {% block js %}
-            <script data-cfasync="false" src="/media/js/jquery.js" type="text/javascript"></script>
-            <script data-cfasync="false" src="/media/js/jquery.timeago.js" type="text/javascript"></script>
-            <script data-cfasync="false" src="/media/js/sjl.js" type="text/javascript"></script>
-            <script data-cfasync="false" src="/media/js/print.js" type="text/javascript"></script>
-            <script data-cfasync="false" type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
-
-            {% block extra_js %}{% endblock %}
-        {% endblock %}
-
-        <link rel="openid.server" href="http://www.myopenid.com/server" />
-        <link rel="openid.delegate" href="http://stevelosh.myopenid.com/" />
-
-        <script type="text/javascript">
-          var _gaq = _gaq || [];
-          _gaq.push(['_setAccount', 'UA-15328874-2']);
-          _gaq.push(['_trackPageview']);
-
-          (function() {
-            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
-            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
-            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
-          })();
-        </script>
-
-    </head>
-
-    <body>
-        <div class="wrap">
-            <div class="top group">
-                <header>
-                    <a href="/">steve losh</a>
-                </header>
-
-                <nav>
-                    <a href="/blog/">Blog</a>
-                    <span class="sep">-</span>
-                    <a href="/projects">Projects</a>
-                    <span class="sep">-</span>
-                    <a href="/links">Links</a>
-                    <span class="sep">-</span>
-                    <a href="/about/">About</a>
-                    <span class="sep">-</span>
-                    <a href="http://feeds2.feedburner.com/stevelosh">Feed</a>
-                </nav>
-            </div>
-
-            <div class="hr">&nbsp;</div>
-
-            <div class="content">
-                {% with page.node.ancestors|last as parent_node %}
-                    {% with parent_node.url as parent_url %}
-                        {% block content %}{% endblock %}
-                    {% endwith %}
-                {% endwith %}
-            </div>
-
-            <div class="hrb">&nbsp;</div>
-
-            <footer>
-                <p>
-                    <a href="https://bitbucket.org/sjl/">Bitbucket</a> ・ 
-                    <a href="https://github.com/sjl/">GitHub</a> ・ 
-                    <a href="https://twitter.com/stevelosh/">Twitter</a> ・ 
-                    <a href="https://instagram.com/thirtytwobirds/">Instagram</a> ・ 
-                    <a href="https://bitbucket.org/sjl/.plan/#readme">.plan</a>
-                </p>
-
-                <a class="rochester-made" href="http://rochestermade.com" title="Rochester Made"><img src="http://rochestermade.com/media/images/rochester-made-dark-on-light.png" alt="Rochester Made" title="Rochester Made" /></a>
-            </footer>
-        </div>
-    </body>
-</html>
-{% endblock %}
--- a/layout/skeleton/_body.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-{% extends "skeleton/_base.html" %}
-
-{% block title %}{{site.name}} / {{ page.title }}{% endblock %}
-
-{% block content %}
-    {% block content_body %}{% endblock %}
-{% endblock %}
\ No newline at end of file
--- a/layout/skeleton/_index.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-{% extends "skeleton/_base.html" %}
-
-{% block content %}
-    {% for node in page.node.walk %}
-        {% include "skeleton/_innerindex.html" %}
-    {% endfor %} 
-{% endblock %}
\ No newline at end of file
--- a/layout/skeleton/_innerindex.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-{% extends "skeleton/_root.html" %}
-
-{% block all %}
-{%spaceless%}
-{% for list_page in node.pages %}
-    {% ifnotequal list_page node.listing_page %}
-        {% if not list_page.exclude %}
-            <div class="article">
-                <div class="title">
-                    {% with list_page.name_without_extension|remove_date_prefix|unslugify as default_title %}
-                        <h3>
-                            <a href="{{list_page.url}}">
-                                {{ list_page.title|default_if_none:default_title }}
-                            </a>
-                        </h3>
-                        {% if list_page.created %}
-                            <span>{{ list_page.created }}</span>
-                        {% endif %}
-                    {%endwith%}
-                </div>
-                {% render_article list_page %}
-            </div>
-        {%endif%}
-    {% endifnotequal %}
-{% endfor %}
-{%endspaceless%}
-{% endblock %}
\ No newline at end of file
--- a/layout/skeleton/_innerlisting.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-{% extends "skeleton/_root.html" %}
-
-{% block all %}
-{%spaceless%}
-
-{% for list_page in node.pages %}
-    {% ifnotequal list_page node.listing_page %}
-        {% if not list_page.exclude %}
-            {% include "skeleton/_listingitem.html" %}
-        {%endif%}
-    {% endifnotequal %}
-{% endfor %}
-
-{%endspaceless%}
-{% endblock %}
\ No newline at end of file
--- a/layout/skeleton/_listing.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-{% extends "skeleton/_base.html"%}
-
-{% block content %}
-    <div class="section-listing">
-        <ol class="group">
-            {% for node in page.node.walk reversed %}
-                {% include "skeleton/_innerlisting.html" %}
-            {% endfor %}
-        </ol>
-    </div>
-{% endblock %}
--- a/layout/skeleton/_listingitem.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,8 +0,0 @@
-<li>
-    <a href="{{ list_page.url }}">
-        {% with list_page.name_without_extension|remove_date_prefix|unslugify as default_title %}
-            {{ list_page.title|default_if_none:default_title|safe|typogrify }}
-        {%endwith%}
-    </a>
-    <span class="snip">{{ list_page.snip|safe|typogrify }}</span>
-</li>
--- a/layout/skeleton/_root.html	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-{% block all %}{% endblock %}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/layouts/shortcodes/toc.html	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,1 @@
+{{ .Page.TableOfContents }}
--- a/media/css/aal.css	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,115 +0,0 @@
-/* 
-  aardvark.legs originally by Anatoli Papirovski - http://fecklessmind.com/
-  Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php
-*/
-
-/* 
-  Reset first. Modified version of Eric Meyer and Paul Chaplin reset 
-  from http://meyerweb.com/eric/tools/css/reset/ 
-*/
-html, body, div, span, applet, object, iframe,
-h1, h2, h3, h4, h5, h6, p, blockquote, pre,
-a, abbr, acronym, address, big, cite, code,
-del, dfn, em, font, img, ins, kbd, q, s, samp,
-small, strike, strong, sub, sup, tt, var,
-b, u, i, center,
-dl, dt, dd, ol, ul, li,
-fieldset, form, label, legend,
-table, caption, tbody, tfoot, thead, tr, th, td,
-header, nav, section, article, aside, footer
-{border: 0; margin: 0; outline: 0; padding: 0; background: transparent; vertical-align: baseline;}
-
-article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section { 
-    display:block;
-}
-
-blockquote, q {quotes: none;}
-blockquote:before,blockquote:after,q:before,q:after {content: ''; content: none;}
-
-header, nav, section, article, aside, footer {display: block;}
-
-/* Basic styles */
-html {overflow-y: scroll;}
-body {background: #fdfdfd; color: #353535; font: normal 18px/25px Palatino, "Palatino Linotype", serif; text-rendering: optimizeLegibility;}
-html>body {font-size: 18px; line-height: 25px;}
-
-img {display: inline-block; vertical-align: bottom;}
-
-h1,h2,h3,h4,h5,h6,strong,b,dt,th {font-weight: 700;}
-address,cite,em,i,caption,dfn,var {font-style: italic;}
-
-h1 { font-size: 45px; line-height: 50px; margin: 25px 0; }
-h2 { font-size: 32px; line-height: 50px; margin: 25px 0; }
-h3 { font-size: 23px; line-height: 25px; margin: 25px 0; }
-h4 {margin: 0 0 22px; font-size: 16px; line-height: 22px;}
-h5 {margin: 0 0 22px; font-size: 14px; line-height: 22px;}
-h6 {margin: 0 0 22px; font-size: 12px; line-height: 22px;}
-
-p,ul,ol,dl,blockquote,pre {margin: 0 0 25px;}
-
-li ul,li ol {margin: 0;}
-ul {list-style: outside disc;}
-ol {list-style: outside decimal;}
-li {margin: 0 0 0 44px;}
-dd {padding-left: 25px;}
-blockquote {padding: 0 25px;}
-
-a {text-decoration: underline;}
-a:hover {text-decoration: none;}
-abbr,acronym {border-bottom: 1px dotted; cursor: help;}
-del {text-decoration: line-through;}
-ins {text-decoration: overline;}
-sub {font-size: 14px; line-height: 25px; vertical-align: sub;}
-sup {font-size: 14px; line-height: 25px; vertical-align: super;}
-
-tt,code,kbd,samp,pre {font-size: 14px; line-height: 25px; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;}
-
-/* Table styles */
-/* TODO */
-table {border-collapse: collapse; border-spacing: 0; margin: 0 0 1.5em;}
-caption {text-align: left;}
-th, td {padding: .25em .5em;}
-tbody td, tbody th {border: 1px solid #222;}
-tfoot {font-style: italic;}
-
-/* Form styles */
-/* TODO */
-fieldset {clear: both;}
-legend {padding: 0 0 1.286em; font-size: 1.167em; font-weight: 700;}
-fieldset fieldset legend {padding: 0 0 1.5em; font-size: 1em;}
-* html legend {margin-left: -7px;}
-*+html legend {margin-left: -7px;}
-
-form .field, form .buttons {clear: both; margin: 0 0 1.5em;}
-form .field label {display: block;}
-form ul.fields li {list-style-type: none; margin: 0;}
-form ul.inline li, form ul.inline label {display: inline;}
-form ul.inline li {padding: 0 .75em 0 0;}
-
-input.radio, input.checkbox {vertical-align: top;}
-label, button, input.submit, input.image {cursor: pointer;}
-* html input.radio, * html input.checkbox {vertical-align: middle;}
-*+html input.radio, *+html input.checkbox {vertical-align: middle;}
-
-textarea {overflow: auto;}
-input.text, input.password, textarea, select {margin: 0; font: 1em/1.3 Helvetica, Arial, "Liberation Sans", "Bitstream Vera Sans", sans-serif; vertical-align: baseline;}
-input.text, input.password, textarea {border: 1px solid #444; border-bottom-color: #666; border-right-color: #666; padding: 2px;}
-
-* html button {margin: 0 .34em 0 0;}
-*+html button {margin: 0 .34em 0 0;}
-
-form.horizontal .field {padding-left: 150px;}
-form.horizontal .field label {display: inline; float: left; width: 140px; margin-left: -150px;}
-
-/* Useful classes */
-/* TODO */
-img.left {display: inline; float: left; margin: 0 1.5em .75em 0;}
-img.right {display: inline; float: right; margin: 0 0 .75em .75em;}
-.group:after {
-    content: ".";
-    display: block;
-    height: 0;
-    clear: both;
-    visibility: hidden;
-}
-
--- a/media/css/print.less	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-body {
-    font: normal 10pt/1.25 Palatino, "Palatino Linotype";
-    text-rendering: optimizeLegibility;
-}
-
-nav, header, .toc {
-    display: none;
-}
-#leaf-title {
-    a {
-        text-decoration: none;
-        color: black;
-    }
-}
-#leaf-content {
-    ul.print-links {
-        display: block;
-        font-size: 1em;
-        list-style-type: none;
-        margin-left: 0em;
-
-        a {
-            text-decoration: none;
-        }
-    }
-    code, pre {
-        font: normal 9pt Menlo, Monaco, Consolas, "Courier New", Courier, monospace;
-    }
-    img {
-        display: block;
-        margin-left: auto;
-        margin-right: auto;
-        border: 1.43em solid #e5e5e5;
-        padding: 1px;
-        background: black;
-    }
-    img.left, img.right {
-        border: none;
-        background: none;
-        padding: none;
-    }
-    img.left {
-         margin: 0 1.5em 1em 0;
-         float: left;
-    }
-    img.right {
-        margin: 0 0 .75em 1em;
-        float: right;
-    }
-}
-div#leaf-content.with-diagrams img {
-    display: block;
-    margin-left: auto;
-    margin-right: auto;
-    background: none;
-    border: none;
-}
-span.amp {
-    font-family: "Palatino", "Constantia", "Palatino Linotype", serif;
-    font-style: italic;
-}
-a {
-    text-decoration: underline;
-    color: #c06;
-}
-footer {
-    display: none;
-}
--- a/media/css/pygments-clean.css	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/* @override http://localhost:8080/media/css/pygments-monokai-light.css */
-.codehilite .hll { background-color: #49483e }
-.codehilite .err { color: #fff; background-color: #f00 } /* Error */
-.codehilite .k { color: #111} /* Keyword */
-.codehilite .l { color: #111 } /* Literal */
-.codehilite .n { color: #111 } /* Name */
-.codehilite .o { color: #111 } /* Operator */
-.codehilite .p { color: #111 } /* Punctuation */
-.codehilite .c  { color: #714678; font-style: italic; font-weight: bold; } /* Comment */
-.codehilite .cm { color: #714678; font-style: italic; font-weight: bold; } /* Comment.Multiline */
-.codehilite .cp { color: #714678; font-style: italic; font-weight: bold; } /* Comment.Preproc */
-.codehilite .c1 { color: #714678; font-style: italic; font-weight: bold; } /* Comment.Single */
-.codehilite .cs { color: #714678; font-style: italic; font-weight: bold; } /* Comment.Special */
-.codehilite .ge { font-style: italic } /* Generic.Emph */
-.codehilite .gs { font-weight: bold } /* Generic.Strong */
-.codehilite .kc { color: #111 } /* Keyword.Constant */
-.codehilite .kd { color: #111 } /* Keyword.Declaration */
-.codehilite .kn { color: #111 } /* Keyword.Namespace */
-.codehilite .kp { color: #111 } /* Keyword.Pseudo */
-.codehilite .kr { color: #111 } /* Keyword.Reserved */
-.codehilite .kt { color: #111 } /* Keyword.Type */
-.codehilite .ld { color: #111 } /* Literal.Date */
-.codehilite .m { color: #111 } /* Literal.Number */
-.codehilite .s { color: #111} /* Literal.String */
-.codehilite .na { color: #111 } /* Name.Attribute */
-.codehilite .nb { color: #111 } /* Name.Builtin */
-.codehilite .nc { color: #111 } /* Name.Class */
-.codehilite .no { color: #111 } /* Name.Constant */
-.codehilite .nd { color: #111 } /* Name.Decorator */
-.codehilite .ni { color: #111 } /* Name.Entity */
-.codehilite .ne { color: #111 } /* Name.Exception */
-.codehilite .nf { color: #111} /* Name.Function */
-.codehilite .nl { color: #111 } /* Name.Label */
-.codehilite .nn { color: #111} /* Name.Namespace */
-.codehilite .nx { color: #111 } /* Name.Other */
-.codehilite .py { color: #111 } /* Name.Property */
-.codehilite .nt { color: #111 } /* Name.Tag */
-.codehilite .nv { color: #111 } /* Name.Variable */
-.codehilite .ow { color: #111 } /* Operator.Word */
-.codehilite .w { color: #111 } /* Text.Whitespace */
-.codehilite .mf { color: #111 } /* Literal.Number.Float */
-.codehilite .mh { color: #111 } /* Literal.Number.Hex */
-.codehilite .mi { color: #111 } /* Literal.Number.Integer */
-.codehilite .mo { color: #111 } /* Literal.Number.Oct */
-.codehilite .sb { color: #111 } /* Literal.String.Backtick */
-.codehilite .sc { color: #111 } /* Literal.String.Char */
-.codehilite .sd { color: #111 } /* Literal.String.Doc */
-.codehilite .s2 { color: #111 } /* Literal.String.Double */
-.codehilite .se { color: #111 } /* Literal.String.Escape */
-.codehilite .sh { color: #111 } /* Literal.String.Heredoc */
-.codehilite .si { color: #111 } /* Literal.String.Interpol */
-.codehilite .sx { color: #111 } /* Literal.String.Other */
-.codehilite .sr { color: #111 } /* Literal.String.Regex */
-.codehilite .s1 { color: #111 } /* Literal.String.Single */
-.codehilite .ss { color: #111 } /* Literal.String.Symbol */
-.codehilite .bp { color: #111 } /* Name.Builtin.Pseudo */
-.codehilite .vc { color: #111 } /* Name.Variable.Class */
-.codehilite .vg { color: #111 } /* Name.Variable.Global */
-.codehilite .vi { color: #111 } /* Name.Variable.Instance */
-.codehilite .il { color: #111 } /* Literal.Number.Integer.Long */
--- a/media/css/pygments-monokai-light.css	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,60 +0,0 @@
-/* @override http://localhost:8080/media/css/pygments-monokai-light.css */
-.codehilite .hll { background-color: #49483e }
-.codehilite .c { color: #7A7663 } /* Comment */
-.codehilite .err { color: #960050; background-color: #1e0010 } /* Error */
-.codehilite .k { color: #00a8c8} /* Keyword */
-.codehilite .l { color: #ae81ff } /* Literal */
-.codehilite .n { color: #111111 } /* Name */
-.codehilite .o { color: #f92672 } /* Operator */
-.codehilite .p { color: #111111 } /* Punctuation */
-.codehilite .cm { color: #75715e } /* Comment.Multiline */
-.codehilite .cp { color: #75715e } /* Comment.Preproc */
-.codehilite .c1 { color: #75715e } /* Comment.Single */
-.codehilite .cs { color: #75715e } /* Comment.Special */
-.codehilite .ge { font-style: italic } /* Generic.Emph */
-.codehilite .gs { font-weight: bold } /* Generic.Strong */
-.codehilite .kc { color: #00a8c8 } /* Keyword.Constant */
-.codehilite .kd { color: #00a8c8 } /* Keyword.Declaration */
-.codehilite .kn { color: #f92672 } /* Keyword.Namespace */
-.codehilite .kp { color: #00a8c8 } /* Keyword.Pseudo */
-.codehilite .kr { color: #00a8c8 } /* Keyword.Reserved */
-.codehilite .kt { color: #00a8c8 } /* Keyword.Type */
-.codehilite .ld { color: #d88200 } /* Literal.Date */
-.codehilite .m { color: #ae81ff } /* Literal.Number */
-.codehilite .s { color: #d88200} /* Literal.String */
-.codehilite .na { color: #75af00 } /* Name.Attribute */
-.codehilite .nb { color: #111111 } /* Name.Builtin */
-.codehilite .nc { color: #75af00 } /* Name.Class */
-.codehilite .no { color: #00a8c8 } /* Name.Constant */
-.codehilite .nd { color: #75af00 } /* Name.Decorator */
-.codehilite .ni { color: #111111 } /* Name.Entity */
-.codehilite .ne { color: #75af00 } /* Name.Exception */
-.codehilite .nf { color: #75af00} /* Name.Function */
-.codehilite .nl { color: #111111 } /* Name.Label */
-.codehilite .nn { color: #111111} /* Name.Namespace */
-.codehilite .nx { color: #111111 } /* Name.Other */
-.codehilite .py { color: #111111 } /* Name.Property */
-.codehilite .nt { color: #f92672 } /* Name.Tag */
-.codehilite .nv { color: #111111 } /* Name.Variable */
-.codehilite .ow { color: #f92672 } /* Operator.Word */
-.codehilite .w { color: #111111 } /* Text.Whitespace */
-.codehilite .mf { color: #ae81ff } /* Literal.Number.Float */
-.codehilite .mh { color: #ae81ff } /* Literal.Number.Hex */
-.codehilite .mi { color: #ae81ff } /* Literal.Number.Integer */
-.codehilite .mo { color: #ae81ff } /* Literal.Number.Oct */
-.codehilite .sb { color: #d88200 } /* Literal.String.Backtick */
-.codehilite .sc { color: #d88200 } /* Literal.String.Char */
-.codehilite .sd { color: #d88200 } /* Literal.String.Doc */
-.codehilite .s2 { color: #d88200 } /* Literal.String.Double */
-.codehilite .se { color: #8045FF } /* Literal.String.Escape */
-.codehilite .sh { color: #d88200 } /* Literal.String.Heredoc */
-.codehilite .si { color: #d88200 } /* Literal.String.Interpol */
-.codehilite .sx { color: #d88200 } /* Literal.String.Other */
-.codehilite .sr { color: #d88200 } /* Literal.String.Regex */
-.codehilite .s1 { color: #d88200 } /* Literal.String.Single */
-.codehilite .ss { color: #d88200 } /* Literal.String.Symbol */
-.codehilite .bp { color: #111111 } /* Name.Builtin.Pseudo */
-.codehilite .vc { color: #111111 } /* Name.Variable.Class */
-.codehilite .vg { color: #111111 } /* Name.Variable.Global */
-.codehilite .vi { color: #111111 } /* Name.Variable.Instance */
-.codehilite .il { color: #ae81ff } /* Literal.Number.Integer.Long */
--- a/media/css/sjl.less	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,362 +0,0 @@
-@c-link: #e50053;
-@c-body: #222;
-@w-body: 612px;
-@font-fancy: 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
-
-html {
-    overflow-y: scroll;
-}
-body {
-    text-rendering: optimizeLegibility;
-    color: @c-body;
-    position: relative;
-
-    a {
-        text-decoration: none;
-        color: @c-link;
-
-        &:hover {
-            text-decoration: underline;
-        }
-    }
-    h1, h2, h3, h4, h5, h6 {
-        font-family: @font-fancy;
-        font-weight: normal;
-
-        a {
-            color: @c-body;
-
-            &:hover {
-                color: @c-link;
-                text-decoration: none;
-            }
-        }
-        .amp {
-            font-style: italic;
-        }
-    }
-    h1 { font-size: 45px; line-height: 50px; margin: 25px 0; } // 3
-    h2 { font-size: 32px; line-height: 50px; margin: 25px 0; } // m7
-    h3 { font-size: 23px; line-height: 25px; margin: 25px 0; } // 3
-    h4 { font-size: 18px; line-height: 25px; margin: 25px 0; font-weight: bold; } // r
-    code, pre {
-        font-family: Consolas, Menlo, "Courier New", monospace;
-        font-size: 14px;
-    }
-    div.threejs {
-        margin-bottom: 16px;
-
-        canvas {
-            border: 1px solid #222222;
-        }
-        div {
-            text-align: center;
-        }
-    }
-    .codehilite {
-        code, pre {
-            font-family: Consolas, Menlo, "Courier New", monospace;
-            font-size: 16px;
-            line-height: 25px;
-
-            overflow-x: auto;
-
-            border: 1px solid #d5d5d5;
-            border-left: 10px solid #d5d5d5;
-            background-color: #fafafa;
-
-            padding: 11px 15px 12px;
-            margin-left: -25px;
-        }
-        pre::-webkit-scrollbar {
-            height: 25px;
-        }
-        pre::-webkit-scrollbar-button:start,
-        pre::-webkit-scrollbar-button:end {
-            display: none;
-        }
-        pre::-webkit-scrollbar-track-piece  {
-            background-color: #eee;
-        }
-        pre::-webkit-scrollbar-thumb {
-            background-color: #bbb;
-            border: 7px solid #eee;
-            -webkit-background-clip: padding-box;
-            -webkit-border-radius: 12px;
-        }
-    }
-    pre.lineart {
-        font-family: Consolas, Menlo, "Courier New", monospace;
-        font-size: 16px;
-        line-height: 20px;
-        border: none;
-    }
-    p code, li code, table code {
-        border: 1px solid #ccc;
-        background-color: #fafafa;
-        font-size: 13px;
-        padding: 1px 3px;
-        line-height: 20px;
-        margin: 0;
-        white-space: nowrap;
-    }
-
-    .wrap {
-        width: @w-body;
-        margin: 0 auto;
-        margin-bottom: 5em;
-
-        .top {
-            header {
-                float: left;
-                font-family: @font-fancy;
-                font-size: 23px;      // 3
-                line-height: 50px;
-                text-transform: lowercase;
-                padding-left: 2px;
-                width: 612px - 2px - 400px;
-
-                .amp {
-                    font-style: italic;
-                }
-                a {
-                    color: @c-body;
-
-                    &:hover {
-                        color: @c-link;
-                    }
-                }
-            }
-            nav {
-                font: normal 18px/50px @font-fancy;    // 1
-                text-align: right;
-                text-transform: lowercase;
-                padding-right: 2px;
-                width: 400px - 2px;
-                float: left;
-
-                .sep {
-                    padding: 0 4px;
-                    color: #666;
-                }
-            }
-        }
-        .hr {
-            margin-top: -12px;
-            margin-bottom: 12px + 25px;
-            height: 25px;
-            background: transparent url('/media/images/hr.png') top left no-repeat;
-        }
-        .hrb {
-            height: 25px;
-            margin-top: 50px;
-            background: transparent url('/media/images/hrb.png') top left no-repeat;
-        }
-        footer {
-            text-align: center;
-
-            p {
-                font-size: 14px;
-                font-style: italic;
-                line-height: 50px;
-                margin-bottom: 0px;
-            }
-            .rochester-made {
-                img {
-                    opacity: 0.7;
-                    padding: 5px 20px;
-                }
-            }
-        }
-    }
-}
-hr {
-    border: none;
-    background: #ccc;
-    height: 1px;
-    margin-bottom: 24px;
-}
-.splash {
-    @color: #454545;
-    color: @color;
-    text-align: center;
-    font: normal 27px/32px @font-fancy;
-    margin-bottom: -1px;
-    padding-top: 0;
-
-    p {
-        margin-bottom: 24px;
-    }
-    .amp {
-        font-style: italic;
-    }
-    .fn {
-        color: @color;
-        text-decoration: none;
-
-        &:hover {
-            color: @c-link;
-            text-decoration: none;
-        }
-        .last-name {
-            display: none;
-        }
-    }
-}
-.section-listing {
-    margin-bottom: -50px;
-    ol {
-        list-style-type: none;
-
-        @w-listing-item: 612px/2;
-        @w-listing-col-padding: 50px;
-
-        li {
-            margin: 0 0 25px 0;
-
-            a {
-                font: normal 23px/32px @font-fancy;    // 3
-                color: @c-body;
-                display: block;
-
-                &:hover {
-                    color: @c-link;
-                    text-decoration: none;
-                }
-            }
-
-            span.snip {
-                font-size: 18px;     // 1
-                color: #333;
-                font-family: @font-fancy;
-                line-height: 25px;
-                font-style: italic;
-            }
-            .amp {
-                font-style: italic;
-            }
-        }
-    }
-}
-
-blockquote {
-    border: 1px solid #ccc;
-    background-color: #fafafa;
-    padding: 11px 15px 12px;
-    margin-left: 2em;
-    overflow: auto;
-
-    p:last-child {
-        margin-bottom: 0;
-    }
-}
-span.dquo {
-    margin-left: -0.23em;
-}
-
-#leaf-stats p {
-    color: #666;
-    margin-top: -22px;
-    margin-bottom: 22px;
-}
-#leaf-content {
-    img {
-        display: block;
-        margin: 25px auto 26px;
-        border: 11px solid #e5e5e5;
-        padding: 1px;
-        background: black;
-        max-width: 590px;
-    }
-    img.left, img.right {
-        border: none;
-        background: none;
-        padding: none;
-    }
-    img.left {
-         margin: 0 1.5em 1em 0;
-    }
-    img.right {
-        margin: 0 0 .75em 1em;
-    }
-    .gallery img {
-        background: none;
-        padding: 0;
-        border: none;
-        display: inline;
-        margin-bottom: 25px;
-        margin-right: 25px;
-    }
-    .toc {
-        ul {
-            list-style: none;
-        }
-
-        ul:first-child>li {
-            margin-left: 0em;
-        }
-    }
-    table {
-        padding: 0px;
-        margin-top: -8px;
-        margin-bottom: 25px;
-
-        tr {
-            margin: 0px;
-            padding: 0px;
-
-            td, th {
-                margin: 0px;
-                padding: 5px 5px;
-                line-height: 23px;
-            }
-            td {
-                border: 1px solid #666;
-            }
-        }
-    }
-}
-#leaf-content.with-diagrams img {
-    display: block;
-    margin: 25px auto;
-    padding: 0;
-    background: none;
-    border: none;
-}
-
-.print-links {
-    display: none;
-}
-img.self {
-    border: none;
-    padding: 0;
-    margin: 0;
-    margin-right: -108px;
-    margin-top: -15px;
-    margin-left: 30px;
-    margin-bottom: 20px;
-}
-
-div#cboxCurrent {
-    bottom: -30px;
-    font-size: 17px;
-    font-weight: normal;
-    left: 60px;
-}
-div.screenshots {
-    img {
-        max-width: 580px;
-    }
-}
-
-#scrolling-header {
-    color: #999;
-    font-size: 23px;
-    font-style: italic;
-    font: italic 23px @font-fancy;
-    line-height: 30px;
-    position: fixed;
-    top: 75px;
-    text-align: right;
-    width: 180px;
-}
Binary file media/diamond-square.monopic has changed
Binary file media/images/blog/2009/02/dj-playlist-sorting.png has changed
Binary file media/images/blog/2009/02/dj-playlist-unrated.png has changed
Binary file media/images/blog/2009/03/prompt-with-branch.png has changed
Binary file media/images/blog/2009/03/prompt-with-dirty.png has changed
Binary file media/images/blog/2009/03/prompt-without-branch.png has changed
Binary file media/images/blog/2009/03/terminal-colors.png has changed
Binary file media/images/blog/2009/08/branch-anon.png has changed
Binary file media/images/blog/2009/08/branch-base.png has changed
Binary file media/images/blog/2009/08/branch-bookmark.png has changed
Binary file media/images/blog/2009/08/branch-clone.png has changed
Binary file media/images/blog/2009/08/branch-named.png has changed
Binary file media/images/blog/2010/01/mercurial-vs-git.jpg has changed
Binary file media/images/blog/2010/02/hg-branching-1-after-merge.png has changed
Binary file media/images/blog/2010/02/hg-branching-1-needs-merge.png has changed
Binary file media/images/blog/2010/02/hg-branching-1-other.png has changed
Binary file media/images/blog/2010/02/hg-branching-1-start.png has changed
Binary file media/images/blog/2010/02/zsh-prompt-comments.png has changed
Binary file media/images/blog/2010/02/zsh-prompt.png has changed
Binary file media/images/blog/2010/05/default-stable-example.png has changed
Binary file media/images/blog/2010/06/translation-branches.png has changed
Binary file media/images/blog/2010/08/git-basics.png has changed
Binary file media/images/blog/2010/08/mercurial-basics.png has changed
Binary file media/images/blog/2010/08/mq-multiple.png has changed
Binary file media/images/blog/2010/08/mq-one.png has changed
Binary file media/images/blog/2010/08/mq-two.png has changed
Binary file media/images/blog/2010/08/mq-versioned.png has changed
Binary file media/images/blog/2010/09/rainbow.png has changed
Binary file media/images/blog/2010/09/vim.png has changed
Binary file media/images/blog/2011/05/rules-1-doxie.png has changed
Binary file media/images/blog/2011/05/rules-2-jotnot.png has changed
Binary file media/images/blog/2011/05/rules-3-ocr.png has changed
Binary file media/images/blog/2011/05/rules-4-clean.png has changed
Binary file media/images/blog/2012/07/caves-01-01.png has changed
Binary file media/images/blog/2012/07/caves-02-01.png has changed
Binary file media/images/blog/2012/07/caves-02-02.png has changed
Binary file media/images/blog/2012/07/caves-02-03.png has changed
Binary file media/images/blog/2012/07/caves-03-1-01.png has changed
Binary file media/images/blog/2012/07/caves-03-1-02.png has changed
Binary file media/images/blog/2012/07/caves-03-1-03.png has changed
Binary file media/images/blog/2012/07/caves-03-2-01.png has changed
Binary file media/images/blog/2012/07/caves-03-2-02.png has changed
Binary file media/images/blog/2012/07/caves-03-2-03.png has changed
Binary file media/images/blog/2012/07/caves-03-3-01.png has changed
Binary file media/images/blog/2012/07/caves-03-3-02.png has changed
Binary file media/images/blog/2012/07/caves-04-01.png has changed
Binary file media/images/blog/2012/07/caves-04-02.png has changed
Binary file media/images/blog/2012/07/caves-04-03.png has changed
Binary file media/images/blog/2012/07/caves-05-01.png has changed
Binary file media/images/blog/2012/07/caves-05-02.png has changed
Binary file media/images/blog/2012/07/caves-05-03.png has changed
Binary file media/images/blog/2012/07/caves-06-01.png has changed
Binary file media/images/blog/2012/07/caves-interlude-1-01.png has changed
Binary file media/images/blog/2012/07/caves-interlude-1-02.png has changed
Binary file media/images/blog/2012/10/caves-07-1-1.png has changed
Binary file media/images/blog/2012/10/caves-07-1-2.png has changed
Binary file media/images/blog/2012/10/kb-apple.jpg has changed
Binary file media/images/blog/2012/10/kb-caps.png has changed
Binary file media/images/blog/2012/10/kb-das.jpg has changed
Binary file media/images/blog/2012/10/kb-hex.png has changed
Binary file media/images/blog/2012/10/kb-hhkb.jpg has changed
Binary file media/images/blog/2012/10/kb-irc.png has changed
Binary file media/images/blog/2012/10/kb-key-overlaid.png has changed
Binary file media/images/blog/2012/10/kb-pck.png has changed
Binary file media/images/blog/2012/10/kb-realforce.jpg has changed
Binary file media/images/blog/2012/10/kb-size.jpg has changed
Binary file media/images/blog/2012/10/keychain-1.png has changed
Binary file media/images/blog/2012/10/keychain-2.png has changed
Binary file media/images/blog/2012/10/keychain-3.png has changed
Binary file media/images/blog/2012/10/mutt-attachments.png has changed
Binary file media/images/blog/2012/10/mutt-contacts-1.png has changed
Binary file media/images/blog/2012/10/mutt-index.png has changed
Binary file media/images/blog/2012/10/mutt-pager.png has changed
Binary file media/images/blog/2012/10/mutt-ready-to-send.png has changed
Binary file media/images/blog/2012/10/mutt-send-1.png has changed
Binary file media/images/blog/2012/10/mutt-urls.png has changed
Binary file media/images/blog/2012/10/what-the-mutt.png has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-01.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-02.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-03.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-04.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-05.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-06.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-07.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-08.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-09.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-10.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-11.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-12.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-13.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-14.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-15.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-16.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-17.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-18.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-19.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-20.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-21.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-22.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-23.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-24.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-25.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-26.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-27.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-28.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-29.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-30.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-31.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-32.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-33.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-34.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-35.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-36.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-37.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-38.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-39.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-40.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-41.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-42.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-43.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-44.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-45.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-46.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-47.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-48.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-a2540-49.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-01.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-02.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-03.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-04.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-05.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-06.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-07.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-08.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-09.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-10.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-11.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-12.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-13.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-14.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-15.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-16.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-17.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-18.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-19.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-20.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-21.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-22.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-23.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-24.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-25.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-26.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-27.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-28.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-29.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-30.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-31.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-32.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-33.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-34.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-35.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-36.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-37.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-38.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-39.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-40.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-41.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-42.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-43.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-44.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-45.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-46.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-47.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-48.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-49.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-50.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-51.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-52.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-53.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-54.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-55.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-56.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-57.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-58.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-59.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-60.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-61.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-62.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-63.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-64.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-65.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-66.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-67.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-68.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-69.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-70.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-71.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-72.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-73.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-74.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-75.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-76.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-77.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-78.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-79.jpg has changed
Binary file media/images/blog/2015/07/full/nat-geo-mc5350-80.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-01.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-02.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-03.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-04.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-05.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-06.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-07.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-08.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-09.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-10.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-11.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-12.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-13.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-14.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-15.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-16.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-17.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-18.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-19.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-20.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-21.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-22.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-23.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-24.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-25.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-26.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-27.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-28.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-29.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-30.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-31.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-32.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-33.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-34.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-35.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-36.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-37.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-38.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-39.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-40.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-41.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-42.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-43.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-44.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-45.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-46.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-47.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-48.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-a2540-49.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-01.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-02.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-03.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-04.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-05.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-06.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-07.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-08.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-09.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-10.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-11.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-12.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-13.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-14.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-15.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-16.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-17.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-18.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-19.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-20.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-21.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-22.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-23.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-24.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-25.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-26.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-27.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-28.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-29.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-30.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-31.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-32.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-33.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-34.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-35.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-36.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-37.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-38.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-39.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-40.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-41.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-42.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-43.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-44.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-45.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-46.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-47.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-48.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-49.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-50.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-51.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-52.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-53.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-54.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-55.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-56.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-57.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-58.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-59.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-60.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-61.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-62.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-63.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-64.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-65.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-66.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-67.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-68.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-69.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-70.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-71.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-72.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-73.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-74.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-75.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-76.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-77.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-78.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-79.jpg has changed
Binary file media/images/blog/2015/07/nat-geo-mc5350-80.jpg has changed
Binary file media/images/blog/2015/11/btd-s2-ggsteve-large.png has changed
Binary file media/images/blog/2015/11/btd-s2-ggsteve.png has changed
Binary file media/images/blog/2015/11/btd-s3-bob-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-bob.png has changed
Binary file media/images/blog/2015/11/btd-s3-douche-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-douche.png has changed
Binary file media/images/blog/2015/11/btd-s3-ggsteve-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-ggsteve.png has changed
Binary file media/images/blog/2015/11/btd-s3-innuendo-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-innuendo.png has changed
Binary file media/images/blog/2015/11/btd-s3-mouthnoises-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-mouthnoises.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-bob-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-bob.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-cringe-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-cringe.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-drugs-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-drugs.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-steve-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-steve.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-the-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-percentile-the.png has changed
Binary file media/images/blog/2015/11/btd-s3-ruined-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-ruined.png has changed
Binary file media/images/blog/2015/11/btd-s3-steve-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-steve.png has changed
Binary file media/images/blog/2015/11/btd-s3-subjects-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-subjects.png has changed
Binary file media/images/blog/2015/11/btd-s3-the-large.png has changed
Binary file media/images/blog/2015/11/btd-s3-the.png has changed
Binary file media/images/blog/2015/11/btd-ssp-bob-large.png has changed
Binary file media/images/blog/2015/11/btd-ssp-bob.png has changed
Binary file media/images/blog/2015/11/btd-ssp-gg-large.png has changed
Binary file media/images/blog/2015/11/btd-ssp-gg.png has changed
Binary file media/images/blog/2015/11/btd-ssp-rip__devil-large.png has changed
Binary file media/images/blog/2015/11/btd-ssp-rip__devil.png has changed
Binary file media/images/blog/2015/11/btd-ssp-ruined-large.png has changed
Binary file media/images/blog/2015/11/btd-ssp-ruined.png has changed
Binary file media/images/blog/2015/11/btd-ssp-steve-large.png has changed
Binary file media/images/blog/2015/11/btd-ssp-steve.png has changed
Binary file media/images/blog/2015/11/btd-ssp-the-large.png has changed
Binary file media/images/blog/2015/11/btd-ssp-the.png has changed
Binary file media/images/blog/2015/11/btd-volume-comparison-large.png has changed
Binary file media/images/blog/2015/11/btd-volume-comparison.png has changed
Binary file media/images/blog/2015/11/hlw-heknew-large.png has changed
Binary file media/images/blog/2015/11/hlw-heknew.png has changed
Binary file media/images/blog/2015/11/hlw-higg-large.png has changed
Binary file media/images/blog/2015/11/hlw-higg.png has changed
Binary file media/images/blog/2015/11/hlw-love-large.png has changed
Binary file media/images/blog/2015/11/hlw-love.png has changed
Binary file media/images/blog/2015/11/hlw-ripdevil-large.png has changed
Binary file media/images/blog/2015/11/hlw-ripdevil.png has changed
Binary file media/images/blog/2015/11/hlw-total-large.png has changed
Binary file media/images/blog/2015/11/hlw-total.png has changed
Binary file media/images/blog/2015/12/silt-initial.gif has changed
Binary file media/images/blog/2015/12/silt-later.gif has changed
Binary file media/images/blog/2016/08/aspect-flavor.png has changed
Binary file media/images/blog/2016/08/aspect-visible.png has changed
Binary file media/images/blog/2016/08/bad-tiling-ds.png has changed
Binary file media/images/blog/2016/08/good-tiling-ds.png has changed
Binary file media/images/blog/2016/08/silt-names.png has changed
Binary file media/images/blog/2016/08/silt1-inspect.png has changed
Binary file media/images/blog/2016/08/silt1-terrain.png has changed
Binary file media/images/blog/2016/08/silt2-inspect.png has changed
Binary file media/images/blog/2016/08/silt2-terrain.png has changed
Binary file media/images/blog/2016/09/loop-macro.jpg has changed
Binary file media/images/hr.png has changed
Binary file media/images/hrb.png has changed
Binary file media/images/projects/fuego/Fuego-4852.jpg has changed
Binary file media/images/projects/fuego/Fuego-4887.jpg has changed
Binary file media/images/projects/fuego/Fuego-4919.jpg has changed
Binary file media/images/projects/fuego/Fuego-4941.jpg has changed
Binary file media/images/projects/fuego/Fuego-4985.jpg has changed
Binary file media/images/projects/fuego/Fuego-5133.jpg has changed
Binary file media/images/projects/hg-prompt/prompt.png has changed
Binary file media/images/projects/lindyjam-com/lindyjamcom-splash.png has changed
Binary file media/images/projects/t/t-screenshot.png has changed
Binary file media/images/projects/women-in-water/alex-tele.jpg has changed
Binary file media/images/projects/women-in-water/alex-wide.jpg has changed
Binary file media/images/projects/women-in-water/anna-tele.jpg has changed
Binary file media/images/projects/women-in-water/anna-wide.jpg has changed
Binary file media/images/projects/women-in-water/erin-tele.jpg has changed
Binary file media/images/projects/women-in-water/erin-wide.jpg has changed
Binary file media/images/projects/women-in-water/leah-tele.jpg has changed
Binary file media/images/projects/women-in-water/leah-wide.jpg has changed
Binary file media/images/projects/women-in-water/lizza-tele.jpg has changed
Binary file media/images/projects/women-in-water/lizza-wide.jpg has changed
Binary file media/images/rhythm.png has changed
Binary file media/images/self.jpg has changed
--- a/media/js/TrackballControls.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,606 +0,0 @@
-
-/**
- * @author Eberhard Graether / http://egraether.com/
- * @author Mark Lundin 	/ http://mark-lundin.com
- * @author Simone Manini / http://daron1337.github.io
- * @author Luca Antiga 	/ http://lantiga.github.io
- */
-
-THREE.TrackballControls = function ( object, domElement ) {
-
-	var _this = this;
-	var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
-
-	this.object = object;
-	this.domElement = ( domElement !== undefined ) ? domElement : document;
-
-	// API
-
-	this.enabled = true;
-
-	this.screen = { left: 0, top: 0, width: 0, height: 0 };
-
-	this.rotateSpeed = 1.0;
-	this.zoomSpeed = 1.2;
-	this.panSpeed = 0.3;
-
-	this.noRotate = false;
-	this.noZoom = false;
-	this.noPan = false;
-
-	this.staticMoving = false;
-	this.dynamicDampingFactor = 0.2;
-
-	this.minDistance = 0;
-	this.maxDistance = Infinity;
-
-	this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ];
-
-	// internals
-
-	this.target = new THREE.Vector3();
-
-	var EPS = 0.000001;
-
-	var lastPosition = new THREE.Vector3();
-
-	var _state = STATE.NONE,
-	_prevState = STATE.NONE,
-
-	_eye = new THREE.Vector3(),
-
-	_movePrev = new THREE.Vector2(),
-	_moveCurr = new THREE.Vector2(),
-
-	_lastAxis = new THREE.Vector3(),
-	_lastAngle = 0,
-
-	_zoomStart = new THREE.Vector2(),
-	_zoomEnd = new THREE.Vector2(),
-
-	_touchZoomDistanceStart = 0,
-	_touchZoomDistanceEnd = 0,
-
-	_panStart = new THREE.Vector2(),
-	_panEnd = new THREE.Vector2();
-
-	// for reset
-
-	this.target0 = this.target.clone();
-	this.position0 = this.object.position.clone();
-	this.up0 = this.object.up.clone();
-
-	// events
-
-	var changeEvent = { type: 'change' };
-	var startEvent = { type: 'start' };
-	var endEvent = { type: 'end' };
-
-
-	// methods
-
-	this.handleResize = function () {
-
-		if ( this.domElement === document ) {
-
-			this.screen.left = 0;
-			this.screen.top = 0;
-			this.screen.width = window.innerWidth;
-			this.screen.height = window.innerHeight;
-
-		} else {
-
-			var box = this.domElement.getBoundingClientRect();
-			// adjustments come from similar code in the jquery offset() function
-			var d = this.domElement.ownerDocument.documentElement;
-			this.screen.left = box.left + window.pageXOffset - d.clientLeft;
-			this.screen.top = box.top + window.pageYOffset - d.clientTop;
-			this.screen.width = box.width;
-			this.screen.height = box.height;
-
-		}
-
-	};
-
-	this.handleEvent = function ( event ) {
-
-		if ( typeof this[ event.type ] == 'function' ) {
-
-			this[ event.type ]( event );
-
-		}
-
-	};
-
-	var getMouseOnScreen = ( function () {
-
-		var vector = new THREE.Vector2();
-
-		return function getMouseOnScreen( pageX, pageY ) {
-
-			vector.set(
-				( pageX - _this.screen.left ) / _this.screen.width,
-				( pageY - _this.screen.top ) / _this.screen.height
-			);
-
-			return vector;
-
-		};
-
-	}() );
-
-	var getMouseOnCircle = ( function () {
-
-		var vector = new THREE.Vector2();
-
-		return function getMouseOnCircle( pageX, pageY ) {
-
-			vector.set(
-				( ( pageX - _this.screen.width * 0.5 - _this.screen.left ) / ( _this.screen.width * 0.5 ) ),
-				( ( _this.screen.height + 2 * ( _this.screen.top - pageY ) ) / _this.screen.width ) // screen.width intentional
-			);
-
-			return vector;
-
-		};
-
-	}() );
-
-	this.rotateCamera = ( function() {
-
-		var axis = new THREE.Vector3(),
-			quaternion = new THREE.Quaternion(),
-			eyeDirection = new THREE.Vector3(),
-			objectUpDirection = new THREE.Vector3(),
-			objectSidewaysDirection = new THREE.Vector3(),
-			moveDirection = new THREE.Vector3(),
-			angle;
-
-		return function rotateCamera() {
-
-			moveDirection.set( _moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0 );
-			angle = moveDirection.length();
-
-			if ( angle ) {
-
-				_eye.copy( _this.object.position ).sub( _this.target );
-
-				eyeDirection.copy( _eye ).normalize();
-				objectUpDirection.copy( _this.object.up ).normalize();
-				objectSidewaysDirection.crossVectors( objectUpDirection, eyeDirection ).normalize();
-
-				objectUpDirection.setLength( _moveCurr.y - _movePrev.y );
-				objectSidewaysDirection.setLength( _moveCurr.x - _movePrev.x );
-
-				moveDirection.copy( objectUpDirection.add( objectSidewaysDirection ) );
-
-				axis.crossVectors( moveDirection, _eye ).normalize();
-
-				angle *= _this.rotateSpeed;
-				quaternion.setFromAxisAngle( axis, angle );
-
-				_eye.applyQuaternion( quaternion );
-				_this.object.up.applyQuaternion( quaternion );
-
-				_lastAxis.copy( axis );
-				_lastAngle = angle;
-
-			} else if ( ! _this.staticMoving && _lastAngle ) {
-
-				_lastAngle *= Math.sqrt( 1.0 - _this.dynamicDampingFactor );
-				_eye.copy( _this.object.position ).sub( _this.target );
-				quaternion.setFromAxisAngle( _lastAxis, _lastAngle );
-				_eye.applyQuaternion( quaternion );
-				_this.object.up.applyQuaternion( quaternion );
-
-			}
-
-			_movePrev.copy( _moveCurr );
-
-		};
-
-	}() );
-
-
-	this.zoomCamera = function () {
-
-		var factor;
-
-		if ( _state === STATE.TOUCH_ZOOM_PAN ) {
-
-			factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
-			_touchZoomDistanceStart = _touchZoomDistanceEnd;
-			_eye.multiplyScalar( factor );
-
-		} else {
-
-			factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed;
-
-			if ( factor !== 1.0 && factor > 0.0 ) {
-
-				_eye.multiplyScalar( factor );
-
-				if ( _this.staticMoving ) {
-
-					_zoomStart.copy( _zoomEnd );
-
-				} else {
-
-					_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;
-
-				}
-
-			}
-
-		}
-
-	};
-
-	this.panCamera = ( function() {
-
-		var mouseChange = new THREE.Vector2(),
-			objectUp = new THREE.Vector3(),
-			pan = new THREE.Vector3();
-
-		return function panCamera() {
-
-			mouseChange.copy( _panEnd ).sub( _panStart );
-
-			if ( mouseChange.lengthSq() ) {
-
-				mouseChange.multiplyScalar( _eye.length() * _this.panSpeed );
-
-				pan.copy( _eye ).cross( _this.object.up ).setLength( mouseChange.x );
-				pan.add( objectUp.copy( _this.object.up ).setLength( mouseChange.y ) );
-
-				_this.object.position.add( pan );
-				_this.target.add( pan );
-
-				if ( _this.staticMoving ) {
-
-					_panStart.copy( _panEnd );
-
-				} else {
-
-					_panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( _this.dynamicDampingFactor ) );
-
-				}
-
-			}
-
-		};
-
-	}() );
-
-	this.checkDistances = function () {
-
-		if ( ! _this.noZoom || ! _this.noPan ) {
-
-			if ( _eye.lengthSq() > _this.maxDistance * _this.maxDistance ) {
-
-				_this.object.position.addVectors( _this.target, _eye.setLength( _this.maxDistance ) );
-				_zoomStart.copy( _zoomEnd );
-
-			}
-
-			if ( _eye.lengthSq() < _this.minDistance * _this.minDistance ) {
-
-				_this.object.position.addVectors( _this.target, _eye.setLength( _this.minDistance ) );
-				_zoomStart.copy( _zoomEnd );
-
-			}
-
-		}
-
-	};
-
-	this.update = function () {
-
-		_eye.subVectors( _this.object.position, _this.target );
-
-		if ( ! _this.noRotate ) {
-
-			_this.rotateCamera();
-
-		}
-
-		if ( ! _this.noZoom ) {
-
-			_this.zoomCamera();
-
-		}
-
-		if ( ! _this.noPan ) {
-
-			_this.panCamera();
-
-		}
-
-		_this.object.position.addVectors( _this.target, _eye );
-
-		_this.checkDistances();
-
-		_this.object.lookAt( _this.target );
-
-		if ( lastPosition.distanceToSquared( _this.object.position ) > EPS ) {
-
-			_this.dispatchEvent( changeEvent );
-
-			lastPosition.copy( _this.object.position );
-
-		}
-
-	};
-
-	this.reset = function () {
-
-		_state = STATE.NONE;
-		_prevState = STATE.NONE;
-
-		_this.target.copy( _this.target0 );
-		_this.object.position.copy( _this.position0 );
-		_this.object.up.copy( _this.up0 );
-
-		_eye.subVectors( _this.object.position, _this.target );
-
-		_this.object.lookAt( _this.target );
-
-		_this.dispatchEvent( changeEvent );
-
-		lastPosition.copy( _this.object.position );
-
-	};
-
-	// listeners
-
-	function keydown( event ) {
-
-		if ( _this.enabled === false ) return;
-
-		_prevState = _state;
-
-		if ( _state !== STATE.NONE ) {
-
-			return;
-
-		} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noRotate ) {
-
-			_state = STATE.ROTATE;
-
-		} else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && ! _this.noZoom ) {
-
-			_state = STATE.ZOOM;
-
-		} else if ( event.keyCode === _this.keys[ STATE.PAN ] && ! _this.noPan ) {
-
-			_state = STATE.PAN;
-
-		}
-
-	}
-
-	function keyup( event ) {
-
-		if ( _this.enabled === false ) return;
-
-		_state = _prevState;
-
-	}
-
-	function mousedown( event ) {
-
-		if ( _this.enabled === false ) return;
-
-		if ( _state === STATE.NONE ) {
-
-			_state = event.button;
-
-		}
-
-		if ( _state === STATE.ROTATE && ! _this.noRotate ) {
-
-			_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
-			_movePrev.copy( _moveCurr );
-
-		} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
-
-			_zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
-			_zoomEnd.copy( _zoomStart );
-
-		} else if ( _state === STATE.PAN && ! _this.noPan ) {
-
-			_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
-			_panEnd.copy( _panStart );
-
-		}
-
-		document.addEventListener( 'mousemove', mousemove, false );
-		document.addEventListener( 'mouseup', mouseup, false );
-
-		_this.dispatchEvent( startEvent );
-
-	}
-
-	function mousemove( event ) {
-
-		if ( _this.enabled === false ) return;
-
-		if ( _state === STATE.ROTATE && ! _this.noRotate ) {
-
-			_movePrev.copy( _moveCurr );
-			_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
-
-		} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
-
-			_zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
-
-		} else if ( _state === STATE.PAN && ! _this.noPan ) {
-
-			_panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
-
-		}
-
-	}
-
-	function mouseup( event ) {
-
-		if ( _this.enabled === false ) return;
-
-		_state = STATE.NONE;
-
-		document.removeEventListener( 'mousemove', mousemove );
-		document.removeEventListener( 'mouseup', mouseup );
-		_this.dispatchEvent( endEvent );
-
-	}
-
-	function mousewheel( event ) {
-
-		if ( _this.enabled === false ) return;
-
-		var delta = 0;
-
-		if ( event.wheelDelta ) {
-
-			// WebKit / Opera / Explorer 9
-
-			delta = event.wheelDelta / 40;
-
-		} else if ( event.detail ) {
-
-			// Firefox
-
-			delta = - event.detail / 3;
-
-		}
-
-		_zoomStart.y += delta * 0.01;
-		_this.dispatchEvent( startEvent );
-		_this.dispatchEvent( endEvent );
-
-	}
-
-	function touchstart( event ) {
-
-		if ( _this.enabled === false ) return;
-
-		switch ( event.touches.length ) {
-
-			case 1:
-				_state = STATE.TOUCH_ROTATE;
-				_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
-				_movePrev.copy( _moveCurr );
-				break;
-
-			default: // 2 or more
-				_state = STATE.TOUCH_ZOOM_PAN;
-				var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
-				var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
-				_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
-
-				var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
-				var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
-				_panStart.copy( getMouseOnScreen( x, y ) );
-				_panEnd.copy( _panStart );
-				break;
-
-		}
-
-		_this.dispatchEvent( startEvent );
-
-	}
-
-	function touchmove( event ) {
-
-		if ( _this.enabled === false ) return;
-
-		switch ( event.touches.length ) {
-
-			case 1:
-				_movePrev.copy( _moveCurr );
-				_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
-				break;
-
-			default: // 2 or more
-				var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
-				var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
-				_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
-
-				var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
-				var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
-				_panEnd.copy( getMouseOnScreen( x, y ) );
-				break;
-
-		}
-
-	}
-
-	function touchend( event ) {
-
-		if ( _this.enabled === false ) return;
-
-		switch ( event.touches.length ) {
-
-			case 0:
-				_state = STATE.NONE;
-				break;
-
-			case 1:
-				_state = STATE.TOUCH_ROTATE;
-				_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
-				_movePrev.copy( _moveCurr );
-				break;
-
-		}
-
-		_this.dispatchEvent( endEvent );
-
-	}
-
-	function contextmenu( event ) {
-
-		event.preventDefault();
-
-	}
-
-	this.dispose = function() {
-
-		this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
-		this.domElement.removeEventListener( 'mousedown', mousedown, false );
-		this.domElement.removeEventListener( 'mousewheel', mousewheel, false );
-		this.domElement.removeEventListener( 'MozMousePixelScroll', mousewheel, false ); // firefox
-
-		this.domElement.removeEventListener( 'touchstart', touchstart, false );
-		this.domElement.removeEventListener( 'touchend', touchend, false );
-		this.domElement.removeEventListener( 'touchmove', touchmove, false );
-
-		document.removeEventListener( 'mousemove', mousemove, false );
-		document.removeEventListener( 'mouseup', mouseup, false );
-
-		window.removeEventListener( 'keydown', keydown, false );
-		window.removeEventListener( 'keyup', keyup, false );
-
-	};
-
-	this.domElement.addEventListener( 'contextmenu', contextmenu, false );
-	this.domElement.addEventListener( 'mousedown', mousedown, false );
-	this.domElement.addEventListener( 'mousewheel', mousewheel, false );
-	this.domElement.addEventListener( 'MozMousePixelScroll', mousewheel, false ); // firefox
-
-	this.domElement.addEventListener( 'touchstart', touchstart, false );
-	this.domElement.addEventListener( 'touchend', touchend, false );
-	this.domElement.addEventListener( 'touchmove', touchmove, false );
-
-	window.addEventListener( 'keydown', keydown, false );
-	window.addEventListener( 'keyup', keyup, false );
-
-	this.handleResize();
-
-	// force an update at start
-	this.update();
-
-};
-
-THREE.TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );
-THREE.TrackballControls.prototype.constructor = THREE.TrackballControls;
-
--- a/media/js/jquery.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-/*!
- * jQuery JavaScript Library v1.4
- * http://jquery.com/
- *
- * Copyright 2010, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://docs.jquery.com/License
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2010, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Wed Jan 13 15:23:05 2010 -0500
- */
-(function(A,w){function oa(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(oa,1);return}c.ready()}}function La(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function $(a,b,d,f,e,i){var j=a.length;if(typeof b==="object"){for(var o in b)$(a,o,b[o],f,e,d);return a}if(d!==w){f=!i&&f&&c.isFunction(d);for(o=0;o<j;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,i);return a}return j?
-e(a[0],b):null}function K(){return(new Date).getTime()}function aa(){return false}function ba(){return true}function pa(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function qa(a){var b=true,d=[],f=[],e=arguments,i,j,o,p,n,t=c.extend({},c.data(this,"events").live);for(p in t){j=t[p];if(j.live===a.type||j.altLive&&c.inArray(a.type,j.altLive)>-1){i=j.data;i.beforeFilter&&i.beforeFilter[a.type]&&!i.beforeFilter[a.type](a)||f.push(j.selector)}else delete t[p]}i=c(a.target).closest(f,a.currentTarget);
-n=0;for(l=i.length;n<l;n++)for(p in t){j=t[p];o=i[n].elem;f=null;if(i[n].selector===j.selector){if(j.live==="mouseenter"||j.live==="mouseleave")f=c(a.relatedTarget).closest(j.selector)[0];if(!f||f!==o)d.push({elem:o,fn:j})}}n=0;for(l=d.length;n<l;n++){i=d[n];a.currentTarget=i.elem;a.data=i.fn.data;if(i.fn.apply(i.elem,e)===false){b=false;break}}return b}function ra(a,b){return["live",a,b.replace(/\./g,"`").replace(/ /g,"&")].join(".")}function sa(a){return!a||!a.parentNode||a.parentNode.nodeType===
-11}function ta(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var i in f)for(var j in f[i])c.event.add(this,i,f[i][j],f[i][j].data)}}})}function ua(a,b,d){var f,e,i;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&a[0].indexOf("<option")<0){e=true;if(i=c.fragments[a[0]])if(i!==1)f=i}if(!f){b=b&&b[0]?b[0].ownerDocument||b[0]:s;f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=
-i?f:1;return{fragment:f,cacheable:e}}function T(a){for(var b=0,d,f;(d=a[b])!=null;b++)if(!c.noData[d.nodeName.toLowerCase()]&&(f=d[H]))delete c.cache[f]}function L(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ma=A.jQuery,Na=A.$,s=A.document,U,Oa=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Pa=/^.[^:#\[\.,]*$/,Qa=/\S/,
-Ra=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Sa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],M,ca=Object.prototype.toString,da=Object.prototype.hasOwnProperty,ea=Array.prototype.push,R=Array.prototype.slice,V=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(typeof a==="string")if((d=Oa.exec(a))&&(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Sa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];
-c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=ua([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return U.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a)}else return!b||b.jquery?(b||U).find(a):c(b).find(a);else if(c.isFunction(a))return U.ready(a);if(a.selector!==w){this.selector=a.selector;
-this.context=a.context}return c.isArray(a)?this.setArray(a):c.makeArray(a,this)},selector:"",jquery:"1.4",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){a=c(a||null);a.prevObject=this;a.context=this.context;if(b==="find")a.selector=this.selector+(this.selector?" ":"")+d;else if(b)a.selector=this.selector+"."+b+"("+d+")";return a},setArray:function(a){this.length=
-0;ea.apply(this,a);return this},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||
-c(null)},push:ea,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,i,j,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(i in e){j=a[i];o=e[i];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){j=j&&(c.isPlainObject(j)||c.isArray(j))?j:c.isArray(o)?[]:{};a[i]=c.extend(f,j,o)}else if(o!==w)a[i]=
-o}return a};c.extend({noConflict:function(a){A.$=Na;if(a)A.jQuery=Ma;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",M,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",
-M);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&oa()}}},isFunction:function(a){return ca.call(a)==="[object Function]"},isArray:function(a){return ca.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||ca.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!da.call(a,"constructor")&&!da.call(a.constructor.prototype,"isPrototypeOf"))return false;var b;for(b in a);return b===w||da.call(a,b)},
-isEmptyObject:function(a){for(var b in a)return false;return true},noop:function(){},globalEval:function(a){if(a&&Qa.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,i=a.length,j=i===w||c.isFunction(a);
-if(d)if(j)for(f in a){if(b.apply(a[f],d)===false)break}else for(;e<i;){if(b.apply(a[e++],d)===false)break}else if(j)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<i&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Ra,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ea.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=
-0,f=b.length;d<f;d++)if(b[d]===a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,i=a.length;e<i;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,i=0,j=a.length;i<j;i++){e=b(a[i],i,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b===
-"string"){d=a;a=d[b];b=w}else if(b&&!c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){var b={browser:""};a=a.toLowerCase();if(/webkit/.test(a))b={browser:"webkit",version:/webkit[\/ ]([\w.]+)/};else if(/opera/.test(a))b={browser:"opera",version:/version/.test(a)?/version[\/ ]([\w.]+)/:/opera[\/ ]([\w.]+)/};else if(/msie/.test(a))b={browser:"msie",version:/msie ([\w.]+)/};else if(/mozilla/.test(a)&&
-!/compatible/.test(a))b={browser:"mozilla",version:/rv:([\w.]+)/};b.version=(b.version&&b.version.exec(a)||[0,"0"])[1];return b},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=true;if(V)c.inArray=function(a,b){return V.call(b,a)};U=c(s);if(s.addEventListener)M=function(){s.removeEventListener("DOMContentLoaded",M,false);c.ready()};else if(s.attachEvent)M=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",
-M);c.ready()}};if(V)c.inArray=function(a,b){return V.call(b,a)};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+K();d.style.display="none";d.innerHTML="   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var e=d.getElementsByTagName("*"),i=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!i)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,
-htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(i.getAttribute("style")),hrefNormalized:i.getAttribute("href")==="/a",opacity:/^0.55$/.test(i.style.opacity),cssFloat:!!i.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(j){}a.insertBefore(b,
-a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function o(){c.support.noCloneEvent=false;d.detachEvent("onclick",o)});d.cloneNode(true).fireEvent("onclick")}c(function(){var o=s.createElement("div");o.style.width=o.style.paddingLeft="1px";s.body.appendChild(o);c.boxModel=c.support.boxModel=o.offsetWidth===2;s.body.removeChild(o).style.display="none"});a=function(o){var p=s.createElement("div");o="on"+o;var n=o in
-p;if(!n){p.setAttribute(o,"return;");n=typeof p[o]==="function"}return n};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=i=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var H="jQuery"+K(),Ta=0,ya={},Ua={};c.extend({cache:{},expando:H,noData:{embed:true,object:true,applet:true},data:function(a,
-b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?ya:a;var f=a[H],e=c.cache;if(!b&&!f)return null;f||(f=++Ta);if(typeof b==="object"){a[H]=f;e=e[f]=c.extend(true,{},b)}else e=e[f]?e[f]:typeof d==="undefined"?Ua:(e[f]={});if(d!==w){a[H]=f;e[b]=d}return typeof b==="string"?e[b]:e}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?ya:a;var d=a[H],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{try{delete a[H]}catch(i){a.removeAttribute&&
-a.removeAttribute(H)}delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,
-a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,
-a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var za=/[\n\t]/g,fa=/\s+/,Va=/\r/g,Wa=/href|src|style/,Xa=/(button|input)/i,Ya=/(button|input|object|select|textarea)/i,Za=/^(a|area)$/i,Aa=/radio|checkbox/;c.fn.extend({attr:function(a,
-b){return $(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(p){var n=c(this);n.addClass(a.call(this,p,n.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(fa),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className)for(var i=" "+e.className+" ",j=0,o=b.length;j<o;j++){if(i.indexOf(" "+b[j]+" ")<0)e.className+=
-" "+b[j]}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(p){var n=c(this);n.removeClass(a.call(this,p,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(fa),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var i=(" "+e.className+" ").replace(za," "),j=0,o=b.length;j<o;j++)i=i.replace(" "+b[j]+" "," ");e.className=i.substring(1,i.length-1)}else e.className=""}return this},toggleClass:function(a,
-b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var i=c(this);i.toggleClass(a.call(this,e,i.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,i=0,j=c(this),o=b,p=a.split(fa);e=p[i++];){o=f?o:!j.hasClass(e);j[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=
-" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(za," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var i=b?d:0;for(d=b?d+1:e.length;i<d;i++){var j=e[i];if(j.selected){a=c(j).val();if(b)return a;f.push(a)}}return f}if(Aa.test(b.type)&&
-!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Va,"")}return w}var o=c.isFunction(a);return this.each(function(p){var n=c(this),t=a;if(this.nodeType===1){if(o)t=a.call(this,p,n.val());if(typeof t==="number")t+="";if(c.isArray(t)&&Aa.test(this.type))this.checked=c.inArray(n.val(),t)>=0;else if(c.nodeName(this,"select")){var z=c.makeArray(t);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),z)>=0});if(!z.length)this.selectedIndex=
--1}else this.value=t}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var i=Wa.test(b);if(b in a&&f&&!i){if(e){if(b==="type"&&Xa.test(a.nodeName)&&a.parentNode)throw"type property can't be changed";a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;
-if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:Ya.test(a.nodeName)||Za.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&i?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var $a=function(a){return a.replace(/[^\w\s\.\|`]/g,function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===
-3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;if(!d.guid)d.guid=c.guid++;if(f!==w){d=c.proxy(d);d.data=f}var e=c.data(a,"events")||c.data(a,"events",{}),i=c.data(a,"handle"),j;if(!i){j=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(j.elem,arguments):w};i=c.data(a,"handle",j)}if(i){i.elem=a;b=b.split(/\s+/);for(var o,p=0;o=b[p++];){var n=o.split(".");o=n.shift();d.type=n.slice(0).sort().join(".");var t=e[o],z=this.special[o]||{};if(!t){t=e[o]={};
-if(!z.setup||z.setup.call(a,f,n,d)===false)if(a.addEventListener)a.addEventListener(o,i,false);else a.attachEvent&&a.attachEvent("on"+o,i)}if(z.add)if((n=z.add.call(a,d,f,n,t))&&c.isFunction(n)){n.guid=n.guid||d.guid;d=n}t[d.guid]=d;this.global[o]=true}a=null}}},global:{},remove:function(a,b,d){if(!(a.nodeType===3||a.nodeType===8)){var f=c.data(a,"events"),e,i,j;if(f){if(b===w||typeof b==="string"&&b.charAt(0)===".")for(i in f)this.remove(a,i+(b||""));else{if(b.type){d=b.handler;b=b.type}b=b.split(/\s+/);
-for(var o=0;i=b[o++];){var p=i.split(".");i=p.shift();var n=!p.length,t=c.map(p.slice(0).sort(),$a);t=new RegExp("(^|\\.)"+t.join("\\.(?:.*\\.)?")+"(\\.|$)");var z=this.special[i]||{};if(f[i]){if(d){j=f[i][d.guid];delete f[i][d.guid]}else for(var B in f[i])if(n||t.test(f[i][B].type))delete f[i][B];z.remove&&z.remove.call(a,p,j);for(e in f[i])break;if(!e){if(!z.teardown||z.teardown.call(a,p)===false)if(a.removeEventListener)a.removeEventListener(i,c.data(a,"handle"),false);else a.detachEvent&&a.detachEvent("on"+
-i,c.data(a,"handle"));e=null;delete f[i]}}}}for(e in f)break;if(!e){if(B=c.data(a,"handle"))B.elem=null;c.removeData(a,"events");c.removeData(a,"handle")}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[H]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();this.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===
-8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;var i=c.data(d,"handle");i&&i.apply(d,b);var j,o;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()])){j=d[e];o=d["on"+e]}}catch(p){}i=c.nodeName(d,"a")&&e==="click";if(!f&&j&&!a.isDefaultPrevented()&&!i){this.triggered=true;try{d[e]()}catch(n){}}else if(o&&d["on"+e].apply(d,b)===false)a.result=false;this.triggered=false;if(!a.isPropagationStopped())(d=d.parentNode||d.ownerDocument)&&c.event.trigger(a,b,d,true)},
-handle:function(a){var b,d;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;d=a.type.split(".");a.type=d.shift();b=!d.length&&!a.exclusive;var f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)");d=(c.data(this,"events")||{})[a.type];for(var e in d){var i=d[e];if(b||f.test(i.type)){a.handler=i;a.data=i.data;i=i.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}return a.result},
-props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[H])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||
-s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&
-a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a,b){c.extend(a,b||{});a.guid+=b.selector+b.live;c.event.add(this,b.live,qa,b)},remove:function(a){if(a.length){var b=0,d=new RegExp("(^|\\.)"+a[0]+"(\\.|$)");c.each(c.data(this,"events").live||{},function(){d.test(this.type)&&b++});b<1&&c.event.remove(this,a[0],qa)}},special:{}},beforeunload:{setup:function(a,
-b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=K();this[H]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=ba;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=
-ba;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=ba;this.stopPropagation()},isDefaultPrevented:aa,isPropagationStopped:aa,isImmediatePropagationStopped:aa};var Ba=function(a){for(var b=a.relatedTarget;b&&b!==this;)try{b=b.parentNode}catch(d){break}if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}},Ca=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",
-mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ca:Ba,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ca:Ba)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(a,b,d){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="submit"||i==="image")&&c(e).closest("form").length)return pa("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit."+
-d.guid,function(f){var e=f.target,i=e.type;if((i==="text"||i==="password")&&c(e).closest("form").length&&f.keyCode===13)return pa("submit",this,arguments)})}else return false},remove:function(a,b){c.event.remove(this,"click.specialSubmit"+(b?"."+b.guid:""));c.event.remove(this,"keypress.specialSubmit"+(b?"."+b.guid:""))}};if(!c.support.changeBubbles){var ga=/textarea|input|select/i;function Da(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>
--1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d}function ha(a,b){var d=a.target,f,e;if(!(!ga.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Da(d);if(e!==f){if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",e);if(d.type!=="select"&&(f!=null||e)){a.type="change";return c.event.trigger(a,b,this)}}}}c.event.special.change={filters:{focusout:ha,click:function(a){var b=a.target,d=b.type;if(d===
-"radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return ha.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return ha.call(this,a)},beforeactivate:function(a){a=a.target;a.nodeName.toLowerCase()==="input"&&a.type==="radio"&&c.data(a,"_change_data",Da(a))}},setup:function(a,b,d){for(var f in W)c.event.add(this,f+".specialChange."+d.guid,W[f]);return ga.test(this.nodeName)},
-remove:function(a,b){for(var d in W)c.event.remove(this,d+".specialChange"+(b?"."+b.guid:""),W[d]);return ga.test(this.nodeName)}};var W=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,
-f,e){if(typeof d==="object"){for(var i in d)this[b](i,f,d[i],e);return this}if(c.isFunction(f)){thisObject=e;e=f;f=w}var j=b==="one"?c.proxy(e,function(o){c(this).unbind(o,j);return e.apply(this,arguments)}):e;return d==="unload"&&b!=="one"?this.one(d,f,e,thisObject):this.each(function(){c.event.add(this,d,j,f)})}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&!a.preventDefault){for(var d in a)this.unbind(d,a[d]);return this}return this.each(function(){c.event.remove(this,a,b)})},trigger:function(a,
-b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||
-a)},live:function(a,b,d){if(c.isFunction(b)){d=b;b=w}c(this.context).bind(ra(a,this.selector),{data:b,selector:this.selector,live:a},d);return this},die:function(a,b){c(this.context).unbind(ra(a,this.selector),b?{guid:b.guid+this.selector+a}:null);return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){c.fn[b]=function(d){return d?
-this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",k,m=0;g[m];m++){k=g[m];if(k.nodeType===3||k.nodeType===4)h+=k.nodeValue;else if(k.nodeType!==8)h+=a(k.childNodes)}return h}function b(g,h,k,m,r,q){r=0;for(var v=m.length;r<v;r++){var u=m[r];if(u){u=u[g];for(var y=false;u;){if(u.sizcache===
-k){y=m[u.sizset];break}if(u.nodeType===1&&!q){u.sizcache=k;u.sizset=r}if(u.nodeName.toLowerCase()===h){y=u;break}u=u[g]}m[r]=y}}}function d(g,h,k,m,r,q){r=0;for(var v=m.length;r<v;r++){var u=m[r];if(u){u=u[g];for(var y=false;u;){if(u.sizcache===k){y=m[u.sizset];break}if(u.nodeType===1){if(!q){u.sizcache=k;u.sizset=r}if(typeof h!=="string"){if(u===h){y=true;break}}else if(p.filter(h,[u]).length>0){y=u;break}}u=u[g]}m[r]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
-e=0,i=Object.prototype.toString,j=false,o=true;[0,0].sort(function(){o=false;return 0});var p=function(g,h,k,m){k=k||[];var r=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return k;for(var q=[],v,u,y,S,I=true,N=x(h),J=g;(f.exec(""),v=f.exec(J))!==null;){J=v[3];q.push(v[1]);if(v[2]){S=v[3];break}}if(q.length>1&&t.exec(g))if(q.length===2&&n.relative[q[0]])u=ia(q[0]+q[1],h);else for(u=n.relative[q[0]]?[h]:p(q.shift(),h);q.length;){g=q.shift();if(n.relative[g])g+=q.shift();
-u=ia(g,u)}else{if(!m&&q.length>1&&h.nodeType===9&&!N&&n.match.ID.test(q[0])&&!n.match.ID.test(q[q.length-1])){v=p.find(q.shift(),h,N);h=v.expr?p.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:q.pop(),set:B(m)}:p.find(q.pop(),q.length===1&&(q[0]==="~"||q[0]==="+")&&h.parentNode?h.parentNode:h,N);u=v.expr?p.filter(v.expr,v.set):v.set;if(q.length>0)y=B(u);else I=false;for(;q.length;){var E=q.pop();v=E;if(n.relative[E])v=q.pop();else E="";if(v==null)v=h;n.relative[E](y,v,N)}}else y=[]}y||(y=u);if(!y)throw"Syntax error, unrecognized expression: "+
-(E||g);if(i.call(y)==="[object Array]")if(I)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&F(h,y[g])))k.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&k.push(u[g]);else k.push.apply(k,y);else B(y,k);if(S){p(S,r,k,m);p.uniqueSort(k)}return k};p.uniqueSort=function(g){if(D){j=o;g.sort(D);if(j)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};p.matches=function(g,h){return p(g,null,null,h)};p.find=function(g,h,k){var m,r;if(!g)return[];
-for(var q=0,v=n.order.length;q<v;q++){var u=n.order[q];if(r=n.leftMatch[u].exec(g)){var y=r[1];r.splice(1,1);if(y.substr(y.length-1)!=="\\"){r[1]=(r[1]||"").replace(/\\/g,"");m=n.find[u](r,h,k);if(m!=null){g=g.replace(n.match[u],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};p.filter=function(g,h,k,m){for(var r=g,q=[],v=h,u,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var I in n.filter)if((u=n.leftMatch[I].exec(g))!=null&&u[2]){var N=n.filter[I],J,E;E=u[1];y=false;u.splice(1,1);if(E.substr(E.length-
-1)!=="\\"){if(v===q)q=[];if(n.preFilter[I])if(u=n.preFilter[I](u,v,k,q,m,S)){if(u===true)continue}else y=J=true;if(u)for(var X=0;(E=v[X])!=null;X++)if(E){J=N(E,u,X,v);var Ea=m^!!J;if(k&&J!=null)if(Ea)y=true;else v[X]=false;else if(Ea){q.push(E);y=true}}if(J!==w){k||(v=q);g=g.replace(n.match[I],"");if(!y)return[];break}}}if(g===r)if(y==null)throw"Syntax error, unrecognized expression: "+g;else break;r=g}return v};var n=p.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
-CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},
-relative:{"+":function(g,h){var k=typeof h==="string",m=k&&!/\W/.test(h);k=k&&!m;if(m)h=h.toLowerCase();m=0;for(var r=g.length,q;m<r;m++)if(q=g[m]){for(;(q=q.previousSibling)&&q.nodeType!==1;);g[m]=k||q&&q.nodeName.toLowerCase()===h?q||false:q===h}k&&p.filter(h,g,true)},">":function(g,h){var k=typeof h==="string";if(k&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,r=g.length;m<r;m++){var q=g[m];if(q){k=q.parentNode;g[m]=k.nodeName.toLowerCase()===h?k:false}}}else{m=0;for(r=g.length;m<r;m++)if(q=g[m])g[m]=
-k?q.parentNode:q.parentNode===h;k&&p.filter(h,g,true)}},"":function(g,h,k){var m=e++,r=d;if(typeof h==="string"&&!/\W/.test(h)){var q=h=h.toLowerCase();r=b}r("parentNode",h,m,g,q,k)},"~":function(g,h,k){var m=e++,r=d;if(typeof h==="string"&&!/\W/.test(h)){var q=h=h.toLowerCase();r=b}r("previousSibling",h,m,g,q,k)}},find:{ID:function(g,h,k){if(typeof h.getElementById!=="undefined"&&!k)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var k=[];
-h=h.getElementsByName(g[1]);for(var m=0,r=h.length;m<r;m++)h[m].getAttribute("name")===g[1]&&k.push(h[m]);return k.length===0?null:k}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,k,m,r,q){g=" "+g[1].replace(/\\/g,"")+" ";if(q)return g;q=0;for(var v;(v=h[q])!=null;q++)if(v)if(r^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))k||m.push(v);else if(k)h[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},
-CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,k,m,r,q){h=g[1].replace(/\\/g,"");if(!q&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,k,m,r){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=p(g[3],null,null,h);else{g=p.filter(g[3],h,k,true^r);k||m.push.apply(m,
-g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,k){return!!p(k[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},
-text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},
-setFilters:{first:function(g,h){return h===0},last:function(g,h,k,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,k){return h<k[3]-0},gt:function(g,h,k){return h>k[3]-0},nth:function(g,h,k){return k[3]-0===h},eq:function(g,h,k){return k[3]-0===h}},filter:{PSEUDO:function(g,h,k,m){var r=h[1],q=n.filters[r];if(q)return q(g,k,h,m);else if(r==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(r==="not"){h=
-h[3];k=0;for(m=h.length;k<m;k++)if(h[k]===g)return false;return true}else throw"Syntax error, unrecognized expression: "+r;},CHILD:function(g,h){var k=h[1],m=g;switch(k){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(k==="first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":k=h[2];var r=h[3];if(k===1&&r===0)return true;h=h[0];var q=g.parentNode;if(q&&(q.sizcache!==h||!g.nodeIndex)){var v=0;for(m=q.firstChild;m;m=
-m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;q.sizcache=h}g=g.nodeIndex-r;return k===0?g===0:g%k===0&&g/k>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var k=h[1];g=n.attrHandle[k]?n.attrHandle[k](g):g[k]!=null?g[k]:g.getAttribute(k);k=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===
-"="?k===h:m==="*="?k.indexOf(h)>=0:m==="~="?(" "+k+" ").indexOf(h)>=0:!h?k&&g!==false:m==="!="?k!==h:m==="^="?k.indexOf(h)===0:m==="$="?k.substr(k.length-h.length)===h:m==="|="?k===h||k.substr(0,h.length+1)===h+"-":false},POS:function(g,h,k,m){var r=n.setFilters[h[2]];if(r)return r(g,k,h,m)}}},t=n.match.POS;for(var z in n.match){n.match[z]=new RegExp(n.match[z].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[z]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[z].source.replace(/\\(\d+)/g,function(g,
-h){return"\\"+(h-0+1)}))}var B=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){B=function(g,h){h=h||[];if(i.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var k=0,m=g.length;k<m;k++)h.push(g[k]);else for(k=0;g[k];k++)h.push(g[k]);return h}}var D;if(s.documentElement.compareDocumentPosition)D=function(g,h){if(!g.compareDocumentPosition||
-!h.compareDocumentPosition){if(g==h)j=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)j=true;return g};else if("sourceIndex"in s.documentElement)D=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)j=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)j=true;return g};else if(s.createRange)D=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)j=true;return g.ownerDocument?-1:1}var k=g.ownerDocument.createRange(),m=
-h.ownerDocument.createRange();k.setStart(g,0);k.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=k.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)j=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var k=s.documentElement;k.insertBefore(g,k.firstChild);if(s.getElementById(h)){n.find.ID=function(m,r,q){if(typeof r.getElementById!=="undefined"&&!q)return(r=r.getElementById(m[1]))?r.id===m[1]||typeof r.getAttributeNode!=="undefined"&&
-r.getAttributeNode("id").nodeValue===m[1]?[r]:w:[]};n.filter.ID=function(m,r){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===r}}k.removeChild(g);k=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,k){k=k.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;k[m];m++)k[m].nodeType===1&&h.push(k[m]);k=h}return k};g.innerHTML="<a href='#'></a>";
-if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=p,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){p=function(m,r,q,v){r=r||s;if(!v&&r.nodeType===9&&!x(r))try{return B(r.querySelectorAll(m),q)}catch(u){}return g(m,r,q,v)};for(var k in g)p[k]=g[k];h=null}}();
-(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,k,m){if(typeof k.getElementsByClassName!=="undefined"&&!m)return k.getElementsByClassName(h[1])};g=null}}})();var F=s.compareDocumentPosition?function(g,h){return g.compareDocumentPosition(h)&16}:function(g,
-h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ia=function(g,h){var k=[],m="",r;for(h=h.nodeType?[h]:h;r=n.match.PSEUDO.exec(g);){m+=r[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;r=0;for(var q=h.length;r<q;r++)p(g,h[r],k);return p.filter(m,k)};c.find=p;c.expr=p.selectors;c.expr[":"]=c.expr.filters;c.unique=p.uniqueSort;c.getText=a;c.isXMLDoc=x;c.contains=F})();var ab=/Until$/,bb=/^(?:parents|prevUntil|prevAll)/,
-cb=/,/;R=Array.prototype.slice;var Fa=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,i){return!!b.call(e,i,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Pa.test(b))return c.filter(b,f,!d);else b=c.filter(b,a)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;
-c.find(a,this[f],b);if(f>0)for(var i=d;i<b.length;i++)for(var j=0;j<d;j++)if(b[j]===b[i]){b.splice(i--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Fa(this,a,false),"not",a)},filter:function(a){return this.pushStack(Fa(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,i=
-{},j;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){j=a[e];i[j]||(i[j]=c.expr.match.POS.test(j)?c(j,b||this.context):j)}for(;f&&f.ownerDocument&&f!==b;){for(j in i){e=i[j];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:j,elem:f});delete i[j]}}f=f.parentNode}}return d}var p=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,t){for(;t&&t.ownerDocument&&t!==b;){if(p?p.index(t)>-1:c(t).is(a))return t;t=t.parentNode}return null})},index:function(a){if(!a||typeof a===
-"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(sa(a[0])||sa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",
-d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?
-a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);ab.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||cb.test(f))&&bb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||!c(a).is(d));){a.nodeType===
-1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ga=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,db=/(<([\w:]+)[^>]*?)\/>/g,eb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,Ha=/<([\w:]+)/,fb=/<tbody/i,gb=/<|&\w+;/,hb=function(a,b,d){return eb.test(d)?a:b+"></"+d+">"},G={option:[1,"<select multiple='multiple'>","</select>"],
-legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};G.optgroup=G.option;G.tbody=G.tfoot=G.colgroup=G.caption=G.thead;G.th=G.td;if(!c.support.htmlSerialize)G._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);
-return d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.getText(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
-wrapInner:function(a){return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&
-this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,
-"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ga,"").replace(Y,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ta(this,b);ta(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===
-1?this[0].innerHTML.replace(Ga,""):null;else if(typeof a==="string"&&!/<script/i.test(a)&&(c.support.leadingWhitespace||!Y.test(a))&&!G[(Ha.exec(a)||["",""])[1].toLowerCase()])try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){T(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}else c.isFunction(a)?this.each(function(e){var i=c(this),j=i.html();i.empty().append(function(){return a.call(this,e,j)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&
-this[0].parentNode){c.isFunction(a)||(a=c(a).detach());return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(t){return c.nodeName(t,"table")?t.getElementsByTagName("tbody")[0]||t.appendChild(t.ownerDocument.createElement("tbody")):t}var e,i,j=a[0],o=[];if(c.isFunction(j))return this.each(function(t){var z=
-c(this);a[0]=j.call(this,t,b?z.html():w);return z.domManip(a,b,d)});if(this[0]){e=a[0]&&a[0].parentNode&&a[0].parentNode.nodeType===11?{fragment:a[0].parentNode}:ua(a,this,o);if(i=e.fragment.firstChild){b=b&&c.nodeName(i,"tr");for(var p=0,n=this.length;p<n;p++)d.call(b?f(this[p],i):this[p],e.cacheable||this.length>1||p>0?e.fragment.cloneNode(true):e.fragment)}o&&c.each(o,La)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},
-function(a,b){c.fn[a]=function(d){var f=[];d=c(d);for(var e=0,i=d.length;e<i;e++){var j=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),j);f=f.concat(j)}return this.pushStack(f,a,d.selector)}});c.each({remove:function(a,b){if(!a||c.filter(a,[this]).length){if(!b&&this.nodeType===1){T(this.getElementsByTagName("*"));T([this])}this.parentNode&&this.parentNode.removeChild(this)}},empty:function(){for(this.nodeType===1&&T(this.getElementsByTagName("*"));this.firstChild;)this.removeChild(this.firstChild)}},
-function(a,b){c.fn[a]=function(){return this.each(b,arguments)}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;var e=[];c.each(a,function(i,j){if(typeof j==="number")j+="";if(j){if(typeof j==="string"&&!gb.test(j))j=b.createTextNode(j);else if(typeof j==="string"){j=j.replace(db,hb);var o=(Ha.exec(j)||["",""])[1].toLowerCase(),p=G[o]||G._default,n=p[0];i=b.createElement("div");for(i.innerHTML=p[1]+j+p[2];n--;)i=i.lastChild;
-if(!c.support.tbody){n=fb.test(j);o=o==="table"&&!n?i.firstChild&&i.firstChild.childNodes:p[1]==="<table>"&&!n?i.childNodes:[];for(p=o.length-1;p>=0;--p)c.nodeName(o[p],"tbody")&&!o[p].childNodes.length&&o[p].parentNode.removeChild(o[p])}!c.support.leadingWhitespace&&Y.test(j)&&i.insertBefore(b.createTextNode(Y.exec(j)[0]),i.firstChild);j=c.makeArray(i.childNodes)}if(j.nodeType)e.push(j);else e=c.merge(e,j)}});if(d)for(a=0;e[a];a++)if(f&&c.nodeName(e[a],"script")&&(!e[a].type||e[a].type.toLowerCase()===
-"text/javascript"))f.push(e[a].parentNode?e[a].parentNode.removeChild(e[a]):e[a]);else{e[a].nodeType===1&&e.splice.apply(e,[a+1,0].concat(c.makeArray(e[a].getElementsByTagName("script"))));d.appendChild(e[a])}return e}});var ib=/z-?index|font-?weight|opacity|zoom|line-?height/i,Ia=/alpha\([^)]*\)/,Ja=/opacity=([^)]*)/,ja=/float/i,ka=/-([a-z])/ig,jb=/([A-Z])/g,kb=/^-?\d+(?:px)?$/i,lb=/^-?\d/,mb={position:"absolute",visibility:"hidden",display:"block"},nb=["Left","Right"],ob=["Top","Bottom"],pb=s.defaultView&&
-s.defaultView.getComputedStyle,Ka=c.support.cssFloat?"cssFloat":"styleFloat",la=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return $(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!ib.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""===
-"NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=Ia.test(a)?a.replace(Ia,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Ja.exec(f.filter)[1])/100+"":""}if(ja.test(b))b=Ka;b=b.replace(ka,la);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,i=b==="width"?nb:ob;function j(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(i,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=
-parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,"border"+this+"Width",true))||0})}a.offsetWidth!==0?j():c.swap(a,mb,j);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Ja.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ja.test(b))b=Ka;if(!d&&e&&e[b])f=e[b];else if(pb){if(ja.test(b))b="float";b=b.replace(jb,"-$1").toLowerCase();e=
-a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ka,la);f=a.currentStyle[b]||a.currentStyle[d];if(!kb.test(f)&&lb.test(f)){b=e.left;var i=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=i}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=
-f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var qb=K(),rb=/<script(.|\s)*?\/script>/gi,sb=/select|textarea/i,tb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,O=/=\?(&|$)/,ma=/\?/,ub=/(\?|&)_=.*?(&|$)/,vb=/^(\w+:)?\/\/([^\/?#]+)/,
-wb=/%20/g;c.fn.extend({_load:c.fn.load,load:function(a,b,d){if(typeof a!=="string")return this._load(a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}c.ajax({url:a,type:f,dataType:"html",data:b,context:this,complete:function(i,j){if(j==="success"||j==="notmodified")this.html(e?c("<div />").append(i.responseText.replace(rb,
-"")).find(e):i.responseText);d&&this.each(d,[i.responseText,j,i])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||sb.test(this.nodeName)||tb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});
-c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},
-ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",
-text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&e.success.call(p,o,j,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(p,x,j);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(r,q){(e.context?c(e.context):c.event).trigger(r,q)}var e=c.extend(true,{},c.ajaxSettings,a),i,j,o,p=e.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,
-e.traditional);if(e.dataType==="jsonp"){if(n==="GET")O.test(e.url)||(e.url+=(ma.test(e.url)?"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!O.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&O.test(e.data)||O.test(e.url))){i=e.jsonpCallback||"jsonp"+qb++;if(e.data)e.data=(e.data+"").replace(O,"="+i+"$1");e.url=e.url.replace(O,"="+i+"$1");e.dataType="script";A[i]=A[i]||function(r){o=r;b();d();A[i]=w;try{delete A[i]}catch(q){}B&&
-B.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===false&&n==="GET"){var t=K(),z=e.url.replace(ub,"$1_="+t+"$2");e.url=z+(z===e.url?(ma.test(e.url)?"&":"?")+"_="+t:"")}if(e.data&&n==="GET")e.url+=(ma.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");t=(t=vb.exec(e.url))&&(t[1]&&t[1]!==location.protocol||t[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&t){var B=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");
-C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!i){var D=false;C.onload=C.onreadystatechange=function(){if(!D&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){D=true;b();d();C.onload=C.onreadystatechange=null;B&&C.parentNode&&B.removeChild(C)}}}B.insertBefore(C,B.firstChild);return w}var F=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",
-e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}t||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ia){}if(e.beforeSend&&e.beforeSend.call(p,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",
-[x,e]);var g=x.onreadystatechange=function(r){if(!x||x.readyState===0){F||d();F=true;if(x)x.onreadystatechange=c.noop}else if(!F&&x&&(x.readyState===4||r==="timeout")){F=true;x.onreadystatechange=c.noop;j=r==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";if(j==="success")try{o=c.httpData(x,e.dataType,e)}catch(q){j="parsererror"}if(j==="success"||j==="notmodified")i||b();else c.handleError(e,x,j);d();r==="timeout"&&x.abort();if(e.async)x=
-null}};try{var h=x.abort;x.abort=function(){if(x){h.call(x);if(x)x.readyState=0}g()}}catch(k){}e.async&&e.timeout>0&&setTimeout(function(){x&&!F&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||A,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol===
-"file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;if(e&&a.documentElement.nodeName==="parsererror")throw"parsererror";if(d&&
-d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&f.indexOf("json")>=0)if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))a=A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "+a))();else throw"Invalid JSON: "+a;else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(e,i){i=
-c.isFunction(i)?i():i;f[f.length]=encodeURIComponent(e)+"="+encodeURIComponent(i)}var f=[];if(b===w)b=c.ajaxSettings.traditional;c.isArray(a)||a.jquery?c.each(a,function(){d(this.name,this.value)}):c.each(a,function e(i,j){if(c.isArray(j))c.each(j,function(o,p){b?d(i,p):e(i+"["+(typeof p==="object"||c.isArray(p)?o:"")+"]",p)});else!b&&j!=null&&typeof j==="object"?c.each(j,function(o,p){e(i+"["+o+"]",p)}):d(i,j)});return f.join("&").replace(wb,"+")}});var na={},xb=/toggle|show|hide/,yb=/^([+-]=)?([\d+-.]+)(.*)$/,
-Z,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a!=null)return this.animate(L("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(na[d])f=na[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();
-na[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a!=null)return this.animate(L("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&
-c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(L("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var i=c.extend({},e),j,o=this.nodeType===1&&c(this).is(":hidden"),
-p=this;for(j in a){var n=j.replace(ka,la);if(j!==n){a[n]=a[j];delete a[j];j=n}if(a[j]==="hide"&&o||a[j]==="show"&&!o)return i.complete.call(this);if((j==="height"||j==="width")&&this.style){i.display=c.css(this,"display");i.overflow=this.style.overflow}if(c.isArray(a[j])){(i.specialEasing=i.specialEasing||{})[j]=a[j][1];a[j]=a[j][0]}}if(i.overflow!=null)this.style.overflow="hidden";i.curAnim=c.extend({},a);c.each(a,function(t,z){var B=new c.fx(p,i,t);if(xb.test(z))B[z==="toggle"?o?"show":"hide":z](a);
-else{var C=yb.exec(z),D=B.cur(true)||0;if(C){z=parseFloat(C[2]);var F=C[3]||"px";if(F!=="px"){p.style[t]=(z||1)+F;D=(z||1)/B.cur(true)*D;p.style[t]=D+F}if(C[1])z=(C[1]==="-="?-1:1)*z+D;B.custom(D,z,F)}else B.custom(D,z,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:L("show",1),slideUp:L("hide",1),slideToggle:L("toggle",
-1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration==="number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,
-b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==
-null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(i){return e.step(i)}this.startTime=K();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!Z)Z=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop===
-"width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=K(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=
-this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=
-c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||c.fx.stop()},stop:function(){clearInterval(Z);Z=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=
-null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?function(a){var b=this[0];if(!b||!b.ownerDocument)return null;if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),
-f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=this[0];if(!b||!b.ownerDocument)return null;if(a)return this.each(function(t){c.offset.setOffset(this,a,t)});if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=
-b,e=b.ownerDocument,i,j=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var p=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==j;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;i=e?e.getComputedStyle(b,null):b.currentStyle;p-=b.scrollTop;n-=b.scrollLeft;if(b===d){p+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){p+=parseFloat(i.borderTopWidth)||
-0;n+=parseFloat(i.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&i.overflow!=="visible"){p+=parseFloat(i.borderTopWidth)||0;n+=parseFloat(i.borderLeftWidth)||0}f=i}if(f.position==="relative"||f.position==="static"){p+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&f.position==="fixed"){p+=Math.max(j.scrollTop,o.scrollTop);n+=Math.max(j.scrollLeft,o.scrollLeft)}return{top:p,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),
-d,f,e,i=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";a.insertBefore(b,a.firstChild);
-d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i;a.removeChild(b);c.offset.initialize=c.noop},
-bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),i=parseInt(c.curCSS(a,"top",true),10)||0,j=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,d,e);d={top:b.top-e.top+i,left:b.left-
-e.left+j};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=
-this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],i;if(!e)return null;if(f!==w)return this.each(function(){if(i=wa(this))i.scrollTo(!a?f:c(i).scrollLeft(),a?f:c(i).scrollTop());else this[d]=f});else return(i=wa(e))?"pageXOffset"in i?i[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&i.document.documentElement[d]||i.document.body[d]:e[d]}});
-c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;return"scrollTo"in e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+
-b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);
\ No newline at end of file
--- a/media/js/jquery.timeago.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,140 +0,0 @@
-/*
- * timeago: a jQuery plugin, version: 0.8.1 (2010-01-04)
- * @requires jQuery v1.2.3 or later
- *
- * Timeago is a jQuery plugin that makes it easy to support automatically
- * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
- *
- * For usage and examples, visit:
- * http://timeago.yarp.com/
- *
- * Licensed under the MIT:
- * http://www.opensource.org/licenses/mit-license.php
- *
- * Copyright (c) 2008-2010, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
- */
-(function($) {
-  $.timeago = function(timestamp) {
-    if (timestamp instanceof Date) return inWords(timestamp);
-    else if (typeof timestamp == "string") return inWords($.timeago.parse(timestamp));
-    else return inWords($.timeago.datetime(timestamp));
-  };
-  var $t = $.timeago;
-
-  $.extend($.timeago, {
-    settings: {
-      refreshMillis: 60000,
-      allowFuture: false,
-      strings: {
-        prefixAgo: null,
-        prefixFromNow: null,
-        suffixAgo: "ago",
-        suffixFromNow: "from now",
-        ago: null, // DEPRECATED, use suffixAgo
-        fromNow: null, // DEPRECATED, use suffixFromNow
-        seconds: "less than a minute",
-        minute: "about a minute",
-        minutes: "%d minutes",
-        hour: "about an hour",
-        hours: "about %d hours",
-        day: "a day",
-        days: "%d days",
-        month: "about a month",
-        months: "%d months",
-        year: "about a year",
-        years: "%d years"
-      }
-    },
-    inWords: function(distanceMillis) {
-      var $l = this.settings.strings;
-      var prefix = $l.prefixAgo;
-      var suffix = $l.suffixAgo || $l.ago;
-      if (this.settings.allowFuture) {
-        if (distanceMillis < 0) {
-          prefix = $l.prefixFromNow;
-          suffix = $l.suffixFromNow || $l.fromNow;
-        }
-        distanceMillis = Math.abs(distanceMillis);
-      }
-
-      var seconds = distanceMillis / 1000;
-      var minutes = seconds / 60;
-      var hours = minutes / 60;
-      var days = hours / 24;
-      var years = days / 365;
-
-      var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
-        seconds < 90 && substitute($l.minute, 1) ||
-        minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
-        minutes < 90 && substitute($l.hour, 1) ||
-        hours < 24 && substitute($l.hours, Math.round(hours)) ||
-        hours < 48 && substitute($l.day, 1) ||
-        days < 30 && substitute($l.days, Math.floor(days)) ||
-        days < 60 && substitute($l.month, 1) ||
-        days < 365 && substitute($l.months, Math.floor(days / 30)) ||
-        years < 2 && substitute($l.year, 1) ||
-        substitute($l.years, Math.floor(years));
-
-      return $.trim([prefix, words, suffix].join(" "));
-    },
-    parse: function(iso8601) {
-      var s = $.trim(iso8601);
-      s = s.replace(/-/,"/").replace(/-/,"/");
-      s = s.replace(/T/," ").replace(/Z/," UTC");
-      s = s.replace(/([\+-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
-      return new Date(s);
-    },
-    datetime: function(elem) {
-      // jQuery's `is()` doesn't play well with HTML5 in IE
-      var isTime = $(elem).get(0).tagName.toLowerCase() == 'time'; // $(elem).is('time');
-      var iso8601 = isTime ? $(elem).attr('datetime') : $(elem).attr('title');
-      return $t.parse(iso8601);
-    }
-  });
-
-  $.fn.timeago = function() {
-    var self = this;
-    self.each(refresh);
-
-    var $s = $t.settings;
-    if ($s.refreshMillis > 0) {
-      setInterval(function() { self.each(refresh); }, $s.refreshMillis);
-    }
-    return self;
-  };
-
-  function refresh() {
-    var data = prepareData(this);
-    if (!isNaN(data.datetime)) {
-      $(this).text(inWords(data.datetime));
-    }
-    return this;
-  }
-
-  function prepareData(element) {
-    element = $(element);
-    if (element.data("timeago") === undefined) {
-      element.data("timeago", { datetime: $t.datetime(element) });
-      var text = $.trim(element.text());
-      if (text.length > 0) element.attr("title", text);
-    }
-    return element.data("timeago");
-  }
-
-  function inWords(date) {
-    return $t.inWords(distance(date));
-  }
-
-  function distance(date) {
-    return (new Date().getTime() - date.getTime());
-  }
-
-  function substitute(stringOrFunction, value) {
-    var string = $.isFunction(stringOrFunction) ? stringOrFunction(value) : stringOrFunction;
-    return string.replace(/%d/i, value);
-  }
-
-  // fix for IE6 suckage
-  document.createElement('abbr');
-  document.createElement('time');
-})(jQuery);
\ No newline at end of file
--- a/media/js/print.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-$(function() {
-    $('#leaf-content p:has(a)').add('#leaf-content ol:has(a)').add('#leaf-content ul:has(a)').each(function() {
-        var printing_links = $(this).find('a')
-                                    .not("[href^='#']")
-                                    .not(":has(img)")
-                                    .clone();
-        $(this).after(printing_links);
-
-        printing_links.wrap('<li></li>')
-                      .parent()
-                      .wrapAll('<ul class="print-links"></ul>');
-
-        printing_links.each(function() {
-            var href = $(this).attr('href');
-            if (href.match("^/")) {
-                href = 'http://stevelosh.com' + href;
-            }
-            $(this).after(': ' + href);
-        });
-    });
-});
--- a/media/js/sjl.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-var h2s = null;
-
-function place_scrolly_header () {
-    var soff = 75;
-
-    var y = $(window).scrollTop();
-
-    var target_content = null;
-    var opacity = null;
-    var header_y = null;
-    h2s.each(function() {
-        var pre_header_y = $(this).position()['top'] - soff;
-        if (y < pre_header_y) {
-            return false;
-        };
-        header_y = pre_header_y;
-
-        target_content = $(this).html().replace(/&nbsp;/g, ' ');
-
-        var opacity_y = y - (header_y + soff);
-        opacity = opacity_y / soff;
-        if (opacity > 1.0) {
-            opacity = 1.0;
-        }
-
-        if (opacity > 0.99) {
-            var next_headers = $(this).nextAll('h2');
-            if (next_headers.length) {
-                var next_header_y = next_headers.first().position()['top'];
-                var next_header_distance = next_header_y - y;
-                if (next_header_distance <= soff*2) {
-                    opacity = 1.0 / (soff - next_header_distance/2);
-                };
-            }
-        }
-    });
-    $('#scrolling-header').css({ opacity: opacity })
-                          .css('left', h2s.first().position()['left'] - 180 - 35)
-                          .html(target_content);
-}
-
-$(function() {
-    jQuery('span.timeago').timeago();
-
-    if ($('#leaf-stats').length) {
-        $('body').append('<div id="scrolling-header"></div>');
-        h2s = $('#leaf-content h2');
-
-        $(window).scroll(function () {
-            place_scrolly_header();
-        });
-        $(window).resize(function () {
-            place_scrolly_header();
-        });
-    }
-});
--- a/media/js/terrain1.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,524 +0,0 @@
-(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
-var width = exports.width = 610;
-var height = exports.height = 400;
-var wireframe = exports.wireframe = true;
-var wireframeWidth = exports.wireframeWidth = 1.2;
-var terrainHeight = exports.terrainHeight = 50;
-var terrainSize = exports.terrainSize = 100;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-var l = exports.l = function l(v) {
-    return console.log(v);
-};
-var midpoint = exports.midpoint = function midpoint(a, b) {
-    return (a + b) / 2;
-};
-var average2 = exports.average2 = function average2(a, b) {
-    return (a + b) / 2;
-};
-var average4 = exports.average4 = function average4(a, b, c, d) {
-    return (a + b + c + d) / 4;
-};
-var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
-    return function () {
-        var totalø1 = 0;
-        var countø1 = 0;
-        a ? (function () {
-            totalø1 = totalø1 + a;
-            return countø1 = countø1 + 1;
-        })() : void 0;
-        b ? (function () {
-            totalø1 = totalø1 + b;
-            return countø1 = countø1 + 1;
-        })() : void 0;
-        c ? (function () {
-            totalø1 = totalø1 + c;
-            return countø1 = countø1 + 1;
-        })() : void 0;
-        d ? (function () {
-            totalø1 = totalø1 + d;
-            return countø1 = countø1 + 1;
-        })() : void 0;
-        return totalø1 / countø1;
-    }.call(this);
-};
-var rand = exports.rand = function rand() {
-    return Math.random();
-};
-var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
-    return spread * rand() * 2 - spread;
-};
-var jitter = exports.jitter = function jitter(value, spread) {
-    return value + randAroundZero(spread);
-};
-void 0;
-var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(hm, x, y) {
-    return 0 <= x && x <= hm.last && (0 <= y && y <= hm.last) ? (function () {
-        return hm[y * hm.resolution + x];
-    })() : void 0;
-};
-void 0;
-var normalize = exports.normalize = function normalize(hm) {
-    return function () {
-        var maxø1 = 0 - Infinity;
-        var minø1 = Infinity;
-        (function () {
-            var G__1ø1 = hm.length;
-            return function loop() {
-                var recur = loop;
-                var iø1 = 0;
-                do {
-                    recur = iø1 < G__1ø1 ? (function () {
-                        (function () {
-                            var elø1 = hm[iø1];
-                            maxø1 < elø1 ? (function () {
-                                return maxø1 = elø1;
-                            })() : void 0;
-                            return minø1 > elø1 ? (function () {
-                                return minø1 = elø1;
-                            })() : void 0;
-                        }.call(this));
-                        return loop[0] = 1 + iø1, loop;
-                    })() : void 0;
-                } while (iø1 = loop[0], recur === loop);
-                return recur;
-            }.call(this);
-        }.call(this));
-        return function () {
-            var spanø1 = maxø1 - minø1;
-            return function () {
-                var G__2ø1 = hm.length;
-                return function loop() {
-                    var recur = loop;
-                    var iø1 = 0;
-                    do {
-                        recur = iø1 < G__2ø1 ? (function () {
-                            hm[iø1] = (hm[iø1] - minø1) / spanø1;
-                            return loop[0] = 1 + iø1, loop;
-                        })() : void 0;
-                    } while (iø1 = loop[0], recur === loop);
-                    return recur;
-                }.call(this);
-            }.call(this);
-        }.call(this);
-    }.call(this);
-};
-var zeroHeightmap = exports.zeroHeightmap = function zeroHeightmap(heightmap) {
-    (function () {
-        var G__3ø1 = heightmap.length;
-        return function loop() {
-            var recur = loop;
-            var iø1 = 0;
-            do {
-                recur = iø1 < G__3ø1 ? (function () {
-                    heightmap[iø1] = 0;
-                    return loop[0] = 1 + iø1, loop;
-                })() : void 0;
-            } while (iø1 = loop[0], recur === loop);
-            return recur;
-        }.call(this);
-    }.call(this));
-    return heightmap;
-};
-var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
-    return function () {
-        var resolutionø1 = 1 + Math.pow(2, exponent);
-        l('Creating ' + resolutionø1 + ' by ' + resolutionø1 + ' heightmap...');
-        var heightmap = new Array(resolutionø1 * resolutionø1);
-        heightmap.resolution = resolutionø1;
-        heightmap.exponent = exponent;
-        heightmap.last = resolutionø1 - 1;
-        return zeroHeightmap(heightmap);
-    }.call(this);
-};
-var randomNoise = exports.randomNoise = function randomNoise(heightmap) {
-    return function () {
-        var G__4ø1 = heightmap.length;
-        return function loop() {
-            var recur = loop;
-            var iø1 = 0;
-            do {
-                recur = iø1 < G__4ø1 ? (function () {
-                    heightmap[iø1] = rand();
-                    return loop[0] = 1 + iø1, loop;
-                })() : void 0;
-            } while (iø1 = loop[0], recur === loop);
-            return recur;
-        }.call(this);
-    }.call(this);
-};
-var mpdInitCorners = exports.mpdInitCorners = function mpdInitCorners(heightmap) {
-    heightmap[0 * heightmap.resolution + 0] = rand();
-    heightmap[heightmap.last * heightmap.resolution + 0] = rand();
-    heightmap[0 * heightmap.resolution + heightmap.last] = rand();
-    return heightmap[heightmap.last * heightmap.resolution + heightmap.last] = rand();
-};
-var mpdDisplace = exports.mpdDisplace = function mpdDisplace(heightmap, lx, rx, by, ty, spread) {
-    return function () {
-        var cxø1 = midpoint(lx, rx);
-        var cyø1 = midpoint(by, ty);
-        var bottomLeftø1 = heightmap[by * heightmap.resolution + lx];
-        var bottomRightø1 = heightmap[by * heightmap.resolution + rx];
-        var topLeftø1 = heightmap[ty * heightmap.resolution + lx];
-        var topRightø1 = heightmap[ty * heightmap.resolution + rx];
-        var topø1 = average2(topLeftø1, topRightø1);
-        var leftø1 = average2(bottomLeftø1, topLeftø1);
-        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
-        var rightø1 = average2(bottomRightø1, topRightø1);
-        var centerø1 = average4(topø1, leftø1, bottomø1, rightø1);
-        heightmap[by * heightmap.resolution + cxø1] = jitter(bottomø1, spread);
-        heightmap[ty * heightmap.resolution + cxø1] = jitter(topø1, spread);
-        heightmap[cyø1 * heightmap.resolution + lx] = jitter(leftø1, spread);
-        heightmap[cyø1 * heightmap.resolution + rx] = jitter(rightø1, spread);
-        return heightmap[cyø1 * heightmap.resolution + cxø1] = jitter(centerø1, spread);
-    }.call(this);
-};
-var midpointDisplacement = exports.midpointDisplacement = function midpointDisplacement(heightmap) {
-    mpdInitCorners(heightmap);
-    (function loop() {
-        var recur = loop;
-        var iterø1 = 0;
-        var spreadø1 = 0.3;
-        do {
-            recur = iterø1 < heightmap.exponent ? (function () {
-                (function () {
-                    var chunksø1 = Math.pow(2, iterø1);
-                    var chunkWidthø1 = (heightmap.resolution - 1) / chunksø1;
-                    return function () {
-                        var G__5ø1 = chunksø1;
-                        return function () {
-                            var G__6ø1 = G__5ø1;
-                            return function loop() {
-                                var recur = loop;
-                                var xchunkø1 = 0;
-                                do {
-                                    recur = xchunkø1 < G__6ø1 ? (function () {
-                                        (function () {
-                                            var G__7ø1 = G__5ø1;
-                                            return function loop() {
-                                                var recur = loop;
-                                                var ychunkø1 = 0;
-                                                do {
-                                                    recur = ychunkø1 < G__7ø1 ? (function () {
-                                                        (function () {
-                                                            var leftXø1 = chunkWidthø1 * xchunkø1;
-                                                            var rightXø1 = leftXø1 + chunkWidthø1;
-                                                            var bottomYø1 = chunkWidthø1 * ychunkø1;
-                                                            var topYø1 = bottomYø1 + chunkWidthø1;
-                                                            return mpdDisplace(heightmap, leftXø1, rightXø1, bottomYø1, topYø1, spreadø1);
-                                                        }.call(this));
-                                                        return loop[0] = 1 + ychunkø1, loop;
-                                                    })() : void 0;
-                                                } while (ychunkø1 = loop[0], recur === loop);
-                                                return recur;
-                                            }.call(this);
-                                        }.call(this));
-                                        return loop[0] = 1 + xchunkø1, loop;
-                                    })() : void 0;
-                                } while (xchunkø1 = loop[0], recur === loop);
-                                return recur;
-                            }.call(this);
-                        }.call(this);
-                    }.call(this);
-                }.call(this));
-                return loop[0] = 1 + iterø1, loop[1] = spreadø1 * 0.5, loop;
-            })() : void 0;
-        } while (iterø1 = loop[0], spreadø1 = loop[1], recur === loop);
-        return recur;
-    }.call(this));
-    return normalize(heightmap);
-};
-var midpointDisplacementFinal = exports.midpointDisplacementFinal = function midpointDisplacementFinal(heightmap) {
-    mpdInitCorners(heightmap);
-    (function loop() {
-        var recur = loop;
-        var iterø1 = 0;
-        var spreadø1 = 0 + $('#input-starting-spread').val();
-        do {
-            recur = iterø1 < heightmap.exponent ? (function () {
-                (function () {
-                    var chunksø1 = Math.pow(2, iterø1);
-                    var chunkWidthø1 = (heightmap.resolution - 1) / chunksø1;
-                    return function () {
-                        var G__8ø1 = chunksø1;
-                        return function () {
-                            var G__9ø1 = G__8ø1;
-                            return function loop() {
-                                var recur = loop;
-                                var xchunkø1 = 0;
-                                do {
-                                    recur = xchunkø1 < G__9ø1 ? (function () {
-                                        (function () {
-                                            var G__10ø1 = G__8ø1;
-                                            return function loop() {
-                                                var recur = loop;
-                                                var ychunkø1 = 0;
-                                                do {
-                                                    recur = ychunkø1 < G__10ø1 ? (function () {
-                                                        (function () {
-                                                            var leftXø1 = chunkWidthø1 * xchunkø1;
-                                                            var rightXø1 = leftXø1 + chunkWidthø1;
-                                                            var bottomYø1 = chunkWidthø1 * ychunkø1;
-                                                            var topYø1 = bottomYø1 + chunkWidthø1;
-                                                            return mpdDisplace(heightmap, leftXø1, rightXø1, bottomYø1, topYø1, spreadø1);
-                                                        }.call(this));
-                                                        return loop[0] = 1 + ychunkø1, loop;
-                                                    })() : void 0;
-                                                } while (ychunkø1 = loop[0], recur === loop);
-                                                return recur;
-                                            }.call(this);
-                                        }.call(this));
-                                        return loop[0] = 1 + xchunkø1, loop;
-                                    })() : void 0;
-                                } while (xchunkø1 = loop[0], recur === loop);
-                                return recur;
-                            }.call(this);
-                        }.call(this);
-                    }.call(this);
-                }.call(this));
-                return loop[0] = 1 + iterø1, loop[1] = spreadø1 * (0 + $('#input-spread-reduction').val()), loop;
-            })() : void 0;
-        } while (iterø1 = loop[0], spreadø1 = loop[1], recur === loop);
-        return recur;
-    }.call(this));
-    return normalize(heightmap);
-};
-var mpdDisplaceD2 = exports.mpdDisplaceD2 = function mpdDisplaceD2(heightmap, lx, rx, by, ty, spread) {
-    return function () {
-        var cxø1 = midpoint(lx, rx);
-        var cyø1 = midpoint(by, ty);
-        var bottomLeftø1 = heightmap[by * heightmap.resolution + lx];
-        var bottomRightø1 = heightmap[by * heightmap.resolution + rx];
-        var topLeftø1 = heightmap[ty * heightmap.resolution + lx];
-        var topRightø1 = heightmap[ty * heightmap.resolution + rx];
-        var topø1 = average2(topLeftø1, topRightø1);
-        var leftø1 = average2(bottomLeftø1, topLeftø1);
-        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
-        var rightø1 = average2(bottomRightø1, topRightø1);
-        heightmap[by * heightmap.resolution + cxø1] = jitter(bottomø1, spread);
-        heightmap[ty * heightmap.resolution + cxø1] = jitter(topø1, spread);
-        heightmap[cyø1 * heightmap.resolution + lx] = jitter(leftø1, spread);
-        return heightmap[cyø1 * heightmap.resolution + rx] = jitter(rightø1, spread);
-    }.call(this);
-};
-var midpointDisplacementD1 = exports.midpointDisplacementD1 = function midpointDisplacementD1(heightmap) {
-    return mpdInitCorners(heightmap);
-};
-var midpointDisplacementD2 = exports.midpointDisplacementD2 = function midpointDisplacementD2(heightmap) {
-    mpdInitCorners(heightmap);
-    return mpdDisplaceD2(heightmap, 0, heightmap.last, 0, heightmap.last, 0.1);
-};
-var midpointDisplacementD3 = exports.midpointDisplacementD3 = function midpointDisplacementD3(heightmap) {
-    mpdInitCorners(heightmap);
-    return mpdDisplace(heightmap, 0, heightmap.last, 0, heightmap.last, 0.1);
-};
-var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
-    return function () {
-        var lightø1 = new THREE.DirectionalLight(16777215, 1);
-        lightø1.position.set(100, 0, 150);
-        return lightø1;
-    }.call(this);
-};
-var makeCamera = exports.makeCamera = function makeCamera() {
-    return function () {
-        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
-        cameraø1.position.set(0, -100, 150);
-        return cameraø1;
-    }.call(this);
-};
-var makeRenderer = exports.makeRenderer = function makeRenderer() {
-    return function () {
-        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
-        rendererø1.setClearColor(16777215);
-        rendererø1.setSize(width, height);
-        rendererø1.setPixelRatio(2);
-        return rendererø1;
-    }.call(this);
-};
-var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
-    return function () {
-        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, heightmap.resolution - 1, heightmap.resolution - 1);
-        geometryø1.dynamic = true;
-        return geometryø1;
-    }.call(this);
-};
-var makeControls = exports.makeControls = function makeControls(camera, renderer) {
-    return function () {
-        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
-        controlsø1.rotateSpeed = 1.4;
-        controlsø1.zoomSpeed = 0.5;
-        controlsø1.staticMoving = true;
-        controlsø1.dynamicDampingFactor = 0.3;
-        return controlsø1;
-    }.call(this);
-};
-var makePlane = exports.makePlane = function makePlane(geometry) {
-    return function () {
-        var materialø1 = new THREE.MeshLambertMaterial({
-            'wireframe': wireframe,
-            'wireframeLinewidth': wireframeWidth,
-            'color': 47872
-        });
-        return new THREE.Mesh(geometry, materialø1);
-    }.call(this);
-};
-var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
-    return function () {
-        var containerø1 = document.getElementById(elName);
-        var settingsø1 = document.createElement('div');
-        var refreshButtonø1 = document.createElement('button');
-        var buttonTextø1 = document.createTextNode('Refresh');
-        var cancelScrollø1 = function (e) {
-            return e.preventDefault();
-        };
-        refreshButtonø1.onclick = refreshFn;
-        renderer.domElement.onmousewheel = cancelScrollø1;
-        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
-        refreshButtonø1.appendChild(buttonTextø1);
-        containerø1.appendChild(renderer.domElement);
-        containerø1.appendChild(settingsø1);
-        return settingsø1.appendChild(refreshButtonø1);
-    }.call(this);
-};
-var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
-    (function () {
-        var G__11ø1 = geometry.vertices.length;
-        return function loop() {
-            var recur = loop;
-            var iø1 = 0;
-            do {
-                recur = iø1 < G__11ø1 ? (function () {
-                    geometry.vertices[iø1].z = terrainHeight * heightmap[iø1];
-                    return loop[0] = 1 + iø1, loop;
-                })() : void 0;
-            } while (iø1 = loop[0], recur === loop);
-            return recur;
-        }.call(this);
-    }.call(this));
-    geometry.verticesNeedUpdate = true;
-    geometry.computeFaceNormals();
-    geometry.computeVertexNormals();
-    geometry.computeMorphNormals();
-    return geometry;
-};
-var makeDemo = exports.makeDemo = function makeDemo(elementId, algorithm, size) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var geometry = makeGeometry(makeHeightmap(size));
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    scene.add(makePlane(geometry));
-    var refresh = function refresh() {
-        l('Refreshing ========================================');
-        return function () {
-            var heightmapø1 = makeHeightmap(size);
-            l('Generating terrain...');
-            (function () {
-                var G__12ø1 = new Date().getTime();
-                var G__14ø1 = (function () {
-                    return algorithm(heightmapø1);
-                })();
-                var G__13ø1 = new Date().getTime();
-                l('Elapsed time: ' + (G__13ø1 - G__12ø1) + 'ms.');
-                return G__14ø1;
-            }.call(this));
-            l('Refreshing geometry...');
-            (function () {
-                var G__15ø1 = new Date().getTime();
-                var G__17ø1 = (function () {
-                    return updateGeometry(geometry, heightmapø1);
-                })();
-                var G__16ø1 = new Date().getTime();
-                l('Elapsed time: ' + (G__16ø1 - G__15ø1) + 'ms.');
-                return G__17ø1;
-            }.call(this));
-            return l('Done!');
-        }.call(this);
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    render();
-    return void 0;
-};
-var makeFinal = exports.makeFinal = function makeFinal(elementId) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var heightmap = makeHeightmap($('#input-exponent').val());
-    var geometry = makeGeometry(heightmap);
-    var plane = makePlane(geometry);
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    scene.add(plane);
-    var refresh = function refresh() {
-        l('Refreshing ========================================');
-        scene.remove(plane);
-        heightmap = makeHeightmap($('#input-exponent').val());
-        geometry = makeGeometry(heightmap);
-        plane = makePlane(geometry);
-        scene.add(plane);
-        l('Generating terrain...');
-        (function () {
-            var G__18ø1 = new Date().getTime();
-            var G__20ø1 = (function () {
-                return midpointDisplacementFinal(heightmap);
-            })();
-            var G__19ø1 = new Date().getTime();
-            l('Elapsed time: ' + (G__19ø1 - G__18ø1) + 'ms.');
-            return G__20ø1;
-        }.call(this));
-        l('Refreshing geometry...');
-        (function () {
-            var G__21ø1 = new Date().getTime();
-            var G__23ø1 = (function () {
-                return updateGeometry(geometry, heightmap);
-            })();
-            var G__22ø1 = new Date().getTime();
-            l('Elapsed time: ' + (G__22ø1 - G__21ø1) + 'ms.');
-            return G__23ø1;
-        }.call(this));
-        return l('Done!');
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    render();
-    return void 0;
-};
-var run = exports.run = function run() {
-    makeDemo('demo-random', randomNoise, 7);
-    makeDemo('demo-mpd-1', midpointDisplacementD1, 2);
-    makeDemo('demo-mpd-2', midpointDisplacementD2, 2);
-    makeDemo('demo-mpd-3', midpointDisplacementD3, 2);
-    makeDemo('demo-mpd-4', midpointDisplacement, 3);
-    return makeFinal('demo-final');
-};
-$(run);
-
-
-},{}]},{},[1])
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Vzci9sb2NhbC9saWIvbm9kZV9tb2R1bGVzL2Jyb3dzZXJpZnkvbm9kZV9tb2R1bGVzL2Jyb3dzZXItcGFjay9fcHJlbHVkZS5qcyIsIm1lZGlhL2pzL3dpc3AvYW5vbnltb3VzLndpc3AiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNDQSxJQUFLLEtBQUEsR0FBQSxPQUFBLENBQUEsS0FBQSxHQUFNLEdBQVg7QUFDQSxJQUFLLE1BQUEsR0FBQSxPQUFBLENBQUEsTUFBQSxHQUFPLEdBQVosQ0FEQTtBQUVBLElBQUssU0FBQSxHQUFBLE9BQUEsQ0FBQSxTQUFBLEcsSUFBTCxDQUZBO0FBR0EsSUFBSyxjQUFBLEdBQUEsT0FBQSxDQUFBLGNBQUEsR0FBZ0IsR0FBckIsQ0FIQTtBQUlBLElBQUssYUFBQSxHQUFBLE9BQUEsQ0FBQSxhQUFBLEdBQWUsRUFBcEIsQ0FKQTtBQUtBLElBQUssV0FBQSxHQUFBLE9BQUEsQ0FBQSxXQUFBLEdBQWEsR0FBbEIsQ0FMQTtPQUFBO09BQUE7T0FBQTtPQUFBO09BQUE7T0FBQTtBQTJDQSxJQUFNLENBQUEsR0FBQSxPQUFBLENBQUEsQ0FBQSxHQUFOLFNBQU0sQ0FBTixDQ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udC1kMiAyKVxuICAobWFrZS1kZW1vIFwiZGVtby1tcGQtM1wiIG1pZHBvaW50LWRpc3BsYWNlbWVudC1kMyAyKVxuICAobWFrZS1kZW1vIFwiZGVtby1tcGQtNFwiIG1pZHBvaW50LWRpc3BsYWNlbWVudCAzKVxuICAobWFrZS1maW5hbCBcImRlbW8tZmluYWxcIilcbiAgOyAobWFrZS1kZW1vIFwiZGVtby1taWRwb2ludFwiIG1pZHBvaW50LWRpc3BsYWNlbWVudClcbiAgOyAobWFrZS1kZW1vIFwiZGVtby1kaWFtb25kXCIgZGlhbW9uZC1zcXVhcmUpXG5cbiAgKVxuXG4oJCBydW4pXG5cblxuOyB2aW06IGx3Kz1kby10aW1lcyBsdys9ZG8tbmVzdGVkIDpcbiJdfQ==
--- a/media/js/terrain2.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,784 +0,0 @@
-(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
-{
-    var _ns_ = {
-        id: 'demo',
-        doc: void 0
-    };
-    var ndarray = require('ndarray');
-}
-var width = exports.width = 610;
-var height = exports.height = 400;
-var wireframe = exports.wireframe = true;
-var wireframeWidth = exports.wireframeWidth = 1.2;
-var terrainHeight = exports.terrainHeight = 50;
-var terrainSize = exports.terrainSize = 100;
-void 0;
-void 0;
-void 0;
-var inc = exports.inc = function inc(x) {
-    return x + 1;
-};
-var dec = exports.dec = function dec(x) {
-    return x - 1;
-};
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-var midpoint = exports.midpoint = function midpoint(a, b) {
-    return (a + b) / 2;
-};
-var average2 = exports.average2 = function average2(a, b) {
-    return (a + b) / 2;
-};
-var average4 = exports.average4 = function average4(a, b, c, d) {
-    return (a + b + c + d) / 4;
-};
-var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
-    return function () {
-        var totalø1 = 0;
-        var countø1 = 0;
-        a ? (function () {
-            totalø1 = totalø1 + a;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        b ? (function () {
-            totalø1 = totalø1 + b;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        c ? (function () {
-            totalø1 = totalø1 + c;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        d ? (function () {
-            totalø1 = totalø1 + d;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        return totalø1 / countø1;
-    }.call(this);
-};
-var rand = exports.rand = function rand() {
-    return Math.random();
-};
-var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
-    return spread * rand() * 2 - spread;
-};
-var jitter = exports.jitter = function jitter(value, spread) {
-    return value + randAroundZero(spread);
-};
-var heightmapResolution = exports.heightmapResolution = function heightmapResolution(heightmap) {
-    return heightmap.shape[0];
-};
-var heightmapLastIndex = exports.heightmapLastIndex = function heightmapLastIndex(heightmap) {
-    return dec(heightmapResolution(heightmap));
-};
-var heightmapCenterIndex = exports.heightmapCenterIndex = function heightmapCenterIndex(heightmap) {
-    return midpoint(0, heightmapLastIndex(heightmap));
-};
-var heightmapGet = exports.heightmapGet = function heightmapGet(heightmap, x, y) {
-    return heightmap.get(x, y);
-};
-var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(heightmap, x, y) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        return 0 <= x && x <= lastø1 && (0 <= y && y <= lastø1) ? (function () {
-            return heightmapGet(heightmap, x, y);
-        })() : void 0;
-    }.call(this);
-};
-var heightmapSet = exports.heightmapSet = function heightmapSet(heightmap, x, y, val) {
-    return heightmap.set(x, y, val);
-};
-var heightmapSetIfUnset = exports.heightmapSetIfUnset = function heightmapSetIfUnset(heightmap, x, y, val) {
-    return 0 == heightmapGet(heightmap, x, y) ? (function () {
-        return heightmapSet(heightmap, x, y, val);
-    })() : void 0;
-};
-var normalize = exports.normalize = function normalize(heightmap) {
-    return function () {
-        var maxø1 = 0 - Infinity;
-        var minø1 = Infinity;
-        (function () {
-            var array2ø1 = heightmap;
-            return function () {
-                var G__3ø1 = array2ø1.data.length;
-                return function loop() {
-                    var recur = loop;
-                    var index1ø1 = 0;
-                    do {
-                        recur = index1ø1 < G__3ø1 ? (function () {
-                            (function () {
-                                var elø1 = array2ø1.data[index1ø1];
-                                maxø1 < elø1 ? (function () {
-                                    return maxø1 = elø1;
-                                })() : void 0;
-                                return minø1 > elø1 ? (function () {
-                                    return minø1 = elø1;
-                                })() : void 0;
-                            }.call(this));
-                            return loop[0] = inc(index1ø1), loop;
-                        })() : void 0;
-                    } while (index1ø1 = loop[0], recur === loop);
-                    return recur;
-                }.call(this);
-            }.call(this);
-        }.call(this));
-        return function () {
-            var spanø1 = maxø1 - minø1;
-            return function () {
-                var array4ø1 = heightmap;
-                return function () {
-                    var G__5ø1 = array4ø1.shape[0];
-                    return function loop() {
-                        var recur = loop;
-                        var xø1 = 0;
-                        do {
-                            recur = xø1 < G__5ø1 ? (function () {
-                                (function () {
-                                    var G__6ø1 = array4ø1.shape[1];
-                                    return function loop() {
-                                        var recur = loop;
-                                        var yø1 = 0;
-                                        do {
-                                            recur = yø1 < G__6ø1 ? (function () {
-                                                (function () {
-                                                    return heightmapSet(heightmap, xø1, yø1, (heightmapGet(heightmap, xø1, yø1) - minø1) / spanø1);
-                                                })();
-                                                return loop[0] = inc(yø1), loop;
-                                            })() : void 0;
-                                        } while (yø1 = loop[0], recur === loop);
-                                        return recur;
-                                    }.call(this);
-                                }.call(this));
-                                return loop[0] = inc(xø1), loop;
-                            })() : void 0;
-                        } while (xø1 = loop[0], recur === loop);
-                        return recur;
-                    }.call(this);
-                }.call(this);
-            }.call(this);
-        }.call(this);
-    }.call(this);
-};
-var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
-    return function () {
-        var resolutionø1 = Math.pow(2, exponent) + 1;
-        return function () {
-            var heightmapø1 = ndarray(new Float64Array(resolutionø1 * resolutionø1), [
-                resolutionø1,
-                resolutionø1
-            ]);
-            heightmapø1.exponent = exponent;
-            heightmapø1.resolution = resolutionø1;
-            heightmapø1.last = dec(resolutionø1);
-            return heightmapø1;
-        }.call(this);
-    }.call(this);
-};
-var topLeftCorner = exports.topLeftCorner = function topLeftCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(0, 0).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var topRightCorner = exports.topRightCorner = function topRightCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(centerø1, 0).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var bottomLeftCorner = exports.bottomLeftCorner = function bottomLeftCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(0, centerø1).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var bottomRightCorner = exports.bottomRightCorner = function bottomRightCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(centerø1, centerø1).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var mpdInitCorners = exports.mpdInitCorners = function mpdInitCorners(heightmap) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        heightmapSet(heightmap, 0, 0, rand());
-        heightmapSet(heightmap, 0, lastø1, rand());
-        heightmapSet(heightmap, lastø1, 0, rand());
-        return heightmapSet(heightmap, lastø1, lastø1, rand());
-    }.call(this);
-};
-var mpdDisplace = exports.mpdDisplace = function mpdDisplace(heightmap, spread, spreadReduction) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        var cø1 = midpoint(0, lastø1);
-        var bottomLeftø1 = heightmapGet(heightmap, 0, 0);
-        var bottomRightø1 = heightmapGet(heightmap, lastø1, 0);
-        var topLeftø1 = heightmapGet(heightmap, 0, lastø1);
-        var topRightø1 = heightmapGet(heightmap, lastø1, lastø1);
-        var topø1 = average2(topLeftø1, topRightø1);
-        var leftø1 = average2(bottomLeftø1, topLeftø1);
-        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
-        var rightø1 = average2(bottomRightø1, topRightø1);
-        var centerø1 = average4(topø1, leftø1, bottomø1, rightø1);
-        var nextSpreadø1 = spread * spreadReduction;
-        heightmapSetIfUnset(heightmap, cø1, 0, jitter(bottomø1, spread));
-        heightmapSetIfUnset(heightmap, cø1, lastø1, jitter(topø1, spread));
-        heightmapSetIfUnset(heightmap, 0, cø1, jitter(leftø1, spread));
-        heightmapSetIfUnset(heightmap, lastø1, cø1, jitter(rightø1, spread));
-        heightmapSetIfUnset(heightmap, cø1, cø1, jitter(centerø1, spread));
-        return !(3 == heightmapResolution(heightmap)) ? (function () {
-            heightmapSetIfUnset(heightmap, cø1, 0, jitter(bottomø1, spread));
-            heightmapSetIfUnset(heightmap, cø1, lastø1, jitter(topø1, spread));
-            heightmapSetIfUnset(heightmap, 0, cø1, jitter(leftø1, spread));
-            heightmapSetIfUnset(heightmap, lastø1, cø1, jitter(rightø1, spread));
-            heightmapSetIfUnset(heightmap, cø1, cø1, jitter(centerø1, spread));
-            mpdDisplace(topLeftCorner(heightmap), nextSpreadø1, spreadReduction);
-            mpdDisplace(topRightCorner(heightmap), nextSpreadø1, spreadReduction);
-            mpdDisplace(bottomLeftCorner(heightmap), nextSpreadø1, spreadReduction);
-            return mpdDisplace(bottomRightCorner(heightmap), nextSpreadø1, spreadReduction);
-        })() : void 0;
-    }.call(this);
-};
-var midpointDisplacement = exports.midpointDisplacement = function midpointDisplacement(heightmap) {
-    return function () {
-        var initialSpreadø1 = 0.3;
-        var spreadReductionø1 = 0.55;
-        mpdInitCorners(heightmap);
-        mpdDisplace(heightmap, initialSpreadø1, spreadReductionø1);
-        return normalize(heightmap);
-    }.call(this);
-};
-var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
-    return function () {
-        var lightø1 = new THREE.DirectionalLight(16777215, 1);
-        lightø1.position.set(100, 0, 150);
-        return lightø1;
-    }.call(this);
-};
-var makeCamera = exports.makeCamera = function makeCamera() {
-    return function () {
-        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
-        cameraø1.position.set(0, -100, 150);
-        return cameraø1;
-    }.call(this);
-};
-var makeRenderer = exports.makeRenderer = function makeRenderer() {
-    return function () {
-        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
-        rendererø1.setClearColor(16777215);
-        rendererø1.setSize(width, height);
-        rendererø1.setPixelRatio(2);
-        return rendererø1;
-    }.call(this);
-};
-var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
-    return function () {
-        var resolutionø1 = heightmap.shape[0];
-        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, resolutionø1 - 1, resolutionø1 - 1);
-        return geometryø1;
-    }.call(this);
-};
-var makeControls = exports.makeControls = function makeControls(camera, renderer) {
-    return function () {
-        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
-        controlsø1.rotateSpeed = 1.4;
-        controlsø1.zoomSpeed = 0.5;
-        controlsø1.staticMoving = true;
-        controlsø1.dynamicDampingFactor = 0.3;
-        return controlsø1;
-    }.call(this);
-};
-var makePlane = exports.makePlane = function makePlane(geometry) {
-    return function () {
-        var materialø1 = new THREE.MeshLambertMaterial({
-            'wireframe': wireframe,
-            'wireframeLinewidth': wireframeWidth,
-            'color': 47872
-        });
-        return new THREE.Mesh(geometry, materialø1);
-    }.call(this);
-};
-var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
-    return function () {
-        var containerø1 = document.getElementById(elName);
-        var settingsø1 = document.createElement('div');
-        var refreshButtonø1 = document.createElement('button');
-        var buttonTextø1 = document.createTextNode('Refresh');
-        var cancelScrollø1 = function (e) {
-            return e.preventDefault();
-        };
-        refreshButtonø1.onclick = refreshFn;
-        renderer.domElement.onmousewheel = cancelScrollø1;
-        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
-        refreshButtonø1.appendChild(buttonTextø1);
-        containerø1.appendChild(renderer.domElement);
-        containerø1.appendChild(settingsø1);
-        return settingsø1.appendChild(refreshButtonø1);
-    }.call(this);
-};
-var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
-    (function loop() {
-        var recur = loop;
-        var iø1 = 0;
-        do {
-            recur = iø1 < geometry.vertices.length ? (function () {
-                geometry.vertices[iø1].z = terrainHeight * heightmap.data[iø1];
-                return loop[0] = iø1 + 1, loop;
-            })() : void 0;
-        } while (iø1 = loop[0], recur === loop);
-        return recur;
-    }.call(this));
-    geometry.computeVertexNormals();
-    return geometry;
-};
-var makeFinal = exports.makeFinal = function makeFinal(elementId) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var geometry = void 0;
-    var plane = void 0;
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    var refresh = function refresh() {
-        return function () {
-            var heightmapø1 = makeHeightmap(6);
-            console.log('Generating terrain...');
-            (function () {
-                var G__7ø1 = new Date().getTime();
-                var G__9ø1 = (function () {
-                    return midpointDisplacement(heightmapø1);
-                })();
-                var G__8ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__8ø1 - G__7ø1) + 'ms.');
-                return G__9ø1;
-            }.call(this));
-            console.log('Rebuilding geometry...');
-            (function () {
-                var G__10ø1 = new Date().getTime();
-                var G__12ø1 = (function () {
-                    geometry = makeGeometry(heightmapø1);
-                    return updateGeometry(geometry, heightmapø1);
-                })();
-                var G__11ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__11ø1 - G__10ø1) + 'ms.');
-                return G__12ø1;
-            }.call(this));
-            console.log('Rebuilding plane...');
-            return function () {
-                var G__13ø1 = new Date().getTime();
-                var G__15ø1 = (function () {
-                    scene.remove(plane);
-                    plane = makePlane(geometry);
-                    return scene.add(plane);
-                })();
-                var G__14ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__14ø1 - G__13ø1) + 'ms.');
-                return G__15ø1;
-            }.call(this);
-        }.call(this);
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    refresh();
-    render();
-    return void 0;
-};
-var run = exports.run = function run() {
-    return makeFinal('demo-final');
-};
-$(run);
-
-
-},{"ndarray":4}],2:[function(require,module,exports){
-"use strict"
-
-function iota(n) {
-  var result = new Array(n)
-  for(var i=0; i<n; ++i) {
-    result[i] = i
-  }
-  return result
-}
-
-module.exports = iota
-},{}],3:[function(require,module,exports){
-/**
- * Determine if an object is Buffer
- *
- * Author:   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
- * License:  MIT
- *
- * `npm install is-buffer`
- */
-
-module.exports = function (obj) {
-  return !!(obj != null &&
-    (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor)
-      (obj.constructor &&
-      typeof obj.constructor.isBuffer === 'function' &&
-      obj.constructor.isBuffer(obj))
-    ))
-}
-
-},{}],4:[function(require,module,exports){
-var iota = require("iota-array")
-var isBuffer = require("is-buffer")
-
-var hasTypedArrays  = ((typeof Float64Array) !== "undefined")
-
-function compare1st(a, b) {
-  return a[0] - b[0]
-}
-
-function order() {
-  var stride = this.stride
-  var terms = new Array(stride.length)
-  var i
-  for(i=0; i<terms.length; ++i) {
-    terms[i] = [Math.abs(stride[i]), i]
-  }
-  terms.sort(compare1st)
-  var result = new Array(terms.length)
-  for(i=0; i<result.length; ++i) {
-    result[i] = terms[i][1]
-  }
-  return result
-}
-
-function compileConstructor(dtype, dimension) {
-  var className = ["View", dimension, "d", dtype].join("")
-  if(dimension < 0) {
-    className = "View_Nil" + dtype
-  }
-  var useGetters = (dtype === "generic")
-
-  if(dimension === -1) {
-    //Special case for trivial arrays
-    var code =
-      "function "+className+"(a){this.data=a;};\
-var proto="+className+".prototype;\
-proto.dtype='"+dtype+"';\
-proto.index=function(){return -1};\
-proto.size=0;\
-proto.dimension=-1;\
-proto.shape=proto.stride=proto.order=[];\
-proto.lo=proto.hi=proto.transpose=proto.step=\
-function(){return new "+className+"(this.data);};\
-proto.get=proto.set=function(){};\
-proto.pick=function(){return null};\
-return function construct_"+className+"(a){return new "+className+"(a);}"
-    var procedure = new Function(code)
-    return procedure()
-  } else if(dimension === 0) {
-    //Special case for 0d arrays
-    var code =
-      "function "+className+"(a,d) {\
-this.data = a;\
-this.offset = d\
-};\
-var proto="+className+".prototype;\
-proto.dtype='"+dtype+"';\
-proto.index=function(){return this.offset};\
-proto.dimension=0;\
-proto.size=1;\
-proto.shape=\
-proto.stride=\
-proto.order=[];\
-proto.lo=\
-proto.hi=\
-proto.transpose=\
-proto.step=function "+className+"_copy() {\
-return new "+className+"(this.data,this.offset)\
-};\
-proto.pick=function "+className+"_pick(){\
-return TrivialArray(this.data);\
-};\
-proto.valueOf=proto.get=function "+className+"_get(){\
-return "+(useGetters ? "this.data.get(this.offset)" : "this.data[this.offset]")+
-"};\
-proto.set=function "+className+"_set(v){\
-return "+(useGetters ? "this.data.set(this.offset,v)" : "this.data[this.offset]=v")+"\
-};\
-return function construct_"+className+"(a,b,c,d){return new "+className+"(a,d)}"
-    var procedure = new Function("TrivialArray", code)
-    return procedure(CACHED_CONSTRUCTORS[dtype][0])
-  }
-
-  var code = ["'use strict'"]
-
-  //Create constructor for view
-  var indices = iota(dimension)
-  var args = indices.map(function(i) { return "i"+i })
-  var index_str = "this.offset+" + indices.map(function(i) {
-        return "this.stride[" + i + "]*i" + i
-      }).join("+")
-  var shapeArg = indices.map(function(i) {
-      return "b"+i
-    }).join(",")
-  var strideArg = indices.map(function(i) {
-      return "c"+i
-    }).join(",")
-  code.push(
-    "function "+className+"(a," + shapeArg + "," + strideArg + ",d){this.data=a",
-      "this.shape=[" + shapeArg + "]",
-      "this.stride=[" + strideArg + "]",
-      "this.offset=d|0}",
-    "var proto="+className+".prototype",
-    "proto.dtype='"+dtype+"'",
-    "proto.dimension="+dimension)
-
-  //view.size:
-  code.push("Object.defineProperty(proto,'size',{get:function "+className+"_size(){\
-return "+indices.map(function(i) { return "this.shape["+i+"]" }).join("*"),
-"}})")
-
-  //view.order:
-  if(dimension === 1) {
-    code.push("proto.order=[0]")
-  } else {
-    code.push("Object.defineProperty(proto,'order',{get:")
-    if(dimension < 4) {
-      code.push("function "+className+"_order(){")
-      if(dimension === 2) {
-        code.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})")
-      } else if(dimension === 3) {
-        code.push(
-"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);\
-if(s0>s1){\
-if(s1>s2){\
-return [2,1,0];\
-}else if(s0>s2){\
-return [1,2,0];\
-}else{\
-return [1,0,2];\
-}\
-}else if(s0>s2){\
-return [2,0,1];\
-}else if(s2>s1){\
-return [0,1,2];\
-}else{\
-return [0,2,1];\
-}}})")
-      }
-    } else {
-      code.push("ORDER})")
-    }
-  }
-
-  //view.set(i0, ..., v):
-  code.push(
-"proto.set=function "+className+"_set("+args.join(",")+",v){")
-  if(useGetters) {
-    code.push("return this.data.set("+index_str+",v)}")
-  } else {
-    code.push("return this.data["+index_str+"]=v}")
-  }
-
-  //view.get(i0, ...):
-  code.push("proto.get=function "+className+"_get("+args.join(",")+"){")
-  if(useGetters) {
-    code.push("return this.data.get("+index_str+")}")
-  } else {
-    code.push("return this.data["+index_str+"]}")
-  }
-
-  //view.index:
-  code.push(
-    "proto.index=function "+className+"_index(", args.join(), "){return "+index_str+"}")
-
-  //view.hi():
-  code.push("proto.hi=function "+className+"_hi("+args.join(",")+"){return new "+className+"(this.data,"+
-    indices.map(function(i) {
-      return ["(typeof i",i,"!=='number'||i",i,"<0)?this.shape[", i, "]:i", i,"|0"].join("")
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "this.stride["+i + "]"
-    }).join(",")+",this.offset)}")
-
-  //view.lo():
-  var a_vars = indices.map(function(i) { return "a"+i+"=this.shape["+i+"]" })
-  var c_vars = indices.map(function(i) { return "c"+i+"=this.stride["+i+"]" })
-  code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(","))
-  for(var i=0; i<dimension; ++i) {
-    code.push(
-"if(typeof i"+i+"==='number'&&i"+i+">=0){\
-d=i"+i+"|0;\
-b+=c"+i+"*d;\
-a"+i+"-=d}")
-  }
-  code.push("return new "+className+"(this.data,"+
-    indices.map(function(i) {
-      return "a"+i
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "c"+i
-    }).join(",")+",b)}")
-
-  //view.step():
-  code.push("proto.step=function "+className+"_step("+args.join(",")+"){var "+
-    indices.map(function(i) {
-      return "a"+i+"=this.shape["+i+"]"
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "b"+i+"=this.stride["+i+"]"
-    }).join(",")+",c=this.offset,d=0,ceil=Math.ceil")
-  for(var i=0; i<dimension; ++i) {
-    code.push(
-"if(typeof i"+i+"==='number'){\
-d=i"+i+"|0;\
-if(d<0){\
-c+=b"+i+"*(a"+i+"-1);\
-a"+i+"=ceil(-a"+i+"/d)\
-}else{\
-a"+i+"=ceil(a"+i+"/d)\
-}\
-b"+i+"*=d\
-}")
-  }
-  code.push("return new "+className+"(this.data,"+
-    indices.map(function(i) {
-      return "a" + i
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "b" + i
-    }).join(",")+",c)}")
-
-  //view.transpose():
-  var tShape = new Array(dimension)
-  var tStride = new Array(dimension)
-  for(var i=0; i<dimension; ++i) {
-    tShape[i] = "a[i"+i+"]"
-    tStride[i] = "b[i"+i+"]"
-  }
-  code.push("proto.transpose=function "+className+"_transpose("+args+"){"+
-    args.map(function(n,idx) { return n + "=(" + n + "===undefined?" + idx + ":" + n + "|0)"}).join(";"),
-    "var a=this.shape,b=this.stride;return new "+className+"(this.data,"+tShape.join(",")+","+tStride.join(",")+",this.offset)}")
-
-  //view.pick():
-  code.push("proto.pick=function "+className+"_pick("+args+"){var a=[],b=[],c=this.offset")
-  for(var i=0; i<dimension; ++i) {
-    code.push("if(typeof i"+i+"==='number'&&i"+i+">=0){c=(c+this.stride["+i+"]*i"+i+")|0}else{a.push(this.shape["+i+"]);b.push(this.stride["+i+"])}")
-  }
-  code.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}")
-
-  //Add return statement
-  code.push("return function construct_"+className+"(data,shape,stride,offset){return new "+className+"(data,"+
-    indices.map(function(i) {
-      return "shape["+i+"]"
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "stride["+i+"]"
-    }).join(",")+",offset)}")
-
-  //Compile procedure
-  var procedure = new Function("CTOR_LIST", "ORDER", code.join("\n"))
-  return procedure(CACHED_CONSTRUCTORS[dtype], order)
-}
-
-function arrayDType(data) {
-  if(isBuffer(data)) {
-    return "buffer"
-  }
-  if(hasTypedArrays) {
-    switch(Object.prototype.toString.call(data)) {
-      case "[object Float64Array]":
-        return "float64"
-      case "[object Float32Array]":
-        return "float32"
-      case "[object Int8Array]":
-        return "int8"
-      case "[object Int16Array]":
-        return "int16"
-      case "[object Int32Array]":
-        return "int32"
-      case "[object Uint8Array]":
-        return "uint8"
-      case "[object Uint16Array]":
-        return "uint16"
-      case "[object Uint32Array]":
-        return "uint32"
-      case "[object Uint8ClampedArray]":
-        return "uint8_clamped"
-    }
-  }
-  if(Array.isArray(data)) {
-    return "array"
-  }
-  return "generic"
-}
-
-var CACHED_CONSTRUCTORS = {
-  "float32":[],
-  "float64":[],
-  "int8":[],
-  "int16":[],
-  "int32":[],
-  "uint8":[],
-  "uint16":[],
-  "uint32":[],
-  "array":[],
-  "uint8_clamped":[],
-  "buffer":[],
-  "generic":[]
-}
-
-;(function() {
-  for(var id in CACHED_CONSTRUCTORS) {
-    CACHED_CONSTRUCTORS[id].push(compileConstructor(id, -1))
-  }
-});
-
-function wrappedNDArrayCtor(data, shape, stride, offset) {
-  if(data === undefined) {
-    var ctor = CACHED_CONSTRUCTORS.array[0]
-    return ctor([])
-  } else if(typeof data === "number") {
-    data = [data]
-  }
-  if(shape === undefined) {
-    shape = [ data.length ]
-  }
-  var d = shape.length
-  if(stride === undefined) {
-    stride = new Array(d)
-    for(var i=d-1, sz=1; i>=0; --i) {
-      stride[i] = sz
-      sz *= shape[i]
-    }
-  }
-  if(offset === undefined) {
-    offset = 0
-    for(var i=0; i<d; ++i) {
-      if(stride[i] < 0) {
-        offset -= (shape[i]-1)*stride[i]
-      }
-    }
-  }
-  var dtype = arrayDType(data)
-  var ctor_list = CACHED_CONSTRUCTORS[dtype]
-  while(ctor_list.length <= d+1) {
-    ctor_list.push(compileConstructor(dtype, ctor_list.length-1))
-  }
-  var ctor = ctor_list[d+1]
-  return ctor(data, shape, stride, offset)
-}
-
-module.exports = wrappedNDArrayCtor
-
-},{"iota-array":2,"is-buffer":3}]},{},[1])
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Vzci9sb2NhbC9saWIvbm9kZV9tb2R1bGVzL2Jyb3dzZXJpZnkvbm9kZV9tb2R1bGVzL2Jyb3dzZXItcGFjay9fcHJlbHVkZS5qcyIsIm1lZGlhL2pzL3dpc3AvYW5vbnltb3VzLndpc3AiLCJub2RlX21vZHVsZXMvaW90YS1hcnJheS9pb3RhLmpzIiwibm9kZV9tb2R1bGVzL2lzLWJ1ZmZlci9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9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c3RyaWRlID09PSB1bmRlZmluZWQpIHtcbiAgICBzdHJpZGUgPSBuZXcgQXJyYXkoZClcbiAgICBmb3IodmFyIGk9ZC0xLCBzej0xOyBpPj0wOyAtLWkpIHtcbiAgICAgIHN0cmlkZVtpXSA9IHN6XG4gICAgICBzeiAqPSBzaGFwZVtpXVxuICAgIH1cbiAgfVxuICBpZihvZmZzZXQgPT09IHVuZGVmaW5lZCkge1xuICAgIG9mZnNldCA9IDBcbiAgICBmb3IodmFyIGk9MDsgaTxkOyArK2kpIHtcbiAgICAgIGlmKHN0cmlkZVtpXSA8IDApIHtcbiAgICAgICAgb2Zmc2V0IC09IChzaGFwZVtpXS0xKSpzdHJpZGVbaV1cbiAgICAgIH1cbiAgICB9XG4gIH1cbiAgdmFyIGR0eXBlID0gYXJyYXlEVHlwZShkYXRhKVxuICB2YXIgY3Rvcl9saXN0ID0gQ0FDSEVEX0NPTlNUUlVDVE9SU1tkdHlwZV1cbiAgd2hpbGUoY3Rvcl9saXN0Lmxlbmd0aCA8PSBkKzEpIHtcbiAgICBjdG9yX2xpc3QucHVzaChjb21waWxlQ29uc3RydWN0b3IoZHR5cGUsIGN0b3JfbGlzdC5sZW5ndGgtMSkpXG4gIH1cbiAgdmFyIGN0b3IgPSBjdG9yX2xpc3RbZCsxXVxuICByZXR1cm4gY3RvcihkYXRhLCBzaGFwZSwgc3RyaWRlLCBvZmZzZXQpXG59XG5cbm1vZHVsZS5leHBvcnRzID0gd3JhcHBlZE5EQXJyYXlDdG9yXG4iXX0=
--- a/media/js/terrain3.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,951 +0,0 @@
-(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
-{
-    var _ns_ = {
-        id: 'demo',
-        doc: void 0
-    };
-    var ndarray = require('ndarray');
-}
-var width = exports.width = 610;
-var height = exports.height = 400;
-var wireframe = exports.wireframe = true;
-var wireframeWidth = exports.wireframeWidth = 1.2;
-var terrainHeight = exports.terrainHeight = 50;
-var terrainSize = exports.terrainSize = 100;
-void 0;
-void 0;
-void 0;
-var inc = exports.inc = function inc(x) {
-    return x + 1;
-};
-var dec = exports.dec = function dec(x) {
-    return x - 1;
-};
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-var midpoint = exports.midpoint = function midpoint(a, b) {
-    return (a + b) / 2;
-};
-var average2 = exports.average2 = function average2(a, b) {
-    return (a + b) / 2;
-};
-var average4 = exports.average4 = function average4(a, b, c, d) {
-    return (a + b + c + d) / 4;
-};
-var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
-    return function () {
-        var totalø1 = 0;
-        var countø1 = 0;
-        a ? (function () {
-            totalø1 = totalø1 + a;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        b ? (function () {
-            totalø1 = totalø1 + b;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        c ? (function () {
-            totalø1 = totalø1 + c;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        d ? (function () {
-            totalø1 = totalø1 + d;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        return totalø1 / countø1;
-    }.call(this);
-};
-var isEven = exports.isEven = function isEven(n) {
-    return 0 == n % 2;
-};
-var isOdd = exports.isOdd = function isOdd(n) {
-    return 1 == n % 2;
-};
-var rand = exports.rand = function rand() {
-    return Math.random();
-};
-var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
-    return spread * rand() * 2 - spread;
-};
-var jitter = exports.jitter = function jitter(value, spread) {
-    return value + randAroundZero(spread);
-};
-var heightmapResolution = exports.heightmapResolution = function heightmapResolution(heightmap) {
-    return heightmap.shape[0];
-};
-var heightmapLastIndex = exports.heightmapLastIndex = function heightmapLastIndex(heightmap) {
-    return dec(heightmapResolution(heightmap));
-};
-var heightmapCenterIndex = exports.heightmapCenterIndex = function heightmapCenterIndex(heightmap) {
-    return midpoint(0, heightmapLastIndex(heightmap));
-};
-var heightmapGet = exports.heightmapGet = function heightmapGet(heightmap, x, y) {
-    return heightmap.get(x, y);
-};
-var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(heightmap, x, y) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        return 0 <= x && x <= lastø1 && (0 <= y && y <= lastø1) ? (function () {
-            return heightmapGet(heightmap, x, y);
-        })() : void 0;
-    }.call(this);
-};
-var heightmapSet = exports.heightmapSet = function heightmapSet(heightmap, x, y, val) {
-    return heightmap.set(x, y, val);
-};
-var heightmapSetIfUnset = exports.heightmapSetIfUnset = function heightmapSetIfUnset(heightmap, x, y, val) {
-    return 0 == heightmapGet(heightmap, x, y) ? (function () {
-        return heightmapSet(heightmap, x, y, val);
-    })() : void 0;
-};
-var normalize = exports.normalize = function normalize(heightmap) {
-    return function () {
-        var maxø1 = 0 - Infinity;
-        var minø1 = Infinity;
-        (function () {
-            var array2ø1 = heightmap;
-            return function () {
-                var G__3ø1 = array2ø1.data.length;
-                return function loop() {
-                    var recur = loop;
-                    var index1ø1 = 0;
-                    do {
-                        recur = index1ø1 < G__3ø1 ? (function () {
-                            (function () {
-                                var elø1 = array2ø1.data[index1ø1];
-                                maxø1 < elø1 ? (function () {
-                                    return maxø1 = elø1;
-                                })() : void 0;
-                                return minø1 > elø1 ? (function () {
-                                    return minø1 = elø1;
-                                })() : void 0;
-                            }.call(this));
-                            return loop[0] = inc(index1ø1), loop;
-                        })() : void 0;
-                    } while (index1ø1 = loop[0], recur === loop);
-                    return recur;
-                }.call(this);
-            }.call(this);
-        }.call(this));
-        return function () {
-            var spanø1 = maxø1 - minø1;
-            return function () {
-                var array4ø1 = heightmap;
-                return function () {
-                    var G__5ø1 = array4ø1.shape[0];
-                    return function loop() {
-                        var recur = loop;
-                        var xø1 = 0;
-                        do {
-                            recur = xø1 < G__5ø1 ? (function () {
-                                (function () {
-                                    var G__6ø1 = array4ø1.shape[1];
-                                    return function loop() {
-                                        var recur = loop;
-                                        var yø1 = 0;
-                                        do {
-                                            recur = yø1 < G__6ø1 ? (function () {
-                                                (function () {
-                                                    return heightmapSet(heightmap, xø1, yø1, (heightmapGet(heightmap, xø1, yø1) - minø1) / spanø1);
-                                                })();
-                                                return loop[0] = inc(yø1), loop;
-                                            })() : void 0;
-                                        } while (yø1 = loop[0], recur === loop);
-                                        return recur;
-                                    }.call(this);
-                                }.call(this));
-                                return loop[0] = inc(xø1), loop;
-                            })() : void 0;
-                        } while (xø1 = loop[0], recur === loop);
-                        return recur;
-                    }.call(this);
-                }.call(this);
-            }.call(this);
-        }.call(this);
-    }.call(this);
-};
-var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
-    return function () {
-        var resolutionø1 = Math.pow(2, exponent) + 1;
-        return function () {
-            var heightmapø1 = ndarray(new Float64Array(resolutionø1 * resolutionø1), [
-                resolutionø1,
-                resolutionø1
-            ]);
-            heightmapø1.exponent = exponent;
-            heightmapø1.resolution = resolutionø1;
-            heightmapø1.last = dec(resolutionø1);
-            return heightmapø1;
-        }.call(this);
-    }.call(this);
-};
-var topLeftCorner = exports.topLeftCorner = function topLeftCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(0, 0).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var topRightCorner = exports.topRightCorner = function topRightCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(centerø1, 0).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var bottomLeftCorner = exports.bottomLeftCorner = function bottomLeftCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(0, centerø1).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var bottomRightCorner = exports.bottomRightCorner = function bottomRightCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(centerø1, centerø1).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var dsInitCorners = exports.dsInitCorners = function dsInitCorners(heightmap) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        heightmapSet(heightmap, 0, 0, rand());
-        heightmapSet(heightmap, 0, lastø1, rand());
-        heightmapSet(heightmap, lastø1, 0, rand());
-        return heightmapSet(heightmap, lastø1, lastø1, rand());
-    }.call(this);
-};
-var dsSquare = exports.dsSquare = function dsSquare(heightmap, x, y, radius, spread) {
-    return function () {
-        var newHeightø1 = jitter(average4(heightmapGet(heightmap, x - radius, y - radius), heightmapGet(heightmap, x - radius, y + radius), heightmapGet(heightmap, x + radius, y - radius), heightmapGet(heightmap, x + radius, y + radius)), spread);
-        return heightmapSet(heightmap, x, y, newHeightø1);
-    }.call(this);
-};
-var dsDiamond = exports.dsDiamond = function dsDiamond(heightmap, x, y, radius, spread) {
-    return function () {
-        var newHeightø1 = jitter(safeAverage(heightmapGetSafe(heightmap, x - radius, y), heightmapGetSafe(heightmap, x + radius, y), heightmapGetSafe(heightmap, x, y - radius), heightmapGetSafe(heightmap, x, y + radius)), spread);
-        return heightmapSet(heightmap, x, y, newHeightø1);
-    }.call(this);
-};
-var dsSquares = exports.dsSquares = function dsSquares(heightmap, radius, spread) {
-    return function () {
-        var start8ø1 = radius;
-        var end9ø1 = heightmapResolution(heightmap);
-        var stride7ø1 = 2 * radius;
-        return function loop() {
-            var recur = loop;
-            var xø1 = start8ø1;
-            do {
-                recur = xø1 < end9ø1 ? (function () {
-                    (function loop() {
-                        var recur = loop;
-                        var yø1 = start8ø1;
-                        do {
-                            recur = yø1 < end9ø1 ? (function () {
-                                (function () {
-                                    return dsSquare(heightmap, xø1, yø1, radius, spread);
-                                })();
-                                return loop[0] = yø1 + stride7ø1, loop;
-                            })() : void 0;
-                        } while (yø1 = loop[0], recur === loop);
-                        return recur;
-                    }.call(this));
-                    return loop[0] = xø1 + stride7ø1, loop;
-                })() : void 0;
-            } while (xø1 = loop[0], recur === loop);
-            return recur;
-        }.call(this);
-    }.call(this);
-};
-var dsDiamonds = exports.dsDiamonds = function dsDiamonds(heightmap, radius, spread) {
-    return function () {
-        var sizeø1 = heightmapResolution(heightmap);
-        return function () {
-            var start11ø1 = 0;
-            var end12ø1 = sizeø1;
-            var stride10ø1 = radius;
-            return function loop() {
-                var recur = loop;
-                var yø1 = start11ø1;
-                do {
-                    recur = yø1 < end12ø1 ? (function () {
-                        (function () {
-                            return function () {
-                                var shiftø1 = isEven(yø1 / radius) ? radius : 0;
-                                return function () {
-                                    var start14ø1 = shiftø1;
-                                    var end15ø1 = sizeø1;
-                                    var stride13ø1 = 2 * radius;
-                                    return function loop() {
-                                        var recur = loop;
-                                        var xø1 = start14ø1;
-                                        do {
-                                            recur = xø1 < end15ø1 ? (function () {
-                                                (function () {
-                                                    return dsDiamond(heightmap, xø1, yø1, radius, spread);
-                                                })();
-                                                return loop[0] = xø1 + stride13ø1, loop;
-                                            })() : void 0;
-                                        } while (xø1 = loop[0], recur === loop);
-                                        return recur;
-                                    }.call(this);
-                                }.call(this);
-                            }.call(this);
-                        })();
-                        return loop[0] = yø1 + stride10ø1, loop;
-                    })() : void 0;
-                } while (yø1 = loop[0], recur === loop);
-                return recur;
-            }.call(this);
-        }.call(this);
-    }.call(this);
-};
-var diamondSquare = exports.diamondSquare = function diamondSquare(heightmap) {
-    return function () {
-        var initialSpreadø1 = 0.3;
-        var spreadReductionø1 = 0.5;
-        var centerø1 = heightmapCenterIndex(heightmap);
-        var sizeø1 = heightmap.shape[0];
-        dsInitCorners(heightmap);
-        (function loop() {
-            var recur = loop;
-            var radiusø1 = centerø1;
-            var spreadø1 = initialSpreadø1;
-            do {
-                recur = radiusø1 >= 1 ? (function () {
-                    dsSquares(heightmap, radiusø1, spreadø1);
-                    dsDiamonds(heightmap, radiusø1, spreadø1);
-                    return loop[0] = radiusø1 / 2, loop[1] = spreadø1 * spreadReductionø1, loop;
-                })() : void 0;
-            } while (radiusø1 = loop[0], spreadø1 = loop[1], recur === loop);
-            return recur;
-        }.call(this));
-        return normalize(heightmap);
-    }.call(this);
-};
-var diamondSquare1 = exports.diamondSquare1 = function diamondSquare1(heightmap) {
-    dsInitCorners(heightmap);
-    return normalize(heightmap);
-};
-var diamondSquare2 = exports.diamondSquare2 = function diamondSquare2(heightmap) {
-    return function () {
-        var initialSpreadø1 = 0.3;
-        var spreadReductionø1 = 0.5;
-        var centerø1 = heightmapCenterIndex(heightmap);
-        var sizeø1 = heightmap.shape[0];
-        dsInitCorners(heightmap);
-        dsSquares(heightmap, centerø1, initialSpreadø1);
-        return normalize(heightmap);
-    }.call(this);
-};
-var diamondSquare3 = exports.diamondSquare3 = function diamondSquare3(heightmap) {
-    return function () {
-        var initialSpreadø1 = 0.3;
-        var spreadReductionø1 = 0.5;
-        var centerø1 = heightmapCenterIndex(heightmap);
-        var sizeø1 = heightmap.shape[0];
-        dsInitCorners(heightmap);
-        dsSquares(heightmap, centerø1, initialSpreadø1);
-        dsDiamonds(heightmap, centerø1, initialSpreadø1);
-        dsSquares(heightmap, centerø1 / 2, spreadReductionø1 * initialSpreadø1);
-        dsDiamonds(heightmap, centerø1 / 2, spreadReductionø1 * initialSpreadø1);
-        return normalize(heightmap);
-    }.call(this);
-};
-var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
-    return function () {
-        var lightø1 = new THREE.DirectionalLight(16777215, 1);
-        lightø1.position.set(100, 0, 150);
-        return lightø1;
-    }.call(this);
-};
-var makeCamera = exports.makeCamera = function makeCamera() {
-    return function () {
-        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
-        cameraø1.position.set(0, -100, 150);
-        return cameraø1;
-    }.call(this);
-};
-var makeRenderer = exports.makeRenderer = function makeRenderer() {
-    return function () {
-        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
-        rendererø1.setClearColor(16777215);
-        rendererø1.setSize(width, height);
-        rendererø1.setPixelRatio(2);
-        return rendererø1;
-    }.call(this);
-};
-var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
-    return function () {
-        var resolutionø1 = heightmap.shape[0];
-        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, resolutionø1 - 1, resolutionø1 - 1);
-        return geometryø1;
-    }.call(this);
-};
-var makeControls = exports.makeControls = function makeControls(camera, renderer) {
-    return function () {
-        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
-        controlsø1.rotateSpeed = 1.4;
-        controlsø1.zoomSpeed = 0.5;
-        controlsø1.staticMoving = true;
-        controlsø1.dynamicDampingFactor = 0.3;
-        return controlsø1;
-    }.call(this);
-};
-var makePlane = exports.makePlane = function makePlane(geometry) {
-    return function () {
-        var materialø1 = new THREE.MeshLambertMaterial({
-            'wireframe': wireframe,
-            'wireframeLinewidth': wireframeWidth,
-            'color': 47872
-        });
-        return new THREE.Mesh(geometry, materialø1);
-    }.call(this);
-};
-var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
-    return function () {
-        var containerø1 = document.getElementById(elName);
-        var settingsø1 = document.createElement('div');
-        var refreshButtonø1 = document.createElement('button');
-        var buttonTextø1 = document.createTextNode('Refresh');
-        var cancelScrollø1 = function (e) {
-            return e.preventDefault();
-        };
-        refreshButtonø1.onclick = refreshFn;
-        renderer.domElement.onmousewheel = cancelScrollø1;
-        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
-        refreshButtonø1.appendChild(buttonTextø1);
-        containerø1.appendChild(renderer.domElement);
-        containerø1.appendChild(settingsø1);
-        return settingsø1.appendChild(refreshButtonø1);
-    }.call(this);
-};
-var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
-    (function loop() {
-        var recur = loop;
-        var iø1 = 0;
-        do {
-            recur = iø1 < geometry.vertices.length ? (function () {
-                geometry.vertices[iø1].z = terrainHeight * heightmap.data[iø1];
-                return loop[0] = iø1 + 1, loop;
-            })() : void 0;
-        } while (iø1 = loop[0], recur === loop);
-        return recur;
-    }.call(this));
-    geometry.computeVertexNormals();
-    return geometry;
-};
-var makeDemo = exports.makeDemo = function makeDemo(elementId, algorithm, size) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var geometry = void 0;
-    var plane = void 0;
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    var refresh = function refresh() {
-        return function () {
-            var heightmapø1 = makeHeightmap(size);
-            console.log('Generating terrain...');
-            (function () {
-                var G__16ø1 = new Date().getTime();
-                var G__18ø1 = (function () {
-                    return algorithm(heightmapø1);
-                })();
-                var G__17ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__17ø1 - G__16ø1) + 'ms.');
-                return G__18ø1;
-            }.call(this));
-            console.log('Rebuilding geometry...');
-            (function () {
-                var G__19ø1 = new Date().getTime();
-                var G__21ø1 = (function () {
-                    geometry = makeGeometry(heightmapø1);
-                    return updateGeometry(geometry, heightmapø1);
-                })();
-                var G__20ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__20ø1 - G__19ø1) + 'ms.');
-                return G__21ø1;
-            }.call(this));
-            console.log('Rebuilding plane...');
-            return function () {
-                var G__22ø1 = new Date().getTime();
-                var G__24ø1 = (function () {
-                    scene.remove(plane);
-                    plane = makePlane(geometry);
-                    return scene.add(plane);
-                })();
-                var G__23ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__23ø1 - G__22ø1) + 'ms.');
-                return G__24ø1;
-            }.call(this);
-        }.call(this);
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    refresh();
-    render();
-    return void 0;
-};
-var makeFinal = exports.makeFinal = function makeFinal(elementId) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var geometry = void 0;
-    var plane = void 0;
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    var refresh = function refresh() {
-        return function () {
-            var heightmapø1 = makeHeightmap(6);
-            console.log('Generating terrain...');
-            (function () {
-                var G__25ø1 = new Date().getTime();
-                var G__27ø1 = (function () {
-                    return diamondSquare(heightmapø1);
-                })();
-                var G__26ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__26ø1 - G__25ø1) + 'ms.');
-                return G__27ø1;
-            }.call(this));
-            console.log('Rebuilding geometry...');
-            (function () {
-                var G__28ø1 = new Date().getTime();
-                var G__30ø1 = (function () {
-                    geometry = makeGeometry(heightmapø1);
-                    return updateGeometry(geometry, heightmapø1);
-                })();
-                var G__29ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__29ø1 - G__28ø1) + 'ms.');
-                return G__30ø1;
-            }.call(this));
-            console.log('Rebuilding plane...');
-            return function () {
-                var G__31ø1 = new Date().getTime();
-                var G__33ø1 = (function () {
-                    scene.remove(plane);
-                    plane = makePlane(geometry);
-                    return scene.add(plane);
-                })();
-                var G__32ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__32ø1 - G__31ø1) + 'ms.');
-                return G__33ø1;
-            }.call(this);
-        }.call(this);
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    refresh();
-    render();
-    return void 0;
-};
-var run = exports.run = function run() {
-    makeDemo('demo-1', diamondSquare1, 2);
-    makeDemo('demo-2', diamondSquare2, 4);
-    makeDemo('demo-3', diamondSquare3, 4);
-    return makeFinal('demo-final');
-};
-$(run);
-
-
-},{"ndarray":4}],2:[function(require,module,exports){
-"use strict"
-
-function iota(n) {
-  var result = new Array(n)
-  for(var i=0; i<n; ++i) {
-    result[i] = i
-  }
-  return result
-}
-
-module.exports = iota
-},{}],3:[function(require,module,exports){
-/**
- * Determine if an object is Buffer
- *
- * Author:   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
- * License:  MIT
- *
- * `npm install is-buffer`
- */
-
-module.exports = function (obj) {
-  return !!(obj != null &&
-    (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor)
-      (obj.constructor &&
-      typeof obj.constructor.isBuffer === 'function' &&
-      obj.constructor.isBuffer(obj))
-    ))
-}
-
-},{}],4:[function(require,module,exports){
-var iota = require("iota-array")
-var isBuffer = require("is-buffer")
-
-var hasTypedArrays  = ((typeof Float64Array) !== "undefined")
-
-function compare1st(a, b) {
-  return a[0] - b[0]
-}
-
-function order() {
-  var stride = this.stride
-  var terms = new Array(stride.length)
-  var i
-  for(i=0; i<terms.length; ++i) {
-    terms[i] = [Math.abs(stride[i]), i]
-  }
-  terms.sort(compare1st)
-  var result = new Array(terms.length)
-  for(i=0; i<result.length; ++i) {
-    result[i] = terms[i][1]
-  }
-  return result
-}
-
-function compileConstructor(dtype, dimension) {
-  var className = ["View", dimension, "d", dtype].join("")
-  if(dimension < 0) {
-    className = "View_Nil" + dtype
-  }
-  var useGetters = (dtype === "generic")
-
-  if(dimension === -1) {
-    //Special case for trivial arrays
-    var code =
-      "function "+className+"(a){this.data=a;};\
-var proto="+className+".prototype;\
-proto.dtype='"+dtype+"';\
-proto.index=function(){return -1};\
-proto.size=0;\
-proto.dimension=-1;\
-proto.shape=proto.stride=proto.order=[];\
-proto.lo=proto.hi=proto.transpose=proto.step=\
-function(){return new "+className+"(this.data);};\
-proto.get=proto.set=function(){};\
-proto.pick=function(){return null};\
-return function construct_"+className+"(a){return new "+className+"(a);}"
-    var procedure = new Function(code)
-    return procedure()
-  } else if(dimension === 0) {
-    //Special case for 0d arrays
-    var code =
-      "function "+className+"(a,d) {\
-this.data = a;\
-this.offset = d\
-};\
-var proto="+className+".prototype;\
-proto.dtype='"+dtype+"';\
-proto.index=function(){return this.offset};\
-proto.dimension=0;\
-proto.size=1;\
-proto.shape=\
-proto.stride=\
-proto.order=[];\
-proto.lo=\
-proto.hi=\
-proto.transpose=\
-proto.step=function "+className+"_copy() {\
-return new "+className+"(this.data,this.offset)\
-};\
-proto.pick=function "+className+"_pick(){\
-return TrivialArray(this.data);\
-};\
-proto.valueOf=proto.get=function "+className+"_get(){\
-return "+(useGetters ? "this.data.get(this.offset)" : "this.data[this.offset]")+
-"};\
-proto.set=function "+className+"_set(v){\
-return "+(useGetters ? "this.data.set(this.offset,v)" : "this.data[this.offset]=v")+"\
-};\
-return function construct_"+className+"(a,b,c,d){return new "+className+"(a,d)}"
-    var procedure = new Function("TrivialArray", code)
-    return procedure(CACHED_CONSTRUCTORS[dtype][0])
-  }
-
-  var code = ["'use strict'"]
-
-  //Create constructor for view
-  var indices = iota(dimension)
-  var args = indices.map(function(i) { return "i"+i })
-  var index_str = "this.offset+" + indices.map(function(i) {
-        return "this.stride[" + i + "]*i" + i
-      }).join("+")
-  var shapeArg = indices.map(function(i) {
-      return "b"+i
-    }).join(",")
-  var strideArg = indices.map(function(i) {
-      return "c"+i
-    }).join(",")
-  code.push(
-    "function "+className+"(a," + shapeArg + "," + strideArg + ",d){this.data=a",
-      "this.shape=[" + shapeArg + "]",
-      "this.stride=[" + strideArg + "]",
-      "this.offset=d|0}",
-    "var proto="+className+".prototype",
-    "proto.dtype='"+dtype+"'",
-    "proto.dimension="+dimension)
-
-  //view.size:
-  code.push("Object.defineProperty(proto,'size',{get:function "+className+"_size(){\
-return "+indices.map(function(i) { return "this.shape["+i+"]" }).join("*"),
-"}})")
-
-  //view.order:
-  if(dimension === 1) {
-    code.push("proto.order=[0]")
-  } else {
-    code.push("Object.defineProperty(proto,'order',{get:")
-    if(dimension < 4) {
-      code.push("function "+className+"_order(){")
-      if(dimension === 2) {
-        code.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})")
-      } else if(dimension === 3) {
-        code.push(
-"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);\
-if(s0>s1){\
-if(s1>s2){\
-return [2,1,0];\
-}else if(s0>s2){\
-return [1,2,0];\
-}else{\
-return [1,0,2];\
-}\
-}else if(s0>s2){\
-return [2,0,1];\
-}else if(s2>s1){\
-return [0,1,2];\
-}else{\
-return [0,2,1];\
-}}})")
-      }
-    } else {
-      code.push("ORDER})")
-    }
-  }
-
-  //view.set(i0, ..., v):
-  code.push(
-"proto.set=function "+className+"_set("+args.join(",")+",v){")
-  if(useGetters) {
-    code.push("return this.data.set("+index_str+",v)}")
-  } else {
-    code.push("return this.data["+index_str+"]=v}")
-  }
-
-  //view.get(i0, ...):
-  code.push("proto.get=function "+className+"_get("+args.join(",")+"){")
-  if(useGetters) {
-    code.push("return this.data.get("+index_str+")}")
-  } else {
-    code.push("return this.data["+index_str+"]}")
-  }
-
-  //view.index:
-  code.push(
-    "proto.index=function "+className+"_index(", args.join(), "){return "+index_str+"}")
-
-  //view.hi():
-  code.push("proto.hi=function "+className+"_hi("+args.join(",")+"){return new "+className+"(this.data,"+
-    indices.map(function(i) {
-      return ["(typeof i",i,"!=='number'||i",i,"<0)?this.shape[", i, "]:i", i,"|0"].join("")
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "this.stride["+i + "]"
-    }).join(",")+",this.offset)}")
-
-  //view.lo():
-  var a_vars = indices.map(function(i) { return "a"+i+"=this.shape["+i+"]" })
-  var c_vars = indices.map(function(i) { return "c"+i+"=this.stride["+i+"]" })
-  code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(","))
-  for(var i=0; i<dimension; ++i) {
-    code.push(
-"if(typeof i"+i+"==='number'&&i"+i+">=0){\
-d=i"+i+"|0;\
-b+=c"+i+"*d;\
-a"+i+"-=d}")
-  }
-  code.push("return new "+className+"(this.data,"+
-    indices.map(function(i) {
-      return "a"+i
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "c"+i
-    }).join(",")+",b)}")
-
-  //view.step():
-  code.push("proto.step=function "+className+"_step("+args.join(",")+"){var "+
-    indices.map(function(i) {
-      return "a"+i+"=this.shape["+i+"]"
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "b"+i+"=this.stride["+i+"]"
-    }).join(",")+",c=this.offset,d=0,ceil=Math.ceil")
-  for(var i=0; i<dimension; ++i) {
-    code.push(
-"if(typeof i"+i+"==='number'){\
-d=i"+i+"|0;\
-if(d<0){\
-c+=b"+i+"*(a"+i+"-1);\
-a"+i+"=ceil(-a"+i+"/d)\
-}else{\
-a"+i+"=ceil(a"+i+"/d)\
-}\
-b"+i+"*=d\
-}")
-  }
-  code.push("return new "+className+"(this.data,"+
-    indices.map(function(i) {
-      return "a" + i
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "b" + i
-    }).join(",")+",c)}")
-
-  //view.transpose():
-  var tShape = new Array(dimension)
-  var tStride = new Array(dimension)
-  for(var i=0; i<dimension; ++i) {
-    tShape[i] = "a[i"+i+"]"
-    tStride[i] = "b[i"+i+"]"
-  }
-  code.push("proto.transpose=function "+className+"_transpose("+args+"){"+
-    args.map(function(n,idx) { return n + "=(" + n + "===undefined?" + idx + ":" + n + "|0)"}).join(";"),
-    "var a=this.shape,b=this.stride;return new "+className+"(this.data,"+tShape.join(",")+","+tStride.join(",")+",this.offset)}")
-
-  //view.pick():
-  code.push("proto.pick=function "+className+"_pick("+args+"){var a=[],b=[],c=this.offset")
-  for(var i=0; i<dimension; ++i) {
-    code.push("if(typeof i"+i+"==='number'&&i"+i+">=0){c=(c+this.stride["+i+"]*i"+i+")|0}else{a.push(this.shape["+i+"]);b.push(this.stride["+i+"])}")
-  }
-  code.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}")
-
-  //Add return statement
-  code.push("return function construct_"+className+"(data,shape,stride,offset){return new "+className+"(data,"+
-    indices.map(function(i) {
-      return "shape["+i+"]"
-    }).join(",")+","+
-    indices.map(function(i) {
-      return "stride["+i+"]"
-    }).join(",")+",offset)}")
-
-  //Compile procedure
-  var procedure = new Function("CTOR_LIST", "ORDER", code.join("\n"))
-  return procedure(CACHED_CONSTRUCTORS[dtype], order)
-}
-
-function arrayDType(data) {
-  if(isBuffer(data)) {
-    return "buffer"
-  }
-  if(hasTypedArrays) {
-    switch(Object.prototype.toString.call(data)) {
-      case "[object Float64Array]":
-        return "float64"
-      case "[object Float32Array]":
-        return "float32"
-      case "[object Int8Array]":
-        return "int8"
-      case "[object Int16Array]":
-        return "int16"
-      case "[object Int32Array]":
-        return "int32"
-      case "[object Uint8Array]":
-        return "uint8"
-      case "[object Uint16Array]":
-        return "uint16"
-      case "[object Uint32Array]":
-        return "uint32"
-      case "[object Uint8ClampedArray]":
-        return "uint8_clamped"
-    }
-  }
-  if(Array.isArray(data)) {
-    return "array"
-  }
-  return "generic"
-}
-
-var CACHED_CONSTRUCTORS = {
-  "float32":[],
-  "float64":[],
-  "int8":[],
-  "int16":[],
-  "int32":[],
-  "uint8":[],
-  "uint16":[],
-  "uint32":[],
-  "array":[],
-  "uint8_clamped":[],
-  "buffer":[],
-  "generic":[]
-}
-
-;(function() {
-  for(var id in CACHED_CONSTRUCTORS) {
-    CACHED_CONSTRUCTORS[id].push(compileConstructor(id, -1))
-  }
-});
-
-function wrappedNDArrayCtor(data, shape, stride, offset) {
-  if(data === undefined) {
-    var ctor = CACHED_CONSTRUCTORS.array[0]
-    return ctor([])
-  } else if(typeof data === "number") {
-    data = [data]
-  }
-  if(shape === undefined) {
-    shape = [ data.length ]
-  }
-  var d = shape.length
-  if(stride === undefined) {
-    stride = new Array(d)
-    for(var i=d-1, sz=1; i>=0; --i) {
-      stride[i] = sz
-      sz *= shape[i]
-    }
-  }
-  if(offset === undefined) {
-    offset = 0
-    for(var i=0; i<d; ++i) {
-      if(stride[i] < 0) {
-        offset -= (shape[i]-1)*stride[i]
-      }
-    }
-  }
-  var dtype = arrayDType(data)
-  var ctor_list = CACHED_CONSTRUCTORS[dtype]
-  while(ctor_list.length <= d+1) {
-    ctor_list.push(compileConstructor(dtype, ctor_list.length-1))
-  }
-  var ctor = ctor_list[d+1]
-  return ctor(data, shape, stride, offset)
-}
-
-module.exports = wrappedNDArrayCtor
-
-},{"iota-array":2,"is-buffer":3}]},{},[1])
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Vzci9sb2NhbC9saWIvbm9kZV9tb2R1bGVzL2Jyb3dzZXJpZnkvbm9kZV9tb2R1bGVzL2Jyb3dzZXItcGFjay9fcHJlbHVkZS5qcyIsIm1lZGlhL2pzL3dpc3AvYW5vbnltb3VzLndpc3AiLCJub2RlX21vZHVsZXMvaW90YS1hcnJheS9pb3RhLmpzIiwibm9kZV9tb2R1bGVzL2lzLWJ1ZmZlci9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9uZGFycmF5L25kYXJyYXkuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0lDQUEsSUFBQyxJLEdBQUQ7QUFBQSxRQUFBLEUsRUFBSSxNQUFKO0FBQUEsUUFBQSxHLEVBQUEsSyxDQUFBO0FBQUEsTTs7O0FBS0EsSUFBSyxLQUFBLEdBQUEsT0FBQSxDQUFBLEtBQUEsR0FBTSxHQUFYLEM7QUFDQSxJQUFLLE1BQUEsR0FBQSxPQUFBLENBQUEsTUFBQSxHQUFPLEdBQVosQztBQUNBLElBQUssU0FBQS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GRlZm1hY3JvIGRvLXN0cmlkZSBbdmFybmFtZXMgc3RhcnQtZm9ybSBlbmQtZm9ybSBzdHJpZGUtZm9ybSAmIGJvZHldXG4gIChsZXQgW3N0cmlkZSAoZ2Vuc3ltIFwic3RyaWRlXCIpXG4gICAgICAgIHN0YXJ0IChnZW5zeW0gXCJzdGFydFwiKVxuICAgICAgICBlbmQgKGdlbnN5bSBcImVuZFwiKVxuICAgICAgICBidWlsZCAoZm4gYnVpbGQgW3ZhcnNdXG4gICAgICAgICAgICAgICAgKGlmIChlbXB0eT8gdmFycylcbiAgICAgICAgICAgICAgICAgIGAoZG8gfkBib2R5KVxuICAgICAgICAgICAgICAgICAgKGxldCBbdmFybmFtZSAoZmlyc3QgdmFycyldXG4gICAgICAgICAgICAgICAgICAgIGAobG9vcCBbfnZhcm5hbWUgfnN0YXJ0XVxuICAgICAgICAgICAgICAgICAgICAgICAod2hlbiAoPCB+dmFybmFtZSB+ZW5kKVxuICAgICAgICAgICAgICAgICAgICAgICAgIH4oYnVpbGQgKHJlc3QgdmFycykpXG4gICAgICAgICAgICAgICAgICAgICAgICAgKHJlY3VyICgrIH52YXJuYW1lIH5zdHJpZGUpKSkpKSkpXVxuICAgIDsgRml4IHRoZSBudW1iZXJzIG9uY2Ugb3V0c2lkZSB0aGUgbmVzdGVkIGxvb3BzLFxuICAgIDsgYW5kIHRoZW4gYnVpbGQgdGhlIGd1dHMuXG4gICAgYChsZXQgW35zdGFydCB+c3RhcnQtZm9ybVxuICAgICAgICAgICB+ZW5kIH5lbmQtZm9ybVxuICAgICAgICAgICB+c3RyaWRlIH5zdHJpZGUtZm9ybV1cbiAgICAgICB+KGJ1aWxkIHZhcm5hbWVzKSkpKVxuXG5cbihkZWZtYWNybyBkby1uZGFycmF5IFt2YXJzIGFycmF5LWZvcm0gJiBib2R5XVxuICAobGV0IFthcnJheS12YXIgKGdlbnN5bSBcImFycmF5XCIpXG4gICAgICAgIGJ1aWxkIChmbiBidWlsZCBbdmFycyBu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yKHZhciBpPTA7IGk8ZDsgKytpKSB7XG4gICAgICBpZihzdHJpZGVbaV0gPCAwKSB7XG4gICAgICAgIG9mZnNldCAtPSAoc2hhcGVbaV0tMSkqc3RyaWRlW2ldXG4gICAgICB9XG4gICAgfVxuICB9XG4gIHZhciBkdHlwZSA9IGFycmF5RFR5cGUoZGF0YSlcbiAgdmFyIGN0b3JfbGlzdCA9IENBQ0hFRF9DT05TVFJVQ1RPUlNbZHR5cGVdXG4gIHdoaWxlKGN0b3JfbGlzdC5sZW5ndGggPD0gZCsxKSB7XG4gICAgY3Rvcl9saXN0LnB1c2goY29tcGlsZUNvbnN0cnVjdG9yKGR0eXBlLCBjdG9yX2xpc3QubGVuZ3RoLTEpKVxuICB9XG4gIHZhciBjdG9yID0gY3Rvcl9saXN0W2QrMV1cbiAgcmV0dXJuIGN0b3IoZGF0YSwgc2hhcGUsIHN0cmlkZSwgb2Zmc2V0KVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHdyYXBwZWROREFycmF5Q3RvclxuIl19
--- a/media/js/three.min.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,958 +0,0 @@
-// threejs.org/license
-'use strict';var THREE={REVISION:"74"};"function"===typeof define&&define.amd?define("three",THREE):"undefined"!==typeof exports&&"undefined"!==typeof module&&(module.exports=THREE);void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0<a?1:+a});void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}});
-void 0===Object.assign&&Object.defineProperty(Object,"assign",{writable:!0,configurable:!0,value:function(a){if(void 0===a||null===a)throw new TypeError("Cannot convert first argument to object");for(var b=Object(a),c=1,d=arguments.length;c!==d;++c){var e=arguments[c];if(void 0!==e&&null!==e)for(var e=Object(e),f=Object.keys(e),g=0,h=f.length;g!==h;++g){var k=f[g],l=Object.getOwnPropertyDescriptor(e,k);void 0!==l&&l.enumerable&&(b[k]=e[k])}}return b}});THREE.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2};
-THREE.CullFaceNone=0;THREE.CullFaceBack=1;THREE.CullFaceFront=2;THREE.CullFaceFrontBack=3;THREE.FrontFaceDirectionCW=0;THREE.FrontFaceDirectionCCW=1;THREE.BasicShadowMap=0;THREE.PCFShadowMap=1;THREE.PCFSoftShadowMap=2;THREE.FrontSide=0;THREE.BackSide=1;THREE.DoubleSide=2;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NoBlending=0;THREE.NormalBlending=1;THREE.AdditiveBlending=2;THREE.SubtractiveBlending=3;THREE.MultiplyBlending=4;
-THREE.CustomBlending=5;THREE.AddEquation=100;THREE.SubtractEquation=101;THREE.ReverseSubtractEquation=102;THREE.MinEquation=103;THREE.MaxEquation=104;THREE.ZeroFactor=200;THREE.OneFactor=201;THREE.SrcColorFactor=202;THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;THREE.OneMinusSrcAlphaFactor=205;THREE.DstAlphaFactor=206;THREE.OneMinusDstAlphaFactor=207;THREE.DstColorFactor=208;THREE.OneMinusDstColorFactor=209;THREE.SrcAlphaSaturateFactor=210;THREE.NeverDepth=0;THREE.AlwaysDepth=1;
-THREE.LessDepth=2;THREE.LessEqualDepth=3;THREE.EqualDepth=4;THREE.GreaterEqualDepth=5;THREE.GreaterDepth=6;THREE.NotEqualDepth=7;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.AddOperation=2;THREE.UVMapping=300;THREE.CubeReflectionMapping=301;THREE.CubeRefractionMapping=302;THREE.EquirectangularReflectionMapping=303;THREE.EquirectangularRefractionMapping=304;THREE.SphericalReflectionMapping=305;THREE.RepeatWrapping=1E3;THREE.ClampToEdgeWrapping=1001;THREE.MirroredRepeatWrapping=1002;
-THREE.NearestFilter=1003;THREE.NearestMipMapNearestFilter=1004;THREE.NearestMipMapLinearFilter=1005;THREE.LinearFilter=1006;THREE.LinearMipMapNearestFilter=1007;THREE.LinearMipMapLinearFilter=1008;THREE.UnsignedByteType=1009;THREE.ByteType=1010;THREE.ShortType=1011;THREE.UnsignedShortType=1012;THREE.IntType=1013;THREE.UnsignedIntType=1014;THREE.FloatType=1015;THREE.HalfFloatType=1025;THREE.UnsignedShort4444Type=1016;THREE.UnsignedShort5551Type=1017;THREE.UnsignedShort565Type=1018;
-THREE.AlphaFormat=1019;THREE.RGBFormat=1020;THREE.RGBAFormat=1021;THREE.LuminanceFormat=1022;THREE.LuminanceAlphaFormat=1023;THREE.RGBEFormat=THREE.RGBAFormat;THREE.RGB_S3TC_DXT1_Format=2001;THREE.RGBA_S3TC_DXT1_Format=2002;THREE.RGBA_S3TC_DXT3_Format=2003;THREE.RGBA_S3TC_DXT5_Format=2004;THREE.RGB_PVRTC_4BPPV1_Format=2100;THREE.RGB_PVRTC_2BPPV1_Format=2101;THREE.RGBA_PVRTC_4BPPV1_Format=2102;THREE.RGBA_PVRTC_2BPPV1_Format=2103;THREE.RGB_ETC1_Format=2151;THREE.LoopOnce=2200;THREE.LoopRepeat=2201;
-THREE.LoopPingPong=2202;THREE.InterpolateDiscrete=2300;THREE.InterpolateLinear=2301;THREE.InterpolateSmooth=2302;THREE.ZeroCurvatureEnding=2400;THREE.ZeroSlopeEnding=2401;THREE.WrapAroundEnding=2402;THREE.TrianglesDrawMode=0;THREE.TriangleStripDrawMode=1;THREE.TriangleFanDrawMode=2;THREE.Color=function(a){return 3===arguments.length?this.fromArray(arguments):this.set(a)};
-THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,set:function(a){a instanceof THREE.Color?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1<d&&(d-=1);return d<1/6?a+6*(c-a)*
-d:.5>d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b,c,d){b=THREE.Math.euclideanModulo(b,1);c=THREE.Math.clamp(c,0,1);d=THREE.Math.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=
-/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){var d=
-parseFloat(c[1])/360,e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^\#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0<a.length&&
-(c=THREE.ColorKeywords[a],void 0!==c?this.setHex(c):console.warn("THREE.Color: Unknown color "+a));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a,b){void 0===b&&(b=2);this.r=Math.pow(a.r,b);this.g=Math.pow(a.g,b);this.b=Math.pow(a.b,b);return this},copyLinearToGamma:function(a,b){void 0===b&&(b=2);var c=0<b?1/b:1;this.r=Math.pow(a.r,c);this.g=Math.pow(a.g,c);this.b=Math.pow(a.b,
-c);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);this.b=Math.sqrt(this.b);return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(a){a=a||{h:0,s:0,l:0};var b=this.r,c=this.g,d=this.b,e=Math.max(b,c,d),f=Math.min(b,c,d),g,h=
-(f+e)/2;if(f===e)f=g=0;else{var k=e-f,f=.5>=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-d)/k+(c<d?6:0);break;case c:g=(d-b)/k+2;break;case d:g=(b-c)/k+4}g/=6}a.h=g;a.s=f;a.l=h;return a},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(a,b,c){var d=this.getHSL();d.h+=a;d.s+=b;d.l+=c;this.setHSL(d.h,d.s,d.l);return this},add:function(a){this.r+=a.r;this.g+=a.g;this.b+=a.b;return this},addColors:function(a,b){this.r=a.r+b.r;this.g=a.g+b.g;this.b=
-a.b+b.b;return this},addScalar:function(a){this.r+=a;this.g+=a;this.b+=a;return this},multiply:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b;return this},multiplyScalar:function(a){this.r*=a;this.g*=a;this.b*=a;return this},lerp:function(a,b){this.r+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},equals:function(a){return a.r===this.r&&a.g===this.g&&a.b===this.b},fromArray:function(a,b){void 0===b&&(b=0);this.r=a[b];this.g=a[b+1];this.b=a[b+2];return this},toArray:function(a,
-b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.r;a[b+1]=this.g;a[b+2]=this.b;return a}};
-THREE.ColorKeywords={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,
-darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,
-grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,
-lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,
-palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,
-tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};THREE.Quaternion=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1};
-THREE.Quaternion.prototype={constructor:THREE.Quaternion,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},
-copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!1===a instanceof THREE.Euler)throw Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),f=Math.sin(a._x/2),g=Math.sin(a._y/2),h=Math.sin(a._z/2),k=a.order;"XYZ"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"YXZ"===
-k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"ZXY"===k?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"ZYX"===k?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"YZX"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e-f*g*h):"XZY"===k&&(this._x=f*d*e-c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e+f*g*h);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,
-b){var c=b/2,d=Math.sin(c);this._x=a.x*d;this._y=a.y*d;this._z=a.z*d;this._w=Math.cos(c);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6],b=b[10],l=c+f+b;0<l?(c=.5/Math.sqrt(l+1),this._w=.25/c,this._x=(k-g)*c,this._y=(d-h)*c,this._z=(e-a)*c):c>f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=
-.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;this.normalize();return this}}(),inverse:function(){this.conjugate().normalize();return this},conjugate:function(){this._x*=
--1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},
-multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,k=b._z,l=b._w;this._x=c*l+f*g+d*k-e*h;this._y=d*l+f*h+e*g-c*k;this._z=e*l+f*k+c*h-d*g;this._w=f*l-c*g-d*h-e*k;this.onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===
-b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.sqrt(1-g*g);if(.001>Math.abs(h))return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;var k=Math.atan2(h,g),g=Math.sin((1-b)*k)/h,h=Math.sin(b*k)/h;this._w=f*g+this._w*h;this._x=c*g+this._x*h;this._y=d*g+
-this._y*h;this._z=e*g+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};
-Object.assign(THREE.Quaternion,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],l=c[d+2];c=c[d+3];d=e[f+0];var n=e[f+1],p=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==n||l!==p){f=1-g;var m=h*d+k*n+l*p+c*e,q=0<=m?1:-1,s=1-m*m;s>Number.EPSILON&&(s=Math.sqrt(s),m=Math.atan2(s,m*q),f=Math.sin(f*m)/s,g=Math.sin(g*m)/s);q*=g;h=h*f+d*q;k=k*f+n*q;l=l*f+p*q;c=c*f+e*q;f===1-g&&(g=1/Math.sqrt(h*h+k*k+l*l+c*c),h*=g,k*=g,l*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=l;
-a[b+3]=c}});THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
-THREE.Vector2.prototype={constructor:THREE.Vector2,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;
-case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},
-addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,
-this.y*=a):this.y=this.x=0;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a,b;return function(c,d){void 0===
-a&&(a=new THREE.Vector2,b=new THREE.Vector2);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();this.multiplyScalar(Math.max(a,Math.min(b,c))/c);return this},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):
-Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=
-2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){this.subVectors(b,a).multiplyScalar(c).add(a);return this},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];
-this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];return this},rotateAround:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=this.x-a.x,f=this.y-a.y;this.x=e*c-f*d+a.x;this.y=e*d+f*c+a.y;return this}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
-THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;
-case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,
-b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},
-multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a;return function(b){!1===b instanceof THREE.Euler&&
-console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");void 0===a&&(a=new THREE.Quaternion);this.applyQuaternion(a.setFromEuler(b));return this}}(),applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new THREE.Quaternion);this.applyQuaternion(a.setFromAxisAngle(b,c));return this}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*
-d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyProjection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,
-f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,l=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-l*-f;this.y=k*a+b*-f+l*-e-h*-g;this.z=l*a+b*-g+h*-f-k*-e;return this},project:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld));return this.applyProjection(a)}}(),unproject:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyProjection(a)}}(),
-transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;this.normalize();return this},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);
-this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3,b=new THREE.Vector3);a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();this.multiplyScalar(Math.max(a,Math.min(b,c))/c);return this},floor:function(){this.x=Math.floor(this.x);
-this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;
-this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*
-b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){this.subVectors(b,a).multiplyScalar(c).add(a);return this},cross:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b);var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;
-this.y=e*f-c*h;this.z=c*g-d*f;return this},projectOnVector:function(){var a,b;return function(c){void 0===a&&(a=new THREE.Vector3);a.copy(c).normalize();b=this.dot(a);return this.copy(a).multiplyScalar(b)}}(),projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=
-this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(THREE.Math.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},setFromMatrixPosition:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setFromMatrixScale:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],
-a.elements[6]).length();a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){var c=4*a,d=b.elements;this.x=d[c];this.y=d[c+1];this.z=d[c+2];return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},
-fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];return this}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
-THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+
-a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);
-this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=
-a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a,this.w*=a):this.w=this.z=this.y=this.x=0;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=
-a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var l=a[10];if(.01>Math.abs(d-g)&&.01>Math.abs(f-c)&&.01>
-Math.abs(k-b)){if(.1>Math.abs(d+g)&&.1>Math.abs(f+c)&&.1>Math.abs(k+b)&&.1>Math.abs(e+h+l-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;l=(l+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;e>h&&e>l?.01>e?(b=0,d=c=.707106781):(b=Math.sqrt(e),c=d/b,d=f/b):h>l?.01>h?(b=.707106781,c=0,d=.707106781):(c=Math.sqrt(h),b=d/c,d=k/c):.01>l?(c=b=.707106781,d=0):(d=Math.sqrt(l),b=f/d,c=k/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));.001>Math.abs(a)&&(a=1);this.x=(b-k)/
-a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+l-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));
-this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector4,b=new THREE.Vector4);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=
-Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*
-a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-
-this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){this.subVectors(b,a).multiplyScalar(c).add(a);return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+
-c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];this.w=a.array[b+3];return this}};THREE.Euler=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||THREE.Euler.DefaultOrder};THREE.Euler.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");THREE.Euler.DefaultOrder="XYZ";
-THREE.Euler.prototype={constructor:THREE.Euler,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,
-this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=THREE.Math.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],l=e[9],n=e[2],p=e[6],e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-l,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(p,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(l,-1,1)),.99999>Math.abs(l)?
-(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-n,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.99999>Math.abs(p)?(this._y=Math.atan2(-n,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(n,-1,1)),.99999>Math.abs(n)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-l,k),this._y=Math.atan2(-n,a)):(this._x=
-0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(p,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-l,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeRotationFromQuaternion(b);this.setFromRotationMatrix(a,c,d);return this}}(),setFromVector3:function(a,
-b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new THREE.Quaternion;return function(b){a.setFromEuler(this);this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+
-3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new THREE.Vector3(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};THREE.Line3=function(a,b){this.start=void 0!==a?a:new THREE.Vector3;this.end=void 0!==b?b:new THREE.Vector3};
-THREE.Line3.prototype={constructor:THREE.Line3,set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},center:function(a){return(a||new THREE.Vector3).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){return(a||new THREE.Vector3).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},
-at:function(a,b){var c=b||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);var e=b.dot(b),e=b.dot(a)/e;d&&(e=THREE.Math.clamp(e,0,1));return e}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);c=c||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a);
-this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}};THREE.Box2=function(a,b){this.min=void 0!==a?a:new THREE.Vector2(Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector2(-Infinity,-Infinity)};
-THREE.Box2.prototype={constructor:THREE.Box2,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new THREE.Vector2;return function(b,c){var d=a.copy(c).multiplyScalar(.5);this.min.copy(b).sub(d);this.max.copy(b).add(d);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);this.max.copy(a.max);
-return this},makeEmpty:function(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},center:function(a){return(a||new THREE.Vector2).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(a){return(a||new THREE.Vector2).subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);
-this.max.addScalar(a);return this},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getParameter:function(a,b){return(b||new THREE.Vector2).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>
-this.max.y?!1:!0},clampPoint:function(a,b){return(b||new THREE.Vector2).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new THREE.Vector2;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&
-a.max.equals(this.max)}};THREE.Box3=function(a,b){this.min=void 0!==a?a:new THREE.Vector3(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};
-THREE.Box3.prototype={constructor:THREE.Box3,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){this.makeEmpty();for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.length;h<k;h+=3){var l=a[h],n=a[h+1],p=a[h+2];l<b&&(b=l);n<c&&(c=n);p<d&&(d=p);l>e&&(e=l);n>f&&(f=n);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g)},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},
-setFromCenterAndSize:function(){var a=new THREE.Vector3;return function(b,c){var d=a.copy(c).multiplyScalar(.5);this.min.copy(b).sub(d);this.max.copy(b).add(d);return this}}(),setFromObject:function(){var a;return function(b){void 0===a&&(a=new THREE.Box3);var c=this;this.makeEmpty();b.updateMatrixWorld(!0);b.traverse(function(b){var e=b.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),a.copy(e.boundingBox),a.applyMatrix4(b.matrixWorld),c.union(a))});return this}}(),clone:function(){return(new this.constructor).copy(this)},
-copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},makeEmpty:function(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},center:function(a){return(a||new THREE.Vector3).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(a){return(a||new THREE.Vector3).subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);
-this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);this.max.addScalar(a);return this},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y||a.z<this.min.z||a.z>this.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getParameter:function(a,
-b){return(b||new THREE.Vector3).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y||a.max.z<this.min.z||a.min.z>this.max.z?!1:!0},intersectsSphere:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){var b,
-c;0<a.normal.x?(b=a.normal.x*this.min.x,c=a.normal.x*this.max.x):(b=a.normal.x*this.max.x,c=a.normal.x*this.min.x);0<a.normal.y?(b+=a.normal.y*this.min.y,c+=a.normal.y*this.max.y):(b+=a.normal.y*this.max.y,c+=a.normal.y*this.min.y);0<a.normal.z?(b+=a.normal.z*this.min.z,c+=a.normal.z*this.max.z):(b+=a.normal.z*this.max.z,c+=a.normal.z*this.min.z);return b<=a.constant&&c>=a.constant},clampPoint:function(a,b){return(b||new THREE.Vector3).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=
-new THREE.Vector3;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new THREE.Vector3;return function(b){b=b||new THREE.Sphere;b.center=this.center();b.radius=.5*this.size(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,
-new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];return function(b){a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);
-a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.makeEmpty();this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};THREE.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]);0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")};
-THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(a,b,c,d,e,f,g,h,k){var l=this.elements;l[0]=a;l[3]=b;l[6]=c;l[1]=d;l[4]=e;l[7]=f;l[2]=g;l[5]=h;l[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Vector3);
-void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;e<d;e+=3,c+=3)a.fromArray(b,c),a.applyMatrix3(this),a.toArray(b,c);return b}}(),applyToBuffer:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Vector3);void 0===c&&(c=0);void 0===d&&(d=b.length/b.itemSize);for(var e=0;e<d;e++,c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.applyMatrix3(this),b.setXYZ(a.x,a.y,a.z);return b}}(),multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[3]*=a;b[6]*=a;b[1]*=a;b[4]*=a;b[7]*=a;b[2]*=a;
-b[5]*=a;b[8]*=a;return this},determinant:function(){var a=this.elements,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],k=a[7],a=a[8];return b*f*a-b*g*k-c*e*a+c*g*h+d*e*k-d*f*h},getInverse:function(a,b){var c=a.elements,d=this.elements;d[0]=c[10]*c[5]-c[6]*c[9];d[1]=-c[10]*c[1]+c[2]*c[9];d[2]=c[6]*c[1]-c[2]*c[5];d[3]=-c[10]*c[4]+c[6]*c[8];d[4]=c[10]*c[0]-c[2]*c[8];d[5]=-c[6]*c[0]+c[2]*c[4];d[6]=c[9]*c[4]-c[5]*c[8];d[7]=-c[9]*c[0]+c[1]*c[8];d[8]=c[5]*c[0]-c[1]*c[4];c=c[0]*d[0]+c[1]*d[3]+c[2]*d[6];
-if(0===c){if(b)throw Error("THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0");console.warn("THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0");this.identity();return this}this.multiplyScalar(1/c);return this},transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},flattenToArrayOffset:function(a,b){var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+
-6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a},getNormalMatrix:function(a){this.getInverse(a).transpose();return this},transposeIntoArray:function(a){var b=this.elements;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this},fromArray:function(a){this.elements.set(a);return this},toArray:function(){var a=this.elements;return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]]}};
-THREE.Matrix4=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")};
-THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,k,l,n,p,m,q,s,u){var t=this.elements;t[0]=a;t[4]=b;t[8]=c;t[12]=d;t[1]=e;t[5]=f;t[9]=g;t[13]=h;t[2]=k;t[6]=l;t[10]=n;t[14]=p;t[3]=m;t[7]=q;t[11]=s;t[15]=u;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new THREE.Matrix4).fromArray(this.elements)},copy:function(a){this.elements.set(a.elements);return this},copyPosition:function(a){var b=this.elements;a=a.elements;
-b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){var d=this.elements;a.set(d[0],d[1],d[2]);b.set(d[4],d[5],d[6]);c.set(d[8],d[9],d[10]);return this},makeBasis:function(a,b,c){this.set(a.x,b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);var c=this.elements;b=b.elements;var d=1/a.set(b[0],b[1],b[2]).length(),e=1/a.set(b[4],b[5],b[6]).length(),f=1/a.set(b[8],b[9],b[10]).length();
-c[0]=b[0]*d;c[1]=b[1]*d;c[2]=b[2]*d;c[4]=b[4]*e;c[5]=b[5]*e;c[6]=b[6]*e;c[8]=b[8]*f;c[9]=b[9]*f;c[10]=b[10]*f;return this}}(),makeRotationFromEuler:function(a){!1===a instanceof THREE.Euler&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,l=c*h,n=c*e;b[0]=g*h;b[4]=-g*e;b[8]=
-d;b[1]=k+l*d;b[5]=a-n*d;b[9]=-c*g;b[2]=n-a*d;b[6]=l+k*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,l=d*h,n=d*e,b[0]=a+n*c,b[4]=l*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-l,b[6]=n+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,l=d*h,n=d*e,b[0]=a-n*c,b[4]=-f*e,b[8]=l+k*c,b[1]=k+l*c,b[5]=f*h,b[9]=n-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,l=c*h,n=c*e,b[0]=g*h,b[4]=l*d-k,b[8]=a*d+n,b[1]=g*e,b[5]=n*d+a,b[9]=k*d-l,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,l=c*g,n=
-c*d,b[0]=g*h,b[4]=n-a*e,b[8]=l*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+l,b[10]=a-n*e):"XZY"===a.order&&(a=f*g,k=f*d,l=c*g,n=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+n,b[5]=f*h,b[9]=k*e-l,b[2]=l*e-k,b[6]=c*h,b[10]=n*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,k=e+e;a=c*g;var l=c*h,c=c*k,n=d*h,d=d*k,e=e*k,g=f*g,h=f*h,f=f*k;b[0]=1-(n+e);b[4]=l-f;b[8]=c+h;b[1]=l+f;b[5]=1-(a+
-e);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+n);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},lookAt:function(){var a,b,c;return function(d,e,f){void 0===a&&(a=new THREE.Vector3);void 0===b&&(b=new THREE.Vector3);void 0===c&&(c=new THREE.Vector3);var g=this.elements;c.subVectors(d,e).normalize();0===c.lengthSq()&&(c.z=1);a.crossVectors(f,c).normalize();0===a.lengthSq()&&(c.x+=1E-4,a.crossVectors(f,c).normalize());b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=
-c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],l=c[1],n=c[5],p=c[9],m=c[13],q=c[2],s=c[6],u=c[10],t=c[14],x=c[3],v=c[7],C=c[11],c=c[15],w=d[0],D=d[4],z=d[8],y=d[12],A=d[1],H=d[5],G=
-d[9],E=d[13],K=d[2],P=d[6],N=d[10],L=d[14],B=d[3],M=d[7],Q=d[11],d=d[15];e[0]=f*w+g*A+h*K+k*B;e[4]=f*D+g*H+h*P+k*M;e[8]=f*z+g*G+h*N+k*Q;e[12]=f*y+g*E+h*L+k*d;e[1]=l*w+n*A+p*K+m*B;e[5]=l*D+n*H+p*P+m*M;e[9]=l*z+n*G+p*N+m*Q;e[13]=l*y+n*E+p*L+m*d;e[2]=q*w+s*A+u*K+t*B;e[6]=q*D+s*H+u*P+t*M;e[10]=q*z+s*G+u*N+t*Q;e[14]=q*y+s*E+u*L+t*d;e[3]=x*w+v*A+C*K+c*B;e[7]=x*D+v*H+C*P+c*M;e[11]=x*z+v*G+C*N+c*Q;e[15]=x*y+v*E+C*L+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a,
-b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Vector3);void 0===c&&(c=0);void 0===
-d&&(d=b.length);for(var e=0;e<d;e+=3,c+=3)a.fromArray(b,c),a.applyMatrix4(this),a.toArray(b,c);return b}}(),applyToBuffer:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Vector3);void 0===c&&(c=0);void 0===d&&(d=b.length/b.itemSize);for(var e=0;e<d;e++,c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.applyMatrix4(this),b.setXYZ(a.x,a.y,a.z);return b}}(),determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],e=a[12],f=a[1],g=a[5],h=a[9],k=a[13],l=a[2],n=a[6],p=a[10],m=a[14];
-return a[3]*(+e*h*n-d*k*n-e*g*p+c*k*p+d*g*m-c*h*m)+a[7]*(+b*h*m-b*k*p+e*f*p-d*f*m+d*k*l-e*h*l)+a[11]*(+b*k*n-b*g*m-e*f*n+c*f*m+e*g*l-c*k*l)+a[15]*(-d*g*l-b*h*n+b*g*p+d*f*n-c*f*p+c*h*l)},transpose:function(){var a=this.elements,b;b=a[1];a[1]=a[4];a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[6];a[6]=a[9];a[9]=b;b=a[3];a[3]=a[12];a[12]=b;b=a[7];a[7]=a[13];a[13]=b;b=a[11];a[11]=a[14];a[14]=b;return this},flattenToArrayOffset:function(a,b){var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=
-c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a},getPosition:function(){var a;return function(){void 0===a&&(a=new THREE.Vector3);console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");var b=this.elements;return a.set(b[12],b[13],b[14])}}(),setPosition:function(a){var b=this.elements;b[12]=a.x;b[13]=a.y;b[14]=a.z;return this},getInverse:function(a,
-b){var c=this.elements,d=a.elements,e=d[0],f=d[4],g=d[8],h=d[12],k=d[1],l=d[5],n=d[9],p=d[13],m=d[2],q=d[6],s=d[10],u=d[14],t=d[3],x=d[7],v=d[11],d=d[15];c[0]=n*u*x-p*s*x+p*q*v-l*u*v-n*q*d+l*s*d;c[4]=h*s*x-g*u*x-h*q*v+f*u*v+g*q*d-f*s*d;c[8]=g*p*x-h*n*x+h*l*v-f*p*v-g*l*d+f*n*d;c[12]=h*n*q-g*p*q-h*l*s+f*p*s+g*l*u-f*n*u;c[1]=p*s*t-n*u*t-p*m*v+k*u*v+n*m*d-k*s*d;c[5]=g*u*t-h*s*t+h*m*v-e*u*v-g*m*d+e*s*d;c[9]=h*n*t-g*p*t-h*k*v+e*p*v+g*k*d-e*n*d;c[13]=g*p*m-h*n*m+h*k*s-e*p*s-g*k*u+e*n*u;c[2]=l*u*t-p*q*t+
-p*m*x-k*u*x-l*m*d+k*q*d;c[6]=h*q*t-f*u*t-h*m*x+e*u*x+f*m*d-e*q*d;c[10]=f*p*t-h*l*t+h*k*x-e*p*x-f*k*d+e*l*d;c[14]=h*l*m-f*p*m-h*k*q+e*p*q+f*k*u-e*l*u;c[3]=n*q*t-l*s*t-n*m*x+k*s*x+l*m*v-k*q*v;c[7]=f*s*t-g*q*t+g*m*x-e*s*x-f*m*v+e*q*v;c[11]=g*l*t-f*n*t-g*k*x+e*n*x+f*k*v-e*l*v;c[15]=f*n*m-g*l*m+g*k*q-e*n*q-f*k*s+e*l*s;c=e*c[0]+k*c[4]+m*c[8]+t*c[12];if(0===c){if(b)throw Error("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0");console.warn("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0");
-this.identity();return this}this.multiplyScalar(1/c);return this},scale:function(a){var b=this.elements,c=a.x,d=a.y;a=a.z;b[0]*=c;b[4]*=d;b[8]*=a;b[1]*=c;b[5]*=d;b[9]*=a;b[2]*=c;b[6]*=d;b[10]*=a;b[3]*=c;b[7]*=d;b[11]*=a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10]))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},makeRotationX:function(a){var b=
-Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},makeRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},makeRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},makeRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,h=a.z,k=e*f,l=e*g;this.set(k*f+c,k*g-d*h,k*h+d*g,0,k*g+d*h,l*g+c,l*h-d*f,0,k*h-d*g,l*h+d*f,e*h*h+c,0,0,0,0,1);
-return this},makeScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},compose:function(a,b,c){this.makeRotationFromQuaternion(b);this.scale(c);this.setPosition(a);return this},decompose:function(){var a,b;return function(c,d,e){void 0===a&&(a=new THREE.Vector3);void 0===b&&(b=new THREE.Matrix4);var f=this.elements,g=a.set(f[0],f[1],f[2]).length(),h=a.set(f[4],f[5],f[6]).length(),k=a.set(f[8],f[9],f[10]).length();0>this.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.elements.set(this.elements);
-c=1/g;var f=1/h,l=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=l;b.elements[9]*=l;b.elements[10]*=l;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makeFrustum:function(a,b,c,d,e,f){var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,
-b,c,d){a=c*Math.tan(THREE.Math.degToRad(.5*a));var e=-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=b-a,k=c-d,l=f-e;g[0]=2/h;g[4]=0;g[8]=0;g[12]=-((b+a)/h);g[1]=0;g[5]=2/k;g[9]=0;g[13]=-((c+d)/k);g[2]=0;g[6]=0;g[10]=-2/l;g[14]=-((f+e)/l);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a){this.elements.set(a);return this},
-toArray:function(){var a=this.elements;return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]]}};THREE.Ray=function(a,b){this.origin=void 0!==a?a:new THREE.Vector3;this.direction=void 0!==b?b:new THREE.Vector3};
-THREE.Ray.prototype={constructor:THREE.Ray,set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){return(b||new THREE.Vector3).copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize()},recast:function(){var a=new THREE.Vector3;return function(b){this.origin.copy(this.at(b,
-a));return this}}(),closestPointToPoint:function(a,b){var c=b||new THREE.Vector3;c.subVectors(a,this.origin);var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new THREE.Vector3;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);
-return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),l=c.dot(this.direction),n=-c.dot(b),p=c.lengthSq(),m=Math.abs(1-k*k),q;0<m?(d=k*n-l,e=k*l-n,q=h*m,0<=d?e>=-q?e<=q?(h=1/m,d*=h,e*=h,k=d*(d+k*e+2*l)+e*(k*d+e+2*n)+p):(e=h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*
-n)+p):(e=-h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*n)+p):e<=-q?(d=Math.max(0,-(-k*h+l)),e=0<d?-h:Math.min(Math.max(-h,-n),h),k=-d*d+e*(e+2*n)+p):e<=q?(d=0,e=Math.min(Math.max(-h,-n),h),k=e*(e+2*n)+p):(d=Math.max(0,-(k*h+l)),e=0<d?h:Math.min(Math.max(-h,-n),h),k=-d*d+e*(e+2*n)+p)):(e=0<k?-h:h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*n)+p);f&&f.copy(this.direction).multiplyScalar(d).add(this.origin);g&&g.copy(b).multiplyScalar(e).add(a);return k}}(),intersectSphere:function(){var a=new THREE.Vector3;return function(b,
-c){a.subVectors(b.center,this.origin);var d=a.dot(this.direction),e=a.dot(a)-d*d,f=b.radius*b.radius;if(e>f)return null;f=Math.sqrt(f-e);e=d-f;d+=f;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<=a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){var c=
-this.distanceToPlane(a);return null===c?null:this.at(c,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z;var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(f<d||d!==
-d)d=f;0<=g?(e=(a.min.z-h.z)*g,g*=a.max.z-h.z):(e=(a.max.z-h.z)*g,g*=a.min.z-h.z);if(c>g||e>d)return null;if(e>c||c!==c)c=e;if(g<d||d!==d)d=g;return 0>d?null:this.at(0<=c?c:d,b)},intersectsBox:function(){var a=new THREE.Vector3;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3,d=new THREE.Vector3;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);
-if(0<f){if(h)return null;h=1}else if(0>f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}};
-THREE.Sphere=function(a,b){this.center=void 0!==a?a:new THREE.Vector3;this.radius=void 0!==b?b:0};
-THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new THREE.Box3;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).center(d);for(var e=0,f=0,g=b.length;f<g;f++)e=Math.max(e,d.distanceToSquared(b[f]));this.radius=Math.sqrt(e);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.center.copy(a.center);this.radius=a.radius;return this},
-empty:function(){return 0>=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(this.center.dot(a.normal)-a.constant)<=this.radius},clampPoint:function(a,b){var c=
-this.center.distanceToSquared(a),d=b||new THREE.Vector3;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a=a||new THREE.Box3;a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&
-a.radius===this.radius}};THREE.Frustum=function(a,b,c,d,e,f){this.planes=[void 0!==a?a:new THREE.Plane,void 0!==b?b:new THREE.Plane,void 0!==c?c:new THREE.Plane,void 0!==d?d:new THREE.Plane,void 0!==e?e:new THREE.Plane,void 0!==f?f:new THREE.Plane]};
-THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],l=c[7],n=c[8],p=c[9],m=c[10],q=c[11],s=c[12],u=c[13],t=c[14],
-c=c[15];b[0].setComponents(f-a,l-g,q-n,c-s).normalize();b[1].setComponents(f+a,l+g,q+n,c+s).normalize();b[2].setComponents(f+d,l+h,q+p,c+u).normalize();b[3].setComponents(f-d,l-h,q-p,c-u).normalize();b[4].setComponents(f-e,l-k,q-m,c-t).normalize();b[5].setComponents(f+e,l+k,q+m,c+t).normalize();return this},intersectsObject:function(){var a=new THREE.Sphere;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere);a.applyMatrix4(b.matrixWorld);
-return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)<a)return!1;return!0},intersectsBox:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c){for(var d=this.planes,e=0;6>e;e++){var f=d[e];a.x=0<f.normal.x?c.min.x:c.max.x;b.x=0<f.normal.x?c.max.x:c.min.x;a.y=0<f.normal.y?c.min.y:c.max.y;b.y=0<f.normal.y?c.max.y:c.min.y;a.z=0<f.normal.z?c.min.z:c.max.z;b.z=0<f.normal.z?c.max.z:c.min.z;
-var g=f.distanceToPoint(a),f=f.distanceToPoint(b);if(0>g&&0>f)return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}};THREE.Plane=function(a,b){this.normal=void 0!==a?a:new THREE.Vector3(1,0,0);this.constant=void 0!==b?b:0};
-THREE.Plane.prototype={constructor:THREE.Plane,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,
-c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,
-b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,b){var c=this.distanceToPoint(a);return(b||new THREE.Vector3).copy(this.normal).multiplyScalar(c)},intersectLine:function(){var a=new THREE.Vector3;return function(b,c){var d=c||new THREE.Vector3,e=b.delta(a),f=this.normal.dot(e);if(0===f){if(0===this.distanceToPoint(b.start))return d.copy(b.start)}else return f=-(b.start.dot(this.normal)+this.constant)/f,0>f||1<f?void 0:d.copy(e).multiplyScalar(f).add(b.start)}}(),intersectsLine:function(a){var b=
-this.distanceToPoint(a.start);a=this.distanceToPoint(a.end);return 0>b&&0<a||0>a&&0<b},intersectsBox:function(a){return a.intersectsPlane(this)},intersectsSphere:function(a){return a.intersectsPlane(this)},coplanarPoint:function(a){return(a||new THREE.Vector3).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Matrix3;return function(d,e){var f=e||c.getNormalMatrix(d),f=a.copy(this.normal).applyMatrix3(f),g=this.coplanarPoint(b);
-g.applyMatrix4(d);this.setFromNormalAndCoplanarPoint(f,g);return this}}(),translate:function(a){this.constant-=a.dot(this.normal);return this},equals:function(a){return a.normal.equals(this.normal)&&a.constant===this.constant}};
-THREE.Math={generateUUID:function(){var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),b=Array(36),c=0,d;return function(){for(var e=0;36>e;e++)8===e||13===e||18===e||23===e?b[e]="-":14===e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19===e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,
-b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead.");return Math.random()},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(){var a=
-Math.PI/180;return function(b){return b*a}}(),radToDeg:function(){var a=180/Math.PI;return function(b){return b*a}}(),isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.pow(2,Math.round(Math.log(a)/Math.LN2))},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;return a}};
-THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,k,l,n,p,m;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:f+
-2;l=this.points[c[0]];n=this.points[c[1]];p=this.points[c[2]];m=this.points[c[3]];h=g*g;k=g*h;d.x=b(l.x,n.x,p.x,m.x,g,h,k);d.y=b(l.y,n.y,p.y,m.y,g,h,k);d.z=b(l.z,n.z,p.z,m.z,g,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],k=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=
-a/c,d=this.getPoint(b),g.copy(d),k+=g.distanceTo(f),f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!==e&&(h[b]=k,e=b);h[h.length]=k;return{chunks:h,total:k}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],k=new THREE.Vector3,m=this.getLength();h.push(k.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=m.chunks[b]-m.chunks[b-1];g=Math.ceil(a*c/m.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+1/g*c*(f-e),d=this.getPoint(d),
-h.push(k.copy(d).clone());h.push(k.copy(this.points[b]).clone())}this.points=h}};THREE.Triangle=function(a,b,c){this.a=void 0!==a?a:new THREE.Vector3;this.b=void 0!==b?b:new THREE.Vector3;this.c=void 0!==c?c:new THREE.Vector3};THREE.Triangle.normal=function(){var a=new THREE.Vector3;return function(b,c,d,e){e=e||new THREE.Vector3;e.subVectors(d,c);a.subVectors(b,c);e.cross(a);b=e.lengthSq();return 0<b?e.multiplyScalar(1/Math.sqrt(b)):e.set(0,0,0)}}();
-THREE.Triangle.barycoordFromPoint=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(d,e,f,g,h){a.subVectors(g,e);b.subVectors(f,e);c.subVectors(d,e);d=a.dot(a);e=a.dot(b);f=a.dot(c);var k=b.dot(b);g=b.dot(c);var l=d*k-e*e;h=h||new THREE.Vector3;if(0===l)return h.set(-2,-1,-1);l=1/l;k=(k*f-e*g)*l;d=(d*g-e*f)*l;return h.set(1-k-d,d,k)}}();
-THREE.Triangle.containsPoint=function(){var a=new THREE.Vector3;return function(b,c,d,e){b=THREE.Triangle.barycoordFromPoint(b,c,d,e,a);return 0<=b.x&&0<=b.y&&1>=b.x+b.y}}();
-THREE.Triangle.prototype={constructor:THREE.Triangle,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},area:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,
-this.b);return.5*a.cross(b).length()}}(),midpoint:function(a){return(a||new THREE.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return THREE.Triangle.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new THREE.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return THREE.Triangle.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return THREE.Triangle.containsPoint(a,this.a,this.b,this.c)},
-equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}};THREE.Interpolant=function(a,b,c,d){this.parameterPositions=a;this._cachedIndex=0;this.resultBuffer=void 0!==d?d:new b.constructor(c);this.sampleValues=b;this.valueSize=c};
-THREE.Interpolant.prototype={constructor:THREE.Interpolant,evaluate:function(a){var b=this.parameterPositions,c=this._cachedIndex,d=b[c],e=b[c-1];a:{b:{c:{d:if(!(a<d)){for(var f=c+2;;){if(void 0===d){if(a<e)break d;this._cachedIndex=c=b.length;return this.afterEnd_(c-1,a,e)}if(c===f)break;e=d;d=b[++c];if(a<d)break b}d=b.length;break c}if(a>=e)break a;else{f=b[1];a<f&&(c=2,e=f);for(f=c-2;;){if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(c===f)break;d=e;e=b[--c-1];if(a>=e)break b}d=
-c;c=0}}for(;c<d;)e=c+d>>>1,a<b[e]?d=e:c=e+1;d=b[c];e=b[c-1];if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(void 0===d)return this._cachedIndex=c=b.length,this.afterEnd_(c-1,e,a)}this._cachedIndex=c;this.intervalChanged_(c,e,d)}return this.interpolate_(c,e,a,d)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(a){var b=this.resultBuffer,c=this.sampleValues,d=this.valueSize;a*=d;for(var e=0;e!==d;++e)b[e]=
-c[a+e];return b},interpolate_:function(a,b,c,d){throw Error("call to abstract method");},intervalChanged_:function(a,b,c){}};Object.assign(THREE.Interpolant.prototype,{beforeStart_:THREE.Interpolant.prototype.copySampleValue_,afterEnd_:THREE.Interpolant.prototype.copySampleValue_});THREE.CubicInterpolant=function(a,b,c,d){THREE.Interpolant.call(this,a,b,c,d);this._offsetNext=this._weightNext=this._offsetPrev=this._weightPrev=-0};
-THREE.CubicInterpolant.prototype=Object.assign(Object.create(THREE.Interpolant.prototype),{constructor:THREE.CubicInterpolant,DefaultSettings_:{endingStart:THREE.ZeroCurvatureEnding,endingEnd:THREE.ZeroCurvatureEnding},intervalChanged_:function(a,b,c){var d=this.parameterPositions,e=a-2,f=a+1,g=d[e],h=d[f];if(void 0===g)switch(this.getSettings_().endingStart){case THREE.ZeroSlopeEnding:e=a;g=2*b-c;break;case THREE.WrapAroundEnding:e=d.length-2;g=b+d[e]-d[e+1];break;default:e=a,g=c}if(void 0===h)switch(this.getSettings_().endingEnd){case THREE.ZeroSlopeEnding:f=
-a;h=2*c-b;break;case THREE.WrapAroundEnding:f=1;h=c+d[1]-d[0];break;default:f=a-1,h=b}a=.5*(c-b);d=this.valueSize;this._weightPrev=a/(b-g);this._weightNext=a/(h-c);this._offsetPrev=e*d;this._offsetNext=f*d},interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g,k=this._offsetPrev,l=this._offsetNext,n=this._weightPrev,p=this._weightNext,m=(c-b)/(d-b);c=m*m;d=c*m;b=-n*d+2*n*c-n*m;n=(1+n)*d+(-1.5-2*n)*c+(-.5+n)*m+1;m=(-1-p)*d+(1.5+p)*c+.5*m;p=p*d-p*
-c;for(c=0;c!==g;++c)e[c]=b*f[k+c]+n*f[h+c]+m*f[a+c]+p*f[l+c];return e}});THREE.DiscreteInterpolant=function(a,b,c,d){THREE.Interpolant.call(this,a,b,c,d)};THREE.DiscreteInterpolant.prototype=Object.assign(Object.create(THREE.Interpolant.prototype),{constructor:THREE.DiscreteInterpolant,interpolate_:function(a,b,c,d){return this.copySampleValue_(a-1)}});THREE.LinearInterpolant=function(a,b,c,d){THREE.Interpolant.call(this,a,b,c,d)};
-THREE.LinearInterpolant.prototype=Object.assign(Object.create(THREE.Interpolant.prototype),{constructor:THREE.LinearInterpolant,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g;b=(c-b)/(d-b);c=1-b;for(d=0;d!==g;++d)e[d]=f[h+d]*c+f[a+d]*b;return e}});THREE.QuaternionLinearInterpolant=function(a,b,c,d){THREE.Interpolant.call(this,a,b,c,d)};
-THREE.QuaternionLinearInterpolant.prototype=Object.assign(Object.create(THREE.Interpolant.prototype),{constructor:THREE.QuaternionLinearInterpolant,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;b=(c-b)/(d-b);for(c=a+g;a!==c;a+=4)THREE.Quaternion.slerpFlat(e,0,f,a-g,f,a,b);return e}});THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};
-THREE.Clock.prototype={constructor:THREE.Clock,start:function(){this.oldTime=this.startTime=performance.now();this.running=!0},stop:function(){this.getElapsedTime();this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=performance.now(),a=.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a}};THREE.EventDispatcher=function(){};
-THREE.EventDispatcher.prototype={constructor:THREE.EventDispatcher,apply:function(a){a.addEventListener=THREE.EventDispatcher.prototype.addEventListener;a.hasEventListener=THREE.EventDispatcher.prototype.hasEventListener;a.removeEventListener=THREE.EventDispatcher.prototype.removeEventListener;a.dispatchEvent=THREE.EventDispatcher.prototype.dispatchEvent},addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]);-1===c[a].indexOf(b)&&
-c[a].push(b)},hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexOf(b)?!0:!1},removeEventListener:function(a,b){if(void 0!==this._listeners){var c=this._listeners[a];if(void 0!==c){var d=c.indexOf(b);-1!==d&&c.splice(d,1)}}},dispatchEvent:function(a){if(void 0!==this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;for(var c=[],d=b.length,e=0;e<d;e++)c[e]=b[e];for(e=0;e<d;e++)c[e].call(this,a)}}}};
-THREE.Layers=function(){this.mask=1};THREE.Layers.prototype={constructor:THREE.Layers,set:function(a){this.mask=1<<a},enable:function(a){this.mask|=1<<a},toggle:function(a){this.mask^=1<<a},disable:function(a){this.mask&=~(1<<a)},test:function(a){return 0!==(this.mask&a.mask)}};
-(function(a){function b(a,b){return a.distance-b.distance}function c(a,b,f,g){if(!1!==a.visible&&(a.raycast(b,f),!0===g)){a=a.children;g=0;for(var h=a.length;g<h;g++)c(a[g],b,f,!0)}}a.Raycaster=function(b,c,f,g){this.ray=new a.Ray(b,c);this.near=f||0;this.far=g||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})};
-a.Raycaster.prototype={constructor:a.Raycaster,linePrecision:1,set:function(a,b){this.ray.set(a,b)},setFromCamera:function(b,c){c instanceof a.PerspectiveCamera?(this.ray.origin.setFromMatrixPosition(c.matrixWorld),this.ray.direction.set(b.x,b.y,.5).unproject(c).sub(this.ray.origin).normalize()):c instanceof a.OrthographicCamera?(this.ray.origin.set(b.x,b.y,-1).unproject(c),this.ray.direction.set(0,0,-1).transformDirection(c.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},
-intersectObject:function(a,e){var f=[];c(a,this,f,e);f.sort(b);return f},intersectObjects:function(a,e){var f=[];if(!1===Array.isArray(a))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),f;for(var g=0,h=a.length;g<h;g++)c(a[g],this,f,e);f.sort(b);return f}}})(THREE);
-THREE.Object3D=function(){Object.defineProperty(this,"id",{value:THREE.Object3DIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=THREE.Object3D.DefaultUp.clone();var a=new THREE.Vector3,b=new THREE.Euler,c=new THREE.Quaternion,d=new THREE.Vector3(1,1,1);b.onChange(function(){c.setFromEuler(b,!1)});c.onChange(function(){b.setFromQuaternion(c,void 0,!1)});Object.defineProperties(this,{position:{enumerable:!0,value:a},rotation:{enumerable:!0,
-value:b},quaternion:{enumerable:!0,value:c},scale:{enumerable:!0,value:d},modelViewMatrix:{value:new THREE.Matrix4},normalMatrix:{value:new THREE.Matrix3}});this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixAutoUpdate=THREE.Object3D.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new THREE.Layers;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData={}};
-THREE.Object3D.DefaultUp=new THREE.Vector3(0,1,0);THREE.Object3D.DefaultMatrixAutoUpdate=!0;
-THREE.Object3D.prototype={constructor:THREE.Object3D,applyMatrix:function(a){this.matrix.multiplyMatrices(a,this.matrix);this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,!0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},setRotationFromQuaternion:function(a){this.quaternion.copy(a)},rotateOnAxis:function(){var a=
-new THREE.Quaternion;return function(b,c){a.setFromAxisAngle(b,c);this.quaternion.multiply(a);return this}}(),rotateX:function(){var a=new THREE.Vector3(1,0,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateY:function(){var a=new THREE.Vector3(0,1,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateZ:function(){var a=new THREE.Vector3(0,0,1);return function(b){return this.rotateOnAxis(a,b)}}(),translateOnAxis:function(){var a=new THREE.Vector3;return function(b,c){a.copy(b).applyQuaternion(this.quaternion);
-this.position.add(a.multiplyScalar(c));return this}}(),translateX:function(){var a=new THREE.Vector3(1,0,0);return function(b){return this.translateOnAxis(a,b)}}(),translateY:function(){var a=new THREE.Vector3(0,1,0);return function(b){return this.translateOnAxis(a,b)}}(),translateZ:function(){var a=new THREE.Vector3(0,0,1);return function(b){return this.translateOnAxis(a,b)}}(),localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var a=new THREE.Matrix4;return function(b){return b.applyMatrix4(a.getInverse(this.matrixWorld))}}(),
-lookAt:function(){var a=new THREE.Matrix4;return function(b){a.lookAt(b,this.position,this.up);this.quaternion.setFromRotationMatrix(a)}}(),add:function(a){if(1<arguments.length){for(var b=0;b<arguments.length;b++)this.add(arguments[b]);return this}if(a===this)return console.error("THREE.Object3D.add: object can't be added as a child of itself.",a),this;a instanceof THREE.Object3D?(null!==a.parent&&a.parent.remove(a),a.parent=this,a.dispatchEvent({type:"added"}),this.children.push(a)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",
-a);return this},remove:function(a){if(1<arguments.length)for(var b=0;b<arguments.length;b++)this.remove(arguments[b]);b=this.children.indexOf(a);-1!==b&&(a.parent=null,a.dispatchEvent({type:"removed"}),this.children.splice(b,1))},getObjectById:function(a){return this.getObjectByProperty("id",a)},getObjectByName:function(a){return this.getObjectByProperty("name",a)},getObjectByProperty:function(a,b){if(this[a]===b)return this;for(var c=0,d=this.children.length;c<d;c++){var e=this.children[c].getObjectByProperty(a,
-b);if(void 0!==e)return e}},getWorldPosition:function(a){a=a||new THREE.Vector3;this.updateMatrixWorld(!0);return a.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c){c=c||new THREE.Quaternion;this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,c,b);return c}}(),getWorldRotation:function(){var a=new THREE.Quaternion;return function(b){b=b||new THREE.Euler;this.getWorldQuaternion(a);return b.setFromQuaternion(a,
-this.rotation.order,!1)}}(),getWorldScale:function(){var a=new THREE.Vector3,b=new THREE.Quaternion;return function(c){c=c||new THREE.Vector3;this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,b,c);return c}}(),getWorldDirection:function(){var a=new THREE.Quaternion;return function(b){b=b||new THREE.Vector3;this.getWorldQuaternion(a);return b.set(0,0,1).applyQuaternion(a)}}(),raycast:function(){},traverse:function(a){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverse(a)},traverseVisible:function(a){if(!1!==
-this.visible){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverseVisible(a)}},traverseAncestors:function(a){var b=this.parent;null!==b&&(a(b),b.traverseAncestors(a))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale);this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){!0===this.matrixAutoUpdate&&this.updateMatrix();if(!0===this.matrixWorldNeedsUpdate||!0===a)null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,
-this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a,d={};c&&(a={geometries:{},materials:{},textures:{},images:{}},d.metadata={version:4.4,type:"Object",generator:"Object3D.toJSON"});var e={};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);"{}"!==JSON.stringify(this.userData)&&(e.userData=
-this.userData);!0===this.castShadow&&(e.castShadow=!0);!0===this.receiveShadow&&(e.receiveShadow=!0);!1===this.visible&&(e.visible=!1);e.matrix=this.matrix.toArray();void 0!==this.geometry&&(void 0===a.geometries[this.geometry.uuid]&&(a.geometries[this.geometry.uuid]=this.geometry.toJSON(a)),e.geometry=this.geometry.uuid);void 0!==this.material&&(void 0===a.materials[this.material.uuid]&&(a.materials[this.material.uuid]=this.material.toJSON(a)),e.material=this.material.uuid);if(0<this.children.length){e.children=
-[];for(var f=0;f<this.children.length;f++)e.children.push(this.children[f].toJSON(a).object)}if(c){var c=b(a.geometries),f=b(a.materials),g=b(a.textures);a=b(a.images);0<c.length&&(d.geometries=c);0<f.length&&(d.materials=f);0<g.length&&(d.textures=g);0<a.length&&(d.images=a)}d.object=e;return d},clone:function(a){return(new this.constructor).copy(this,a)},copy:function(a,b){void 0===b&&(b=!0);this.name=a.name;this.up.copy(a.up);this.position.copy(a.position);this.quaternion.copy(a.quaternion);this.scale.copy(a.scale);
-this.rotationAutoUpdate=a.rotationAutoUpdate;this.matrix.copy(a.matrix);this.matrixWorld.copy(a.matrixWorld);this.matrixAutoUpdate=a.matrixAutoUpdate;this.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;this.visible=a.visible;this.castShadow=a.castShadow;this.receiveShadow=a.receiveShadow;this.frustumCulled=a.frustumCulled;this.renderOrder=a.renderOrder;this.userData=JSON.parse(JSON.stringify(a.userData));if(!0===b)for(var c=0;c<a.children.length;c++)this.add(a.children[c].clone());return this}};
-THREE.EventDispatcher.prototype.apply(THREE.Object3D.prototype);THREE.Object3DIdCount=0;THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=Array.isArray(d)?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0};
-THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a=a.a;this.b=a.b;this.c=a.c;this.normal.copy(a.normal);this.color.copy(a.color);this.materialIndex=a.materialIndex;for(var b=0,c=a.vertexNormals.length;b<c;b++)this.vertexNormals[b]=a.vertexNormals[b].clone();b=0;for(c=a.vertexColors.length;b<c;b++)this.vertexColors[b]=a.vertexColors[b].clone();return this}};
-THREE.BufferAttribute=function(a,b){this.uuid=THREE.Math.generateUUID();this.array=a;this.itemSize=b;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0};
-THREE.BufferAttribute.prototype={constructor:THREE.BufferAttribute,get count(){return this.array.length/this.itemSize},set needsUpdate(a){!0===a&&this.version++},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.itemSize=a.itemSize;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.itemSize;c*=b.itemSize;for(var d=0,e=this.itemSize;d<e;d++)this.array[a+d]=b.array[c+d];return this},copyArray:function(a){this.array.set(a);
-return this},copyColorsArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",d),f=new THREE.Color);b[c++]=f.r;b[c++]=f.g;b[c++]=f.b}return this},copyIndicesArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];b[c++]=f.a;b[c++]=f.b;b[c++]=f.c}return this},copyVector2sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",
-d),f=new THREE.Vector2);b[c++]=f.x;b[c++]=f.y}return this},copyVector3sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",d),f=new THREE.Vector3);b[c++]=f.x;b[c++]=f.y;b[c++]=f.z}return this},copyVector4sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",d),f=new THREE.Vector4);
-b[c++]=f.x;b[c++]=f.y;b[c++]=f.z;b[c++]=f.w}return this},set:function(a,b){void 0===b&&(b=0);this.array.set(a,b);return this},getX:function(a){return this.array[a*this.itemSize]},setX:function(a,b){this.array[a*this.itemSize]=b;return this},getY:function(a){return this.array[a*this.itemSize+1]},setY:function(a,b){this.array[a*this.itemSize+1]=b;return this},getZ:function(a){return this.array[a*this.itemSize+2]},setZ:function(a,b){this.array[a*this.itemSize+2]=b;return this},getW:function(a){return this.array[a*
-this.itemSize+3]},setW:function(a,b){this.array[a*this.itemSize+3]=b;return this},setXY:function(a,b,c){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;return this},setXYZ:function(a,b,c,d){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;return this},setXYZW:function(a,b,c,d,e){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;this.array[a+3]=e;return this},clone:function(){return(new this.constructor).copy(this)}};
-THREE.Int8Attribute=function(a,b){return new THREE.BufferAttribute(new Int8Array(a),b)};THREE.Uint8Attribute=function(a,b){return new THREE.BufferAttribute(new Uint8Array(a),b)};THREE.Uint8ClampedAttribute=function(a,b){return new THREE.BufferAttribute(new Uint8ClampedArray(a),b)};THREE.Int16Attribute=function(a,b){return new THREE.BufferAttribute(new Int16Array(a),b)};THREE.Uint16Attribute=function(a,b){return new THREE.BufferAttribute(new Uint16Array(a),b)};
-THREE.Int32Attribute=function(a,b){return new THREE.BufferAttribute(new Int32Array(a),b)};THREE.Uint32Attribute=function(a,b){return new THREE.BufferAttribute(new Uint32Array(a),b)};THREE.Float32Attribute=function(a,b){return new THREE.BufferAttribute(new Float32Array(a),b)};THREE.Float64Attribute=function(a,b){return new THREE.BufferAttribute(new Float64Array(a),b)};
-THREE.DynamicBufferAttribute=function(a,b){console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.");return(new THREE.BufferAttribute(a,b)).setDynamic(!0)};THREE.InstancedBufferAttribute=function(a,b,c){THREE.BufferAttribute.call(this,a,b);this.meshPerAttribute=c||1};THREE.InstancedBufferAttribute.prototype=Object.create(THREE.BufferAttribute.prototype);THREE.InstancedBufferAttribute.prototype.constructor=THREE.InstancedBufferAttribute;
-THREE.InstancedBufferAttribute.prototype.copy=function(a){THREE.BufferAttribute.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this};THREE.InterleavedBuffer=function(a,b){this.uuid=THREE.Math.generateUUID();this.array=a;this.stride=b;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0};
-THREE.InterleavedBuffer.prototype={constructor:THREE.InterleavedBuffer,get length(){return this.array.length},get count(){return this.array.length/this.stride},set needsUpdate(a){!0===a&&this.version++},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.stride=a.stride;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.stride;c*=b.stride;for(var d=0,e=this.stride;d<e;d++)this.array[a+d]=b.array[c+d];return this},set:function(a,
-b){void 0===b&&(b=0);this.array.set(a,b);return this},clone:function(){return(new this.constructor).copy(this)}};THREE.InstancedInterleavedBuffer=function(a,b,c){THREE.InterleavedBuffer.call(this,a,b);this.meshPerAttribute=c||1};THREE.InstancedInterleavedBuffer.prototype=Object.create(THREE.InterleavedBuffer.prototype);THREE.InstancedInterleavedBuffer.prototype.constructor=THREE.InstancedInterleavedBuffer;
-THREE.InstancedInterleavedBuffer.prototype.copy=function(a){THREE.InterleavedBuffer.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this};THREE.InterleavedBufferAttribute=function(a,b,c){this.uuid=THREE.Math.generateUUID();this.data=a;this.itemSize=b;this.offset=c};
-THREE.InterleavedBufferAttribute.prototype={constructor:THREE.InterleavedBufferAttribute,get length(){console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count.");return this.array.length},get count(){return this.data.count},setX:function(a,b){this.data.array[a*this.data.stride+this.offset]=b;return this},setY:function(a,b){this.data.array[a*this.data.stride+this.offset+1]=b;return this},setZ:function(a,b){this.data.array[a*this.data.stride+this.offset+2]=b;return this},
-setW:function(a,b){this.data.array[a*this.data.stride+this.offset+3]=b;return this},getX:function(a){return this.data.array[a*this.data.stride+this.offset]},getY:function(a){return this.data.array[a*this.data.stride+this.offset+1]},getZ:function(a){return this.data.array[a*this.data.stride+this.offset+2]},getW:function(a){return this.data.array[a*this.data.stride+this.offset+3]},setXY:function(a,b,c){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;return this},setXYZ:function(a,
-b,c,d){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;return this},setXYZW:function(a,b,c,d,e){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;this.data.array[a+3]=e;return this}};
-THREE.Geometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.elementsNeedUpdate=
-this.verticesNeedUpdate=!1};
-THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){for(var b=(new THREE.Matrix3).getNormalMatrix(a),c=0,d=this.vertices.length;c<d;c++)this.vertices[c].applyMatrix4(a);c=0;for(d=this.faces.length;c<d;c++){a=this.faces[c];a.normal.applyMatrix3(b).normalize();for(var e=0,f=a.vertexNormals.length;e<f;e++)a.vertexNormals[e].applyMatrix3(b).normalize()}null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();this.normalsNeedUpdate=
-this.verticesNeedUpdate=!0},rotateX:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationZ(b);this.applyMatrix(a);return this}}(),translate:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);
-a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a;return function(b){void 0===a&&(a=new THREE.Object3D);a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),fromBufferGeometry:function(a){function b(a,b,d){var e=void 0!==g?[n[a].clone(),n[b].clone(),n[d].clone()]:[],f=void 0!==h?[c.colors[a].clone(),c.colors[b].clone(),c.colors[d].clone()]:
-[],e=new THREE.Face3(a,b,d,e,f);c.faces.push(e);void 0!==k&&c.faceVertexUvs[0].push([p[a].clone(),p[b].clone(),p[d].clone()]);void 0!==l&&c.faceVertexUvs[1].push([m[a].clone(),m[b].clone(),m[d].clone()])}var c=this,d=null!==a.index?a.index.array:void 0,e=a.attributes,f=e.position.array,g=void 0!==e.normal?e.normal.array:void 0,h=void 0!==e.color?e.color.array:void 0,k=void 0!==e.uv?e.uv.array:void 0,l=void 0!==e.uv2?e.uv2.array:void 0;void 0!==l&&(this.faceVertexUvs[1]=[]);for(var n=[],p=[],m=[],
-q=e=0;e<f.length;e+=3,q+=2)c.vertices.push(new THREE.Vector3(f[e],f[e+1],f[e+2])),void 0!==g&&n.push(new THREE.Vector3(g[e],g[e+1],g[e+2])),void 0!==h&&c.colors.push(new THREE.Color(h[e],h[e+1],h[e+2])),void 0!==k&&p.push(new THREE.Vector2(k[q],k[q+1])),void 0!==l&&m.push(new THREE.Vector2(l[q],l[q+1]));if(void 0!==d)if(f=a.groups,0<f.length)for(e=0;e<f.length;e++)for(var q=f[e],s=q.start,u=q.count,q=s,s=s+u;q<s;q+=3)b(d[q],d[q+1],d[q+2]);else for(e=0;e<d.length;e+=3)b(d[e],d[e+1],d[e+2]);else for(e=
-0;e<f.length/3;e+=3)b(e,e+1,e+2);this.computeFaceNormals();null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());return this},center:function(){this.computeBoundingBox();var a=this.boundingBox.center().negate();this.translate(a.x,a.y,a.z);return a},normalize:function(){this.computeBoundingSphere();var a=this.boundingSphere.center,b=this.boundingSphere.radius,b=0===b?1:1/b,c=new THREE.Matrix4;c.set(b,0,0,-b*a.x,0,b,0,
--b*a.y,0,0,b,-b*a.z,0,0,0,1);this.applyMatrix(c);return this},computeFaceNormals:function(){for(var a=new THREE.Vector3,b=new THREE.Vector3,c=0,d=this.faces.length;c<d;c++){var e=this.faces[c],f=this.vertices[e.a],g=this.vertices[e.b];a.subVectors(this.vertices[e.c],g);b.subVectors(f,g);a.cross(b);a.normalize();e.normal.copy(a)}},computeVertexNormals:function(a){void 0===a&&(a=!0);var b,c,d;d=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)d[b]=new THREE.Vector3;if(a){var e,f,g,
-h=new THREE.Vector3,k=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],e=this.vertices[c.a],f=this.vertices[c.b],g=this.vertices[c.c],h.subVectors(g,f),k.subVectors(e,f),h.cross(k),d[c.a].add(h),d[c.b].add(h),d[c.c].add(h)}else for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d[c.a].add(c.normal),d[c.b].add(c.normal),d[c.c].add(c.normal);b=0;for(c=this.vertices.length;b<c;b++)d[b].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],e=c.vertexNormals,3===e.length?
-(e[0].copy(d[c.a]),e[1].copy(d[c.b]),e[2].copy(d[c.c])):(e[0]=d[c.a].clone(),e[1]=d[c.b].clone(),e[2]=d[c.c].clone());0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var a,b,c,d,e;c=0;for(d=this.faces.length;c<d;c++)for(e=this.faces[c],e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone(),e.__originalVertexNormals||(e.__originalVertexNormals=[]),a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):
-e.__originalVertexNormals[a]=e.vertexNormals[a].clone();var f=new THREE.Geometry;f.faces=this.faces;a=0;for(b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];e=this.morphNormals[a].faceNormals;var g=this.morphNormals[a].vertexNormals,h,k;c=0;for(d=this.faces.length;c<d;c++)h=new THREE.Vector3,k={a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3},e.push(h),g.push(k)}g=this.morphNormals[a];
-f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();f.computeVertexNormals();c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],h=g.faceNormals[c],k=g.vertexNormals[c],h.copy(e.normal),k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2])}c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")},
-computeLineDistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;c<d;c++)0<c&&(a+=b[c].distanceTo(b[c-1])),this.lineDistances[c]=a},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);this.boundingSphere.setFromPoints(this.vertices)},merge:function(a,b,c){if(!1===a instanceof THREE.Geometry)console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",
-a);else{var d,e=this.vertices.length,f=this.vertices,g=a.vertices,h=this.faces,k=a.faces,l=this.faceVertexUvs[0];a=a.faceVertexUvs[0];void 0===c&&(c=0);void 0!==b&&(d=(new THREE.Matrix3).getNormalMatrix(b));for(var n=0,p=g.length;n<p;n++){var m=g[n].clone();void 0!==b&&m.applyMatrix4(b);f.push(m)}n=0;for(p=k.length;n<p;n++){var g=k[n],q,s=g.vertexNormals,u=g.vertexColors,m=new THREE.Face3(g.a+e,g.b+e,g.c+e);m.normal.copy(g.normal);void 0!==d&&m.normal.applyMatrix3(d).normalize();b=0;for(f=s.length;b<
-f;b++)q=s[b].clone(),void 0!==d&&q.applyMatrix3(d).normalize(),m.vertexNormals.push(q);m.color.copy(g.color);b=0;for(f=u.length;b<f;b++)q=u[b],m.vertexColors.push(q.clone());m.materialIndex=g.materialIndex+c;h.push(m)}n=0;for(p=a.length;n<p;n++)if(c=a[n],d=[],void 0!==c){b=0;for(f=c.length;b<f;b++)d.push(c[b].clone());l.push(d)}}},mergeMesh:function(a){!1===a instanceof THREE.Mesh?console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",a):(a.matrixAutoUpdate&&a.updateMatrix(),
-this.merge(a.geometry,a.matrix))},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f],d=Math.round(d.x*e)+"_"+Math.round(d.y*e)+"_"+Math.round(d.z*e),void 0===a[d]?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];a=[];f=0;for(g=this.faces.length;f<g;f++)for(e=this.faces[f],e.a=c[e.a],e.b=c[e.b],e.c=c[e.c],e=[e.a,e.b,e.c],d=0;3>d;d++)if(e[d]===e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,
-1),c=0,g=this.faceVertexUvs.length;c<g;c++)this.faceVertexUvs[c].splice(e,1);f=this.vertices.length-b.length;this.vertices=b;return f},sortFacesByMaterialIndex:function(){for(var a=this.faces,b=a.length,c=0;c<b;c++)a[c]._id=c;a.sort(function(a,b){return a.materialIndex-b.materialIndex});var d=this.faceVertexUvs[0],e=this.faceVertexUvs[1],f,g;d&&d.length===b&&(f=[]);e&&e.length===b&&(g=[]);for(c=0;c<b;c++){var h=a[c]._id;f&&f.push(d[h]);g&&g.push(e[h])}f&&(this.faceVertexUvs[0]=f);g&&(this.faceVertexUvs[1]=
-g)},toJSON:function(){function a(a,b,c){return c?a|1<<b:a&~(1<<b)}function b(a){var b=a.x.toString()+a.y.toString()+a.z.toString();if(void 0!==l[b])return l[b];l[b]=k.length/3;k.push(a.x,a.y,a.z);return l[b]}function c(a){var b=a.r.toString()+a.g.toString()+a.b.toString();if(void 0!==p[b])return p[b];p[b]=n.length;n.push(a.getHex());return p[b]}function d(a){var b=a.x.toString()+a.y.toString();if(void 0!==q[b])return q[b];q[b]=m.length/2;m.push(a.x,a.y);return q[b]}var e={metadata:{version:4.4,type:"Geometry",
-generator:"Geometry.toJSON"}};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);if(void 0!==this.parameters){var f=this.parameters,g;for(g in f)void 0!==f[g]&&(e[g]=f[g]);return e}f=[];for(g=0;g<this.vertices.length;g++){var h=this.vertices[g];f.push(h.x,h.y,h.z)}var h=[],k=[],l={},n=[],p={},m=[],q={};for(g=0;g<this.faces.length;g++){var s=this.faces[g],u=void 0!==this.faceVertexUvs[0][g],t=0<s.normal.length(),x=0<s.vertexNormals.length,v=1!==s.color.r||1!==s.color.g||1!==s.color.b,
-C=0<s.vertexColors.length,w=0,w=a(w,0,0),w=a(w,1,!0),w=a(w,2,!1),w=a(w,3,u),w=a(w,4,t),w=a(w,5,x),w=a(w,6,v),w=a(w,7,C);h.push(w);h.push(s.a,s.b,s.c);h.push(s.materialIndex);u&&(u=this.faceVertexUvs[0][g],h.push(d(u[0]),d(u[1]),d(u[2])));t&&h.push(b(s.normal));x&&(t=s.vertexNormals,h.push(b(t[0]),b(t[1]),b(t[2])));v&&h.push(c(s.color));C&&(s=s.vertexColors,h.push(c(s[0]),c(s[1]),c(s[2])))}e.data={};e.data.vertices=f;e.data.normals=k;0<n.length&&(e.data.colors=n);0<m.length&&(e.data.uvs=[m]);e.data.faces=
-h;return e},clone:function(){return(new THREE.Geometry).copy(this)},copy:function(a){this.vertices=[];this.faces=[];this.faceVertexUvs=[[]];for(var b=a.vertices,c=0,d=b.length;c<d;c++)this.vertices.push(b[c].clone());b=a.faces;c=0;for(d=b.length;c<d;c++)this.faces.push(b[c].clone());c=0;for(d=a.faceVertexUvs.length;c<d;c++){b=a.faceVertexUvs[c];void 0===this.faceVertexUvs[c]&&(this.faceVertexUvs[c]=[]);for(var e=0,f=b.length;e<f;e++){for(var g=b[e],h=[],k=0,l=g.length;k<l;k++)h.push(g[k].clone());
-this.faceVertexUvs[c].push(h)}}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.Geometry.prototype);THREE.GeometryIdCount=0;
-THREE.DirectGeometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="DirectGeometry";this.indices=[];this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1};
-THREE.DirectGeometry.prototype={constructor:THREE.DirectGeometry,computeBoundingBox:THREE.Geometry.prototype.computeBoundingBox,computeBoundingSphere:THREE.Geometry.prototype.computeBoundingSphere,computeFaceNormals:function(){console.warn("THREE.DirectGeometry: computeFaceNormals() is not a method of this type of geometry.")},computeVertexNormals:function(){console.warn("THREE.DirectGeometry: computeVertexNormals() is not a method of this type of geometry.")},computeGroups:function(a){var b,c=[],
-d;a=a.faces;for(var e=0;e<a.length;e++){var f=a[e];f.materialIndex!==d&&(d=f.materialIndex,void 0!==b&&(b.count=3*e-b.start,c.push(b)),b={start:3*e,materialIndex:d})}void 0!==b&&(b.count=3*e-b.start,c.push(b));this.groups=c},fromGeometry:function(a){var b=a.faces,c=a.vertices,d=a.faceVertexUvs,e=d[0]&&0<d[0].length,f=d[1]&&0<d[1].length,g=a.morphTargets,h=g.length,k;if(0<h){k=[];for(var l=0;l<h;l++)k[l]=[];this.morphTargets.position=k}var n=a.morphNormals,p=n.length,m;if(0<p){m=[];for(l=0;l<p;l++)m[l]=
-[];this.morphTargets.normal=m}for(var q=a.skinIndices,s=a.skinWeights,u=q.length===c.length,t=s.length===c.length,l=0;l<b.length;l++){var x=b[l];this.vertices.push(c[x.a],c[x.b],c[x.c]);var v=x.vertexNormals;3===v.length?this.normals.push(v[0],v[1],v[2]):(v=x.normal,this.normals.push(v,v,v));v=x.vertexColors;3===v.length?this.colors.push(v[0],v[1],v[2]):(v=x.color,this.colors.push(v,v,v));!0===e&&(v=d[0][l],void 0!==v?this.uvs.push(v[0],v[1],v[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",
-l),this.uvs.push(new THREE.Vector2,new THREE.Vector2,new THREE.Vector2)));!0===f&&(v=d[1][l],void 0!==v?this.uvs2.push(v[0],v[1],v[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",l),this.uvs2.push(new THREE.Vector2,new THREE.Vector2,new THREE.Vector2)));for(v=0;v<h;v++){var C=g[v].vertices;k[v].push(C[x.a],C[x.b],C[x.c])}for(v=0;v<p;v++)C=n[v].vertexNormals[l],m[v].push(C.a,C.b,C.c);u&&this.skinIndices.push(q[x.a],q[x.b],q[x.c]);t&&this.skinWeights.push(s[x.a],s[x.b],
-s[x.c])}this.computeGroups(a);this.verticesNeedUpdate=a.verticesNeedUpdate;this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.DirectGeometry.prototype);
-THREE.BufferGeometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity}};
-THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,getIndex:function(){return this.index},setIndex:function(a){this.index=a},addAttribute:function(a,b,c){if(!1===b instanceof THREE.BufferAttribute&&!1===b instanceof THREE.InterleavedBufferAttribute)console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(a,new THREE.BufferAttribute(b,c));else if("index"===a)console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),
-this.setIndex(b);else return this.attributes[a]=b,this},getAttribute:function(a){return this.attributes[a]},removeAttribute:function(a){delete this.attributes[a];return this},addGroup:function(a,b,c){this.groups.push({start:a,count:b,materialIndex:void 0!==c?c:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(a,b){this.drawRange.start=a;this.drawRange.count=b},applyMatrix:function(a){var b=this.attributes.position;void 0!==b&&(a.applyToVector3Array(b.array),b.needsUpdate=!0);b=this.attributes.normal;
-void 0!==b&&((new THREE.Matrix3).getNormalMatrix(a).applyToVector3Array(b.array),b.needsUpdate=!0);null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere()},rotateX:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a;return function(b){void 0===
-a&&(a=new THREE.Matrix4);a.makeRotationZ(b);this.applyMatrix(a);return this}}(),translate:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a;return function(b){void 0===a&&(a=new THREE.Object3D);a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),center:function(){this.computeBoundingBox();
-var a=this.boundingBox.center().negate();this.translate(a.x,a.y,a.z);return a},setFromObject:function(a){var b=a.geometry;if(a instanceof THREE.Points||a instanceof THREE.Line){a=new THREE.Float32Attribute(3*b.vertices.length,3);var c=new THREE.Float32Attribute(3*b.colors.length,3);this.addAttribute("position",a.copyVector3sArray(b.vertices));this.addAttribute("color",c.copyColorsArray(b.colors));b.lineDistances&&b.lineDistances.length===b.vertices.length&&(a=new THREE.Float32Attribute(b.lineDistances.length,
-1),this.addAttribute("lineDistance",a.copyArray(b.lineDistances)));null!==b.boundingSphere&&(this.boundingSphere=b.boundingSphere.clone());null!==b.boundingBox&&(this.boundingBox=b.boundingBox.clone())}else a instanceof THREE.Mesh&&b instanceof THREE.Geometry&&this.fromGeometry(b);return this},updateFromObject:function(a){var b=a.geometry;if(a instanceof THREE.Mesh){var c=b.__directGeometry;if(void 0===c)return this.fromGeometry(b);c.verticesNeedUpdate=b.verticesNeedUpdate;c.normalsNeedUpdate=b.normalsNeedUpdate;
-c.colorsNeedUpdate=b.colorsNeedUpdate;c.uvsNeedUpdate=b.uvsNeedUpdate;c.groupsNeedUpdate=b.groupsNeedUpdate;b.verticesNeedUpdate=!1;b.normalsNeedUpdate=!1;b.colorsNeedUpdate=!1;b.uvsNeedUpdate=!1;b.groupsNeedUpdate=!1;b=c}!0===b.verticesNeedUpdate&&(c=this.attributes.position,void 0!==c&&(c.copyVector3sArray(b.vertices),c.needsUpdate=!0),b.verticesNeedUpdate=!1);!0===b.normalsNeedUpdate&&(c=this.attributes.normal,void 0!==c&&(c.copyVector3sArray(b.normals),c.needsUpdate=!0),b.normalsNeedUpdate=!1);
-!0===b.colorsNeedUpdate&&(c=this.attributes.color,void 0!==c&&(c.copyColorsArray(b.colors),c.needsUpdate=!0),b.colorsNeedUpdate=!1);b.uvsNeedUpdate&&(c=this.attributes.uv,void 0!==c&&(c.copyVector2sArray(b.uvs),c.needsUpdate=!0),b.uvsNeedUpdate=!1);b.lineDistancesNeedUpdate&&(c=this.attributes.lineDistance,void 0!==c&&(c.copyArray(b.lineDistances),c.needsUpdate=!0),b.lineDistancesNeedUpdate=!1);b.groupsNeedUpdate&&(b.computeGroups(a.geometry),this.groups=b.groups,b.groupsNeedUpdate=!1);return this},
-fromGeometry:function(a){a.__directGeometry=(new THREE.DirectGeometry).fromGeometry(a);return this.fromDirectGeometry(a.__directGeometry)},fromDirectGeometry:function(a){var b=new Float32Array(3*a.vertices.length);this.addAttribute("position",(new THREE.BufferAttribute(b,3)).copyVector3sArray(a.vertices));0<a.normals.length&&(b=new Float32Array(3*a.normals.length),this.addAttribute("normal",(new THREE.BufferAttribute(b,3)).copyVector3sArray(a.normals)));0<a.colors.length&&(b=new Float32Array(3*a.colors.length),
-this.addAttribute("color",(new THREE.BufferAttribute(b,3)).copyColorsArray(a.colors)));0<a.uvs.length&&(b=new Float32Array(2*a.uvs.length),this.addAttribute("uv",(new THREE.BufferAttribute(b,2)).copyVector2sArray(a.uvs)));0<a.uvs2.length&&(b=new Float32Array(2*a.uvs2.length),this.addAttribute("uv2",(new THREE.BufferAttribute(b,2)).copyVector2sArray(a.uvs2)));0<a.indices.length&&(b=new (65535<a.vertices.length?Uint32Array:Uint16Array)(3*a.indices.length),this.setIndex((new THREE.BufferAttribute(b,
-1)).copyIndicesArray(a.indices)));this.groups=a.groups;for(var c in a.morphTargets){for(var b=[],d=a.morphTargets[c],e=0,f=d.length;e<f;e++){var g=d[e],h=new THREE.Float32Attribute(3*g.length,3);b.push(h.copyVector3sArray(g))}this.morphAttributes[c]=b}0<a.skinIndices.length&&(c=new THREE.Float32Attribute(4*a.skinIndices.length,4),this.addAttribute("skinIndex",c.copyVector4sArray(a.skinIndices)));0<a.skinWeights.length&&(c=new THREE.Float32Attribute(4*a.skinWeights.length,4),this.addAttribute("skinWeight",
-c.copyVector4sArray(a.skinWeights)));null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());return this},computeBoundingBox:function(){new THREE.Vector3;return function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var a=this.attributes.position.array;a&&this.boundingBox.setFromArray(a);if(void 0===a||0===a.length)this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0);(isNaN(this.boundingBox.min.x)||
-isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}}(),computeBoundingSphere:function(){var a=new THREE.Box3,b=new THREE.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var c=this.attributes.position.array;if(c){var d=this.boundingSphere.center;a.setFromArray(c);a.center(d);for(var e=0,f=0,g=
-c.length;f<g;f+=3)b.fromArray(c,f),e=Math.max(e,d.distanceToSquared(b));this.boundingSphere.radius=Math.sqrt(e);isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var a=this.index,b=this.attributes,c=this.groups;if(b.position){var d=b.position.array;if(void 0===b.normal)this.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(d.length),
-3));else for(var e=b.normal.array,f=0,g=e.length;f<g;f++)e[f]=0;var e=b.normal.array,h,k,l,n=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector3,q=new THREE.Vector3,s=new THREE.Vector3;if(a){a=a.array;0===c.length&&this.addGroup(0,a.length);for(var u=0,t=c.length;u<t;++u)for(f=c[u],g=f.start,h=f.count,f=g,g+=h;f<g;f+=3)h=3*a[f+0],k=3*a[f+1],l=3*a[f+2],n.fromArray(d,h),p.fromArray(d,k),m.fromArray(d,l),q.subVectors(m,p),s.subVectors(n,p),q.cross(s),e[h]+=q.x,e[h+1]+=q.y,e[h+2]+=q.z,e[k]+=q.x,
-e[k+1]+=q.y,e[k+2]+=q.z,e[l]+=q.x,e[l+1]+=q.y,e[l+2]+=q.z}else for(f=0,g=d.length;f<g;f+=9)n.fromArray(d,f),p.fromArray(d,f+3),m.fromArray(d,f+6),q.subVectors(m,p),s.subVectors(n,p),q.cross(s),e[f]=q.x,e[f+1]=q.y,e[f+2]=q.z,e[f+3]=q.x,e[f+4]=q.y,e[f+5]=q.z,e[f+6]=q.x,e[f+7]=q.y,e[f+8]=q.z;this.normalizeNormals();b.normal.needsUpdate=!0}},merge:function(a,b){if(!1===a instanceof THREE.BufferGeometry)console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",a);
-else{void 0===b&&(b=0);var c=this.attributes,d;for(d in c)if(void 0!==a.attributes[d])for(var e=c[d].array,f=a.attributes[d],g=f.array,h=0,f=f.itemSize*b;h<g.length;h++,f++)e[f]=g[h];return this}},normalizeNormals:function(){for(var a=this.attributes.normal.array,b,c,d,e=0,f=a.length;e<f;e+=3)b=a[e],c=a[e+1],d=a[e+2],b=1/Math.sqrt(b*b+c*c+d*d),a[e]*=b,a[e+1]*=b,a[e+2]*=b},toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),
-this;var a=new THREE.BufferGeometry,b=this.index.array,c=this.attributes,d;for(d in c){for(var e=c[d],f=e.array,e=e.itemSize,g=new f.constructor(b.length*e),h=0,k=0,l=0,n=b.length;l<n;l++)for(var h=b[l]*e,p=0;p<e;p++)g[k++]=f[h++];a.addAttribute(d,new THREE.BufferAttribute(g,e))}return a},toJSON:function(){var a={metadata:{version:4.4,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};a.uuid=this.uuid;a.type=this.type;""!==this.name&&(a.name=this.name);if(void 0!==this.parameters){var b=this.parameters,
-c;for(c in b)void 0!==b[c]&&(a[c]=b[c]);return a}a.data={attributes:{}};var d=this.index;null!==d&&(b=Array.prototype.slice.call(d.array),a.data.index={type:d.array.constructor.name,array:b});d=this.attributes;for(c in d){var e=d[c],b=Array.prototype.slice.call(e.array);a.data.attributes[c]={itemSize:e.itemSize,type:e.array.constructor.name,array:b}}c=this.groups;0<c.length&&(a.data.groups=JSON.parse(JSON.stringify(c)));c=this.boundingSphere;null!==c&&(a.data.boundingSphere={center:c.center.toArray(),
-radius:c.radius});return a},clone:function(){return(new THREE.BufferGeometry).copy(this)},copy:function(a){var b=a.index;null!==b&&this.setIndex(b.clone());var b=a.attributes,c;for(c in b)this.addAttribute(c,b[c].clone());a=a.groups;c=0;for(b=a.length;c<b;c++){var d=a[c];this.addGroup(d.start,d.count)}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.BufferGeometry.prototype);THREE.BufferGeometry.MaxIndex=65535;
-THREE.InstancedBufferGeometry=function(){THREE.BufferGeometry.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0};THREE.InstancedBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.InstancedBufferGeometry.prototype.constructor=THREE.InstancedBufferGeometry;THREE.InstancedBufferGeometry.prototype.addGroup=function(a,b,c){this.groups.push({start:a,count:b,instances:c})};
-THREE.InstancedBufferGeometry.prototype.copy=function(a){var b=a.index;null!==b&&this.setIndex(b.clone());var b=a.attributes,c;for(c in b)this.addAttribute(c,b[c].clone());a=a.groups;c=0;for(b=a.length;c<b;c++){var d=a[c];this.addGroup(d.start,d.count,d.instances)}return this};THREE.EventDispatcher.prototype.apply(THREE.InstancedBufferGeometry.prototype);THREE.Uniform=function(a,b){this.type=a;this.value=b;this.dynamic=!1};
-THREE.Uniform.prototype={constructor:THREE.Uniform,onUpdate:function(a){this.dynamic=!0;this.onUpdateCallback=a;return this}};THREE.AnimationClip=function(a,b,c){this.name=a||THREE.Math.generateUUID();this.tracks=c;this.duration=void 0!==b?b:-1;0>this.duration&&this.resetDuration();this.trim();this.optimize()};
-THREE.AnimationClip.prototype={constructor:THREE.AnimationClip,resetDuration:function(){for(var a=0,b=0,c=this.tracks.length;b!==c;++b)var d=this.tracks[b],a=Math.max(a,d.times[d.times.length-1]);this.duration=a},trim:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].trim(0,this.duration);return this},optimize:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].optimize();return this}};
-Object.assign(THREE.AnimationClip,{parse:function(a){for(var b=[],c=a.tracks,d=1/(a.fps||1),e=0,f=c.length;e!==f;++e)b.push(THREE.KeyframeTrack.parse(c[e]).scale(d));return new THREE.AnimationClip(a.name,a.duration,b)},toJSON:function(a){var b=[],c=a.tracks;a={name:a.name,duration:a.duration,tracks:b};for(var d=0,e=c.length;d!==e;++d)b.push(THREE.KeyframeTrack.toJSON(c[d]));return a},CreateFromMorphTargetSequence:function(a,b,c){for(var d=b.length,e=[],f=0;f<d;f++){var g=[],h=[];g.push((f+d-1)%d,
-f,(f+1)%d);h.push(0,1,0);var k=THREE.AnimationUtils.getKeyframeOrder(g),g=THREE.AnimationUtils.sortedArray(g,1,k),h=THREE.AnimationUtils.sortedArray(h,1,k);0===g[0]&&(g.push(d),h.push(h[0]));e.push((new THREE.NumberKeyframeTrack(".morphTargetInfluences["+b[f].name+"]",g,h)).scale(1/c))}return new THREE.AnimationClip(a,-1,e)},findByName:function(a,b){for(var c=0;c<a.length;c++)if(a[c].name===b)return a[c];return null},CreateClipsFromMorphTargetSequences:function(a,b){for(var c={},d=/^([\w-]*?)([\d]+)$/,
-e=0,f=a.length;e<f;e++){var g=a[e],h=g.name.match(d);if(h&&1<h.length){var k=h[1];(h=c[k])||(c[k]=h=[]);h.push(g)}}d=[];for(k in c)d.push(THREE.AnimationClip.CreateFromMorphTargetSequence(k,c[k],b));return d},parseAnimation:function(a,b,c){if(!a)return console.error("  no animation in JSONLoader data"),null;c=function(a,b,c,d,e){if(0!==c.length){var f=[],g=[];THREE.AnimationUtils.flattenJSON(c,f,g,d);0!==f.length&&e.push(new a(b,f,g))}};var d=[],e=a.name||"default",f=a.length||-1,g=a.fps||30;a=a.hierarchy||
-[];for(var h=0;h<a.length;h++){var k=a[h].keys;if(k&&0!=k.length)if(k[0].morphTargets){for(var f={},l=0;l<k.length;l++)if(k[l].morphTargets)for(var n=0;n<k[l].morphTargets.length;n++)f[k[l].morphTargets[n]]=-1;for(var p in f){for(var m=[],q=[],n=0;n!==k[l].morphTargets.length;++n){var s=k[l];m.push(s.time);q.push(s.morphTarget===p?1:0)}d.push(new THREE.NumberKeyframeTrack(".morphTargetInfluence["+p+"]",m,q))}f=f.length*(g||1)}else l=".bones["+b[h].name+"]",c(THREE.VectorKeyframeTrack,l+".position",
-k,"pos",d),c(THREE.QuaternionKeyframeTrack,l+".quaternion",k,"rot",d),c(THREE.VectorKeyframeTrack,l+".scale",k,"scl",d)}return 0===d.length?null:new THREE.AnimationClip(e,f,d)}});THREE.AnimationMixer=function(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1};
-THREE.AnimationMixer.prototype={constructor:THREE.AnimationMixer,clipAction:function(a,b){var c=(b||this._root).uuid,d="string"===typeof a?a:a.name,e=a!==d?a:null,f=this._actionsByClip[d],g;if(void 0!==f){g=f.actionByRoot[c];if(void 0!==g)return g;g=f.knownActions[0];e=g._clip;if(a!==d&&a!==e)throw Error("Different clips with the same name detected!");}if(null===e)return null;f=new THREE.AnimationMixer._Action(this,e,b);this._bindAction(f,g);this._addInactiveAction(f,d,c);return f},existingAction:function(a,
-b){var c=(b||this._root).uuid,d=this._actionsByClip["string"===typeof a?a:a.name];return void 0!==d?d.actionByRoot[c]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,d=this._nActiveBindings,e=this._nActiveBindings=this._nActiveActions=0;e!==b;++e)a[e].reset();for(e=0;e!==d;++e)c[e].useCount=0;return this},update:function(a){a*=this.timeScale;for(var b=this._actions,c=this._nActiveActions,d=this.time+=a,e=Math.sign(a),f=this._accuIndex^=1,g=0;g!==
-c;++g){var h=b[g];h.enabled&&h._update(d,a,e,f)}a=this._bindings;b=this._nActiveBindings;for(g=0;g!==b;++g)a[g].apply(f);return this},getRoot:function(){return this._root},uncacheClip:function(a){var b=this._actions;a=a.name;var c=this._actionsByClip,d=c[a];if(void 0!==d){for(var d=d.knownActions,e=0,f=d.length;e!==f;++e){var g=d[e];this._deactivateAction(g);var h=g._cacheIndex,k=b[b.length-1];g._cacheIndex=null;g._byClipCacheIndex=null;k._cacheIndex=h;b[h]=k;b.pop();this._removeInactiveBindingsForAction(g)}delete c[a]}},
-uncacheRoot:function(a){a=a.uuid;var b=this._actionsByClip,c;for(c in b){var d=b[c].actionByRoot[a];void 0!==d&&(this._deactivateAction(d),this._removeInactiveAction(d))}c=this._bindingsByRootAndName[a];if(void 0!==c)for(var e in c)a=c[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){var c=this.existingAction(a,b);null!==c&&(this._deactivateAction(c),this._removeInactiveAction(c))}};THREE.EventDispatcher.prototype.apply(THREE.AnimationMixer.prototype);
-THREE.AnimationMixer._Action=function(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:THREE.ZeroCurvatureEnding,endingEnd:THREE.ZeroCurvatureEnding},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=THREE.LoopRepeat;this._loopCount=
--1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0};
-THREE.AnimationMixer._Action.prototype={constructor:THREE.AnimationMixer._Action,play:function(){this._mixer._activateAction(this);return this},stop:function(){this._mixer._deactivateAction(this);return this.reset()},reset:function(){this.paused=!1;this.enabled=!0;this.time=0;this._loopCount=-1;this._startTime=null;return this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},
-startAt:function(a){this._startTime=a;return this},setLoop:function(a,b){this.loop=a;this.repetitions=b;return this},setEffectiveWeight:function(a){this.weight=a;this._effectiveWeight=this.enabled?a:0;return this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(a){return this._scheduleFading(a,0,1)},fadeOut:function(a){return this._scheduleFading(a,1,0)},crossFadeFrom:function(a,b,c){a.fadeOut(b);this.fadeIn(b);if(c){c=this._clip.duration;var d=a._clip.duration,
-e=c/d;a.warp(1,d/c,b);this.warp(e,1,b)}return this},crossFadeTo:function(a,b,c){return a.crossFadeFrom(this,b,c)},stopFading:function(){var a=this._weightInterpolant;null!==a&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(a));return this},setEffectiveTimeScale:function(a){this.timeScale=a;this._effectiveTimeScale=this.paused?0:a;return this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(a){this.timeScale=this._clip.duration/
-a;return this.stopWarping()},syncWith:function(a){this.time=a.time;this.timeScale=a.timeScale;return this.stopWarping()},halt:function(a){return this.warp(this._currentTimeScale,0,a)},warp:function(a,b,c){var d=this._mixer,e=d.time,f=this._timeScaleInterpolant,g=this.timeScale;null===f&&(this._timeScaleInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;d[1]=e+c;f[0]=a/g;f[1]=b/g;return this},stopWarping:function(){var a=this._timeScaleInterpolant;null!==a&&(this._timeScaleInterpolant=
-null,this._mixer._takeBackControlInterpolant(a));return this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(a,b,c,d){var e=this._startTime;if(null!==e){b=(a-e)*c;if(0>b||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0<a){b=this._interpolants;for(var e=this._propertyBindings,f=0,g=b.length;f!==g;++f)b[f].evaluate(c),e[f].accumulate(d,
-a)}},_updateWeight:function(a){var b=0;if(this.enabled){var b=this.weight,c=this._weightInterpolant;if(null!==c){var d=c.evaluate(a)[0],b=b*d;a>c.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){var b=this.timeScale,c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0],b=b*d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.pause=!0:this.timeScale=b)}}return this._effectiveTimeScale=
-b},_updateTime:function(a){var b=this.time+a;if(0===a)return b;var c=this._clip.duration,d=this.loop,e=this._loopCount,f=!1;switch(d){case THREE.LoopOnce:-1===e&&(this.loopCount=0,this._setEndings(!0,!0,!1));if(b>=c)b=c;else if(0>b)b=0;else break;this.clampWhenFinished?this.pause=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1});break;case THREE.LoopPingPong:f=!0;case THREE.LoopRepeat:-1===e&&(0<a?(e=0,this._setEndings(!0,0===this.repetitions,f)):this._setEndings(0===
-this.repetitions,!0,f));if(b>=c||0>b){var g=Math.floor(b/c),b=b-c*g,e=e+Math.abs(g),h=this.repetitions-e;if(0>h){this.clampWhenFinished?this.paused=!0:this.enabled=!1;b=0<a?c:0;this._mixer.dispatchEvent({type:"finished",action:this,direction:0<a?1:-1});break}else 0===h?(a=0>a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f);this._loopCount=e;this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:g})}if(d===THREE.LoopPingPong&&1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,
-b,c){var d=this._interpolantSettings;c?(d.endingStart=THREE.ZeroSlopeEnding,d.endingEnd=THREE.ZeroSlopeEnding):(d.endingStart=a?this.zeroSlopeAtStart?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:THREE.WrapAroundEnding,d.endingEnd=b?this.zeroSlopeAtEnd?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:THREE.WrapAroundEnding)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;
-f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}};
-Object.assign(THREE.AnimationMixer.prototype,{_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings,g=a._interpolants,h=c.uuid,k=this._bindingsByRootAndName,l=k[h];void 0===l&&(l={},k[h]=l);for(k=0;k!==e;++k){var n=d[k],p=n.name,m=l[p];if(void 0===m){m=f[k];if(void 0!==m){null===m._cacheIndex&&(++m.referenceCount,this._addInactiveBinding(m,h,p));continue}m=new THREE.PropertyMixer(THREE.PropertyBinding.create(c,p,b&&b._propertyBindings[k].binding.parsedPath),
-n.ValueTypeName,n.getValueSize());++m.referenceCount;this._addInactiveBinding(m,h,p)}f[k]=m;g[k].resultBuffer=m.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.name,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},
-_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},
-get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length},get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&a<this._nActiveActions},_addInactiveAction:function(a,b,c){var d=this._actions,e=this._actionsByClip,f=e[b];void 0===f?(f={knownActions:[a],actionByRoot:{}},a._byClipCacheIndex=0,e[b]=f):(b=
-f.knownActions,a._byClipCacheIndex=b.length,b.push(a));a._cacheIndex=d.length;d.push(a);f.actionByRoot[c]=a},_removeInactiveAction:function(a){var b=this._actions,c=b[b.length-1],d=a._cacheIndex;c._cacheIndex=d;b[d]=c;b.pop();a._cacheIndex=null;var c=a._clip.name,d=this._actionsByClip,e=d[c],f=e.knownActions,g=f[f.length-1],h=a._byClipCacheIndex;g._byClipCacheIndex=h;f[h]=g;f.pop();a._byClipCacheIndex=null;delete e.actionByRoot[(b._localRoot||this._root).uuid];0===f.length&&delete d[c];this._removeInactiveBindingsForAction(a)},
-_removeInactiveBindingsForAction:function(a){a=a._propertyBindings;for(var b=0,c=a.length;b!==c;++b){var d=a[b];0===--d.referenceCount&&this._removeInactiveBinding(d)}},_lendAction:function(a){var b=this._actions,c=a._cacheIndex,d=this._nActiveActions++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackAction:function(a){var b=this._actions,c=a._cacheIndex,d=--this._nActiveActions,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_addInactiveBinding:function(a,b,c){var d=this._bindingsByRootAndName,
-e=d[b],f=this._bindings;void 0===e&&(e={},d[b]=e);e[c]=a;a._cacheIndex=f.length;f.push(a)},_removeInactiveBinding:function(a){var b=this._bindings,c=a.binding,d=c.rootNode.uuid,c=c.path,e=this._bindingsByRootAndName,f=e[d],g=b[b.length-1];a=a._cacheIndex;g._cacheIndex=a;b[a]=g;b.pop();delete f[c];a:{for(var h in f)break a;delete e[d]}},_lendBinding:function(a){var b=this._bindings,c=a._cacheIndex,d=this._nActiveBindings++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackBinding:function(a){var b=
-this._bindings,c=a._cacheIndex,d=--this._nActiveBindings,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_lendControlInterpolant:function(){var a=this._controlInterpolants,b=this._nActiveControlInterpolants++,c=a[b];void 0===c&&(c=new THREE.LinearInterpolant(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),c.__cacheIndex=b,a[b]=c);return c},_takeBackControlInterpolant:function(a){var b=this._controlInterpolants,c=a.__cacheIndex,d=--this._nActiveControlInterpolants,
-e=b[d];a.__cacheIndex=d;b[d]=a;e.__cacheIndex=c;b[c]=e},_controlInterpolantsResultBuffer:new Float32Array(1)});
-THREE.AnimationObjectGroup=function(a){this.uuid=THREE.Math.generateUUID();this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var b={};this._indicesByUUID=b;for(var c=0,d=arguments.length;c!==d;++c)b[arguments[c].uuid]=c;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}};
-THREE.AnimationObjectGroup.prototype={constructor:THREE.AnimationObjectGroup,add:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._paths,g=this._parsedPaths,h=this._bindings,k=h.length,l=0,n=arguments.length;l!==n;++l){var p=arguments[l],m=p.uuid,q=e[m];if(void 0===q){q=c++;e[m]=q;b.push(p);for(var m=0,s=k;m!==s;++m)h[m].push(new THREE.PropertyBinding(p,f[m],g[m]))}else if(q<d){var u=b[q],t=--d,s=b[t];e[s.uuid]=q;b[q]=s;e[m]=t;b[t]=p;m=0;for(s=k;m!==
-s;++m){var x=h[m],v=x[q];x[q]=x[t];void 0===v&&(v=new THREE.PropertyBinding(p,f[m],g[m]));x[t]=v}}else b[q]!==u&&console.error("Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes...")}this.nCachedObjects_=d},remove:function(a){for(var b=this._objects,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var k=arguments[g],l=k.uuid,n=d[l];if(void 0!==n&&n>=c){var p=c++,m=b[p];d[m.uuid]=
-n;b[n]=m;d[l]=p;b[p]=k;k=0;for(l=f;k!==l;++k){var m=e[k],q=m[n];m[n]=m[p];m[p]=q}}}this.nCachedObjects_=c},uncache:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._bindings,g=f.length,h=0,k=arguments.length;h!==k;++h){var l=arguments[h].uuid,n=e[l];if(void 0!==n)if(delete e[l],n<d){var l=--d,p=b[l],m=--c,q=b[m];e[p.uuid]=n;b[n]=p;e[q.uuid]=l;b[l]=q;b.pop();p=0;for(q=g;p!==q;++p){var s=f[p],u=s[m];s[n]=s[l];s[l]=u;s.pop()}}else for(m=--c,q=b[m],e[q.uuid]=
-n,b[n]=q,b.pop(),p=0,q=g;p!==q;++p)s=f[p],s[n]=s[m],s.pop()}this.nCachedObjects_=d},subscribe_:function(a,b){var c=this._bindingsIndicesByPath,d=c[a],e=this._bindings;if(void 0!==d)return e[d];var f=this._paths,g=this._parsedPaths,h=this._objects,k=this.nCachedObjects_,l=Array(h.length),d=e.length;c[a]=d;f.push(a);g.push(b);e.push(l);c=k;for(d=h.length;c!==d;++c)l[c]=new THREE.PropertyBinding(h[c],a,b);return l},unsubscribe_:function(a){var b=this._bindingsIndicesByPath,c=b[a];if(void 0!==c){var d=
-this._paths,e=this._parsedPaths,f=this._bindings,g=f.length-1,h=f[g];b[a[g]]=c;f[c]=h;f.pop();e[c]=e[g];e.pop();d[c]=d[g];d.pop()}}};
-THREE.AnimationUtils={arraySlice:function(a,b,c){return THREE.AnimationUtils.isTypedArray(a)?new a.constructor(a.subarray(b,c)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b,c){return a[b]-a[c]});return c},sortedArray:function(a,
-b,c){for(var d=a.length,e=new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,k=0;k!==b;++k)e[g++]=a[h+k];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(Array.isArray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d],void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++];while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),
-c.push(g)),f=a[e++];while(void 0!==f)}}}};THREE.KeyframeTrack=function(a,b,c,d){if(void 0===a)throw Error("track name is undefined");if(void 0===b||0===b.length)throw Error("no keyframes in track named "+a);this.name=a;this.times=THREE.AnimationUtils.convertArray(b,this.TimeBufferType);this.values=THREE.AnimationUtils.convertArray(c,this.ValueBufferType);this.setInterpolation(d||this.DefaultInterpolation);this.validate();this.optimize()};
-THREE.KeyframeTrack.prototype={constructor:THREE.KeyframeTrack,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:THREE.InterpolateLinear,InterpolantFactoryMethodDiscrete:function(a){return new THREE.DiscreteInterpolant(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodLinear:function(a){return new THREE.LinearInterpolant(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:function(a){return new THREE.CubicInterpolant(this.times,
-this.values,this.getValueSize(),a)},setInterpolation:function(a){var b=void 0;switch(a){case THREE.InterpolateDiscrete:b=this.InterpolantFactoryMethodDiscrete;break;case THREE.InterpolateLinear:b=this.InterpolantFactoryMethodLinear;break;case THREE.InterpolateSmooth:b=this.InterpolantFactoryMethodSmooth}if(void 0===b){b="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant)if(a!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);
-else throw Error(b);console.warn(b)}else this.createInterpolant=b},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return THREE.InterpolateDiscrete;case this.InterpolantFactoryMethodLinear:return THREE.InterpolateLinear;case this.InterpolantFactoryMethodSmooth:return THREE.InterpolateSmooth}},getValueSize:function(){return this.values.length/this.times.length},shift:function(a){if(0!==a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]+=a;return this},
-scale:function(a){if(1!==a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]*=a;return this},trim:function(a,b){for(var c=this.times,d=c.length,e=0,f=d-1;e!==d&&c[e]<a;)++e;for(;-1!==f&&c[f]>b;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),d=this.getValueSize(),this.times=THREE.AnimationUtils.arraySlice(c,e,f),this.values=THREE.AnimationUtils.arraySlice(this.values,e*d,f*d);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("invalid value size in track",
-this),a=!1);var c=this.times,b=this.values,d=c.length;0===d&&(console.error("track is empty",this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("time is not a valid number",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("out of order keys",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&THREE.AnimationUtils.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("value is not a valid number",this,f,d);a=!1;break}return a},optimize:function(){for(var a=
-this.times,b=this.values,c=this.getValueSize(),d=1,e=1,f=a.length-1;e<=f;++e){var g=!1,h=a[e];if(h!==a[e+1]&&(1!==e||h!==h[0]))for(var k=e*c,l=k-c,n=k+c,h=0;h!==c;++h){var p=b[k+h];if(p!==b[l+h]||p!==b[n+h]){g=!0;break}}if(g){if(e!==d)for(a[d]=a[e],g=e*c,k=d*c,h=0;h!==c;++h)b[k+h]=b[g+h];++d}}d!==a.length&&(this.times=THREE.AnimationUtils.arraySlice(a,0,d),this.values=THREE.AnimationUtils.arraySlice(b,0,d*c));return this}};
-Object.assign(THREE.KeyframeTrack,{parse:function(a){if(void 0===a.type)throw Error("track type undefined, can not parse");var b=THREE.KeyframeTrack._getTrackTypeForValueTypeName(a.type);if(void 0===a.times){console.warn("legacy JSON format detected, converting");var c=[],d=[];THREE.AnimationUtils.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)},toJSON:function(a){var b=a.constructor;if(void 0!==b.toJSON)b=b.toJSON(a);
-else{var b={name:a.name,times:THREE.AnimationUtils.convertArray(a.times,Array),values:THREE.AnimationUtils.convertArray(a.values,Array)},c=a.getInterpolation();c!==a.DefaultInterpolation&&(b.interpolation=c)}b.type=a.ValueTypeName;return b},_getTrackTypeForValueTypeName:function(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return THREE.NumberKeyframeTrack;case "vector":case "vector2":case "vector3":case "vector4":return THREE.VectorKeyframeTrack;
-case "color":return THREE.ColorKeyframeTrack;case "quaternion":return THREE.QuaternionKeyframeTrack;case "bool":case "boolean":return THREE.BooleanKeyframeTrack;case "string":return THREE.StringKeyframeTrack}throw Error("Unsupported typeName: "+a);}});THREE.PropertyBinding=function(a,b,c){this.path=b;this.parsedPath=c||THREE.PropertyBinding.parseTrackName(b);this.node=THREE.PropertyBinding.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a};
-THREE.PropertyBinding.prototype={constructor:THREE.PropertyBinding,getValue:function(a,b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a=this.node,b=this.parsedPath,c=b.objectName,d=b.propertyName,e=b.propertyIndex;a||(this.node=a=THREE.PropertyBinding.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error("  can not bind to material as node does not have a material",
-this);return}if(!a.material.materials){console.error("  can not bind to material.materials as node.material does not have a materials array",this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error("  can not bind to bones as node does not have a skeleton",this);return}a=a.skeleton.bones;for(c=0;c<a.length;c++)if(a[c].name===f){f=c;break}break;default:if(void 0===a[c]){console.error("  can not bind to objectName of node, undefined",this);return}a=a[c]}if(void 0!==f){if(void 0===
-a[f]){console.error("  trying to bind to objectIndex of objectName, but is undefined:",this,a);return}a=a[f]}}if(f=a[d]){b=this.Versioning.None;void 0!==a.needsUpdate?(b=this.Versioning.NeedsUpdate,this.targetObject=a):void 0!==a.matrixWorldNeedsUpdate&&(b=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=a);c=this.BindingType.Direct;if(void 0!==e){if("morphTargetInfluences"===d){if(!a.geometry){console.error("  can not bind to morphTargetInfluences becasuse node does not have a geometry",
-this);return}if(!a.geometry.morphTargets){console.error("  can not bind to morphTargetInfluences becasuse node does not have a geometry.morphTargets",this);return}for(c=0;c<this.node.geometry.morphTargets.length;c++)if(a.geometry.morphTargets[c].name===e){e=c;break}}c=this.BindingType.ArrayElement;this.resolvedProperty=f;this.propertyIndex=e}else void 0!==f.fromArray&&void 0!==f.toArray?(c=this.BindingType.HasFromToArray,this.resolvedProperty=f):void 0!==f.length?(c=this.BindingType.EntireArray,this.resolvedProperty=
-f):this.propertyName=d;this.getValue=this.GetterByBindingType[c];this.setValue=this.SetterByBindingTypeAndVersioning[c][b]}else console.error("  trying to update property for track: "+b.nodeName+"."+d+" but it wasn't found.",a)}else console.error("  trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null;this.getValue=this._getValue_unbound;this.setValue=this._setValue_unbound}};
-Object.assign(THREE.PropertyBinding.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},_getValue_unbound:THREE.PropertyBinding.prototype.getValue,_setValue_unbound:THREE.PropertyBinding.prototype.setValue,BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(a,b){a[b]=this.node[this.propertyName]},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)a[b++]=
-c[d]},function(a,b){a[b]=this.resolvedProperty[this.propertyIndex]},function(a,b){this.resolvedProperty.toArray(a,b)}],SetterByBindingTypeAndVersioning:[[function(a,b){this.node[this.propertyName]=a[b]},function(a,b){this.node[this.propertyName]=a[b];this.targetObject.needsUpdate=!0},function(a,b){this.node[this.propertyName]=a[b];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++]},function(a,b){for(var c=this.resolvedProperty,
-d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.needsUpdate=!0},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty[this.propertyIndex]=a[b]},function(a,b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.needsUpdate=!0},function(a,b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty.fromArray(a,
-b)},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.needsUpdate=!0},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.matrixWorldNeedsUpdate=!0}]]});THREE.PropertyBinding.Composite=function(a,b,c){c=c||THREE.PropertyBinding.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)};
-THREE.PropertyBinding.Composite.prototype={constructor:THREE.PropertyBinding.Composite,getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];void 0!==c&&c.getValue(a,b)},setValue:function(a,b){for(var c=this._bindings,d=this._targetGroup.nCachedObjects_,e=c.length;d!==e;++d)c[d].setValue(a,b)},bind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].bind()},unbind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,
-c=a.length;b!==c;++b)a[b].unbind()}};THREE.PropertyBinding.create=function(a,b,c){return a instanceof THREE.AnimationObjectGroup?new THREE.PropertyBinding.Composite(a,b,c):new THREE.PropertyBinding(a,b,c)};
-THREE.PropertyBinding.parseTrackName=function(a){var b=/^(([\w]+\/)*)([\w-\d]+)?(\.([\w]+)(\[([\w\d\[\]\_. ]+)\])?)?(\.([\w.]+)(\[([\w\d\[\]\_. ]+)\])?)$/,c=b.exec(a);if(!c)throw Error("cannot parse trackName at all: "+a);c.index===b.lastIndex&&b.lastIndex++;b={nodeName:c[3],objectName:c[5],objectIndex:c[7],propertyName:c[9],propertyIndex:c[11]};if(null===b.propertyName||0===b.propertyName.length)throw Error("can not parse propertyName from trackName: "+a);return b};
-THREE.PropertyBinding.findNode=function(a,b){if(!b||""===b||"root"===b||"."===b||-1===b||b===a.name||b===a.uuid)return a;if(a.skeleton){var c=function(a){for(var c=0;c<a.bones.length;c++){var d=a.bones[c];if(d.name===b)return d}return null}(a.skeleton);if(c)return c}if(a.children){var d=function(a){for(var c=0;c<a.length;c++){var g=a[c];if(g.name===b||g.uuid===b||(g=d(g.children)))return g}return null};if(c=d(a.children))return c}return null};
-THREE.PropertyMixer=function(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0};
-THREE.PropertyMixer.prototype={constructor:THREE.PropertyMixer,accumulate:function(a,b){var c=this.buffer,d=this.valueSize,e=a*d+d,f=this.cumulativeWeight;if(0===f){for(f=0;f!==d;++f)c[e+f]=c[f];f=b}else f+=b,this._mixBufferRegion(c,e,0,b/f,d);this.cumulativeWeight=f},apply:function(a){var b=this.valueSize,c=this.buffer;a=a*b+b;var d=this.cumulativeWeight,e=this.binding;this.cumulativeWeight=0;1>d&&this._mixBufferRegion(c,a,3*b,1-d,b);for(var d=b,f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);
-break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d,e){THREE.Quaternion.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}};
-THREE.BooleanKeyframeTrack=function(a,b,c){THREE.KeyframeTrack.call(this,a,b,c)};THREE.BooleanKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.BooleanKeyframeTrack,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:THREE.IntepolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});THREE.NumberKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
-THREE.NumberKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.NumberKeyframeTrack,ValueTypeName:"number"});THREE.QuaternionKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
-THREE.QuaternionKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.QuaternionKeyframeTrack,ValueTypeName:"quaternion",DefaultInterpolation:THREE.InterpolateLinear,InterpolantFactoryMethodLinear:function(a){return new THREE.QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:void 0});THREE.StringKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
-THREE.StringKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.StringKeyframeTrack,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:THREE.IntepolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});THREE.VectorKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
-THREE.VectorKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.VectorKeyframeTrack,ValueTypeName:"vector"});
-THREE.Audio=function(a){THREE.Object3D.call(this);this.type="Audio";this.context=a.context;this.source=this.context.createBufferSource();this.source.onended=this.onEnded.bind(this);this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filter=null};THREE.Audio.prototype=Object.create(THREE.Object3D.prototype);THREE.Audio.prototype.constructor=THREE.Audio;
-THREE.Audio.prototype.getOutput=function(){return this.gain};THREE.Audio.prototype.load=function(a){var b=new THREE.AudioBuffer(this.context);b.load(a);this.setBuffer(b);return this};THREE.Audio.prototype.setNodeSource=function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode";this.source=a;this.connect();return this};THREE.Audio.prototype.setBuffer=function(a){var b=this;a.onReady(function(a){b.source.buffer=a;b.sourceType="buffer";b.autoplay&&b.play()});return this};
-THREE.Audio.prototype.play=function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else{var a=this.context.createBufferSource();a.buffer=this.source.buffer;a.loop=this.source.loop;a.onended=this.source.onended;a.start(0,this.startTime);a.playbackRate.value=this.playbackRate;this.isPlaying=!0;this.source=a;this.connect()}};
-THREE.Audio.prototype.pause=function(){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=this.context.currentTime)};THREE.Audio.prototype.stop=function(){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=0)};THREE.Audio.prototype.connect=function(){null!==this.filter?(this.source.connect(this.filter),this.filter.connect(this.getOutput())):this.source.connect(this.getOutput())};
-THREE.Audio.prototype.disconnect=function(){null!==this.filter?(this.source.disconnect(this.filter),this.filter.disconnect(this.getOutput())):this.source.disconnect(this.getOutput())};THREE.Audio.prototype.getFilter=function(){return this.filter};THREE.Audio.prototype.setFilter=function(a){void 0===a&&(a=null);!0===this.isPlaying?(this.disconnect(),this.filter=a,this.connect()):this.filter=a};
-THREE.Audio.prototype.setPlaybackRate=function(a){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):(this.playbackRate=a,!0===this.isPlaying&&(this.source.playbackRate.value=this.playbackRate))};THREE.Audio.prototype.getPlaybackRate=function(){return this.playbackRate};THREE.Audio.prototype.onEnded=function(){this.isPlaying=!1};
-THREE.Audio.prototype.setLoop=function(a){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):this.source.loop=a};THREE.Audio.prototype.getLoop=function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.source.loop};THREE.Audio.prototype.setVolume=function(a){this.gain.gain.value=a};THREE.Audio.prototype.getVolume=function(){return this.gain.gain.value};
-THREE.AudioAnalyser=function(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)};THREE.AudioAnalyser.prototype={constructor:THREE.AudioAnalyser,getData:function(){this.analyser.getByteFrequencyData(this.data);return this.data}};THREE.AudioBuffer=function(a){this.context=a;this.ready=!1;this.readyCallbacks=[]};
-THREE.AudioBuffer.prototype.load=function(a){var b=this,c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(a){b.context.decodeAudioData(this.response,function(a){b.buffer=a;b.ready=!0;for(a=0;a<b.readyCallbacks.length;a++)b.readyCallbacks[a](b.buffer);b.readyCallbacks=[]})};c.send();return this};THREE.AudioBuffer.prototype.onReady=function(a){this.ready?a(this.buffer):this.readyCallbacks.push(a)};
-THREE.PositionalAudio=function(a){THREE.Audio.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)};THREE.PositionalAudio.prototype=Object.create(THREE.Audio.prototype);THREE.PositionalAudio.prototype.constructor=THREE.PositionalAudio;THREE.PositionalAudio.prototype.getOutput=function(){return this.panner};THREE.PositionalAudio.prototype.setRefDistance=function(a){this.panner.refDistance=a};THREE.PositionalAudio.prototype.getRefDistance=function(){return this.panner.refDistance};
-THREE.PositionalAudio.prototype.setRolloffFactor=function(a){this.panner.rolloffFactor=a};THREE.PositionalAudio.prototype.getRolloffFactor=function(){return this.panner.rolloffFactor};THREE.PositionalAudio.prototype.setDistanceModel=function(a){this.panner.distanceModel=a};THREE.PositionalAudio.prototype.getDistanceModel=function(){return this.panner.distanceModel};THREE.PositionalAudio.prototype.setMaxDistance=function(a){this.panner.maxDistance=a};
-THREE.PositionalAudio.prototype.getMaxDistance=function(){return this.panner.maxDistance};THREE.PositionalAudio.prototype.updateMatrixWorld=function(){var a=new THREE.Vector3;return function(b){THREE.Object3D.prototype.updateMatrixWorld.call(this,b);a.setFromMatrixPosition(this.matrixWorld);this.panner.setPosition(a.x,a.y,a.z)}}();
-THREE.AudioListener=function(){THREE.Object3D.call(this);this.type="AudioListener";this.context=new (window.AudioContext||window.webkitAudioContext);this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null};THREE.AudioListener.prototype=Object.create(THREE.Object3D.prototype);THREE.AudioListener.prototype.constructor=THREE.AudioListener;THREE.AudioListener.prototype.getInput=function(){return this.gain};
-THREE.AudioListener.prototype.removeFilter=function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null)};THREE.AudioListener.prototype.setFilter=function(a){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);this.filter.connect(this.context.destination)};
-THREE.AudioListener.prototype.getFilter=function(){return this.filter};THREE.AudioListener.prototype.setMasterVolume=function(a){this.gain.gain.value=a};THREE.AudioListener.prototype.getMasterVolume=function(){return this.gain.gain.value};
-THREE.AudioListener.prototype.updateMatrixWorld=function(){var a=new THREE.Vector3,b=new THREE.Quaternion,c=new THREE.Vector3,d=new THREE.Vector3;return function(e){THREE.Object3D.prototype.updateMatrixWorld.call(this,e);e=this.context.listener;var f=this.up;this.matrixWorld.decompose(a,b,c);d.set(0,0,-1).applyQuaternion(b);e.setPosition(a.x,a.y,a.z);e.setOrientation(d.x,d.y,d.z,f.x,f.y,f.z)}}();
-THREE.Camera=function(){THREE.Object3D.call(this);this.type="Camera";this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4};THREE.Camera.prototype=Object.create(THREE.Object3D.prototype);THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.getWorldDirection=function(){var a=new THREE.Quaternion;return function(b){b=b||new THREE.Vector3;this.getWorldQuaternion(a);return b.set(0,0,-1).applyQuaternion(a)}}();
-THREE.Camera.prototype.lookAt=function(){var a=new THREE.Matrix4;return function(b){a.lookAt(this.position,b,this.up);this.quaternion.setFromRotationMatrix(a)}}();THREE.Camera.prototype.clone=function(){return(new this.constructor).copy(this)};THREE.Camera.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.matrixWorldInverse.copy(a.matrixWorldInverse);this.projectionMatrix.copy(a.projectionMatrix);return this};
-THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this);this.type="CubeCamera";var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new THREE.Vector3(1,0,0));this.add(d);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new THREE.Vector3(-1,0,0));this.add(e);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,0,1);f.lookAt(new THREE.Vector3(0,1,0));this.add(f);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new THREE.Vector3(0,-1,0));
-this.add(g);var h=new THREE.PerspectiveCamera(90,1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var k=new THREE.PerspectiveCamera(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new THREE.Vector3(0,0,-1));this.add(k);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,m=c.texture.generateMipmaps;c.texture.generateMipmaps=
-!1;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace=2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.texture.generateMipmaps=m;c.activeCubeFace=5;a.render(b,k,c);a.setRenderTarget(null)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CubeCamera.prototype.constructor=THREE.CubeCamera;
-THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.type="OrthographicCamera";this.zoom=1;this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=Object.create(THREE.Camera.prototype);THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
-THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){var a=(this.right-this.left)/(2*this.zoom),b=(this.top-this.bottom)/(2*this.zoom),c=(this.right+this.left)/2,d=(this.top+this.bottom)/2;this.projectionMatrix.makeOrthographic(c-a,c+a,d+b,d-b,this.near,this.far)};THREE.OrthographicCamera.prototype.copy=function(a){THREE.Camera.prototype.copy.call(this,a);this.left=a.left;this.right=a.right;this.top=a.top;this.bottom=a.bottom;this.near=a.near;this.far=a.far;this.zoom=a.zoom;return this};
-THREE.OrthographicCamera.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.zoom=this.zoom;a.object.left=this.left;a.object.right=this.right;a.object.top=this.top;a.object.bottom=this.bottom;a.object.near=this.near;a.object.far=this.far;return a};
-THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.type="PerspectiveCamera";this.focalLength=10;this.zoom=1;this.fov=void 0!==a?a:50;this.aspect=void 0!==b?b:1;this.near=void 0!==c?c:.1;this.far=void 0!==d?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=Object.create(THREE.Camera.prototype);THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
-THREE.PerspectiveCamera.prototype.setLens=function(a,b){void 0===b&&(b=24);this.fov=2*THREE.Math.radToDeg(Math.atan(b/(2*a)));this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
-THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){var a=THREE.Math.radToDeg(2*Math.atan(Math.tan(.5*THREE.Math.degToRad(this.fov))/this.zoom));if(this.fullWidth){var b=this.fullWidth/this.fullHeight,a=Math.tan(THREE.Math.degToRad(.5*a))*this.near,c=-a,d=b*c,b=Math.abs(b*a-d),c=Math.abs(a-c);this.projectionMatrix.makeFrustum(d+this.x*b/this.fullWidth,d+(this.x+this.width)*b/this.fullWidth,a-(this.y+this.height)*c/this.fullHeight,a-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(a,
-this.aspect,this.near,this.far)};THREE.PerspectiveCamera.prototype.copy=function(a){THREE.Camera.prototype.copy.call(this,a);this.focalLength=a.focalLength;this.zoom=a.zoom;this.fov=a.fov;this.aspect=a.aspect;this.near=a.near;this.far=a.far;return this};
-THREE.PerspectiveCamera.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.focalLength=this.focalLength;a.object.zoom=this.zoom;a.object.fov=this.fov;a.object.aspect=this.aspect;a.object.near=this.near;a.object.far=this.far;return a};
-THREE.StereoCamera=function(){this.type="StereoCamera";this.aspect=1;this.cameraL=new THREE.PerspectiveCamera;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new THREE.PerspectiveCamera;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1};
-THREE.StereoCamera.prototype={constructor:THREE.StereoCamera,update:function(){var a,b,c,d,e,f=new THREE.Matrix4,g=new THREE.Matrix4;return function(h){if(a!==h.focalLength||b!==h.fov||c!==h.aspect*this.aspect||d!==h.near||e!==h.far){a=h.focalLength;b=h.fov;c=h.aspect*this.aspect;d=h.near;e=h.far;var k=h.projectionMatrix.clone(),l=.032*d/a,n=d*Math.tan(THREE.Math.degToRad(.5*b)),p,m;g.elements[12]=-.032;f.elements[12]=.032;p=-n*c+l;m=n*c+l;k.elements[0]=2*d/(m-p);k.elements[8]=(m+p)/(m-p);this.cameraL.projectionMatrix.copy(k);
-p=-n*c-l;m=n*c-l;k.elements[0]=2*d/(m-p);k.elements[8]=(m+p)/(m-p);this.cameraR.projectionMatrix.copy(k)}this.cameraL.matrixWorld.copy(h.matrixWorld).multiply(g);this.cameraR.matrixWorld.copy(h.matrixWorld).multiply(f)}}()};THREE.Light=function(a,b){THREE.Object3D.call(this);this.type="Light";this.color=new THREE.Color(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0};THREE.Light.prototype=Object.create(THREE.Object3D.prototype);THREE.Light.prototype.constructor=THREE.Light;
-THREE.Light.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this};
-THREE.Light.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.color=this.color.getHex();a.object.intensity=this.intensity;void 0!==this.groundColor&&(a.object.groundColor=this.groundColor.getHex());void 0!==this.distance&&(a.object.distance=this.distance);void 0!==this.angle&&(a.object.angle=this.angle);void 0!==this.decay&&(a.object.decay=this.decay);void 0!==this.penumbra&&(a.object.penumbra=this.penumbra);return a};
-THREE.LightShadow=function(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=new THREE.Vector2(512,512);this.map=null;this.matrix=new THREE.Matrix4};THREE.LightShadow.prototype={constructor:THREE.LightShadow,copy:function(a){this.camera=a.camera.clone();this.bias=a.bias;this.radius=a.radius;this.mapSize.copy(a.mapSize);return this},clone:function(){return(new this.constructor).copy(this)}};THREE.AmbientLight=function(a,b){THREE.Light.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0};
-THREE.AmbientLight.prototype=Object.create(THREE.Light.prototype);THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a,b);this.type="DirectionalLight";this.position.set(0,1,0);this.updateMatrix();this.target=new THREE.Object3D;this.shadow=new THREE.LightShadow(new THREE.OrthographicCamera(-5,5,5,-5,.5,500))};THREE.DirectionalLight.prototype=Object.create(THREE.Light.prototype);THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
-THREE.DirectionalLight.prototype.copy=function(a){THREE.Light.prototype.copy.call(this,a);this.target=a.target.clone();this.shadow=a.shadow.clone();return this};THREE.HemisphereLight=function(a,b,c){THREE.Light.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.set(0,1,0);this.updateMatrix();this.groundColor=new THREE.Color(b)};THREE.HemisphereLight.prototype=Object.create(THREE.Light.prototype);THREE.HemisphereLight.prototype.constructor=THREE.HemisphereLight;
-THREE.HemisphereLight.prototype.copy=function(a){THREE.Light.prototype.copy.call(this,a);this.groundColor.copy(a.groundColor);return this};THREE.PointLight=function(a,b,c,d){THREE.Light.call(this,a,b);this.type="PointLight";this.distance=void 0!==c?c:0;this.decay=void 0!==d?d:1;this.shadow=new THREE.LightShadow(new THREE.PerspectiveCamera(90,1,.5,500))};THREE.PointLight.prototype=Object.create(THREE.Light.prototype);THREE.PointLight.prototype.constructor=THREE.PointLight;
-THREE.PointLight.prototype.copy=function(a){THREE.Light.prototype.copy.call(this,a);this.distance=a.distance;this.decay=a.decay;this.shadow=a.shadow.clone();return this};
-THREE.SpotLight=function(a,b,c,d,e,f){THREE.Light.call(this,a,b);this.type="SpotLight";this.position.set(0,1,0);this.updateMatrix();this.target=new THREE.Object3D;this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/3;this.penumbra=void 0!==e?e:0;this.decay=void 0!==f?f:1;this.shadow=new THREE.LightShadow(new THREE.PerspectiveCamera(50,1,.5,500))};THREE.SpotLight.prototype=Object.create(THREE.Light.prototype);THREE.SpotLight.prototype.constructor=THREE.SpotLight;
-THREE.SpotLight.prototype.copy=function(a){THREE.Light.prototype.copy.call(this,a);this.distance=a.distance;this.angle=a.angle;this.penumbra=a.penumbra;this.decay=a.decay;this.target=a.target.clone();this.shadow=a.shadow.clone();return this};THREE.Cache={enabled:!1,files:{},add:function(a,b){!1!==this.enabled&&(this.files[a]=b)},get:function(a){if(!1!==this.enabled)return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}};
-THREE.Loader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
-THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:void 0,extractUrlBase:function(a){a=a.split("/");if(1===a.length)return"./";a.pop();return a.join("/")+"/"},initMaterials:function(a,b,c){for(var d=[],e=0;e<a.length;++e)d[e]=this.createMaterial(a[e],b,c);return d},createMaterial:function(){var a,b,c;return function(d,e,f){function g(a,c,d,g,k){a=e+a;var l=THREE.Loader.Handlers.get(a);null!==l?a=l.load(a):(b.setCrossOrigin(f),a=b.load(a));void 0!==c&&(a.repeat.fromArray(c),1!==c[0]&&(a.wrapS=
-THREE.RepeatWrapping),1!==c[1]&&(a.wrapT=THREE.RepeatWrapping));void 0!==d&&a.offset.fromArray(d);void 0!==g&&("repeat"===g[0]&&(a.wrapS=THREE.RepeatWrapping),"mirror"===g[0]&&(a.wrapS=THREE.MirroredRepeatWrapping),"repeat"===g[1]&&(a.wrapT=THREE.RepeatWrapping),"mirror"===g[1]&&(a.wrapT=THREE.MirroredRepeatWrapping));void 0!==k&&(a.anisotropy=k);c=THREE.Math.generateUUID();h[c]=a;return c}void 0===a&&(a=new THREE.Color);void 0===b&&(b=new THREE.TextureLoader);void 0===c&&(c=new THREE.MaterialLoader);
-var h={},k={uuid:THREE.Math.generateUUID(),type:"MeshLambertMaterial"},l;for(l in d){var n=d[l];switch(l){case "DbgColor":case "DbgIndex":case "opticalDensity":case "illumination":break;case "DbgName":k.name=n;break;case "blending":k.blending=THREE[n];break;case "colorAmbient":case "mapAmbient":console.warn("THREE.Loader.createMaterial:",l,"is no longer supported.");break;case "colorDiffuse":k.color=a.fromArray(n).getHex();break;case "colorSpecular":k.specular=a.fromArray(n).getHex();break;case "colorEmissive":k.emissive=
-a.fromArray(n).getHex();break;case "specularCoef":k.shininess=n;break;case "shading":"basic"===n.toLowerCase()&&(k.type="MeshBasicMaterial");"phong"===n.toLowerCase()&&(k.type="MeshPhongMaterial");break;case "mapDiffuse":k.map=g(n,d.mapDiffuseRepeat,d.mapDiffuseOffset,d.mapDiffuseWrap,d.mapDiffuseAnisotropy);break;case "mapDiffuseRepeat":case "mapDiffuseOffset":case "mapDiffuseWrap":case "mapDiffuseAnisotropy":break;case "mapLight":k.lightMap=g(n,d.mapLightRepeat,d.mapLightOffset,d.mapLightWrap,d.mapLightAnisotropy);
-break;case "mapLightRepeat":case "mapLightOffset":case "mapLightWrap":case "mapLightAnisotropy":break;case "mapAO":k.aoMap=g(n,d.mapAORepeat,d.mapAOOffset,d.mapAOWrap,d.mapAOAnisotropy);break;case "mapAORepeat":case "mapAOOffset":case "mapAOWrap":case "mapAOAnisotropy":break;case "mapBump":k.bumpMap=g(n,d.mapBumpRepeat,d.mapBumpOffset,d.mapBumpWrap,d.mapBumpAnisotropy);break;case "mapBumpScale":k.bumpScale=n;break;case "mapBumpRepeat":case "mapBumpOffset":case "mapBumpWrap":case "mapBumpAnisotropy":break;
-case "mapNormal":k.normalMap=g(n,d.mapNormalRepeat,d.mapNormalOffset,d.mapNormalWrap,d.mapNormalAnisotropy);break;case "mapNormalFactor":k.normalScale=[n,n];break;case "mapNormalRepeat":case "mapNormalOffset":case "mapNormalWrap":case "mapNormalAnisotropy":break;case "mapSpecular":k.specularMap=g(n,d.mapSpecularRepeat,d.mapSpecularOffset,d.mapSpecularWrap,d.mapSpecularAnisotropy);break;case "mapSpecularRepeat":case "mapSpecularOffset":case "mapSpecularWrap":case "mapSpecularAnisotropy":break;case "mapAlpha":k.alphaMap=
-g(n,d.mapAlphaRepeat,d.mapAlphaOffset,d.mapAlphaWrap,d.mapAlphaAnisotropy);break;case "mapAlphaRepeat":case "mapAlphaOffset":case "mapAlphaWrap":case "mapAlphaAnisotropy":break;case "flipSided":k.side=THREE.BackSide;break;case "doubleSided":k.side=THREE.DoubleSide;break;case "transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity");k.opacity=n;break;case "depthTest":case "depthWrite":case "colorWrite":case "opacity":case "reflectivity":case "transparent":case "visible":case "wireframe":k[l]=
-n;break;case "vertexColors":!0===n&&(k.vertexColors=THREE.VertexColors);"face"===n&&(k.vertexColors=THREE.FaceColors);break;default:console.error("THREE.Loader.createMaterial: Unsupported",l,n)}}"MeshBasicMaterial"===k.type&&delete k.emissive;"MeshPhongMaterial"!==k.type&&delete k.specular;1>k.opacity&&(k.transparent=!0);c.setTextures(h);return c.parse(k)}}()};
-THREE.Loader.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;c<d;c+=2){var e=b[c+1];if(b[c].test(a))return e}return null}};THREE.XHRLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};
-THREE.XHRLoader.prototype={constructor:THREE.XHRLoader,load:function(a,b,c,d){void 0!==this.path&&(a=this.path+a);var e=this,f=THREE.Cache.get(a);if(void 0!==f)return b&&setTimeout(function(){b(f)},0),f;var g=new XMLHttpRequest;g.overrideMimeType("text/plain");g.open("GET",a,!0);g.addEventListener("load",function(c){var f=c.target.response;THREE.Cache.add(a,f);200===this.status?(b&&b(f),e.manager.itemEnd(a)):0===this.status?(console.warn("THREE.XHRLoader: HTTP Status 0 received."),b&&b(f),e.manager.itemEnd(a)):
-(d&&d(c),e.manager.itemError(a))},!1);void 0!==c&&g.addEventListener("progress",function(a){c(a)},!1);g.addEventListener("error",function(b){d&&d(b);e.manager.itemError(a)},!1);void 0!==this.responseType&&(g.responseType=this.responseType);void 0!==this.withCredentials&&(g.withCredentials=this.withCredentials);g.send(null);e.manager.itemStart(a);return g},setPath:function(a){this.path=a},setResponseType:function(a){this.responseType=a},setWithCredentials:function(a){this.withCredentials=a}};
-THREE.FontLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};THREE.FontLoader.prototype={constructor:THREE.FontLoader,load:function(a,b,c,d){(new THREE.XHRLoader(this.manager)).load(a,function(a){b(new THREE.Font(JSON.parse(a.substring(65,a.length-2))))},c,d)}};THREE.ImageLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};
-THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a,b,c,d){void 0!==this.path&&(a=this.path+a);var e=this,f=THREE.Cache.get(a);if(void 0!==f)return e.manager.itemStart(a),b?setTimeout(function(){b(f);e.manager.itemEnd(a)},0):e.manager.itemEnd(a),f;var g=document.createElement("img");g.addEventListener("load",function(c){THREE.Cache.add(a,this);b&&b(this);e.manager.itemEnd(a)},!1);void 0!==c&&g.addEventListener("progress",function(a){c(a)},!1);g.addEventListener("error",function(b){d&&
-d(b);e.manager.itemError(a)},!1);void 0!==this.crossOrigin&&(g.crossOrigin=this.crossOrigin);e.manager.itemStart(a);g.src=a;return g},setCrossOrigin:function(a){this.crossOrigin=a},setPath:function(a){this.path=a}};THREE.JSONLoader=function(a){"boolean"===typeof a&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),a=void 0);this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this.withCredentials=!1};
-THREE.JSONLoader.prototype={constructor:THREE.JSONLoader,get statusDomElement(){void 0===this._statusDomElement&&(this._statusDomElement=document.createElement("div"));console.warn("THREE.JSONLoader: .statusDomElement has been removed.");return this._statusDomElement},load:function(a,b,c,d){var e=this,f=this.texturePath&&"string"===typeof this.texturePath?this.texturePath:THREE.Loader.prototype.extractUrlBase(a),g=new THREE.XHRLoader(this.manager);g.setWithCredentials(this.withCredentials);g.load(a,
-function(c){c=JSON.parse(c);var d=c.metadata;if(void 0!==d&&(d=d.type,void 0!==d)){if("object"===d.toLowerCase()){console.error("THREE.JSONLoader: "+a+" should be loaded with THREE.ObjectLoader instead.");return}if("scene"===d.toLowerCase()){console.error("THREE.JSONLoader: "+a+" should be loaded with THREE.SceneLoader instead.");return}}c=e.parse(c,f);b(c.geometry,c.materials)},c,d)},setTexturePath:function(a){this.texturePath=a},parse:function(a,b){var c=new THREE.Geometry,d=void 0!==a.scale?1/
-a.scale:1;(function(b){var d,g,h,k,l,n,p,m,q,s,u,t,x,v=a.faces;n=a.vertices;var C=a.normals,w=a.colors,D=0;if(void 0!==a.uvs){for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&D++;for(d=0;d<D;d++)c.faceVertexUvs[d]=[]}k=0;for(l=n.length;k<l;)d=new THREE.Vector3,d.x=n[k++]*b,d.y=n[k++]*b,d.z=n[k++]*b,c.vertices.push(d);k=0;for(l=v.length;k<l;)if(b=v[k++],q=b&1,h=b&2,d=b&8,p=b&16,s=b&32,n=b&64,b&=128,q){q=new THREE.Face3;q.a=v[k];q.b=v[k+1];q.c=v[k+3];u=new THREE.Face3;u.a=v[k+1];u.b=v[k+2];u.c=v[k+3];k+=
-4;h&&(h=v[k++],q.materialIndex=h,u.materialIndex=h);h=c.faces.length;if(d)for(d=0;d<D;d++)for(t=a.uvs[d],c.faceVertexUvs[d][h]=[],c.faceVertexUvs[d][h+1]=[],g=0;4>g;g++)m=v[k++],x=t[2*m],m=t[2*m+1],x=new THREE.Vector2(x,m),2!==g&&c.faceVertexUvs[d][h].push(x),0!==g&&c.faceVertexUvs[d][h+1].push(x);p&&(p=3*v[k++],q.normal.set(C[p++],C[p++],C[p]),u.normal.copy(q.normal));if(s)for(d=0;4>d;d++)p=3*v[k++],s=new THREE.Vector3(C[p++],C[p++],C[p]),2!==d&&q.vertexNormals.push(s),0!==d&&u.vertexNormals.push(s);
-n&&(n=v[k++],n=w[n],q.color.setHex(n),u.color.setHex(n));if(b)for(d=0;4>d;d++)n=v[k++],n=w[n],2!==d&&q.vertexColors.push(new THREE.Color(n)),0!==d&&u.vertexColors.push(new THREE.Color(n));c.faces.push(q);c.faces.push(u)}else{q=new THREE.Face3;q.a=v[k++];q.b=v[k++];q.c=v[k++];h&&(h=v[k++],q.materialIndex=h);h=c.faces.length;if(d)for(d=0;d<D;d++)for(t=a.uvs[d],c.faceVertexUvs[d][h]=[],g=0;3>g;g++)m=v[k++],x=t[2*m],m=t[2*m+1],x=new THREE.Vector2(x,m),c.faceVertexUvs[d][h].push(x);p&&(p=3*v[k++],q.normal.set(C[p++],
-C[p++],C[p]));if(s)for(d=0;3>d;d++)p=3*v[k++],s=new THREE.Vector3(C[p++],C[p++],C[p]),q.vertexNormals.push(s);n&&(n=v[k++],q.color.setHex(w[n]));if(b)for(d=0;3>d;d++)n=v[k++],q.vertexColors.push(new THREE.Color(w[n]));c.faces.push(q)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;d<g;d+=b)c.skinWeights.push(new THREE.Vector4(a.skinWeights[d],1<b?a.skinWeights[d+1]:0,2<b?a.skinWeights[d+2]:0,3<b?a.skinWeights[d+3]:
-0));if(a.skinIndices)for(d=0,g=a.skinIndices.length;d<g;d+=b)c.skinIndices.push(new THREE.Vector4(a.skinIndices[d],1<b?a.skinIndices[d+1]:0,2<b?a.skinIndices[d+2]:0,3<b?a.skinIndices[d+3]:0));c.bones=a.bones;c.bones&&0<c.bones.length&&(c.skinWeights.length!==c.skinIndices.length||c.skinIndices.length!==c.vertices.length)&&console.warn("When skinning, number of vertices ("+c.vertices.length+"), skinIndices ("+c.skinIndices.length+"), and skinWeights ("+c.skinWeights.length+") should match.")})();(function(b){if(void 0!==
-a.morphTargets)for(var d=0,g=a.morphTargets.length;d<g;d++){c.morphTargets[d]={};c.morphTargets[d].name=a.morphTargets[d].name;c.morphTargets[d].vertices=[];for(var h=c.morphTargets[d].vertices,k=a.morphTargets[d].vertices,l=0,n=k.length;l<n;l+=3){var p=new THREE.Vector3;p.x=k[l]*b;p.y=k[l+1]*b;p.z=k[l+2]*b;h.push(p)}}if(void 0!==a.morphColors&&0<a.morphColors.length)for(console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.'),b=c.faces,h=a.morphColors[0].colors,
-d=0,g=b.length;d<g;d++)b[d].color.fromArray(h,3*d)})(d);(function(){var b=[],d=[];void 0!==a.animation&&d.push(a.animation);void 0!==a.animations&&(a.animations.length?d=d.concat(a.animations):d.push(a.animations));for(var g=0;g<d.length;g++){var h=THREE.AnimationClip.parseAnimation(d[g],c.bones);h&&b.push(h)}c.morphTargets&&(d=THREE.AnimationClip.CreateClipsFromMorphTargetSequences(c.morphTargets,10),b=b.concat(d));0<b.length&&(c.animations=b)})();c.computeFaceNormals();c.computeBoundingSphere();
-if(void 0===a.materials||0===a.materials.length)return{geometry:c};d=THREE.Loader.prototype.initMaterials(a.materials,b,this.crossOrigin);return{geometry:c,materials:d}}};
-THREE.LoadingManager=function(a,b,c){var d=this,e=!1,f=0,g=0;this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,f,g);e=!0};this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};this.itemError=function(a){if(void 0!==d.onError)d.onError(a)}};THREE.DefaultLoadingManager=new THREE.LoadingManager;
-THREE.BufferGeometryLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};
-THREE.BufferGeometryLoader.prototype={constructor:THREE.BufferGeometryLoader,load:function(a,b,c,d){var e=this;(new THREE.XHRLoader(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},parse:function(a){var b=new THREE.BufferGeometry,c=a.data.index,d={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};void 0!==c&&(c=
-new d[c.type](c.array),b.setIndex(new THREE.BufferAttribute(c,1)));var e=a.data.attributes,f;for(f in e){var g=e[f],c=new d[g.type](g.array);b.addAttribute(f,new THREE.BufferAttribute(c,g.itemSize))}d=a.data.groups||a.data.drawcalls||a.data.offsets;if(void 0!==d)for(f=0,c=d.length;f!==c;++f)e=d[f],b.addGroup(e.start,e.count,e.materialIndex);a=a.data.boundingSphere;void 0!==a&&(d=new THREE.Vector3,void 0!==a.center&&d.fromArray(a.center),b.boundingSphere=new THREE.Sphere(d,a.radius));return b}};
-THREE.MaterialLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this.textures={}};
-THREE.MaterialLoader.prototype={constructor:THREE.MaterialLoader,load:function(a,b,c,d){var e=this;(new THREE.XHRLoader(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},setTextures:function(a){this.textures=a},getTexture:function(a){var b=this.textures;void 0===b[a]&&console.warn("THREE.MaterialLoader: Undefined texture",a);return b[a]},parse:function(a){var b=new THREE[a.type];void 0!==a.uuid&&(b.uuid=a.uuid);void 0!==a.name&&(b.name=a.name);void 0!==a.color&&b.color.setHex(a.color);
-void 0!==a.roughness&&(b.roughness=a.roughness);void 0!==a.metalness&&(b.metalness=a.metalness);void 0!==a.emissive&&b.emissive.setHex(a.emissive);void 0!==a.specular&&b.specular.setHex(a.specular);void 0!==a.shininess&&(b.shininess=a.shininess);void 0!==a.uniforms&&(b.uniforms=a.uniforms);void 0!==a.vertexShader&&(b.vertexShader=a.vertexShader);void 0!==a.fragmentShader&&(b.fragmentShader=a.fragmentShader);void 0!==a.vertexColors&&(b.vertexColors=a.vertexColors);void 0!==a.shading&&(b.shading=a.shading);
-void 0!==a.blending&&(b.blending=a.blending);void 0!==a.side&&(b.side=a.side);void 0!==a.opacity&&(b.opacity=a.opacity);void 0!==a.transparent&&(b.transparent=a.transparent);void 0!==a.alphaTest&&(b.alphaTest=a.alphaTest);void 0!==a.depthTest&&(b.depthTest=a.depthTest);void 0!==a.depthWrite&&(b.depthWrite=a.depthWrite);void 0!==a.colorWrite&&(b.colorWrite=a.colorWrite);void 0!==a.wireframe&&(b.wireframe=a.wireframe);void 0!==a.wireframeLinewidth&&(b.wireframeLinewidth=a.wireframeLinewidth);void 0!==
-a.size&&(b.size=a.size);void 0!==a.sizeAttenuation&&(b.sizeAttenuation=a.sizeAttenuation);void 0!==a.map&&(b.map=this.getTexture(a.map));void 0!==a.alphaMap&&(b.alphaMap=this.getTexture(a.alphaMap),b.transparent=!0);void 0!==a.bumpMap&&(b.bumpMap=this.getTexture(a.bumpMap));void 0!==a.bumpScale&&(b.bumpScale=a.bumpScale);void 0!==a.normalMap&&(b.normalMap=this.getTexture(a.normalMap));if(void 0!==a.normalScale){var c=a.normalScale;!1===Array.isArray(c)&&(c=[c,c]);b.normalScale=(new THREE.Vector2).fromArray(c)}void 0!==
-a.displacementMap&&(b.displacementMap=this.getTexture(a.displacementMap));void 0!==a.displacementScale&&(b.displacementScale=a.displacementScale);void 0!==a.displacementBias&&(b.displacementBias=a.displacementBias);void 0!==a.roughnessMap&&(b.roughnessMap=this.getTexture(a.roughnessMap));void 0!==a.metalnessMap&&(b.metalnessMap=this.getTexture(a.metalnessMap));void 0!==a.emissiveMap&&(b.emissiveMap=this.getTexture(a.emissiveMap));void 0!==a.emissiveIntensity&&(b.emissiveIntensity=a.emissiveIntensity);
-void 0!==a.specularMap&&(b.specularMap=this.getTexture(a.specularMap));void 0!==a.envMap&&(b.envMap=this.getTexture(a.envMap),b.combine=THREE.MultiplyOperation);a.reflectivity&&(b.reflectivity=a.reflectivity);void 0!==a.lightMap&&(b.lightMap=this.getTexture(a.lightMap));void 0!==a.lightMapIntensity&&(b.lightMapIntensity=a.lightMapIntensity);void 0!==a.aoMap&&(b.aoMap=this.getTexture(a.aoMap));void 0!==a.aoMapIntensity&&(b.aoMapIntensity=a.aoMapIntensity);if(void 0!==a.materials)for(var c=0,d=a.materials.length;c<
-d;c++)b.materials.push(this.parse(a.materials[c]));return b}};THREE.ObjectLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this.texturePath=""};
-THREE.ObjectLoader.prototype={constructor:THREE.ObjectLoader,load:function(a,b,c,d){""===this.texturePath&&(this.texturePath=a.substring(0,a.lastIndexOf("/")+1));var e=this;(new THREE.XHRLoader(e.manager)).load(a,function(a){e.parse(JSON.parse(a),b)},c,d)},setTexturePath:function(a){this.texturePath=a},setCrossOrigin:function(a){this.crossOrigin=a},parse:function(a,b){var c=this.parseGeometries(a.geometries),d=this.parseImages(a.images,function(){void 0!==b&&b(e)}),d=this.parseTextures(a.textures,
-d),d=this.parseMaterials(a.materials,d),e=this.parseObject(a.object,c,d);a.animations&&(e.animations=this.parseAnimations(a.animations));void 0!==a.images&&0!==a.images.length||void 0===b||b(e);return e},parseGeometries:function(a){var b={};if(void 0!==a)for(var c=new THREE.JSONLoader,d=new THREE.BufferGeometryLoader,e=0,f=a.length;e<f;e++){var g,h=a[e];switch(h.type){case "PlaneGeometry":case "PlaneBufferGeometry":g=new THREE[h.type](h.width,h.height,h.widthSegments,h.heightSegments);break;case "BoxGeometry":case "CubeGeometry":g=
-new THREE.BoxGeometry(h.width,h.height,h.depth,h.widthSegments,h.heightSegments,h.depthSegments);break;case "CircleBufferGeometry":g=new THREE.CircleBufferGeometry(h.radius,h.segments,h.thetaStart,h.thetaLength);break;case "CircleGeometry":g=new THREE.CircleGeometry(h.radius,h.segments,h.thetaStart,h.thetaLength);break;case "CylinderGeometry":g=new THREE.CylinderGeometry(h.radiusTop,h.radiusBottom,h.height,h.radialSegments,h.heightSegments,h.openEnded,h.thetaStart,h.thetaLength);break;case "SphereGeometry":g=
-new THREE.SphereGeometry(h.radius,h.widthSegments,h.heightSegments,h.phiStart,h.phiLength,h.thetaStart,h.thetaLength);break;case "SphereBufferGeometry":g=new THREE.SphereBufferGeometry(h.radius,h.widthSegments,h.heightSegments,h.phiStart,h.phiLength,h.thetaStart,h.thetaLength);break;case "DodecahedronGeometry":g=new THREE.DodecahedronGeometry(h.radius,h.detail);break;case "IcosahedronGeometry":g=new THREE.IcosahedronGeometry(h.radius,h.detail);break;case "OctahedronGeometry":g=new THREE.OctahedronGeometry(h.radius,
-h.detail);break;case "TetrahedronGeometry":g=new THREE.TetrahedronGeometry(h.radius,h.detail);break;case "RingGeometry":g=new THREE.RingGeometry(h.innerRadius,h.outerRadius,h.thetaSegments,h.phiSegments,h.thetaStart,h.thetaLength);break;case "TorusGeometry":g=new THREE.TorusGeometry(h.radius,h.tube,h.radialSegments,h.tubularSegments,h.arc);break;case "TorusKnotGeometry":g=new THREE.TorusKnotGeometry(h.radius,h.tube,h.radialSegments,h.tubularSegments,h.p,h.q,h.heightScale);break;case "LatheGeometry":g=
-new THREE.LatheGeometry(h.points,h.segments,h.phiStart,h.phiLength);break;case "BufferGeometry":g=d.parse(h);break;case "Geometry":g=c.parse(h.data,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+h.type+'"');continue}g.uuid=h.uuid;void 0!==h.name&&(g.name=h.name);b[h.uuid]=g}return b},parseMaterials:function(a,b){var c={};if(void 0!==a){var d=new THREE.MaterialLoader;d.setTextures(b);for(var e=0,f=a.length;e<f;e++){var g=d.parse(a[e]);c[g.uuid]=
-g}}return c},parseAnimations:function(a){for(var b=[],c=0;c<a.length;c++){var d=THREE.AnimationClip.parse(a[c]);b.push(d)}return b},parseImages:function(a,b){function c(a){d.manager.itemStart(a);return g.load(a,function(){d.manager.itemEnd(a)})}var d=this,e={};if(void 0!==a&&0<a.length){var f=new THREE.LoadingManager(b),g=new THREE.ImageLoader(f);g.setCrossOrigin(this.crossOrigin);for(var f=0,h=a.length;f<h;f++){var k=a[f],l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(k.url)?k.url:d.texturePath+k.url;e[k.uuid]=
-c(l)}}return e},parseTextures:function(a,b){function c(a){if("number"===typeof a)return a;console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",a);return THREE[a]}var d={};if(void 0!==a)for(var e=0,f=a.length;e<f;e++){var g=a[e];void 0===g.image&&console.warn('THREE.ObjectLoader: No "image" specified for',g.uuid);void 0===b[g.image]&&console.warn("THREE.ObjectLoader: Undefined image",g.image);var h=new THREE.Texture(b[g.image]);h.needsUpdate=!0;h.uuid=g.uuid;void 0!==
-g.name&&(h.name=g.name);void 0!==g.mapping&&(h.mapping=c(g.mapping));void 0!==g.offset&&(h.offset=new THREE.Vector2(g.offset[0],g.offset[1]));void 0!==g.repeat&&(h.repeat=new THREE.Vector2(g.repeat[0],g.repeat[1]));void 0!==g.minFilter&&(h.minFilter=c(g.minFilter));void 0!==g.magFilter&&(h.magFilter=c(g.magFilter));void 0!==g.anisotropy&&(h.anisotropy=g.anisotropy);Array.isArray(g.wrap)&&(h.wrapS=c(g.wrap[0]),h.wrapT=c(g.wrap[1]));d[g.uuid]=h}return d},parseObject:function(){var a=new THREE.Matrix4;
-return function(b,c,d){function e(a){void 0===c[a]&&console.warn("THREE.ObjectLoader: Undefined geometry",a);return c[a]}function f(a){if(void 0!==a)return void 0===d[a]&&console.warn("THREE.ObjectLoader: Undefined material",a),d[a]}var g;switch(b.type){case "Scene":g=new THREE.Scene;break;case "PerspectiveCamera":g=new THREE.PerspectiveCamera(b.fov,b.aspect,b.near,b.far);break;case "OrthographicCamera":g=new THREE.OrthographicCamera(b.left,b.right,b.top,b.bottom,b.near,b.far);break;case "AmbientLight":g=
-new THREE.AmbientLight(b.color,b.intensity);break;case "DirectionalLight":g=new THREE.DirectionalLight(b.color,b.intensity);break;case "PointLight":g=new THREE.PointLight(b.color,b.intensity,b.distance,b.decay);break;case "SpotLight":g=new THREE.SpotLight(b.color,b.intensity,b.distance,b.angle,b.penumbra,b.decay);break;case "HemisphereLight":g=new THREE.HemisphereLight(b.color,b.groundColor,b.intensity);break;case "Mesh":g=e(b.geometry);var h=f(b.material);g=g.bones&&0<g.bones.length?new THREE.SkinnedMesh(g,
-h):new THREE.Mesh(g,h);break;case "LOD":g=new THREE.LOD;break;case "Line":g=new THREE.Line(e(b.geometry),f(b.material),b.mode);break;case "PointCloud":case "Points":g=new THREE.Points(e(b.geometry),f(b.material));break;case "Sprite":g=new THREE.Sprite(f(b.material));break;case "Group":g=new THREE.Group;break;default:g=new THREE.Object3D}g.uuid=b.uuid;void 0!==b.name&&(g.name=b.name);void 0!==b.matrix?(a.fromArray(b.matrix),a.decompose(g.position,g.quaternion,g.scale)):(void 0!==b.position&&g.position.fromArray(b.position),
-void 0!==b.rotation&&g.rotation.fromArray(b.rotation),void 0!==b.scale&&g.scale.fromArray(b.scale));void 0!==b.castShadow&&(g.castShadow=b.castShadow);void 0!==b.receiveShadow&&(g.receiveShadow=b.receiveShadow);void 0!==b.visible&&(g.visible=b.visible);void 0!==b.userData&&(g.userData=b.userData);if(void 0!==b.children)for(var k in b.children)g.add(this.parseObject(b.children[k],c,d));if("LOD"===b.type)for(b=b.levels,h=0;h<b.length;h++){var l=b[h];k=g.getObjectByProperty("uuid",l.object);void 0!==
-k&&g.addLevel(k,l.distance)}return g}}()};THREE.TextureLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a,b,c,d){var e=new THREE.Texture,f=new THREE.ImageLoader(this.manager);f.setCrossOrigin(this.crossOrigin);f.setPath(this.path);f.load(a,function(a){e.image=a;e.needsUpdate=!0;void 0!==b&&b(e)},c,d);return e},setCrossOrigin:function(a){this.crossOrigin=a},setPath:function(a){this.path=a}};
-THREE.CubeTextureLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};
-THREE.CubeTextureLoader.prototype={constructor:THREE.CubeTextureLoader,load:function(a,b,c,d){function e(c){g.load(a[c],function(a){f.images[c]=a;h++;6===h&&(f.needsUpdate=!0,b&&b(f))},void 0,d)}var f=new THREE.CubeTexture([]),g=new THREE.ImageLoader(this.manager);g.setCrossOrigin(this.crossOrigin);g.setPath(this.path);var h=0;for(c=0;c<a.length;++c)e(c);return f},setCrossOrigin:function(a){this.crossOrigin=a},setPath:function(a){this.path=a}};
-THREE.DataTextureLoader=THREE.BinaryTextureLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this._parser=null};
-THREE.BinaryTextureLoader.prototype={constructor:THREE.BinaryTextureLoader,load:function(a,b,c,d){var e=this,f=new THREE.DataTexture,g=new THREE.XHRLoader(this.manager);g.setResponseType("arraybuffer");g.load(a,function(a){if(a=e._parser(a))void 0!==a.image?f.image=a.image:void 0!==a.data&&(f.image.width=a.width,f.image.height=a.height,f.image.data=a.data),f.wrapS=void 0!==a.wrapS?a.wrapS:THREE.ClampToEdgeWrapping,f.wrapT=void 0!==a.wrapT?a.wrapT:THREE.ClampToEdgeWrapping,f.magFilter=void 0!==a.magFilter?
-a.magFilter:THREE.LinearFilter,f.minFilter=void 0!==a.minFilter?a.minFilter:THREE.LinearMipMapLinearFilter,f.anisotropy=void 0!==a.anisotropy?a.anisotropy:1,void 0!==a.format&&(f.format=a.format),void 0!==a.type&&(f.type=a.type),void 0!==a.mipmaps&&(f.mipmaps=a.mipmaps),1===a.mipmapCount&&(f.minFilter=THREE.LinearFilter),f.needsUpdate=!0,b&&b(f,a)},c,d);return f}};THREE.CompressedTextureLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this._parser=null};
-THREE.CompressedTextureLoader.prototype={constructor:THREE.CompressedTextureLoader,load:function(a,b,c,d){function e(e){k.load(a[e],function(a){a=f._parser(a,!0);g[e]={width:a.width,height:a.height,format:a.format,mipmaps:a.mipmaps};l+=1;6===l&&(1===a.mipmapCount&&(h.minFilter=THREE.LinearFilter),h.format=a.format,h.needsUpdate=!0,b&&b(h))},c,d)}var f=this,g=[],h=new THREE.CompressedTexture;h.image=g;var k=new THREE.XHRLoader(this.manager);k.setPath(this.path);k.setResponseType("arraybuffer");if(Array.isArray(a))for(var l=
-0,n=0,p=a.length;n<p;++n)e(n);else k.load(a,function(a){a=f._parser(a,!0);if(a.isCubemap)for(var c=a.mipmaps.length/a.mipmapCount,d=0;d<c;d++){g[d]={mipmaps:[]};for(var e=0;e<a.mipmapCount;e++)g[d].mipmaps.push(a.mipmaps[d*a.mipmapCount+e]),g[d].format=a.format,g[d].width=a.width,g[d].height=a.height}else h.image.width=a.width,h.image.height=a.height,h.mipmaps=a.mipmaps;1===a.mipmapCount&&(h.minFilter=THREE.LinearFilter);h.format=a.format;h.needsUpdate=!0;b&&b(h)},c,d);return h},setPath:function(a){this.path=
-a}};
-THREE.Material=function(){Object.defineProperty(this,"id",{value:THREE.MaterialIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="Material";this.side=THREE.FrontSide;this.opacity=1;this.transparent=!1;this.blending=THREE.NormalBlending;this.blendSrc=THREE.SrcAlphaFactor;this.blendDst=THREE.OneMinusSrcAlphaFactor;this.blendEquation=THREE.AddEquation;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=THREE.LessEqualDepth;this.colorWrite=this.depthWrite=this.depthTest=
-!0;this.precision=null;this.polygonOffset=!1;this.overdraw=this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this._needsUpdate=this.visible=!0};
-THREE.Material.prototype={constructor:THREE.Material,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update();this._needsUpdate=a},setValues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else{var d=this[b];void 0===d?console.warn("THREE."+this.type+": '"+b+"' is not a property of this material."):d instanceof THREE.Color?d.set(c):d instanceof THREE.Vector3&&c instanceof THREE.Vector3?d.copy(c):
-this[b]="overdraw"===b?Number(c):c}}},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a;c&&(a={textures:{},images:{}});var d={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};d.uuid=this.uuid;d.type=this.type;""!==this.name&&(d.name=this.name);this.color instanceof THREE.Color&&(d.color=this.color.getHex());.5!==this.roughness&&(d.roughness=this.roughness);.5!==this.metalness&&(d.metalness=this.metalness);this.emissive instanceof
-THREE.Color&&(d.emissive=this.emissive.getHex());this.specular instanceof THREE.Color&&(d.specular=this.specular.getHex());void 0!==this.shininess&&(d.shininess=this.shininess);this.map instanceof THREE.Texture&&(d.map=this.map.toJSON(a).uuid);this.alphaMap instanceof THREE.Texture&&(d.alphaMap=this.alphaMap.toJSON(a).uuid);this.lightMap instanceof THREE.Texture&&(d.lightMap=this.lightMap.toJSON(a).uuid);this.bumpMap instanceof THREE.Texture&&(d.bumpMap=this.bumpMap.toJSON(a).uuid,d.bumpScale=this.bumpScale);
-this.normalMap instanceof THREE.Texture&&(d.normalMap=this.normalMap.toJSON(a).uuid,d.normalScale=this.normalScale.toArray());this.displacementMap instanceof THREE.Texture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,d.displacementScale=this.displacementScale,d.displacementBias=this.displacementBias);this.roughnessMap instanceof THREE.Texture&&(d.roughnessMap=this.roughnessMap.toJSON(a).uuid);this.metalnessMap instanceof THREE.Texture&&(d.metalnessMap=this.metalnessMap.toJSON(a).uuid);
-this.emissiveMap instanceof THREE.Texture&&(d.emissiveMap=this.emissiveMap.toJSON(a).uuid);this.specularMap instanceof THREE.Texture&&(d.specularMap=this.specularMap.toJSON(a).uuid);this.envMap instanceof THREE.Texture&&(d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity=this.reflectivity);void 0!==this.size&&(d.size=this.size);void 0!==this.sizeAttenuation&&(d.sizeAttenuation=this.sizeAttenuation);void 0!==this.vertexColors&&this.vertexColors!==THREE.NoColors&&(d.vertexColors=this.vertexColors);
-void 0!==this.shading&&this.shading!==THREE.SmoothShading&&(d.shading=this.shading);void 0!==this.blending&&this.blending!==THREE.NormalBlending&&(d.blending=this.blending);void 0!==this.side&&this.side!==THREE.FrontSide&&(d.side=this.side);1>this.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);0<this.alphaTest&&(d.alphaTest=this.alphaTest);!0===this.wireframe&&(d.wireframe=this.wireframe);1<this.wireframeLinewidth&&(d.wireframeLinewidth=this.wireframeLinewidth);
-c&&(c=b(a.textures),a=b(a.images),0<c.length&&(d.textures=c),0<a.length&&(d.images=a));return d},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.name=a.name;this.side=a.side;this.opacity=a.opacity;this.transparent=a.transparent;this.blending=a.blending;this.blendSrc=a.blendSrc;this.blendDst=a.blendDst;this.blendEquation=a.blendEquation;this.blendSrcAlpha=a.blendSrcAlpha;this.blendDstAlpha=a.blendDstAlpha;this.blendEquationAlpha=a.blendEquationAlpha;this.depthFunc=a.depthFunc;
-this.depthTest=a.depthTest;this.depthWrite=a.depthWrite;this.colorWrite=a.colorWrite;this.precision=a.precision;this.polygonOffset=a.polygonOffset;this.polygonOffsetFactor=a.polygonOffsetFactor;this.polygonOffsetUnits=a.polygonOffsetUnits;this.alphaTest=a.alphaTest;this.overdraw=a.overdraw;this.visible=a.visible;return this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.Material.prototype);
-THREE.MaterialIdCount=0;THREE.LineBasicMaterial=function(a){THREE.Material.call(this);this.type="LineBasicMaterial";this.color=new THREE.Color(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=THREE.NoColors;this.fog=!0;this.setValues(a)};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
-THREE.LineBasicMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.linecap=a.linecap;this.linejoin=a.linejoin;this.vertexColors=a.vertexColors;this.fog=a.fog;return this};THREE.LineDashedMaterial=function(a){THREE.Material.call(this);this.type="LineDashedMaterial";this.color=new THREE.Color(16777215);this.scale=this.linewidth=1;this.dashSize=3;this.gapSize=1;this.vertexColors=THREE.NoColors;this.fog=!0;this.setValues(a)};
-THREE.LineDashedMaterial.prototype=Object.create(THREE.Material.prototype);THREE.LineDashedMaterial.prototype.constructor=THREE.LineDashedMaterial;THREE.LineDashedMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;this.vertexColors=a.vertexColors;this.fog=a.fog;return this};
-THREE.MeshBasicMaterial=function(a){THREE.Material.call(this);this.type="MeshBasicMaterial";this.color=new THREE.Color(16777215);this.aoMap=this.map=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=.98;this.fog=!0;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphTargets=this.skinning=
-!1;this.setValues(a)};THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
-THREE.MeshBasicMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;
-this.wireframeLinejoin=a.wireframeLinejoin;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;return this};
-THREE.MeshLambertMaterial=function(a){THREE.Material.call(this);this.type="MeshLambertMaterial";this.color=new THREE.Color(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new THREE.Color(0);this.emissiveIntensity=1;this.envMap=this.alphaMap=this.specularMap=this.emissiveMap=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=.98;this.fog=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=
-this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
-THREE.MeshLambertMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=
-a.refractionRatio;this.fog=a.fog;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};
-THREE.MeshPhongMaterial=function(a){THREE.Material.call(this);this.type="MeshPhongMaterial";this.color=new THREE.Color(16777215);this.specular=new THREE.Color(1118481);this.shininess=30;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new THREE.Color(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new THREE.Vector2(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=
-0;this.envMap=this.alphaMap=this.specularMap=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=.98;this.fog=!0;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;
-THREE.MeshPhongMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalScale.copy(a.normalScale);
-this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.vertexColors=
-a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};
-THREE.MeshStandardMaterial=function(a){THREE.Material.call(this);this.type="MeshStandardMaterial";this.color=new THREE.Color(16777215);this.metalness=this.roughness=.5;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new THREE.Color(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new THREE.Vector2(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=
-0;this.envMap=this.alphaMap=this.metalnessMap=this.roughnessMap=null;this.envMapIntensity=1;this.refractionRatio=.98;this.fog=!0;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.MeshStandardMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshStandardMaterial.prototype.constructor=THREE.MeshStandardMaterial;
-THREE.MeshStandardMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalScale.copy(a.normalScale);
-this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;
-this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};THREE.MeshDepthMaterial=function(a){THREE.Material.call(this);this.type="MeshDepthMaterial";this.wireframe=this.morphTargets=!1;this.wireframeLinewidth=1;this.setValues(a)};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;
-THREE.MeshDepthMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);this.type="MeshNormalMaterial";this.wireframe=!1;this.wireframeLinewidth=1;this.morphTargets=!1;this.setValues(a)};THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;
-THREE.MeshNormalMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};THREE.MultiMaterial=function(a){this.uuid=THREE.Math.generateUUID();this.type="MultiMaterial";this.materials=a instanceof Array?a:[];this.visible=!0};
-THREE.MultiMaterial.prototype={constructor:THREE.MultiMaterial,toJSON:function(a){for(var b={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},c=this.materials,d=0,e=c.length;d<e;d++){var f=c[d].toJSON(a);delete f.metadata;b.materials.push(f)}b.visible=this.visible;return b},clone:function(){for(var a=new this.constructor,b=0;b<this.materials.length;b++)a.materials.push(this.materials[b].clone());a.visible=this.visible;return a}};
-THREE.PointsMaterial=function(a){THREE.Material.call(this);this.type="PointsMaterial";this.color=new THREE.Color(16777215);this.map=null;this.size=1;this.sizeAttenuation=!0;this.vertexColors=THREE.NoColors;this.fog=!0;this.setValues(a)};THREE.PointsMaterial.prototype=Object.create(THREE.Material.prototype);THREE.PointsMaterial.prototype.constructor=THREE.PointsMaterial;
-THREE.PointsMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;this.vertexColors=a.vertexColors;this.fog=a.fog;return this};
-THREE.ShaderMaterial=function(a){THREE.Material.call(this);this.type="ShaderMaterial";this.defines={};this.uniforms={};this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";this.shading=THREE.SmoothShading;this.linewidth=1;this.wireframe=!1;this.wireframeLinewidth=1;this.lights=this.fog=!1;this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=
-this.skinning=!1;this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]};this.index0AttributeName=void 0;void 0!==a&&(void 0!==a.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(a))};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
-THREE.ShaderMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.fragmentShader=a.fragmentShader;this.vertexShader=a.vertexShader;this.uniforms=THREE.UniformsUtils.clone(a.uniforms);this.defines=a.defines;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.fog=a.fog;this.lights=a.lights;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;this.extensions=
-a.extensions;return this};THREE.ShaderMaterial.prototype.toJSON=function(a){a=THREE.Material.prototype.toJSON.call(this,a);a.uniforms=this.uniforms;a.vertexShader=this.vertexShader;a.fragmentShader=this.fragmentShader;return a};THREE.RawShaderMaterial=function(a){THREE.ShaderMaterial.call(this,a);this.type="RawShaderMaterial"};THREE.RawShaderMaterial.prototype=Object.create(THREE.ShaderMaterial.prototype);THREE.RawShaderMaterial.prototype.constructor=THREE.RawShaderMaterial;
-THREE.SpriteMaterial=function(a){THREE.Material.call(this);this.type="SpriteMaterial";this.color=new THREE.Color(16777215);this.map=null;this.rotation=0;this.fog=!1;this.setValues(a)};THREE.SpriteMaterial.prototype=Object.create(THREE.Material.prototype);THREE.SpriteMaterial.prototype.constructor=THREE.SpriteMaterial;THREE.SpriteMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.rotation=a.rotation;this.fog=a.fog;return this};
-THREE.Texture=function(a,b,c,d,e,f,g,h,k){Object.defineProperty(this,"id",{value:THREE.TextureIdCount++});this.uuid=THREE.Math.generateUUID();this.sourceFile=this.name="";this.image=void 0!==a?a:THREE.Texture.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:THREE.Texture.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==e?e:THREE.LinearFilter;this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter;
-this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:THREE.RGBAFormat;this.type=void 0!==h?h:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.version=0;this.onUpdate=null};THREE.Texture.DEFAULT_IMAGE=void 0;THREE.Texture.DEFAULT_MAPPING=THREE.UVMapping;
-THREE.Texture.prototype={constructor:THREE.Texture,set needsUpdate(a){!0===a&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=a.wrapT;this.magFilter=a.magFilter;this.minFilter=a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format;this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=
-a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;return this},toJSON:function(a){if(void 0!==a.textures[this.uuid])return a.textures[this.uuid];var b={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy};if(void 0!==this.image){var c=
-this.image;void 0===c.uuid&&(c.uuid=THREE.Math.generateUUID());if(void 0===a.images[c.uuid]){var d=a.images,e=c.uuid,f=c.uuid,g;void 0!==c.toDataURL?g=c:(g=document.createElement("canvas"),g.width=c.width,g.height=c.height,g.getContext("2d").drawImage(c,0,0,c.width,c.height));g=2048<g.width||2048<g.height?g.toDataURL("image/jpeg",.6):g.toDataURL("image/png");d[e]={uuid:f,url:g}}b.image=c.uuid}return a.textures[this.uuid]=b},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(a){if(this.mapping===
-THREE.UVMapping){a.multiply(this.repeat);a.add(this.offset);if(0>a.x||1<a.x)switch(this.wrapS){case THREE.RepeatWrapping:a.x-=Math.floor(a.x);break;case THREE.ClampToEdgeWrapping:a.x=0>a.x?0:1;break;case THREE.MirroredRepeatWrapping:1===Math.abs(Math.floor(a.x)%2)?a.x=Math.ceil(a.x)-a.x:a.x-=Math.floor(a.x)}if(0>a.y||1<a.y)switch(this.wrapT){case THREE.RepeatWrapping:a.y-=Math.floor(a.y);break;case THREE.ClampToEdgeWrapping:a.y=0>a.y?0:1;break;case THREE.MirroredRepeatWrapping:1===Math.abs(Math.floor(a.y)%
-2)?a.y=Math.ceil(a.y)-a.y:a.y-=Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};THREE.EventDispatcher.prototype.apply(THREE.Texture.prototype);THREE.TextureIdCount=0;THREE.CanvasTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.needsUpdate=!0};THREE.CanvasTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CanvasTexture.prototype.constructor=THREE.CanvasTexture;
-THREE.CubeTexture=function(a,b,c,d,e,f,g,h,k){b=void 0!==b?b:THREE.CubeReflectionMapping;THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.images=a;this.flipY=!1};THREE.CubeTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CubeTexture.prototype.constructor=THREE.CubeTexture;THREE.CubeTexture.prototype.copy=function(a){THREE.Texture.prototype.copy.call(this,a);this.images=a.images;return this};
-THREE.CompressedTexture=function(a,b,c,d,e,f,g,h,k,l,n){THREE.Texture.call(this,null,f,g,h,k,l,d,e,n);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1};THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CompressedTexture.prototype.constructor=THREE.CompressedTexture;
-THREE.DataTexture=function(a,b,c,d,e,f,g,h,k,l,n){THREE.Texture.call(this,null,f,g,h,k,l,d,e,n);this.image={data:a,width:b,height:c};this.magFilter=void 0!==k?k:THREE.NearestFilter;this.minFilter=void 0!==l?l:THREE.NearestFilter;this.generateMipmaps=this.flipY=!1};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.constructor=THREE.DataTexture;
-THREE.VideoTexture=function(a,b,c,d,e,f,g,h,k){function l(){requestAnimationFrame(l);a.readyState===a.HAVE_ENOUGH_DATA&&(n.needsUpdate=!0)}THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.generateMipmaps=!1;var n=this;l()};THREE.VideoTexture.prototype=Object.create(THREE.Texture.prototype);THREE.VideoTexture.prototype.constructor=THREE.VideoTexture;THREE.Group=function(){THREE.Object3D.call(this);this.type="Group"};THREE.Group.prototype=Object.create(THREE.Object3D.prototype);
-THREE.Group.prototype.constructor=THREE.Group;THREE.Points=function(a,b){THREE.Object3D.call(this);this.type="Points";this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.PointsMaterial({color:16777215*Math.random()})};THREE.Points.prototype=Object.create(THREE.Object3D.prototype);THREE.Points.prototype.constructor=THREE.Points;
-THREE.Points.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray,c=new THREE.Sphere;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a);if(f<n){var h=b.closestPointToPoint(a);h.applyMatrix4(k);var l=d.ray.origin.distanceTo(h);l<d.near||l>d.far||e.push({distance:l,distanceToRay:Math.sqrt(f),point:h.clone(),index:c,face:null,object:g})}}var g=this,h=this.geometry,k=this.matrixWorld,l=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);
-c.applyMatrix4(k);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);var l=l/((this.scale.x+this.scale.y+this.scale.z)/3),n=l*l,l=new THREE.Vector3;if(h instanceof THREE.BufferGeometry){var p=h.index,h=h.attributes.position.array;if(null!==p)for(var m=p.array,p=0,q=m.length;p<q;p++){var s=m[p];l.fromArray(h,3*s);f(l,s)}else for(p=0,m=h.length/3;p<m;p++)l.fromArray(h,3*p),f(l,p)}else for(l=h.vertices,p=0,m=l.length;p<m;p++)f(l[p],p)}}}();
-THREE.Points.prototype.clone=function(){return(new this.constructor(this.geometry,this.material)).copy(this)};THREE.Line=function(a,b,c){if(1===c)return console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),new THREE.LineSegments(a,b);THREE.Object3D.call(this);this.type="Line";this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.LineBasicMaterial({color:16777215*Math.random()})};THREE.Line.prototype=Object.create(THREE.Object3D.prototype);
-THREE.Line.prototype.constructor=THREE.Line;
-THREE.Line.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray,c=new THREE.Sphere;return function(d,e){var f=d.linePrecision,f=f*f,g=this.geometry,h=this.matrixWorld;null===g.boundingSphere&&g.computeBoundingSphere();c.copy(g.boundingSphere);c.applyMatrix4(h);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(h);b.copy(d.ray).applyMatrix4(a);var k=new THREE.Vector3,l=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3,p=this instanceof THREE.LineSegments?2:1;if(g instanceof THREE.BufferGeometry){var m=
-g.index,q=g.attributes.position.array;if(null!==m)for(var m=m.array,g=0,s=m.length-1;g<s;g+=p){var u=m[g+1];k.fromArray(q,3*m[g]);l.fromArray(q,3*u);u=b.distanceSqToSegment(k,l,n,h);u>f||(n.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(n),u<d.near||u>d.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else for(g=0,s=q.length/3-1;g<s;g+=p)k.fromArray(q,3*g),l.fromArray(q,3*g+3),u=b.distanceSqToSegment(k,l,n,h),u>f||(n.applyMatrix4(this.matrixWorld),
-u=d.ray.origin.distanceTo(n),u<d.near||u>d.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g instanceof THREE.Geometry)for(k=g.vertices,l=k.length,g=0;g<l-1;g+=p)u=b.distanceSqToSegment(k[g],k[g+1],n,h),u>f||(n.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(n),u<d.near||u>d.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}();
-THREE.Line.prototype.clone=function(){return(new this.constructor(this.geometry,this.material)).copy(this)};THREE.LineStrip=0;THREE.LinePieces=1;THREE.LineSegments=function(a,b){THREE.Line.call(this,a,b);this.type="LineSegments"};THREE.LineSegments.prototype=Object.create(THREE.Line.prototype);THREE.LineSegments.prototype.constructor=THREE.LineSegments;
-THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.MeshBasicMaterial({color:16777215*Math.random()});this.drawMode=THREE.TrianglesDrawMode;this.updateMorphTargets()};THREE.Mesh.prototype=Object.create(THREE.Object3D.prototype);THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.setDrawMode=function(a){this.drawMode=a};
-THREE.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&0<this.geometry.morphTargets.length){this.morphTargetBase=-1;this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var a=0,b=this.geometry.morphTargets.length;a<b;a++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[a].name]=a}};
-THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morphTargetDictionary[a])return this.morphTargetDictionary[a];console.warn("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
-THREE.Mesh.prototype.raycast=function(){function a(a,b,c,d,e,f,g){THREE.Triangle.barycoordFromPoint(a,b,c,d,u);e.multiplyScalar(u.x);f.multiplyScalar(u.y);g.multiplyScalar(u.z);e.add(f).add(g);return e.clone()}function b(a,b,c,d,e,f,g){var h=a.material;if(null===(h.side===THREE.BackSide?c.intersectTriangle(f,e,d,!0,g):c.intersectTriangle(d,e,f,h.side!==THREE.DoubleSide,g)))return null;x.copy(g);x.applyMatrix4(a.matrixWorld);c=b.ray.origin.distanceTo(x);return c<b.near||c>b.far?null:{distance:c,point:x.clone(),
-object:a}}function c(c,d,e,f,l,n,p,x){g.fromArray(f,3*n);h.fromArray(f,3*p);k.fromArray(f,3*x);if(c=b(c,d,e,g,h,k,t))l&&(m.fromArray(l,2*n),q.fromArray(l,2*p),s.fromArray(l,2*x),c.uv=a(t,g,h,k,m,q,s)),c.face=new THREE.Face3(n,p,x,THREE.Triangle.normal(g,h,k)),c.faceIndex=n;return c}var d=new THREE.Matrix4,e=new THREE.Ray,f=new THREE.Sphere,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,n=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector2,q=new THREE.Vector2,
-s=new THREE.Vector2,u=new THREE.Vector3,t=new THREE.Vector3,x=new THREE.Vector3;return function(x,u){var w=this.geometry,D=this.material,z=this.matrixWorld;if(void 0!==D&&(null===w.boundingSphere&&w.computeBoundingSphere(),f.copy(w.boundingSphere),f.applyMatrix4(z),!1!==x.ray.intersectsSphere(f)&&(d.getInverse(z),e.copy(x.ray).applyMatrix4(d),null===w.boundingBox||!1!==e.intersectsBox(w.boundingBox)))){var y,A;if(w instanceof THREE.BufferGeometry){var H,G,D=w.index,z=w.attributes,w=z.position.array;
-void 0!==z.uv&&(y=z.uv.array);if(null!==D)for(var z=D.array,E=0,K=z.length;E<K;E+=3){if(D=z[E],H=z[E+1],G=z[E+2],A=c(this,x,e,w,y,D,H,G))A.faceIndex=Math.floor(E/3),u.push(A)}else for(E=0,K=w.length;E<K;E+=9)if(D=E/3,H=D+1,G=D+2,A=c(this,x,e,w,y,D,H,G))A.index=D,u.push(A)}else if(w instanceof THREE.Geometry){var P,N,z=D instanceof THREE.MultiMaterial,E=!0===z?D.materials:null,K=w.vertices;H=w.faces;G=w.faceVertexUvs[0];0<G.length&&(y=G);for(var L=0,B=H.length;L<B;L++){var M=H[L];A=!0===z?E[M.materialIndex]:
-D;if(void 0!==A){G=K[M.a];P=K[M.b];N=K[M.c];if(!0===A.morphTargets){A=w.morphTargets;var Q=this.morphTargetInfluences;g.set(0,0,0);h.set(0,0,0);k.set(0,0,0);for(var O=0,S=A.length;O<S;O++){var J=Q[O];if(0!==J){var F=A[O].vertices;g.addScaledVector(l.subVectors(F[M.a],G),J);h.addScaledVector(n.subVectors(F[M.b],P),J);k.addScaledVector(p.subVectors(F[M.c],N),J)}}g.add(G);h.add(P);k.add(N);G=g;P=h;N=k}if(A=b(this,x,e,G,P,N,t))y&&(Q=y[L],m.copy(Q[0]),q.copy(Q[1]),s.copy(Q[2]),A.uv=a(t,G,P,N,m,q,s)),A.face=
-M,A.faceIndex=L,u.push(A)}}}}}}();THREE.Mesh.prototype.clone=function(){return(new this.constructor(this.geometry,this.material)).copy(this)};THREE.Bone=function(a){THREE.Object3D.call(this);this.type="Bone";this.skin=a};THREE.Bone.prototype=Object.create(THREE.Object3D.prototype);THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.skin=a.skin;return this};
-THREE.Skeleton=function(a,b,c){this.useVertexTexture=void 0!==c?c:!0;this.identityMatrix=new THREE.Matrix4;a=a||[];this.bones=a.slice(0);this.useVertexTexture?(a=Math.sqrt(4*this.bones.length),a=THREE.Math.nextPowerOfTwo(Math.ceil(a)),this.boneTextureHeight=this.boneTextureWidth=a=Math.max(a,4),this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new THREE.DataTexture(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,THREE.RGBAFormat,THREE.FloatType)):
-this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[],b=0,a=this.bones.length;b<a;b++)this.boneInverses.push(new THREE.Matrix4)};
-THREE.Skeleton.prototype.calculateInverses=function(){this.boneInverses=[];for(var a=0,b=this.bones.length;a<b;a++){var c=new THREE.Matrix4;this.bones[a]&&c.getInverse(this.bones[a].matrixWorld);this.boneInverses.push(c)}};
-THREE.Skeleton.prototype.pose=function(){for(var a,b=0,c=this.bones.length;b<c;b++)(a=this.bones[b])&&a.matrixWorld.getInverse(this.boneInverses[b]);b=0;for(c=this.bones.length;b<c;b++)if(a=this.bones[b])a.parent?(a.matrix.getInverse(a.parent.matrixWorld),a.matrix.multiply(a.matrixWorld)):a.matrix.copy(a.matrixWorld),a.matrix.decompose(a.position,a.quaternion,a.scale)};
-THREE.Skeleton.prototype.update=function(){var a=new THREE.Matrix4;return function(){for(var b=0,c=this.bones.length;b<c;b++)a.multiplyMatrices(this.bones[b]?this.bones[b].matrixWorld:this.identityMatrix,this.boneInverses[b]),a.flattenToArrayOffset(this.boneMatrices,16*b);this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)}}();THREE.Skeleton.prototype.clone=function(){return new THREE.Skeleton(this.bones,this.boneInverses,this.useVertexTexture)};
-THREE.SkinnedMesh=function(a,b,c){THREE.Mesh.call(this,a,b);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new THREE.Matrix4;this.bindMatrixInverse=new THREE.Matrix4;a=[];if(this.geometry&&void 0!==this.geometry.bones){for(var d,e=0,f=this.geometry.bones.length;e<f;++e)d=this.geometry.bones[e],b=new THREE.Bone(this),a.push(b),b.name=d.name,b.position.fromArray(d.pos),b.quaternion.fromArray(d.rotq),void 0!==d.scl&&b.scale.fromArray(d.scl);e=0;for(f=this.geometry.bones.length;e<f;++e)d=
-this.geometry.bones[e],-1!==d.parent&&null!==d.parent?a[d.parent].add(a[e]):this.add(a[e])}this.normalizeSkinWeights();this.updateMatrixWorld(!0);this.bind(new THREE.Skeleton(a,void 0,c),this.matrixWorld)};THREE.SkinnedMesh.prototype=Object.create(THREE.Mesh.prototype);THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
-THREE.SkinnedMesh.prototype.bind=function(a,b){this.skeleton=a;void 0===b&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),b=this.matrixWorld);this.bindMatrix.copy(b);this.bindMatrixInverse.getInverse(b)};THREE.SkinnedMesh.prototype.pose=function(){this.skeleton.pose()};
-THREE.SkinnedMesh.prototype.normalizeSkinWeights=function(){if(this.geometry instanceof THREE.Geometry)for(var a=0;a<this.geometry.skinWeights.length;a++){var b=this.geometry.skinWeights[a],c=1/b.lengthManhattan();Infinity!==c?b.multiplyScalar(c):b.set(1,0,0,0)}else if(this.geometry instanceof THREE.BufferGeometry)for(var b=new THREE.Vector4,d=this.geometry.attributes.skinWeight,a=0;a<d.count;a++)b.x=d.getX(a),b.y=d.getY(a),b.z=d.getZ(a),b.w=d.getW(a),c=1/b.lengthManhattan(),Infinity!==c?b.multiplyScalar(c):
-b.set(1,0,0,0),d.setXYZW(a,b.x,b.y,b.z,b.w)};THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){THREE.Mesh.prototype.updateMatrixWorld.call(this,!0);"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh unrecognized bindMode: "+this.bindMode)};THREE.SkinnedMesh.prototype.clone=function(){return(new this.constructor(this.geometry,this.material,this.useVertexTexture)).copy(this)};
-THREE.LOD=function(){THREE.Object3D.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]},objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");return this.levels}}})};THREE.LOD.prototype=Object.create(THREE.Object3D.prototype);THREE.LOD.prototype.constructor=THREE.LOD;
-THREE.LOD.prototype.addLevel=function(a,b){void 0===b&&(b=0);b=Math.abs(b);for(var c=this.levels,d=0;d<c.length&&!(b<c[d].distance);d++);c.splice(d,0,{distance:b,object:a});this.add(a)};THREE.LOD.prototype.getObjectForDistance=function(a){for(var b=this.levels,c=1,d=b.length;c<d&&!(a<b[c].distance);c++);return b[c-1].object};
-THREE.LOD.prototype.raycast=function(){var a=new THREE.Vector3;return function(b,c){a.setFromMatrixPosition(this.matrixWorld);var d=b.ray.origin.distanceTo(a);this.getObjectForDistance(d).raycast(b,c)}}();
-THREE.LOD.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c){var d=this.levels;if(1<d.length){a.setFromMatrixPosition(c.matrixWorld);b.setFromMatrixPosition(this.matrixWorld);c=a.distanceTo(b);d[0].object.visible=!0;for(var e=1,f=d.length;e<f;e++)if(c>=d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;for(;e<f;e++)d[e].object.visible=!1}}}();
-THREE.LOD.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b<c;b++){var d=a[b];this.addLevel(d.object.clone(),d.distance)}return this};THREE.LOD.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.levels=[];for(var b=this.levels,c=0,d=b.length;c<d;c++){var e=b[c];a.object.levels.push({object:e.object.uuid,distance:e.distance})}return a};
-THREE.Sprite=function(){var a=new Uint16Array([0,1,2,0,2,3]),b=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),c=new Float32Array([0,0,1,0,1,1,0,1]),d=new THREE.BufferGeometry;d.setIndex(new THREE.BufferAttribute(a,1));d.addAttribute("position",new THREE.BufferAttribute(b,3));d.addAttribute("uv",new THREE.BufferAttribute(c,2));return function(a){THREE.Object3D.call(this);this.type="Sprite";this.geometry=d;this.material=void 0!==a?a:new THREE.SpriteMaterial}}();THREE.Sprite.prototype=Object.create(THREE.Object3D.prototype);
-THREE.Sprite.prototype.constructor=THREE.Sprite;THREE.Sprite.prototype.raycast=function(){var a=new THREE.Vector3;return function(b,c){a.setFromMatrixPosition(this.matrixWorld);var d=b.ray.distanceSqToPoint(a);d>this.scale.x*this.scale.y||c.push({distance:Math.sqrt(d),point:this.position,face:null,object:this})}}();THREE.Sprite.prototype.clone=function(){return(new this.constructor(this.material)).copy(this)};THREE.Particle=THREE.Sprite;
-THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype);THREE.LensFlare.prototype.constructor=THREE.LensFlare;
-THREE.LensFlare.prototype.add=function(a,b,c,d,e,f){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===f&&(f=1);void 0===e&&(e=new THREE.Color(16777215));void 0===d&&(d=THREE.NormalBlending);c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:0,opacity:f,color:e,blending:d})};
-THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,e=2*-this.positionScreen.y;for(a=0;a<b;a++)c=this.lensFlares[a],c.x=this.positionScreen.x+d*c.distance,c.y=this.positionScreen.y+e*c.distance,c.wantedRotation=c.x*Math.PI*.25,c.rotation+=.25*(c.wantedRotation-c.rotation)};
-THREE.LensFlare.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.positionScreen.copy(a.positionScreen);this.customUpdateCallback=a.customUpdateCallback;for(var b=0,c=a.lensFlares.length;b<c;b++)this.lensFlares.push(a.lensFlares[b]);return this};THREE.Scene=function(){THREE.Object3D.call(this);this.type="Scene";this.overrideMaterial=this.fog=null;this.autoUpdate=!0};THREE.Scene.prototype=Object.create(THREE.Object3D.prototype);THREE.Scene.prototype.constructor=THREE.Scene;
-THREE.Scene.prototype.copy=function(a,b){THREE.Object3D.prototype.copy.call(this,a,b);null!==a.fog&&(this.fog=a.fog.clone());null!==a.overrideMaterial&&(this.overrideMaterial=a.overrideMaterial.clone());this.autoUpdate=a.autoUpdate;this.matrixAutoUpdate=a.matrixAutoUpdate;return this};THREE.Fog=function(a,b,c){this.name="";this.color=new THREE.Color(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3};THREE.Fog.prototype.clone=function(){return new THREE.Fog(this.color.getHex(),this.near,this.far)};
-THREE.FogExp2=function(a,b){this.name="";this.color=new THREE.Color(a);this.density=void 0!==b?b:2.5E-4};THREE.FogExp2.prototype.clone=function(){return new THREE.FogExp2(this.color.getHex(),this.density)};THREE.ShaderChunk={};THREE.ShaderChunk.alphamap_fragment="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n";THREE.ShaderChunk.alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n";THREE.ShaderChunk.alphatest_fragment="#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n";
-THREE.ShaderChunk.ambient_pars="uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\treturn PI * ambientLightColor;\n}\n";THREE.ShaderChunk.aomap_fragment="#ifdef USE_AOMAP\n\treflectedLight.indirectDiffuse *= ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n#endif\n";THREE.ShaderChunk.aomap_pars_fragment="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";THREE.ShaderChunk.begin_vertex="\nvec3 transformed = vec3( position );\n";
-THREE.ShaderChunk.beginnormal_vertex="\nvec3 objectNormal = vec3( normal );\n";THREE.ShaderChunk.bsdfs="bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {\n\treturn any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );\n}\nfloat calcLightAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif ( decayExponent > 0.0 ) {\n\t  return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = alpha * alpha;\n\tfloat gl = dotNL + pow( a2 + ( 1.0 - a2 ) * dotNL * dotNL, 0.5 );\n\tfloat gv = dotNV + pow( a2 + ( 1.0 - a2 ) * dotNV * dotNV, 0.5 );\n\treturn 1.0 / ( gl * gv );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = alpha * alpha;\n\tfloat denom = dotNH * dotNH * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / ( denom * denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = roughness * roughness;\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_Smith( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / square( ggxRoughness + 0.0001 ) - 2.0 );\n}\n";
-THREE.ShaderChunk.bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
-THREE.ShaderChunk.color_fragment="#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif";THREE.ShaderChunk.color_pars_fragment="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n";THREE.ShaderChunk.color_pars_vertex="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif";THREE.ShaderChunk.color_vertex="#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif";THREE.ShaderChunk.common="#define PI 3.14159\n#define PI2 6.28318\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat square( const in float x ) { return x*x; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nvec3 inputToLinear( in vec3 a ) {\n\t#ifdef GAMMA_INPUT\n\t\treturn pow( a, vec3( float( GAMMA_FACTOR ) ) );\n\t#else\n\t\treturn a;\n\t#endif\n}\nvec3 linearToOutput( in vec3 a ) {\n\t#ifdef GAMMA_OUTPUT\n\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );\n\t#else\n\t\treturn a;\n\t#endif\n}\n";
-THREE.ShaderChunk.defaultnormal_vertex="#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n";THREE.ShaderChunk.displacementmap_vertex="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n";THREE.ShaderChunk.displacementmap_pars_vertex="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n";
-THREE.ShaderChunk.emissivemap_fragment="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = inputToLinear( emissiveColor.rgb );\n\ttotalEmissiveLight *= emissiveColor.rgb;\n#endif\n";THREE.ShaderChunk.emissivemap_pars_fragment="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n";THREE.ShaderChunk.envmap_fragment="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#else\n\t\tfloat flipNormal = 1.0;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#endif\n\tenvColor.xyz = inputToLinear( envColor.xyz );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
-THREE.ShaderChunk.envmap_pars_fragment="#if defined( USE_ENVMAP ) || defined( STANDARD )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( STANDARD )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
-THREE.ShaderChunk.envmap_pars_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG ) && ! defined( STANDARD )\n\tvarying vec3 vReflect;\n\tuniform float refractionRatio;\n#endif\n";THREE.ShaderChunk.envmap_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG ) && ! defined( STANDARD )\n\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t#ifdef ENVMAP_MODE_REFLECTION\n\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t#else\n\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t#endif\n#endif\n";
-THREE.ShaderChunk.fog_fragment="#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\t#endif\n\t\n\toutgoingLight = mix( outgoingLight, fogColor, fogFactor );\n#endif";
-THREE.ShaderChunk.fog_pars_fragment="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";THREE.ShaderChunk.lightmap_fragment="#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n";THREE.ShaderChunk.lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
-THREE.ShaderChunk.lights_lambert_vertex="vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tdirectLight = getPointDirectLight( pointLights[ i ], geometry );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tdirectLight = getSpotDirectLight( spotLights[ i ], geometry );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectLight = getDirectionalDirectLight( directionalLights[ i ], geometry );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
-THREE.ShaderChunk.lights_pars="#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tIncidentLight getDirectionalDirectLight( const in DirectionalLight directionalLight, const in GeometricContext geometry ) {\n\t\tIncidentLight directLight;\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t\treturn directLight;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tIncidentLight getPointDirectLight( const in PointLight pointLight, const in GeometricContext geometry ) {\n\t\tIncidentLight directLight;\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tif ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= calcLightAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t\treturn directLight;\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat angleCos;\n\t\tfloat penumbra;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tIncidentLight getSpotDirectLight( const in SpotLight spotLight, const in GeometricContext geometry ) {\n\t\tIncidentLight directLight;\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat spotEffect = dot( directLight.direction, spotLight.direction );\n\t\tif ( all( bvec2( spotEffect > spotLight.angleCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n\t\t\tfloat spotEffect = dot( spotLight.direction, directLight.direction );\n\t\t\tspotEffect *= clamp( ( spotEffect - spotLight.angleCos ) / spotLight.penumbra, 0.0, 1.0 );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= ( spotEffect * calcLightAttenuation( lightDistance, spotLight.distance, spotLight.decay ) );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t\treturn directLight;\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\treturn PI * mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( STANDARD )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tfloat flipNormal = 1.0;\n\t\t#endif\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t#else\n\t\t\tvec3 envMapColor = vec3( 0.0 );\n\t\t#endif\n\t\tenvMapColor.rgb = inputToLinear( envMapColor.rgb );\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( square( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tfloat flipNormal = 1.0;\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t#endif\n\t\tenvMapColor.rgb = inputToLinear( envMapColor.rgb );\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
-THREE.ShaderChunk.lights_phong_fragment="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n";THREE.ShaderChunk.lights_phong_pars_fragment="#ifdef USE_ENVMAP\n\tvarying vec3 vWorldPosition;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * PI * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n";
-THREE.ShaderChunk.lights_phong_pars_vertex="#ifdef USE_ENVMAP\n\tvarying vec3 vWorldPosition;\n#endif\n";THREE.ShaderChunk.lights_phong_vertex="#ifdef USE_ENVMAP\n\tvWorldPosition = worldPosition.xyz;\n#endif\n";THREE.ShaderChunk.lights_standard_fragment="StandardMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\nmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n";
-THREE.ShaderChunk.lights_standard_pars_fragment="struct StandardMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n};\nvoid RE_Direct_Standard( const in IncidentLight directLight, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * PI * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n}\nvoid RE_IndirectDiffuse_Standard( const in vec3 irradiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Standard( const in vec3 radiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectSpecular += radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Standard\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Standard\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Standard\n#define Material_BlinnShininessExponent( material )   GGXRoughnessToBlinnExponent( material.specularRoughness )\n";
-THREE.ShaderChunk.lights_template="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tdirectLight = getPointDirectLight( pointLight, geometry );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tdirectLight = getSpotDirectLight( spotLight, geometry );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tdirectLight = getDirectionalDirectLight( directionalLight, geometry );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tirradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\tRE_IndirectSpecular( radiance, geometry, material, reflectedLight );\n#endif\n";
-THREE.ShaderChunk.linear_to_gamma_fragment="\n\toutgoingLight = linearToOutput( outgoingLight );\n";THREE.ShaderChunk.logdepthbuf_fragment="#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif";THREE.ShaderChunk.logdepthbuf_pars_fragment="#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n";THREE.ShaderChunk.logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif";
-THREE.ShaderChunk.logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n";THREE.ShaderChunk.map_fragment="#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor.xyz = inputToLinear( texelColor.xyz );\n\tdiffuseColor *= texelColor;\n#endif\n";
-THREE.ShaderChunk.map_pars_fragment="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif";THREE.ShaderChunk.map_particle_fragment="#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n#endif\n";THREE.ShaderChunk.map_particle_pars_fragment="#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n";THREE.ShaderChunk.metalnessmap_fragment="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n";
-THREE.ShaderChunk.metalnessmap_pars_fragment="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";THREE.ShaderChunk.morphnormal_vertex="#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n";
-THREE.ShaderChunk.morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif";THREE.ShaderChunk.morphtarget_vertex="#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n";
-THREE.ShaderChunk.normal_fragment="#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n\t#endif\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n";
-THREE.ShaderChunk.normalmap_pars_fragment="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n";
-THREE.ShaderChunk.project_vertex="#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n";THREE.ShaderChunk.roughnessmap_fragment="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n";THREE.ShaderChunk.roughnessmap_pars_fragment="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
-THREE.ShaderChunk.shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat unpackDepth( const in vec4 rgba_depth ) {\n\t\tconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n\t\treturn dot( rgba_depth, bit_shift );\n\t}\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n";
-THREE.ShaderChunk.shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n";
-THREE.ShaderChunk.shadowmap_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n";
-THREE.ShaderChunk.shadowmask_pars_fragment="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n";
-THREE.ShaderChunk.skinbase_vertex="#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";THREE.ShaderChunk.skinning_pars_vertex="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneGlobalMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
-THREE.ShaderChunk.skinning_vertex="#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned  = bindMatrixInverse * skinned;\n#endif\n";THREE.ShaderChunk.skinnormal_vertex="#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix  = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n";
-THREE.ShaderChunk.specularmap_fragment="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif";THREE.ShaderChunk.specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif";THREE.ShaderChunk.uv2_pars_fragment="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif";THREE.ShaderChunk.uv2_pars_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif";
-THREE.ShaderChunk.uv2_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif";THREE.ShaderChunk.uv_pars_fragment="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif";THREE.ShaderChunk.uv_pars_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n";
-THREE.ShaderChunk.uv_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif";THREE.ShaderChunk.worldpos_vertex="#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( STANDARD ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n";
-THREE.UniformsUtils={merge:function(a){for(var b={},c=0;c<a.length;c++){var d=this.clone(a[c]),e;for(e in d)b[e]=d[e]}return b},clone:function(a){var b={},c;for(c in a){b[c]={};for(var d in a[c]){var e=a[c][d];e instanceof THREE.Color||e instanceof THREE.Vector2||e instanceof THREE.Vector3||e instanceof THREE.Vector4||e instanceof THREE.Matrix3||e instanceof THREE.Matrix4||e instanceof THREE.Texture?b[c][d]=e.clone():Array.isArray(e)?b[c][d]=e.slice():b[c][d]=e}}return b}};
-THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},specularMap:{type:"t",value:null},alphaMap:{type:"t",value:null},envMap:{type:"t",value:null},flipEnvMap:{type:"f",value:-1},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:.98}},aomap:{aoMap:{type:"t",value:null},aoMapIntensity:{type:"f",value:1}},lightmap:{lightMap:{type:"t",value:null},lightMapIntensity:{type:"f",
-value:1}},emissivemap:{emissiveMap:{type:"t",value:null}},bumpmap:{bumpMap:{type:"t",value:null},bumpScale:{type:"f",value:1}},normalmap:{normalMap:{type:"t",value:null},normalScale:{type:"v2",value:new THREE.Vector2(1,1)}},displacementmap:{displacementMap:{type:"t",value:null},displacementScale:{type:"f",value:1},displacementBias:{type:"f",value:0}},roughnessmap:{roughnessMap:{type:"t",value:null}},metalnessmap:{metalnessMap:{type:"t",value:null}},fog:{fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",
-value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},ambient:{ambientLightColor:{type:"fv",value:[]}},lights:{directionalLights:{type:"sa",value:[],properties:{direction:{type:"v3"},color:{type:"c"},shadow:{type:"i"},shadowBias:{type:"f"},shadowRadius:{type:"f"},shadowMapSize:{type:"v2"}}},directionalShadowMap:{type:"tv",value:[]},directionalShadowMatrix:{type:"m4v",value:[]},spotLights:{type:"sa",value:[],properties:{color:{type:"c"},position:{type:"v3"},direction:{type:"v3"},
-distance:{type:"f"},angleCos:{type:"f"},penumbra:{type:"f"},decay:{type:"f"},shadow:{type:"i"},shadowBias:{type:"f"},shadowRadius:{type:"f"},shadowMapSize:{type:"v2"}}},spotShadowMap:{type:"tv",value:[]},spotShadowMatrix:{type:"m4v",value:[]},pointLights:{type:"sa",value:[],properties:{color:{type:"c"},position:{type:"v3"},decay:{type:"f"},distance:{type:"f"},shadow:{type:"i"},shadowBias:{type:"f"},shadowRadius:{type:"f"},shadowMapSize:{type:"v2"}}},pointShadowMap:{type:"tv",value:[]},pointShadowMatrix:{type:"m4v",
-value:[]},hemisphereLights:{type:"sa",value:[],properties:{direction:{type:"v3"},skyColor:{type:"c"},groundColor:{type:"c"}}}},points:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)}}};
-THREE.ShaderLib={basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.aomap,THREE.UniformsLib.fog]),vertexShader:[THREE.ShaderChunk.common,THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.uv2_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.uv2_vertex,
-THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinbase_vertex,"\t#ifdef USE_ENVMAP",THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,"\t#endif",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,"}"].join("\n"),
-fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.uv2_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.aomap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,
-"void main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,"\tReflectedLight reflectedLight;\n\treflectedLight.directDiffuse = vec3( 0.0 );\n\treflectedLight.directSpecular = vec3( 0.0 );\n\treflectedLight.indirectDiffuse = diffuseColor.rgb;\n\treflectedLight.indirectSpecular = vec3( 0.0 );",
-THREE.ShaderChunk.aomap_fragment,"\tvec3 outgoingLight = reflectedLight.indirectDiffuse;",THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.aomap,THREE.UniformsLib.lightmap,THREE.UniformsLib.emissivemap,THREE.UniformsLib.fog,THREE.UniformsLib.ambient,THREE.UniformsLib.lights,{emissive:{type:"c",
-value:new THREE.Color(0)}}]),vertexShader:["#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.uv2_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.bsdfs,THREE.ShaderChunk.lights_pars,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,
-"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.uv2_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,
-THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.uv2_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.aomap_pars_fragment,
-THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.emissivemap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.bsdfs,THREE.ShaderChunk.ambient_pars,THREE.ShaderChunk.lights_pars,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.shadowmask_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveLight = emissive;",
-THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.emissivemap_fragment,"\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );",THREE.ShaderChunk.lightmap_fragment,"\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();",
-THREE.ShaderChunk.aomap_fragment,"\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveLight;",THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.aomap,THREE.UniformsLib.lightmap,THREE.UniformsLib.emissivemap,THREE.UniformsLib.bumpmap,THREE.UniformsLib.normalmap,
-THREE.UniformsLib.displacementmap,THREE.UniformsLib.fog,THREE.UniformsLib.ambient,THREE.UniformsLib.lights,{emissive:{type:"c",value:new THREE.Color(0)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),vertexShader:["#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.uv2_pars_vertex,THREE.ShaderChunk.displacementmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,
-THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.uv2_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,
-"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.displacementmap_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"\tvViewPosition = - mvPosition.xyz;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;",
-THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.uv2_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.aomap_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.emissivemap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.bsdfs,THREE.ShaderChunk.ambient_pars,THREE.ShaderChunk.lights_pars,THREE.ShaderChunk.lights_phong_pars_fragment,
-THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.bumpmap_pars_fragment,THREE.ShaderChunk.normalmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveLight = emissive;",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.color_fragment,
-THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.normal_fragment,THREE.ShaderChunk.emissivemap_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lights_template,THREE.ShaderChunk.aomap_fragment,"vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,
-THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},standard:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.aomap,THREE.UniformsLib.lightmap,THREE.UniformsLib.emissivemap,THREE.UniformsLib.bumpmap,THREE.UniformsLib.normalmap,THREE.UniformsLib.displacementmap,THREE.UniformsLib.roughnessmap,THREE.UniformsLib.metalnessmap,THREE.UniformsLib.fog,THREE.UniformsLib.ambient,THREE.UniformsLib.lights,{emissive:{type:"c",value:new THREE.Color(0)},
-roughness:{type:"f",value:.5},metalness:{type:"f",value:0},envMapIntensity:{type:"f",value:1}}]),vertexShader:["#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.uv2_pars_vertex,THREE.ShaderChunk.displacementmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,
-THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.uv2_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif",THREE.ShaderChunk.begin_vertex,
-THREE.ShaderChunk.displacementmap_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"\tvViewPosition = - mvPosition.xyz;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["#define STANDARD\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif",
-THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.uv2_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.aomap_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.emissivemap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.bsdfs,THREE.ShaderChunk.ambient_pars,THREE.ShaderChunk.lights_pars,THREE.ShaderChunk.lights_standard_pars_fragment,
-THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.bumpmap_pars_fragment,THREE.ShaderChunk.normalmap_pars_fragment,THREE.ShaderChunk.roughnessmap_pars_fragment,THREE.ShaderChunk.metalnessmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveLight = emissive;",THREE.ShaderChunk.logdepthbuf_fragment,
-THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.roughnessmap_fragment,THREE.ShaderChunk.metalnessmap_fragment,THREE.ShaderChunk.normal_fragment,THREE.ShaderChunk.emissivemap_fragment,THREE.ShaderChunk.lights_standard_fragment,THREE.ShaderChunk.lights_template,THREE.ShaderChunk.aomap_fragment,"vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",
-THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},points:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.points,THREE.UniformsLib.fog]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.begin_vertex,
-THREE.ShaderChunk.project_vertex,"\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif",THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,
-THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.alphatest_fragment,"\toutgoingLight = diffuseColor.rgb;",THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},dashed:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,
-THREE.UniformsLib.fog,{scale:{type:"f",value:1},dashSize:{type:"f",value:1},totalSize:{type:"f",value:2}}]),vertexShader:["uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;",
-THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );",
-THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.color_fragment,"\toutgoingLight = diffuseColor.rgb;",THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},vertexShader:[THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,
-THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float mNear;\nuniform float mFar;\nuniform float opacity;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {",THREE.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\tfloat color = 1.0 - smoothstep( mNear, mFar, depth );\n\tgl_FragColor = vec4( vec3( color ), opacity );\n}"].join("\n")},
-normal:{uniforms:{opacity:{type:"f",value:1}},vertexShader:["varying vec3 vNormal;",THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vNormal;",THREE.ShaderChunk.common,
-THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
-THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},equirect:{uniforms:{tEquirect:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;",
-THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\nvec3 direction = normalize( vWorldPosition );\nvec2 sampleUV;\nsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\nsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\ngl_FragColor = texture2D( tEquirect, sampleUV );",
-THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:[THREE.ShaderChunk.common,
-THREE.ShaderChunk.logdepthbuf_pars_fragment,"vec4 pack_depth( const in float depth ) {\n\tconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n\tconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n\tvec4 res = mod( depth * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\nvoid main() {",THREE.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tgl_FragData[ 0 ] = pack_depth( gl_FragDepthEXT );\n\t#else\n\t\tgl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n\t#endif\n}"].join("\n")},
-distanceRGBA:{uniforms:{lightPos:{type:"v3",value:new THREE.Vector3(0,0,0)}},vertexShader:["varying vec4 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.worldpos_vertex,"vWorldPosition = worldPosition;\n}"].join("\n"),fragmentShader:["uniform vec3 lightPos;\nvarying vec4 vWorldPosition;",
-THREE.ShaderChunk.common,"vec4 pack1K ( float depth ) {\n\tdepth /= 1000.0;\n\tconst vec4 bitSh = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n\tconst vec4 bitMsk = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n\tvec4 res = mod( depth * bitSh * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n\tres -= res.xxyz * bitMsk;\n\treturn res; \n}\nfloat unpack1K ( vec4 color ) {\n\tconst vec4 bitSh = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n\treturn dot( color, bitSh ) * 1000.0;\n}\nvoid main () {\n\tgl_FragColor = pack1K( length( vWorldPosition.xyz - lightPos.xyz ) );\n}"].join("\n")}};
-THREE.WebGLRenderer=function(a){function b(a,b,c,d){!0===Q&&(a*=d,b*=d,c*=d);I.clearColor(a,b,c,d)}function c(){I.init();I.scissor(qa.copy(xa).multiplyScalar(Z));I.viewport(ja.copy(ka).multiplyScalar(Z));b($.r,$.g,$.b,fa)}function d(){la=ma=null;na="";ra=-1;I.reset()}function e(a){a.preventDefault();d();c();T.clear()}function f(a){a=a.target;a.removeEventListener("dispose",f);a:{var b=T.get(a);if(a.image&&b.__image__webglTextureCube)r.deleteTexture(b.__image__webglTextureCube);else{if(void 0===b.__webglInit)break a;
-r.deleteTexture(b.__webglTexture)}T.delete(a)}ga.textures--}function g(a){a=a.target;a.removeEventListener("dispose",g);var b=T.get(a),c=T.get(a.texture);if(a&&void 0!==c.__webglTexture){r.deleteTexture(c.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(c=0;6>c;c++)r.deleteFramebuffer(b.__webglFramebuffer[c]),r.deleteRenderbuffer(b.__webglDepthbuffer[c]);else r.deleteFramebuffer(b.__webglFramebuffer),r.deleteRenderbuffer(b.__webglDepthbuffer);T.delete(a.texture);T.delete(a)}ga.textures--}
-function h(a){a=a.target;a.removeEventListener("dispose",h);k(a);T.delete(a)}function k(a){var b=T.get(a).program;a.program=void 0;void 0!==b&&oa.releaseProgram(b)}function l(a,b){return Math.abs(b[0])-Math.abs(a[0])}function n(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function p(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:
-a.z!==b.z?b.z-a.z:a.id-b.id}function m(a,b,c,d,e){var f;c.transparent?(d=Y,f=++V):(d=J,f=++F);f=d[f];void 0!==f?(f.id=a.id,f.object=a,f.geometry=b,f.material=c,f.z=W.z,f.group=e):(f={id:a.id,object:a,geometry:b,material:c,z:W.z,group:e},d.push(f))}function q(a,b){if(!1!==a.visible){if(a.layers.test(b.layers))if(a instanceof THREE.Light)S.push(a);else if(a instanceof THREE.Sprite)!1!==a.frustumCulled&&!0!==ya.intersectsObject(a)||ca.push(a);else if(a instanceof THREE.LensFlare)ha.push(a);else if(a instanceof
-THREE.ImmediateRenderObject)!0===X.sortObjects&&(W.setFromMatrixPosition(a.matrixWorld),W.applyProjection(sa)),m(a,null,a.material,W.z,null);else if(a instanceof THREE.Mesh||a instanceof THREE.Line||a instanceof THREE.Points)if(a instanceof THREE.SkinnedMesh&&a.skeleton.update(),!1===a.frustumCulled||!0===ya.intersectsObject(a)){var c=a.material;if(!0===c.visible){!0===X.sortObjects&&(W.setFromMatrixPosition(a.matrixWorld),W.applyProjection(sa));var d=pa.update(a);if(c instanceof THREE.MultiMaterial)for(var e=
-d.groups,f=c.materials,c=0,g=e.length;c<g;c++){var h=e[c],k=f[h.materialIndex];!0===k.visible&&m(a,d,k,W.z,h)}else m(a,d,c,W.z,null)}}d=a.children;c=0;for(g=d.length;c<g;c++)q(d[c],b)}}function s(a,b,c,d){for(var e=0,f=a.length;e<f;e++){var g=a[e],h=g.object,k=g.geometry,l=void 0===d?g.material:d,g=g.group;h.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,h.matrixWorld);h.normalMatrix.getNormalMatrix(h.modelViewMatrix);if(h instanceof THREE.ImmediateRenderObject){u(l);var m=t(b,c,l,h);na="";
-h.render(function(a){X.renderBufferImmediate(a,m,l)})}else X.renderBufferDirect(b,c,k,l,h,g)}}function u(a){a.side!==THREE.DoubleSide?I.enable(r.CULL_FACE):I.disable(r.CULL_FACE);I.setFlipSided(a.side===THREE.BackSide);!0===a.transparent?I.setBlending(a.blending,a.blendEquation,a.blendSrc,a.blendDst,a.blendEquationAlpha,a.blendSrcAlpha,a.blendDstAlpha):I.setBlending(THREE.NoBlending);I.setDepthFunc(a.depthFunc);I.setDepthTest(a.depthTest);I.setDepthWrite(a.depthWrite);I.setColorWrite(a.colorWrite);
-I.setPolygonOffset(a.polygonOffset,a.polygonOffsetFactor,a.polygonOffsetUnits)}function t(a,b,c,d){ta=0;var e=T.get(c);void 0===e.program&&(c.needsUpdate=!0);void 0!==e.lightsHash&&e.lightsHash!==R.hash&&(c.needsUpdate=!0);if(c.needsUpdate){a:{var f=T.get(c),g=oa.getParameters(c,R,b,d),l=oa.getProgramCode(c,g),m=f.program,n=!0;if(void 0===m)c.addEventListener("dispose",h);else if(m.code!==l)k(c);else if(void 0!==g.shaderID)break a;else n=!1;n&&(g.shaderID?(m=THREE.ShaderLib[g.shaderID],f.__webglShader=
-{name:c.type,uniforms:THREE.UniformsUtils.clone(m.uniforms),vertexShader:m.vertexShader,fragmentShader:m.fragmentShader}):f.__webglShader={name:c.type,uniforms:c.uniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader},c.__webglShader=f.__webglShader,m=oa.acquireProgram(c,g,l),f.program=m,c.program=m);g=m.getAttributes();if(c.morphTargets)for(l=c.numSupportedMorphTargets=0;l<X.maxMorphTargets;l++)0<=g["morphTarget"+l]&&c.numSupportedMorphTargets++;if(c.morphNormals)for(l=c.numSupportedMorphNormals=
-0;l<X.maxMorphNormals;l++)0<=g["morphNormal"+l]&&c.numSupportedMorphNormals++;f.uniformsList=[];var g=f.__webglShader.uniforms,l=f.program.getUniforms(),q;for(q in g)(m=l[q])&&f.uniformsList.push([f.__webglShader.uniforms[q],m]);if(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshStandardMaterial||c.lights)f.lightsHash=R.hash,g.ambientLightColor.value=R.ambient,g.directionalLights.value=R.directional,g.spotLights.value=R.spot,g.pointLights.value=
-R.point,g.hemisphereLights.value=R.hemi,g.directionalShadowMap.value=R.directionalShadowMap,g.directionalShadowMatrix.value=R.directionalShadowMatrix,g.spotShadowMap.value=R.spotShadowMap,g.spotShadowMatrix.value=R.spotShadowMatrix,g.pointShadowMap.value=R.pointShadowMap,g.pointShadowMatrix.value=R.pointShadowMatrix;f.hasDynamicUniforms=!1;q=0;for(g=f.uniformsList.length;q<g;q++)if(!0===f.uniformsList[q][0].dynamic){f.hasDynamicUniforms=!0;break}}c.needsUpdate=!1}m=l=n=!1;f=e.program;q=f.getUniforms();
-g=e.__webglShader.uniforms;f.id!==ma&&(r.useProgram(f.program),ma=f.id,m=l=n=!0);c.id!==ra&&(ra=c.id,l=!0);if(n||a!==la)r.uniformMatrix4fv(q.projectionMatrix,!1,a.projectionMatrix.elements),da.logarithmicDepthBuffer&&r.uniform1f(q.logDepthBufFC,2/(Math.log(a.far+1)/Math.LN2)),a!==la&&(la=a,m=l=!0),(c instanceof THREE.ShaderMaterial||c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshStandardMaterial||c.envMap)&&void 0!==q.cameraPosition&&(W.setFromMatrixPosition(a.matrixWorld),r.uniform3f(q.cameraPosition,
-W.x,W.y,W.z)),(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshBasicMaterial||c instanceof THREE.MeshStandardMaterial||c instanceof THREE.ShaderMaterial||c.skinning)&&void 0!==q.viewMatrix&&r.uniformMatrix4fv(q.viewMatrix,!1,a.matrixWorldInverse.elements);c.skinning&&(d.bindMatrix&&void 0!==q.bindMatrix&&r.uniformMatrix4fv(q.bindMatrix,!1,d.bindMatrix.elements),d.bindMatrixInverse&&void 0!==q.bindMatrixInverse&&r.uniformMatrix4fv(q.bindMatrixInverse,
-!1,d.bindMatrixInverse.elements),da.floatVertexTextures&&d.skeleton&&d.skeleton.useVertexTexture?(void 0!==q.boneTexture&&(n=x(),r.uniform1i(q.boneTexture,n),X.setTexture(d.skeleton.boneTexture,n)),void 0!==q.boneTextureWidth&&r.uniform1i(q.boneTextureWidth,d.skeleton.boneTextureWidth),void 0!==q.boneTextureHeight&&r.uniform1i(q.boneTextureHeight,d.skeleton.boneTextureHeight)):d.skeleton&&d.skeleton.boneMatrices&&void 0!==q.boneGlobalMatrices&&r.uniformMatrix4fv(q.boneGlobalMatrices,!1,d.skeleton.boneMatrices));
-if(l){if(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshStandardMaterial||c.lights)l=m,g.ambientLightColor.needsUpdate=l,g.directionalLights.needsUpdate=l,g.pointLights.needsUpdate=l,g.spotLights.needsUpdate=l,g.hemisphereLights.needsUpdate=l;b&&c.fog&&(g.fogColor.value=b.color,b instanceof THREE.Fog?(g.fogNear.value=b.near,g.fogFar.value=b.far):b instanceof THREE.FogExp2&&(g.fogDensity.value=b.density));if(c instanceof THREE.MeshBasicMaterial||
-c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshStandardMaterial){g.opacity.value=c.opacity;g.diffuse.value=c.color;c.emissive&&g.emissive.value.copy(c.emissive).multiplyScalar(c.emissiveIntensity);g.map.value=c.map;g.specularMap.value=c.specularMap;g.alphaMap.value=c.alphaMap;c.aoMap&&(g.aoMap.value=c.aoMap,g.aoMapIntensity.value=c.aoMapIntensity);var p;c.map?p=c.map:c.specularMap?p=c.specularMap:c.displacementMap?p=c.displacementMap:c.normalMap?
-p=c.normalMap:c.bumpMap?p=c.bumpMap:c.roughnessMap?p=c.roughnessMap:c.metalnessMap?p=c.metalnessMap:c.alphaMap?p=c.alphaMap:c.emissiveMap&&(p=c.emissiveMap);void 0!==p&&(p instanceof THREE.WebGLRenderTarget&&(p=p.texture),b=p.offset,p=p.repeat,g.offsetRepeat.value.set(b.x,b.y,p.x,p.y));g.envMap.value=c.envMap;g.flipEnvMap.value=c.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;g.reflectivity.value=c.reflectivity;g.refractionRatio.value=c.refractionRatio}c instanceof THREE.LineBasicMaterial?(g.diffuse.value=
-c.color,g.opacity.value=c.opacity):c instanceof THREE.LineDashedMaterial?(g.diffuse.value=c.color,g.opacity.value=c.opacity,g.dashSize.value=c.dashSize,g.totalSize.value=c.dashSize+c.gapSize,g.scale.value=c.scale):c instanceof THREE.PointsMaterial?(g.diffuse.value=c.color,g.opacity.value=c.opacity,g.size.value=c.size*Z,g.scale.value=K.clientHeight/2,g.map.value=c.map,null!==c.map&&(p=c.map.offset,c=c.map.repeat,g.offsetRepeat.value.set(p.x,p.y,c.x,c.y))):c instanceof THREE.MeshLambertMaterial?(c.lightMap&&
-(g.lightMap.value=c.lightMap,g.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(g.emissiveMap.value=c.emissiveMap)):c instanceof THREE.MeshPhongMaterial?(g.specular.value=c.specular,g.shininess.value=Math.max(c.shininess,1E-4),c.lightMap&&(g.lightMap.value=c.lightMap,g.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(g.emissiveMap.value=c.emissiveMap),c.bumpMap&&(g.bumpMap.value=c.bumpMap,g.bumpScale.value=c.bumpScale),c.normalMap&&(g.normalMap.value=c.normalMap,g.normalScale.value.copy(c.normalScale)),
-c.displacementMap&&(g.displacementMap.value=c.displacementMap,g.displacementScale.value=c.displacementScale,g.displacementBias.value=c.displacementBias)):c instanceof THREE.MeshStandardMaterial?(g.roughness.value=c.roughness,g.metalness.value=c.metalness,c.roughnessMap&&(g.roughnessMap.value=c.roughnessMap),c.metalnessMap&&(g.metalnessMap.value=c.metalnessMap),c.lightMap&&(g.lightMap.value=c.lightMap,g.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(g.emissiveMap.value=c.emissiveMap),
-c.bumpMap&&(g.bumpMap.value=c.bumpMap,g.bumpScale.value=c.bumpScale),c.normalMap&&(g.normalMap.value=c.normalMap,g.normalScale.value.copy(c.normalScale)),c.displacementMap&&(g.displacementMap.value=c.displacementMap,g.displacementScale.value=c.displacementScale,g.displacementBias.value=c.displacementBias),c.envMap&&(g.envMapIntensity.value=c.envMapIntensity)):c instanceof THREE.MeshDepthMaterial?(g.mNear.value=a.near,g.mFar.value=a.far,g.opacity.value=c.opacity):c instanceof THREE.MeshNormalMaterial&&
-(g.opacity.value=c.opacity);v(e.uniformsList)}r.uniformMatrix4fv(q.modelViewMatrix,!1,d.modelViewMatrix.elements);q.normalMatrix&&r.uniformMatrix3fv(q.normalMatrix,!1,d.normalMatrix.elements);void 0!==q.modelMatrix&&r.uniformMatrix4fv(q.modelMatrix,!1,d.matrixWorld.elements);if(!0===e.hasDynamicUniforms){e=e.uniformsList;c=[];p=0;for(b=e.length;p<b;p++)q=e[p][0],g=q.onUpdateCallback,void 0!==g&&(g.bind(q)(d,a),c.push(e[p]));v(c)}return f}function x(){var a=ta;a>=da.maxTextures&&console.warn("WebGLRenderer: trying to use "+
-a+" texture units while this GPU supports only "+da.maxTextures);ta+=1;return a}function v(a){for(var b,c,d=0,e=a.length;d<e;d++){var g=a[d][0];if(!1!==g.needsUpdate){var f=g.type;b=g.value;var h=a[d][1];switch(f){case "1i":r.uniform1i(h,b);break;case "1f":r.uniform1f(h,b);break;case "2f":r.uniform2f(h,b[0],b[1]);break;case "3f":r.uniform3f(h,b[0],b[1],b[2]);break;case "4f":r.uniform4f(h,b[0],b[1],b[2],b[3]);break;case "1iv":r.uniform1iv(h,b);break;case "3iv":r.uniform3iv(h,b);break;case "1fv":r.uniform1fv(h,
-b);break;case "2fv":r.uniform2fv(h,b);break;case "3fv":r.uniform3fv(h,b);break;case "4fv":r.uniform4fv(h,b);break;case "Matrix2fv":r.uniformMatrix2fv(h,!1,b);break;case "Matrix3fv":r.uniformMatrix3fv(h,!1,b);break;case "Matrix4fv":r.uniformMatrix4fv(h,!1,b);break;case "i":r.uniform1i(h,b);break;case "f":r.uniform1f(h,b);break;case "v2":r.uniform2f(h,b.x,b.y);break;case "v3":r.uniform3f(h,b.x,b.y,b.z);break;case "v4":r.uniform4f(h,b.x,b.y,b.z,b.w);break;case "c":r.uniform3f(h,b.r,b.g,b.b);break;case "sa":for(f=
-0;f<b.length;f++)for(var k in g.properties){var l=h[f][k];c=b[f][k];switch(g.properties[k].type){case "i":r.uniform1i(l,c);break;case "f":r.uniform1f(l,c);break;case "v2":r.uniform2f(l,c.x,c.y);break;case "v3":r.uniform3f(l,c.x,c.y,c.z);break;case "v4":r.uniform4f(l,c.x,c.y,c.z,c.w);break;case "c":r.uniform3f(l,c.r,c.g,c.b);break;case "m4":r.uniformMatrix4fv(l,!1,c.elements)}}break;case "iv1":r.uniform1iv(h,b);break;case "iv":r.uniform3iv(h,b);break;case "fv1":r.uniform1fv(h,b);break;case "fv":r.uniform3fv(h,
-b);break;case "v2v":void 0===g._array&&(g._array=new Float32Array(2*b.length));c=f=0;for(l=b.length;f<l;f++,c+=2)g._array[c+0]=b[f].x,g._array[c+1]=b[f].y;r.uniform2fv(h,g._array);break;case "v3v":void 0===g._array&&(g._array=new Float32Array(3*b.length));c=f=0;for(l=b.length;f<l;f++,c+=3)g._array[c+0]=b[f].x,g._array[c+1]=b[f].y,g._array[c+2]=b[f].z;r.uniform3fv(h,g._array);break;case "v4v":void 0===g._array&&(g._array=new Float32Array(4*b.length));c=f=0;for(l=b.length;f<l;f++,c+=4)g._array[c+0]=
-b[f].x,g._array[c+1]=b[f].y,g._array[c+2]=b[f].z,g._array[c+3]=b[f].w;r.uniform4fv(h,g._array);break;case "m2":r.uniformMatrix2fv(h,!1,b.elements);break;case "m3":r.uniformMatrix3fv(h,!1,b.elements);break;case "m3v":void 0===g._array&&(g._array=new Float32Array(9*b.length));f=0;for(l=b.length;f<l;f++)b[f].flattenToArrayOffset(g._array,9*f);r.uniformMatrix3fv(h,!1,g._array);break;case "m4":r.uniformMatrix4fv(h,!1,b.elements);break;case "m4v":void 0===g._array&&(g._array=new Float32Array(16*b.length));
-f=0;for(l=b.length;f<l;f++)b[f].flattenToArrayOffset(g._array,16*f);r.uniformMatrix4fv(h,!1,g._array);break;case "t":c=x();r.uniform1i(h,c);if(!b)continue;b instanceof THREE.CubeTexture||Array.isArray(b.image)&&6===b.image.length?z(b,c):b instanceof THREE.WebGLRenderTargetCube?y(b.texture,c):b instanceof THREE.WebGLRenderTarget?X.setTexture(b.texture,c):X.setTexture(b,c);break;case "tv":void 0===g._array&&(g._array=[]);f=0;for(l=g.value.length;f<l;f++)g._array[f]=x();r.uniform1iv(h,g._array);f=0;
-for(l=g.value.length;f<l;f++)b=g.value[f],c=g._array[f],b&&(b instanceof THREE.CubeTexture||b.image instanceof Array&&6===b.image.length?z(b,c):b instanceof THREE.WebGLRenderTarget?X.setTexture(b.texture,c):b instanceof THREE.WebGLRenderTargetCube?y(b.texture,c):X.setTexture(b,c));break;default:console.warn("THREE.WebGLRenderer: Unknown uniform type: "+f)}}}}function C(a,b,c){c?(r.texParameteri(a,r.TEXTURE_WRAP_S,E(b.wrapS)),r.texParameteri(a,r.TEXTURE_WRAP_T,E(b.wrapT)),r.texParameteri(a,r.TEXTURE_MAG_FILTER,
-E(b.magFilter)),r.texParameteri(a,r.TEXTURE_MIN_FILTER,E(b.minFilter))):(r.texParameteri(a,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(a,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),b.wrapS===THREE.ClampToEdgeWrapping&&b.wrapT===THREE.ClampToEdgeWrapping||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",b),r.texParameteri(a,r.TEXTURE_MAG_FILTER,G(b.magFilter)),r.texParameteri(a,r.TEXTURE_MIN_FILTER,G(b.minFilter)),
-b.minFilter!==THREE.NearestFilter&&b.minFilter!==THREE.LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",b));!(c=U.get("EXT_texture_filter_anisotropic"))||b.type===THREE.FloatType&&null===U.get("OES_texture_float_linear")||b.type===THREE.HalfFloatType&&null===U.get("OES_texture_half_float_linear")||!(1<b.anisotropy||T.get(b).__currentAnisotropy)||(r.texParameterf(a,c.TEXTURE_MAX_ANISOTROPY_EXT,
-Math.min(b.anisotropy,X.getMaxAnisotropy())),T.get(b).__currentAnisotropy=b.anisotropy)}function w(a,b){if(a.width>b||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElement("canvas");d.width=Math.floor(a.width*c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a}function D(a){return THREE.Math.isPowerOfTwo(a.width)&&
-THREE.Math.isPowerOfTwo(a.height)}function z(a,b){var c=T.get(a);if(6===a.image.length)if(0<a.version&&c.__version!==a.version){c.__image__webglTextureCube||(a.addEventListener("dispose",f),c.__image__webglTextureCube=r.createTexture(),ga.textures++);I.activeTexture(r.TEXTURE0+b);I.bindTexture(r.TEXTURE_CUBE_MAP,c.__image__webglTextureCube);r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,a.flipY);for(var d=a instanceof THREE.CompressedTexture,e=a.image[0]instanceof THREE.DataTexture,g=[],h=0;6>h;h++)g[h]=!X.autoScaleCubemaps||
-d||e?e?a.image[h].image:a.image[h]:w(a.image[h],da.maxCubemapSize);var k=D(g[0]),l=E(a.format),m=E(a.type);C(r.TEXTURE_CUBE_MAP,a,k);for(h=0;6>h;h++)if(d)for(var n,q=g[h].mipmaps,p=0,s=q.length;p<s;p++)n=q[p],a.format!==THREE.RGBAFormat&&a.format!==THREE.RGBFormat?-1<I.getCompressedTextureFormats().indexOf(l)?I.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,p,l,n.width,n.height,0,n.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setCubeTexture()"):
-I.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,p,l,n.width,n.height,0,l,m,n.data);else e?I.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,l,g[h].width,g[h].height,0,l,m,g[h].data):I.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,l,l,m,g[h]);a.generateMipmaps&&k&&r.generateMipmap(r.TEXTURE_CUBE_MAP);c.__version=a.version;if(a.onUpdate)a.onUpdate(a)}else I.activeTexture(r.TEXTURE0+b),I.bindTexture(r.TEXTURE_CUBE_MAP,c.__image__webglTextureCube)}function y(a,b){I.activeTexture(r.TEXTURE0+b);I.bindTexture(r.TEXTURE_CUBE_MAP,
-T.get(a).__webglTexture)}function A(a,b,c,d){var e=E(b.texture.format),g=E(b.texture.type);I.texImage2D(d,0,e,b.width,b.height,0,e,g,null);r.bindFramebuffer(r.FRAMEBUFFER,a);r.framebufferTexture2D(r.FRAMEBUFFER,c,d,T.get(b.texture).__webglTexture,0);r.bindFramebuffer(r.FRAMEBUFFER,null)}function H(a,b){r.bindRenderbuffer(r.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,b.width,b.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,
-r.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,b.width,b.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)):r.renderbufferStorage(r.RENDERBUFFER,r.RGBA4,b.width,b.height);r.bindRenderbuffer(r.RENDERBUFFER,null)}function G(a){return a===THREE.NearestFilter||a===THREE.NearestMipMapNearestFilter||a===THREE.NearestMipMapLinearFilter?r.NEAREST:r.LINEAR}function E(a){var b;if(a===THREE.RepeatWrapping)return r.REPEAT;
-if(a===THREE.ClampToEdgeWrapping)return r.CLAMP_TO_EDGE;if(a===THREE.MirroredRepeatWrapping)return r.MIRRORED_REPEAT;if(a===THREE.NearestFilter)return r.NEAREST;if(a===THREE.NearestMipMapNearestFilter)return r.NEAREST_MIPMAP_NEAREST;if(a===THREE.NearestMipMapLinearFilter)return r.NEAREST_MIPMAP_LINEAR;if(a===THREE.LinearFilter)return r.LINEAR;if(a===THREE.LinearMipMapNearestFilter)return r.LINEAR_MIPMAP_NEAREST;if(a===THREE.LinearMipMapLinearFilter)return r.LINEAR_MIPMAP_LINEAR;if(a===THREE.UnsignedByteType)return r.UNSIGNED_BYTE;
-if(a===THREE.UnsignedShort4444Type)return r.UNSIGNED_SHORT_4_4_4_4;if(a===THREE.UnsignedShort5551Type)return r.UNSIGNED_SHORT_5_5_5_1;if(a===THREE.UnsignedShort565Type)return r.UNSIGNED_SHORT_5_6_5;if(a===THREE.ByteType)return r.BYTE;if(a===THREE.ShortType)return r.SHORT;if(a===THREE.UnsignedShortType)return r.UNSIGNED_SHORT;if(a===THREE.IntType)return r.INT;if(a===THREE.UnsignedIntType)return r.UNSIGNED_INT;if(a===THREE.FloatType)return r.FLOAT;b=U.get("OES_texture_half_float");if(null!==b&&a===
-THREE.HalfFloatType)return b.HALF_FLOAT_OES;if(a===THREE.AlphaFormat)return r.ALPHA;if(a===THREE.RGBFormat)return r.RGB;if(a===THREE.RGBAFormat)return r.RGBA;if(a===THREE.LuminanceFormat)return r.LUMINANCE;if(a===THREE.LuminanceAlphaFormat)return r.LUMINANCE_ALPHA;if(a===THREE.AddEquation)return r.FUNC_ADD;if(a===THREE.SubtractEquation)return r.FUNC_SUBTRACT;if(a===THREE.ReverseSubtractEquation)return r.FUNC_REVERSE_SUBTRACT;if(a===THREE.ZeroFactor)return r.ZERO;if(a===THREE.OneFactor)return r.ONE;
-if(a===THREE.SrcColorFactor)return r.SRC_COLOR;if(a===THREE.OneMinusSrcColorFactor)return r.ONE_MINUS_SRC_COLOR;if(a===THREE.SrcAlphaFactor)return r.SRC_ALPHA;if(a===THREE.OneMinusSrcAlphaFactor)return r.ONE_MINUS_SRC_ALPHA;if(a===THREE.DstAlphaFactor)return r.DST_ALPHA;if(a===THREE.OneMinusDstAlphaFactor)return r.ONE_MINUS_DST_ALPHA;if(a===THREE.DstColorFactor)return r.DST_COLOR;if(a===THREE.OneMinusDstColorFactor)return r.ONE_MINUS_DST_COLOR;if(a===THREE.SrcAlphaSaturateFactor)return r.SRC_ALPHA_SATURATE;
-b=U.get("WEBGL_compressed_texture_s3tc");if(null!==b){if(a===THREE.RGB_S3TC_DXT1_Format)return b.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT1_Format)return b.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT3_Format)return b.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===THREE.RGBA_S3TC_DXT5_Format)return b.COMPRESSED_RGBA_S3TC_DXT5_EXT}b=U.get("WEBGL_compressed_texture_pvrtc");if(null!==b){if(a===THREE.RGB_PVRTC_4BPPV1_Format)return b.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===THREE.RGB_PVRTC_2BPPV1_Format)return b.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
-if(a===THREE.RGBA_PVRTC_4BPPV1_Format)return b.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===THREE.RGBA_PVRTC_2BPPV1_Format)return b.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}b=U.get("WEBGL_compressed_texture_etc1");if(null!==b&&a===THREE.RGB_ETC1_Format)return b.COMPRESSED_RGB_ETC1_WEBGL;b=U.get("EXT_blend_minmax");if(null!==b){if(a===THREE.MinEquation)return b.MIN_EXT;if(a===THREE.MaxEquation)return b.MAX_EXT}return 0}console.log("THREE.WebGLRenderer",THREE.REVISION);a=a||{};var K=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
-P=void 0!==a.context?a.context:null,N=void 0!==a.alpha?a.alpha:!1,L=void 0!==a.depth?a.depth:!0,B=void 0!==a.stencil?a.stencil:!0,M=void 0!==a.antialias?a.antialias:!1,Q=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,O=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,S=[],J=[],F=-1,Y=[],V=-1,aa=new Float32Array(8),ca=[],ha=[];this.domElement=K;this.context=null;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.gammaFactor=2;this.gammaOutput=
-this.gammaInput=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;var X=this,ma=null,ia=null,ba=null,ra=-1,na="",la=null,qa=new THREE.Vector4,za=null,ja=new THREE.Vector4,ta=0,$=new THREE.Color(0),fa=0,ua=K.width,va=K.height,Z=1,xa=new THREE.Vector4(0,0,ua,va),Aa=!1,ka=new THREE.Vector4(0,0,ua,va),ya=new THREE.Frustum,sa=new THREE.Matrix4,W=new THREE.Vector3,R={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],
-spotShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[],shadowsPointLight:0},ga={geometries:0,textures:0},ea={calls:0,vertices:0,faces:0,points:0};this.info={render:ea,memory:ga,programs:null};var r;try{N={alpha:N,depth:L,stencil:B,antialias:M,premultipliedAlpha:Q,preserveDrawingBuffer:O};r=P||K.getContext("webgl",N)||K.getContext("experimental-webgl",N);if(null===r){if(null!==K.getContext("webgl"))throw"Error creating WebGL context with your selected attributes.";throw"Error creating WebGL context.";
-}K.addEventListener("webglcontextlost",e,!1)}catch(Ca){console.error("THREE.WebGLRenderer: "+Ca)}var U=new THREE.WebGLExtensions(r);U.get("OES_texture_float");U.get("OES_texture_float_linear");U.get("OES_texture_half_float");U.get("OES_texture_half_float_linear");U.get("OES_standard_derivatives");U.get("ANGLE_instanced_arrays");U.get("OES_element_index_uint")&&(THREE.BufferGeometry.MaxIndex=4294967296);var da=new THREE.WebGLCapabilities(r,U,a),I=new THREE.WebGLState(r,U,E),T=new THREE.WebGLProperties,
-pa=new THREE.WebGLObjects(r,T,this.info),oa=new THREE.WebGLPrograms(this,da),wa=new THREE.WebGLLights;this.info.programs=oa.programs;var Da=new THREE.WebGLBufferRenderer(r,U,ea),Ea=new THREE.WebGLIndexedBufferRenderer(r,U,ea);c();this.context=r;this.capabilities=da;this.extensions=U;this.properties=T;this.state=I;var Ba=new THREE.WebGLShadowMap(this,R,pa);this.shadowMap=Ba;var Fa=new THREE.SpritePlugin(this,ca),Ga=new THREE.LensFlarePlugin(this,ha);this.getContext=function(){return r};this.getContextAttributes=
-function(){return r.getContextAttributes()};this.forceContextLoss=function(){U.get("WEBGL_lose_context").loseContext()};this.getMaxAnisotropy=function(){var a;return function(){if(void 0!==a)return a;var b=U.get("EXT_texture_filter_anisotropic");return a=null!==b?r.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}}();this.getPrecision=function(){return da.precision};this.getPixelRatio=function(){return Z};this.setPixelRatio=function(a){void 0!==a&&(Z=a,this.setSize(ka.z,ka.w,!1))};this.getSize=function(){return{width:ua,
-height:va}};this.setSize=function(a,b,c){ua=a;va=b;K.width=a*Z;K.height=b*Z;!1!==c&&(K.style.width=a+"px",K.style.height=b+"px");this.setViewport(0,0,a,b)};this.setViewport=function(a,b,c,d){I.viewport(ka.set(a,b,c,d))};this.setScissor=function(a,b,c,d){I.scissor(xa.set(a,b,c,d))};this.setScissorTest=function(a){I.setScissorTest(Aa=a)};this.getClearColor=function(){return $};this.setClearColor=function(a,c){$.set(a);fa=void 0!==c?c:1;b($.r,$.g,$.b,fa)};this.getClearAlpha=function(){return fa};this.setClearAlpha=
-function(a){fa=a;b($.r,$.g,$.b,fa)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=r.COLOR_BUFFER_BIT;if(void 0===b||b)d|=r.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=r.STENCIL_BUFFER_BIT;r.clear(d)};this.clearColor=function(){this.clear(!0,!1,!1)};this.clearDepth=function(){this.clear(!1,!0,!1)};this.clearStencil=function(){this.clear(!1,!1,!0)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.resetGLState=d;this.dispose=function(){K.removeEventListener("webglcontextlost",
-e,!1)};this.renderBufferImmediate=function(a,b,c){I.initAttributes();var d=T.get(a);a.hasPositions&&!d.position&&(d.position=r.createBuffer());a.hasNormals&&!d.normal&&(d.normal=r.createBuffer());a.hasUvs&&!d.uv&&(d.uv=r.createBuffer());a.hasColors&&!d.color&&(d.color=r.createBuffer());b=b.getAttributes();a.hasPositions&&(r.bindBuffer(r.ARRAY_BUFFER,d.position),r.bufferData(r.ARRAY_BUFFER,a.positionArray,r.DYNAMIC_DRAW),I.enableAttribute(b.position),r.vertexAttribPointer(b.position,3,r.FLOAT,!1,0,
-0));if(a.hasNormals){r.bindBuffer(r.ARRAY_BUFFER,d.normal);if("MeshPhongMaterial"!==c.type&&"MeshStandardMaterial"!==c.type&&c.shading===THREE.FlatShading)for(var e=0,g=3*a.count;e<g;e+=9){var f=a.normalArray,h=(f[e+0]+f[e+3]+f[e+6])/3,k=(f[e+1]+f[e+4]+f[e+7])/3,l=(f[e+2]+f[e+5]+f[e+8])/3;f[e+0]=h;f[e+1]=k;f[e+2]=l;f[e+3]=h;f[e+4]=k;f[e+5]=l;f[e+6]=h;f[e+7]=k;f[e+8]=l}r.bufferData(r.ARRAY_BUFFER,a.normalArray,r.DYNAMIC_DRAW);I.enableAttribute(b.normal);r.vertexAttribPointer(b.normal,3,r.FLOAT,!1,
-0,0)}a.hasUvs&&c.map&&(r.bindBuffer(r.ARRAY_BUFFER,d.uv),r.bufferData(r.ARRAY_BUFFER,a.uvArray,r.DYNAMIC_DRAW),I.enableAttribute(b.uv),r.vertexAttribPointer(b.uv,2,r.FLOAT,!1,0,0));a.hasColors&&c.vertexColors!==THREE.NoColors&&(r.bindBuffer(r.ARRAY_BUFFER,d.color),r.bufferData(r.ARRAY_BUFFER,a.colorArray,r.DYNAMIC_DRAW),I.enableAttribute(b.color),r.vertexAttribPointer(b.color,3,r.FLOAT,!1,0,0));I.disableUnusedAttributes();r.drawArrays(r.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,
-b,c,d,e,f){u(d);var g=t(a,b,d,e),h=!1;a=c.id+"_"+g.id+"_"+d.wireframe;a!==na&&(na=a,h=!0);b=e.morphTargetInfluences;if(void 0!==b){a=[];for(var k=0,h=b.length;k<h;k++){var m=b[k];a.push([m,k])}a.sort(l);8<a.length&&(a.length=8);for(var n=c.morphAttributes,k=0,h=a.length;k<h;k++)m=a[k],aa[k]=m[0],0!==m[0]?(b=m[1],!0===d.morphTargets&&n.position&&c.addAttribute("morphTarget"+k,n.position[b]),!0===d.morphNormals&&n.normal&&c.addAttribute("morphNormal"+k,n.normal[b])):(!0===d.morphTargets&&c.removeAttribute("morphTarget"+
-k),!0===d.morphNormals&&c.removeAttribute("morphNormal"+k));a=g.getUniforms();null!==a.morphTargetInfluences&&r.uniform1fv(a.morphTargetInfluences,aa);h=!0}b=c.index;k=c.attributes.position;!0===d.wireframe&&(b=pa.getWireframeAttribute(c));null!==b?(a=Ea,a.setIndex(b)):a=Da;if(h){a:{var h=void 0,q;if(c instanceof THREE.InstancedBufferGeometry&&(q=U.get("ANGLE_instanced_arrays"),null===q)){console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
-break a}void 0===h&&(h=0);I.initAttributes();var m=c.attributes,g=g.getAttributes(),n=d.defaultAttributeValues,p;for(p in g){var s=g[p];if(0<=s){var x=m[p];if(void 0!==x){var v=x.itemSize,w=pa.getAttributeBuffer(x);if(x instanceof THREE.InterleavedBufferAttribute){var C=x.data,V=C.stride,x=x.offset;C instanceof THREE.InstancedInterleavedBuffer?(I.enableAttributeAndDivisor(s,C.meshPerAttribute,q),void 0===c.maxInstancedCount&&(c.maxInstancedCount=C.meshPerAttribute*C.count)):I.enableAttribute(s);r.bindBuffer(r.ARRAY_BUFFER,
-w);r.vertexAttribPointer(s,v,r.FLOAT,!1,V*C.array.BYTES_PER_ELEMENT,(h*V+x)*C.array.BYTES_PER_ELEMENT)}else x instanceof THREE.InstancedBufferAttribute?(I.enableAttributeAndDivisor(s,x.meshPerAttribute,q),void 0===c.maxInstancedCount&&(c.maxInstancedCount=x.meshPerAttribute*x.count)):I.enableAttribute(s),r.bindBuffer(r.ARRAY_BUFFER,w),r.vertexAttribPointer(s,v,r.FLOAT,!1,0,h*v*4)}else if(void 0!==n&&(v=n[p],void 0!==v))switch(v.length){case 2:r.vertexAttrib2fv(s,v);break;case 3:r.vertexAttrib3fv(s,
-v);break;case 4:r.vertexAttrib4fv(s,v);break;default:r.vertexAttrib1fv(s,v)}}}I.disableUnusedAttributes()}null!==b&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,pa.getAttributeBuffer(b))}q=Infinity;null!==b?q=b.count:void 0!==k&&(q=k.count);p=c.drawRange.start;b=c.drawRange.count;k=null!==f?f.start:0;h=null!==f?f.count:Infinity;f=Math.max(0,p,k);q=Math.min(0+q,p+b,k+h)-1;q=Math.max(0,q-f+1);if(e instanceof THREE.Mesh)if(!0===d.wireframe)I.setLineWidth(d.wireframeLinewidth*(null===ia?Z:1)),a.setMode(r.LINES);
-else switch(e.drawMode){case THREE.TrianglesDrawMode:a.setMode(r.TRIANGLES);break;case THREE.TriangleStripDrawMode:a.setMode(r.TRIANGLE_STRIP);break;case THREE.TriangleFanDrawMode:a.setMode(r.TRIANGLE_FAN)}else e instanceof THREE.Line?(d=d.linewidth,void 0===d&&(d=1),I.setLineWidth(d*(null===ia?Z:1)),e instanceof THREE.LineSegments?a.setMode(r.LINES):a.setMode(r.LINE_STRIP)):e instanceof THREE.Points&&a.setMode(r.POINTS);c instanceof THREE.InstancedBufferGeometry&&0<c.maxInstancedCount?a.renderInstances(c,
-f,q):a.render(f,q)};this.render=function(a,b,c,d){if(!1===b instanceof THREE.Camera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else{var e=a.fog;na="";ra=-1;la=null;!0===a.autoUpdate&&a.updateMatrixWorld();null===b.parent&&b.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);sa.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse);ya.setFromMatrix(sa);S.length=0;V=F=-1;ca.length=0;ha.length=0;q(a,b);J.length=F+1;Y.length=V+1;!0===X.sortObjects&&
-(J.sort(n),Y.sort(p));var f=S,g,h,k,l=0,m=0,x=0,t,v,u,w=b.matrixWorldInverse,C=0,y=0,z=0,A=0,E=0;g=R.shadowsPointLight=0;for(h=f.length;g<h;g++)if(k=f[g],t=k.color,v=k.intensity,u=k.distance,k instanceof THREE.AmbientLight)l+=t.r*v,m+=t.g*v,x+=t.b*v;else if(k instanceof THREE.DirectionalLight){var B=wa.get(k);B.color.copy(k.color).multiplyScalar(k.intensity);B.direction.setFromMatrixPosition(k.matrixWorld);W.setFromMatrixPosition(k.target.matrixWorld);B.direction.sub(W);B.direction.transformDirection(w);
-if(B.shadow=k.castShadow)B.shadowBias=k.shadow.bias,B.shadowRadius=k.shadow.radius,B.shadowMapSize=k.shadow.mapSize,R.shadows[E++]=k;R.directionalShadowMap[C]=k.shadow.map;R.directionalShadowMatrix[C]=k.shadow.matrix;R.directional[C++]=B}else if(k instanceof THREE.SpotLight){B=wa.get(k);B.position.setFromMatrixPosition(k.matrixWorld);B.position.applyMatrix4(w);B.color.copy(t).multiplyScalar(v);B.distance=u;B.direction.setFromMatrixPosition(k.matrixWorld);W.setFromMatrixPosition(k.target.matrixWorld);
-B.direction.sub(W);B.direction.transformDirection(w);B.angleCos=Math.cos(k.angle);B.penumbra=Math.cos(k.angle)*k.penumbra;B.decay=0===k.distance?0:k.decay;if(B.shadow=k.castShadow)B.shadowBias=k.shadow.bias,B.shadowRadius=k.shadow.radius,B.shadowMapSize=k.shadow.mapSize,R.shadows[E++]=k;R.spotShadowMap[z]=k.shadow.map;R.spotShadowMatrix[z]=k.shadow.matrix;R.spot[z++]=B}else if(k instanceof THREE.PointLight){B=wa.get(k);B.position.setFromMatrixPosition(k.matrixWorld);B.position.applyMatrix4(w);B.color.copy(k.color).multiplyScalar(k.intensity);
-B.distance=k.distance;B.decay=0===k.distance?0:k.decay;if(B.shadow=k.castShadow)B.shadowBias=k.shadow.bias,B.shadowRadius=k.shadow.radius,B.shadowMapSize=k.shadow.mapSize,R.shadows[E++]=k;R.pointShadowMap[y]=k.shadow.map;void 0===R.pointShadowMatrix[y]&&(R.pointShadowMatrix[y]=new THREE.Matrix4);W.setFromMatrixPosition(k.matrixWorld).negate();R.pointShadowMatrix[y].identity().setPosition(W);R.point[y++]=B}else k instanceof THREE.HemisphereLight&&(B=wa.get(k),B.direction.setFromMatrixPosition(k.matrixWorld),
-B.direction.transformDirection(w),B.direction.normalize(),B.skyColor.copy(k.color).multiplyScalar(v),B.groundColor.copy(k.groundColor).multiplyScalar(v),R.hemi[A++]=B);R.ambient[0]=l;R.ambient[1]=m;R.ambient[2]=x;R.directional.length=C;R.spot.length=z;R.point.length=y;R.hemi.length=A;R.shadows.length=E;R.hash=C+","+y+","+z+","+A+","+E;Ba.render(a,b);ea.calls=0;ea.vertices=0;ea.faces=0;ea.points=0;void 0===c&&(c=null);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,
-this.autoClearStencil);a.overrideMaterial?(d=a.overrideMaterial,s(J,b,e,d),s(Y,b,e,d)):(I.setBlending(THREE.NoBlending),s(J,b,e),s(Y,b,e));Fa.render(a,b);Ga.render(a,b,ja);c&&(a=c.texture,a.generateMipmaps&&D(c)&&a.minFilter!==THREE.NearestFilter&&a.minFilter!==THREE.LinearFilter&&(a=c instanceof THREE.WebGLRenderTargetCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,c=T.get(c.texture).__webglTexture,I.bindTexture(a,c),r.generateMipmap(a),I.bindTexture(a,null)));I.setDepthTest(!0);I.setDepthWrite(!0);I.setColorWrite(!0)}};
-this.setFaceCulling=function(a,b){a===THREE.CullFaceNone?I.disable(r.CULL_FACE):(b===THREE.FrontFaceDirectionCW?r.frontFace(r.CW):r.frontFace(r.CCW),a===THREE.CullFaceBack?r.cullFace(r.BACK):a===THREE.CullFaceFront?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK),I.enable(r.CULL_FACE))};this.setTexture=function(a,b){var c=T.get(a);if(0<a.version&&c.__version!==a.version){var d=a.image;if(void 0===d)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",a);else if(!1===
-d.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",a);else{void 0===c.__webglInit&&(c.__webglInit=!0,a.addEventListener("dispose",f),c.__webglTexture=r.createTexture(),ga.textures++);I.activeTexture(r.TEXTURE0+b);I.bindTexture(r.TEXTURE_2D,c.__webglTexture);r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,a.flipY);r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);r.pixelStorei(r.UNPACK_ALIGNMENT,a.unpackAlignment);var e=w(a.image,da.maxTextureSize);
-if((a.wrapS!==THREE.ClampToEdgeWrapping||a.wrapT!==THREE.ClampToEdgeWrapping||a.minFilter!==THREE.NearestFilter&&a.minFilter!==THREE.LinearFilter)&&!1===D(e))if(d=e,d instanceof HTMLImageElement||d instanceof HTMLCanvasElement){var g=document.createElement("canvas");g.width=THREE.Math.nearestPowerOfTwo(d.width);g.height=THREE.Math.nearestPowerOfTwo(d.height);g.getContext("2d").drawImage(d,0,0,g.width,g.height);console.warn("THREE.WebGLRenderer: image is not power of two ("+d.width+"x"+d.height+"). Resized to "+
-g.width+"x"+g.height,d);e=g}else e=d;var d=D(e),g=E(a.format),h=E(a.type);C(r.TEXTURE_2D,a,d);var k=a.mipmaps;if(a instanceof THREE.DataTexture)if(0<k.length&&d){for(var l=0,m=k.length;l<m;l++)e=k[l],I.texImage2D(r.TEXTURE_2D,l,g,e.width,e.height,0,g,h,e.data);a.generateMipmaps=!1}else I.texImage2D(r.TEXTURE_2D,0,g,e.width,e.height,0,g,h,e.data);else if(a instanceof THREE.CompressedTexture)for(l=0,m=k.length;l<m;l++)e=k[l],a.format!==THREE.RGBAFormat&&a.format!==THREE.RGBFormat?-1<I.getCompressedTextureFormats().indexOf(g)?
-I.compressedTexImage2D(r.TEXTURE_2D,l,g,e.width,e.height,0,e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):I.texImage2D(r.TEXTURE_2D,l,g,e.width,e.height,0,g,h,e.data);else if(0<k.length&&d){l=0;for(m=k.length;l<m;l++)e=k[l],I.texImage2D(r.TEXTURE_2D,l,g,g,h,e);a.generateMipmaps=!1}else I.texImage2D(r.TEXTURE_2D,0,g,g,h,e);a.generateMipmaps&&d&&r.generateMipmap(r.TEXTURE_2D);c.__version=a.version;if(a.onUpdate)a.onUpdate(a)}}else I.activeTexture(r.TEXTURE0+
-b),I.bindTexture(r.TEXTURE_2D,c.__webglTexture)};this.setRenderTarget=function(a){if((ia=a)&&void 0===T.get(a).__webglFramebuffer){var b=T.get(a),c=T.get(a.texture);a.addEventListener("dispose",g);c.__webglTexture=r.createTexture();ga.textures++;var d=a instanceof THREE.WebGLRenderTargetCube,e=THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height);if(d){b.__webglFramebuffer=[];for(var f=0;6>f;f++)b.__webglFramebuffer[f]=r.createFramebuffer()}else b.__webglFramebuffer=r.createFramebuffer();
-if(d){I.bindTexture(r.TEXTURE_CUBE_MAP,c.__webglTexture);C(r.TEXTURE_CUBE_MAP,a.texture,e);for(f=0;6>f;f++)A(b.__webglFramebuffer[f],a,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+f);a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_CUBE_MAP);I.bindTexture(r.TEXTURE_CUBE_MAP,null)}else I.bindTexture(r.TEXTURE_2D,c.__webglTexture),C(r.TEXTURE_2D,a.texture,e),A(b.__webglFramebuffer,a,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_2D),I.bindTexture(r.TEXTURE_2D,
-null);if(a.depthBuffer){b=T.get(a);if(a instanceof THREE.WebGLRenderTargetCube)for(b.__webglDepthbuffer=[],c=0;6>c;c++)r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[c]),b.__webglDepthbuffer[c]=r.createRenderbuffer(),H(b.__webglDepthbuffer[c],a);else r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer=r.createRenderbuffer(),H(b.__webglDepthbuffer,a);r.bindFramebuffer(r.FRAMEBUFFER,null)}}b=a instanceof THREE.WebGLRenderTargetCube;a?(c=T.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:
-c.__webglFramebuffer,qa.copy(a.scissor),za=a.scissorTest,ja.copy(a.viewport)):(c=null,qa.copy(xa).multiplyScalar(Z),za=Aa,ja.copy(ka).multiplyScalar(Z));ba!==c&&(r.bindFramebuffer(r.FRAMEBUFFER,c),ba=c);I.scissor(qa);I.setScissorTest(za);I.viewport(ja);b&&(b=T.get(a.texture),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,0))};this.readRenderTargetPixels=function(a,b,c,d,e,g){if(!1===a instanceof THREE.WebGLRenderTarget)console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
-else{var f=T.get(a).__webglFramebuffer;if(f){var h=!1;f!==ba&&(r.bindFramebuffer(r.FRAMEBUFFER,f),h=!0);try{var k=a.texture;k.format!==THREE.RGBAFormat&&E(k.format)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):k.type===THREE.UnsignedByteType||E(k.type)===r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)||k.type===THREE.FloatType&&U.get("WEBGL_color_buffer_float")||k.type===
-THREE.HalfFloatType&&U.get("EXT_color_buffer_half_float")?r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE?r.readPixels(b,c,d,e,E(k.format),E(k.type),g):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&r.bindFramebuffer(r.FRAMEBUFFER,ba)}}}}};
-THREE.WebGLRenderTarget=function(a,b,c){this.uuid=THREE.Math.generateUUID();this.width=a;this.height=b;this.scissor=new THREE.Vector4(0,0,a,b);this.scissorTest=!1;this.viewport=new THREE.Vector4(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=THREE.LinearFilter);this.texture=new THREE.Texture(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0};
-THREE.WebGLRenderTarget.prototype={constructor:THREE.WebGLRenderTarget,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.shareDepthFrom=a.shareDepthFrom;
-return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;
-THREE.WebGLBufferRenderer=function(a,b,c){var d;this.setMode=function(a){d=a};this.render=function(b,f){a.drawArrays(d,b,f);c.calls++;c.vertices+=f;d===a.TRIANGLES&&(c.faces+=f/3)};this.renderInstances=function(e){var f=b.get("ANGLE_instanced_arrays");if(null===f)console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");else{var g=e.attributes.position,h=0,h=g instanceof THREE.InterleavedBufferAttribute?g.data.count:
-g.count;f.drawArraysInstancedANGLE(d,0,h,e.maxInstancedCount);c.calls++;c.vertices+=h*e.maxInstancedCount;d===a.TRIANGLES&&(c.faces+=e.maxInstancedCount*h/3)}}};
-THREE.WebGLIndexedBufferRenderer=function(a,b,c){var d,e,f;this.setMode=function(a){d=a};this.setIndex=function(c){c.array instanceof Uint32Array&&b.get("OES_element_index_uint")?(e=a.UNSIGNED_INT,f=4):(e=a.UNSIGNED_SHORT,f=2)};this.render=function(b,h){a.drawElements(d,h,e,b*f);c.calls++;c.vertices+=h;d===a.TRIANGLES&&(c.faces+=h/3)};this.renderInstances=function(g,h,k){var l=b.get("ANGLE_instanced_arrays");null===l?console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."):
-(l.drawElementsInstancedANGLE(d,k,e,h*f,g.maxInstancedCount),c.calls++,c.vertices+=k*g.maxInstancedCount,d===a.TRIANGLES&&(c.faces+=g.maxInstancedCount*k/3))}};
-THREE.WebGLExtensions=function(a){var b={};this.get=function(c){if(void 0!==b[c])return b[c];var d;switch(c){case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
-break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case "WEBGL_compressed_texture_etc1":d=a.getExtension("WEBGL_compressed_texture_etc1");break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}};
-THREE.WebGLCapabilities=function(a,b,c){function d(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision)return"highp";b="mediump"}return"mediump"===b&&0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision?"mediump":"lowp"}this.getMaxPrecision=d;this.precision=void 0!==c.precision?c.precision:"highp";
-this.logarithmicDepthBuffer=void 0!==c.logarithmicDepthBuffer?c.logarithmicDepthBuffer:!1;this.maxTextures=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);this.maxVertexTextures=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS);this.maxTextureSize=a.getParameter(a.MAX_TEXTURE_SIZE);this.maxCubemapSize=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE);this.maxAttributes=a.getParameter(a.MAX_VERTEX_ATTRIBS);this.maxVertexUniforms=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS);this.maxVaryings=a.getParameter(a.MAX_VARYING_VECTORS);
-this.maxFragmentUniforms=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS);this.vertexTextures=0<this.maxVertexTextures;this.floatFragmentTextures=!!b.get("OES_texture_float");this.floatVertexTextures=this.vertexTextures&&this.floatFragmentTextures;c=d(this.precision);c!==this.precision&&(console.warn("THREE.WebGLRenderer:",this.precision,"not supported, using",c,"instead."),this.precision=c);this.logarithmicDepthBuffer&&(this.logarithmicDepthBuffer=!!b.get("EXT_frag_depth"))};
-THREE.WebGLGeometries=function(a,b,c){function d(a){var h=a.target;a=f[h.id];null!==a.index&&e(a.index);var k=a.attributes,l;for(l in k)e(k[l]);h.removeEventListener("dispose",d);delete f[h.id];l=b.get(h);l.wireframe&&e(l.wireframe);b.delete(h);h=b.get(a);h.wireframe&&e(h.wireframe);b.delete(a);c.memory.geometries--}function e(c){var d;d=c instanceof THREE.InterleavedBufferAttribute?b.get(c.data).__webglBuffer:b.get(c).__webglBuffer;void 0!==d&&(a.deleteBuffer(d),c instanceof THREE.InterleavedBufferAttribute?
-b.delete(c.data):b.delete(c))}var f={};this.get=function(a){var b=a.geometry;if(void 0!==f[b.id])return f[b.id];b.addEventListener("dispose",d);var e;b instanceof THREE.BufferGeometry?e=b:b instanceof THREE.Geometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new THREE.BufferGeometry).setFromObject(a)),e=b._bufferGeometry);f[b.id]=e;c.memory.geometries++;return e}};
-THREE.WebGLLights=function(){var a={};this.get=function(b){if(void 0!==a[b.id])return a[b.id];var c;switch(b.type){case "DirectionalLight":c={direction:new THREE.Vector3,color:new THREE.Color,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new THREE.Vector2};break;case "SpotLight":c={position:new THREE.Vector3,direction:new THREE.Vector3,color:new THREE.Color,distance:0,angleCos:0,penumbra:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new THREE.Vector2};break;case "PointLight":c=
-{position:new THREE.Vector3,color:new THREE.Color,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new THREE.Vector2};break;case "HemisphereLight":c={direction:new THREE.Vector3,skyColor:new THREE.Color,groundColor:new THREE.Color}}return a[b.id]=c}};
-THREE.WebGLObjects=function(a,b,c){function d(c,d){var e=c instanceof THREE.InterleavedBufferAttribute?c.data:c,f=b.get(e);void 0===f.__webglBuffer?(f.__webglBuffer=a.createBuffer(),a.bindBuffer(d,f.__webglBuffer),a.bufferData(d,e.array,e.dynamic?a.DYNAMIC_DRAW:a.STATIC_DRAW),f.version=e.version):f.version!==e.version&&(a.bindBuffer(d,f.__webglBuffer),!1===e.dynamic||-1===e.updateRange.count?a.bufferSubData(d,0,e.array):0===e.updateRange.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):
-(a.bufferSubData(d,e.updateRange.offset*e.array.BYTES_PER_ELEMENT,e.array.subarray(e.updateRange.offset,e.updateRange.offset+e.updateRange.count)),e.updateRange.count=0),f.version=e.version)}function e(a,b,c){if(b>c){var d=b;b=c;c=d}d=a[b];return void 0===d?(a[b]=[c],!0):-1===d.indexOf(c)?(d.push(c),!0):!1}var f=new THREE.WebGLGeometries(a,b,c);this.getAttributeBuffer=function(a){return a instanceof THREE.InterleavedBufferAttribute?b.get(a.data).__webglBuffer:b.get(a).__webglBuffer};this.getWireframeAttribute=
-function(c){var f=b.get(c);if(void 0!==f.wireframe)return f.wireframe;var k=[],l=c.index,n=c.attributes;c=n.position;if(null!==l)for(var n={},l=l.array,p=0,m=l.length;p<m;p+=3){var q=l[p+0],s=l[p+1],u=l[p+2];e(n,q,s)&&k.push(q,s);e(n,s,u)&&k.push(s,u);e(n,u,q)&&k.push(u,q)}else for(l=n.position.array,p=0,m=l.length/3-1;p<m;p+=3)q=p+0,s=p+1,u=p+2,k.push(q,s,s,u,u,q);k=new THREE.BufferAttribute(new (65535<c.count?Uint32Array:Uint16Array)(k),1);d(k,a.ELEMENT_ARRAY_BUFFER);return f.wireframe=k};this.update=
-function(b){var c=f.get(b);b.geometry instanceof THREE.Geometry&&c.updateFromObject(b);b=c.index;var e=c.attributes;null!==b&&d(b,a.ELEMENT_ARRAY_BUFFER);for(var l in e)d(e[l],a.ARRAY_BUFFER);b=c.morphAttributes;for(l in b)for(var e=b[l],n=0,p=e.length;n<p;n++)d(e[n],a.ARRAY_BUFFER);return c}};
-THREE.WebGLProgram=function(){function a(a,b,d){a=a||{};return[a.derivatives||b.bumpMap||b.normalMap||b.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(a.fragDepth||b.logarithmicDepthBuffer)&&d.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",a.drawBuffers&&d.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(a.shaderTextureLOD||b.envMap)&&d.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(c).join("\n")}
-function b(a){var b=[],c;for(c in a){var d=a[c];!1!==d&&b.push("#define "+c+" "+d)}return b.join("\n")}function c(a){return""!==a}function d(a,b){return a.replace(/NUM_DIR_LIGHTS/g,b.numDirLights).replace(/NUM_SPOT_LIGHTS/g,b.numSpotLights).replace(/NUM_POINT_LIGHTS/g,b.numPointLights).replace(/NUM_HEMI_LIGHTS/g,b.numHemiLights)}function e(a){return a.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,b,c,d){a="";for(b=parseInt(b);b<parseInt(c);b++)a+=d.replace(/\[ i \]/g,
-"[ "+b+" ]");return a})}var f=0,g=/^([\w\d_]+)\.([\w\d_]+)$/,h=/^([\w\d_]+)\[(\d+)\]\.([\w\d_]+)$/,k=/^([\w\d_]+)\[0\]$/;return function(l,n,p,m){var q=l.context,s=p.extensions,u=p.defines,t=p.__webglShader.vertexShader,x=p.__webglShader.fragmentShader,v="SHADOWMAP_TYPE_BASIC";m.shadowMapType===THREE.PCFShadowMap?v="SHADOWMAP_TYPE_PCF":m.shadowMapType===THREE.PCFSoftShadowMap&&(v="SHADOWMAP_TYPE_PCF_SOFT");var C="ENVMAP_TYPE_CUBE",w="ENVMAP_MODE_REFLECTION",D="ENVMAP_BLENDING_MULTIPLY";if(m.envMap){switch(p.envMap.mapping){case THREE.CubeReflectionMapping:case THREE.CubeRefractionMapping:C=
-"ENVMAP_TYPE_CUBE";break;case THREE.EquirectangularReflectionMapping:case THREE.EquirectangularRefractionMapping:C="ENVMAP_TYPE_EQUIREC";break;case THREE.SphericalReflectionMapping:C="ENVMAP_TYPE_SPHERE"}switch(p.envMap.mapping){case THREE.CubeRefractionMapping:case THREE.EquirectangularRefractionMapping:w="ENVMAP_MODE_REFRACTION"}switch(p.combine){case THREE.MultiplyOperation:D="ENVMAP_BLENDING_MULTIPLY";break;case THREE.MixOperation:D="ENVMAP_BLENDING_MIX";break;case THREE.AddOperation:D="ENVMAP_BLENDING_ADD"}}var z=
-0<l.gammaFactor?l.gammaFactor:1,s=a(s,m,l.extensions),y=b(u),A=q.createProgram();p instanceof THREE.RawShaderMaterial?l=u="":(u=["precision "+m.precision+" float;","precision "+m.precision+" int;","#define SHADER_NAME "+p.__webglShader.name,y,m.supportsVertexTextures?"#define VERTEX_TEXTURES":"",l.gammaInput?"#define GAMMA_INPUT":"",l.gammaOutput?"#define GAMMA_OUTPUT":"","#define GAMMA_FACTOR "+z,"#define MAX_BONES "+m.maxBones,m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.envMap?
-"#define "+w:"",m.lightMap?"#define USE_LIGHTMAP":"",m.aoMap?"#define USE_AOMAP":"",m.emissiveMap?"#define USE_EMISSIVEMAP":"",m.bumpMap?"#define USE_BUMPMAP":"",m.normalMap?"#define USE_NORMALMAP":"",m.displacementMap&&m.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",m.specularMap?"#define USE_SPECULARMAP":"",m.roughnessMap?"#define USE_ROUGHNESSMAP":"",m.metalnessMap?"#define USE_METALNESSMAP":"",m.alphaMap?"#define USE_ALPHAMAP":"",m.vertexColors?"#define USE_COLOR":"",m.flatShading?"#define FLAT_SHADED":
-"",m.skinning?"#define USE_SKINNING":"",m.useVertexTexture?"#define BONE_TEXTURE":"",m.morphTargets?"#define USE_MORPHTARGETS":"",m.morphNormals&&!1===m.flatShading?"#define USE_MORPHNORMALS":"",m.doubleSided?"#define DOUBLE_SIDED":"",m.flipSided?"#define FLIP_SIDED":"",m.shadowMapEnabled?"#define USE_SHADOWMAP":"",m.shadowMapEnabled?"#define "+v:"",0<m.pointLightShadows?"#define POINT_LIGHT_SHADOWS":"",m.sizeAttenuation?"#define USE_SIZEATTENUATION":"",m.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":
-"",m.logarithmicDepthBuffer&&l.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;",
-"\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(c).join("\n"),l=[s,"precision "+
-m.precision+" float;","precision "+m.precision+" int;","#define SHADER_NAME "+p.__webglShader.name,y,m.alphaTest?"#define ALPHATEST "+m.alphaTest:"",l.gammaInput?"#define GAMMA_INPUT":"",l.gammaOutput?"#define GAMMA_OUTPUT":"","#define GAMMA_FACTOR "+z,m.useFog&&m.fog?"#define USE_FOG":"",m.useFog&&m.fogExp?"#define FOG_EXP2":"",m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.envMap?"#define "+C:"",m.envMap?"#define "+w:"",m.envMap?"#define "+D:"",m.lightMap?"#define USE_LIGHTMAP":"",
-m.aoMap?"#define USE_AOMAP":"",m.emissiveMap?"#define USE_EMISSIVEMAP":"",m.bumpMap?"#define USE_BUMPMAP":"",m.normalMap?"#define USE_NORMALMAP":"",m.specularMap?"#define USE_SPECULARMAP":"",m.roughnessMap?"#define USE_ROUGHNESSMAP":"",m.metalnessMap?"#define USE_METALNESSMAP":"",m.alphaMap?"#define USE_ALPHAMAP":"",m.vertexColors?"#define USE_COLOR":"",m.flatShading?"#define FLAT_SHADED":"",m.doubleSided?"#define DOUBLE_SIDED":"",m.flipSided?"#define FLIP_SIDED":"",m.shadowMapEnabled?"#define USE_SHADOWMAP":
-"",m.shadowMapEnabled?"#define "+v:"",0<m.pointLightShadows?"#define POINT_LIGHT_SHADOWS":"",m.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",m.logarithmicDepthBuffer&&l.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",m.envMap&&l.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","\n"].filter(c).join("\n"));t=d(t,m);x=d(x,m);!1===p instanceof THREE.ShaderMaterial&&(t=e(t),x=e(x));x=l+x;t=THREE.WebGLShader(q,
-q.VERTEX_SHADER,u+t);x=THREE.WebGLShader(q,q.FRAGMENT_SHADER,x);q.attachShader(A,t);q.attachShader(A,x);void 0!==p.index0AttributeName?q.bindAttribLocation(A,0,p.index0AttributeName):!0===m.morphTargets&&q.bindAttribLocation(A,0,"position");q.linkProgram(A);m=q.getProgramInfoLog(A);v=q.getShaderInfoLog(t);C=q.getShaderInfoLog(x);D=w=!0;if(!1===q.getProgramParameter(A,q.LINK_STATUS))w=!1,console.error("THREE.WebGLProgram: shader error: ",q.getError(),"gl.VALIDATE_STATUS",q.getProgramParameter(A,q.VALIDATE_STATUS),
-"gl.getProgramInfoLog",m,v,C);else if(""!==m)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",m);else if(""===v||""===C)D=!1;D&&(this.diagnostics={runnable:w,material:p,programLog:m,vertexShader:{log:v,prefix:u},fragmentShader:{log:C,prefix:l}});q.deleteShader(t);q.deleteShader(x);var H;this.getUniforms=function(){if(void 0===H){for(var a={},b=q.getProgramParameter(A,q.ACTIVE_UNIFORMS),c=0;c<b;c++){var d=q.getActiveUniform(A,c).name,e=q.getUniformLocation(A,d),f=g.exec(d);if(f){var d=f[1],
-f=f[2],l=a[d];l||(l=a[d]={});l[f]=e}else if(f=h.exec(d)){var l=f[1],d=f[2],f=f[3],m=a[l];m||(m=a[l]=[]);(l=m[d])||(l=m[d]={});l[f]=e}else(f=k.exec(d))?(l=f[1],a[l]=e):a[d]=e}H=a}return H};var G;this.getAttributes=function(){if(void 0===G){for(var a={},b=q.getProgramParameter(A,q.ACTIVE_ATTRIBUTES),c=0;c<b;c++){var d=q.getActiveAttrib(A,c).name;a[d]=q.getAttribLocation(A,d)}G=a}return G};this.destroy=function(){q.deleteProgram(A);this.program=void 0};Object.defineProperties(this,{uniforms:{get:function(){console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms().");
-return this.getUniforms()}},attributes:{get:function(){console.warn("THREE.WebGLProgram: .attributes is now .getAttributes().");return this.getAttributes()}}});this.id=f++;this.code=n;this.usedTimes=1;this.program=A;this.vertexShader=t;this.fragmentShader=x;return this}}();
-THREE.WebGLPrograms=function(a,b){var c=[],d={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshStandardMaterial:"standard",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},e="precision supportsVertexTextures map envMap envMapMode lightMap aoMap emissiveMap bumpMap normalMap displacementMap specularMap roughnessMap metalnessMap alphaMap combine vertexColors fog useFog fogExp flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals numDirLights numPointLights numSpotLights numHemiLights shadowMapEnabled pointLightShadows shadowMapType alphaTest doubleSided flipSided".split(" ");
-this.getParameters=function(c,e,h,k){var l=d[c.type],n;b.floatVertexTextures&&k&&k.skeleton&&k.skeleton.useVertexTexture?n=1024:(n=Math.floor((b.maxVertexUniforms-20)/4),void 0!==k&&k instanceof THREE.SkinnedMesh&&(n=Math.min(k.skeleton.bones.length,n),n<k.skeleton.bones.length&&console.warn("WebGLRenderer: too many bones - "+k.skeleton.bones.length+", this GPU supports just "+n+" (try OpenGL instead of ANGLE)")));var p=a.getPrecision();null!==c.precision&&(p=b.getMaxPrecision(c.precision),p!==c.precision&&
-console.warn("THREE.WebGLProgram.getParameters:",c.precision,"not supported, using",p,"instead."));return{shaderID:l,precision:p,supportsVertexTextures:b.vertexTextures,map:!!c.map,envMap:!!c.envMap,envMapMode:c.envMap&&c.envMap.mapping,lightMap:!!c.lightMap,aoMap:!!c.aoMap,emissiveMap:!!c.emissiveMap,bumpMap:!!c.bumpMap,normalMap:!!c.normalMap,displacementMap:!!c.displacementMap,roughnessMap:!!c.roughnessMap,metalnessMap:!!c.metalnessMap,specularMap:!!c.specularMap,alphaMap:!!c.alphaMap,combine:c.combine,
-vertexColors:c.vertexColors,fog:h,useFog:c.fog,fogExp:h instanceof THREE.FogExp2,flatShading:c.shading===THREE.FlatShading,sizeAttenuation:c.sizeAttenuation,logarithmicDepthBuffer:b.logarithmicDepthBuffer,skinning:c.skinning,maxBones:n,useVertexTexture:b.floatVertexTextures&&k&&k.skeleton&&k.skeleton.useVertexTexture,morphTargets:c.morphTargets,morphNormals:c.morphNormals,maxMorphTargets:a.maxMorphTargets,maxMorphNormals:a.maxMorphNormals,numDirLights:e.directional.length,numPointLights:e.point.length,
-numSpotLights:e.spot.length,numHemiLights:e.hemi.length,pointLightShadows:e.shadowsPointLight,shadowMapEnabled:a.shadowMap.enabled&&k.receiveShadow&&0<e.shadows.length,shadowMapType:a.shadowMap.type,alphaTest:c.alphaTest,doubleSided:c.side===THREE.DoubleSide,flipSided:c.side===THREE.BackSide}};this.getProgramCode=function(a,b){var c=[];b.shaderID?c.push(b.shaderID):(c.push(a.fragmentShader),c.push(a.vertexShader));if(void 0!==a.defines)for(var d in a.defines)c.push(d),c.push(a.defines[d]);for(d=0;d<
-e.length;d++){var l=e[d];c.push(l);c.push(b[l])}return c.join()};this.acquireProgram=function(b,d,e){for(var k,l=0,n=c.length;l<n;l++){var p=c[l];if(p.code===e){k=p;++k.usedTimes;break}}void 0===k&&(k=new THREE.WebGLProgram(a,e,b,d),c.push(k));return k};this.releaseProgram=function(a){if(0===--a.usedTimes){var b=c.indexOf(a);c[b]=c[c.length-1];c.pop();a.destroy()}};this.programs=c};
-THREE.WebGLProperties=function(){var a={};this.get=function(b){b=b.uuid;var c=a[b];void 0===c&&(c={},a[b]=c);return c};this.delete=function(b){delete a[b.uuid]};this.clear=function(){a={}}};
-THREE.WebGLShader=function(){function a(a){a=a.split("\n");for(var c=0;c<a.length;c++)a[c]=c+1+": "+a[c];return a.join("\n")}return function(b,c,d){var e=b.createShader(c);b.shaderSource(e,d);b.compileShader(e);!1===b.getShaderParameter(e,b.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile.");""!==b.getShaderInfoLog(e)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",c===b.VERTEX_SHADER?"vertex":"fragment",b.getShaderInfoLog(e),a(d));return e}}();
-THREE.WebGLShadowMap=function(a,b,c){function d(a,b,c,d){var e=a.geometry,f=null,f=q,g=a.customDepthMaterial;c&&(f=s,g=a.customDistanceMaterial);g?f=g:(a=a instanceof THREE.SkinnedMesh&&b.skinning,g=0,void 0!==e.morphTargets&&0<e.morphTargets.length&&b.morphTargets&&(g|=1),a&&(g|=2),f=f[g]);f.visible=b.visible;f.wireframe=b.wireframe;f.wireframeLinewidth=b.wireframeLinewidth;c&&void 0!==f.uniforms.lightPos&&f.uniforms.lightPos.value.copy(d);return f}function e(a,b,c){if(!1!==a.visible){a.layers.test(b.layers)&&
-(a instanceof THREE.Mesh||a instanceof THREE.Line||a instanceof THREE.Points)&&a.castShadow&&(!1===a.frustumCulled||!0===h.intersectsObject(a))&&!0===a.material.visible&&(a.modelViewMatrix.multiplyMatrices(c.matrixWorldInverse,a.matrixWorld),m.push(a));a=a.children;for(var d=0,f=a.length;d<f;d++)e(a[d],b,c)}}for(var f=a.context,g=a.state,h=new THREE.Frustum,k=new THREE.Matrix4,l=new THREE.Vector2,n=new THREE.Vector3,p=new THREE.Vector3,m=[],q=Array(4),s=Array(4),u=[new THREE.Vector3(1,0,0),new THREE.Vector3(-1,
-0,0),new THREE.Vector3(0,0,1),new THREE.Vector3(0,0,-1),new THREE.Vector3(0,1,0),new THREE.Vector3(0,-1,0)],t=[new THREE.Vector3(0,1,0),new THREE.Vector3(0,1,0),new THREE.Vector3(0,1,0),new THREE.Vector3(0,1,0),new THREE.Vector3(0,0,1),new THREE.Vector3(0,0,-1)],x=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],v=THREE.ShaderLib.depthRGBA,C=THREE.UniformsUtils.clone(v.uniforms),w=THREE.ShaderLib.distanceRGBA,D=THREE.UniformsUtils.clone(w.uniforms),
-z=0;4!==z;++z){var y=0!==(z&1),A=0!==(z&2),H=new THREE.ShaderMaterial({uniforms:C,vertexShader:v.vertexShader,fragmentShader:v.fragmentShader,morphTargets:y,skinning:A});H._shadowPass=!0;q[z]=H;y=new THREE.ShaderMaterial({uniforms:D,vertexShader:w.vertexShader,fragmentShader:w.fragmentShader,morphTargets:y,skinning:A});y._shadowPass=!0;s[z]=y}var G=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=THREE.PCFShadowMap;this.cullFace=THREE.CullFaceFront;this.render=function(q,s){var v,
-w;if(!1!==G.enabled&&(!1!==G.autoUpdate||!1!==G.needsUpdate)){g.clearColor(1,1,1,1);g.disable(f.BLEND);g.enable(f.CULL_FACE);f.frontFace(f.CCW);f.cullFace(G.cullFace===THREE.CullFaceFront?f.FRONT:f.BACK);g.setDepthTest(!0);g.setScissorTest(!1);for(var C=b.shadows,y=0,z=C.length;y<z;y++){var A=C[y],D=A.shadow,H=D.camera;l.copy(D.mapSize);if(A instanceof THREE.PointLight){v=6;w=!0;var J=l.x,F=l.y;x[0].set(2*J,F,J,F);x[1].set(0,F,J,F);x[2].set(3*J,F,J,F);x[3].set(J,F,J,F);x[4].set(3*J,0,J,F);x[5].set(J,
-0,J,F);l.x*=4;l.y*=2}else v=1,w=!1;null===D.map&&(D.map=new THREE.WebGLRenderTarget(l.x,l.y,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat}),A instanceof THREE.SpotLight&&(H.aspect=l.x/l.y),H.updateProjectionMatrix());J=D.map;D=D.matrix;p.setFromMatrixPosition(A.matrixWorld);H.position.copy(p);a.setRenderTarget(J);a.clear();for(J=0;J<v;J++){w?(n.copy(H.position),n.add(u[J]),H.up.copy(t[J]),H.lookAt(n),g.viewport(x[J])):(n.setFromMatrixPosition(A.target.matrixWorld),
-H.lookAt(n));H.updateMatrixWorld();H.matrixWorldInverse.getInverse(H.matrixWorld);D.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);D.multiply(H.projectionMatrix);D.multiply(H.matrixWorldInverse);k.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse);h.setFromMatrix(k);m.length=0;e(q,s,H);for(var F=0,Y=m.length;F<Y;F++){var V=m[F],aa=c.update(V),ca=V.material;if(ca instanceof THREE.MultiMaterial)for(var ha=aa.groups,ca=ca.materials,X=0,ma=ha.length;X<ma;X++){var ia=ha[X],ba=ca[ia.materialIndex];!0===
-ba.visible&&(ba=d(V,ba,w,p),a.renderBufferDirect(H,null,aa,ba,V,ia))}else ba=d(V,ca,w,p),a.renderBufferDirect(H,null,aa,ba,V,null)}}a.resetGLState()}v=a.getClearColor();w=a.getClearAlpha();a.setClearColor(v,w);g.enable(f.BLEND);G.cullFace===THREE.CullFaceFront&&f.cullFace(f.BACK);a.resetGLState();G.needsUpdate=!1}}};
-THREE.WebGLState=function(a,b,c){var d=this,e=new THREE.Vector4,f=new Uint8Array(16),g=new Uint8Array(16),h=new Uint8Array(16),k={},l=null,n=null,p=null,m=null,q=null,s=null,u=null,t=null,x=null,v=null,C=null,w=null,D=null,z=null,y=null,A=null,H=null,G=null,E=null,K=null,P=null,N=null,L=null,B=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),M=void 0,Q={},O=new THREE.Vector4,S=null,J=null,F=new THREE.Vector4,Y=new THREE.Vector4;this.init=function(){this.clearColor(0,0,0,1);this.clearDepth(1);this.clearStencil(0);
-this.enable(a.DEPTH_TEST);a.depthFunc(a.LEQUAL);a.frontFace(a.CCW);a.cullFace(a.BACK);this.enable(a.CULL_FACE);this.enable(a.BLEND);a.blendEquation(a.FUNC_ADD);a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA)};this.initAttributes=function(){for(var a=0,b=f.length;a<b;a++)f[a]=0};this.enableAttribute=function(c){f[c]=1;0===g[c]&&(a.enableVertexAttribArray(c),g[c]=1);0!==h[c]&&(b.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(c,0),h[c]=0)};this.enableAttributeAndDivisor=function(b,c,d){f[b]=1;
-0===g[b]&&(a.enableVertexAttribArray(b),g[b]=1);h[b]!==c&&(d.vertexAttribDivisorANGLE(b,c),h[b]=c)};this.disableUnusedAttributes=function(){for(var b=0,c=g.length;b<c;b++)g[b]!==f[b]&&(a.disableVertexAttribArray(b),g[b]=0)};this.enable=function(b){!0!==k[b]&&(a.enable(b),k[b]=!0)};this.disable=function(b){!1!==k[b]&&(a.disable(b),k[b]=!1)};this.getCompressedTextureFormats=function(){if(null===l&&(l=[],b.get("WEBGL_compressed_texture_pvrtc")||b.get("WEBGL_compressed_texture_s3tc")||b.get("WEBGL_compressed_texture_etc1")))for(var c=
-a.getParameter(a.COMPRESSED_TEXTURE_FORMATS),d=0;d<c.length;d++)l.push(c[d]);return l};this.setBlending=function(b,d,e,f,g,h,k){b===THREE.NoBlending?this.disable(a.BLEND):this.enable(a.BLEND);b!==n&&(b===THREE.AdditiveBlending?(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.SRC_ALPHA,a.ONE)):b===THREE.SubtractiveBlending?(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.ONE_MINUS_SRC_COLOR)):b===THREE.MultiplyBlending?(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.SRC_COLOR)):(a.blendEquationSeparate(a.FUNC_ADD,
-a.FUNC_ADD),a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA)),n=b);if(b===THREE.CustomBlending){g=g||d;h=h||e;k=k||f;if(d!==p||g!==s)a.blendEquationSeparate(c(d),c(g)),p=d,s=g;if(e!==m||f!==q||h!==u||k!==t)a.blendFuncSeparate(c(e),c(f),c(h),c(k)),m=e,q=f,u=h,t=k}else t=u=s=q=m=p=null};this.setDepthFunc=function(b){if(x!==b){if(b)switch(b){case THREE.NeverDepth:a.depthFunc(a.NEVER);break;case THREE.AlwaysDepth:a.depthFunc(a.ALWAYS);break;case THREE.LessDepth:a.depthFunc(a.LESS);
-break;case THREE.LessEqualDepth:a.depthFunc(a.LEQUAL);break;case THREE.EqualDepth:a.depthFunc(a.EQUAL);break;case THREE.GreaterEqualDepth:a.depthFunc(a.GEQUAL);break;case THREE.GreaterDepth:a.depthFunc(a.GREATER);break;case THREE.NotEqualDepth:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}else a.depthFunc(a.LEQUAL);x=b}};this.setDepthTest=function(b){b?this.enable(a.DEPTH_TEST):this.disable(a.DEPTH_TEST)};this.setDepthWrite=function(b){v!==b&&(a.depthMask(b),v=b)};this.setColorWrite=
-function(b){C!==b&&(a.colorMask(b,b,b,b),C=b)};this.setStencilFunc=function(b,c,d){if(D!==b||z!==c||y!==d)a.stencilFunc(b,c,d),D=b,z=c,y=d};this.setStencilOp=function(b,c,d){if(A!==b||H!==c||G!==d)a.stencilOp(b,c,d),A=b,H=c,G=d};this.setStencilTest=function(b){b?this.enable(a.STENCIL_TEST):this.disable(a.STENCIL_TEST)};this.setStencilWrite=function(b){w!==b&&(a.stencilMask(b),w=b)};this.setFlipSided=function(b){E!==b&&(b?a.frontFace(a.CW):a.frontFace(a.CCW),E=b)};this.setLineWidth=function(b){b!==
-K&&(a.lineWidth(b),K=b)};this.setPolygonOffset=function(b,c,d){b?this.enable(a.POLYGON_OFFSET_FILL):this.disable(a.POLYGON_OFFSET_FILL);!b||P===c&&N===d||(a.polygonOffset(c,d),P=c,N=d)};this.getScissorTest=function(){return L};this.setScissorTest=function(b){(L=b)?this.enable(a.SCISSOR_TEST):this.disable(a.SCISSOR_TEST)};this.activeTexture=function(b){void 0===b&&(b=a.TEXTURE0+B-1);M!==b&&(a.activeTexture(b),M=b)};this.bindTexture=function(b,c){void 0===M&&d.activeTexture();var e=Q[M];void 0===e&&
-(e={type:void 0,texture:void 0},Q[M]=e);if(e.type!==b||e.texture!==c)a.bindTexture(b,c),e.type=b,e.texture=c};this.compressedTexImage2D=function(){try{a.compressedTexImage2D.apply(a,arguments)}catch(b){console.error(b)}};this.texImage2D=function(){try{a.texImage2D.apply(a,arguments)}catch(b){console.error(b)}};this.clearColor=function(b,c,d,f){e.set(b,c,d,f);!1===O.equals(e)&&(a.clearColor(b,c,d,f),O.copy(e))};this.clearDepth=function(b){S!==b&&(a.clearDepth(b),S=b)};this.clearStencil=function(b){J!==
-b&&(a.clearStencil(b),J=b)};this.scissor=function(b){!1===F.equals(b)&&(a.scissor(b.x,b.y,b.z,b.w),F.copy(b))};this.viewport=function(b){!1===Y.equals(b)&&(a.viewport(b.x,b.y,b.z,b.w),Y.copy(b))};this.reset=function(){for(var b=0;b<g.length;b++)1===g[b]&&(a.disableVertexAttribArray(b),g[b]=0);k={};E=w=v=C=n=l=null}};
-THREE.LensFlarePlugin=function(a,b){var c,d,e,f,g,h,k,l,n,p,m=a.context,q=a.state,s,u,t,x,v,C;this.render=function(w,D,z){if(0!==b.length){w=new THREE.Vector3;var y=z.w/z.z,A=.5*z.z,H=.5*z.w,G=16/z.w,E=new THREE.Vector2(G*y,G),K=new THREE.Vector3(1,1,0),P=new THREE.Vector2(1,1);if(void 0===t){var G=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),N=new Uint16Array([0,1,2,0,2,3]);s=m.createBuffer();u=m.createBuffer();m.bindBuffer(m.ARRAY_BUFFER,s);m.bufferData(m.ARRAY_BUFFER,G,m.STATIC_DRAW);
-m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,u);m.bufferData(m.ELEMENT_ARRAY_BUFFER,N,m.STATIC_DRAW);v=m.createTexture();C=m.createTexture();q.bindTexture(m.TEXTURE_2D,v);m.texImage2D(m.TEXTURE_2D,0,m.RGB,16,16,0,m.RGB,m.UNSIGNED_BYTE,null);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.NEAREST);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.NEAREST);q.bindTexture(m.TEXTURE_2D,
-C);m.texImage2D(m.TEXTURE_2D,0,m.RGBA,16,16,0,m.RGBA,m.UNSIGNED_BYTE,null);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.NEAREST);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.NEAREST);var G=(x=0<m.getParameter(m.MAX_VERTEX_TEXTURE_IMAGE_UNITS))?{vertexShader:"uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif ( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility =        visibility.r / 9.0;\nvVisibility *= 1.0 - visibility.g / 9.0;\nvVisibility *=       visibility.b / 9.0;\nvVisibility *= 1.0 - visibility.a / 9.0;\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",
-fragmentShader:"uniform lowp int renderType;\nuniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif ( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if ( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"}:{vertexShader:"uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif ( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",
-fragmentShader:"precision mediump float;\nuniform lowp int renderType;\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvoid main() {\nif ( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if ( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * visibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},
-N=m.createProgram(),L=m.createShader(m.FRAGMENT_SHADER),B=m.createShader(m.VERTEX_SHADER),M="precision "+a.getPrecision()+" float;\n";m.shaderSource(L,M+G.fragmentShader);m.shaderSource(B,M+G.vertexShader);m.compileShader(L);m.compileShader(B);m.attachShader(N,L);m.attachShader(N,B);m.linkProgram(N);t=N;n=m.getAttribLocation(t,"position");p=m.getAttribLocation(t,"uv");c=m.getUniformLocation(t,"renderType");d=m.getUniformLocation(t,"map");e=m.getUniformLocation(t,"occlusionMap");f=m.getUniformLocation(t,
-"opacity");g=m.getUniformLocation(t,"color");h=m.getUniformLocation(t,"scale");k=m.getUniformLocation(t,"rotation");l=m.getUniformLocation(t,"screenPosition")}m.useProgram(t);q.initAttributes();q.enableAttribute(n);q.enableAttribute(p);q.disableUnusedAttributes();m.uniform1i(e,0);m.uniform1i(d,1);m.bindBuffer(m.ARRAY_BUFFER,s);m.vertexAttribPointer(n,2,m.FLOAT,!1,16,0);m.vertexAttribPointer(p,2,m.FLOAT,!1,16,8);m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,u);q.disable(m.CULL_FACE);q.setDepthWrite(!1);N=0;
-for(L=b.length;N<L;N++)if(G=16/z.w,E.set(G*y,G),B=b[N],w.set(B.matrixWorld.elements[12],B.matrixWorld.elements[13],B.matrixWorld.elements[14]),w.applyMatrix4(D.matrixWorldInverse),w.applyProjection(D.projectionMatrix),K.copy(w),P.x=K.x*A+A,P.y=K.y*H+H,x||0<P.x&&P.x<z.z&&0<P.y&&P.y<z.w){q.activeTexture(m.TEXTURE0);q.bindTexture(m.TEXTURE_2D,null);q.activeTexture(m.TEXTURE1);q.bindTexture(m.TEXTURE_2D,v);m.copyTexImage2D(m.TEXTURE_2D,0,m.RGB,z.x+P.x-8,z.y+P.y-8,16,16,0);m.uniform1i(c,0);m.uniform2f(h,
-E.x,E.y);m.uniform3f(l,K.x,K.y,K.z);q.disable(m.BLEND);q.enable(m.DEPTH_TEST);m.drawElements(m.TRIANGLES,6,m.UNSIGNED_SHORT,0);q.activeTexture(m.TEXTURE0);q.bindTexture(m.TEXTURE_2D,C);m.copyTexImage2D(m.TEXTURE_2D,0,m.RGBA,z.x+P.x-8,z.y+P.y-8,16,16,0);m.uniform1i(c,1);q.disable(m.DEPTH_TEST);q.activeTexture(m.TEXTURE1);q.bindTexture(m.TEXTURE_2D,v);m.drawElements(m.TRIANGLES,6,m.UNSIGNED_SHORT,0);B.positionScreen.copy(K);B.customUpdateCallback?B.customUpdateCallback(B):B.updateLensFlares();m.uniform1i(c,
-2);q.enable(m.BLEND);for(var M=0,Q=B.lensFlares.length;M<Q;M++){var O=B.lensFlares[M];.001<O.opacity&&.001<O.scale&&(K.x=O.x,K.y=O.y,K.z=O.z,G=O.size*O.scale/z.w,E.x=G*y,E.y=G,m.uniform3f(l,K.x,K.y,K.z),m.uniform2f(h,E.x,E.y),m.uniform1f(k,O.rotation),m.uniform1f(f,O.opacity),m.uniform3f(g,O.color.r,O.color.g,O.color.b),q.setBlending(O.blending,O.blendEquation,O.blendSrc,O.blendDst),a.setTexture(O.texture,1),m.drawElements(m.TRIANGLES,6,m.UNSIGNED_SHORT,0))}}q.enable(m.CULL_FACE);q.enable(m.DEPTH_TEST);
-q.setDepthWrite(!0);a.resetGLState()}}};
-THREE.SpritePlugin=function(a,b){var c,d,e,f,g,h,k,l,n,p,m,q,s,u,t,x,v;function C(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:b.id-a.id}var w=a.context,D=a.state,z,y,A,H,G=new THREE.Vector3,E=new THREE.Quaternion,K=new THREE.Vector3;this.render=function(P,N){if(0!==b.length){if(void 0===A){var L=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),B=new Uint16Array([0,1,2,0,2,3]);z=w.createBuffer();y=w.createBuffer();w.bindBuffer(w.ARRAY_BUFFER,
-z);w.bufferData(w.ARRAY_BUFFER,L,w.STATIC_DRAW);w.bindBuffer(w.ELEMENT_ARRAY_BUFFER,y);w.bufferData(w.ELEMENT_ARRAY_BUFFER,B,w.STATIC_DRAW);var L=w.createProgram(),B=w.createShader(w.VERTEX_SHADER),M=w.createShader(w.FRAGMENT_SHADER);w.shaderSource(B,["precision "+a.getPrecision()+" float;","uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\nvec4 finalPosition;\nfinalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition;\nfinalPosition = projectionMatrix * finalPosition;\ngl_Position = finalPosition;\n}"].join("\n"));
-w.shaderSource(M,["precision "+a.getPrecision()+" float;","uniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n"));
-w.compileShader(B);w.compileShader(M);w.attachShader(L,B);w.attachShader(L,M);w.linkProgram(L);A=L;x=w.getAttribLocation(A,"position");v=w.getAttribLocation(A,"uv");c=w.getUniformLocation(A,"uvOffset");d=w.getUniformLocation(A,"uvScale");e=w.getUniformLocation(A,"rotation");f=w.getUniformLocation(A,"scale");g=w.getUniformLocation(A,"color");h=w.getUniformLocation(A,"map");k=w.getUniformLocation(A,"opacity");l=w.getUniformLocation(A,"modelViewMatrix");n=w.getUniformLocation(A,"projectionMatrix");p=
-w.getUniformLocation(A,"fogType");m=w.getUniformLocation(A,"fogDensity");q=w.getUniformLocation(A,"fogNear");s=w.getUniformLocation(A,"fogFar");u=w.getUniformLocation(A,"fogColor");t=w.getUniformLocation(A,"alphaTest");L=document.createElement("canvas");L.width=8;L.height=8;B=L.getContext("2d");B.fillStyle="white";B.fillRect(0,0,8,8);H=new THREE.Texture(L);H.needsUpdate=!0}w.useProgram(A);D.initAttributes();D.enableAttribute(x);D.enableAttribute(v);D.disableUnusedAttributes();D.disable(w.CULL_FACE);
-D.enable(w.BLEND);w.bindBuffer(w.ARRAY_BUFFER,z);w.vertexAttribPointer(x,2,w.FLOAT,!1,16,0);w.vertexAttribPointer(v,2,w.FLOAT,!1,16,8);w.bindBuffer(w.ELEMENT_ARRAY_BUFFER,y);w.uniformMatrix4fv(n,!1,N.projectionMatrix.elements);D.activeTexture(w.TEXTURE0);w.uniform1i(h,0);B=L=0;(M=P.fog)?(w.uniform3f(u,M.color.r,M.color.g,M.color.b),M instanceof THREE.Fog?(w.uniform1f(q,M.near),w.uniform1f(s,M.far),w.uniform1i(p,1),B=L=1):M instanceof THREE.FogExp2&&(w.uniform1f(m,M.density),w.uniform1i(p,2),B=L=2)):
-(w.uniform1i(p,0),B=L=0);for(var M=0,Q=b.length;M<Q;M++){var O=b[M];O.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,O.matrixWorld);O.z=-O.modelViewMatrix.elements[14]}b.sort(C);for(var S=[],M=0,Q=b.length;M<Q;M++){var O=b[M],J=O.material;w.uniform1f(t,J.alphaTest);w.uniformMatrix4fv(l,!1,O.modelViewMatrix.elements);O.matrixWorld.decompose(G,E,K);S[0]=K.x;S[1]=K.y;O=0;P.fog&&J.fog&&(O=B);L!==O&&(w.uniform1i(p,O),L=O);null!==J.map?(w.uniform2f(c,J.map.offset.x,J.map.offset.y),w.uniform2f(d,
-J.map.repeat.x,J.map.repeat.y)):(w.uniform2f(c,0,0),w.uniform2f(d,1,1));w.uniform1f(k,J.opacity);w.uniform3f(g,J.color.r,J.color.g,J.color.b);w.uniform1f(e,J.rotation);w.uniform2fv(f,S);D.setBlending(J.blending,J.blendEquation,J.blendSrc,J.blendDst);D.setDepthTest(J.depthTest);D.setDepthWrite(J.depthWrite);J.map&&J.map.image&&J.map.image.width?a.setTexture(J.map,0):a.setTexture(H,0);w.drawElements(w.TRIANGLES,6,w.UNSIGNED_SHORT,0)}D.enable(w.CULL_FACE);a.resetGLState()}}};
-Object.defineProperties(THREE.Box2.prototype,{empty:{value:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");return this.isEmpty()}},isIntersectionBox:{value:function(a){console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)}}});
-Object.defineProperties(THREE.Box3.prototype,{empty:{value:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");return this.isEmpty()}},isIntersectionBox:{value:function(a){console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)}},isIntersectionSphere:{value:function(a){console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}}});
-Object.defineProperties(THREE.Matrix3.prototype,{multiplyVector3:{value:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)}},multiplyVector3Array:{value:function(a){console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)}}});
-Object.defineProperties(THREE.Matrix4.prototype,{extractPosition:{value:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");return this.copyPosition(a)}},setRotationFromQuaternion:{value:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");return this.makeRotationFromQuaternion(a)}},multiplyVector3:{value:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.");
-return a.applyProjection(this)}},multiplyVector4:{value:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)}},multiplyVector3Array:{value:function(a){console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)}},rotateAxis:{value:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");
-a.transformDirection(this)}},crossVector:{value:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)}},translate:{value:function(a){console.error("THREE.Matrix4: .translate() has been removed.")}},rotateX:{value:function(a){console.error("THREE.Matrix4: .rotateX() has been removed.")}},rotateY:{value:function(a){console.error("THREE.Matrix4: .rotateY() has been removed.")}},rotateZ:{value:function(a){console.error("THREE.Matrix4: .rotateZ() has been removed.")}},
-rotateByAxis:{value:function(a,b){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")}}});Object.defineProperties(THREE.Plane.prototype,{isIntersectionLine:{value:function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)}}});
-Object.defineProperties(THREE.Quaternion.prototype,{multiplyVector3:{value:function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)}}});
-Object.defineProperties(THREE.Ray.prototype,{isIntersectionBox:{value:function(a){console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)}},isIntersectionPlane:{value:function(a){console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");return this.intersectsPlane(a)}},isIntersectionSphere:{value:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}}});
-Object.defineProperties(THREE.Vector3.prototype,{setEulerFromRotationMatrix:{value:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")}},setEulerFromQuaternion:{value:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")}},getPositionFromMatrix:{value:function(a){console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");
-return this.setFromMatrixPosition(a)}},getScaleFromMatrix:{value:function(a){console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().");return this.setFromMatrixScale(a)}},getColumnFromMatrix:{value:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(a,b)}}});
-THREE.Face4=function(a,b,c,d,e,f,g){console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead.");return new THREE.Face3(a,b,c,e,f,g)};
-Object.defineProperties(THREE.Object3D.prototype,{eulerOrder:{get:function(){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");return this.rotation.order},set:function(a){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");this.rotation.order=a}},getChildByName:{value:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");return this.getObjectByName(a)}},renderDepth:{set:function(a){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")}},
-translate:{value:function(a,b){console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");return this.translateOnAxis(b,a)}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(a){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});
-Object.defineProperties(THREE,{PointCloud:{value:function(a,b){console.warn("THREE.PointCloud has been renamed to THREE.Points.");return new THREE.Points(a,b)}},ParticleSystem:{value:function(a,b){console.warn("THREE.ParticleSystem has been renamed to THREE.Points.");return new THREE.Points(a,b)}}});
-Object.defineProperties(THREE.Light.prototype,{onlyShadow:{set:function(a){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");this.shadow.camera.fov=a}},shadowCameraLeft:{set:function(a){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");this.shadow.camera.left=a}},shadowCameraRight:{set:function(a){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");
-this.shadow.camera.right=a}},shadowCameraTop:{set:function(a){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");this.shadow.camera.top=a}},shadowCameraBottom:{set:function(a){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");this.shadow.camera.bottom=a}},shadowCameraNear:{set:function(a){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");this.shadow.camera.near=a}},shadowCameraFar:{set:function(a){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");
-this.shadow.camera.far=a}},shadowCameraVisible:{set:function(a){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(a){console.warn("THREE.Light: .shadowBias is now .shadow.bias.");this.shadow.bias=a}},shadowDarkness:{set:function(a){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(a){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");
-this.shadow.mapSize.width=a}},shadowMapHeight:{set:function(a){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");this.shadow.mapSize.height=a}}});Object.defineProperties(THREE.BufferAttribute.prototype,{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count.");return this.array.length}}});
-Object.defineProperties(THREE.BufferGeometry.prototype,{drawcalls:{get:function(){console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");return this.groups}},offsets:{get:function(){console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");return this.groups}},addIndex:{value:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");this.setIndex(a)}},addDrawCall:{value:function(a,b,c){void 0!==c&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");
-console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");this.addGroup(a,b)}},clearDrawCalls:{value:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");this.clearGroups()}},computeTangents:{value:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")}},computeOffsets:{value:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}});
-Object.defineProperties(THREE.Material.prototype,{wrapAround:{get:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")},set:function(a){console.warn("THREE."+this.type+": .wrapAround has been removed.")}},wrapRGB:{get:function(){console.warn("THREE."+this.type+": .wrapRGB has been removed.");return new THREE.Color}}});
-Object.defineProperties(THREE,{PointCloudMaterial:{value:function(a){console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.");return new THREE.PointsMaterial(a)}},ParticleBasicMaterial:{value:function(a){console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.");return new THREE.PointsMaterial(a)}},ParticleSystemMaterial:{value:function(a){console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.");return new THREE.PointsMaterial(a)}}});
-Object.defineProperties(THREE.MeshPhongMaterial.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");return!1},set:function(a){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});
-Object.defineProperties(THREE.ShaderMaterial.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");return this.extensions.derivatives},set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});
-Object.defineProperties(THREE.WebGLRenderer.prototype,{supportsFloatTextures:{value:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");return this.extensions.get("OES_texture_float")}},supportsHalfFloatTextures:{value:function(){console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' ).");return this.extensions.get("OES_texture_half_float")}},supportsStandardDerivatives:{value:function(){console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");
-return this.extensions.get("OES_standard_derivatives")}},supportsCompressedTextureS3TC:{value:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).");return this.extensions.get("WEBGL_compressed_texture_s3tc")}},supportsCompressedTexturePVRTC:{value:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");return this.extensions.get("WEBGL_compressed_texture_pvrtc")}},
-supportsBlendMinMax:{value:function(){console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");return this.extensions.get("EXT_blend_minmax")}},supportsVertexTextures:{value:function(){return this.capabilities.vertexTextures}},supportsInstancedArrays:{value:function(){console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");return this.extensions.get("ANGLE_instanced_arrays")}},enableScissorTest:{value:function(a){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");
-this.setScissorTest(a)}},initMaterial:{value:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")}},addPrePlugin:{value:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")}},addPostPlugin:{value:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")}},updateShadowMap:{value:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}},shadowMapEnabled:{get:function(){return this.shadowMap.enabled},
-set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.");this.shadowMap.type=a}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.");this.shadowMap.cullFace=a}}});
-Object.defineProperties(THREE.WebGLRenderTarget.prototype,{wrapS:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");return this.texture.wrapS},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");this.texture.wrapS=a}},wrapT:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");return this.texture.wrapT},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");this.texture.wrapT=
-a}},magFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");return this.texture.magFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=a}},minFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");return this.texture.minFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");this.texture.minFilter=
-a}},anisotropy:{get:function(){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");return this.texture.anisotropy},set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=a}},offset:{get:function(){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");return this.texture.offset},set:function(a){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");this.texture.offset=
-a}},repeat:{get:function(){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");return this.texture.repeat},set:function(a){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");this.texture.repeat=a}},format:{get:function(){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");return this.texture.format},set:function(a){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");this.texture.format=a}},type:{get:function(){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");
-return this.texture.type},set:function(a){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");this.texture.type=a}},generateMipmaps:{get:function(){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");return this.texture.generateMipmaps},set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});
-THREE.GeometryUtils={merge:function(a,b,c){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");var d;b instanceof THREE.Mesh&&(b.matrixAutoUpdate&&b.updateMatrix(),d=b.matrix,b=b.geometry);a.merge(b,d,c)},center:function(a){console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.");return a.center()}};
-THREE.ImageUtils={crossOrigin:void 0,loadTexture:function(a,b,c,d){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var e=new THREE.TextureLoader;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a},loadTextureCube:function(a,b,c,d){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var e=new THREE.CubeTextureLoader;e.setCrossOrigin(this.crossOrigin);a=e.load(a,
-c,void 0,d);b&&(a.mapping=b);return a},loadCompressedTexture:function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},loadCompressedTextureCube:function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")}};
-THREE.Projector=function(){console.error("THREE.Projector has been moved to /examples/js/renderers/Projector.js.");this.projectVector=function(a,b){console.warn("THREE.Projector: .projectVector() is now vector.project().");a.project(b)};this.unprojectVector=function(a,b){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject().");a.unproject(b)};this.pickingRay=function(a,b){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}};
-THREE.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js");this.domElement=document.createElement("canvas");this.clear=function(){};this.render=function(){};this.setClearColor=function(){};this.setSize=function(){}};THREE.MeshFaceMaterial=THREE.MultiMaterial;
-THREE.CurveUtils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a,b,c,d,e){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){a=.5*(c-a);d=.5*(d-b);var f=e*e;return(2*b-2*c+a+d)*e*f+(-3*b+3*c-2*a-d)*f+a*e+b}};
-THREE.SceneUtils={createMultiMaterialObject:function(a,b){for(var c=new THREE.Group,d=0,e=b.length;d<e;d++)c.add(new THREE.Mesh(a,b[d]));return c},detach:function(a,b,c){a.applyMatrix(b.matrixWorld);b.remove(a);c.add(a)},attach:function(a,b,c){var d=new THREE.Matrix4;d.getInverse(c.matrixWorld);a.applyMatrix(d);b.remove(a);c.add(a)}};
-THREE.ShapeUtils={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;e<b;d=e++)c+=a[d].x*a[e].y-a[e].x*a[d].y;return.5*c},triangulate:function(){return function(a,b){var c=a.length;if(3>c)return null;var d=[],e=[],f=[],g,h,k;if(0<THREE.ShapeUtils.area(a))for(h=0;h<c;h++)e[h]=h;else for(h=0;h<c;h++)e[h]=c-1-h;var l=2*c;for(h=c-1;2<c;){if(0>=l--){console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()");break}g=h;c<=g&&(g=0);h=g+1;c<=h&&(h=0);k=h+1;c<=k&&(k=0);var n;a:{var p=
-n=void 0,m=void 0,q=void 0,s=void 0,u=void 0,t=void 0,x=void 0,v=void 0,p=a[e[g]].x,m=a[e[g]].y,q=a[e[h]].x,s=a[e[h]].y,u=a[e[k]].x,t=a[e[k]].y;if(Number.EPSILON>(q-p)*(t-m)-(s-m)*(u-p))n=!1;else{var C=void 0,w=void 0,D=void 0,z=void 0,y=void 0,A=void 0,H=void 0,G=void 0,E=void 0,K=void 0,E=G=H=v=x=void 0,C=u-q,w=t-s,D=p-u,z=m-t,y=q-p,A=s-m;for(n=0;n<c;n++)if(x=a[e[n]].x,v=a[e[n]].y,!(x===p&&v===m||x===q&&v===s||x===u&&v===t)&&(H=x-p,G=v-m,E=x-q,K=v-s,x-=u,v-=t,E=C*K-w*E,H=y*G-A*H,G=D*v-z*x,E>=-Number.EPSILON&&
-G>=-Number.EPSILON&&H>=-Number.EPSILON)){n=!1;break a}n=!0}}if(n){d.push([a[e[g]],a[e[h]],a[e[k]]]);f.push([e[g],e[h],e[k]]);g=h;for(k=h+1;k<c;g++,k++)e[g]=e[k];c--;l=2*c}}return b?f:d}}(),triangulateShape:function(a,b){function c(a,b,c){return a.x!==b.x?a.x<b.x?a.x<=c.x&&c.x<=b.x:b.x<=c.x&&c.x<=a.x:a.y<b.y?a.y<=c.y&&c.y<=b.y:b.y<=c.y&&c.y<=a.y}function d(a,b,d,e,f){var g=b.x-a.x,h=b.y-a.y,k=e.x-d.x,l=e.y-d.y,n=a.x-d.x,p=a.y-d.y,y=h*k-g*l,A=h*n-g*p;if(Math.abs(y)>Number.EPSILON){if(0<y){if(0>A||A>
-y)return[];k=l*n-k*p;if(0>k||k>y)return[]}else{if(0<A||A<y)return[];k=l*n-k*p;if(0<k||k<y)return[]}if(0===k)return!f||0!==A&&A!==y?[a]:[];if(k===y)return!f||0!==A&&A!==y?[b]:[];if(0===A)return[d];if(A===y)return[e];f=k/y;return[{x:a.x+f*g,y:a.y+f*h}]}if(0!==A||l*n!==k*p)return[];h=0===g&&0===h;k=0===k&&0===l;if(h&&k)return a.x!==d.x||a.y!==d.y?[]:[a];if(h)return c(d,e,a)?[a]:[];if(k)return c(a,b,d)?[d]:[];0!==g?(a.x<b.x?(g=a,k=a.x,h=b,a=b.x):(g=b,k=b.x,h=a,a=a.x),d.x<e.x?(b=d,y=d.x,l=e,d=e.x):(b=
-e,y=e.x,l=d,d=d.x)):(a.y<b.y?(g=a,k=a.y,h=b,a=b.y):(g=b,k=b.y,h=a,a=a.y),d.y<e.y?(b=d,y=d.y,l=e,d=e.y):(b=e,y=e.y,l=d,d=d.y));return k<=y?a<y?[]:a===y?f?[]:[b]:a<=d?[b,h]:[b,l]:k>d?[]:k===d?f?[]:[g]:a<=d?[g,h]:[g,l]}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return Math.abs(a)>Number.EPSILON?(b=g*c-d*b,0<a?0<=e&&0<=b:0<=e||0<=b):0<e}var f,g,h,k,l,n={};h=a.concat();f=0;for(g=b.length;f<g;f++)Array.prototype.push.apply(h,b[f]);f=0;for(g=
-h.length;f<g;f++)l=h[f].x+":"+h[f].y,void 0!==n[l]&&console.warn("THREE.Shape: Duplicate point",l),n[l]=f;f=function(a,b){function c(a,b){var d=h.length-1,f=a-1;0>f&&(f=d);var g=a+1;g>d&&(g=0);d=e(h[a],h[f],h[g],k[b]);if(!d)return!1;d=k.length-1;f=b-1;0>f&&(f=d);g=b+1;g>d&&(g=0);return(d=e(k[b],k[f],k[g],h[a]))?!0:!1}function f(a,b){var c,e;for(c=0;c<h.length;c++)if(e=c+1,e%=h.length,e=d(a,b,h[c],h[e],!0),0<e.length)return!0;return!1}function g(a,c){var e,f,h,k;for(e=0;e<l.length;e++)for(f=b[l[e]],
-h=0;h<f.length;h++)if(k=h+1,k%=f.length,k=d(a,c,f[h],f[k],!0),0<k.length)return!0;return!1}var h=a.concat(),k,l=[],n,p,z,y,A,H=[],G,E,K,P=0;for(n=b.length;P<n;P++)l.push(P);G=0;for(var N=2*l.length;0<l.length;){N--;if(0>N){console.log("Infinite Loop! Holes left:"+l.length+", Probably Hole outside Shape!");break}for(p=G;p<h.length;p++){z=h[p];n=-1;for(P=0;P<l.length;P++)if(y=l[P],A=z.x+":"+z.y+":"+y,void 0===H[A]){k=b[y];for(E=0;E<k.length;E++)if(y=k[E],c(p,E)&&!f(z,y)&&!g(z,y)){n=E;l.splice(P,1);
-G=h.slice(0,p+1);y=h.slice(p);E=k.slice(n);K=k.slice(0,n+1);h=G.concat(E).concat(K).concat(y);G=p;break}if(0<=n)break;H[A]=!0}if(0<=n)break}}return h}(a,b);var p=THREE.ShapeUtils.triangulate(f,!1);f=0;for(g=p.length;f<g;f++)for(k=p[f],h=0;3>h;h++)l=k[h].x+":"+k[h].y,l=n[l],void 0!==l&&(k[h]=l);return p.concat()},isClockWise:function(a){return 0>THREE.ShapeUtils.area(a)},b2:function(){return function(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}}(),b3:function(){return function(a,b,c,d,e){var f=
-1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}}()};THREE.Curve=function(){};
-THREE.Curve.prototype={constructor:THREE.Curve,getPoint:function(a){console.warn("THREE.Curve: Warning, getPoint() not implemented!");return null},getPointAt:function(a){a=this.getUtoTmapping(a);return this.getPoint(a)},getPoints:function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c},getSpacedPoints:function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c},getLength:function(){var a=this.getLengths();return a[a.length-1]},getLengths:function(a){a||
-(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length===a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var b=[],c,d=this.getPoint(0),e,f=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),f+=c.distanceTo(d),b.push(f),d=c;return this.cacheArcLengths=b},updateArcLengths:function(){this.needsUpdate=!0;this.getLengths()},getUtoTmapping:function(a,b){var c=this.getLengths(),d=0,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e-
-1,k;g<=h;)if(d=Math.floor(g+(h-g)/2),k=c[d]-f,0>k)g=d+1;else if(0<k)h=d-1;else{h=d;break}d=h;if(c[d]===f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)},getTangent:function(a){var b=a-1E-4;a+=1E-4;0>b&&(b=0);1<a&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().sub(b).normalize()},getTangentAt:function(a){a=this.getUtoTmapping(a);return this.getTangent(a)}};
-THREE.Curve.create=function(a,b){a.prototype=Object.create(THREE.Curve.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};THREE.CurvePath=function(){this.curves=[];this.autoClose=!1};THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype);THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};
-THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))};THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),d=0;d<c.length;){if(c[d]>=b)return a=this.curves[d],b=1-(c[d]-b)/a.getLength(),a.getPointAt(b);d++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]};
-THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;c<d;c++)b+=this.curves[c].getLength(),a.push(b);return this.cacheLengths=a};THREE.CurvePath.prototype.createPointsGeometry=function(a){a=this.getPoints(a);return this.createGeometry(a)};THREE.CurvePath.prototype.createSpacedPointsGeometry=function(a){a=this.getSpacedPoints(a);return this.createGeometry(a)};
-THREE.CurvePath.prototype.createGeometry=function(a){for(var b=new THREE.Geometry,c=0,d=a.length;c<d;c++){var e=a[c];b.vertices.push(new THREE.Vector3(e.x,e.y,e.z||0))}return b};THREE.Font=function(a){this.data=a};
-THREE.Font.prototype={constructor:THREE.Font,generateShapes:function(a,b,c){void 0===b&&(b=100);void 0===c&&(c=4);var d=this.data;a=String(a).split("");var e=b/d.resolution,f=0;b=[];for(var g=0;g<a.length;g++){var h;h=e;var k=f,l=d.glyphs[a[g]]||d.glyphs["?"];if(l){var n=new THREE.Path,p=[],m=THREE.ShapeUtils.b2,q=THREE.ShapeUtils.b3,s=void 0,u=void 0,t=u=s=void 0,x=void 0,v=void 0,C=void 0,w=void 0,D=void 0,x=void 0;if(l.o)for(var z=l._cachedOutline||(l._cachedOutline=l.o.split(" ")),y=0,A=z.length;y<
-A;)switch(z[y++]){case "m":s=z[y++]*h+k;u=z[y++]*h;n.moveTo(s,u);break;case "l":s=z[y++]*h+k;u=z[y++]*h;n.lineTo(s,u);break;case "q":s=z[y++]*h+k;u=z[y++]*h;v=z[y++]*h+k;C=z[y++]*h;n.quadraticCurveTo(v,C,s,u);if(x=p[p.length-1])for(var t=x.x,x=x.y,H=1;H<=c;H++){var G=H/c;m(G,t,v,s);m(G,x,C,u)}break;case "b":if(s=z[y++]*h+k,u=z[y++]*h,v=z[y++]*h+k,C=z[y++]*h,w=z[y++]*h+k,D=z[y++]*h,n.bezierCurveTo(v,C,w,D,s,u),x=p[p.length-1])for(t=x.x,x=x.y,H=1;H<=c;H++)G=H/c,q(G,t,v,w,s),q(G,x,C,D,u)}h={offset:l.ha*
-h,path:n}}else h=void 0;f+=h.offset;b.push(h.path)}c=[];d=0;for(a=b.length;d<a;d++)Array.prototype.push.apply(c,b[d].toShapes());return c}};THREE.Path=function(a){THREE.CurvePath.call(this);this.actions=[];a&&this.fromPoints(a)};THREE.Path.prototype=Object.create(THREE.CurvePath.prototype);THREE.Path.prototype.constructor=THREE.Path;THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)};
-THREE.Path.prototype.moveTo=function(a,b){this.actions.push({action:"moveTo",args:[a,b]})};THREE.Path.prototype.lineTo=function(a,b){var c=this.actions[this.actions.length-1].args,c=new THREE.LineCurve(new THREE.Vector2(c[c.length-2],c[c.length-1]),new THREE.Vector2(a,b));this.curves.push(c);this.actions.push({action:"lineTo",args:[a,b]})};
-THREE.Path.prototype.quadraticCurveTo=function(a,b,c,d){var e=this.actions[this.actions.length-1].args,e=new THREE.QuadraticBezierCurve(new THREE.Vector2(e[e.length-2],e[e.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d));this.curves.push(e);this.actions.push({action:"quadraticCurveTo",args:[a,b,c,d]})};
-THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,e,f){var g=this.actions[this.actions.length-1].args,g=new THREE.CubicBezierCurve(new THREE.Vector2(g[g.length-2],g[g.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(e,f));this.curves.push(g);this.actions.push({action:"bezierCurveTo",args:[a,b,c,d,e,f]})};
-THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);c=new THREE.SplineCurve(c);this.curves.push(c);this.actions.push({action:"splineThru",args:b})};THREE.Path.prototype.arc=function(a,b,c,d,e,f){var g=this.actions[this.actions.length-1].args;this.absarc(a+g[g.length-2],b+g[g.length-1],c,d,e,f)};
-THREE.Path.prototype.absarc=function(a,b,c,d,e,f){this.absellipse(a,b,c,c,d,e,f)};THREE.Path.prototype.ellipse=function(a,b,c,d,e,f,g,h){var k=this.actions[this.actions.length-1].args;this.absellipse(a+k[k.length-2],b+k[k.length-1],c,d,e,f,g,h)};THREE.Path.prototype.absellipse=function(a,b,c,d,e,f,g,h){var k=[a,b,c,d,e,f,g,h||0];a=new THREE.EllipseCurve(a,b,c,d,e,f,g,h);this.curves.push(a);a=a.getPoint(1);k.push(a.x);k.push(a.y);this.actions.push({action:"ellipse",args:k})};
-THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));this.autoClose&&b.push(b[0]);return b};
-THREE.Path.prototype.getPoints=function(a){a=a||12;for(var b=THREE.ShapeUtils.b2,c=THREE.ShapeUtils.b3,d=[],e,f,g,h,k,l,n,p,m,q,s=0,u=this.actions.length;s<u;s++){m=this.actions[s];var t=m.args;switch(m.action){case "moveTo":d.push(new THREE.Vector2(t[0],t[1]));break;case "lineTo":d.push(new THREE.Vector2(t[0],t[1]));break;case "quadraticCurveTo":e=t[2];f=t[3];k=t[0];l=t[1];0<d.length?(m=d[d.length-1],n=m.x,p=m.y):(m=this.actions[s-1].args,n=m[m.length-2],p=m[m.length-1]);for(t=1;t<=a;t++)q=t/a,m=
-b(q,n,k,e),q=b(q,p,l,f),d.push(new THREE.Vector2(m,q));break;case "bezierCurveTo":e=t[4];f=t[5];k=t[0];l=t[1];g=t[2];h=t[3];0<d.length?(m=d[d.length-1],n=m.x,p=m.y):(m=this.actions[s-1].args,n=m[m.length-2],p=m[m.length-1]);for(t=1;t<=a;t++)q=t/a,m=c(q,n,k,g,e),q=c(q,p,l,h,f),d.push(new THREE.Vector2(m,q));break;case "splineThru":m=this.actions[s-1].args;q=[new THREE.Vector2(m[m.length-2],m[m.length-1])];m=a*t[0].length;q=q.concat(t[0]);q=new THREE.SplineCurve(q);for(t=1;t<=m;t++)d.push(q.getPointAt(t/
-m));break;case "arc":e=t[0];f=t[1];l=t[2];g=t[3];m=t[4];k=!!t[5];n=m-g;p=2*a;for(t=1;t<=p;t++)q=t/p,k||(q=1-q),q=g+q*n,m=e+l*Math.cos(q),q=f+l*Math.sin(q),d.push(new THREE.Vector2(m,q));break;case "ellipse":e=t[0];f=t[1];l=t[2];h=t[3];g=t[4];m=t[5];k=!!t[6];var x=t[7];n=m-g;p=2*a;var v,C;0!==x&&(v=Math.cos(x),C=Math.sin(x));for(t=1;t<=p;t++){q=t/p;k||(q=1-q);q=g+q*n;m=e+l*Math.cos(q);q=f+h*Math.sin(q);if(0!==x){var w=m;m=(w-e)*v-(q-f)*C+e;q=(w-e)*C+(q-f)*v+f}d.push(new THREE.Vector2(m,q))}}}a=d[d.length-
-1];Math.abs(a.x-d[0].x)<Number.EPSILON&&Math.abs(a.y-d[0].y)<Number.EPSILON&&d.splice(d.length-1,1);this.autoClose&&d.push(d[0]);return d};
-THREE.Path.prototype.toShapes=function(a,b){function c(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c],f=new THREE.Shape;f.actions=e.actions;f.curves=e.curves;b.push(f)}return b}function d(a,b){for(var c=b.length,d=!1,e=c-1,f=0;f<c;e=f++){var g=b[e],h=b[f],k=h.x-g.x,l=h.y-g.y;if(Math.abs(l)>Number.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.y<g.y||a.y>h.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||
-g.x<=a.x&&a.x<=h.x))return!0}return d}var e=THREE.ShapeUtils.isClockWise,f=function(a){for(var b=[],c=new THREE.Path,d=0,e=a.length;d<e;d++){var f=a[d],g=f.args,f=f.action;"moveTo"===f&&0!==c.actions.length&&(b.push(c),c=new THREE.Path);c[f].apply(c,g)}0!==c.actions.length&&b.push(c);return b}(this.actions);if(0===f.length)return[];if(!0===b)return c(f);var g,h,k,l=[];if(1===f.length)return h=f[0],k=new THREE.Shape,k.actions=h.actions,k.curves=h.curves,l.push(k),l;var n=!e(f[0].getPoints()),n=a?!n:
-n;k=[];var p=[],m=[],q=0,s;p[q]=void 0;m[q]=[];for(var u=0,t=f.length;u<t;u++)h=f[u],s=h.getPoints(),g=e(s),(g=a?!g:g)?(!n&&p[q]&&q++,p[q]={s:new THREE.Shape,p:s},p[q].s.actions=h.actions,p[q].s.curves=h.curves,n&&q++,m[q]=[]):m[q].push({h:h,p:s[0]});if(!p[0])return c(f);if(1<p.length){u=!1;h=[];e=0;for(f=p.length;e<f;e++)k[e]=[];e=0;for(f=p.length;e<f;e++)for(g=m[e],n=0;n<g.length;n++){q=g[n];s=!0;for(t=0;t<p.length;t++)d(q.p,p[t].p)&&(e!==t&&h.push({froms:e,tos:t,hole:n}),s?(s=!1,k[t].push(q)):
-u=!0);s&&k[e].push(q)}0<h.length&&(u||(m=k))}u=0;for(e=p.length;u<e;u++)for(k=p[u].s,l.push(k),h=m[u],f=0,g=h.length;f<g;f++)k.holes.push(h[f].h);return l};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=Object.create(THREE.Path.prototype);THREE.Shape.prototype.constructor=THREE.Shape;THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};THREE.Shape.prototype.makeGeometry=function(a){return new THREE.ShapeGeometry(this,a)};
-THREE.Shape.prototype.getPointsHoles=function(a){for(var b=[],c=0,d=this.holes.length;c<d;c++)b[c]=this.holes[c].getPoints(a);return b};THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getPoints(a),holes:this.getPointsHoles(a)}};THREE.Shape.prototype.extractPoints=function(a){return this.extractAllPoints(a)};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.constructor=THREE.LineCurve;
-THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().sub(this.v1);b.multiplyScalar(a).add(this.v1);return b};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(a){return this.v2.clone().sub(this.v1).normalize()};THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;
-THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b=THREE.ShapeUtils.b2;return new THREE.Vector2(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b=THREE.CurveUtils.tangentQuadraticBezier;return(new THREE.Vector2(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))).normalize()};THREE.CubicBezierCurve=function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d};
-THREE.CubicBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve;THREE.CubicBezierCurve.prototype.getPoint=function(a){var b=THREE.ShapeUtils.b3;return new THREE.Vector2(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))};
-THREE.CubicBezierCurve.prototype.getTangent=function(a){var b=THREE.CurveUtils.tangentCubicBezier;return(new THREE.Vector2(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))).normalize()};THREE.SplineCurve=function(a){this.points=void 0==a?[]:a};THREE.SplineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.SplineCurve.prototype.constructor=THREE.SplineCurve;
-THREE.SplineCurve.prototype.getPoint=function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0===c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=THREE.CurveUtils.interpolate;return new THREE.Vector2(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a))};THREE.EllipseCurve=function(a,b,c,d,e,f,g,h){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g;this.aRotation=h||0};THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype);
-THREE.EllipseCurve.prototype.constructor=THREE.EllipseCurve;
-THREE.EllipseCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;0>b&&(b+=2*Math.PI);b>2*Math.PI&&(b-=2*Math.PI);b=!0===this.aClockwise?this.aEndAngle+(1-a)*(2*Math.PI-b):this.aStartAngle+a*b;a=this.aX+this.xRadius*Math.cos(b);var c=this.aY+this.yRadius*Math.sin(b);if(0!==this.aRotation){var b=Math.cos(this.aRotation),d=Math.sin(this.aRotation),e=a;a=(e-this.aX)*b-(c-this.aY)*d+this.aX;c=(e-this.aX)*d+(c-this.aY)*b+this.aY}return new THREE.Vector2(a,c)};
-THREE.ArcCurve=function(a,b,c,d,e,f){THREE.EllipseCurve.call(this,a,b,c,c,d,e,f)};THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype);THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.subVectors(this.v2,this.v1);b.multiplyScalar(a);b.add(this.v1);return b});
-THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b=THREE.ShapeUtils.b2;return new THREE.Vector3(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y),b(a,this.v0.z,this.v1.z,this.v2.z))});
-THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b=THREE.ShapeUtils.b3;return new THREE.Vector3(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y),b(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z))});
-THREE.SplineCurve3=THREE.Curve.create(function(a){console.warn("THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3");this.points=void 0==a?[]:a},function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=THREE.CurveUtils.interpolate;return new THREE.Vector3(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a),c(d.z,e.z,f.z,b.z,a))});
-THREE.CatmullRomCurve3=function(){function a(){}var b=new THREE.Vector3,c=new a,d=new a,e=new a;a.prototype.init=function(a,b,c,d){this.c0=a;this.c1=c;this.c2=-3*a+3*b-2*c-d;this.c3=2*a-2*b+c+d};a.prototype.initNonuniformCatmullRom=function(a,b,c,d,e,n,p){a=((b-a)/e-(c-a)/(e+n)+(c-b)/n)*n;d=((c-b)/n-(d-b)/(n+p)+(d-c)/p)*n;this.init(b,c,a,d)};a.prototype.initCatmullRom=function(a,b,c,d,e){this.init(b,c,e*(c-a),e*(d-b))};a.prototype.calc=function(a){var b=a*a;return this.c0+this.c1*a+this.c2*b+this.c3*
-b*a};return THREE.Curve.create(function(a){this.points=a||[];this.closed=!1},function(a){var g=this.points,h,k;k=g.length;2>k&&console.log("duh, you need at least 2 points");a*=k-(this.closed?0:1);h=Math.floor(a);a-=h;this.closed?h+=0<h?0:(Math.floor(Math.abs(h)/g.length)+1)*g.length:0===a&&h===k-1&&(h=k-2,a=1);var l,n,p;this.closed||0<h?l=g[(h-1)%k]:(b.subVectors(g[0],g[1]).add(g[0]),l=b);n=g[h%k];p=g[(h+1)%k];this.closed||h+2<k?g=g[(h+2)%k]:(b.subVectors(g[k-1],g[k-2]).add(g[k-1]),g=b);if(void 0===
-this.type||"centripetal"===this.type||"chordal"===this.type){var m="chordal"===this.type?.5:.25;k=Math.pow(l.distanceToSquared(n),m);h=Math.pow(n.distanceToSquared(p),m);m=Math.pow(p.distanceToSquared(g),m);1E-4>h&&(h=1);1E-4>k&&(k=h);1E-4>m&&(m=h);c.initNonuniformCatmullRom(l.x,n.x,p.x,g.x,k,h,m);d.initNonuniformCatmullRom(l.y,n.y,p.y,g.y,k,h,m);e.initNonuniformCatmullRom(l.z,n.z,p.z,g.z,k,h,m)}else"catmullrom"===this.type&&(k=void 0!==this.tension?this.tension:.5,c.initCatmullRom(l.x,n.x,p.x,g.x,
-k),d.initCatmullRom(l.y,n.y,p.y,g.y,k),e.initCatmullRom(l.z,n.z,p.z,g.z,k));return new THREE.Vector3(c.calc(a),d.calc(a),e.calc(a))})}();THREE.ClosedSplineCurve3=function(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.");THREE.CatmullRomCurve3.call(this,a);this.type="catmullrom";this.closed=!0};THREE.ClosedSplineCurve3.prototype=Object.create(THREE.CatmullRomCurve3.prototype);
-THREE.BoxGeometry=function(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,u){var t,x=h.widthSegments,v=h.heightSegments,C=e/2,w=f/2,D=h.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)t="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)t="y",v=h.depthSegments;else if("z"===a&&"y"===b||"y"===a&&"z"===b)t="x",x=h.depthSegments;var z=x+1,y=v+1,A=e/x,H=f/v,G=new THREE.Vector3;G[t]=0<g?1:-1;for(e=0;e<y;e++)for(f=0;f<z;f++){var E=new THREE.Vector3;E[a]=(f*A-C)*c;E[b]=(e*H-w)*d;E[t]=g;h.vertices.push(E)}for(e=
-0;e<v;e++)for(f=0;f<x;f++)w=f+z*e,a=f+z*(e+1),b=f+1+z*(e+1),c=f+1+z*e,d=new THREE.Vector2(f/x,1-e/v),g=new THREE.Vector2(f/x,1-(e+1)/v),t=new THREE.Vector2((f+1)/x,1-(e+1)/v),C=new THREE.Vector2((f+1)/x,1-e/v),w=new THREE.Face3(w+D,a+D,c+D),w.normal.copy(G),w.vertexNormals.push(G.clone(),G.clone(),G.clone()),w.materialIndex=u,h.faces.push(w),h.faceVertexUvs[0].push([d,g,C]),w=new THREE.Face3(a+D,b+D,c+D),w.normal.copy(G),w.vertexNormals.push(G.clone(),G.clone(),G.clone()),w.materialIndex=u,h.faces.push(w),
-h.faceVertexUvs[0].push([g.clone(),t,C.clone()])}THREE.Geometry.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.widthSegments=d||1;this.heightSegments=e||1;this.depthSegments=f||1;var h=this;d=a/2;e=b/2;f=c/2;g("z","y",-1,-1,c,b,d,0);g("z","y",1,-1,c,b,-d,1);g("x","z",1,1,a,c,e,2);g("x","z",1,-1,a,c,-e,3);g("x","y",1,-1,a,b,f,4);g("x","y",-1,-1,a,b,-f,5);this.mergeVertices()};THREE.BoxGeometry.prototype=Object.create(THREE.Geometry.prototype);
-THREE.BoxGeometry.prototype.constructor=THREE.BoxGeometry;THREE.CubeGeometry=THREE.BoxGeometry;THREE.CircleGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="CircleGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};this.fromBufferGeometry(new THREE.CircleBufferGeometry(a,b,c,d))};THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.CircleGeometry.prototype.constructor=THREE.CircleGeometry;
-THREE.CircleBufferGeometry=function(a,b,c,d){THREE.BufferGeometry.call(this);this.type="CircleBufferGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};a=a||50;b=void 0!==b?Math.max(3,b):8;c=void 0!==c?c:0;d=void 0!==d?d:2*Math.PI;var e=b+2,f=new Float32Array(3*e),g=new Float32Array(3*e),e=new Float32Array(2*e);g[2]=1;e[0]=.5;e[1]=.5;for(var h=0,k=3,l=2;h<=b;h++,k+=3,l+=2){var n=c+h/b*d;f[k]=a*Math.cos(n);f[k+1]=a*Math.sin(n);g[k+2]=1;e[l]=(f[k]/a+1)/2;e[l+1]=(f[k+1]/a+1)/2}c=
-[];for(k=1;k<=b;k++)c.push(k,k+1,0);this.setIndex(new THREE.BufferAttribute(new Uint16Array(c),1));this.addAttribute("position",new THREE.BufferAttribute(f,3));this.addAttribute("normal",new THREE.BufferAttribute(g,3));this.addAttribute("uv",new THREE.BufferAttribute(e,2));this.boundingSphere=new THREE.Sphere(new THREE.Vector3,a)};THREE.CircleBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.CircleBufferGeometry.prototype.constructor=THREE.CircleBufferGeometry;
-THREE.CylinderGeometry=function(a,b,c,d,e,f,g,h){THREE.Geometry.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};a=void 0!==a?a:20;b=void 0!==b?b:20;c=void 0!==c?c:100;d=d||8;e=e||1;f=void 0!==f?f:!1;g=void 0!==g?g:0;h=void 0!==h?h:2*Math.PI;var k=c/2,l,n,p=[],m=[];for(n=0;n<=e;n++){var q=[],s=[],u=n/e,t=u*(b-a)+a;for(l=0;l<=d;l++){var x=l/d,v=new THREE.Vector3;v.x=t*Math.sin(x*h+
-g);v.y=-u*c+k;v.z=t*Math.cos(x*h+g);this.vertices.push(v);q.push(this.vertices.length-1);s.push(new THREE.Vector2(x,1-u))}p.push(q);m.push(s)}c=(b-a)/c;for(l=0;l<d;l++)for(0!==a?(g=this.vertices[p[0][l]].clone(),h=this.vertices[p[0][l+1]].clone()):(g=this.vertices[p[1][l]].clone(),h=this.vertices[p[1][l+1]].clone()),g.setY(Math.sqrt(g.x*g.x+g.z*g.z)*c).normalize(),h.setY(Math.sqrt(h.x*h.x+h.z*h.z)*c).normalize(),n=0;n<e;n++){var q=p[n][l],s=p[n+1][l],u=p[n+1][l+1],t=p[n][l+1],x=g.clone(),v=g.clone(),
-C=h.clone(),w=h.clone(),D=m[n][l].clone(),z=m[n+1][l].clone(),y=m[n+1][l+1].clone(),A=m[n][l+1].clone();this.faces.push(new THREE.Face3(q,s,t,[x,v,w]));this.faceVertexUvs[0].push([D,z,A]);this.faces.push(new THREE.Face3(s,u,t,[v.clone(),C,w.clone()]));this.faceVertexUvs[0].push([z.clone(),y,A.clone()])}if(!1===f&&0<a)for(this.vertices.push(new THREE.Vector3(0,k,0)),l=0;l<d;l++)q=p[0][l],s=p[0][l+1],u=this.vertices.length-1,x=new THREE.Vector3(0,1,0),v=new THREE.Vector3(0,1,0),C=new THREE.Vector3(0,
-1,0),D=m[0][l].clone(),z=m[0][l+1].clone(),y=new THREE.Vector2(z.x,0),this.faces.push(new THREE.Face3(q,s,u,[x,v,C],void 0,1)),this.faceVertexUvs[0].push([D,z,y]);if(!1===f&&0<b)for(this.vertices.push(new THREE.Vector3(0,-k,0)),l=0;l<d;l++)q=p[e][l+1],s=p[e][l],u=this.vertices.length-1,x=new THREE.Vector3(0,-1,0),v=new THREE.Vector3(0,-1,0),C=new THREE.Vector3(0,-1,0),D=m[e][l+1].clone(),z=m[e][l].clone(),y=new THREE.Vector2(z.x,1),this.faces.push(new THREE.Face3(q,s,u,[x,v,C],void 0,2)),this.faceVertexUvs[0].push([D,
-z,y]);this.computeFaceNormals()};THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
-THREE.EdgesGeometry=function(a,b){function c(a,b){return a-b}THREE.BufferGeometry.call(this);var d=Math.cos(THREE.Math.degToRad(void 0!==b?b:1)),e=[0,0],f={},g=["a","b","c"],h;a instanceof THREE.BufferGeometry?(h=new THREE.Geometry,h.fromBufferGeometry(a)):h=a.clone();h.mergeVertices();h.computeFaceNormals();var k=h.vertices;h=h.faces;for(var l=0,n=h.length;l<n;l++)for(var p=h[l],m=0;3>m;m++){e[0]=p[g[m]];e[1]=p[g[(m+1)%3]];e.sort(c);var q=e.toString();void 0===f[q]?f[q]={vert1:e[0],vert2:e[1],face1:l,
-face2:void 0}:f[q].face2=l}e=[];for(q in f)if(g=f[q],void 0===g.face2||h[g.face1].normal.dot(h[g.face2].normal)<=d)l=k[g.vert1],e.push(l.x),e.push(l.y),e.push(l.z),l=k[g.vert2],e.push(l.x),e.push(l.y),e.push(l.z);this.addAttribute("position",new THREE.BufferAttribute(new Float32Array(e),3))};THREE.EdgesGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.EdgesGeometry.prototype.constructor=THREE.EdgesGeometry;
-THREE.ExtrudeGeometry=function(a,b){"undefined"!==typeof a&&(THREE.Geometry.call(this),this.type="ExtrudeGeometry",a=Array.isArray(a)?a:[a],this.addShapeList(a,b),this.computeFaceNormals())};THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
-THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.error("THREE.ExtrudeGeometry: vec does not exist");return b.clone().multiplyScalar(c).add(a)}function d(a,b,c){var d=1,d=a.x-b.x,e=a.y-b.y,f=c.x-a.x,g=c.y-a.y,h=d*d+e*e;if(Math.abs(d*g-e*f)>Number.EPSILON){var k=Math.sqrt(h),l=Math.sqrt(f*f+g*g),h=b.x-e/k;b=b.y+d/k;f=((c.x-g/l-h)*g-(c.y+f/l-b)*f)/(d*g-e*f);c=h+d*f-a.x;a=b+e*f-a.y;d=c*c+a*a;if(2>=d)return new THREE.Vector2(c,a);d=Math.sqrt(d/2)}else a=!1,d>Number.EPSILON?
-f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(c=-e,a=d,d=Math.sqrt(h)):(c=d,a=e,d=Math.sqrt(h/2));return new THREE.Vector2(c/d,a/d)}function e(a,b){var c,d;for(F=a.length;0<=--F;){c=F;d=F-1;0>d&&(d=a.length-1);for(var e=0,f=q+2*n,e=0;e<f;e++){var g=O*e,h=O*(e+1),k=b+c+g,g=b+d+g,l=b+d+h,h=b+c+h,k=k+G,g=g+G,l=l+G,h=h+G;H.faces.push(new THREE.Face3(k,g,h,null,null,1));H.faces.push(new THREE.Face3(g,l,h,null,null,1));k=x.generateSideWallUV(H,
-k,g,l,h);H.faceVertexUvs[0].push([k[0],k[1],k[3]]);H.faceVertexUvs[0].push([k[1],k[2],k[3]])}}}function f(a,b,c){H.vertices.push(new THREE.Vector3(a,b,c))}function g(a,b,c){a+=G;b+=G;c+=G;H.faces.push(new THREE.Face3(a,b,c,null,null,0));a=x.generateTopUV(H,a,b,c);H.faceVertexUvs[0].push(a)}var h=void 0!==b.amount?b.amount:100,k=void 0!==b.bevelThickness?b.bevelThickness:6,l=void 0!==b.bevelSize?b.bevelSize:k-2,n=void 0!==b.bevelSegments?b.bevelSegments:3,p=void 0!==b.bevelEnabled?b.bevelEnabled:!0,
-m=void 0!==b.curveSegments?b.curveSegments:12,q=void 0!==b.steps?b.steps:1,s=b.extrudePath,u,t=!1,x=void 0!==b.UVGenerator?b.UVGenerator:THREE.ExtrudeGeometry.WorldUVGenerator,v,C,w,D;s&&(u=s.getSpacedPoints(q),t=!0,p=!1,v=void 0!==b.frames?b.frames:new THREE.TubeGeometry.FrenetFrames(s,q,!1),C=new THREE.Vector3,w=new THREE.Vector3,D=new THREE.Vector3);p||(l=k=n=0);var z,y,A,H=this,G=this.vertices.length,s=a.extractPoints(m),m=s.shape,E=s.holes;if(s=!THREE.ShapeUtils.isClockWise(m)){m=m.reverse();
-y=0;for(A=E.length;y<A;y++)z=E[y],THREE.ShapeUtils.isClockWise(z)&&(E[y]=z.reverse());s=!1}var K=THREE.ShapeUtils.triangulateShape(m,E),P=m;y=0;for(A=E.length;y<A;y++)z=E[y],m=m.concat(z);var N,L,B,M,Q,O=m.length,S,J=K.length,s=[],F=0;B=P.length;N=B-1;for(L=F+1;F<B;F++,N++,L++)N===B&&(N=0),L===B&&(L=0),s[F]=d(P[F],P[N],P[L]);var Y=[],V,aa=s.concat();y=0;for(A=E.length;y<A;y++){z=E[y];V=[];F=0;B=z.length;N=B-1;for(L=F+1;F<B;F++,N++,L++)N===B&&(N=0),L===B&&(L=0),V[F]=d(z[F],z[N],z[L]);Y.push(V);aa=
-aa.concat(V)}for(N=0;N<n;N++){B=N/n;M=k*(1-B);L=l*Math.sin(B*Math.PI/2);F=0;for(B=P.length;F<B;F++)Q=c(P[F],s[F],L),f(Q.x,Q.y,-M);y=0;for(A=E.length;y<A;y++)for(z=E[y],V=Y[y],F=0,B=z.length;F<B;F++)Q=c(z[F],V[F],L),f(Q.x,Q.y,-M)}L=l;for(F=0;F<O;F++)Q=p?c(m[F],aa[F],L):m[F],t?(w.copy(v.normals[0]).multiplyScalar(Q.x),C.copy(v.binormals[0]).multiplyScalar(Q.y),D.copy(u[0]).add(w).add(C),f(D.x,D.y,D.z)):f(Q.x,Q.y,0);for(B=1;B<=q;B++)for(F=0;F<O;F++)Q=p?c(m[F],aa[F],L):m[F],t?(w.copy(v.normals[B]).multiplyScalar(Q.x),
-C.copy(v.binormals[B]).multiplyScalar(Q.y),D.copy(u[B]).add(w).add(C),f(D.x,D.y,D.z)):f(Q.x,Q.y,h/q*B);for(N=n-1;0<=N;N--){B=N/n;M=k*(1-B);L=l*Math.sin(B*Math.PI/2);F=0;for(B=P.length;F<B;F++)Q=c(P[F],s[F],L),f(Q.x,Q.y,h+M);y=0;for(A=E.length;y<A;y++)for(z=E[y],V=Y[y],F=0,B=z.length;F<B;F++)Q=c(z[F],V[F],L),t?f(Q.x,Q.y+u[q-1].y,u[q-1].x+M):f(Q.x,Q.y,h+M)}(function(){if(p){var a;a=0*O;for(F=0;F<J;F++)S=K[F],g(S[2]+a,S[1]+a,S[0]+a);a=q+2*n;a*=O;for(F=0;F<J;F++)S=K[F],g(S[0]+a,S[1]+a,S[2]+a)}else{for(F=
-0;F<J;F++)S=K[F],g(S[2],S[1],S[0]);for(F=0;F<J;F++)S=K[F],g(S[0]+O*q,S[1]+O*q,S[2]+O*q)}})();(function(){var a=0;e(P,a);a+=P.length;y=0;for(A=E.length;y<A;y++)z=E[y],e(z,a),a+=z.length})()};
-THREE.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(a,b,c,d){a=a.vertices;b=a[b];c=a[c];d=a[d];return[new THREE.Vector2(b.x,b.y),new THREE.Vector2(c.x,c.y),new THREE.Vector2(d.x,d.y)]},generateSideWallUV:function(a,b,c,d,e){a=a.vertices;b=a[b];c=a[c];d=a[d];e=a[e];return.01>Math.abs(b.y-c.y)?[new THREE.Vector2(b.x,1-b.z),new THREE.Vector2(c.x,1-c.z),new THREE.Vector2(d.x,1-d.z),new THREE.Vector2(e.x,1-e.z)]:[new THREE.Vector2(b.y,1-b.z),new THREE.Vector2(c.y,1-c.z),new THREE.Vector2(d.y,
-1-d.z),new THREE.Vector2(e.y,1-e.z)]}};THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);this.type="ShapeGeometry";!1===Array.isArray(a)&&(a=[a]);this.addShapeList(a,b);this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ShapeGeometry.prototype.constructor=THREE.ShapeGeometry;THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;c<d;c++)this.addShape(a[c],b);return this};
-THREE.ShapeGeometry.prototype.addShape=function(a,b){void 0===b&&(b={});var c=b.material,d=void 0===b.UVGenerator?THREE.ExtrudeGeometry.WorldUVGenerator:b.UVGenerator,e,f,g,h=this.vertices.length;e=a.extractPoints(void 0!==b.curveSegments?b.curveSegments:12);var k=e.shape,l=e.holes;if(!THREE.ShapeUtils.isClockWise(k))for(k=k.reverse(),e=0,f=l.length;e<f;e++)g=l[e],THREE.ShapeUtils.isClockWise(g)&&(l[e]=g.reverse());var n=THREE.ShapeUtils.triangulateShape(k,l);e=0;for(f=l.length;e<f;e++)g=l[e],k=k.concat(g);
-l=k.length;f=n.length;for(e=0;e<l;e++)g=k[e],this.vertices.push(new THREE.Vector3(g.x,g.y,0));for(e=0;e<f;e++)l=n[e],k=l[0]+h,g=l[1]+h,l=l[2]+h,this.faces.push(new THREE.Face3(k,g,l,null,null,c)),this.faceVertexUvs[0].push(d.generateTopUV(this,k,g,l))};
-THREE.LatheGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};b=b||12;c=c||0;d=d||2*Math.PI;for(var e=1/(a.length-1),f=1/b,g=0,h=b;g<=h;g++)for(var k=c+g*f*d,l=Math.sin(k),n=Math.cos(k),k=0,p=a.length;k<p;k++){var m=a[k],q=new THREE.Vector3;q.x=m.x*l;q.y=m.y;q.z=m.x*n;this.vertices.push(q)}c=a.length;g=0;for(h=b;g<h;g++)for(k=0,p=a.length-1;k<p;k++){b=k+c*g;d=b+c;var l=b+1+c,n=b+1,m=g*f,q=k*e,s=m+f,u=q+e;this.faces.push(new THREE.Face3(b,
-d,n));this.faceVertexUvs[0].push([new THREE.Vector2(m,q),new THREE.Vector2(s,q),new THREE.Vector2(m,u)]);this.faces.push(new THREE.Face3(d,l,n));this.faceVertexUvs[0].push([new THREE.Vector2(s,q),new THREE.Vector2(s,u),new THREE.Vector2(m,u)])}this.mergeVertices();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
-THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new THREE.PlaneBufferGeometry(a,b,c,d))};THREE.PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
-THREE.PlaneBufferGeometry=function(a,b,c,d){THREE.BufferGeometry.call(this);this.type="PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};var e=a/2,f=b/2;c=Math.floor(c)||1;d=Math.floor(d)||1;var g=c+1,h=d+1,k=a/c,l=b/d;b=new Float32Array(g*h*3);a=new Float32Array(g*h*3);for(var n=new Float32Array(g*h*2),p=0,m=0,q=0;q<h;q++)for(var s=q*l-f,u=0;u<g;u++)b[p]=u*k-e,b[p+1]=-s,a[p+2]=1,n[m]=u/c,n[m+1]=1-q/d,p+=3,m+=2;p=0;e=new (65535<b.length/3?Uint32Array:Uint16Array)(c*
-d*6);for(q=0;q<d;q++)for(u=0;u<c;u++)f=u+g*(q+1),h=u+1+g*(q+1),k=u+1+g*q,e[p]=u+g*q,e[p+1]=f,e[p+2]=k,e[p+3]=f,e[p+4]=h,e[p+5]=k,p+=6;this.setIndex(new THREE.BufferAttribute(e,1));this.addAttribute("position",new THREE.BufferAttribute(b,3));this.addAttribute("normal",new THREE.BufferAttribute(a,3));this.addAttribute("uv",new THREE.BufferAttribute(n,2))};THREE.PlaneBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.PlaneBufferGeometry.prototype.constructor=THREE.PlaneBufferGeometry;
-THREE.RingGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.type="RingGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};a=a||0;b=b||50;e=void 0!==e?e:0;f=void 0!==f?f:2*Math.PI;c=void 0!==c?Math.max(3,c):8;d=void 0!==d?Math.max(1,d):8;var g,h=[],k=a,l=(b-a)/d;for(a=0;a<d+1;a++){for(g=0;g<c+1;g++){var n=new THREE.Vector3,p=e+g/c*f;n.x=k*Math.cos(p);n.y=k*Math.sin(p);this.vertices.push(n);h.push(new THREE.Vector2((n.x/b+1)/2,
-(n.y/b+1)/2))}k+=l}b=new THREE.Vector3(0,0,1);for(a=0;a<d;a++)for(e=a*(c+1),g=0;g<c;g++)f=p=g+e,l=p+c+1,n=p+c+2,this.faces.push(new THREE.Face3(f,l,n,[b.clone(),b.clone(),b.clone()])),this.faceVertexUvs[0].push([h[f].clone(),h[l].clone(),h[n].clone()]),f=p,l=p+c+2,n=p+1,this.faces.push(new THREE.Face3(f,l,n,[b.clone(),b.clone(),b.clone()])),this.faceVertexUvs[0].push([h[f].clone(),h[l].clone(),h[n].clone()]);this.computeFaceNormals();this.boundingSphere=new THREE.Sphere(new THREE.Vector3,k)};
-THREE.RingGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.RingGeometry.prototype.constructor=THREE.RingGeometry;THREE.SphereGeometry=function(a,b,c,d,e,f,g){THREE.Geometry.call(this);this.type="SphereGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};this.fromBufferGeometry(new THREE.SphereBufferGeometry(a,b,c,d,e,f,g))};THREE.SphereGeometry.prototype=Object.create(THREE.Geometry.prototype);
-THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
-THREE.SphereBufferGeometry=function(a,b,c,d,e,f,g){THREE.BufferGeometry.call(this);this.type="SphereBufferGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};a=a||50;b=Math.max(3,Math.floor(b)||8);c=Math.max(2,Math.floor(c)||6);d=void 0!==d?d:0;e=void 0!==e?e:2*Math.PI;f=void 0!==f?f:0;g=void 0!==g?g:Math.PI;for(var h=f+g,k=(b+1)*(c+1),l=new THREE.BufferAttribute(new Float32Array(3*k),3),n=new THREE.BufferAttribute(new Float32Array(3*
-k),3),k=new THREE.BufferAttribute(new Float32Array(2*k),2),p=0,m=[],q=new THREE.Vector3,s=0;s<=c;s++){for(var u=[],t=s/c,x=0;x<=b;x++){var v=x/b,C=-a*Math.cos(d+v*e)*Math.sin(f+t*g),w=a*Math.cos(f+t*g),D=a*Math.sin(d+v*e)*Math.sin(f+t*g);q.set(C,w,D).normalize();l.setXYZ(p,C,w,D);n.setXYZ(p,q.x,q.y,q.z);k.setXY(p,v,1-t);u.push(p);p++}m.push(u)}d=[];for(s=0;s<c;s++)for(x=0;x<b;x++)e=m[s][x+1],g=m[s][x],p=m[s+1][x],q=m[s+1][x+1],(0!==s||0<f)&&d.push(e,g,q),(s!==c-1||h<Math.PI)&&d.push(g,p,q);this.setIndex(new (65535<
-l.count?THREE.Uint32Attribute:THREE.Uint16Attribute)(d,1));this.addAttribute("position",l);this.addAttribute("normal",n);this.addAttribute("uv",k);this.boundingSphere=new THREE.Sphere(new THREE.Vector3,a)};THREE.SphereBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.SphereBufferGeometry.prototype.constructor=THREE.SphereBufferGeometry;
-THREE.TextGeometry=function(a,b){b=b||{};var c=b.font;if(!1===c instanceof THREE.Font)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new THREE.Geometry;c=c.generateShapes(a,b.size,b.curveSegments);b.amount=void 0!==b.height?b.height:50;void 0===b.bevelThickness&&(b.bevelThickness=10);void 0===b.bevelSize&&(b.bevelSize=8);void 0===b.bevelEnabled&&(b.bevelEnabled=!1);THREE.ExtrudeGeometry.call(this,c,b);this.type="TextGeometry"};
-THREE.TextGeometry.prototype=Object.create(THREE.ExtrudeGeometry.prototype);THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
-THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.type="TorusGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};a=a||100;b=b||40;c=c||8;d=d||6;e=e||2*Math.PI;for(var f=new THREE.Vector3,g=[],h=[],k=0;k<=c;k++)for(var l=0;l<=d;l++){var n=l/d*e,p=k/c*Math.PI*2;f.x=a*Math.cos(n);f.y=a*Math.sin(n);var m=new THREE.Vector3;m.x=(a+b*Math.cos(p))*Math.cos(n);m.y=(a+b*Math.cos(p))*Math.sin(n);m.z=b*Math.sin(p);this.vertices.push(m);g.push(new THREE.Vector2(l/
-d,k/c));h.push(m.clone().sub(f).normalize())}for(k=1;k<=c;k++)for(l=1;l<=d;l++)a=(d+1)*k+l-1,b=(d+1)*(k-1)+l-1,e=(d+1)*(k-1)+l,f=(d+1)*k+l,n=new THREE.Face3(a,b,f,[h[a].clone(),h[b].clone(),h[f].clone()]),this.faces.push(n),this.faceVertexUvs[0].push([g[a].clone(),g[b].clone(),g[f].clone()]),n=new THREE.Face3(b,e,f,[h[b].clone(),h[e].clone(),h[f].clone()]),this.faces.push(n),this.faceVertexUvs[0].push([g[b].clone(),g[e].clone(),g[f].clone()]);this.computeFaceNormals()};
-THREE.TorusGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
-THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e){var f=Math.cos(a),g=Math.sin(a);a*=b/c;b=Math.cos(a);f*=d*(2+b)*.5;g=d*(2+b)*g*.5;d=e*d*Math.sin(a)*.5;return new THREE.Vector3(f,g,d)}THREE.Geometry.call(this);this.type="TorusKnotGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,p:e,q:f,heightScale:g};a=a||100;b=b||40;c=c||64;d=d||8;e=e||2;f=f||3;g=g||1;for(var k=Array(c),l=new THREE.Vector3,n=new THREE.Vector3,p=new THREE.Vector3,m=0;m<c;++m){k[m]=
-Array(d);var q=m/c*2*e*Math.PI,s=h(q,f,e,a,g),q=h(q+.01,f,e,a,g);l.subVectors(q,s);n.addVectors(q,s);p.crossVectors(l,n);n.crossVectors(p,l);p.normalize();n.normalize();for(q=0;q<d;++q){var u=q/d*2*Math.PI,t=-b*Math.cos(u),u=b*Math.sin(u),x=new THREE.Vector3;x.x=s.x+t*n.x+u*p.x;x.y=s.y+t*n.y+u*p.y;x.z=s.z+t*n.z+u*p.z;k[m][q]=this.vertices.push(x)-1}}for(m=0;m<c;++m)for(q=0;q<d;++q)e=(m+1)%c,f=(q+1)%d,a=k[m][q],b=k[e][q],e=k[e][f],f=k[m][f],g=new THREE.Vector2(m/c,q/d),l=new THREE.Vector2((m+1)/c,
-q/d),n=new THREE.Vector2((m+1)/c,(q+1)/d),p=new THREE.Vector2(m/c,(q+1)/d),this.faces.push(new THREE.Face3(a,b,f)),this.faceVertexUvs[0].push([g,l,p]),this.faces.push(new THREE.Face3(b,e,f)),this.faceVertexUvs[0].push([l.clone(),n,p.clone()]);this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;
-THREE.TubeGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.type="TubeGeometry";this.parameters={path:a,segments:b,radius:c,radialSegments:d,closed:e,taper:f};b=b||64;c=c||1;d=d||8;e=e||!1;f=f||THREE.TubeGeometry.NoTaper;var g=[],h,k,l=b+1,n,p,m,q,s,u=new THREE.Vector3,t,x,v;t=new THREE.TubeGeometry.FrenetFrames(a,b,e);x=t.normals;v=t.binormals;this.tangents=t.tangents;this.normals=x;this.binormals=v;for(t=0;t<l;t++)for(g[t]=[],n=t/(l-1),s=a.getPointAt(n),h=x[t],k=v[t],m=c*f(n),n=0;n<
-d;n++)p=n/d*2*Math.PI,q=-m*Math.cos(p),p=m*Math.sin(p),u.copy(s),u.x+=q*h.x+p*k.x,u.y+=q*h.y+p*k.y,u.z+=q*h.z+p*k.z,g[t][n]=this.vertices.push(new THREE.Vector3(u.x,u.y,u.z))-1;for(t=0;t<b;t++)for(n=0;n<d;n++)f=e?(t+1)%b:t+1,l=(n+1)%d,a=g[t][n],c=g[f][n],f=g[f][l],l=g[t][l],u=new THREE.Vector2(t/b,n/d),x=new THREE.Vector2((t+1)/b,n/d),v=new THREE.Vector2((t+1)/b,(n+1)/d),h=new THREE.Vector2(t/b,(n+1)/d),this.faces.push(new THREE.Face3(a,c,l)),this.faceVertexUvs[0].push([u,x,h]),this.faces.push(new THREE.Face3(c,
-f,l)),this.faceVertexUvs[0].push([x.clone(),v,h.clone()]);this.computeFaceNormals();this.computeVertexNormals()};THREE.TubeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TubeGeometry.prototype.constructor=THREE.TubeGeometry;THREE.TubeGeometry.NoTaper=function(a){return 1};THREE.TubeGeometry.SinusoidalTaper=function(a){return Math.sin(Math.PI*a)};
-THREE.TubeGeometry.FrenetFrames=function(a,b,c){var d=new THREE.Vector3,e=[],f=[],g=[],h=new THREE.Vector3,k=new THREE.Matrix4;b+=1;var l,n,p;this.tangents=e;this.normals=f;this.binormals=g;for(l=0;l<b;l++)n=l/(b-1),e[l]=a.getTangentAt(n),e[l].normalize();f[0]=new THREE.Vector3;g[0]=new THREE.Vector3;a=Number.MAX_VALUE;l=Math.abs(e[0].x);n=Math.abs(e[0].y);p=Math.abs(e[0].z);l<=a&&(a=l,d.set(1,0,0));n<=a&&(a=n,d.set(0,1,0));p<=a&&d.set(0,0,1);h.crossVectors(e[0],d).normalize();f[0].crossVectors(e[0],
-h);g[0].crossVectors(e[0],f[0]);for(l=1;l<b;l++)f[l]=f[l-1].clone(),g[l]=g[l-1].clone(),h.crossVectors(e[l-1],e[l]),h.length()>Number.EPSILON&&(h.normalize(),d=Math.acos(THREE.Math.clamp(e[l-1].dot(e[l]),-1,1)),f[l].applyMatrix4(k.makeRotationAxis(h,d))),g[l].crossVectors(e[l],f[l]);if(c)for(d=Math.acos(THREE.Math.clamp(f[0].dot(f[b-1]),-1,1)),d/=b-1,0<e[0].dot(h.crossVectors(f[0],f[b-1]))&&(d=-d),l=1;l<b;l++)f[l].applyMatrix4(k.makeRotationAxis(e[l],d*l)),g[l].crossVectors(e[l],f[l])};
-THREE.PolyhedronGeometry=function(a,b,c,d){function e(a){var b=a.normalize().clone();b.index=k.vertices.push(b)-1;var c=Math.atan2(a.z,-a.x)/2/Math.PI+.5;a=Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+.5;b.uv=new THREE.Vector2(c,1-a);return b}function f(a,b,c,d){d=new THREE.Face3(a.index,b.index,c.index,[a.clone(),b.clone(),c.clone()],void 0,d);k.faces.push(d);t.copy(a).add(b).add(c).divideScalar(3);d=Math.atan2(t.z,-t.x);k.faceVertexUvs[0].push([h(a.uv,a,d),h(b.uv,b,d),h(c.uv,c,d)])}function g(a,
-b){for(var c=Math.pow(2,b),d=e(k.vertices[a.a]),g=e(k.vertices[a.b]),h=e(k.vertices[a.c]),l=[],m=a.materialIndex,n=0;n<=c;n++){l[n]=[];for(var p=e(d.clone().lerp(h,n/c)),q=e(g.clone().lerp(h,n/c)),s=c-n,t=0;t<=s;t++)l[n][t]=0===t&&n===c?p:e(p.clone().lerp(q,t/s))}for(n=0;n<c;n++)for(t=0;t<2*(c-n)-1;t++)d=Math.floor(t/2),0===t%2?f(l[n][d+1],l[n+1][d],l[n][d],m):f(l[n][d+1],l[n+1][d+1],l[n+1][d],m)}function h(a,b,c){0>c&&1===a.x&&(a=new THREE.Vector2(a.x-1,a.y));0===b.x&&0===b.z&&(a=new THREE.Vector2(c/
-2/Math.PI+.5,a.y));return a.clone()}THREE.Geometry.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;for(var k=this,l=0,n=a.length;l<n;l+=3)e(new THREE.Vector3(a[l],a[l+1],a[l+2]));a=this.vertices;for(var p=[],m=l=0,n=b.length;l<n;l+=3,m++){var q=a[b[l]],s=a[b[l+1]],u=a[b[l+2]];p[m]=new THREE.Face3(q.index,s.index,u.index,[q.clone(),s.clone(),u.clone()],void 0,m)}for(var t=new THREE.Vector3,l=0,n=p.length;l<n;l++)g(p[l],d);l=0;for(n=this.faceVertexUvs[0].length;l<
-n;l++)b=this.faceVertexUvs[0][l],d=b[0].x,a=b[1].x,p=b[2].x,m=Math.max(d,a,p),q=Math.min(d,a,p),.9<m&&.1>q&&(.2>d&&(b[0].x+=1),.2>a&&(b[1].x+=1),.2>p&&(b[2].x+=1));l=0;for(n=this.vertices.length;l<n;l++)this.vertices[l].multiplyScalar(c);this.mergeVertices();this.computeFaceNormals();this.boundingSphere=new THREE.Sphere(new THREE.Vector3,c)};THREE.PolyhedronGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.PolyhedronGeometry.prototype.constructor=THREE.PolyhedronGeometry;
-THREE.DodecahedronGeometry=function(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;THREE.PolyhedronGeometry.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,
-12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b}};THREE.DodecahedronGeometry.prototype=Object.create(THREE.PolyhedronGeometry.prototype);THREE.DodecahedronGeometry.prototype.constructor=THREE.DodecahedronGeometry;
-THREE.IcosahedronGeometry=function(a,b){var c=(1+Math.sqrt(5))/2;THREE.PolyhedronGeometry.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b}};THREE.IcosahedronGeometry.prototype=Object.create(THREE.PolyhedronGeometry.prototype);
-THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;THREE.OctahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b}};THREE.OctahedronGeometry.prototype=Object.create(THREE.PolyhedronGeometry.prototype);THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;
-THREE.TetrahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b}};THREE.TetrahedronGeometry.prototype=Object.create(THREE.PolyhedronGeometry.prototype);THREE.TetrahedronGeometry.prototype.constructor=THREE.TetrahedronGeometry;
-THREE.ParametricGeometry=function(a,b,c){THREE.Geometry.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};var d=this.vertices,e=this.faces,f=this.faceVertexUvs[0],g,h,k,l,n=b+1;for(g=0;g<=c;g++)for(l=g/c,h=0;h<=b;h++)k=h/b,k=a(k,l),d.push(k);var p,m,q,s;for(g=0;g<c;g++)for(h=0;h<b;h++)a=g*n+h,d=g*n+h+1,l=(g+1)*n+h+1,k=(g+1)*n+h,p=new THREE.Vector2(h/b,g/c),m=new THREE.Vector2((h+1)/b,g/c),q=new THREE.Vector2((h+1)/b,(g+1)/c),s=new THREE.Vector2(h/b,(g+1)/c),e.push(new THREE.Face3(a,
-d,k)),f.push([p,m,s]),e.push(new THREE.Face3(d,l,k)),f.push([m.clone(),q,s.clone()]);this.computeFaceNormals();this.computeVertexNormals()};THREE.ParametricGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ParametricGeometry.prototype.constructor=THREE.ParametricGeometry;
-THREE.WireframeGeometry=function(a){function b(a,b){return a-b}THREE.BufferGeometry.call(this);var c=[0,0],d={},e=["a","b","c"];if(a instanceof THREE.Geometry){var f=a.vertices,g=a.faces,h=0,k=new Uint32Array(6*g.length);a=0;for(var l=g.length;a<l;a++)for(var n=g[a],p=0;3>p;p++){c[0]=n[e[p]];c[1]=n[e[(p+1)%3]];c.sort(b);var m=c.toString();void 0===d[m]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[m]=!0,h++)}c=new Float32Array(6*h);a=0;for(l=h;a<l;a++)for(p=0;2>p;p++)d=f[k[2*a+p]],h=6*a+3*p,c[h+0]=d.x,c[h+1]=d.y,
-c[h+2]=d.z;this.addAttribute("position",new THREE.BufferAttribute(c,3))}else if(a instanceof THREE.BufferGeometry){if(null!==a.index){l=a.index.array;f=a.attributes.position;e=a.groups;h=0;0===e.length&&a.addGroup(0,l.length);k=new Uint32Array(2*l.length);g=0;for(n=e.length;g<n;++g){a=e[g];p=a.start;m=a.count;a=p;for(var q=p+m;a<q;a+=3)for(p=0;3>p;p++)c[0]=l[a+p],c[1]=l[a+(p+1)%3],c.sort(b),m=c.toString(),void 0===d[m]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[m]=!0,h++)}c=new Float32Array(6*h);a=0;for(l=h;a<
-l;a++)for(p=0;2>p;p++)h=6*a+3*p,d=k[2*a+p],c[h+0]=f.getX(d),c[h+1]=f.getY(d),c[h+2]=f.getZ(d)}else for(f=a.attributes.position.array,h=f.length/3,k=h/3,c=new Float32Array(6*h),a=0,l=k;a<l;a++)for(p=0;3>p;p++)h=18*a+6*p,k=9*a+3*p,c[h+0]=f[k],c[h+1]=f[k+1],c[h+2]=f[k+2],d=9*a+(p+1)%3*3,c[h+3]=f[d],c[h+4]=f[d+1],c[h+5]=f[d+2];this.addAttribute("position",new THREE.BufferAttribute(c,3))}};THREE.WireframeGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);
-THREE.WireframeGeometry.prototype.constructor=THREE.WireframeGeometry;THREE.AxisHelper=function(a){a=a||1;var b=new Float32Array([0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a]),c=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]);a=new THREE.BufferGeometry;a.addAttribute("position",new THREE.BufferAttribute(b,3));a.addAttribute("color",new THREE.BufferAttribute(c,3));b=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});THREE.LineSegments.call(this,a,b)};THREE.AxisHelper.prototype=Object.create(THREE.LineSegments.prototype);
-THREE.AxisHelper.prototype.constructor=THREE.AxisHelper;
-THREE.ArrowHelper=function(){var a=new THREE.Geometry;a.vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(0,1,0));var b=new THREE.CylinderGeometry(0,.5,1,5,1);b.translate(0,-.5,0);return function(c,d,e,f,g,h){THREE.Object3D.call(this);void 0===f&&(f=16776960);void 0===e&&(e=1);void 0===g&&(g=.2*e);void 0===h&&(h=.2*g);this.position.copy(d);this.line=new THREE.Line(a,new THREE.LineBasicMaterial({color:f}));this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:f}));
-this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(c);this.setLength(e,g,h)}}();THREE.ArrowHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.ArrowHelper.prototype.constructor=THREE.ArrowHelper;THREE.ArrowHelper.prototype.setDirection=function(){var a=new THREE.Vector3,b;return function(c){.99999<c.y?this.quaternion.set(0,0,0,1):-.99999>c.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();
-THREE.ArrowHelper.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};
-THREE.BoxHelper=function(a){var b=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),c=new Float32Array(24),d=new THREE.BufferGeometry;d.setIndex(new THREE.BufferAttribute(b,1));d.addAttribute("position",new THREE.BufferAttribute(c,3));THREE.LineSegments.call(this,d,new THREE.LineBasicMaterial({color:16776960}));void 0!==a&&this.update(a)};THREE.BoxHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.BoxHelper.prototype.constructor=THREE.BoxHelper;
-THREE.BoxHelper.prototype.update=function(){var a=new THREE.Box3;return function(b){a.setFromObject(b);if(!a.isEmpty()){b=a.min;var c=a.max,d=this.geometry.attributes.position,e=d.array;e[0]=c.x;e[1]=c.y;e[2]=c.z;e[3]=b.x;e[4]=c.y;e[5]=c.z;e[6]=b.x;e[7]=b.y;e[8]=c.z;e[9]=c.x;e[10]=b.y;e[11]=c.z;e[12]=c.x;e[13]=c.y;e[14]=b.z;e[15]=b.x;e[16]=c.y;e[17]=b.z;e[18]=b.x;e[19]=b.y;e[20]=b.z;e[21]=c.x;e[22]=b.y;e[23]=b.z;d.needsUpdate=!0;this.geometry.computeBoundingSphere()}}}();
-THREE.BoundingBoxHelper=function(a,b){var c=void 0!==b?b:8947848;this.object=a;this.box=new THREE.Box3;THREE.Mesh.call(this,new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:c,wireframe:!0}))};THREE.BoundingBoxHelper.prototype=Object.create(THREE.Mesh.prototype);THREE.BoundingBoxHelper.prototype.constructor=THREE.BoundingBoxHelper;THREE.BoundingBoxHelper.prototype.update=function(){this.box.setFromObject(this.object);this.box.size(this.scale);this.box.center(this.position)};
-THREE.CameraHelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.vertices.push(new THREE.Vector3);d.colors.push(new THREE.Color(b));void 0===f[a]&&(f[a]=[]);f[a].push(d.vertices.length-1)}var d=new THREE.Geometry,e=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors}),f={};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);
-b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);THREE.LineSegments.call(this,d,e);this.camera=a;this.camera.updateProjectionMatrix();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=f;this.update()};
-THREE.CameraHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.CameraHelper.prototype.constructor=THREE.CameraHelper;
-THREE.CameraHelper.prototype.update=function(){function a(a,g,h,k){d.set(g,h,k).unproject(e);a=c[a];if(void 0!==a)for(g=0,h=a.length;g<h;g++)b.vertices[a[g]].copy(d)}var b,c,d=new THREE.Vector3,e=new THREE.Camera;return function(){b=this.geometry;c=this.pointMap;e.projectionMatrix.copy(this.camera.projectionMatrix);a("c",0,0,-1);a("t",0,0,1);a("n1",-1,-1,-1);a("n2",1,-1,-1);a("n3",-1,1,-1);a("n4",1,1,-1);a("f1",-1,-1,1);a("f2",1,-1,1);a("f3",-1,1,1);a("f4",1,1,1);a("u1",.7,1.1,-1);a("u2",-.7,1.1,
--1);a("u3",0,2,-1);a("cf1",-1,0,1);a("cf2",1,0,1);a("cf3",0,-1,1);a("cf4",0,1,1);a("cn1",-1,0,-1);a("cn2",1,0,-1);a("cn3",0,-1,-1);a("cn4",0,1,-1);b.verticesNeedUpdate=!0}}();
-THREE.DirectionalLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;b=b||1;var c=new THREE.Geometry;c.vertices.push(new THREE.Vector3(-b,b,0),new THREE.Vector3(b,b,0),new THREE.Vector3(b,-b,0),new THREE.Vector3(-b,-b,0),new THREE.Vector3(-b,b,0));var d=new THREE.LineBasicMaterial({fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.lightPlane=new THREE.Line(c,d);this.add(this.lightPlane);
-c=new THREE.Geometry;c.vertices.push(new THREE.Vector3,new THREE.Vector3);d=new THREE.LineBasicMaterial({fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.targetLine=new THREE.Line(c,d);this.add(this.targetLine);this.update()};THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.DirectionalLightHelper.prototype.constructor=THREE.DirectionalLightHelper;
-THREE.DirectionalLightHelper.prototype.dispose=function(){this.lightPlane.geometry.dispose();this.lightPlane.material.dispose();this.targetLine.geometry.dispose();this.targetLine.material.dispose()};
-THREE.DirectionalLightHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(){a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);c.subVectors(b,a);this.lightPlane.lookAt(c);this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.targetLine.geometry.vertices[1].copy(c);this.targetLine.geometry.verticesNeedUpdate=!0;this.targetLine.material.color.copy(this.lightPlane.material.color)}}();
-THREE.EdgesHelper=function(a,b,c){b=void 0!==b?b:16777215;THREE.LineSegments.call(this,new THREE.EdgesGeometry(a.geometry,c),new THREE.LineBasicMaterial({color:b}));this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1};THREE.EdgesHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.EdgesHelper.prototype.constructor=THREE.EdgesHelper;
-THREE.FaceNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=0;c=this.object.geometry;c instanceof THREE.Geometry?b=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");c=new THREE.BufferGeometry;b=new THREE.Float32Attribute(6*b,3);c.addAttribute("position",b);THREE.LineSegments.call(this,c,new THREE.LineBasicMaterial({color:a,linewidth:d}));this.matrixAutoUpdate=
-!1;this.update()};THREE.FaceNormalsHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.FaceNormalsHelper.prototype.constructor=THREE.FaceNormalsHelper;
-THREE.FaceNormalsHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Matrix3;return function(){this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);for(var d=this.object.matrixWorld,e=this.geometry.attributes.position,f=this.object.geometry,g=f.vertices,f=f.faces,h=0,k=0,l=f.length;k<l;k++){var n=f[k],p=n.normal;a.copy(g[n.a]).add(g[n.b]).add(g[n.c]).divideScalar(3).applyMatrix4(d);b.copy(p).applyMatrix3(c).normalize().multiplyScalar(this.size).add(a);
-e.setXYZ(h,a.x,a.y,a.z);h+=1;e.setXYZ(h,b.x,b.y,b.z);h+=1}e.needsUpdate=!0;return this}}();
-THREE.GridHelper=function(a,b){var c=new THREE.Geometry,d=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});this.color1=new THREE.Color(4473924);this.color2=new THREE.Color(8947848);for(var e=-a;e<=a;e+=b){c.vertices.push(new THREE.Vector3(-a,0,e),new THREE.Vector3(a,0,e),new THREE.Vector3(e,0,-a),new THREE.Vector3(e,0,a));var f=0===e?this.color1:this.color2;c.colors.push(f,f,f,f)}THREE.LineSegments.call(this,c,d)};THREE.GridHelper.prototype=Object.create(THREE.LineSegments.prototype);
-THREE.GridHelper.prototype.constructor=THREE.GridHelper;THREE.GridHelper.prototype.setColors=function(a,b){this.color1.set(a);this.color2.set(b);this.geometry.colorsNeedUpdate=!0};
-THREE.HemisphereLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.colors=[new THREE.Color,new THREE.Color];var c=new THREE.SphereGeometry(b,4,2);c.rotateX(-Math.PI/2);for(var d=0;8>d;d++)c.faces[d].color=this.colors[4>d?0:1];d=new THREE.MeshBasicMaterial({vertexColors:THREE.FaceColors,wireframe:!0});this.lightSphere=new THREE.Mesh(c,d);this.add(this.lightSphere);this.update()};
-THREE.HemisphereLightHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.HemisphereLightHelper.prototype.constructor=THREE.HemisphereLightHelper;THREE.HemisphereLightHelper.prototype.dispose=function(){this.lightSphere.geometry.dispose();this.lightSphere.material.dispose()};
-THREE.HemisphereLightHelper.prototype.update=function(){var a=new THREE.Vector3;return function(){this.colors[0].copy(this.light.color).multiplyScalar(this.light.intensity);this.colors[1].copy(this.light.groundColor).multiplyScalar(this.light.intensity);this.lightSphere.lookAt(a.setFromMatrixPosition(this.light.matrixWorld).negate());this.lightSphere.geometry.colorsNeedUpdate=!0}}();
-THREE.PointLightHelper=function(a,b){this.light=a;this.light.updateMatrixWorld();var c=new THREE.SphereGeometry(b,4,2),d=new THREE.MeshBasicMaterial({wireframe:!0,fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);THREE.Mesh.call(this,c,d);this.matrix=this.light.matrixWorld;this.matrixAutoUpdate=!1};THREE.PointLightHelper.prototype=Object.create(THREE.Mesh.prototype);THREE.PointLightHelper.prototype.constructor=THREE.PointLightHelper;
-THREE.PointLightHelper.prototype.dispose=function(){this.geometry.dispose();this.material.dispose()};THREE.PointLightHelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)};
-THREE.SkeletonHelper=function(a){this.bones=this.getBoneList(a);for(var b=new THREE.Geometry,c=0;c<this.bones.length;c++)this.bones[c].parent instanceof THREE.Bone&&(b.vertices.push(new THREE.Vector3),b.vertices.push(new THREE.Vector3),b.colors.push(new THREE.Color(0,0,1)),b.colors.push(new THREE.Color(0,1,0)));b.dynamic=!0;c=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,depthTest:!1,depthWrite:!1,transparent:!0});THREE.LineSegments.call(this,b,c);this.root=a;this.matrix=a.matrixWorld;
-this.matrixAutoUpdate=!1;this.update()};THREE.SkeletonHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.SkeletonHelper.prototype.constructor=THREE.SkeletonHelper;THREE.SkeletonHelper.prototype.getBoneList=function(a){var b=[];a instanceof THREE.Bone&&b.push(a);for(var c=0;c<a.children.length;c++)b.push.apply(b,this.getBoneList(a.children[c]));return b};
-THREE.SkeletonHelper.prototype.update=function(){for(var a=this.geometry,b=(new THREE.Matrix4).getInverse(this.root.matrixWorld),c=new THREE.Matrix4,d=0,e=0;e<this.bones.length;e++){var f=this.bones[e];f.parent instanceof THREE.Bone&&(c.multiplyMatrices(b,f.matrixWorld),a.vertices[d].setFromMatrixPosition(c),c.multiplyMatrices(b,f.parent.matrixWorld),a.vertices[d+1].setFromMatrixPosition(c),d+=2)}a.verticesNeedUpdate=!0;a.computeBoundingSphere()};
-THREE.SpotLightHelper=function(a){THREE.Object3D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;a=new THREE.CylinderGeometry(0,1,1,8,1,!0);a.translate(0,-.5,0);a.rotateX(-Math.PI/2);var b=new THREE.MeshBasicMaterial({wireframe:!0,fog:!1});this.cone=new THREE.Mesh(a,b);this.add(this.cone);this.update()};THREE.SpotLightHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.SpotLightHelper.prototype.constructor=THREE.SpotLightHelper;
-THREE.SpotLightHelper.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};THREE.SpotLightHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){var c=this.light.distance?this.light.distance:1E4,d=c*Math.tan(this.light.angle);this.cone.scale.set(d,d,c);a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);this.cone.lookAt(b.sub(a));this.cone.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)}}();
-THREE.VertexNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16711680;d=void 0!==d?d:1;b=0;c=this.object.geometry;c instanceof THREE.Geometry?b=3*c.faces.length:c instanceof THREE.BufferGeometry&&(b=c.attributes.normal.count);c=new THREE.BufferGeometry;b=new THREE.Float32Attribute(6*b,3);c.addAttribute("position",b);THREE.LineSegments.call(this,c,new THREE.LineBasicMaterial({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()};
-THREE.VertexNormalsHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.VertexNormalsHelper.prototype.constructor=THREE.VertexNormalsHelper;
-THREE.VertexNormalsHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Matrix3;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,f=this.geometry.attributes.position,g=this.object.geometry;if(g instanceof THREE.Geometry)for(var h=g.vertices,k=g.faces,l=g=0,n=k.length;l<n;l++)for(var p=k[l],m=0,q=p.vertexNormals.length;m<q;m++){var s=p.vertexNormals[m];a.copy(h[p[d[m]]]).applyMatrix4(e);
-b.copy(s).applyMatrix3(c).normalize().multiplyScalar(this.size).add(a);f.setXYZ(g,a.x,a.y,a.z);g+=1;f.setXYZ(g,b.x,b.y,b.z);g+=1}else if(g instanceof THREE.BufferGeometry)for(d=g.attributes.position,h=g.attributes.normal,m=g=0,q=d.count;m<q;m++)a.set(d.getX(m),d.getY(m),d.getZ(m)).applyMatrix4(e),b.set(h.getX(m),h.getY(m),h.getZ(m)),b.applyMatrix3(c).normalize().multiplyScalar(this.size).add(a),f.setXYZ(g,a.x,a.y,a.z),g+=1,f.setXYZ(g,b.x,b.y,b.z),g+=1;f.needsUpdate=!0;return this}}();
-THREE.WireframeHelper=function(a,b){var c=void 0!==b?b:16777215;THREE.LineSegments.call(this,new THREE.WireframeGeometry(a.geometry),new THREE.LineBasicMaterial({color:c}));this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1};THREE.WireframeHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.WireframeHelper.prototype.constructor=THREE.WireframeHelper;THREE.ImmediateRenderObject=function(a){THREE.Object3D.call(this);this.material=a;this.render=function(a){}};
-THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype);THREE.ImmediateRenderObject.prototype.constructor=THREE.ImmediateRenderObject;THREE.MorphBlendMesh=function(a,b){THREE.Mesh.call(this,a,b);this.animationsMap={};this.animationsList=[];var c=this.geometry.morphTargets.length;this.createAnimation("__default",0,c-1,c/1);this.setAnimationWeight("__default",1)};THREE.MorphBlendMesh.prototype=Object.create(THREE.Mesh.prototype);THREE.MorphBlendMesh.prototype.constructor=THREE.MorphBlendMesh;
-THREE.MorphBlendMesh.prototype.createAnimation=function(a,b,c,d){b={start:b,end:c,length:c-b+1,fps:d,duration:(c-b)/d,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1};this.animationsMap[a]=b;this.animationsList.push(b)};
-THREE.MorphBlendMesh.prototype.autoCreateAnimations=function(a){for(var b=/([a-z]+)_?(\d+)/i,c,d={},e=this.geometry,f=0,g=e.morphTargets.length;f<g;f++){var h=e.morphTargets[f].name.match(b);if(h&&1<h.length){var k=h[1];d[k]||(d[k]={start:Infinity,end:-Infinity});h=d[k];f<h.start&&(h.start=f);f>h.end&&(h.end=f);c||(c=k)}}for(k in d)h=d[k],this.createAnimation(k,h.start,h.end,a);this.firstAnimation=c};
-THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a])a.direction=1,a.directionBackwards=!1};THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a])a.direction=-1,a.directionBackwards=!0};THREE.MorphBlendMesh.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)};
-THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)};THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};
-THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("THREE.MorphBlendMesh: animation["+a+"] undefined in .playAnimation()")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1};
-THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b<c;b++){var d=this.animationsList[b];if(d.active){var e=d.duration/d.length;d.time+=d.direction*a;if(d.mirroredLoop){if(d.time>d.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.start+THREE.Math.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;f!==d.currentFrame&&
-(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);d.currentFrame!==d.lastFrame?(this.morphTargetInfluences[d.currentFrame]=e*g,this.morphTargetInfluences[d.lastFrame]=(1-e)*g):this.morphTargetInfluences[d.currentFrame]=g}}};
--- a/media/js/utils/modi.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,941 +0,0 @@
-/********
-
-	Mouseover DOM Inspector
-	version 2.0.2
-	last rev: 05.12.2005
-
-	steve@slayeroffice.com
-
-	Thanks to Aaron Barker of zelph.com for his additions to v1.x.
-	
-	Should you modify/improve upon this, please let me know about it so that
-	I can update the version hosted on slayeroffice.
-	
-	PLEASE LEAVE THIS NOTICE IN TACT
-	
-TODO:
-	-- add identifiers to MODI created objects to prevent them from appearing during manual DOM walk
-	-- fix firstChild selections
-	-- fix outline reversion
-	- Replace outline's with an abs-pos DIV to emulate the outlines. (maybe)
-********/
-
-// prevent IE from making tons of requests to background images
-if(document.execCommand && document.all && !window.opera) document.execCommand("BackgroundImageCache",false,true);
-
-var d=document;
-var mObj,cssObj;
-var isActive = false;
-var activeObj = null;
-var pause = false;
-
-var treeIndex = 0;
-var clonedObj = null;
-var mDown = false;
-var offsetX,offsetY;
-
-
-if(d.all && !window.opera) {
-	var statusImg = new Array("gray.png","");
-} else {
-	var statusImg = new Array("gray.png","outline.png","");
-}
-var keyboardObjIndex = 0;
-var modiHiddenObjects = new Array();
-var modiFocused = false;
-if(d.contentType) {
-	var isAppXML = document.contentType.indexOf("application/xhtml") > -1;
-} else {
-	var isAppXML = false;
-}
-
-// default preferences
-var pref_showAttr = true;
-var pref_showDim = true;
-var pref_showParents = true;
-var pref_highlights = 0;
-var pref_freeze = true;
-var pref_backgroundHighlightColor = "#C0C0C0";
-var pref_childHighlightColor = "#FAFAFA";
-var pref_outlineColor = "#FF0000";
-var pref_outlineWidth = "2px";
-var pref_visible = true;
-var pref_alwaysTransparent = false;
-var pref_alwaysTransparentValue = 60;
-var pref_allDataListsCollapsed = false;
-var pref_showChildren = true;
-
-var oHighlightColor = pref_backgroundHighlightColor;
-var so_host = "http://slayeroffice.com/tools/modi/v2.0/";
-var so_lbl = new Array();
-
-// See: http://www.quirksmode.org/dom/getstyles.html
-function getStyle(obj,styleProp)
-{
-	if (obj.currentStyle)
-		var y = obj.currentStyle[styleProp];
-	else if (window.getComputedStyle)
-		var y = document.defaultView.getComputedStyle(obj,null).getPropertyValue(styleProp);
-	return y;
-}
-
-function so_init() {
-	try {
-		if(prefFile != "") {
-			nPrefs = d.getElementsByTagName("head")[0].appendChild(d.createElement("script"));
-			nPrefs.type = "text/javascript";
-			nPrefs.src = prefFile;
-			oHighlightColor = pref_backgroundHighlightColor;
-		}
-	} catch(err) { }
-	d.onmousemove = so_captureMouseMoveEvent;
-	d.onkeydown = so_captureKeyDownEvent;
-	window.onscroll = so_keepModiInView;
-	so_prepInputs();
-	
-	all = d.getElementsByTagName("*");
-	for(i=0;i<all.length;i++) {
-		if(all[i].tagName != "HTML" && all[i].tagName != "BODY" && all[i].tagName != "!") {
-		 	so_prepareObjForMODI(all[i]);
-		}
-	}
-
-	cssObj = d.getElementsByTagName("head")[0].appendChild(d.createElement("link"));
-	cssObj.type = "text/css";
-	cssObj.rel = "Stylesheet";
-	cssObj.href = so_host + "modi_v2.0.css";
-	cssObj.id = "modiCSS";
-	cssObj.xid = "modi";
-	
-	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
-	mObj.id = "modiContainer";
-	mObj.xid = "modi";
-	mObj.style.visibility = pref_visible?"visible":"hidden";
-	mObj.onmouseover = function() { modiFocused = true; so_setOpacity(mObj,99); }
-	mObj.onmouseout = function() { modiFocused = false; }
-	
-	h2 = mObj.appendChild(d.createElement("h2"));
-	h2.appendChild(d.createTextNode("Mouse-over any element to begin."));
-	h2.id = "tmp_h2";
-}
-
-function so_prepInputs() {
-	txtInput = d.getElementsByTagName("input");
-	txtArea = d.getElementsByTagName("textarea");
-	for(i=0;i<txtInput.length;i++) {
-		if(txtInput[i].getAttribute("type")=="text" || txtInput[i].getAttribute("type") == "") {
-			txtInput[i].onfocus = function() { 
-				if(pause)return;
-				pause = true; 
-				// yeah, the innerHTML is cheating. at least i'm only reading, not writing :)
-				if(d.getElementById("so_h2").innerHTML.indexOf("paused")==-1)d.getElementById("so_h2").appendChild(d.createTextNode(" [paused for input focus]"));
-			}
-			txtInput[i].onblur = function() { 
-				pause = false; 
-			}
-		}
-	}
-	for(i=0;i<txtArea.length;i++) {
-		txtArea[i].onfocus = function() {
-			if(pause)return;
-			pause = true; 
-			if(d.getElementById("so_h2").innerHTML.indexOf("paused")==-1)d.getElementById("so_h2").appendChild(d.createTextNode(" [paused for input focus]"));
-		}
-		txtArea[i].onblur = function() { 
-			pause = false; 
-		}
-	}
-}
-
-function so_keepModiInView() {
-	winHeight = d.all && !window.opera?document.documentElement.clientHeight:window.innerHeight;
-	if(mObj.offsetHeight > winHeight) return;
-	if(mObj.offsetTop < _returnScrollDimensions(1)) {
-		mObj.style.top = _returnScrollDimensions(1)+"px";
-	}
-	
-	if(mObj.offsetTop+mObj.offsetHeight > winHeight + _returnScrollDimensions(1)) {
-		mObj.style.top = (_returnScrollDimensions(1) + winHeight) - mObj.offsetHeight + "px";
-	}
-}
-
-function so_captureMouseMoveEvent(e) {
-	x=d.all?window.event.clientX:e.clientX;
-	y=d.all?window.event.clientY:e.pageY;
-
-	if(pause || pref_freeze) {
-		if(mDown) {
-			x-=offsetX;
-			y-=offsetY;
-			if(mDown) {
-				mObj.style.top = y+"px";
-				mObj.style.left = x+"px";
-			}
-			return;
-		}
-	}
-		
-	if(activeObj == null && !modiFocused) {
-		so_setOpacity(mObj,40);
-	} else {
-		so_setOpacity(mObj,99);
-	}
-	
-	if(pref_freeze) {
-		so_keepModiInView();
-		return;
-	}
-	
-	if(d.all && !window.opera) {
-		x+=_returnScrollDimensions(0);
-		y+=_returnScrollDimensions(1);
-	}
-
-	if(x+mObj.offsetWidth > d.getElementsByTagName("body")[0].offsetWidth) {
-		mObj.style.left = (x-mObj.offsetWidth)+"px";
-	} else {
-		mObj.style.left = (x+15) + "px";
-	}
-	if(mObj.offsetLeft < 0) mObj.style.left = "0px"
-	
-	yOffset = _returnScrollDimensions(1);
-	
-	if(y-mObj.offsetHeight<=0 || (y-mObj.offsetHeight)<yOffset) {
-		mObj.style.top=(y+15)+"px";
-	} else {
-		mObj.style.top = (y-mObj.offsetHeight) + "px";
-	}
-
-}
-
-function _returnScrollDimensions(which) {
-	
-	if(which) {
-		if(d.body.scrollTop != 0)return d.body.scrollTop;
-		if(d.documentElement.scrollTop != 0)return d.documentElement.scrollTop;
-	} else {
-		if(d.body.scrollLeft != 0)return d.body.scrollTop;
-		if(d.documentElement.scrollLeft != 0)return d.documentElement.scrollLeft;
-	}
-	return 0;
-}	
-	
-function so_setObjHighlight(obj) {
-	switch(pref_highlights) {
-		case 0:
-			obj.style.backgroundColor = pref_backgroundHighlightColor;
-			break;
-		case 1:
-			//activeObj.prevOutline = 
-			outline = pref_outlineWidth + " solid " + pref_outlineColor;
-			obj.style.MozOutline = outline;
-			obj.style.outline = outline;
-			break;
-		case 2:
-			return;
-			break;
-	}
-}
-
-function so_unsetObjHighlight(obj) {
-	if(!obj)return;
-	switch(pref_highlights) {
-		case 0:
-			if(obj.randomBGColor == null) {
-				obj.style.backgroundColor = obj.so_prevBGColor;
-			} else {
-				obj.style.backgroundColor = obj.randomBGColor;
-			}
-			break;
-		case 1:
-			obj.style.MozOutline = "none";
-			obj.style.outline = "none";
-			break;
-		case 2:
-			return;
-			break;
-	}
-}
-
-function so_captureKeyDownEvent(e) {
-	keyCode = d.all?window.event.keyCode:e.keyCode;
-	if(d.getElementById("htmlView")){ 
-		 switch(keyCode) {
-		 	case 27:
-				so_closeEditWindow();
-				break;
-			case 13:
-				so_applyInnerHTML(d.getElementById("htmlViewText").value,activeObj);
-				break;
-		}
-		return;
-	}
-	
-	if(pause) {
-		if(keyCode == 80) {
-			pause=false;
-			return;
-		}
-	}
-	switch(keyCode) {
-		case 27:
-			so_cleanUp();
-			break;
-		case 49:
-			so_snapWindow(0);
-			break;
-		case 50:
-			//so_snapWindow(1);
-			break;
-		case 65:
-			so_cloneObject();
-			break;
-		case 66:
-			if(pause) return;
-			so_unsetObjHighlight(activeObj);
-			pref_highlights++;
-			if(d.all && !window.opera) {
-				maxValue = 1;
-			} else {
-				maxValue = 2;
-			}
-			if(pref_highlights>maxValue) pref_highlights = 0;
-			if(activeObj) so_setObjHighlight(activeObj);
-			d.getElementById("so_h2").style.backgroundImage = "url(" + so_host +""+ statusImg[pref_highlights] + ")";
-			break;
-		case 67:
-			so_randomColor();
-			break;
-		case 68:
-			if(pause)return;
-			pref_visible = pref_visible?false:true;
-			mObj.style.visibility = pref_visible?"visible":"hidden";
-			break;
-		case 69:
-			so_removeWidth();
-			break;
-		case 70:
-			if(pause)return;
-			pref_freeze = pref_freeze?false:true;
-			if(!pref_freeze)mDown = false;
-			break;
-		case 71:
-			so_changeListState();
-			break;
-		case 72:
-			so_hideObject();
-			break;
-		case 74:
-			so_showModiHiddenObjects();
-			break;
-		case 75:
-			so_removeLables();
-			break;
-		case 76:
-			so_labelObj(activeObj);
-			break;
-		case 78:
-			so_showFirstChild();
-			break;
-		case 79:
-			if(activeObj) so_outlineObj(activeObj);
-			break;
-		case 80:
-			if(!activeObj) return;
-			pause = pause?false:true;
-			if(pause)d.getElementById("so_h2").appendChild(d.createTextNode(" [paused]"));
-			so_setOpacity(mObj,99);
-			break;
-		case 82:
-			so_removeObj();
-			break;
-		case 83:
-			so_insertClonedObj();
-			break;
-		case 84:
-			if(d.getElementsByTagName("*")[treeIndex].xid == "modi") {
-				do {
-					treeIndex++;
-					if(treeIndex>=d.getElementsByTagName("*").length)treeIndex = 0;
-				} while(d.getElementsByTagName("*")[treeIndex].xid == "modi");
-			}
-			so_walkDOMTree();
-			treeIndex++;
-			break;
-		case 85:
-				pref_alwaysTransparent = pref_alwaysTransparent?false:true;
-				so_setOpacity(mObj,pref_alwaysTransparent?60:99);
-				break;
-		case 86:
-			so_createEditWindow(activeObj);
-			break;
-		case 87:
-			so_showParentObj();
-			break;
-		case 89:
-			if(d.getElementsByTagName("*")[treeIndex].xid == "modi") {
-				do {
-					treeIndex--;
-					if(treeIndex<0)treeIndex = d.getElementsByTagName("*").length-1;
-				} while(d.getElementsByTagName("*")[treeIndex].xid == "modi");
-			}
-			so_walkDOMTree();
-			treeIndex--;
-			break;
-	}
-}
-
-function so_snapWindow(corner) {
-	if(!pref_freeze)pref_freeze = true;
-	switch(corner) {
-		case 0:
-			y = _returnScrollDimensions(1);
-			mObj.style.left = "10px";
-			mObj.style.top = y+"px";
-			break;
-		case 1:
-			
-			break;
-	}
-}
-
-function so_changeListState() {
-	if(!pref_allDataListsCollapsed) {
- 		d.getElementById("attributeData").style.display = "none";
- 		d.getElementById("parentData").style.display = "none";
- 		d.getElementById("dimensionData").style.display = "none";
- 		d.getElementById("childData").style.display = "none";
- 		pref_showAttr = false; pref_showDim = false; pref_showParents = false; pref_showChildren = false;
- 		pref_allDataListsCollapsed = true;
- 	} else {
- 		d.getElementById("attributeData").style.display = "block";
- 		d.getElementById("parentData").style.display = "block";
- 		d.getElementById("dimensionData").style.display = "block";
- 		d.getElementById("childData").style.display = "block";
- 		pref_showAttr = true; pref_showDim = true; pref_showParents = true; pref_showChildren = true;
- 		pref_allDataListsCollapsed = false;
- 	}
-}
-
-function so_removeLables() {
-	for(i=0;i<so_lbl.length;i++) {
-		try {
-			d.getElementsByTagName("body")[0].removeChild(so_lbl[i]);
-		} catch(err) { }
-	}
-	so_lbl = new Array();
-}
-
-function so_createEditWindow(obj) {
-	if(!activeObj)return;
-	if(pause)return;
-	pause = true;
-	if(d.all && !window.opera) {
-		if(mObj.offsetWidth<315) mObj.style.width = "318px";
-		if(mObj.offsetHeight<215) mObj.style.height = "218px";
-	}
-	editWindow = mObj.appendChild(d.createElement("div"));
-	editWindow.id = "htmlView";
-		
-	h3 = editWindow.appendChild(d.createElement("h3"));
-	h3.appendChild(d.createTextNode("HTML Source for " + obj.tagName.toLowerCase()));		
-
-	txt = editWindow.appendChild(d.createElement("textarea"));
-	txt.setAttribute("id","htmlViewText")
-	txt.value = obj.innerHTML;
-	editWindow.appendChild(d.createElement("br"));
-		
-	a = editWindow.appendChild(d.createElement("a"));
-	a.onclick = so_closeEditWindow;
-	a.className = "btn";
-	if(!isAppXML) {
-		a.appendChild(d.createTextNode("Cancel"));
-	} else {
-		a.appendChild(d.createTextNode("Close"));
-	}
-	if(!isAppXML) {
-		a = editWindow.appendChild(d.createElement("a"));
-		a.onclick = function() { so_applyInnerHTML(d.getElementById("htmlViewText").value,obj); }
-		a.className = "btn";
-		a.appendChild(d.createTextNode("Apply"));
-	}
-}
-
-function so_applyInnerHTML(mHTML,obj) {
-	if(isAppXML) {
-		so_closeEditWindow();
-		return;
-	}
-	try {
-		obj.innerHTML = mHTML;
-		so_closeEditWindow();
-	
-		all = obj.getElementsByTagName("*");
-		for(i=0;i<all.length;i++) {
-			so_prepareObjForMODI(all[i]);
-		}
-	} catch(err) { 
-		alert("An error occured while applying the innerHTML of this object. The most likely culprit is that this site is serving its content as application/xhtml+xml.\nError text was:\n\n" + err.message);
-		so_closeEditWindow();
-	}
-}
-
-
-function so_prepareObjForMODI(dObj) {
-	//dObj.onmouseover = so_showObjInfo;
-	//dObj.onmouseout = so_hideObjInfo;
-	dObj.addEventListener?dObj.addEventListener("mouseover",so_showObjInfo,false):dObj.onmouseover = so_showObjInfo;//dObj.attachEvent("onmouseover",so_showObjInfo);
-	dObj.addEventListener?dObj.addEventListener("mouseout",so_hideObjInfo,false):dObj.onmouseout = so_hideObjInfo;//dObj.attachEvent("onmouseout",so_hideObjInfo);
-	dObj.so_prevBGColor = all[i].style.backgroundColor;
-	dObj.so_prevWidth = all[i].offsetWidth;
-	dObj.so_prevTitle = all[i].getAttribute("title");
-}
-
-function so_closeEditWindow() {
-	document.getElementById("modiContainer").removeChild(document.getElementById("htmlView")) 
-	so_unsetObjHighlight(activeObj);
-	activeObj=null;
-	pause = false;
-}
-
-function so_outlineObj(obj) {
-	if(pause)return;
-	outline = pref_outlineWidth + " solid " + pref_outlineColor;
-	obj.style.MozOutline = outline;
-	obj.style.outline = outline;
-}
-
-function so_setOpacity(obj,op) {
-	if(pref_alwaysTransparent) {
-		op = pref_alwaysTransparentValue;
-	}
-	if(!d.all)op/=100;
-	obj.style.opacity = op;
-	obj.style.MozOpacity = op;
-	obj.style.filter = "alpha(opacity=" + op + ")";
-}
-
-function so_showObjInfo() {
-	if(pause)return;
-	if(isActive)return;
-	//if(pref_visible)mObj.style.display = "block";
-	activeObj = this;
-	isActive = true;
-	so_buildDataDisplay(this);
-	so_setOpacity(mObj,99);
-	so_setObjHighlight(this);
-
-}
-
-function so_hideObjInfo() {
-	if(pause)return;
-	try {
-		so_unsetObjHighlight(this);
-	} catch(err) { }
-	isActive = false;
-	activeObj = null;
-}
-
-function so_buildDataDisplay(obj) {
-	if(pause)return;
-	if(d.getElementById("tmp_h2")) mObj.removeChild(d.getElementById("tmp_h2"));
-	if(d.getElementById("sContainer")) mObj.removeChild(d.getElementById("sContainer"));
-	
-	if(!pref_visible) {
-		ttl = obj.tagName.toLowerCase();
-		if(obj.id) ttl+= " id=\"" + obj.id + "\"";
-		if(obj.className) ttl+= " class=\""+obj.className+"\"";
-		obj.setAttribute("title",ttl);
-		return;
-	}
-	
-	sObj = mObj.appendChild(d.createElement("div"));
-	sObj.setAttribute("id","sContainer");
-
-	h2 = sObj.appendChild(d.createElement("h2"));
-	h2.appendChild(d.createTextNode(obj.tagName.toLowerCase()));
-	if(pause)h2.appendChild(d.createTextNode(" [paused]"));
-	h2.onmousedown =  so_captureOffset;
-	h2.onmouseup = function() {	mDown = false; }
-	h2.id = "so_h2";
-	h2.style.backgroundImage = "url("+so_host+""+ statusImg[pref_highlights] + ")";
-	
-	// attributes
-	h3 = sObj.appendChild(d.createElement("h3"));
-	h3.appendChild(d.createTextNode("attributes"));
-	h3.className = pref_showAttr?"h3_on":"h3_off";
-	h3.onclick = function() { 
-		pref_showAttr = pref_showAttr?false:true;
-		this.className = pref_showAttr?"h3_on":"h3_off";
-		document.getElementById("attributeData").style.display = pref_showAttr?"block":"none"; 
-	}
-	
-	ul = sObj.appendChild(d.createElement("ul"));
-	ul.setAttribute("id","attributeData");
-	ul.style.display = pref_showAttr?"block":"none";
-	
-	attrCount = 0;
-	for(i=0;i<obj.attributes.length;i++) {
-		if(obj.attributes[i].specified) {
-			if(obj.attributes[i].value && obj.attributes[i].name.indexOf("so_")==-1) {
-				attrCount++;
-				li = ul.appendChild(d.createElement("li"));
-				val = so_wrapAttributeValue(obj.attributes[i].value);
-				li.appendChild(d.createTextNode(obj.attributes[i].name.toLowerCase() + " : " + val));
-			}
-		}
-	}
-	
-	if(attrCount == 0) {
-		li = ul.appendChild(d.createElement("li"));
-		li.appendChild(d.createTextNode("None Specified."));
-	}
-
-	// dimensions
-	h3 = sObj.appendChild(d.createElement("h3"));
-	h3.appendChild(d.createTextNode("dimensions"));
-	h3.className = pref_showDim?"h3_on":"h3_off";
-	h3.onclick = function() {
-		pref_showDim = pref_showDim?false:true;
-		this.className = pref_showDim?"h3_on":"h3_off";
-		document.getElementById("dimensionData").style.display = pref_showDim?"block":"none";
-	}
-	ul = sObj.appendChild(d.createElement("ul"));
-	ul.setAttribute("id","dimensionData");
-	ul.style.display = pref_showDim?"block":"none";
-	
-	li = ul.appendChild(d.createElement("li"));
-	li.appendChild(d.createTextNode("Font Size : " + getStyle(obj, 'font-size')));
-	li = ul.appendChild(d.createElement("li"));
-	li.appendChild(d.createTextNode("Width : " + obj.offsetWidth + "px"));
-	li = ul.appendChild(d.createElement("li"));
-	li.appendChild(d.createTextNode("Height : " + obj.offsetHeight + "px"));
-	li = ul.appendChild(d.createElement("li"));
-	li.appendChild(d.createTextNode("Top : " + so_findPosition(obj,0) + "px"));
-	li = ul.appendChild(d.createElement("li"));
-	li.appendChild(d.createTextNode("Left : " + so_findPosition(obj,1) + "px"));
-
-	// parents
-	h3 = sObj.appendChild(d.createElement("h3"));
-	h3.appendChild(d.createTextNode("parent structure"));
-	h3.className = pref_showParents?"h3_on":"h3_off";
-	h3.onclick = function() {
-		pref_showParents = pref_showParents?false:true;
-		this.className = pref_showParents?"h3_on":"h3_off";
-		document.getElementById("parentData").style.display = pref_showParents?"block":"none";
-	}
-	so_getParents(obj,sObj);
-
-	// children
-	if(obj.childNodes.length) {
-		h3 = sObj.appendChild(d.createElement("h3"));
-		h3.appendChild(d.createTextNode("children"));
-		h3.className = pref_showChildren?"h3_on":"h3_off";
-		h3.onclick = function() {
-			pref_showChildren = pref_showChildren?false:true;
-			this.className = pref_showChildren?"h3_on":"h3_off";
-			document.getElementById("childData").style.display = pref_showChildren?"block":"none";
-		}
-		
-		ul = sObj.appendChild(d.createElement("ul"));
-		ul.setAttribute("id","childData");
-		ul.style.display = pref_showChildren?"block":"none";
-		
-		for(i=0;i<obj.childNodes.length;i++) {
-			li = ul.appendChild(d.createElement("li"));
-			if(obj.childNodes[i].nodeType == 1) {
-				li.appendChild(d.createTextNode(obj.childNodes[i].nodeName.toLowerCase()));
-				li.className = "parentStructure";
-				li.myObj = obj.childNodes[i];
-				li.onmouseover = function() {
-					pref_backgroundHighlightColor = pref_childHighlightColor;
-					this.myObj.so_prevBGColor = this.myObj.style.backgroundColor;
-					so_setObjHighlight(this.myObj);
-				}
-				li.onmouseout = function() {
-					pref_backgroundHighlightColor = oHighlightColor;
-					so_unsetObjHighlight(this.myObj);
-				}
-				if(obj.childNodes[i].getAttribute("id")) li.appendChild(d.createTextNode(" id=\"" + obj.childNodes[i].getAttribute("id") + "\""));
-				if(obj.childNodes[i].className) li.appendChild(d.createTextNode(" class=\"" + obj.childNodes[i].className + "\""));
-			} else {
-				nodes = new Array("","Element Node","Attribute Node","#text","CDATA Node","Entity Reference Node","Entity Node","Processing Instruction Node","Comment Node","Document Node","Document Fragment Node","Notation Node");
-				li.appendChild(d.createTextNode(nodes[obj.childNodes[i].nodeType]));
-				li.setAttribute("title",obj.childNodes[i].nodeValue);
-			}
-		}
-	}
-	
-	// credits
-	div = sObj.appendChild(d.createElement("div"));
-	div.setAttribute("id","credits");
-	b = div.appendChild(d.createElement("b"));
-	//b.appendChild(d.createTextNode("[esc] to quit | "));
-	a = d.createElement("a"); 
-	a.setAttribute("href","javascript:so_cleanUp();");
-	a.appendChild(d.createTextNode("[esc] to quit"));
-	b.appendChild(a); 
-	b.appendChild(d.createTextNode(" | "));
-	
-	a = b.appendChild(d.createElement("a"));
-	a.setAttribute("title","Help!");
-	a.setAttribute("href",so_host + "modi_help.html");
-	a.setAttribute("target","_blank");
-	a.appendChild(d.createTextNode("help documentation"));
-	
-	div.appendChild(d.createElement("br"));
-	div.appendChild(d.createTextNode("Mouseover DOM Inspector"));
-	div.appendChild(d.createElement("br"));
-	div.appendChild(d.createTextNode("version 2.0.2 (05.11.2005)"));
-	div.appendChild(d.createElement("br"));
-	div.appendChild(d.createTextNode("slayeroffice.com"));
-	div.appendChild(d.createElement("br"));
-
-	so_tagAsMODI();
-	
-	if(d.all && !window.opera) {
-		// make up for IE's lack of max-width support.
-		if(mObj.offsetWidth>400) mObj.style.width="400px";
-	}
-	
-	function so_wrapAttributeValue(attrValue) {
-		// IE has a word-break css property. no need to do anything if this is IE
-		if(d.all && !window.opera) return attrValue;
-		// attribute value has a space in it. return.
-		if(attrValue.indexOf(" ")>-1) return attrValue;
-		for(ee=0;ee<attrValue.length;ee++) if(ee%50==0) attrValue = attrValue.substring(0,ee) + " " + attrValue.substring(ee,attrValue.length);
-		return attrValue;
-	}
-	
-}
-
-function so_getParents(curNode,dataContainer){
-	parents = new Array();
-	parentObjRef = new Array();
-	while(curNode.parentNode){
-		parents[parents.length] = curNode.tagName.toLowerCase();
-		parentObjRef[parentObjRef.length] = curNode;
-		curNode = curNode.parentNode;
-	}
-
-	ul = dataContainer.appendChild(d.createElement("ul"));
-	ul.setAttribute("id","parentData");
-	ul.style.display = pref_showParents?"block":"none";
-	
-	for(i=parents.length-1; i>0; i--){
-		li = ul.appendChild(d.createElement("li"));
-		li.appendChild(d.createTextNode(parents[i]));
-		if(parentObjRef[i].getAttribute("id")) li.appendChild(d.createTextNode(" id=\"" + parentObjRef[i].getAttribute("id") +"\""));
-		if(parentObjRef[i].className) li.appendChild(d.createTextNode(" class=\"" + parentObjRef[i].className + "\""));
-		
-		li.myObj = parentObjRef[i];
-		li.className = "parentStructure";
-		li.onmouseover = function() {
-			this.myObj.so_prevBGColor = this.myObj.style.backgroundColor;
-			so_setObjHighlight(this.myObj);
-		}
-		li.onmouseout = function() {
-			so_unsetObjHighlight(this.myObj);
-		}
-	}
-
-}
-
-function so_showParentObj() {
-	if(pause)return;
-	so_unsetObjHighlight(activeObj);
-	if(activeObj.parentNode && activeObj.tagName != "HTML") {
-		activeObj = activeObj.parentNode
-		activeObj.so_prevBGColor = activeObj.style.backgroundColor;
-		so_setObjHighlight(activeObj);
-		so_buildDataDisplay(activeObj);
-	}
-}
-
-function so_labelObj(obj) {
-	if(pause || !activeObj) return;
-	lblText = obj.tagName.toLowerCase();
-	len = so_lbl.length;
-	so_lbl[len] = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
-	so_lbl[len].appendChild(d.createTextNode(lblText));
-	so_lbl[len].className = "modi_label";
-	so_lbl[len].style.top = so_findPosition(obj,0) + "px";
-	so_lbl[len].style.left = so_findPosition(obj,1) + "px";
-	so_lbl[len].onclick = function() {
-		this.parentNode.removeChild(this);
-	}
-}
-
-function so_removeObj() {
-	if(pause)return;
-	activeObj.parentNode.removeChild(activeObj);
-}
-
-function so_cleanUp() {
-	d.getElementsByTagName("head")[0].removeChild(d.getElementById("modiCSS"));
-	d.getElementsByTagName("body")[0].removeChild(d.getElementById("modiContainer"));
-	// id is "modi" if invoked on its own, "sss" if invoked from the favelet suite
-	if(d.getElementById("modi")) {
-		d.getElementsByTagName("body")[0].removeChild(d.getElementById("modi"));
-	} else {
-		d.getElementsByTagName("body")[0].removeChild(d.getElementById("sss"));
-	}
-	d.onkeydown = null;
-	d.onmousemove = null;
-
-	all = d.getElementsByTagName("*");
-	for(i=0;i<all.length;i++) {
-		//all[i].onmouseover = null;
-		//all[i].onmouseout = null;
-		all[i].removeEventListener?all[i].removeEventListener("mouseover",so_showObjInfo,false):all[i].onmouseover = null;//all[i].detachEvent("onmouseover",so_showObjInfo);
-		all[i].removeEventListener?all[i].removeEventListener("mouseout",so_hideObjInfo,false):all[i].onmouseout = null;//all[i].detachEvent("onmouseout",so_hideObjInfo);
-		all[i].style.backgroundColor = all[i].so_prevBGColor;
-		all[i].so_prevBGColor = null;
-		if(all[i].randomBGColor)all[i].randomBGColor = null;
-		all[i].setAttribute("title",all[i].so_prevTitle); 
-		all[i].style.outline = "none";
-		all[i].style.MozOutline = "none";
-	}
-
-	if(activeObj)activeObj.style.backgroundColor = activeObj.so_prevBGColor;
-}
-
-function so_randomColor() {
-	if(pause)return;
-	if(activeObj == null) return;
-	if(!activeObj.randomBGColor) {
-		r = Math.floor(Math.random() * 256);
-		g = Math.floor(Math.random() * 256);
-		b = Math.floor(Math.random() * 256);
-		rgb = "rgb(" + r + "," + g + "," + b + ")";
-		if(activeObj) {
-			activeObj.style.backgroundColor = rgb;
-			activeObj.randomBGColor = rgb;
-		}
-	} else {
-		if(activeObj.style.backgroundColor == activeObj.so_prevBGColor) {
-			activeObj.style.backgroundColor = activeObj.randomBGColor;
-		} else {
-			activeObj.style.backgroundColor = activeObj.so_prevBGColor;
-			activeObj.randomBGColor = activeObj.so_prevBGColor;
-		}
-	}
-}
-
-function so_walkDOMTree() {
-	if(pause)return;
-	if(activeObj) so_unsetObjHighlight(activeObj);
-	if(treeIndex>=d.getElementsByTagName("*").length) treeIndex = 0;
-	if(treeIndex<0) treeIndex = d.getElementsByTagName("*").length - 1;
-	
-	activeObj = d.getElementsByTagName("*")[treeIndex];
-	if(d.all && !window.opera) {
-		if(activeObj.tagName == "!") {
-			treeIndex++;
-			activeObj = d.getElementsByTagName("*")[treeIndex];
-		}
-	}
-	so_buildDataDisplay(activeObj);
-	so_setObjHighlight(activeObj);
-	if(!pref_freeze) {
-		mObj.style.top = so_findPosition(activeObj,0)+15 + "px";
-		mObj.style.left = so_findPosition(activeObj,1)+15 + "px";
-	}
-}
-
-function so_tagAsMODI() {
-	modiChildren = mObj.getElementsByTagName("*");
-	for(m=0;m<modiChildren.length;m++) modiChildren[m].xid = "modi";
-}
-	
-function so_findPosition(obj,pType) {
-	cur = 0;
-	if(obj.offsetParent) {		
-		while(obj.offsetParent) {
-			cur+=pType?obj.offsetLeft:obj.offsetTop;
-			obj = obj.offsetParent;
-		}
-	}
-	return cur;
-}
-
-function so_cloneObject() {
-	if(pause)return;
-	if(!activeObj)return;
-	clonedObj = activeObj.cloneNode(true);
-}
-
-function so_insertClonedObj() {
-	if(pause)return;
-	if(!activeObj || !clonedObj)return;
-	activeObj.appendChild(clonedObj);
-	so_prepareObjForMODI(clonedObj);
-	
-	c = clonedObj.getElementsByTagName("*");
-	for(i=0;i<c.length;i++) so_prepareObjForMODI(c[i]);
-}
-
-function so_captureOffset(e) {
-	mDown = true;
-	nx = parseInt(mObj.offsetLeft);
-	ny = parseInt(mObj.offsetTop);
-
-	if(d.all) {
-		offsetX=window.event.clientX - nx;
-		offsetY=window.event.clientY - ny;
-	} else {
-		offsetX = e.pageX - nx;
-		offsetY = e.pageY - ny;
-	}
-}
-
-function so_hideObject() {
-	if(pause || !activeObj)return;
-	if(activeObj.style.visibility == "" || activeObj.style.visibility == "visible") {
-		modiHiddenObjects[modiHiddenObjects.length] = activeObj;
-		activeObj.style.visibility = "hidden"
-		activeObj = null;
-	} 
-}
-
-function so_showModiHiddenObjects() {
-if(pause)return;
-	for(w=0;w<modiHiddenObjects.length;w++) {
-		modiHiddenObjects[w].style.visibility = "visible";
-	}
-	modiHiddenObjects = new Array();
-}
-
-function so_removeWidth() {
-	if(pause) return;
-	if(!activeObj) return;
-
-	if(activeObj.so_prevWidth != activeObj.offsetWidth) {
-		activeObj.style.width = activeObj.so_prevWidth + "px";
-		activeObj.so_prevWidth = activeObj.offsetWidth;
-	} else {
-		activeObj.style.width = "auto";
-	}
-}
-
-function so_showFirstChild() {
-	if(pause)return;
-	if(!activeObj) return;
-	n = activeObj.childNodes;
-	if(!n.length)return;
-	m=null;
-	for(k=0;k<n.length;k++) {
-		if(n[k].nodeType == 1) {
-			m = n[k];
-			break;
-		}
-	}
-	
-	if(!m) return;
-	so_unsetObjHighlight(activeObj);
-	activeObj = m;
-	so_buildDataDisplay(activeObj);
-}
-
-
-so_init();
\ No newline at end of file
--- a/media/js/wisp/terrain1.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,520 +0,0 @@
-var width = exports.width = 610;
-var height = exports.height = 400;
-var wireframe = exports.wireframe = true;
-var wireframeWidth = exports.wireframeWidth = 1.2;
-var terrainHeight = exports.terrainHeight = 50;
-var terrainSize = exports.terrainSize = 100;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-var l = exports.l = function l(v) {
-    return console.log(v);
-};
-var midpoint = exports.midpoint = function midpoint(a, b) {
-    return (a + b) / 2;
-};
-var average2 = exports.average2 = function average2(a, b) {
-    return (a + b) / 2;
-};
-var average4 = exports.average4 = function average4(a, b, c, d) {
-    return (a + b + c + d) / 4;
-};
-var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
-    return function () {
-        var totalø1 = 0;
-        var countø1 = 0;
-        a ? (function () {
-            totalø1 = totalø1 + a;
-            return countø1 = countø1 + 1;
-        })() : void 0;
-        b ? (function () {
-            totalø1 = totalø1 + b;
-            return countø1 = countø1 + 1;
-        })() : void 0;
-        c ? (function () {
-            totalø1 = totalø1 + c;
-            return countø1 = countø1 + 1;
-        })() : void 0;
-        d ? (function () {
-            totalø1 = totalø1 + d;
-            return countø1 = countø1 + 1;
-        })() : void 0;
-        return totalø1 / countø1;
-    }.call(this);
-};
-var rand = exports.rand = function rand() {
-    return Math.random();
-};
-var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
-    return spread * rand() * 2 - spread;
-};
-var jitter = exports.jitter = function jitter(value, spread) {
-    return value + randAroundZero(spread);
-};
-void 0;
-var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(hm, x, y) {
-    return 0 <= x && x <= hm.last && (0 <= y && y <= hm.last) ? (function () {
-        return hm[y * hm.resolution + x];
-    })() : void 0;
-};
-void 0;
-var normalize = exports.normalize = function normalize(hm) {
-    return function () {
-        var maxø1 = 0 - Infinity;
-        var minø1 = Infinity;
-        (function () {
-            var G__1ø1 = hm.length;
-            return function loop() {
-                var recur = loop;
-                var iø1 = 0;
-                do {
-                    recur = iø1 < G__1ø1 ? (function () {
-                        (function () {
-                            var elø1 = hm[iø1];
-                            maxø1 < elø1 ? (function () {
-                                return maxø1 = elø1;
-                            })() : void 0;
-                            return minø1 > elø1 ? (function () {
-                                return minø1 = elø1;
-                            })() : void 0;
-                        }.call(this));
-                        return loop[0] = 1 + iø1, loop;
-                    })() : void 0;
-                } while (iø1 = loop[0], recur === loop);
-                return recur;
-            }.call(this);
-        }.call(this));
-        return function () {
-            var spanø1 = maxø1 - minø1;
-            return function () {
-                var G__2ø1 = hm.length;
-                return function loop() {
-                    var recur = loop;
-                    var iø1 = 0;
-                    do {
-                        recur = iø1 < G__2ø1 ? (function () {
-                            hm[iø1] = (hm[iø1] - minø1) / spanø1;
-                            return loop[0] = 1 + iø1, loop;
-                        })() : void 0;
-                    } while (iø1 = loop[0], recur === loop);
-                    return recur;
-                }.call(this);
-            }.call(this);
-        }.call(this);
-    }.call(this);
-};
-var zeroHeightmap = exports.zeroHeightmap = function zeroHeightmap(heightmap) {
-    (function () {
-        var G__3ø1 = heightmap.length;
-        return function loop() {
-            var recur = loop;
-            var iø1 = 0;
-            do {
-                recur = iø1 < G__3ø1 ? (function () {
-                    heightmap[iø1] = 0;
-                    return loop[0] = 1 + iø1, loop;
-                })() : void 0;
-            } while (iø1 = loop[0], recur === loop);
-            return recur;
-        }.call(this);
-    }.call(this));
-    return heightmap;
-};
-var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
-    return function () {
-        var resolutionø1 = 1 + Math.pow(2, exponent);
-        l('Creating ' + resolutionø1 + ' by ' + resolutionø1 + ' heightmap...');
-        var heightmap = new Array(resolutionø1 * resolutionø1);
-        heightmap.resolution = resolutionø1;
-        heightmap.exponent = exponent;
-        heightmap.last = resolutionø1 - 1;
-        return zeroHeightmap(heightmap);
-    }.call(this);
-};
-var randomNoise = exports.randomNoise = function randomNoise(heightmap) {
-    return function () {
-        var G__4ø1 = heightmap.length;
-        return function loop() {
-            var recur = loop;
-            var iø1 = 0;
-            do {
-                recur = iø1 < G__4ø1 ? (function () {
-                    heightmap[iø1] = rand();
-                    return loop[0] = 1 + iø1, loop;
-                })() : void 0;
-            } while (iø1 = loop[0], recur === loop);
-            return recur;
-        }.call(this);
-    }.call(this);
-};
-var mpdInitCorners = exports.mpdInitCorners = function mpdInitCorners(heightmap) {
-    heightmap[0 * heightmap.resolution + 0] = rand();
-    heightmap[heightmap.last * heightmap.resolution + 0] = rand();
-    heightmap[0 * heightmap.resolution + heightmap.last] = rand();
-    return heightmap[heightmap.last * heightmap.resolution + heightmap.last] = rand();
-};
-var mpdDisplace = exports.mpdDisplace = function mpdDisplace(heightmap, lx, rx, by, ty, spread) {
-    return function () {
-        var cxø1 = midpoint(lx, rx);
-        var cyø1 = midpoint(by, ty);
-        var bottomLeftø1 = heightmap[by * heightmap.resolution + lx];
-        var bottomRightø1 = heightmap[by * heightmap.resolution + rx];
-        var topLeftø1 = heightmap[ty * heightmap.resolution + lx];
-        var topRightø1 = heightmap[ty * heightmap.resolution + rx];
-        var topø1 = average2(topLeftø1, topRightø1);
-        var leftø1 = average2(bottomLeftø1, topLeftø1);
-        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
-        var rightø1 = average2(bottomRightø1, topRightø1);
-        var centerø1 = average4(topø1, leftø1, bottomø1, rightø1);
-        heightmap[by * heightmap.resolution + cxø1] = jitter(bottomø1, spread);
-        heightmap[ty * heightmap.resolution + cxø1] = jitter(topø1, spread);
-        heightmap[cyø1 * heightmap.resolution + lx] = jitter(leftø1, spread);
-        heightmap[cyø1 * heightmap.resolution + rx] = jitter(rightø1, spread);
-        return heightmap[cyø1 * heightmap.resolution + cxø1] = jitter(centerø1, spread);
-    }.call(this);
-};
-var midpointDisplacement = exports.midpointDisplacement = function midpointDisplacement(heightmap) {
-    mpdInitCorners(heightmap);
-    (function loop() {
-        var recur = loop;
-        var iterø1 = 0;
-        var spreadø1 = 0.3;
-        do {
-            recur = iterø1 < heightmap.exponent ? (function () {
-                (function () {
-                    var chunksø1 = Math.pow(2, iterø1);
-                    var chunkWidthø1 = (heightmap.resolution - 1) / chunksø1;
-                    return function () {
-                        var G__5ø1 = chunksø1;
-                        return function () {
-                            var G__6ø1 = G__5ø1;
-                            return function loop() {
-                                var recur = loop;
-                                var xchunkø1 = 0;
-                                do {
-                                    recur = xchunkø1 < G__6ø1 ? (function () {
-                                        (function () {
-                                            var G__7ø1 = G__5ø1;
-                                            return function loop() {
-                                                var recur = loop;
-                                                var ychunkø1 = 0;
-                                                do {
-                                                    recur = ychunkø1 < G__7ø1 ? (function () {
-                                                        (function () {
-                                                            var leftXø1 = chunkWidthø1 * xchunkø1;
-                                                            var rightXø1 = leftXø1 + chunkWidthø1;
-                                                            var bottomYø1 = chunkWidthø1 * ychunkø1;
-                                                            var topYø1 = bottomYø1 + chunkWidthø1;
-                                                            return mpdDisplace(heightmap, leftXø1, rightXø1, bottomYø1, topYø1, spreadø1);
-                                                        }.call(this));
-                                                        return loop[0] = 1 + ychunkø1, loop;
-                                                    })() : void 0;
-                                                } while (ychunkø1 = loop[0], recur === loop);
-                                                return recur;
-                                            }.call(this);
-                                        }.call(this));
-                                        return loop[0] = 1 + xchunkø1, loop;
-                                    })() : void 0;
-                                } while (xchunkø1 = loop[0], recur === loop);
-                                return recur;
-                            }.call(this);
-                        }.call(this);
-                    }.call(this);
-                }.call(this));
-                return loop[0] = 1 + iterø1, loop[1] = spreadø1 * 0.5, loop;
-            })() : void 0;
-        } while (iterø1 = loop[0], spreadø1 = loop[1], recur === loop);
-        return recur;
-    }.call(this));
-    return normalize(heightmap);
-};
-var midpointDisplacementFinal = exports.midpointDisplacementFinal = function midpointDisplacementFinal(heightmap) {
-    mpdInitCorners(heightmap);
-    (function loop() {
-        var recur = loop;
-        var iterø1 = 0;
-        var spreadø1 = 0 + $('#input-starting-spread').val();
-        do {
-            recur = iterø1 < heightmap.exponent ? (function () {
-                (function () {
-                    var chunksø1 = Math.pow(2, iterø1);
-                    var chunkWidthø1 = (heightmap.resolution - 1) / chunksø1;
-                    return function () {
-                        var G__8ø1 = chunksø1;
-                        return function () {
-                            var G__9ø1 = G__8ø1;
-                            return function loop() {
-                                var recur = loop;
-                                var xchunkø1 = 0;
-                                do {
-                                    recur = xchunkø1 < G__9ø1 ? (function () {
-                                        (function () {
-                                            var G__10ø1 = G__8ø1;
-                                            return function loop() {
-                                                var recur = loop;
-                                                var ychunkø1 = 0;
-                                                do {
-                                                    recur = ychunkø1 < G__10ø1 ? (function () {
-                                                        (function () {
-                                                            var leftXø1 = chunkWidthø1 * xchunkø1;
-                                                            var rightXø1 = leftXø1 + chunkWidthø1;
-                                                            var bottomYø1 = chunkWidthø1 * ychunkø1;
-                                                            var topYø1 = bottomYø1 + chunkWidthø1;
-                                                            return mpdDisplace(heightmap, leftXø1, rightXø1, bottomYø1, topYø1, spreadø1);
-                                                        }.call(this));
-                                                        return loop[0] = 1 + ychunkø1, loop;
-                                                    })() : void 0;
-                                                } while (ychunkø1 = loop[0], recur === loop);
-                                                return recur;
-                                            }.call(this);
-                                        }.call(this));
-                                        return loop[0] = 1 + xchunkø1, loop;
-                                    })() : void 0;
-                                } while (xchunkø1 = loop[0], recur === loop);
-                                return recur;
-                            }.call(this);
-                        }.call(this);
-                    }.call(this);
-                }.call(this));
-                return loop[0] = 1 + iterø1, loop[1] = spreadø1 * (0 + $('#input-spread-reduction').val()), loop;
-            })() : void 0;
-        } while (iterø1 = loop[0], spreadø1 = loop[1], recur === loop);
-        return recur;
-    }.call(this));
-    return normalize(heightmap);
-};
-var mpdDisplaceD2 = exports.mpdDisplaceD2 = function mpdDisplaceD2(heightmap, lx, rx, by, ty, spread) {
-    return function () {
-        var cxø1 = midpoint(lx, rx);
-        var cyø1 = midpoint(by, ty);
-        var bottomLeftø1 = heightmap[by * heightmap.resolution + lx];
-        var bottomRightø1 = heightmap[by * heightmap.resolution + rx];
-        var topLeftø1 = heightmap[ty * heightmap.resolution + lx];
-        var topRightø1 = heightmap[ty * heightmap.resolution + rx];
-        var topø1 = average2(topLeftø1, topRightø1);
-        var leftø1 = average2(bottomLeftø1, topLeftø1);
-        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
-        var rightø1 = average2(bottomRightø1, topRightø1);
-        heightmap[by * heightmap.resolution + cxø1] = jitter(bottomø1, spread);
-        heightmap[ty * heightmap.resolution + cxø1] = jitter(topø1, spread);
-        heightmap[cyø1 * heightmap.resolution + lx] = jitter(leftø1, spread);
-        return heightmap[cyø1 * heightmap.resolution + rx] = jitter(rightø1, spread);
-    }.call(this);
-};
-var midpointDisplacementD1 = exports.midpointDisplacementD1 = function midpointDisplacementD1(heightmap) {
-    return mpdInitCorners(heightmap);
-};
-var midpointDisplacementD2 = exports.midpointDisplacementD2 = function midpointDisplacementD2(heightmap) {
-    mpdInitCorners(heightmap);
-    return mpdDisplaceD2(heightmap, 0, heightmap.last, 0, heightmap.last, 0.1);
-};
-var midpointDisplacementD3 = exports.midpointDisplacementD3 = function midpointDisplacementD3(heightmap) {
-    mpdInitCorners(heightmap);
-    return mpdDisplace(heightmap, 0, heightmap.last, 0, heightmap.last, 0.1);
-};
-var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
-    return function () {
-        var lightø1 = new THREE.DirectionalLight(16777215, 1);
-        lightø1.position.set(100, 0, 150);
-        return lightø1;
-    }.call(this);
-};
-var makeCamera = exports.makeCamera = function makeCamera() {
-    return function () {
-        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
-        cameraø1.position.set(0, -100, 150);
-        return cameraø1;
-    }.call(this);
-};
-var makeRenderer = exports.makeRenderer = function makeRenderer() {
-    return function () {
-        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
-        rendererø1.setClearColor(16777215);
-        rendererø1.setSize(width, height);
-        rendererø1.setPixelRatio(2);
-        return rendererø1;
-    }.call(this);
-};
-var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
-    return function () {
-        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, heightmap.resolution - 1, heightmap.resolution - 1);
-        geometryø1.dynamic = true;
-        return geometryø1;
-    }.call(this);
-};
-var makeControls = exports.makeControls = function makeControls(camera, renderer) {
-    return function () {
-        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
-        controlsø1.rotateSpeed = 1.4;
-        controlsø1.zoomSpeed = 0.5;
-        controlsø1.staticMoving = true;
-        controlsø1.dynamicDampingFactor = 0.3;
-        return controlsø1;
-    }.call(this);
-};
-var makePlane = exports.makePlane = function makePlane(geometry) {
-    return function () {
-        var materialø1 = new THREE.MeshLambertMaterial({
-            'wireframe': wireframe,
-            'wireframeLinewidth': wireframeWidth,
-            'color': 47872
-        });
-        return new THREE.Mesh(geometry, materialø1);
-    }.call(this);
-};
-var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
-    return function () {
-        var containerø1 = document.getElementById(elName);
-        var settingsø1 = document.createElement('div');
-        var refreshButtonø1 = document.createElement('button');
-        var buttonTextø1 = document.createTextNode('Refresh');
-        var cancelScrollø1 = function (e) {
-            return e.preventDefault();
-        };
-        refreshButtonø1.onclick = refreshFn;
-        renderer.domElement.onmousewheel = cancelScrollø1;
-        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
-        refreshButtonø1.appendChild(buttonTextø1);
-        containerø1.appendChild(renderer.domElement);
-        containerø1.appendChild(settingsø1);
-        return settingsø1.appendChild(refreshButtonø1);
-    }.call(this);
-};
-var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
-    (function () {
-        var G__11ø1 = geometry.vertices.length;
-        return function loop() {
-            var recur = loop;
-            var iø1 = 0;
-            do {
-                recur = iø1 < G__11ø1 ? (function () {
-                    geometry.vertices[iø1].z = terrainHeight * heightmap[iø1];
-                    return loop[0] = 1 + iø1, loop;
-                })() : void 0;
-            } while (iø1 = loop[0], recur === loop);
-            return recur;
-        }.call(this);
-    }.call(this));
-    geometry.verticesNeedUpdate = true;
-    geometry.computeFaceNormals();
-    geometry.computeVertexNormals();
-    geometry.computeMorphNormals();
-    return geometry;
-};
-var makeDemo = exports.makeDemo = function makeDemo(elementId, algorithm, size) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var geometry = makeGeometry(makeHeightmap(size));
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    scene.add(makePlane(geometry));
-    var refresh = function refresh() {
-        l('Refreshing ========================================');
-        return function () {
-            var heightmapø1 = makeHeightmap(size);
-            l('Generating terrain...');
-            (function () {
-                var G__12ø1 = new Date().getTime();
-                var G__14ø1 = (function () {
-                    return algorithm(heightmapø1);
-                })();
-                var G__13ø1 = new Date().getTime();
-                l('Elapsed time: ' + (G__13ø1 - G__12ø1) + 'ms.');
-                return G__14ø1;
-            }.call(this));
-            l('Refreshing geometry...');
-            (function () {
-                var G__15ø1 = new Date().getTime();
-                var G__17ø1 = (function () {
-                    return updateGeometry(geometry, heightmapø1);
-                })();
-                var G__16ø1 = new Date().getTime();
-                l('Elapsed time: ' + (G__16ø1 - G__15ø1) + 'ms.');
-                return G__17ø1;
-            }.call(this));
-            return l('Done!');
-        }.call(this);
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    render();
-    return void 0;
-};
-var makeFinal = exports.makeFinal = function makeFinal(elementId) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var heightmap = makeHeightmap($('#input-exponent').val());
-    var geometry = makeGeometry(heightmap);
-    var plane = makePlane(geometry);
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    scene.add(plane);
-    var refresh = function refresh() {
-        l('Refreshing ========================================');
-        scene.remove(plane);
-        heightmap = makeHeightmap($('#input-exponent').val());
-        geometry = makeGeometry(heightmap);
-        plane = makePlane(geometry);
-        scene.add(plane);
-        l('Generating terrain...');
-        (function () {
-            var G__18ø1 = new Date().getTime();
-            var G__20ø1 = (function () {
-                return midpointDisplacementFinal(heightmap);
-            })();
-            var G__19ø1 = new Date().getTime();
-            l('Elapsed time: ' + (G__19ø1 - G__18ø1) + 'ms.');
-            return G__20ø1;
-        }.call(this));
-        l('Refreshing geometry...');
-        (function () {
-            var G__21ø1 = new Date().getTime();
-            var G__23ø1 = (function () {
-                return updateGeometry(geometry, heightmap);
-            })();
-            var G__22ø1 = new Date().getTime();
-            l('Elapsed time: ' + (G__22ø1 - G__21ø1) + 'ms.');
-            return G__23ø1;
-        }.call(this));
-        return l('Done!');
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    render();
-    return void 0;
-};
-var run = exports.run = function run() {
-    makeDemo('demo-random', randomNoise, 7);
-    makeDemo('demo-mpd-1', midpointDisplacementD1, 2);
-    makeDemo('demo-mpd-2', midpointDisplacementD2, 2);
-    makeDemo('demo-mpd-3', midpointDisplacementD3, 2);
-    makeDemo('demo-mpd-4', midpointDisplacement, 3);
-    return makeFinal('demo-final');
-};
-$(run);
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFub255bW91cy53aXNwIl0sIm5hbWVzIjpbIndpZHRoIiwiZXhwb3J0cyIsImhl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ICAgbGlnaHQpKVxuXG4oZGVmbiBtYWtlLWNhbWVyYSBbXVxuICAobGV0IFtjYW1lcmEgKG5ldyBUSFJFRS5QZXJzcGVjdGl2ZUNhbWVyYVxuICAgICAgICAgICAgICAgICAgICA1NSxcbiAgICAgICAgICAgICAgICAgICAgKC8gd2lkdGggaGVpZ2h0KVxuICAgICAgICAgICAgICAgICAgICAwLjEsXG4gICAgICAgICAgICAgICAgICAgIDEwMDApXVxuICAgIChjYW1lcmEucG9zaXRpb24uc2V0IDAgLTEwMCAxNTApXG4gICAgY2FtZXJhKSlcblxuKGRlZm4gbWFrZS1yZW5kZXJlciBbXVxuICAobGV0IFtyZW5kZXJlciAobmV3IFRIUkVFLldlYkdMUmVuZGVyZXIgezphbnRpYWxpYXMgZmFsc2V9KV1cbiAgICAocmVuZGVyZXIuc2V0Q2xlYXJDb2xvciAweGZmZmZmZilcbiAgICAocmVuZGVyZXIuc2V0U2l6ZSB3aWR0aCBoZWlnaHQpXG4gICAgKHJlbmRlcmVyLnNldFBpeGVsUmF0aW8gMilcbiAgICByZW5kZXJlcikpXG5cbihkZWZuIG1ha2UtZ2VvbWV0cnkgW2hlaWdodG1hcF1cbiAgKGxldCBbZ2VvbWV0cnkgKG5ldyBUSFJFRS5QbGFuZUdlb21ldHJ5XG4gICAgICAgICAgICAgICAgICAgICAgdGVycmFpbi1zaXplXG4gICAgICAgICAgICAgICAgICAgICAgdGVycmFpbi1zaXplXG4gICAgICAgICAgICAgICAgICAgICAgKC0gaGVpZ2h0bWFwLnJlc29sdXRpb24gMSlcbiAgICAgICAgICAgICAgICAgICAgICAoLSBoZWlnaHRtYXAucmVzb2x1dGlvbiAxKSldXG4gICAgKHNldCEgZ2VvbWV0cnkuZHluYW1pYyB0cnVlKVxuICAgIGdlb21ldHJ5KSlcblxuKGRlZm4gbWFrZS1jb250cm9scyBbY2FtZXJhIHJlbmRlcmVyXVxuICAobGV0IFtjb250cm9scyAobmV3IFRIUkVFLlRyYWNrYmFsbENvb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VtZW50LWQzIDIpXG4gIChtYWtlLWRlbW8gXCJkZW1vLW1wZC00XCIgbWlkcG9pbnQtZGlzcGxhY2VtZW50IDMpXG4gIChtYWtlLWZpbmFsIFwiZGVtby1maW5hbFwiKVxuICA7IChtYWtlLWRlbW8gXCJkZW1vLW1pZHBvaW50XCIgbWlkcG9pbnQtZGlzcGxhY2VtZW50KVxuICA7IChtYWtlLWRlbW8gXCJkZW1vLWRpYW1vbmRcIiBkaWFtb25kLXNxdWFyZSlcblxuICApXG5cbigkIHJ1bilcblxuXG47IHZpbTogbHcrPWRvLXRpbWVzIGx3Kz1kby1uZXN0ZWQgOlxuIl19
--- a/media/js/wisp/terrain1.wisp	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,392 +0,0 @@
-; Constants -------------------------------------------------------------------
-(def width 610)
-(def height 400)
-(def wireframe true)
-(def wireframe-width 1.2)
-(def terrain-height 50)
-(def terrain-size 100)
-
-; General Utilities -----------------------------------------------------------
-(defmacro when [condition & body]
-  `(if ~condition
-     (do ~@body)))
-
-(defmacro do-times [varname limit & body]
-  (let [end (gensym)]
-    `(let [~end ~limit]
-       (loop [~varname 0]
-         (when (< ~varname ~end)
-           ~@body
-           (recur (+ 1 ~varname)))))))
-
-(defmacro do-nested [xname yname width & body]
-  (let [iterations (gensym)]
-    `(let [~iterations ~width]
-       (do-times ~xname ~iterations
-         (do-times ~yname ~iterations
-           ~@body)))))
-
-(defmacro inc! [place]
-  `(set! ~place (+ ~place 1)))
-
-(defmacro add! [place amount]
-  `(set! ~place (+ ~place ~amount)))
-
-(defmacro time [& body]
-  (let [start (gensym)
-        end (gensym)
-        result (gensym)]
-    `(let [~start (.getTime (new Date))
-           ~result (do ~@body)
-           ~end (.getTime (new Date))]
-       (l (+ "Elapsed time: " (- ~end ~start) "ms."))
-       ~result)))
-
-(defn l [v]
-  (console.log v))
-
-
-(defn midpoint [a b]
-  (/ (+ a b) 2))
-
-(defn average2 [a b]
-  (/ (+ a b) 2))
-
-(defn average4 [a b c d]
-  (/ (+ a b c d) 4))
-
-(defn safe-average [a b c d]
-  (let [total 0 count 0]
-    (when a (add! total a) (inc! count))
-    (when b (add! total b) (inc! count))
-    (when c (add! total c) (inc! count))
-    (when d (add! total d) (inc! count))
-    (/ total count)))
-
-
-(defn rand []
-  (Math.random))
-
-(defn rand-around-zero [spread]
-  (- (* spread (rand) 2) spread))
-
-
-(defn jitter [value spread]
-  (+ value (rand-around-zero spread)))
-
-
-; Heightmap Helpers -----------------------------------------------------------
-(defmacro heightmap-get [hm x y]
-  `(aget ~hm (+ (* ~y (.-resolution ~hm)) ~x)))
-
-(defn heightmap-get-safe [hm x y]
-  (when (and (<= 0 x hm.last)
-             (<= 0 y hm.last))
-    (heightmap-get hm x y)))
-
-(defmacro heightmap-set! [hm x y val]
-  `(set! (heightmap-get ~hm ~x ~y) ~val))
-
-
-(defn normalize [hm]
-  (let [max (- Infinity)
-        min Infinity]
-    (do-times i hm.length
-      (let [el (aget hm i)]
-        (when (< max el) (set! max el))
-        (when (> min el) (set! min el))))
-    (let [span (- max min)]
-      (do-times i hm.length
-        (set! (aget hm i)
-          (/ (- (aget hm i) min)
-             span))))))
-
-(defn zero-heightmap [heightmap]
-  (do-times i heightmap.length
-    (set! (aget heightmap i) 0.0))
-  heightmap)
-
-(defn make-heightmap [exponent]
-  (let [resolution (+ 1 (Math.pow 2 exponent))]
-    (l (+ "Creating " resolution " by " resolution " heightmap..."))
-    (def heightmap
-      (new Array (* resolution resolution)))
-    (set! heightmap.resolution resolution)
-    (set! heightmap.exponent exponent)
-    (set! heightmap.last (- resolution 1))
-    (zero-heightmap heightmap)))
-
-
-; Random Noise ----------------------------------------------------------------
-(defn random-noise [heightmap]
-  (do-times i heightmap.length
-    (set! (aget heightmap i) (rand))))
-
-
-; Midpoint Displacement -------------------------------------------------------
-(defn mpd-init-corners [heightmap]
-  (heightmap-set! heightmap 0 0 (rand))
-  (heightmap-set! heightmap 0 heightmap.last (rand))
-  (heightmap-set! heightmap heightmap.last 0 (rand))
-  (heightmap-set! heightmap heightmap.last heightmap.last (rand)))
-
-(defn mpd-displace [heightmap lx rx by ty spread]
-  (let [cx (midpoint lx rx)
-        cy (midpoint by ty)
-
-        bottom-left (heightmap-get heightmap lx by)
-        bottom-right (heightmap-get heightmap rx by)
-        top-left (heightmap-get heightmap lx ty)
-        top-right (heightmap-get heightmap rx ty)
-
-        top (average2 top-left top-right)
-        left (average2 bottom-left top-left)
-        bottom (average2 bottom-left bottom-right)
-        right (average2 bottom-right top-right)
-        center (average4 top left bottom right)]
-    (heightmap-set! heightmap cx by (jitter bottom spread))
-    (heightmap-set! heightmap cx ty (jitter top spread))
-    (heightmap-set! heightmap lx cy (jitter left spread))
-    (heightmap-set! heightmap rx cy (jitter right spread))
-    (heightmap-set! heightmap cx cy (jitter center spread))))
-
-(defn midpoint-displacement [heightmap]
-  (mpd-init-corners heightmap)
-  ; (mpd-displace heightmap 0 heightmap.last 0 heightmap.last 0.1)
-  (loop [iter 0
-         spread 0.3]
-    (when (< iter heightmap.exponent)
-      (let [chunks (Math.pow 2 iter)
-            chunk-width (/ (- heightmap.resolution 1) chunks)]
-        (do-nested xchunk ychunk chunks
-          (let [left-x (* chunk-width xchunk)
-                right-x (+ left-x chunk-width)
-                bottom-y (* chunk-width ychunk)
-                top-y (+ bottom-y chunk-width)]
-            (mpd-displace heightmap left-x right-x bottom-y top-y spread))))
-      (recur (+ 1 iter) (* spread 0.5))))
-  (normalize heightmap))
-
-
-(defn midpoint-displacement-final [heightmap]
-  (mpd-init-corners heightmap)
-  ; (let [spread ])
-  (loop [iter 0
-         spread (+ 0 (.val ($ "#input-starting-spread")))]
-    (when (< iter heightmap.exponent)
-      (let [chunks (Math.pow 2 iter)
-            chunk-width (/ (- heightmap.resolution 1) chunks)]
-        (do-nested xchunk ychunk chunks
-          (let [left-x (* chunk-width xchunk)
-                right-x (+ left-x chunk-width)
-                bottom-y (* chunk-width ychunk)
-                top-y (+ bottom-y chunk-width)]
-            (mpd-displace heightmap left-x right-x bottom-y top-y spread))))
-      (recur (+ 1 iter) (* spread
-                           (+ 0 (.val ($ "#input-spread-reduction")))))))
-  (normalize heightmap))
-
-
-(defn mpd-displace-d2 [heightmap lx rx by ty spread]
-  (let [cx (midpoint lx rx)
-        cy (midpoint by ty)
-
-        bottom-left (heightmap-get heightmap lx by)
-        bottom-right (heightmap-get heightmap rx by)
-        top-left (heightmap-get heightmap lx ty)
-        top-right (heightmap-get heightmap rx ty)
-
-        top (average2 top-left top-right)
-        left (average2 bottom-left top-left)
-        bottom (average2 bottom-left bottom-right)
-        right (average2 bottom-right top-right)]
-    (heightmap-set! heightmap cx by (jitter bottom spread))
-    (heightmap-set! heightmap cx ty (jitter top spread))
-    (heightmap-set! heightmap lx cy (jitter left spread))
-    (heightmap-set! heightmap rx cy (jitter right spread))))
-
-(defn midpoint-displacement-d1 [heightmap]
-  (mpd-init-corners heightmap))
-
-(defn midpoint-displacement-d2 [heightmap]
-  (mpd-init-corners heightmap)
-  (mpd-displace-d2 heightmap
-                   0 heightmap.last
-                   0 heightmap.last
-                   0.1))
-
-(defn midpoint-displacement-d3 [heightmap]
-  (mpd-init-corners heightmap)
-  (mpd-displace heightmap
-                0 heightmap.last
-                0 heightmap.last
-                0.1))
-
-
-
-; Three.js Helpers ------------------------------------------------------------
-(defn make-directional-light []
-  (let [light (new THREE.DirectionalLight 0xffffff 1)]
-    (light.position.set 100 0 150)
-    light))
-
-(defn make-camera []
-  (let [camera (new THREE.PerspectiveCamera
-                    55,
-                    (/ width height)
-                    0.1,
-                    1000)]
-    (camera.position.set 0 -100 150)
-    camera))
-
-(defn make-renderer []
-  (let [renderer (new THREE.WebGLRenderer {:antialias false})]
-    (renderer.setClearColor 0xffffff)
-    (renderer.setSize width height)
-    (renderer.setPixelRatio 2)
-    renderer))
-
-(defn make-geometry [heightmap]
-  (let [geometry (new THREE.PlaneGeometry
-                      terrain-size
-                      terrain-size
-                      (- heightmap.resolution 1)
-                      (- heightmap.resolution 1))]
-    (set! geometry.dynamic true)
-    geometry))
-
-(defn make-controls [camera renderer]
-  (let [controls (new THREE.TrackballControls camera renderer.domElement)]
-    (set! controls.rotateSpeed 1.4)
-    (set! controls.zoomSpeed 0.5)
-    (set! controls.staticMoving true)
-    (set! controls.dynamicDampingFactor 0.3)
-    controls))
-
-(defn make-plane [geometry]
-  (let [material (new THREE.MeshLambertMaterial
-                      {:wireframe wireframe
-                       :wireframeLinewidth wireframe-width
-                       :color 0x00bb00})]
-    (new THREE.Mesh geometry material)))
-
-
-(defn attach-to-dom [renderer el-name refresh-fn]
-  (let [container (document.getElementById el-name)
-        settings (document.createElement "div")
-        refresh-button (document.createElement "button")
-        button-text (document.createTextNode "Refresh")
-        cancel-scroll (fn [e] (.preventDefault e))]
-    (set! refresh-button.onclick refresh-fn)
-    (set! renderer.domElement.onmousewheel cancel-scroll)
-    (renderer.domElement.addEventListener "MozMousePixelScroll" cancel-scroll false)
-    (.appendChild refresh-button button-text)
-    (.appendChild container renderer.domElement)
-    (.appendChild container settings)
-    (.appendChild settings refresh-button)))
-
-(defn update-geometry [geometry heightmap]
-  (do-times i geometry.vertices.length
-    (set! (.-z (aget geometry.vertices i))
-      (* terrain-height (aget heightmap i))))
-  (set! geometry.verticesNeedUpdate true)
-  (geometry.computeFaceNormals)
-  (geometry.computeVertexNormals)
-  (geometry.computeMorphNormals)
-  geometry)
-
-
-; Main ------------------------------------------------------------------------
-(defn make-demo [element-id algorithm size]
-  (def scene (new THREE.Scene))
-  (scene.add (new THREE.AxisHelper 100))
-
-  (def clock (new THREE.Clock))
-  (def camera (make-camera))
-  (def renderer (make-renderer))
-  (def geometry (make-geometry (make-heightmap size)))
-
-  (scene.add (make-directional-light))
-  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
-  (scene.add (make-plane geometry))
-
-  (defn refresh []
-    (l "Refreshing ========================================")
-    (let [heightmap (make-heightmap size)]
-      (l "Generating terrain...")
-      (time (algorithm heightmap))
-      (l "Refreshing geometry...")
-      (time (update-geometry geometry heightmap))
-      (l "Done!")))
-
-  (attach-to-dom renderer element-id refresh)
-  (def controls (make-controls camera renderer))
-
-  (defn render []
-    (let [delta (clock.getDelta)]
-      (requestAnimationFrame render)
-      (.update controls delta)
-      (renderer.render scene camera)))
-
-  (render)
-
-  nil)
-
-(defn make-final [element-id]
-  (def scene (new THREE.Scene))
-  (scene.add (new THREE.AxisHelper 100))
-
-  (def clock (new THREE.Clock))
-  (def camera (make-camera))
-  (def renderer (make-renderer))
-  (def heightmap (make-heightmap (.val ($ "#input-exponent"))))
-  (def geometry (make-geometry heightmap))
-  (def plane (make-plane geometry))
-
-  (scene.add (make-directional-light))
-  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
-  (scene.add plane)
-
-  (defn refresh []
-    (l "Refreshing ========================================")
-    (scene.remove plane)
-    (set! heightmap (make-heightmap (.val ($ "#input-exponent"))))
-    (set! geometry (make-geometry heightmap))
-    (set! plane (make-plane geometry))
-    (scene.add plane)
-    (l "Generating terrain...")
-    (time (midpoint-displacement-final heightmap))
-    (l "Refreshing geometry...")
-    (time (update-geometry geometry heightmap))
-    (l "Done!"))
-
-  (attach-to-dom renderer element-id refresh)
-  (def controls (make-controls camera renderer))
-
-  (defn render []
-    (let [delta (clock.getDelta)]
-      (requestAnimationFrame render)
-      (.update controls delta)
-      (renderer.render scene camera)))
-
-  (render)
-
-  nil)
-
-
-(defn run []
-  (make-demo "demo-random" random-noise 7)
-  (make-demo "demo-mpd-1" midpoint-displacement-d1 2)
-  (make-demo "demo-mpd-2" midpoint-displacement-d2 2)
-  (make-demo "demo-mpd-3" midpoint-displacement-d3 2)
-  (make-demo "demo-mpd-4" midpoint-displacement 3)
-  (make-final "demo-final")
-  ; (make-demo "demo-midpoint" midpoint-displacement)
-  ; (make-demo "demo-diamond" diamond-square)
-
-  )
-
-($ run)
-
-
-; vim: lw+=do-times lw+=do-nested :
--- a/media/js/wisp/terrain2.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,404 +0,0 @@
-{
-    var _ns_ = {
-        id: 'demo',
-        doc: void 0
-    };
-    var ndarray = require('ndarray');
-}
-var width = exports.width = 610;
-var height = exports.height = 400;
-var wireframe = exports.wireframe = true;
-var wireframeWidth = exports.wireframeWidth = 1.2;
-var terrainHeight = exports.terrainHeight = 50;
-var terrainSize = exports.terrainSize = 100;
-void 0;
-void 0;
-void 0;
-var inc = exports.inc = function inc(x) {
-    return x + 1;
-};
-var dec = exports.dec = function dec(x) {
-    return x - 1;
-};
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-var midpoint = exports.midpoint = function midpoint(a, b) {
-    return (a + b) / 2;
-};
-var average2 = exports.average2 = function average2(a, b) {
-    return (a + b) / 2;
-};
-var average4 = exports.average4 = function average4(a, b, c, d) {
-    return (a + b + c + d) / 4;
-};
-var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
-    return function () {
-        var totalø1 = 0;
-        var countø1 = 0;
-        a ? (function () {
-            totalø1 = totalø1 + a;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        b ? (function () {
-            totalø1 = totalø1 + b;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        c ? (function () {
-            totalø1 = totalø1 + c;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        d ? (function () {
-            totalø1 = totalø1 + d;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        return totalø1 / countø1;
-    }.call(this);
-};
-var rand = exports.rand = function rand() {
-    return Math.random();
-};
-var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
-    return spread * rand() * 2 - spread;
-};
-var jitter = exports.jitter = function jitter(value, spread) {
-    return value + randAroundZero(spread);
-};
-var heightmapResolution = exports.heightmapResolution = function heightmapResolution(heightmap) {
-    return heightmap.shape[0];
-};
-var heightmapLastIndex = exports.heightmapLastIndex = function heightmapLastIndex(heightmap) {
-    return dec(heightmapResolution(heightmap));
-};
-var heightmapCenterIndex = exports.heightmapCenterIndex = function heightmapCenterIndex(heightmap) {
-    return midpoint(0, heightmapLastIndex(heightmap));
-};
-var heightmapGet = exports.heightmapGet = function heightmapGet(heightmap, x, y) {
-    return heightmap.get(x, y);
-};
-var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(heightmap, x, y) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        return 0 <= x && x <= lastø1 && (0 <= y && y <= lastø1) ? (function () {
-            return heightmapGet(heightmap, x, y);
-        })() : void 0;
-    }.call(this);
-};
-var heightmapSet = exports.heightmapSet = function heightmapSet(heightmap, x, y, val) {
-    return heightmap.set(x, y, val);
-};
-var heightmapSetIfUnset = exports.heightmapSetIfUnset = function heightmapSetIfUnset(heightmap, x, y, val) {
-    return 0 == heightmapGet(heightmap, x, y) ? (function () {
-        return heightmapSet(heightmap, x, y, val);
-    })() : void 0;
-};
-var normalize = exports.normalize = function normalize(heightmap) {
-    return function () {
-        var maxø1 = 0 - Infinity;
-        var minø1 = Infinity;
-        (function () {
-            var array2ø1 = heightmap;
-            return function () {
-                var G__3ø1 = array2ø1.data.length;
-                return function loop() {
-                    var recur = loop;
-                    var index1ø1 = 0;
-                    do {
-                        recur = index1ø1 < G__3ø1 ? (function () {
-                            (function () {
-                                var elø1 = array2ø1.data[index1ø1];
-                                maxø1 < elø1 ? (function () {
-                                    return maxø1 = elø1;
-                                })() : void 0;
-                                return minø1 > elø1 ? (function () {
-                                    return minø1 = elø1;
-                                })() : void 0;
-                            }.call(this));
-                            return loop[0] = inc(index1ø1), loop;
-                        })() : void 0;
-                    } while (index1ø1 = loop[0], recur === loop);
-                    return recur;
-                }.call(this);
-            }.call(this);
-        }.call(this));
-        return function () {
-            var spanø1 = maxø1 - minø1;
-            return function () {
-                var array4ø1 = heightmap;
-                return function () {
-                    var G__5ø1 = array4ø1.shape[0];
-                    return function loop() {
-                        var recur = loop;
-                        var xø1 = 0;
-                        do {
-                            recur = xø1 < G__5ø1 ? (function () {
-                                (function () {
-                                    var G__6ø1 = array4ø1.shape[1];
-                                    return function loop() {
-                                        var recur = loop;
-                                        var yø1 = 0;
-                                        do {
-                                            recur = yø1 < G__6ø1 ? (function () {
-                                                (function () {
-                                                    return heightmapSet(heightmap, xø1, yø1, (heightmapGet(heightmap, xø1, yø1) - minø1) / spanø1);
-                                                })();
-                                                return loop[0] = inc(yø1), loop;
-                                            })() : void 0;
-                                        } while (yø1 = loop[0], recur === loop);
-                                        return recur;
-                                    }.call(this);
-                                }.call(this));
-                                return loop[0] = inc(xø1), loop;
-                            })() : void 0;
-                        } while (xø1 = loop[0], recur === loop);
-                        return recur;
-                    }.call(this);
-                }.call(this);
-            }.call(this);
-        }.call(this);
-    }.call(this);
-};
-var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
-    return function () {
-        var resolutionø1 = Math.pow(2, exponent) + 1;
-        return function () {
-            var heightmapø1 = ndarray(new Float64Array(resolutionø1 * resolutionø1), [
-                resolutionø1,
-                resolutionø1
-            ]);
-            heightmapø1.exponent = exponent;
-            heightmapø1.resolution = resolutionø1;
-            heightmapø1.last = dec(resolutionø1);
-            return heightmapø1;
-        }.call(this);
-    }.call(this);
-};
-var topLeftCorner = exports.topLeftCorner = function topLeftCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(0, 0).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var topRightCorner = exports.topRightCorner = function topRightCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(centerø1, 0).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var bottomLeftCorner = exports.bottomLeftCorner = function bottomLeftCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(0, centerø1).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var bottomRightCorner = exports.bottomRightCorner = function bottomRightCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(centerø1, centerø1).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var mpdInitCorners = exports.mpdInitCorners = function mpdInitCorners(heightmap) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        heightmapSet(heightmap, 0, 0, rand());
-        heightmapSet(heightmap, 0, lastø1, rand());
-        heightmapSet(heightmap, lastø1, 0, rand());
-        return heightmapSet(heightmap, lastø1, lastø1, rand());
-    }.call(this);
-};
-var mpdDisplace = exports.mpdDisplace = function mpdDisplace(heightmap, spread, spreadReduction) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        var cø1 = midpoint(0, lastø1);
-        var bottomLeftø1 = heightmapGet(heightmap, 0, 0);
-        var bottomRightø1 = heightmapGet(heightmap, lastø1, 0);
-        var topLeftø1 = heightmapGet(heightmap, 0, lastø1);
-        var topRightø1 = heightmapGet(heightmap, lastø1, lastø1);
-        var topø1 = average2(topLeftø1, topRightø1);
-        var leftø1 = average2(bottomLeftø1, topLeftø1);
-        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
-        var rightø1 = average2(bottomRightø1, topRightø1);
-        var centerø1 = average4(topø1, leftø1, bottomø1, rightø1);
-        var nextSpreadø1 = spread * spreadReduction;
-        heightmapSetIfUnset(heightmap, cø1, 0, jitter(bottomø1, spread));
-        heightmapSetIfUnset(heightmap, cø1, lastø1, jitter(topø1, spread));
-        heightmapSetIfUnset(heightmap, 0, cø1, jitter(leftø1, spread));
-        heightmapSetIfUnset(heightmap, lastø1, cø1, jitter(rightø1, spread));
-        heightmapSetIfUnset(heightmap, cø1, cø1, jitter(centerø1, spread));
-        return !(3 == heightmapResolution(heightmap)) ? (function () {
-            heightmapSetIfUnset(heightmap, cø1, 0, jitter(bottomø1, spread));
-            heightmapSetIfUnset(heightmap, cø1, lastø1, jitter(topø1, spread));
-            heightmapSetIfUnset(heightmap, 0, cø1, jitter(leftø1, spread));
-            heightmapSetIfUnset(heightmap, lastø1, cø1, jitter(rightø1, spread));
-            heightmapSetIfUnset(heightmap, cø1, cø1, jitter(centerø1, spread));
-            mpdDisplace(topLeftCorner(heightmap), nextSpreadø1, spreadReduction);
-            mpdDisplace(topRightCorner(heightmap), nextSpreadø1, spreadReduction);
-            mpdDisplace(bottomLeftCorner(heightmap), nextSpreadø1, spreadReduction);
-            return mpdDisplace(bottomRightCorner(heightmap), nextSpreadø1, spreadReduction);
-        })() : void 0;
-    }.call(this);
-};
-var midpointDisplacement = exports.midpointDisplacement = function midpointDisplacement(heightmap) {
-    return function () {
-        var initialSpreadø1 = 0.3;
-        var spreadReductionø1 = 0.55;
-        mpdInitCorners(heightmap);
-        mpdDisplace(heightmap, initialSpreadø1, spreadReductionø1);
-        return normalize(heightmap);
-    }.call(this);
-};
-var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
-    return function () {
-        var lightø1 = new THREE.DirectionalLight(16777215, 1);
-        lightø1.position.set(100, 0, 150);
-        return lightø1;
-    }.call(this);
-};
-var makeCamera = exports.makeCamera = function makeCamera() {
-    return function () {
-        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
-        cameraø1.position.set(0, -100, 150);
-        return cameraø1;
-    }.call(this);
-};
-var makeRenderer = exports.makeRenderer = function makeRenderer() {
-    return function () {
-        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
-        rendererø1.setClearColor(16777215);
-        rendererø1.setSize(width, height);
-        rendererø1.setPixelRatio(2);
-        return rendererø1;
-    }.call(this);
-};
-var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
-    return function () {
-        var resolutionø1 = heightmap.shape[0];
-        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, resolutionø1 - 1, resolutionø1 - 1);
-        return geometryø1;
-    }.call(this);
-};
-var makeControls = exports.makeControls = function makeControls(camera, renderer) {
-    return function () {
-        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
-        controlsø1.rotateSpeed = 1.4;
-        controlsø1.zoomSpeed = 0.5;
-        controlsø1.staticMoving = true;
-        controlsø1.dynamicDampingFactor = 0.3;
-        return controlsø1;
-    }.call(this);
-};
-var makePlane = exports.makePlane = function makePlane(geometry) {
-    return function () {
-        var materialø1 = new THREE.MeshLambertMaterial({
-            'wireframe': wireframe,
-            'wireframeLinewidth': wireframeWidth,
-            'color': 47872
-        });
-        return new THREE.Mesh(geometry, materialø1);
-    }.call(this);
-};
-var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
-    return function () {
-        var containerø1 = document.getElementById(elName);
-        var settingsø1 = document.createElement('div');
-        var refreshButtonø1 = document.createElement('button');
-        var buttonTextø1 = document.createTextNode('Refresh');
-        var cancelScrollø1 = function (e) {
-            return e.preventDefault();
-        };
-        refreshButtonø1.onclick = refreshFn;
-        renderer.domElement.onmousewheel = cancelScrollø1;
-        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
-        refreshButtonø1.appendChild(buttonTextø1);
-        containerø1.appendChild(renderer.domElement);
-        containerø1.appendChild(settingsø1);
-        return settingsø1.appendChild(refreshButtonø1);
-    }.call(this);
-};
-var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
-    (function loop() {
-        var recur = loop;
-        var iø1 = 0;
-        do {
-            recur = iø1 < geometry.vertices.length ? (function () {
-                geometry.vertices[iø1].z = terrainHeight * heightmap.data[iø1];
-                return loop[0] = iø1 + 1, loop;
-            })() : void 0;
-        } while (iø1 = loop[0], recur === loop);
-        return recur;
-    }.call(this));
-    geometry.computeVertexNormals();
-    return geometry;
-};
-var makeFinal = exports.makeFinal = function makeFinal(elementId) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var geometry = void 0;
-    var plane = void 0;
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    var refresh = function refresh() {
-        return function () {
-            var heightmapø1 = makeHeightmap(6);
-            console.log('Generating terrain...');
-            (function () {
-                var G__7ø1 = new Date().getTime();
-                var G__9ø1 = (function () {
-                    return midpointDisplacement(heightmapø1);
-                })();
-                var G__8ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__8ø1 - G__7ø1) + 'ms.');
-                return G__9ø1;
-            }.call(this));
-            console.log('Rebuilding geometry...');
-            (function () {
-                var G__10ø1 = new Date().getTime();
-                var G__12ø1 = (function () {
-                    geometry = makeGeometry(heightmapø1);
-                    return updateGeometry(geometry, heightmapø1);
-                })();
-                var G__11ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__11ø1 - G__10ø1) + 'ms.');
-                return G__12ø1;
-            }.call(this));
-            console.log('Rebuilding plane...');
-            return function () {
-                var G__13ø1 = new Date().getTime();
-                var G__15ø1 = (function () {
-                    scene.remove(plane);
-                    plane = makePlane(geometry);
-                    return scene.add(plane);
-                })();
-                var G__14ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__14ø1 - G__13ø1) + 'ms.');
-                return G__15ø1;
-            }.call(this);
-        }.call(this);
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    refresh();
-    render();
-    return void 0;
-};
-var run = exports.run = function run() {
-    return makeFinal('demo-final');
-};
-$(run);
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFub255bW91cy53aXNwIl0sIm5hbWVzIjpbIl9uc18iLCJpZCIsImRvYyIsIndpZHRoIiwiZXhwb3J0cyIsImhlaWdodCIsIndpcmVmcmFtZSIsIndpcmVmcmFtZVdpZHRoIiwidGVycmFpbkhlaWdodCIsInRlcnJhaW5TaXplIiwiaW5jIiwie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sZCBbdmFyc11cbiAgICAgICAgICAgICAgICAoaWYgKGVtcHR5PyB2YXJzKVxuICAgICAgICAgICAgICAgICAgYChkbyB+QGJvZHkpXG4gICAgICAgICAgICAgICAgICAobGV0IFt2YXJuYW1lIChmaXJzdCB2YXJzKV1cbiAgICAgICAgICAgICAgICAgICAgYChsb29wIFt+dmFybmFtZSB+c3RhcnRdXG4gICAgICAgICAgICAgICAgICAgICAgICh3aGVuICg8IH52YXJuYW1lIH5lbmQpXG4gICAgICAgICAgICAgICAgICAgICAgICAgfihidWlsZCAocmVzdCB2YXJzKSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAocmVjdXIgKCsgfnZhcm5hbWUgfnN0cmlkZSkpKSkpKSldXG4gICAgOyBGaXggdGhlIG51bWJlcnMgb25jZSBvdXRzaWRlIHRoZSBuZXN0ZWQgbG9vcHMsXG4gICAgOyBhbmQgdGhlbiBidWlsZCB0aGUgZ3V0cy5cbiAgICBgKGxldCBbfnN0YXJ0IH5zdGFydC1mb3JtXG4gICAgICAgICAgIH5lbmQgfmVuZC1mb3JtXG4gICAgICAgICAgIH5zdHJpZGUgfnN0cmlkZS1mb3JtXVxuICAgICAgIH4oYnVpbGQgdmFybmFtZXMpKSkpXG5cblxuKGRlZm1hY3JvIGRvLW5kYXJyYXkgW3ZhcnMgYXJyYXktZm9ybSAmIGJvZHldXG4gIChsZXQgW2FycmF5LXZhciAoZ2Vuc3ltIFwiYXJyYXlcIilcbiAgICAgICAgYnVpbGQgKGZuIGJ1aWxkIFt2YXJzIG5dXG4gICAgICAgICAgICAgICAgKGlmIChlbXB0eT8gdmFycylcbiAgICAgICAgICAgICAgICAgIGAoZG8gfkBib2R5KVxuICAgICAgICAgICAgICAgICAgYChkby10aW1lcyB+KGZpcnN0IHZhcnMpIChhZ2V0ICguLXNoYXBlIH5hcnJheS12YXIpIH5uKVxuICAgICAgICAgICAgICAgICAgICAgfihidWlsZCAocmVzdCB2YXJzKSAoaW5jIG4pKSkpKV1cbiAg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lsZGluZyBwbGFuZS4uLlwiKVxuICAgICAgKHRpbWVcbiAgICAgICAgKHNjZW5lLnJlbW92ZSBwbGFuZSlcbiAgICAgICAgKHNldCEgcGxhbmUgKG1ha2UtcGxhbmUgZ2VvbWV0cnkpKVxuICAgICAgICAoc2NlbmUuYWRkIHBsYW5lKSkpKVxuXG4gIChhdHRhY2gtdG8tZG9tIHJlbmRlcmVyIGVsZW1lbnQtaWQgcmVmcmVzaClcbiAgKGRlZiBjb250cm9scyAobWFrZS1jb250cm9scyBjYW1lcmEgcmVuZGVyZXIpKVxuXG4gIChkZWZuIHJlbmRlciBbXVxuICAgIChsZXQgW2RlbHRhIChjbG9jay5nZXREZWx0YSldXG4gICAgICAocmVxdWVzdEFuaW1hdGlvbkZyYW1lIHJlbmRlcilcbiAgICAgICgudXBkYXRlIGNvbnRyb2xzIGRlbHRhKVxuICAgICAgKHJlbmRlcmVyLnJlbmRlciBzY2VuZSBjYW1lcmEpKSlcblxuICAocmVmcmVzaClcbiAgKHJlbmRlcilcblxuICBuaWwpXG5cbihkZWZuIHJ1biBbXVxuICAobWFrZS1maW5hbCBcImRlbW8tZmluYWxcIikpXG5cbigkIHJ1bilcblxuXG47IHZpbTogbHcrPWRvLXRpbWVzIGx3Kz1kby1uZXN0ZWQgOlxuIl19
--- a/media/js/wisp/terrain2.wisp	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,376 +0,0 @@
-(ns demo
-  (:require [ndarray]))
-
-; Constants -------------------------------------------------------------------
-(def width 610)
-(def height 400)
-(def wireframe true)
-(def wireframe-width 1.2)
-(def terrain-height 50)
-(def terrain-size 100)
-
-; General Utilities -----------------------------------------------------------
-(defmacro when [condition & body]
-  `(if ~condition
-     (do ~@body)))
-
-(defmacro when-not [condition & body]
-  `(when (not ~condition)
-     ~@body))
-
-(defmacro -> [& operations]
-  (reduce
-    (fn [form operation]
-      (cons (first operation)
-            (cons form (rest operation))))
-    (first operations)
-    (rest operations)))
-
-
-(defn inc [x]
-  (+ x 1))
-
-(defn dec [x]
-  (- x 1))
-
-
-(defmacro do-times [varname limit & body]
-  (let [end (gensym)]
-    `(let [~end ~limit]
-       (loop [~varname 0]
-         (when (< ~varname ~end)
-           ~@body
-           (recur (inc ~varname)))))))
-
-(defmacro do-stride [varnames start-form end-form stride-form & body]
-  (let [stride (gensym "stride")
-        start (gensym "start")
-        end (gensym "end")
-        build (fn build [vars]
-                (if (empty? vars)
-                  `(do ~@body)
-                  (let [varname (first vars)]
-                    `(loop [~varname ~start]
-                       (when (< ~varname ~end)
-                         ~(build (rest vars))
-                         (recur (+ ~varname ~stride)))))))]
-    ; Fix the numbers once outside the nested loops,
-    ; and then build the guts.
-    `(let [~start ~start-form
-           ~end ~end-form
-           ~stride ~stride-form]
-       ~(build varnames))))
-
-
-(defmacro do-ndarray [vars array-form & body]
-  (let [array-var (gensym "array")
-        build (fn build [vars n]
-                (if (empty? vars)
-                  `(do ~@body)
-                  `(do-times ~(first vars) (aget (.-shape ~array-var) ~n)
-                     ~(build (rest vars) (inc n)))))]
-    `(let [~array-var ~array-form]
-       ~(build vars 0))))
-
-(defmacro do-ndarray-el [element array-form & body]
-  (let [index (gensym "index")
-        array (gensym "array")]
-    `(let [~array ~array-form]
-       (do-times ~index (.-length (.-data ~array))
-         (let [~element (aget (.-data ~array) ~index)]
-           ~@body)))))
-
-
-(defmacro inc! [place]
-  `(set! ~place (inc ~place)))
-
-(defmacro add! [place amount]
-  `(set! ~place (+ ~place ~amount)))
-
-
-(defmacro l [& forms]
-  `(console.log ~@forms))
-
-(defmacro time [& body]
-  (let [start (gensym)
-        end (gensym)
-        result (gensym)]
-    `(let [~start (.getTime (new Date))
-           ~result (do ~@body)
-           ~end (.getTime (new Date))]
-       (l (+ "Elapsed time: " (- ~end ~start) "ms."))
-       ~result)))
-
-
-(defn midpoint [a b]
-  (/ (+ a b) 2))
-
-(defn average2 [a b]
-  (/ (+ a b) 2))
-
-(defn average4 [a b c d]
-  (/ (+ a b c d) 4))
-
-(defn safe-average [a b c d]
-  (let [total 0 count 0]
-    (when a (add! total a) (inc! count))
-    (when b (add! total b) (inc! count))
-    (when c (add! total c) (inc! count))
-    (when d (add! total d) (inc! count))
-    (/ total count)))
-
-
-; Randomness ------------------------------------------------------------------
-(defn rand []
-  (Math.random))
-
-(defn rand-around-zero [spread]
-  (- (* spread (rand) 2) spread))
-
-(defn jitter [value spread]
-  (+ value (rand-around-zero spread)))
-
-
-; Heightmap Helpers -----------------------------------------------------------
-(defn heightmap-resolution [heightmap]
-  (aget heightmap.shape 0))
-
-(defn heightmap-last-index [heightmap]
-  (dec (heightmap-resolution heightmap)))
-
-(defn heightmap-center-index [heightmap]
-  (midpoint 0 (heightmap-last-index heightmap)))
-
-
-(defn heightmap-get [heightmap x y]
-  (.get heightmap x y))
-
-(defn heightmap-get-safe [heightmap x y]
-  (let [last (heightmap-last-index heightmap)]
-    (when (and (<= 0 x last)
-               (<= 0 y last))
-      (heightmap-get heightmap x y))))
-
-(defn heightmap-set! [heightmap x y val]
-  (.set heightmap x y val))
-
-(defn heightmap-set-if-unset! [heightmap x y val]
-  (when (== 0 (heightmap-get heightmap x y))
-    (heightmap-set! heightmap x y val)))
-
-
-(defn normalize [heightmap]
-  (let [max (- Infinity)
-        min Infinity]
-    (do-ndarray-el el heightmap
-      (when (< max el) (set! max el))
-      (when (> min el) (set! min el)))
-    (let [span (- max min)]
-      (do-ndarray [x y] heightmap
-        (heightmap-set! heightmap x y
-                        (/ (- (heightmap-get heightmap x y) min)
-                           span))))))
-
-
-(defn make-heightmap [exponent]
-  (let [resolution (+ (Math.pow 2 exponent) 1)]
-    (let [heightmap (ndarray (new Float64Array (* resolution resolution))
-                             [resolution resolution])]
-      (set! heightmap.exponent exponent)
-      (set! heightmap.resolution resolution)
-      (set! heightmap.last (dec resolution))
-      heightmap)))
-
-
-(defn top-left-corner [heightmap]
-  (let [center (heightmap-center-index heightmap)]
-    (-> heightmap
-      (.lo 0 0)
-      (.hi (inc center) (inc center)))))
-
-(defn top-right-corner [heightmap]
-  (let [center (heightmap-center-index heightmap)]
-    (-> heightmap
-      (.lo center 0)
-      (.hi (inc center) (inc center)))))
-
-(defn bottom-left-corner [heightmap]
-  (let [center (heightmap-center-index heightmap)]
-    (-> heightmap
-      (.lo 0 center)
-      (.hi (inc center) (inc center)))))
-
-(defn bottom-right-corner [heightmap]
-  (let [center (heightmap-center-index heightmap)]
-    (-> heightmap
-      (.lo center center)
-      (.hi (inc center) (inc center)))))
-
-
-; Midpoint Displacement -------------------------------------------------------
-(defn mpd-init-corners [heightmap]
-  (let [last (heightmap-last-index heightmap)]
-    (heightmap-set! heightmap 0    0    (rand))
-    (heightmap-set! heightmap 0    last (rand))
-    (heightmap-set! heightmap last 0    (rand))
-    (heightmap-set! heightmap last last (rand))))
-
-(defn mpd-displace [heightmap spread spread-reduction]
-  (let [last (heightmap-last-index heightmap)
-        c (midpoint 0 last)
-
-        bottom-left  (heightmap-get heightmap 0    0)
-        bottom-right (heightmap-get heightmap last 0)
-        top-left     (heightmap-get heightmap 0    last)
-        top-right    (heightmap-get heightmap last last)
-
-        top    (average2 top-left top-right)
-        left   (average2 bottom-left top-left)
-        bottom (average2 bottom-left bottom-right)
-        right  (average2 bottom-right top-right)
-        center (average4 top left bottom right)
-
-        next-spread (* spread spread-reduction)]
-    (heightmap-set-if-unset! heightmap c    0    (jitter bottom spread))
-    (heightmap-set-if-unset! heightmap c    last (jitter top spread))
-    (heightmap-set-if-unset! heightmap 0    c    (jitter left spread))
-    (heightmap-set-if-unset! heightmap last c    (jitter right spread))
-    (heightmap-set-if-unset! heightmap c    c    (jitter center spread))
-    (when-not (== 3 (heightmap-resolution heightmap))
-      (mpd-displace (top-left-corner heightmap) next-spread spread-reduction)
-      (mpd-displace (top-right-corner heightmap) next-spread spread-reduction)
-      (mpd-displace (bottom-left-corner heightmap) next-spread spread-reduction)
-      (mpd-displace (bottom-right-corner heightmap) next-spread spread-reduction))))
-
-(defn midpoint-displacement [heightmap]
-  (let [initial-spread 0.3 
-        spread-reduction 0.55]
-    (mpd-init-corners heightmap)
-    (mpd-displace heightmap initial-spread spread-reduction)
-    (normalize heightmap)))
-
-
-; Three.js Helpers ------------------------------------------------------------
-(defn make-directional-light []
-  (let [light (new THREE.DirectionalLight 0xffffff 1)]
-    (light.position.set 100 0 150)
-    light))
-
-(defn make-camera []
-  (let [camera (new THREE.PerspectiveCamera
-                    55,
-                    (/ width height)
-                    0.1,
-                    1000)]
-    (camera.position.set 0 -100 150)
-    camera))
-
-(defn make-renderer []
-  (let [renderer (new THREE.WebGLRenderer {:antialias false})]
-    (renderer.setClearColor 0xffffff)
-    (renderer.setSize width height)
-    (renderer.setPixelRatio 2)
-    renderer))
-
-(defn make-geometry [heightmap]
-  (let [resolution (aget heightmap.shape 0)
-        geometry (new THREE.PlaneGeometry
-                      terrain-size
-                      terrain-size
-                      (- resolution 1)
-                      (- resolution 1))]
-    geometry))
-
-(defn make-controls [camera renderer]
-  (let [controls (new THREE.TrackballControls camera renderer.domElement)]
-    (set! controls.rotateSpeed 1.4)
-    (set! controls.zoomSpeed 0.5)
-    (set! controls.staticMoving true)
-    (set! controls.dynamicDampingFactor 0.3)
-    controls))
-
-(defn make-plane [geometry]
-  (let [material (new THREE.MeshLambertMaterial
-                      {:wireframe wireframe
-                       :wireframeLinewidth wireframe-width
-                       :color 0x00bb00})]
-    (new THREE.Mesh geometry material)))
-
-
-(defn attach-to-dom [renderer el-name refresh-fn]
-  (let [container (document.getElementById el-name)
-        settings (document.createElement "div")
-        refresh-button (document.createElement "button")
-        button-text (document.createTextNode "Refresh")
-        cancel-scroll (fn [e] (.preventDefault e))]
-    (set! refresh-button.onclick refresh-fn)
-    (set! renderer.domElement.onmousewheel cancel-scroll)
-    (renderer.domElement.addEventListener "MozMousePixelScroll" cancel-scroll false)
-    (.appendChild refresh-button button-text)
-    (.appendChild container renderer.domElement)
-    (.appendChild container settings)
-    (.appendChild settings refresh-button)))
-
-
-(defn update-geometry [geometry heightmap]
-  (loop [i 0]
-    (if (< i geometry.vertices.length)
-      (do (set! (.-z (aget geometry.vertices i))
-                (* terrain-height (aget (.-data heightmap) i)))
-        (recur (+ i 1)))))
-  (geometry.computeVertexNormals)
-  geometry)
-
-
-; Main ------------------------------------------------------------------------
-(defn make-final [element-id]
-  (def scene (new THREE.Scene))
-  (scene.add (new THREE.AxisHelper 100))
-
-  (def clock (new THREE.Clock))
-  (def camera (make-camera))
-  (def renderer (make-renderer))
-
-  (def geometry)
-  (def plane)
-
-  (scene.add (make-directional-light))
-  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
-
-  (defn refresh []
-    (let [heightmap (make-heightmap 6)]
-      (l "Generating terrain...")
-      (time (midpoint-displacement heightmap))
-
-      (l "Rebuilding geometry...")
-      (time
-        (set! geometry (make-geometry heightmap))
-        (update-geometry geometry heightmap))
-
-      (l "Rebuilding plane...")
-      (time
-        (scene.remove plane)
-        (set! plane (make-plane geometry))
-        (scene.add plane))))
-
-  (attach-to-dom renderer element-id refresh)
-  (def controls (make-controls camera renderer))
-
-  (defn render []
-    (let [delta (clock.getDelta)]
-      (requestAnimationFrame render)
-      (.update controls delta)
-      (renderer.render scene camera)))
-
-  (refresh)
-  (render)
-
-  nil)
-
-(defn run []
-  (make-final "demo-final"))
-
-($ run)
-
-
-; vim: lw+=do-times lw+=do-nested :
--- a/media/js/wisp/terrain3.js	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,571 +0,0 @@
-{
-    var _ns_ = {
-        id: 'demo',
-        doc: void 0
-    };
-    var ndarray = require('ndarray');
-}
-var width = exports.width = 610;
-var height = exports.height = 400;
-var wireframe = exports.wireframe = true;
-var wireframeWidth = exports.wireframeWidth = 1.2;
-var terrainHeight = exports.terrainHeight = 50;
-var terrainSize = exports.terrainSize = 100;
-void 0;
-void 0;
-void 0;
-var inc = exports.inc = function inc(x) {
-    return x + 1;
-};
-var dec = exports.dec = function dec(x) {
-    return x - 1;
-};
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-void 0;
-var midpoint = exports.midpoint = function midpoint(a, b) {
-    return (a + b) / 2;
-};
-var average2 = exports.average2 = function average2(a, b) {
-    return (a + b) / 2;
-};
-var average4 = exports.average4 = function average4(a, b, c, d) {
-    return (a + b + c + d) / 4;
-};
-var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
-    return function () {
-        var totalø1 = 0;
-        var countø1 = 0;
-        a ? (function () {
-            totalø1 = totalø1 + a;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        b ? (function () {
-            totalø1 = totalø1 + b;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        c ? (function () {
-            totalø1 = totalø1 + c;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        d ? (function () {
-            totalø1 = totalø1 + d;
-            return countø1 = inc(countø1);
-        })() : void 0;
-        return totalø1 / countø1;
-    }.call(this);
-};
-var isEven = exports.isEven = function isEven(n) {
-    return 0 == n % 2;
-};
-var isOdd = exports.isOdd = function isOdd(n) {
-    return 1 == n % 2;
-};
-var rand = exports.rand = function rand() {
-    return Math.random();
-};
-var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
-    return spread * rand() * 2 - spread;
-};
-var jitter = exports.jitter = function jitter(value, spread) {
-    return value + randAroundZero(spread);
-};
-var heightmapResolution = exports.heightmapResolution = function heightmapResolution(heightmap) {
-    return heightmap.shape[0];
-};
-var heightmapLastIndex = exports.heightmapLastIndex = function heightmapLastIndex(heightmap) {
-    return dec(heightmapResolution(heightmap));
-};
-var heightmapCenterIndex = exports.heightmapCenterIndex = function heightmapCenterIndex(heightmap) {
-    return midpoint(0, heightmapLastIndex(heightmap));
-};
-var heightmapGet = exports.heightmapGet = function heightmapGet(heightmap, x, y) {
-    return heightmap.get(x, y);
-};
-var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(heightmap, x, y) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        return 0 <= x && x <= lastø1 && (0 <= y && y <= lastø1) ? (function () {
-            return heightmapGet(heightmap, x, y);
-        })() : void 0;
-    }.call(this);
-};
-var heightmapSet = exports.heightmapSet = function heightmapSet(heightmap, x, y, val) {
-    return heightmap.set(x, y, val);
-};
-var heightmapSetIfUnset = exports.heightmapSetIfUnset = function heightmapSetIfUnset(heightmap, x, y, val) {
-    return 0 == heightmapGet(heightmap, x, y) ? (function () {
-        return heightmapSet(heightmap, x, y, val);
-    })() : void 0;
-};
-var normalize = exports.normalize = function normalize(heightmap) {
-    return function () {
-        var maxø1 = 0 - Infinity;
-        var minø1 = Infinity;
-        (function () {
-            var array2ø1 = heightmap;
-            return function () {
-                var G__3ø1 = array2ø1.data.length;
-                return function loop() {
-                    var recur = loop;
-                    var index1ø1 = 0;
-                    do {
-                        recur = index1ø1 < G__3ø1 ? (function () {
-                            (function () {
-                                var elø1 = array2ø1.data[index1ø1];
-                                maxø1 < elø1 ? (function () {
-                                    return maxø1 = elø1;
-                                })() : void 0;
-                                return minø1 > elø1 ? (function () {
-                                    return minø1 = elø1;
-                                })() : void 0;
-                            }.call(this));
-                            return loop[0] = inc(index1ø1), loop;
-                        })() : void 0;
-                    } while (index1ø1 = loop[0], recur === loop);
-                    return recur;
-                }.call(this);
-            }.call(this);
-        }.call(this));
-        return function () {
-            var spanø1 = maxø1 - minø1;
-            return function () {
-                var array4ø1 = heightmap;
-                return function () {
-                    var G__5ø1 = array4ø1.shape[0];
-                    return function loop() {
-                        var recur = loop;
-                        var xø1 = 0;
-                        do {
-                            recur = xø1 < G__5ø1 ? (function () {
-                                (function () {
-                                    var G__6ø1 = array4ø1.shape[1];
-                                    return function loop() {
-                                        var recur = loop;
-                                        var yø1 = 0;
-                                        do {
-                                            recur = yø1 < G__6ø1 ? (function () {
-                                                (function () {
-                                                    return heightmapSet(heightmap, xø1, yø1, (heightmapGet(heightmap, xø1, yø1) - minø1) / spanø1);
-                                                })();
-                                                return loop[0] = inc(yø1), loop;
-                                            })() : void 0;
-                                        } while (yø1 = loop[0], recur === loop);
-                                        return recur;
-                                    }.call(this);
-                                }.call(this));
-                                return loop[0] = inc(xø1), loop;
-                            })() : void 0;
-                        } while (xø1 = loop[0], recur === loop);
-                        return recur;
-                    }.call(this);
-                }.call(this);
-            }.call(this);
-        }.call(this);
-    }.call(this);
-};
-var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
-    return function () {
-        var resolutionø1 = Math.pow(2, exponent) + 1;
-        return function () {
-            var heightmapø1 = ndarray(new Float64Array(resolutionø1 * resolutionø1), [
-                resolutionø1,
-                resolutionø1
-            ]);
-            heightmapø1.exponent = exponent;
-            heightmapø1.resolution = resolutionø1;
-            heightmapø1.last = dec(resolutionø1);
-            return heightmapø1;
-        }.call(this);
-    }.call(this);
-};
-var topLeftCorner = exports.topLeftCorner = function topLeftCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(0, 0).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var topRightCorner = exports.topRightCorner = function topRightCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(centerø1, 0).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var bottomLeftCorner = exports.bottomLeftCorner = function bottomLeftCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(0, centerø1).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var bottomRightCorner = exports.bottomRightCorner = function bottomRightCorner(heightmap) {
-    return function () {
-        var centerø1 = heightmapCenterIndex(heightmap);
-        return heightmap.lo(centerø1, centerø1).hi(inc(centerø1), inc(centerø1));
-    }.call(this);
-};
-var dsInitCorners = exports.dsInitCorners = function dsInitCorners(heightmap) {
-    return function () {
-        var lastø1 = heightmapLastIndex(heightmap);
-        heightmapSet(heightmap, 0, 0, rand());
-        heightmapSet(heightmap, 0, lastø1, rand());
-        heightmapSet(heightmap, lastø1, 0, rand());
-        return heightmapSet(heightmap, lastø1, lastø1, rand());
-    }.call(this);
-};
-var dsSquare = exports.dsSquare = function dsSquare(heightmap, x, y, radius, spread) {
-    return function () {
-        var newHeightø1 = jitter(average4(heightmapGet(heightmap, x - radius, y - radius), heightmapGet(heightmap, x - radius, y + radius), heightmapGet(heightmap, x + radius, y - radius), heightmapGet(heightmap, x + radius, y + radius)), spread);
-        return heightmapSet(heightmap, x, y, newHeightø1);
-    }.call(this);
-};
-var dsDiamond = exports.dsDiamond = function dsDiamond(heightmap, x, y, radius, spread) {
-    return function () {
-        var newHeightø1 = jitter(safeAverage(heightmapGetSafe(heightmap, x - radius, y), heightmapGetSafe(heightmap, x + radius, y), heightmapGetSafe(heightmap, x, y - radius), heightmapGetSafe(heightmap, x, y + radius)), spread);
-        return heightmapSet(heightmap, x, y, newHeightø1);
-    }.call(this);
-};
-var dsSquares = exports.dsSquares = function dsSquares(heightmap, radius, spread) {
-    return function () {
-        var start8ø1 = radius;
-        var end9ø1 = heightmapResolution(heightmap);
-        var stride7ø1 = 2 * radius;
-        return function loop() {
-            var recur = loop;
-            var xø1 = start8ø1;
-            do {
-                recur = xø1 < end9ø1 ? (function () {
-                    (function loop() {
-                        var recur = loop;
-                        var yø1 = start8ø1;
-                        do {
-                            recur = yø1 < end9ø1 ? (function () {
-                                (function () {
-                                    return dsSquare(heightmap, xø1, yø1, radius, spread);
-                                })();
-                                return loop[0] = yø1 + stride7ø1, loop;
-                            })() : void 0;
-                        } while (yø1 = loop[0], recur === loop);
-                        return recur;
-                    }.call(this));
-                    return loop[0] = xø1 + stride7ø1, loop;
-                })() : void 0;
-            } while (xø1 = loop[0], recur === loop);
-            return recur;
-        }.call(this);
-    }.call(this);
-};
-var dsDiamonds = exports.dsDiamonds = function dsDiamonds(heightmap, radius, spread) {
-    return function () {
-        var sizeø1 = heightmapResolution(heightmap);
-        return function () {
-            var start11ø1 = 0;
-            var end12ø1 = sizeø1;
-            var stride10ø1 = radius;
-            return function loop() {
-                var recur = loop;
-                var yø1 = start11ø1;
-                do {
-                    recur = yø1 < end12ø1 ? (function () {
-                        (function () {
-                            return function () {
-                                var shiftø1 = isEven(yø1 / radius) ? radius : 0;
-                                return function () {
-                                    var start14ø1 = shiftø1;
-                                    var end15ø1 = sizeø1;
-                                    var stride13ø1 = 2 * radius;
-                                    return function loop() {
-                                        var recur = loop;
-                                        var xø1 = start14ø1;
-                                        do {
-                                            recur = xø1 < end15ø1 ? (function () {
-                                                (function () {
-                                                    return dsDiamond(heightmap, xø1, yø1, radius, spread);
-                                                })();
-                                                return loop[0] = xø1 + stride13ø1, loop;
-                                            })() : void 0;
-                                        } while (xø1 = loop[0], recur === loop);
-                                        return recur;
-                                    }.call(this);
-                                }.call(this);
-                            }.call(this);
-                        })();
-                        return loop[0] = yø1 + stride10ø1, loop;
-                    })() : void 0;
-                } while (yø1 = loop[0], recur === loop);
-                return recur;
-            }.call(this);
-        }.call(this);
-    }.call(this);
-};
-var diamondSquare = exports.diamondSquare = function diamondSquare(heightmap) {
-    return function () {
-        var initialSpreadø1 = 0.3;
-        var spreadReductionø1 = 0.5;
-        var centerø1 = heightmapCenterIndex(heightmap);
-        var sizeø1 = heightmap.shape[0];
-        dsInitCorners(heightmap);
-        (function loop() {
-            var recur = loop;
-            var radiusø1 = centerø1;
-            var spreadø1 = initialSpreadø1;
-            do {
-                recur = radiusø1 >= 1 ? (function () {
-                    dsSquares(heightmap, radiusø1, spreadø1);
-                    dsDiamonds(heightmap, radiusø1, spreadø1);
-                    return loop[0] = radiusø1 / 2, loop[1] = spreadø1 * spreadReductionø1, loop;
-                })() : void 0;
-            } while (radiusø1 = loop[0], spreadø1 = loop[1], recur === loop);
-            return recur;
-        }.call(this));
-        return normalize(heightmap);
-    }.call(this);
-};
-var diamondSquare1 = exports.diamondSquare1 = function diamondSquare1(heightmap) {
-    dsInitCorners(heightmap);
-    return normalize(heightmap);
-};
-var diamondSquare2 = exports.diamondSquare2 = function diamondSquare2(heightmap) {
-    return function () {
-        var initialSpreadø1 = 0.3;
-        var spreadReductionø1 = 0.5;
-        var centerø1 = heightmapCenterIndex(heightmap);
-        var sizeø1 = heightmap.shape[0];
-        dsInitCorners(heightmap);
-        dsSquares(heightmap, centerø1, initialSpreadø1);
-        return normalize(heightmap);
-    }.call(this);
-};
-var diamondSquare3 = exports.diamondSquare3 = function diamondSquare3(heightmap) {
-    return function () {
-        var initialSpreadø1 = 0.3;
-        var spreadReductionø1 = 0.5;
-        var centerø1 = heightmapCenterIndex(heightmap);
-        var sizeø1 = heightmap.shape[0];
-        dsInitCorners(heightmap);
-        dsSquares(heightmap, centerø1, initialSpreadø1);
-        dsDiamonds(heightmap, centerø1, initialSpreadø1);
-        dsSquares(heightmap, centerø1 / 2, spreadReductionø1 * initialSpreadø1);
-        dsDiamonds(heightmap, centerø1 / 2, spreadReductionø1 * initialSpreadø1);
-        return normalize(heightmap);
-    }.call(this);
-};
-var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
-    return function () {
-        var lightø1 = new THREE.DirectionalLight(16777215, 1);
-        lightø1.position.set(100, 0, 150);
-        return lightø1;
-    }.call(this);
-};
-var makeCamera = exports.makeCamera = function makeCamera() {
-    return function () {
-        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
-        cameraø1.position.set(0, -100, 150);
-        return cameraø1;
-    }.call(this);
-};
-var makeRenderer = exports.makeRenderer = function makeRenderer() {
-    return function () {
-        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
-        rendererø1.setClearColor(16777215);
-        rendererø1.setSize(width, height);
-        rendererø1.setPixelRatio(2);
-        return rendererø1;
-    }.call(this);
-};
-var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
-    return function () {
-        var resolutionø1 = heightmap.shape[0];
-        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, resolutionø1 - 1, resolutionø1 - 1);
-        return geometryø1;
-    }.call(this);
-};
-var makeControls = exports.makeControls = function makeControls(camera, renderer) {
-    return function () {
-        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
-        controlsø1.rotateSpeed = 1.4;
-        controlsø1.zoomSpeed = 0.5;
-        controlsø1.staticMoving = true;
-        controlsø1.dynamicDampingFactor = 0.3;
-        return controlsø1;
-    }.call(this);
-};
-var makePlane = exports.makePlane = function makePlane(geometry) {
-    return function () {
-        var materialø1 = new THREE.MeshLambertMaterial({
-            'wireframe': wireframe,
-            'wireframeLinewidth': wireframeWidth,
-            'color': 47872
-        });
-        return new THREE.Mesh(geometry, materialø1);
-    }.call(this);
-};
-var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
-    return function () {
-        var containerø1 = document.getElementById(elName);
-        var settingsø1 = document.createElement('div');
-        var refreshButtonø1 = document.createElement('button');
-        var buttonTextø1 = document.createTextNode('Refresh');
-        var cancelScrollø1 = function (e) {
-            return e.preventDefault();
-        };
-        refreshButtonø1.onclick = refreshFn;
-        renderer.domElement.onmousewheel = cancelScrollø1;
-        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
-        refreshButtonø1.appendChild(buttonTextø1);
-        containerø1.appendChild(renderer.domElement);
-        containerø1.appendChild(settingsø1);
-        return settingsø1.appendChild(refreshButtonø1);
-    }.call(this);
-};
-var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
-    (function loop() {
-        var recur = loop;
-        var iø1 = 0;
-        do {
-            recur = iø1 < geometry.vertices.length ? (function () {
-                geometry.vertices[iø1].z = terrainHeight * heightmap.data[iø1];
-                return loop[0] = iø1 + 1, loop;
-            })() : void 0;
-        } while (iø1 = loop[0], recur === loop);
-        return recur;
-    }.call(this));
-    geometry.computeVertexNormals();
-    return geometry;
-};
-var makeDemo = exports.makeDemo = function makeDemo(elementId, algorithm, size) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var geometry = void 0;
-    var plane = void 0;
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    var refresh = function refresh() {
-        return function () {
-            var heightmapø1 = makeHeightmap(size);
-            console.log('Generating terrain...');
-            (function () {
-                var G__16ø1 = new Date().getTime();
-                var G__18ø1 = (function () {
-                    return algorithm(heightmapø1);
-                })();
-                var G__17ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__17ø1 - G__16ø1) + 'ms.');
-                return G__18ø1;
-            }.call(this));
-            console.log('Rebuilding geometry...');
-            (function () {
-                var G__19ø1 = new Date().getTime();
-                var G__21ø1 = (function () {
-                    geometry = makeGeometry(heightmapø1);
-                    return updateGeometry(geometry, heightmapø1);
-                })();
-                var G__20ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__20ø1 - G__19ø1) + 'ms.');
-                return G__21ø1;
-            }.call(this));
-            console.log('Rebuilding plane...');
-            return function () {
-                var G__22ø1 = new Date().getTime();
-                var G__24ø1 = (function () {
-                    scene.remove(plane);
-                    plane = makePlane(geometry);
-                    return scene.add(plane);
-                })();
-                var G__23ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__23ø1 - G__22ø1) + 'ms.');
-                return G__24ø1;
-            }.call(this);
-        }.call(this);
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    refresh();
-    render();
-    return void 0;
-};
-var makeFinal = exports.makeFinal = function makeFinal(elementId) {
-    var scene = new THREE.Scene();
-    scene.add(new THREE.AxisHelper(100));
-    var clock = new THREE.Clock();
-    var camera = makeCamera();
-    var renderer = makeRenderer();
-    var geometry = void 0;
-    var plane = void 0;
-    scene.add(makeDirectionalLight());
-    scene.add(new THREE.AmbientLight(16777215, 0.05));
-    var refresh = function refresh() {
-        return function () {
-            var heightmapø1 = makeHeightmap(6);
-            console.log('Generating terrain...');
-            (function () {
-                var G__25ø1 = new Date().getTime();
-                var G__27ø1 = (function () {
-                    return diamondSquare(heightmapø1);
-                })();
-                var G__26ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__26ø1 - G__25ø1) + 'ms.');
-                return G__27ø1;
-            }.call(this));
-            console.log('Rebuilding geometry...');
-            (function () {
-                var G__28ø1 = new Date().getTime();
-                var G__30ø1 = (function () {
-                    geometry = makeGeometry(heightmapø1);
-                    return updateGeometry(geometry, heightmapø1);
-                })();
-                var G__29ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__29ø1 - G__28ø1) + 'ms.');
-                return G__30ø1;
-            }.call(this));
-            console.log('Rebuilding plane...');
-            return function () {
-                var G__31ø1 = new Date().getTime();
-                var G__33ø1 = (function () {
-                    scene.remove(plane);
-                    plane = makePlane(geometry);
-                    return scene.add(plane);
-                })();
-                var G__32ø1 = new Date().getTime();
-                console.log('Elapsed time: ' + (G__32ø1 - G__31ø1) + 'ms.');
-                return G__33ø1;
-            }.call(this);
-        }.call(this);
-    };
-    attachToDom(renderer, elementId, refresh);
-    var controls = makeControls(camera, renderer);
-    var render = function render() {
-        return function () {
-            var deltaø1 = clock.getDelta();
-            requestAnimationFrame(render);
-            controls.update(deltaø1);
-            return renderer.render(scene, camera);
-        }.call(this);
-    };
-    refresh();
-    render();
-    return void 0;
-};
-var run = exports.run = function run() {
-    makeDemo('demo-1', diamondSquare1, 2);
-    makeDemo('demo-2', diamondSquare2, 4);
-    makeDemo('demo-3', diamondSquare3, 4);
-    return makeFinal('demo-final');
-};
-$(run);
-//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFub255bW91cy53aXNwIl0sIm5hbWVzIjpbIl9uc18iLCJpZCIsImRvYyIsIndpZHRoIiwiZXhwb3J0cyIsImhlaWdodCIsIndpcmVmcmFtZSIsIndpcmVmcmFtZVdp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CAxKSlcblxuXG4oZGVmbWFjcm8gZG8tdGltZXMgW3Zhcm5hbWUgbGltaXQgJiBib2R5XVxuICAobGV0IFtlbmQgKGdlbnN5bSldXG4gICAgYChsZXQgW35lbmQgfmxpbWl0XVxuICAgICAgIChsb29wIFt+dmFybmFtZSAwXVxuICAgICAgICAgKHdoZW4gKDwgfnZhcm5hbWUgfmVuZClcbiAgICAgICAgICAgfkBib2R5XG4gICAgICAgICAgIChyZWN1ciAoaW5jIH52YXJuYW1lKSkpKSkpKVxuXG4oZGVmbWFjcm8gZG8tc3RyaWRlIFt2YXJuYW1lcyBzdGFydC1mb3JtIGVuZC1mb3JtIHN0cmlkZS1mb3JtICYgYm9keV1cbiAgKGxldCBbc3RyaWRlIChnZW5zeW0gXCJzdHJpZGVcIilcbiAgICAgICAgc3RhcnQgKGdlbnN5bSBcInN0YXJ0XCIpXG4gICAgICAgIGVuZCAoZ2Vuc3ltIFwiZW5kXCIpXG4gICAgICAgIGJ1aWxkIChmbiBidWlsZCBbdmFyc11cbiAgICAgICAgICAgICAgICAoaWYgKGVtcHR5PyB2YXJzKVxuICAgICAgICAgICAgICAgICAgYChkbyB+QGJvZHkpXG4gICAgICAgICAgICAgICAgICAobGV0IFt2YXJuYW1lIChmaXJzdCB2YXJzKV1cbiAgICAgICAgICAgICAgICAgICAgYChsb29wIFt+dmFybmFtZSB+c3RhcnRdXG4gICAgICAgICAgICAgICAgICAgICAgICh3aGVuICg8IH52YXJuYW1lIH5lbmQpXG4gICAgICAgICAgICAgICAgICAgICAgICAgfihidWlsZCAocmVzdCB2YXJzKSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAocmVjdXIgKCsgfnZhcm5hbWUgfnN0cmlkZSkpKSkpKSldXG4gICAgOyBGaXggdGhlIG51bWJlcnMgb25jZSBvdXRzaWRlIHRoZSBuZXN0ZWQgbG9vcHMsXG4gICAgOyBhbmQgdGhlbiBidWlsZCB0aGUgZ3V0cy5cbiAgICBgKGxldCBbfnN0YXJ0I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ZW1vLTJcIiBkaWFtb25kLXNxdWFyZS0yIDQpXG4gIChtYWtlLWRlbW8gXCJkZW1vLTNcIiBkaWFtb25kLXNxdWFyZS0zIDQpXG4gIChtYWtlLWZpbmFsIFwiZGVtby1maW5hbFwiKSlcblxuKCQgcnVuKVxuXG5cbjsgdmltOiBsdys9ZG8tdGltZXMgbHcrPWRvLW5lc3RlZCA6XG4iXX0=
--- a/media/js/wisp/terrain3.wisp	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,470 +0,0 @@
-(ns demo
-  (:require [ndarray]))
-
-
-; Constants -------------------------------------------------------------------
-(def width 610)
-(def height 400)
-(def wireframe true)
-(def wireframe-width 1.2)
-(def terrain-height 50)
-(def terrain-size 100)
-
-; General Utilities -----------------------------------------------------------
-(defmacro when [condition & body]
-  `(if ~condition
-     (do ~@body)))
-
-(defmacro when-not [condition & body]
-  `(when (not ~condition)
-     ~@body))
-
-(defmacro -> [& operations]
-  (reduce
-    (fn [form operation]
-      (cons (first operation)
-            (cons form (rest operation))))
-    (first operations)
-    (rest operations)))
-
-
-(defn inc [x]
-  (+ x 1))
-
-(defn dec [x]
-  (- x 1))
-
-
-(defmacro do-times [varname limit & body]
-  (let [end (gensym)]
-    `(let [~end ~limit]
-       (loop [~varname 0]
-         (when (< ~varname ~end)
-           ~@body
-           (recur (inc ~varname)))))))
-
-(defmacro do-stride [varnames start-form end-form stride-form & body]
-  (let [stride (gensym "stride")
-        start (gensym "start")
-        end (gensym "end")
-        build (fn build [vars]
-                (if (empty? vars)
-                  `(do ~@body)
-                  (let [varname (first vars)]
-                    `(loop [~varname ~start]
-                       (when (< ~varname ~end)
-                         ~(build (rest vars))
-                         (recur (+ ~varname ~stride)))))))]
-    ; Fix the numbers once outside the nested loops,
-    ; and then build the guts.
-    `(let [~start ~start-form
-           ~end ~end-form
-           ~stride ~stride-form]
-       ~(build varnames))))
-
-
-(defmacro do-ndarray [vars array-form & body]
-  (let [array-var (gensym "array")
-        build (fn build [vars n]
-                (if (empty? vars)
-                  `(do ~@body)
-                  `(do-times ~(first vars) (aget (.-shape ~array-var) ~n)
-                     ~(build (rest vars) (inc n)))))]
-    `(let [~array-var ~array-form]
-       ~(build vars 0))))
-
-(defmacro do-ndarray-el [element array-form & body]
-  (let [index (gensym "index")
-        array (gensym "array")]
-    `(let [~array ~array-form]
-       (do-times ~index (.-length (.-data ~array))
-         (let [~element (aget (.-data ~array) ~index)]
-           ~@body)))))
-
-
-(defmacro inc! [place]
-  `(set! ~place (inc ~place)))
-
-(defmacro add! [place amount]
-  `(set! ~place (+ ~place ~amount)))
-
-
-(defmacro l [& forms]
-  `(console.log ~@forms))
-
-(defmacro time [& body]
-  (let [start (gensym)
-        end (gensym)
-        result (gensym)]
-    `(let [~start (.getTime (new Date))
-           ~result (do ~@body)
-           ~end (.getTime (new Date))]
-       (l (+ "Elapsed time: " (- ~end ~start) "ms."))
-       ~result)))
-
-
-(defn midpoint [a b]
-  (/ (+ a b) 2))
-
-(defn average2 [a b]
-  (/ (+ a b) 2))
-
-(defn average4 [a b c d]
-  (/ (+ a b c d) 4))
-
-(defn safe-average [a b c d]
-  (let [total 0 count 0]
-    (when a (add! total a) (inc! count))
-    (when b (add! total b) (inc! count))
-    (when c (add! total c) (inc! count))
-    (when d (add! total d) (inc! count))
-    (/ total count)))
-
-
-(defn even? [n]
-  (== 0 (mod n 2)))
-
-(defn odd? [n]
-  (== 1 (mod n 2)))
-
-
-; Randomness ------------------------------------------------------------------
-(defn rand []
-  (Math.random))
-
-(defn rand-around-zero [spread]
-  (- (* spread (rand) 2) spread))
-
-(defn jitter [value spread]
-  (+ value (rand-around-zero spread)))
-
-
-; Heightmap Helpers -----------------------------------------------------------
-(defn heightmap-resolution [heightmap]
-  (aget heightmap.shape 0))
-
-(defn heightmap-last-index [heightmap]
-  (dec (heightmap-resolution heightmap)))
-
-(defn heightmap-center-index [heightmap]
-  (midpoint 0 (heightmap-last-index heightmap)))
-
-
-(defn heightmap-get [heightmap x y]
-  (.get heightmap x y))
-
-(defn heightmap-get-safe [heightmap x y]
-  (let [last (heightmap-last-index heightmap)]
-    (when (and (<= 0 x last)
-               (<= 0 y last))
-      (heightmap-get heightmap x y))))
-
-(defn heightmap-set! [heightmap x y val]
-  (.set heightmap x y val))
-
-(defn heightmap-set-if-unset! [heightmap x y val]
-  (when (== 0 (heightmap-get heightmap x y))
-    (heightmap-set! heightmap x y val)))
-
-
-(defn normalize [heightmap]
-  (let [max (- Infinity)
-        min Infinity]
-    (do-ndarray-el el heightmap
-      (when (< max el) (set! max el))
-      (when (> min el) (set! min el)))
-    (let [span (- max min)]
-      (do-ndarray [x y] heightmap
-        (heightmap-set! heightmap x y
-                        (/ (- (heightmap-get heightmap x y) min)
-                           span))))))
-
-
-(defn make-heightmap [exponent]
-  (let [resolution (+ (Math.pow 2 exponent) 1)]
-    (let [heightmap (ndarray (new Float64Array (* resolution resolution))
-                             [resolution resolution])]
-      (set! heightmap.exponent exponent)
-      (set! heightmap.resolution resolution)
-      (set! heightmap.last (dec resolution))
-      heightmap)))
-
-
-(defn top-left-corner [heightmap]
-  (let [center (heightmap-center-index heightmap)]
-    (-> heightmap
-      (.lo 0 0)
-      (.hi (inc center) (inc center)))))
-
-(defn top-right-corner [heightmap]
-  (let [center (heightmap-center-index heightmap)]
-    (-> heightmap
-      (.lo center 0)
-      (.hi (inc center) (inc center)))))
-
-(defn bottom-left-corner [heightmap]
-  (let [center (heightmap-center-index heightmap)]
-    (-> heightmap
-      (.lo 0 center)
-      (.hi (inc center) (inc center)))))
-
-(defn bottom-right-corner [heightmap]
-  (let [center (heightmap-center-index heightmap)]
-    (-> heightmap
-      (.lo center center)
-      (.hi (inc center) (inc center)))))
-
-
-; Diamond-Square --------------------------------------------------------------
-(defn ds-init-corners [heightmap]
-  (let [last (heightmap-last-index heightmap)]
-    (heightmap-set! heightmap 0    0    (rand))
-    (heightmap-set! heightmap 0    last (rand))
-    (heightmap-set! heightmap last 0    (rand))
-    (heightmap-set! heightmap last last (rand))))
-
-(defn ds-square [heightmap x y radius spread]
-  (let [new-height (jitter
-                     (average4
-                       (heightmap-get heightmap (- x radius) (- y radius))
-                       (heightmap-get heightmap (- x radius) (+ y radius))
-                       (heightmap-get heightmap (+ x radius) (- y radius))
-                       (heightmap-get heightmap (+ x radius) (+ y radius)))
-                     spread)]
-    (heightmap-set! heightmap x y new-height)))
-
-(defn ds-diamond [heightmap x y radius spread]
-  (let [new-height (jitter
-                     (safe-average
-                       (heightmap-get-safe heightmap (- x radius) y)
-                       (heightmap-get-safe heightmap (+ x radius) y)
-                       (heightmap-get-safe heightmap x (- y radius))
-                       (heightmap-get-safe heightmap x (+ y radius)))
-                     spread)]
-    (heightmap-set! heightmap x y new-height)))
-
-
-(defn ds-squares [heightmap radius spread]
-  (do-stride [x y] radius (heightmap-resolution heightmap) (* 2 radius)
-    (ds-square heightmap x y radius spread)))
-
-(defn ds-diamonds [heightmap radius spread]
-  (let [size (heightmap-resolution heightmap)]
-    (do-stride [y] 0 size radius
-      (let [shift (if (even? (/ y radius)) radius 0)]
-        (do-stride [x] shift size (* 2 radius)
-          (ds-diamond heightmap x y radius spread))))))
-
-(defn diamond-square [heightmap]
-  (let [initial-spread 0.3
-        spread-reduction 0.5
-        center (heightmap-center-index heightmap)
-        size (aget heightmap.shape 0)]
-    (ds-init-corners heightmap)
-    (loop [radius center
-           spread initial-spread]
-      (when (>= radius 1)
-        (ds-squares heightmap radius spread)
-        (ds-diamonds heightmap radius spread)
-        (recur (/ radius 2)
-               (* spread spread-reduction))))
-    (normalize heightmap)))
-
-
-(defn diamond-square-1 [heightmap]
-  (ds-init-corners heightmap)
-  (normalize heightmap))
-
-(defn diamond-square-2 [heightmap]
-  (let [initial-spread 0.3
-        spread-reduction 0.5
-        center (heightmap-center-index heightmap)
-        size (aget heightmap.shape 0)]
-    (ds-init-corners heightmap)
-    (ds-squares heightmap center initial-spread)
-    (normalize heightmap)))
-
-(defn diamond-square-3 [heightmap]
-  (let [initial-spread 0.3
-        spread-reduction 0.5
-        center (heightmap-center-index heightmap)
-        size (aget heightmap.shape 0)]
-    (ds-init-corners heightmap)
-    (ds-squares heightmap center initial-spread)
-    (ds-diamonds heightmap center initial-spread)
-    (ds-squares heightmap (/ center 2) (* spread-reduction initial-spread))
-    (ds-diamonds heightmap (/ center 2) (* spread-reduction initial-spread))
-    (normalize heightmap)))
-
-
-; Three.js Helpers ------------------------------------------------------------
-(defn make-directional-light []
-  (let [light (new THREE.DirectionalLight 0xffffff 1)]
-    (light.position.set 100 0 150)
-    light))
-
-(defn make-camera []
-  (let [camera (new THREE.PerspectiveCamera
-                    55,
-                    (/ width height)
-                    0.1,
-                    1000)]
-    (camera.position.set 0 -100 150)
-    camera))
-
-(defn make-renderer []
-  (let [renderer (new THREE.WebGLRenderer {:antialias false})]
-    (renderer.setClearColor 0xffffff)
-    (renderer.setSize width height)
-    (renderer.setPixelRatio 2)
-    renderer))
-
-(defn make-geometry [heightmap]
-  (let [resolution (aget heightmap.shape 0)
-        geometry (new THREE.PlaneGeometry
-                      terrain-size
-                      terrain-size
-                      (- resolution 1)
-                      (- resolution 1))]
-    geometry))
-
-(defn make-controls [camera renderer]
-  (let [controls (new THREE.TrackballControls camera renderer.domElement)]
-    (set! controls.rotateSpeed 1.4)
-    (set! controls.zoomSpeed 0.5)
-    (set! controls.staticMoving true)
-    (set! controls.dynamicDampingFactor 0.3)
-    controls))
-
-(defn make-plane [geometry]
-  (let [material (new THREE.MeshLambertMaterial
-                      {:wireframe wireframe
-                       :wireframeLinewidth wireframe-width
-                       :color 0x00bb00})]
-    (new THREE.Mesh geometry material)))
-
-
-(defn attach-to-dom [renderer el-name refresh-fn]
-  (let [container (document.getElementById el-name)
-        settings (document.createElement "div")
-        refresh-button (document.createElement "button")
-        button-text (document.createTextNode "Refresh")
-        cancel-scroll (fn [e] (.preventDefault e))]
-    (set! refresh-button.onclick refresh-fn)
-    (set! renderer.domElement.onmousewheel cancel-scroll)
-    (renderer.domElement.addEventListener "MozMousePixelScroll" cancel-scroll false)
-    (.appendChild refresh-button button-text)
-    (.appendChild container renderer.domElement)
-    (.appendChild container settings)
-    (.appendChild settings refresh-button)))
-
-
-(defn update-geometry [geometry heightmap]
-  (loop [i 0]
-    (if (< i geometry.vertices.length)
-      (do (set! (.-z (aget geometry.vertices i))
-                (* terrain-height (aget (.-data heightmap) i)))
-        (recur (+ i 1)))))
-  (geometry.computeVertexNormals)
-  geometry)
-
-
-; Main ------------------------------------------------------------------------
-(defn make-demo [element-id algorithm size]
-  (def scene (new THREE.Scene))
-  (scene.add (new THREE.AxisHelper 100))
-
-  (def clock (new THREE.Clock))
-  (def camera (make-camera))
-  (def renderer (make-renderer))
-
-  (def geometry)
-  (def plane)
-
-  (scene.add (make-directional-light))
-  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
-
-  (defn refresh []
-    (let [heightmap (make-heightmap size)]
-      (l "Generating terrain...")
-      (time (algorithm heightmap))
-
-      (l "Rebuilding geometry...")
-      (time
-        (set! geometry (make-geometry heightmap))
-        (update-geometry geometry heightmap))
-
-      (l "Rebuilding plane...")
-      (time
-        (scene.remove plane)
-        (set! plane (make-plane geometry))
-        (scene.add plane))))
-
-  (attach-to-dom renderer element-id refresh)
-  (def controls (make-controls camera renderer))
-
-  (defn render []
-    (let [delta (clock.getDelta)]
-      (requestAnimationFrame render)
-      (.update controls delta)
-      (renderer.render scene camera)))
-
-  (refresh)
-  (render)
-
-  nil)
-
-(defn make-final [element-id]
-  (def scene (new THREE.Scene))
-  (scene.add (new THREE.AxisHelper 100))
-
-  (def clock (new THREE.Clock))
-  (def camera (make-camera))
-  (def renderer (make-renderer))
-
-  (def geometry)
-  (def plane)
-
-  (scene.add (make-directional-light))
-  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
-
-  (defn refresh []
-    (let [heightmap (make-heightmap 6)]
-      (l "Generating terrain...")
-      (time (diamond-square heightmap))
-
-      (l "Rebuilding geometry...")
-      (time
-        (set! geometry (make-geometry heightmap))
-        (update-geometry geometry heightmap))
-
-      (l "Rebuilding plane...")
-      (time
-        (scene.remove plane)
-        (set! plane (make-plane geometry))
-        (scene.add plane))))
-
-  (attach-to-dom renderer element-id refresh)
-  (def controls (make-controls camera renderer))
-
-  (defn render []
-    (let [delta (clock.getDelta)]
-      (requestAnimationFrame render)
-      (.update controls delta)
-      (renderer.render scene camera)))
-
-  (refresh)
-  (render)
-
-  nil)
-
-(defn run []
-  (make-demo "demo-1" diamond-square-1 2)
-  (make-demo "demo-2" diamond-square-2 4)
-  (make-demo "demo-3" diamond-square-3 4)
-  (make-final "demo-final"))
-
-($ run)
-
-
-; vim: lw+=do-times lw+=do-nested :
Binary file media/midpoint-displacement.monopic has changed
--- a/nginx.conf	Tue Sep 20 15:23:05 2016 +0000
+++ b/nginx.conf	Fri Oct 07 12:48:36 2016 +0000
@@ -10,6 +10,10 @@
     access_log /tmp/stevelosh.com.access.log;
     error_log /tmp/stevelosh.com.error.log;
 
+    location /feed.html {
+        return 301 /index.xml;
+    }
+
     location / {
         root   /var/www/stevelosh.com/;
         index  index.html;
--- a/requirements.txt	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
--e git://github.com/django/django.git@stable/1.1.x#egg=django
--e svn+http://typogrify.googlecode.com/svn/trunk/#egg=typogrify
--e hg+http://bitbucket.org/cherrypy/cherrypy@cherrypy-3.2.0rc1#egg=cherrypy
--e git://github.com/waylan/python-markdown.git#egg=markdown
--e git://github.com/lakshmivyas/hyde.git#egg=hyde
-
-PyYAML
-smartypants
-Pygments
-PIL
--- a/settings.py	Tue Sep 20 15:23:05 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,117 +0,0 @@
-import os
-
-ROOT_PATH = os.path.abspath(os.path.dirname(__file__))
-
-import hydeengine
-HYDE_FOLDER = os.path.dirname(os.path.dirname(hydeengine.__file__))
-
-LAYOUT_DIR = os.path.join(ROOT_PATH, 'layout')
-CONTENT_DIR = os.path.join(ROOT_PATH, 'content')
-MEDIA_DIR = os.path.join(ROOT_PATH, 'media')
-DEPLOY_DIR = os.path.join(ROOT_PATH, 'deploy')
-TMP_DIR = os.path.join(ROOT_PATH, 'deploy_tmp')
-BACKUPS_DIR = os.path.join(ROOT_PATH, 'backups')
-
-BACKUP = False
-DEBUG = True
-
-SITE_ROOT = "/"
-SITE_WWW_URL = "http://stevelosh.com"
-SITE_NAME = "Steve Losh"
-SITE_AUTHOR = "Steve Losh"
-
-GENERATE_ABSOLUTE_FS_URLS = False
-GENERATE_CLEAN_URLS = True
-LISTING_PAGE_NAMES = ['index']
-APPEND_SLASH = True
-
-# {folder : extension : (processors)}
-# The processors are run in the given order and are chained.
-# Only a lone * is supported as an indicator for folders. Path
-# should be specified. No wildcard card support yet.
-
-# Starting under the media folder. For example, if you have media/css under
-# your site root,you should specify just css. If you have media/css/ie you
-# should specify css/ie for the folder name. css/* is not supported (yet).
-
-# Extensions do not support wildcards.
-
-MEDIA_PROCESSORS = {
-    '*': {
-        '.less': ('hydeengine.media_processors.LessCSS',),
-        '.js': ('hydeengine.media_processors.TemplateProcessor',
-                # 'hydeengine.media_processors.YUICompressor',
-                )
-    },
-    'images/': {
-        '.png': ('hydeengine.media_processors.Thumbnail',),
-        '.jpg': ('hydeengine.media_processors.Thumbnail',),
-    },
-}
-
-CONTENT_PROCESSORS = {}
-
-SITE_PRE_PROCESSORS = {
-    '/': {
-        'hydeengine.site_pre_processors.NodeInjector' : {
-            'variable': 'blog_node',
-            'path': 'content/blog',
-        }
-    }
-}
-
-SITE_POST_PROCESSORS = {
-    # 'media/js': {
-    #        'hydeengine.site_post_processors.FolderFlattener' : {
-    #                'remove_processed_folders': True,
-    #                'pattern':"*.js"
-    #        }
-    #    }
-}
-
-CONTEXT = {
-    'GENERATE_CLEAN_URLS': GENERATE_CLEAN_URLS,
-    'links': {
-        'python': 'http://python.org/',
-        'django': 'http://www.djangoproject.com/',
-        'cherrypy': 'http://cherrypy.org/',
-        'hyde': 'http://github.com/lakshmivyas/hyde/',
-        'markdown': 'http://daringfireball.net/projects/markdown/',
-        'fabric': 'http://fabfile.org/',
-        'blatter': 'http://bitbucket.org/jek/blatter/',
-        'webfaction': 'http://www.webfaction.com?affiliate=sjl',
-        'mercurial': 'http://mercurial.selenic.com/',
-        'git': 'http://git-scm.com/',
-        'aardvarklegs': 'http://fecklessmind.com/2009/01/20/aardvark-css-framework/',
-        'hgtip': 'http://hgtip.com/',
-        'lesscss': 'http://lesscss.org/',
-        'bitbucket': 'http://bitbucket.org/',
-        'github': 'http://github.com/',
-        'twsl': 'http://twitter.com/stevelosh/',
-    },
-}
-
-FILTER = {
-    'include': (".htaccess",),
-    'exclude': (".*","*~")
-}
-
-
-# Processor Configuration
-
-YUI_COMPRESSOR = os.path.join(ROOT_PATH, 'yuicompressor-2.4.2.jar')
-HSS_PATH = None # if you don't want to use HSS
-LESS_CSS_PATH = '/usr/local/bin/lessc'
-THUMBNAIL_MAX_WIDTH = 1400000000
-THUMBNAIL_MAX_HEIGHT = 100
-THUMBNAIL_FILENAME_POSTFIX = '-thumb'
-WISP_PATH = '/usr/local/bin/wisp'
-
-# Django settings
-
-TEMPLATE_DIRS = (LAYOUT_DIR, CONTENT_DIR, TMP_DIR, MEDIA_DIR)
-INSTALLED_APPS = (
-    'hydeengine',
-    'django.contrib.webdesign',
-    'custom',
-)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/css/aal.css	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,115 @@
+/* 
+  aardvark.legs originally by Anatoli Papirovski - http://fecklessmind.com/
+  Licensed under the MIT license. http://www.opensource.org/licenses/mit-license.php
+*/
+
+/* 
+  Reset first. Modified version of Eric Meyer and Paul Chaplin reset 
+  from http://meyerweb.com/eric/tools/css/reset/ 
+*/
+html, body, div, span, applet, object, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, acronym, address, big, cite, code,
+del, dfn, em, font, img, ins, kbd, q, s, samp,
+small, strike, strong, sub, sup, tt, var,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+header, nav, section, article, aside, footer
+{border: 0; margin: 0; outline: 0; padding: 0; background: transparent; vertical-align: baseline;}
+
+article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section { 
+    display:block;
+}
+
+blockquote, q {quotes: none;}
+blockquote:before,blockquote:after,q:before,q:after {content: ''; content: none;}
+
+header, nav, section, article, aside, footer {display: block;}
+
+/* Basic styles */
+html {overflow-y: scroll;}
+body {background: #fdfdfd; color: #353535; font: normal 18px/25px Palatino, "Palatino Linotype", serif; text-rendering: optimizeLegibility;}
+html>body {font-size: 18px; line-height: 25px;}
+
+img {display: inline-block; vertical-align: bottom;}
+
+h1,h2,h3,h4,h5,h6,strong,b,dt,th {font-weight: 700;}
+address,cite,em,i,caption,dfn,var {font-style: italic;}
+
+h1 { font-size: 45px; line-height: 50px; margin: 25px 0; }
+h2 { font-size: 32px; line-height: 50px; margin: 25px 0; }
+h3 { font-size: 23px; line-height: 25px; margin: 25px 0; }
+h4 {margin: 0 0 22px; font-size: 16px; line-height: 22px;}
+h5 {margin: 0 0 22px; font-size: 14px; line-height: 22px;}
+h6 {margin: 0 0 22px; font-size: 12px; line-height: 22px;}
+
+p,ul,ol,dl,blockquote,pre {margin: 0 0 25px;}
+
+li ul,li ol {margin: 0;}
+ul {list-style: outside disc;}
+ol {list-style: outside decimal;}
+li {margin: 0 0 0 44px;}
+dd {padding-left: 25px;}
+blockquote {padding: 0 25px;}
+
+a {text-decoration: underline;}
+a:hover {text-decoration: none;}
+abbr,acronym {border-bottom: 1px dotted; cursor: help;}
+del {text-decoration: line-through;}
+ins {text-decoration: overline;}
+sub {font-size: 14px; line-height: 25px; vertical-align: sub;}
+sup {font-size: 14px; line-height: 25px; vertical-align: super;}
+
+tt,code,kbd,samp,pre {font-size: 14px; line-height: 25px; font-family: Menlo, Monaco, Consolas, "Courier New", monospace;}
+
+/* Table styles */
+/* TODO */
+table {border-collapse: collapse; border-spacing: 0; margin: 0 0 1.5em;}
+caption {text-align: left;}
+th, td {padding: .25em .5em;}
+tbody td, tbody th {border: 1px solid #222;}
+tfoot {font-style: italic;}
+
+/* Form styles */
+/* TODO */
+fieldset {clear: both;}
+legend {padding: 0 0 1.286em; font-size: 1.167em; font-weight: 700;}
+fieldset fieldset legend {padding: 0 0 1.5em; font-size: 1em;}
+* html legend {margin-left: -7px;}
+*+html legend {margin-left: -7px;}
+
+form .field, form .buttons {clear: both; margin: 0 0 1.5em;}
+form .field label {display: block;}
+form ul.fields li {list-style-type: none; margin: 0;}
+form ul.inline li, form ul.inline label {display: inline;}
+form ul.inline li {padding: 0 .75em 0 0;}
+
+input.radio, input.checkbox {vertical-align: top;}
+label, button, input.submit, input.image {cursor: pointer;}
+* html input.radio, * html input.checkbox {vertical-align: middle;}
+*+html input.radio, *+html input.checkbox {vertical-align: middle;}
+
+textarea {overflow: auto;}
+input.text, input.password, textarea, select {margin: 0; font: 1em/1.3 Helvetica, Arial, "Liberation Sans", "Bitstream Vera Sans", sans-serif; vertical-align: baseline;}
+input.text, input.password, textarea {border: 1px solid #444; border-bottom-color: #666; border-right-color: #666; padding: 2px;}
+
+* html button {margin: 0 .34em 0 0;}
+*+html button {margin: 0 .34em 0 0;}
+
+form.horizontal .field {padding-left: 150px;}
+form.horizontal .field label {display: inline; float: left; width: 140px; margin-left: -150px;}
+
+/* Useful classes */
+/* TODO */
+img.left {display: inline; float: left; margin: 0 1.5em .75em 0;}
+img.right {display: inline; float: right; margin: 0 0 .75em .75em;}
+.group:after {
+    content: ".";
+    display: block;
+    height: 0;
+    clear: both;
+    visibility: hidden;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/css/print.css	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,67 @@
+body {
+  font: normal 10pt/1.25 Palatino, "Palatino Linotype";
+  text-rendering: optimizeLegibility;
+}
+nav,
+header,
+.toc {
+  display: none;
+}
+#leaf-title a {
+  text-decoration: none;
+  color: black;
+}
+#leaf-content ul.print-links {
+  display: block;
+  font-size: 1em;
+  list-style-type: none;
+  margin-left: 0em;
+}
+#leaf-content ul.print-links a {
+  text-decoration: none;
+}
+#leaf-content code,
+#leaf-content pre {
+  font: normal 9pt Menlo, Monaco, Consolas, "Courier New", Courier, monospace;
+}
+#leaf-content img {
+  display: block;
+  margin-left: auto;
+  margin-right: auto;
+  border: 1.43em solid #e5e5e5;
+  padding: 1px;
+  background: black;
+  width: 400px;
+}
+#leaf-content img.left,
+#leaf-content img.right {
+  border: none;
+  background: none;
+  padding: none;
+}
+#leaf-content img.left {
+  margin: 0 1.5em 1em 0;
+  float: left;
+}
+#leaf-content img.right {
+  margin: 0 0 .75em 1em;
+  float: right;
+}
+div#leaf-content.with-diagrams img {
+  display: block;
+  margin-left: auto;
+  margin-right: auto;
+  background: none;
+  border: none;
+}
+span.amp {
+  font-family: "Palatino", "Constantia", "Palatino Linotype", serif;
+  font-style: italic;
+}
+a {
+  text-decoration: underline;
+  color: #c06;
+}
+footer {
+  display: none;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/css/print.less	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,69 @@
+body {
+    font: normal 10pt/1.25 Palatino, "Palatino Linotype";
+    text-rendering: optimizeLegibility;
+}
+
+nav, header, .toc {
+    display: none;
+}
+#leaf-title {
+    a {
+        text-decoration: none;
+        color: black;
+    }
+}
+#leaf-content {
+    ul.print-links {
+        display: block;
+        font-size: 1em;
+        list-style-type: none;
+        margin-left: 0em;
+
+        a {
+            text-decoration: none;
+        }
+    }
+    code, pre {
+        font: normal 9pt Menlo, Monaco, Consolas, "Courier New", Courier, monospace;
+    }
+    img {
+        display: block;
+        margin-left: auto;
+        margin-right: auto;
+        border: 1.43em solid #e5e5e5;
+        padding: 1px;
+        background: black;
+        width: 400px;
+    }
+    img.left, img.right {
+        border: none;
+        background: none;
+        padding: none;
+    }
+    img.left {
+         margin: 0 1.5em 1em 0;
+         float: left;
+    }
+    img.right {
+        margin: 0 0 .75em 1em;
+        float: right;
+    }
+}
+div#leaf-content.with-diagrams img {
+    display: block;
+    margin-left: auto;
+    margin-right: auto;
+    background: none;
+    border: none;
+}
+span.amp {
+    font-family: "Palatino", "Constantia", "Palatino Linotype", serif;
+    font-style: italic;
+}
+a {
+    text-decoration: underline;
+    color: #c06;
+}
+footer {
+    display: none;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/css/pygments-clean.css	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,60 @@
+/* @override http://localhost:8080/media/css/pygments-monokai-light.css */
+div.highlight .hll { background-color: #49483e }
+div.highlight .err { color: #fff; background-color: #f00 } /* Error */
+div.highlight .k { color: #111} /* Keyword */
+div.highlight .l { color: #111 } /* Literal */
+div.highlight .n { color: #111 } /* Name */
+div.highlight .o { color: #111 } /* Operator */
+div.highlight .p { color: #111 } /* Punctuation */
+div.highlight .c  { color: #714678; font-style: italic; font-weight: bold; } /* Comment */
+div.highlight .cm { color: #714678; font-style: italic; font-weight: bold; } /* Comment.Multiline */
+div.highlight .cp { color: #714678; font-style: italic; font-weight: bold; } /* Comment.Preproc */
+div.highlight .c1 { color: #714678; font-style: italic; font-weight: bold; } /* Comment.Single */
+div.highlight .cs { color: #714678; font-style: italic; font-weight: bold; } /* Comment.Special */
+div.highlight .ge { font-style: italic } /* Generic.Emph */
+div.highlight .gs { font-weight: bold } /* Generic.Strong */
+div.highlight .kc { color: #111 } /* Keyword.Constant */
+div.highlight .kd { color: #111 } /* Keyword.Declaration */
+div.highlight .kn { color: #111 } /* Keyword.Namespace */
+div.highlight .kp { color: #111 } /* Keyword.Pseudo */
+div.highlight .kr { color: #111 } /* Keyword.Reserved */
+div.highlight .kt { color: #111 } /* Keyword.Type */
+div.highlight .ld { color: #111 } /* Literal.Date */
+div.highlight .m { color: #111 } /* Literal.Number */
+div.highlight .s { color: #111; font-style: italic; } /* Literal.String */
+div.highlight .na { color: #111 } /* Name.Attribute */
+div.highlight .nb { color: #111 } /* Name.Builtin */
+div.highlight .nc { color: #111 } /* Name.Class */
+div.highlight .no { color: #111 } /* Name.Constant */
+div.highlight .nd { color: #111 } /* Name.Decorator */
+div.highlight .ni { color: #111 } /* Name.Entity */
+div.highlight .ne { color: #111 } /* Name.Exception */
+div.highlight .nf { color: #111} /* Name.Function */
+div.highlight .nl { color: #111 } /* Name.Label */
+div.highlight .nn { color: #111} /* Name.Namespace */
+div.highlight .nx { color: #111 } /* Name.Other */
+div.highlight .py { color: #111 } /* Name.Property */
+div.highlight .nt { color: #111 } /* Name.Tag */
+div.highlight .nv { color: #111 } /* Name.Variable */
+div.highlight .ow { color: #111 } /* Operator.Word */
+div.highlight .w { color: #111 } /* Text.Whitespace */
+div.highlight .mf { color: #111 } /* Literal.Number.Float */
+div.highlight .mh { color: #111 } /* Literal.Number.Hex */
+div.highlight .mi { color: #111 } /* Literal.Number.Integer */
+div.highlight .mo { color: #111 } /* Literal.Number.Oct */
+div.highlight .sb { color: #111 } /* Literal.String.Backtick */
+div.highlight .sc { color: #111 } /* Literal.String.Char */
+div.highlight .sd { color: #111 } /* Literal.String.Doc */
+div.highlight .s2 { color: #111 } /* Literal.String.Double */
+div.highlight .se { color: #111 } /* Literal.String.Escape */
+div.highlight .sh { color: #111 } /* Literal.String.Heredoc */
+div.highlight .si { color: #111 } /* Literal.String.Interpol */
+div.highlight .sx { color: #111 } /* Literal.String.Other */
+div.highlight .sr { color: #111 } /* Literal.String.Regex */
+div.highlight .s1 { color: #111 } /* Literal.String.Single */
+div.highlight .ss { color: #111 } /* Literal.String.Symbol */
+div.highlight .bp { color: #111 } /* Name.Builtin.Pseudo */
+div.highlight .vc { color: #111 } /* Name.Variable.Class */
+div.highlight .vg { color: #111 } /* Name.Variable.Global */
+div.highlight .vi { color: #111 } /* Name.Variable.Instance */
+div.highlight .il { color: #111 } /* Literal.Number.Integer.Long */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/css/pygments-monokai-light.css	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,60 @@
+/* @override http://localhost:8080/media/css/pygments-monokai-light.css */
+.codehilite .hll { background-color: #49483e }
+.codehilite .c { color: #7A7663 } /* Comment */
+.codehilite .err { color: #960050; background-color: #1e0010 } /* Error */
+.codehilite .k { color: #00a8c8} /* Keyword */
+.codehilite .l { color: #ae81ff } /* Literal */
+.codehilite .n { color: #111111 } /* Name */
+.codehilite .o { color: #f92672 } /* Operator */
+.codehilite .p { color: #111111 } /* Punctuation */
+.codehilite .cm { color: #75715e } /* Comment.Multiline */
+.codehilite .cp { color: #75715e } /* Comment.Preproc */
+.codehilite .c1 { color: #75715e } /* Comment.Single */
+.codehilite .cs { color: #75715e } /* Comment.Special */
+.codehilite .ge { font-style: italic } /* Generic.Emph */
+.codehilite .gs { font-weight: bold } /* Generic.Strong */
+.codehilite .kc { color: #00a8c8 } /* Keyword.Constant */
+.codehilite .kd { color: #00a8c8 } /* Keyword.Declaration */
+.codehilite .kn { color: #f92672 } /* Keyword.Namespace */
+.codehilite .kp { color: #00a8c8 } /* Keyword.Pseudo */
+.codehilite .kr { color: #00a8c8 } /* Keyword.Reserved */
+.codehilite .kt { color: #00a8c8 } /* Keyword.Type */
+.codehilite .ld { color: #d88200 } /* Literal.Date */
+.codehilite .m { color: #ae81ff } /* Literal.Number */
+.codehilite .s { color: #d88200} /* Literal.String */
+.codehilite .na { color: #75af00 } /* Name.Attribute */
+.codehilite .nb { color: #111111 } /* Name.Builtin */
+.codehilite .nc { color: #75af00 } /* Name.Class */
+.codehilite .no { color: #00a8c8 } /* Name.Constant */
+.codehilite .nd { color: #75af00 } /* Name.Decorator */
+.codehilite .ni { color: #111111 } /* Name.Entity */
+.codehilite .ne { color: #75af00 } /* Name.Exception */
+.codehilite .nf { color: #75af00} /* Name.Function */
+.codehilite .nl { color: #111111 } /* Name.Label */
+.codehilite .nn { color: #111111} /* Name.Namespace */
+.codehilite .nx { color: #111111 } /* Name.Other */
+.codehilite .py { color: #111111 } /* Name.Property */
+.codehilite .nt { color: #f92672 } /* Name.Tag */
+.codehilite .nv { color: #111111 } /* Name.Variable */
+.codehilite .ow { color: #f92672 } /* Operator.Word */
+.codehilite .w { color: #111111 } /* Text.Whitespace */
+.codehilite .mf { color: #ae81ff } /* Literal.Number.Float */
+.codehilite .mh { color: #ae81ff } /* Literal.Number.Hex */
+.codehilite .mi { color: #ae81ff } /* Literal.Number.Integer */
+.codehilite .mo { color: #ae81ff } /* Literal.Number.Oct */
+.codehilite .sb { color: #d88200 } /* Literal.String.Backtick */
+.codehilite .sc { color: #d88200 } /* Literal.String.Char */
+.codehilite .sd { color: #d88200 } /* Literal.String.Doc */
+.codehilite .s2 { color: #d88200 } /* Literal.String.Double */
+.codehilite .se { color: #8045FF } /* Literal.String.Escape */
+.codehilite .sh { color: #d88200 } /* Literal.String.Heredoc */
+.codehilite .si { color: #d88200 } /* Literal.String.Interpol */
+.codehilite .sx { color: #d88200 } /* Literal.String.Other */
+.codehilite .sr { color: #d88200 } /* Literal.String.Regex */
+.codehilite .s1 { color: #d88200 } /* Literal.String.Single */
+.codehilite .ss { color: #d88200 } /* Literal.String.Symbol */
+.codehilite .bp { color: #111111 } /* Name.Builtin.Pseudo */
+.codehilite .vc { color: #111111 } /* Name.Variable.Class */
+.codehilite .vg { color: #111111 } /* Name.Variable.Global */
+.codehilite .vi { color: #111111 } /* Name.Variable.Instance */
+.codehilite .il { color: #ae81ff } /* Literal.Number.Integer.Long */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/css/sjl.css	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,355 @@
+html {
+  overflow-y: scroll;
+}
+body {
+  text-rendering: optimizeLegibility;
+  color: #222222;
+  position: relative;
+}
+body a {
+  text-decoration: none;
+  color: #e50053;
+}
+body a:hover {
+  text-decoration: underline;
+}
+body h1,
+body h2,
+body h3,
+body h4,
+body h5,
+body h6 {
+  font-family: 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
+  font-weight: normal;
+}
+body h1 a,
+body h2 a,
+body h3 a,
+body h4 a,
+body h5 a,
+body h6 a {
+  color: #222222;
+}
+body h1 a:hover,
+body h2 a:hover,
+body h3 a:hover,
+body h4 a:hover,
+body h5 a:hover,
+body h6 a:hover {
+  color: #e50053;
+  text-decoration: none;
+}
+body h1 .amp,
+body h2 .amp,
+body h3 .amp,
+body h4 .amp,
+body h5 .amp,
+body h6 .amp {
+  font-style: italic;
+}
+body h1 {
+  font-size: 45px;
+  line-height: 50px;
+  margin: 25px 0;
+}
+body h2 {
+  font-size: 32px;
+  line-height: 50px;
+  margin: 25px 0;
+}
+body h3 {
+  font-size: 23px;
+  line-height: 25px;
+  margin: 25px 0;
+}
+body h4 {
+  font-size: 18px;
+  line-height: 25px;
+  margin: 25px 0;
+  font-weight: bold;
+}
+body code,
+body pre {
+  font-family: Consolas, Menlo, "Courier New", monospace;
+  font-size: 14px;
+}
+body div.threejs {
+  margin-bottom: 16px;
+}
+body div.threejs canvas {
+  border: 1px solid #222222;
+}
+body div.threejs div {
+  text-align: center;
+}
+body pre {
+  font-family: Consolas, Menlo, "Courier New", monospace;
+  font-size: 16px;
+  line-height: 25px;
+  overflow-x: auto;
+  border: 1px solid #d5d5d5;
+  border-left: 10px solid #d5d5d5;
+  background-color: #fafafa;
+  padding: 11px 15px 12px;
+  margin-left: -25px;
+}
+body pre::-webkit-scrollbar {
+  height: 25px;
+}
+body pre::-webkit-scrollbar-button:start,
+body pre::-webkit-scrollbar-button:end {
+  display: none;
+}
+body pre::-webkit-scrollbar-track-piece {
+  background-color: #eee;
+}
+body pre::-webkit-scrollbar-thumb {
+  background-color: #bbb;
+  border: 7px solid #eee;
+  -webkit-background-clip: padding-box;
+  -webkit-border-radius: 12px;
+}
+body pre.lineart {
+  background: none;
+  font-family: Consolas, Menlo, "Courier New", monospace;
+  font-size: 16px;
+  line-height: 20px;
+  border: none;
+}
+body p code,
+body li code,
+body table code {
+  border: 1px solid #ccc;
+  background-color: #fafafa;
+  font-size: 13px;
+  padding: 1px 3px;
+  line-height: 20px;
+  margin: 0;
+  white-space: nowrap;
+}
+body .wrap {
+  width: 612px;
+  margin: 0 auto;
+  margin-bottom: 5em;
+}
+body .wrap .top header {
+  float: left;
+  font-family: 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
+  font-size: 23px;
+  line-height: 50px;
+  text-transform: lowercase;
+  padding-left: 2px;
+  width: 210px;
+}
+body .wrap .top header .amp {
+  font-style: italic;
+}
+body .wrap .top header a {
+  color: #222222;
+}
+body .wrap .top header a:hover {
+  color: #e50053;
+}
+body .wrap .top nav {
+  font: normal 18px/50px 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
+  text-align: right;
+  text-transform: lowercase;
+  padding-right: 2px;
+  width: 398px;
+  float: left;
+}
+body .wrap .top nav .sep {
+  padding: 0 4px;
+  color: #666;
+}
+body .wrap .hr {
+  margin-top: -12px;
+  margin-bottom: 37px;
+  height: 25px;
+  background: transparent url('/media/images/hr.png') top left no-repeat;
+}
+body .wrap .hrb {
+  height: 25px;
+  margin-top: 50px;
+  background: transparent url('/media/images/hrb.png') top left no-repeat;
+}
+body .wrap footer {
+  text-align: center;
+}
+body .wrap footer p {
+  font-size: 14px;
+  font-style: italic;
+  line-height: 50px;
+  margin-bottom: 0px;
+}
+body .wrap footer .rochester-made img {
+  opacity: 0.7;
+  padding: 5px 20px;
+}
+hr {
+  border: none;
+  background: #ccc;
+  height: 1px;
+  margin-bottom: 24px;
+}
+.splash {
+  color: #454545;
+  text-align: center;
+  font: normal 27px/32px 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
+  margin-bottom: -1px;
+  padding-top: 0;
+}
+.splash p {
+  margin-bottom: 24px;
+}
+.splash .amp {
+  font-style: italic;
+}
+.splash .fn {
+  color: #454545;
+  text-decoration: none;
+}
+.splash .fn:hover {
+  color: #e50053;
+  text-decoration: none;
+}
+.splash .fn .last-name {
+  display: none;
+}
+.section-listing {
+  margin-bottom: -50px;
+}
+.section-listing ol {
+  list-style-type: none;
+}
+.section-listing ol li {
+  margin: 0 0 25px 0;
+}
+.section-listing ol li a {
+  font: normal 23px/32px 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
+  color: #222222;
+  display: block;
+}
+.section-listing ol li a:hover {
+  color: #e50053;
+  text-decoration: none;
+}
+.section-listing ol li span.snip {
+  font-size: 18px;
+  color: #333;
+  font-family: 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
+  line-height: 25px;
+  font-style: italic;
+}
+.section-listing ol li .amp {
+  font-style: italic;
+}
+blockquote {
+  border: 1px solid #ccc;
+  background-color: #fafafa;
+  padding: 11px 15px 12px;
+  margin-left: 2em;
+  overflow: auto;
+}
+blockquote p:last-child {
+  margin-bottom: 0;
+}
+span.dquo {
+  margin-left: -0.23em;
+}
+#leaf-stats p {
+  color: #666;
+  margin-top: -22px;
+  margin-bottom: 22px;
+}
+#leaf-content img {
+  display: block;
+  margin: 25px auto 26px;
+  border: 11px solid #e5e5e5;
+  padding: 1px;
+  background: black;
+  max-width: 590px;
+}
+#leaf-content img.diagram {
+  display: block;
+  margin: 25px auto;
+  padding: 0;
+  background: none;
+  border: none;
+}
+#leaf-content img.left,
+#leaf-content img.right {
+  border: none;
+  background: none;
+  padding: none;
+}
+#leaf-content img.left {
+  margin: 0 1.5em 1em 0;
+}
+#leaf-content img.right {
+  margin: 0 0 .75em 1em;
+}
+#leaf-content .gallery img {
+  background: none;
+  padding: 0;
+  border: none;
+  display: inline;
+  margin-bottom: 25px;
+  margin-right: 25px;
+}
+#leaf-content nav#TableOfContents ul {
+  list-style: none;
+}
+#leaf-content nav#TableOfContents ul:first-child > li {
+  margin-left: 0em;
+}
+#leaf-content table {
+  padding: 0px;
+  margin-top: -8px;
+  margin-bottom: 25px;
+}
+#leaf-content table tr {
+  margin: 0px;
+  padding: 0px;
+}
+#leaf-content table tr td,
+#leaf-content table tr th {
+  margin: 0px;
+  padding: 5px 5px;
+  line-height: 23px;
+}
+#leaf-content table tr td {
+  border: 1px solid #666;
+}
+.print-links {
+  display: none;
+}
+img.self {
+  border: none;
+  padding: 0;
+  margin: 0;
+  margin-right: -108px;
+  margin-top: -15px;
+  margin-left: 30px;
+  margin-bottom: 20px;
+}
+div#cboxCurrent {
+  bottom: -30px;
+  font-size: 17px;
+  font-weight: normal;
+  left: 60px;
+}
+div.screenshots img {
+  max-width: 580px;
+}
+#scrolling-header {
+  color: #999;
+  font-size: 23px;
+  font-style: italic;
+  font: italic 23px 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
+  line-height: 30px;
+  position: fixed;
+  top: 75px;
+  text-align: right;
+  width: 180px;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/css/sjl.less	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,363 @@
+@c-link: #e50053;
+@c-body: #222;
+@w-body: 612px;
+@font-fancy: 'OFL Sorts Mill Goudy', 'OFL Sorts Mill Goudy TT', serif;
+
+html {
+    overflow-y: scroll;
+}
+body {
+    text-rendering: optimizeLegibility;
+    color: @c-body;
+    position: relative;
+
+    a {
+        text-decoration: none;
+        color: @c-link;
+
+        &:hover {
+            text-decoration: underline;
+        }
+    }
+    h1, h2, h3, h4, h5, h6 {
+        font-family: @font-fancy;
+        font-weight: normal;
+
+        a {
+            color: @c-body;
+
+            &:hover {
+                color: @c-link;
+                text-decoration: none;
+            }
+        }
+        .amp {
+            font-style: italic;
+        }
+    }
+    h1 { font-size: 45px; line-height: 50px; margin: 25px 0; } // 3
+    h2 { font-size: 32px; line-height: 50px; margin: 25px 0; } // m7
+    h3 { font-size: 23px; line-height: 25px; margin: 25px 0; } // 3
+    h4 { font-size: 18px; line-height: 25px; margin: 25px 0; font-weight: bold; } // r
+    code, pre {
+        font-family: Consolas, Menlo, "Courier New", monospace;
+        font-size: 14px;
+    }
+    div.threejs {
+        margin-bottom: 16px;
+
+        canvas {
+            border: 1px solid #222222;
+        }
+        div {
+            text-align: center;
+        }
+    }
+
+    pre {
+        font-family: Consolas, Menlo, "Courier New", monospace;
+        font-size: 16px;
+        line-height: 25px;
+
+        overflow-x: auto;
+
+        border: 1px solid #d5d5d5;
+        border-left: 10px solid #d5d5d5;
+        background-color: #fafafa;
+
+        padding: 11px 15px 12px;
+        margin-left: -25px;
+    }
+    pre::-webkit-scrollbar {
+        height: 25px;
+    }
+    pre::-webkit-scrollbar-button:start,
+    pre::-webkit-scrollbar-button:end {
+        display: none;
+    }
+    pre::-webkit-scrollbar-track-piece  {
+        background-color: #eee;
+    }
+    pre::-webkit-scrollbar-thumb {
+        background-color: #bbb;
+        border: 7px solid #eee;
+        -webkit-background-clip: padding-box;
+        -webkit-border-radius: 12px;
+    }
+
+    pre.lineart {
+        background: none;
+        font-family: Consolas, Menlo, "Courier New", monospace;
+        font-size: 16px;
+        line-height: 20px;
+        border: none;
+    }
+    p code, li code, table code {
+        border: 1px solid #ccc;
+        background-color: #fafafa;
+        font-size: 13px;
+        padding: 1px 3px;
+        line-height: 20px;
+        margin: 0;
+        white-space: nowrap;
+    }
+
+    .wrap {
+        width: @w-body;
+        margin: 0 auto;
+        margin-bottom: 5em;
+
+        .top {
+            header {
+                float: left;
+                font-family: @font-fancy;
+                font-size: 23px;      // 3
+                line-height: 50px;
+                text-transform: lowercase;
+                padding-left: 2px;
+                width: 612px - 2px - 400px;
+
+                .amp {
+                    font-style: italic;
+                }
+                a {
+                    color: @c-body;
+
+                    &:hover {
+                        color: @c-link;
+                    }
+                }
+            }
+            nav {
+                font: normal 18px/50px @font-fancy;    // 1
+                text-align: right;
+                text-transform: lowercase;
+                padding-right: 2px;
+                width: 400px - 2px;
+                float: left;
+
+                .sep {
+                    padding: 0 4px;
+                    color: #666;
+                }
+            }
+        }
+        .hr {
+            margin-top: -12px;
+            margin-bottom: 12px + 25px;
+            height: 25px;
+            background: transparent url('/media/images/hr.png') top left no-repeat;
+        }
+        .hrb {
+            height: 25px;
+            margin-top: 50px;
+            background: transparent url('/media/images/hrb.png') top left no-repeat;
+        }
+        footer {
+            text-align: center;
+
+            p {
+                font-size: 14px;
+                font-style: italic;
+                line-height: 50px;
+                margin-bottom: 0px;
+            }
+            .rochester-made {
+                img {
+                    opacity: 0.7;
+                    padding: 5px 20px;
+                }
+            }
+        }
+    }
+}
+hr {
+    border: none;
+    background: #ccc;
+    height: 1px;
+    margin-bottom: 24px;
+}
+.splash {
+    @color: #454545;
+    color: @color;
+    text-align: center;
+    font: normal 27px/32px @font-fancy;
+    margin-bottom: -1px;
+    padding-top: 0;
+
+    p {
+        margin-bottom: 24px;
+    }
+    .amp {
+        font-style: italic;
+    }
+    .fn {
+        color: @color;
+        text-decoration: none;
+
+        &:hover {
+            color: @c-link;
+            text-decoration: none;
+        }
+        .last-name {
+            display: none;
+        }
+    }
+}
+.section-listing {
+    margin-bottom: -50px;
+    ol {
+        list-style-type: none;
+
+        @w-listing-item: 612px/2;
+        @w-listing-col-padding: 50px;
+
+        li {
+            margin: 0 0 25px 0;
+
+            a {
+                font: normal 23px/32px @font-fancy;    // 3
+                color: @c-body;
+                display: block;
+
+                &:hover {
+                    color: @c-link;
+                    text-decoration: none;
+                }
+            }
+
+            span.snip {
+                font-size: 18px;     // 1
+                color: #333;
+                font-family: @font-fancy;
+                line-height: 25px;
+                font-style: italic;
+            }
+            .amp {
+                font-style: italic;
+            }
+        }
+    }
+}
+
+blockquote {
+    border: 1px solid #ccc;
+    background-color: #fafafa;
+    padding: 11px 15px 12px;
+    margin-left: 2em;
+    overflow: auto;
+
+    p:last-child {
+        margin-bottom: 0;
+    }
+}
+span.dquo {
+    margin-left: -0.23em;
+}
+
+#leaf-stats p {
+    color: #666;
+    margin-top: -22px;
+    margin-bottom: 22px;
+}
+#leaf-content {
+    img {
+        display: block;
+        margin: 25px auto 26px;
+        border: 11px solid #e5e5e5;
+        padding: 1px;
+        background: black;
+        max-width: 590px;
+    }
+    img.diagram {
+        display: block;
+        margin: 25px auto;
+        padding: 0;
+        background: none;
+        border: none;
+    }
+    img.left, img.right {
+        border: none;
+        background: none;
+        padding: none;
+    }
+    img.left {
+         margin: 0 1.5em 1em 0;
+    }
+    img.right {
+        margin: 0 0 .75em 1em;
+    }
+    .gallery img {
+        background: none;
+        padding: 0;
+        border: none;
+        display: inline;
+        margin-bottom: 25px;
+        margin-right: 25px;
+    }
+    nav#TableOfContents {
+        ul {
+            list-style: none;
+        }
+
+        ul:first-child>li {
+            margin-left: 0em;
+        }
+    }
+    table {
+        padding: 0px;
+        margin-top: -8px;
+        margin-bottom: 25px;
+
+        tr {
+            margin: 0px;
+            padding: 0px;
+
+            td, th {
+                margin: 0px;
+                padding: 5px 5px;
+                line-height: 23px;
+            }
+            td {
+                border: 1px solid #666;
+            }
+        }
+    }
+}
+
+.print-links {
+    display: none;
+}
+img.self {
+    border: none;
+    padding: 0;
+    margin: 0;
+    margin-right: -108px;
+    margin-top: -15px;
+    margin-left: 30px;
+    margin-bottom: 20px;
+}
+
+div#cboxCurrent {
+    bottom: -30px;
+    font-size: 17px;
+    font-weight: normal;
+    left: 60px;
+}
+div.screenshots {
+    img {
+        max-width: 580px;
+    }
+}
+
+#scrolling-header {
+    color: #999;
+    font-size: 23px;
+    font-style: italic;
+    font: italic 23px @font-fancy;
+    line-height: 30px;
+    position: fixed;
+    top: 75px;
+    text-align: right;
+    width: 180px;
+}
Binary file static/media/diamond-square.monopic has changed
Binary file static/media/images/blog/2009/02/dj-playlist-sorting.png has changed
Binary file static/media/images/blog/2009/02/dj-playlist-unrated.png has changed
Binary file static/media/images/blog/2009/03/prompt-with-branch.png has changed
Binary file static/media/images/blog/2009/03/prompt-with-dirty.png has changed
Binary file static/media/images/blog/2009/03/prompt-without-branch.png has changed
Binary file static/media/images/blog/2009/03/terminal-colors.png has changed
Binary file static/media/images/blog/2009/08/branch-anon.png has changed
Binary file static/media/images/blog/2009/08/branch-base.png has changed
Binary file static/media/images/blog/2009/08/branch-bookmark.png has changed
Binary file static/media/images/blog/2009/08/branch-clone.png has changed
Binary file static/media/images/blog/2009/08/branch-named.png has changed
Binary file static/media/images/blog/2010/01/mercurial-vs-git.jpg has changed
Binary file static/media/images/blog/2010/02/hg-branching-1-after-merge.png has changed
Binary file static/media/images/blog/2010/02/hg-branching-1-needs-merge.png has changed
Binary file static/media/images/blog/2010/02/hg-branching-1-other.png has changed
Binary file static/media/images/blog/2010/02/hg-branching-1-start.png has changed
Binary file static/media/images/blog/2010/02/zsh-prompt-comments.png has changed
Binary file static/media/images/blog/2010/02/zsh-prompt.png has changed
Binary file static/media/images/blog/2010/05/default-stable-example.png has changed
Binary file static/media/images/blog/2010/06/translation-branches.png has changed
Binary file static/media/images/blog/2010/08/git-basics.png has changed
Binary file static/media/images/blog/2010/08/mercurial-basics.png has changed
Binary file static/media/images/blog/2010/08/mq-multiple.png has changed
Binary file static/media/images/blog/2010/08/mq-one.png has changed
Binary file static/media/images/blog/2010/08/mq-two.png has changed
Binary file static/media/images/blog/2010/08/mq-versioned.png has changed
Binary file static/media/images/blog/2010/09/rainbow.png has changed
Binary file static/media/images/blog/2010/09/vim.png has changed
Binary file static/media/images/blog/2011/05/rules-1-doxie.png has changed
Binary file static/media/images/blog/2011/05/rules-2-jotnot.png has changed
Binary file static/media/images/blog/2011/05/rules-3-ocr.png has changed
Binary file static/media/images/blog/2011/05/rules-4-clean.png has changed
Binary file static/media/images/blog/2012/07/caves-01-01.png has changed
Binary file static/media/images/blog/2012/07/caves-02-01.png has changed
Binary file static/media/images/blog/2012/07/caves-02-02.png has changed
Binary file static/media/images/blog/2012/07/caves-02-03.png has changed
Binary file static/media/images/blog/2012/07/caves-03-1-01.png has changed
Binary file static/media/images/blog/2012/07/caves-03-1-02.png has changed
Binary file static/media/images/blog/2012/07/caves-03-1-03.png has changed
Binary file static/media/images/blog/2012/07/caves-03-2-01.png has changed
Binary file static/media/images/blog/2012/07/caves-03-2-02.png has changed
Binary file static/media/images/blog/2012/07/caves-03-2-03.png has changed
Binary file static/media/images/blog/2012/07/caves-03-3-01.png has changed
Binary file static/media/images/blog/2012/07/caves-03-3-02.png has changed
Binary file static/media/images/blog/2012/07/caves-04-01.png has changed
Binary file static/media/images/blog/2012/07/caves-04-02.png has changed
Binary file static/media/images/blog/2012/07/caves-04-03.png has changed
Binary file static/media/images/blog/2012/07/caves-05-01.png has changed
Binary file static/media/images/blog/2012/07/caves-05-02.png has changed
Binary file static/media/images/blog/2012/07/caves-05-03.png has changed
Binary file static/media/images/blog/2012/07/caves-06-01.png has changed
Binary file static/media/images/blog/2012/07/caves-interlude-1-01.png has changed
Binary file static/media/images/blog/2012/07/caves-interlude-1-02.png has changed
Binary file static/media/images/blog/2012/10/caves-07-1-1.png has changed
Binary file static/media/images/blog/2012/10/caves-07-1-2.png has changed
Binary file static/media/images/blog/2012/10/kb-apple.jpg has changed
Binary file static/media/images/blog/2012/10/kb-caps.png has changed
Binary file static/media/images/blog/2012/10/kb-das.jpg has changed
Binary file static/media/images/blog/2012/10/kb-hex.png has changed
Binary file static/media/images/blog/2012/10/kb-hhkb.jpg has changed
Binary file static/media/images/blog/2012/10/kb-irc.png has changed
Binary file static/media/images/blog/2012/10/kb-key-overlaid.png has changed
Binary file static/media/images/blog/2012/10/kb-pck.png has changed
Binary file static/media/images/blog/2012/10/kb-realforce.jpg has changed
Binary file static/media/images/blog/2012/10/kb-size.jpg has changed
Binary file static/media/images/blog/2012/10/keychain-1.png has changed
Binary file static/media/images/blog/2012/10/keychain-2.png has changed
Binary file static/media/images/blog/2012/10/keychain-3.png has changed
Binary file static/media/images/blog/2012/10/mutt-attachments.png has changed
Binary file static/media/images/blog/2012/10/mutt-contacts-1.png has changed
Binary file static/media/images/blog/2012/10/mutt-index.png has changed
Binary file static/media/images/blog/2012/10/mutt-pager.png has changed
Binary file static/media/images/blog/2012/10/mutt-ready-to-send.png has changed
Binary file static/media/images/blog/2012/10/mutt-send-1.png has changed
Binary file static/media/images/blog/2012/10/mutt-urls.png has changed
Binary file static/media/images/blog/2012/10/what-the-mutt.png has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-01.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-02.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-03.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-04.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-05.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-06.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-07.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-08.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-09.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-10.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-11.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-12.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-13.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-14.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-15.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-16.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-17.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-18.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-19.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-20.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-21.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-22.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-23.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-24.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-25.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-26.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-27.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-28.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-29.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-30.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-31.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-32.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-33.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-34.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-35.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-36.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-37.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-38.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-39.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-40.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-41.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-42.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-43.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-44.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-45.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-46.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-47.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-48.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-a2540-49.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-01.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-02.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-03.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-04.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-05.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-06.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-07.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-08.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-09.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-10.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-11.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-12.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-13.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-14.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-15.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-16.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-17.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-18.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-19.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-20.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-21.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-22.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-23.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-24.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-25.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-26.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-27.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-28.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-29.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-30.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-31.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-32.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-33.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-34.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-35.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-36.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-37.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-38.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-39.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-40.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-41.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-42.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-43.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-44.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-45.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-46.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-47.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-48.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-49.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-50.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-51.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-52.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-53.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-54.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-55.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-56.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-57.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-58.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-59.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-60.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-61.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-62.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-63.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-64.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-65.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-66.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-67.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-68.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-69.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-70.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-71.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-72.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-73.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-74.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-75.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-76.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-77.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-78.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-79.jpg has changed
Binary file static/media/images/blog/2015/07/full/nat-geo-mc5350-80.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-01.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-02.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-03.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-04.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-05.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-06.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-07.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-08.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-09.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-10.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-11.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-12.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-13.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-14.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-15.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-16.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-17.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-18.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-19.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-20.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-21.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-22.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-23.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-24.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-25.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-26.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-27.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-28.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-29.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-30.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-31.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-32.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-33.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-34.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-35.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-36.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-37.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-38.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-39.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-40.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-41.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-42.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-43.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-44.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-45.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-46.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-47.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-48.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-a2540-49.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-01.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-02.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-03.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-04.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-05.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-06.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-07.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-08.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-09.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-10.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-11.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-12.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-13.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-14.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-15.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-16.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-17.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-18.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-19.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-20.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-21.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-22.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-23.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-24.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-25.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-26.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-27.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-28.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-29.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-30.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-31.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-32.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-33.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-34.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-35.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-36.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-37.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-38.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-39.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-40.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-41.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-42.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-43.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-44.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-45.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-46.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-47.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-48.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-49.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-50.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-51.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-52.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-53.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-54.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-55.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-56.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-57.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-58.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-59.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-60.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-61.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-62.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-63.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-64.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-65.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-66.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-67.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-68.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-69.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-70.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-71.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-72.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-73.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-74.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-75.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-76.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-77.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-78.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-79.jpg has changed
Binary file static/media/images/blog/2015/07/nat-geo-mc5350-80.jpg has changed
Binary file static/media/images/blog/2015/11/btd-s2-ggsteve-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s2-ggsteve.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-bob-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-bob.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-douche-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-douche.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-ggsteve-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-ggsteve.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-innuendo-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-innuendo.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-mouthnoises-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-mouthnoises.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-bob-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-bob.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-cringe-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-cringe.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-drugs-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-drugs.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-steve-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-steve.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-the-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-percentile-the.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-ruined-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-ruined.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-steve-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-steve.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-subjects-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-subjects.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-the-large.png has changed
Binary file static/media/images/blog/2015/11/btd-s3-the.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-bob-large.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-bob.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-gg-large.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-gg.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-rip__devil-large.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-rip__devil.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-ruined-large.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-ruined.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-steve-large.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-steve.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-the-large.png has changed
Binary file static/media/images/blog/2015/11/btd-ssp-the.png has changed
Binary file static/media/images/blog/2015/11/btd-volume-comparison-large.png has changed
Binary file static/media/images/blog/2015/11/btd-volume-comparison.png has changed
Binary file static/media/images/blog/2015/11/hlw-heknew-large.png has changed
Binary file static/media/images/blog/2015/11/hlw-heknew.png has changed
Binary file static/media/images/blog/2015/11/hlw-higg-large.png has changed
Binary file static/media/images/blog/2015/11/hlw-higg.png has changed
Binary file static/media/images/blog/2015/11/hlw-love-large.png has changed
Binary file static/media/images/blog/2015/11/hlw-love.png has changed
Binary file static/media/images/blog/2015/11/hlw-ripdevil-large.png has changed
Binary file static/media/images/blog/2015/11/hlw-ripdevil.png has changed
Binary file static/media/images/blog/2015/11/hlw-total-large.png has changed
Binary file static/media/images/blog/2015/11/hlw-total.png has changed
Binary file static/media/images/blog/2015/12/silt-initial.gif has changed
Binary file static/media/images/blog/2015/12/silt-later.gif has changed
Binary file static/media/images/blog/2016/08/aspect-flavor.png has changed
Binary file static/media/images/blog/2016/08/aspect-visible.png has changed
Binary file static/media/images/blog/2016/08/bad-tiling-ds.png has changed
Binary file static/media/images/blog/2016/08/good-tiling-ds.png has changed
Binary file static/media/images/blog/2016/08/silt-names.png has changed
Binary file static/media/images/blog/2016/08/silt1-inspect.png has changed
Binary file static/media/images/blog/2016/08/silt1-terrain.png has changed
Binary file static/media/images/blog/2016/08/silt2-inspect.png has changed
Binary file static/media/images/blog/2016/08/silt2-terrain.png has changed
Binary file static/media/images/blog/2016/09/loop-macro.jpg has changed
Binary file static/media/images/hr.png has changed
Binary file static/media/images/hrb.png has changed
Binary file static/media/images/projects/fuego/Fuego-4852.jpg has changed
Binary file static/media/images/projects/fuego/Fuego-4887.jpg has changed
Binary file static/media/images/projects/fuego/Fuego-4919.jpg has changed
Binary file static/media/images/projects/fuego/Fuego-4941.jpg has changed
Binary file static/media/images/projects/fuego/Fuego-4985.jpg has changed
Binary file static/media/images/projects/fuego/Fuego-5133.jpg has changed
Binary file static/media/images/projects/hg-prompt/prompt.png has changed
Binary file static/media/images/projects/lindyjam-com/lindyjamcom-splash.png has changed
Binary file static/media/images/projects/t/t-screenshot.png has changed
Binary file static/media/images/projects/women-in-water/alex-tele.jpg has changed
Binary file static/media/images/projects/women-in-water/alex-wide.jpg has changed
Binary file static/media/images/projects/women-in-water/anna-tele.jpg has changed
Binary file static/media/images/projects/women-in-water/anna-wide.jpg has changed
Binary file static/media/images/projects/women-in-water/erin-tele.jpg has changed
Binary file static/media/images/projects/women-in-water/erin-wide.jpg has changed
Binary file static/media/images/projects/women-in-water/leah-tele.jpg has changed
Binary file static/media/images/projects/women-in-water/leah-wide.jpg has changed
Binary file static/media/images/projects/women-in-water/lizza-tele.jpg has changed
Binary file static/media/images/projects/women-in-water/lizza-wide.jpg has changed
Binary file static/media/images/rhythm.png has changed
Binary file static/media/images/self.jpg has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/TrackballControls.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,606 @@
+
+/**
+ * @author Eberhard Graether / http://egraether.com/
+ * @author Mark Lundin 	/ http://mark-lundin.com
+ * @author Simone Manini / http://daron1337.github.io
+ * @author Luca Antiga 	/ http://lantiga.github.io
+ */
+
+THREE.TrackballControls = function ( object, domElement ) {
+
+	var _this = this;
+	var STATE = { NONE: - 1, ROTATE: 0, ZOOM: 1, PAN: 2, TOUCH_ROTATE: 3, TOUCH_ZOOM_PAN: 4 };
+
+	this.object = object;
+	this.domElement = ( domElement !== undefined ) ? domElement : document;
+
+	// API
+
+	this.enabled = true;
+
+	this.screen = { left: 0, top: 0, width: 0, height: 0 };
+
+	this.rotateSpeed = 1.0;
+	this.zoomSpeed = 1.2;
+	this.panSpeed = 0.3;
+
+	this.noRotate = false;
+	this.noZoom = false;
+	this.noPan = false;
+
+	this.staticMoving = false;
+	this.dynamicDampingFactor = 0.2;
+
+	this.minDistance = 0;
+	this.maxDistance = Infinity;
+
+	this.keys = [ 65 /*A*/, 83 /*S*/, 68 /*D*/ ];
+
+	// internals
+
+	this.target = new THREE.Vector3();
+
+	var EPS = 0.000001;
+
+	var lastPosition = new THREE.Vector3();
+
+	var _state = STATE.NONE,
+	_prevState = STATE.NONE,
+
+	_eye = new THREE.Vector3(),
+
+	_movePrev = new THREE.Vector2(),
+	_moveCurr = new THREE.Vector2(),
+
+	_lastAxis = new THREE.Vector3(),
+	_lastAngle = 0,
+
+	_zoomStart = new THREE.Vector2(),
+	_zoomEnd = new THREE.Vector2(),
+
+	_touchZoomDistanceStart = 0,
+	_touchZoomDistanceEnd = 0,
+
+	_panStart = new THREE.Vector2(),
+	_panEnd = new THREE.Vector2();
+
+	// for reset
+
+	this.target0 = this.target.clone();
+	this.position0 = this.object.position.clone();
+	this.up0 = this.object.up.clone();
+
+	// events
+
+	var changeEvent = { type: 'change' };
+	var startEvent = { type: 'start' };
+	var endEvent = { type: 'end' };
+
+
+	// methods
+
+	this.handleResize = function () {
+
+		if ( this.domElement === document ) {
+
+			this.screen.left = 0;
+			this.screen.top = 0;
+			this.screen.width = window.innerWidth;
+			this.screen.height = window.innerHeight;
+
+		} else {
+
+			var box = this.domElement.getBoundingClientRect();
+			// adjustments come from similar code in the jquery offset() function
+			var d = this.domElement.ownerDocument.documentElement;
+			this.screen.left = box.left + window.pageXOffset - d.clientLeft;
+			this.screen.top = box.top + window.pageYOffset - d.clientTop;
+			this.screen.width = box.width;
+			this.screen.height = box.height;
+
+		}
+
+	};
+
+	this.handleEvent = function ( event ) {
+
+		if ( typeof this[ event.type ] == 'function' ) {
+
+			this[ event.type ]( event );
+
+		}
+
+	};
+
+	var getMouseOnScreen = ( function () {
+
+		var vector = new THREE.Vector2();
+
+		return function getMouseOnScreen( pageX, pageY ) {
+
+			vector.set(
+				( pageX - _this.screen.left ) / _this.screen.width,
+				( pageY - _this.screen.top ) / _this.screen.height
+			);
+
+			return vector;
+
+		};
+
+	}() );
+
+	var getMouseOnCircle = ( function () {
+
+		var vector = new THREE.Vector2();
+
+		return function getMouseOnCircle( pageX, pageY ) {
+
+			vector.set(
+				( ( pageX - _this.screen.width * 0.5 - _this.screen.left ) / ( _this.screen.width * 0.5 ) ),
+				( ( _this.screen.height + 2 * ( _this.screen.top - pageY ) ) / _this.screen.width ) // screen.width intentional
+			);
+
+			return vector;
+
+		};
+
+	}() );
+
+	this.rotateCamera = ( function() {
+
+		var axis = new THREE.Vector3(),
+			quaternion = new THREE.Quaternion(),
+			eyeDirection = new THREE.Vector3(),
+			objectUpDirection = new THREE.Vector3(),
+			objectSidewaysDirection = new THREE.Vector3(),
+			moveDirection = new THREE.Vector3(),
+			angle;
+
+		return function rotateCamera() {
+
+			moveDirection.set( _moveCurr.x - _movePrev.x, _moveCurr.y - _movePrev.y, 0 );
+			angle = moveDirection.length();
+
+			if ( angle ) {
+
+				_eye.copy( _this.object.position ).sub( _this.target );
+
+				eyeDirection.copy( _eye ).normalize();
+				objectUpDirection.copy( _this.object.up ).normalize();
+				objectSidewaysDirection.crossVectors( objectUpDirection, eyeDirection ).normalize();
+
+				objectUpDirection.setLength( _moveCurr.y - _movePrev.y );
+				objectSidewaysDirection.setLength( _moveCurr.x - _movePrev.x );
+
+				moveDirection.copy( objectUpDirection.add( objectSidewaysDirection ) );
+
+				axis.crossVectors( moveDirection, _eye ).normalize();
+
+				angle *= _this.rotateSpeed;
+				quaternion.setFromAxisAngle( axis, angle );
+
+				_eye.applyQuaternion( quaternion );
+				_this.object.up.applyQuaternion( quaternion );
+
+				_lastAxis.copy( axis );
+				_lastAngle = angle;
+
+			} else if ( ! _this.staticMoving && _lastAngle ) {
+
+				_lastAngle *= Math.sqrt( 1.0 - _this.dynamicDampingFactor );
+				_eye.copy( _this.object.position ).sub( _this.target );
+				quaternion.setFromAxisAngle( _lastAxis, _lastAngle );
+				_eye.applyQuaternion( quaternion );
+				_this.object.up.applyQuaternion( quaternion );
+
+			}
+
+			_movePrev.copy( _moveCurr );
+
+		};
+
+	}() );
+
+
+	this.zoomCamera = function () {
+
+		var factor;
+
+		if ( _state === STATE.TOUCH_ZOOM_PAN ) {
+
+			factor = _touchZoomDistanceStart / _touchZoomDistanceEnd;
+			_touchZoomDistanceStart = _touchZoomDistanceEnd;
+			_eye.multiplyScalar( factor );
+
+		} else {
+
+			factor = 1.0 + ( _zoomEnd.y - _zoomStart.y ) * _this.zoomSpeed;
+
+			if ( factor !== 1.0 && factor > 0.0 ) {
+
+				_eye.multiplyScalar( factor );
+
+				if ( _this.staticMoving ) {
+
+					_zoomStart.copy( _zoomEnd );
+
+				} else {
+
+					_zoomStart.y += ( _zoomEnd.y - _zoomStart.y ) * this.dynamicDampingFactor;
+
+				}
+
+			}
+
+		}
+
+	};
+
+	this.panCamera = ( function() {
+
+		var mouseChange = new THREE.Vector2(),
+			objectUp = new THREE.Vector3(),
+			pan = new THREE.Vector3();
+
+		return function panCamera() {
+
+			mouseChange.copy( _panEnd ).sub( _panStart );
+
+			if ( mouseChange.lengthSq() ) {
+
+				mouseChange.multiplyScalar( _eye.length() * _this.panSpeed );
+
+				pan.copy( _eye ).cross( _this.object.up ).setLength( mouseChange.x );
+				pan.add( objectUp.copy( _this.object.up ).setLength( mouseChange.y ) );
+
+				_this.object.position.add( pan );
+				_this.target.add( pan );
+
+				if ( _this.staticMoving ) {
+
+					_panStart.copy( _panEnd );
+
+				} else {
+
+					_panStart.add( mouseChange.subVectors( _panEnd, _panStart ).multiplyScalar( _this.dynamicDampingFactor ) );
+
+				}
+
+			}
+
+		};
+
+	}() );
+
+	this.checkDistances = function () {
+
+		if ( ! _this.noZoom || ! _this.noPan ) {
+
+			if ( _eye.lengthSq() > _this.maxDistance * _this.maxDistance ) {
+
+				_this.object.position.addVectors( _this.target, _eye.setLength( _this.maxDistance ) );
+				_zoomStart.copy( _zoomEnd );
+
+			}
+
+			if ( _eye.lengthSq() < _this.minDistance * _this.minDistance ) {
+
+				_this.object.position.addVectors( _this.target, _eye.setLength( _this.minDistance ) );
+				_zoomStart.copy( _zoomEnd );
+
+			}
+
+		}
+
+	};
+
+	this.update = function () {
+
+		_eye.subVectors( _this.object.position, _this.target );
+
+		if ( ! _this.noRotate ) {
+
+			_this.rotateCamera();
+
+		}
+
+		if ( ! _this.noZoom ) {
+
+			_this.zoomCamera();
+
+		}
+
+		if ( ! _this.noPan ) {
+
+			_this.panCamera();
+
+		}
+
+		_this.object.position.addVectors( _this.target, _eye );
+
+		_this.checkDistances();
+
+		_this.object.lookAt( _this.target );
+
+		if ( lastPosition.distanceToSquared( _this.object.position ) > EPS ) {
+
+			_this.dispatchEvent( changeEvent );
+
+			lastPosition.copy( _this.object.position );
+
+		}
+
+	};
+
+	this.reset = function () {
+
+		_state = STATE.NONE;
+		_prevState = STATE.NONE;
+
+		_this.target.copy( _this.target0 );
+		_this.object.position.copy( _this.position0 );
+		_this.object.up.copy( _this.up0 );
+
+		_eye.subVectors( _this.object.position, _this.target );
+
+		_this.object.lookAt( _this.target );
+
+		_this.dispatchEvent( changeEvent );
+
+		lastPosition.copy( _this.object.position );
+
+	};
+
+	// listeners
+
+	function keydown( event ) {
+
+		if ( _this.enabled === false ) return;
+
+		_prevState = _state;
+
+		if ( _state !== STATE.NONE ) {
+
+			return;
+
+		} else if ( event.keyCode === _this.keys[ STATE.ROTATE ] && ! _this.noRotate ) {
+
+			_state = STATE.ROTATE;
+
+		} else if ( event.keyCode === _this.keys[ STATE.ZOOM ] && ! _this.noZoom ) {
+
+			_state = STATE.ZOOM;
+
+		} else if ( event.keyCode === _this.keys[ STATE.PAN ] && ! _this.noPan ) {
+
+			_state = STATE.PAN;
+
+		}
+
+	}
+
+	function keyup( event ) {
+
+		if ( _this.enabled === false ) return;
+
+		_state = _prevState;
+
+	}
+
+	function mousedown( event ) {
+
+		if ( _this.enabled === false ) return;
+
+		if ( _state === STATE.NONE ) {
+
+			_state = event.button;
+
+		}
+
+		if ( _state === STATE.ROTATE && ! _this.noRotate ) {
+
+			_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
+			_movePrev.copy( _moveCurr );
+
+		} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
+
+			_zoomStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
+			_zoomEnd.copy( _zoomStart );
+
+		} else if ( _state === STATE.PAN && ! _this.noPan ) {
+
+			_panStart.copy( getMouseOnScreen( event.pageX, event.pageY ) );
+			_panEnd.copy( _panStart );
+
+		}
+
+		document.addEventListener( 'mousemove', mousemove, false );
+		document.addEventListener( 'mouseup', mouseup, false );
+
+		_this.dispatchEvent( startEvent );
+
+	}
+
+	function mousemove( event ) {
+
+		if ( _this.enabled === false ) return;
+
+		if ( _state === STATE.ROTATE && ! _this.noRotate ) {
+
+			_movePrev.copy( _moveCurr );
+			_moveCurr.copy( getMouseOnCircle( event.pageX, event.pageY ) );
+
+		} else if ( _state === STATE.ZOOM && ! _this.noZoom ) {
+
+			_zoomEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
+
+		} else if ( _state === STATE.PAN && ! _this.noPan ) {
+
+			_panEnd.copy( getMouseOnScreen( event.pageX, event.pageY ) );
+
+		}
+
+	}
+
+	function mouseup( event ) {
+
+		if ( _this.enabled === false ) return;
+
+		_state = STATE.NONE;
+
+		document.removeEventListener( 'mousemove', mousemove );
+		document.removeEventListener( 'mouseup', mouseup );
+		_this.dispatchEvent( endEvent );
+
+	}
+
+	function mousewheel( event ) {
+
+		if ( _this.enabled === false ) return;
+
+		var delta = 0;
+
+		if ( event.wheelDelta ) {
+
+			// WebKit / Opera / Explorer 9
+
+			delta = event.wheelDelta / 40;
+
+		} else if ( event.detail ) {
+
+			// Firefox
+
+			delta = - event.detail / 3;
+
+		}
+
+		_zoomStart.y += delta * 0.01;
+		_this.dispatchEvent( startEvent );
+		_this.dispatchEvent( endEvent );
+
+	}
+
+	function touchstart( event ) {
+
+		if ( _this.enabled === false ) return;
+
+		switch ( event.touches.length ) {
+
+			case 1:
+				_state = STATE.TOUCH_ROTATE;
+				_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
+				_movePrev.copy( _moveCurr );
+				break;
+
+			default: // 2 or more
+				_state = STATE.TOUCH_ZOOM_PAN;
+				var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
+				var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
+				_touchZoomDistanceEnd = _touchZoomDistanceStart = Math.sqrt( dx * dx + dy * dy );
+
+				var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
+				var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
+				_panStart.copy( getMouseOnScreen( x, y ) );
+				_panEnd.copy( _panStart );
+				break;
+
+		}
+
+		_this.dispatchEvent( startEvent );
+
+	}
+
+	function touchmove( event ) {
+
+		if ( _this.enabled === false ) return;
+
+		switch ( event.touches.length ) {
+
+			case 1:
+				_movePrev.copy( _moveCurr );
+				_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
+				break;
+
+			default: // 2 or more
+				var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
+				var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
+				_touchZoomDistanceEnd = Math.sqrt( dx * dx + dy * dy );
+
+				var x = ( event.touches[ 0 ].pageX + event.touches[ 1 ].pageX ) / 2;
+				var y = ( event.touches[ 0 ].pageY + event.touches[ 1 ].pageY ) / 2;
+				_panEnd.copy( getMouseOnScreen( x, y ) );
+				break;
+
+		}
+
+	}
+
+	function touchend( event ) {
+
+		if ( _this.enabled === false ) return;
+
+		switch ( event.touches.length ) {
+
+			case 0:
+				_state = STATE.NONE;
+				break;
+
+			case 1:
+				_state = STATE.TOUCH_ROTATE;
+				_moveCurr.copy( getMouseOnCircle( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY ) );
+				_movePrev.copy( _moveCurr );
+				break;
+
+		}
+
+		_this.dispatchEvent( endEvent );
+
+	}
+
+	function contextmenu( event ) {
+
+		event.preventDefault();
+
+	}
+
+	this.dispose = function() {
+
+		this.domElement.removeEventListener( 'contextmenu', contextmenu, false );
+		this.domElement.removeEventListener( 'mousedown', mousedown, false );
+		this.domElement.removeEventListener( 'mousewheel', mousewheel, false );
+		this.domElement.removeEventListener( 'MozMousePixelScroll', mousewheel, false ); // firefox
+
+		this.domElement.removeEventListener( 'touchstart', touchstart, false );
+		this.domElement.removeEventListener( 'touchend', touchend, false );
+		this.domElement.removeEventListener( 'touchmove', touchmove, false );
+
+		document.removeEventListener( 'mousemove', mousemove, false );
+		document.removeEventListener( 'mouseup', mouseup, false );
+
+		window.removeEventListener( 'keydown', keydown, false );
+		window.removeEventListener( 'keyup', keyup, false );
+
+	};
+
+	this.domElement.addEventListener( 'contextmenu', contextmenu, false );
+	this.domElement.addEventListener( 'mousedown', mousedown, false );
+	this.domElement.addEventListener( 'mousewheel', mousewheel, false );
+	this.domElement.addEventListener( 'MozMousePixelScroll', mousewheel, false ); // firefox
+
+	this.domElement.addEventListener( 'touchstart', touchstart, false );
+	this.domElement.addEventListener( 'touchend', touchend, false );
+	this.domElement.addEventListener( 'touchmove', touchmove, false );
+
+	window.addEventListener( 'keydown', keydown, false );
+	window.addEventListener( 'keyup', keyup, false );
+
+	this.handleResize();
+
+	// force an update at start
+	this.update();
+
+};
+
+THREE.TrackballControls.prototype = Object.create( THREE.EventDispatcher.prototype );
+THREE.TrackballControls.prototype.constructor = THREE.TrackballControls;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/jquery.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,151 @@
+/*!
+ * jQuery JavaScript Library v1.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://docs.jquery.com/License
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Wed Jan 13 15:23:05 2010 -0500
+ */
+(function(A,w){function oa(){if(!c.isReady){try{s.documentElement.doScroll("left")}catch(a){setTimeout(oa,1);return}c.ready()}}function La(a,b){b.src?c.ajax({url:b.src,async:false,dataType:"script"}):c.globalEval(b.text||b.textContent||b.innerHTML||"");b.parentNode&&b.parentNode.removeChild(b)}function $(a,b,d,f,e,i){var j=a.length;if(typeof b==="object"){for(var o in b)$(a,o,b[o],f,e,d);return a}if(d!==w){f=!i&&f&&c.isFunction(d);for(o=0;o<j;o++)e(a[o],b,f?d.call(a[o],o,e(a[o],b)):d,i);return a}return j?
+e(a[0],b):null}function K(){return(new Date).getTime()}function aa(){return false}function ba(){return true}function pa(a,b,d){d[0].type=a;return c.event.handle.apply(b,d)}function qa(a){var b=true,d=[],f=[],e=arguments,i,j,o,p,n,t=c.extend({},c.data(this,"events").live);for(p in t){j=t[p];if(j.live===a.type||j.altLive&&c.inArray(a.type,j.altLive)>-1){i=j.data;i.beforeFilter&&i.beforeFilter[a.type]&&!i.beforeFilter[a.type](a)||f.push(j.selector)}else delete t[p]}i=c(a.target).closest(f,a.currentTarget);
+n=0;for(l=i.length;n<l;n++)for(p in t){j=t[p];o=i[n].elem;f=null;if(i[n].selector===j.selector){if(j.live==="mouseenter"||j.live==="mouseleave")f=c(a.relatedTarget).closest(j.selector)[0];if(!f||f!==o)d.push({elem:o,fn:j})}}n=0;for(l=d.length;n<l;n++){i=d[n];a.currentTarget=i.elem;a.data=i.fn.data;if(i.fn.apply(i.elem,e)===false){b=false;break}}return b}function ra(a,b){return["live",a,b.replace(/\./g,"`").replace(/ /g,"&")].join(".")}function sa(a){return!a||!a.parentNode||a.parentNode.nodeType===
+11}function ta(a,b){var d=0;b.each(function(){if(this.nodeName===(a[d]&&a[d].nodeName)){var f=c.data(a[d++]),e=c.data(this,f);if(f=f&&f.events){delete e.handle;e.events={};for(var i in f)for(var j in f[i])c.event.add(this,i,f[i][j],f[i][j].data)}}})}function ua(a,b,d){var f,e,i;if(a.length===1&&typeof a[0]==="string"&&a[0].length<512&&a[0].indexOf("<option")<0){e=true;if(i=c.fragments[a[0]])if(i!==1)f=i}if(!f){b=b&&b[0]?b[0].ownerDocument||b[0]:s;f=b.createDocumentFragment();c.clean(a,b,f,d)}if(e)c.fragments[a[0]]=
+i?f:1;return{fragment:f,cacheable:e}}function T(a){for(var b=0,d,f;(d=a[b])!=null;b++)if(!c.noData[d.nodeName.toLowerCase()]&&(f=d[H]))delete c.cache[f]}function L(a,b){var d={};c.each(va.concat.apply([],va.slice(0,b)),function(){d[this]=a});return d}function wa(a){return"scrollTo"in a&&a.document?a:a.nodeType===9?a.defaultView||a.parentWindow:false}var c=function(a,b){return new c.fn.init(a,b)},Ma=A.jQuery,Na=A.$,s=A.document,U,Oa=/^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,Pa=/^.[^:#\[\.,]*$/,Qa=/\S/,
+Ra=/^(\s|\u00A0)+|(\s|\u00A0)+$/g,Sa=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,P=navigator.userAgent,xa=false,Q=[],M,ca=Object.prototype.toString,da=Object.prototype.hasOwnProperty,ea=Array.prototype.push,R=Array.prototype.slice,V=Array.prototype.indexOf;c.fn=c.prototype={init:function(a,b){var d,f;if(!a)return this;if(a.nodeType){this.context=this[0]=a;this.length=1;return this}if(typeof a==="string")if((d=Oa.exec(a))&&(d[1]||!b))if(d[1]){f=b?b.ownerDocument||b:s;if(a=Sa.exec(a))if(c.isPlainObject(b)){a=[s.createElement(a[1])];
+c.fn.attr.call(a,b,true)}else a=[f.createElement(a[1])];else{a=ua([d[1]],[f]);a=(a.cacheable?a.fragment.cloneNode(true):a.fragment).childNodes}}else{if(b=s.getElementById(d[2])){if(b.id!==d[2])return U.find(a);this.length=1;this[0]=b}this.context=s;this.selector=a;return this}else if(!b&&/^\w+$/.test(a)){this.selector=a;this.context=s;a=s.getElementsByTagName(a)}else return!b||b.jquery?(b||U).find(a):c(b).find(a);else if(c.isFunction(a))return U.ready(a);if(a.selector!==w){this.selector=a.selector;
+this.context=a.context}return c.isArray(a)?this.setArray(a):c.makeArray(a,this)},selector:"",jquery:"1.4",length:0,size:function(){return this.length},toArray:function(){return R.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this.slice(a)[0]:this[a]},pushStack:function(a,b,d){a=c(a||null);a.prevObject=this;a.context=this.context;if(b==="find")a.selector=this.selector+(this.selector?" ":"")+d;else if(b)a.selector=this.selector+"."+b+"("+d+")";return a},setArray:function(a){this.length=
+0;ea.apply(this,a);return this},each:function(a,b){return c.each(this,a,b)},ready:function(a){c.bindReady();if(c.isReady)a.call(s,c);else Q&&Q.push(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(R.apply(this,arguments),"slice",R.call(arguments).join(","))},map:function(a){return this.pushStack(c.map(this,function(b,d){return a.call(b,d,b)}))},end:function(){return this.prevObject||
+c(null)},push:ea,sort:[].sort,splice:[].splice};c.fn.init.prototype=c.fn;c.extend=c.fn.extend=function(){var a=arguments[0]||{},b=1,d=arguments.length,f=false,e,i,j,o;if(typeof a==="boolean"){f=a;a=arguments[1]||{};b=2}if(typeof a!=="object"&&!c.isFunction(a))a={};if(d===b){a=this;--b}for(;b<d;b++)if((e=arguments[b])!=null)for(i in e){j=a[i];o=e[i];if(a!==o)if(f&&o&&(c.isPlainObject(o)||c.isArray(o))){j=j&&(c.isPlainObject(j)||c.isArray(j))?j:c.isArray(o)?[]:{};a[i]=c.extend(f,j,o)}else if(o!==w)a[i]=
+o}return a};c.extend({noConflict:function(a){A.$=Na;if(a)A.jQuery=Ma;return c},isReady:false,ready:function(){if(!c.isReady){if(!s.body)return setTimeout(c.ready,13);c.isReady=true;if(Q){for(var a,b=0;a=Q[b++];)a.call(s,c);Q=null}c.fn.triggerHandler&&c(s).triggerHandler("ready")}},bindReady:function(){if(!xa){xa=true;if(s.readyState==="complete")return c.ready();if(s.addEventListener){s.addEventListener("DOMContentLoaded",M,false);A.addEventListener("load",c.ready,false)}else if(s.attachEvent){s.attachEvent("onreadystatechange",
+M);A.attachEvent("onload",c.ready);var a=false;try{a=A.frameElement==null}catch(b){}s.documentElement.doScroll&&a&&oa()}}},isFunction:function(a){return ca.call(a)==="[object Function]"},isArray:function(a){return ca.call(a)==="[object Array]"},isPlainObject:function(a){if(!a||ca.call(a)!=="[object Object]"||a.nodeType||a.setInterval)return false;if(a.constructor&&!da.call(a,"constructor")&&!da.call(a.constructor.prototype,"isPrototypeOf"))return false;var b;for(b in a);return b===w||da.call(a,b)},
+isEmptyObject:function(a){for(var b in a)return false;return true},noop:function(){},globalEval:function(a){if(a&&Qa.test(a)){var b=s.getElementsByTagName("head")[0]||s.documentElement,d=s.createElement("script");d.type="text/javascript";if(c.support.scriptEval)d.appendChild(s.createTextNode(a));else d.text=a;b.insertBefore(d,b.firstChild);b.removeChild(d)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,b,d){var f,e=0,i=a.length,j=i===w||c.isFunction(a);
+if(d)if(j)for(f in a){if(b.apply(a[f],d)===false)break}else for(;e<i;){if(b.apply(a[e++],d)===false)break}else if(j)for(f in a){if(b.call(a[f],f,a[f])===false)break}else for(d=a[0];e<i&&b.call(d,e,d)!==false;d=a[++e]);return a},trim:function(a){return(a||"").replace(Ra,"")},makeArray:function(a,b){b=b||[];if(a!=null)a.length==null||typeof a==="string"||c.isFunction(a)||typeof a!=="function"&&a.setInterval?ea.call(b,a):c.merge(b,a);return b},inArray:function(a,b){if(b.indexOf)return b.indexOf(a);for(var d=
+0,f=b.length;d<f;d++)if(b[d]===a)return d;return-1},merge:function(a,b){var d=a.length,f=0;if(typeof b.length==="number")for(var e=b.length;f<e;f++)a[d++]=b[f];else for(;b[f]!==w;)a[d++]=b[f++];a.length=d;return a},grep:function(a,b,d){for(var f=[],e=0,i=a.length;e<i;e++)!d!==!b(a[e],e)&&f.push(a[e]);return f},map:function(a,b,d){for(var f=[],e,i=0,j=a.length;i<j;i++){e=b(a[i],i,d);if(e!=null)f[f.length]=e}return f.concat.apply([],f)},guid:1,proxy:function(a,b,d){if(arguments.length===2)if(typeof b===
+"string"){d=a;a=d[b];b=w}else if(b&&!c.isFunction(b)){d=b;b=w}if(!b&&a)b=function(){return a.apply(d||this,arguments)};if(a)b.guid=a.guid=a.guid||b.guid||c.guid++;return b},uaMatch:function(a){var b={browser:""};a=a.toLowerCase();if(/webkit/.test(a))b={browser:"webkit",version:/webkit[\/ ]([\w.]+)/};else if(/opera/.test(a))b={browser:"opera",version:/version/.test(a)?/version[\/ ]([\w.]+)/:/opera[\/ ]([\w.]+)/};else if(/msie/.test(a))b={browser:"msie",version:/msie ([\w.]+)/};else if(/mozilla/.test(a)&&
+!/compatible/.test(a))b={browser:"mozilla",version:/rv:([\w.]+)/};b.version=(b.version&&b.version.exec(a)||[0,"0"])[1];return b},browser:{}});P=c.uaMatch(P);if(P.browser){c.browser[P.browser]=true;c.browser.version=P.version}if(c.browser.webkit)c.browser.safari=true;if(V)c.inArray=function(a,b){return V.call(b,a)};U=c(s);if(s.addEventListener)M=function(){s.removeEventListener("DOMContentLoaded",M,false);c.ready()};else if(s.attachEvent)M=function(){if(s.readyState==="complete"){s.detachEvent("onreadystatechange",
+M);c.ready()}};if(V)c.inArray=function(a,b){return V.call(b,a)};(function(){c.support={};var a=s.documentElement,b=s.createElement("script"),d=s.createElement("div"),f="script"+K();d.style.display="none";d.innerHTML="   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";var e=d.getElementsByTagName("*"),i=d.getElementsByTagName("a")[0];if(!(!e||!e.length||!i)){c.support={leadingWhitespace:d.firstChild.nodeType===3,tbody:!d.getElementsByTagName("tbody").length,
+htmlSerialize:!!d.getElementsByTagName("link").length,style:/red/.test(i.getAttribute("style")),hrefNormalized:i.getAttribute("href")==="/a",opacity:/^0.55$/.test(i.style.opacity),cssFloat:!!i.style.cssFloat,checkOn:d.getElementsByTagName("input")[0].value==="on",optSelected:s.createElement("select").appendChild(s.createElement("option")).selected,scriptEval:false,noCloneEvent:true,boxModel:null};b.type="text/javascript";try{b.appendChild(s.createTextNode("window."+f+"=1;"))}catch(j){}a.insertBefore(b,
+a.firstChild);if(A[f]){c.support.scriptEval=true;delete A[f]}a.removeChild(b);if(d.attachEvent&&d.fireEvent){d.attachEvent("onclick",function o(){c.support.noCloneEvent=false;d.detachEvent("onclick",o)});d.cloneNode(true).fireEvent("onclick")}c(function(){var o=s.createElement("div");o.style.width=o.style.paddingLeft="1px";s.body.appendChild(o);c.boxModel=c.support.boxModel=o.offsetWidth===2;s.body.removeChild(o).style.display="none"});a=function(o){var p=s.createElement("div");o="on"+o;var n=o in
+p;if(!n){p.setAttribute(o,"return;");n=typeof p[o]==="function"}return n};c.support.submitBubbles=a("submit");c.support.changeBubbles=a("change");a=b=d=e=i=null}})();c.props={"for":"htmlFor","class":"className",readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",colspan:"colSpan",tabindex:"tabIndex",usemap:"useMap",frameborder:"frameBorder"};var H="jQuery"+K(),Ta=0,ya={},Ua={};c.extend({cache:{},expando:H,noData:{embed:true,object:true,applet:true},data:function(a,
+b,d){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?ya:a;var f=a[H],e=c.cache;if(!b&&!f)return null;f||(f=++Ta);if(typeof b==="object"){a[H]=f;e=e[f]=c.extend(true,{},b)}else e=e[f]?e[f]:typeof d==="undefined"?Ua:(e[f]={});if(d!==w){a[H]=f;e[b]=d}return typeof b==="string"?e[b]:e}},removeData:function(a,b){if(!(a.nodeName&&c.noData[a.nodeName.toLowerCase()])){a=a==A?ya:a;var d=a[H],f=c.cache,e=f[d];if(b){if(e){delete e[b];c.isEmptyObject(e)&&c.removeData(a)}}else{try{delete a[H]}catch(i){a.removeAttribute&&
+a.removeAttribute(H)}delete f[d]}}}});c.fn.extend({data:function(a,b){if(typeof a==="undefined"&&this.length)return c.data(this[0]);else if(typeof a==="object")return this.each(function(){c.data(this,a)});var d=a.split(".");d[1]=d[1]?"."+d[1]:"";if(b===w){var f=this.triggerHandler("getData"+d[1]+"!",[d[0]]);if(f===w&&this.length)f=c.data(this[0],a);return f===w&&d[1]?this.data(d[0]):f}else return this.trigger("setData"+d[1]+"!",[d[0],b]).each(function(){c.data(this,a,b)})},removeData:function(a){return this.each(function(){c.removeData(this,
+a)})}});c.extend({queue:function(a,b,d){if(a){b=(b||"fx")+"queue";var f=c.data(a,b);if(!d)return f||[];if(!f||c.isArray(d))f=c.data(a,b,c.makeArray(d));else f.push(d);return f}},dequeue:function(a,b){b=b||"fx";var d=c.queue(a,b),f=d.shift();if(f==="inprogress")f=d.shift();if(f){b==="fx"&&d.unshift("inprogress");f.call(a,function(){c.dequeue(a,b)})}}});c.fn.extend({queue:function(a,b){if(typeof a!=="string"){b=a;a="fx"}if(b===w)return c.queue(this[0],a);return this.each(function(){var d=c.queue(this,
+a,b);a==="fx"&&d[0]!=="inprogress"&&c.dequeue(this,a)})},dequeue:function(a){return this.each(function(){c.dequeue(this,a)})},delay:function(a,b){a=c.fx?c.fx.speeds[a]||a:a;b=b||"fx";return this.queue(b,function(){var d=this;setTimeout(function(){c.dequeue(d,b)},a)})},clearQueue:function(a){return this.queue(a||"fx",[])}});var za=/[\n\t]/g,fa=/\s+/,Va=/\r/g,Wa=/href|src|style/,Xa=/(button|input)/i,Ya=/(button|input|object|select|textarea)/i,Za=/^(a|area)$/i,Aa=/radio|checkbox/;c.fn.extend({attr:function(a,
+b){return $(this,a,b,true,c.attr)},removeAttr:function(a){return this.each(function(){c.attr(this,a,"");this.nodeType===1&&this.removeAttribute(a)})},addClass:function(a){if(c.isFunction(a))return this.each(function(p){var n=c(this);n.addClass(a.call(this,p,n.attr("class")))});if(a&&typeof a==="string")for(var b=(a||"").split(fa),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1)if(e.className)for(var i=" "+e.className+" ",j=0,o=b.length;j<o;j++){if(i.indexOf(" "+b[j]+" ")<0)e.className+=
+" "+b[j]}else e.className=a}return this},removeClass:function(a){if(c.isFunction(a))return this.each(function(p){var n=c(this);n.removeClass(a.call(this,p,n.attr("class")))});if(a&&typeof a==="string"||a===w)for(var b=(a||"").split(fa),d=0,f=this.length;d<f;d++){var e=this[d];if(e.nodeType===1&&e.className)if(a){for(var i=(" "+e.className+" ").replace(za," "),j=0,o=b.length;j<o;j++)i=i.replace(" "+b[j]+" "," ");e.className=i.substring(1,i.length-1)}else e.className=""}return this},toggleClass:function(a,
+b){var d=typeof a,f=typeof b==="boolean";if(c.isFunction(a))return this.each(function(e){var i=c(this);i.toggleClass(a.call(this,e,i.attr("class"),b),b)});return this.each(function(){if(d==="string")for(var e,i=0,j=c(this),o=b,p=a.split(fa);e=p[i++];){o=f?o:!j.hasClass(e);j[o?"addClass":"removeClass"](e)}else if(d==="undefined"||d==="boolean"){this.className&&c.data(this,"__className__",this.className);this.className=this.className||a===false?"":c.data(this,"__className__")||""}})},hasClass:function(a){a=
+" "+a+" ";for(var b=0,d=this.length;b<d;b++)if((" "+this[b].className+" ").replace(za," ").indexOf(a)>-1)return true;return false},val:function(a){if(a===w){var b=this[0];if(b){if(c.nodeName(b,"option"))return(b.attributes.value||{}).specified?b.value:b.text;if(c.nodeName(b,"select")){var d=b.selectedIndex,f=[],e=b.options;b=b.type==="select-one";if(d<0)return null;var i=b?d:0;for(d=b?d+1:e.length;i<d;i++){var j=e[i];if(j.selected){a=c(j).val();if(b)return a;f.push(a)}}return f}if(Aa.test(b.type)&&
+!c.support.checkOn)return b.getAttribute("value")===null?"on":b.value;return(b.value||"").replace(Va,"")}return w}var o=c.isFunction(a);return this.each(function(p){var n=c(this),t=a;if(this.nodeType===1){if(o)t=a.call(this,p,n.val());if(typeof t==="number")t+="";if(c.isArray(t)&&Aa.test(this.type))this.checked=c.inArray(n.val(),t)>=0;else if(c.nodeName(this,"select")){var z=c.makeArray(t);c("option",this).each(function(){this.selected=c.inArray(c(this).val(),z)>=0});if(!z.length)this.selectedIndex=
+-1}else this.value=t}})}});c.extend({attrFn:{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true},attr:function(a,b,d,f){if(!a||a.nodeType===3||a.nodeType===8)return w;if(f&&b in c.attrFn)return c(a)[b](d);f=a.nodeType!==1||!c.isXMLDoc(a);var e=d!==w;b=f&&c.props[b]||b;if(a.nodeType===1){var i=Wa.test(b);if(b in a&&f&&!i){if(e){if(b==="type"&&Xa.test(a.nodeName)&&a.parentNode)throw"type property can't be changed";a[b]=d}if(c.nodeName(a,"form")&&a.getAttributeNode(b))return a.getAttributeNode(b).nodeValue;
+if(b==="tabIndex")return(b=a.getAttributeNode("tabIndex"))&&b.specified?b.value:Ya.test(a.nodeName)||Za.test(a.nodeName)&&a.href?0:w;return a[b]}if(!c.support.style&&f&&b==="style"){if(e)a.style.cssText=""+d;return a.style.cssText}e&&a.setAttribute(b,""+d);a=!c.support.hrefNormalized&&f&&i?a.getAttribute(b,2):a.getAttribute(b);return a===null?w:a}return c.style(a,b,d)}});var $a=function(a){return a.replace(/[^\w\s\.\|`]/g,function(b){return"\\"+b})};c.event={add:function(a,b,d,f){if(!(a.nodeType===
+3||a.nodeType===8)){if(a.setInterval&&a!==A&&!a.frameElement)a=A;if(!d.guid)d.guid=c.guid++;if(f!==w){d=c.proxy(d);d.data=f}var e=c.data(a,"events")||c.data(a,"events",{}),i=c.data(a,"handle"),j;if(!i){j=function(){return typeof c!=="undefined"&&!c.event.triggered?c.event.handle.apply(j.elem,arguments):w};i=c.data(a,"handle",j)}if(i){i.elem=a;b=b.split(/\s+/);for(var o,p=0;o=b[p++];){var n=o.split(".");o=n.shift();d.type=n.slice(0).sort().join(".");var t=e[o],z=this.special[o]||{};if(!t){t=e[o]={};
+if(!z.setup||z.setup.call(a,f,n,d)===false)if(a.addEventListener)a.addEventListener(o,i,false);else a.attachEvent&&a.attachEvent("on"+o,i)}if(z.add)if((n=z.add.call(a,d,f,n,t))&&c.isFunction(n)){n.guid=n.guid||d.guid;d=n}t[d.guid]=d;this.global[o]=true}a=null}}},global:{},remove:function(a,b,d){if(!(a.nodeType===3||a.nodeType===8)){var f=c.data(a,"events"),e,i,j;if(f){if(b===w||typeof b==="string"&&b.charAt(0)===".")for(i in f)this.remove(a,i+(b||""));else{if(b.type){d=b.handler;b=b.type}b=b.split(/\s+/);
+for(var o=0;i=b[o++];){var p=i.split(".");i=p.shift();var n=!p.length,t=c.map(p.slice(0).sort(),$a);t=new RegExp("(^|\\.)"+t.join("\\.(?:.*\\.)?")+"(\\.|$)");var z=this.special[i]||{};if(f[i]){if(d){j=f[i][d.guid];delete f[i][d.guid]}else for(var B in f[i])if(n||t.test(f[i][B].type))delete f[i][B];z.remove&&z.remove.call(a,p,j);for(e in f[i])break;if(!e){if(!z.teardown||z.teardown.call(a,p)===false)if(a.removeEventListener)a.removeEventListener(i,c.data(a,"handle"),false);else a.detachEvent&&a.detachEvent("on"+
+i,c.data(a,"handle"));e=null;delete f[i]}}}}for(e in f)break;if(!e){if(B=c.data(a,"handle"))B.elem=null;c.removeData(a,"events");c.removeData(a,"handle")}}}},trigger:function(a,b,d,f){var e=a.type||a;if(!f){a=typeof a==="object"?a[H]?a:c.extend(c.Event(e),a):c.Event(e);if(e.indexOf("!")>=0){a.type=e=e.slice(0,-1);a.exclusive=true}if(!d){a.stopPropagation();this.global[e]&&c.each(c.cache,function(){this.events&&this.events[e]&&c.event.trigger(a,b,this.handle.elem)})}if(!d||d.nodeType===3||d.nodeType===
+8)return w;a.result=w;a.target=d;b=c.makeArray(b);b.unshift(a)}a.currentTarget=d;var i=c.data(d,"handle");i&&i.apply(d,b);var j,o;try{if(!(d&&d.nodeName&&c.noData[d.nodeName.toLowerCase()])){j=d[e];o=d["on"+e]}}catch(p){}i=c.nodeName(d,"a")&&e==="click";if(!f&&j&&!a.isDefaultPrevented()&&!i){this.triggered=true;try{d[e]()}catch(n){}}else if(o&&d["on"+e].apply(d,b)===false)a.result=false;this.triggered=false;if(!a.isPropagationStopped())(d=d.parentNode||d.ownerDocument)&&c.event.trigger(a,b,d,true)},
+handle:function(a){var b,d;a=arguments[0]=c.event.fix(a||A.event);a.currentTarget=this;d=a.type.split(".");a.type=d.shift();b=!d.length&&!a.exclusive;var f=new RegExp("(^|\\.)"+d.slice(0).sort().join("\\.(?:.*\\.)?")+"(\\.|$)");d=(c.data(this,"events")||{})[a.type];for(var e in d){var i=d[e];if(b||f.test(i.type)){a.handler=i;a.data=i.data;i=i.apply(this,arguments);if(i!==w){a.result=i;if(i===false){a.preventDefault();a.stopPropagation()}}if(a.isImmediatePropagationStopped())break}}return a.result},
+props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(a){if(a[H])return a;var b=a;a=c.Event(b);for(var d=this.props.length,f;d;){f=this.props[--d];a[f]=b[f]}if(!a.target)a.target=a.srcElement||
+s;if(a.target.nodeType===3)a.target=a.target.parentNode;if(!a.relatedTarget&&a.fromElement)a.relatedTarget=a.fromElement===a.target?a.toElement:a.fromElement;if(a.pageX==null&&a.clientX!=null){b=s.documentElement;d=s.body;a.pageX=a.clientX+(b&&b.scrollLeft||d&&d.scrollLeft||0)-(b&&b.clientLeft||d&&d.clientLeft||0);a.pageY=a.clientY+(b&&b.scrollTop||d&&d.scrollTop||0)-(b&&b.clientTop||d&&d.clientTop||0)}if(!a.which&&(a.charCode||a.charCode===0?a.charCode:a.keyCode))a.which=a.charCode||a.keyCode;if(!a.metaKey&&
+a.ctrlKey)a.metaKey=a.ctrlKey;if(!a.which&&a.button!==w)a.which=a.button&1?1:a.button&2?3:a.button&4?2:0;return a},guid:1E8,proxy:c.proxy,special:{ready:{setup:c.bindReady,teardown:c.noop},live:{add:function(a,b){c.extend(a,b||{});a.guid+=b.selector+b.live;c.event.add(this,b.live,qa,b)},remove:function(a){if(a.length){var b=0,d=new RegExp("(^|\\.)"+a[0]+"(\\.|$)");c.each(c.data(this,"events").live||{},function(){d.test(this.type)&&b++});b<1&&c.event.remove(this,a[0],qa)}},special:{}},beforeunload:{setup:function(a,
+b,d){if(this.setInterval)this.onbeforeunload=d;return false},teardown:function(a,b){if(this.onbeforeunload===b)this.onbeforeunload=null}}}};c.Event=function(a){if(!this.preventDefault)return new c.Event(a);if(a&&a.type){this.originalEvent=a;this.type=a.type}else this.type=a;this.timeStamp=K();this[H]=true};c.Event.prototype={preventDefault:function(){this.isDefaultPrevented=ba;var a=this.originalEvent;if(a){a.preventDefault&&a.preventDefault();a.returnValue=false}},stopPropagation:function(){this.isPropagationStopped=
+ba;var a=this.originalEvent;if(a){a.stopPropagation&&a.stopPropagation();a.cancelBubble=true}},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=ba;this.stopPropagation()},isDefaultPrevented:aa,isPropagationStopped:aa,isImmediatePropagationStopped:aa};var Ba=function(a){for(var b=a.relatedTarget;b&&b!==this;)try{b=b.parentNode}catch(d){break}if(b!==this){a.type=a.data;c.event.handle.apply(this,arguments)}},Ca=function(a){a.type=a.data;c.event.handle.apply(this,arguments)};c.each({mouseenter:"mouseover",
+mouseleave:"mouseout"},function(a,b){c.event.special[a]={setup:function(d){c.event.add(this,b,d&&d.selector?Ca:Ba,a)},teardown:function(d){c.event.remove(this,b,d&&d.selector?Ca:Ba)}}});if(!c.support.submitBubbles)c.event.special.submit={setup:function(a,b,d){if(this.nodeName.toLowerCase()!=="form"){c.event.add(this,"click.specialSubmit."+d.guid,function(f){var e=f.target,i=e.type;if((i==="submit"||i==="image")&&c(e).closest("form").length)return pa("submit",this,arguments)});c.event.add(this,"keypress.specialSubmit."+
+d.guid,function(f){var e=f.target,i=e.type;if((i==="text"||i==="password")&&c(e).closest("form").length&&f.keyCode===13)return pa("submit",this,arguments)})}else return false},remove:function(a,b){c.event.remove(this,"click.specialSubmit"+(b?"."+b.guid:""));c.event.remove(this,"keypress.specialSubmit"+(b?"."+b.guid:""))}};if(!c.support.changeBubbles){var ga=/textarea|input|select/i;function Da(a){var b=a.type,d=a.value;if(b==="radio"||b==="checkbox")d=a.checked;else if(b==="select-multiple")d=a.selectedIndex>
+-1?c.map(a.options,function(f){return f.selected}).join("-"):"";else if(a.nodeName.toLowerCase()==="select")d=a.selectedIndex;return d}function ha(a,b){var d=a.target,f,e;if(!(!ga.test(d.nodeName)||d.readOnly)){f=c.data(d,"_change_data");e=Da(d);if(e!==f){if(a.type!=="focusout"||d.type!=="radio")c.data(d,"_change_data",e);if(d.type!=="select"&&(f!=null||e)){a.type="change";return c.event.trigger(a,b,this)}}}}c.event.special.change={filters:{focusout:ha,click:function(a){var b=a.target,d=b.type;if(d===
+"radio"||d==="checkbox"||b.nodeName.toLowerCase()==="select")return ha.call(this,a)},keydown:function(a){var b=a.target,d=b.type;if(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(d==="checkbox"||d==="radio")||d==="select-multiple")return ha.call(this,a)},beforeactivate:function(a){a=a.target;a.nodeName.toLowerCase()==="input"&&a.type==="radio"&&c.data(a,"_change_data",Da(a))}},setup:function(a,b,d){for(var f in W)c.event.add(this,f+".specialChange."+d.guid,W[f]);return ga.test(this.nodeName)},
+remove:function(a,b){for(var d in W)c.event.remove(this,d+".specialChange"+(b?"."+b.guid:""),W[d]);return ga.test(this.nodeName)}};var W=c.event.special.change.filters}s.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(f){f=c.event.fix(f);f.type=b;return c.event.handle.call(this,f)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)}}});c.each(["bind","one"],function(a,b){c.fn[b]=function(d,
+f,e){if(typeof d==="object"){for(var i in d)this[b](i,f,d[i],e);return this}if(c.isFunction(f)){thisObject=e;e=f;f=w}var j=b==="one"?c.proxy(e,function(o){c(this).unbind(o,j);return e.apply(this,arguments)}):e;return d==="unload"&&b!=="one"?this.one(d,f,e,thisObject):this.each(function(){c.event.add(this,d,j,f)})}});c.fn.extend({unbind:function(a,b){if(typeof a==="object"&&!a.preventDefault){for(var d in a)this.unbind(d,a[d]);return this}return this.each(function(){c.event.remove(this,a,b)})},trigger:function(a,
+b){return this.each(function(){c.event.trigger(a,b,this)})},triggerHandler:function(a,b){if(this[0]){a=c.Event(a);a.preventDefault();a.stopPropagation();c.event.trigger(a,b,this[0]);return a.result}},toggle:function(a){for(var b=arguments,d=1;d<b.length;)c.proxy(a,b[d++]);return this.click(c.proxy(a,function(f){var e=(c.data(this,"lastToggle"+a.guid)||0)%d;c.data(this,"lastToggle"+a.guid,e+1);f.preventDefault();return b[e].apply(this,arguments)||false}))},hover:function(a,b){return this.mouseenter(a).mouseleave(b||
+a)},live:function(a,b,d){if(c.isFunction(b)){d=b;b=w}c(this.context).bind(ra(a,this.selector),{data:b,selector:this.selector,live:a},d);return this},die:function(a,b){c(this.context).unbind(ra(a,this.selector),b?{guid:b.guid+this.selector+a}:null);return this}});c.each("blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error".split(" "),function(a,b){c.fn[b]=function(d){return d?
+this.bind(b,d):this.trigger(b)};if(c.attrFn)c.attrFn[b]=true});A.attachEvent&&!A.addEventListener&&A.attachEvent("onunload",function(){for(var a in c.cache)if(c.cache[a].handle)try{c.event.remove(c.cache[a].handle.elem)}catch(b){}});(function(){function a(g){for(var h="",k,m=0;g[m];m++){k=g[m];if(k.nodeType===3||k.nodeType===4)h+=k.nodeValue;else if(k.nodeType!==8)h+=a(k.childNodes)}return h}function b(g,h,k,m,r,q){r=0;for(var v=m.length;r<v;r++){var u=m[r];if(u){u=u[g];for(var y=false;u;){if(u.sizcache===
+k){y=m[u.sizset];break}if(u.nodeType===1&&!q){u.sizcache=k;u.sizset=r}if(u.nodeName.toLowerCase()===h){y=u;break}u=u[g]}m[r]=y}}}function d(g,h,k,m,r,q){r=0;for(var v=m.length;r<v;r++){var u=m[r];if(u){u=u[g];for(var y=false;u;){if(u.sizcache===k){y=m[u.sizset];break}if(u.nodeType===1){if(!q){u.sizcache=k;u.sizset=r}if(typeof h!=="string"){if(u===h){y=true;break}}else if(p.filter(h,[u]).length>0){y=u;break}}u=u[g]}m[r]=y}}}var f=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+e=0,i=Object.prototype.toString,j=false,o=true;[0,0].sort(function(){o=false;return 0});var p=function(g,h,k,m){k=k||[];var r=h=h||s;if(h.nodeType!==1&&h.nodeType!==9)return[];if(!g||typeof g!=="string")return k;for(var q=[],v,u,y,S,I=true,N=x(h),J=g;(f.exec(""),v=f.exec(J))!==null;){J=v[3];q.push(v[1]);if(v[2]){S=v[3];break}}if(q.length>1&&t.exec(g))if(q.length===2&&n.relative[q[0]])u=ia(q[0]+q[1],h);else for(u=n.relative[q[0]]?[h]:p(q.shift(),h);q.length;){g=q.shift();if(n.relative[g])g+=q.shift();
+u=ia(g,u)}else{if(!m&&q.length>1&&h.nodeType===9&&!N&&n.match.ID.test(q[0])&&!n.match.ID.test(q[q.length-1])){v=p.find(q.shift(),h,N);h=v.expr?p.filter(v.expr,v.set)[0]:v.set[0]}if(h){v=m?{expr:q.pop(),set:B(m)}:p.find(q.pop(),q.length===1&&(q[0]==="~"||q[0]==="+")&&h.parentNode?h.parentNode:h,N);u=v.expr?p.filter(v.expr,v.set):v.set;if(q.length>0)y=B(u);else I=false;for(;q.length;){var E=q.pop();v=E;if(n.relative[E])v=q.pop();else E="";if(v==null)v=h;n.relative[E](y,v,N)}}else y=[]}y||(y=u);if(!y)throw"Syntax error, unrecognized expression: "+
+(E||g);if(i.call(y)==="[object Array]")if(I)if(h&&h.nodeType===1)for(g=0;y[g]!=null;g++){if(y[g]&&(y[g]===true||y[g].nodeType===1&&F(h,y[g])))k.push(u[g])}else for(g=0;y[g]!=null;g++)y[g]&&y[g].nodeType===1&&k.push(u[g]);else k.push.apply(k,y);else B(y,k);if(S){p(S,r,k,m);p.uniqueSort(k)}return k};p.uniqueSort=function(g){if(D){j=o;g.sort(D);if(j)for(var h=1;h<g.length;h++)g[h]===g[h-1]&&g.splice(h--,1)}return g};p.matches=function(g,h){return p(g,null,null,h)};p.find=function(g,h,k){var m,r;if(!g)return[];
+for(var q=0,v=n.order.length;q<v;q++){var u=n.order[q];if(r=n.leftMatch[u].exec(g)){var y=r[1];r.splice(1,1);if(y.substr(y.length-1)!=="\\"){r[1]=(r[1]||"").replace(/\\/g,"");m=n.find[u](r,h,k);if(m!=null){g=g.replace(n.match[u],"");break}}}}m||(m=h.getElementsByTagName("*"));return{set:m,expr:g}};p.filter=function(g,h,k,m){for(var r=g,q=[],v=h,u,y,S=h&&h[0]&&x(h[0]);g&&h.length;){for(var I in n.filter)if((u=n.leftMatch[I].exec(g))!=null&&u[2]){var N=n.filter[I],J,E;E=u[1];y=false;u.splice(1,1);if(E.substr(E.length-
+1)!=="\\"){if(v===q)q=[];if(n.preFilter[I])if(u=n.preFilter[I](u,v,k,q,m,S)){if(u===true)continue}else y=J=true;if(u)for(var X=0;(E=v[X])!=null;X++)if(E){J=N(E,u,X,v);var Ea=m^!!J;if(k&&J!=null)if(Ea)y=true;else v[X]=false;else if(Ea){q.push(E);y=true}}if(J!==w){k||(v=q);g=g.replace(n.match[I],"");if(!y)return[];break}}}if(g===r)if(y==null)throw"Syntax error, unrecognized expression: "+g;else break;r=g}return v};var n=p.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
+CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(g){return g.getAttribute("href")}},
+relative:{"+":function(g,h){var k=typeof h==="string",m=k&&!/\W/.test(h);k=k&&!m;if(m)h=h.toLowerCase();m=0;for(var r=g.length,q;m<r;m++)if(q=g[m]){for(;(q=q.previousSibling)&&q.nodeType!==1;);g[m]=k||q&&q.nodeName.toLowerCase()===h?q||false:q===h}k&&p.filter(h,g,true)},">":function(g,h){var k=typeof h==="string";if(k&&!/\W/.test(h)){h=h.toLowerCase();for(var m=0,r=g.length;m<r;m++){var q=g[m];if(q){k=q.parentNode;g[m]=k.nodeName.toLowerCase()===h?k:false}}}else{m=0;for(r=g.length;m<r;m++)if(q=g[m])g[m]=
+k?q.parentNode:q.parentNode===h;k&&p.filter(h,g,true)}},"":function(g,h,k){var m=e++,r=d;if(typeof h==="string"&&!/\W/.test(h)){var q=h=h.toLowerCase();r=b}r("parentNode",h,m,g,q,k)},"~":function(g,h,k){var m=e++,r=d;if(typeof h==="string"&&!/\W/.test(h)){var q=h=h.toLowerCase();r=b}r("previousSibling",h,m,g,q,k)}},find:{ID:function(g,h,k){if(typeof h.getElementById!=="undefined"&&!k)return(g=h.getElementById(g[1]))?[g]:[]},NAME:function(g,h){if(typeof h.getElementsByName!=="undefined"){var k=[];
+h=h.getElementsByName(g[1]);for(var m=0,r=h.length;m<r;m++)h[m].getAttribute("name")===g[1]&&k.push(h[m]);return k.length===0?null:k}},TAG:function(g,h){return h.getElementsByTagName(g[1])}},preFilter:{CLASS:function(g,h,k,m,r,q){g=" "+g[1].replace(/\\/g,"")+" ";if(q)return g;q=0;for(var v;(v=h[q])!=null;q++)if(v)if(r^(v.className&&(" "+v.className+" ").replace(/[\t\n]/g," ").indexOf(g)>=0))k||m.push(v);else if(k)h[q]=false;return false},ID:function(g){return g[1].replace(/\\/g,"")},TAG:function(g){return g[1].toLowerCase()},
+CHILD:function(g){if(g[1]==="nth"){var h=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(g[2]==="even"&&"2n"||g[2]==="odd"&&"2n+1"||!/\D/.test(g[2])&&"0n+"+g[2]||g[2]);g[2]=h[1]+(h[2]||1)-0;g[3]=h[3]-0}g[0]=e++;return g},ATTR:function(g,h,k,m,r,q){h=g[1].replace(/\\/g,"");if(!q&&n.attrMap[h])g[1]=n.attrMap[h];if(g[2]==="~=")g[4]=" "+g[4]+" ";return g},PSEUDO:function(g,h,k,m,r){if(g[1]==="not")if((f.exec(g[3])||"").length>1||/^\w/.test(g[3]))g[3]=p(g[3],null,null,h);else{g=p.filter(g[3],h,k,true^r);k||m.push.apply(m,
+g);return false}else if(n.match.POS.test(g[0])||n.match.CHILD.test(g[0]))return true;return g},POS:function(g){g.unshift(true);return g}},filters:{enabled:function(g){return g.disabled===false&&g.type!=="hidden"},disabled:function(g){return g.disabled===true},checked:function(g){return g.checked===true},selected:function(g){return g.selected===true},parent:function(g){return!!g.firstChild},empty:function(g){return!g.firstChild},has:function(g,h,k){return!!p(k[3],g).length},header:function(g){return/h\d/i.test(g.nodeName)},
+text:function(g){return"text"===g.type},radio:function(g){return"radio"===g.type},checkbox:function(g){return"checkbox"===g.type},file:function(g){return"file"===g.type},password:function(g){return"password"===g.type},submit:function(g){return"submit"===g.type},image:function(g){return"image"===g.type},reset:function(g){return"reset"===g.type},button:function(g){return"button"===g.type||g.nodeName.toLowerCase()==="button"},input:function(g){return/input|select|textarea|button/i.test(g.nodeName)}},
+setFilters:{first:function(g,h){return h===0},last:function(g,h,k,m){return h===m.length-1},even:function(g,h){return h%2===0},odd:function(g,h){return h%2===1},lt:function(g,h,k){return h<k[3]-0},gt:function(g,h,k){return h>k[3]-0},nth:function(g,h,k){return k[3]-0===h},eq:function(g,h,k){return k[3]-0===h}},filter:{PSEUDO:function(g,h,k,m){var r=h[1],q=n.filters[r];if(q)return q(g,k,h,m);else if(r==="contains")return(g.textContent||g.innerText||a([g])||"").indexOf(h[3])>=0;else if(r==="not"){h=
+h[3];k=0;for(m=h.length;k<m;k++)if(h[k]===g)return false;return true}else throw"Syntax error, unrecognized expression: "+r;},CHILD:function(g,h){var k=h[1],m=g;switch(k){case "only":case "first":for(;m=m.previousSibling;)if(m.nodeType===1)return false;if(k==="first")return true;m=g;case "last":for(;m=m.nextSibling;)if(m.nodeType===1)return false;return true;case "nth":k=h[2];var r=h[3];if(k===1&&r===0)return true;h=h[0];var q=g.parentNode;if(q&&(q.sizcache!==h||!g.nodeIndex)){var v=0;for(m=q.firstChild;m;m=
+m.nextSibling)if(m.nodeType===1)m.nodeIndex=++v;q.sizcache=h}g=g.nodeIndex-r;return k===0?g===0:g%k===0&&g/k>=0}},ID:function(g,h){return g.nodeType===1&&g.getAttribute("id")===h},TAG:function(g,h){return h==="*"&&g.nodeType===1||g.nodeName.toLowerCase()===h},CLASS:function(g,h){return(" "+(g.className||g.getAttribute("class"))+" ").indexOf(h)>-1},ATTR:function(g,h){var k=h[1];g=n.attrHandle[k]?n.attrHandle[k](g):g[k]!=null?g[k]:g.getAttribute(k);k=g+"";var m=h[2];h=h[4];return g==null?m==="!=":m===
+"="?k===h:m==="*="?k.indexOf(h)>=0:m==="~="?(" "+k+" ").indexOf(h)>=0:!h?k&&g!==false:m==="!="?k!==h:m==="^="?k.indexOf(h)===0:m==="$="?k.substr(k.length-h.length)===h:m==="|="?k===h||k.substr(0,h.length+1)===h+"-":false},POS:function(g,h,k,m){var r=n.setFilters[h[2]];if(r)return r(g,k,h,m)}}},t=n.match.POS;for(var z in n.match){n.match[z]=new RegExp(n.match[z].source+/(?![^\[]*\])(?![^\(]*\))/.source);n.leftMatch[z]=new RegExp(/(^(?:.|\r|\n)*?)/.source+n.match[z].source.replace(/\\(\d+)/g,function(g,
+h){return"\\"+(h-0+1)}))}var B=function(g,h){g=Array.prototype.slice.call(g,0);if(h){h.push.apply(h,g);return h}return g};try{Array.prototype.slice.call(s.documentElement.childNodes,0)}catch(C){B=function(g,h){h=h||[];if(i.call(g)==="[object Array]")Array.prototype.push.apply(h,g);else if(typeof g.length==="number")for(var k=0,m=g.length;k<m;k++)h.push(g[k]);else for(k=0;g[k];k++)h.push(g[k]);return h}}var D;if(s.documentElement.compareDocumentPosition)D=function(g,h){if(!g.compareDocumentPosition||
+!h.compareDocumentPosition){if(g==h)j=true;return g.compareDocumentPosition?-1:1}g=g.compareDocumentPosition(h)&4?-1:g===h?0:1;if(g===0)j=true;return g};else if("sourceIndex"in s.documentElement)D=function(g,h){if(!g.sourceIndex||!h.sourceIndex){if(g==h)j=true;return g.sourceIndex?-1:1}g=g.sourceIndex-h.sourceIndex;if(g===0)j=true;return g};else if(s.createRange)D=function(g,h){if(!g.ownerDocument||!h.ownerDocument){if(g==h)j=true;return g.ownerDocument?-1:1}var k=g.ownerDocument.createRange(),m=
+h.ownerDocument.createRange();k.setStart(g,0);k.setEnd(g,0);m.setStart(h,0);m.setEnd(h,0);g=k.compareBoundaryPoints(Range.START_TO_END,m);if(g===0)j=true;return g};(function(){var g=s.createElement("div"),h="script"+(new Date).getTime();g.innerHTML="<a name='"+h+"'/>";var k=s.documentElement;k.insertBefore(g,k.firstChild);if(s.getElementById(h)){n.find.ID=function(m,r,q){if(typeof r.getElementById!=="undefined"&&!q)return(r=r.getElementById(m[1]))?r.id===m[1]||typeof r.getAttributeNode!=="undefined"&&
+r.getAttributeNode("id").nodeValue===m[1]?[r]:w:[]};n.filter.ID=function(m,r){var q=typeof m.getAttributeNode!=="undefined"&&m.getAttributeNode("id");return m.nodeType===1&&q&&q.nodeValue===r}}k.removeChild(g);k=g=null})();(function(){var g=s.createElement("div");g.appendChild(s.createComment(""));if(g.getElementsByTagName("*").length>0)n.find.TAG=function(h,k){k=k.getElementsByTagName(h[1]);if(h[1]==="*"){h=[];for(var m=0;k[m];m++)k[m].nodeType===1&&h.push(k[m]);k=h}return k};g.innerHTML="<a href='#'></a>";
+if(g.firstChild&&typeof g.firstChild.getAttribute!=="undefined"&&g.firstChild.getAttribute("href")!=="#")n.attrHandle.href=function(h){return h.getAttribute("href",2)};g=null})();s.querySelectorAll&&function(){var g=p,h=s.createElement("div");h.innerHTML="<p class='TEST'></p>";if(!(h.querySelectorAll&&h.querySelectorAll(".TEST").length===0)){p=function(m,r,q,v){r=r||s;if(!v&&r.nodeType===9&&!x(r))try{return B(r.querySelectorAll(m),q)}catch(u){}return g(m,r,q,v)};for(var k in g)p[k]=g[k];h=null}}();
+(function(){var g=s.createElement("div");g.innerHTML="<div class='test e'></div><div class='test'></div>";if(!(!g.getElementsByClassName||g.getElementsByClassName("e").length===0)){g.lastChild.className="e";if(g.getElementsByClassName("e").length!==1){n.order.splice(1,0,"CLASS");n.find.CLASS=function(h,k,m){if(typeof k.getElementsByClassName!=="undefined"&&!m)return k.getElementsByClassName(h[1])};g=null}}})();var F=s.compareDocumentPosition?function(g,h){return g.compareDocumentPosition(h)&16}:function(g,
+h){return g!==h&&(g.contains?g.contains(h):true)},x=function(g){return(g=(g?g.ownerDocument||g:0).documentElement)?g.nodeName!=="HTML":false},ia=function(g,h){var k=[],m="",r;for(h=h.nodeType?[h]:h;r=n.match.PSEUDO.exec(g);){m+=r[0];g=g.replace(n.match.PSEUDO,"")}g=n.relative[g]?g+"*":g;r=0;for(var q=h.length;r<q;r++)p(g,h[r],k);return p.filter(m,k)};c.find=p;c.expr=p.selectors;c.expr[":"]=c.expr.filters;c.unique=p.uniqueSort;c.getText=a;c.isXMLDoc=x;c.contains=F})();var ab=/Until$/,bb=/^(?:parents|prevUntil|prevAll)/,
+cb=/,/;R=Array.prototype.slice;var Fa=function(a,b,d){if(c.isFunction(b))return c.grep(a,function(e,i){return!!b.call(e,i,e)===d});else if(b.nodeType)return c.grep(a,function(e){return e===b===d});else if(typeof b==="string"){var f=c.grep(a,function(e){return e.nodeType===1});if(Pa.test(b))return c.filter(b,f,!d);else b=c.filter(b,a)}return c.grep(a,function(e){return c.inArray(e,b)>=0===d})};c.fn.extend({find:function(a){for(var b=this.pushStack("","find",a),d=0,f=0,e=this.length;f<e;f++){d=b.length;
+c.find(a,this[f],b);if(f>0)for(var i=d;i<b.length;i++)for(var j=0;j<d;j++)if(b[j]===b[i]){b.splice(i--,1);break}}return b},has:function(a){var b=c(a);return this.filter(function(){for(var d=0,f=b.length;d<f;d++)if(c.contains(this,b[d]))return true})},not:function(a){return this.pushStack(Fa(this,a,false),"not",a)},filter:function(a){return this.pushStack(Fa(this,a,true),"filter",a)},is:function(a){return!!a&&c.filter(a,this).length>0},closest:function(a,b){if(c.isArray(a)){var d=[],f=this[0],e,i=
+{},j;if(f&&a.length){e=0;for(var o=a.length;e<o;e++){j=a[e];i[j]||(i[j]=c.expr.match.POS.test(j)?c(j,b||this.context):j)}for(;f&&f.ownerDocument&&f!==b;){for(j in i){e=i[j];if(e.jquery?e.index(f)>-1:c(f).is(e)){d.push({selector:j,elem:f});delete i[j]}}f=f.parentNode}}return d}var p=c.expr.match.POS.test(a)?c(a,b||this.context):null;return this.map(function(n,t){for(;t&&t.ownerDocument&&t!==b;){if(p?p.index(t)>-1:c(t).is(a))return t;t=t.parentNode}return null})},index:function(a){if(!a||typeof a===
+"string")return c.inArray(this[0],a?c(a):this.parent().children());return c.inArray(a.jquery?a[0]:a,this)},add:function(a,b){a=typeof a==="string"?c(a,b||this.context):c.makeArray(a);b=c.merge(this.get(),a);return this.pushStack(sa(a[0])||sa(b[0])?b:c.unique(b))},andSelf:function(){return this.add(this.prevObject)}});c.each({parent:function(a){return(a=a.parentNode)&&a.nodeType!==11?a:null},parents:function(a){return c.dir(a,"parentNode")},parentsUntil:function(a,b,d){return c.dir(a,"parentNode",
+d)},next:function(a){return c.nth(a,2,"nextSibling")},prev:function(a){return c.nth(a,2,"previousSibling")},nextAll:function(a){return c.dir(a,"nextSibling")},prevAll:function(a){return c.dir(a,"previousSibling")},nextUntil:function(a,b,d){return c.dir(a,"nextSibling",d)},prevUntil:function(a,b,d){return c.dir(a,"previousSibling",d)},siblings:function(a){return c.sibling(a.parentNode.firstChild,a)},children:function(a){return c.sibling(a.firstChild)},contents:function(a){return c.nodeName(a,"iframe")?
+a.contentDocument||a.contentWindow.document:c.makeArray(a.childNodes)}},function(a,b){c.fn[a]=function(d,f){var e=c.map(this,b,d);ab.test(a)||(f=d);if(f&&typeof f==="string")e=c.filter(f,e);e=this.length>1?c.unique(e):e;if((this.length>1||cb.test(f))&&bb.test(a))e=e.reverse();return this.pushStack(e,a,R.call(arguments).join(","))}});c.extend({filter:function(a,b,d){if(d)a=":not("+a+")";return c.find.matches(a,b)},dir:function(a,b,d){var f=[];for(a=a[b];a&&a.nodeType!==9&&(d===w||!c(a).is(d));){a.nodeType===
+1&&f.push(a);a=a[b]}return f},nth:function(a,b,d){b=b||1;for(var f=0;a;a=a[d])if(a.nodeType===1&&++f===b)break;return a},sibling:function(a,b){for(var d=[];a;a=a.nextSibling)a.nodeType===1&&a!==b&&d.push(a);return d}});var Ga=/ jQuery\d+="(?:\d+|null)"/g,Y=/^\s+/,db=/(<([\w:]+)[^>]*?)\/>/g,eb=/^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,Ha=/<([\w:]+)/,fb=/<tbody/i,gb=/<|&\w+;/,hb=function(a,b,d){return eb.test(d)?a:b+"></"+d+">"},G={option:[1,"<select multiple='multiple'>","</select>"],
+legend:[1,"<fieldset>","</fieldset>"],thead:[1,"<table>","</table>"],tr:[2,"<table><tbody>","</tbody></table>"],td:[3,"<table><tbody><tr>","</tr></tbody></table>"],col:[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"],area:[1,"<map>","</map>"],_default:[0,"",""]};G.optgroup=G.option;G.tbody=G.tfoot=G.colgroup=G.caption=G.thead;G.th=G.td;if(!c.support.htmlSerialize)G._default=[1,"div<div>","</div>"];c.fn.extend({text:function(a){if(c.isFunction(a))return this.each(function(b){var d=c(this);
+return d.text(a.call(this,b,d.text()))});if(typeof a!=="object"&&a!==w)return this.empty().append((this[0]&&this[0].ownerDocument||s).createTextNode(a));return c.getText(this)},wrapAll:function(a){if(c.isFunction(a))return this.each(function(d){c(this).wrapAll(a.call(this,d))});if(this[0]){var b=c(a,this[0].ownerDocument).eq(0).clone(true);this[0].parentNode&&b.insertBefore(this[0]);b.map(function(){for(var d=this;d.firstChild&&d.firstChild.nodeType===1;)d=d.firstChild;return d}).append(this)}return this},
+wrapInner:function(a){return this.each(function(){var b=c(this),d=b.contents();d.length?d.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){c(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){c.nodeName(this,"body")||c(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,true,function(a){this.nodeType===1&&
+this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this)});else if(arguments.length){var a=c(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,false,function(b){this.parentNode.insertBefore(b,this.nextSibling)});else if(arguments.length){var a=this.pushStack(this,
+"after",arguments);a.push.apply(a,c(arguments[0]).toArray());return a}},clone:function(a){var b=this.map(function(){if(!c.support.noCloneEvent&&!c.isXMLDoc(this)){var d=this.outerHTML,f=this.ownerDocument;if(!d){d=f.createElement("div");d.appendChild(this.cloneNode(true));d=d.innerHTML}return c.clean([d.replace(Ga,"").replace(Y,"")],f)[0]}else return this.cloneNode(true)});if(a===true){ta(this,b);ta(this.find("*"),b.find("*"))}return b},html:function(a){if(a===w)return this[0]&&this[0].nodeType===
+1?this[0].innerHTML.replace(Ga,""):null;else if(typeof a==="string"&&!/<script/i.test(a)&&(c.support.leadingWhitespace||!Y.test(a))&&!G[(Ha.exec(a)||["",""])[1].toLowerCase()])try{for(var b=0,d=this.length;b<d;b++)if(this[b].nodeType===1){T(this[b].getElementsByTagName("*"));this[b].innerHTML=a}}catch(f){this.empty().append(a)}else c.isFunction(a)?this.each(function(e){var i=c(this),j=i.html();i.empty().append(function(){return a.call(this,e,j)})}):this.empty().append(a);return this},replaceWith:function(a){if(this[0]&&
+this[0].parentNode){c.isFunction(a)||(a=c(a).detach());return this.each(function(){var b=this.nextSibling,d=this.parentNode;c(this).remove();b?c(b).before(a):c(d).append(a)})}else return this.pushStack(c(c.isFunction(a)?a():a),"replaceWith",a)},detach:function(a){return this.remove(a,true)},domManip:function(a,b,d){function f(t){return c.nodeName(t,"table")?t.getElementsByTagName("tbody")[0]||t.appendChild(t.ownerDocument.createElement("tbody")):t}var e,i,j=a[0],o=[];if(c.isFunction(j))return this.each(function(t){var z=
+c(this);a[0]=j.call(this,t,b?z.html():w);return z.domManip(a,b,d)});if(this[0]){e=a[0]&&a[0].parentNode&&a[0].parentNode.nodeType===11?{fragment:a[0].parentNode}:ua(a,this,o);if(i=e.fragment.firstChild){b=b&&c.nodeName(i,"tr");for(var p=0,n=this.length;p<n;p++)d.call(b?f(this[p],i):this[p],e.cacheable||this.length>1||p>0?e.fragment.cloneNode(true):e.fragment)}o&&c.each(o,La)}return this}});c.fragments={};c.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},
+function(a,b){c.fn[a]=function(d){var f=[];d=c(d);for(var e=0,i=d.length;e<i;e++){var j=(e>0?this.clone(true):this).get();c.fn[b].apply(c(d[e]),j);f=f.concat(j)}return this.pushStack(f,a,d.selector)}});c.each({remove:function(a,b){if(!a||c.filter(a,[this]).length){if(!b&&this.nodeType===1){T(this.getElementsByTagName("*"));T([this])}this.parentNode&&this.parentNode.removeChild(this)}},empty:function(){for(this.nodeType===1&&T(this.getElementsByTagName("*"));this.firstChild;)this.removeChild(this.firstChild)}},
+function(a,b){c.fn[a]=function(){return this.each(b,arguments)}});c.extend({clean:function(a,b,d,f){b=b||s;if(typeof b.createElement==="undefined")b=b.ownerDocument||b[0]&&b[0].ownerDocument||s;var e=[];c.each(a,function(i,j){if(typeof j==="number")j+="";if(j){if(typeof j==="string"&&!gb.test(j))j=b.createTextNode(j);else if(typeof j==="string"){j=j.replace(db,hb);var o=(Ha.exec(j)||["",""])[1].toLowerCase(),p=G[o]||G._default,n=p[0];i=b.createElement("div");for(i.innerHTML=p[1]+j+p[2];n--;)i=i.lastChild;
+if(!c.support.tbody){n=fb.test(j);o=o==="table"&&!n?i.firstChild&&i.firstChild.childNodes:p[1]==="<table>"&&!n?i.childNodes:[];for(p=o.length-1;p>=0;--p)c.nodeName(o[p],"tbody")&&!o[p].childNodes.length&&o[p].parentNode.removeChild(o[p])}!c.support.leadingWhitespace&&Y.test(j)&&i.insertBefore(b.createTextNode(Y.exec(j)[0]),i.firstChild);j=c.makeArray(i.childNodes)}if(j.nodeType)e.push(j);else e=c.merge(e,j)}});if(d)for(a=0;e[a];a++)if(f&&c.nodeName(e[a],"script")&&(!e[a].type||e[a].type.toLowerCase()===
+"text/javascript"))f.push(e[a].parentNode?e[a].parentNode.removeChild(e[a]):e[a]);else{e[a].nodeType===1&&e.splice.apply(e,[a+1,0].concat(c.makeArray(e[a].getElementsByTagName("script"))));d.appendChild(e[a])}return e}});var ib=/z-?index|font-?weight|opacity|zoom|line-?height/i,Ia=/alpha\([^)]*\)/,Ja=/opacity=([^)]*)/,ja=/float/i,ka=/-([a-z])/ig,jb=/([A-Z])/g,kb=/^-?\d+(?:px)?$/i,lb=/^-?\d/,mb={position:"absolute",visibility:"hidden",display:"block"},nb=["Left","Right"],ob=["Top","Bottom"],pb=s.defaultView&&
+s.defaultView.getComputedStyle,Ka=c.support.cssFloat?"cssFloat":"styleFloat",la=function(a,b){return b.toUpperCase()};c.fn.css=function(a,b){return $(this,a,b,true,function(d,f,e){if(e===w)return c.curCSS(d,f);if(typeof e==="number"&&!ib.test(f))e+="px";c.style(d,f,e)})};c.extend({style:function(a,b,d){if(!a||a.nodeType===3||a.nodeType===8)return w;if((b==="width"||b==="height")&&parseFloat(d)<0)d=w;var f=a.style||a,e=d!==w;if(!c.support.opacity&&b==="opacity"){if(e){f.zoom=1;b=parseInt(d,10)+""===
+"NaN"?"":"alpha(opacity="+d*100+")";a=f.filter||c.curCSS(a,"filter")||"";f.filter=Ia.test(a)?a.replace(Ia,b):b}return f.filter&&f.filter.indexOf("opacity=")>=0?parseFloat(Ja.exec(f.filter)[1])/100+"":""}if(ja.test(b))b=Ka;b=b.replace(ka,la);if(e)f[b]=d;return f[b]},css:function(a,b,d,f){if(b==="width"||b==="height"){var e,i=b==="width"?nb:ob;function j(){e=b==="width"?a.offsetWidth:a.offsetHeight;f!=="border"&&c.each(i,function(){f||(e-=parseFloat(c.curCSS(a,"padding"+this,true))||0);if(f==="margin")e+=
+parseFloat(c.curCSS(a,"margin"+this,true))||0;else e-=parseFloat(c.curCSS(a,"border"+this+"Width",true))||0})}a.offsetWidth!==0?j():c.swap(a,mb,j);return Math.max(0,Math.round(e))}return c.curCSS(a,b,d)},curCSS:function(a,b,d){var f,e=a.style;if(!c.support.opacity&&b==="opacity"&&a.currentStyle){f=Ja.test(a.currentStyle.filter||"")?parseFloat(RegExp.$1)/100+"":"";return f===""?"1":f}if(ja.test(b))b=Ka;if(!d&&e&&e[b])f=e[b];else if(pb){if(ja.test(b))b="float";b=b.replace(jb,"-$1").toLowerCase();e=
+a.ownerDocument.defaultView;if(!e)return null;if(a=e.getComputedStyle(a,null))f=a.getPropertyValue(b);if(b==="opacity"&&f==="")f="1"}else if(a.currentStyle){d=b.replace(ka,la);f=a.currentStyle[b]||a.currentStyle[d];if(!kb.test(f)&&lb.test(f)){b=e.left;var i=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;e.left=d==="fontSize"?"1em":f||0;f=e.pixelLeft+"px";e.left=b;a.runtimeStyle.left=i}}return f},swap:function(a,b,d){var f={};for(var e in b){f[e]=a.style[e];a.style[e]=b[e]}d.call(a);for(e in b)a.style[e]=
+f[e]}});if(c.expr&&c.expr.filters){c.expr.filters.hidden=function(a){var b=a.offsetWidth,d=a.offsetHeight,f=a.nodeName.toLowerCase()==="tr";return b===0&&d===0&&!f?true:b>0&&d>0&&!f?false:c.curCSS(a,"display")==="none"};c.expr.filters.visible=function(a){return!c.expr.filters.hidden(a)}}var qb=K(),rb=/<script(.|\s)*?\/script>/gi,sb=/select|textarea/i,tb=/color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,O=/=\?(&|$)/,ma=/\?/,ub=/(\?|&)_=.*?(&|$)/,vb=/^(\w+:)?\/\/([^\/?#]+)/,
+wb=/%20/g;c.fn.extend({_load:c.fn.load,load:function(a,b,d){if(typeof a!=="string")return this._load(a);else if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var e=a.slice(f,a.length);a=a.slice(0,f)}f="GET";if(b)if(c.isFunction(b)){d=b;b=null}else if(typeof b==="object"){b=c.param(b,c.ajaxSettings.traditional);f="POST"}c.ajax({url:a,type:f,dataType:"html",data:b,context:this,complete:function(i,j){if(j==="success"||j==="notmodified")this.html(e?c("<div />").append(i.responseText.replace(rb,
+"")).find(e):i.responseText);d&&this.each(d,[i.responseText,j,i])}});return this},serialize:function(){return c.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?c.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||sb.test(this.nodeName)||tb.test(this.type))}).map(function(a,b){a=c(this).val();return a==null?null:c.isArray(a)?c.map(a,function(d){return{name:b.name,value:d}}):{name:b.name,value:a}}).get()}});
+c.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){c.fn[b]=function(d){return this.bind(b,d)}});c.extend({get:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b=null}return c.ajax({type:"GET",url:a,data:b,success:d,dataType:f})},getScript:function(a,b){return c.get(a,null,b,"script")},getJSON:function(a,b,d){return c.get(a,b,d,"json")},post:function(a,b,d,f){if(c.isFunction(b)){f=f||d;d=b;b={}}return c.ajax({type:"POST",url:a,data:b,success:d,dataType:f})},
+ajaxSetup:function(a){c.extend(c.ajaxSettings,a)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:A.XMLHttpRequest&&(A.location.protocol!=="file:"||!A.ActiveXObject)?function(){return new A.XMLHttpRequest}:function(){try{return new A.ActiveXObject("Microsoft.XMLHTTP")}catch(a){}},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",
+text:"text/plain",_default:"*/*"}},lastModified:{},etag:{},ajax:function(a){function b(){e.success&&e.success.call(p,o,j,x);e.global&&f("ajaxSuccess",[x,e])}function d(){e.complete&&e.complete.call(p,x,j);e.global&&f("ajaxComplete",[x,e]);e.global&&!--c.active&&c.event.trigger("ajaxStop")}function f(r,q){(e.context?c(e.context):c.event).trigger(r,q)}var e=c.extend(true,{},c.ajaxSettings,a),i,j,o,p=e.context||e,n=e.type.toUpperCase();if(e.data&&e.processData&&typeof e.data!=="string")e.data=c.param(e.data,
+e.traditional);if(e.dataType==="jsonp"){if(n==="GET")O.test(e.url)||(e.url+=(ma.test(e.url)?"&":"?")+(e.jsonp||"callback")+"=?");else if(!e.data||!O.test(e.data))e.data=(e.data?e.data+"&":"")+(e.jsonp||"callback")+"=?";e.dataType="json"}if(e.dataType==="json"&&(e.data&&O.test(e.data)||O.test(e.url))){i=e.jsonpCallback||"jsonp"+qb++;if(e.data)e.data=(e.data+"").replace(O,"="+i+"$1");e.url=e.url.replace(O,"="+i+"$1");e.dataType="script";A[i]=A[i]||function(r){o=r;b();d();A[i]=w;try{delete A[i]}catch(q){}B&&
+B.removeChild(C)}}if(e.dataType==="script"&&e.cache===null)e.cache=false;if(e.cache===false&&n==="GET"){var t=K(),z=e.url.replace(ub,"$1_="+t+"$2");e.url=z+(z===e.url?(ma.test(e.url)?"&":"?")+"_="+t:"")}if(e.data&&n==="GET")e.url+=(ma.test(e.url)?"&":"?")+e.data;e.global&&!c.active++&&c.event.trigger("ajaxStart");t=(t=vb.exec(e.url))&&(t[1]&&t[1]!==location.protocol||t[2]!==location.host);if(e.dataType==="script"&&n==="GET"&&t){var B=s.getElementsByTagName("head")[0]||s.documentElement,C=s.createElement("script");
+C.src=e.url;if(e.scriptCharset)C.charset=e.scriptCharset;if(!i){var D=false;C.onload=C.onreadystatechange=function(){if(!D&&(!this.readyState||this.readyState==="loaded"||this.readyState==="complete")){D=true;b();d();C.onload=C.onreadystatechange=null;B&&C.parentNode&&B.removeChild(C)}}}B.insertBefore(C,B.firstChild);return w}var F=false,x=e.xhr();if(x){e.username?x.open(n,e.url,e.async,e.username,e.password):x.open(n,e.url,e.async);try{if(e.data||a&&a.contentType)x.setRequestHeader("Content-Type",
+e.contentType);if(e.ifModified){c.lastModified[e.url]&&x.setRequestHeader("If-Modified-Since",c.lastModified[e.url]);c.etag[e.url]&&x.setRequestHeader("If-None-Match",c.etag[e.url])}t||x.setRequestHeader("X-Requested-With","XMLHttpRequest");x.setRequestHeader("Accept",e.dataType&&e.accepts[e.dataType]?e.accepts[e.dataType]+", */*":e.accepts._default)}catch(ia){}if(e.beforeSend&&e.beforeSend.call(p,x,e)===false){e.global&&!--c.active&&c.event.trigger("ajaxStop");x.abort();return false}e.global&&f("ajaxSend",
+[x,e]);var g=x.onreadystatechange=function(r){if(!x||x.readyState===0){F||d();F=true;if(x)x.onreadystatechange=c.noop}else if(!F&&x&&(x.readyState===4||r==="timeout")){F=true;x.onreadystatechange=c.noop;j=r==="timeout"?"timeout":!c.httpSuccess(x)?"error":e.ifModified&&c.httpNotModified(x,e.url)?"notmodified":"success";if(j==="success")try{o=c.httpData(x,e.dataType,e)}catch(q){j="parsererror"}if(j==="success"||j==="notmodified")i||b();else c.handleError(e,x,j);d();r==="timeout"&&x.abort();if(e.async)x=
+null}};try{var h=x.abort;x.abort=function(){if(x){h.call(x);if(x)x.readyState=0}g()}}catch(k){}e.async&&e.timeout>0&&setTimeout(function(){x&&!F&&g("timeout")},e.timeout);try{x.send(n==="POST"||n==="PUT"||n==="DELETE"?e.data:null)}catch(m){c.handleError(e,x,null,m);d()}e.async||g();return x}},handleError:function(a,b,d,f){if(a.error)a.error.call(a.context||A,b,d,f);if(a.global)(a.context?c(a.context):c.event).trigger("ajaxError",[b,a,f])},active:0,httpSuccess:function(a){try{return!a.status&&location.protocol===
+"file:"||a.status>=200&&a.status<300||a.status===304||a.status===1223||a.status===0}catch(b){}return false},httpNotModified:function(a,b){var d=a.getResponseHeader("Last-Modified"),f=a.getResponseHeader("Etag");if(d)c.lastModified[b]=d;if(f)c.etag[b]=f;return a.status===304||a.status===0},httpData:function(a,b,d){var f=a.getResponseHeader("content-type")||"",e=b==="xml"||!b&&f.indexOf("xml")>=0;a=e?a.responseXML:a.responseText;if(e&&a.documentElement.nodeName==="parsererror")throw"parsererror";if(d&&
+d.dataFilter)a=d.dataFilter(a,b);if(typeof a==="string")if(b==="json"||!b&&f.indexOf("json")>=0)if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))a=A.JSON&&A.JSON.parse?A.JSON.parse(a):(new Function("return "+a))();else throw"Invalid JSON: "+a;else if(b==="script"||!b&&f.indexOf("javascript")>=0)c.globalEval(a);return a},param:function(a,b){function d(e,i){i=
+c.isFunction(i)?i():i;f[f.length]=encodeURIComponent(e)+"="+encodeURIComponent(i)}var f=[];if(b===w)b=c.ajaxSettings.traditional;c.isArray(a)||a.jquery?c.each(a,function(){d(this.name,this.value)}):c.each(a,function e(i,j){if(c.isArray(j))c.each(j,function(o,p){b?d(i,p):e(i+"["+(typeof p==="object"||c.isArray(p)?o:"")+"]",p)});else!b&&j!=null&&typeof j==="object"?c.each(j,function(o,p){e(i+"["+o+"]",p)}):d(i,j)});return f.join("&").replace(wb,"+")}});var na={},xb=/toggle|show|hide/,yb=/^([+-]=)?([\d+-.]+)(.*)$/,
+Z,va=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];c.fn.extend({show:function(a,b){if(a!=null)return this.animate(L("show",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");this[a].style.display=d||"";if(c.css(this[a],"display")==="none"){d=this[a].nodeName;var f;if(na[d])f=na[d];else{var e=c("<"+d+" />").appendTo("body");f=e.css("display");if(f==="none")f="block";e.remove();
+na[d]=f}c.data(this[a],"olddisplay",f)}}a=0;for(b=this.length;a<b;a++)this[a].style.display=c.data(this[a],"olddisplay")||"";return this}},hide:function(a,b){if(a!=null)return this.animate(L("hide",3),a,b);else{a=0;for(b=this.length;a<b;a++){var d=c.data(this[a],"olddisplay");!d&&d!=="none"&&c.data(this[a],"olddisplay",c.css(this[a],"display"))}a=0;for(b=this.length;a<b;a++)this[a].style.display="none";return this}},_toggle:c.fn.toggle,toggle:function(a,b){var d=typeof a==="boolean";if(c.isFunction(a)&&
+c.isFunction(b))this._toggle.apply(this,arguments);else a==null||d?this.each(function(){var f=d?a:c(this).is(":hidden");c(this)[f?"show":"hide"]()}):this.animate(L("toggle",3),a,b);return this},fadeTo:function(a,b,d){return this.filter(":hidden").css("opacity",0).show().end().animate({opacity:b},a,d)},animate:function(a,b,d,f){var e=c.speed(b,d,f);if(c.isEmptyObject(a))return this.each(e.complete);return this[e.queue===false?"each":"queue"](function(){var i=c.extend({},e),j,o=this.nodeType===1&&c(this).is(":hidden"),
+p=this;for(j in a){var n=j.replace(ka,la);if(j!==n){a[n]=a[j];delete a[j];j=n}if(a[j]==="hide"&&o||a[j]==="show"&&!o)return i.complete.call(this);if((j==="height"||j==="width")&&this.style){i.display=c.css(this,"display");i.overflow=this.style.overflow}if(c.isArray(a[j])){(i.specialEasing=i.specialEasing||{})[j]=a[j][1];a[j]=a[j][0]}}if(i.overflow!=null)this.style.overflow="hidden";i.curAnim=c.extend({},a);c.each(a,function(t,z){var B=new c.fx(p,i,t);if(xb.test(z))B[z==="toggle"?o?"show":"hide":z](a);
+else{var C=yb.exec(z),D=B.cur(true)||0;if(C){z=parseFloat(C[2]);var F=C[3]||"px";if(F!=="px"){p.style[t]=(z||1)+F;D=(z||1)/B.cur(true)*D;p.style[t]=D+F}if(C[1])z=(C[1]==="-="?-1:1)*z+D;B.custom(D,z,F)}else B.custom(D,z,"")}});return true})},stop:function(a,b){var d=c.timers;a&&this.queue([]);this.each(function(){for(var f=d.length-1;f>=0;f--)if(d[f].elem===this){b&&d[f](true);d.splice(f,1)}});b||this.dequeue();return this}});c.each({slideDown:L("show",1),slideUp:L("hide",1),slideToggle:L("toggle",
+1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(a,b){c.fn[a]=function(d,f){return this.animate(b,d,f)}});c.extend({speed:function(a,b,d){var f=a&&typeof a==="object"?a:{complete:d||!d&&b||c.isFunction(a)&&a,duration:a,easing:d&&b||b&&!c.isFunction(b)&&b};f.duration=c.fx.off?0:typeof f.duration==="number"?f.duration:c.fx.speeds[f.duration]||c.fx.speeds._default;f.old=f.complete;f.complete=function(){f.queue!==false&&c(this).dequeue();c.isFunction(f.old)&&f.old.call(this)};return f},easing:{linear:function(a,
+b,d,f){return d+f*a},swing:function(a,b,d,f){return(-Math.cos(a*Math.PI)/2+0.5)*f+d}},timers:[],fx:function(a,b,d){this.options=b;this.elem=a;this.prop=d;if(!b.orig)b.orig={}}});c.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this);(c.fx.step[this.prop]||c.fx.step._default)(this);if((this.prop==="height"||this.prop==="width")&&this.elem.style)this.elem.style.display="block"},cur:function(a){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==
+null))return this.elem[this.prop];return(a=parseFloat(c.css(this.elem,this.prop,a)))&&a>-10000?a:parseFloat(c.curCSS(this.elem,this.prop))||0},custom:function(a,b,d){function f(i){return e.step(i)}this.startTime=K();this.start=a;this.end=b;this.unit=d||this.unit||"px";this.now=this.start;this.pos=this.state=0;var e=this;f.elem=this.elem;if(f()&&c.timers.push(f)&&!Z)Z=setInterval(c.fx.tick,13)},show:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.show=true;this.custom(this.prop===
+"width"||this.prop==="height"?1:0,this.cur());c(this.elem).show()},hide:function(){this.options.orig[this.prop]=c.style(this.elem,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(a){var b=K(),d=true;if(a||b>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;for(var f in this.options.curAnim)if(this.options.curAnim[f]!==true)d=false;if(d){if(this.options.display!=null){this.elem.style.overflow=
+this.options.overflow;a=c.data(this.elem,"olddisplay");this.elem.style.display=a?a:this.options.display;if(c.css(this.elem,"display")==="none")this.elem.style.display="block"}this.options.hide&&c(this.elem).hide();if(this.options.hide||this.options.show)for(var e in this.options.curAnim)c.style(this.elem,e,this.options.orig[e]);this.options.complete.call(this.elem)}return false}else{e=b-this.startTime;this.state=e/this.options.duration;a=this.options.easing||(c.easing.swing?"swing":"linear");this.pos=
+c.easing[this.options.specialEasing&&this.options.specialEasing[this.prop]||a](this.state,e,0,1,this.options.duration);this.now=this.start+(this.end-this.start)*this.pos;this.update()}return true}};c.extend(c.fx,{tick:function(){for(var a=c.timers,b=0;b<a.length;b++)a[b]()||a.splice(b--,1);a.length||c.fx.stop()},stop:function(){clearInterval(Z);Z=null},speeds:{slow:600,fast:200,_default:400},step:{opacity:function(a){c.style(a.elem,"opacity",a.now)},_default:function(a){if(a.elem.style&&a.elem.style[a.prop]!=
+null)a.elem.style[a.prop]=(a.prop==="width"||a.prop==="height"?Math.max(0,a.now):a.now)+a.unit;else a.elem[a.prop]=a.now}}});if(c.expr&&c.expr.filters)c.expr.filters.animated=function(a){return c.grep(c.timers,function(b){return a===b.elem}).length};c.fn.offset="getBoundingClientRect"in s.documentElement?function(a){var b=this[0];if(!b||!b.ownerDocument)return null;if(a)return this.each(function(e){c.offset.setOffset(this,a,e)});if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);var d=b.getBoundingClientRect(),
+f=b.ownerDocument;b=f.body;f=f.documentElement;return{top:d.top+(self.pageYOffset||c.support.boxModel&&f.scrollTop||b.scrollTop)-(f.clientTop||b.clientTop||0),left:d.left+(self.pageXOffset||c.support.boxModel&&f.scrollLeft||b.scrollLeft)-(f.clientLeft||b.clientLeft||0)}}:function(a){var b=this[0];if(!b||!b.ownerDocument)return null;if(a)return this.each(function(t){c.offset.setOffset(this,a,t)});if(b===b.ownerDocument.body)return c.offset.bodyOffset(b);c.offset.initialize();var d=b.offsetParent,f=
+b,e=b.ownerDocument,i,j=e.documentElement,o=e.body;f=(e=e.defaultView)?e.getComputedStyle(b,null):b.currentStyle;for(var p=b.offsetTop,n=b.offsetLeft;(b=b.parentNode)&&b!==o&&b!==j;){if(c.offset.supportsFixedPosition&&f.position==="fixed")break;i=e?e.getComputedStyle(b,null):b.currentStyle;p-=b.scrollTop;n-=b.scrollLeft;if(b===d){p+=b.offsetTop;n+=b.offsetLeft;if(c.offset.doesNotAddBorder&&!(c.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(b.nodeName))){p+=parseFloat(i.borderTopWidth)||
+0;n+=parseFloat(i.borderLeftWidth)||0}f=d;d=b.offsetParent}if(c.offset.subtractsBorderForOverflowNotVisible&&i.overflow!=="visible"){p+=parseFloat(i.borderTopWidth)||0;n+=parseFloat(i.borderLeftWidth)||0}f=i}if(f.position==="relative"||f.position==="static"){p+=o.offsetTop;n+=o.offsetLeft}if(c.offset.supportsFixedPosition&&f.position==="fixed"){p+=Math.max(j.scrollTop,o.scrollTop);n+=Math.max(j.scrollLeft,o.scrollLeft)}return{top:p,left:n}};c.offset={initialize:function(){var a=s.body,b=s.createElement("div"),
+d,f,e,i=parseFloat(c.curCSS(a,"marginTop",true))||0;c.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"});b.innerHTML="<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";a.insertBefore(b,a.firstChild);
+d=b.firstChild;f=d.firstChild;e=d.nextSibling.firstChild.firstChild;this.doesNotAddBorder=f.offsetTop!==5;this.doesAddBorderForTableAndCells=e.offsetTop===5;f.style.position="fixed";f.style.top="20px";this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15;f.style.position=f.style.top="";d.style.overflow="hidden";d.style.position="relative";this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5;this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i;a.removeChild(b);c.offset.initialize=c.noop},
+bodyOffset:function(a){var b=a.offsetTop,d=a.offsetLeft;c.offset.initialize();if(c.offset.doesNotIncludeMarginInBodyOffset){b+=parseFloat(c.curCSS(a,"marginTop",true))||0;d+=parseFloat(c.curCSS(a,"marginLeft",true))||0}return{top:b,left:d}},setOffset:function(a,b,d){if(/static/.test(c.curCSS(a,"position")))a.style.position="relative";var f=c(a),e=f.offset(),i=parseInt(c.curCSS(a,"top",true),10)||0,j=parseInt(c.curCSS(a,"left",true),10)||0;if(c.isFunction(b))b=b.call(a,d,e);d={top:b.top-e.top+i,left:b.left-
+e.left+j};"using"in b?b.using.call(a,d):f.css(d)}};c.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),d=this.offset(),f=/^body|html$/i.test(b[0].nodeName)?{top:0,left:0}:b.offset();d.top-=parseFloat(c.curCSS(a,"marginTop",true))||0;d.left-=parseFloat(c.curCSS(a,"marginLeft",true))||0;f.top+=parseFloat(c.curCSS(b[0],"borderTopWidth",true))||0;f.left+=parseFloat(c.curCSS(b[0],"borderLeftWidth",true))||0;return{top:d.top-f.top,left:d.left-f.left}},offsetParent:function(){return this.map(function(){for(var a=
+this.offsetParent||s.body;a&&!/^body|html$/i.test(a.nodeName)&&c.css(a,"position")==="static";)a=a.offsetParent;return a})}});c.each(["Left","Top"],function(a,b){var d="scroll"+b;c.fn[d]=function(f){var e=this[0],i;if(!e)return null;if(f!==w)return this.each(function(){if(i=wa(this))i.scrollTo(!a?f:c(i).scrollLeft(),a?f:c(i).scrollTop());else this[d]=f});else return(i=wa(e))?"pageXOffset"in i?i[a?"pageYOffset":"pageXOffset"]:c.support.boxModel&&i.document.documentElement[d]||i.document.body[d]:e[d]}});
+c.each(["Height","Width"],function(a,b){var d=b.toLowerCase();c.fn["inner"+b]=function(){return this[0]?c.css(this[0],d,false,"padding"):null};c.fn["outer"+b]=function(f){return this[0]?c.css(this[0],d,false,f?"margin":"border"):null};c.fn[d]=function(f){var e=this[0];if(!e)return f==null?null:this;return"scrollTo"in e&&e.document?e.document.compatMode==="CSS1Compat"&&e.document.documentElement["client"+b]||e.document.body["client"+b]:e.nodeType===9?Math.max(e.documentElement["client"+b],e.body["scroll"+
+b],e.documentElement["scroll"+b],e.body["offset"+b],e.documentElement["offset"+b]):f===w?c.css(e,d):this.css(d,typeof f==="string"?f:f+"px")}});A.jQuery=A.$=c})(window);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/jquery.timeago.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,140 @@
+/*
+ * timeago: a jQuery plugin, version: 0.8.1 (2010-01-04)
+ * @requires jQuery v1.2.3 or later
+ *
+ * Timeago is a jQuery plugin that makes it easy to support automatically
+ * updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
+ *
+ * For usage and examples, visit:
+ * http://timeago.yarp.com/
+ *
+ * Licensed under the MIT:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * Copyright (c) 2008-2010, Ryan McGeary (ryanonjavascript -[at]- mcgeary [*dot*] org)
+ */
+(function($) {
+  $.timeago = function(timestamp) {
+    if (timestamp instanceof Date) return inWords(timestamp);
+    else if (typeof timestamp == "string") return inWords($.timeago.parse(timestamp));
+    else return inWords($.timeago.datetime(timestamp));
+  };
+  var $t = $.timeago;
+
+  $.extend($.timeago, {
+    settings: {
+      refreshMillis: 60000,
+      allowFuture: false,
+      strings: {
+        prefixAgo: null,
+        prefixFromNow: null,
+        suffixAgo: "ago",
+        suffixFromNow: "from now",
+        ago: null, // DEPRECATED, use suffixAgo
+        fromNow: null, // DEPRECATED, use suffixFromNow
+        seconds: "less than a minute",
+        minute: "about a minute",
+        minutes: "%d minutes",
+        hour: "about an hour",
+        hours: "about %d hours",
+        day: "a day",
+        days: "%d days",
+        month: "about a month",
+        months: "%d months",
+        year: "about a year",
+        years: "%d years"
+      }
+    },
+    inWords: function(distanceMillis) {
+      var $l = this.settings.strings;
+      var prefix = $l.prefixAgo;
+      var suffix = $l.suffixAgo || $l.ago;
+      if (this.settings.allowFuture) {
+        if (distanceMillis < 0) {
+          prefix = $l.prefixFromNow;
+          suffix = $l.suffixFromNow || $l.fromNow;
+        }
+        distanceMillis = Math.abs(distanceMillis);
+      }
+
+      var seconds = distanceMillis / 1000;
+      var minutes = seconds / 60;
+      var hours = minutes / 60;
+      var days = hours / 24;
+      var years = days / 365;
+
+      var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
+        seconds < 90 && substitute($l.minute, 1) ||
+        minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
+        minutes < 90 && substitute($l.hour, 1) ||
+        hours < 24 && substitute($l.hours, Math.round(hours)) ||
+        hours < 48 && substitute($l.day, 1) ||
+        days < 30 && substitute($l.days, Math.floor(days)) ||
+        days < 60 && substitute($l.month, 1) ||
+        days < 365 && substitute($l.months, Math.floor(days / 30)) ||
+        years < 2 && substitute($l.year, 1) ||
+        substitute($l.years, Math.floor(years));
+
+      return $.trim([prefix, words, suffix].join(" "));
+    },
+    parse: function(iso8601) {
+      var s = $.trim(iso8601);
+      s = s.replace(/-/,"/").replace(/-/,"/");
+      s = s.replace(/T/," ").replace(/Z/," UTC");
+      s = s.replace(/([\+-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
+      return new Date(s);
+    },
+    datetime: function(elem) {
+      // jQuery's `is()` doesn't play well with HTML5 in IE
+      var isTime = $(elem).get(0).tagName.toLowerCase() == 'time'; // $(elem).is('time');
+      var iso8601 = isTime ? $(elem).attr('datetime') : $(elem).attr('title');
+      return $t.parse(iso8601);
+    }
+  });
+
+  $.fn.timeago = function() {
+    var self = this;
+    self.each(refresh);
+
+    var $s = $t.settings;
+    if ($s.refreshMillis > 0) {
+      setInterval(function() { self.each(refresh); }, $s.refreshMillis);
+    }
+    return self;
+  };
+
+  function refresh() {
+    var data = prepareData(this);
+    if (!isNaN(data.datetime)) {
+      $(this).text(inWords(data.datetime));
+    }
+    return this;
+  }
+
+  function prepareData(element) {
+    element = $(element);
+    if (element.data("timeago") === undefined) {
+      element.data("timeago", { datetime: $t.datetime(element) });
+      var text = $.trim(element.text());
+      if (text.length > 0) element.attr("title", text);
+    }
+    return element.data("timeago");
+  }
+
+  function inWords(date) {
+    return $t.inWords(distance(date));
+  }
+
+  function distance(date) {
+    return (new Date().getTime() - date.getTime());
+  }
+
+  function substitute(stringOrFunction, value) {
+    var string = $.isFunction(stringOrFunction) ? stringOrFunction(value) : stringOrFunction;
+    return string.replace(/%d/i, value);
+  }
+
+  // fix for IE6 suckage
+  document.createElement('abbr');
+  document.createElement('time');
+})(jQuery);
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/print.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,21 @@
+$(function() {
+    $('#leaf-content p:has(a)').add('#leaf-content ol:has(a)').add('#leaf-content ul:has(a)').each(function() {
+        var printing_links = $(this).find('a')
+                                    .not("[href^='#']")
+                                    .not(":has(img)")
+                                    .clone();
+        $(this).after(printing_links);
+
+        printing_links.wrap('<li></li>')
+                      .parent()
+                      .wrapAll('<ul class="print-links"></ul>');
+
+        printing_links.each(function() {
+            var href = $(this).attr('href');
+            if (href.match("^/")) {
+                href = 'http://stevelosh.com' + href;
+            }
+            $(this).after(': ' + href);
+        });
+    });
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/sjl.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,56 @@
+var h2s = null;
+
+function place_scrolly_header () {
+    var soff = 75;
+
+    var y = $(window).scrollTop();
+
+    var target_content = null;
+    var opacity = null;
+    var header_y = null;
+    h2s.each(function() {
+        var pre_header_y = $(this).position()['top'] - soff;
+        if (y < pre_header_y) {
+            return false;
+        };
+        header_y = pre_header_y;
+
+        target_content = $(this).html().replace(/&nbsp;/g, ' ');
+
+        var opacity_y = y - (header_y + soff);
+        opacity = opacity_y / soff;
+        if (opacity > 1.0) {
+            opacity = 1.0;
+        }
+
+        if (opacity > 0.99) {
+            var next_headers = $(this).nextAll('h2');
+            if (next_headers.length) {
+                var next_header_y = next_headers.first().position()['top'];
+                var next_header_distance = next_header_y - y;
+                if (next_header_distance <= soff*2) {
+                    opacity = 1.0 / (soff - next_header_distance/2);
+                };
+            }
+        }
+    });
+    $('#scrolling-header').css({ opacity: opacity })
+                          .css('left', h2s.first().position()['left'] - 180 - 35)
+                          .html(target_content);
+}
+
+$(function() {
+    jQuery('span.timeago').timeago();
+
+    if ($('#leaf-stats').length) {
+        $('body').append('<div id="scrolling-header"></div>');
+        h2s = $('#leaf-content h2');
+
+        $(window).scroll(function () {
+            place_scrolly_header();
+        });
+        $(window).resize(function () {
+            place_scrolly_header();
+        });
+    }
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/terrain1.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,524 @@
+(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+var width = exports.width = 610;
+var height = exports.height = 400;
+var wireframe = exports.wireframe = true;
+var wireframeWidth = exports.wireframeWidth = 1.2;
+var terrainHeight = exports.terrainHeight = 50;
+var terrainSize = exports.terrainSize = 100;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+var l = exports.l = function l(v) {
+    return console.log(v);
+};
+var midpoint = exports.midpoint = function midpoint(a, b) {
+    return (a + b) / 2;
+};
+var average2 = exports.average2 = function average2(a, b) {
+    return (a + b) / 2;
+};
+var average4 = exports.average4 = function average4(a, b, c, d) {
+    return (a + b + c + d) / 4;
+};
+var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
+    return function () {
+        var totalø1 = 0;
+        var countø1 = 0;
+        a ? (function () {
+            totalø1 = totalø1 + a;
+            return countø1 = countø1 + 1;
+        })() : void 0;
+        b ? (function () {
+            totalø1 = totalø1 + b;
+            return countø1 = countø1 + 1;
+        })() : void 0;
+        c ? (function () {
+            totalø1 = totalø1 + c;
+            return countø1 = countø1 + 1;
+        })() : void 0;
+        d ? (function () {
+            totalø1 = totalø1 + d;
+            return countø1 = countø1 + 1;
+        })() : void 0;
+        return totalø1 / countø1;
+    }.call(this);
+};
+var rand = exports.rand = function rand() {
+    return Math.random();
+};
+var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
+    return spread * rand() * 2 - spread;
+};
+var jitter = exports.jitter = function jitter(value, spread) {
+    return value + randAroundZero(spread);
+};
+void 0;
+var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(hm, x, y) {
+    return 0 <= x && x <= hm.last && (0 <= y && y <= hm.last) ? (function () {
+        return hm[y * hm.resolution + x];
+    })() : void 0;
+};
+void 0;
+var normalize = exports.normalize = function normalize(hm) {
+    return function () {
+        var maxø1 = 0 - Infinity;
+        var minø1 = Infinity;
+        (function () {
+            var G__1ø1 = hm.length;
+            return function loop() {
+                var recur = loop;
+                var iø1 = 0;
+                do {
+                    recur = iø1 < G__1ø1 ? (function () {
+                        (function () {
+                            var elø1 = hm[iø1];
+                            maxø1 < elø1 ? (function () {
+                                return maxø1 = elø1;
+                            })() : void 0;
+                            return minø1 > elø1 ? (function () {
+                                return minø1 = elø1;
+                            })() : void 0;
+                        }.call(this));
+                        return loop[0] = 1 + iø1, loop;
+                    })() : void 0;
+                } while (iø1 = loop[0], recur === loop);
+                return recur;
+            }.call(this);
+        }.call(this));
+        return function () {
+            var spanø1 = maxø1 - minø1;
+            return function () {
+                var G__2ø1 = hm.length;
+                return function loop() {
+                    var recur = loop;
+                    var iø1 = 0;
+                    do {
+                        recur = iø1 < G__2ø1 ? (function () {
+                            hm[iø1] = (hm[iø1] - minø1) / spanø1;
+                            return loop[0] = 1 + iø1, loop;
+                        })() : void 0;
+                    } while (iø1 = loop[0], recur === loop);
+                    return recur;
+                }.call(this);
+            }.call(this);
+        }.call(this);
+    }.call(this);
+};
+var zeroHeightmap = exports.zeroHeightmap = function zeroHeightmap(heightmap) {
+    (function () {
+        var G__3ø1 = heightmap.length;
+        return function loop() {
+            var recur = loop;
+            var iø1 = 0;
+            do {
+                recur = iø1 < G__3ø1 ? (function () {
+                    heightmap[iø1] = 0;
+                    return loop[0] = 1 + iø1, loop;
+                })() : void 0;
+            } while (iø1 = loop[0], recur === loop);
+            return recur;
+        }.call(this);
+    }.call(this));
+    return heightmap;
+};
+var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
+    return function () {
+        var resolutionø1 = 1 + Math.pow(2, exponent);
+        l('Creating ' + resolutionø1 + ' by ' + resolutionø1 + ' heightmap...');
+        var heightmap = new Array(resolutionø1 * resolutionø1);
+        heightmap.resolution = resolutionø1;
+        heightmap.exponent = exponent;
+        heightmap.last = resolutionø1 - 1;
+        return zeroHeightmap(heightmap);
+    }.call(this);
+};
+var randomNoise = exports.randomNoise = function randomNoise(heightmap) {
+    return function () {
+        var G__4ø1 = heightmap.length;
+        return function loop() {
+            var recur = loop;
+            var iø1 = 0;
+            do {
+                recur = iø1 < G__4ø1 ? (function () {
+                    heightmap[iø1] = rand();
+                    return loop[0] = 1 + iø1, loop;
+                })() : void 0;
+            } while (iø1 = loop[0], recur === loop);
+            return recur;
+        }.call(this);
+    }.call(this);
+};
+var mpdInitCorners = exports.mpdInitCorners = function mpdInitCorners(heightmap) {
+    heightmap[0 * heightmap.resolution + 0] = rand();
+    heightmap[heightmap.last * heightmap.resolution + 0] = rand();
+    heightmap[0 * heightmap.resolution + heightmap.last] = rand();
+    return heightmap[heightmap.last * heightmap.resolution + heightmap.last] = rand();
+};
+var mpdDisplace = exports.mpdDisplace = function mpdDisplace(heightmap, lx, rx, by, ty, spread) {
+    return function () {
+        var cxø1 = midpoint(lx, rx);
+        var cyø1 = midpoint(by, ty);
+        var bottomLeftø1 = heightmap[by * heightmap.resolution + lx];
+        var bottomRightø1 = heightmap[by * heightmap.resolution + rx];
+        var topLeftø1 = heightmap[ty * heightmap.resolution + lx];
+        var topRightø1 = heightmap[ty * heightmap.resolution + rx];
+        var topø1 = average2(topLeftø1, topRightø1);
+        var leftø1 = average2(bottomLeftø1, topLeftø1);
+        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
+        var rightø1 = average2(bottomRightø1, topRightø1);
+        var centerø1 = average4(topø1, leftø1, bottomø1, rightø1);
+        heightmap[by * heightmap.resolution + cxø1] = jitter(bottomø1, spread);
+        heightmap[ty * heightmap.resolution + cxø1] = jitter(topø1, spread);
+        heightmap[cyø1 * heightmap.resolution + lx] = jitter(leftø1, spread);
+        heightmap[cyø1 * heightmap.resolution + rx] = jitter(rightø1, spread);
+        return heightmap[cyø1 * heightmap.resolution + cxø1] = jitter(centerø1, spread);
+    }.call(this);
+};
+var midpointDisplacement = exports.midpointDisplacement = function midpointDisplacement(heightmap) {
+    mpdInitCorners(heightmap);
+    (function loop() {
+        var recur = loop;
+        var iterø1 = 0;
+        var spreadø1 = 0.3;
+        do {
+            recur = iterø1 < heightmap.exponent ? (function () {
+                (function () {
+                    var chunksø1 = Math.pow(2, iterø1);
+                    var chunkWidthø1 = (heightmap.resolution - 1) / chunksø1;
+                    return function () {
+                        var G__5ø1 = chunksø1;
+                        return function () {
+                            var G__6ø1 = G__5ø1;
+                            return function loop() {
+                                var recur = loop;
+                                var xchunkø1 = 0;
+                                do {
+                                    recur = xchunkø1 < G__6ø1 ? (function () {
+                                        (function () {
+                                            var G__7ø1 = G__5ø1;
+                                            return function loop() {
+                                                var recur = loop;
+                                                var ychunkø1 = 0;
+                                                do {
+                                                    recur = ychunkø1 < G__7ø1 ? (function () {
+                                                        (function () {
+                                                            var leftXø1 = chunkWidthø1 * xchunkø1;
+                                                            var rightXø1 = leftXø1 + chunkWidthø1;
+                                                            var bottomYø1 = chunkWidthø1 * ychunkø1;
+                                                            var topYø1 = bottomYø1 + chunkWidthø1;
+                                                            return mpdDisplace(heightmap, leftXø1, rightXø1, bottomYø1, topYø1, spreadø1);
+                                                        }.call(this));
+                                                        return loop[0] = 1 + ychunkø1, loop;
+                                                    })() : void 0;
+                                                } while (ychunkø1 = loop[0], recur === loop);
+                                                return recur;
+                                            }.call(this);
+                                        }.call(this));
+                                        return loop[0] = 1 + xchunkø1, loop;
+                                    })() : void 0;
+                                } while (xchunkø1 = loop[0], recur === loop);
+                                return recur;
+                            }.call(this);
+                        }.call(this);
+                    }.call(this);
+                }.call(this));
+                return loop[0] = 1 + iterø1, loop[1] = spreadø1 * 0.5, loop;
+            })() : void 0;
+        } while (iterø1 = loop[0], spreadø1 = loop[1], recur === loop);
+        return recur;
+    }.call(this));
+    return normalize(heightmap);
+};
+var midpointDisplacementFinal = exports.midpointDisplacementFinal = function midpointDisplacementFinal(heightmap) {
+    mpdInitCorners(heightmap);
+    (function loop() {
+        var recur = loop;
+        var iterø1 = 0;
+        var spreadø1 = 0 + $('#input-starting-spread').val();
+        do {
+            recur = iterø1 < heightmap.exponent ? (function () {
+                (function () {
+                    var chunksø1 = Math.pow(2, iterø1);
+                    var chunkWidthø1 = (heightmap.resolution - 1) / chunksø1;
+                    return function () {
+                        var G__8ø1 = chunksø1;
+                        return function () {
+                            var G__9ø1 = G__8ø1;
+                            return function loop() {
+                                var recur = loop;
+                                var xchunkø1 = 0;
+                                do {
+                                    recur = xchunkø1 < G__9ø1 ? (function () {
+                                        (function () {
+                                            var G__10ø1 = G__8ø1;
+                                            return function loop() {
+                                                var recur = loop;
+                                                var ychunkø1 = 0;
+                                                do {
+                                                    recur = ychunkø1 < G__10ø1 ? (function () {
+                                                        (function () {
+                                                            var leftXø1 = chunkWidthø1 * xchunkø1;
+                                                            var rightXø1 = leftXø1 + chunkWidthø1;
+                                                            var bottomYø1 = chunkWidthø1 * ychunkø1;
+                                                            var topYø1 = bottomYø1 + chunkWidthø1;
+                                                            return mpdDisplace(heightmap, leftXø1, rightXø1, bottomYø1, topYø1, spreadø1);
+                                                        }.call(this));
+                                                        return loop[0] = 1 + ychunkø1, loop;
+                                                    })() : void 0;
+                                                } while (ychunkø1 = loop[0], recur === loop);
+                                                return recur;
+                                            }.call(this);
+                                        }.call(this));
+                                        return loop[0] = 1 + xchunkø1, loop;
+                                    })() : void 0;
+                                } while (xchunkø1 = loop[0], recur === loop);
+                                return recur;
+                            }.call(this);
+                        }.call(this);
+                    }.call(this);
+                }.call(this));
+                return loop[0] = 1 + iterø1, loop[1] = spreadø1 * (0 + $('#input-spread-reduction').val()), loop;
+            })() : void 0;
+        } while (iterø1 = loop[0], spreadø1 = loop[1], recur === loop);
+        return recur;
+    }.call(this));
+    return normalize(heightmap);
+};
+var mpdDisplaceD2 = exports.mpdDisplaceD2 = function mpdDisplaceD2(heightmap, lx, rx, by, ty, spread) {
+    return function () {
+        var cxø1 = midpoint(lx, rx);
+        var cyø1 = midpoint(by, ty);
+        var bottomLeftø1 = heightmap[by * heightmap.resolution + lx];
+        var bottomRightø1 = heightmap[by * heightmap.resolution + rx];
+        var topLeftø1 = heightmap[ty * heightmap.resolution + lx];
+        var topRightø1 = heightmap[ty * heightmap.resolution + rx];
+        var topø1 = average2(topLeftø1, topRightø1);
+        var leftø1 = average2(bottomLeftø1, topLeftø1);
+        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
+        var rightø1 = average2(bottomRightø1, topRightø1);
+        heightmap[by * heightmap.resolution + cxø1] = jitter(bottomø1, spread);
+        heightmap[ty * heightmap.resolution + cxø1] = jitter(topø1, spread);
+        heightmap[cyø1 * heightmap.resolution + lx] = jitter(leftø1, spread);
+        return heightmap[cyø1 * heightmap.resolution + rx] = jitter(rightø1, spread);
+    }.call(this);
+};
+var midpointDisplacementD1 = exports.midpointDisplacementD1 = function midpointDisplacementD1(heightmap) {
+    return mpdInitCorners(heightmap);
+};
+var midpointDisplacementD2 = exports.midpointDisplacementD2 = function midpointDisplacementD2(heightmap) {
+    mpdInitCorners(heightmap);
+    return mpdDisplaceD2(heightmap, 0, heightmap.last, 0, heightmap.last, 0.1);
+};
+var midpointDisplacementD3 = exports.midpointDisplacementD3 = function midpointDisplacementD3(heightmap) {
+    mpdInitCorners(heightmap);
+    return mpdDisplace(heightmap, 0, heightmap.last, 0, heightmap.last, 0.1);
+};
+var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
+    return function () {
+        var lightø1 = new THREE.DirectionalLight(16777215, 1);
+        lightø1.position.set(100, 0, 150);
+        return lightø1;
+    }.call(this);
+};
+var makeCamera = exports.makeCamera = function makeCamera() {
+    return function () {
+        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
+        cameraø1.position.set(0, -100, 150);
+        return cameraø1;
+    }.call(this);
+};
+var makeRenderer = exports.makeRenderer = function makeRenderer() {
+    return function () {
+        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
+        rendererø1.setClearColor(16777215);
+        rendererø1.setSize(width, height);
+        rendererø1.setPixelRatio(2);
+        return rendererø1;
+    }.call(this);
+};
+var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
+    return function () {
+        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, heightmap.resolution - 1, heightmap.resolution - 1);
+        geometryø1.dynamic = true;
+        return geometryø1;
+    }.call(this);
+};
+var makeControls = exports.makeControls = function makeControls(camera, renderer) {
+    return function () {
+        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
+        controlsø1.rotateSpeed = 1.4;
+        controlsø1.zoomSpeed = 0.5;
+        controlsø1.staticMoving = true;
+        controlsø1.dynamicDampingFactor = 0.3;
+        return controlsø1;
+    }.call(this);
+};
+var makePlane = exports.makePlane = function makePlane(geometry) {
+    return function () {
+        var materialø1 = new THREE.MeshLambertMaterial({
+            'wireframe': wireframe,
+            'wireframeLinewidth': wireframeWidth,
+            'color': 47872
+        });
+        return new THREE.Mesh(geometry, materialø1);
+    }.call(this);
+};
+var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
+    return function () {
+        var containerø1 = document.getElementById(elName);
+        var settingsø1 = document.createElement('div');
+        var refreshButtonø1 = document.createElement('button');
+        var buttonTextø1 = document.createTextNode('Refresh');
+        var cancelScrollø1 = function (e) {
+            return e.preventDefault();
+        };
+        refreshButtonø1.onclick = refreshFn;
+        renderer.domElement.onmousewheel = cancelScrollø1;
+        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
+        refreshButtonø1.appendChild(buttonTextø1);
+        containerø1.appendChild(renderer.domElement);
+        containerø1.appendChild(settingsø1);
+        return settingsø1.appendChild(refreshButtonø1);
+    }.call(this);
+};
+var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
+    (function () {
+        var G__11ø1 = geometry.vertices.length;
+        return function loop() {
+            var recur = loop;
+            var iø1 = 0;
+            do {
+                recur = iø1 < G__11ø1 ? (function () {
+                    geometry.vertices[iø1].z = terrainHeight * heightmap[iø1];
+                    return loop[0] = 1 + iø1, loop;
+                })() : void 0;
+            } while (iø1 = loop[0], recur === loop);
+            return recur;
+        }.call(this);
+    }.call(this));
+    geometry.verticesNeedUpdate = true;
+    geometry.computeFaceNormals();
+    geometry.computeVertexNormals();
+    geometry.computeMorphNormals();
+    return geometry;
+};
+var makeDemo = exports.makeDemo = function makeDemo(elementId, algorithm, size) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var geometry = makeGeometry(makeHeightmap(size));
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    scene.add(makePlane(geometry));
+    var refresh = function refresh() {
+        l('Refreshing ========================================');
+        return function () {
+            var heightmapø1 = makeHeightmap(size);
+            l('Generating terrain...');
+            (function () {
+                var G__12ø1 = new Date().getTime();
+                var G__14ø1 = (function () {
+                    return algorithm(heightmapø1);
+                })();
+                var G__13ø1 = new Date().getTime();
+                l('Elapsed time: ' + (G__13ø1 - G__12ø1) + 'ms.');
+                return G__14ø1;
+            }.call(this));
+            l('Refreshing geometry...');
+            (function () {
+                var G__15ø1 = new Date().getTime();
+                var G__17ø1 = (function () {
+                    return updateGeometry(geometry, heightmapø1);
+                })();
+                var G__16ø1 = new Date().getTime();
+                l('Elapsed time: ' + (G__16ø1 - G__15ø1) + 'ms.');
+                return G__17ø1;
+            }.call(this));
+            return l('Done!');
+        }.call(this);
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    render();
+    return void 0;
+};
+var makeFinal = exports.makeFinal = function makeFinal(elementId) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var heightmap = makeHeightmap($('#input-exponent').val());
+    var geometry = makeGeometry(heightmap);
+    var plane = makePlane(geometry);
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    scene.add(plane);
+    var refresh = function refresh() {
+        l('Refreshing ========================================');
+        scene.remove(plane);
+        heightmap = makeHeightmap($('#input-exponent').val());
+        geometry = makeGeometry(heightmap);
+        plane = makePlane(geometry);
+        scene.add(plane);
+        l('Generating terrain...');
+        (function () {
+            var G__18ø1 = new Date().getTime();
+            var G__20ø1 = (function () {
+                return midpointDisplacementFinal(heightmap);
+            })();
+            var G__19ø1 = new Date().getTime();
+            l('Elapsed time: ' + (G__19ø1 - G__18ø1) + 'ms.');
+            return G__20ø1;
+        }.call(this));
+        l('Refreshing geometry...');
+        (function () {
+            var G__21ø1 = new Date().getTime();
+            var G__23ø1 = (function () {
+                return updateGeometry(geometry, heightmap);
+            })();
+            var G__22ø1 = new Date().getTime();
+            l('Elapsed time: ' + (G__22ø1 - G__21ø1) + 'ms.');
+            return G__23ø1;
+        }.call(this));
+        return l('Done!');
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    render();
+    return void 0;
+};
+var run = exports.run = function run() {
+    makeDemo('demo-random', randomNoise, 7);
+    makeDemo('demo-mpd-1', midpointDisplacementD1, 2);
+    makeDemo('demo-mpd-2', midpointDisplacementD2, 2);
+    makeDemo('demo-mpd-3', midpointDisplacementD3, 2);
+    makeDemo('demo-mpd-4', midpointDisplacement, 3);
+    return makeFinal('demo-final');
+};
+$(run);
+
+
+},{}]},{},[1])
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Vzci9sb2NhbC9saWIvbm9kZV9tb2R1bGVzL2Jyb3dzZXJpZnkvbm9kZV9tb2R1bGVzL2Jyb3dzZXItcGFjay9fcHJlbHVkZS5qcyIsIm1lZGlhL2pzL3dpc3AvYW5vbnltb3VzLndpc3AiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7QUNDQSxJQUFLLEtBQUEsR0FBQSxPQUFBLENBQUEsS0FBQSxHQUFNLEdBQVg7QUFDQSxJQUFLLE1BQUEsR0FBQSxPQUFBLENBQUEsTUFBQSxHQUFPLEdBQVosQ0FEQTtBQUVBLElBQUssU0FBQSxHQUFBLE9BQUEsQ0FBQSxTQUFBLEcsSUFBTCxDQUZBO0FBR0EsSUFBSyxjQUFBLEdBQUEsT0FBQSxDQUFBLGNBQUEsR0FBZ0IsR0FBckIsQ0FIQTtBQUlBLElBQUssYUFBQSxHQUFBLE9BQUEsQ0FBQSxhQUFBLEdBQWUsRUFBcEIsQ0FKQTtBQUtBLElBQUssV0FBQSxHQUFBLE9B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RvbS1ub2lzZSA3KVxuICAobWFrZS1kZW1vIFwiZGVtby1tcGQtMVwiIG1pZHBvaW50LWRpc3BsYWNlbWVudC1kMSAyKVxuICAobWFrZS1kZW1vIFwiZGVtby1tcGQtMlwiIG1pZHBvaW50LWRpc3BsYWNlbWVudC1kMiAyKVxuICAobWFrZS1kZW1vIFwiZGVtby1tcGQtM1wiIG1pZHBvaW50LWRpc3BsYWNlbWVudC1kMyAyKVxuICAobWFrZS1kZW1vIFwiZGVtby1tcGQtNFwiIG1pZHBvaW50LWRpc3BsYWNlbWVudCAzKVxuICAobWFrZS1maW5hbCBcImRlbW8tZmluYWxcIilcbiAgOyAobWFrZS1kZW1vIFwiZGVtby1taWRwb2ludFwiIG1pZHBvaW50LWRpc3BsYWNlbWVudClcbiAgOyAobWFrZS1kZW1vIFwiZGVtby1kaWFtb25kXCIgZGlhbW9uZC1zcXVhcmUpXG5cbiAgKVxuXG4oJCBydW4pXG5cblxuOyB2aW06IGx3Kz1kby10aW1lcyBsdys9ZG8tbmVzdGVkIDpcbiJdfQ==
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/terrain2.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,784 @@
+(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+{
+    var _ns_ = {
+        id: 'demo',
+        doc: void 0
+    };
+    var ndarray = require('ndarray');
+}
+var width = exports.width = 610;
+var height = exports.height = 400;
+var wireframe = exports.wireframe = true;
+var wireframeWidth = exports.wireframeWidth = 1.2;
+var terrainHeight = exports.terrainHeight = 50;
+var terrainSize = exports.terrainSize = 100;
+void 0;
+void 0;
+void 0;
+var inc = exports.inc = function inc(x) {
+    return x + 1;
+};
+var dec = exports.dec = function dec(x) {
+    return x - 1;
+};
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+var midpoint = exports.midpoint = function midpoint(a, b) {
+    return (a + b) / 2;
+};
+var average2 = exports.average2 = function average2(a, b) {
+    return (a + b) / 2;
+};
+var average4 = exports.average4 = function average4(a, b, c, d) {
+    return (a + b + c + d) / 4;
+};
+var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
+    return function () {
+        var totalø1 = 0;
+        var countø1 = 0;
+        a ? (function () {
+            totalø1 = totalø1 + a;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        b ? (function () {
+            totalø1 = totalø1 + b;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        c ? (function () {
+            totalø1 = totalø1 + c;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        d ? (function () {
+            totalø1 = totalø1 + d;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        return totalø1 / countø1;
+    }.call(this);
+};
+var rand = exports.rand = function rand() {
+    return Math.random();
+};
+var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
+    return spread * rand() * 2 - spread;
+};
+var jitter = exports.jitter = function jitter(value, spread) {
+    return value + randAroundZero(spread);
+};
+var heightmapResolution = exports.heightmapResolution = function heightmapResolution(heightmap) {
+    return heightmap.shape[0];
+};
+var heightmapLastIndex = exports.heightmapLastIndex = function heightmapLastIndex(heightmap) {
+    return dec(heightmapResolution(heightmap));
+};
+var heightmapCenterIndex = exports.heightmapCenterIndex = function heightmapCenterIndex(heightmap) {
+    return midpoint(0, heightmapLastIndex(heightmap));
+};
+var heightmapGet = exports.heightmapGet = function heightmapGet(heightmap, x, y) {
+    return heightmap.get(x, y);
+};
+var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(heightmap, x, y) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        return 0 <= x && x <= lastø1 && (0 <= y && y <= lastø1) ? (function () {
+            return heightmapGet(heightmap, x, y);
+        })() : void 0;
+    }.call(this);
+};
+var heightmapSet = exports.heightmapSet = function heightmapSet(heightmap, x, y, val) {
+    return heightmap.set(x, y, val);
+};
+var heightmapSetIfUnset = exports.heightmapSetIfUnset = function heightmapSetIfUnset(heightmap, x, y, val) {
+    return 0 == heightmapGet(heightmap, x, y) ? (function () {
+        return heightmapSet(heightmap, x, y, val);
+    })() : void 0;
+};
+var normalize = exports.normalize = function normalize(heightmap) {
+    return function () {
+        var maxø1 = 0 - Infinity;
+        var minø1 = Infinity;
+        (function () {
+            var array2ø1 = heightmap;
+            return function () {
+                var G__3ø1 = array2ø1.data.length;
+                return function loop() {
+                    var recur = loop;
+                    var index1ø1 = 0;
+                    do {
+                        recur = index1ø1 < G__3ø1 ? (function () {
+                            (function () {
+                                var elø1 = array2ø1.data[index1ø1];
+                                maxø1 < elø1 ? (function () {
+                                    return maxø1 = elø1;
+                                })() : void 0;
+                                return minø1 > elø1 ? (function () {
+                                    return minø1 = elø1;
+                                })() : void 0;
+                            }.call(this));
+                            return loop[0] = inc(index1ø1), loop;
+                        })() : void 0;
+                    } while (index1ø1 = loop[0], recur === loop);
+                    return recur;
+                }.call(this);
+            }.call(this);
+        }.call(this));
+        return function () {
+            var spanø1 = maxø1 - minø1;
+            return function () {
+                var array4ø1 = heightmap;
+                return function () {
+                    var G__5ø1 = array4ø1.shape[0];
+                    return function loop() {
+                        var recur = loop;
+                        var xø1 = 0;
+                        do {
+                            recur = xø1 < G__5ø1 ? (function () {
+                                (function () {
+                                    var G__6ø1 = array4ø1.shape[1];
+                                    return function loop() {
+                                        var recur = loop;
+                                        var yø1 = 0;
+                                        do {
+                                            recur = yø1 < G__6ø1 ? (function () {
+                                                (function () {
+                                                    return heightmapSet(heightmap, xø1, yø1, (heightmapGet(heightmap, xø1, yø1) - minø1) / spanø1);
+                                                })();
+                                                return loop[0] = inc(yø1), loop;
+                                            })() : void 0;
+                                        } while (yø1 = loop[0], recur === loop);
+                                        return recur;
+                                    }.call(this);
+                                }.call(this));
+                                return loop[0] = inc(xø1), loop;
+                            })() : void 0;
+                        } while (xø1 = loop[0], recur === loop);
+                        return recur;
+                    }.call(this);
+                }.call(this);
+            }.call(this);
+        }.call(this);
+    }.call(this);
+};
+var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
+    return function () {
+        var resolutionø1 = Math.pow(2, exponent) + 1;
+        return function () {
+            var heightmapø1 = ndarray(new Float64Array(resolutionø1 * resolutionø1), [
+                resolutionø1,
+                resolutionø1
+            ]);
+            heightmapø1.exponent = exponent;
+            heightmapø1.resolution = resolutionø1;
+            heightmapø1.last = dec(resolutionø1);
+            return heightmapø1;
+        }.call(this);
+    }.call(this);
+};
+var topLeftCorner = exports.topLeftCorner = function topLeftCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(0, 0).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var topRightCorner = exports.topRightCorner = function topRightCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(centerø1, 0).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var bottomLeftCorner = exports.bottomLeftCorner = function bottomLeftCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(0, centerø1).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var bottomRightCorner = exports.bottomRightCorner = function bottomRightCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(centerø1, centerø1).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var mpdInitCorners = exports.mpdInitCorners = function mpdInitCorners(heightmap) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        heightmapSet(heightmap, 0, 0, rand());
+        heightmapSet(heightmap, 0, lastø1, rand());
+        heightmapSet(heightmap, lastø1, 0, rand());
+        return heightmapSet(heightmap, lastø1, lastø1, rand());
+    }.call(this);
+};
+var mpdDisplace = exports.mpdDisplace = function mpdDisplace(heightmap, spread, spreadReduction) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        var cø1 = midpoint(0, lastø1);
+        var bottomLeftø1 = heightmapGet(heightmap, 0, 0);
+        var bottomRightø1 = heightmapGet(heightmap, lastø1, 0);
+        var topLeftø1 = heightmapGet(heightmap, 0, lastø1);
+        var topRightø1 = heightmapGet(heightmap, lastø1, lastø1);
+        var topø1 = average2(topLeftø1, topRightø1);
+        var leftø1 = average2(bottomLeftø1, topLeftø1);
+        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
+        var rightø1 = average2(bottomRightø1, topRightø1);
+        var centerø1 = average4(topø1, leftø1, bottomø1, rightø1);
+        var nextSpreadø1 = spread * spreadReduction;
+        heightmapSetIfUnset(heightmap, cø1, 0, jitter(bottomø1, spread));
+        heightmapSetIfUnset(heightmap, cø1, lastø1, jitter(topø1, spread));
+        heightmapSetIfUnset(heightmap, 0, cø1, jitter(leftø1, spread));
+        heightmapSetIfUnset(heightmap, lastø1, cø1, jitter(rightø1, spread));
+        heightmapSetIfUnset(heightmap, cø1, cø1, jitter(centerø1, spread));
+        return !(3 == heightmapResolution(heightmap)) ? (function () {
+            heightmapSetIfUnset(heightmap, cø1, 0, jitter(bottomø1, spread));
+            heightmapSetIfUnset(heightmap, cø1, lastø1, jitter(topø1, spread));
+            heightmapSetIfUnset(heightmap, 0, cø1, jitter(leftø1, spread));
+            heightmapSetIfUnset(heightmap, lastø1, cø1, jitter(rightø1, spread));
+            heightmapSetIfUnset(heightmap, cø1, cø1, jitter(centerø1, spread));
+            mpdDisplace(topLeftCorner(heightmap), nextSpreadø1, spreadReduction);
+            mpdDisplace(topRightCorner(heightmap), nextSpreadø1, spreadReduction);
+            mpdDisplace(bottomLeftCorner(heightmap), nextSpreadø1, spreadReduction);
+            return mpdDisplace(bottomRightCorner(heightmap), nextSpreadø1, spreadReduction);
+        })() : void 0;
+    }.call(this);
+};
+var midpointDisplacement = exports.midpointDisplacement = function midpointDisplacement(heightmap) {
+    return function () {
+        var initialSpreadø1 = 0.3;
+        var spreadReductionø1 = 0.55;
+        mpdInitCorners(heightmap);
+        mpdDisplace(heightmap, initialSpreadø1, spreadReductionø1);
+        return normalize(heightmap);
+    }.call(this);
+};
+var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
+    return function () {
+        var lightø1 = new THREE.DirectionalLight(16777215, 1);
+        lightø1.position.set(100, 0, 150);
+        return lightø1;
+    }.call(this);
+};
+var makeCamera = exports.makeCamera = function makeCamera() {
+    return function () {
+        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
+        cameraø1.position.set(0, -100, 150);
+        return cameraø1;
+    }.call(this);
+};
+var makeRenderer = exports.makeRenderer = function makeRenderer() {
+    return function () {
+        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
+        rendererø1.setClearColor(16777215);
+        rendererø1.setSize(width, height);
+        rendererø1.setPixelRatio(2);
+        return rendererø1;
+    }.call(this);
+};
+var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
+    return function () {
+        var resolutionø1 = heightmap.shape[0];
+        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, resolutionø1 - 1, resolutionø1 - 1);
+        return geometryø1;
+    }.call(this);
+};
+var makeControls = exports.makeControls = function makeControls(camera, renderer) {
+    return function () {
+        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
+        controlsø1.rotateSpeed = 1.4;
+        controlsø1.zoomSpeed = 0.5;
+        controlsø1.staticMoving = true;
+        controlsø1.dynamicDampingFactor = 0.3;
+        return controlsø1;
+    }.call(this);
+};
+var makePlane = exports.makePlane = function makePlane(geometry) {
+    return function () {
+        var materialø1 = new THREE.MeshLambertMaterial({
+            'wireframe': wireframe,
+            'wireframeLinewidth': wireframeWidth,
+            'color': 47872
+        });
+        return new THREE.Mesh(geometry, materialø1);
+    }.call(this);
+};
+var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
+    return function () {
+        var containerø1 = document.getElementById(elName);
+        var settingsø1 = document.createElement('div');
+        var refreshButtonø1 = document.createElement('button');
+        var buttonTextø1 = document.createTextNode('Refresh');
+        var cancelScrollø1 = function (e) {
+            return e.preventDefault();
+        };
+        refreshButtonø1.onclick = refreshFn;
+        renderer.domElement.onmousewheel = cancelScrollø1;
+        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
+        refreshButtonø1.appendChild(buttonTextø1);
+        containerø1.appendChild(renderer.domElement);
+        containerø1.appendChild(settingsø1);
+        return settingsø1.appendChild(refreshButtonø1);
+    }.call(this);
+};
+var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
+    (function loop() {
+        var recur = loop;
+        var iø1 = 0;
+        do {
+            recur = iø1 < geometry.vertices.length ? (function () {
+                geometry.vertices[iø1].z = terrainHeight * heightmap.data[iø1];
+                return loop[0] = iø1 + 1, loop;
+            })() : void 0;
+        } while (iø1 = loop[0], recur === loop);
+        return recur;
+    }.call(this));
+    geometry.computeVertexNormals();
+    return geometry;
+};
+var makeFinal = exports.makeFinal = function makeFinal(elementId) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var geometry = void 0;
+    var plane = void 0;
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    var refresh = function refresh() {
+        return function () {
+            var heightmapø1 = makeHeightmap(6);
+            console.log('Generating terrain...');
+            (function () {
+                var G__7ø1 = new Date().getTime();
+                var G__9ø1 = (function () {
+                    return midpointDisplacement(heightmapø1);
+                })();
+                var G__8ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__8ø1 - G__7ø1) + 'ms.');
+                return G__9ø1;
+            }.call(this));
+            console.log('Rebuilding geometry...');
+            (function () {
+                var G__10ø1 = new Date().getTime();
+                var G__12ø1 = (function () {
+                    geometry = makeGeometry(heightmapø1);
+                    return updateGeometry(geometry, heightmapø1);
+                })();
+                var G__11ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__11ø1 - G__10ø1) + 'ms.');
+                return G__12ø1;
+            }.call(this));
+            console.log('Rebuilding plane...');
+            return function () {
+                var G__13ø1 = new Date().getTime();
+                var G__15ø1 = (function () {
+                    scene.remove(plane);
+                    plane = makePlane(geometry);
+                    return scene.add(plane);
+                })();
+                var G__14ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__14ø1 - G__13ø1) + 'ms.');
+                return G__15ø1;
+            }.call(this);
+        }.call(this);
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    refresh();
+    render();
+    return void 0;
+};
+var run = exports.run = function run() {
+    return makeFinal('demo-final');
+};
+$(run);
+
+
+},{"ndarray":4}],2:[function(require,module,exports){
+"use strict"
+
+function iota(n) {
+  var result = new Array(n)
+  for(var i=0; i<n; ++i) {
+    result[i] = i
+  }
+  return result
+}
+
+module.exports = iota
+},{}],3:[function(require,module,exports){
+/**
+ * Determine if an object is Buffer
+ *
+ * Author:   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
+ * License:  MIT
+ *
+ * `npm install is-buffer`
+ */
+
+module.exports = function (obj) {
+  return !!(obj != null &&
+    (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor)
+      (obj.constructor &&
+      typeof obj.constructor.isBuffer === 'function' &&
+      obj.constructor.isBuffer(obj))
+    ))
+}
+
+},{}],4:[function(require,module,exports){
+var iota = require("iota-array")
+var isBuffer = require("is-buffer")
+
+var hasTypedArrays  = ((typeof Float64Array) !== "undefined")
+
+function compare1st(a, b) {
+  return a[0] - b[0]
+}
+
+function order() {
+  var stride = this.stride
+  var terms = new Array(stride.length)
+  var i
+  for(i=0; i<terms.length; ++i) {
+    terms[i] = [Math.abs(stride[i]), i]
+  }
+  terms.sort(compare1st)
+  var result = new Array(terms.length)
+  for(i=0; i<result.length; ++i) {
+    result[i] = terms[i][1]
+  }
+  return result
+}
+
+function compileConstructor(dtype, dimension) {
+  var className = ["View", dimension, "d", dtype].join("")
+  if(dimension < 0) {
+    className = "View_Nil" + dtype
+  }
+  var useGetters = (dtype === "generic")
+
+  if(dimension === -1) {
+    //Special case for trivial arrays
+    var code =
+      "function "+className+"(a){this.data=a;};\
+var proto="+className+".prototype;\
+proto.dtype='"+dtype+"';\
+proto.index=function(){return -1};\
+proto.size=0;\
+proto.dimension=-1;\
+proto.shape=proto.stride=proto.order=[];\
+proto.lo=proto.hi=proto.transpose=proto.step=\
+function(){return new "+className+"(this.data);};\
+proto.get=proto.set=function(){};\
+proto.pick=function(){return null};\
+return function construct_"+className+"(a){return new "+className+"(a);}"
+    var procedure = new Function(code)
+    return procedure()
+  } else if(dimension === 0) {
+    //Special case for 0d arrays
+    var code =
+      "function "+className+"(a,d) {\
+this.data = a;\
+this.offset = d\
+};\
+var proto="+className+".prototype;\
+proto.dtype='"+dtype+"';\
+proto.index=function(){return this.offset};\
+proto.dimension=0;\
+proto.size=1;\
+proto.shape=\
+proto.stride=\
+proto.order=[];\
+proto.lo=\
+proto.hi=\
+proto.transpose=\
+proto.step=function "+className+"_copy() {\
+return new "+className+"(this.data,this.offset)\
+};\
+proto.pick=function "+className+"_pick(){\
+return TrivialArray(this.data);\
+};\
+proto.valueOf=proto.get=function "+className+"_get(){\
+return "+(useGetters ? "this.data.get(this.offset)" : "this.data[this.offset]")+
+"};\
+proto.set=function "+className+"_set(v){\
+return "+(useGetters ? "this.data.set(this.offset,v)" : "this.data[this.offset]=v")+"\
+};\
+return function construct_"+className+"(a,b,c,d){return new "+className+"(a,d)}"
+    var procedure = new Function("TrivialArray", code)
+    return procedure(CACHED_CONSTRUCTORS[dtype][0])
+  }
+
+  var code = ["'use strict'"]
+
+  //Create constructor for view
+  var indices = iota(dimension)
+  var args = indices.map(function(i) { return "i"+i })
+  var index_str = "this.offset+" + indices.map(function(i) {
+        return "this.stride[" + i + "]*i" + i
+      }).join("+")
+  var shapeArg = indices.map(function(i) {
+      return "b"+i
+    }).join(",")
+  var strideArg = indices.map(function(i) {
+      return "c"+i
+    }).join(",")
+  code.push(
+    "function "+className+"(a," + shapeArg + "," + strideArg + ",d){this.data=a",
+      "this.shape=[" + shapeArg + "]",
+      "this.stride=[" + strideArg + "]",
+      "this.offset=d|0}",
+    "var proto="+className+".prototype",
+    "proto.dtype='"+dtype+"'",
+    "proto.dimension="+dimension)
+
+  //view.size:
+  code.push("Object.defineProperty(proto,'size',{get:function "+className+"_size(){\
+return "+indices.map(function(i) { return "this.shape["+i+"]" }).join("*"),
+"}})")
+
+  //view.order:
+  if(dimension === 1) {
+    code.push("proto.order=[0]")
+  } else {
+    code.push("Object.defineProperty(proto,'order',{get:")
+    if(dimension < 4) {
+      code.push("function "+className+"_order(){")
+      if(dimension === 2) {
+        code.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})")
+      } else if(dimension === 3) {
+        code.push(
+"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);\
+if(s0>s1){\
+if(s1>s2){\
+return [2,1,0];\
+}else if(s0>s2){\
+return [1,2,0];\
+}else{\
+return [1,0,2];\
+}\
+}else if(s0>s2){\
+return [2,0,1];\
+}else if(s2>s1){\
+return [0,1,2];\
+}else{\
+return [0,2,1];\
+}}})")
+      }
+    } else {
+      code.push("ORDER})")
+    }
+  }
+
+  //view.set(i0, ..., v):
+  code.push(
+"proto.set=function "+className+"_set("+args.join(",")+",v){")
+  if(useGetters) {
+    code.push("return this.data.set("+index_str+",v)}")
+  } else {
+    code.push("return this.data["+index_str+"]=v}")
+  }
+
+  //view.get(i0, ...):
+  code.push("proto.get=function "+className+"_get("+args.join(",")+"){")
+  if(useGetters) {
+    code.push("return this.data.get("+index_str+")}")
+  } else {
+    code.push("return this.data["+index_str+"]}")
+  }
+
+  //view.index:
+  code.push(
+    "proto.index=function "+className+"_index(", args.join(), "){return "+index_str+"}")
+
+  //view.hi():
+  code.push("proto.hi=function "+className+"_hi("+args.join(",")+"){return new "+className+"(this.data,"+
+    indices.map(function(i) {
+      return ["(typeof i",i,"!=='number'||i",i,"<0)?this.shape[", i, "]:i", i,"|0"].join("")
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "this.stride["+i + "]"
+    }).join(",")+",this.offset)}")
+
+  //view.lo():
+  var a_vars = indices.map(function(i) { return "a"+i+"=this.shape["+i+"]" })
+  var c_vars = indices.map(function(i) { return "c"+i+"=this.stride["+i+"]" })
+  code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(","))
+  for(var i=0; i<dimension; ++i) {
+    code.push(
+"if(typeof i"+i+"==='number'&&i"+i+">=0){\
+d=i"+i+"|0;\
+b+=c"+i+"*d;\
+a"+i+"-=d}")
+  }
+  code.push("return new "+className+"(this.data,"+
+    indices.map(function(i) {
+      return "a"+i
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "c"+i
+    }).join(",")+",b)}")
+
+  //view.step():
+  code.push("proto.step=function "+className+"_step("+args.join(",")+"){var "+
+    indices.map(function(i) {
+      return "a"+i+"=this.shape["+i+"]"
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "b"+i+"=this.stride["+i+"]"
+    }).join(",")+",c=this.offset,d=0,ceil=Math.ceil")
+  for(var i=0; i<dimension; ++i) {
+    code.push(
+"if(typeof i"+i+"==='number'){\
+d=i"+i+"|0;\
+if(d<0){\
+c+=b"+i+"*(a"+i+"-1);\
+a"+i+"=ceil(-a"+i+"/d)\
+}else{\
+a"+i+"=ceil(a"+i+"/d)\
+}\
+b"+i+"*=d\
+}")
+  }
+  code.push("return new "+className+"(this.data,"+
+    indices.map(function(i) {
+      return "a" + i
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "b" + i
+    }).join(",")+",c)}")
+
+  //view.transpose():
+  var tShape = new Array(dimension)
+  var tStride = new Array(dimension)
+  for(var i=0; i<dimension; ++i) {
+    tShape[i] = "a[i"+i+"]"
+    tStride[i] = "b[i"+i+"]"
+  }
+  code.push("proto.transpose=function "+className+"_transpose("+args+"){"+
+    args.map(function(n,idx) { return n + "=(" + n + "===undefined?" + idx + ":" + n + "|0)"}).join(";"),
+    "var a=this.shape,b=this.stride;return new "+className+"(this.data,"+tShape.join(",")+","+tStride.join(",")+",this.offset)}")
+
+  //view.pick():
+  code.push("proto.pick=function "+className+"_pick("+args+"){var a=[],b=[],c=this.offset")
+  for(var i=0; i<dimension; ++i) {
+    code.push("if(typeof i"+i+"==='number'&&i"+i+">=0){c=(c+this.stride["+i+"]*i"+i+")|0}else{a.push(this.shape["+i+"]);b.push(this.stride["+i+"])}")
+  }
+  code.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}")
+
+  //Add return statement
+  code.push("return function construct_"+className+"(data,shape,stride,offset){return new "+className+"(data,"+
+    indices.map(function(i) {
+      return "shape["+i+"]"
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "stride["+i+"]"
+    }).join(",")+",offset)}")
+
+  //Compile procedure
+  var procedure = new Function("CTOR_LIST", "ORDER", code.join("\n"))
+  return procedure(CACHED_CONSTRUCTORS[dtype], order)
+}
+
+function arrayDType(data) {
+  if(isBuffer(data)) {
+    return "buffer"
+  }
+  if(hasTypedArrays) {
+    switch(Object.prototype.toString.call(data)) {
+      case "[object Float64Array]":
+        return "float64"
+      case "[object Float32Array]":
+        return "float32"
+      case "[object Int8Array]":
+        return "int8"
+      case "[object Int16Array]":
+        return "int16"
+      case "[object Int32Array]":
+        return "int32"
+      case "[object Uint8Array]":
+        return "uint8"
+      case "[object Uint16Array]":
+        return "uint16"
+      case "[object Uint32Array]":
+        return "uint32"
+      case "[object Uint8ClampedArray]":
+        return "uint8_clamped"
+    }
+  }
+  if(Array.isArray(data)) {
+    return "array"
+  }
+  return "generic"
+}
+
+var CACHED_CONSTRUCTORS = {
+  "float32":[],
+  "float64":[],
+  "int8":[],
+  "int16":[],
+  "int32":[],
+  "uint8":[],
+  "uint16":[],
+  "uint32":[],
+  "array":[],
+  "uint8_clamped":[],
+  "buffer":[],
+  "generic":[]
+}
+
+;(function() {
+  for(var id in CACHED_CONSTRUCTORS) {
+    CACHED_CONSTRUCTORS[id].push(compileConstructor(id, -1))
+  }
+});
+
+function wrappedNDArrayCtor(data, shape, stride, offset) {
+  if(data === undefined) {
+    var ctor = CACHED_CONSTRUCTORS.array[0]
+    return ctor([])
+  } else if(typeof data === "number") {
+    data = [data]
+  }
+  if(shape === undefined) {
+    shape = [ data.length ]
+  }
+  var d = shape.length
+  if(stride === undefined) {
+    stride = new Array(d)
+    for(var i=d-1, sz=1; i>=0; --i) {
+      stride[i] = sz
+      sz *= shape[i]
+    }
+  }
+  if(offset === undefined) {
+    offset = 0
+    for(var i=0; i<d; ++i) {
+      if(stride[i] < 0) {
+        offset -= (shape[i]-1)*stride[i]
+      }
+    }
+  }
+  var dtype = arrayDType(data)
+  var ctor_list = CACHED_CONSTRUCTORS[dtype]
+  while(ctor_list.length <= d+1) {
+    ctor_list.push(compileConstructor(dtype, ctor_list.length-1))
+  }
+  var ctor = ctor_list[d+1]
+  return ctor(data, shape, stride, offset)
+}
+
+module.exports = wrappedNDArrayCtor
+
+},{"iota-array":2,"is-buffer":3}]},{},[1])
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Vzci9sb2NhbC9saWIvbm9kZV9tb2R1bGVzL2Jyb3dzZXJpZnkvbm9kZV9tb2R1bGVzL2Jyb3dzZXItcGFjay9fcHJ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jdGl2ZUNhbWVyYVxuICAgICAgICAgICAgICAgICAgICA1NSxcbiAgICAgICAgICAgICAgICAgICAgKC8gd2lkdGggaGVpZ2h0KVxuICAgICAgICAgICAgICAgICAgICAwLjEsXG4gICAgICAgICAgICAgICAgICAgIDEwMDApXVxuICAgIChjYW1lcmEucG9zaXRpb24uc2V0IDAgLTEwMCAxNTApXG4gICAgY2FtZXJhKSlcblxuKGRlZm4gbWFrZS1yZW5kZXJlciBbXVxuICAobGV0IFtyZW5kZXJlciAobmV3IFRIUkVFLldlYkdMUmVuZGVyZXIgezphbnRpYWxpYXMgZmFsc2V9KV1cbiAgICAocmVuZGVyZXIuc2V0Q2xlYXJDb2xvciAweGZmZmZmZilcbiAgICAocmVuZGVyZXIuc2V0U2l6ZSB3aWR0aCBoZWlnaHQpXG4gICAgKHJlbmRlcmVyLnNldFBpeGVsUmF0aW8gMilcbiAgICByZW5kZXJlcikpXG5cbihkZWZuIG1ha2UtZ2VvbWV0cnkgW2hlaWdodG1hcF1cbiAgKGxldCBbcmVzb2x1dGlvbiAoYWdldCBoZWlnaHRtYXAuc2hhcGUgMClcbiAgICAgICAgZ2VvbWV0cnkgKG5ldyBUSFJFRS5QbGFuZUdlb21ldHJ5XG4gICAgICAgICAgICAgICAgICAgICAgdGVycmFpbi1zaXplXG4gICAgICAgICAgICAgICAgICAgICAgdGVycmFpbi1zaXplXG4gICAgICAgICAgICAgICAgICAgICAgKC0gcmVzb2x1dGlvbiAxKVxuICAgICAgICAgICAgICAgICAgICAgICgtIHJlc29sdXRpb24gMSkpXVxuICAgIGdlb21ldHJ5KSlcblxuKGRlZm4gbWFrZS1jb250cm9scyBbY2FtZXJhIHJlbmRlcmVyXVxuICAobGV0IFtjb250cm9scyAobmV3IFRIUkVFLlRyYWNrYmFsbENvbnRyb2xzIGNhbWVyYSByZW5kZXJlci5kb21FbGVtZW50KV1cbiAgICAoc2V0ISBjb250cm9scy5yb3RhdGVTcGVlZCAxLjQpXG4gICAgKHNldCEgY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 @@
+(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
+{
+    var _ns_ = {
+        id: 'demo',
+        doc: void 0
+    };
+    var ndarray = require('ndarray');
+}
+var width = exports.width = 610;
+var height = exports.height = 400;
+var wireframe = exports.wireframe = true;
+var wireframeWidth = exports.wireframeWidth = 1.2;
+var terrainHeight = exports.terrainHeight = 50;
+var terrainSize = exports.terrainSize = 100;
+void 0;
+void 0;
+void 0;
+var inc = exports.inc = function inc(x) {
+    return x + 1;
+};
+var dec = exports.dec = function dec(x) {
+    return x - 1;
+};
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+var midpoint = exports.midpoint = function midpoint(a, b) {
+    return (a + b) / 2;
+};
+var average2 = exports.average2 = function average2(a, b) {
+    return (a + b) / 2;
+};
+var average4 = exports.average4 = function average4(a, b, c, d) {
+    return (a + b + c + d) / 4;
+};
+var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
+    return function () {
+        var totalø1 = 0;
+        var countø1 = 0;
+        a ? (function () {
+            totalø1 = totalø1 + a;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        b ? (function () {
+            totalø1 = totalø1 + b;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        c ? (function () {
+            totalø1 = totalø1 + c;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        d ? (function () {
+            totalø1 = totalø1 + d;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        return totalø1 / countø1;
+    }.call(this);
+};
+var isEven = exports.isEven = function isEven(n) {
+    return 0 == n % 2;
+};
+var isOdd = exports.isOdd = function isOdd(n) {
+    return 1 == n % 2;
+};
+var rand = exports.rand = function rand() {
+    return Math.random();
+};
+var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
+    return spread * rand() * 2 - spread;
+};
+var jitter = exports.jitter = function jitter(value, spread) {
+    return value + randAroundZero(spread);
+};
+var heightmapResolution = exports.heightmapResolution = function heightmapResolution(heightmap) {
+    return heightmap.shape[0];
+};
+var heightmapLastIndex = exports.heightmapLastIndex = function heightmapLastIndex(heightmap) {
+    return dec(heightmapResolution(heightmap));
+};
+var heightmapCenterIndex = exports.heightmapCenterIndex = function heightmapCenterIndex(heightmap) {
+    return midpoint(0, heightmapLastIndex(heightmap));
+};
+var heightmapGet = exports.heightmapGet = function heightmapGet(heightmap, x, y) {
+    return heightmap.get(x, y);
+};
+var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(heightmap, x, y) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        return 0 <= x && x <= lastø1 && (0 <= y && y <= lastø1) ? (function () {
+            return heightmapGet(heightmap, x, y);
+        })() : void 0;
+    }.call(this);
+};
+var heightmapSet = exports.heightmapSet = function heightmapSet(heightmap, x, y, val) {
+    return heightmap.set(x, y, val);
+};
+var heightmapSetIfUnset = exports.heightmapSetIfUnset = function heightmapSetIfUnset(heightmap, x, y, val) {
+    return 0 == heightmapGet(heightmap, x, y) ? (function () {
+        return heightmapSet(heightmap, x, y, val);
+    })() : void 0;
+};
+var normalize = exports.normalize = function normalize(heightmap) {
+    return function () {
+        var maxø1 = 0 - Infinity;
+        var minø1 = Infinity;
+        (function () {
+            var array2ø1 = heightmap;
+            return function () {
+                var G__3ø1 = array2ø1.data.length;
+                return function loop() {
+                    var recur = loop;
+                    var index1ø1 = 0;
+                    do {
+                        recur = index1ø1 < G__3ø1 ? (function () {
+                            (function () {
+                                var elø1 = array2ø1.data[index1ø1];
+                                maxø1 < elø1 ? (function () {
+                                    return maxø1 = elø1;
+                                })() : void 0;
+                                return minø1 > elø1 ? (function () {
+                                    return minø1 = elø1;
+                                })() : void 0;
+                            }.call(this));
+                            return loop[0] = inc(index1ø1), loop;
+                        })() : void 0;
+                    } while (index1ø1 = loop[0], recur === loop);
+                    return recur;
+                }.call(this);
+            }.call(this);
+        }.call(this));
+        return function () {
+            var spanø1 = maxø1 - minø1;
+            return function () {
+                var array4ø1 = heightmap;
+                return function () {
+                    var G__5ø1 = array4ø1.shape[0];
+                    return function loop() {
+                        var recur = loop;
+                        var xø1 = 0;
+                        do {
+                            recur = xø1 < G__5ø1 ? (function () {
+                                (function () {
+                                    var G__6ø1 = array4ø1.shape[1];
+                                    return function loop() {
+                                        var recur = loop;
+                                        var yø1 = 0;
+                                        do {
+                                            recur = yø1 < G__6ø1 ? (function () {
+                                                (function () {
+                                                    return heightmapSet(heightmap, xø1, yø1, (heightmapGet(heightmap, xø1, yø1) - minø1) / spanø1);
+                                                })();
+                                                return loop[0] = inc(yø1), loop;
+                                            })() : void 0;
+                                        } while (yø1 = loop[0], recur === loop);
+                                        return recur;
+                                    }.call(this);
+                                }.call(this));
+                                return loop[0] = inc(xø1), loop;
+                            })() : void 0;
+                        } while (xø1 = loop[0], recur === loop);
+                        return recur;
+                    }.call(this);
+                }.call(this);
+            }.call(this);
+        }.call(this);
+    }.call(this);
+};
+var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
+    return function () {
+        var resolutionø1 = Math.pow(2, exponent) + 1;
+        return function () {
+            var heightmapø1 = ndarray(new Float64Array(resolutionø1 * resolutionø1), [
+                resolutionø1,
+                resolutionø1
+            ]);
+            heightmapø1.exponent = exponent;
+            heightmapø1.resolution = resolutionø1;
+            heightmapø1.last = dec(resolutionø1);
+            return heightmapø1;
+        }.call(this);
+    }.call(this);
+};
+var topLeftCorner = exports.topLeftCorner = function topLeftCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(0, 0).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var topRightCorner = exports.topRightCorner = function topRightCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(centerø1, 0).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var bottomLeftCorner = exports.bottomLeftCorner = function bottomLeftCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(0, centerø1).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var bottomRightCorner = exports.bottomRightCorner = function bottomRightCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(centerø1, centerø1).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var dsInitCorners = exports.dsInitCorners = function dsInitCorners(heightmap) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        heightmapSet(heightmap, 0, 0, rand());
+        heightmapSet(heightmap, 0, lastø1, rand());
+        heightmapSet(heightmap, lastø1, 0, rand());
+        return heightmapSet(heightmap, lastø1, lastø1, rand());
+    }.call(this);
+};
+var dsSquare = exports.dsSquare = function dsSquare(heightmap, x, y, radius, spread) {
+    return function () {
+        var newHeightø1 = jitter(average4(heightmapGet(heightmap, x - radius, y - radius), heightmapGet(heightmap, x - radius, y + radius), heightmapGet(heightmap, x + radius, y - radius), heightmapGet(heightmap, x + radius, y + radius)), spread);
+        return heightmapSet(heightmap, x, y, newHeightø1);
+    }.call(this);
+};
+var dsDiamond = exports.dsDiamond = function dsDiamond(heightmap, x, y, radius, spread) {
+    return function () {
+        var newHeightø1 = jitter(safeAverage(heightmapGetSafe(heightmap, x - radius, y), heightmapGetSafe(heightmap, x + radius, y), heightmapGetSafe(heightmap, x, y - radius), heightmapGetSafe(heightmap, x, y + radius)), spread);
+        return heightmapSet(heightmap, x, y, newHeightø1);
+    }.call(this);
+};
+var dsSquares = exports.dsSquares = function dsSquares(heightmap, radius, spread) {
+    return function () {
+        var start8ø1 = radius;
+        var end9ø1 = heightmapResolution(heightmap);
+        var stride7ø1 = 2 * radius;
+        return function loop() {
+            var recur = loop;
+            var xø1 = start8ø1;
+            do {
+                recur = xø1 < end9ø1 ? (function () {
+                    (function loop() {
+                        var recur = loop;
+                        var yø1 = start8ø1;
+                        do {
+                            recur = yø1 < end9ø1 ? (function () {
+                                (function () {
+                                    return dsSquare(heightmap, xø1, yø1, radius, spread);
+                                })();
+                                return loop[0] = yø1 + stride7ø1, loop;
+                            })() : void 0;
+                        } while (yø1 = loop[0], recur === loop);
+                        return recur;
+                    }.call(this));
+                    return loop[0] = xø1 + stride7ø1, loop;
+                })() : void 0;
+            } while (xø1 = loop[0], recur === loop);
+            return recur;
+        }.call(this);
+    }.call(this);
+};
+var dsDiamonds = exports.dsDiamonds = function dsDiamonds(heightmap, radius, spread) {
+    return function () {
+        var sizeø1 = heightmapResolution(heightmap);
+        return function () {
+            var start11ø1 = 0;
+            var end12ø1 = sizeø1;
+            var stride10ø1 = radius;
+            return function loop() {
+                var recur = loop;
+                var yø1 = start11ø1;
+                do {
+                    recur = yø1 < end12ø1 ? (function () {
+                        (function () {
+                            return function () {
+                                var shiftø1 = isEven(yø1 / radius) ? radius : 0;
+                                return function () {
+                                    var start14ø1 = shiftø1;
+                                    var end15ø1 = sizeø1;
+                                    var stride13ø1 = 2 * radius;
+                                    return function loop() {
+                                        var recur = loop;
+                                        var xø1 = start14ø1;
+                                        do {
+                                            recur = xø1 < end15ø1 ? (function () {
+                                                (function () {
+                                                    return dsDiamond(heightmap, xø1, yø1, radius, spread);
+                                                })();
+                                                return loop[0] = xø1 + stride13ø1, loop;
+                                            })() : void 0;
+                                        } while (xø1 = loop[0], recur === loop);
+                                        return recur;
+                                    }.call(this);
+                                }.call(this);
+                            }.call(this);
+                        })();
+                        return loop[0] = yø1 + stride10ø1, loop;
+                    })() : void 0;
+                } while (yø1 = loop[0], recur === loop);
+                return recur;
+            }.call(this);
+        }.call(this);
+    }.call(this);
+};
+var diamondSquare = exports.diamondSquare = function diamondSquare(heightmap) {
+    return function () {
+        var initialSpreadø1 = 0.3;
+        var spreadReductionø1 = 0.5;
+        var centerø1 = heightmapCenterIndex(heightmap);
+        var sizeø1 = heightmap.shape[0];
+        dsInitCorners(heightmap);
+        (function loop() {
+            var recur = loop;
+            var radiusø1 = centerø1;
+            var spreadø1 = initialSpreadø1;
+            do {
+                recur = radiusø1 >= 1 ? (function () {
+                    dsSquares(heightmap, radiusø1, spreadø1);
+                    dsDiamonds(heightmap, radiusø1, spreadø1);
+                    return loop[0] = radiusø1 / 2, loop[1] = spreadø1 * spreadReductionø1, loop;
+                })() : void 0;
+            } while (radiusø1 = loop[0], spreadø1 = loop[1], recur === loop);
+            return recur;
+        }.call(this));
+        return normalize(heightmap);
+    }.call(this);
+};
+var diamondSquare1 = exports.diamondSquare1 = function diamondSquare1(heightmap) {
+    dsInitCorners(heightmap);
+    return normalize(heightmap);
+};
+var diamondSquare2 = exports.diamondSquare2 = function diamondSquare2(heightmap) {
+    return function () {
+        var initialSpreadø1 = 0.3;
+        var spreadReductionø1 = 0.5;
+        var centerø1 = heightmapCenterIndex(heightmap);
+        var sizeø1 = heightmap.shape[0];
+        dsInitCorners(heightmap);
+        dsSquares(heightmap, centerø1, initialSpreadø1);
+        return normalize(heightmap);
+    }.call(this);
+};
+var diamondSquare3 = exports.diamondSquare3 = function diamondSquare3(heightmap) {
+    return function () {
+        var initialSpreadø1 = 0.3;
+        var spreadReductionø1 = 0.5;
+        var centerø1 = heightmapCenterIndex(heightmap);
+        var sizeø1 = heightmap.shape[0];
+        dsInitCorners(heightmap);
+        dsSquares(heightmap, centerø1, initialSpreadø1);
+        dsDiamonds(heightmap, centerø1, initialSpreadø1);
+        dsSquares(heightmap, centerø1 / 2, spreadReductionø1 * initialSpreadø1);
+        dsDiamonds(heightmap, centerø1 / 2, spreadReductionø1 * initialSpreadø1);
+        return normalize(heightmap);
+    }.call(this);
+};
+var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
+    return function () {
+        var lightø1 = new THREE.DirectionalLight(16777215, 1);
+        lightø1.position.set(100, 0, 150);
+        return lightø1;
+    }.call(this);
+};
+var makeCamera = exports.makeCamera = function makeCamera() {
+    return function () {
+        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
+        cameraø1.position.set(0, -100, 150);
+        return cameraø1;
+    }.call(this);
+};
+var makeRenderer = exports.makeRenderer = function makeRenderer() {
+    return function () {
+        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
+        rendererø1.setClearColor(16777215);
+        rendererø1.setSize(width, height);
+        rendererø1.setPixelRatio(2);
+        return rendererø1;
+    }.call(this);
+};
+var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
+    return function () {
+        var resolutionø1 = heightmap.shape[0];
+        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, resolutionø1 - 1, resolutionø1 - 1);
+        return geometryø1;
+    }.call(this);
+};
+var makeControls = exports.makeControls = function makeControls(camera, renderer) {
+    return function () {
+        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
+        controlsø1.rotateSpeed = 1.4;
+        controlsø1.zoomSpeed = 0.5;
+        controlsø1.staticMoving = true;
+        controlsø1.dynamicDampingFactor = 0.3;
+        return controlsø1;
+    }.call(this);
+};
+var makePlane = exports.makePlane = function makePlane(geometry) {
+    return function () {
+        var materialø1 = new THREE.MeshLambertMaterial({
+            'wireframe': wireframe,
+            'wireframeLinewidth': wireframeWidth,
+            'color': 47872
+        });
+        return new THREE.Mesh(geometry, materialø1);
+    }.call(this);
+};
+var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
+    return function () {
+        var containerø1 = document.getElementById(elName);
+        var settingsø1 = document.createElement('div');
+        var refreshButtonø1 = document.createElement('button');
+        var buttonTextø1 = document.createTextNode('Refresh');
+        var cancelScrollø1 = function (e) {
+            return e.preventDefault();
+        };
+        refreshButtonø1.onclick = refreshFn;
+        renderer.domElement.onmousewheel = cancelScrollø1;
+        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
+        refreshButtonø1.appendChild(buttonTextø1);
+        containerø1.appendChild(renderer.domElement);
+        containerø1.appendChild(settingsø1);
+        return settingsø1.appendChild(refreshButtonø1);
+    }.call(this);
+};
+var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
+    (function loop() {
+        var recur = loop;
+        var iø1 = 0;
+        do {
+            recur = iø1 < geometry.vertices.length ? (function () {
+                geometry.vertices[iø1].z = terrainHeight * heightmap.data[iø1];
+                return loop[0] = iø1 + 1, loop;
+            })() : void 0;
+        } while (iø1 = loop[0], recur === loop);
+        return recur;
+    }.call(this));
+    geometry.computeVertexNormals();
+    return geometry;
+};
+var makeDemo = exports.makeDemo = function makeDemo(elementId, algorithm, size) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var geometry = void 0;
+    var plane = void 0;
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    var refresh = function refresh() {
+        return function () {
+            var heightmapø1 = makeHeightmap(size);
+            console.log('Generating terrain...');
+            (function () {
+                var G__16ø1 = new Date().getTime();
+                var G__18ø1 = (function () {
+                    return algorithm(heightmapø1);
+                })();
+                var G__17ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__17ø1 - G__16ø1) + 'ms.');
+                return G__18ø1;
+            }.call(this));
+            console.log('Rebuilding geometry...');
+            (function () {
+                var G__19ø1 = new Date().getTime();
+                var G__21ø1 = (function () {
+                    geometry = makeGeometry(heightmapø1);
+                    return updateGeometry(geometry, heightmapø1);
+                })();
+                var G__20ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__20ø1 - G__19ø1) + 'ms.');
+                return G__21ø1;
+            }.call(this));
+            console.log('Rebuilding plane...');
+            return function () {
+                var G__22ø1 = new Date().getTime();
+                var G__24ø1 = (function () {
+                    scene.remove(plane);
+                    plane = makePlane(geometry);
+                    return scene.add(plane);
+                })();
+                var G__23ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__23ø1 - G__22ø1) + 'ms.');
+                return G__24ø1;
+            }.call(this);
+        }.call(this);
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    refresh();
+    render();
+    return void 0;
+};
+var makeFinal = exports.makeFinal = function makeFinal(elementId) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var geometry = void 0;
+    var plane = void 0;
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    var refresh = function refresh() {
+        return function () {
+            var heightmapø1 = makeHeightmap(6);
+            console.log('Generating terrain...');
+            (function () {
+                var G__25ø1 = new Date().getTime();
+                var G__27ø1 = (function () {
+                    return diamondSquare(heightmapø1);
+                })();
+                var G__26ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__26ø1 - G__25ø1) + 'ms.');
+                return G__27ø1;
+            }.call(this));
+            console.log('Rebuilding geometry...');
+            (function () {
+                var G__28ø1 = new Date().getTime();
+                var G__30ø1 = (function () {
+                    geometry = makeGeometry(heightmapø1);
+                    return updateGeometry(geometry, heightmapø1);
+                })();
+                var G__29ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__29ø1 - G__28ø1) + 'ms.');
+                return G__30ø1;
+            }.call(this));
+            console.log('Rebuilding plane...');
+            return function () {
+                var G__31ø1 = new Date().getTime();
+                var G__33ø1 = (function () {
+                    scene.remove(plane);
+                    plane = makePlane(geometry);
+                    return scene.add(plane);
+                })();
+                var G__32ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__32ø1 - G__31ø1) + 'ms.');
+                return G__33ø1;
+            }.call(this);
+        }.call(this);
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    refresh();
+    render();
+    return void 0;
+};
+var run = exports.run = function run() {
+    makeDemo('demo-1', diamondSquare1, 2);
+    makeDemo('demo-2', diamondSquare2, 4);
+    makeDemo('demo-3', diamondSquare3, 4);
+    return makeFinal('demo-final');
+};
+$(run);
+
+
+},{"ndarray":4}],2:[function(require,module,exports){
+"use strict"
+
+function iota(n) {
+  var result = new Array(n)
+  for(var i=0; i<n; ++i) {
+    result[i] = i
+  }
+  return result
+}
+
+module.exports = iota
+},{}],3:[function(require,module,exports){
+/**
+ * Determine if an object is Buffer
+ *
+ * Author:   Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
+ * License:  MIT
+ *
+ * `npm install is-buffer`
+ */
+
+module.exports = function (obj) {
+  return !!(obj != null &&
+    (obj._isBuffer || // For Safari 5-7 (missing Object.prototype.constructor)
+      (obj.constructor &&
+      typeof obj.constructor.isBuffer === 'function' &&
+      obj.constructor.isBuffer(obj))
+    ))
+}
+
+},{}],4:[function(require,module,exports){
+var iota = require("iota-array")
+var isBuffer = require("is-buffer")
+
+var hasTypedArrays  = ((typeof Float64Array) !== "undefined")
+
+function compare1st(a, b) {
+  return a[0] - b[0]
+}
+
+function order() {
+  var stride = this.stride
+  var terms = new Array(stride.length)
+  var i
+  for(i=0; i<terms.length; ++i) {
+    terms[i] = [Math.abs(stride[i]), i]
+  }
+  terms.sort(compare1st)
+  var result = new Array(terms.length)
+  for(i=0; i<result.length; ++i) {
+    result[i] = terms[i][1]
+  }
+  return result
+}
+
+function compileConstructor(dtype, dimension) {
+  var className = ["View", dimension, "d", dtype].join("")
+  if(dimension < 0) {
+    className = "View_Nil" + dtype
+  }
+  var useGetters = (dtype === "generic")
+
+  if(dimension === -1) {
+    //Special case for trivial arrays
+    var code =
+      "function "+className+"(a){this.data=a;};\
+var proto="+className+".prototype;\
+proto.dtype='"+dtype+"';\
+proto.index=function(){return -1};\
+proto.size=0;\
+proto.dimension=-1;\
+proto.shape=proto.stride=proto.order=[];\
+proto.lo=proto.hi=proto.transpose=proto.step=\
+function(){return new "+className+"(this.data);};\
+proto.get=proto.set=function(){};\
+proto.pick=function(){return null};\
+return function construct_"+className+"(a){return new "+className+"(a);}"
+    var procedure = new Function(code)
+    return procedure()
+  } else if(dimension === 0) {
+    //Special case for 0d arrays
+    var code =
+      "function "+className+"(a,d) {\
+this.data = a;\
+this.offset = d\
+};\
+var proto="+className+".prototype;\
+proto.dtype='"+dtype+"';\
+proto.index=function(){return this.offset};\
+proto.dimension=0;\
+proto.size=1;\
+proto.shape=\
+proto.stride=\
+proto.order=[];\
+proto.lo=\
+proto.hi=\
+proto.transpose=\
+proto.step=function "+className+"_copy() {\
+return new "+className+"(this.data,this.offset)\
+};\
+proto.pick=function "+className+"_pick(){\
+return TrivialArray(this.data);\
+};\
+proto.valueOf=proto.get=function "+className+"_get(){\
+return "+(useGetters ? "this.data.get(this.offset)" : "this.data[this.offset]")+
+"};\
+proto.set=function "+className+"_set(v){\
+return "+(useGetters ? "this.data.set(this.offset,v)" : "this.data[this.offset]=v")+"\
+};\
+return function construct_"+className+"(a,b,c,d){return new "+className+"(a,d)}"
+    var procedure = new Function("TrivialArray", code)
+    return procedure(CACHED_CONSTRUCTORS[dtype][0])
+  }
+
+  var code = ["'use strict'"]
+
+  //Create constructor for view
+  var indices = iota(dimension)
+  var args = indices.map(function(i) { return "i"+i })
+  var index_str = "this.offset+" + indices.map(function(i) {
+        return "this.stride[" + i + "]*i" + i
+      }).join("+")
+  var shapeArg = indices.map(function(i) {
+      return "b"+i
+    }).join(",")
+  var strideArg = indices.map(function(i) {
+      return "c"+i
+    }).join(",")
+  code.push(
+    "function "+className+"(a," + shapeArg + "," + strideArg + ",d){this.data=a",
+      "this.shape=[" + shapeArg + "]",
+      "this.stride=[" + strideArg + "]",
+      "this.offset=d|0}",
+    "var proto="+className+".prototype",
+    "proto.dtype='"+dtype+"'",
+    "proto.dimension="+dimension)
+
+  //view.size:
+  code.push("Object.defineProperty(proto,'size',{get:function "+className+"_size(){\
+return "+indices.map(function(i) { return "this.shape["+i+"]" }).join("*"),
+"}})")
+
+  //view.order:
+  if(dimension === 1) {
+    code.push("proto.order=[0]")
+  } else {
+    code.push("Object.defineProperty(proto,'order',{get:")
+    if(dimension < 4) {
+      code.push("function "+className+"_order(){")
+      if(dimension === 2) {
+        code.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})")
+      } else if(dimension === 3) {
+        code.push(
+"var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);\
+if(s0>s1){\
+if(s1>s2){\
+return [2,1,0];\
+}else if(s0>s2){\
+return [1,2,0];\
+}else{\
+return [1,0,2];\
+}\
+}else if(s0>s2){\
+return [2,0,1];\
+}else if(s2>s1){\
+return [0,1,2];\
+}else{\
+return [0,2,1];\
+}}})")
+      }
+    } else {
+      code.push("ORDER})")
+    }
+  }
+
+  //view.set(i0, ..., v):
+  code.push(
+"proto.set=function "+className+"_set("+args.join(",")+",v){")
+  if(useGetters) {
+    code.push("return this.data.set("+index_str+",v)}")
+  } else {
+    code.push("return this.data["+index_str+"]=v}")
+  }
+
+  //view.get(i0, ...):
+  code.push("proto.get=function "+className+"_get("+args.join(",")+"){")
+  if(useGetters) {
+    code.push("return this.data.get("+index_str+")}")
+  } else {
+    code.push("return this.data["+index_str+"]}")
+  }
+
+  //view.index:
+  code.push(
+    "proto.index=function "+className+"_index(", args.join(), "){return "+index_str+"}")
+
+  //view.hi():
+  code.push("proto.hi=function "+className+"_hi("+args.join(",")+"){return new "+className+"(this.data,"+
+    indices.map(function(i) {
+      return ["(typeof i",i,"!=='number'||i",i,"<0)?this.shape[", i, "]:i", i,"|0"].join("")
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "this.stride["+i + "]"
+    }).join(",")+",this.offset)}")
+
+  //view.lo():
+  var a_vars = indices.map(function(i) { return "a"+i+"=this.shape["+i+"]" })
+  var c_vars = indices.map(function(i) { return "c"+i+"=this.stride["+i+"]" })
+  code.push("proto.lo=function "+className+"_lo("+args.join(",")+"){var b=this.offset,d=0,"+a_vars.join(",")+","+c_vars.join(","))
+  for(var i=0; i<dimension; ++i) {
+    code.push(
+"if(typeof i"+i+"==='number'&&i"+i+">=0){\
+d=i"+i+"|0;\
+b+=c"+i+"*d;\
+a"+i+"-=d}")
+  }
+  code.push("return new "+className+"(this.data,"+
+    indices.map(function(i) {
+      return "a"+i
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "c"+i
+    }).join(",")+",b)}")
+
+  //view.step():
+  code.push("proto.step=function "+className+"_step("+args.join(",")+"){var "+
+    indices.map(function(i) {
+      return "a"+i+"=this.shape["+i+"]"
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "b"+i+"=this.stride["+i+"]"
+    }).join(",")+",c=this.offset,d=0,ceil=Math.ceil")
+  for(var i=0; i<dimension; ++i) {
+    code.push(
+"if(typeof i"+i+"==='number'){\
+d=i"+i+"|0;\
+if(d<0){\
+c+=b"+i+"*(a"+i+"-1);\
+a"+i+"=ceil(-a"+i+"/d)\
+}else{\
+a"+i+"=ceil(a"+i+"/d)\
+}\
+b"+i+"*=d\
+}")
+  }
+  code.push("return new "+className+"(this.data,"+
+    indices.map(function(i) {
+      return "a" + i
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "b" + i
+    }).join(",")+",c)}")
+
+  //view.transpose():
+  var tShape = new Array(dimension)
+  var tStride = new Array(dimension)
+  for(var i=0; i<dimension; ++i) {
+    tShape[i] = "a[i"+i+"]"
+    tStride[i] = "b[i"+i+"]"
+  }
+  code.push("proto.transpose=function "+className+"_transpose("+args+"){"+
+    args.map(function(n,idx) { return n + "=(" + n + "===undefined?" + idx + ":" + n + "|0)"}).join(";"),
+    "var a=this.shape,b=this.stride;return new "+className+"(this.data,"+tShape.join(",")+","+tStride.join(",")+",this.offset)}")
+
+  //view.pick():
+  code.push("proto.pick=function "+className+"_pick("+args+"){var a=[],b=[],c=this.offset")
+  for(var i=0; i<dimension; ++i) {
+    code.push("if(typeof i"+i+"==='number'&&i"+i+">=0){c=(c+this.stride["+i+"]*i"+i+")|0}else{a.push(this.shape["+i+"]);b.push(this.stride["+i+"])}")
+  }
+  code.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}")
+
+  //Add return statement
+  code.push("return function construct_"+className+"(data,shape,stride,offset){return new "+className+"(data,"+
+    indices.map(function(i) {
+      return "shape["+i+"]"
+    }).join(",")+","+
+    indices.map(function(i) {
+      return "stride["+i+"]"
+    }).join(",")+",offset)}")
+
+  //Compile procedure
+  var procedure = new Function("CTOR_LIST", "ORDER", code.join("\n"))
+  return procedure(CACHED_CONSTRUCTORS[dtype], order)
+}
+
+function arrayDType(data) {
+  if(isBuffer(data)) {
+    return "buffer"
+  }
+  if(hasTypedArrays) {
+    switch(Object.prototype.toString.call(data)) {
+      case "[object Float64Array]":
+        return "float64"
+      case "[object Float32Array]":
+        return "float32"
+      case "[object Int8Array]":
+        return "int8"
+      case "[object Int16Array]":
+        return "int16"
+      case "[object Int32Array]":
+        return "int32"
+      case "[object Uint8Array]":
+        return "uint8"
+      case "[object Uint16Array]":
+        return "uint16"
+      case "[object Uint32Array]":
+        return "uint32"
+      case "[object Uint8ClampedArray]":
+        return "uint8_clamped"
+    }
+  }
+  if(Array.isArray(data)) {
+    return "array"
+  }
+  return "generic"
+}
+
+var CACHED_CONSTRUCTORS = {
+  "float32":[],
+  "float64":[],
+  "int8":[],
+  "int16":[],
+  "int32":[],
+  "uint8":[],
+  "uint16":[],
+  "uint32":[],
+  "array":[],
+  "uint8_clamped":[],
+  "buffer":[],
+  "generic":[]
+}
+
+;(function() {
+  for(var id in CACHED_CONSTRUCTORS) {
+    CACHED_CONSTRUCTORS[id].push(compileConstructor(id, -1))
+  }
+});
+
+function wrappedNDArrayCtor(data, shape, stride, offset) {
+  if(data === undefined) {
+    var ctor = CACHED_CONSTRUCTORS.array[0]
+    return ctor([])
+  } else if(typeof data === "number") {
+    data = [data]
+  }
+  if(shape === undefined) {
+    shape = [ data.length ]
+  }
+  var d = shape.length
+  if(stride === undefined) {
+    stride = new Array(d)
+    for(var i=d-1, sz=1; i>=0; --i) {
+      stride[i] = sz
+      sz *= shape[i]
+    }
+  }
+  if(offset === undefined) {
+    offset = 0
+    for(var i=0; i<d; ++i) {
+      if(stride[i] < 0) {
+        offset -= (shape[i]-1)*stride[i]
+      }
+    }
+  }
+  var dtype = arrayDType(data)
+  var ctor_list = CACHED_CONSTRUCTORS[dtype]
+  while(ctor_list.length <= d+1) {
+    ctor_list.push(compileConstructor(dtype, ctor_list.length-1))
+  }
+  var ctor = ctor_list[d+1]
+  return ctor(data, shape, stride, offset)
+}
+
+module.exports = wrappedNDArrayCtor
+
+},{"iota-array":2,"is-buffer":3}]},{},[1])
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Vzci9sb2NhbC9saWIvbm9kZV9tb2R1bGVzL2Jyb3dzZXJpZnkvbm9kZV9tb2R1bGVzL2Jyb3dzZXItcGFjay9fcHJlbHVkZS5qcyIsIm1lZGlhL2pzL3dpc3AvYW5vbnltb3VzLndpc3AiLCJub2RlX21vZHVsZXMvaW90YS1hcnJheS9pb3RhLmpzIiwibm9kZV9tb2R1bGVzL2lzLWJ1ZmZlci9pbmRleC5qcyIsIm5vZGVfbW9kdWxlcy9uZGFycmF5L25kYXJyYXkuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0lDQUEsSUFBQyxJLEdBQUQ7QUFBQSxRQUFBLEUsRUFBSSxNQUFKO0FBQUEsUUFBQSxHLEV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0IFt+ZW5kIH5saW1pdF1cbiAgICAgICAobG9vcCBbfnZhcm5hbWUgMF1cbiAgICAgICAgICh3aGVuICg8IH52YXJuYW1lIH5lbmQpXG4gICAgICAgICAgIH5AYm9keVxuICAgICAgICAgICAocmVjdXIgKGluYyB+dmFybmFtZSkpKSkpKSlcblxuKGRlZm1hY3JvIGRvLXN0cmlkZSBbdmFybmFtZXMgc3RhcnQtZm9ybSBlbmQtZm9ybSBzdHJpZGUtZm9ybSAmIGJvZHldXG4gIChsZXQgW3N0cmlkZSAoZ2Vuc3ltIFwic3RyaWRlXCIpXG4gICAgICAgIHN0YXJ0IChnZW5zeW0gXCJzdGFydFwiKVxuICAgICAgICBlbmQgKGdlbnN5bSBcImVuZFwiKVxuICAgICAgICBidWlsZCAoZm4gYnVpbGQgW3ZhcnNdXG4gICAgICAgICAgICAgICAgKGlmIChlbXB0eT8gdmFycylcbiAgICAgICAgICAgICAgICAgIGAoZG8gfkBib2R5KVxuICAgICAgICAgICAgICAgICAgKGxldCBbdmFybmFtZSAoZmlyc3QgdmFycyldXG4gICAgICAgICAgICAgICAgICAgIGAobG9vcCBbfnZhcm5hbWUgfnN0YXJ0XVxuICAgICAgICAgICAgICAgICAgICAgICAod2hlbiAoPCB+dmFybmFtZSB+ZW5kKVxuICAgICAgICAgICAgICAgICAgICAgICAgIH4oYnVpbGQgKHJlc3QgdmFycykpXG4gICAgICAgICAgICAgICAgICAgICAgICAgKHJlY3VyICgrIH52YXJuYW1lIH5zdHJpZGUpKSkpKSkpXVxuICAgIDsgRml4IHRoZSBudW1iZXJzIG9uY2Ugb3V0c2lkZSB0aGUgbmVzdGVkIGxvb3BzLFxuICAgIDsgYW5kIHRoZW4gYnVpbGQgdGhlIGd1dHMuXG4gICAgYChsZXQgW35zdGFydCB+c3RhcnQtZm9ybVxuICAgICAgICAgICB+ZW5kIH5lbmQtZm9ybVxuICAgICAgICAgICB+c3RyaWRlIH5zdHJpZGUtZm9ybV1cbiAgICAgICB+KGJ1a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QtMSwgc3o9MTsgaT49MDsgLS1pKSB7XG4gICAgICBzdHJpZGVbaV0gPSBzelxuICAgICAgc3ogKj0gc2hhcGVbaV1cbiAgICB9XG4gIH1cbiAgaWYob2Zmc2V0ID09PSB1bmRlZmluZWQpIHtcbiAgICBvZmZzZXQgPSAwXG4gICAgZm9yKHZhciBpPTA7IGk8ZDsgKytpKSB7XG4gICAgICBpZihzdHJpZGVbaV0gPCAwKSB7XG4gICAgICAgIG9mZnNldCAtPSAoc2hhcGVbaV0tMSkqc3RyaWRlW2ldXG4gICAgICB9XG4gICAgfVxuICB9XG4gIHZhciBkdHlwZSA9IGFycmF5RFR5cGUoZGF0YSlcbiAgdmFyIGN0b3JfbGlzdCA9IENBQ0hFRF9DT05TVFJVQ1RPUlNbZHR5cGVdXG4gIHdoaWxlKGN0b3JfbGlzdC5sZW5ndGggPD0gZCsxKSB7XG4gICAgY3Rvcl9saXN0LnB1c2goY29tcGlsZUNvbnN0cnVjdG9yKGR0eXBlLCBjdG9yX2xpc3QubGVuZ3RoLTEpKVxuICB9XG4gIHZhciBjdG9yID0gY3Rvcl9saXN0W2QrMV1cbiAgcmV0dXJuIGN0b3IoZGF0YSwgc2hhcGUsIHN0cmlkZSwgb2Zmc2V0KVxufVxuXG5tb2R1bGUuZXhwb3J0cyA9IHdyYXBwZWROREFycmF5Q3RvclxuIl19
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/three.min.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,958 @@
+// threejs.org/license
+'use strict';var THREE={REVISION:"74"};"function"===typeof define&&define.amd?define("three",THREE):"undefined"!==typeof exports&&"undefined"!==typeof module&&(module.exports=THREE);void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Math.sign&&(Math.sign=function(a){return 0>a?-1:0<a?1:+a});void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}});
+void 0===Object.assign&&Object.defineProperty(Object,"assign",{writable:!0,configurable:!0,value:function(a){if(void 0===a||null===a)throw new TypeError("Cannot convert first argument to object");for(var b=Object(a),c=1,d=arguments.length;c!==d;++c){var e=arguments[c];if(void 0!==e&&null!==e)for(var e=Object(e),f=Object.keys(e),g=0,h=f.length;g!==h;++g){var k=f[g],l=Object.getOwnPropertyDescriptor(e,k);void 0!==l&&l.enumerable&&(b[k]=e[k])}}return b}});THREE.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2};
+THREE.CullFaceNone=0;THREE.CullFaceBack=1;THREE.CullFaceFront=2;THREE.CullFaceFrontBack=3;THREE.FrontFaceDirectionCW=0;THREE.FrontFaceDirectionCCW=1;THREE.BasicShadowMap=0;THREE.PCFShadowMap=1;THREE.PCFSoftShadowMap=2;THREE.FrontSide=0;THREE.BackSide=1;THREE.DoubleSide=2;THREE.FlatShading=1;THREE.SmoothShading=2;THREE.NoColors=0;THREE.FaceColors=1;THREE.VertexColors=2;THREE.NoBlending=0;THREE.NormalBlending=1;THREE.AdditiveBlending=2;THREE.SubtractiveBlending=3;THREE.MultiplyBlending=4;
+THREE.CustomBlending=5;THREE.AddEquation=100;THREE.SubtractEquation=101;THREE.ReverseSubtractEquation=102;THREE.MinEquation=103;THREE.MaxEquation=104;THREE.ZeroFactor=200;THREE.OneFactor=201;THREE.SrcColorFactor=202;THREE.OneMinusSrcColorFactor=203;THREE.SrcAlphaFactor=204;THREE.OneMinusSrcAlphaFactor=205;THREE.DstAlphaFactor=206;THREE.OneMinusDstAlphaFactor=207;THREE.DstColorFactor=208;THREE.OneMinusDstColorFactor=209;THREE.SrcAlphaSaturateFactor=210;THREE.NeverDepth=0;THREE.AlwaysDepth=1;
+THREE.LessDepth=2;THREE.LessEqualDepth=3;THREE.EqualDepth=4;THREE.GreaterEqualDepth=5;THREE.GreaterDepth=6;THREE.NotEqualDepth=7;THREE.MultiplyOperation=0;THREE.MixOperation=1;THREE.AddOperation=2;THREE.UVMapping=300;THREE.CubeReflectionMapping=301;THREE.CubeRefractionMapping=302;THREE.EquirectangularReflectionMapping=303;THREE.EquirectangularRefractionMapping=304;THREE.SphericalReflectionMapping=305;THREE.RepeatWrapping=1E3;THREE.ClampToEdgeWrapping=1001;THREE.MirroredRepeatWrapping=1002;
+THREE.NearestFilter=1003;THREE.NearestMipMapNearestFilter=1004;THREE.NearestMipMapLinearFilter=1005;THREE.LinearFilter=1006;THREE.LinearMipMapNearestFilter=1007;THREE.LinearMipMapLinearFilter=1008;THREE.UnsignedByteType=1009;THREE.ByteType=1010;THREE.ShortType=1011;THREE.UnsignedShortType=1012;THREE.IntType=1013;THREE.UnsignedIntType=1014;THREE.FloatType=1015;THREE.HalfFloatType=1025;THREE.UnsignedShort4444Type=1016;THREE.UnsignedShort5551Type=1017;THREE.UnsignedShort565Type=1018;
+THREE.AlphaFormat=1019;THREE.RGBFormat=1020;THREE.RGBAFormat=1021;THREE.LuminanceFormat=1022;THREE.LuminanceAlphaFormat=1023;THREE.RGBEFormat=THREE.RGBAFormat;THREE.RGB_S3TC_DXT1_Format=2001;THREE.RGBA_S3TC_DXT1_Format=2002;THREE.RGBA_S3TC_DXT3_Format=2003;THREE.RGBA_S3TC_DXT5_Format=2004;THREE.RGB_PVRTC_4BPPV1_Format=2100;THREE.RGB_PVRTC_2BPPV1_Format=2101;THREE.RGBA_PVRTC_4BPPV1_Format=2102;THREE.RGBA_PVRTC_2BPPV1_Format=2103;THREE.RGB_ETC1_Format=2151;THREE.LoopOnce=2200;THREE.LoopRepeat=2201;
+THREE.LoopPingPong=2202;THREE.InterpolateDiscrete=2300;THREE.InterpolateLinear=2301;THREE.InterpolateSmooth=2302;THREE.ZeroCurvatureEnding=2400;THREE.ZeroSlopeEnding=2401;THREE.WrapAroundEnding=2402;THREE.TrianglesDrawMode=0;THREE.TriangleStripDrawMode=1;THREE.TriangleFanDrawMode=2;THREE.Color=function(a){return 3===arguments.length?this.fromArray(arguments):this.set(a)};
+THREE.Color.prototype={constructor:THREE.Color,r:1,g:1,b:1,set:function(a){a instanceof THREE.Color?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,b,c){this.r=a;this.g=b;this.b=c;return this},setHSL:function(){function a(a,c,d){0>d&&(d+=1);1<d&&(d-=1);return d<1/6?a+6*(c-a)*
+d:.5>d?c:d<2/3?a+6*(c-a)*(2/3-d):a}return function(b,c,d){b=THREE.Math.euclideanModulo(b,1);c=THREE.Math.clamp(c,0,1);d=THREE.Math.clamp(d,0,1);0===c?this.r=this.g=this.b=d:(c=.5>=d?d*(1+c):d+c-d*c,d=2*d-c,this.r=a(d,c,b+1/3),this.g=a(d,c,b),this.b=a(d,c,b-1/3));return this}}(),setStyle:function(a){function b(b){void 0!==b&&1>parseFloat(b)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var c;if(c=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var d=c[2];switch(c[1]){case "rgb":case "rgba":if(c=
+/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(255,parseInt(c[1],10))/255,this.g=Math.min(255,parseInt(c[2],10))/255,this.b=Math.min(255,parseInt(c[3],10))/255,b(c[5]),this;if(c=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d))return this.r=Math.min(100,parseInt(c[1],10))/100,this.g=Math.min(100,parseInt(c[2],10))/100,this.b=Math.min(100,parseInt(c[3],10))/100,b(c[5]),this;break;case "hsl":case "hsla":if(c=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(d)){var d=
+parseFloat(c[1])/360,e=parseInt(c[2],10)/100,f=parseInt(c[3],10)/100;b(c[5]);return this.setHSL(d,e,f)}}}else if(c=/^\#([A-Fa-f0-9]+)$/.exec(a)){c=c[1];d=c.length;if(3===d)return this.r=parseInt(c.charAt(0)+c.charAt(0),16)/255,this.g=parseInt(c.charAt(1)+c.charAt(1),16)/255,this.b=parseInt(c.charAt(2)+c.charAt(2),16)/255,this;if(6===d)return this.r=parseInt(c.charAt(0)+c.charAt(1),16)/255,this.g=parseInt(c.charAt(2)+c.charAt(3),16)/255,this.b=parseInt(c.charAt(4)+c.charAt(5),16)/255,this}a&&0<a.length&&
+(c=THREE.ColorKeywords[a],void 0!==c?this.setHex(c):console.warn("THREE.Color: Unknown color "+a));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a,b){void 0===b&&(b=2);this.r=Math.pow(a.r,b);this.g=Math.pow(a.g,b);this.b=Math.pow(a.b,b);return this},copyLinearToGamma:function(a,b){void 0===b&&(b=2);var c=0<b?1/b:1;this.r=Math.pow(a.r,c);this.g=Math.pow(a.g,c);this.b=Math.pow(a.b,
+c);return this},convertGammaToLinear:function(){var a=this.r,b=this.g,c=this.b;this.r=a*a;this.g=b*b;this.b=c*c;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);this.b=Math.sqrt(this.b);return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(a){a=a||{h:0,s:0,l:0};var b=this.r,c=this.g,d=this.b,e=Math.max(b,c,d),f=Math.min(b,c,d),g,h=
+(f+e)/2;if(f===e)f=g=0;else{var k=e-f,f=.5>=h?k/(e+f):k/(2-e-f);switch(e){case b:g=(c-d)/k+(c<d?6:0);break;case c:g=(d-b)/k+2;break;case d:g=(b-c)/k+4}g/=6}a.h=g;a.s=f;a.l=h;return a},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(a,b,c){var d=this.getHSL();d.h+=a;d.s+=b;d.l+=c;this.setHSL(d.h,d.s,d.l);return this},add:function(a){this.r+=a.r;this.g+=a.g;this.b+=a.b;return this},addColors:function(a,b){this.r=a.r+b.r;this.g=a.g+b.g;this.b=
+a.b+b.b;return this},addScalar:function(a){this.r+=a;this.g+=a;this.b+=a;return this},multiply:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b;return this},multiplyScalar:function(a){this.r*=a;this.g*=a;this.b*=a;return this},lerp:function(a,b){this.r+=(a.r-this.r)*b;this.g+=(a.g-this.g)*b;this.b+=(a.b-this.b)*b;return this},equals:function(a){return a.r===this.r&&a.g===this.g&&a.b===this.b},fromArray:function(a,b){void 0===b&&(b=0);this.r=a[b];this.g=a[b+1];this.b=a[b+2];return this},toArray:function(a,
+b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.r;a[b+1]=this.g;a[b+2]=this.b;return a}};
+THREE.ColorKeywords={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,
+darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,
+grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,
+lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,
+palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,
+tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};THREE.Quaternion=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._w=void 0!==d?d:1};
+THREE.Quaternion.prototype={constructor:THREE.Quaternion,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._w=d;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},
+copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,b){if(!1===a instanceof THREE.Euler)throw Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var c=Math.cos(a._x/2),d=Math.cos(a._y/2),e=Math.cos(a._z/2),f=Math.sin(a._x/2),g=Math.sin(a._y/2),h=Math.sin(a._z/2),k=a.order;"XYZ"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"YXZ"===
+k?(this._x=f*d*e+c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"ZXY"===k?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e-f*g*h):"ZYX"===k?(this._x=f*d*e-c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e+f*g*h):"YZX"===k?(this._x=f*d*e+c*g*h,this._y=c*g*e+f*d*h,this._z=c*d*h-f*g*e,this._w=c*d*e-f*g*h):"XZY"===k&&(this._x=f*d*e-c*g*h,this._y=c*g*e-f*d*h,this._z=c*d*h+f*g*e,this._w=c*d*e+f*g*h);if(!1!==b)this.onChangeCallback();return this},setFromAxisAngle:function(a,
+b){var c=b/2,d=Math.sin(c);this._x=a.x*d;this._y=a.y*d;this._z=a.z*d;this._w=Math.cos(c);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var b=a.elements,c=b[0];a=b[4];var d=b[8],e=b[1],f=b[5],g=b[9],h=b[2],k=b[6],b=b[10],l=c+f+b;0<l?(c=.5/Math.sqrt(l+1),this._w=.25/c,this._x=(k-g)*c,this._y=(d-h)*c,this._z=(e-a)*c):c>f&&c>b?(c=2*Math.sqrt(1+c-f-b),this._w=(k-g)/c,this._x=.25*c,this._y=(a+e)/c,this._z=(d+h)/c):f>b?(c=2*Math.sqrt(1+f-c-b),this._w=(d-h)/c,this._x=(a+e)/c,this._y=
+.25*c,this._z=(g+k)/c):(c=2*Math.sqrt(1+b-c-f),this._w=(e-a)/c,this._x=(d+h)/c,this._y=(g+k)/c,this._z=.25*c);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3);b=c.dot(d)+1;1E-6>b?(b=0,Math.abs(c.x)>Math.abs(c.z)?a.set(-c.y,c.x,0):a.set(0,-c.z,c.y)):a.crossVectors(c,d);this._x=a.x;this._y=a.y;this._z=a.z;this._w=b;this.normalize();return this}}(),inverse:function(){this.conjugate().normalize();return this},conjugate:function(){this._x*=
+-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},
+multiply:function(a,b){return void 0!==b?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,b)):this.multiplyQuaternions(this,a)},multiplyQuaternions:function(a,b){var c=a._x,d=a._y,e=a._z,f=a._w,g=b._x,h=b._y,k=b._z,l=b._w;this._x=c*l+f*g+d*k-e*h;this._y=d*l+f*h+e*g-c*k;this._z=e*l+f*k+c*h-d*g;this._w=f*l-c*g-d*h-e*k;this.onChangeCallback();return this},slerp:function(a,b){if(0===b)return this;if(1===
+b)return this.copy(a);var c=this._x,d=this._y,e=this._z,f=this._w,g=f*a._w+c*a._x+d*a._y+e*a._z;0>g?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,g=-g):this.copy(a);if(1<=g)return this._w=f,this._x=c,this._y=d,this._z=e,this;var h=Math.sqrt(1-g*g);if(.001>Math.abs(h))return this._w=.5*(f+this._w),this._x=.5*(c+this._x),this._y=.5*(d+this._y),this._z=.5*(e+this._z),this;var k=Math.atan2(h,g),g=Math.sin((1-b)*k)/h,h=Math.sin(b*k)/h;this._w=f*g+this._w*h;this._x=c*g+this._x*h;this._y=d*g+
+this._y*h;this._z=e*g+this._z*h;this.onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,b){void 0===b&&(b=0);this._x=a[b];this._y=a[b+1];this._z=a[b+2];this._w=a[b+3];this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};
+Object.assign(THREE.Quaternion,{slerp:function(a,b,c,d){return c.copy(a).slerp(b,d)},slerpFlat:function(a,b,c,d,e,f,g){var h=c[d+0],k=c[d+1],l=c[d+2];c=c[d+3];d=e[f+0];var n=e[f+1],p=e[f+2];e=e[f+3];if(c!==e||h!==d||k!==n||l!==p){f=1-g;var m=h*d+k*n+l*p+c*e,q=0<=m?1:-1,s=1-m*m;s>Number.EPSILON&&(s=Math.sqrt(s),m=Math.atan2(s,m*q),f=Math.sin(f*m)/s,g=Math.sin(g*m)/s);q*=g;h=h*f+d*q;k=k*f+n*q;l=l*f+p*q;c=c*f+e*q;f===1-g&&(g=1/Math.sqrt(h*h+k*k+l*l+c*c),h*=g,k*=g,l*=g,c*=g)}a[b]=h;a[b+1]=k;a[b+2]=l;
+a[b+3]=c}});THREE.Vector2=function(a,b){this.x=a||0;this.y=b||0};
+THREE.Vector2.prototype={constructor:THREE.Vector2,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,b){this.x=a;this.y=b;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;
+case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;this.y=a.y;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;return this},
+addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,
+this.y*=a):this.y=this.x=0;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));return this},clampScalar:function(){var a,b;return function(c,d){void 0===
+a&&(a=new THREE.Vector2,b=new THREE.Vector2);a.set(c,c);b.set(d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();this.multiplyScalar(Math.max(a,Math.min(b,c))/c);return this},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):
+Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=
+2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x;a=this.y-a.y;return b*b+a*a},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;return this},lerpVectors:function(a,b,c){this.subVectors(b,a).multiplyScalar(c).add(a);return this},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];
+this.y=a[b+1];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];return this},rotateAround:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=this.x-a.x,f=this.y-a.y;this.x=e*c-f*d+a.x;this.y=e*d+f*c+a.y;return this}};THREE.Vector3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};
+THREE.Vector3.prototype={constructor:THREE.Vector3,set:function(a,b,c){this.x=a;this.y=b;this.z=c;return this},setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;
+case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,
+b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=a.x;this.y-=a.y;this.z-=a.z;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;return this},
+multiply:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,b);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},multiplyVectors:function(a,b){this.x=a.x*b.x;this.y=a.y*b.y;this.z=a.z*b.z;return this},applyEuler:function(){var a;return function(b){!1===b instanceof THREE.Euler&&
+console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");void 0===a&&(a=new THREE.Quaternion);this.applyQuaternion(a.setFromEuler(b));return this}}(),applyAxisAngle:function(){var a;return function(b,c){void 0===a&&(a=new THREE.Quaternion);this.applyQuaternion(a.setFromAxisAngle(b,c));return this}}(),applyMatrix3:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[3]*c+a[6]*d;this.y=a[1]*b+a[4]*c+a[7]*d;this.z=a[2]*b+a[5]*c+a[8]*
+d;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12];this.y=a[1]*b+a[5]*c+a[9]*d+a[13];this.z=a[2]*b+a[6]*c+a[10]*d+a[14];return this},applyProjection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;var e=1/(a[3]*b+a[7]*c+a[11]*d+a[15]);this.x=(a[0]*b+a[4]*c+a[8]*d+a[12])*e;this.y=(a[1]*b+a[5]*c+a[9]*d+a[13])*e;this.z=(a[2]*b+a[6]*c+a[10]*d+a[14])*e;return this},applyQuaternion:function(a){var b=this.x,c=this.y,d=this.z,e=a.x,
+f=a.y,g=a.z;a=a.w;var h=a*b+f*d-g*c,k=a*c+g*b-e*d,l=a*d+e*c-f*b,b=-e*b-f*c-g*d;this.x=h*a+b*-e+k*-g-l*-f;this.y=k*a+b*-f+l*-e-h*-g;this.z=l*a+b*-g+h*-f-k*-e;return this},project:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.multiplyMatrices(b.projectionMatrix,a.getInverse(b.matrixWorld));return this.applyProjection(a)}}(),unproject:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.multiplyMatrices(b.matrixWorld,a.getInverse(b.projectionMatrix));return this.applyProjection(a)}}(),
+transformDirection:function(a){var b=this.x,c=this.y,d=this.z;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d;this.y=a[1]*b+a[5]*c+a[9]*d;this.z=a[2]*b+a[6]*c+a[10]*d;this.normalize();return this},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);
+this.z=Math.max(this.z,a.z);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector3,b=new THREE.Vector3);a.set(c,c,c);b.set(d,d,d);return this.clamp(a,b)}}(),clampLength:function(a,b){var c=this.length();this.multiplyScalar(Math.max(a,Math.min(b,c))/c);return this},floor:function(){this.x=Math.floor(this.x);
+this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;
+this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*
+b;this.y+=(a.y-this.y)*b;this.z+=(a.z-this.z)*b;return this},lerpVectors:function(a,b,c){this.subVectors(b,a).multiplyScalar(c).add(a);return this},cross:function(a,b){if(void 0!==b)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,b);var c=this.x,d=this.y,e=this.z;this.x=d*a.z-e*a.y;this.y=e*a.x-c*a.z;this.z=c*a.y-d*a.x;return this},crossVectors:function(a,b){var c=a.x,d=a.y,e=a.z,f=b.x,g=b.y,h=b.z;this.x=d*h-e*g;
+this.y=e*f-c*h;this.z=c*g-d*f;return this},projectOnVector:function(){var a,b;return function(c){void 0===a&&(a=new THREE.Vector3);a.copy(c).normalize();b=this.dot(a);return this.copy(a).multiplyScalar(b)}}(),projectOnPlane:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);a.copy(this).projectOnVector(b);return this.sub(a)}}(),reflect:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);return this.sub(a.copy(b).multiplyScalar(2*this.dot(b)))}}(),angleTo:function(a){a=
+this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(THREE.Math.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var b=this.x-a.x,c=this.y-a.y;a=this.z-a.z;return b*b+c*c+a*a},setFromMatrixPosition:function(a){this.x=a.elements[12];this.y=a.elements[13];this.z=a.elements[14];return this},setFromMatrixScale:function(a){var b=this.set(a.elements[0],a.elements[1],a.elements[2]).length(),c=this.set(a.elements[4],a.elements[5],
+a.elements[6]).length();a=this.set(a.elements[8],a.elements[9],a.elements[10]).length();this.x=b;this.y=c;this.z=a;return this},setFromMatrixColumn:function(a,b){var c=4*a,d=b.elements;this.x=d[c];this.y=d[c+1];this.z=d[c+2];return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;return a},
+fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];return this}};THREE.Vector4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=void 0!==d?d:1};
+THREE.Vector4.prototype={constructor:THREE.Vector4,set:function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,b){switch(a){case 0:this.x=b;break;case 1:this.y=b;break;case 2:this.z=b;break;case 3:this.w=b;break;default:throw Error("index is out of range: "+
+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,b);
+this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,b){this.x=a.x+b.x;this.y=a.y+b.y;this.z=a.z+b.z;this.w=a.w+b.w;return this},addScaledVector:function(a,b){this.x+=a.x*b;this.y+=a.y*b;this.z+=a.z*b;this.w+=a.w*b;return this},sub:function(a,b){if(void 0!==b)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,b);this.x-=
+a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,b){this.x=a.x-b.x;this.y=a.y-b.y;this.z=a.z-b.z;this.w=a.w-b.w;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a,this.w*=a):this.w=this.z=this.y=this.x=0;return this},applyMatrix4:function(a){var b=this.x,c=this.y,d=this.z,e=this.w;a=a.elements;this.x=a[0]*b+a[4]*c+a[8]*d+a[12]*e;this.y=a[1]*b+a[5]*c+a[9]*d+a[13]*e;this.z=
+a[2]*b+a[6]*c+a[10]*d+a[14]*e;this.w=a[3]*b+a[7]*c+a[11]*d+a[15]*e;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var b=Math.sqrt(1-a.w*a.w);1E-4>b?(this.x=1,this.z=this.y=0):(this.x=a.x/b,this.y=a.y/b,this.z=a.z/b);return this},setAxisAngleFromRotationMatrix:function(a){var b,c,d;a=a.elements;var e=a[0];d=a[4];var f=a[8],g=a[1],h=a[5],k=a[9];c=a[2];b=a[6];var l=a[10];if(.01>Math.abs(d-g)&&.01>Math.abs(f-c)&&.01>
+Math.abs(k-b)){if(.1>Math.abs(d+g)&&.1>Math.abs(f+c)&&.1>Math.abs(k+b)&&.1>Math.abs(e+h+l-3))return this.set(1,0,0,0),this;a=Math.PI;e=(e+1)/2;h=(h+1)/2;l=(l+1)/2;d=(d+g)/4;f=(f+c)/4;k=(k+b)/4;e>h&&e>l?.01>e?(b=0,d=c=.707106781):(b=Math.sqrt(e),c=d/b,d=f/b):h>l?.01>h?(b=.707106781,c=0,d=.707106781):(c=Math.sqrt(h),b=d/c,d=k/c):.01>l?(c=b=.707106781,d=0):(d=Math.sqrt(l),b=f/d,c=k/d);this.set(b,c,d,a);return this}a=Math.sqrt((b-k)*(b-k)+(f-c)*(f-c)+(g-d)*(g-d));.001>Math.abs(a)&&(a=1);this.x=(b-k)/
+a;this.y=(f-c)/a;this.z=(g-d)/a;this.w=Math.acos((e+h+l-1)/2);return this},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,b){this.x=Math.max(a.x,Math.min(b.x,this.x));this.y=Math.max(a.y,Math.min(b.y,this.y));this.z=Math.max(a.z,Math.min(b.z,this.z));
+this.w=Math.max(a.w,Math.min(b.w,this.w));return this},clampScalar:function(){var a,b;return function(c,d){void 0===a&&(a=new THREE.Vector4,b=new THREE.Vector4);a.set(c,c,c,c);b.set(d,d,d,d);return this.clamp(a,b)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=
+Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*
+a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,b){this.x+=(a.x-this.x)*b;this.y+=(a.y-this.y)*b;this.z+=(a.z-
+this.z)*b;this.w+=(a.w-this.w)*b;return this},lerpVectors:function(a,b,c){this.subVectors(b,a).multiplyScalar(c).add(a);return this},equals:function(a){return a.x===this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,b){void 0===b&&(b=0);this.x=a[b];this.y=a[b+1];this.z=a[b+2];this.w=a[b+3];return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this.x;a[b+1]=this.y;a[b+2]=this.z;a[b+3]=this.w;return a},fromAttribute:function(a,b,c){void 0===c&&(c=0);b=b*a.itemSize+
+c;this.x=a.array[b];this.y=a.array[b+1];this.z=a.array[b+2];this.w=a.array[b+3];return this}};THREE.Euler=function(a,b,c,d){this._x=a||0;this._y=b||0;this._z=c||0;this._order=d||THREE.Euler.DefaultOrder};THREE.Euler.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");THREE.Euler.DefaultOrder="XYZ";
+THREE.Euler.prototype={constructor:THREE.Euler,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a;this.onChangeCallback()},set:function(a,b,c,d){this._x=a;this._y=b;this._z=c;this._order=d||this._order;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,
+this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,b,c){var d=THREE.Math.clamp,e=a.elements;a=e[0];var f=e[4],g=e[8],h=e[1],k=e[5],l=e[9],n=e[2],p=e[6],e=e[10];b=b||this._order;"XYZ"===b?(this._y=Math.asin(d(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(-l,e),this._z=Math.atan2(-f,a)):(this._x=Math.atan2(p,k),this._z=0)):"YXZ"===b?(this._x=Math.asin(-d(l,-1,1)),.99999>Math.abs(l)?
+(this._y=Math.atan2(g,e),this._z=Math.atan2(h,k)):(this._y=Math.atan2(-n,a),this._z=0)):"ZXY"===b?(this._x=Math.asin(d(p,-1,1)),.99999>Math.abs(p)?(this._y=Math.atan2(-n,e),this._z=Math.atan2(-f,k)):(this._y=0,this._z=Math.atan2(h,a))):"ZYX"===b?(this._y=Math.asin(-d(n,-1,1)),.99999>Math.abs(n)?(this._x=Math.atan2(p,e),this._z=Math.atan2(h,a)):(this._x=0,this._z=Math.atan2(-f,k))):"YZX"===b?(this._z=Math.asin(d(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-l,k),this._y=Math.atan2(-n,a)):(this._x=
+0,this._y=Math.atan2(g,e))):"XZY"===b?(this._z=Math.asin(-d(f,-1,1)),.99999>Math.abs(f)?(this._x=Math.atan2(p,k),this._y=Math.atan2(g,a)):(this._x=Math.atan2(-l,e),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+b);this._order=b;if(!1!==c)this.onChangeCallback();return this},setFromQuaternion:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeRotationFromQuaternion(b);this.setFromRotationMatrix(a,c,d);return this}}(),setFromVector3:function(a,
+b){return this.set(a.x,a.y,a.z,b||this._order)},reorder:function(){var a=new THREE.Quaternion;return function(b){a.setFromEuler(this);this.setFromQuaternion(a,b)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();return this},toArray:function(a,b){void 0===a&&(a=[]);void 0===b&&(b=0);a[b]=this._x;a[b+1]=this._y;a[b+2]=this._z;a[b+
+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new THREE.Vector3(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};THREE.Line3=function(a,b){this.start=void 0!==a?a:new THREE.Vector3;this.end=void 0!==b?b:new THREE.Vector3};
+THREE.Line3.prototype={constructor:THREE.Line3,set:function(a,b){this.start.copy(a);this.end.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.start.copy(a.start);this.end.copy(a.end);return this},center:function(a){return(a||new THREE.Vector3).addVectors(this.start,this.end).multiplyScalar(.5)},delta:function(a){return(a||new THREE.Vector3).subVectors(this.end,this.start)},distanceSq:function(){return this.start.distanceToSquared(this.end)},distance:function(){return this.start.distanceTo(this.end)},
+at:function(a,b){var c=b||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},closestPointToPointParameter:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d){a.subVectors(c,this.start);b.subVectors(this.end,this.start);var e=b.dot(b),e=b.dot(a)/e;d&&(e=THREE.Math.clamp(e,0,1));return e}}(),closestPointToPoint:function(a,b,c){a=this.closestPointToPointParameter(a,b);c=c||new THREE.Vector3;return this.delta(c).multiplyScalar(a).add(this.start)},applyMatrix4:function(a){this.start.applyMatrix4(a);
+this.end.applyMatrix4(a);return this},equals:function(a){return a.start.equals(this.start)&&a.end.equals(this.end)}};THREE.Box2=function(a,b){this.min=void 0!==a?a:new THREE.Vector2(Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector2(-Infinity,-Infinity)};
+THREE.Box2.prototype={constructor:THREE.Box2,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new THREE.Vector2;return function(b,c){var d=a.copy(c).multiplyScalar(.5);this.min.copy(b).sub(d);this.max.copy(b).add(d);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);this.max.copy(a.max);
+return this},makeEmpty:function(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},center:function(a){return(a||new THREE.Vector2).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(a){return(a||new THREE.Vector2).subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);
+this.max.addScalar(a);return this},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getParameter:function(a,b){return(b||new THREE.Vector2).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>
+this.max.y?!1:!0},clampPoint:function(a,b){return(b||new THREE.Vector2).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new THREE.Vector2;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&
+a.max.equals(this.max)}};THREE.Box3=function(a,b){this.min=void 0!==a?a:new THREE.Vector3(Infinity,Infinity,Infinity);this.max=void 0!==b?b:new THREE.Vector3(-Infinity,-Infinity,-Infinity)};
+THREE.Box3.prototype={constructor:THREE.Box3,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){this.makeEmpty();for(var b=Infinity,c=Infinity,d=Infinity,e=-Infinity,f=-Infinity,g=-Infinity,h=0,k=a.length;h<k;h+=3){var l=a[h],n=a[h+1],p=a[h+2];l<b&&(b=l);n<c&&(c=n);p<d&&(d=p);l>e&&(e=l);n>f&&(f=n);p>g&&(g=p)}this.min.set(b,c,d);this.max.set(e,f,g)},setFromPoints:function(a){this.makeEmpty();for(var b=0,c=a.length;b<c;b++)this.expandByPoint(a[b]);return this},
+setFromCenterAndSize:function(){var a=new THREE.Vector3;return function(b,c){var d=a.copy(c).multiplyScalar(.5);this.min.copy(b).sub(d);this.max.copy(b).add(d);return this}}(),setFromObject:function(){var a;return function(b){void 0===a&&(a=new THREE.Box3);var c=this;this.makeEmpty();b.updateMatrixWorld(!0);b.traverse(function(b){var e=b.geometry;void 0!==e&&(null===e.boundingBox&&e.computeBoundingBox(),a.copy(e.boundingBox),a.applyMatrix4(b.matrixWorld),c.union(a))});return this}}(),clone:function(){return(new this.constructor).copy(this)},
+copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},makeEmpty:function(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=this.max.y=this.max.z=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},center:function(a){return(a||new THREE.Vector3).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(a){return(a||new THREE.Vector3).subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);
+this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);this.max.addScalar(a);return this},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y||a.z<this.min.z||a.z>this.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getParameter:function(a,
+b){return(b||new THREE.Vector3).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y||a.max.z<this.min.z||a.min.z>this.max.z?!1:!0},intersectsSphere:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);this.clampPoint(b.center,a);return a.distanceToSquared(b.center)<=b.radius*b.radius}}(),intersectsPlane:function(a){var b,
+c;0<a.normal.x?(b=a.normal.x*this.min.x,c=a.normal.x*this.max.x):(b=a.normal.x*this.max.x,c=a.normal.x*this.min.x);0<a.normal.y?(b+=a.normal.y*this.min.y,c+=a.normal.y*this.max.y):(b+=a.normal.y*this.max.y,c+=a.normal.y*this.min.y);0<a.normal.z?(b+=a.normal.z*this.min.z,c+=a.normal.z*this.max.z):(b+=a.normal.z*this.max.z,c+=a.normal.z*this.min.z);return b<=a.constant&&c>=a.constant},clampPoint:function(a,b){return(b||new THREE.Vector3).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=
+new THREE.Vector3;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new THREE.Vector3;return function(b){b=b||new THREE.Sphere;b.center=this.center();b.radius=.5*this.size(a).length();return b}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,
+new THREE.Vector3,new THREE.Vector3,new THREE.Vector3,new THREE.Vector3];return function(b){a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);
+a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.makeEmpty();this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};THREE.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]);0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")};
+THREE.Matrix3.prototype={constructor:THREE.Matrix3,set:function(a,b,c,d,e,f,g,h,k){var l=this.elements;l[0]=a;l[3]=b;l[6]=c;l[1]=d;l[4]=e;l[7]=f;l[2]=g;l[5]=h;l[8]=k;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Vector3);
+void 0===c&&(c=0);void 0===d&&(d=b.length);for(var e=0;e<d;e+=3,c+=3)a.fromArray(b,c),a.applyMatrix3(this),a.toArray(b,c);return b}}(),applyToBuffer:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Vector3);void 0===c&&(c=0);void 0===d&&(d=b.length/b.itemSize);for(var e=0;e<d;e++,c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.applyMatrix3(this),b.setXYZ(a.x,a.y,a.z);return b}}(),multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[3]*=a;b[6]*=a;b[1]*=a;b[4]*=a;b[7]*=a;b[2]*=a;
+b[5]*=a;b[8]*=a;return this},determinant:function(){var a=this.elements,b=a[0],c=a[1],d=a[2],e=a[3],f=a[4],g=a[5],h=a[6],k=a[7],a=a[8];return b*f*a-b*g*k-c*e*a+c*g*h+d*e*k-d*f*h},getInverse:function(a,b){var c=a.elements,d=this.elements;d[0]=c[10]*c[5]-c[6]*c[9];d[1]=-c[10]*c[1]+c[2]*c[9];d[2]=c[6]*c[1]-c[2]*c[5];d[3]=-c[10]*c[4]+c[6]*c[8];d[4]=c[10]*c[0]-c[2]*c[8];d[5]=-c[6]*c[0]+c[2]*c[4];d[6]=c[9]*c[4]-c[5]*c[8];d[7]=-c[9]*c[0]+c[1]*c[8];d[8]=c[5]*c[0]-c[1]*c[4];c=c[0]*d[0]+c[1]*d[3]+c[2]*d[6];
+if(0===c){if(b)throw Error("THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0");console.warn("THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0");this.identity();return this}this.multiplyScalar(1/c);return this},transpose:function(){var a,b=this.elements;a=b[1];b[1]=b[3];b[3]=a;a=b[2];b[2]=b[6];b[6]=a;a=b[5];b[5]=b[7];b[7]=a;return this},flattenToArrayOffset:function(a,b){var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=c[4];a[b+5]=c[5];a[b+
+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];return a},getNormalMatrix:function(a){this.getInverse(a).transpose();return this},transposeIntoArray:function(a){var b=this.elements;a[0]=b[0];a[1]=b[3];a[2]=b[6];a[3]=b[1];a[4]=b[4];a[5]=b[7];a[6]=b[2];a[7]=b[5];a[8]=b[8];return this},fromArray:function(a){this.elements.set(a);return this},toArray:function(){var a=this.elements;return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8]]}};
+THREE.Matrix4=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")};
+THREE.Matrix4.prototype={constructor:THREE.Matrix4,set:function(a,b,c,d,e,f,g,h,k,l,n,p,m,q,s,u){var t=this.elements;t[0]=a;t[4]=b;t[8]=c;t[12]=d;t[1]=e;t[5]=f;t[9]=g;t[13]=h;t[2]=k;t[6]=l;t[10]=n;t[14]=p;t[3]=m;t[7]=q;t[11]=s;t[15]=u;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new THREE.Matrix4).fromArray(this.elements)},copy:function(a){this.elements.set(a.elements);return this},copyPosition:function(a){var b=this.elements;a=a.elements;
+b[12]=a[12];b[13]=a[13];b[14]=a[14];return this},extractBasis:function(a,b,c){var d=this.elements;a.set(d[0],d[1],d[2]);b.set(d[4],d[5],d[6]);c.set(d[8],d[9],d[10]);return this},makeBasis:function(a,b,c){this.set(a.x,b.x,c.x,0,a.y,b.y,c.y,0,a.z,b.z,c.z,0,0,0,0,1);return this},extractRotation:function(){var a;return function(b){void 0===a&&(a=new THREE.Vector3);var c=this.elements;b=b.elements;var d=1/a.set(b[0],b[1],b[2]).length(),e=1/a.set(b[4],b[5],b[6]).length(),f=1/a.set(b[8],b[9],b[10]).length();
+c[0]=b[0]*d;c[1]=b[1]*d;c[2]=b[2]*d;c[4]=b[4]*e;c[5]=b[5]*e;c[6]=b[6]*e;c[8]=b[8]*f;c[9]=b[9]*f;c[10]=b[10]*f;return this}}(),makeRotationFromEuler:function(a){!1===a instanceof THREE.Euler&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var b=this.elements,c=a.x,d=a.y,e=a.z,f=Math.cos(c),c=Math.sin(c),g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e);if("XYZ"===a.order){a=f*h;var k=f*e,l=c*h,n=c*e;b[0]=g*h;b[4]=-g*e;b[8]=
+d;b[1]=k+l*d;b[5]=a-n*d;b[9]=-c*g;b[2]=n-a*d;b[6]=l+k*d;b[10]=f*g}else"YXZ"===a.order?(a=g*h,k=g*e,l=d*h,n=d*e,b[0]=a+n*c,b[4]=l*c-k,b[8]=f*d,b[1]=f*e,b[5]=f*h,b[9]=-c,b[2]=k*c-l,b[6]=n+a*c,b[10]=f*g):"ZXY"===a.order?(a=g*h,k=g*e,l=d*h,n=d*e,b[0]=a-n*c,b[4]=-f*e,b[8]=l+k*c,b[1]=k+l*c,b[5]=f*h,b[9]=n-a*c,b[2]=-f*d,b[6]=c,b[10]=f*g):"ZYX"===a.order?(a=f*h,k=f*e,l=c*h,n=c*e,b[0]=g*h,b[4]=l*d-k,b[8]=a*d+n,b[1]=g*e,b[5]=n*d+a,b[9]=k*d-l,b[2]=-d,b[6]=c*g,b[10]=f*g):"YZX"===a.order?(a=f*g,k=f*d,l=c*g,n=
+c*d,b[0]=g*h,b[4]=n-a*e,b[8]=l*e+k,b[1]=e,b[5]=f*h,b[9]=-c*h,b[2]=-d*h,b[6]=k*e+l,b[10]=a-n*e):"XZY"===a.order&&(a=f*g,k=f*d,l=c*g,n=c*d,b[0]=g*h,b[4]=-e,b[8]=d*h,b[1]=a*e+n,b[5]=f*h,b[9]=k*e-l,b[2]=l*e-k,b[6]=c*h,b[10]=n*e+a);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},makeRotationFromQuaternion:function(a){var b=this.elements,c=a.x,d=a.y,e=a.z,f=a.w,g=c+c,h=d+d,k=e+e;a=c*g;var l=c*h,c=c*k,n=d*h,d=d*k,e=e*k,g=f*g,h=f*h,f=f*k;b[0]=1-(n+e);b[4]=l-f;b[8]=c+h;b[1]=l+f;b[5]=1-(a+
+e);b[9]=d-g;b[2]=c-h;b[6]=d+g;b[10]=1-(a+n);b[3]=0;b[7]=0;b[11]=0;b[12]=0;b[13]=0;b[14]=0;b[15]=1;return this},lookAt:function(){var a,b,c;return function(d,e,f){void 0===a&&(a=new THREE.Vector3);void 0===b&&(b=new THREE.Vector3);void 0===c&&(c=new THREE.Vector3);var g=this.elements;c.subVectors(d,e).normalize();0===c.lengthSq()&&(c.z=1);a.crossVectors(f,c).normalize();0===a.lengthSq()&&(c.x+=1E-4,a.crossVectors(f,c).normalize());b.crossVectors(c,a);g[0]=a.x;g[4]=b.x;g[8]=c.x;g[1]=a.y;g[5]=b.y;g[9]=
+c.y;g[2]=a.z;g[6]=b.z;g[10]=c.z;return this}}(),multiply:function(a,b){return void 0!==b?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,b)):this.multiplyMatrices(this,a)},multiplyMatrices:function(a,b){var c=a.elements,d=b.elements,e=this.elements,f=c[0],g=c[4],h=c[8],k=c[12],l=c[1],n=c[5],p=c[9],m=c[13],q=c[2],s=c[6],u=c[10],t=c[14],x=c[3],v=c[7],C=c[11],c=c[15],w=d[0],D=d[4],z=d[8],y=d[12],A=d[1],H=d[5],G=
+d[9],E=d[13],K=d[2],P=d[6],N=d[10],L=d[14],B=d[3],M=d[7],Q=d[11],d=d[15];e[0]=f*w+g*A+h*K+k*B;e[4]=f*D+g*H+h*P+k*M;e[8]=f*z+g*G+h*N+k*Q;e[12]=f*y+g*E+h*L+k*d;e[1]=l*w+n*A+p*K+m*B;e[5]=l*D+n*H+p*P+m*M;e[9]=l*z+n*G+p*N+m*Q;e[13]=l*y+n*E+p*L+m*d;e[2]=q*w+s*A+u*K+t*B;e[6]=q*D+s*H+u*P+t*M;e[10]=q*z+s*G+u*N+t*Q;e[14]=q*y+s*E+u*L+t*d;e[3]=x*w+v*A+C*K+c*B;e[7]=x*D+v*H+C*P+c*M;e[11]=x*z+v*G+C*N+c*Q;e[15]=x*y+v*E+C*L+c*d;return this},multiplyToArray:function(a,b,c){var d=this.elements;this.multiplyMatrices(a,
+b);c[0]=d[0];c[1]=d[1];c[2]=d[2];c[3]=d[3];c[4]=d[4];c[5]=d[5];c[6]=d[6];c[7]=d[7];c[8]=d[8];c[9]=d[9];c[10]=d[10];c[11]=d[11];c[12]=d[12];c[13]=d[13];c[14]=d[14];c[15]=d[15];return this},multiplyScalar:function(a){var b=this.elements;b[0]*=a;b[4]*=a;b[8]*=a;b[12]*=a;b[1]*=a;b[5]*=a;b[9]*=a;b[13]*=a;b[2]*=a;b[6]*=a;b[10]*=a;b[14]*=a;b[3]*=a;b[7]*=a;b[11]*=a;b[15]*=a;return this},applyToVector3Array:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Vector3);void 0===c&&(c=0);void 0===
+d&&(d=b.length);for(var e=0;e<d;e+=3,c+=3)a.fromArray(b,c),a.applyMatrix4(this),a.toArray(b,c);return b}}(),applyToBuffer:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Vector3);void 0===c&&(c=0);void 0===d&&(d=b.length/b.itemSize);for(var e=0;e<d;e++,c++)a.x=b.getX(c),a.y=b.getY(c),a.z=b.getZ(c),a.applyMatrix4(this),b.setXYZ(a.x,a.y,a.z);return b}}(),determinant:function(){var a=this.elements,b=a[0],c=a[4],d=a[8],e=a[12],f=a[1],g=a[5],h=a[9],k=a[13],l=a[2],n=a[6],p=a[10],m=a[14];
+return a[3]*(+e*h*n-d*k*n-e*g*p+c*k*p+d*g*m-c*h*m)+a[7]*(+b*h*m-b*k*p+e*f*p-d*f*m+d*k*l-e*h*l)+a[11]*(+b*k*n-b*g*m-e*f*n+c*f*m+e*g*l-c*k*l)+a[15]*(-d*g*l-b*h*n+b*g*p+d*f*n-c*f*p+c*h*l)},transpose:function(){var a=this.elements,b;b=a[1];a[1]=a[4];a[4]=b;b=a[2];a[2]=a[8];a[8]=b;b=a[6];a[6]=a[9];a[9]=b;b=a[3];a[3]=a[12];a[12]=b;b=a[7];a[7]=a[13];a[13]=b;b=a[11];a[11]=a[14];a[14]=b;return this},flattenToArrayOffset:function(a,b){var c=this.elements;a[b]=c[0];a[b+1]=c[1];a[b+2]=c[2];a[b+3]=c[3];a[b+4]=
+c[4];a[b+5]=c[5];a[b+6]=c[6];a[b+7]=c[7];a[b+8]=c[8];a[b+9]=c[9];a[b+10]=c[10];a[b+11]=c[11];a[b+12]=c[12];a[b+13]=c[13];a[b+14]=c[14];a[b+15]=c[15];return a},getPosition:function(){var a;return function(){void 0===a&&(a=new THREE.Vector3);console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");var b=this.elements;return a.set(b[12],b[13],b[14])}}(),setPosition:function(a){var b=this.elements;b[12]=a.x;b[13]=a.y;b[14]=a.z;return this},getInverse:function(a,
+b){var c=this.elements,d=a.elements,e=d[0],f=d[4],g=d[8],h=d[12],k=d[1],l=d[5],n=d[9],p=d[13],m=d[2],q=d[6],s=d[10],u=d[14],t=d[3],x=d[7],v=d[11],d=d[15];c[0]=n*u*x-p*s*x+p*q*v-l*u*v-n*q*d+l*s*d;c[4]=h*s*x-g*u*x-h*q*v+f*u*v+g*q*d-f*s*d;c[8]=g*p*x-h*n*x+h*l*v-f*p*v-g*l*d+f*n*d;c[12]=h*n*q-g*p*q-h*l*s+f*p*s+g*l*u-f*n*u;c[1]=p*s*t-n*u*t-p*m*v+k*u*v+n*m*d-k*s*d;c[5]=g*u*t-h*s*t+h*m*v-e*u*v-g*m*d+e*s*d;c[9]=h*n*t-g*p*t-h*k*v+e*p*v+g*k*d-e*n*d;c[13]=g*p*m-h*n*m+h*k*s-e*p*s-g*k*u+e*n*u;c[2]=l*u*t-p*q*t+
+p*m*x-k*u*x-l*m*d+k*q*d;c[6]=h*q*t-f*u*t-h*m*x+e*u*x+f*m*d-e*q*d;c[10]=f*p*t-h*l*t+h*k*x-e*p*x-f*k*d+e*l*d;c[14]=h*l*m-f*p*m-h*k*q+e*p*q+f*k*u-e*l*u;c[3]=n*q*t-l*s*t-n*m*x+k*s*x+l*m*v-k*q*v;c[7]=f*s*t-g*q*t+g*m*x-e*s*x-f*m*v+e*q*v;c[11]=g*l*t-f*n*t-g*k*x+e*n*x+f*k*v-e*l*v;c[15]=f*n*m-g*l*m+g*k*q-e*n*q-f*k*s+e*l*s;c=e*c[0]+k*c[4]+m*c[8]+t*c[12];if(0===c){if(b)throw Error("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0");console.warn("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0");
+this.identity();return this}this.multiplyScalar(1/c);return this},scale:function(a){var b=this.elements,c=a.x,d=a.y;a=a.z;b[0]*=c;b[4]*=d;b[8]*=a;b[1]*=c;b[5]*=d;b[9]*=a;b[2]*=c;b[6]*=d;b[10]*=a;b[3]*=c;b[7]*=d;b[11]*=a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10]))},makeTranslation:function(a,b,c){this.set(1,0,0,a,0,1,0,b,0,0,1,c,0,0,0,1);return this},makeRotationX:function(a){var b=
+Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,b,-a,0,0,a,b,0,0,0,0,1);return this},makeRotationY:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,0,a,0,0,1,0,0,-a,0,b,0,0,0,0,1);return this},makeRotationZ:function(a){var b=Math.cos(a);a=Math.sin(a);this.set(b,-a,0,0,a,b,0,0,0,0,1,0,0,0,0,1);return this},makeRotationAxis:function(a,b){var c=Math.cos(b),d=Math.sin(b),e=1-c,f=a.x,g=a.y,h=a.z,k=e*f,l=e*g;this.set(k*f+c,k*g-d*h,k*h+d*g,0,k*g+d*h,l*g+c,l*h-d*f,0,k*h-d*g,l*h+d*f,e*h*h+c,0,0,0,0,1);
+return this},makeScale:function(a,b,c){this.set(a,0,0,0,0,b,0,0,0,0,c,0,0,0,0,1);return this},compose:function(a,b,c){this.makeRotationFromQuaternion(b);this.scale(c);this.setPosition(a);return this},decompose:function(){var a,b;return function(c,d,e){void 0===a&&(a=new THREE.Vector3);void 0===b&&(b=new THREE.Matrix4);var f=this.elements,g=a.set(f[0],f[1],f[2]).length(),h=a.set(f[4],f[5],f[6]).length(),k=a.set(f[8],f[9],f[10]).length();0>this.determinant()&&(g=-g);c.x=f[12];c.y=f[13];c.z=f[14];b.elements.set(this.elements);
+c=1/g;var f=1/h,l=1/k;b.elements[0]*=c;b.elements[1]*=c;b.elements[2]*=c;b.elements[4]*=f;b.elements[5]*=f;b.elements[6]*=f;b.elements[8]*=l;b.elements[9]*=l;b.elements[10]*=l;d.setFromRotationMatrix(b);e.x=g;e.y=h;e.z=k;return this}}(),makeFrustum:function(a,b,c,d,e,f){var g=this.elements;g[0]=2*e/(b-a);g[4]=0;g[8]=(b+a)/(b-a);g[12]=0;g[1]=0;g[5]=2*e/(d-c);g[9]=(d+c)/(d-c);g[13]=0;g[2]=0;g[6]=0;g[10]=-(f+e)/(f-e);g[14]=-2*f*e/(f-e);g[3]=0;g[7]=0;g[11]=-1;g[15]=0;return this},makePerspective:function(a,
+b,c,d){a=c*Math.tan(THREE.Math.degToRad(.5*a));var e=-a;return this.makeFrustum(e*b,a*b,e,a,c,d)},makeOrthographic:function(a,b,c,d,e,f){var g=this.elements,h=b-a,k=c-d,l=f-e;g[0]=2/h;g[4]=0;g[8]=0;g[12]=-((b+a)/h);g[1]=0;g[5]=2/k;g[9]=0;g[13]=-((c+d)/k);g[2]=0;g[6]=0;g[10]=-2/l;g[14]=-((f+e)/l);g[3]=0;g[7]=0;g[11]=0;g[15]=1;return this},equals:function(a){var b=this.elements;a=a.elements;for(var c=0;16>c;c++)if(b[c]!==a[c])return!1;return!0},fromArray:function(a){this.elements.set(a);return this},
+toArray:function(){var a=this.elements;return[a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9],a[10],a[11],a[12],a[13],a[14],a[15]]}};THREE.Ray=function(a,b){this.origin=void 0!==a?a:new THREE.Vector3;this.direction=void 0!==b?b:new THREE.Vector3};
+THREE.Ray.prototype={constructor:THREE.Ray,set:function(a,b){this.origin.copy(a);this.direction.copy(b);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,b){return(b||new THREE.Vector3).copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize()},recast:function(){var a=new THREE.Vector3;return function(b){this.origin.copy(this.at(b,
+a));return this}}(),closestPointToPoint:function(a,b){var c=b||new THREE.Vector3;c.subVectors(a,this.origin);var d=c.dot(this.direction);return 0>d?c.copy(this.origin):c.copy(this.direction).multiplyScalar(d).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new THREE.Vector3;return function(b){var c=a.subVectors(b,this.origin).dot(this.direction);if(0>c)return this.origin.distanceToSquared(b);a.copy(this.direction).multiplyScalar(c).add(this.origin);
+return a.distanceToSquared(b)}}(),distanceSqToSegment:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(d,e,f,g){a.copy(d).add(e).multiplyScalar(.5);b.copy(e).sub(d).normalize();c.copy(this.origin).sub(a);var h=.5*d.distanceTo(e),k=-this.direction.dot(b),l=c.dot(this.direction),n=-c.dot(b),p=c.lengthSq(),m=Math.abs(1-k*k),q;0<m?(d=k*n-l,e=k*l-n,q=h*m,0<=d?e>=-q?e<=q?(h=1/m,d*=h,e*=h,k=d*(d+k*e+2*l)+e*(k*d+e+2*n)+p):(e=h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*
+n)+p):(e=-h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*n)+p):e<=-q?(d=Math.max(0,-(-k*h+l)),e=0<d?-h:Math.min(Math.max(-h,-n),h),k=-d*d+e*(e+2*n)+p):e<=q?(d=0,e=Math.min(Math.max(-h,-n),h),k=e*(e+2*n)+p):(d=Math.max(0,-(k*h+l)),e=0<d?h:Math.min(Math.max(-h,-n),h),k=-d*d+e*(e+2*n)+p)):(e=0<k?-h:h,d=Math.max(0,-(k*e+l)),k=-d*d+e*(e+2*n)+p);f&&f.copy(this.direction).multiplyScalar(d).add(this.origin);g&&g.copy(b).multiplyScalar(e).add(a);return k}}(),intersectSphere:function(){var a=new THREE.Vector3;return function(b,
+c){a.subVectors(b.center,this.origin);var d=a.dot(this.direction),e=a.dot(a)-d*d,f=b.radius*b.radius;if(e>f)return null;f=Math.sqrt(f-e);e=d-f;d+=f;return 0>e&&0>d?null:0>e?this.at(d,c):this.at(e,c)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<=a.radius},distanceToPlane:function(a){var b=a.normal.dot(this.direction);if(0===b)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/b;return 0<=a?a:null},intersectPlane:function(a,b){var c=
+this.distanceToPlane(a);return null===c?null:this.at(c,b)},intersectsPlane:function(a){var b=a.distanceToPoint(this.origin);return 0===b||0>a.normal.dot(this.direction)*b?!0:!1},intersectBox:function(a,b){var c,d,e,f,g;d=1/this.direction.x;f=1/this.direction.y;g=1/this.direction.z;var h=this.origin;0<=d?(c=(a.min.x-h.x)*d,d*=a.max.x-h.x):(c=(a.max.x-h.x)*d,d*=a.min.x-h.x);0<=f?(e=(a.min.y-h.y)*f,f*=a.max.y-h.y):(e=(a.max.y-h.y)*f,f*=a.min.y-h.y);if(c>f||e>d)return null;if(e>c||c!==c)c=e;if(f<d||d!==
+d)d=f;0<=g?(e=(a.min.z-h.z)*g,g*=a.max.z-h.z):(e=(a.max.z-h.z)*g,g*=a.min.z-h.z);if(c>g||e>d)return null;if(e>c||c!==c)c=e;if(g<d||d!==d)d=g;return 0>d?null:this.at(0<=c?c:d,b)},intersectsBox:function(){var a=new THREE.Vector3;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3,d=new THREE.Vector3;return function(e,f,g,h,k){b.subVectors(f,e);c.subVectors(g,e);d.crossVectors(b,c);f=this.direction.dot(d);
+if(0<f){if(h)return null;h=1}else if(0>f)h=-1,f=-f;else return null;a.subVectors(this.origin,e);e=h*this.direction.dot(c.crossVectors(a,c));if(0>e)return null;g=h*this.direction.dot(b.cross(a));if(0>g||e+g>f)return null;e=-h*a.dot(d);return 0>e?null:this.at(e/f,k)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}};
+THREE.Sphere=function(a,b){this.center=void 0!==a?a:new THREE.Vector3;this.radius=void 0!==b?b:0};
+THREE.Sphere.prototype={constructor:THREE.Sphere,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new THREE.Box3;return function(b,c){var d=this.center;void 0!==c?d.copy(c):a.setFromPoints(b).center(d);for(var e=0,f=0,g=b.length;f<g;f++)e=Math.max(e,d.distanceToSquared(b[f]));this.radius=Math.sqrt(e);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.center.copy(a.center);this.radius=a.radius;return this},
+empty:function(){return 0>=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},intersectsPlane:function(a){return Math.abs(this.center.dot(a.normal)-a.constant)<=this.radius},clampPoint:function(a,b){var c=
+this.center.distanceToSquared(a),d=b||new THREE.Vector3;d.copy(a);c>this.radius*this.radius&&(d.sub(this.center).normalize(),d.multiplyScalar(this.radius).add(this.center));return d},getBoundingBox:function(a){a=a||new THREE.Box3;a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&
+a.radius===this.radius}};THREE.Frustum=function(a,b,c,d,e,f){this.planes=[void 0!==a?a:new THREE.Plane,void 0!==b?b:new THREE.Plane,void 0!==c?c:new THREE.Plane,void 0!==d?d:new THREE.Plane,void 0!==e?e:new THREE.Plane,void 0!==f?f:new THREE.Plane]};
+THREE.Frustum.prototype={constructor:THREE.Frustum,set:function(a,b,c,d,e,f){var g=this.planes;g[0].copy(a);g[1].copy(b);g[2].copy(c);g[3].copy(d);g[4].copy(e);g[5].copy(f);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){for(var b=this.planes,c=0;6>c;c++)b[c].copy(a.planes[c]);return this},setFromMatrix:function(a){var b=this.planes,c=a.elements;a=c[0];var d=c[1],e=c[2],f=c[3],g=c[4],h=c[5],k=c[6],l=c[7],n=c[8],p=c[9],m=c[10],q=c[11],s=c[12],u=c[13],t=c[14],
+c=c[15];b[0].setComponents(f-a,l-g,q-n,c-s).normalize();b[1].setComponents(f+a,l+g,q+n,c+s).normalize();b[2].setComponents(f+d,l+h,q+p,c+u).normalize();b[3].setComponents(f-d,l-h,q-p,c-u).normalize();b[4].setComponents(f-e,l-k,q-m,c-t).normalize();b[5].setComponents(f+e,l+k,q+m,c+t).normalize();return this},intersectsObject:function(){var a=new THREE.Sphere;return function(b){var c=b.geometry;null===c.boundingSphere&&c.computeBoundingSphere();a.copy(c.boundingSphere);a.applyMatrix4(b.matrixWorld);
+return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,c=a.center;a=-a.radius;for(var d=0;6>d;d++)if(b[d].distanceToPoint(c)<a)return!1;return!0},intersectsBox:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c){for(var d=this.planes,e=0;6>e;e++){var f=d[e];a.x=0<f.normal.x?c.min.x:c.max.x;b.x=0<f.normal.x?c.max.x:c.min.x;a.y=0<f.normal.y?c.min.y:c.max.y;b.y=0<f.normal.y?c.max.y:c.min.y;a.z=0<f.normal.z?c.min.z:c.max.z;b.z=0<f.normal.z?c.max.z:c.min.z;
+var g=f.distanceToPoint(a),f=f.distanceToPoint(b);if(0>g&&0>f)return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,c=0;6>c;c++)if(0>b[c].distanceToPoint(a))return!1;return!0}};THREE.Plane=function(a,b){this.normal=void 0!==a?a:new THREE.Vector3(1,0,0);this.constant=void 0!==b?b:0};
+THREE.Plane.prototype={constructor:THREE.Plane,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,c,d){this.normal.set(a,b,c);this.constant=d;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c,d,e){d=a.subVectors(e,d).cross(b.subVectors(c,d)).normalize();this.setFromNormalAndCoplanarPoint(d,
+c);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,
+b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,b){var c=this.distanceToPoint(a);return(b||new THREE.Vector3).copy(this.normal).multiplyScalar(c)},intersectLine:function(){var a=new THREE.Vector3;return function(b,c){var d=c||new THREE.Vector3,e=b.delta(a),f=this.normal.dot(e);if(0===f){if(0===this.distanceToPoint(b.start))return d.copy(b.start)}else return f=-(b.start.dot(this.normal)+this.constant)/f,0>f||1<f?void 0:d.copy(e).multiplyScalar(f).add(b.start)}}(),intersectsLine:function(a){var b=
+this.distanceToPoint(a.start);a=this.distanceToPoint(a.end);return 0>b&&0<a||0>a&&0<b},intersectsBox:function(a){return a.intersectsPlane(this)},intersectsSphere:function(a){return a.intersectsPlane(this)},coplanarPoint:function(a){return(a||new THREE.Vector3).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Matrix3;return function(d,e){var f=e||c.getNormalMatrix(d),f=a.copy(this.normal).applyMatrix3(f),g=this.coplanarPoint(b);
+g.applyMatrix4(d);this.setFromNormalAndCoplanarPoint(f,g);return this}}(),translate:function(a){this.constant-=a.dot(this.normal);return this},equals:function(a){return a.normal.equals(this.normal)&&a.constant===this.constant}};
+THREE.Math={generateUUID:function(){var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),b=Array(36),c=0,d;return function(){for(var e=0;36>e;e++)8===e||13===e||18===e||23===e?b[e]="-":14===e?b[e]="4":(2>=c&&(c=33554432+16777216*Math.random()|0),d=c&15,c>>=4,b[e]=a[19===e?d&3|8:d]);return b.join("")}}(),clamp:function(a,b,c){return Math.max(b,Math.min(c,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,c,d,e){return d+(a-b)*(e-d)/(c-b)},smoothstep:function(a,
+b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*(3-2*a)},smootherstep:function(a,b,c){if(a<=b)return 0;if(a>=c)return 1;a=(a-b)/(c-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead.");return Math.random()},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(){var a=
+Math.PI/180;return function(b){return b*a}}(),radToDeg:function(){var a=180/Math.PI;return function(b){return b*a}}(),isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.pow(2,Math.round(Math.log(a)/Math.LN2))},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;return a}};
+THREE.Spline=function(a){function b(a,b,c,d,e,f,g){a=.5*(c-a);d=.5*(d-b);return(2*(b-c)+a+d)*g+(-3*(b-c)-2*a-d)*f+a*e+b}this.points=a;var c=[],d={x:0,y:0,z:0},e,f,g,h,k,l,n,p,m;this.initFromArray=function(a){this.points=[];for(var b=0;b<a.length;b++)this.points[b]={x:a[b][0],y:a[b][1],z:a[b][2]}};this.getPoint=function(a){e=(this.points.length-1)*a;f=Math.floor(e);g=e-f;c[0]=0===f?f:f-1;c[1]=f;c[2]=f>this.points.length-2?this.points.length-1:f+1;c[3]=f>this.points.length-3?this.points.length-1:f+
+2;l=this.points[c[0]];n=this.points[c[1]];p=this.points[c[2]];m=this.points[c[3]];h=g*g;k=g*h;d.x=b(l.x,n.x,p.x,m.x,g,h,k);d.y=b(l.y,n.y,p.y,m.y,g,h,k);d.z=b(l.z,n.z,p.z,m.z,g,h,k);return d};this.getControlPointsArray=function(){var a,b,c=this.points.length,d=[];for(a=0;a<c;a++)b=this.points[a],d[a]=[b.x,b.y,b.z];return d};this.getLength=function(a){var b,c,d,e=b=b=0,f=new THREE.Vector3,g=new THREE.Vector3,h=[],k=0;h[0]=0;a||(a=100);c=this.points.length*a;f.copy(this.points[0]);for(a=1;a<c;a++)b=
+a/c,d=this.getPoint(b),g.copy(d),k+=g.distanceTo(f),f.copy(d),b*=this.points.length-1,b=Math.floor(b),b!==e&&(h[b]=k,e=b);h[h.length]=k;return{chunks:h,total:k}};this.reparametrizeByArcLength=function(a){var b,c,d,e,f,g,h=[],k=new THREE.Vector3,m=this.getLength();h.push(k.copy(this.points[0]).clone());for(b=1;b<this.points.length;b++){c=m.chunks[b]-m.chunks[b-1];g=Math.ceil(a*c/m.total);e=(b-1)/(this.points.length-1);f=b/(this.points.length-1);for(c=1;c<g-1;c++)d=e+1/g*c*(f-e),d=this.getPoint(d),
+h.push(k.copy(d).clone());h.push(k.copy(this.points[b]).clone())}this.points=h}};THREE.Triangle=function(a,b,c){this.a=void 0!==a?a:new THREE.Vector3;this.b=void 0!==b?b:new THREE.Vector3;this.c=void 0!==c?c:new THREE.Vector3};THREE.Triangle.normal=function(){var a=new THREE.Vector3;return function(b,c,d,e){e=e||new THREE.Vector3;e.subVectors(d,c);a.subVectors(b,c);e.cross(a);b=e.lengthSq();return 0<b?e.multiplyScalar(1/Math.sqrt(b)):e.set(0,0,0)}}();
+THREE.Triangle.barycoordFromPoint=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(d,e,f,g,h){a.subVectors(g,e);b.subVectors(f,e);c.subVectors(d,e);d=a.dot(a);e=a.dot(b);f=a.dot(c);var k=b.dot(b);g=b.dot(c);var l=d*k-e*e;h=h||new THREE.Vector3;if(0===l)return h.set(-2,-1,-1);l=1/l;k=(k*f-e*g)*l;d=(d*g-e*f)*l;return h.set(1-k-d,d,k)}}();
+THREE.Triangle.containsPoint=function(){var a=new THREE.Vector3;return function(b,c,d,e){b=THREE.Triangle.barycoordFromPoint(b,c,d,e,a);return 0<=b.x&&0<=b.y&&1>=b.x+b.y}}();
+THREE.Triangle.prototype={constructor:THREE.Triangle,set:function(a,b,c){this.a.copy(a);this.b.copy(b);this.c.copy(c);return this},setFromPointsAndIndices:function(a,b,c,d){this.a.copy(a[b]);this.b.copy(a[c]);this.c.copy(a[d]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},area:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){a.subVectors(this.c,this.b);b.subVectors(this.a,
+this.b);return.5*a.cross(b).length()}}(),midpoint:function(a){return(a||new THREE.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return THREE.Triangle.normal(this.a,this.b,this.c,a)},plane:function(a){return(a||new THREE.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,b){return THREE.Triangle.barycoordFromPoint(a,this.a,this.b,this.c,b)},containsPoint:function(a){return THREE.Triangle.containsPoint(a,this.a,this.b,this.c)},
+equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}};THREE.Interpolant=function(a,b,c,d){this.parameterPositions=a;this._cachedIndex=0;this.resultBuffer=void 0!==d?d:new b.constructor(c);this.sampleValues=b;this.valueSize=c};
+THREE.Interpolant.prototype={constructor:THREE.Interpolant,evaluate:function(a){var b=this.parameterPositions,c=this._cachedIndex,d=b[c],e=b[c-1];a:{b:{c:{d:if(!(a<d)){for(var f=c+2;;){if(void 0===d){if(a<e)break d;this._cachedIndex=c=b.length;return this.afterEnd_(c-1,a,e)}if(c===f)break;e=d;d=b[++c];if(a<d)break b}d=b.length;break c}if(a>=e)break a;else{f=b[1];a<f&&(c=2,e=f);for(f=c-2;;){if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(c===f)break;d=e;e=b[--c-1];if(a>=e)break b}d=
+c;c=0}}for(;c<d;)e=c+d>>>1,a<b[e]?d=e:c=e+1;d=b[c];e=b[c-1];if(void 0===e)return this._cachedIndex=0,this.beforeStart_(0,a,d);if(void 0===d)return this._cachedIndex=c=b.length,this.afterEnd_(c-1,e,a)}this._cachedIndex=c;this.intervalChanged_(c,e,d)}return this.interpolate_(c,e,a,d)},settings:null,DefaultSettings_:{},getSettings_:function(){return this.settings||this.DefaultSettings_},copySampleValue_:function(a){var b=this.resultBuffer,c=this.sampleValues,d=this.valueSize;a*=d;for(var e=0;e!==d;++e)b[e]=
+c[a+e];return b},interpolate_:function(a,b,c,d){throw Error("call to abstract method");},intervalChanged_:function(a,b,c){}};Object.assign(THREE.Interpolant.prototype,{beforeStart_:THREE.Interpolant.prototype.copySampleValue_,afterEnd_:THREE.Interpolant.prototype.copySampleValue_});THREE.CubicInterpolant=function(a,b,c,d){THREE.Interpolant.call(this,a,b,c,d);this._offsetNext=this._weightNext=this._offsetPrev=this._weightPrev=-0};
+THREE.CubicInterpolant.prototype=Object.assign(Object.create(THREE.Interpolant.prototype),{constructor:THREE.CubicInterpolant,DefaultSettings_:{endingStart:THREE.ZeroCurvatureEnding,endingEnd:THREE.ZeroCurvatureEnding},intervalChanged_:function(a,b,c){var d=this.parameterPositions,e=a-2,f=a+1,g=d[e],h=d[f];if(void 0===g)switch(this.getSettings_().endingStart){case THREE.ZeroSlopeEnding:e=a;g=2*b-c;break;case THREE.WrapAroundEnding:e=d.length-2;g=b+d[e]-d[e+1];break;default:e=a,g=c}if(void 0===h)switch(this.getSettings_().endingEnd){case THREE.ZeroSlopeEnding:f=
+a;h=2*c-b;break;case THREE.WrapAroundEnding:f=1;h=c+d[1]-d[0];break;default:f=a-1,h=b}a=.5*(c-b);d=this.valueSize;this._weightPrev=a/(b-g);this._weightNext=a/(h-c);this._offsetPrev=e*d;this._offsetNext=f*d},interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g,k=this._offsetPrev,l=this._offsetNext,n=this._weightPrev,p=this._weightNext,m=(c-b)/(d-b);c=m*m;d=c*m;b=-n*d+2*n*c-n*m;n=(1+n)*d+(-1.5-2*n)*c+(-.5+n)*m+1;m=(-1-p)*d+(1.5+p)*c+.5*m;p=p*d-p*
+c;for(c=0;c!==g;++c)e[c]=b*f[k+c]+n*f[h+c]+m*f[a+c]+p*f[l+c];return e}});THREE.DiscreteInterpolant=function(a,b,c,d){THREE.Interpolant.call(this,a,b,c,d)};THREE.DiscreteInterpolant.prototype=Object.assign(Object.create(THREE.Interpolant.prototype),{constructor:THREE.DiscreteInterpolant,interpolate_:function(a,b,c,d){return this.copySampleValue_(a-1)}});THREE.LinearInterpolant=function(a,b,c,d){THREE.Interpolant.call(this,a,b,c,d)};
+THREE.LinearInterpolant.prototype=Object.assign(Object.create(THREE.Interpolant.prototype),{constructor:THREE.LinearInterpolant,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;var h=a-g;b=(c-b)/(d-b);c=1-b;for(d=0;d!==g;++d)e[d]=f[h+d]*c+f[a+d]*b;return e}});THREE.QuaternionLinearInterpolant=function(a,b,c,d){THREE.Interpolant.call(this,a,b,c,d)};
+THREE.QuaternionLinearInterpolant.prototype=Object.assign(Object.create(THREE.Interpolant.prototype),{constructor:THREE.QuaternionLinearInterpolant,interpolate_:function(a,b,c,d){var e=this.resultBuffer,f=this.sampleValues,g=this.valueSize;a*=g;b=(c-b)/(d-b);for(c=a+g;a!==c;a+=4)THREE.Quaternion.slerpFlat(e,0,f,a-g,f,a,b);return e}});THREE.Clock=function(a){this.autoStart=void 0!==a?a:!0;this.elapsedTime=this.oldTime=this.startTime=0;this.running=!1};
+THREE.Clock.prototype={constructor:THREE.Clock,start:function(){this.oldTime=this.startTime=performance.now();this.running=!0},stop:function(){this.getElapsedTime();this.running=!1},getElapsedTime:function(){this.getDelta();return this.elapsedTime},getDelta:function(){var a=0;this.autoStart&&!this.running&&this.start();if(this.running){var b=performance.now(),a=.001*(b-this.oldTime);this.oldTime=b;this.elapsedTime+=a}return a}};THREE.EventDispatcher=function(){};
+THREE.EventDispatcher.prototype={constructor:THREE.EventDispatcher,apply:function(a){a.addEventListener=THREE.EventDispatcher.prototype.addEventListener;a.hasEventListener=THREE.EventDispatcher.prototype.hasEventListener;a.removeEventListener=THREE.EventDispatcher.prototype.removeEventListener;a.dispatchEvent=THREE.EventDispatcher.prototype.dispatchEvent},addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var c=this._listeners;void 0===c[a]&&(c[a]=[]);-1===c[a].indexOf(b)&&
+c[a].push(b)},hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var c=this._listeners;return void 0!==c[a]&&-1!==c[a].indexOf(b)?!0:!1},removeEventListener:function(a,b){if(void 0!==this._listeners){var c=this._listeners[a];if(void 0!==c){var d=c.indexOf(b);-1!==d&&c.splice(d,1)}}},dispatchEvent:function(a){if(void 0!==this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;for(var c=[],d=b.length,e=0;e<d;e++)c[e]=b[e];for(e=0;e<d;e++)c[e].call(this,a)}}}};
+THREE.Layers=function(){this.mask=1};THREE.Layers.prototype={constructor:THREE.Layers,set:function(a){this.mask=1<<a},enable:function(a){this.mask|=1<<a},toggle:function(a){this.mask^=1<<a},disable:function(a){this.mask&=~(1<<a)},test:function(a){return 0!==(this.mask&a.mask)}};
+(function(a){function b(a,b){return a.distance-b.distance}function c(a,b,f,g){if(!1!==a.visible&&(a.raycast(b,f),!0===g)){a=a.children;g=0;for(var h=a.length;g<h;g++)c(a[g],b,f,!0)}}a.Raycaster=function(b,c,f,g){this.ray=new a.Ray(b,c);this.near=f||0;this.far=g||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})};
+a.Raycaster.prototype={constructor:a.Raycaster,linePrecision:1,set:function(a,b){this.ray.set(a,b)},setFromCamera:function(b,c){c instanceof a.PerspectiveCamera?(this.ray.origin.setFromMatrixPosition(c.matrixWorld),this.ray.direction.set(b.x,b.y,.5).unproject(c).sub(this.ray.origin).normalize()):c instanceof a.OrthographicCamera?(this.ray.origin.set(b.x,b.y,-1).unproject(c),this.ray.direction.set(0,0,-1).transformDirection(c.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},
+intersectObject:function(a,e){var f=[];c(a,this,f,e);f.sort(b);return f},intersectObjects:function(a,e){var f=[];if(!1===Array.isArray(a))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),f;for(var g=0,h=a.length;g<h;g++)c(a[g],this,f,e);f.sort(b);return f}}})(THREE);
+THREE.Object3D=function(){Object.defineProperty(this,"id",{value:THREE.Object3DIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=THREE.Object3D.DefaultUp.clone();var a=new THREE.Vector3,b=new THREE.Euler,c=new THREE.Quaternion,d=new THREE.Vector3(1,1,1);b.onChange(function(){c.setFromEuler(b,!1)});c.onChange(function(){b.setFromQuaternion(c,void 0,!1)});Object.defineProperties(this,{position:{enumerable:!0,value:a},rotation:{enumerable:!0,
+value:b},quaternion:{enumerable:!0,value:c},scale:{enumerable:!0,value:d},modelViewMatrix:{value:new THREE.Matrix4},normalMatrix:{value:new THREE.Matrix3}});this.rotationAutoUpdate=!0;this.matrix=new THREE.Matrix4;this.matrixWorld=new THREE.Matrix4;this.matrixAutoUpdate=THREE.Object3D.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new THREE.Layers;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData={}};
+THREE.Object3D.DefaultUp=new THREE.Vector3(0,1,0);THREE.Object3D.DefaultMatrixAutoUpdate=!0;
+THREE.Object3D.prototype={constructor:THREE.Object3D,applyMatrix:function(a){this.matrix.multiplyMatrices(a,this.matrix);this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,!0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},setRotationFromQuaternion:function(a){this.quaternion.copy(a)},rotateOnAxis:function(){var a=
+new THREE.Quaternion;return function(b,c){a.setFromAxisAngle(b,c);this.quaternion.multiply(a);return this}}(),rotateX:function(){var a=new THREE.Vector3(1,0,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateY:function(){var a=new THREE.Vector3(0,1,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateZ:function(){var a=new THREE.Vector3(0,0,1);return function(b){return this.rotateOnAxis(a,b)}}(),translateOnAxis:function(){var a=new THREE.Vector3;return function(b,c){a.copy(b).applyQuaternion(this.quaternion);
+this.position.add(a.multiplyScalar(c));return this}}(),translateX:function(){var a=new THREE.Vector3(1,0,0);return function(b){return this.translateOnAxis(a,b)}}(),translateY:function(){var a=new THREE.Vector3(0,1,0);return function(b){return this.translateOnAxis(a,b)}}(),translateZ:function(){var a=new THREE.Vector3(0,0,1);return function(b){return this.translateOnAxis(a,b)}}(),localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var a=new THREE.Matrix4;return function(b){return b.applyMatrix4(a.getInverse(this.matrixWorld))}}(),
+lookAt:function(){var a=new THREE.Matrix4;return function(b){a.lookAt(b,this.position,this.up);this.quaternion.setFromRotationMatrix(a)}}(),add:function(a){if(1<arguments.length){for(var b=0;b<arguments.length;b++)this.add(arguments[b]);return this}if(a===this)return console.error("THREE.Object3D.add: object can't be added as a child of itself.",a),this;a instanceof THREE.Object3D?(null!==a.parent&&a.parent.remove(a),a.parent=this,a.dispatchEvent({type:"added"}),this.children.push(a)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",
+a);return this},remove:function(a){if(1<arguments.length)for(var b=0;b<arguments.length;b++)this.remove(arguments[b]);b=this.children.indexOf(a);-1!==b&&(a.parent=null,a.dispatchEvent({type:"removed"}),this.children.splice(b,1))},getObjectById:function(a){return this.getObjectByProperty("id",a)},getObjectByName:function(a){return this.getObjectByProperty("name",a)},getObjectByProperty:function(a,b){if(this[a]===b)return this;for(var c=0,d=this.children.length;c<d;c++){var e=this.children[c].getObjectByProperty(a,
+b);if(void 0!==e)return e}},getWorldPosition:function(a){a=a||new THREE.Vector3;this.updateMatrixWorld(!0);return a.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c){c=c||new THREE.Quaternion;this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,c,b);return c}}(),getWorldRotation:function(){var a=new THREE.Quaternion;return function(b){b=b||new THREE.Euler;this.getWorldQuaternion(a);return b.setFromQuaternion(a,
+this.rotation.order,!1)}}(),getWorldScale:function(){var a=new THREE.Vector3,b=new THREE.Quaternion;return function(c){c=c||new THREE.Vector3;this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,b,c);return c}}(),getWorldDirection:function(){var a=new THREE.Quaternion;return function(b){b=b||new THREE.Vector3;this.getWorldQuaternion(a);return b.set(0,0,1).applyQuaternion(a)}}(),raycast:function(){},traverse:function(a){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverse(a)},traverseVisible:function(a){if(!1!==
+this.visible){a(this);for(var b=this.children,c=0,d=b.length;c<d;c++)b[c].traverseVisible(a)}},traverseAncestors:function(a){var b=this.parent;null!==b&&(a(b),b.traverseAncestors(a))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale);this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){!0===this.matrixAutoUpdate&&this.updateMatrix();if(!0===this.matrixWorldNeedsUpdate||!0===a)null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,
+this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,c=this.children.length;b<c;b++)this.children[b].updateMatrixWorld(a)},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a,d={};c&&(a={geometries:{},materials:{},textures:{},images:{}},d.metadata={version:4.4,type:"Object",generator:"Object3D.toJSON"});var e={};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);"{}"!==JSON.stringify(this.userData)&&(e.userData=
+this.userData);!0===this.castShadow&&(e.castShadow=!0);!0===this.receiveShadow&&(e.receiveShadow=!0);!1===this.visible&&(e.visible=!1);e.matrix=this.matrix.toArray();void 0!==this.geometry&&(void 0===a.geometries[this.geometry.uuid]&&(a.geometries[this.geometry.uuid]=this.geometry.toJSON(a)),e.geometry=this.geometry.uuid);void 0!==this.material&&(void 0===a.materials[this.material.uuid]&&(a.materials[this.material.uuid]=this.material.toJSON(a)),e.material=this.material.uuid);if(0<this.children.length){e.children=
+[];for(var f=0;f<this.children.length;f++)e.children.push(this.children[f].toJSON(a).object)}if(c){var c=b(a.geometries),f=b(a.materials),g=b(a.textures);a=b(a.images);0<c.length&&(d.geometries=c);0<f.length&&(d.materials=f);0<g.length&&(d.textures=g);0<a.length&&(d.images=a)}d.object=e;return d},clone:function(a){return(new this.constructor).copy(this,a)},copy:function(a,b){void 0===b&&(b=!0);this.name=a.name;this.up.copy(a.up);this.position.copy(a.position);this.quaternion.copy(a.quaternion);this.scale.copy(a.scale);
+this.rotationAutoUpdate=a.rotationAutoUpdate;this.matrix.copy(a.matrix);this.matrixWorld.copy(a.matrixWorld);this.matrixAutoUpdate=a.matrixAutoUpdate;this.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;this.visible=a.visible;this.castShadow=a.castShadow;this.receiveShadow=a.receiveShadow;this.frustumCulled=a.frustumCulled;this.renderOrder=a.renderOrder;this.userData=JSON.parse(JSON.stringify(a.userData));if(!0===b)for(var c=0;c<a.children.length;c++)this.add(a.children[c].clone());return this}};
+THREE.EventDispatcher.prototype.apply(THREE.Object3D.prototype);THREE.Object3DIdCount=0;THREE.Face3=function(a,b,c,d,e,f){this.a=a;this.b=b;this.c=c;this.normal=d instanceof THREE.Vector3?d:new THREE.Vector3;this.vertexNormals=Array.isArray(d)?d:[];this.color=e instanceof THREE.Color?e:new THREE.Color;this.vertexColors=Array.isArray(e)?e:[];this.materialIndex=void 0!==f?f:0};
+THREE.Face3.prototype={constructor:THREE.Face3,clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a=a.a;this.b=a.b;this.c=a.c;this.normal.copy(a.normal);this.color.copy(a.color);this.materialIndex=a.materialIndex;for(var b=0,c=a.vertexNormals.length;b<c;b++)this.vertexNormals[b]=a.vertexNormals[b].clone();b=0;for(c=a.vertexColors.length;b<c;b++)this.vertexColors[b]=a.vertexColors[b].clone();return this}};
+THREE.BufferAttribute=function(a,b){this.uuid=THREE.Math.generateUUID();this.array=a;this.itemSize=b;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0};
+THREE.BufferAttribute.prototype={constructor:THREE.BufferAttribute,get count(){return this.array.length/this.itemSize},set needsUpdate(a){!0===a&&this.version++},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.itemSize=a.itemSize;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.itemSize;c*=b.itemSize;for(var d=0,e=this.itemSize;d<e;d++)this.array[a+d]=b.array[c+d];return this},copyArray:function(a){this.array.set(a);
+return this},copyColorsArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",d),f=new THREE.Color);b[c++]=f.r;b[c++]=f.g;b[c++]=f.b}return this},copyIndicesArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];b[c++]=f.a;b[c++]=f.b;b[c++]=f.c}return this},copyVector2sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",
+d),f=new THREE.Vector2);b[c++]=f.x;b[c++]=f.y}return this},copyVector3sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",d),f=new THREE.Vector3);b[c++]=f.x;b[c++]=f.y;b[c++]=f.z}return this},copyVector4sArray:function(a){for(var b=this.array,c=0,d=0,e=a.length;d<e;d++){var f=a[d];void 0===f&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",d),f=new THREE.Vector4);
+b[c++]=f.x;b[c++]=f.y;b[c++]=f.z;b[c++]=f.w}return this},set:function(a,b){void 0===b&&(b=0);this.array.set(a,b);return this},getX:function(a){return this.array[a*this.itemSize]},setX:function(a,b){this.array[a*this.itemSize]=b;return this},getY:function(a){return this.array[a*this.itemSize+1]},setY:function(a,b){this.array[a*this.itemSize+1]=b;return this},getZ:function(a){return this.array[a*this.itemSize+2]},setZ:function(a,b){this.array[a*this.itemSize+2]=b;return this},getW:function(a){return this.array[a*
+this.itemSize+3]},setW:function(a,b){this.array[a*this.itemSize+3]=b;return this},setXY:function(a,b,c){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;return this},setXYZ:function(a,b,c,d){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;return this},setXYZW:function(a,b,c,d,e){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=c;this.array[a+2]=d;this.array[a+3]=e;return this},clone:function(){return(new this.constructor).copy(this)}};
+THREE.Int8Attribute=function(a,b){return new THREE.BufferAttribute(new Int8Array(a),b)};THREE.Uint8Attribute=function(a,b){return new THREE.BufferAttribute(new Uint8Array(a),b)};THREE.Uint8ClampedAttribute=function(a,b){return new THREE.BufferAttribute(new Uint8ClampedArray(a),b)};THREE.Int16Attribute=function(a,b){return new THREE.BufferAttribute(new Int16Array(a),b)};THREE.Uint16Attribute=function(a,b){return new THREE.BufferAttribute(new Uint16Array(a),b)};
+THREE.Int32Attribute=function(a,b){return new THREE.BufferAttribute(new Int32Array(a),b)};THREE.Uint32Attribute=function(a,b){return new THREE.BufferAttribute(new Uint32Array(a),b)};THREE.Float32Attribute=function(a,b){return new THREE.BufferAttribute(new Float32Array(a),b)};THREE.Float64Attribute=function(a,b){return new THREE.BufferAttribute(new Float64Array(a),b)};
+THREE.DynamicBufferAttribute=function(a,b){console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.");return(new THREE.BufferAttribute(a,b)).setDynamic(!0)};THREE.InstancedBufferAttribute=function(a,b,c){THREE.BufferAttribute.call(this,a,b);this.meshPerAttribute=c||1};THREE.InstancedBufferAttribute.prototype=Object.create(THREE.BufferAttribute.prototype);THREE.InstancedBufferAttribute.prototype.constructor=THREE.InstancedBufferAttribute;
+THREE.InstancedBufferAttribute.prototype.copy=function(a){THREE.BufferAttribute.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this};THREE.InterleavedBuffer=function(a,b){this.uuid=THREE.Math.generateUUID();this.array=a;this.stride=b;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0};
+THREE.InterleavedBuffer.prototype={constructor:THREE.InterleavedBuffer,get length(){return this.array.length},get count(){return this.array.length/this.stride},set needsUpdate(a){!0===a&&this.version++},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.stride=a.stride;this.dynamic=a.dynamic;return this},copyAt:function(a,b,c){a*=this.stride;c*=b.stride;for(var d=0,e=this.stride;d<e;d++)this.array[a+d]=b.array[c+d];return this},set:function(a,
+b){void 0===b&&(b=0);this.array.set(a,b);return this},clone:function(){return(new this.constructor).copy(this)}};THREE.InstancedInterleavedBuffer=function(a,b,c){THREE.InterleavedBuffer.call(this,a,b);this.meshPerAttribute=c||1};THREE.InstancedInterleavedBuffer.prototype=Object.create(THREE.InterleavedBuffer.prototype);THREE.InstancedInterleavedBuffer.prototype.constructor=THREE.InstancedInterleavedBuffer;
+THREE.InstancedInterleavedBuffer.prototype.copy=function(a){THREE.InterleavedBuffer.prototype.copy.call(this,a);this.meshPerAttribute=a.meshPerAttribute;return this};THREE.InterleavedBufferAttribute=function(a,b,c){this.uuid=THREE.Math.generateUUID();this.data=a;this.itemSize=b;this.offset=c};
+THREE.InterleavedBufferAttribute.prototype={constructor:THREE.InterleavedBufferAttribute,get length(){console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count.");return this.array.length},get count(){return this.data.count},setX:function(a,b){this.data.array[a*this.data.stride+this.offset]=b;return this},setY:function(a,b){this.data.array[a*this.data.stride+this.offset+1]=b;return this},setZ:function(a,b){this.data.array[a*this.data.stride+this.offset+2]=b;return this},
+setW:function(a,b){this.data.array[a*this.data.stride+this.offset+3]=b;return this},getX:function(a){return this.data.array[a*this.data.stride+this.offset]},getY:function(a){return this.data.array[a*this.data.stride+this.offset+1]},getZ:function(a){return this.data.array[a*this.data.stride+this.offset+2]},getW:function(a){return this.data.array[a*this.data.stride+this.offset+3]},setXY:function(a,b,c){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;return this},setXYZ:function(a,
+b,c,d){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;return this},setXYZW:function(a,b,c,d,e){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=c;this.data.array[a+2]=d;this.data.array[a+3]=e;return this}};
+THREE.Geometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.uvsNeedUpdate=this.elementsNeedUpdate=
+this.verticesNeedUpdate=!1};
+THREE.Geometry.prototype={constructor:THREE.Geometry,applyMatrix:function(a){for(var b=(new THREE.Matrix3).getNormalMatrix(a),c=0,d=this.vertices.length;c<d;c++)this.vertices[c].applyMatrix4(a);c=0;for(d=this.faces.length;c<d;c++){a=this.faces[c];a.normal.applyMatrix3(b).normalize();for(var e=0,f=a.vertexNormals.length;e<f;e++)a.vertexNormals[e].applyMatrix3(b).normalize()}null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();this.normalsNeedUpdate=
+this.verticesNeedUpdate=!0},rotateX:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationZ(b);this.applyMatrix(a);return this}}(),translate:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);
+a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a;return function(b){void 0===a&&(a=new THREE.Object3D);a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),fromBufferGeometry:function(a){function b(a,b,d){var e=void 0!==g?[n[a].clone(),n[b].clone(),n[d].clone()]:[],f=void 0!==h?[c.colors[a].clone(),c.colors[b].clone(),c.colors[d].clone()]:
+[],e=new THREE.Face3(a,b,d,e,f);c.faces.push(e);void 0!==k&&c.faceVertexUvs[0].push([p[a].clone(),p[b].clone(),p[d].clone()]);void 0!==l&&c.faceVertexUvs[1].push([m[a].clone(),m[b].clone(),m[d].clone()])}var c=this,d=null!==a.index?a.index.array:void 0,e=a.attributes,f=e.position.array,g=void 0!==e.normal?e.normal.array:void 0,h=void 0!==e.color?e.color.array:void 0,k=void 0!==e.uv?e.uv.array:void 0,l=void 0!==e.uv2?e.uv2.array:void 0;void 0!==l&&(this.faceVertexUvs[1]=[]);for(var n=[],p=[],m=[],
+q=e=0;e<f.length;e+=3,q+=2)c.vertices.push(new THREE.Vector3(f[e],f[e+1],f[e+2])),void 0!==g&&n.push(new THREE.Vector3(g[e],g[e+1],g[e+2])),void 0!==h&&c.colors.push(new THREE.Color(h[e],h[e+1],h[e+2])),void 0!==k&&p.push(new THREE.Vector2(k[q],k[q+1])),void 0!==l&&m.push(new THREE.Vector2(l[q],l[q+1]));if(void 0!==d)if(f=a.groups,0<f.length)for(e=0;e<f.length;e++)for(var q=f[e],s=q.start,u=q.count,q=s,s=s+u;q<s;q+=3)b(d[q],d[q+1],d[q+2]);else for(e=0;e<d.length;e+=3)b(d[e],d[e+1],d[e+2]);else for(e=
+0;e<f.length/3;e+=3)b(e,e+1,e+2);this.computeFaceNormals();null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());return this},center:function(){this.computeBoundingBox();var a=this.boundingBox.center().negate();this.translate(a.x,a.y,a.z);return a},normalize:function(){this.computeBoundingSphere();var a=this.boundingSphere.center,b=this.boundingSphere.radius,b=0===b?1:1/b,c=new THREE.Matrix4;c.set(b,0,0,-b*a.x,0,b,0,
+-b*a.y,0,0,b,-b*a.z,0,0,0,1);this.applyMatrix(c);return this},computeFaceNormals:function(){for(var a=new THREE.Vector3,b=new THREE.Vector3,c=0,d=this.faces.length;c<d;c++){var e=this.faces[c],f=this.vertices[e.a],g=this.vertices[e.b];a.subVectors(this.vertices[e.c],g);b.subVectors(f,g);a.cross(b);a.normalize();e.normal.copy(a)}},computeVertexNormals:function(a){void 0===a&&(a=!0);var b,c,d;d=Array(this.vertices.length);b=0;for(c=this.vertices.length;b<c;b++)d[b]=new THREE.Vector3;if(a){var e,f,g,
+h=new THREE.Vector3,k=new THREE.Vector3;a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],e=this.vertices[c.a],f=this.vertices[c.b],g=this.vertices[c.c],h.subVectors(g,f),k.subVectors(e,f),h.cross(k),d[c.a].add(h),d[c.b].add(h),d[c.c].add(h)}else for(a=0,b=this.faces.length;a<b;a++)c=this.faces[a],d[c.a].add(c.normal),d[c.b].add(c.normal),d[c.c].add(c.normal);b=0;for(c=this.vertices.length;b<c;b++)d[b].normalize();a=0;for(b=this.faces.length;a<b;a++)c=this.faces[a],e=c.vertexNormals,3===e.length?
+(e[0].copy(d[c.a]),e[1].copy(d[c.b]),e[2].copy(d[c.c])):(e[0]=d[c.a].clone(),e[1]=d[c.b].clone(),e[2]=d[c.c].clone());0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var a,b,c,d,e;c=0;for(d=this.faces.length;c<d;c++)for(e=this.faces[c],e.__originalFaceNormal?e.__originalFaceNormal.copy(e.normal):e.__originalFaceNormal=e.normal.clone(),e.__originalVertexNormals||(e.__originalVertexNormals=[]),a=0,b=e.vertexNormals.length;a<b;a++)e.__originalVertexNormals[a]?e.__originalVertexNormals[a].copy(e.vertexNormals[a]):
+e.__originalVertexNormals[a]=e.vertexNormals[a].clone();var f=new THREE.Geometry;f.faces=this.faces;a=0;for(b=this.morphTargets.length;a<b;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];e=this.morphNormals[a].faceNormals;var g=this.morphNormals[a].vertexNormals,h,k;c=0;for(d=this.faces.length;c<d;c++)h=new THREE.Vector3,k={a:new THREE.Vector3,b:new THREE.Vector3,c:new THREE.Vector3},e.push(h),g.push(k)}g=this.morphNormals[a];
+f.vertices=this.morphTargets[a].vertices;f.computeFaceNormals();f.computeVertexNormals();c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],h=g.faceNormals[c],k=g.vertexNormals[c],h.copy(e.normal),k.a.copy(e.vertexNormals[0]),k.b.copy(e.vertexNormals[1]),k.c.copy(e.vertexNormals[2])}c=0;for(d=this.faces.length;c<d;c++)e=this.faces[c],e.normal=e.__originalFaceNormal,e.vertexNormals=e.__originalVertexNormals},computeTangents:function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")},
+computeLineDistances:function(){for(var a=0,b=this.vertices,c=0,d=b.length;c<d;c++)0<c&&(a+=b[c].distanceTo(b[c-1])),this.lineDistances[c]=a},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);this.boundingSphere.setFromPoints(this.vertices)},merge:function(a,b,c){if(!1===a instanceof THREE.Geometry)console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",
+a);else{var d,e=this.vertices.length,f=this.vertices,g=a.vertices,h=this.faces,k=a.faces,l=this.faceVertexUvs[0];a=a.faceVertexUvs[0];void 0===c&&(c=0);void 0!==b&&(d=(new THREE.Matrix3).getNormalMatrix(b));for(var n=0,p=g.length;n<p;n++){var m=g[n].clone();void 0!==b&&m.applyMatrix4(b);f.push(m)}n=0;for(p=k.length;n<p;n++){var g=k[n],q,s=g.vertexNormals,u=g.vertexColors,m=new THREE.Face3(g.a+e,g.b+e,g.c+e);m.normal.copy(g.normal);void 0!==d&&m.normal.applyMatrix3(d).normalize();b=0;for(f=s.length;b<
+f;b++)q=s[b].clone(),void 0!==d&&q.applyMatrix3(d).normalize(),m.vertexNormals.push(q);m.color.copy(g.color);b=0;for(f=u.length;b<f;b++)q=u[b],m.vertexColors.push(q.clone());m.materialIndex=g.materialIndex+c;h.push(m)}n=0;for(p=a.length;n<p;n++)if(c=a[n],d=[],void 0!==c){b=0;for(f=c.length;b<f;b++)d.push(c[b].clone());l.push(d)}}},mergeMesh:function(a){!1===a instanceof THREE.Mesh?console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",a):(a.matrixAutoUpdate&&a.updateMatrix(),
+this.merge(a.geometry,a.matrix))},mergeVertices:function(){var a={},b=[],c=[],d,e=Math.pow(10,4),f,g;f=0;for(g=this.vertices.length;f<g;f++)d=this.vertices[f],d=Math.round(d.x*e)+"_"+Math.round(d.y*e)+"_"+Math.round(d.z*e),void 0===a[d]?(a[d]=f,b.push(this.vertices[f]),c[f]=b.length-1):c[f]=c[a[d]];a=[];f=0;for(g=this.faces.length;f<g;f++)for(e=this.faces[f],e.a=c[e.a],e.b=c[e.b],e.c=c[e.c],e=[e.a,e.b,e.c],d=0;3>d;d++)if(e[d]===e[(d+1)%3]){a.push(f);break}for(f=a.length-1;0<=f;f--)for(e=a[f],this.faces.splice(e,
+1),c=0,g=this.faceVertexUvs.length;c<g;c++)this.faceVertexUvs[c].splice(e,1);f=this.vertices.length-b.length;this.vertices=b;return f},sortFacesByMaterialIndex:function(){for(var a=this.faces,b=a.length,c=0;c<b;c++)a[c]._id=c;a.sort(function(a,b){return a.materialIndex-b.materialIndex});var d=this.faceVertexUvs[0],e=this.faceVertexUvs[1],f,g;d&&d.length===b&&(f=[]);e&&e.length===b&&(g=[]);for(c=0;c<b;c++){var h=a[c]._id;f&&f.push(d[h]);g&&g.push(e[h])}f&&(this.faceVertexUvs[0]=f);g&&(this.faceVertexUvs[1]=
+g)},toJSON:function(){function a(a,b,c){return c?a|1<<b:a&~(1<<b)}function b(a){var b=a.x.toString()+a.y.toString()+a.z.toString();if(void 0!==l[b])return l[b];l[b]=k.length/3;k.push(a.x,a.y,a.z);return l[b]}function c(a){var b=a.r.toString()+a.g.toString()+a.b.toString();if(void 0!==p[b])return p[b];p[b]=n.length;n.push(a.getHex());return p[b]}function d(a){var b=a.x.toString()+a.y.toString();if(void 0!==q[b])return q[b];q[b]=m.length/2;m.push(a.x,a.y);return q[b]}var e={metadata:{version:4.4,type:"Geometry",
+generator:"Geometry.toJSON"}};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);if(void 0!==this.parameters){var f=this.parameters,g;for(g in f)void 0!==f[g]&&(e[g]=f[g]);return e}f=[];for(g=0;g<this.vertices.length;g++){var h=this.vertices[g];f.push(h.x,h.y,h.z)}var h=[],k=[],l={},n=[],p={},m=[],q={};for(g=0;g<this.faces.length;g++){var s=this.faces[g],u=void 0!==this.faceVertexUvs[0][g],t=0<s.normal.length(),x=0<s.vertexNormals.length,v=1!==s.color.r||1!==s.color.g||1!==s.color.b,
+C=0<s.vertexColors.length,w=0,w=a(w,0,0),w=a(w,1,!0),w=a(w,2,!1),w=a(w,3,u),w=a(w,4,t),w=a(w,5,x),w=a(w,6,v),w=a(w,7,C);h.push(w);h.push(s.a,s.b,s.c);h.push(s.materialIndex);u&&(u=this.faceVertexUvs[0][g],h.push(d(u[0]),d(u[1]),d(u[2])));t&&h.push(b(s.normal));x&&(t=s.vertexNormals,h.push(b(t[0]),b(t[1]),b(t[2])));v&&h.push(c(s.color));C&&(s=s.vertexColors,h.push(c(s[0]),c(s[1]),c(s[2])))}e.data={};e.data.vertices=f;e.data.normals=k;0<n.length&&(e.data.colors=n);0<m.length&&(e.data.uvs=[m]);e.data.faces=
+h;return e},clone:function(){return(new THREE.Geometry).copy(this)},copy:function(a){this.vertices=[];this.faces=[];this.faceVertexUvs=[[]];for(var b=a.vertices,c=0,d=b.length;c<d;c++)this.vertices.push(b[c].clone());b=a.faces;c=0;for(d=b.length;c<d;c++)this.faces.push(b[c].clone());c=0;for(d=a.faceVertexUvs.length;c<d;c++){b=a.faceVertexUvs[c];void 0===this.faceVertexUvs[c]&&(this.faceVertexUvs[c]=[]);for(var e=0,f=b.length;e<f;e++){for(var g=b[e],h=[],k=0,l=g.length;k<l;k++)h.push(g[k].clone());
+this.faceVertexUvs[c].push(h)}}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.Geometry.prototype);THREE.GeometryIdCount=0;
+THREE.DirectGeometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="DirectGeometry";this.indices=[];this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1};
+THREE.DirectGeometry.prototype={constructor:THREE.DirectGeometry,computeBoundingBox:THREE.Geometry.prototype.computeBoundingBox,computeBoundingSphere:THREE.Geometry.prototype.computeBoundingSphere,computeFaceNormals:function(){console.warn("THREE.DirectGeometry: computeFaceNormals() is not a method of this type of geometry.")},computeVertexNormals:function(){console.warn("THREE.DirectGeometry: computeVertexNormals() is not a method of this type of geometry.")},computeGroups:function(a){var b,c=[],
+d;a=a.faces;for(var e=0;e<a.length;e++){var f=a[e];f.materialIndex!==d&&(d=f.materialIndex,void 0!==b&&(b.count=3*e-b.start,c.push(b)),b={start:3*e,materialIndex:d})}void 0!==b&&(b.count=3*e-b.start,c.push(b));this.groups=c},fromGeometry:function(a){var b=a.faces,c=a.vertices,d=a.faceVertexUvs,e=d[0]&&0<d[0].length,f=d[1]&&0<d[1].length,g=a.morphTargets,h=g.length,k;if(0<h){k=[];for(var l=0;l<h;l++)k[l]=[];this.morphTargets.position=k}var n=a.morphNormals,p=n.length,m;if(0<p){m=[];for(l=0;l<p;l++)m[l]=
+[];this.morphTargets.normal=m}for(var q=a.skinIndices,s=a.skinWeights,u=q.length===c.length,t=s.length===c.length,l=0;l<b.length;l++){var x=b[l];this.vertices.push(c[x.a],c[x.b],c[x.c]);var v=x.vertexNormals;3===v.length?this.normals.push(v[0],v[1],v[2]):(v=x.normal,this.normals.push(v,v,v));v=x.vertexColors;3===v.length?this.colors.push(v[0],v[1],v[2]):(v=x.color,this.colors.push(v,v,v));!0===e&&(v=d[0][l],void 0!==v?this.uvs.push(v[0],v[1],v[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",
+l),this.uvs.push(new THREE.Vector2,new THREE.Vector2,new THREE.Vector2)));!0===f&&(v=d[1][l],void 0!==v?this.uvs2.push(v[0],v[1],v[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",l),this.uvs2.push(new THREE.Vector2,new THREE.Vector2,new THREE.Vector2)));for(v=0;v<h;v++){var C=g[v].vertices;k[v].push(C[x.a],C[x.b],C[x.c])}for(v=0;v<p;v++)C=n[v].vertexNormals[l],m[v].push(C.a,C.b,C.c);u&&this.skinIndices.push(q[x.a],q[x.b],q[x.c]);t&&this.skinWeights.push(s[x.a],s[x.b],
+s[x.c])}this.computeGroups(a);this.verticesNeedUpdate=a.verticesNeedUpdate;this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.DirectGeometry.prototype);
+THREE.BufferGeometry=function(){Object.defineProperty(this,"id",{value:THREE.GeometryIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="BufferGeometry";this.index=null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity}};
+THREE.BufferGeometry.prototype={constructor:THREE.BufferGeometry,getIndex:function(){return this.index},setIndex:function(a){this.index=a},addAttribute:function(a,b,c){if(!1===b instanceof THREE.BufferAttribute&&!1===b instanceof THREE.InterleavedBufferAttribute)console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(a,new THREE.BufferAttribute(b,c));else if("index"===a)console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),
+this.setIndex(b);else return this.attributes[a]=b,this},getAttribute:function(a){return this.attributes[a]},removeAttribute:function(a){delete this.attributes[a];return this},addGroup:function(a,b,c){this.groups.push({start:a,count:b,materialIndex:void 0!==c?c:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(a,b){this.drawRange.start=a;this.drawRange.count=b},applyMatrix:function(a){var b=this.attributes.position;void 0!==b&&(a.applyToVector3Array(b.array),b.needsUpdate=!0);b=this.attributes.normal;
+void 0!==b&&((new THREE.Matrix3).getNormalMatrix(a).applyToVector3Array(b.array),b.needsUpdate=!0);null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere()},rotateX:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationX(b);this.applyMatrix(a);return this}}(),rotateY:function(){var a;return function(b){void 0===a&&(a=new THREE.Matrix4);a.makeRotationY(b);this.applyMatrix(a);return this}}(),rotateZ:function(){var a;return function(b){void 0===
+a&&(a=new THREE.Matrix4);a.makeRotationZ(b);this.applyMatrix(a);return this}}(),translate:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeTranslation(b,c,d);this.applyMatrix(a);return this}}(),scale:function(){var a;return function(b,c,d){void 0===a&&(a=new THREE.Matrix4);a.makeScale(b,c,d);this.applyMatrix(a);return this}}(),lookAt:function(){var a;return function(b){void 0===a&&(a=new THREE.Object3D);a.lookAt(b);a.updateMatrix();this.applyMatrix(a.matrix)}}(),center:function(){this.computeBoundingBox();
+var a=this.boundingBox.center().negate();this.translate(a.x,a.y,a.z);return a},setFromObject:function(a){var b=a.geometry;if(a instanceof THREE.Points||a instanceof THREE.Line){a=new THREE.Float32Attribute(3*b.vertices.length,3);var c=new THREE.Float32Attribute(3*b.colors.length,3);this.addAttribute("position",a.copyVector3sArray(b.vertices));this.addAttribute("color",c.copyColorsArray(b.colors));b.lineDistances&&b.lineDistances.length===b.vertices.length&&(a=new THREE.Float32Attribute(b.lineDistances.length,
+1),this.addAttribute("lineDistance",a.copyArray(b.lineDistances)));null!==b.boundingSphere&&(this.boundingSphere=b.boundingSphere.clone());null!==b.boundingBox&&(this.boundingBox=b.boundingBox.clone())}else a instanceof THREE.Mesh&&b instanceof THREE.Geometry&&this.fromGeometry(b);return this},updateFromObject:function(a){var b=a.geometry;if(a instanceof THREE.Mesh){var c=b.__directGeometry;if(void 0===c)return this.fromGeometry(b);c.verticesNeedUpdate=b.verticesNeedUpdate;c.normalsNeedUpdate=b.normalsNeedUpdate;
+c.colorsNeedUpdate=b.colorsNeedUpdate;c.uvsNeedUpdate=b.uvsNeedUpdate;c.groupsNeedUpdate=b.groupsNeedUpdate;b.verticesNeedUpdate=!1;b.normalsNeedUpdate=!1;b.colorsNeedUpdate=!1;b.uvsNeedUpdate=!1;b.groupsNeedUpdate=!1;b=c}!0===b.verticesNeedUpdate&&(c=this.attributes.position,void 0!==c&&(c.copyVector3sArray(b.vertices),c.needsUpdate=!0),b.verticesNeedUpdate=!1);!0===b.normalsNeedUpdate&&(c=this.attributes.normal,void 0!==c&&(c.copyVector3sArray(b.normals),c.needsUpdate=!0),b.normalsNeedUpdate=!1);
+!0===b.colorsNeedUpdate&&(c=this.attributes.color,void 0!==c&&(c.copyColorsArray(b.colors),c.needsUpdate=!0),b.colorsNeedUpdate=!1);b.uvsNeedUpdate&&(c=this.attributes.uv,void 0!==c&&(c.copyVector2sArray(b.uvs),c.needsUpdate=!0),b.uvsNeedUpdate=!1);b.lineDistancesNeedUpdate&&(c=this.attributes.lineDistance,void 0!==c&&(c.copyArray(b.lineDistances),c.needsUpdate=!0),b.lineDistancesNeedUpdate=!1);b.groupsNeedUpdate&&(b.computeGroups(a.geometry),this.groups=b.groups,b.groupsNeedUpdate=!1);return this},
+fromGeometry:function(a){a.__directGeometry=(new THREE.DirectGeometry).fromGeometry(a);return this.fromDirectGeometry(a.__directGeometry)},fromDirectGeometry:function(a){var b=new Float32Array(3*a.vertices.length);this.addAttribute("position",(new THREE.BufferAttribute(b,3)).copyVector3sArray(a.vertices));0<a.normals.length&&(b=new Float32Array(3*a.normals.length),this.addAttribute("normal",(new THREE.BufferAttribute(b,3)).copyVector3sArray(a.normals)));0<a.colors.length&&(b=new Float32Array(3*a.colors.length),
+this.addAttribute("color",(new THREE.BufferAttribute(b,3)).copyColorsArray(a.colors)));0<a.uvs.length&&(b=new Float32Array(2*a.uvs.length),this.addAttribute("uv",(new THREE.BufferAttribute(b,2)).copyVector2sArray(a.uvs)));0<a.uvs2.length&&(b=new Float32Array(2*a.uvs2.length),this.addAttribute("uv2",(new THREE.BufferAttribute(b,2)).copyVector2sArray(a.uvs2)));0<a.indices.length&&(b=new (65535<a.vertices.length?Uint32Array:Uint16Array)(3*a.indices.length),this.setIndex((new THREE.BufferAttribute(b,
+1)).copyIndicesArray(a.indices)));this.groups=a.groups;for(var c in a.morphTargets){for(var b=[],d=a.morphTargets[c],e=0,f=d.length;e<f;e++){var g=d[e],h=new THREE.Float32Attribute(3*g.length,3);b.push(h.copyVector3sArray(g))}this.morphAttributes[c]=b}0<a.skinIndices.length&&(c=new THREE.Float32Attribute(4*a.skinIndices.length,4),this.addAttribute("skinIndex",c.copyVector4sArray(a.skinIndices)));0<a.skinWeights.length&&(c=new THREE.Float32Attribute(4*a.skinWeights.length,4),this.addAttribute("skinWeight",
+c.copyVector4sArray(a.skinWeights)));null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());return this},computeBoundingBox:function(){new THREE.Vector3;return function(){null===this.boundingBox&&(this.boundingBox=new THREE.Box3);var a=this.attributes.position.array;a&&this.boundingBox.setFromArray(a);if(void 0===a||0===a.length)this.boundingBox.min.set(0,0,0),this.boundingBox.max.set(0,0,0);(isNaN(this.boundingBox.min.x)||
+isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}}(),computeBoundingSphere:function(){var a=new THREE.Box3,b=new THREE.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new THREE.Sphere);var c=this.attributes.position.array;if(c){var d=this.boundingSphere.center;a.setFromArray(c);a.center(d);for(var e=0,f=0,g=
+c.length;f<g;f+=3)b.fromArray(c,f),e=Math.max(e,d.distanceToSquared(b));this.boundingSphere.radius=Math.sqrt(e);isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var a=this.index,b=this.attributes,c=this.groups;if(b.position){var d=b.position.array;if(void 0===b.normal)this.addAttribute("normal",new THREE.BufferAttribute(new Float32Array(d.length),
+3));else for(var e=b.normal.array,f=0,g=e.length;f<g;f++)e[f]=0;var e=b.normal.array,h,k,l,n=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector3,q=new THREE.Vector3,s=new THREE.Vector3;if(a){a=a.array;0===c.length&&this.addGroup(0,a.length);for(var u=0,t=c.length;u<t;++u)for(f=c[u],g=f.start,h=f.count,f=g,g+=h;f<g;f+=3)h=3*a[f+0],k=3*a[f+1],l=3*a[f+2],n.fromArray(d,h),p.fromArray(d,k),m.fromArray(d,l),q.subVectors(m,p),s.subVectors(n,p),q.cross(s),e[h]+=q.x,e[h+1]+=q.y,e[h+2]+=q.z,e[k]+=q.x,
+e[k+1]+=q.y,e[k+2]+=q.z,e[l]+=q.x,e[l+1]+=q.y,e[l+2]+=q.z}else for(f=0,g=d.length;f<g;f+=9)n.fromArray(d,f),p.fromArray(d,f+3),m.fromArray(d,f+6),q.subVectors(m,p),s.subVectors(n,p),q.cross(s),e[f]=q.x,e[f+1]=q.y,e[f+2]=q.z,e[f+3]=q.x,e[f+4]=q.y,e[f+5]=q.z,e[f+6]=q.x,e[f+7]=q.y,e[f+8]=q.z;this.normalizeNormals();b.normal.needsUpdate=!0}},merge:function(a,b){if(!1===a instanceof THREE.BufferGeometry)console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",a);
+else{void 0===b&&(b=0);var c=this.attributes,d;for(d in c)if(void 0!==a.attributes[d])for(var e=c[d].array,f=a.attributes[d],g=f.array,h=0,f=f.itemSize*b;h<g.length;h++,f++)e[f]=g[h];return this}},normalizeNormals:function(){for(var a=this.attributes.normal.array,b,c,d,e=0,f=a.length;e<f;e+=3)b=a[e],c=a[e+1],d=a[e+2],b=1/Math.sqrt(b*b+c*c+d*d),a[e]*=b,a[e+1]*=b,a[e+2]*=b},toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),
+this;var a=new THREE.BufferGeometry,b=this.index.array,c=this.attributes,d;for(d in c){for(var e=c[d],f=e.array,e=e.itemSize,g=new f.constructor(b.length*e),h=0,k=0,l=0,n=b.length;l<n;l++)for(var h=b[l]*e,p=0;p<e;p++)g[k++]=f[h++];a.addAttribute(d,new THREE.BufferAttribute(g,e))}return a},toJSON:function(){var a={metadata:{version:4.4,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};a.uuid=this.uuid;a.type=this.type;""!==this.name&&(a.name=this.name);if(void 0!==this.parameters){var b=this.parameters,
+c;for(c in b)void 0!==b[c]&&(a[c]=b[c]);return a}a.data={attributes:{}};var d=this.index;null!==d&&(b=Array.prototype.slice.call(d.array),a.data.index={type:d.array.constructor.name,array:b});d=this.attributes;for(c in d){var e=d[c],b=Array.prototype.slice.call(e.array);a.data.attributes[c]={itemSize:e.itemSize,type:e.array.constructor.name,array:b}}c=this.groups;0<c.length&&(a.data.groups=JSON.parse(JSON.stringify(c)));c=this.boundingSphere;null!==c&&(a.data.boundingSphere={center:c.center.toArray(),
+radius:c.radius});return a},clone:function(){return(new THREE.BufferGeometry).copy(this)},copy:function(a){var b=a.index;null!==b&&this.setIndex(b.clone());var b=a.attributes,c;for(c in b)this.addAttribute(c,b[c].clone());a=a.groups;c=0;for(b=a.length;c<b;c++){var d=a[c];this.addGroup(d.start,d.count)}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.BufferGeometry.prototype);THREE.BufferGeometry.MaxIndex=65535;
+THREE.InstancedBufferGeometry=function(){THREE.BufferGeometry.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0};THREE.InstancedBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.InstancedBufferGeometry.prototype.constructor=THREE.InstancedBufferGeometry;THREE.InstancedBufferGeometry.prototype.addGroup=function(a,b,c){this.groups.push({start:a,count:b,instances:c})};
+THREE.InstancedBufferGeometry.prototype.copy=function(a){var b=a.index;null!==b&&this.setIndex(b.clone());var b=a.attributes,c;for(c in b)this.addAttribute(c,b[c].clone());a=a.groups;c=0;for(b=a.length;c<b;c++){var d=a[c];this.addGroup(d.start,d.count,d.instances)}return this};THREE.EventDispatcher.prototype.apply(THREE.InstancedBufferGeometry.prototype);THREE.Uniform=function(a,b){this.type=a;this.value=b;this.dynamic=!1};
+THREE.Uniform.prototype={constructor:THREE.Uniform,onUpdate:function(a){this.dynamic=!0;this.onUpdateCallback=a;return this}};THREE.AnimationClip=function(a,b,c){this.name=a||THREE.Math.generateUUID();this.tracks=c;this.duration=void 0!==b?b:-1;0>this.duration&&this.resetDuration();this.trim();this.optimize()};
+THREE.AnimationClip.prototype={constructor:THREE.AnimationClip,resetDuration:function(){for(var a=0,b=0,c=this.tracks.length;b!==c;++b)var d=this.tracks[b],a=Math.max(a,d.times[d.times.length-1]);this.duration=a},trim:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].trim(0,this.duration);return this},optimize:function(){for(var a=0;a<this.tracks.length;a++)this.tracks[a].optimize();return this}};
+Object.assign(THREE.AnimationClip,{parse:function(a){for(var b=[],c=a.tracks,d=1/(a.fps||1),e=0,f=c.length;e!==f;++e)b.push(THREE.KeyframeTrack.parse(c[e]).scale(d));return new THREE.AnimationClip(a.name,a.duration,b)},toJSON:function(a){var b=[],c=a.tracks;a={name:a.name,duration:a.duration,tracks:b};for(var d=0,e=c.length;d!==e;++d)b.push(THREE.KeyframeTrack.toJSON(c[d]));return a},CreateFromMorphTargetSequence:function(a,b,c){for(var d=b.length,e=[],f=0;f<d;f++){var g=[],h=[];g.push((f+d-1)%d,
+f,(f+1)%d);h.push(0,1,0);var k=THREE.AnimationUtils.getKeyframeOrder(g),g=THREE.AnimationUtils.sortedArray(g,1,k),h=THREE.AnimationUtils.sortedArray(h,1,k);0===g[0]&&(g.push(d),h.push(h[0]));e.push((new THREE.NumberKeyframeTrack(".morphTargetInfluences["+b[f].name+"]",g,h)).scale(1/c))}return new THREE.AnimationClip(a,-1,e)},findByName:function(a,b){for(var c=0;c<a.length;c++)if(a[c].name===b)return a[c];return null},CreateClipsFromMorphTargetSequences:function(a,b){for(var c={},d=/^([\w-]*?)([\d]+)$/,
+e=0,f=a.length;e<f;e++){var g=a[e],h=g.name.match(d);if(h&&1<h.length){var k=h[1];(h=c[k])||(c[k]=h=[]);h.push(g)}}d=[];for(k in c)d.push(THREE.AnimationClip.CreateFromMorphTargetSequence(k,c[k],b));return d},parseAnimation:function(a,b,c){if(!a)return console.error("  no animation in JSONLoader data"),null;c=function(a,b,c,d,e){if(0!==c.length){var f=[],g=[];THREE.AnimationUtils.flattenJSON(c,f,g,d);0!==f.length&&e.push(new a(b,f,g))}};var d=[],e=a.name||"default",f=a.length||-1,g=a.fps||30;a=a.hierarchy||
+[];for(var h=0;h<a.length;h++){var k=a[h].keys;if(k&&0!=k.length)if(k[0].morphTargets){for(var f={},l=0;l<k.length;l++)if(k[l].morphTargets)for(var n=0;n<k[l].morphTargets.length;n++)f[k[l].morphTargets[n]]=-1;for(var p in f){for(var m=[],q=[],n=0;n!==k[l].morphTargets.length;++n){var s=k[l];m.push(s.time);q.push(s.morphTarget===p?1:0)}d.push(new THREE.NumberKeyframeTrack(".morphTargetInfluence["+p+"]",m,q))}f=f.length*(g||1)}else l=".bones["+b[h].name+"]",c(THREE.VectorKeyframeTrack,l+".position",
+k,"pos",d),c(THREE.QuaternionKeyframeTrack,l+".quaternion",k,"rot",d),c(THREE.VectorKeyframeTrack,l+".scale",k,"scl",d)}return 0===d.length?null:new THREE.AnimationClip(e,f,d)}});THREE.AnimationMixer=function(a){this._root=a;this._initMemoryManager();this.time=this._accuIndex=0;this.timeScale=1};
+THREE.AnimationMixer.prototype={constructor:THREE.AnimationMixer,clipAction:function(a,b){var c=(b||this._root).uuid,d="string"===typeof a?a:a.name,e=a!==d?a:null,f=this._actionsByClip[d],g;if(void 0!==f){g=f.actionByRoot[c];if(void 0!==g)return g;g=f.knownActions[0];e=g._clip;if(a!==d&&a!==e)throw Error("Different clips with the same name detected!");}if(null===e)return null;f=new THREE.AnimationMixer._Action(this,e,b);this._bindAction(f,g);this._addInactiveAction(f,d,c);return f},existingAction:function(a,
+b){var c=(b||this._root).uuid,d=this._actionsByClip["string"===typeof a?a:a.name];return void 0!==d?d.actionByRoot[c]||null:null},stopAllAction:function(){for(var a=this._actions,b=this._nActiveActions,c=this._bindings,d=this._nActiveBindings,e=this._nActiveBindings=this._nActiveActions=0;e!==b;++e)a[e].reset();for(e=0;e!==d;++e)c[e].useCount=0;return this},update:function(a){a*=this.timeScale;for(var b=this._actions,c=this._nActiveActions,d=this.time+=a,e=Math.sign(a),f=this._accuIndex^=1,g=0;g!==
+c;++g){var h=b[g];h.enabled&&h._update(d,a,e,f)}a=this._bindings;b=this._nActiveBindings;for(g=0;g!==b;++g)a[g].apply(f);return this},getRoot:function(){return this._root},uncacheClip:function(a){var b=this._actions;a=a.name;var c=this._actionsByClip,d=c[a];if(void 0!==d){for(var d=d.knownActions,e=0,f=d.length;e!==f;++e){var g=d[e];this._deactivateAction(g);var h=g._cacheIndex,k=b[b.length-1];g._cacheIndex=null;g._byClipCacheIndex=null;k._cacheIndex=h;b[h]=k;b.pop();this._removeInactiveBindingsForAction(g)}delete c[a]}},
+uncacheRoot:function(a){a=a.uuid;var b=this._actionsByClip,c;for(c in b){var d=b[c].actionByRoot[a];void 0!==d&&(this._deactivateAction(d),this._removeInactiveAction(d))}c=this._bindingsByRootAndName[a];if(void 0!==c)for(var e in c)a=c[e],a.restoreOriginalState(),this._removeInactiveBinding(a)},uncacheAction:function(a,b){var c=this.existingAction(a,b);null!==c&&(this._deactivateAction(c),this._removeInactiveAction(c))}};THREE.EventDispatcher.prototype.apply(THREE.AnimationMixer.prototype);
+THREE.AnimationMixer._Action=function(a,b,c){this._mixer=a;this._clip=b;this._localRoot=c||null;a=b.tracks;b=a.length;c=Array(b);for(var d={endingStart:THREE.ZeroCurvatureEnding,endingEnd:THREE.ZeroCurvatureEnding},e=0;e!==b;++e){var f=a[e].createInterpolant(null);c[e]=f;f.settings=d}this._interpolantSettings=d;this._interpolants=c;this._propertyBindings=Array(b);this._weightInterpolant=this._timeScaleInterpolant=this._byClipCacheIndex=this._cacheIndex=null;this.loop=THREE.LoopRepeat;this._loopCount=
+-1;this._startTime=null;this.time=0;this._effectiveWeight=this.weight=this._effectiveTimeScale=this.timeScale=1;this.repetitions=Infinity;this.paused=!1;this.enabled=!0;this.clampWhenFinished=!1;this.zeroSlopeAtEnd=this.zeroSlopeAtStart=!0};
+THREE.AnimationMixer._Action.prototype={constructor:THREE.AnimationMixer._Action,play:function(){this._mixer._activateAction(this);return this},stop:function(){this._mixer._deactivateAction(this);return this.reset()},reset:function(){this.paused=!1;this.enabled=!0;this.time=0;this._loopCount=-1;this._startTime=null;return this.stopFading().stopWarping()},isRunning:function(){return this.enabled&&!this.paused&&0!==this.timeScale&&null===this._startTime&&this._mixer._isActiveAction(this)},isScheduled:function(){return this._mixer._isActiveAction(this)},
+startAt:function(a){this._startTime=a;return this},setLoop:function(a,b){this.loop=a;this.repetitions=b;return this},setEffectiveWeight:function(a){this.weight=a;this._effectiveWeight=this.enabled?a:0;return this.stopFading()},getEffectiveWeight:function(){return this._effectiveWeight},fadeIn:function(a){return this._scheduleFading(a,0,1)},fadeOut:function(a){return this._scheduleFading(a,1,0)},crossFadeFrom:function(a,b,c){a.fadeOut(b);this.fadeIn(b);if(c){c=this._clip.duration;var d=a._clip.duration,
+e=c/d;a.warp(1,d/c,b);this.warp(e,1,b)}return this},crossFadeTo:function(a,b,c){return a.crossFadeFrom(this,b,c)},stopFading:function(){var a=this._weightInterpolant;null!==a&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(a));return this},setEffectiveTimeScale:function(a){this.timeScale=a;this._effectiveTimeScale=this.paused?0:a;return this.stopWarping()},getEffectiveTimeScale:function(){return this._effectiveTimeScale},setDuration:function(a){this.timeScale=this._clip.duration/
+a;return this.stopWarping()},syncWith:function(a){this.time=a.time;this.timeScale=a.timeScale;return this.stopWarping()},halt:function(a){return this.warp(this._currentTimeScale,0,a)},warp:function(a,b,c){var d=this._mixer,e=d.time,f=this._timeScaleInterpolant,g=this.timeScale;null===f&&(this._timeScaleInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;f=f.sampleValues;d[0]=e;d[1]=e+c;f[0]=a/g;f[1]=b/g;return this},stopWarping:function(){var a=this._timeScaleInterpolant;null!==a&&(this._timeScaleInterpolant=
+null,this._mixer._takeBackControlInterpolant(a));return this},getMixer:function(){return this._mixer},getClip:function(){return this._clip},getRoot:function(){return this._localRoot||this._mixer._root},_update:function(a,b,c,d){var e=this._startTime;if(null!==e){b=(a-e)*c;if(0>b||0===c)return;this._startTime=null;b*=c}b*=this._updateTimeScale(a);c=this._updateTime(b);a=this._updateWeight(a);if(0<a){b=this._interpolants;for(var e=this._propertyBindings,f=0,g=b.length;f!==g;++f)b[f].evaluate(c),e[f].accumulate(d,
+a)}},_updateWeight:function(a){var b=0;if(this.enabled){var b=this.weight,c=this._weightInterpolant;if(null!==c){var d=c.evaluate(a)[0],b=b*d;a>c.parameterPositions[1]&&(this.stopFading(),0===d&&(this.enabled=!1))}}return this._effectiveWeight=b},_updateTimeScale:function(a){var b=0;if(!this.paused){var b=this.timeScale,c=this._timeScaleInterpolant;if(null!==c){var d=c.evaluate(a)[0],b=b*d;a>c.parameterPositions[1]&&(this.stopWarping(),0===b?this.pause=!0:this.timeScale=b)}}return this._effectiveTimeScale=
+b},_updateTime:function(a){var b=this.time+a;if(0===a)return b;var c=this._clip.duration,d=this.loop,e=this._loopCount,f=!1;switch(d){case THREE.LoopOnce:-1===e&&(this.loopCount=0,this._setEndings(!0,!0,!1));if(b>=c)b=c;else if(0>b)b=0;else break;this.clampWhenFinished?this.pause=!0:this.enabled=!1;this._mixer.dispatchEvent({type:"finished",action:this,direction:0>a?-1:1});break;case THREE.LoopPingPong:f=!0;case THREE.LoopRepeat:-1===e&&(0<a?(e=0,this._setEndings(!0,0===this.repetitions,f)):this._setEndings(0===
+this.repetitions,!0,f));if(b>=c||0>b){var g=Math.floor(b/c),b=b-c*g,e=e+Math.abs(g),h=this.repetitions-e;if(0>h){this.clampWhenFinished?this.paused=!0:this.enabled=!1;b=0<a?c:0;this._mixer.dispatchEvent({type:"finished",action:this,direction:0<a?1:-1});break}else 0===h?(a=0>a,this._setEndings(a,!a,f)):this._setEndings(!1,!1,f);this._loopCount=e;this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:g})}if(d===THREE.LoopPingPong&&1===(e&1))return this.time=b,c-b}return this.time=b},_setEndings:function(a,
+b,c){var d=this._interpolantSettings;c?(d.endingStart=THREE.ZeroSlopeEnding,d.endingEnd=THREE.ZeroSlopeEnding):(d.endingStart=a?this.zeroSlopeAtStart?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:THREE.WrapAroundEnding,d.endingEnd=b?this.zeroSlopeAtEnd?THREE.ZeroSlopeEnding:THREE.ZeroCurvatureEnding:THREE.WrapAroundEnding)},_scheduleFading:function(a,b,c){var d=this._mixer,e=d.time,f=this._weightInterpolant;null===f&&(this._weightInterpolant=f=d._lendControlInterpolant());d=f.parameterPositions;
+f=f.sampleValues;d[0]=e;f[0]=b;d[1]=e+a;f[1]=c;return this}};
+Object.assign(THREE.AnimationMixer.prototype,{_bindAction:function(a,b){var c=a._localRoot||this._root,d=a._clip.tracks,e=d.length,f=a._propertyBindings,g=a._interpolants,h=c.uuid,k=this._bindingsByRootAndName,l=k[h];void 0===l&&(l={},k[h]=l);for(k=0;k!==e;++k){var n=d[k],p=n.name,m=l[p];if(void 0===m){m=f[k];if(void 0!==m){null===m._cacheIndex&&(++m.referenceCount,this._addInactiveBinding(m,h,p));continue}m=new THREE.PropertyMixer(THREE.PropertyBinding.create(c,p,b&&b._propertyBindings[k].binding.parsedPath),
+n.ValueTypeName,n.getValueSize());++m.referenceCount;this._addInactiveBinding(m,h,p)}f[k]=m;g[k].resultBuffer=m.buffer}},_activateAction:function(a){if(!this._isActiveAction(a)){if(null===a._cacheIndex){var b=(a._localRoot||this._root).uuid,c=a._clip.name,d=this._actionsByClip[c];this._bindAction(a,d&&d.knownActions[0]);this._addInactiveAction(a,c,b)}b=a._propertyBindings;c=0;for(d=b.length;c!==d;++c){var e=b[c];0===e.useCount++&&(this._lendBinding(e),e.saveOriginalState())}this._lendAction(a)}},
+_deactivateAction:function(a){if(this._isActiveAction(a)){for(var b=a._propertyBindings,c=0,d=b.length;c!==d;++c){var e=b[c];0===--e.useCount&&(e.restoreOriginalState(),this._takeBackBinding(e))}this._takeBackAction(a)}},_initMemoryManager:function(){this._actions=[];this._nActiveActions=0;this._actionsByClip={};this._bindings=[];this._nActiveBindings=0;this._bindingsByRootAndName={};this._controlInterpolants=[];this._nActiveControlInterpolants=0;var a=this;this.stats={actions:{get total(){return a._actions.length},
+get inUse(){return a._nActiveActions}},bindings:{get total(){return a._bindings.length},get inUse(){return a._nActiveBindings}},controlInterpolants:{get total(){return a._controlInterpolants.length},get inUse(){return a._nActiveControlInterpolants}}}},_isActiveAction:function(a){a=a._cacheIndex;return null!==a&&a<this._nActiveActions},_addInactiveAction:function(a,b,c){var d=this._actions,e=this._actionsByClip,f=e[b];void 0===f?(f={knownActions:[a],actionByRoot:{}},a._byClipCacheIndex=0,e[b]=f):(b=
+f.knownActions,a._byClipCacheIndex=b.length,b.push(a));a._cacheIndex=d.length;d.push(a);f.actionByRoot[c]=a},_removeInactiveAction:function(a){var b=this._actions,c=b[b.length-1],d=a._cacheIndex;c._cacheIndex=d;b[d]=c;b.pop();a._cacheIndex=null;var c=a._clip.name,d=this._actionsByClip,e=d[c],f=e.knownActions,g=f[f.length-1],h=a._byClipCacheIndex;g._byClipCacheIndex=h;f[h]=g;f.pop();a._byClipCacheIndex=null;delete e.actionByRoot[(b._localRoot||this._root).uuid];0===f.length&&delete d[c];this._removeInactiveBindingsForAction(a)},
+_removeInactiveBindingsForAction:function(a){a=a._propertyBindings;for(var b=0,c=a.length;b!==c;++b){var d=a[b];0===--d.referenceCount&&this._removeInactiveBinding(d)}},_lendAction:function(a){var b=this._actions,c=a._cacheIndex,d=this._nActiveActions++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackAction:function(a){var b=this._actions,c=a._cacheIndex,d=--this._nActiveActions,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_addInactiveBinding:function(a,b,c){var d=this._bindingsByRootAndName,
+e=d[b],f=this._bindings;void 0===e&&(e={},d[b]=e);e[c]=a;a._cacheIndex=f.length;f.push(a)},_removeInactiveBinding:function(a){var b=this._bindings,c=a.binding,d=c.rootNode.uuid,c=c.path,e=this._bindingsByRootAndName,f=e[d],g=b[b.length-1];a=a._cacheIndex;g._cacheIndex=a;b[a]=g;b.pop();delete f[c];a:{for(var h in f)break a;delete e[d]}},_lendBinding:function(a){var b=this._bindings,c=a._cacheIndex,d=this._nActiveBindings++,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_takeBackBinding:function(a){var b=
+this._bindings,c=a._cacheIndex,d=--this._nActiveBindings,e=b[d];a._cacheIndex=d;b[d]=a;e._cacheIndex=c;b[c]=e},_lendControlInterpolant:function(){var a=this._controlInterpolants,b=this._nActiveControlInterpolants++,c=a[b];void 0===c&&(c=new THREE.LinearInterpolant(new Float32Array(2),new Float32Array(2),1,this._controlInterpolantsResultBuffer),c.__cacheIndex=b,a[b]=c);return c},_takeBackControlInterpolant:function(a){var b=this._controlInterpolants,c=a.__cacheIndex,d=--this._nActiveControlInterpolants,
+e=b[d];a.__cacheIndex=d;b[d]=a;e.__cacheIndex=c;b[c]=e},_controlInterpolantsResultBuffer:new Float32Array(1)});
+THREE.AnimationObjectGroup=function(a){this.uuid=THREE.Math.generateUUID();this._objects=Array.prototype.slice.call(arguments);this.nCachedObjects_=0;var b={};this._indicesByUUID=b;for(var c=0,d=arguments.length;c!==d;++c)b[arguments[c].uuid]=c;this._paths=[];this._parsedPaths=[];this._bindings=[];this._bindingsIndicesByPath={};var e=this;this.stats={objects:{get total(){return e._objects.length},get inUse(){return this.total-e.nCachedObjects_}},get bindingsPerObject(){return e._bindings.length}}};
+THREE.AnimationObjectGroup.prototype={constructor:THREE.AnimationObjectGroup,add:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._paths,g=this._parsedPaths,h=this._bindings,k=h.length,l=0,n=arguments.length;l!==n;++l){var p=arguments[l],m=p.uuid,q=e[m];if(void 0===q){q=c++;e[m]=q;b.push(p);for(var m=0,s=k;m!==s;++m)h[m].push(new THREE.PropertyBinding(p,f[m],g[m]))}else if(q<d){var u=b[q],t=--d,s=b[t];e[s.uuid]=q;b[q]=s;e[m]=t;b[t]=p;m=0;for(s=k;m!==
+s;++m){var x=h[m],v=x[q];x[q]=x[t];void 0===v&&(v=new THREE.PropertyBinding(p,f[m],g[m]));x[t]=v}}else b[q]!==u&&console.error("Different objects with the same UUID detected. Clean the caches or recreate your infrastructure when reloading scenes...")}this.nCachedObjects_=d},remove:function(a){for(var b=this._objects,c=this.nCachedObjects_,d=this._indicesByUUID,e=this._bindings,f=e.length,g=0,h=arguments.length;g!==h;++g){var k=arguments[g],l=k.uuid,n=d[l];if(void 0!==n&&n>=c){var p=c++,m=b[p];d[m.uuid]=
+n;b[n]=m;d[l]=p;b[p]=k;k=0;for(l=f;k!==l;++k){var m=e[k],q=m[n];m[n]=m[p];m[p]=q}}}this.nCachedObjects_=c},uncache:function(a){for(var b=this._objects,c=b.length,d=this.nCachedObjects_,e=this._indicesByUUID,f=this._bindings,g=f.length,h=0,k=arguments.length;h!==k;++h){var l=arguments[h].uuid,n=e[l];if(void 0!==n)if(delete e[l],n<d){var l=--d,p=b[l],m=--c,q=b[m];e[p.uuid]=n;b[n]=p;e[q.uuid]=l;b[l]=q;b.pop();p=0;for(q=g;p!==q;++p){var s=f[p],u=s[m];s[n]=s[l];s[l]=u;s.pop()}}else for(m=--c,q=b[m],e[q.uuid]=
+n,b[n]=q,b.pop(),p=0,q=g;p!==q;++p)s=f[p],s[n]=s[m],s.pop()}this.nCachedObjects_=d},subscribe_:function(a,b){var c=this._bindingsIndicesByPath,d=c[a],e=this._bindings;if(void 0!==d)return e[d];var f=this._paths,g=this._parsedPaths,h=this._objects,k=this.nCachedObjects_,l=Array(h.length),d=e.length;c[a]=d;f.push(a);g.push(b);e.push(l);c=k;for(d=h.length;c!==d;++c)l[c]=new THREE.PropertyBinding(h[c],a,b);return l},unsubscribe_:function(a){var b=this._bindingsIndicesByPath,c=b[a];if(void 0!==c){var d=
+this._paths,e=this._parsedPaths,f=this._bindings,g=f.length-1,h=f[g];b[a[g]]=c;f[c]=h;f.pop();e[c]=e[g];e.pop();d[c]=d[g];d.pop()}}};
+THREE.AnimationUtils={arraySlice:function(a,b,c){return THREE.AnimationUtils.isTypedArray(a)?new a.constructor(a.subarray(b,c)):a.slice(b,c)},convertArray:function(a,b,c){return!a||!c&&a.constructor===b?a:"number"===typeof b.BYTES_PER_ELEMENT?new b(a):Array.prototype.slice.call(a)},isTypedArray:function(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)},getKeyframeOrder:function(a){for(var b=a.length,c=Array(b),d=0;d!==b;++d)c[d]=d;c.sort(function(b,c){return a[b]-a[c]});return c},sortedArray:function(a,
+b,c){for(var d=a.length,e=new a.constructor(d),f=0,g=0;g!==d;++f)for(var h=c[f]*b,k=0;k!==b;++k)e[g++]=a[h+k];return e},flattenJSON:function(a,b,c,d){for(var e=1,f=a[0];void 0!==f&&void 0===f[d];)f=a[e++];if(void 0!==f){var g=f[d];if(void 0!==g)if(Array.isArray(g)){do g=f[d],void 0!==g&&(b.push(f.time),c.push.apply(c,g)),f=a[e++];while(void 0!==f)}else if(void 0!==g.toArray){do g=f[d],void 0!==g&&(b.push(f.time),g.toArray(c,c.length)),f=a[e++];while(void 0!==f)}else{do g=f[d],void 0!==g&&(b.push(f.time),
+c.push(g)),f=a[e++];while(void 0!==f)}}}};THREE.KeyframeTrack=function(a,b,c,d){if(void 0===a)throw Error("track name is undefined");if(void 0===b||0===b.length)throw Error("no keyframes in track named "+a);this.name=a;this.times=THREE.AnimationUtils.convertArray(b,this.TimeBufferType);this.values=THREE.AnimationUtils.convertArray(c,this.ValueBufferType);this.setInterpolation(d||this.DefaultInterpolation);this.validate();this.optimize()};
+THREE.KeyframeTrack.prototype={constructor:THREE.KeyframeTrack,TimeBufferType:Float32Array,ValueBufferType:Float32Array,DefaultInterpolation:THREE.InterpolateLinear,InterpolantFactoryMethodDiscrete:function(a){return new THREE.DiscreteInterpolant(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodLinear:function(a){return new THREE.LinearInterpolant(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:function(a){return new THREE.CubicInterpolant(this.times,
+this.values,this.getValueSize(),a)},setInterpolation:function(a){var b=void 0;switch(a){case THREE.InterpolateDiscrete:b=this.InterpolantFactoryMethodDiscrete;break;case THREE.InterpolateLinear:b=this.InterpolantFactoryMethodLinear;break;case THREE.InterpolateSmooth:b=this.InterpolantFactoryMethodSmooth}if(void 0===b){b="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(void 0===this.createInterpolant)if(a!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);
+else throw Error(b);console.warn(b)}else this.createInterpolant=b},getInterpolation:function(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return THREE.InterpolateDiscrete;case this.InterpolantFactoryMethodLinear:return THREE.InterpolateLinear;case this.InterpolantFactoryMethodSmooth:return THREE.InterpolateSmooth}},getValueSize:function(){return this.values.length/this.times.length},shift:function(a){if(0!==a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]+=a;return this},
+scale:function(a){if(1!==a)for(var b=this.times,c=0,d=b.length;c!==d;++c)b[c]*=a;return this},trim:function(a,b){for(var c=this.times,d=c.length,e=0,f=d-1;e!==d&&c[e]<a;)++e;for(;-1!==f&&c[f]>b;)--f;++f;if(0!==e||f!==d)e>=f&&(f=Math.max(f,1),e=f-1),d=this.getValueSize(),this.times=THREE.AnimationUtils.arraySlice(c,e,f),this.values=THREE.AnimationUtils.arraySlice(this.values,e*d,f*d);return this},validate:function(){var a=!0,b=this.getValueSize();0!==b-Math.floor(b)&&(console.error("invalid value size in track",
+this),a=!1);var c=this.times,b=this.values,d=c.length;0===d&&(console.error("track is empty",this),a=!1);for(var e=null,f=0;f!==d;f++){var g=c[f];if("number"===typeof g&&isNaN(g)){console.error("time is not a valid number",this,f,g);a=!1;break}if(null!==e&&e>g){console.error("out of order keys",this,f,g,e);a=!1;break}e=g}if(void 0!==b&&THREE.AnimationUtils.isTypedArray(b))for(f=0,c=b.length;f!==c;++f)if(d=b[f],isNaN(d)){console.error("value is not a valid number",this,f,d);a=!1;break}return a},optimize:function(){for(var a=
+this.times,b=this.values,c=this.getValueSize(),d=1,e=1,f=a.length-1;e<=f;++e){var g=!1,h=a[e];if(h!==a[e+1]&&(1!==e||h!==h[0]))for(var k=e*c,l=k-c,n=k+c,h=0;h!==c;++h){var p=b[k+h];if(p!==b[l+h]||p!==b[n+h]){g=!0;break}}if(g){if(e!==d)for(a[d]=a[e],g=e*c,k=d*c,h=0;h!==c;++h)b[k+h]=b[g+h];++d}}d!==a.length&&(this.times=THREE.AnimationUtils.arraySlice(a,0,d),this.values=THREE.AnimationUtils.arraySlice(b,0,d*c));return this}};
+Object.assign(THREE.KeyframeTrack,{parse:function(a){if(void 0===a.type)throw Error("track type undefined, can not parse");var b=THREE.KeyframeTrack._getTrackTypeForValueTypeName(a.type);if(void 0===a.times){console.warn("legacy JSON format detected, converting");var c=[],d=[];THREE.AnimationUtils.flattenJSON(a.keys,c,d,"value");a.times=c;a.values=d}return void 0!==b.parse?b.parse(a):new b(a.name,a.times,a.values,a.interpolation)},toJSON:function(a){var b=a.constructor;if(void 0!==b.toJSON)b=b.toJSON(a);
+else{var b={name:a.name,times:THREE.AnimationUtils.convertArray(a.times,Array),values:THREE.AnimationUtils.convertArray(a.values,Array)},c=a.getInterpolation();c!==a.DefaultInterpolation&&(b.interpolation=c)}b.type=a.ValueTypeName;return b},_getTrackTypeForValueTypeName:function(a){switch(a.toLowerCase()){case "scalar":case "double":case "float":case "number":case "integer":return THREE.NumberKeyframeTrack;case "vector":case "vector2":case "vector3":case "vector4":return THREE.VectorKeyframeTrack;
+case "color":return THREE.ColorKeyframeTrack;case "quaternion":return THREE.QuaternionKeyframeTrack;case "bool":case "boolean":return THREE.BooleanKeyframeTrack;case "string":return THREE.StringKeyframeTrack}throw Error("Unsupported typeName: "+a);}});THREE.PropertyBinding=function(a,b,c){this.path=b;this.parsedPath=c||THREE.PropertyBinding.parseTrackName(b);this.node=THREE.PropertyBinding.findNode(a,this.parsedPath.nodeName)||a;this.rootNode=a};
+THREE.PropertyBinding.prototype={constructor:THREE.PropertyBinding,getValue:function(a,b){this.bind();this.getValue(a,b)},setValue:function(a,b){this.bind();this.setValue(a,b)},bind:function(){var a=this.node,b=this.parsedPath,c=b.objectName,d=b.propertyName,e=b.propertyIndex;a||(this.node=a=THREE.PropertyBinding.findNode(this.rootNode,b.nodeName)||this.rootNode);this.getValue=this._getValue_unavailable;this.setValue=this._setValue_unavailable;if(a){if(c){var f=b.objectIndex;switch(c){case "materials":if(!a.material){console.error("  can not bind to material as node does not have a material",
+this);return}if(!a.material.materials){console.error("  can not bind to material.materials as node.material does not have a materials array",this);return}a=a.material.materials;break;case "bones":if(!a.skeleton){console.error("  can not bind to bones as node does not have a skeleton",this);return}a=a.skeleton.bones;for(c=0;c<a.length;c++)if(a[c].name===f){f=c;break}break;default:if(void 0===a[c]){console.error("  can not bind to objectName of node, undefined",this);return}a=a[c]}if(void 0!==f){if(void 0===
+a[f]){console.error("  trying to bind to objectIndex of objectName, but is undefined:",this,a);return}a=a[f]}}if(f=a[d]){b=this.Versioning.None;void 0!==a.needsUpdate?(b=this.Versioning.NeedsUpdate,this.targetObject=a):void 0!==a.matrixWorldNeedsUpdate&&(b=this.Versioning.MatrixWorldNeedsUpdate,this.targetObject=a);c=this.BindingType.Direct;if(void 0!==e){if("morphTargetInfluences"===d){if(!a.geometry){console.error("  can not bind to morphTargetInfluences becasuse node does not have a geometry",
+this);return}if(!a.geometry.morphTargets){console.error("  can not bind to morphTargetInfluences becasuse node does not have a geometry.morphTargets",this);return}for(c=0;c<this.node.geometry.morphTargets.length;c++)if(a.geometry.morphTargets[c].name===e){e=c;break}}c=this.BindingType.ArrayElement;this.resolvedProperty=f;this.propertyIndex=e}else void 0!==f.fromArray&&void 0!==f.toArray?(c=this.BindingType.HasFromToArray,this.resolvedProperty=f):void 0!==f.length?(c=this.BindingType.EntireArray,this.resolvedProperty=
+f):this.propertyName=d;this.getValue=this.GetterByBindingType[c];this.setValue=this.SetterByBindingTypeAndVersioning[c][b]}else console.error("  trying to update property for track: "+b.nodeName+"."+d+" but it wasn't found.",a)}else console.error("  trying to update node for track: "+this.path+" but it wasn't found.")},unbind:function(){this.node=null;this.getValue=this._getValue_unbound;this.setValue=this._setValue_unbound}};
+Object.assign(THREE.PropertyBinding.prototype,{_getValue_unavailable:function(){},_setValue_unavailable:function(){},_getValue_unbound:THREE.PropertyBinding.prototype.getValue,_setValue_unbound:THREE.PropertyBinding.prototype.setValue,BindingType:{Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3},Versioning:{None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2},GetterByBindingType:[function(a,b){a[b]=this.node[this.propertyName]},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)a[b++]=
+c[d]},function(a,b){a[b]=this.resolvedProperty[this.propertyIndex]},function(a,b){this.resolvedProperty.toArray(a,b)}],SetterByBindingTypeAndVersioning:[[function(a,b){this.node[this.propertyName]=a[b]},function(a,b){this.node[this.propertyName]=a[b];this.targetObject.needsUpdate=!0},function(a,b){this.node[this.propertyName]=a[b];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++]},function(a,b){for(var c=this.resolvedProperty,
+d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.needsUpdate=!0},function(a,b){for(var c=this.resolvedProperty,d=0,e=c.length;d!==e;++d)c[d]=a[b++];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty[this.propertyIndex]=a[b]},function(a,b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.needsUpdate=!0},function(a,b){this.resolvedProperty[this.propertyIndex]=a[b];this.targetObject.matrixWorldNeedsUpdate=!0}],[function(a,b){this.resolvedProperty.fromArray(a,
+b)},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.needsUpdate=!0},function(a,b){this.resolvedProperty.fromArray(a,b);this.targetObject.matrixWorldNeedsUpdate=!0}]]});THREE.PropertyBinding.Composite=function(a,b,c){c=c||THREE.PropertyBinding.parseTrackName(b);this._targetGroup=a;this._bindings=a.subscribe_(b,c)};
+THREE.PropertyBinding.Composite.prototype={constructor:THREE.PropertyBinding.Composite,getValue:function(a,b){this.bind();var c=this._bindings[this._targetGroup.nCachedObjects_];void 0!==c&&c.getValue(a,b)},setValue:function(a,b){for(var c=this._bindings,d=this._targetGroup.nCachedObjects_,e=c.length;d!==e;++d)c[d].setValue(a,b)},bind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,c=a.length;b!==c;++b)a[b].bind()},unbind:function(){for(var a=this._bindings,b=this._targetGroup.nCachedObjects_,
+c=a.length;b!==c;++b)a[b].unbind()}};THREE.PropertyBinding.create=function(a,b,c){return a instanceof THREE.AnimationObjectGroup?new THREE.PropertyBinding.Composite(a,b,c):new THREE.PropertyBinding(a,b,c)};
+THREE.PropertyBinding.parseTrackName=function(a){var b=/^(([\w]+\/)*)([\w-\d]+)?(\.([\w]+)(\[([\w\d\[\]\_. ]+)\])?)?(\.([\w.]+)(\[([\w\d\[\]\_. ]+)\])?)$/,c=b.exec(a);if(!c)throw Error("cannot parse trackName at all: "+a);c.index===b.lastIndex&&b.lastIndex++;b={nodeName:c[3],objectName:c[5],objectIndex:c[7],propertyName:c[9],propertyIndex:c[11]};if(null===b.propertyName||0===b.propertyName.length)throw Error("can not parse propertyName from trackName: "+a);return b};
+THREE.PropertyBinding.findNode=function(a,b){if(!b||""===b||"root"===b||"."===b||-1===b||b===a.name||b===a.uuid)return a;if(a.skeleton){var c=function(a){for(var c=0;c<a.bones.length;c++){var d=a.bones[c];if(d.name===b)return d}return null}(a.skeleton);if(c)return c}if(a.children){var d=function(a){for(var c=0;c<a.length;c++){var g=a[c];if(g.name===b||g.uuid===b||(g=d(g.children)))return g}return null};if(c=d(a.children))return c}return null};
+THREE.PropertyMixer=function(a,b,c){this.binding=a;this.valueSize=c;a=Float64Array;switch(b){case "quaternion":b=this._slerp;break;case "string":case "bool":a=Array;b=this._select;break;default:b=this._lerp}this.buffer=new a(4*c);this._mixBufferRegion=b;this.referenceCount=this.useCount=this.cumulativeWeight=0};
+THREE.PropertyMixer.prototype={constructor:THREE.PropertyMixer,accumulate:function(a,b){var c=this.buffer,d=this.valueSize,e=a*d+d,f=this.cumulativeWeight;if(0===f){for(f=0;f!==d;++f)c[e+f]=c[f];f=b}else f+=b,this._mixBufferRegion(c,e,0,b/f,d);this.cumulativeWeight=f},apply:function(a){var b=this.valueSize,c=this.buffer;a=a*b+b;var d=this.cumulativeWeight,e=this.binding;this.cumulativeWeight=0;1>d&&this._mixBufferRegion(c,a,3*b,1-d,b);for(var d=b,f=b+b;d!==f;++d)if(c[d]!==c[d+b]){e.setValue(c,a);
+break}},saveOriginalState:function(){var a=this.buffer,b=this.valueSize,c=3*b;this.binding.getValue(a,c);for(var d=b;d!==c;++d)a[d]=a[c+d%b];this.cumulativeWeight=0},restoreOriginalState:function(){this.binding.setValue(this.buffer,3*this.valueSize)},_select:function(a,b,c,d,e){if(.5<=d)for(d=0;d!==e;++d)a[b+d]=a[c+d]},_slerp:function(a,b,c,d,e){THREE.Quaternion.slerpFlat(a,b,a,b,a,c,d)},_lerp:function(a,b,c,d,e){for(var f=1-d,g=0;g!==e;++g){var h=b+g;a[h]=a[h]*f+a[c+g]*d}}};
+THREE.BooleanKeyframeTrack=function(a,b,c){THREE.KeyframeTrack.call(this,a,b,c)};THREE.BooleanKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.BooleanKeyframeTrack,ValueTypeName:"bool",ValueBufferType:Array,DefaultInterpolation:THREE.IntepolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});THREE.NumberKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
+THREE.NumberKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.NumberKeyframeTrack,ValueTypeName:"number"});THREE.QuaternionKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
+THREE.QuaternionKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.QuaternionKeyframeTrack,ValueTypeName:"quaternion",DefaultInterpolation:THREE.InterpolateLinear,InterpolantFactoryMethodLinear:function(a){return new THREE.QuaternionLinearInterpolant(this.times,this.values,this.getValueSize(),a)},InterpolantFactoryMethodSmooth:void 0});THREE.StringKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
+THREE.StringKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.StringKeyframeTrack,ValueTypeName:"string",ValueBufferType:Array,DefaultInterpolation:THREE.IntepolateDiscrete,InterpolantFactoryMethodLinear:void 0,InterpolantFactoryMethodSmooth:void 0});THREE.VectorKeyframeTrack=function(a,b,c,d){THREE.KeyframeTrack.call(this,a,b,c,d)};
+THREE.VectorKeyframeTrack.prototype=Object.assign(Object.create(THREE.KeyframeTrack.prototype),{constructor:THREE.VectorKeyframeTrack,ValueTypeName:"vector"});
+THREE.Audio=function(a){THREE.Object3D.call(this);this.type="Audio";this.context=a.context;this.source=this.context.createBufferSource();this.source.onended=this.onEnded.bind(this);this.gain=this.context.createGain();this.gain.connect(a.getInput());this.autoplay=!1;this.startTime=0;this.playbackRate=1;this.isPlaying=!1;this.hasPlaybackControl=!0;this.sourceType="empty";this.filter=null};THREE.Audio.prototype=Object.create(THREE.Object3D.prototype);THREE.Audio.prototype.constructor=THREE.Audio;
+THREE.Audio.prototype.getOutput=function(){return this.gain};THREE.Audio.prototype.load=function(a){var b=new THREE.AudioBuffer(this.context);b.load(a);this.setBuffer(b);return this};THREE.Audio.prototype.setNodeSource=function(a){this.hasPlaybackControl=!1;this.sourceType="audioNode";this.source=a;this.connect();return this};THREE.Audio.prototype.setBuffer=function(a){var b=this;a.onReady(function(a){b.source.buffer=a;b.sourceType="buffer";b.autoplay&&b.play()});return this};
+THREE.Audio.prototype.play=function(){if(!0===this.isPlaying)console.warn("THREE.Audio: Audio is already playing.");else if(!1===this.hasPlaybackControl)console.warn("THREE.Audio: this Audio has no playback control.");else{var a=this.context.createBufferSource();a.buffer=this.source.buffer;a.loop=this.source.loop;a.onended=this.source.onended;a.start(0,this.startTime);a.playbackRate.value=this.playbackRate;this.isPlaying=!0;this.source=a;this.connect()}};
+THREE.Audio.prototype.pause=function(){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=this.context.currentTime)};THREE.Audio.prototype.stop=function(){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):(this.source.stop(),this.startTime=0)};THREE.Audio.prototype.connect=function(){null!==this.filter?(this.source.connect(this.filter),this.filter.connect(this.getOutput())):this.source.connect(this.getOutput())};
+THREE.Audio.prototype.disconnect=function(){null!==this.filter?(this.source.disconnect(this.filter),this.filter.disconnect(this.getOutput())):this.source.disconnect(this.getOutput())};THREE.Audio.prototype.getFilter=function(){return this.filter};THREE.Audio.prototype.setFilter=function(a){void 0===a&&(a=null);!0===this.isPlaying?(this.disconnect(),this.filter=a,this.connect()):this.filter=a};
+THREE.Audio.prototype.setPlaybackRate=function(a){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):(this.playbackRate=a,!0===this.isPlaying&&(this.source.playbackRate.value=this.playbackRate))};THREE.Audio.prototype.getPlaybackRate=function(){return this.playbackRate};THREE.Audio.prototype.onEnded=function(){this.isPlaying=!1};
+THREE.Audio.prototype.setLoop=function(a){!1===this.hasPlaybackControl?console.warn("THREE.Audio: this Audio has no playback control."):this.source.loop=a};THREE.Audio.prototype.getLoop=function(){return!1===this.hasPlaybackControl?(console.warn("THREE.Audio: this Audio has no playback control."),!1):this.source.loop};THREE.Audio.prototype.setVolume=function(a){this.gain.gain.value=a};THREE.Audio.prototype.getVolume=function(){return this.gain.gain.value};
+THREE.AudioAnalyser=function(a,b){this.analyser=a.context.createAnalyser();this.analyser.fftSize=void 0!==b?b:2048;this.data=new Uint8Array(this.analyser.frequencyBinCount);a.getOutput().connect(this.analyser)};THREE.AudioAnalyser.prototype={constructor:THREE.AudioAnalyser,getData:function(){this.analyser.getByteFrequencyData(this.data);return this.data}};THREE.AudioBuffer=function(a){this.context=a;this.ready=!1;this.readyCallbacks=[]};
+THREE.AudioBuffer.prototype.load=function(a){var b=this,c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(a){b.context.decodeAudioData(this.response,function(a){b.buffer=a;b.ready=!0;for(a=0;a<b.readyCallbacks.length;a++)b.readyCallbacks[a](b.buffer);b.readyCallbacks=[]})};c.send();return this};THREE.AudioBuffer.prototype.onReady=function(a){this.ready?a(this.buffer):this.readyCallbacks.push(a)};
+THREE.PositionalAudio=function(a){THREE.Audio.call(this,a);this.panner=this.context.createPanner();this.panner.connect(this.gain)};THREE.PositionalAudio.prototype=Object.create(THREE.Audio.prototype);THREE.PositionalAudio.prototype.constructor=THREE.PositionalAudio;THREE.PositionalAudio.prototype.getOutput=function(){return this.panner};THREE.PositionalAudio.prototype.setRefDistance=function(a){this.panner.refDistance=a};THREE.PositionalAudio.prototype.getRefDistance=function(){return this.panner.refDistance};
+THREE.PositionalAudio.prototype.setRolloffFactor=function(a){this.panner.rolloffFactor=a};THREE.PositionalAudio.prototype.getRolloffFactor=function(){return this.panner.rolloffFactor};THREE.PositionalAudio.prototype.setDistanceModel=function(a){this.panner.distanceModel=a};THREE.PositionalAudio.prototype.getDistanceModel=function(){return this.panner.distanceModel};THREE.PositionalAudio.prototype.setMaxDistance=function(a){this.panner.maxDistance=a};
+THREE.PositionalAudio.prototype.getMaxDistance=function(){return this.panner.maxDistance};THREE.PositionalAudio.prototype.updateMatrixWorld=function(){var a=new THREE.Vector3;return function(b){THREE.Object3D.prototype.updateMatrixWorld.call(this,b);a.setFromMatrixPosition(this.matrixWorld);this.panner.setPosition(a.x,a.y,a.z)}}();
+THREE.AudioListener=function(){THREE.Object3D.call(this);this.type="AudioListener";this.context=new (window.AudioContext||window.webkitAudioContext);this.gain=this.context.createGain();this.gain.connect(this.context.destination);this.filter=null};THREE.AudioListener.prototype=Object.create(THREE.Object3D.prototype);THREE.AudioListener.prototype.constructor=THREE.AudioListener;THREE.AudioListener.prototype.getInput=function(){return this.gain};
+THREE.AudioListener.prototype.removeFilter=function(){null!==this.filter&&(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination),this.gain.connect(this.context.destination),this.filter=null)};THREE.AudioListener.prototype.setFilter=function(a){null!==this.filter?(this.gain.disconnect(this.filter),this.filter.disconnect(this.context.destination)):this.gain.disconnect(this.context.destination);this.filter=a;this.gain.connect(this.filter);this.filter.connect(this.context.destination)};
+THREE.AudioListener.prototype.getFilter=function(){return this.filter};THREE.AudioListener.prototype.setMasterVolume=function(a){this.gain.gain.value=a};THREE.AudioListener.prototype.getMasterVolume=function(){return this.gain.gain.value};
+THREE.AudioListener.prototype.updateMatrixWorld=function(){var a=new THREE.Vector3,b=new THREE.Quaternion,c=new THREE.Vector3,d=new THREE.Vector3;return function(e){THREE.Object3D.prototype.updateMatrixWorld.call(this,e);e=this.context.listener;var f=this.up;this.matrixWorld.decompose(a,b,c);d.set(0,0,-1).applyQuaternion(b);e.setPosition(a.x,a.y,a.z);e.setOrientation(d.x,d.y,d.z,f.x,f.y,f.z)}}();
+THREE.Camera=function(){THREE.Object3D.call(this);this.type="Camera";this.matrixWorldInverse=new THREE.Matrix4;this.projectionMatrix=new THREE.Matrix4};THREE.Camera.prototype=Object.create(THREE.Object3D.prototype);THREE.Camera.prototype.constructor=THREE.Camera;THREE.Camera.prototype.getWorldDirection=function(){var a=new THREE.Quaternion;return function(b){b=b||new THREE.Vector3;this.getWorldQuaternion(a);return b.set(0,0,-1).applyQuaternion(a)}}();
+THREE.Camera.prototype.lookAt=function(){var a=new THREE.Matrix4;return function(b){a.lookAt(this.position,b,this.up);this.quaternion.setFromRotationMatrix(a)}}();THREE.Camera.prototype.clone=function(){return(new this.constructor).copy(this)};THREE.Camera.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.matrixWorldInverse.copy(a.matrixWorldInverse);this.projectionMatrix.copy(a.projectionMatrix);return this};
+THREE.CubeCamera=function(a,b,c){THREE.Object3D.call(this);this.type="CubeCamera";var d=new THREE.PerspectiveCamera(90,1,a,b);d.up.set(0,-1,0);d.lookAt(new THREE.Vector3(1,0,0));this.add(d);var e=new THREE.PerspectiveCamera(90,1,a,b);e.up.set(0,-1,0);e.lookAt(new THREE.Vector3(-1,0,0));this.add(e);var f=new THREE.PerspectiveCamera(90,1,a,b);f.up.set(0,0,1);f.lookAt(new THREE.Vector3(0,1,0));this.add(f);var g=new THREE.PerspectiveCamera(90,1,a,b);g.up.set(0,0,-1);g.lookAt(new THREE.Vector3(0,-1,0));
+this.add(g);var h=new THREE.PerspectiveCamera(90,1,a,b);h.up.set(0,-1,0);h.lookAt(new THREE.Vector3(0,0,1));this.add(h);var k=new THREE.PerspectiveCamera(90,1,a,b);k.up.set(0,-1,0);k.lookAt(new THREE.Vector3(0,0,-1));this.add(k);this.renderTarget=new THREE.WebGLRenderTargetCube(c,c,{format:THREE.RGBFormat,magFilter:THREE.LinearFilter,minFilter:THREE.LinearFilter});this.updateCubeMap=function(a,b){null===this.parent&&this.updateMatrixWorld();var c=this.renderTarget,m=c.texture.generateMipmaps;c.texture.generateMipmaps=
+!1;c.activeCubeFace=0;a.render(b,d,c);c.activeCubeFace=1;a.render(b,e,c);c.activeCubeFace=2;a.render(b,f,c);c.activeCubeFace=3;a.render(b,g,c);c.activeCubeFace=4;a.render(b,h,c);c.texture.generateMipmaps=m;c.activeCubeFace=5;a.render(b,k,c);a.setRenderTarget(null)}};THREE.CubeCamera.prototype=Object.create(THREE.Object3D.prototype);THREE.CubeCamera.prototype.constructor=THREE.CubeCamera;
+THREE.OrthographicCamera=function(a,b,c,d,e,f){THREE.Camera.call(this);this.type="OrthographicCamera";this.zoom=1;this.left=a;this.right=b;this.top=c;this.bottom=d;this.near=void 0!==e?e:.1;this.far=void 0!==f?f:2E3;this.updateProjectionMatrix()};THREE.OrthographicCamera.prototype=Object.create(THREE.Camera.prototype);THREE.OrthographicCamera.prototype.constructor=THREE.OrthographicCamera;
+THREE.OrthographicCamera.prototype.updateProjectionMatrix=function(){var a=(this.right-this.left)/(2*this.zoom),b=(this.top-this.bottom)/(2*this.zoom),c=(this.right+this.left)/2,d=(this.top+this.bottom)/2;this.projectionMatrix.makeOrthographic(c-a,c+a,d+b,d-b,this.near,this.far)};THREE.OrthographicCamera.prototype.copy=function(a){THREE.Camera.prototype.copy.call(this,a);this.left=a.left;this.right=a.right;this.top=a.top;this.bottom=a.bottom;this.near=a.near;this.far=a.far;this.zoom=a.zoom;return this};
+THREE.OrthographicCamera.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.zoom=this.zoom;a.object.left=this.left;a.object.right=this.right;a.object.top=this.top;a.object.bottom=this.bottom;a.object.near=this.near;a.object.far=this.far;return a};
+THREE.PerspectiveCamera=function(a,b,c,d){THREE.Camera.call(this);this.type="PerspectiveCamera";this.focalLength=10;this.zoom=1;this.fov=void 0!==a?a:50;this.aspect=void 0!==b?b:1;this.near=void 0!==c?c:.1;this.far=void 0!==d?d:2E3;this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype=Object.create(THREE.Camera.prototype);THREE.PerspectiveCamera.prototype.constructor=THREE.PerspectiveCamera;
+THREE.PerspectiveCamera.prototype.setLens=function(a,b){void 0===b&&(b=24);this.fov=2*THREE.Math.radToDeg(Math.atan(b/(2*a)));this.updateProjectionMatrix()};THREE.PerspectiveCamera.prototype.setViewOffset=function(a,b,c,d,e,f){this.fullWidth=a;this.fullHeight=b;this.x=c;this.y=d;this.width=e;this.height=f;this.updateProjectionMatrix()};
+THREE.PerspectiveCamera.prototype.updateProjectionMatrix=function(){var a=THREE.Math.radToDeg(2*Math.atan(Math.tan(.5*THREE.Math.degToRad(this.fov))/this.zoom));if(this.fullWidth){var b=this.fullWidth/this.fullHeight,a=Math.tan(THREE.Math.degToRad(.5*a))*this.near,c=-a,d=b*c,b=Math.abs(b*a-d),c=Math.abs(a-c);this.projectionMatrix.makeFrustum(d+this.x*b/this.fullWidth,d+(this.x+this.width)*b/this.fullWidth,a-(this.y+this.height)*c/this.fullHeight,a-this.y*c/this.fullHeight,this.near,this.far)}else this.projectionMatrix.makePerspective(a,
+this.aspect,this.near,this.far)};THREE.PerspectiveCamera.prototype.copy=function(a){THREE.Camera.prototype.copy.call(this,a);this.focalLength=a.focalLength;this.zoom=a.zoom;this.fov=a.fov;this.aspect=a.aspect;this.near=a.near;this.far=a.far;return this};
+THREE.PerspectiveCamera.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.focalLength=this.focalLength;a.object.zoom=this.zoom;a.object.fov=this.fov;a.object.aspect=this.aspect;a.object.near=this.near;a.object.far=this.far;return a};
+THREE.StereoCamera=function(){this.type="StereoCamera";this.aspect=1;this.cameraL=new THREE.PerspectiveCamera;this.cameraL.layers.enable(1);this.cameraL.matrixAutoUpdate=!1;this.cameraR=new THREE.PerspectiveCamera;this.cameraR.layers.enable(2);this.cameraR.matrixAutoUpdate=!1};
+THREE.StereoCamera.prototype={constructor:THREE.StereoCamera,update:function(){var a,b,c,d,e,f=new THREE.Matrix4,g=new THREE.Matrix4;return function(h){if(a!==h.focalLength||b!==h.fov||c!==h.aspect*this.aspect||d!==h.near||e!==h.far){a=h.focalLength;b=h.fov;c=h.aspect*this.aspect;d=h.near;e=h.far;var k=h.projectionMatrix.clone(),l=.032*d/a,n=d*Math.tan(THREE.Math.degToRad(.5*b)),p,m;g.elements[12]=-.032;f.elements[12]=.032;p=-n*c+l;m=n*c+l;k.elements[0]=2*d/(m-p);k.elements[8]=(m+p)/(m-p);this.cameraL.projectionMatrix.copy(k);
+p=-n*c-l;m=n*c-l;k.elements[0]=2*d/(m-p);k.elements[8]=(m+p)/(m-p);this.cameraR.projectionMatrix.copy(k)}this.cameraL.matrixWorld.copy(h.matrixWorld).multiply(g);this.cameraR.matrixWorld.copy(h.matrixWorld).multiply(f)}}()};THREE.Light=function(a,b){THREE.Object3D.call(this);this.type="Light";this.color=new THREE.Color(a);this.intensity=void 0!==b?b:1;this.receiveShadow=void 0};THREE.Light.prototype=Object.create(THREE.Object3D.prototype);THREE.Light.prototype.constructor=THREE.Light;
+THREE.Light.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this};
+THREE.Light.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.color=this.color.getHex();a.object.intensity=this.intensity;void 0!==this.groundColor&&(a.object.groundColor=this.groundColor.getHex());void 0!==this.distance&&(a.object.distance=this.distance);void 0!==this.angle&&(a.object.angle=this.angle);void 0!==this.decay&&(a.object.decay=this.decay);void 0!==this.penumbra&&(a.object.penumbra=this.penumbra);return a};
+THREE.LightShadow=function(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=new THREE.Vector2(512,512);this.map=null;this.matrix=new THREE.Matrix4};THREE.LightShadow.prototype={constructor:THREE.LightShadow,copy:function(a){this.camera=a.camera.clone();this.bias=a.bias;this.radius=a.radius;this.mapSize.copy(a.mapSize);return this},clone:function(){return(new this.constructor).copy(this)}};THREE.AmbientLight=function(a,b){THREE.Light.call(this,a,b);this.type="AmbientLight";this.castShadow=void 0};
+THREE.AmbientLight.prototype=Object.create(THREE.Light.prototype);THREE.AmbientLight.prototype.constructor=THREE.AmbientLight;THREE.DirectionalLight=function(a,b){THREE.Light.call(this,a,b);this.type="DirectionalLight";this.position.set(0,1,0);this.updateMatrix();this.target=new THREE.Object3D;this.shadow=new THREE.LightShadow(new THREE.OrthographicCamera(-5,5,5,-5,.5,500))};THREE.DirectionalLight.prototype=Object.create(THREE.Light.prototype);THREE.DirectionalLight.prototype.constructor=THREE.DirectionalLight;
+THREE.DirectionalLight.prototype.copy=function(a){THREE.Light.prototype.copy.call(this,a);this.target=a.target.clone();this.shadow=a.shadow.clone();return this};THREE.HemisphereLight=function(a,b,c){THREE.Light.call(this,a,c);this.type="HemisphereLight";this.castShadow=void 0;this.position.set(0,1,0);this.updateMatrix();this.groundColor=new THREE.Color(b)};THREE.HemisphereLight.prototype=Object.create(THREE.Light.prototype);THREE.HemisphereLight.prototype.constructor=THREE.HemisphereLight;
+THREE.HemisphereLight.prototype.copy=function(a){THREE.Light.prototype.copy.call(this,a);this.groundColor.copy(a.groundColor);return this};THREE.PointLight=function(a,b,c,d){THREE.Light.call(this,a,b);this.type="PointLight";this.distance=void 0!==c?c:0;this.decay=void 0!==d?d:1;this.shadow=new THREE.LightShadow(new THREE.PerspectiveCamera(90,1,.5,500))};THREE.PointLight.prototype=Object.create(THREE.Light.prototype);THREE.PointLight.prototype.constructor=THREE.PointLight;
+THREE.PointLight.prototype.copy=function(a){THREE.Light.prototype.copy.call(this,a);this.distance=a.distance;this.decay=a.decay;this.shadow=a.shadow.clone();return this};
+THREE.SpotLight=function(a,b,c,d,e,f){THREE.Light.call(this,a,b);this.type="SpotLight";this.position.set(0,1,0);this.updateMatrix();this.target=new THREE.Object3D;this.distance=void 0!==c?c:0;this.angle=void 0!==d?d:Math.PI/3;this.penumbra=void 0!==e?e:0;this.decay=void 0!==f?f:1;this.shadow=new THREE.LightShadow(new THREE.PerspectiveCamera(50,1,.5,500))};THREE.SpotLight.prototype=Object.create(THREE.Light.prototype);THREE.SpotLight.prototype.constructor=THREE.SpotLight;
+THREE.SpotLight.prototype.copy=function(a){THREE.Light.prototype.copy.call(this,a);this.distance=a.distance;this.angle=a.angle;this.penumbra=a.penumbra;this.decay=a.decay;this.target=a.target.clone();this.shadow=a.shadow.clone();return this};THREE.Cache={enabled:!1,files:{},add:function(a,b){!1!==this.enabled&&(this.files[a]=b)},get:function(a){if(!1!==this.enabled)return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}};
+THREE.Loader=function(){this.onLoadStart=function(){};this.onLoadProgress=function(){};this.onLoadComplete=function(){}};
+THREE.Loader.prototype={constructor:THREE.Loader,crossOrigin:void 0,extractUrlBase:function(a){a=a.split("/");if(1===a.length)return"./";a.pop();return a.join("/")+"/"},initMaterials:function(a,b,c){for(var d=[],e=0;e<a.length;++e)d[e]=this.createMaterial(a[e],b,c);return d},createMaterial:function(){var a,b,c;return function(d,e,f){function g(a,c,d,g,k){a=e+a;var l=THREE.Loader.Handlers.get(a);null!==l?a=l.load(a):(b.setCrossOrigin(f),a=b.load(a));void 0!==c&&(a.repeat.fromArray(c),1!==c[0]&&(a.wrapS=
+THREE.RepeatWrapping),1!==c[1]&&(a.wrapT=THREE.RepeatWrapping));void 0!==d&&a.offset.fromArray(d);void 0!==g&&("repeat"===g[0]&&(a.wrapS=THREE.RepeatWrapping),"mirror"===g[0]&&(a.wrapS=THREE.MirroredRepeatWrapping),"repeat"===g[1]&&(a.wrapT=THREE.RepeatWrapping),"mirror"===g[1]&&(a.wrapT=THREE.MirroredRepeatWrapping));void 0!==k&&(a.anisotropy=k);c=THREE.Math.generateUUID();h[c]=a;return c}void 0===a&&(a=new THREE.Color);void 0===b&&(b=new THREE.TextureLoader);void 0===c&&(c=new THREE.MaterialLoader);
+var h={},k={uuid:THREE.Math.generateUUID(),type:"MeshLambertMaterial"},l;for(l in d){var n=d[l];switch(l){case "DbgColor":case "DbgIndex":case "opticalDensity":case "illumination":break;case "DbgName":k.name=n;break;case "blending":k.blending=THREE[n];break;case "colorAmbient":case "mapAmbient":console.warn("THREE.Loader.createMaterial:",l,"is no longer supported.");break;case "colorDiffuse":k.color=a.fromArray(n).getHex();break;case "colorSpecular":k.specular=a.fromArray(n).getHex();break;case "colorEmissive":k.emissive=
+a.fromArray(n).getHex();break;case "specularCoef":k.shininess=n;break;case "shading":"basic"===n.toLowerCase()&&(k.type="MeshBasicMaterial");"phong"===n.toLowerCase()&&(k.type="MeshPhongMaterial");break;case "mapDiffuse":k.map=g(n,d.mapDiffuseRepeat,d.mapDiffuseOffset,d.mapDiffuseWrap,d.mapDiffuseAnisotropy);break;case "mapDiffuseRepeat":case "mapDiffuseOffset":case "mapDiffuseWrap":case "mapDiffuseAnisotropy":break;case "mapLight":k.lightMap=g(n,d.mapLightRepeat,d.mapLightOffset,d.mapLightWrap,d.mapLightAnisotropy);
+break;case "mapLightRepeat":case "mapLightOffset":case "mapLightWrap":case "mapLightAnisotropy":break;case "mapAO":k.aoMap=g(n,d.mapAORepeat,d.mapAOOffset,d.mapAOWrap,d.mapAOAnisotropy);break;case "mapAORepeat":case "mapAOOffset":case "mapAOWrap":case "mapAOAnisotropy":break;case "mapBump":k.bumpMap=g(n,d.mapBumpRepeat,d.mapBumpOffset,d.mapBumpWrap,d.mapBumpAnisotropy);break;case "mapBumpScale":k.bumpScale=n;break;case "mapBumpRepeat":case "mapBumpOffset":case "mapBumpWrap":case "mapBumpAnisotropy":break;
+case "mapNormal":k.normalMap=g(n,d.mapNormalRepeat,d.mapNormalOffset,d.mapNormalWrap,d.mapNormalAnisotropy);break;case "mapNormalFactor":k.normalScale=[n,n];break;case "mapNormalRepeat":case "mapNormalOffset":case "mapNormalWrap":case "mapNormalAnisotropy":break;case "mapSpecular":k.specularMap=g(n,d.mapSpecularRepeat,d.mapSpecularOffset,d.mapSpecularWrap,d.mapSpecularAnisotropy);break;case "mapSpecularRepeat":case "mapSpecularOffset":case "mapSpecularWrap":case "mapSpecularAnisotropy":break;case "mapAlpha":k.alphaMap=
+g(n,d.mapAlphaRepeat,d.mapAlphaOffset,d.mapAlphaWrap,d.mapAlphaAnisotropy);break;case "mapAlphaRepeat":case "mapAlphaOffset":case "mapAlphaWrap":case "mapAlphaAnisotropy":break;case "flipSided":k.side=THREE.BackSide;break;case "doubleSided":k.side=THREE.DoubleSide;break;case "transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity");k.opacity=n;break;case "depthTest":case "depthWrite":case "colorWrite":case "opacity":case "reflectivity":case "transparent":case "visible":case "wireframe":k[l]=
+n;break;case "vertexColors":!0===n&&(k.vertexColors=THREE.VertexColors);"face"===n&&(k.vertexColors=THREE.FaceColors);break;default:console.error("THREE.Loader.createMaterial: Unsupported",l,n)}}"MeshBasicMaterial"===k.type&&delete k.emissive;"MeshPhongMaterial"!==k.type&&delete k.specular;1>k.opacity&&(k.transparent=!0);c.setTextures(h);return c.parse(k)}}()};
+THREE.Loader.Handlers={handlers:[],add:function(a,b){this.handlers.push(a,b)},get:function(a){for(var b=this.handlers,c=0,d=b.length;c<d;c+=2){var e=b[c+1];if(b[c].test(a))return e}return null}};THREE.XHRLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};
+THREE.XHRLoader.prototype={constructor:THREE.XHRLoader,load:function(a,b,c,d){void 0!==this.path&&(a=this.path+a);var e=this,f=THREE.Cache.get(a);if(void 0!==f)return b&&setTimeout(function(){b(f)},0),f;var g=new XMLHttpRequest;g.overrideMimeType("text/plain");g.open("GET",a,!0);g.addEventListener("load",function(c){var f=c.target.response;THREE.Cache.add(a,f);200===this.status?(b&&b(f),e.manager.itemEnd(a)):0===this.status?(console.warn("THREE.XHRLoader: HTTP Status 0 received."),b&&b(f),e.manager.itemEnd(a)):
+(d&&d(c),e.manager.itemError(a))},!1);void 0!==c&&g.addEventListener("progress",function(a){c(a)},!1);g.addEventListener("error",function(b){d&&d(b);e.manager.itemError(a)},!1);void 0!==this.responseType&&(g.responseType=this.responseType);void 0!==this.withCredentials&&(g.withCredentials=this.withCredentials);g.send(null);e.manager.itemStart(a);return g},setPath:function(a){this.path=a},setResponseType:function(a){this.responseType=a},setWithCredentials:function(a){this.withCredentials=a}};
+THREE.FontLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};THREE.FontLoader.prototype={constructor:THREE.FontLoader,load:function(a,b,c,d){(new THREE.XHRLoader(this.manager)).load(a,function(a){b(new THREE.Font(JSON.parse(a.substring(65,a.length-2))))},c,d)}};THREE.ImageLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};
+THREE.ImageLoader.prototype={constructor:THREE.ImageLoader,load:function(a,b,c,d){void 0!==this.path&&(a=this.path+a);var e=this,f=THREE.Cache.get(a);if(void 0!==f)return e.manager.itemStart(a),b?setTimeout(function(){b(f);e.manager.itemEnd(a)},0):e.manager.itemEnd(a),f;var g=document.createElement("img");g.addEventListener("load",function(c){THREE.Cache.add(a,this);b&&b(this);e.manager.itemEnd(a)},!1);void 0!==c&&g.addEventListener("progress",function(a){c(a)},!1);g.addEventListener("error",function(b){d&&
+d(b);e.manager.itemError(a)},!1);void 0!==this.crossOrigin&&(g.crossOrigin=this.crossOrigin);e.manager.itemStart(a);g.src=a;return g},setCrossOrigin:function(a){this.crossOrigin=a},setPath:function(a){this.path=a}};THREE.JSONLoader=function(a){"boolean"===typeof a&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),a=void 0);this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this.withCredentials=!1};
+THREE.JSONLoader.prototype={constructor:THREE.JSONLoader,get statusDomElement(){void 0===this._statusDomElement&&(this._statusDomElement=document.createElement("div"));console.warn("THREE.JSONLoader: .statusDomElement has been removed.");return this._statusDomElement},load:function(a,b,c,d){var e=this,f=this.texturePath&&"string"===typeof this.texturePath?this.texturePath:THREE.Loader.prototype.extractUrlBase(a),g=new THREE.XHRLoader(this.manager);g.setWithCredentials(this.withCredentials);g.load(a,
+function(c){c=JSON.parse(c);var d=c.metadata;if(void 0!==d&&(d=d.type,void 0!==d)){if("object"===d.toLowerCase()){console.error("THREE.JSONLoader: "+a+" should be loaded with THREE.ObjectLoader instead.");return}if("scene"===d.toLowerCase()){console.error("THREE.JSONLoader: "+a+" should be loaded with THREE.SceneLoader instead.");return}}c=e.parse(c,f);b(c.geometry,c.materials)},c,d)},setTexturePath:function(a){this.texturePath=a},parse:function(a,b){var c=new THREE.Geometry,d=void 0!==a.scale?1/
+a.scale:1;(function(b){var d,g,h,k,l,n,p,m,q,s,u,t,x,v=a.faces;n=a.vertices;var C=a.normals,w=a.colors,D=0;if(void 0!==a.uvs){for(d=0;d<a.uvs.length;d++)a.uvs[d].length&&D++;for(d=0;d<D;d++)c.faceVertexUvs[d]=[]}k=0;for(l=n.length;k<l;)d=new THREE.Vector3,d.x=n[k++]*b,d.y=n[k++]*b,d.z=n[k++]*b,c.vertices.push(d);k=0;for(l=v.length;k<l;)if(b=v[k++],q=b&1,h=b&2,d=b&8,p=b&16,s=b&32,n=b&64,b&=128,q){q=new THREE.Face3;q.a=v[k];q.b=v[k+1];q.c=v[k+3];u=new THREE.Face3;u.a=v[k+1];u.b=v[k+2];u.c=v[k+3];k+=
+4;h&&(h=v[k++],q.materialIndex=h,u.materialIndex=h);h=c.faces.length;if(d)for(d=0;d<D;d++)for(t=a.uvs[d],c.faceVertexUvs[d][h]=[],c.faceVertexUvs[d][h+1]=[],g=0;4>g;g++)m=v[k++],x=t[2*m],m=t[2*m+1],x=new THREE.Vector2(x,m),2!==g&&c.faceVertexUvs[d][h].push(x),0!==g&&c.faceVertexUvs[d][h+1].push(x);p&&(p=3*v[k++],q.normal.set(C[p++],C[p++],C[p]),u.normal.copy(q.normal));if(s)for(d=0;4>d;d++)p=3*v[k++],s=new THREE.Vector3(C[p++],C[p++],C[p]),2!==d&&q.vertexNormals.push(s),0!==d&&u.vertexNormals.push(s);
+n&&(n=v[k++],n=w[n],q.color.setHex(n),u.color.setHex(n));if(b)for(d=0;4>d;d++)n=v[k++],n=w[n],2!==d&&q.vertexColors.push(new THREE.Color(n)),0!==d&&u.vertexColors.push(new THREE.Color(n));c.faces.push(q);c.faces.push(u)}else{q=new THREE.Face3;q.a=v[k++];q.b=v[k++];q.c=v[k++];h&&(h=v[k++],q.materialIndex=h);h=c.faces.length;if(d)for(d=0;d<D;d++)for(t=a.uvs[d],c.faceVertexUvs[d][h]=[],g=0;3>g;g++)m=v[k++],x=t[2*m],m=t[2*m+1],x=new THREE.Vector2(x,m),c.faceVertexUvs[d][h].push(x);p&&(p=3*v[k++],q.normal.set(C[p++],
+C[p++],C[p]));if(s)for(d=0;3>d;d++)p=3*v[k++],s=new THREE.Vector3(C[p++],C[p++],C[p]),q.vertexNormals.push(s);n&&(n=v[k++],q.color.setHex(w[n]));if(b)for(d=0;3>d;d++)n=v[k++],q.vertexColors.push(new THREE.Color(w[n]));c.faces.push(q)}})(d);(function(){var b=void 0!==a.influencesPerVertex?a.influencesPerVertex:2;if(a.skinWeights)for(var d=0,g=a.skinWeights.length;d<g;d+=b)c.skinWeights.push(new THREE.Vector4(a.skinWeights[d],1<b?a.skinWeights[d+1]:0,2<b?a.skinWeights[d+2]:0,3<b?a.skinWeights[d+3]:
+0));if(a.skinIndices)for(d=0,g=a.skinIndices.length;d<g;d+=b)c.skinIndices.push(new THREE.Vector4(a.skinIndices[d],1<b?a.skinIndices[d+1]:0,2<b?a.skinIndices[d+2]:0,3<b?a.skinIndices[d+3]:0));c.bones=a.bones;c.bones&&0<c.bones.length&&(c.skinWeights.length!==c.skinIndices.length||c.skinIndices.length!==c.vertices.length)&&console.warn("When skinning, number of vertices ("+c.vertices.length+"), skinIndices ("+c.skinIndices.length+"), and skinWeights ("+c.skinWeights.length+") should match.")})();(function(b){if(void 0!==
+a.morphTargets)for(var d=0,g=a.morphTargets.length;d<g;d++){c.morphTargets[d]={};c.morphTargets[d].name=a.morphTargets[d].name;c.morphTargets[d].vertices=[];for(var h=c.morphTargets[d].vertices,k=a.morphTargets[d].vertices,l=0,n=k.length;l<n;l+=3){var p=new THREE.Vector3;p.x=k[l]*b;p.y=k[l+1]*b;p.z=k[l+2]*b;h.push(p)}}if(void 0!==a.morphColors&&0<a.morphColors.length)for(console.warn('THREE.JSONLoader: "morphColors" no longer supported. Using them as face colors.'),b=c.faces,h=a.morphColors[0].colors,
+d=0,g=b.length;d<g;d++)b[d].color.fromArray(h,3*d)})(d);(function(){var b=[],d=[];void 0!==a.animation&&d.push(a.animation);void 0!==a.animations&&(a.animations.length?d=d.concat(a.animations):d.push(a.animations));for(var g=0;g<d.length;g++){var h=THREE.AnimationClip.parseAnimation(d[g],c.bones);h&&b.push(h)}c.morphTargets&&(d=THREE.AnimationClip.CreateClipsFromMorphTargetSequences(c.morphTargets,10),b=b.concat(d));0<b.length&&(c.animations=b)})();c.computeFaceNormals();c.computeBoundingSphere();
+if(void 0===a.materials||0===a.materials.length)return{geometry:c};d=THREE.Loader.prototype.initMaterials(a.materials,b,this.crossOrigin);return{geometry:c,materials:d}}};
+THREE.LoadingManager=function(a,b,c){var d=this,e=!1,f=0,g=0;this.onStart=void 0;this.onLoad=a;this.onProgress=b;this.onError=c;this.itemStart=function(a){g++;if(!1===e&&void 0!==d.onStart)d.onStart(a,f,g);e=!0};this.itemEnd=function(a){f++;if(void 0!==d.onProgress)d.onProgress(a,f,g);if(f===g&&(e=!1,void 0!==d.onLoad))d.onLoad()};this.itemError=function(a){if(void 0!==d.onError)d.onError(a)}};THREE.DefaultLoadingManager=new THREE.LoadingManager;
+THREE.BufferGeometryLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};
+THREE.BufferGeometryLoader.prototype={constructor:THREE.BufferGeometryLoader,load:function(a,b,c,d){var e=this;(new THREE.XHRLoader(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},parse:function(a){var b=new THREE.BufferGeometry,c=a.data.index,d={Int8Array:Int8Array,Uint8Array:Uint8Array,Uint8ClampedArray:Uint8ClampedArray,Int16Array:Int16Array,Uint16Array:Uint16Array,Int32Array:Int32Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array};void 0!==c&&(c=
+new d[c.type](c.array),b.setIndex(new THREE.BufferAttribute(c,1)));var e=a.data.attributes,f;for(f in e){var g=e[f],c=new d[g.type](g.array);b.addAttribute(f,new THREE.BufferAttribute(c,g.itemSize))}d=a.data.groups||a.data.drawcalls||a.data.offsets;if(void 0!==d)for(f=0,c=d.length;f!==c;++f)e=d[f],b.addGroup(e.start,e.count,e.materialIndex);a=a.data.boundingSphere;void 0!==a&&(d=new THREE.Vector3,void 0!==a.center&&d.fromArray(a.center),b.boundingSphere=new THREE.Sphere(d,a.radius));return b}};
+THREE.MaterialLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this.textures={}};
+THREE.MaterialLoader.prototype={constructor:THREE.MaterialLoader,load:function(a,b,c,d){var e=this;(new THREE.XHRLoader(e.manager)).load(a,function(a){b(e.parse(JSON.parse(a)))},c,d)},setTextures:function(a){this.textures=a},getTexture:function(a){var b=this.textures;void 0===b[a]&&console.warn("THREE.MaterialLoader: Undefined texture",a);return b[a]},parse:function(a){var b=new THREE[a.type];void 0!==a.uuid&&(b.uuid=a.uuid);void 0!==a.name&&(b.name=a.name);void 0!==a.color&&b.color.setHex(a.color);
+void 0!==a.roughness&&(b.roughness=a.roughness);void 0!==a.metalness&&(b.metalness=a.metalness);void 0!==a.emissive&&b.emissive.setHex(a.emissive);void 0!==a.specular&&b.specular.setHex(a.specular);void 0!==a.shininess&&(b.shininess=a.shininess);void 0!==a.uniforms&&(b.uniforms=a.uniforms);void 0!==a.vertexShader&&(b.vertexShader=a.vertexShader);void 0!==a.fragmentShader&&(b.fragmentShader=a.fragmentShader);void 0!==a.vertexColors&&(b.vertexColors=a.vertexColors);void 0!==a.shading&&(b.shading=a.shading);
+void 0!==a.blending&&(b.blending=a.blending);void 0!==a.side&&(b.side=a.side);void 0!==a.opacity&&(b.opacity=a.opacity);void 0!==a.transparent&&(b.transparent=a.transparent);void 0!==a.alphaTest&&(b.alphaTest=a.alphaTest);void 0!==a.depthTest&&(b.depthTest=a.depthTest);void 0!==a.depthWrite&&(b.depthWrite=a.depthWrite);void 0!==a.colorWrite&&(b.colorWrite=a.colorWrite);void 0!==a.wireframe&&(b.wireframe=a.wireframe);void 0!==a.wireframeLinewidth&&(b.wireframeLinewidth=a.wireframeLinewidth);void 0!==
+a.size&&(b.size=a.size);void 0!==a.sizeAttenuation&&(b.sizeAttenuation=a.sizeAttenuation);void 0!==a.map&&(b.map=this.getTexture(a.map));void 0!==a.alphaMap&&(b.alphaMap=this.getTexture(a.alphaMap),b.transparent=!0);void 0!==a.bumpMap&&(b.bumpMap=this.getTexture(a.bumpMap));void 0!==a.bumpScale&&(b.bumpScale=a.bumpScale);void 0!==a.normalMap&&(b.normalMap=this.getTexture(a.normalMap));if(void 0!==a.normalScale){var c=a.normalScale;!1===Array.isArray(c)&&(c=[c,c]);b.normalScale=(new THREE.Vector2).fromArray(c)}void 0!==
+a.displacementMap&&(b.displacementMap=this.getTexture(a.displacementMap));void 0!==a.displacementScale&&(b.displacementScale=a.displacementScale);void 0!==a.displacementBias&&(b.displacementBias=a.displacementBias);void 0!==a.roughnessMap&&(b.roughnessMap=this.getTexture(a.roughnessMap));void 0!==a.metalnessMap&&(b.metalnessMap=this.getTexture(a.metalnessMap));void 0!==a.emissiveMap&&(b.emissiveMap=this.getTexture(a.emissiveMap));void 0!==a.emissiveIntensity&&(b.emissiveIntensity=a.emissiveIntensity);
+void 0!==a.specularMap&&(b.specularMap=this.getTexture(a.specularMap));void 0!==a.envMap&&(b.envMap=this.getTexture(a.envMap),b.combine=THREE.MultiplyOperation);a.reflectivity&&(b.reflectivity=a.reflectivity);void 0!==a.lightMap&&(b.lightMap=this.getTexture(a.lightMap));void 0!==a.lightMapIntensity&&(b.lightMapIntensity=a.lightMapIntensity);void 0!==a.aoMap&&(b.aoMap=this.getTexture(a.aoMap));void 0!==a.aoMapIntensity&&(b.aoMapIntensity=a.aoMapIntensity);if(void 0!==a.materials)for(var c=0,d=a.materials.length;c<
+d;c++)b.materials.push(this.parse(a.materials[c]));return b}};THREE.ObjectLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this.texturePath=""};
+THREE.ObjectLoader.prototype={constructor:THREE.ObjectLoader,load:function(a,b,c,d){""===this.texturePath&&(this.texturePath=a.substring(0,a.lastIndexOf("/")+1));var e=this;(new THREE.XHRLoader(e.manager)).load(a,function(a){e.parse(JSON.parse(a),b)},c,d)},setTexturePath:function(a){this.texturePath=a},setCrossOrigin:function(a){this.crossOrigin=a},parse:function(a,b){var c=this.parseGeometries(a.geometries),d=this.parseImages(a.images,function(){void 0!==b&&b(e)}),d=this.parseTextures(a.textures,
+d),d=this.parseMaterials(a.materials,d),e=this.parseObject(a.object,c,d);a.animations&&(e.animations=this.parseAnimations(a.animations));void 0!==a.images&&0!==a.images.length||void 0===b||b(e);return e},parseGeometries:function(a){var b={};if(void 0!==a)for(var c=new THREE.JSONLoader,d=new THREE.BufferGeometryLoader,e=0,f=a.length;e<f;e++){var g,h=a[e];switch(h.type){case "PlaneGeometry":case "PlaneBufferGeometry":g=new THREE[h.type](h.width,h.height,h.widthSegments,h.heightSegments);break;case "BoxGeometry":case "CubeGeometry":g=
+new THREE.BoxGeometry(h.width,h.height,h.depth,h.widthSegments,h.heightSegments,h.depthSegments);break;case "CircleBufferGeometry":g=new THREE.CircleBufferGeometry(h.radius,h.segments,h.thetaStart,h.thetaLength);break;case "CircleGeometry":g=new THREE.CircleGeometry(h.radius,h.segments,h.thetaStart,h.thetaLength);break;case "CylinderGeometry":g=new THREE.CylinderGeometry(h.radiusTop,h.radiusBottom,h.height,h.radialSegments,h.heightSegments,h.openEnded,h.thetaStart,h.thetaLength);break;case "SphereGeometry":g=
+new THREE.SphereGeometry(h.radius,h.widthSegments,h.heightSegments,h.phiStart,h.phiLength,h.thetaStart,h.thetaLength);break;case "SphereBufferGeometry":g=new THREE.SphereBufferGeometry(h.radius,h.widthSegments,h.heightSegments,h.phiStart,h.phiLength,h.thetaStart,h.thetaLength);break;case "DodecahedronGeometry":g=new THREE.DodecahedronGeometry(h.radius,h.detail);break;case "IcosahedronGeometry":g=new THREE.IcosahedronGeometry(h.radius,h.detail);break;case "OctahedronGeometry":g=new THREE.OctahedronGeometry(h.radius,
+h.detail);break;case "TetrahedronGeometry":g=new THREE.TetrahedronGeometry(h.radius,h.detail);break;case "RingGeometry":g=new THREE.RingGeometry(h.innerRadius,h.outerRadius,h.thetaSegments,h.phiSegments,h.thetaStart,h.thetaLength);break;case "TorusGeometry":g=new THREE.TorusGeometry(h.radius,h.tube,h.radialSegments,h.tubularSegments,h.arc);break;case "TorusKnotGeometry":g=new THREE.TorusKnotGeometry(h.radius,h.tube,h.radialSegments,h.tubularSegments,h.p,h.q,h.heightScale);break;case "LatheGeometry":g=
+new THREE.LatheGeometry(h.points,h.segments,h.phiStart,h.phiLength);break;case "BufferGeometry":g=d.parse(h);break;case "Geometry":g=c.parse(h.data,this.texturePath).geometry;break;default:console.warn('THREE.ObjectLoader: Unsupported geometry type "'+h.type+'"');continue}g.uuid=h.uuid;void 0!==h.name&&(g.name=h.name);b[h.uuid]=g}return b},parseMaterials:function(a,b){var c={};if(void 0!==a){var d=new THREE.MaterialLoader;d.setTextures(b);for(var e=0,f=a.length;e<f;e++){var g=d.parse(a[e]);c[g.uuid]=
+g}}return c},parseAnimations:function(a){for(var b=[],c=0;c<a.length;c++){var d=THREE.AnimationClip.parse(a[c]);b.push(d)}return b},parseImages:function(a,b){function c(a){d.manager.itemStart(a);return g.load(a,function(){d.manager.itemEnd(a)})}var d=this,e={};if(void 0!==a&&0<a.length){var f=new THREE.LoadingManager(b),g=new THREE.ImageLoader(f);g.setCrossOrigin(this.crossOrigin);for(var f=0,h=a.length;f<h;f++){var k=a[f],l=/^(\/\/)|([a-z]+:(\/\/)?)/i.test(k.url)?k.url:d.texturePath+k.url;e[k.uuid]=
+c(l)}}return e},parseTextures:function(a,b){function c(a){if("number"===typeof a)return a;console.warn("THREE.ObjectLoader.parseTexture: Constant should be in numeric form.",a);return THREE[a]}var d={};if(void 0!==a)for(var e=0,f=a.length;e<f;e++){var g=a[e];void 0===g.image&&console.warn('THREE.ObjectLoader: No "image" specified for',g.uuid);void 0===b[g.image]&&console.warn("THREE.ObjectLoader: Undefined image",g.image);var h=new THREE.Texture(b[g.image]);h.needsUpdate=!0;h.uuid=g.uuid;void 0!==
+g.name&&(h.name=g.name);void 0!==g.mapping&&(h.mapping=c(g.mapping));void 0!==g.offset&&(h.offset=new THREE.Vector2(g.offset[0],g.offset[1]));void 0!==g.repeat&&(h.repeat=new THREE.Vector2(g.repeat[0],g.repeat[1]));void 0!==g.minFilter&&(h.minFilter=c(g.minFilter));void 0!==g.magFilter&&(h.magFilter=c(g.magFilter));void 0!==g.anisotropy&&(h.anisotropy=g.anisotropy);Array.isArray(g.wrap)&&(h.wrapS=c(g.wrap[0]),h.wrapT=c(g.wrap[1]));d[g.uuid]=h}return d},parseObject:function(){var a=new THREE.Matrix4;
+return function(b,c,d){function e(a){void 0===c[a]&&console.warn("THREE.ObjectLoader: Undefined geometry",a);return c[a]}function f(a){if(void 0!==a)return void 0===d[a]&&console.warn("THREE.ObjectLoader: Undefined material",a),d[a]}var g;switch(b.type){case "Scene":g=new THREE.Scene;break;case "PerspectiveCamera":g=new THREE.PerspectiveCamera(b.fov,b.aspect,b.near,b.far);break;case "OrthographicCamera":g=new THREE.OrthographicCamera(b.left,b.right,b.top,b.bottom,b.near,b.far);break;case "AmbientLight":g=
+new THREE.AmbientLight(b.color,b.intensity);break;case "DirectionalLight":g=new THREE.DirectionalLight(b.color,b.intensity);break;case "PointLight":g=new THREE.PointLight(b.color,b.intensity,b.distance,b.decay);break;case "SpotLight":g=new THREE.SpotLight(b.color,b.intensity,b.distance,b.angle,b.penumbra,b.decay);break;case "HemisphereLight":g=new THREE.HemisphereLight(b.color,b.groundColor,b.intensity);break;case "Mesh":g=e(b.geometry);var h=f(b.material);g=g.bones&&0<g.bones.length?new THREE.SkinnedMesh(g,
+h):new THREE.Mesh(g,h);break;case "LOD":g=new THREE.LOD;break;case "Line":g=new THREE.Line(e(b.geometry),f(b.material),b.mode);break;case "PointCloud":case "Points":g=new THREE.Points(e(b.geometry),f(b.material));break;case "Sprite":g=new THREE.Sprite(f(b.material));break;case "Group":g=new THREE.Group;break;default:g=new THREE.Object3D}g.uuid=b.uuid;void 0!==b.name&&(g.name=b.name);void 0!==b.matrix?(a.fromArray(b.matrix),a.decompose(g.position,g.quaternion,g.scale)):(void 0!==b.position&&g.position.fromArray(b.position),
+void 0!==b.rotation&&g.rotation.fromArray(b.rotation),void 0!==b.scale&&g.scale.fromArray(b.scale));void 0!==b.castShadow&&(g.castShadow=b.castShadow);void 0!==b.receiveShadow&&(g.receiveShadow=b.receiveShadow);void 0!==b.visible&&(g.visible=b.visible);void 0!==b.userData&&(g.userData=b.userData);if(void 0!==b.children)for(var k in b.children)g.add(this.parseObject(b.children[k],c,d));if("LOD"===b.type)for(b=b.levels,h=0;h<b.length;h++){var l=b[h];k=g.getObjectByProperty("uuid",l.object);void 0!==
+k&&g.addLevel(k,l.distance)}return g}}()};THREE.TextureLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};THREE.TextureLoader.prototype={constructor:THREE.TextureLoader,load:function(a,b,c,d){var e=new THREE.Texture,f=new THREE.ImageLoader(this.manager);f.setCrossOrigin(this.crossOrigin);f.setPath(this.path);f.load(a,function(a){e.image=a;e.needsUpdate=!0;void 0!==b&&b(e)},c,d);return e},setCrossOrigin:function(a){this.crossOrigin=a},setPath:function(a){this.path=a}};
+THREE.CubeTextureLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager};
+THREE.CubeTextureLoader.prototype={constructor:THREE.CubeTextureLoader,load:function(a,b,c,d){function e(c){g.load(a[c],function(a){f.images[c]=a;h++;6===h&&(f.needsUpdate=!0,b&&b(f))},void 0,d)}var f=new THREE.CubeTexture([]),g=new THREE.ImageLoader(this.manager);g.setCrossOrigin(this.crossOrigin);g.setPath(this.path);var h=0;for(c=0;c<a.length;++c)e(c);return f},setCrossOrigin:function(a){this.crossOrigin=a},setPath:function(a){this.path=a}};
+THREE.DataTextureLoader=THREE.BinaryTextureLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this._parser=null};
+THREE.BinaryTextureLoader.prototype={constructor:THREE.BinaryTextureLoader,load:function(a,b,c,d){var e=this,f=new THREE.DataTexture,g=new THREE.XHRLoader(this.manager);g.setResponseType("arraybuffer");g.load(a,function(a){if(a=e._parser(a))void 0!==a.image?f.image=a.image:void 0!==a.data&&(f.image.width=a.width,f.image.height=a.height,f.image.data=a.data),f.wrapS=void 0!==a.wrapS?a.wrapS:THREE.ClampToEdgeWrapping,f.wrapT=void 0!==a.wrapT?a.wrapT:THREE.ClampToEdgeWrapping,f.magFilter=void 0!==a.magFilter?
+a.magFilter:THREE.LinearFilter,f.minFilter=void 0!==a.minFilter?a.minFilter:THREE.LinearMipMapLinearFilter,f.anisotropy=void 0!==a.anisotropy?a.anisotropy:1,void 0!==a.format&&(f.format=a.format),void 0!==a.type&&(f.type=a.type),void 0!==a.mipmaps&&(f.mipmaps=a.mipmaps),1===a.mipmapCount&&(f.minFilter=THREE.LinearFilter),f.needsUpdate=!0,b&&b(f,a)},c,d);return f}};THREE.CompressedTextureLoader=function(a){this.manager=void 0!==a?a:THREE.DefaultLoadingManager;this._parser=null};
+THREE.CompressedTextureLoader.prototype={constructor:THREE.CompressedTextureLoader,load:function(a,b,c,d){function e(e){k.load(a[e],function(a){a=f._parser(a,!0);g[e]={width:a.width,height:a.height,format:a.format,mipmaps:a.mipmaps};l+=1;6===l&&(1===a.mipmapCount&&(h.minFilter=THREE.LinearFilter),h.format=a.format,h.needsUpdate=!0,b&&b(h))},c,d)}var f=this,g=[],h=new THREE.CompressedTexture;h.image=g;var k=new THREE.XHRLoader(this.manager);k.setPath(this.path);k.setResponseType("arraybuffer");if(Array.isArray(a))for(var l=
+0,n=0,p=a.length;n<p;++n)e(n);else k.load(a,function(a){a=f._parser(a,!0);if(a.isCubemap)for(var c=a.mipmaps.length/a.mipmapCount,d=0;d<c;d++){g[d]={mipmaps:[]};for(var e=0;e<a.mipmapCount;e++)g[d].mipmaps.push(a.mipmaps[d*a.mipmapCount+e]),g[d].format=a.format,g[d].width=a.width,g[d].height=a.height}else h.image.width=a.width,h.image.height=a.height,h.mipmaps=a.mipmaps;1===a.mipmapCount&&(h.minFilter=THREE.LinearFilter);h.format=a.format;h.needsUpdate=!0;b&&b(h)},c,d);return h},setPath:function(a){this.path=
+a}};
+THREE.Material=function(){Object.defineProperty(this,"id",{value:THREE.MaterialIdCount++});this.uuid=THREE.Math.generateUUID();this.name="";this.type="Material";this.side=THREE.FrontSide;this.opacity=1;this.transparent=!1;this.blending=THREE.NormalBlending;this.blendSrc=THREE.SrcAlphaFactor;this.blendDst=THREE.OneMinusSrcAlphaFactor;this.blendEquation=THREE.AddEquation;this.blendEquationAlpha=this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=THREE.LessEqualDepth;this.colorWrite=this.depthWrite=this.depthTest=
+!0;this.precision=null;this.polygonOffset=!1;this.overdraw=this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this._needsUpdate=this.visible=!0};
+THREE.Material.prototype={constructor:THREE.Material,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update();this._needsUpdate=a},setValues:function(a){if(void 0!==a)for(var b in a){var c=a[b];if(void 0===c)console.warn("THREE.Material: '"+b+"' parameter is undefined.");else{var d=this[b];void 0===d?console.warn("THREE."+this.type+": '"+b+"' is not a property of this material."):d instanceof THREE.Color?d.set(c):d instanceof THREE.Vector3&&c instanceof THREE.Vector3?d.copy(c):
+this[b]="overdraw"===b?Number(c):c}}},toJSON:function(a){function b(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var c=void 0===a;c&&(a={textures:{},images:{}});var d={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};d.uuid=this.uuid;d.type=this.type;""!==this.name&&(d.name=this.name);this.color instanceof THREE.Color&&(d.color=this.color.getHex());.5!==this.roughness&&(d.roughness=this.roughness);.5!==this.metalness&&(d.metalness=this.metalness);this.emissive instanceof
+THREE.Color&&(d.emissive=this.emissive.getHex());this.specular instanceof THREE.Color&&(d.specular=this.specular.getHex());void 0!==this.shininess&&(d.shininess=this.shininess);this.map instanceof THREE.Texture&&(d.map=this.map.toJSON(a).uuid);this.alphaMap instanceof THREE.Texture&&(d.alphaMap=this.alphaMap.toJSON(a).uuid);this.lightMap instanceof THREE.Texture&&(d.lightMap=this.lightMap.toJSON(a).uuid);this.bumpMap instanceof THREE.Texture&&(d.bumpMap=this.bumpMap.toJSON(a).uuid,d.bumpScale=this.bumpScale);
+this.normalMap instanceof THREE.Texture&&(d.normalMap=this.normalMap.toJSON(a).uuid,d.normalScale=this.normalScale.toArray());this.displacementMap instanceof THREE.Texture&&(d.displacementMap=this.displacementMap.toJSON(a).uuid,d.displacementScale=this.displacementScale,d.displacementBias=this.displacementBias);this.roughnessMap instanceof THREE.Texture&&(d.roughnessMap=this.roughnessMap.toJSON(a).uuid);this.metalnessMap instanceof THREE.Texture&&(d.metalnessMap=this.metalnessMap.toJSON(a).uuid);
+this.emissiveMap instanceof THREE.Texture&&(d.emissiveMap=this.emissiveMap.toJSON(a).uuid);this.specularMap instanceof THREE.Texture&&(d.specularMap=this.specularMap.toJSON(a).uuid);this.envMap instanceof THREE.Texture&&(d.envMap=this.envMap.toJSON(a).uuid,d.reflectivity=this.reflectivity);void 0!==this.size&&(d.size=this.size);void 0!==this.sizeAttenuation&&(d.sizeAttenuation=this.sizeAttenuation);void 0!==this.vertexColors&&this.vertexColors!==THREE.NoColors&&(d.vertexColors=this.vertexColors);
+void 0!==this.shading&&this.shading!==THREE.SmoothShading&&(d.shading=this.shading);void 0!==this.blending&&this.blending!==THREE.NormalBlending&&(d.blending=this.blending);void 0!==this.side&&this.side!==THREE.FrontSide&&(d.side=this.side);1>this.opacity&&(d.opacity=this.opacity);!0===this.transparent&&(d.transparent=this.transparent);0<this.alphaTest&&(d.alphaTest=this.alphaTest);!0===this.wireframe&&(d.wireframe=this.wireframe);1<this.wireframeLinewidth&&(d.wireframeLinewidth=this.wireframeLinewidth);
+c&&(c=b(a.textures),a=b(a.images),0<c.length&&(d.textures=c),0<a.length&&(d.images=a));return d},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.name=a.name;this.side=a.side;this.opacity=a.opacity;this.transparent=a.transparent;this.blending=a.blending;this.blendSrc=a.blendSrc;this.blendDst=a.blendDst;this.blendEquation=a.blendEquation;this.blendSrcAlpha=a.blendSrcAlpha;this.blendDstAlpha=a.blendDstAlpha;this.blendEquationAlpha=a.blendEquationAlpha;this.depthFunc=a.depthFunc;
+this.depthTest=a.depthTest;this.depthWrite=a.depthWrite;this.colorWrite=a.colorWrite;this.precision=a.precision;this.polygonOffset=a.polygonOffset;this.polygonOffsetFactor=a.polygonOffsetFactor;this.polygonOffsetUnits=a.polygonOffsetUnits;this.alphaTest=a.alphaTest;this.overdraw=a.overdraw;this.visible=a.visible;return this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.Material.prototype);
+THREE.MaterialIdCount=0;THREE.LineBasicMaterial=function(a){THREE.Material.call(this);this.type="LineBasicMaterial";this.color=new THREE.Color(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.vertexColors=THREE.NoColors;this.fog=!0;this.setValues(a)};THREE.LineBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.LineBasicMaterial.prototype.constructor=THREE.LineBasicMaterial;
+THREE.LineBasicMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.linecap=a.linecap;this.linejoin=a.linejoin;this.vertexColors=a.vertexColors;this.fog=a.fog;return this};THREE.LineDashedMaterial=function(a){THREE.Material.call(this);this.type="LineDashedMaterial";this.color=new THREE.Color(16777215);this.scale=this.linewidth=1;this.dashSize=3;this.gapSize=1;this.vertexColors=THREE.NoColors;this.fog=!0;this.setValues(a)};
+THREE.LineDashedMaterial.prototype=Object.create(THREE.Material.prototype);THREE.LineDashedMaterial.prototype.constructor=THREE.LineDashedMaterial;THREE.LineDashedMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;this.vertexColors=a.vertexColors;this.fog=a.fog;return this};
+THREE.MeshBasicMaterial=function(a){THREE.Material.call(this);this.type="MeshBasicMaterial";this.color=new THREE.Color(16777215);this.aoMap=this.map=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=.98;this.fog=!0;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphTargets=this.skinning=
+!1;this.setValues(a)};THREE.MeshBasicMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshBasicMaterial.prototype.constructor=THREE.MeshBasicMaterial;
+THREE.MeshBasicMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;
+this.wireframeLinejoin=a.wireframeLinejoin;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;return this};
+THREE.MeshLambertMaterial=function(a){THREE.Material.call(this);this.type="MeshLambertMaterial";this.color=new THREE.Color(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new THREE.Color(0);this.emissiveIntensity=1;this.envMap=this.alphaMap=this.specularMap=this.emissiveMap=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=.98;this.fog=!0;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=
+this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.MeshLambertMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshLambertMaterial.prototype.constructor=THREE.MeshLambertMaterial;
+THREE.MeshLambertMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=
+a.refractionRatio;this.fog=a.fog;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};
+THREE.MeshPhongMaterial=function(a){THREE.Material.call(this);this.type="MeshPhongMaterial";this.color=new THREE.Color(16777215);this.specular=new THREE.Color(1118481);this.shininess=30;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new THREE.Color(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new THREE.Vector2(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=
+0;this.envMap=this.alphaMap=this.specularMap=null;this.combine=THREE.MultiplyOperation;this.reflectivity=1;this.refractionRatio=.98;this.fog=!0;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.MeshPhongMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshPhongMaterial.prototype.constructor=THREE.MeshPhongMaterial;
+THREE.MeshPhongMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalScale.copy(a.normalScale);
+this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.vertexColors=
+a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};
+THREE.MeshStandardMaterial=function(a){THREE.Material.call(this);this.type="MeshStandardMaterial";this.color=new THREE.Color(16777215);this.metalness=this.roughness=.5;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new THREE.Color(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new THREE.Vector2(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=
+0;this.envMap=this.alphaMap=this.metalnessMap=this.roughnessMap=null;this.envMapIntensity=1;this.refractionRatio=.98;this.fog=!0;this.shading=THREE.SmoothShading;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};THREE.MeshStandardMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshStandardMaterial.prototype.constructor=THREE.MeshStandardMaterial;
+THREE.MeshStandardMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.roughness=a.roughness;this.metalness=a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalScale.copy(a.normalScale);
+this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=a.roughnessMap;this.metalnessMap=a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;
+this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};THREE.MeshDepthMaterial=function(a){THREE.Material.call(this);this.type="MeshDepthMaterial";this.wireframe=this.morphTargets=!1;this.wireframeLinewidth=1;this.setValues(a)};THREE.MeshDepthMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshDepthMaterial.prototype.constructor=THREE.MeshDepthMaterial;
+THREE.MeshDepthMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};THREE.MeshNormalMaterial=function(a){THREE.Material.call(this,a);this.type="MeshNormalMaterial";this.wireframe=!1;this.wireframeLinewidth=1;this.morphTargets=!1;this.setValues(a)};THREE.MeshNormalMaterial.prototype=Object.create(THREE.Material.prototype);THREE.MeshNormalMaterial.prototype.constructor=THREE.MeshNormalMaterial;
+THREE.MeshNormalMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};THREE.MultiMaterial=function(a){this.uuid=THREE.Math.generateUUID();this.type="MultiMaterial";this.materials=a instanceof Array?a:[];this.visible=!0};
+THREE.MultiMaterial.prototype={constructor:THREE.MultiMaterial,toJSON:function(a){for(var b={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},c=this.materials,d=0,e=c.length;d<e;d++){var f=c[d].toJSON(a);delete f.metadata;b.materials.push(f)}b.visible=this.visible;return b},clone:function(){for(var a=new this.constructor,b=0;b<this.materials.length;b++)a.materials.push(this.materials[b].clone());a.visible=this.visible;return a}};
+THREE.PointsMaterial=function(a){THREE.Material.call(this);this.type="PointsMaterial";this.color=new THREE.Color(16777215);this.map=null;this.size=1;this.sizeAttenuation=!0;this.vertexColors=THREE.NoColors;this.fog=!0;this.setValues(a)};THREE.PointsMaterial.prototype=Object.create(THREE.Material.prototype);THREE.PointsMaterial.prototype.constructor=THREE.PointsMaterial;
+THREE.PointsMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;this.vertexColors=a.vertexColors;this.fog=a.fog;return this};
+THREE.ShaderMaterial=function(a){THREE.Material.call(this);this.type="ShaderMaterial";this.defines={};this.uniforms={};this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";this.shading=THREE.SmoothShading;this.linewidth=1;this.wireframe=!1;this.wireframeLinewidth=1;this.lights=this.fog=!1;this.vertexColors=THREE.NoColors;this.morphNormals=this.morphTargets=
+this.skinning=!1;this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]};this.index0AttributeName=void 0;void 0!==a&&(void 0!==a.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(a))};THREE.ShaderMaterial.prototype=Object.create(THREE.Material.prototype);THREE.ShaderMaterial.prototype.constructor=THREE.ShaderMaterial;
+THREE.ShaderMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.fragmentShader=a.fragmentShader;this.vertexShader=a.vertexShader;this.uniforms=THREE.UniformsUtils.clone(a.uniforms);this.defines=a.defines;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.fog=a.fog;this.lights=a.lights;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;this.extensions=
+a.extensions;return this};THREE.ShaderMaterial.prototype.toJSON=function(a){a=THREE.Material.prototype.toJSON.call(this,a);a.uniforms=this.uniforms;a.vertexShader=this.vertexShader;a.fragmentShader=this.fragmentShader;return a};THREE.RawShaderMaterial=function(a){THREE.ShaderMaterial.call(this,a);this.type="RawShaderMaterial"};THREE.RawShaderMaterial.prototype=Object.create(THREE.ShaderMaterial.prototype);THREE.RawShaderMaterial.prototype.constructor=THREE.RawShaderMaterial;
+THREE.SpriteMaterial=function(a){THREE.Material.call(this);this.type="SpriteMaterial";this.color=new THREE.Color(16777215);this.map=null;this.rotation=0;this.fog=!1;this.setValues(a)};THREE.SpriteMaterial.prototype=Object.create(THREE.Material.prototype);THREE.SpriteMaterial.prototype.constructor=THREE.SpriteMaterial;THREE.SpriteMaterial.prototype.copy=function(a){THREE.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.rotation=a.rotation;this.fog=a.fog;return this};
+THREE.Texture=function(a,b,c,d,e,f,g,h,k){Object.defineProperty(this,"id",{value:THREE.TextureIdCount++});this.uuid=THREE.Math.generateUUID();this.sourceFile=this.name="";this.image=void 0!==a?a:THREE.Texture.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==b?b:THREE.Texture.DEFAULT_MAPPING;this.wrapS=void 0!==c?c:THREE.ClampToEdgeWrapping;this.wrapT=void 0!==d?d:THREE.ClampToEdgeWrapping;this.magFilter=void 0!==e?e:THREE.LinearFilter;this.minFilter=void 0!==f?f:THREE.LinearMipMapLinearFilter;
+this.anisotropy=void 0!==k?k:1;this.format=void 0!==g?g:THREE.RGBAFormat;this.type=void 0!==h?h:THREE.UnsignedByteType;this.offset=new THREE.Vector2(0,0);this.repeat=new THREE.Vector2(1,1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.version=0;this.onUpdate=null};THREE.Texture.DEFAULT_IMAGE=void 0;THREE.Texture.DEFAULT_MAPPING=THREE.UVMapping;
+THREE.Texture.prototype={constructor:THREE.Texture,set needsUpdate(a){!0===a&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=a.wrapT;this.magFilter=a.magFilter;this.minFilter=a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format;this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=
+a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;return this},toJSON:function(a){if(void 0!==a.textures[this.uuid])return a.textures[this.uuid];var b={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy};if(void 0!==this.image){var c=
+this.image;void 0===c.uuid&&(c.uuid=THREE.Math.generateUUID());if(void 0===a.images[c.uuid]){var d=a.images,e=c.uuid,f=c.uuid,g;void 0!==c.toDataURL?g=c:(g=document.createElement("canvas"),g.width=c.width,g.height=c.height,g.getContext("2d").drawImage(c,0,0,c.width,c.height));g=2048<g.width||2048<g.height?g.toDataURL("image/jpeg",.6):g.toDataURL("image/png");d[e]={uuid:f,url:g}}b.image=c.uuid}return a.textures[this.uuid]=b},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(a){if(this.mapping===
+THREE.UVMapping){a.multiply(this.repeat);a.add(this.offset);if(0>a.x||1<a.x)switch(this.wrapS){case THREE.RepeatWrapping:a.x-=Math.floor(a.x);break;case THREE.ClampToEdgeWrapping:a.x=0>a.x?0:1;break;case THREE.MirroredRepeatWrapping:1===Math.abs(Math.floor(a.x)%2)?a.x=Math.ceil(a.x)-a.x:a.x-=Math.floor(a.x)}if(0>a.y||1<a.y)switch(this.wrapT){case THREE.RepeatWrapping:a.y-=Math.floor(a.y);break;case THREE.ClampToEdgeWrapping:a.y=0>a.y?0:1;break;case THREE.MirroredRepeatWrapping:1===Math.abs(Math.floor(a.y)%
+2)?a.y=Math.ceil(a.y)-a.y:a.y-=Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};THREE.EventDispatcher.prototype.apply(THREE.Texture.prototype);THREE.TextureIdCount=0;THREE.CanvasTexture=function(a,b,c,d,e,f,g,h,k){THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.needsUpdate=!0};THREE.CanvasTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CanvasTexture.prototype.constructor=THREE.CanvasTexture;
+THREE.CubeTexture=function(a,b,c,d,e,f,g,h,k){b=void 0!==b?b:THREE.CubeReflectionMapping;THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.images=a;this.flipY=!1};THREE.CubeTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CubeTexture.prototype.constructor=THREE.CubeTexture;THREE.CubeTexture.prototype.copy=function(a){THREE.Texture.prototype.copy.call(this,a);this.images=a.images;return this};
+THREE.CompressedTexture=function(a,b,c,d,e,f,g,h,k,l,n){THREE.Texture.call(this,null,f,g,h,k,l,d,e,n);this.image={width:b,height:c};this.mipmaps=a;this.generateMipmaps=this.flipY=!1};THREE.CompressedTexture.prototype=Object.create(THREE.Texture.prototype);THREE.CompressedTexture.prototype.constructor=THREE.CompressedTexture;
+THREE.DataTexture=function(a,b,c,d,e,f,g,h,k,l,n){THREE.Texture.call(this,null,f,g,h,k,l,d,e,n);this.image={data:a,width:b,height:c};this.magFilter=void 0!==k?k:THREE.NearestFilter;this.minFilter=void 0!==l?l:THREE.NearestFilter;this.generateMipmaps=this.flipY=!1};THREE.DataTexture.prototype=Object.create(THREE.Texture.prototype);THREE.DataTexture.prototype.constructor=THREE.DataTexture;
+THREE.VideoTexture=function(a,b,c,d,e,f,g,h,k){function l(){requestAnimationFrame(l);a.readyState===a.HAVE_ENOUGH_DATA&&(n.needsUpdate=!0)}THREE.Texture.call(this,a,b,c,d,e,f,g,h,k);this.generateMipmaps=!1;var n=this;l()};THREE.VideoTexture.prototype=Object.create(THREE.Texture.prototype);THREE.VideoTexture.prototype.constructor=THREE.VideoTexture;THREE.Group=function(){THREE.Object3D.call(this);this.type="Group"};THREE.Group.prototype=Object.create(THREE.Object3D.prototype);
+THREE.Group.prototype.constructor=THREE.Group;THREE.Points=function(a,b){THREE.Object3D.call(this);this.type="Points";this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.PointsMaterial({color:16777215*Math.random()})};THREE.Points.prototype=Object.create(THREE.Object3D.prototype);THREE.Points.prototype.constructor=THREE.Points;
+THREE.Points.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray,c=new THREE.Sphere;return function(d,e){function f(a,c){var f=b.distanceSqToPoint(a);if(f<n){var h=b.closestPointToPoint(a);h.applyMatrix4(k);var l=d.ray.origin.distanceTo(h);l<d.near||l>d.far||e.push({distance:l,distanceToRay:Math.sqrt(f),point:h.clone(),index:c,face:null,object:g})}}var g=this,h=this.geometry,k=this.matrixWorld,l=d.params.Points.threshold;null===h.boundingSphere&&h.computeBoundingSphere();c.copy(h.boundingSphere);
+c.applyMatrix4(k);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(k);b.copy(d.ray).applyMatrix4(a);var l=l/((this.scale.x+this.scale.y+this.scale.z)/3),n=l*l,l=new THREE.Vector3;if(h instanceof THREE.BufferGeometry){var p=h.index,h=h.attributes.position.array;if(null!==p)for(var m=p.array,p=0,q=m.length;p<q;p++){var s=m[p];l.fromArray(h,3*s);f(l,s)}else for(p=0,m=h.length/3;p<m;p++)l.fromArray(h,3*p),f(l,p)}else for(l=h.vertices,p=0,m=l.length;p<m;p++)f(l[p],p)}}}();
+THREE.Points.prototype.clone=function(){return(new this.constructor(this.geometry,this.material)).copy(this)};THREE.Line=function(a,b,c){if(1===c)return console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),new THREE.LineSegments(a,b);THREE.Object3D.call(this);this.type="Line";this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.LineBasicMaterial({color:16777215*Math.random()})};THREE.Line.prototype=Object.create(THREE.Object3D.prototype);
+THREE.Line.prototype.constructor=THREE.Line;
+THREE.Line.prototype.raycast=function(){var a=new THREE.Matrix4,b=new THREE.Ray,c=new THREE.Sphere;return function(d,e){var f=d.linePrecision,f=f*f,g=this.geometry,h=this.matrixWorld;null===g.boundingSphere&&g.computeBoundingSphere();c.copy(g.boundingSphere);c.applyMatrix4(h);if(!1!==d.ray.intersectsSphere(c)){a.getInverse(h);b.copy(d.ray).applyMatrix4(a);var k=new THREE.Vector3,l=new THREE.Vector3,h=new THREE.Vector3,n=new THREE.Vector3,p=this instanceof THREE.LineSegments?2:1;if(g instanceof THREE.BufferGeometry){var m=
+g.index,q=g.attributes.position.array;if(null!==m)for(var m=m.array,g=0,s=m.length-1;g<s;g+=p){var u=m[g+1];k.fromArray(q,3*m[g]);l.fromArray(q,3*u);u=b.distanceSqToSegment(k,l,n,h);u>f||(n.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(n),u<d.near||u>d.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else for(g=0,s=q.length/3-1;g<s;g+=p)k.fromArray(q,3*g),l.fromArray(q,3*g+3),u=b.distanceSqToSegment(k,l,n,h),u>f||(n.applyMatrix4(this.matrixWorld),
+u=d.ray.origin.distanceTo(n),u<d.near||u>d.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}else if(g instanceof THREE.Geometry)for(k=g.vertices,l=k.length,g=0;g<l-1;g+=p)u=b.distanceSqToSegment(k[g],k[g+1],n,h),u>f||(n.applyMatrix4(this.matrixWorld),u=d.ray.origin.distanceTo(n),u<d.near||u>d.far||e.push({distance:u,point:h.clone().applyMatrix4(this.matrixWorld),index:g,face:null,faceIndex:null,object:this}))}}}();
+THREE.Line.prototype.clone=function(){return(new this.constructor(this.geometry,this.material)).copy(this)};THREE.LineStrip=0;THREE.LinePieces=1;THREE.LineSegments=function(a,b){THREE.Line.call(this,a,b);this.type="LineSegments"};THREE.LineSegments.prototype=Object.create(THREE.Line.prototype);THREE.LineSegments.prototype.constructor=THREE.LineSegments;
+THREE.Mesh=function(a,b){THREE.Object3D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:new THREE.Geometry;this.material=void 0!==b?b:new THREE.MeshBasicMaterial({color:16777215*Math.random()});this.drawMode=THREE.TrianglesDrawMode;this.updateMorphTargets()};THREE.Mesh.prototype=Object.create(THREE.Object3D.prototype);THREE.Mesh.prototype.constructor=THREE.Mesh;THREE.Mesh.prototype.setDrawMode=function(a){this.drawMode=a};
+THREE.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&0<this.geometry.morphTargets.length){this.morphTargetBase=-1;this.morphTargetInfluences=[];this.morphTargetDictionary={};for(var a=0,b=this.geometry.morphTargets.length;a<b;a++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[a].name]=a}};
+THREE.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morphTargetDictionary[a])return this.morphTargetDictionary[a];console.warn("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};
+THREE.Mesh.prototype.raycast=function(){function a(a,b,c,d,e,f,g){THREE.Triangle.barycoordFromPoint(a,b,c,d,u);e.multiplyScalar(u.x);f.multiplyScalar(u.y);g.multiplyScalar(u.z);e.add(f).add(g);return e.clone()}function b(a,b,c,d,e,f,g){var h=a.material;if(null===(h.side===THREE.BackSide?c.intersectTriangle(f,e,d,!0,g):c.intersectTriangle(d,e,f,h.side!==THREE.DoubleSide,g)))return null;x.copy(g);x.applyMatrix4(a.matrixWorld);c=b.ray.origin.distanceTo(x);return c<b.near||c>b.far?null:{distance:c,point:x.clone(),
+object:a}}function c(c,d,e,f,l,n,p,x){g.fromArray(f,3*n);h.fromArray(f,3*p);k.fromArray(f,3*x);if(c=b(c,d,e,g,h,k,t))l&&(m.fromArray(l,2*n),q.fromArray(l,2*p),s.fromArray(l,2*x),c.uv=a(t,g,h,k,m,q,s)),c.face=new THREE.Face3(n,p,x,THREE.Triangle.normal(g,h,k)),c.faceIndex=n;return c}var d=new THREE.Matrix4,e=new THREE.Ray,f=new THREE.Sphere,g=new THREE.Vector3,h=new THREE.Vector3,k=new THREE.Vector3,l=new THREE.Vector3,n=new THREE.Vector3,p=new THREE.Vector3,m=new THREE.Vector2,q=new THREE.Vector2,
+s=new THREE.Vector2,u=new THREE.Vector3,t=new THREE.Vector3,x=new THREE.Vector3;return function(x,u){var w=this.geometry,D=this.material,z=this.matrixWorld;if(void 0!==D&&(null===w.boundingSphere&&w.computeBoundingSphere(),f.copy(w.boundingSphere),f.applyMatrix4(z),!1!==x.ray.intersectsSphere(f)&&(d.getInverse(z),e.copy(x.ray).applyMatrix4(d),null===w.boundingBox||!1!==e.intersectsBox(w.boundingBox)))){var y,A;if(w instanceof THREE.BufferGeometry){var H,G,D=w.index,z=w.attributes,w=z.position.array;
+void 0!==z.uv&&(y=z.uv.array);if(null!==D)for(var z=D.array,E=0,K=z.length;E<K;E+=3){if(D=z[E],H=z[E+1],G=z[E+2],A=c(this,x,e,w,y,D,H,G))A.faceIndex=Math.floor(E/3),u.push(A)}else for(E=0,K=w.length;E<K;E+=9)if(D=E/3,H=D+1,G=D+2,A=c(this,x,e,w,y,D,H,G))A.index=D,u.push(A)}else if(w instanceof THREE.Geometry){var P,N,z=D instanceof THREE.MultiMaterial,E=!0===z?D.materials:null,K=w.vertices;H=w.faces;G=w.faceVertexUvs[0];0<G.length&&(y=G);for(var L=0,B=H.length;L<B;L++){var M=H[L];A=!0===z?E[M.materialIndex]:
+D;if(void 0!==A){G=K[M.a];P=K[M.b];N=K[M.c];if(!0===A.morphTargets){A=w.morphTargets;var Q=this.morphTargetInfluences;g.set(0,0,0);h.set(0,0,0);k.set(0,0,0);for(var O=0,S=A.length;O<S;O++){var J=Q[O];if(0!==J){var F=A[O].vertices;g.addScaledVector(l.subVectors(F[M.a],G),J);h.addScaledVector(n.subVectors(F[M.b],P),J);k.addScaledVector(p.subVectors(F[M.c],N),J)}}g.add(G);h.add(P);k.add(N);G=g;P=h;N=k}if(A=b(this,x,e,G,P,N,t))y&&(Q=y[L],m.copy(Q[0]),q.copy(Q[1]),s.copy(Q[2]),A.uv=a(t,G,P,N,m,q,s)),A.face=
+M,A.faceIndex=L,u.push(A)}}}}}}();THREE.Mesh.prototype.clone=function(){return(new this.constructor(this.geometry,this.material)).copy(this)};THREE.Bone=function(a){THREE.Object3D.call(this);this.type="Bone";this.skin=a};THREE.Bone.prototype=Object.create(THREE.Object3D.prototype);THREE.Bone.prototype.constructor=THREE.Bone;THREE.Bone.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.skin=a.skin;return this};
+THREE.Skeleton=function(a,b,c){this.useVertexTexture=void 0!==c?c:!0;this.identityMatrix=new THREE.Matrix4;a=a||[];this.bones=a.slice(0);this.useVertexTexture?(a=Math.sqrt(4*this.bones.length),a=THREE.Math.nextPowerOfTwo(Math.ceil(a)),this.boneTextureHeight=this.boneTextureWidth=a=Math.max(a,4),this.boneMatrices=new Float32Array(this.boneTextureWidth*this.boneTextureHeight*4),this.boneTexture=new THREE.DataTexture(this.boneMatrices,this.boneTextureWidth,this.boneTextureHeight,THREE.RGBAFormat,THREE.FloatType)):
+this.boneMatrices=new Float32Array(16*this.bones.length);if(void 0===b)this.calculateInverses();else if(this.bones.length===b.length)this.boneInverses=b.slice(0);else for(console.warn("THREE.Skeleton bonInverses is the wrong length."),this.boneInverses=[],b=0,a=this.bones.length;b<a;b++)this.boneInverses.push(new THREE.Matrix4)};
+THREE.Skeleton.prototype.calculateInverses=function(){this.boneInverses=[];for(var a=0,b=this.bones.length;a<b;a++){var c=new THREE.Matrix4;this.bones[a]&&c.getInverse(this.bones[a].matrixWorld);this.boneInverses.push(c)}};
+THREE.Skeleton.prototype.pose=function(){for(var a,b=0,c=this.bones.length;b<c;b++)(a=this.bones[b])&&a.matrixWorld.getInverse(this.boneInverses[b]);b=0;for(c=this.bones.length;b<c;b++)if(a=this.bones[b])a.parent?(a.matrix.getInverse(a.parent.matrixWorld),a.matrix.multiply(a.matrixWorld)):a.matrix.copy(a.matrixWorld),a.matrix.decompose(a.position,a.quaternion,a.scale)};
+THREE.Skeleton.prototype.update=function(){var a=new THREE.Matrix4;return function(){for(var b=0,c=this.bones.length;b<c;b++)a.multiplyMatrices(this.bones[b]?this.bones[b].matrixWorld:this.identityMatrix,this.boneInverses[b]),a.flattenToArrayOffset(this.boneMatrices,16*b);this.useVertexTexture&&(this.boneTexture.needsUpdate=!0)}}();THREE.Skeleton.prototype.clone=function(){return new THREE.Skeleton(this.bones,this.boneInverses,this.useVertexTexture)};
+THREE.SkinnedMesh=function(a,b,c){THREE.Mesh.call(this,a,b);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new THREE.Matrix4;this.bindMatrixInverse=new THREE.Matrix4;a=[];if(this.geometry&&void 0!==this.geometry.bones){for(var d,e=0,f=this.geometry.bones.length;e<f;++e)d=this.geometry.bones[e],b=new THREE.Bone(this),a.push(b),b.name=d.name,b.position.fromArray(d.pos),b.quaternion.fromArray(d.rotq),void 0!==d.scl&&b.scale.fromArray(d.scl);e=0;for(f=this.geometry.bones.length;e<f;++e)d=
+this.geometry.bones[e],-1!==d.parent&&null!==d.parent?a[d.parent].add(a[e]):this.add(a[e])}this.normalizeSkinWeights();this.updateMatrixWorld(!0);this.bind(new THREE.Skeleton(a,void 0,c),this.matrixWorld)};THREE.SkinnedMesh.prototype=Object.create(THREE.Mesh.prototype);THREE.SkinnedMesh.prototype.constructor=THREE.SkinnedMesh;
+THREE.SkinnedMesh.prototype.bind=function(a,b){this.skeleton=a;void 0===b&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),b=this.matrixWorld);this.bindMatrix.copy(b);this.bindMatrixInverse.getInverse(b)};THREE.SkinnedMesh.prototype.pose=function(){this.skeleton.pose()};
+THREE.SkinnedMesh.prototype.normalizeSkinWeights=function(){if(this.geometry instanceof THREE.Geometry)for(var a=0;a<this.geometry.skinWeights.length;a++){var b=this.geometry.skinWeights[a],c=1/b.lengthManhattan();Infinity!==c?b.multiplyScalar(c):b.set(1,0,0,0)}else if(this.geometry instanceof THREE.BufferGeometry)for(var b=new THREE.Vector4,d=this.geometry.attributes.skinWeight,a=0;a<d.count;a++)b.x=d.getX(a),b.y=d.getY(a),b.z=d.getZ(a),b.w=d.getW(a),c=1/b.lengthManhattan(),Infinity!==c?b.multiplyScalar(c):
+b.set(1,0,0,0),d.setXYZW(a,b.x,b.y,b.z,b.w)};THREE.SkinnedMesh.prototype.updateMatrixWorld=function(a){THREE.Mesh.prototype.updateMatrixWorld.call(this,!0);"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh unrecognized bindMode: "+this.bindMode)};THREE.SkinnedMesh.prototype.clone=function(){return(new this.constructor(this.geometry,this.material,this.useVertexTexture)).copy(this)};
+THREE.LOD=function(){THREE.Object3D.call(this);this.type="LOD";Object.defineProperties(this,{levels:{enumerable:!0,value:[]},objects:{get:function(){console.warn("THREE.LOD: .objects has been renamed to .levels.");return this.levels}}})};THREE.LOD.prototype=Object.create(THREE.Object3D.prototype);THREE.LOD.prototype.constructor=THREE.LOD;
+THREE.LOD.prototype.addLevel=function(a,b){void 0===b&&(b=0);b=Math.abs(b);for(var c=this.levels,d=0;d<c.length&&!(b<c[d].distance);d++);c.splice(d,0,{distance:b,object:a});this.add(a)};THREE.LOD.prototype.getObjectForDistance=function(a){for(var b=this.levels,c=1,d=b.length;c<d&&!(a<b[c].distance);c++);return b[c-1].object};
+THREE.LOD.prototype.raycast=function(){var a=new THREE.Vector3;return function(b,c){a.setFromMatrixPosition(this.matrixWorld);var d=b.ray.origin.distanceTo(a);this.getObjectForDistance(d).raycast(b,c)}}();
+THREE.LOD.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(c){var d=this.levels;if(1<d.length){a.setFromMatrixPosition(c.matrixWorld);b.setFromMatrixPosition(this.matrixWorld);c=a.distanceTo(b);d[0].object.visible=!0;for(var e=1,f=d.length;e<f;e++)if(c>=d[e].distance)d[e-1].object.visible=!1,d[e].object.visible=!0;else break;for(;e<f;e++)d[e].object.visible=!1}}}();
+THREE.LOD.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a,!1);a=a.levels;for(var b=0,c=a.length;b<c;b++){var d=a[b];this.addLevel(d.object.clone(),d.distance)}return this};THREE.LOD.prototype.toJSON=function(a){a=THREE.Object3D.prototype.toJSON.call(this,a);a.object.levels=[];for(var b=this.levels,c=0,d=b.length;c<d;c++){var e=b[c];a.object.levels.push({object:e.object.uuid,distance:e.distance})}return a};
+THREE.Sprite=function(){var a=new Uint16Array([0,1,2,0,2,3]),b=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),c=new Float32Array([0,0,1,0,1,1,0,1]),d=new THREE.BufferGeometry;d.setIndex(new THREE.BufferAttribute(a,1));d.addAttribute("position",new THREE.BufferAttribute(b,3));d.addAttribute("uv",new THREE.BufferAttribute(c,2));return function(a){THREE.Object3D.call(this);this.type="Sprite";this.geometry=d;this.material=void 0!==a?a:new THREE.SpriteMaterial}}();THREE.Sprite.prototype=Object.create(THREE.Object3D.prototype);
+THREE.Sprite.prototype.constructor=THREE.Sprite;THREE.Sprite.prototype.raycast=function(){var a=new THREE.Vector3;return function(b,c){a.setFromMatrixPosition(this.matrixWorld);var d=b.ray.distanceSqToPoint(a);d>this.scale.x*this.scale.y||c.push({distance:Math.sqrt(d),point:this.position,face:null,object:this})}}();THREE.Sprite.prototype.clone=function(){return(new this.constructor(this.material)).copy(this)};THREE.Particle=THREE.Sprite;
+THREE.LensFlare=function(a,b,c,d,e){THREE.Object3D.call(this);this.lensFlares=[];this.positionScreen=new THREE.Vector3;this.customUpdateCallback=void 0;void 0!==a&&this.add(a,b,c,d,e)};THREE.LensFlare.prototype=Object.create(THREE.Object3D.prototype);THREE.LensFlare.prototype.constructor=THREE.LensFlare;
+THREE.LensFlare.prototype.add=function(a,b,c,d,e,f){void 0===b&&(b=-1);void 0===c&&(c=0);void 0===f&&(f=1);void 0===e&&(e=new THREE.Color(16777215));void 0===d&&(d=THREE.NormalBlending);c=Math.min(c,Math.max(0,c));this.lensFlares.push({texture:a,size:b,distance:c,x:0,y:0,z:0,scale:1,rotation:0,opacity:f,color:e,blending:d})};
+THREE.LensFlare.prototype.updateLensFlares=function(){var a,b=this.lensFlares.length,c,d=2*-this.positionScreen.x,e=2*-this.positionScreen.y;for(a=0;a<b;a++)c=this.lensFlares[a],c.x=this.positionScreen.x+d*c.distance,c.y=this.positionScreen.y+e*c.distance,c.wantedRotation=c.x*Math.PI*.25,c.rotation+=.25*(c.wantedRotation-c.rotation)};
+THREE.LensFlare.prototype.copy=function(a){THREE.Object3D.prototype.copy.call(this,a);this.positionScreen.copy(a.positionScreen);this.customUpdateCallback=a.customUpdateCallback;for(var b=0,c=a.lensFlares.length;b<c;b++)this.lensFlares.push(a.lensFlares[b]);return this};THREE.Scene=function(){THREE.Object3D.call(this);this.type="Scene";this.overrideMaterial=this.fog=null;this.autoUpdate=!0};THREE.Scene.prototype=Object.create(THREE.Object3D.prototype);THREE.Scene.prototype.constructor=THREE.Scene;
+THREE.Scene.prototype.copy=function(a,b){THREE.Object3D.prototype.copy.call(this,a,b);null!==a.fog&&(this.fog=a.fog.clone());null!==a.overrideMaterial&&(this.overrideMaterial=a.overrideMaterial.clone());this.autoUpdate=a.autoUpdate;this.matrixAutoUpdate=a.matrixAutoUpdate;return this};THREE.Fog=function(a,b,c){this.name="";this.color=new THREE.Color(a);this.near=void 0!==b?b:1;this.far=void 0!==c?c:1E3};THREE.Fog.prototype.clone=function(){return new THREE.Fog(this.color.getHex(),this.near,this.far)};
+THREE.FogExp2=function(a,b){this.name="";this.color=new THREE.Color(a);this.density=void 0!==b?b:2.5E-4};THREE.FogExp2.prototype.clone=function(){return new THREE.FogExp2(this.color.getHex(),this.density)};THREE.ShaderChunk={};THREE.ShaderChunk.alphamap_fragment="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n";THREE.ShaderChunk.alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n";THREE.ShaderChunk.alphatest_fragment="#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n";
+THREE.ShaderChunk.ambient_pars="uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\treturn PI * ambientLightColor;\n}\n";THREE.ShaderChunk.aomap_fragment="#ifdef USE_AOMAP\n\treflectedLight.indirectDiffuse *= ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n#endif\n";THREE.ShaderChunk.aomap_pars_fragment="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";THREE.ShaderChunk.begin_vertex="\nvec3 transformed = vec3( position );\n";
+THREE.ShaderChunk.beginnormal_vertex="\nvec3 objectNormal = vec3( normal );\n";THREE.ShaderChunk.bsdfs="bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {\n\treturn any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );\n}\nfloat calcLightAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\tif ( decayExponent > 0.0 ) {\n\t  return pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\t}\n\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = alpha * alpha;\n\tfloat gl = dotNL + pow( a2 + ( 1.0 - a2 ) * dotNL * dotNL, 0.5 );\n\tfloat gv = dotNV + pow( a2 + ( 1.0 - a2 ) * dotNV * dotNV, 0.5 );\n\treturn 1.0 / ( gl * gv );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = alpha * alpha;\n\tfloat denom = dotNH * dotNH * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / ( denom * denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = roughness * roughness;\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_Smith( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / square( ggxRoughness + 0.0001 ) - 2.0 );\n}\n";
+THREE.ShaderChunk.bumpmap_pars_fragment="#ifdef USE_BUMPMAP\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\tvec2 dHdxy_fwd() {\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\t\treturn vec2( dBx, dBy );\n\t}\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\t\tvec3 vSigmaX = dFdx( surf_pos );\n\t\tvec3 vSigmaY = dFdy( surf_pos );\n\t\tvec3 vN = surf_norm;\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\t}\n#endif\n";
+THREE.ShaderChunk.color_fragment="#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif";THREE.ShaderChunk.color_pars_fragment="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n";THREE.ShaderChunk.color_pars_vertex="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif";THREE.ShaderChunk.color_vertex="#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif";THREE.ShaderChunk.common="#define PI 3.14159\n#define PI2 6.28318\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat square( const in float x ) { return x*x; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\nvec3 inputToLinear( in vec3 a ) {\n\t#ifdef GAMMA_INPUT\n\t\treturn pow( a, vec3( float( GAMMA_FACTOR ) ) );\n\t#else\n\t\treturn a;\n\t#endif\n}\nvec3 linearToOutput( in vec3 a ) {\n\t#ifdef GAMMA_OUTPUT\n\t\treturn pow( a, vec3( 1.0 / float( GAMMA_FACTOR ) ) );\n\t#else\n\t\treturn a;\n\t#endif\n}\n";
+THREE.ShaderChunk.defaultnormal_vertex="#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n";THREE.ShaderChunk.displacementmap_vertex="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n";THREE.ShaderChunk.displacementmap_pars_vertex="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n";
+THREE.ShaderChunk.emissivemap_fragment="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = inputToLinear( emissiveColor.rgb );\n\ttotalEmissiveLight *= emissiveColor.rgb;\n#endif\n";THREE.ShaderChunk.emissivemap_pars_fragment="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n";THREE.ShaderChunk.envmap_fragment="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#else\n\t\tfloat flipNormal = 1.0;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#endif\n\tenvColor.xyz = inputToLinear( envColor.xyz );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
+THREE.ShaderChunk.envmap_pars_fragment="#if defined( USE_ENVMAP ) || defined( STANDARD )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( STANDARD )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
+THREE.ShaderChunk.envmap_pars_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG ) && ! defined( STANDARD )\n\tvarying vec3 vReflect;\n\tuniform float refractionRatio;\n#endif\n";THREE.ShaderChunk.envmap_vertex="#if defined( USE_ENVMAP ) && ! defined( USE_BUMPMAP ) && ! defined( USE_NORMALMAP ) && ! defined( PHONG ) && ! defined( STANDARD )\n\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t#ifdef ENVMAP_MODE_REFLECTION\n\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t#else\n\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t#endif\n#endif\n";
+THREE.ShaderChunk.fog_fragment="#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\t#endif\n\t\n\toutgoingLight = mix( outgoingLight, fogColor, fogFactor );\n#endif";
+THREE.ShaderChunk.fog_pars_fragment="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";THREE.ShaderChunk.lightmap_fragment="#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n";THREE.ShaderChunk.lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";
+THREE.ShaderChunk.lights_lambert_vertex="vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tdirectLight = getPointDirectLight( pointLights[ i ], geometry );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tdirectLight = getSpotDirectLight( spotLights[ i ], geometry );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectLight = getDirectionalDirectLight( directionalLights[ i ], geometry );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
+THREE.ShaderChunk.lights_pars="#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tIncidentLight getDirectionalDirectLight( const in DirectionalLight directionalLight, const in GeometricContext geometry ) {\n\t\tIncidentLight directLight;\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t\treturn directLight;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tIncidentLight getPointDirectLight( const in PointLight pointLight, const in GeometricContext geometry ) {\n\t\tIncidentLight directLight;\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tif ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= calcLightAttenuation( lightDistance, pointLight.distance, pointLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t\treturn directLight;\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat angleCos;\n\t\tfloat penumbra;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tIncidentLight getSpotDirectLight( const in SpotLight spotLight, const in GeometricContext geometry ) {\n\t\tIncidentLight directLight;\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat spotEffect = dot( directLight.direction, spotLight.direction );\n\t\tif ( all( bvec2( spotEffect > spotLight.angleCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n\t\t\tfloat spotEffect = dot( spotLight.direction, directLight.direction );\n\t\t\tspotEffect *= clamp( ( spotEffect - spotLight.angleCos ) / spotLight.penumbra, 0.0, 1.0 );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= ( spotEffect * calcLightAttenuation( lightDistance, spotLight.distance, spotLight.decay ) );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t\treturn directLight;\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\treturn PI * mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( STANDARD )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tfloat flipNormal = 1.0;\n\t\t#endif\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t#else\n\t\t\tvec3 envMapColor = vec3( 0.0 );\n\t\t#endif\n\t\tenvMapColor.rgb = inputToLinear( envMapColor.rgb );\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( square( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tfloat flipNormal = 1.0;\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t#endif\n\t\tenvMapColor.rgb = inputToLinear( envMapColor.rgb );\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
+THREE.ShaderChunk.lights_phong_fragment="BlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n";THREE.ShaderChunk.lights_phong_pars_fragment="#ifdef USE_ENVMAP\n\tvarying vec3 vWorldPosition;\n#endif\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\nstruct BlinnPhongMaterial {\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n};\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * PI * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n}\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n#define Material_LightProbeLOD( material )\t(0)\n";
+THREE.ShaderChunk.lights_phong_pars_vertex="#ifdef USE_ENVMAP\n\tvarying vec3 vWorldPosition;\n#endif\n";THREE.ShaderChunk.lights_phong_vertex="#ifdef USE_ENVMAP\n\tvWorldPosition = worldPosition.xyz;\n#endif\n";THREE.ShaderChunk.lights_standard_fragment="StandardMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\nmaterial.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );\nmaterial.specularColor = mix( vec3( 0.04 ), diffuseColor.rgb, metalnessFactor );\n";
+THREE.ShaderChunk.lights_standard_pars_fragment="struct StandardMaterial {\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n};\nvoid RE_Direct_Standard( const in IncidentLight directLight, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * PI * directLight.color;\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_GGX( directLight, geometry, material.specularColor, material.specularRoughness );\n}\nvoid RE_IndirectDiffuse_Standard( const in vec3 irradiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\nvoid RE_IndirectSpecular_Standard( const in vec3 radiance, const in GeometricContext geometry, const in StandardMaterial material, inout ReflectedLight reflectedLight ) {\n\treflectedLight.indirectSpecular += radiance * BRDF_Specular_GGX_Environment( geometry, material.specularColor, material.specularRoughness );\n}\n#define RE_Direct\t\t\t\tRE_Direct_Standard\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Standard\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Standard\n#define Material_BlinnShininessExponent( material )   GGXRoughnessToBlinnExponent( material.specularRoughness )\n";
+THREE.ShaderChunk.lights_template="\nGeometricContext geometry;\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = normalize( vViewPosition );\nIncidentLight directLight;\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tdirectLight = getPointDirectLight( pointLight, geometry );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( pointLight.shadow, directLight.visible ) ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tdirectLight = getSpotDirectLight( spotLight, geometry );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( spotLight.shadow, directLight.visible ) ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tdirectLight = getDirectionalDirectLight( directionalLight, geometry );\n\t\t#ifdef USE_SHADOWMAP\n\t\tdirectLight.color *= all( bvec2( directionalLight.shadow, directLight.visible ) ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\t}\n#endif\n#if defined( RE_IndirectDiffuse )\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\t#ifdef USE_LIGHTMAP\n\t\tirradiance += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n\t#endif\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t}\n\t#endif\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n#endif\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\tvec3 radiance = getLightProbeIndirectRadiance( geometry, Material_BlinnShininessExponent( material ), 8 );\n\tRE_IndirectSpecular( radiance, geometry, material, reflectedLight );\n#endif\n";
+THREE.ShaderChunk.linear_to_gamma_fragment="\n\toutgoingLight = linearToOutput( outgoingLight );\n";THREE.ShaderChunk.logdepthbuf_fragment="#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif";THREE.ShaderChunk.logdepthbuf_pars_fragment="#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n";THREE.ShaderChunk.logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif";
+THREE.ShaderChunk.logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n";THREE.ShaderChunk.map_fragment="#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor.xyz = inputToLinear( texelColor.xyz );\n\tdiffuseColor *= texelColor;\n#endif\n";
+THREE.ShaderChunk.map_pars_fragment="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif";THREE.ShaderChunk.map_particle_fragment="#ifdef USE_MAP\n\tdiffuseColor *= texture2D( map, vec2( gl_PointCoord.x, 1.0 - gl_PointCoord.y ) * offsetRepeat.zw + offsetRepeat.xy );\n#endif\n";THREE.ShaderChunk.map_particle_pars_fragment="#ifdef USE_MAP\n\tuniform vec4 offsetRepeat;\n\tuniform sampler2D map;\n#endif\n";THREE.ShaderChunk.metalnessmap_fragment="float metalnessFactor = metalness;\n#ifdef USE_METALNESSMAP\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\tmetalnessFactor *= texelMetalness.r;\n#endif\n";
+THREE.ShaderChunk.metalnessmap_pars_fragment="#ifdef USE_METALNESSMAP\n\tuniform sampler2D metalnessMap;\n#endif";THREE.ShaderChunk.morphnormal_vertex="#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n";
+THREE.ShaderChunk.morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif";THREE.ShaderChunk.morphtarget_vertex="#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n";
+THREE.ShaderChunk.normal_fragment="#ifdef FLAT_SHADED\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n#else\n\tvec3 normal = normalize( vNormal );\n\t#ifdef DOUBLE_SIDED\n\t\tnormal = normal * ( -1.0 + 2.0 * float( gl_FrontFacing ) );\n\t#endif\n#endif\n#ifdef USE_NORMALMAP\n\tnormal = perturbNormal2Arb( -vViewPosition, normal );\n#elif defined( USE_BUMPMAP )\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n#endif\n";
+THREE.ShaderChunk.normalmap_pars_fragment="#ifdef USE_NORMALMAP\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm ) {\n\t\tvec3 q0 = dFdx( eye_pos.xyz );\n\t\tvec3 q1 = dFdy( eye_pos.xyz );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\t\tvec3 S = normalize( q0 * st1.t - q1 * st0.t );\n\t\tvec3 T = normalize( -q0 * st1.s + q1 * st0.s );\n\t\tvec3 N = normalize( surf_norm );\n\t\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\t\tmapN.xy = normalScale * mapN.xy;\n\t\tmat3 tsn = mat3( S, T, N );\n\t\treturn normalize( tsn * mapN );\n\t}\n#endif\n";
+THREE.ShaderChunk.project_vertex="#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n";THREE.ShaderChunk.roughnessmap_fragment="float roughnessFactor = roughness;\n#ifdef USE_ROUGHNESSMAP\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\troughnessFactor *= texelRoughness.r;\n#endif\n";THREE.ShaderChunk.roughnessmap_pars_fragment="#ifdef USE_ROUGHNESSMAP\n\tuniform sampler2D roughnessMap;\n#endif";
+THREE.ShaderChunk.shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat unpackDepth( const in vec4 rgba_depth ) {\n\t\tconst vec4 bit_shift = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n\t\treturn dot( rgba_depth, bit_shift );\n\t}\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n";
+THREE.ShaderChunk.shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n";
+THREE.ShaderChunk.shadowmap_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n";
+THREE.ShaderChunk.shadowmask_pars_fragment="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n";
+THREE.ShaderChunk.skinbase_vertex="#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";THREE.ShaderChunk.skinning_pars_vertex="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneGlobalMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneGlobalMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
+THREE.ShaderChunk.skinning_vertex="#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned  = bindMatrixInverse * skinned;\n#endif\n";THREE.ShaderChunk.skinnormal_vertex="#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix  = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n";
+THREE.ShaderChunk.specularmap_fragment="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif";THREE.ShaderChunk.specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif";THREE.ShaderChunk.uv2_pars_fragment="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif";THREE.ShaderChunk.uv2_pars_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif";
+THREE.ShaderChunk.uv2_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif";THREE.ShaderChunk.uv_pars_fragment="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif";THREE.ShaderChunk.uv_pars_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n";
+THREE.ShaderChunk.uv_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif";THREE.ShaderChunk.worldpos_vertex="#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( STANDARD ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n";
+THREE.UniformsUtils={merge:function(a){for(var b={},c=0;c<a.length;c++){var d=this.clone(a[c]),e;for(e in d)b[e]=d[e]}return b},clone:function(a){var b={},c;for(c in a){b[c]={};for(var d in a[c]){var e=a[c][d];e instanceof THREE.Color||e instanceof THREE.Vector2||e instanceof THREE.Vector3||e instanceof THREE.Vector4||e instanceof THREE.Matrix3||e instanceof THREE.Matrix4||e instanceof THREE.Texture?b[c][d]=e.clone():Array.isArray(e)?b[c][d]=e.slice():b[c][d]=e}}return b}};
+THREE.UniformsLib={common:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)},specularMap:{type:"t",value:null},alphaMap:{type:"t",value:null},envMap:{type:"t",value:null},flipEnvMap:{type:"f",value:-1},reflectivity:{type:"f",value:1},refractionRatio:{type:"f",value:.98}},aomap:{aoMap:{type:"t",value:null},aoMapIntensity:{type:"f",value:1}},lightmap:{lightMap:{type:"t",value:null},lightMapIntensity:{type:"f",
+value:1}},emissivemap:{emissiveMap:{type:"t",value:null}},bumpmap:{bumpMap:{type:"t",value:null},bumpScale:{type:"f",value:1}},normalmap:{normalMap:{type:"t",value:null},normalScale:{type:"v2",value:new THREE.Vector2(1,1)}},displacementmap:{displacementMap:{type:"t",value:null},displacementScale:{type:"f",value:1},displacementBias:{type:"f",value:0}},roughnessmap:{roughnessMap:{type:"t",value:null}},metalnessmap:{metalnessMap:{type:"t",value:null}},fog:{fogDensity:{type:"f",value:2.5E-4},fogNear:{type:"f",
+value:1},fogFar:{type:"f",value:2E3},fogColor:{type:"c",value:new THREE.Color(16777215)}},ambient:{ambientLightColor:{type:"fv",value:[]}},lights:{directionalLights:{type:"sa",value:[],properties:{direction:{type:"v3"},color:{type:"c"},shadow:{type:"i"},shadowBias:{type:"f"},shadowRadius:{type:"f"},shadowMapSize:{type:"v2"}}},directionalShadowMap:{type:"tv",value:[]},directionalShadowMatrix:{type:"m4v",value:[]},spotLights:{type:"sa",value:[],properties:{color:{type:"c"},position:{type:"v3"},direction:{type:"v3"},
+distance:{type:"f"},angleCos:{type:"f"},penumbra:{type:"f"},decay:{type:"f"},shadow:{type:"i"},shadowBias:{type:"f"},shadowRadius:{type:"f"},shadowMapSize:{type:"v2"}}},spotShadowMap:{type:"tv",value:[]},spotShadowMatrix:{type:"m4v",value:[]},pointLights:{type:"sa",value:[],properties:{color:{type:"c"},position:{type:"v3"},decay:{type:"f"},distance:{type:"f"},shadow:{type:"i"},shadowBias:{type:"f"},shadowRadius:{type:"f"},shadowMapSize:{type:"v2"}}},pointShadowMap:{type:"tv",value:[]},pointShadowMatrix:{type:"m4v",
+value:[]},hemisphereLights:{type:"sa",value:[],properties:{direction:{type:"v3"},skyColor:{type:"c"},groundColor:{type:"c"}}}},points:{diffuse:{type:"c",value:new THREE.Color(15658734)},opacity:{type:"f",value:1},size:{type:"f",value:1},scale:{type:"f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new THREE.Vector4(0,0,1,1)}}};
+THREE.ShaderLib={basic:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.aomap,THREE.UniformsLib.fog]),vertexShader:[THREE.ShaderChunk.common,THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.uv2_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.uv2_vertex,
+THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.skinbase_vertex,"\t#ifdef USE_ENVMAP",THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,"\t#endif",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,"}"].join("\n"),
+fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.uv2_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.aomap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,
+"void main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,"\tReflectedLight reflectedLight;\n\treflectedLight.directDiffuse = vec3( 0.0 );\n\treflectedLight.directSpecular = vec3( 0.0 );\n\treflectedLight.indirectDiffuse = diffuseColor.rgb;\n\treflectedLight.indirectSpecular = vec3( 0.0 );",
+THREE.ShaderChunk.aomap_fragment,"\tvec3 outgoingLight = reflectedLight.indirectDiffuse;",THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},lambert:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.aomap,THREE.UniformsLib.lightmap,THREE.UniformsLib.emissivemap,THREE.UniformsLib.fog,THREE.UniformsLib.ambient,THREE.UniformsLib.lights,{emissive:{type:"c",
+value:new THREE.Color(0)}}]),vertexShader:["#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.uv2_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.bsdfs,THREE.ShaderChunk.lights_pars,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,
+"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.uv2_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,
+THREE.ShaderChunk.lights_lambert_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.uv2_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.aomap_pars_fragment,
+THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.emissivemap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.bsdfs,THREE.ShaderChunk.ambient_pars,THREE.ShaderChunk.lights_pars,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.shadowmask_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveLight = emissive;",
+THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.emissivemap_fragment,"\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );",THREE.ShaderChunk.lightmap_fragment,"\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();",
+THREE.ShaderChunk.aomap_fragment,"\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveLight;",THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},phong:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.aomap,THREE.UniformsLib.lightmap,THREE.UniformsLib.emissivemap,THREE.UniformsLib.bumpmap,THREE.UniformsLib.normalmap,
+THREE.UniformsLib.displacementmap,THREE.UniformsLib.fog,THREE.UniformsLib.ambient,THREE.UniformsLib.lights,{emissive:{type:"c",value:new THREE.Color(0)},specular:{type:"c",value:new THREE.Color(1118481)},shininess:{type:"f",value:30}}]),vertexShader:["#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.uv2_pars_vertex,THREE.ShaderChunk.displacementmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,
+THREE.ShaderChunk.lights_phong_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.uv2_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,
+"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.displacementmap_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"\tvViewPosition = - mvPosition.xyz;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.lights_phong_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;",
+THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.uv2_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.aomap_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.emissivemap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.bsdfs,THREE.ShaderChunk.ambient_pars,THREE.ShaderChunk.lights_pars,THREE.ShaderChunk.lights_phong_pars_fragment,
+THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.bumpmap_pars_fragment,THREE.ShaderChunk.normalmap_pars_fragment,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveLight = emissive;",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.color_fragment,
+THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.normal_fragment,THREE.ShaderChunk.emissivemap_fragment,THREE.ShaderChunk.lights_phong_fragment,THREE.ShaderChunk.lights_template,THREE.ShaderChunk.aomap_fragment,"vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",THREE.ShaderChunk.envmap_fragment,THREE.ShaderChunk.linear_to_gamma_fragment,
+THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},standard:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,THREE.UniformsLib.aomap,THREE.UniformsLib.lightmap,THREE.UniformsLib.emissivemap,THREE.UniformsLib.bumpmap,THREE.UniformsLib.normalmap,THREE.UniformsLib.displacementmap,THREE.UniformsLib.roughnessmap,THREE.UniformsLib.metalnessmap,THREE.UniformsLib.fog,THREE.UniformsLib.ambient,THREE.UniformsLib.lights,{emissive:{type:"c",value:new THREE.Color(0)},
+roughness:{type:"f",value:.5},metalness:{type:"f",value:0},envMapIntensity:{type:"f",value:1}}]),vertexShader:["#define STANDARD\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif",THREE.ShaderChunk.common,THREE.ShaderChunk.uv_pars_vertex,THREE.ShaderChunk.uv2_pars_vertex,THREE.ShaderChunk.displacementmap_pars_vertex,THREE.ShaderChunk.envmap_pars_vertex,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,
+THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.specularmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.uv_vertex,THREE.ShaderChunk.uv2_vertex,THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.beginnormal_vertex,THREE.ShaderChunk.morphnormal_vertex,THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.skinnormal_vertex,THREE.ShaderChunk.defaultnormal_vertex,"#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif",THREE.ShaderChunk.begin_vertex,
+THREE.ShaderChunk.displacementmap_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"\tvViewPosition = - mvPosition.xyz;",THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.envmap_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["#define STANDARD\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif",
+THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.uv_pars_fragment,THREE.ShaderChunk.uv2_pars_fragment,THREE.ShaderChunk.map_pars_fragment,THREE.ShaderChunk.alphamap_pars_fragment,THREE.ShaderChunk.aomap_pars_fragment,THREE.ShaderChunk.lightmap_pars_fragment,THREE.ShaderChunk.emissivemap_pars_fragment,THREE.ShaderChunk.envmap_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.bsdfs,THREE.ShaderChunk.ambient_pars,THREE.ShaderChunk.lights_pars,THREE.ShaderChunk.lights_standard_pars_fragment,
+THREE.ShaderChunk.shadowmap_pars_fragment,THREE.ShaderChunk.bumpmap_pars_fragment,THREE.ShaderChunk.normalmap_pars_fragment,THREE.ShaderChunk.roughnessmap_pars_fragment,THREE.ShaderChunk.metalnessmap_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveLight = emissive;",THREE.ShaderChunk.logdepthbuf_fragment,
+THREE.ShaderChunk.map_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.alphamap_fragment,THREE.ShaderChunk.alphatest_fragment,THREE.ShaderChunk.specularmap_fragment,THREE.ShaderChunk.roughnessmap_fragment,THREE.ShaderChunk.metalnessmap_fragment,THREE.ShaderChunk.normal_fragment,THREE.ShaderChunk.emissivemap_fragment,THREE.ShaderChunk.lights_standard_fragment,THREE.ShaderChunk.lights_template,THREE.ShaderChunk.aomap_fragment,"vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;",
+THREE.ShaderChunk.linear_to_gamma_fragment,THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},points:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.points,THREE.UniformsLib.fog]),vertexShader:["uniform float size;\nuniform float scale;",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.shadowmap_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,THREE.ShaderChunk.begin_vertex,
+THREE.ShaderChunk.project_vertex,"\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif",THREE.ShaderChunk.logdepthbuf_vertex,THREE.ShaderChunk.worldpos_vertex,THREE.ShaderChunk.shadowmap_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.map_particle_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.shadowmap_pars_fragment,
+THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.map_particle_fragment,THREE.ShaderChunk.color_fragment,THREE.ShaderChunk.alphatest_fragment,"\toutgoingLight = diffuseColor.rgb;",THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},dashed:{uniforms:THREE.UniformsUtils.merge([THREE.UniformsLib.common,
+THREE.UniformsLib.fog,{scale:{type:"f",value:1},dashSize:{type:"f",value:1},totalSize:{type:"f",value:2}}]),vertexShader:["uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.color_vertex,"\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;",
+THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;",THREE.ShaderChunk.common,THREE.ShaderChunk.color_pars_fragment,THREE.ShaderChunk.fog_pars_fragment,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );",
+THREE.ShaderChunk.logdepthbuf_fragment,THREE.ShaderChunk.color_fragment,"\toutgoingLight = diffuseColor.rgb;",THREE.ShaderChunk.fog_fragment,"\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n}"].join("\n")},depth:{uniforms:{mNear:{type:"f",value:1},mFar:{type:"f",value:2E3},opacity:{type:"f",value:1}},vertexShader:[THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,
+THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float mNear;\nuniform float mFar;\nuniform float opacity;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {",THREE.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\tfloat color = 1.0 - smoothstep( mNear, mFar, depth );\n\tgl_FragColor = vec4( vec3( color ), opacity );\n}"].join("\n")},
+normal:{uniforms:{opacity:{type:"f",value:1}},vertexShader:["varying vec3 vNormal;",THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvNormal = normalize( normalMatrix * normal );",THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform float opacity;\nvarying vec3 vNormal;",THREE.ShaderChunk.common,
+THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = vec4( 0.5 * normalize( vNormal ) + 0.5, opacity );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",
+THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );",THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},equirect:{uniforms:{tEquirect:{type:"t",value:null},tFlip:{type:"f",value:-1}},vertexShader:["varying vec3 vWorldPosition;",
+THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );",THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:["uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.logdepthbuf_pars_fragment,"void main() {\nvec3 direction = normalize( vWorldPosition );\nvec2 sampleUV;\nsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\nsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\ngl_FragColor = texture2D( tEquirect, sampleUV );",
+THREE.ShaderChunk.logdepthbuf_fragment,"}"].join("\n")},depthRGBA:{uniforms:{},vertexShader:[THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,THREE.ShaderChunk.logdepthbuf_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.logdepthbuf_vertex,"}"].join("\n"),fragmentShader:[THREE.ShaderChunk.common,
+THREE.ShaderChunk.logdepthbuf_pars_fragment,"vec4 pack_depth( const in float depth ) {\n\tconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n\tconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n\tvec4 res = mod( depth * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\nvoid main() {",THREE.ShaderChunk.logdepthbuf_fragment,"\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tgl_FragData[ 0 ] = pack_depth( gl_FragDepthEXT );\n\t#else\n\t\tgl_FragData[ 0 ] = pack_depth( gl_FragCoord.z );\n\t#endif\n}"].join("\n")},
+distanceRGBA:{uniforms:{lightPos:{type:"v3",value:new THREE.Vector3(0,0,0)}},vertexShader:["varying vec4 vWorldPosition;",THREE.ShaderChunk.common,THREE.ShaderChunk.morphtarget_pars_vertex,THREE.ShaderChunk.skinning_pars_vertex,"void main() {",THREE.ShaderChunk.skinbase_vertex,THREE.ShaderChunk.begin_vertex,THREE.ShaderChunk.morphtarget_vertex,THREE.ShaderChunk.skinning_vertex,THREE.ShaderChunk.project_vertex,THREE.ShaderChunk.worldpos_vertex,"vWorldPosition = worldPosition;\n}"].join("\n"),fragmentShader:["uniform vec3 lightPos;\nvarying vec4 vWorldPosition;",
+THREE.ShaderChunk.common,"vec4 pack1K ( float depth ) {\n\tdepth /= 1000.0;\n\tconst vec4 bitSh = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n\tconst vec4 bitMsk = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n\tvec4 res = mod( depth * bitSh * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n\tres -= res.xxyz * bitMsk;\n\treturn res; \n}\nfloat unpack1K ( vec4 color ) {\n\tconst vec4 bitSh = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n\treturn dot( color, bitSh ) * 1000.0;\n}\nvoid main () {\n\tgl_FragColor = pack1K( length( vWorldPosition.xyz - lightPos.xyz ) );\n}"].join("\n")}};
+THREE.WebGLRenderer=function(a){function b(a,b,c,d){!0===Q&&(a*=d,b*=d,c*=d);I.clearColor(a,b,c,d)}function c(){I.init();I.scissor(qa.copy(xa).multiplyScalar(Z));I.viewport(ja.copy(ka).multiplyScalar(Z));b($.r,$.g,$.b,fa)}function d(){la=ma=null;na="";ra=-1;I.reset()}function e(a){a.preventDefault();d();c();T.clear()}function f(a){a=a.target;a.removeEventListener("dispose",f);a:{var b=T.get(a);if(a.image&&b.__image__webglTextureCube)r.deleteTexture(b.__image__webglTextureCube);else{if(void 0===b.__webglInit)break a;
+r.deleteTexture(b.__webglTexture)}T.delete(a)}ga.textures--}function g(a){a=a.target;a.removeEventListener("dispose",g);var b=T.get(a),c=T.get(a.texture);if(a&&void 0!==c.__webglTexture){r.deleteTexture(c.__webglTexture);if(a instanceof THREE.WebGLRenderTargetCube)for(c=0;6>c;c++)r.deleteFramebuffer(b.__webglFramebuffer[c]),r.deleteRenderbuffer(b.__webglDepthbuffer[c]);else r.deleteFramebuffer(b.__webglFramebuffer),r.deleteRenderbuffer(b.__webglDepthbuffer);T.delete(a.texture);T.delete(a)}ga.textures--}
+function h(a){a=a.target;a.removeEventListener("dispose",h);k(a);T.delete(a)}function k(a){var b=T.get(a).program;a.program=void 0;void 0!==b&&oa.releaseProgram(b)}function l(a,b){return Math.abs(b[0])-Math.abs(a[0])}function n(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function p(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:
+a.z!==b.z?b.z-a.z:a.id-b.id}function m(a,b,c,d,e){var f;c.transparent?(d=Y,f=++V):(d=J,f=++F);f=d[f];void 0!==f?(f.id=a.id,f.object=a,f.geometry=b,f.material=c,f.z=W.z,f.group=e):(f={id:a.id,object:a,geometry:b,material:c,z:W.z,group:e},d.push(f))}function q(a,b){if(!1!==a.visible){if(a.layers.test(b.layers))if(a instanceof THREE.Light)S.push(a);else if(a instanceof THREE.Sprite)!1!==a.frustumCulled&&!0!==ya.intersectsObject(a)||ca.push(a);else if(a instanceof THREE.LensFlare)ha.push(a);else if(a instanceof
+THREE.ImmediateRenderObject)!0===X.sortObjects&&(W.setFromMatrixPosition(a.matrixWorld),W.applyProjection(sa)),m(a,null,a.material,W.z,null);else if(a instanceof THREE.Mesh||a instanceof THREE.Line||a instanceof THREE.Points)if(a instanceof THREE.SkinnedMesh&&a.skeleton.update(),!1===a.frustumCulled||!0===ya.intersectsObject(a)){var c=a.material;if(!0===c.visible){!0===X.sortObjects&&(W.setFromMatrixPosition(a.matrixWorld),W.applyProjection(sa));var d=pa.update(a);if(c instanceof THREE.MultiMaterial)for(var e=
+d.groups,f=c.materials,c=0,g=e.length;c<g;c++){var h=e[c],k=f[h.materialIndex];!0===k.visible&&m(a,d,k,W.z,h)}else m(a,d,c,W.z,null)}}d=a.children;c=0;for(g=d.length;c<g;c++)q(d[c],b)}}function s(a,b,c,d){for(var e=0,f=a.length;e<f;e++){var g=a[e],h=g.object,k=g.geometry,l=void 0===d?g.material:d,g=g.group;h.modelViewMatrix.multiplyMatrices(b.matrixWorldInverse,h.matrixWorld);h.normalMatrix.getNormalMatrix(h.modelViewMatrix);if(h instanceof THREE.ImmediateRenderObject){u(l);var m=t(b,c,l,h);na="";
+h.render(function(a){X.renderBufferImmediate(a,m,l)})}else X.renderBufferDirect(b,c,k,l,h,g)}}function u(a){a.side!==THREE.DoubleSide?I.enable(r.CULL_FACE):I.disable(r.CULL_FACE);I.setFlipSided(a.side===THREE.BackSide);!0===a.transparent?I.setBlending(a.blending,a.blendEquation,a.blendSrc,a.blendDst,a.blendEquationAlpha,a.blendSrcAlpha,a.blendDstAlpha):I.setBlending(THREE.NoBlending);I.setDepthFunc(a.depthFunc);I.setDepthTest(a.depthTest);I.setDepthWrite(a.depthWrite);I.setColorWrite(a.colorWrite);
+I.setPolygonOffset(a.polygonOffset,a.polygonOffsetFactor,a.polygonOffsetUnits)}function t(a,b,c,d){ta=0;var e=T.get(c);void 0===e.program&&(c.needsUpdate=!0);void 0!==e.lightsHash&&e.lightsHash!==R.hash&&(c.needsUpdate=!0);if(c.needsUpdate){a:{var f=T.get(c),g=oa.getParameters(c,R,b,d),l=oa.getProgramCode(c,g),m=f.program,n=!0;if(void 0===m)c.addEventListener("dispose",h);else if(m.code!==l)k(c);else if(void 0!==g.shaderID)break a;else n=!1;n&&(g.shaderID?(m=THREE.ShaderLib[g.shaderID],f.__webglShader=
+{name:c.type,uniforms:THREE.UniformsUtils.clone(m.uniforms),vertexShader:m.vertexShader,fragmentShader:m.fragmentShader}):f.__webglShader={name:c.type,uniforms:c.uniforms,vertexShader:c.vertexShader,fragmentShader:c.fragmentShader},c.__webglShader=f.__webglShader,m=oa.acquireProgram(c,g,l),f.program=m,c.program=m);g=m.getAttributes();if(c.morphTargets)for(l=c.numSupportedMorphTargets=0;l<X.maxMorphTargets;l++)0<=g["morphTarget"+l]&&c.numSupportedMorphTargets++;if(c.morphNormals)for(l=c.numSupportedMorphNormals=
+0;l<X.maxMorphNormals;l++)0<=g["morphNormal"+l]&&c.numSupportedMorphNormals++;f.uniformsList=[];var g=f.__webglShader.uniforms,l=f.program.getUniforms(),q;for(q in g)(m=l[q])&&f.uniformsList.push([f.__webglShader.uniforms[q],m]);if(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshStandardMaterial||c.lights)f.lightsHash=R.hash,g.ambientLightColor.value=R.ambient,g.directionalLights.value=R.directional,g.spotLights.value=R.spot,g.pointLights.value=
+R.point,g.hemisphereLights.value=R.hemi,g.directionalShadowMap.value=R.directionalShadowMap,g.directionalShadowMatrix.value=R.directionalShadowMatrix,g.spotShadowMap.value=R.spotShadowMap,g.spotShadowMatrix.value=R.spotShadowMatrix,g.pointShadowMap.value=R.pointShadowMap,g.pointShadowMatrix.value=R.pointShadowMatrix;f.hasDynamicUniforms=!1;q=0;for(g=f.uniformsList.length;q<g;q++)if(!0===f.uniformsList[q][0].dynamic){f.hasDynamicUniforms=!0;break}}c.needsUpdate=!1}m=l=n=!1;f=e.program;q=f.getUniforms();
+g=e.__webglShader.uniforms;f.id!==ma&&(r.useProgram(f.program),ma=f.id,m=l=n=!0);c.id!==ra&&(ra=c.id,l=!0);if(n||a!==la)r.uniformMatrix4fv(q.projectionMatrix,!1,a.projectionMatrix.elements),da.logarithmicDepthBuffer&&r.uniform1f(q.logDepthBufFC,2/(Math.log(a.far+1)/Math.LN2)),a!==la&&(la=a,m=l=!0),(c instanceof THREE.ShaderMaterial||c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshStandardMaterial||c.envMap)&&void 0!==q.cameraPosition&&(W.setFromMatrixPosition(a.matrixWorld),r.uniform3f(q.cameraPosition,
+W.x,W.y,W.z)),(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshBasicMaterial||c instanceof THREE.MeshStandardMaterial||c instanceof THREE.ShaderMaterial||c.skinning)&&void 0!==q.viewMatrix&&r.uniformMatrix4fv(q.viewMatrix,!1,a.matrixWorldInverse.elements);c.skinning&&(d.bindMatrix&&void 0!==q.bindMatrix&&r.uniformMatrix4fv(q.bindMatrix,!1,d.bindMatrix.elements),d.bindMatrixInverse&&void 0!==q.bindMatrixInverse&&r.uniformMatrix4fv(q.bindMatrixInverse,
+!1,d.bindMatrixInverse.elements),da.floatVertexTextures&&d.skeleton&&d.skeleton.useVertexTexture?(void 0!==q.boneTexture&&(n=x(),r.uniform1i(q.boneTexture,n),X.setTexture(d.skeleton.boneTexture,n)),void 0!==q.boneTextureWidth&&r.uniform1i(q.boneTextureWidth,d.skeleton.boneTextureWidth),void 0!==q.boneTextureHeight&&r.uniform1i(q.boneTextureHeight,d.skeleton.boneTextureHeight)):d.skeleton&&d.skeleton.boneMatrices&&void 0!==q.boneGlobalMatrices&&r.uniformMatrix4fv(q.boneGlobalMatrices,!1,d.skeleton.boneMatrices));
+if(l){if(c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshStandardMaterial||c.lights)l=m,g.ambientLightColor.needsUpdate=l,g.directionalLights.needsUpdate=l,g.pointLights.needsUpdate=l,g.spotLights.needsUpdate=l,g.hemisphereLights.needsUpdate=l;b&&c.fog&&(g.fogColor.value=b.color,b instanceof THREE.Fog?(g.fogNear.value=b.near,g.fogFar.value=b.far):b instanceof THREE.FogExp2&&(g.fogDensity.value=b.density));if(c instanceof THREE.MeshBasicMaterial||
+c instanceof THREE.MeshLambertMaterial||c instanceof THREE.MeshPhongMaterial||c instanceof THREE.MeshStandardMaterial){g.opacity.value=c.opacity;g.diffuse.value=c.color;c.emissive&&g.emissive.value.copy(c.emissive).multiplyScalar(c.emissiveIntensity);g.map.value=c.map;g.specularMap.value=c.specularMap;g.alphaMap.value=c.alphaMap;c.aoMap&&(g.aoMap.value=c.aoMap,g.aoMapIntensity.value=c.aoMapIntensity);var p;c.map?p=c.map:c.specularMap?p=c.specularMap:c.displacementMap?p=c.displacementMap:c.normalMap?
+p=c.normalMap:c.bumpMap?p=c.bumpMap:c.roughnessMap?p=c.roughnessMap:c.metalnessMap?p=c.metalnessMap:c.alphaMap?p=c.alphaMap:c.emissiveMap&&(p=c.emissiveMap);void 0!==p&&(p instanceof THREE.WebGLRenderTarget&&(p=p.texture),b=p.offset,p=p.repeat,g.offsetRepeat.value.set(b.x,b.y,p.x,p.y));g.envMap.value=c.envMap;g.flipEnvMap.value=c.envMap instanceof THREE.WebGLRenderTargetCube?1:-1;g.reflectivity.value=c.reflectivity;g.refractionRatio.value=c.refractionRatio}c instanceof THREE.LineBasicMaterial?(g.diffuse.value=
+c.color,g.opacity.value=c.opacity):c instanceof THREE.LineDashedMaterial?(g.diffuse.value=c.color,g.opacity.value=c.opacity,g.dashSize.value=c.dashSize,g.totalSize.value=c.dashSize+c.gapSize,g.scale.value=c.scale):c instanceof THREE.PointsMaterial?(g.diffuse.value=c.color,g.opacity.value=c.opacity,g.size.value=c.size*Z,g.scale.value=K.clientHeight/2,g.map.value=c.map,null!==c.map&&(p=c.map.offset,c=c.map.repeat,g.offsetRepeat.value.set(p.x,p.y,c.x,c.y))):c instanceof THREE.MeshLambertMaterial?(c.lightMap&&
+(g.lightMap.value=c.lightMap,g.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(g.emissiveMap.value=c.emissiveMap)):c instanceof THREE.MeshPhongMaterial?(g.specular.value=c.specular,g.shininess.value=Math.max(c.shininess,1E-4),c.lightMap&&(g.lightMap.value=c.lightMap,g.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(g.emissiveMap.value=c.emissiveMap),c.bumpMap&&(g.bumpMap.value=c.bumpMap,g.bumpScale.value=c.bumpScale),c.normalMap&&(g.normalMap.value=c.normalMap,g.normalScale.value.copy(c.normalScale)),
+c.displacementMap&&(g.displacementMap.value=c.displacementMap,g.displacementScale.value=c.displacementScale,g.displacementBias.value=c.displacementBias)):c instanceof THREE.MeshStandardMaterial?(g.roughness.value=c.roughness,g.metalness.value=c.metalness,c.roughnessMap&&(g.roughnessMap.value=c.roughnessMap),c.metalnessMap&&(g.metalnessMap.value=c.metalnessMap),c.lightMap&&(g.lightMap.value=c.lightMap,g.lightMapIntensity.value=c.lightMapIntensity),c.emissiveMap&&(g.emissiveMap.value=c.emissiveMap),
+c.bumpMap&&(g.bumpMap.value=c.bumpMap,g.bumpScale.value=c.bumpScale),c.normalMap&&(g.normalMap.value=c.normalMap,g.normalScale.value.copy(c.normalScale)),c.displacementMap&&(g.displacementMap.value=c.displacementMap,g.displacementScale.value=c.displacementScale,g.displacementBias.value=c.displacementBias),c.envMap&&(g.envMapIntensity.value=c.envMapIntensity)):c instanceof THREE.MeshDepthMaterial?(g.mNear.value=a.near,g.mFar.value=a.far,g.opacity.value=c.opacity):c instanceof THREE.MeshNormalMaterial&&
+(g.opacity.value=c.opacity);v(e.uniformsList)}r.uniformMatrix4fv(q.modelViewMatrix,!1,d.modelViewMatrix.elements);q.normalMatrix&&r.uniformMatrix3fv(q.normalMatrix,!1,d.normalMatrix.elements);void 0!==q.modelMatrix&&r.uniformMatrix4fv(q.modelMatrix,!1,d.matrixWorld.elements);if(!0===e.hasDynamicUniforms){e=e.uniformsList;c=[];p=0;for(b=e.length;p<b;p++)q=e[p][0],g=q.onUpdateCallback,void 0!==g&&(g.bind(q)(d,a),c.push(e[p]));v(c)}return f}function x(){var a=ta;a>=da.maxTextures&&console.warn("WebGLRenderer: trying to use "+
+a+" texture units while this GPU supports only "+da.maxTextures);ta+=1;return a}function v(a){for(var b,c,d=0,e=a.length;d<e;d++){var g=a[d][0];if(!1!==g.needsUpdate){var f=g.type;b=g.value;var h=a[d][1];switch(f){case "1i":r.uniform1i(h,b);break;case "1f":r.uniform1f(h,b);break;case "2f":r.uniform2f(h,b[0],b[1]);break;case "3f":r.uniform3f(h,b[0],b[1],b[2]);break;case "4f":r.uniform4f(h,b[0],b[1],b[2],b[3]);break;case "1iv":r.uniform1iv(h,b);break;case "3iv":r.uniform3iv(h,b);break;case "1fv":r.uniform1fv(h,
+b);break;case "2fv":r.uniform2fv(h,b);break;case "3fv":r.uniform3fv(h,b);break;case "4fv":r.uniform4fv(h,b);break;case "Matrix2fv":r.uniformMatrix2fv(h,!1,b);break;case "Matrix3fv":r.uniformMatrix3fv(h,!1,b);break;case "Matrix4fv":r.uniformMatrix4fv(h,!1,b);break;case "i":r.uniform1i(h,b);break;case "f":r.uniform1f(h,b);break;case "v2":r.uniform2f(h,b.x,b.y);break;case "v3":r.uniform3f(h,b.x,b.y,b.z);break;case "v4":r.uniform4f(h,b.x,b.y,b.z,b.w);break;case "c":r.uniform3f(h,b.r,b.g,b.b);break;case "sa":for(f=
+0;f<b.length;f++)for(var k in g.properties){var l=h[f][k];c=b[f][k];switch(g.properties[k].type){case "i":r.uniform1i(l,c);break;case "f":r.uniform1f(l,c);break;case "v2":r.uniform2f(l,c.x,c.y);break;case "v3":r.uniform3f(l,c.x,c.y,c.z);break;case "v4":r.uniform4f(l,c.x,c.y,c.z,c.w);break;case "c":r.uniform3f(l,c.r,c.g,c.b);break;case "m4":r.uniformMatrix4fv(l,!1,c.elements)}}break;case "iv1":r.uniform1iv(h,b);break;case "iv":r.uniform3iv(h,b);break;case "fv1":r.uniform1fv(h,b);break;case "fv":r.uniform3fv(h,
+b);break;case "v2v":void 0===g._array&&(g._array=new Float32Array(2*b.length));c=f=0;for(l=b.length;f<l;f++,c+=2)g._array[c+0]=b[f].x,g._array[c+1]=b[f].y;r.uniform2fv(h,g._array);break;case "v3v":void 0===g._array&&(g._array=new Float32Array(3*b.length));c=f=0;for(l=b.length;f<l;f++,c+=3)g._array[c+0]=b[f].x,g._array[c+1]=b[f].y,g._array[c+2]=b[f].z;r.uniform3fv(h,g._array);break;case "v4v":void 0===g._array&&(g._array=new Float32Array(4*b.length));c=f=0;for(l=b.length;f<l;f++,c+=4)g._array[c+0]=
+b[f].x,g._array[c+1]=b[f].y,g._array[c+2]=b[f].z,g._array[c+3]=b[f].w;r.uniform4fv(h,g._array);break;case "m2":r.uniformMatrix2fv(h,!1,b.elements);break;case "m3":r.uniformMatrix3fv(h,!1,b.elements);break;case "m3v":void 0===g._array&&(g._array=new Float32Array(9*b.length));f=0;for(l=b.length;f<l;f++)b[f].flattenToArrayOffset(g._array,9*f);r.uniformMatrix3fv(h,!1,g._array);break;case "m4":r.uniformMatrix4fv(h,!1,b.elements);break;case "m4v":void 0===g._array&&(g._array=new Float32Array(16*b.length));
+f=0;for(l=b.length;f<l;f++)b[f].flattenToArrayOffset(g._array,16*f);r.uniformMatrix4fv(h,!1,g._array);break;case "t":c=x();r.uniform1i(h,c);if(!b)continue;b instanceof THREE.CubeTexture||Array.isArray(b.image)&&6===b.image.length?z(b,c):b instanceof THREE.WebGLRenderTargetCube?y(b.texture,c):b instanceof THREE.WebGLRenderTarget?X.setTexture(b.texture,c):X.setTexture(b,c);break;case "tv":void 0===g._array&&(g._array=[]);f=0;for(l=g.value.length;f<l;f++)g._array[f]=x();r.uniform1iv(h,g._array);f=0;
+for(l=g.value.length;f<l;f++)b=g.value[f],c=g._array[f],b&&(b instanceof THREE.CubeTexture||b.image instanceof Array&&6===b.image.length?z(b,c):b instanceof THREE.WebGLRenderTarget?X.setTexture(b.texture,c):b instanceof THREE.WebGLRenderTargetCube?y(b.texture,c):X.setTexture(b,c));break;default:console.warn("THREE.WebGLRenderer: Unknown uniform type: "+f)}}}}function C(a,b,c){c?(r.texParameteri(a,r.TEXTURE_WRAP_S,E(b.wrapS)),r.texParameteri(a,r.TEXTURE_WRAP_T,E(b.wrapT)),r.texParameteri(a,r.TEXTURE_MAG_FILTER,
+E(b.magFilter)),r.texParameteri(a,r.TEXTURE_MIN_FILTER,E(b.minFilter))):(r.texParameteri(a,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(a,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),b.wrapS===THREE.ClampToEdgeWrapping&&b.wrapT===THREE.ClampToEdgeWrapping||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",b),r.texParameteri(a,r.TEXTURE_MAG_FILTER,G(b.magFilter)),r.texParameteri(a,r.TEXTURE_MIN_FILTER,G(b.minFilter)),
+b.minFilter!==THREE.NearestFilter&&b.minFilter!==THREE.LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",b));!(c=U.get("EXT_texture_filter_anisotropic"))||b.type===THREE.FloatType&&null===U.get("OES_texture_float_linear")||b.type===THREE.HalfFloatType&&null===U.get("OES_texture_half_float_linear")||!(1<b.anisotropy||T.get(b).__currentAnisotropy)||(r.texParameterf(a,c.TEXTURE_MAX_ANISOTROPY_EXT,
+Math.min(b.anisotropy,X.getMaxAnisotropy())),T.get(b).__currentAnisotropy=b.anisotropy)}function w(a,b){if(a.width>b||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElement("canvas");d.width=Math.floor(a.width*c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a}function D(a){return THREE.Math.isPowerOfTwo(a.width)&&
+THREE.Math.isPowerOfTwo(a.height)}function z(a,b){var c=T.get(a);if(6===a.image.length)if(0<a.version&&c.__version!==a.version){c.__image__webglTextureCube||(a.addEventListener("dispose",f),c.__image__webglTextureCube=r.createTexture(),ga.textures++);I.activeTexture(r.TEXTURE0+b);I.bindTexture(r.TEXTURE_CUBE_MAP,c.__image__webglTextureCube);r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,a.flipY);for(var d=a instanceof THREE.CompressedTexture,e=a.image[0]instanceof THREE.DataTexture,g=[],h=0;6>h;h++)g[h]=!X.autoScaleCubemaps||
+d||e?e?a.image[h].image:a.image[h]:w(a.image[h],da.maxCubemapSize);var k=D(g[0]),l=E(a.format),m=E(a.type);C(r.TEXTURE_CUBE_MAP,a,k);for(h=0;6>h;h++)if(d)for(var n,q=g[h].mipmaps,p=0,s=q.length;p<s;p++)n=q[p],a.format!==THREE.RGBAFormat&&a.format!==THREE.RGBFormat?-1<I.getCompressedTextureFormats().indexOf(l)?I.compressedTexImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,p,l,n.width,n.height,0,n.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setCubeTexture()"):
+I.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,p,l,n.width,n.height,0,l,m,n.data);else e?I.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,l,g[h].width,g[h].height,0,l,m,g[h].data):I.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+h,0,l,l,m,g[h]);a.generateMipmaps&&k&&r.generateMipmap(r.TEXTURE_CUBE_MAP);c.__version=a.version;if(a.onUpdate)a.onUpdate(a)}else I.activeTexture(r.TEXTURE0+b),I.bindTexture(r.TEXTURE_CUBE_MAP,c.__image__webglTextureCube)}function y(a,b){I.activeTexture(r.TEXTURE0+b);I.bindTexture(r.TEXTURE_CUBE_MAP,
+T.get(a).__webglTexture)}function A(a,b,c,d){var e=E(b.texture.format),g=E(b.texture.type);I.texImage2D(d,0,e,b.width,b.height,0,e,g,null);r.bindFramebuffer(r.FRAMEBUFFER,a);r.framebufferTexture2D(r.FRAMEBUFFER,c,d,T.get(b.texture).__webglTexture,0);r.bindFramebuffer(r.FRAMEBUFFER,null)}function H(a,b){r.bindRenderbuffer(r.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,b.width,b.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,
+r.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,b.width,b.height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,a)):r.renderbufferStorage(r.RENDERBUFFER,r.RGBA4,b.width,b.height);r.bindRenderbuffer(r.RENDERBUFFER,null)}function G(a){return a===THREE.NearestFilter||a===THREE.NearestMipMapNearestFilter||a===THREE.NearestMipMapLinearFilter?r.NEAREST:r.LINEAR}function E(a){var b;if(a===THREE.RepeatWrapping)return r.REPEAT;
+if(a===THREE.ClampToEdgeWrapping)return r.CLAMP_TO_EDGE;if(a===THREE.MirroredRepeatWrapping)return r.MIRRORED_REPEAT;if(a===THREE.NearestFilter)return r.NEAREST;if(a===THREE.NearestMipMapNearestFilter)return r.NEAREST_MIPMAP_NEAREST;if(a===THREE.NearestMipMapLinearFilter)return r.NEAREST_MIPMAP_LINEAR;if(a===THREE.LinearFilter)return r.LINEAR;if(a===THREE.LinearMipMapNearestFilter)return r.LINEAR_MIPMAP_NEAREST;if(a===THREE.LinearMipMapLinearFilter)return r.LINEAR_MIPMAP_LINEAR;if(a===THREE.UnsignedByteType)return r.UNSIGNED_BYTE;
+if(a===THREE.UnsignedShort4444Type)return r.UNSIGNED_SHORT_4_4_4_4;if(a===THREE.UnsignedShort5551Type)return r.UNSIGNED_SHORT_5_5_5_1;if(a===THREE.UnsignedShort565Type)return r.UNSIGNED_SHORT_5_6_5;if(a===THREE.ByteType)return r.BYTE;if(a===THREE.ShortType)return r.SHORT;if(a===THREE.UnsignedShortType)return r.UNSIGNED_SHORT;if(a===THREE.IntType)return r.INT;if(a===THREE.UnsignedIntType)return r.UNSIGNED_INT;if(a===THREE.FloatType)return r.FLOAT;b=U.get("OES_texture_half_float");if(null!==b&&a===
+THREE.HalfFloatType)return b.HALF_FLOAT_OES;if(a===THREE.AlphaFormat)return r.ALPHA;if(a===THREE.RGBFormat)return r.RGB;if(a===THREE.RGBAFormat)return r.RGBA;if(a===THREE.LuminanceFormat)return r.LUMINANCE;if(a===THREE.LuminanceAlphaFormat)return r.LUMINANCE_ALPHA;if(a===THREE.AddEquation)return r.FUNC_ADD;if(a===THREE.SubtractEquation)return r.FUNC_SUBTRACT;if(a===THREE.ReverseSubtractEquation)return r.FUNC_REVERSE_SUBTRACT;if(a===THREE.ZeroFactor)return r.ZERO;if(a===THREE.OneFactor)return r.ONE;
+if(a===THREE.SrcColorFactor)return r.SRC_COLOR;if(a===THREE.OneMinusSrcColorFactor)return r.ONE_MINUS_SRC_COLOR;if(a===THREE.SrcAlphaFactor)return r.SRC_ALPHA;if(a===THREE.OneMinusSrcAlphaFactor)return r.ONE_MINUS_SRC_ALPHA;if(a===THREE.DstAlphaFactor)return r.DST_ALPHA;if(a===THREE.OneMinusDstAlphaFactor)return r.ONE_MINUS_DST_ALPHA;if(a===THREE.DstColorFactor)return r.DST_COLOR;if(a===THREE.OneMinusDstColorFactor)return r.ONE_MINUS_DST_COLOR;if(a===THREE.SrcAlphaSaturateFactor)return r.SRC_ALPHA_SATURATE;
+b=U.get("WEBGL_compressed_texture_s3tc");if(null!==b){if(a===THREE.RGB_S3TC_DXT1_Format)return b.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT1_Format)return b.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===THREE.RGBA_S3TC_DXT3_Format)return b.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===THREE.RGBA_S3TC_DXT5_Format)return b.COMPRESSED_RGBA_S3TC_DXT5_EXT}b=U.get("WEBGL_compressed_texture_pvrtc");if(null!==b){if(a===THREE.RGB_PVRTC_4BPPV1_Format)return b.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===THREE.RGB_PVRTC_2BPPV1_Format)return b.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;
+if(a===THREE.RGBA_PVRTC_4BPPV1_Format)return b.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===THREE.RGBA_PVRTC_2BPPV1_Format)return b.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}b=U.get("WEBGL_compressed_texture_etc1");if(null!==b&&a===THREE.RGB_ETC1_Format)return b.COMPRESSED_RGB_ETC1_WEBGL;b=U.get("EXT_blend_minmax");if(null!==b){if(a===THREE.MinEquation)return b.MIN_EXT;if(a===THREE.MaxEquation)return b.MAX_EXT}return 0}console.log("THREE.WebGLRenderer",THREE.REVISION);a=a||{};var K=void 0!==a.canvas?a.canvas:document.createElement("canvas"),
+P=void 0!==a.context?a.context:null,N=void 0!==a.alpha?a.alpha:!1,L=void 0!==a.depth?a.depth:!0,B=void 0!==a.stencil?a.stencil:!0,M=void 0!==a.antialias?a.antialias:!1,Q=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,O=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,S=[],J=[],F=-1,Y=[],V=-1,aa=new Float32Array(8),ca=[],ha=[];this.domElement=K;this.context=null;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.gammaFactor=2;this.gammaOutput=
+this.gammaInput=!1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;var X=this,ma=null,ia=null,ba=null,ra=-1,na="",la=null,qa=new THREE.Vector4,za=null,ja=new THREE.Vector4,ta=0,$=new THREE.Color(0),fa=0,ua=K.width,va=K.height,Z=1,xa=new THREE.Vector4(0,0,ua,va),Aa=!1,ka=new THREE.Vector4(0,0,ua,va),ya=new THREE.Frustum,sa=new THREE.Matrix4,W=new THREE.Vector3,R={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],
+spotShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],shadows:[],shadowsPointLight:0},ga={geometries:0,textures:0},ea={calls:0,vertices:0,faces:0,points:0};this.info={render:ea,memory:ga,programs:null};var r;try{N={alpha:N,depth:L,stencil:B,antialias:M,premultipliedAlpha:Q,preserveDrawingBuffer:O};r=P||K.getContext("webgl",N)||K.getContext("experimental-webgl",N);if(null===r){if(null!==K.getContext("webgl"))throw"Error creating WebGL context with your selected attributes.";throw"Error creating WebGL context.";
+}K.addEventListener("webglcontextlost",e,!1)}catch(Ca){console.error("THREE.WebGLRenderer: "+Ca)}var U=new THREE.WebGLExtensions(r);U.get("OES_texture_float");U.get("OES_texture_float_linear");U.get("OES_texture_half_float");U.get("OES_texture_half_float_linear");U.get("OES_standard_derivatives");U.get("ANGLE_instanced_arrays");U.get("OES_element_index_uint")&&(THREE.BufferGeometry.MaxIndex=4294967296);var da=new THREE.WebGLCapabilities(r,U,a),I=new THREE.WebGLState(r,U,E),T=new THREE.WebGLProperties,
+pa=new THREE.WebGLObjects(r,T,this.info),oa=new THREE.WebGLPrograms(this,da),wa=new THREE.WebGLLights;this.info.programs=oa.programs;var Da=new THREE.WebGLBufferRenderer(r,U,ea),Ea=new THREE.WebGLIndexedBufferRenderer(r,U,ea);c();this.context=r;this.capabilities=da;this.extensions=U;this.properties=T;this.state=I;var Ba=new THREE.WebGLShadowMap(this,R,pa);this.shadowMap=Ba;var Fa=new THREE.SpritePlugin(this,ca),Ga=new THREE.LensFlarePlugin(this,ha);this.getContext=function(){return r};this.getContextAttributes=
+function(){return r.getContextAttributes()};this.forceContextLoss=function(){U.get("WEBGL_lose_context").loseContext()};this.getMaxAnisotropy=function(){var a;return function(){if(void 0!==a)return a;var b=U.get("EXT_texture_filter_anisotropic");return a=null!==b?r.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}}();this.getPrecision=function(){return da.precision};this.getPixelRatio=function(){return Z};this.setPixelRatio=function(a){void 0!==a&&(Z=a,this.setSize(ka.z,ka.w,!1))};this.getSize=function(){return{width:ua,
+height:va}};this.setSize=function(a,b,c){ua=a;va=b;K.width=a*Z;K.height=b*Z;!1!==c&&(K.style.width=a+"px",K.style.height=b+"px");this.setViewport(0,0,a,b)};this.setViewport=function(a,b,c,d){I.viewport(ka.set(a,b,c,d))};this.setScissor=function(a,b,c,d){I.scissor(xa.set(a,b,c,d))};this.setScissorTest=function(a){I.setScissorTest(Aa=a)};this.getClearColor=function(){return $};this.setClearColor=function(a,c){$.set(a);fa=void 0!==c?c:1;b($.r,$.g,$.b,fa)};this.getClearAlpha=function(){return fa};this.setClearAlpha=
+function(a){fa=a;b($.r,$.g,$.b,fa)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=r.COLOR_BUFFER_BIT;if(void 0===b||b)d|=r.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=r.STENCIL_BUFFER_BIT;r.clear(d)};this.clearColor=function(){this.clear(!0,!1,!1)};this.clearDepth=function(){this.clear(!1,!0,!1)};this.clearStencil=function(){this.clear(!1,!1,!0)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.resetGLState=d;this.dispose=function(){K.removeEventListener("webglcontextlost",
+e,!1)};this.renderBufferImmediate=function(a,b,c){I.initAttributes();var d=T.get(a);a.hasPositions&&!d.position&&(d.position=r.createBuffer());a.hasNormals&&!d.normal&&(d.normal=r.createBuffer());a.hasUvs&&!d.uv&&(d.uv=r.createBuffer());a.hasColors&&!d.color&&(d.color=r.createBuffer());b=b.getAttributes();a.hasPositions&&(r.bindBuffer(r.ARRAY_BUFFER,d.position),r.bufferData(r.ARRAY_BUFFER,a.positionArray,r.DYNAMIC_DRAW),I.enableAttribute(b.position),r.vertexAttribPointer(b.position,3,r.FLOAT,!1,0,
+0));if(a.hasNormals){r.bindBuffer(r.ARRAY_BUFFER,d.normal);if("MeshPhongMaterial"!==c.type&&"MeshStandardMaterial"!==c.type&&c.shading===THREE.FlatShading)for(var e=0,g=3*a.count;e<g;e+=9){var f=a.normalArray,h=(f[e+0]+f[e+3]+f[e+6])/3,k=(f[e+1]+f[e+4]+f[e+7])/3,l=(f[e+2]+f[e+5]+f[e+8])/3;f[e+0]=h;f[e+1]=k;f[e+2]=l;f[e+3]=h;f[e+4]=k;f[e+5]=l;f[e+6]=h;f[e+7]=k;f[e+8]=l}r.bufferData(r.ARRAY_BUFFER,a.normalArray,r.DYNAMIC_DRAW);I.enableAttribute(b.normal);r.vertexAttribPointer(b.normal,3,r.FLOAT,!1,
+0,0)}a.hasUvs&&c.map&&(r.bindBuffer(r.ARRAY_BUFFER,d.uv),r.bufferData(r.ARRAY_BUFFER,a.uvArray,r.DYNAMIC_DRAW),I.enableAttribute(b.uv),r.vertexAttribPointer(b.uv,2,r.FLOAT,!1,0,0));a.hasColors&&c.vertexColors!==THREE.NoColors&&(r.bindBuffer(r.ARRAY_BUFFER,d.color),r.bufferData(r.ARRAY_BUFFER,a.colorArray,r.DYNAMIC_DRAW),I.enableAttribute(b.color),r.vertexAttribPointer(b.color,3,r.FLOAT,!1,0,0));I.disableUnusedAttributes();r.drawArrays(r.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,
+b,c,d,e,f){u(d);var g=t(a,b,d,e),h=!1;a=c.id+"_"+g.id+"_"+d.wireframe;a!==na&&(na=a,h=!0);b=e.morphTargetInfluences;if(void 0!==b){a=[];for(var k=0,h=b.length;k<h;k++){var m=b[k];a.push([m,k])}a.sort(l);8<a.length&&(a.length=8);for(var n=c.morphAttributes,k=0,h=a.length;k<h;k++)m=a[k],aa[k]=m[0],0!==m[0]?(b=m[1],!0===d.morphTargets&&n.position&&c.addAttribute("morphTarget"+k,n.position[b]),!0===d.morphNormals&&n.normal&&c.addAttribute("morphNormal"+k,n.normal[b])):(!0===d.morphTargets&&c.removeAttribute("morphTarget"+
+k),!0===d.morphNormals&&c.removeAttribute("morphNormal"+k));a=g.getUniforms();null!==a.morphTargetInfluences&&r.uniform1fv(a.morphTargetInfluences,aa);h=!0}b=c.index;k=c.attributes.position;!0===d.wireframe&&(b=pa.getWireframeAttribute(c));null!==b?(a=Ea,a.setIndex(b)):a=Da;if(h){a:{var h=void 0,q;if(c instanceof THREE.InstancedBufferGeometry&&(q=U.get("ANGLE_instanced_arrays"),null===q)){console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
+break a}void 0===h&&(h=0);I.initAttributes();var m=c.attributes,g=g.getAttributes(),n=d.defaultAttributeValues,p;for(p in g){var s=g[p];if(0<=s){var x=m[p];if(void 0!==x){var v=x.itemSize,w=pa.getAttributeBuffer(x);if(x instanceof THREE.InterleavedBufferAttribute){var C=x.data,V=C.stride,x=x.offset;C instanceof THREE.InstancedInterleavedBuffer?(I.enableAttributeAndDivisor(s,C.meshPerAttribute,q),void 0===c.maxInstancedCount&&(c.maxInstancedCount=C.meshPerAttribute*C.count)):I.enableAttribute(s);r.bindBuffer(r.ARRAY_BUFFER,
+w);r.vertexAttribPointer(s,v,r.FLOAT,!1,V*C.array.BYTES_PER_ELEMENT,(h*V+x)*C.array.BYTES_PER_ELEMENT)}else x instanceof THREE.InstancedBufferAttribute?(I.enableAttributeAndDivisor(s,x.meshPerAttribute,q),void 0===c.maxInstancedCount&&(c.maxInstancedCount=x.meshPerAttribute*x.count)):I.enableAttribute(s),r.bindBuffer(r.ARRAY_BUFFER,w),r.vertexAttribPointer(s,v,r.FLOAT,!1,0,h*v*4)}else if(void 0!==n&&(v=n[p],void 0!==v))switch(v.length){case 2:r.vertexAttrib2fv(s,v);break;case 3:r.vertexAttrib3fv(s,
+v);break;case 4:r.vertexAttrib4fv(s,v);break;default:r.vertexAttrib1fv(s,v)}}}I.disableUnusedAttributes()}null!==b&&r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,pa.getAttributeBuffer(b))}q=Infinity;null!==b?q=b.count:void 0!==k&&(q=k.count);p=c.drawRange.start;b=c.drawRange.count;k=null!==f?f.start:0;h=null!==f?f.count:Infinity;f=Math.max(0,p,k);q=Math.min(0+q,p+b,k+h)-1;q=Math.max(0,q-f+1);if(e instanceof THREE.Mesh)if(!0===d.wireframe)I.setLineWidth(d.wireframeLinewidth*(null===ia?Z:1)),a.setMode(r.LINES);
+else switch(e.drawMode){case THREE.TrianglesDrawMode:a.setMode(r.TRIANGLES);break;case THREE.TriangleStripDrawMode:a.setMode(r.TRIANGLE_STRIP);break;case THREE.TriangleFanDrawMode:a.setMode(r.TRIANGLE_FAN)}else e instanceof THREE.Line?(d=d.linewidth,void 0===d&&(d=1),I.setLineWidth(d*(null===ia?Z:1)),e instanceof THREE.LineSegments?a.setMode(r.LINES):a.setMode(r.LINE_STRIP)):e instanceof THREE.Points&&a.setMode(r.POINTS);c instanceof THREE.InstancedBufferGeometry&&0<c.maxInstancedCount?a.renderInstances(c,
+f,q):a.render(f,q)};this.render=function(a,b,c,d){if(!1===b instanceof THREE.Camera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else{var e=a.fog;na="";ra=-1;la=null;!0===a.autoUpdate&&a.updateMatrixWorld();null===b.parent&&b.updateMatrixWorld();b.matrixWorldInverse.getInverse(b.matrixWorld);sa.multiplyMatrices(b.projectionMatrix,b.matrixWorldInverse);ya.setFromMatrix(sa);S.length=0;V=F=-1;ca.length=0;ha.length=0;q(a,b);J.length=F+1;Y.length=V+1;!0===X.sortObjects&&
+(J.sort(n),Y.sort(p));var f=S,g,h,k,l=0,m=0,x=0,t,v,u,w=b.matrixWorldInverse,C=0,y=0,z=0,A=0,E=0;g=R.shadowsPointLight=0;for(h=f.length;g<h;g++)if(k=f[g],t=k.color,v=k.intensity,u=k.distance,k instanceof THREE.AmbientLight)l+=t.r*v,m+=t.g*v,x+=t.b*v;else if(k instanceof THREE.DirectionalLight){var B=wa.get(k);B.color.copy(k.color).multiplyScalar(k.intensity);B.direction.setFromMatrixPosition(k.matrixWorld);W.setFromMatrixPosition(k.target.matrixWorld);B.direction.sub(W);B.direction.transformDirection(w);
+if(B.shadow=k.castShadow)B.shadowBias=k.shadow.bias,B.shadowRadius=k.shadow.radius,B.shadowMapSize=k.shadow.mapSize,R.shadows[E++]=k;R.directionalShadowMap[C]=k.shadow.map;R.directionalShadowMatrix[C]=k.shadow.matrix;R.directional[C++]=B}else if(k instanceof THREE.SpotLight){B=wa.get(k);B.position.setFromMatrixPosition(k.matrixWorld);B.position.applyMatrix4(w);B.color.copy(t).multiplyScalar(v);B.distance=u;B.direction.setFromMatrixPosition(k.matrixWorld);W.setFromMatrixPosition(k.target.matrixWorld);
+B.direction.sub(W);B.direction.transformDirection(w);B.angleCos=Math.cos(k.angle);B.penumbra=Math.cos(k.angle)*k.penumbra;B.decay=0===k.distance?0:k.decay;if(B.shadow=k.castShadow)B.shadowBias=k.shadow.bias,B.shadowRadius=k.shadow.radius,B.shadowMapSize=k.shadow.mapSize,R.shadows[E++]=k;R.spotShadowMap[z]=k.shadow.map;R.spotShadowMatrix[z]=k.shadow.matrix;R.spot[z++]=B}else if(k instanceof THREE.PointLight){B=wa.get(k);B.position.setFromMatrixPosition(k.matrixWorld);B.position.applyMatrix4(w);B.color.copy(k.color).multiplyScalar(k.intensity);
+B.distance=k.distance;B.decay=0===k.distance?0:k.decay;if(B.shadow=k.castShadow)B.shadowBias=k.shadow.bias,B.shadowRadius=k.shadow.radius,B.shadowMapSize=k.shadow.mapSize,R.shadows[E++]=k;R.pointShadowMap[y]=k.shadow.map;void 0===R.pointShadowMatrix[y]&&(R.pointShadowMatrix[y]=new THREE.Matrix4);W.setFromMatrixPosition(k.matrixWorld).negate();R.pointShadowMatrix[y].identity().setPosition(W);R.point[y++]=B}else k instanceof THREE.HemisphereLight&&(B=wa.get(k),B.direction.setFromMatrixPosition(k.matrixWorld),
+B.direction.transformDirection(w),B.direction.normalize(),B.skyColor.copy(k.color).multiplyScalar(v),B.groundColor.copy(k.groundColor).multiplyScalar(v),R.hemi[A++]=B);R.ambient[0]=l;R.ambient[1]=m;R.ambient[2]=x;R.directional.length=C;R.spot.length=z;R.point.length=y;R.hemi.length=A;R.shadows.length=E;R.hash=C+","+y+","+z+","+A+","+E;Ba.render(a,b);ea.calls=0;ea.vertices=0;ea.faces=0;ea.points=0;void 0===c&&(c=null);this.setRenderTarget(c);(this.autoClear||d)&&this.clear(this.autoClearColor,this.autoClearDepth,
+this.autoClearStencil);a.overrideMaterial?(d=a.overrideMaterial,s(J,b,e,d),s(Y,b,e,d)):(I.setBlending(THREE.NoBlending),s(J,b,e),s(Y,b,e));Fa.render(a,b);Ga.render(a,b,ja);c&&(a=c.texture,a.generateMipmaps&&D(c)&&a.minFilter!==THREE.NearestFilter&&a.minFilter!==THREE.LinearFilter&&(a=c instanceof THREE.WebGLRenderTargetCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D,c=T.get(c.texture).__webglTexture,I.bindTexture(a,c),r.generateMipmap(a),I.bindTexture(a,null)));I.setDepthTest(!0);I.setDepthWrite(!0);I.setColorWrite(!0)}};
+this.setFaceCulling=function(a,b){a===THREE.CullFaceNone?I.disable(r.CULL_FACE):(b===THREE.FrontFaceDirectionCW?r.frontFace(r.CW):r.frontFace(r.CCW),a===THREE.CullFaceBack?r.cullFace(r.BACK):a===THREE.CullFaceFront?r.cullFace(r.FRONT):r.cullFace(r.FRONT_AND_BACK),I.enable(r.CULL_FACE))};this.setTexture=function(a,b){var c=T.get(a);if(0<a.version&&c.__version!==a.version){var d=a.image;if(void 0===d)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",a);else if(!1===
+d.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",a);else{void 0===c.__webglInit&&(c.__webglInit=!0,a.addEventListener("dispose",f),c.__webglTexture=r.createTexture(),ga.textures++);I.activeTexture(r.TEXTURE0+b);I.bindTexture(r.TEXTURE_2D,c.__webglTexture);r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,a.flipY);r.pixelStorei(r.UNPACK_PREMULTIPLY_ALPHA_WEBGL,a.premultiplyAlpha);r.pixelStorei(r.UNPACK_ALIGNMENT,a.unpackAlignment);var e=w(a.image,da.maxTextureSize);
+if((a.wrapS!==THREE.ClampToEdgeWrapping||a.wrapT!==THREE.ClampToEdgeWrapping||a.minFilter!==THREE.NearestFilter&&a.minFilter!==THREE.LinearFilter)&&!1===D(e))if(d=e,d instanceof HTMLImageElement||d instanceof HTMLCanvasElement){var g=document.createElement("canvas");g.width=THREE.Math.nearestPowerOfTwo(d.width);g.height=THREE.Math.nearestPowerOfTwo(d.height);g.getContext("2d").drawImage(d,0,0,g.width,g.height);console.warn("THREE.WebGLRenderer: image is not power of two ("+d.width+"x"+d.height+"). Resized to "+
+g.width+"x"+g.height,d);e=g}else e=d;var d=D(e),g=E(a.format),h=E(a.type);C(r.TEXTURE_2D,a,d);var k=a.mipmaps;if(a instanceof THREE.DataTexture)if(0<k.length&&d){for(var l=0,m=k.length;l<m;l++)e=k[l],I.texImage2D(r.TEXTURE_2D,l,g,e.width,e.height,0,g,h,e.data);a.generateMipmaps=!1}else I.texImage2D(r.TEXTURE_2D,0,g,e.width,e.height,0,g,h,e.data);else if(a instanceof THREE.CompressedTexture)for(l=0,m=k.length;l<m;l++)e=k[l],a.format!==THREE.RGBAFormat&&a.format!==THREE.RGBFormat?-1<I.getCompressedTextureFormats().indexOf(g)?
+I.compressedTexImage2D(r.TEXTURE_2D,l,g,e.width,e.height,0,e.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):I.texImage2D(r.TEXTURE_2D,l,g,e.width,e.height,0,g,h,e.data);else if(0<k.length&&d){l=0;for(m=k.length;l<m;l++)e=k[l],I.texImage2D(r.TEXTURE_2D,l,g,g,h,e);a.generateMipmaps=!1}else I.texImage2D(r.TEXTURE_2D,0,g,g,h,e);a.generateMipmaps&&d&&r.generateMipmap(r.TEXTURE_2D);c.__version=a.version;if(a.onUpdate)a.onUpdate(a)}}else I.activeTexture(r.TEXTURE0+
+b),I.bindTexture(r.TEXTURE_2D,c.__webglTexture)};this.setRenderTarget=function(a){if((ia=a)&&void 0===T.get(a).__webglFramebuffer){var b=T.get(a),c=T.get(a.texture);a.addEventListener("dispose",g);c.__webglTexture=r.createTexture();ga.textures++;var d=a instanceof THREE.WebGLRenderTargetCube,e=THREE.Math.isPowerOfTwo(a.width)&&THREE.Math.isPowerOfTwo(a.height);if(d){b.__webglFramebuffer=[];for(var f=0;6>f;f++)b.__webglFramebuffer[f]=r.createFramebuffer()}else b.__webglFramebuffer=r.createFramebuffer();
+if(d){I.bindTexture(r.TEXTURE_CUBE_MAP,c.__webglTexture);C(r.TEXTURE_CUBE_MAP,a.texture,e);for(f=0;6>f;f++)A(b.__webglFramebuffer[f],a,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+f);a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_CUBE_MAP);I.bindTexture(r.TEXTURE_CUBE_MAP,null)}else I.bindTexture(r.TEXTURE_2D,c.__webglTexture),C(r.TEXTURE_2D,a.texture,e),A(b.__webglFramebuffer,a,r.COLOR_ATTACHMENT0,r.TEXTURE_2D),a.texture.generateMipmaps&&e&&r.generateMipmap(r.TEXTURE_2D),I.bindTexture(r.TEXTURE_2D,
+null);if(a.depthBuffer){b=T.get(a);if(a instanceof THREE.WebGLRenderTargetCube)for(b.__webglDepthbuffer=[],c=0;6>c;c++)r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer[c]),b.__webglDepthbuffer[c]=r.createRenderbuffer(),H(b.__webglDepthbuffer[c],a);else r.bindFramebuffer(r.FRAMEBUFFER,b.__webglFramebuffer),b.__webglDepthbuffer=r.createRenderbuffer(),H(b.__webglDepthbuffer,a);r.bindFramebuffer(r.FRAMEBUFFER,null)}}b=a instanceof THREE.WebGLRenderTargetCube;a?(c=T.get(a),c=b?c.__webglFramebuffer[a.activeCubeFace]:
+c.__webglFramebuffer,qa.copy(a.scissor),za=a.scissorTest,ja.copy(a.viewport)):(c=null,qa.copy(xa).multiplyScalar(Z),za=Aa,ja.copy(ka).multiplyScalar(Z));ba!==c&&(r.bindFramebuffer(r.FRAMEBUFFER,c),ba=c);I.scissor(qa);I.setScissorTest(za);I.viewport(ja);b&&(b=T.get(a.texture),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,b.__webglTexture,0))};this.readRenderTargetPixels=function(a,b,c,d,e,g){if(!1===a instanceof THREE.WebGLRenderTarget)console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");
+else{var f=T.get(a).__webglFramebuffer;if(f){var h=!1;f!==ba&&(r.bindFramebuffer(r.FRAMEBUFFER,f),h=!0);try{var k=a.texture;k.format!==THREE.RGBAFormat&&E(k.format)!==r.getParameter(r.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):k.type===THREE.UnsignedByteType||E(k.type)===r.getParameter(r.IMPLEMENTATION_COLOR_READ_TYPE)||k.type===THREE.FloatType&&U.get("WEBGL_color_buffer_float")||k.type===
+THREE.HalfFloatType&&U.get("EXT_color_buffer_half_float")?r.checkFramebufferStatus(r.FRAMEBUFFER)===r.FRAMEBUFFER_COMPLETE?r.readPixels(b,c,d,e,E(k.format),E(k.type),g):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{h&&r.bindFramebuffer(r.FRAMEBUFFER,ba)}}}}};
+THREE.WebGLRenderTarget=function(a,b,c){this.uuid=THREE.Math.generateUUID();this.width=a;this.height=b;this.scissor=new THREE.Vector4(0,0,a,b);this.scissorTest=!1;this.viewport=new THREE.Vector4(0,0,a,b);c=c||{};void 0===c.minFilter&&(c.minFilter=THREE.LinearFilter);this.texture=new THREE.Texture(void 0,void 0,c.wrapS,c.wrapT,c.magFilter,c.minFilter,c.format,c.type,c.anisotropy);this.depthBuffer=void 0!==c.depthBuffer?c.depthBuffer:!0;this.stencilBuffer=void 0!==c.stencilBuffer?c.stencilBuffer:!0};
+THREE.WebGLRenderTarget.prototype={constructor:THREE.WebGLRenderTarget,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.shareDepthFrom=a.shareDepthFrom;
+return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};THREE.EventDispatcher.prototype.apply(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube=function(a,b,c){THREE.WebGLRenderTarget.call(this,a,b,c);this.activeCubeFace=0};THREE.WebGLRenderTargetCube.prototype=Object.create(THREE.WebGLRenderTarget.prototype);THREE.WebGLRenderTargetCube.prototype.constructor=THREE.WebGLRenderTargetCube;
+THREE.WebGLBufferRenderer=function(a,b,c){var d;this.setMode=function(a){d=a};this.render=function(b,f){a.drawArrays(d,b,f);c.calls++;c.vertices+=f;d===a.TRIANGLES&&(c.faces+=f/3)};this.renderInstances=function(e){var f=b.get("ANGLE_instanced_arrays");if(null===f)console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");else{var g=e.attributes.position,h=0,h=g instanceof THREE.InterleavedBufferAttribute?g.data.count:
+g.count;f.drawArraysInstancedANGLE(d,0,h,e.maxInstancedCount);c.calls++;c.vertices+=h*e.maxInstancedCount;d===a.TRIANGLES&&(c.faces+=e.maxInstancedCount*h/3)}}};
+THREE.WebGLIndexedBufferRenderer=function(a,b,c){var d,e,f;this.setMode=function(a){d=a};this.setIndex=function(c){c.array instanceof Uint32Array&&b.get("OES_element_index_uint")?(e=a.UNSIGNED_INT,f=4):(e=a.UNSIGNED_SHORT,f=2)};this.render=function(b,h){a.drawElements(d,h,e,b*f);c.calls++;c.vertices+=h;d===a.TRIANGLES&&(c.faces+=h/3)};this.renderInstances=function(g,h,k){var l=b.get("ANGLE_instanced_arrays");null===l?console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."):
+(l.drawElementsInstancedANGLE(d,k,e,h*f,g.maxInstancedCount),c.calls++,c.vertices+=k*g.maxInstancedCount,d===a.TRIANGLES&&(c.faces+=g.maxInstancedCount*k/3))}};
+THREE.WebGLExtensions=function(a){var b={};this.get=function(c){if(void 0!==b[c])return b[c];var d;switch(c){case "EXT_texture_filter_anisotropic":d=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":d=a.getExtension("WEBGL_compressed_texture_s3tc")||a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");
+break;case "WEBGL_compressed_texture_pvrtc":d=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case "WEBGL_compressed_texture_etc1":d=a.getExtension("WEBGL_compressed_texture_etc1");break;default:d=a.getExtension(c)}null===d&&console.warn("THREE.WebGLRenderer: "+c+" extension not supported.");return b[c]=d}};
+THREE.WebGLCapabilities=function(a,b,c){function d(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision)return"highp";b="mediump"}return"mediump"===b&&0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision?"mediump":"lowp"}this.getMaxPrecision=d;this.precision=void 0!==c.precision?c.precision:"highp";
+this.logarithmicDepthBuffer=void 0!==c.logarithmicDepthBuffer?c.logarithmicDepthBuffer:!1;this.maxTextures=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);this.maxVertexTextures=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS);this.maxTextureSize=a.getParameter(a.MAX_TEXTURE_SIZE);this.maxCubemapSize=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE);this.maxAttributes=a.getParameter(a.MAX_VERTEX_ATTRIBS);this.maxVertexUniforms=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS);this.maxVaryings=a.getParameter(a.MAX_VARYING_VECTORS);
+this.maxFragmentUniforms=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS);this.vertexTextures=0<this.maxVertexTextures;this.floatFragmentTextures=!!b.get("OES_texture_float");this.floatVertexTextures=this.vertexTextures&&this.floatFragmentTextures;c=d(this.precision);c!==this.precision&&(console.warn("THREE.WebGLRenderer:",this.precision,"not supported, using",c,"instead."),this.precision=c);this.logarithmicDepthBuffer&&(this.logarithmicDepthBuffer=!!b.get("EXT_frag_depth"))};
+THREE.WebGLGeometries=function(a,b,c){function d(a){var h=a.target;a=f[h.id];null!==a.index&&e(a.index);var k=a.attributes,l;for(l in k)e(k[l]);h.removeEventListener("dispose",d);delete f[h.id];l=b.get(h);l.wireframe&&e(l.wireframe);b.delete(h);h=b.get(a);h.wireframe&&e(h.wireframe);b.delete(a);c.memory.geometries--}function e(c){var d;d=c instanceof THREE.InterleavedBufferAttribute?b.get(c.data).__webglBuffer:b.get(c).__webglBuffer;void 0!==d&&(a.deleteBuffer(d),c instanceof THREE.InterleavedBufferAttribute?
+b.delete(c.data):b.delete(c))}var f={};this.get=function(a){var b=a.geometry;if(void 0!==f[b.id])return f[b.id];b.addEventListener("dispose",d);var e;b instanceof THREE.BufferGeometry?e=b:b instanceof THREE.Geometry&&(void 0===b._bufferGeometry&&(b._bufferGeometry=(new THREE.BufferGeometry).setFromObject(a)),e=b._bufferGeometry);f[b.id]=e;c.memory.geometries++;return e}};
+THREE.WebGLLights=function(){var a={};this.get=function(b){if(void 0!==a[b.id])return a[b.id];var c;switch(b.type){case "DirectionalLight":c={direction:new THREE.Vector3,color:new THREE.Color,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new THREE.Vector2};break;case "SpotLight":c={position:new THREE.Vector3,direction:new THREE.Vector3,color:new THREE.Color,distance:0,angleCos:0,penumbra:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new THREE.Vector2};break;case "PointLight":c=
+{position:new THREE.Vector3,color:new THREE.Color,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new THREE.Vector2};break;case "HemisphereLight":c={direction:new THREE.Vector3,skyColor:new THREE.Color,groundColor:new THREE.Color}}return a[b.id]=c}};
+THREE.WebGLObjects=function(a,b,c){function d(c,d){var e=c instanceof THREE.InterleavedBufferAttribute?c.data:c,f=b.get(e);void 0===f.__webglBuffer?(f.__webglBuffer=a.createBuffer(),a.bindBuffer(d,f.__webglBuffer),a.bufferData(d,e.array,e.dynamic?a.DYNAMIC_DRAW:a.STATIC_DRAW),f.version=e.version):f.version!==e.version&&(a.bindBuffer(d,f.__webglBuffer),!1===e.dynamic||-1===e.updateRange.count?a.bufferSubData(d,0,e.array):0===e.updateRange.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):
+(a.bufferSubData(d,e.updateRange.offset*e.array.BYTES_PER_ELEMENT,e.array.subarray(e.updateRange.offset,e.updateRange.offset+e.updateRange.count)),e.updateRange.count=0),f.version=e.version)}function e(a,b,c){if(b>c){var d=b;b=c;c=d}d=a[b];return void 0===d?(a[b]=[c],!0):-1===d.indexOf(c)?(d.push(c),!0):!1}var f=new THREE.WebGLGeometries(a,b,c);this.getAttributeBuffer=function(a){return a instanceof THREE.InterleavedBufferAttribute?b.get(a.data).__webglBuffer:b.get(a).__webglBuffer};this.getWireframeAttribute=
+function(c){var f=b.get(c);if(void 0!==f.wireframe)return f.wireframe;var k=[],l=c.index,n=c.attributes;c=n.position;if(null!==l)for(var n={},l=l.array,p=0,m=l.length;p<m;p+=3){var q=l[p+0],s=l[p+1],u=l[p+2];e(n,q,s)&&k.push(q,s);e(n,s,u)&&k.push(s,u);e(n,u,q)&&k.push(u,q)}else for(l=n.position.array,p=0,m=l.length/3-1;p<m;p+=3)q=p+0,s=p+1,u=p+2,k.push(q,s,s,u,u,q);k=new THREE.BufferAttribute(new (65535<c.count?Uint32Array:Uint16Array)(k),1);d(k,a.ELEMENT_ARRAY_BUFFER);return f.wireframe=k};this.update=
+function(b){var c=f.get(b);b.geometry instanceof THREE.Geometry&&c.updateFromObject(b);b=c.index;var e=c.attributes;null!==b&&d(b,a.ELEMENT_ARRAY_BUFFER);for(var l in e)d(e[l],a.ARRAY_BUFFER);b=c.morphAttributes;for(l in b)for(var e=b[l],n=0,p=e.length;n<p;n++)d(e[n],a.ARRAY_BUFFER);return c}};
+THREE.WebGLProgram=function(){function a(a,b,d){a=a||{};return[a.derivatives||b.bumpMap||b.normalMap||b.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(a.fragDepth||b.logarithmicDepthBuffer)&&d.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":"",a.drawBuffers&&d.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(a.shaderTextureLOD||b.envMap)&&d.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(c).join("\n")}
+function b(a){var b=[],c;for(c in a){var d=a[c];!1!==d&&b.push("#define "+c+" "+d)}return b.join("\n")}function c(a){return""!==a}function d(a,b){return a.replace(/NUM_DIR_LIGHTS/g,b.numDirLights).replace(/NUM_SPOT_LIGHTS/g,b.numSpotLights).replace(/NUM_POINT_LIGHTS/g,b.numPointLights).replace(/NUM_HEMI_LIGHTS/g,b.numHemiLights)}function e(a){return a.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,b,c,d){a="";for(b=parseInt(b);b<parseInt(c);b++)a+=d.replace(/\[ i \]/g,
+"[ "+b+" ]");return a})}var f=0,g=/^([\w\d_]+)\.([\w\d_]+)$/,h=/^([\w\d_]+)\[(\d+)\]\.([\w\d_]+)$/,k=/^([\w\d_]+)\[0\]$/;return function(l,n,p,m){var q=l.context,s=p.extensions,u=p.defines,t=p.__webglShader.vertexShader,x=p.__webglShader.fragmentShader,v="SHADOWMAP_TYPE_BASIC";m.shadowMapType===THREE.PCFShadowMap?v="SHADOWMAP_TYPE_PCF":m.shadowMapType===THREE.PCFSoftShadowMap&&(v="SHADOWMAP_TYPE_PCF_SOFT");var C="ENVMAP_TYPE_CUBE",w="ENVMAP_MODE_REFLECTION",D="ENVMAP_BLENDING_MULTIPLY";if(m.envMap){switch(p.envMap.mapping){case THREE.CubeReflectionMapping:case THREE.CubeRefractionMapping:C=
+"ENVMAP_TYPE_CUBE";break;case THREE.EquirectangularReflectionMapping:case THREE.EquirectangularRefractionMapping:C="ENVMAP_TYPE_EQUIREC";break;case THREE.SphericalReflectionMapping:C="ENVMAP_TYPE_SPHERE"}switch(p.envMap.mapping){case THREE.CubeRefractionMapping:case THREE.EquirectangularRefractionMapping:w="ENVMAP_MODE_REFRACTION"}switch(p.combine){case THREE.MultiplyOperation:D="ENVMAP_BLENDING_MULTIPLY";break;case THREE.MixOperation:D="ENVMAP_BLENDING_MIX";break;case THREE.AddOperation:D="ENVMAP_BLENDING_ADD"}}var z=
+0<l.gammaFactor?l.gammaFactor:1,s=a(s,m,l.extensions),y=b(u),A=q.createProgram();p instanceof THREE.RawShaderMaterial?l=u="":(u=["precision "+m.precision+" float;","precision "+m.precision+" int;","#define SHADER_NAME "+p.__webglShader.name,y,m.supportsVertexTextures?"#define VERTEX_TEXTURES":"",l.gammaInput?"#define GAMMA_INPUT":"",l.gammaOutput?"#define GAMMA_OUTPUT":"","#define GAMMA_FACTOR "+z,"#define MAX_BONES "+m.maxBones,m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.envMap?
+"#define "+w:"",m.lightMap?"#define USE_LIGHTMAP":"",m.aoMap?"#define USE_AOMAP":"",m.emissiveMap?"#define USE_EMISSIVEMAP":"",m.bumpMap?"#define USE_BUMPMAP":"",m.normalMap?"#define USE_NORMALMAP":"",m.displacementMap&&m.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",m.specularMap?"#define USE_SPECULARMAP":"",m.roughnessMap?"#define USE_ROUGHNESSMAP":"",m.metalnessMap?"#define USE_METALNESSMAP":"",m.alphaMap?"#define USE_ALPHAMAP":"",m.vertexColors?"#define USE_COLOR":"",m.flatShading?"#define FLAT_SHADED":
+"",m.skinning?"#define USE_SKINNING":"",m.useVertexTexture?"#define BONE_TEXTURE":"",m.morphTargets?"#define USE_MORPHTARGETS":"",m.morphNormals&&!1===m.flatShading?"#define USE_MORPHNORMALS":"",m.doubleSided?"#define DOUBLE_SIDED":"",m.flipSided?"#define FLIP_SIDED":"",m.shadowMapEnabled?"#define USE_SHADOWMAP":"",m.shadowMapEnabled?"#define "+v:"",0<m.pointLightShadows?"#define POINT_LIGHT_SHADOWS":"",m.sizeAttenuation?"#define USE_SIZEATTENUATION":"",m.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":
+"",m.logarithmicDepthBuffer&&l.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;",
+"\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;","\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(c).join("\n"),l=[s,"precision "+
+m.precision+" float;","precision "+m.precision+" int;","#define SHADER_NAME "+p.__webglShader.name,y,m.alphaTest?"#define ALPHATEST "+m.alphaTest:"",l.gammaInput?"#define GAMMA_INPUT":"",l.gammaOutput?"#define GAMMA_OUTPUT":"","#define GAMMA_FACTOR "+z,m.useFog&&m.fog?"#define USE_FOG":"",m.useFog&&m.fogExp?"#define FOG_EXP2":"",m.map?"#define USE_MAP":"",m.envMap?"#define USE_ENVMAP":"",m.envMap?"#define "+C:"",m.envMap?"#define "+w:"",m.envMap?"#define "+D:"",m.lightMap?"#define USE_LIGHTMAP":"",
+m.aoMap?"#define USE_AOMAP":"",m.emissiveMap?"#define USE_EMISSIVEMAP":"",m.bumpMap?"#define USE_BUMPMAP":"",m.normalMap?"#define USE_NORMALMAP":"",m.specularMap?"#define USE_SPECULARMAP":"",m.roughnessMap?"#define USE_ROUGHNESSMAP":"",m.metalnessMap?"#define USE_METALNESSMAP":"",m.alphaMap?"#define USE_ALPHAMAP":"",m.vertexColors?"#define USE_COLOR":"",m.flatShading?"#define FLAT_SHADED":"",m.doubleSided?"#define DOUBLE_SIDED":"",m.flipSided?"#define FLIP_SIDED":"",m.shadowMapEnabled?"#define USE_SHADOWMAP":
+"",m.shadowMapEnabled?"#define "+v:"",0<m.pointLightShadows?"#define POINT_LIGHT_SHADOWS":"",m.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",m.logarithmicDepthBuffer&&l.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",m.envMap&&l.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","\n"].filter(c).join("\n"));t=d(t,m);x=d(x,m);!1===p instanceof THREE.ShaderMaterial&&(t=e(t),x=e(x));x=l+x;t=THREE.WebGLShader(q,
+q.VERTEX_SHADER,u+t);x=THREE.WebGLShader(q,q.FRAGMENT_SHADER,x);q.attachShader(A,t);q.attachShader(A,x);void 0!==p.index0AttributeName?q.bindAttribLocation(A,0,p.index0AttributeName):!0===m.morphTargets&&q.bindAttribLocation(A,0,"position");q.linkProgram(A);m=q.getProgramInfoLog(A);v=q.getShaderInfoLog(t);C=q.getShaderInfoLog(x);D=w=!0;if(!1===q.getProgramParameter(A,q.LINK_STATUS))w=!1,console.error("THREE.WebGLProgram: shader error: ",q.getError(),"gl.VALIDATE_STATUS",q.getProgramParameter(A,q.VALIDATE_STATUS),
+"gl.getProgramInfoLog",m,v,C);else if(""!==m)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",m);else if(""===v||""===C)D=!1;D&&(this.diagnostics={runnable:w,material:p,programLog:m,vertexShader:{log:v,prefix:u},fragmentShader:{log:C,prefix:l}});q.deleteShader(t);q.deleteShader(x);var H;this.getUniforms=function(){if(void 0===H){for(var a={},b=q.getProgramParameter(A,q.ACTIVE_UNIFORMS),c=0;c<b;c++){var d=q.getActiveUniform(A,c).name,e=q.getUniformLocation(A,d),f=g.exec(d);if(f){var d=f[1],
+f=f[2],l=a[d];l||(l=a[d]={});l[f]=e}else if(f=h.exec(d)){var l=f[1],d=f[2],f=f[3],m=a[l];m||(m=a[l]=[]);(l=m[d])||(l=m[d]={});l[f]=e}else(f=k.exec(d))?(l=f[1],a[l]=e):a[d]=e}H=a}return H};var G;this.getAttributes=function(){if(void 0===G){for(var a={},b=q.getProgramParameter(A,q.ACTIVE_ATTRIBUTES),c=0;c<b;c++){var d=q.getActiveAttrib(A,c).name;a[d]=q.getAttribLocation(A,d)}G=a}return G};this.destroy=function(){q.deleteProgram(A);this.program=void 0};Object.defineProperties(this,{uniforms:{get:function(){console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms().");
+return this.getUniforms()}},attributes:{get:function(){console.warn("THREE.WebGLProgram: .attributes is now .getAttributes().");return this.getAttributes()}}});this.id=f++;this.code=n;this.usedTimes=1;this.program=A;this.vertexShader=t;this.fragmentShader=x;return this}}();
+THREE.WebGLPrograms=function(a,b){var c=[],d={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshStandardMaterial:"standard",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},e="precision supportsVertexTextures map envMap envMapMode lightMap aoMap emissiveMap bumpMap normalMap displacementMap specularMap roughnessMap metalnessMap alphaMap combine vertexColors fog useFog fogExp flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals numDirLights numPointLights numSpotLights numHemiLights shadowMapEnabled pointLightShadows shadowMapType alphaTest doubleSided flipSided".split(" ");
+this.getParameters=function(c,e,h,k){var l=d[c.type],n;b.floatVertexTextures&&k&&k.skeleton&&k.skeleton.useVertexTexture?n=1024:(n=Math.floor((b.maxVertexUniforms-20)/4),void 0!==k&&k instanceof THREE.SkinnedMesh&&(n=Math.min(k.skeleton.bones.length,n),n<k.skeleton.bones.length&&console.warn("WebGLRenderer: too many bones - "+k.skeleton.bones.length+", this GPU supports just "+n+" (try OpenGL instead of ANGLE)")));var p=a.getPrecision();null!==c.precision&&(p=b.getMaxPrecision(c.precision),p!==c.precision&&
+console.warn("THREE.WebGLProgram.getParameters:",c.precision,"not supported, using",p,"instead."));return{shaderID:l,precision:p,supportsVertexTextures:b.vertexTextures,map:!!c.map,envMap:!!c.envMap,envMapMode:c.envMap&&c.envMap.mapping,lightMap:!!c.lightMap,aoMap:!!c.aoMap,emissiveMap:!!c.emissiveMap,bumpMap:!!c.bumpMap,normalMap:!!c.normalMap,displacementMap:!!c.displacementMap,roughnessMap:!!c.roughnessMap,metalnessMap:!!c.metalnessMap,specularMap:!!c.specularMap,alphaMap:!!c.alphaMap,combine:c.combine,
+vertexColors:c.vertexColors,fog:h,useFog:c.fog,fogExp:h instanceof THREE.FogExp2,flatShading:c.shading===THREE.FlatShading,sizeAttenuation:c.sizeAttenuation,logarithmicDepthBuffer:b.logarithmicDepthBuffer,skinning:c.skinning,maxBones:n,useVertexTexture:b.floatVertexTextures&&k&&k.skeleton&&k.skeleton.useVertexTexture,morphTargets:c.morphTargets,morphNormals:c.morphNormals,maxMorphTargets:a.maxMorphTargets,maxMorphNormals:a.maxMorphNormals,numDirLights:e.directional.length,numPointLights:e.point.length,
+numSpotLights:e.spot.length,numHemiLights:e.hemi.length,pointLightShadows:e.shadowsPointLight,shadowMapEnabled:a.shadowMap.enabled&&k.receiveShadow&&0<e.shadows.length,shadowMapType:a.shadowMap.type,alphaTest:c.alphaTest,doubleSided:c.side===THREE.DoubleSide,flipSided:c.side===THREE.BackSide}};this.getProgramCode=function(a,b){var c=[];b.shaderID?c.push(b.shaderID):(c.push(a.fragmentShader),c.push(a.vertexShader));if(void 0!==a.defines)for(var d in a.defines)c.push(d),c.push(a.defines[d]);for(d=0;d<
+e.length;d++){var l=e[d];c.push(l);c.push(b[l])}return c.join()};this.acquireProgram=function(b,d,e){for(var k,l=0,n=c.length;l<n;l++){var p=c[l];if(p.code===e){k=p;++k.usedTimes;break}}void 0===k&&(k=new THREE.WebGLProgram(a,e,b,d),c.push(k));return k};this.releaseProgram=function(a){if(0===--a.usedTimes){var b=c.indexOf(a);c[b]=c[c.length-1];c.pop();a.destroy()}};this.programs=c};
+THREE.WebGLProperties=function(){var a={};this.get=function(b){b=b.uuid;var c=a[b];void 0===c&&(c={},a[b]=c);return c};this.delete=function(b){delete a[b.uuid]};this.clear=function(){a={}}};
+THREE.WebGLShader=function(){function a(a){a=a.split("\n");for(var c=0;c<a.length;c++)a[c]=c+1+": "+a[c];return a.join("\n")}return function(b,c,d){var e=b.createShader(c);b.shaderSource(e,d);b.compileShader(e);!1===b.getShaderParameter(e,b.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile.");""!==b.getShaderInfoLog(e)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",c===b.VERTEX_SHADER?"vertex":"fragment",b.getShaderInfoLog(e),a(d));return e}}();
+THREE.WebGLShadowMap=function(a,b,c){function d(a,b,c,d){var e=a.geometry,f=null,f=q,g=a.customDepthMaterial;c&&(f=s,g=a.customDistanceMaterial);g?f=g:(a=a instanceof THREE.SkinnedMesh&&b.skinning,g=0,void 0!==e.morphTargets&&0<e.morphTargets.length&&b.morphTargets&&(g|=1),a&&(g|=2),f=f[g]);f.visible=b.visible;f.wireframe=b.wireframe;f.wireframeLinewidth=b.wireframeLinewidth;c&&void 0!==f.uniforms.lightPos&&f.uniforms.lightPos.value.copy(d);return f}function e(a,b,c){if(!1!==a.visible){a.layers.test(b.layers)&&
+(a instanceof THREE.Mesh||a instanceof THREE.Line||a instanceof THREE.Points)&&a.castShadow&&(!1===a.frustumCulled||!0===h.intersectsObject(a))&&!0===a.material.visible&&(a.modelViewMatrix.multiplyMatrices(c.matrixWorldInverse,a.matrixWorld),m.push(a));a=a.children;for(var d=0,f=a.length;d<f;d++)e(a[d],b,c)}}for(var f=a.context,g=a.state,h=new THREE.Frustum,k=new THREE.Matrix4,l=new THREE.Vector2,n=new THREE.Vector3,p=new THREE.Vector3,m=[],q=Array(4),s=Array(4),u=[new THREE.Vector3(1,0,0),new THREE.Vector3(-1,
+0,0),new THREE.Vector3(0,0,1),new THREE.Vector3(0,0,-1),new THREE.Vector3(0,1,0),new THREE.Vector3(0,-1,0)],t=[new THREE.Vector3(0,1,0),new THREE.Vector3(0,1,0),new THREE.Vector3(0,1,0),new THREE.Vector3(0,1,0),new THREE.Vector3(0,0,1),new THREE.Vector3(0,0,-1)],x=[new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4,new THREE.Vector4],v=THREE.ShaderLib.depthRGBA,C=THREE.UniformsUtils.clone(v.uniforms),w=THREE.ShaderLib.distanceRGBA,D=THREE.UniformsUtils.clone(w.uniforms),
+z=0;4!==z;++z){var y=0!==(z&1),A=0!==(z&2),H=new THREE.ShaderMaterial({uniforms:C,vertexShader:v.vertexShader,fragmentShader:v.fragmentShader,morphTargets:y,skinning:A});H._shadowPass=!0;q[z]=H;y=new THREE.ShaderMaterial({uniforms:D,vertexShader:w.vertexShader,fragmentShader:w.fragmentShader,morphTargets:y,skinning:A});y._shadowPass=!0;s[z]=y}var G=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=THREE.PCFShadowMap;this.cullFace=THREE.CullFaceFront;this.render=function(q,s){var v,
+w;if(!1!==G.enabled&&(!1!==G.autoUpdate||!1!==G.needsUpdate)){g.clearColor(1,1,1,1);g.disable(f.BLEND);g.enable(f.CULL_FACE);f.frontFace(f.CCW);f.cullFace(G.cullFace===THREE.CullFaceFront?f.FRONT:f.BACK);g.setDepthTest(!0);g.setScissorTest(!1);for(var C=b.shadows,y=0,z=C.length;y<z;y++){var A=C[y],D=A.shadow,H=D.camera;l.copy(D.mapSize);if(A instanceof THREE.PointLight){v=6;w=!0;var J=l.x,F=l.y;x[0].set(2*J,F,J,F);x[1].set(0,F,J,F);x[2].set(3*J,F,J,F);x[3].set(J,F,J,F);x[4].set(3*J,0,J,F);x[5].set(J,
+0,J,F);l.x*=4;l.y*=2}else v=1,w=!1;null===D.map&&(D.map=new THREE.WebGLRenderTarget(l.x,l.y,{minFilter:THREE.NearestFilter,magFilter:THREE.NearestFilter,format:THREE.RGBAFormat}),A instanceof THREE.SpotLight&&(H.aspect=l.x/l.y),H.updateProjectionMatrix());J=D.map;D=D.matrix;p.setFromMatrixPosition(A.matrixWorld);H.position.copy(p);a.setRenderTarget(J);a.clear();for(J=0;J<v;J++){w?(n.copy(H.position),n.add(u[J]),H.up.copy(t[J]),H.lookAt(n),g.viewport(x[J])):(n.setFromMatrixPosition(A.target.matrixWorld),
+H.lookAt(n));H.updateMatrixWorld();H.matrixWorldInverse.getInverse(H.matrixWorld);D.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);D.multiply(H.projectionMatrix);D.multiply(H.matrixWorldInverse);k.multiplyMatrices(H.projectionMatrix,H.matrixWorldInverse);h.setFromMatrix(k);m.length=0;e(q,s,H);for(var F=0,Y=m.length;F<Y;F++){var V=m[F],aa=c.update(V),ca=V.material;if(ca instanceof THREE.MultiMaterial)for(var ha=aa.groups,ca=ca.materials,X=0,ma=ha.length;X<ma;X++){var ia=ha[X],ba=ca[ia.materialIndex];!0===
+ba.visible&&(ba=d(V,ba,w,p),a.renderBufferDirect(H,null,aa,ba,V,ia))}else ba=d(V,ca,w,p),a.renderBufferDirect(H,null,aa,ba,V,null)}}a.resetGLState()}v=a.getClearColor();w=a.getClearAlpha();a.setClearColor(v,w);g.enable(f.BLEND);G.cullFace===THREE.CullFaceFront&&f.cullFace(f.BACK);a.resetGLState();G.needsUpdate=!1}}};
+THREE.WebGLState=function(a,b,c){var d=this,e=new THREE.Vector4,f=new Uint8Array(16),g=new Uint8Array(16),h=new Uint8Array(16),k={},l=null,n=null,p=null,m=null,q=null,s=null,u=null,t=null,x=null,v=null,C=null,w=null,D=null,z=null,y=null,A=null,H=null,G=null,E=null,K=null,P=null,N=null,L=null,B=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),M=void 0,Q={},O=new THREE.Vector4,S=null,J=null,F=new THREE.Vector4,Y=new THREE.Vector4;this.init=function(){this.clearColor(0,0,0,1);this.clearDepth(1);this.clearStencil(0);
+this.enable(a.DEPTH_TEST);a.depthFunc(a.LEQUAL);a.frontFace(a.CCW);a.cullFace(a.BACK);this.enable(a.CULL_FACE);this.enable(a.BLEND);a.blendEquation(a.FUNC_ADD);a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA)};this.initAttributes=function(){for(var a=0,b=f.length;a<b;a++)f[a]=0};this.enableAttribute=function(c){f[c]=1;0===g[c]&&(a.enableVertexAttribArray(c),g[c]=1);0!==h[c]&&(b.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(c,0),h[c]=0)};this.enableAttributeAndDivisor=function(b,c,d){f[b]=1;
+0===g[b]&&(a.enableVertexAttribArray(b),g[b]=1);h[b]!==c&&(d.vertexAttribDivisorANGLE(b,c),h[b]=c)};this.disableUnusedAttributes=function(){for(var b=0,c=g.length;b<c;b++)g[b]!==f[b]&&(a.disableVertexAttribArray(b),g[b]=0)};this.enable=function(b){!0!==k[b]&&(a.enable(b),k[b]=!0)};this.disable=function(b){!1!==k[b]&&(a.disable(b),k[b]=!1)};this.getCompressedTextureFormats=function(){if(null===l&&(l=[],b.get("WEBGL_compressed_texture_pvrtc")||b.get("WEBGL_compressed_texture_s3tc")||b.get("WEBGL_compressed_texture_etc1")))for(var c=
+a.getParameter(a.COMPRESSED_TEXTURE_FORMATS),d=0;d<c.length;d++)l.push(c[d]);return l};this.setBlending=function(b,d,e,f,g,h,k){b===THREE.NoBlending?this.disable(a.BLEND):this.enable(a.BLEND);b!==n&&(b===THREE.AdditiveBlending?(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.SRC_ALPHA,a.ONE)):b===THREE.SubtractiveBlending?(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.ONE_MINUS_SRC_COLOR)):b===THREE.MultiplyBlending?(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.SRC_COLOR)):(a.blendEquationSeparate(a.FUNC_ADD,
+a.FUNC_ADD),a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA)),n=b);if(b===THREE.CustomBlending){g=g||d;h=h||e;k=k||f;if(d!==p||g!==s)a.blendEquationSeparate(c(d),c(g)),p=d,s=g;if(e!==m||f!==q||h!==u||k!==t)a.blendFuncSeparate(c(e),c(f),c(h),c(k)),m=e,q=f,u=h,t=k}else t=u=s=q=m=p=null};this.setDepthFunc=function(b){if(x!==b){if(b)switch(b){case THREE.NeverDepth:a.depthFunc(a.NEVER);break;case THREE.AlwaysDepth:a.depthFunc(a.ALWAYS);break;case THREE.LessDepth:a.depthFunc(a.LESS);
+break;case THREE.LessEqualDepth:a.depthFunc(a.LEQUAL);break;case THREE.EqualDepth:a.depthFunc(a.EQUAL);break;case THREE.GreaterEqualDepth:a.depthFunc(a.GEQUAL);break;case THREE.GreaterDepth:a.depthFunc(a.GREATER);break;case THREE.NotEqualDepth:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}else a.depthFunc(a.LEQUAL);x=b}};this.setDepthTest=function(b){b?this.enable(a.DEPTH_TEST):this.disable(a.DEPTH_TEST)};this.setDepthWrite=function(b){v!==b&&(a.depthMask(b),v=b)};this.setColorWrite=
+function(b){C!==b&&(a.colorMask(b,b,b,b),C=b)};this.setStencilFunc=function(b,c,d){if(D!==b||z!==c||y!==d)a.stencilFunc(b,c,d),D=b,z=c,y=d};this.setStencilOp=function(b,c,d){if(A!==b||H!==c||G!==d)a.stencilOp(b,c,d),A=b,H=c,G=d};this.setStencilTest=function(b){b?this.enable(a.STENCIL_TEST):this.disable(a.STENCIL_TEST)};this.setStencilWrite=function(b){w!==b&&(a.stencilMask(b),w=b)};this.setFlipSided=function(b){E!==b&&(b?a.frontFace(a.CW):a.frontFace(a.CCW),E=b)};this.setLineWidth=function(b){b!==
+K&&(a.lineWidth(b),K=b)};this.setPolygonOffset=function(b,c,d){b?this.enable(a.POLYGON_OFFSET_FILL):this.disable(a.POLYGON_OFFSET_FILL);!b||P===c&&N===d||(a.polygonOffset(c,d),P=c,N=d)};this.getScissorTest=function(){return L};this.setScissorTest=function(b){(L=b)?this.enable(a.SCISSOR_TEST):this.disable(a.SCISSOR_TEST)};this.activeTexture=function(b){void 0===b&&(b=a.TEXTURE0+B-1);M!==b&&(a.activeTexture(b),M=b)};this.bindTexture=function(b,c){void 0===M&&d.activeTexture();var e=Q[M];void 0===e&&
+(e={type:void 0,texture:void 0},Q[M]=e);if(e.type!==b||e.texture!==c)a.bindTexture(b,c),e.type=b,e.texture=c};this.compressedTexImage2D=function(){try{a.compressedTexImage2D.apply(a,arguments)}catch(b){console.error(b)}};this.texImage2D=function(){try{a.texImage2D.apply(a,arguments)}catch(b){console.error(b)}};this.clearColor=function(b,c,d,f){e.set(b,c,d,f);!1===O.equals(e)&&(a.clearColor(b,c,d,f),O.copy(e))};this.clearDepth=function(b){S!==b&&(a.clearDepth(b),S=b)};this.clearStencil=function(b){J!==
+b&&(a.clearStencil(b),J=b)};this.scissor=function(b){!1===F.equals(b)&&(a.scissor(b.x,b.y,b.z,b.w),F.copy(b))};this.viewport=function(b){!1===Y.equals(b)&&(a.viewport(b.x,b.y,b.z,b.w),Y.copy(b))};this.reset=function(){for(var b=0;b<g.length;b++)1===g[b]&&(a.disableVertexAttribArray(b),g[b]=0);k={};E=w=v=C=n=l=null}};
+THREE.LensFlarePlugin=function(a,b){var c,d,e,f,g,h,k,l,n,p,m=a.context,q=a.state,s,u,t,x,v,C;this.render=function(w,D,z){if(0!==b.length){w=new THREE.Vector3;var y=z.w/z.z,A=.5*z.z,H=.5*z.w,G=16/z.w,E=new THREE.Vector2(G*y,G),K=new THREE.Vector3(1,1,0),P=new THREE.Vector2(1,1);if(void 0===t){var G=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),N=new Uint16Array([0,1,2,0,2,3]);s=m.createBuffer();u=m.createBuffer();m.bindBuffer(m.ARRAY_BUFFER,s);m.bufferData(m.ARRAY_BUFFER,G,m.STATIC_DRAW);
+m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,u);m.bufferData(m.ELEMENT_ARRAY_BUFFER,N,m.STATIC_DRAW);v=m.createTexture();C=m.createTexture();q.bindTexture(m.TEXTURE_2D,v);m.texImage2D(m.TEXTURE_2D,0,m.RGB,16,16,0,m.RGB,m.UNSIGNED_BYTE,null);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.NEAREST);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.NEAREST);q.bindTexture(m.TEXTURE_2D,
+C);m.texImage2D(m.TEXTURE_2D,0,m.RGBA,16,16,0,m.RGBA,m.UNSIGNED_BYTE,null);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.NEAREST);m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.NEAREST);var G=(x=0<m.getParameter(m.MAX_VERTEX_TEXTURE_IMAGE_UNITS))?{vertexShader:"uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif ( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility =        visibility.r / 9.0;\nvVisibility *= 1.0 - visibility.g / 9.0;\nvVisibility *=       visibility.b / 9.0;\nvVisibility *= 1.0 - visibility.a / 9.0;\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",
+fragmentShader:"uniform lowp int renderType;\nuniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif ( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if ( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"}:{vertexShader:"uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif ( renderType == 2 ) {\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",
+fragmentShader:"precision mediump float;\nuniform lowp int renderType;\nuniform sampler2D map;\nuniform sampler2D occlusionMap;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvoid main() {\nif ( renderType == 0 ) {\ngl_FragColor = vec4( texture2D( map, vUV ).rgb, 0.0 );\n} else if ( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nfloat visibility = texture2D( occlusionMap, vec2( 0.5, 0.1 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) ).a;\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) ).a;\nvisibility = ( 1.0 - visibility / 4.0 );\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * visibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},
+N=m.createProgram(),L=m.createShader(m.FRAGMENT_SHADER),B=m.createShader(m.VERTEX_SHADER),M="precision "+a.getPrecision()+" float;\n";m.shaderSource(L,M+G.fragmentShader);m.shaderSource(B,M+G.vertexShader);m.compileShader(L);m.compileShader(B);m.attachShader(N,L);m.attachShader(N,B);m.linkProgram(N);t=N;n=m.getAttribLocation(t,"position");p=m.getAttribLocation(t,"uv");c=m.getUniformLocation(t,"renderType");d=m.getUniformLocation(t,"map");e=m.getUniformLocation(t,"occlusionMap");f=m.getUniformLocation(t,
+"opacity");g=m.getUniformLocation(t,"color");h=m.getUniformLocation(t,"scale");k=m.getUniformLocation(t,"rotation");l=m.getUniformLocation(t,"screenPosition")}m.useProgram(t);q.initAttributes();q.enableAttribute(n);q.enableAttribute(p);q.disableUnusedAttributes();m.uniform1i(e,0);m.uniform1i(d,1);m.bindBuffer(m.ARRAY_BUFFER,s);m.vertexAttribPointer(n,2,m.FLOAT,!1,16,0);m.vertexAttribPointer(p,2,m.FLOAT,!1,16,8);m.bindBuffer(m.ELEMENT_ARRAY_BUFFER,u);q.disable(m.CULL_FACE);q.setDepthWrite(!1);N=0;
+for(L=b.length;N<L;N++)if(G=16/z.w,E.set(G*y,G),B=b[N],w.set(B.matrixWorld.elements[12],B.matrixWorld.elements[13],B.matrixWorld.elements[14]),w.applyMatrix4(D.matrixWorldInverse),w.applyProjection(D.projectionMatrix),K.copy(w),P.x=K.x*A+A,P.y=K.y*H+H,x||0<P.x&&P.x<z.z&&0<P.y&&P.y<z.w){q.activeTexture(m.TEXTURE0);q.bindTexture(m.TEXTURE_2D,null);q.activeTexture(m.TEXTURE1);q.bindTexture(m.TEXTURE_2D,v);m.copyTexImage2D(m.TEXTURE_2D,0,m.RGB,z.x+P.x-8,z.y+P.y-8,16,16,0);m.uniform1i(c,0);m.uniform2f(h,
+E.x,E.y);m.uniform3f(l,K.x,K.y,K.z);q.disable(m.BLEND);q.enable(m.DEPTH_TEST);m.drawElements(m.TRIANGLES,6,m.UNSIGNED_SHORT,0);q.activeTexture(m.TEXTURE0);q.bindTexture(m.TEXTURE_2D,C);m.copyTexImage2D(m.TEXTURE_2D,0,m.RGBA,z.x+P.x-8,z.y+P.y-8,16,16,0);m.uniform1i(c,1);q.disable(m.DEPTH_TEST);q.activeTexture(m.TEXTURE1);q.bindTexture(m.TEXTURE_2D,v);m.drawElements(m.TRIANGLES,6,m.UNSIGNED_SHORT,0);B.positionScreen.copy(K);B.customUpdateCallback?B.customUpdateCallback(B):B.updateLensFlares();m.uniform1i(c,
+2);q.enable(m.BLEND);for(var M=0,Q=B.lensFlares.length;M<Q;M++){var O=B.lensFlares[M];.001<O.opacity&&.001<O.scale&&(K.x=O.x,K.y=O.y,K.z=O.z,G=O.size*O.scale/z.w,E.x=G*y,E.y=G,m.uniform3f(l,K.x,K.y,K.z),m.uniform2f(h,E.x,E.y),m.uniform1f(k,O.rotation),m.uniform1f(f,O.opacity),m.uniform3f(g,O.color.r,O.color.g,O.color.b),q.setBlending(O.blending,O.blendEquation,O.blendSrc,O.blendDst),a.setTexture(O.texture,1),m.drawElements(m.TRIANGLES,6,m.UNSIGNED_SHORT,0))}}q.enable(m.CULL_FACE);q.enable(m.DEPTH_TEST);
+q.setDepthWrite(!0);a.resetGLState()}}};
+THREE.SpritePlugin=function(a,b){var c,d,e,f,g,h,k,l,n,p,m,q,s,u,t,x,v;function C(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:b.id-a.id}var w=a.context,D=a.state,z,y,A,H,G=new THREE.Vector3,E=new THREE.Quaternion,K=new THREE.Vector3;this.render=function(P,N){if(0!==b.length){if(void 0===A){var L=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),B=new Uint16Array([0,1,2,0,2,3]);z=w.createBuffer();y=w.createBuffer();w.bindBuffer(w.ARRAY_BUFFER,
+z);w.bufferData(w.ARRAY_BUFFER,L,w.STATIC_DRAW);w.bindBuffer(w.ELEMENT_ARRAY_BUFFER,y);w.bufferData(w.ELEMENT_ARRAY_BUFFER,B,w.STATIC_DRAW);var L=w.createProgram(),B=w.createShader(w.VERTEX_SHADER),M=w.createShader(w.FRAGMENT_SHADER);w.shaderSource(B,["precision "+a.getPrecision()+" float;","uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\nvec4 finalPosition;\nfinalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition;\nfinalPosition = projectionMatrix * finalPosition;\ngl_Position = finalPosition;\n}"].join("\n"));
+w.shaderSource(M,["precision "+a.getPrecision()+" float;","uniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n"));
+w.compileShader(B);w.compileShader(M);w.attachShader(L,B);w.attachShader(L,M);w.linkProgram(L);A=L;x=w.getAttribLocation(A,"position");v=w.getAttribLocation(A,"uv");c=w.getUniformLocation(A,"uvOffset");d=w.getUniformLocation(A,"uvScale");e=w.getUniformLocation(A,"rotation");f=w.getUniformLocation(A,"scale");g=w.getUniformLocation(A,"color");h=w.getUniformLocation(A,"map");k=w.getUniformLocation(A,"opacity");l=w.getUniformLocation(A,"modelViewMatrix");n=w.getUniformLocation(A,"projectionMatrix");p=
+w.getUniformLocation(A,"fogType");m=w.getUniformLocation(A,"fogDensity");q=w.getUniformLocation(A,"fogNear");s=w.getUniformLocation(A,"fogFar");u=w.getUniformLocation(A,"fogColor");t=w.getUniformLocation(A,"alphaTest");L=document.createElement("canvas");L.width=8;L.height=8;B=L.getContext("2d");B.fillStyle="white";B.fillRect(0,0,8,8);H=new THREE.Texture(L);H.needsUpdate=!0}w.useProgram(A);D.initAttributes();D.enableAttribute(x);D.enableAttribute(v);D.disableUnusedAttributes();D.disable(w.CULL_FACE);
+D.enable(w.BLEND);w.bindBuffer(w.ARRAY_BUFFER,z);w.vertexAttribPointer(x,2,w.FLOAT,!1,16,0);w.vertexAttribPointer(v,2,w.FLOAT,!1,16,8);w.bindBuffer(w.ELEMENT_ARRAY_BUFFER,y);w.uniformMatrix4fv(n,!1,N.projectionMatrix.elements);D.activeTexture(w.TEXTURE0);w.uniform1i(h,0);B=L=0;(M=P.fog)?(w.uniform3f(u,M.color.r,M.color.g,M.color.b),M instanceof THREE.Fog?(w.uniform1f(q,M.near),w.uniform1f(s,M.far),w.uniform1i(p,1),B=L=1):M instanceof THREE.FogExp2&&(w.uniform1f(m,M.density),w.uniform1i(p,2),B=L=2)):
+(w.uniform1i(p,0),B=L=0);for(var M=0,Q=b.length;M<Q;M++){var O=b[M];O.modelViewMatrix.multiplyMatrices(N.matrixWorldInverse,O.matrixWorld);O.z=-O.modelViewMatrix.elements[14]}b.sort(C);for(var S=[],M=0,Q=b.length;M<Q;M++){var O=b[M],J=O.material;w.uniform1f(t,J.alphaTest);w.uniformMatrix4fv(l,!1,O.modelViewMatrix.elements);O.matrixWorld.decompose(G,E,K);S[0]=K.x;S[1]=K.y;O=0;P.fog&&J.fog&&(O=B);L!==O&&(w.uniform1i(p,O),L=O);null!==J.map?(w.uniform2f(c,J.map.offset.x,J.map.offset.y),w.uniform2f(d,
+J.map.repeat.x,J.map.repeat.y)):(w.uniform2f(c,0,0),w.uniform2f(d,1,1));w.uniform1f(k,J.opacity);w.uniform3f(g,J.color.r,J.color.g,J.color.b);w.uniform1f(e,J.rotation);w.uniform2fv(f,S);D.setBlending(J.blending,J.blendEquation,J.blendSrc,J.blendDst);D.setDepthTest(J.depthTest);D.setDepthWrite(J.depthWrite);J.map&&J.map.image&&J.map.image.width?a.setTexture(J.map,0):a.setTexture(H,0);w.drawElements(w.TRIANGLES,6,w.UNSIGNED_SHORT,0)}D.enable(w.CULL_FACE);a.resetGLState()}}};
+Object.defineProperties(THREE.Box2.prototype,{empty:{value:function(){console.warn("THREE.Box2: .empty() has been renamed to .isEmpty().");return this.isEmpty()}},isIntersectionBox:{value:function(a){console.warn("THREE.Box2: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)}}});
+Object.defineProperties(THREE.Box3.prototype,{empty:{value:function(){console.warn("THREE.Box3: .empty() has been renamed to .isEmpty().");return this.isEmpty()}},isIntersectionBox:{value:function(a){console.warn("THREE.Box3: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)}},isIntersectionSphere:{value:function(a){console.warn("THREE.Box3: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}}});
+Object.defineProperties(THREE.Matrix3.prototype,{multiplyVector3:{value:function(a){console.warn("THREE.Matrix3: .multiplyVector3() has been removed. Use vector.applyMatrix3( matrix ) instead.");return a.applyMatrix3(this)}},multiplyVector3Array:{value:function(a){console.warn("THREE.Matrix3: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)}}});
+Object.defineProperties(THREE.Matrix4.prototype,{extractPosition:{value:function(a){console.warn("THREE.Matrix4: .extractPosition() has been renamed to .copyPosition().");return this.copyPosition(a)}},setRotationFromQuaternion:{value:function(a){console.warn("THREE.Matrix4: .setRotationFromQuaternion() has been renamed to .makeRotationFromQuaternion().");return this.makeRotationFromQuaternion(a)}},multiplyVector3:{value:function(a){console.warn("THREE.Matrix4: .multiplyVector3() has been removed. Use vector.applyMatrix4( matrix ) or vector.applyProjection( matrix ) instead.");
+return a.applyProjection(this)}},multiplyVector4:{value:function(a){console.warn("THREE.Matrix4: .multiplyVector4() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)}},multiplyVector3Array:{value:function(a){console.warn("THREE.Matrix4: .multiplyVector3Array() has been renamed. Use matrix.applyToVector3Array( array ) instead.");return this.applyToVector3Array(a)}},rotateAxis:{value:function(a){console.warn("THREE.Matrix4: .rotateAxis() has been removed. Use Vector3.transformDirection( matrix ) instead.");
+a.transformDirection(this)}},crossVector:{value:function(a){console.warn("THREE.Matrix4: .crossVector() has been removed. Use vector.applyMatrix4( matrix ) instead.");return a.applyMatrix4(this)}},translate:{value:function(a){console.error("THREE.Matrix4: .translate() has been removed.")}},rotateX:{value:function(a){console.error("THREE.Matrix4: .rotateX() has been removed.")}},rotateY:{value:function(a){console.error("THREE.Matrix4: .rotateY() has been removed.")}},rotateZ:{value:function(a){console.error("THREE.Matrix4: .rotateZ() has been removed.")}},
+rotateByAxis:{value:function(a,b){console.error("THREE.Matrix4: .rotateByAxis() has been removed.")}}});Object.defineProperties(THREE.Plane.prototype,{isIntersectionLine:{value:function(a){console.warn("THREE.Plane: .isIntersectionLine() has been renamed to .intersectsLine().");return this.intersectsLine(a)}}});
+Object.defineProperties(THREE.Quaternion.prototype,{multiplyVector3:{value:function(a){console.warn("THREE.Quaternion: .multiplyVector3() has been removed. Use is now vector.applyQuaternion( quaternion ) instead.");return a.applyQuaternion(this)}}});
+Object.defineProperties(THREE.Ray.prototype,{isIntersectionBox:{value:function(a){console.warn("THREE.Ray: .isIntersectionBox() has been renamed to .intersectsBox().");return this.intersectsBox(a)}},isIntersectionPlane:{value:function(a){console.warn("THREE.Ray: .isIntersectionPlane() has been renamed to .intersectsPlane().");return this.intersectsPlane(a)}},isIntersectionSphere:{value:function(a){console.warn("THREE.Ray: .isIntersectionSphere() has been renamed to .intersectsSphere().");return this.intersectsSphere(a)}}});
+Object.defineProperties(THREE.Vector3.prototype,{setEulerFromRotationMatrix:{value:function(){console.error("THREE.Vector3: .setEulerFromRotationMatrix() has been removed. Use Euler.setFromRotationMatrix() instead.")}},setEulerFromQuaternion:{value:function(){console.error("THREE.Vector3: .setEulerFromQuaternion() has been removed. Use Euler.setFromQuaternion() instead.")}},getPositionFromMatrix:{value:function(a){console.warn("THREE.Vector3: .getPositionFromMatrix() has been renamed to .setFromMatrixPosition().");
+return this.setFromMatrixPosition(a)}},getScaleFromMatrix:{value:function(a){console.warn("THREE.Vector3: .getScaleFromMatrix() has been renamed to .setFromMatrixScale().");return this.setFromMatrixScale(a)}},getColumnFromMatrix:{value:function(a,b){console.warn("THREE.Vector3: .getColumnFromMatrix() has been renamed to .setFromMatrixColumn().");return this.setFromMatrixColumn(a,b)}}});
+THREE.Face4=function(a,b,c,d,e,f,g){console.warn("THREE.Face4 has been removed. A THREE.Face3 will be created instead.");return new THREE.Face3(a,b,c,e,f,g)};
+Object.defineProperties(THREE.Object3D.prototype,{eulerOrder:{get:function(){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");return this.rotation.order},set:function(a){console.warn("THREE.Object3D: .eulerOrder is now .rotation.order.");this.rotation.order=a}},getChildByName:{value:function(a){console.warn("THREE.Object3D: .getChildByName() has been renamed to .getObjectByName().");return this.getObjectByName(a)}},renderDepth:{set:function(a){console.warn("THREE.Object3D: .renderDepth has been removed. Use .renderOrder, instead.")}},
+translate:{value:function(a,b){console.warn("THREE.Object3D: .translate() has been removed. Use .translateOnAxis( axis, distance ) instead.");return this.translateOnAxis(b,a)}},useQuaternion:{get:function(){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")},set:function(a){console.warn("THREE.Object3D: .useQuaternion has been removed. The library now uses quaternions by default.")}}});
+Object.defineProperties(THREE,{PointCloud:{value:function(a,b){console.warn("THREE.PointCloud has been renamed to THREE.Points.");return new THREE.Points(a,b)}},ParticleSystem:{value:function(a,b){console.warn("THREE.ParticleSystem has been renamed to THREE.Points.");return new THREE.Points(a,b)}}});
+Object.defineProperties(THREE.Light.prototype,{onlyShadow:{set:function(a){console.warn("THREE.Light: .onlyShadow has been removed.")}},shadowCameraFov:{set:function(a){console.warn("THREE.Light: .shadowCameraFov is now .shadow.camera.fov.");this.shadow.camera.fov=a}},shadowCameraLeft:{set:function(a){console.warn("THREE.Light: .shadowCameraLeft is now .shadow.camera.left.");this.shadow.camera.left=a}},shadowCameraRight:{set:function(a){console.warn("THREE.Light: .shadowCameraRight is now .shadow.camera.right.");
+this.shadow.camera.right=a}},shadowCameraTop:{set:function(a){console.warn("THREE.Light: .shadowCameraTop is now .shadow.camera.top.");this.shadow.camera.top=a}},shadowCameraBottom:{set:function(a){console.warn("THREE.Light: .shadowCameraBottom is now .shadow.camera.bottom.");this.shadow.camera.bottom=a}},shadowCameraNear:{set:function(a){console.warn("THREE.Light: .shadowCameraNear is now .shadow.camera.near.");this.shadow.camera.near=a}},shadowCameraFar:{set:function(a){console.warn("THREE.Light: .shadowCameraFar is now .shadow.camera.far.");
+this.shadow.camera.far=a}},shadowCameraVisible:{set:function(a){console.warn("THREE.Light: .shadowCameraVisible has been removed. Use new THREE.CameraHelper( light.shadow.camera ) instead.")}},shadowBias:{set:function(a){console.warn("THREE.Light: .shadowBias is now .shadow.bias.");this.shadow.bias=a}},shadowDarkness:{set:function(a){console.warn("THREE.Light: .shadowDarkness has been removed.")}},shadowMapWidth:{set:function(a){console.warn("THREE.Light: .shadowMapWidth is now .shadow.mapSize.width.");
+this.shadow.mapSize.width=a}},shadowMapHeight:{set:function(a){console.warn("THREE.Light: .shadowMapHeight is now .shadow.mapSize.height.");this.shadow.mapSize.height=a}}});Object.defineProperties(THREE.BufferAttribute.prototype,{length:{get:function(){console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count.");return this.array.length}}});
+Object.defineProperties(THREE.BufferGeometry.prototype,{drawcalls:{get:function(){console.error("THREE.BufferGeometry: .drawcalls has been renamed to .groups.");return this.groups}},offsets:{get:function(){console.warn("THREE.BufferGeometry: .offsets has been renamed to .groups.");return this.groups}},addIndex:{value:function(a){console.warn("THREE.BufferGeometry: .addIndex() has been renamed to .setIndex().");this.setIndex(a)}},addDrawCall:{value:function(a,b,c){void 0!==c&&console.warn("THREE.BufferGeometry: .addDrawCall() no longer supports indexOffset.");
+console.warn("THREE.BufferGeometry: .addDrawCall() is now .addGroup().");this.addGroup(a,b)}},clearDrawCalls:{value:function(){console.warn("THREE.BufferGeometry: .clearDrawCalls() is now .clearGroups().");this.clearGroups()}},computeTangents:{value:function(){console.warn("THREE.BufferGeometry: .computeTangents() has been removed.")}},computeOffsets:{value:function(){console.warn("THREE.BufferGeometry: .computeOffsets() has been removed.")}}});
+Object.defineProperties(THREE.Material.prototype,{wrapAround:{get:function(){console.warn("THREE."+this.type+": .wrapAround has been removed.")},set:function(a){console.warn("THREE."+this.type+": .wrapAround has been removed.")}},wrapRGB:{get:function(){console.warn("THREE."+this.type+": .wrapRGB has been removed.");return new THREE.Color}}});
+Object.defineProperties(THREE,{PointCloudMaterial:{value:function(a){console.warn("THREE.PointCloudMaterial has been renamed to THREE.PointsMaterial.");return new THREE.PointsMaterial(a)}},ParticleBasicMaterial:{value:function(a){console.warn("THREE.ParticleBasicMaterial has been renamed to THREE.PointsMaterial.");return new THREE.PointsMaterial(a)}},ParticleSystemMaterial:{value:function(a){console.warn("THREE.ParticleSystemMaterial has been renamed to THREE.PointsMaterial.");return new THREE.PointsMaterial(a)}}});
+Object.defineProperties(THREE.MeshPhongMaterial.prototype,{metal:{get:function(){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead.");return!1},set:function(a){console.warn("THREE.MeshPhongMaterial: .metal has been removed. Use THREE.MeshStandardMaterial instead")}}});
+Object.defineProperties(THREE.ShaderMaterial.prototype,{derivatives:{get:function(){console.warn("THREE.ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");return this.extensions.derivatives},set:function(a){console.warn("THREE. ShaderMaterial: .derivatives has been moved to .extensions.derivatives.");this.extensions.derivatives=a}}});
+Object.defineProperties(THREE.WebGLRenderer.prototype,{supportsFloatTextures:{value:function(){console.warn("THREE.WebGLRenderer: .supportsFloatTextures() is now .extensions.get( 'OES_texture_float' ).");return this.extensions.get("OES_texture_float")}},supportsHalfFloatTextures:{value:function(){console.warn("THREE.WebGLRenderer: .supportsHalfFloatTextures() is now .extensions.get( 'OES_texture_half_float' ).");return this.extensions.get("OES_texture_half_float")}},supportsStandardDerivatives:{value:function(){console.warn("THREE.WebGLRenderer: .supportsStandardDerivatives() is now .extensions.get( 'OES_standard_derivatives' ).");
+return this.extensions.get("OES_standard_derivatives")}},supportsCompressedTextureS3TC:{value:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTextureS3TC() is now .extensions.get( 'WEBGL_compressed_texture_s3tc' ).");return this.extensions.get("WEBGL_compressed_texture_s3tc")}},supportsCompressedTexturePVRTC:{value:function(){console.warn("THREE.WebGLRenderer: .supportsCompressedTexturePVRTC() is now .extensions.get( 'WEBGL_compressed_texture_pvrtc' ).");return this.extensions.get("WEBGL_compressed_texture_pvrtc")}},
+supportsBlendMinMax:{value:function(){console.warn("THREE.WebGLRenderer: .supportsBlendMinMax() is now .extensions.get( 'EXT_blend_minmax' ).");return this.extensions.get("EXT_blend_minmax")}},supportsVertexTextures:{value:function(){return this.capabilities.vertexTextures}},supportsInstancedArrays:{value:function(){console.warn("THREE.WebGLRenderer: .supportsInstancedArrays() is now .extensions.get( 'ANGLE_instanced_arrays' ).");return this.extensions.get("ANGLE_instanced_arrays")}},enableScissorTest:{value:function(a){console.warn("THREE.WebGLRenderer: .enableScissorTest() is now .setScissorTest().");
+this.setScissorTest(a)}},initMaterial:{value:function(){console.warn("THREE.WebGLRenderer: .initMaterial() has been removed.")}},addPrePlugin:{value:function(){console.warn("THREE.WebGLRenderer: .addPrePlugin() has been removed.")}},addPostPlugin:{value:function(){console.warn("THREE.WebGLRenderer: .addPostPlugin() has been removed.")}},updateShadowMap:{value:function(){console.warn("THREE.WebGLRenderer: .updateShadowMap() has been removed.")}},shadowMapEnabled:{get:function(){return this.shadowMap.enabled},
+set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapEnabled is now .shadowMap.enabled.");this.shadowMap.enabled=a}},shadowMapType:{get:function(){return this.shadowMap.type},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapType is now .shadowMap.type.");this.shadowMap.type=a}},shadowMapCullFace:{get:function(){return this.shadowMap.cullFace},set:function(a){console.warn("THREE.WebGLRenderer: .shadowMapCullFace is now .shadowMap.cullFace.");this.shadowMap.cullFace=a}}});
+Object.defineProperties(THREE.WebGLRenderTarget.prototype,{wrapS:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");return this.texture.wrapS},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapS is now .texture.wrapS.");this.texture.wrapS=a}},wrapT:{get:function(){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");return this.texture.wrapT},set:function(a){console.warn("THREE.WebGLRenderTarget: .wrapT is now .texture.wrapT.");this.texture.wrapT=
+a}},magFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");return this.texture.magFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .magFilter is now .texture.magFilter.");this.texture.magFilter=a}},minFilter:{get:function(){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");return this.texture.minFilter},set:function(a){console.warn("THREE.WebGLRenderTarget: .minFilter is now .texture.minFilter.");this.texture.minFilter=
+a}},anisotropy:{get:function(){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");return this.texture.anisotropy},set:function(a){console.warn("THREE.WebGLRenderTarget: .anisotropy is now .texture.anisotropy.");this.texture.anisotropy=a}},offset:{get:function(){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");return this.texture.offset},set:function(a){console.warn("THREE.WebGLRenderTarget: .offset is now .texture.offset.");this.texture.offset=
+a}},repeat:{get:function(){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");return this.texture.repeat},set:function(a){console.warn("THREE.WebGLRenderTarget: .repeat is now .texture.repeat.");this.texture.repeat=a}},format:{get:function(){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");return this.texture.format},set:function(a){console.warn("THREE.WebGLRenderTarget: .format is now .texture.format.");this.texture.format=a}},type:{get:function(){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");
+return this.texture.type},set:function(a){console.warn("THREE.WebGLRenderTarget: .type is now .texture.type.");this.texture.type=a}},generateMipmaps:{get:function(){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");return this.texture.generateMipmaps},set:function(a){console.warn("THREE.WebGLRenderTarget: .generateMipmaps is now .texture.generateMipmaps.");this.texture.generateMipmaps=a}}});
+THREE.GeometryUtils={merge:function(a,b,c){console.warn("THREE.GeometryUtils: .merge() has been moved to Geometry. Use geometry.merge( geometry2, matrix, materialIndexOffset ) instead.");var d;b instanceof THREE.Mesh&&(b.matrixAutoUpdate&&b.updateMatrix(),d=b.matrix,b=b.geometry);a.merge(b,d,c)},center:function(a){console.warn("THREE.GeometryUtils: .center() has been moved to Geometry. Use geometry.center() instead.");return a.center()}};
+THREE.ImageUtils={crossOrigin:void 0,loadTexture:function(a,b,c,d){console.warn("THREE.ImageUtils.loadTexture has been deprecated. Use THREE.TextureLoader() instead.");var e=new THREE.TextureLoader;e.setCrossOrigin(this.crossOrigin);a=e.load(a,c,void 0,d);b&&(a.mapping=b);return a},loadTextureCube:function(a,b,c,d){console.warn("THREE.ImageUtils.loadTextureCube has been deprecated. Use THREE.CubeTextureLoader() instead.");var e=new THREE.CubeTextureLoader;e.setCrossOrigin(this.crossOrigin);a=e.load(a,
+c,void 0,d);b&&(a.mapping=b);return a},loadCompressedTexture:function(){console.error("THREE.ImageUtils.loadCompressedTexture has been removed. Use THREE.DDSLoader instead.")},loadCompressedTextureCube:function(){console.error("THREE.ImageUtils.loadCompressedTextureCube has been removed. Use THREE.DDSLoader instead.")}};
+THREE.Projector=function(){console.error("THREE.Projector has been moved to /examples/js/renderers/Projector.js.");this.projectVector=function(a,b){console.warn("THREE.Projector: .projectVector() is now vector.project().");a.project(b)};this.unprojectVector=function(a,b){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject().");a.unproject(b)};this.pickingRay=function(a,b){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")}};
+THREE.CanvasRenderer=function(){console.error("THREE.CanvasRenderer has been moved to /examples/js/renderers/CanvasRenderer.js");this.domElement=document.createElement("canvas");this.clear=function(){};this.render=function(){};this.setClearColor=function(){};this.setSize=function(){}};THREE.MeshFaceMaterial=THREE.MultiMaterial;
+THREE.CurveUtils={tangentQuadraticBezier:function(a,b,c,d){return 2*(1-a)*(c-b)+2*a*(d-c)},tangentCubicBezier:function(a,b,c,d,e){return-3*b*(1-a)*(1-a)+3*c*(1-a)*(1-a)-6*a*c*(1-a)+6*a*d*(1-a)-3*a*a*d+3*a*a*e},tangentSpline:function(a,b,c,d,e){return 6*a*a-6*a+(3*a*a-4*a+1)+(-6*a*a+6*a)+(3*a*a-2*a)},interpolate:function(a,b,c,d,e){a=.5*(c-a);d=.5*(d-b);var f=e*e;return(2*b-2*c+a+d)*e*f+(-3*b+3*c-2*a-d)*f+a*e+b}};
+THREE.SceneUtils={createMultiMaterialObject:function(a,b){for(var c=new THREE.Group,d=0,e=b.length;d<e;d++)c.add(new THREE.Mesh(a,b[d]));return c},detach:function(a,b,c){a.applyMatrix(b.matrixWorld);b.remove(a);c.add(a)},attach:function(a,b,c){var d=new THREE.Matrix4;d.getInverse(c.matrixWorld);a.applyMatrix(d);b.remove(a);c.add(a)}};
+THREE.ShapeUtils={area:function(a){for(var b=a.length,c=0,d=b-1,e=0;e<b;d=e++)c+=a[d].x*a[e].y-a[e].x*a[d].y;return.5*c},triangulate:function(){return function(a,b){var c=a.length;if(3>c)return null;var d=[],e=[],f=[],g,h,k;if(0<THREE.ShapeUtils.area(a))for(h=0;h<c;h++)e[h]=h;else for(h=0;h<c;h++)e[h]=c-1-h;var l=2*c;for(h=c-1;2<c;){if(0>=l--){console.warn("THREE.ShapeUtils: Unable to triangulate polygon! in triangulate()");break}g=h;c<=g&&(g=0);h=g+1;c<=h&&(h=0);k=h+1;c<=k&&(k=0);var n;a:{var p=
+n=void 0,m=void 0,q=void 0,s=void 0,u=void 0,t=void 0,x=void 0,v=void 0,p=a[e[g]].x,m=a[e[g]].y,q=a[e[h]].x,s=a[e[h]].y,u=a[e[k]].x,t=a[e[k]].y;if(Number.EPSILON>(q-p)*(t-m)-(s-m)*(u-p))n=!1;else{var C=void 0,w=void 0,D=void 0,z=void 0,y=void 0,A=void 0,H=void 0,G=void 0,E=void 0,K=void 0,E=G=H=v=x=void 0,C=u-q,w=t-s,D=p-u,z=m-t,y=q-p,A=s-m;for(n=0;n<c;n++)if(x=a[e[n]].x,v=a[e[n]].y,!(x===p&&v===m||x===q&&v===s||x===u&&v===t)&&(H=x-p,G=v-m,E=x-q,K=v-s,x-=u,v-=t,E=C*K-w*E,H=y*G-A*H,G=D*v-z*x,E>=-Number.EPSILON&&
+G>=-Number.EPSILON&&H>=-Number.EPSILON)){n=!1;break a}n=!0}}if(n){d.push([a[e[g]],a[e[h]],a[e[k]]]);f.push([e[g],e[h],e[k]]);g=h;for(k=h+1;k<c;g++,k++)e[g]=e[k];c--;l=2*c}}return b?f:d}}(),triangulateShape:function(a,b){function c(a,b,c){return a.x!==b.x?a.x<b.x?a.x<=c.x&&c.x<=b.x:b.x<=c.x&&c.x<=a.x:a.y<b.y?a.y<=c.y&&c.y<=b.y:b.y<=c.y&&c.y<=a.y}function d(a,b,d,e,f){var g=b.x-a.x,h=b.y-a.y,k=e.x-d.x,l=e.y-d.y,n=a.x-d.x,p=a.y-d.y,y=h*k-g*l,A=h*n-g*p;if(Math.abs(y)>Number.EPSILON){if(0<y){if(0>A||A>
+y)return[];k=l*n-k*p;if(0>k||k>y)return[]}else{if(0<A||A<y)return[];k=l*n-k*p;if(0<k||k<y)return[]}if(0===k)return!f||0!==A&&A!==y?[a]:[];if(k===y)return!f||0!==A&&A!==y?[b]:[];if(0===A)return[d];if(A===y)return[e];f=k/y;return[{x:a.x+f*g,y:a.y+f*h}]}if(0!==A||l*n!==k*p)return[];h=0===g&&0===h;k=0===k&&0===l;if(h&&k)return a.x!==d.x||a.y!==d.y?[]:[a];if(h)return c(d,e,a)?[a]:[];if(k)return c(a,b,d)?[d]:[];0!==g?(a.x<b.x?(g=a,k=a.x,h=b,a=b.x):(g=b,k=b.x,h=a,a=a.x),d.x<e.x?(b=d,y=d.x,l=e,d=e.x):(b=
+e,y=e.x,l=d,d=d.x)):(a.y<b.y?(g=a,k=a.y,h=b,a=b.y):(g=b,k=b.y,h=a,a=a.y),d.y<e.y?(b=d,y=d.y,l=e,d=e.y):(b=e,y=e.y,l=d,d=d.y));return k<=y?a<y?[]:a===y?f?[]:[b]:a<=d?[b,h]:[b,l]:k>d?[]:k===d?f?[]:[g]:a<=d?[g,h]:[g,l]}function e(a,b,c,d){var e=b.x-a.x,f=b.y-a.y;b=c.x-a.x;c=c.y-a.y;var g=d.x-a.x;d=d.y-a.y;a=e*c-f*b;e=e*d-f*g;return Math.abs(a)>Number.EPSILON?(b=g*c-d*b,0<a?0<=e&&0<=b:0<=e||0<=b):0<e}var f,g,h,k,l,n={};h=a.concat();f=0;for(g=b.length;f<g;f++)Array.prototype.push.apply(h,b[f]);f=0;for(g=
+h.length;f<g;f++)l=h[f].x+":"+h[f].y,void 0!==n[l]&&console.warn("THREE.Shape: Duplicate point",l),n[l]=f;f=function(a,b){function c(a,b){var d=h.length-1,f=a-1;0>f&&(f=d);var g=a+1;g>d&&(g=0);d=e(h[a],h[f],h[g],k[b]);if(!d)return!1;d=k.length-1;f=b-1;0>f&&(f=d);g=b+1;g>d&&(g=0);return(d=e(k[b],k[f],k[g],h[a]))?!0:!1}function f(a,b){var c,e;for(c=0;c<h.length;c++)if(e=c+1,e%=h.length,e=d(a,b,h[c],h[e],!0),0<e.length)return!0;return!1}function g(a,c){var e,f,h,k;for(e=0;e<l.length;e++)for(f=b[l[e]],
+h=0;h<f.length;h++)if(k=h+1,k%=f.length,k=d(a,c,f[h],f[k],!0),0<k.length)return!0;return!1}var h=a.concat(),k,l=[],n,p,z,y,A,H=[],G,E,K,P=0;for(n=b.length;P<n;P++)l.push(P);G=0;for(var N=2*l.length;0<l.length;){N--;if(0>N){console.log("Infinite Loop! Holes left:"+l.length+", Probably Hole outside Shape!");break}for(p=G;p<h.length;p++){z=h[p];n=-1;for(P=0;P<l.length;P++)if(y=l[P],A=z.x+":"+z.y+":"+y,void 0===H[A]){k=b[y];for(E=0;E<k.length;E++)if(y=k[E],c(p,E)&&!f(z,y)&&!g(z,y)){n=E;l.splice(P,1);
+G=h.slice(0,p+1);y=h.slice(p);E=k.slice(n);K=k.slice(0,n+1);h=G.concat(E).concat(K).concat(y);G=p;break}if(0<=n)break;H[A]=!0}if(0<=n)break}}return h}(a,b);var p=THREE.ShapeUtils.triangulate(f,!1);f=0;for(g=p.length;f<g;f++)for(k=p[f],h=0;3>h;h++)l=k[h].x+":"+k[h].y,l=n[l],void 0!==l&&(k[h]=l);return p.concat()},isClockWise:function(a){return 0>THREE.ShapeUtils.area(a)},b2:function(){return function(a,b,c,d){var e=1-a;return e*e*b+2*(1-a)*a*c+a*a*d}}(),b3:function(){return function(a,b,c,d,e){var f=
+1-a,g=1-a;return f*f*f*b+3*g*g*a*c+3*(1-a)*a*a*d+a*a*a*e}}()};THREE.Curve=function(){};
+THREE.Curve.prototype={constructor:THREE.Curve,getPoint:function(a){console.warn("THREE.Curve: Warning, getPoint() not implemented!");return null},getPointAt:function(a){a=this.getUtoTmapping(a);return this.getPoint(a)},getPoints:function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPoint(b/a));return c},getSpacedPoints:function(a){a||(a=5);var b,c=[];for(b=0;b<=a;b++)c.push(this.getPointAt(b/a));return c},getLength:function(){var a=this.getLengths();return a[a.length-1]},getLengths:function(a){a||
+(a=this.__arcLengthDivisions?this.__arcLengthDivisions:200);if(this.cacheArcLengths&&this.cacheArcLengths.length===a+1&&!this.needsUpdate)return this.cacheArcLengths;this.needsUpdate=!1;var b=[],c,d=this.getPoint(0),e,f=0;b.push(0);for(e=1;e<=a;e++)c=this.getPoint(e/a),f+=c.distanceTo(d),b.push(f),d=c;return this.cacheArcLengths=b},updateArcLengths:function(){this.needsUpdate=!0;this.getLengths()},getUtoTmapping:function(a,b){var c=this.getLengths(),d=0,e=c.length,f;f=b?b:a*c[e-1];for(var g=0,h=e-
+1,k;g<=h;)if(d=Math.floor(g+(h-g)/2),k=c[d]-f,0>k)g=d+1;else if(0<k)h=d-1;else{h=d;break}d=h;if(c[d]===f)return d/(e-1);g=c[d];return c=(d+(f-g)/(c[d+1]-g))/(e-1)},getTangent:function(a){var b=a-1E-4;a+=1E-4;0>b&&(b=0);1<a&&(a=1);b=this.getPoint(b);return this.getPoint(a).clone().sub(b).normalize()},getTangentAt:function(a){a=this.getUtoTmapping(a);return this.getTangent(a)}};
+THREE.Curve.create=function(a,b){a.prototype=Object.create(THREE.Curve.prototype);a.prototype.constructor=a;a.prototype.getPoint=b;return a};THREE.CurvePath=function(){this.curves=[];this.autoClose=!1};THREE.CurvePath.prototype=Object.create(THREE.Curve.prototype);THREE.CurvePath.prototype.constructor=THREE.CurvePath;THREE.CurvePath.prototype.add=function(a){this.curves.push(a)};
+THREE.CurvePath.prototype.closePath=function(){var a=this.curves[0].getPoint(0),b=this.curves[this.curves.length-1].getPoint(1);a.equals(b)||this.curves.push(new THREE.LineCurve(b,a))};THREE.CurvePath.prototype.getPoint=function(a){for(var b=a*this.getLength(),c=this.getCurveLengths(),d=0;d<c.length;){if(c[d]>=b)return a=this.curves[d],b=1-(c[d]-b)/a.getLength(),a.getPointAt(b);d++}return null};THREE.CurvePath.prototype.getLength=function(){var a=this.getCurveLengths();return a[a.length-1]};
+THREE.CurvePath.prototype.getCurveLengths=function(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;for(var a=[],b=0,c=0,d=this.curves.length;c<d;c++)b+=this.curves[c].getLength(),a.push(b);return this.cacheLengths=a};THREE.CurvePath.prototype.createPointsGeometry=function(a){a=this.getPoints(a);return this.createGeometry(a)};THREE.CurvePath.prototype.createSpacedPointsGeometry=function(a){a=this.getSpacedPoints(a);return this.createGeometry(a)};
+THREE.CurvePath.prototype.createGeometry=function(a){for(var b=new THREE.Geometry,c=0,d=a.length;c<d;c++){var e=a[c];b.vertices.push(new THREE.Vector3(e.x,e.y,e.z||0))}return b};THREE.Font=function(a){this.data=a};
+THREE.Font.prototype={constructor:THREE.Font,generateShapes:function(a,b,c){void 0===b&&(b=100);void 0===c&&(c=4);var d=this.data;a=String(a).split("");var e=b/d.resolution,f=0;b=[];for(var g=0;g<a.length;g++){var h;h=e;var k=f,l=d.glyphs[a[g]]||d.glyphs["?"];if(l){var n=new THREE.Path,p=[],m=THREE.ShapeUtils.b2,q=THREE.ShapeUtils.b3,s=void 0,u=void 0,t=u=s=void 0,x=void 0,v=void 0,C=void 0,w=void 0,D=void 0,x=void 0;if(l.o)for(var z=l._cachedOutline||(l._cachedOutline=l.o.split(" ")),y=0,A=z.length;y<
+A;)switch(z[y++]){case "m":s=z[y++]*h+k;u=z[y++]*h;n.moveTo(s,u);break;case "l":s=z[y++]*h+k;u=z[y++]*h;n.lineTo(s,u);break;case "q":s=z[y++]*h+k;u=z[y++]*h;v=z[y++]*h+k;C=z[y++]*h;n.quadraticCurveTo(v,C,s,u);if(x=p[p.length-1])for(var t=x.x,x=x.y,H=1;H<=c;H++){var G=H/c;m(G,t,v,s);m(G,x,C,u)}break;case "b":if(s=z[y++]*h+k,u=z[y++]*h,v=z[y++]*h+k,C=z[y++]*h,w=z[y++]*h+k,D=z[y++]*h,n.bezierCurveTo(v,C,w,D,s,u),x=p[p.length-1])for(t=x.x,x=x.y,H=1;H<=c;H++)G=H/c,q(G,t,v,w,s),q(G,x,C,D,u)}h={offset:l.ha*
+h,path:n}}else h=void 0;f+=h.offset;b.push(h.path)}c=[];d=0;for(a=b.length;d<a;d++)Array.prototype.push.apply(c,b[d].toShapes());return c}};THREE.Path=function(a){THREE.CurvePath.call(this);this.actions=[];a&&this.fromPoints(a)};THREE.Path.prototype=Object.create(THREE.CurvePath.prototype);THREE.Path.prototype.constructor=THREE.Path;THREE.Path.prototype.fromPoints=function(a){this.moveTo(a[0].x,a[0].y);for(var b=1,c=a.length;b<c;b++)this.lineTo(a[b].x,a[b].y)};
+THREE.Path.prototype.moveTo=function(a,b){this.actions.push({action:"moveTo",args:[a,b]})};THREE.Path.prototype.lineTo=function(a,b){var c=this.actions[this.actions.length-1].args,c=new THREE.LineCurve(new THREE.Vector2(c[c.length-2],c[c.length-1]),new THREE.Vector2(a,b));this.curves.push(c);this.actions.push({action:"lineTo",args:[a,b]})};
+THREE.Path.prototype.quadraticCurveTo=function(a,b,c,d){var e=this.actions[this.actions.length-1].args,e=new THREE.QuadraticBezierCurve(new THREE.Vector2(e[e.length-2],e[e.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d));this.curves.push(e);this.actions.push({action:"quadraticCurveTo",args:[a,b,c,d]})};
+THREE.Path.prototype.bezierCurveTo=function(a,b,c,d,e,f){var g=this.actions[this.actions.length-1].args,g=new THREE.CubicBezierCurve(new THREE.Vector2(g[g.length-2],g[g.length-1]),new THREE.Vector2(a,b),new THREE.Vector2(c,d),new THREE.Vector2(e,f));this.curves.push(g);this.actions.push({action:"bezierCurveTo",args:[a,b,c,d,e,f]})};
+THREE.Path.prototype.splineThru=function(a){var b=Array.prototype.slice.call(arguments),c=this.actions[this.actions.length-1].args,c=[new THREE.Vector2(c[c.length-2],c[c.length-1])];Array.prototype.push.apply(c,a);c=new THREE.SplineCurve(c);this.curves.push(c);this.actions.push({action:"splineThru",args:b})};THREE.Path.prototype.arc=function(a,b,c,d,e,f){var g=this.actions[this.actions.length-1].args;this.absarc(a+g[g.length-2],b+g[g.length-1],c,d,e,f)};
+THREE.Path.prototype.absarc=function(a,b,c,d,e,f){this.absellipse(a,b,c,c,d,e,f)};THREE.Path.prototype.ellipse=function(a,b,c,d,e,f,g,h){var k=this.actions[this.actions.length-1].args;this.absellipse(a+k[k.length-2],b+k[k.length-1],c,d,e,f,g,h)};THREE.Path.prototype.absellipse=function(a,b,c,d,e,f,g,h){var k=[a,b,c,d,e,f,g,h||0];a=new THREE.EllipseCurve(a,b,c,d,e,f,g,h);this.curves.push(a);a=a.getPoint(1);k.push(a.x);k.push(a.y);this.actions.push({action:"ellipse",args:k})};
+THREE.Path.prototype.getSpacedPoints=function(a){a||(a=40);for(var b=[],c=0;c<a;c++)b.push(this.getPoint(c/a));this.autoClose&&b.push(b[0]);return b};
+THREE.Path.prototype.getPoints=function(a){a=a||12;for(var b=THREE.ShapeUtils.b2,c=THREE.ShapeUtils.b3,d=[],e,f,g,h,k,l,n,p,m,q,s=0,u=this.actions.length;s<u;s++){m=this.actions[s];var t=m.args;switch(m.action){case "moveTo":d.push(new THREE.Vector2(t[0],t[1]));break;case "lineTo":d.push(new THREE.Vector2(t[0],t[1]));break;case "quadraticCurveTo":e=t[2];f=t[3];k=t[0];l=t[1];0<d.length?(m=d[d.length-1],n=m.x,p=m.y):(m=this.actions[s-1].args,n=m[m.length-2],p=m[m.length-1]);for(t=1;t<=a;t++)q=t/a,m=
+b(q,n,k,e),q=b(q,p,l,f),d.push(new THREE.Vector2(m,q));break;case "bezierCurveTo":e=t[4];f=t[5];k=t[0];l=t[1];g=t[2];h=t[3];0<d.length?(m=d[d.length-1],n=m.x,p=m.y):(m=this.actions[s-1].args,n=m[m.length-2],p=m[m.length-1]);for(t=1;t<=a;t++)q=t/a,m=c(q,n,k,g,e),q=c(q,p,l,h,f),d.push(new THREE.Vector2(m,q));break;case "splineThru":m=this.actions[s-1].args;q=[new THREE.Vector2(m[m.length-2],m[m.length-1])];m=a*t[0].length;q=q.concat(t[0]);q=new THREE.SplineCurve(q);for(t=1;t<=m;t++)d.push(q.getPointAt(t/
+m));break;case "arc":e=t[0];f=t[1];l=t[2];g=t[3];m=t[4];k=!!t[5];n=m-g;p=2*a;for(t=1;t<=p;t++)q=t/p,k||(q=1-q),q=g+q*n,m=e+l*Math.cos(q),q=f+l*Math.sin(q),d.push(new THREE.Vector2(m,q));break;case "ellipse":e=t[0];f=t[1];l=t[2];h=t[3];g=t[4];m=t[5];k=!!t[6];var x=t[7];n=m-g;p=2*a;var v,C;0!==x&&(v=Math.cos(x),C=Math.sin(x));for(t=1;t<=p;t++){q=t/p;k||(q=1-q);q=g+q*n;m=e+l*Math.cos(q);q=f+h*Math.sin(q);if(0!==x){var w=m;m=(w-e)*v-(q-f)*C+e;q=(w-e)*C+(q-f)*v+f}d.push(new THREE.Vector2(m,q))}}}a=d[d.length-
+1];Math.abs(a.x-d[0].x)<Number.EPSILON&&Math.abs(a.y-d[0].y)<Number.EPSILON&&d.splice(d.length-1,1);this.autoClose&&d.push(d[0]);return d};
+THREE.Path.prototype.toShapes=function(a,b){function c(a){for(var b=[],c=0,d=a.length;c<d;c++){var e=a[c],f=new THREE.Shape;f.actions=e.actions;f.curves=e.curves;b.push(f)}return b}function d(a,b){for(var c=b.length,d=!1,e=c-1,f=0;f<c;e=f++){var g=b[e],h=b[f],k=h.x-g.x,l=h.y-g.y;if(Math.abs(l)>Number.EPSILON){if(0>l&&(g=b[f],k=-k,h=b[e],l=-l),!(a.y<g.y||a.y>h.y))if(a.y===g.y){if(a.x===g.x)return!0}else{e=l*(a.x-g.x)-k*(a.y-g.y);if(0===e)return!0;0>e||(d=!d)}}else if(a.y===g.y&&(h.x<=a.x&&a.x<=g.x||
+g.x<=a.x&&a.x<=h.x))return!0}return d}var e=THREE.ShapeUtils.isClockWise,f=function(a){for(var b=[],c=new THREE.Path,d=0,e=a.length;d<e;d++){var f=a[d],g=f.args,f=f.action;"moveTo"===f&&0!==c.actions.length&&(b.push(c),c=new THREE.Path);c[f].apply(c,g)}0!==c.actions.length&&b.push(c);return b}(this.actions);if(0===f.length)return[];if(!0===b)return c(f);var g,h,k,l=[];if(1===f.length)return h=f[0],k=new THREE.Shape,k.actions=h.actions,k.curves=h.curves,l.push(k),l;var n=!e(f[0].getPoints()),n=a?!n:
+n;k=[];var p=[],m=[],q=0,s;p[q]=void 0;m[q]=[];for(var u=0,t=f.length;u<t;u++)h=f[u],s=h.getPoints(),g=e(s),(g=a?!g:g)?(!n&&p[q]&&q++,p[q]={s:new THREE.Shape,p:s},p[q].s.actions=h.actions,p[q].s.curves=h.curves,n&&q++,m[q]=[]):m[q].push({h:h,p:s[0]});if(!p[0])return c(f);if(1<p.length){u=!1;h=[];e=0;for(f=p.length;e<f;e++)k[e]=[];e=0;for(f=p.length;e<f;e++)for(g=m[e],n=0;n<g.length;n++){q=g[n];s=!0;for(t=0;t<p.length;t++)d(q.p,p[t].p)&&(e!==t&&h.push({froms:e,tos:t,hole:n}),s?(s=!1,k[t].push(q)):
+u=!0);s&&k[e].push(q)}0<h.length&&(u||(m=k))}u=0;for(e=p.length;u<e;u++)for(k=p[u].s,l.push(k),h=m[u],f=0,g=h.length;f<g;f++)k.holes.push(h[f].h);return l};THREE.Shape=function(){THREE.Path.apply(this,arguments);this.holes=[]};THREE.Shape.prototype=Object.create(THREE.Path.prototype);THREE.Shape.prototype.constructor=THREE.Shape;THREE.Shape.prototype.extrude=function(a){return new THREE.ExtrudeGeometry(this,a)};THREE.Shape.prototype.makeGeometry=function(a){return new THREE.ShapeGeometry(this,a)};
+THREE.Shape.prototype.getPointsHoles=function(a){for(var b=[],c=0,d=this.holes.length;c<d;c++)b[c]=this.holes[c].getPoints(a);return b};THREE.Shape.prototype.extractAllPoints=function(a){return{shape:this.getPoints(a),holes:this.getPointsHoles(a)}};THREE.Shape.prototype.extractPoints=function(a){return this.extractAllPoints(a)};THREE.LineCurve=function(a,b){this.v1=a;this.v2=b};THREE.LineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.LineCurve.prototype.constructor=THREE.LineCurve;
+THREE.LineCurve.prototype.getPoint=function(a){var b=this.v2.clone().sub(this.v1);b.multiplyScalar(a).add(this.v1);return b};THREE.LineCurve.prototype.getPointAt=function(a){return this.getPoint(a)};THREE.LineCurve.prototype.getTangent=function(a){return this.v2.clone().sub(this.v1).normalize()};THREE.QuadraticBezierCurve=function(a,b,c){this.v0=a;this.v1=b;this.v2=c};THREE.QuadraticBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.QuadraticBezierCurve.prototype.constructor=THREE.QuadraticBezierCurve;
+THREE.QuadraticBezierCurve.prototype.getPoint=function(a){var b=THREE.ShapeUtils.b2;return new THREE.Vector2(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))};THREE.QuadraticBezierCurve.prototype.getTangent=function(a){var b=THREE.CurveUtils.tangentQuadraticBezier;return(new THREE.Vector2(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y))).normalize()};THREE.CubicBezierCurve=function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d};
+THREE.CubicBezierCurve.prototype=Object.create(THREE.Curve.prototype);THREE.CubicBezierCurve.prototype.constructor=THREE.CubicBezierCurve;THREE.CubicBezierCurve.prototype.getPoint=function(a){var b=THREE.ShapeUtils.b3;return new THREE.Vector2(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))};
+THREE.CubicBezierCurve.prototype.getTangent=function(a){var b=THREE.CurveUtils.tangentCubicBezier;return(new THREE.Vector2(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y))).normalize()};THREE.SplineCurve=function(a){this.points=void 0==a?[]:a};THREE.SplineCurve.prototype=Object.create(THREE.Curve.prototype);THREE.SplineCurve.prototype.constructor=THREE.SplineCurve;
+THREE.SplineCurve.prototype.getPoint=function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0===c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=THREE.CurveUtils.interpolate;return new THREE.Vector2(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a))};THREE.EllipseCurve=function(a,b,c,d,e,f,g,h){this.aX=a;this.aY=b;this.xRadius=c;this.yRadius=d;this.aStartAngle=e;this.aEndAngle=f;this.aClockwise=g;this.aRotation=h||0};THREE.EllipseCurve.prototype=Object.create(THREE.Curve.prototype);
+THREE.EllipseCurve.prototype.constructor=THREE.EllipseCurve;
+THREE.EllipseCurve.prototype.getPoint=function(a){var b=this.aEndAngle-this.aStartAngle;0>b&&(b+=2*Math.PI);b>2*Math.PI&&(b-=2*Math.PI);b=!0===this.aClockwise?this.aEndAngle+(1-a)*(2*Math.PI-b):this.aStartAngle+a*b;a=this.aX+this.xRadius*Math.cos(b);var c=this.aY+this.yRadius*Math.sin(b);if(0!==this.aRotation){var b=Math.cos(this.aRotation),d=Math.sin(this.aRotation),e=a;a=(e-this.aX)*b-(c-this.aY)*d+this.aX;c=(e-this.aX)*d+(c-this.aY)*b+this.aY}return new THREE.Vector2(a,c)};
+THREE.ArcCurve=function(a,b,c,d,e,f){THREE.EllipseCurve.call(this,a,b,c,c,d,e,f)};THREE.ArcCurve.prototype=Object.create(THREE.EllipseCurve.prototype);THREE.ArcCurve.prototype.constructor=THREE.ArcCurve;THREE.LineCurve3=THREE.Curve.create(function(a,b){this.v1=a;this.v2=b},function(a){var b=new THREE.Vector3;b.subVectors(this.v2,this.v1);b.multiplyScalar(a);b.add(this.v1);return b});
+THREE.QuadraticBezierCurve3=THREE.Curve.create(function(a,b,c){this.v0=a;this.v1=b;this.v2=c},function(a){var b=THREE.ShapeUtils.b2;return new THREE.Vector3(b(a,this.v0.x,this.v1.x,this.v2.x),b(a,this.v0.y,this.v1.y,this.v2.y),b(a,this.v0.z,this.v1.z,this.v2.z))});
+THREE.CubicBezierCurve3=THREE.Curve.create(function(a,b,c,d){this.v0=a;this.v1=b;this.v2=c;this.v3=d},function(a){var b=THREE.ShapeUtils.b3;return new THREE.Vector3(b(a,this.v0.x,this.v1.x,this.v2.x,this.v3.x),b(a,this.v0.y,this.v1.y,this.v2.y,this.v3.y),b(a,this.v0.z,this.v1.z,this.v2.z,this.v3.z))});
+THREE.SplineCurve3=THREE.Curve.create(function(a){console.warn("THREE.SplineCurve3 will be deprecated. Please use THREE.CatmullRomCurve3");this.points=void 0==a?[]:a},function(a){var b=this.points;a*=b.length-1;var c=Math.floor(a);a-=c;var d=b[0==c?c:c-1],e=b[c],f=b[c>b.length-2?b.length-1:c+1],b=b[c>b.length-3?b.length-1:c+2],c=THREE.CurveUtils.interpolate;return new THREE.Vector3(c(d.x,e.x,f.x,b.x,a),c(d.y,e.y,f.y,b.y,a),c(d.z,e.z,f.z,b.z,a))});
+THREE.CatmullRomCurve3=function(){function a(){}var b=new THREE.Vector3,c=new a,d=new a,e=new a;a.prototype.init=function(a,b,c,d){this.c0=a;this.c1=c;this.c2=-3*a+3*b-2*c-d;this.c3=2*a-2*b+c+d};a.prototype.initNonuniformCatmullRom=function(a,b,c,d,e,n,p){a=((b-a)/e-(c-a)/(e+n)+(c-b)/n)*n;d=((c-b)/n-(d-b)/(n+p)+(d-c)/p)*n;this.init(b,c,a,d)};a.prototype.initCatmullRom=function(a,b,c,d,e){this.init(b,c,e*(c-a),e*(d-b))};a.prototype.calc=function(a){var b=a*a;return this.c0+this.c1*a+this.c2*b+this.c3*
+b*a};return THREE.Curve.create(function(a){this.points=a||[];this.closed=!1},function(a){var g=this.points,h,k;k=g.length;2>k&&console.log("duh, you need at least 2 points");a*=k-(this.closed?0:1);h=Math.floor(a);a-=h;this.closed?h+=0<h?0:(Math.floor(Math.abs(h)/g.length)+1)*g.length:0===a&&h===k-1&&(h=k-2,a=1);var l,n,p;this.closed||0<h?l=g[(h-1)%k]:(b.subVectors(g[0],g[1]).add(g[0]),l=b);n=g[h%k];p=g[(h+1)%k];this.closed||h+2<k?g=g[(h+2)%k]:(b.subVectors(g[k-1],g[k-2]).add(g[k-1]),g=b);if(void 0===
+this.type||"centripetal"===this.type||"chordal"===this.type){var m="chordal"===this.type?.5:.25;k=Math.pow(l.distanceToSquared(n),m);h=Math.pow(n.distanceToSquared(p),m);m=Math.pow(p.distanceToSquared(g),m);1E-4>h&&(h=1);1E-4>k&&(k=h);1E-4>m&&(m=h);c.initNonuniformCatmullRom(l.x,n.x,p.x,g.x,k,h,m);d.initNonuniformCatmullRom(l.y,n.y,p.y,g.y,k,h,m);e.initNonuniformCatmullRom(l.z,n.z,p.z,g.z,k,h,m)}else"catmullrom"===this.type&&(k=void 0!==this.tension?this.tension:.5,c.initCatmullRom(l.x,n.x,p.x,g.x,
+k),d.initCatmullRom(l.y,n.y,p.y,g.y,k),e.initCatmullRom(l.z,n.z,p.z,g.z,k));return new THREE.Vector3(c.calc(a),d.calc(a),e.calc(a))})}();THREE.ClosedSplineCurve3=function(a){console.warn("THREE.ClosedSplineCurve3 has been deprecated. Please use THREE.CatmullRomCurve3.");THREE.CatmullRomCurve3.call(this,a);this.type="catmullrom";this.closed=!0};THREE.ClosedSplineCurve3.prototype=Object.create(THREE.CatmullRomCurve3.prototype);
+THREE.BoxGeometry=function(a,b,c,d,e,f){function g(a,b,c,d,e,f,g,u){var t,x=h.widthSegments,v=h.heightSegments,C=e/2,w=f/2,D=h.vertices.length;if("x"===a&&"y"===b||"y"===a&&"x"===b)t="z";else if("x"===a&&"z"===b||"z"===a&&"x"===b)t="y",v=h.depthSegments;else if("z"===a&&"y"===b||"y"===a&&"z"===b)t="x",x=h.depthSegments;var z=x+1,y=v+1,A=e/x,H=f/v,G=new THREE.Vector3;G[t]=0<g?1:-1;for(e=0;e<y;e++)for(f=0;f<z;f++){var E=new THREE.Vector3;E[a]=(f*A-C)*c;E[b]=(e*H-w)*d;E[t]=g;h.vertices.push(E)}for(e=
+0;e<v;e++)for(f=0;f<x;f++)w=f+z*e,a=f+z*(e+1),b=f+1+z*(e+1),c=f+1+z*e,d=new THREE.Vector2(f/x,1-e/v),g=new THREE.Vector2(f/x,1-(e+1)/v),t=new THREE.Vector2((f+1)/x,1-(e+1)/v),C=new THREE.Vector2((f+1)/x,1-e/v),w=new THREE.Face3(w+D,a+D,c+D),w.normal.copy(G),w.vertexNormals.push(G.clone(),G.clone(),G.clone()),w.materialIndex=u,h.faces.push(w),h.faceVertexUvs[0].push([d,g,C]),w=new THREE.Face3(a+D,b+D,c+D),w.normal.copy(G),w.vertexNormals.push(G.clone(),G.clone(),G.clone()),w.materialIndex=u,h.faces.push(w),
+h.faceVertexUvs[0].push([g.clone(),t,C.clone()])}THREE.Geometry.call(this);this.type="BoxGeometry";this.parameters={width:a,height:b,depth:c,widthSegments:d,heightSegments:e,depthSegments:f};this.widthSegments=d||1;this.heightSegments=e||1;this.depthSegments=f||1;var h=this;d=a/2;e=b/2;f=c/2;g("z","y",-1,-1,c,b,d,0);g("z","y",1,-1,c,b,-d,1);g("x","z",1,1,a,c,e,2);g("x","z",1,-1,a,c,-e,3);g("x","y",1,-1,a,b,f,4);g("x","y",-1,-1,a,b,-f,5);this.mergeVertices()};THREE.BoxGeometry.prototype=Object.create(THREE.Geometry.prototype);
+THREE.BoxGeometry.prototype.constructor=THREE.BoxGeometry;THREE.CubeGeometry=THREE.BoxGeometry;THREE.CircleGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="CircleGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};this.fromBufferGeometry(new THREE.CircleBufferGeometry(a,b,c,d))};THREE.CircleGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.CircleGeometry.prototype.constructor=THREE.CircleGeometry;
+THREE.CircleBufferGeometry=function(a,b,c,d){THREE.BufferGeometry.call(this);this.type="CircleBufferGeometry";this.parameters={radius:a,segments:b,thetaStart:c,thetaLength:d};a=a||50;b=void 0!==b?Math.max(3,b):8;c=void 0!==c?c:0;d=void 0!==d?d:2*Math.PI;var e=b+2,f=new Float32Array(3*e),g=new Float32Array(3*e),e=new Float32Array(2*e);g[2]=1;e[0]=.5;e[1]=.5;for(var h=0,k=3,l=2;h<=b;h++,k+=3,l+=2){var n=c+h/b*d;f[k]=a*Math.cos(n);f[k+1]=a*Math.sin(n);g[k+2]=1;e[l]=(f[k]/a+1)/2;e[l+1]=(f[k+1]/a+1)/2}c=
+[];for(k=1;k<=b;k++)c.push(k,k+1,0);this.setIndex(new THREE.BufferAttribute(new Uint16Array(c),1));this.addAttribute("position",new THREE.BufferAttribute(f,3));this.addAttribute("normal",new THREE.BufferAttribute(g,3));this.addAttribute("uv",new THREE.BufferAttribute(e,2));this.boundingSphere=new THREE.Sphere(new THREE.Vector3,a)};THREE.CircleBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.CircleBufferGeometry.prototype.constructor=THREE.CircleBufferGeometry;
+THREE.CylinderGeometry=function(a,b,c,d,e,f,g,h){THREE.Geometry.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:b,height:c,radialSegments:d,heightSegments:e,openEnded:f,thetaStart:g,thetaLength:h};a=void 0!==a?a:20;b=void 0!==b?b:20;c=void 0!==c?c:100;d=d||8;e=e||1;f=void 0!==f?f:!1;g=void 0!==g?g:0;h=void 0!==h?h:2*Math.PI;var k=c/2,l,n,p=[],m=[];for(n=0;n<=e;n++){var q=[],s=[],u=n/e,t=u*(b-a)+a;for(l=0;l<=d;l++){var x=l/d,v=new THREE.Vector3;v.x=t*Math.sin(x*h+
+g);v.y=-u*c+k;v.z=t*Math.cos(x*h+g);this.vertices.push(v);q.push(this.vertices.length-1);s.push(new THREE.Vector2(x,1-u))}p.push(q);m.push(s)}c=(b-a)/c;for(l=0;l<d;l++)for(0!==a?(g=this.vertices[p[0][l]].clone(),h=this.vertices[p[0][l+1]].clone()):(g=this.vertices[p[1][l]].clone(),h=this.vertices[p[1][l+1]].clone()),g.setY(Math.sqrt(g.x*g.x+g.z*g.z)*c).normalize(),h.setY(Math.sqrt(h.x*h.x+h.z*h.z)*c).normalize(),n=0;n<e;n++){var q=p[n][l],s=p[n+1][l],u=p[n+1][l+1],t=p[n][l+1],x=g.clone(),v=g.clone(),
+C=h.clone(),w=h.clone(),D=m[n][l].clone(),z=m[n+1][l].clone(),y=m[n+1][l+1].clone(),A=m[n][l+1].clone();this.faces.push(new THREE.Face3(q,s,t,[x,v,w]));this.faceVertexUvs[0].push([D,z,A]);this.faces.push(new THREE.Face3(s,u,t,[v.clone(),C,w.clone()]));this.faceVertexUvs[0].push([z.clone(),y,A.clone()])}if(!1===f&&0<a)for(this.vertices.push(new THREE.Vector3(0,k,0)),l=0;l<d;l++)q=p[0][l],s=p[0][l+1],u=this.vertices.length-1,x=new THREE.Vector3(0,1,0),v=new THREE.Vector3(0,1,0),C=new THREE.Vector3(0,
+1,0),D=m[0][l].clone(),z=m[0][l+1].clone(),y=new THREE.Vector2(z.x,0),this.faces.push(new THREE.Face3(q,s,u,[x,v,C],void 0,1)),this.faceVertexUvs[0].push([D,z,y]);if(!1===f&&0<b)for(this.vertices.push(new THREE.Vector3(0,-k,0)),l=0;l<d;l++)q=p[e][l+1],s=p[e][l],u=this.vertices.length-1,x=new THREE.Vector3(0,-1,0),v=new THREE.Vector3(0,-1,0),C=new THREE.Vector3(0,-1,0),D=m[e][l+1].clone(),z=m[e][l].clone(),y=new THREE.Vector2(z.x,1),this.faces.push(new THREE.Face3(q,s,u,[x,v,C],void 0,2)),this.faceVertexUvs[0].push([D,
+z,y]);this.computeFaceNormals()};THREE.CylinderGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.CylinderGeometry.prototype.constructor=THREE.CylinderGeometry;
+THREE.EdgesGeometry=function(a,b){function c(a,b){return a-b}THREE.BufferGeometry.call(this);var d=Math.cos(THREE.Math.degToRad(void 0!==b?b:1)),e=[0,0],f={},g=["a","b","c"],h;a instanceof THREE.BufferGeometry?(h=new THREE.Geometry,h.fromBufferGeometry(a)):h=a.clone();h.mergeVertices();h.computeFaceNormals();var k=h.vertices;h=h.faces;for(var l=0,n=h.length;l<n;l++)for(var p=h[l],m=0;3>m;m++){e[0]=p[g[m]];e[1]=p[g[(m+1)%3]];e.sort(c);var q=e.toString();void 0===f[q]?f[q]={vert1:e[0],vert2:e[1],face1:l,
+face2:void 0}:f[q].face2=l}e=[];for(q in f)if(g=f[q],void 0===g.face2||h[g.face1].normal.dot(h[g.face2].normal)<=d)l=k[g.vert1],e.push(l.x),e.push(l.y),e.push(l.z),l=k[g.vert2],e.push(l.x),e.push(l.y),e.push(l.z);this.addAttribute("position",new THREE.BufferAttribute(new Float32Array(e),3))};THREE.EdgesGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.EdgesGeometry.prototype.constructor=THREE.EdgesGeometry;
+THREE.ExtrudeGeometry=function(a,b){"undefined"!==typeof a&&(THREE.Geometry.call(this),this.type="ExtrudeGeometry",a=Array.isArray(a)?a:[a],this.addShapeList(a,b),this.computeFaceNormals())};THREE.ExtrudeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ExtrudeGeometry.prototype.constructor=THREE.ExtrudeGeometry;THREE.ExtrudeGeometry.prototype.addShapeList=function(a,b){for(var c=a.length,d=0;d<c;d++)this.addShape(a[d],b)};
+THREE.ExtrudeGeometry.prototype.addShape=function(a,b){function c(a,b,c){b||console.error("THREE.ExtrudeGeometry: vec does not exist");return b.clone().multiplyScalar(c).add(a)}function d(a,b,c){var d=1,d=a.x-b.x,e=a.y-b.y,f=c.x-a.x,g=c.y-a.y,h=d*d+e*e;if(Math.abs(d*g-e*f)>Number.EPSILON){var k=Math.sqrt(h),l=Math.sqrt(f*f+g*g),h=b.x-e/k;b=b.y+d/k;f=((c.x-g/l-h)*g-(c.y+f/l-b)*f)/(d*g-e*f);c=h+d*f-a.x;a=b+e*f-a.y;d=c*c+a*a;if(2>=d)return new THREE.Vector2(c,a);d=Math.sqrt(d/2)}else a=!1,d>Number.EPSILON?
+f>Number.EPSILON&&(a=!0):d<-Number.EPSILON?f<-Number.EPSILON&&(a=!0):Math.sign(e)===Math.sign(g)&&(a=!0),a?(c=-e,a=d,d=Math.sqrt(h)):(c=d,a=e,d=Math.sqrt(h/2));return new THREE.Vector2(c/d,a/d)}function e(a,b){var c,d;for(F=a.length;0<=--F;){c=F;d=F-1;0>d&&(d=a.length-1);for(var e=0,f=q+2*n,e=0;e<f;e++){var g=O*e,h=O*(e+1),k=b+c+g,g=b+d+g,l=b+d+h,h=b+c+h,k=k+G,g=g+G,l=l+G,h=h+G;H.faces.push(new THREE.Face3(k,g,h,null,null,1));H.faces.push(new THREE.Face3(g,l,h,null,null,1));k=x.generateSideWallUV(H,
+k,g,l,h);H.faceVertexUvs[0].push([k[0],k[1],k[3]]);H.faceVertexUvs[0].push([k[1],k[2],k[3]])}}}function f(a,b,c){H.vertices.push(new THREE.Vector3(a,b,c))}function g(a,b,c){a+=G;b+=G;c+=G;H.faces.push(new THREE.Face3(a,b,c,null,null,0));a=x.generateTopUV(H,a,b,c);H.faceVertexUvs[0].push(a)}var h=void 0!==b.amount?b.amount:100,k=void 0!==b.bevelThickness?b.bevelThickness:6,l=void 0!==b.bevelSize?b.bevelSize:k-2,n=void 0!==b.bevelSegments?b.bevelSegments:3,p=void 0!==b.bevelEnabled?b.bevelEnabled:!0,
+m=void 0!==b.curveSegments?b.curveSegments:12,q=void 0!==b.steps?b.steps:1,s=b.extrudePath,u,t=!1,x=void 0!==b.UVGenerator?b.UVGenerator:THREE.ExtrudeGeometry.WorldUVGenerator,v,C,w,D;s&&(u=s.getSpacedPoints(q),t=!0,p=!1,v=void 0!==b.frames?b.frames:new THREE.TubeGeometry.FrenetFrames(s,q,!1),C=new THREE.Vector3,w=new THREE.Vector3,D=new THREE.Vector3);p||(l=k=n=0);var z,y,A,H=this,G=this.vertices.length,s=a.extractPoints(m),m=s.shape,E=s.holes;if(s=!THREE.ShapeUtils.isClockWise(m)){m=m.reverse();
+y=0;for(A=E.length;y<A;y++)z=E[y],THREE.ShapeUtils.isClockWise(z)&&(E[y]=z.reverse());s=!1}var K=THREE.ShapeUtils.triangulateShape(m,E),P=m;y=0;for(A=E.length;y<A;y++)z=E[y],m=m.concat(z);var N,L,B,M,Q,O=m.length,S,J=K.length,s=[],F=0;B=P.length;N=B-1;for(L=F+1;F<B;F++,N++,L++)N===B&&(N=0),L===B&&(L=0),s[F]=d(P[F],P[N],P[L]);var Y=[],V,aa=s.concat();y=0;for(A=E.length;y<A;y++){z=E[y];V=[];F=0;B=z.length;N=B-1;for(L=F+1;F<B;F++,N++,L++)N===B&&(N=0),L===B&&(L=0),V[F]=d(z[F],z[N],z[L]);Y.push(V);aa=
+aa.concat(V)}for(N=0;N<n;N++){B=N/n;M=k*(1-B);L=l*Math.sin(B*Math.PI/2);F=0;for(B=P.length;F<B;F++)Q=c(P[F],s[F],L),f(Q.x,Q.y,-M);y=0;for(A=E.length;y<A;y++)for(z=E[y],V=Y[y],F=0,B=z.length;F<B;F++)Q=c(z[F],V[F],L),f(Q.x,Q.y,-M)}L=l;for(F=0;F<O;F++)Q=p?c(m[F],aa[F],L):m[F],t?(w.copy(v.normals[0]).multiplyScalar(Q.x),C.copy(v.binormals[0]).multiplyScalar(Q.y),D.copy(u[0]).add(w).add(C),f(D.x,D.y,D.z)):f(Q.x,Q.y,0);for(B=1;B<=q;B++)for(F=0;F<O;F++)Q=p?c(m[F],aa[F],L):m[F],t?(w.copy(v.normals[B]).multiplyScalar(Q.x),
+C.copy(v.binormals[B]).multiplyScalar(Q.y),D.copy(u[B]).add(w).add(C),f(D.x,D.y,D.z)):f(Q.x,Q.y,h/q*B);for(N=n-1;0<=N;N--){B=N/n;M=k*(1-B);L=l*Math.sin(B*Math.PI/2);F=0;for(B=P.length;F<B;F++)Q=c(P[F],s[F],L),f(Q.x,Q.y,h+M);y=0;for(A=E.length;y<A;y++)for(z=E[y],V=Y[y],F=0,B=z.length;F<B;F++)Q=c(z[F],V[F],L),t?f(Q.x,Q.y+u[q-1].y,u[q-1].x+M):f(Q.x,Q.y,h+M)}(function(){if(p){var a;a=0*O;for(F=0;F<J;F++)S=K[F],g(S[2]+a,S[1]+a,S[0]+a);a=q+2*n;a*=O;for(F=0;F<J;F++)S=K[F],g(S[0]+a,S[1]+a,S[2]+a)}else{for(F=
+0;F<J;F++)S=K[F],g(S[2],S[1],S[0]);for(F=0;F<J;F++)S=K[F],g(S[0]+O*q,S[1]+O*q,S[2]+O*q)}})();(function(){var a=0;e(P,a);a+=P.length;y=0;for(A=E.length;y<A;y++)z=E[y],e(z,a),a+=z.length})()};
+THREE.ExtrudeGeometry.WorldUVGenerator={generateTopUV:function(a,b,c,d){a=a.vertices;b=a[b];c=a[c];d=a[d];return[new THREE.Vector2(b.x,b.y),new THREE.Vector2(c.x,c.y),new THREE.Vector2(d.x,d.y)]},generateSideWallUV:function(a,b,c,d,e){a=a.vertices;b=a[b];c=a[c];d=a[d];e=a[e];return.01>Math.abs(b.y-c.y)?[new THREE.Vector2(b.x,1-b.z),new THREE.Vector2(c.x,1-c.z),new THREE.Vector2(d.x,1-d.z),new THREE.Vector2(e.x,1-e.z)]:[new THREE.Vector2(b.y,1-b.z),new THREE.Vector2(c.y,1-c.z),new THREE.Vector2(d.y,
+1-d.z),new THREE.Vector2(e.y,1-e.z)]}};THREE.ShapeGeometry=function(a,b){THREE.Geometry.call(this);this.type="ShapeGeometry";!1===Array.isArray(a)&&(a=[a]);this.addShapeList(a,b);this.computeFaceNormals()};THREE.ShapeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ShapeGeometry.prototype.constructor=THREE.ShapeGeometry;THREE.ShapeGeometry.prototype.addShapeList=function(a,b){for(var c=0,d=a.length;c<d;c++)this.addShape(a[c],b);return this};
+THREE.ShapeGeometry.prototype.addShape=function(a,b){void 0===b&&(b={});var c=b.material,d=void 0===b.UVGenerator?THREE.ExtrudeGeometry.WorldUVGenerator:b.UVGenerator,e,f,g,h=this.vertices.length;e=a.extractPoints(void 0!==b.curveSegments?b.curveSegments:12);var k=e.shape,l=e.holes;if(!THREE.ShapeUtils.isClockWise(k))for(k=k.reverse(),e=0,f=l.length;e<f;e++)g=l[e],THREE.ShapeUtils.isClockWise(g)&&(l[e]=g.reverse());var n=THREE.ShapeUtils.triangulateShape(k,l);e=0;for(f=l.length;e<f;e++)g=l[e],k=k.concat(g);
+l=k.length;f=n.length;for(e=0;e<l;e++)g=k[e],this.vertices.push(new THREE.Vector3(g.x,g.y,0));for(e=0;e<f;e++)l=n[e],k=l[0]+h,g=l[1]+h,l=l[2]+h,this.faces.push(new THREE.Face3(k,g,l,null,null,c)),this.faceVertexUvs[0].push(d.generateTopUV(this,k,g,l))};
+THREE.LatheGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="LatheGeometry";this.parameters={points:a,segments:b,phiStart:c,phiLength:d};b=b||12;c=c||0;d=d||2*Math.PI;for(var e=1/(a.length-1),f=1/b,g=0,h=b;g<=h;g++)for(var k=c+g*f*d,l=Math.sin(k),n=Math.cos(k),k=0,p=a.length;k<p;k++){var m=a[k],q=new THREE.Vector3;q.x=m.x*l;q.y=m.y;q.z=m.x*n;this.vertices.push(q)}c=a.length;g=0;for(h=b;g<h;g++)for(k=0,p=a.length-1;k<p;k++){b=k+c*g;d=b+c;var l=b+1+c,n=b+1,m=g*f,q=k*e,s=m+f,u=q+e;this.faces.push(new THREE.Face3(b,
+d,n));this.faceVertexUvs[0].push([new THREE.Vector2(m,q),new THREE.Vector2(s,q),new THREE.Vector2(m,u)]);this.faces.push(new THREE.Face3(d,l,n));this.faceVertexUvs[0].push([new THREE.Vector2(s,q),new THREE.Vector2(s,u),new THREE.Vector2(m,u)])}this.mergeVertices();this.computeFaceNormals();this.computeVertexNormals()};THREE.LatheGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.LatheGeometry.prototype.constructor=THREE.LatheGeometry;
+THREE.PlaneGeometry=function(a,b,c,d){THREE.Geometry.call(this);this.type="PlaneGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};this.fromBufferGeometry(new THREE.PlaneBufferGeometry(a,b,c,d))};THREE.PlaneGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.PlaneGeometry.prototype.constructor=THREE.PlaneGeometry;
+THREE.PlaneBufferGeometry=function(a,b,c,d){THREE.BufferGeometry.call(this);this.type="PlaneBufferGeometry";this.parameters={width:a,height:b,widthSegments:c,heightSegments:d};var e=a/2,f=b/2;c=Math.floor(c)||1;d=Math.floor(d)||1;var g=c+1,h=d+1,k=a/c,l=b/d;b=new Float32Array(g*h*3);a=new Float32Array(g*h*3);for(var n=new Float32Array(g*h*2),p=0,m=0,q=0;q<h;q++)for(var s=q*l-f,u=0;u<g;u++)b[p]=u*k-e,b[p+1]=-s,a[p+2]=1,n[m]=u/c,n[m+1]=1-q/d,p+=3,m+=2;p=0;e=new (65535<b.length/3?Uint32Array:Uint16Array)(c*
+d*6);for(q=0;q<d;q++)for(u=0;u<c;u++)f=u+g*(q+1),h=u+1+g*(q+1),k=u+1+g*q,e[p]=u+g*q,e[p+1]=f,e[p+2]=k,e[p+3]=f,e[p+4]=h,e[p+5]=k,p+=6;this.setIndex(new THREE.BufferAttribute(e,1));this.addAttribute("position",new THREE.BufferAttribute(b,3));this.addAttribute("normal",new THREE.BufferAttribute(a,3));this.addAttribute("uv",new THREE.BufferAttribute(n,2))};THREE.PlaneBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.PlaneBufferGeometry.prototype.constructor=THREE.PlaneBufferGeometry;
+THREE.RingGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.type="RingGeometry";this.parameters={innerRadius:a,outerRadius:b,thetaSegments:c,phiSegments:d,thetaStart:e,thetaLength:f};a=a||0;b=b||50;e=void 0!==e?e:0;f=void 0!==f?f:2*Math.PI;c=void 0!==c?Math.max(3,c):8;d=void 0!==d?Math.max(1,d):8;var g,h=[],k=a,l=(b-a)/d;for(a=0;a<d+1;a++){for(g=0;g<c+1;g++){var n=new THREE.Vector3,p=e+g/c*f;n.x=k*Math.cos(p);n.y=k*Math.sin(p);this.vertices.push(n);h.push(new THREE.Vector2((n.x/b+1)/2,
+(n.y/b+1)/2))}k+=l}b=new THREE.Vector3(0,0,1);for(a=0;a<d;a++)for(e=a*(c+1),g=0;g<c;g++)f=p=g+e,l=p+c+1,n=p+c+2,this.faces.push(new THREE.Face3(f,l,n,[b.clone(),b.clone(),b.clone()])),this.faceVertexUvs[0].push([h[f].clone(),h[l].clone(),h[n].clone()]),f=p,l=p+c+2,n=p+1,this.faces.push(new THREE.Face3(f,l,n,[b.clone(),b.clone(),b.clone()])),this.faceVertexUvs[0].push([h[f].clone(),h[l].clone(),h[n].clone()]);this.computeFaceNormals();this.boundingSphere=new THREE.Sphere(new THREE.Vector3,k)};
+THREE.RingGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.RingGeometry.prototype.constructor=THREE.RingGeometry;THREE.SphereGeometry=function(a,b,c,d,e,f,g){THREE.Geometry.call(this);this.type="SphereGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};this.fromBufferGeometry(new THREE.SphereBufferGeometry(a,b,c,d,e,f,g))};THREE.SphereGeometry.prototype=Object.create(THREE.Geometry.prototype);
+THREE.SphereGeometry.prototype.constructor=THREE.SphereGeometry;
+THREE.SphereBufferGeometry=function(a,b,c,d,e,f,g){THREE.BufferGeometry.call(this);this.type="SphereBufferGeometry";this.parameters={radius:a,widthSegments:b,heightSegments:c,phiStart:d,phiLength:e,thetaStart:f,thetaLength:g};a=a||50;b=Math.max(3,Math.floor(b)||8);c=Math.max(2,Math.floor(c)||6);d=void 0!==d?d:0;e=void 0!==e?e:2*Math.PI;f=void 0!==f?f:0;g=void 0!==g?g:Math.PI;for(var h=f+g,k=(b+1)*(c+1),l=new THREE.BufferAttribute(new Float32Array(3*k),3),n=new THREE.BufferAttribute(new Float32Array(3*
+k),3),k=new THREE.BufferAttribute(new Float32Array(2*k),2),p=0,m=[],q=new THREE.Vector3,s=0;s<=c;s++){for(var u=[],t=s/c,x=0;x<=b;x++){var v=x/b,C=-a*Math.cos(d+v*e)*Math.sin(f+t*g),w=a*Math.cos(f+t*g),D=a*Math.sin(d+v*e)*Math.sin(f+t*g);q.set(C,w,D).normalize();l.setXYZ(p,C,w,D);n.setXYZ(p,q.x,q.y,q.z);k.setXY(p,v,1-t);u.push(p);p++}m.push(u)}d=[];for(s=0;s<c;s++)for(x=0;x<b;x++)e=m[s][x+1],g=m[s][x],p=m[s+1][x],q=m[s+1][x+1],(0!==s||0<f)&&d.push(e,g,q),(s!==c-1||h<Math.PI)&&d.push(g,p,q);this.setIndex(new (65535<
+l.count?THREE.Uint32Attribute:THREE.Uint16Attribute)(d,1));this.addAttribute("position",l);this.addAttribute("normal",n);this.addAttribute("uv",k);this.boundingSphere=new THREE.Sphere(new THREE.Vector3,a)};THREE.SphereBufferGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);THREE.SphereBufferGeometry.prototype.constructor=THREE.SphereBufferGeometry;
+THREE.TextGeometry=function(a,b){b=b||{};var c=b.font;if(!1===c instanceof THREE.Font)return console.error("THREE.TextGeometry: font parameter is not an instance of THREE.Font."),new THREE.Geometry;c=c.generateShapes(a,b.size,b.curveSegments);b.amount=void 0!==b.height?b.height:50;void 0===b.bevelThickness&&(b.bevelThickness=10);void 0===b.bevelSize&&(b.bevelSize=8);void 0===b.bevelEnabled&&(b.bevelEnabled=!1);THREE.ExtrudeGeometry.call(this,c,b);this.type="TextGeometry"};
+THREE.TextGeometry.prototype=Object.create(THREE.ExtrudeGeometry.prototype);THREE.TextGeometry.prototype.constructor=THREE.TextGeometry;
+THREE.TorusGeometry=function(a,b,c,d,e){THREE.Geometry.call(this);this.type="TorusGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,arc:e};a=a||100;b=b||40;c=c||8;d=d||6;e=e||2*Math.PI;for(var f=new THREE.Vector3,g=[],h=[],k=0;k<=c;k++)for(var l=0;l<=d;l++){var n=l/d*e,p=k/c*Math.PI*2;f.x=a*Math.cos(n);f.y=a*Math.sin(n);var m=new THREE.Vector3;m.x=(a+b*Math.cos(p))*Math.cos(n);m.y=(a+b*Math.cos(p))*Math.sin(n);m.z=b*Math.sin(p);this.vertices.push(m);g.push(new THREE.Vector2(l/
+d,k/c));h.push(m.clone().sub(f).normalize())}for(k=1;k<=c;k++)for(l=1;l<=d;l++)a=(d+1)*k+l-1,b=(d+1)*(k-1)+l-1,e=(d+1)*(k-1)+l,f=(d+1)*k+l,n=new THREE.Face3(a,b,f,[h[a].clone(),h[b].clone(),h[f].clone()]),this.faces.push(n),this.faceVertexUvs[0].push([g[a].clone(),g[b].clone(),g[f].clone()]),n=new THREE.Face3(b,e,f,[h[b].clone(),h[e].clone(),h[f].clone()]),this.faces.push(n),this.faceVertexUvs[0].push([g[b].clone(),g[e].clone(),g[f].clone()]);this.computeFaceNormals()};
+THREE.TorusGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TorusGeometry.prototype.constructor=THREE.TorusGeometry;
+THREE.TorusKnotGeometry=function(a,b,c,d,e,f,g){function h(a,b,c,d,e){var f=Math.cos(a),g=Math.sin(a);a*=b/c;b=Math.cos(a);f*=d*(2+b)*.5;g=d*(2+b)*g*.5;d=e*d*Math.sin(a)*.5;return new THREE.Vector3(f,g,d)}THREE.Geometry.call(this);this.type="TorusKnotGeometry";this.parameters={radius:a,tube:b,radialSegments:c,tubularSegments:d,p:e,q:f,heightScale:g};a=a||100;b=b||40;c=c||64;d=d||8;e=e||2;f=f||3;g=g||1;for(var k=Array(c),l=new THREE.Vector3,n=new THREE.Vector3,p=new THREE.Vector3,m=0;m<c;++m){k[m]=
+Array(d);var q=m/c*2*e*Math.PI,s=h(q,f,e,a,g),q=h(q+.01,f,e,a,g);l.subVectors(q,s);n.addVectors(q,s);p.crossVectors(l,n);n.crossVectors(p,l);p.normalize();n.normalize();for(q=0;q<d;++q){var u=q/d*2*Math.PI,t=-b*Math.cos(u),u=b*Math.sin(u),x=new THREE.Vector3;x.x=s.x+t*n.x+u*p.x;x.y=s.y+t*n.y+u*p.y;x.z=s.z+t*n.z+u*p.z;k[m][q]=this.vertices.push(x)-1}}for(m=0;m<c;++m)for(q=0;q<d;++q)e=(m+1)%c,f=(q+1)%d,a=k[m][q],b=k[e][q],e=k[e][f],f=k[m][f],g=new THREE.Vector2(m/c,q/d),l=new THREE.Vector2((m+1)/c,
+q/d),n=new THREE.Vector2((m+1)/c,(q+1)/d),p=new THREE.Vector2(m/c,(q+1)/d),this.faces.push(new THREE.Face3(a,b,f)),this.faceVertexUvs[0].push([g,l,p]),this.faces.push(new THREE.Face3(b,e,f)),this.faceVertexUvs[0].push([l.clone(),n,p.clone()]);this.computeFaceNormals();this.computeVertexNormals()};THREE.TorusKnotGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TorusKnotGeometry.prototype.constructor=THREE.TorusKnotGeometry;
+THREE.TubeGeometry=function(a,b,c,d,e,f){THREE.Geometry.call(this);this.type="TubeGeometry";this.parameters={path:a,segments:b,radius:c,radialSegments:d,closed:e,taper:f};b=b||64;c=c||1;d=d||8;e=e||!1;f=f||THREE.TubeGeometry.NoTaper;var g=[],h,k,l=b+1,n,p,m,q,s,u=new THREE.Vector3,t,x,v;t=new THREE.TubeGeometry.FrenetFrames(a,b,e);x=t.normals;v=t.binormals;this.tangents=t.tangents;this.normals=x;this.binormals=v;for(t=0;t<l;t++)for(g[t]=[],n=t/(l-1),s=a.getPointAt(n),h=x[t],k=v[t],m=c*f(n),n=0;n<
+d;n++)p=n/d*2*Math.PI,q=-m*Math.cos(p),p=m*Math.sin(p),u.copy(s),u.x+=q*h.x+p*k.x,u.y+=q*h.y+p*k.y,u.z+=q*h.z+p*k.z,g[t][n]=this.vertices.push(new THREE.Vector3(u.x,u.y,u.z))-1;for(t=0;t<b;t++)for(n=0;n<d;n++)f=e?(t+1)%b:t+1,l=(n+1)%d,a=g[t][n],c=g[f][n],f=g[f][l],l=g[t][l],u=new THREE.Vector2(t/b,n/d),x=new THREE.Vector2((t+1)/b,n/d),v=new THREE.Vector2((t+1)/b,(n+1)/d),h=new THREE.Vector2(t/b,(n+1)/d),this.faces.push(new THREE.Face3(a,c,l)),this.faceVertexUvs[0].push([u,x,h]),this.faces.push(new THREE.Face3(c,
+f,l)),this.faceVertexUvs[0].push([x.clone(),v,h.clone()]);this.computeFaceNormals();this.computeVertexNormals()};THREE.TubeGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.TubeGeometry.prototype.constructor=THREE.TubeGeometry;THREE.TubeGeometry.NoTaper=function(a){return 1};THREE.TubeGeometry.SinusoidalTaper=function(a){return Math.sin(Math.PI*a)};
+THREE.TubeGeometry.FrenetFrames=function(a,b,c){var d=new THREE.Vector3,e=[],f=[],g=[],h=new THREE.Vector3,k=new THREE.Matrix4;b+=1;var l,n,p;this.tangents=e;this.normals=f;this.binormals=g;for(l=0;l<b;l++)n=l/(b-1),e[l]=a.getTangentAt(n),e[l].normalize();f[0]=new THREE.Vector3;g[0]=new THREE.Vector3;a=Number.MAX_VALUE;l=Math.abs(e[0].x);n=Math.abs(e[0].y);p=Math.abs(e[0].z);l<=a&&(a=l,d.set(1,0,0));n<=a&&(a=n,d.set(0,1,0));p<=a&&d.set(0,0,1);h.crossVectors(e[0],d).normalize();f[0].crossVectors(e[0],
+h);g[0].crossVectors(e[0],f[0]);for(l=1;l<b;l++)f[l]=f[l-1].clone(),g[l]=g[l-1].clone(),h.crossVectors(e[l-1],e[l]),h.length()>Number.EPSILON&&(h.normalize(),d=Math.acos(THREE.Math.clamp(e[l-1].dot(e[l]),-1,1)),f[l].applyMatrix4(k.makeRotationAxis(h,d))),g[l].crossVectors(e[l],f[l]);if(c)for(d=Math.acos(THREE.Math.clamp(f[0].dot(f[b-1]),-1,1)),d/=b-1,0<e[0].dot(h.crossVectors(f[0],f[b-1]))&&(d=-d),l=1;l<b;l++)f[l].applyMatrix4(k.makeRotationAxis(e[l],d*l)),g[l].crossVectors(e[l],f[l])};
+THREE.PolyhedronGeometry=function(a,b,c,d){function e(a){var b=a.normalize().clone();b.index=k.vertices.push(b)-1;var c=Math.atan2(a.z,-a.x)/2/Math.PI+.5;a=Math.atan2(-a.y,Math.sqrt(a.x*a.x+a.z*a.z))/Math.PI+.5;b.uv=new THREE.Vector2(c,1-a);return b}function f(a,b,c,d){d=new THREE.Face3(a.index,b.index,c.index,[a.clone(),b.clone(),c.clone()],void 0,d);k.faces.push(d);t.copy(a).add(b).add(c).divideScalar(3);d=Math.atan2(t.z,-t.x);k.faceVertexUvs[0].push([h(a.uv,a,d),h(b.uv,b,d),h(c.uv,c,d)])}function g(a,
+b){for(var c=Math.pow(2,b),d=e(k.vertices[a.a]),g=e(k.vertices[a.b]),h=e(k.vertices[a.c]),l=[],m=a.materialIndex,n=0;n<=c;n++){l[n]=[];for(var p=e(d.clone().lerp(h,n/c)),q=e(g.clone().lerp(h,n/c)),s=c-n,t=0;t<=s;t++)l[n][t]=0===t&&n===c?p:e(p.clone().lerp(q,t/s))}for(n=0;n<c;n++)for(t=0;t<2*(c-n)-1;t++)d=Math.floor(t/2),0===t%2?f(l[n][d+1],l[n+1][d],l[n][d],m):f(l[n][d+1],l[n+1][d+1],l[n+1][d],m)}function h(a,b,c){0>c&&1===a.x&&(a=new THREE.Vector2(a.x-1,a.y));0===b.x&&0===b.z&&(a=new THREE.Vector2(c/
+2/Math.PI+.5,a.y));return a.clone()}THREE.Geometry.call(this);this.type="PolyhedronGeometry";this.parameters={vertices:a,indices:b,radius:c,detail:d};c=c||1;d=d||0;for(var k=this,l=0,n=a.length;l<n;l+=3)e(new THREE.Vector3(a[l],a[l+1],a[l+2]));a=this.vertices;for(var p=[],m=l=0,n=b.length;l<n;l+=3,m++){var q=a[b[l]],s=a[b[l+1]],u=a[b[l+2]];p[m]=new THREE.Face3(q.index,s.index,u.index,[q.clone(),s.clone(),u.clone()],void 0,m)}for(var t=new THREE.Vector3,l=0,n=p.length;l<n;l++)g(p[l],d);l=0;for(n=this.faceVertexUvs[0].length;l<
+n;l++)b=this.faceVertexUvs[0][l],d=b[0].x,a=b[1].x,p=b[2].x,m=Math.max(d,a,p),q=Math.min(d,a,p),.9<m&&.1>q&&(.2>d&&(b[0].x+=1),.2>a&&(b[1].x+=1),.2>p&&(b[2].x+=1));l=0;for(n=this.vertices.length;l<n;l++)this.vertices[l].multiplyScalar(c);this.mergeVertices();this.computeFaceNormals();this.boundingSphere=new THREE.Sphere(new THREE.Vector3,c)};THREE.PolyhedronGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.PolyhedronGeometry.prototype.constructor=THREE.PolyhedronGeometry;
+THREE.DodecahedronGeometry=function(a,b){var c=(1+Math.sqrt(5))/2,d=1/c;THREE.PolyhedronGeometry.call(this,[-1,-1,-1,-1,-1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,1,1,1,-1,1,1,1,0,-d,-c,0,-d,c,0,d,-c,0,d,c,-d,-c,0,-d,c,0,d,-c,0,d,c,0,-c,0,-d,c,0,-d,-c,0,d,c,0,d],[3,11,7,3,7,15,3,15,13,7,19,17,7,17,6,7,6,15,17,4,8,17,8,10,17,10,6,8,0,16,8,16,2,8,2,10,0,12,1,0,1,18,0,18,16,6,10,2,6,2,13,6,13,15,2,16,18,2,18,3,2,3,13,18,1,9,18,9,11,18,11,3,4,14,12,4,12,0,4,0,8,11,9,5,11,5,19,11,19,7,19,5,14,19,14,4,19,4,17,1,
+12,14,1,14,5,1,5,9],a,b);this.type="DodecahedronGeometry";this.parameters={radius:a,detail:b}};THREE.DodecahedronGeometry.prototype=Object.create(THREE.PolyhedronGeometry.prototype);THREE.DodecahedronGeometry.prototype.constructor=THREE.DodecahedronGeometry;
+THREE.IcosahedronGeometry=function(a,b){var c=(1+Math.sqrt(5))/2;THREE.PolyhedronGeometry.call(this,[-1,c,0,1,c,0,-1,-c,0,1,-c,0,0,-1,c,0,1,c,0,-1,-c,0,1,-c,c,0,-1,c,0,1,-c,0,-1,-c,0,1],[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1],a,b);this.type="IcosahedronGeometry";this.parameters={radius:a,detail:b}};THREE.IcosahedronGeometry.prototype=Object.create(THREE.PolyhedronGeometry.prototype);
+THREE.IcosahedronGeometry.prototype.constructor=THREE.IcosahedronGeometry;THREE.OctahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[1,0,0,-1,0,0,0,1,0,0,-1,0,0,0,1,0,0,-1],[0,2,4,0,4,3,0,3,5,0,5,2,1,2,5,1,5,3,1,3,4,1,4,2],a,b);this.type="OctahedronGeometry";this.parameters={radius:a,detail:b}};THREE.OctahedronGeometry.prototype=Object.create(THREE.PolyhedronGeometry.prototype);THREE.OctahedronGeometry.prototype.constructor=THREE.OctahedronGeometry;
+THREE.TetrahedronGeometry=function(a,b){THREE.PolyhedronGeometry.call(this,[1,1,1,-1,-1,1,-1,1,-1,1,-1,-1],[2,1,0,0,3,2,1,3,0,2,3,1],a,b);this.type="TetrahedronGeometry";this.parameters={radius:a,detail:b}};THREE.TetrahedronGeometry.prototype=Object.create(THREE.PolyhedronGeometry.prototype);THREE.TetrahedronGeometry.prototype.constructor=THREE.TetrahedronGeometry;
+THREE.ParametricGeometry=function(a,b,c){THREE.Geometry.call(this);this.type="ParametricGeometry";this.parameters={func:a,slices:b,stacks:c};var d=this.vertices,e=this.faces,f=this.faceVertexUvs[0],g,h,k,l,n=b+1;for(g=0;g<=c;g++)for(l=g/c,h=0;h<=b;h++)k=h/b,k=a(k,l),d.push(k);var p,m,q,s;for(g=0;g<c;g++)for(h=0;h<b;h++)a=g*n+h,d=g*n+h+1,l=(g+1)*n+h+1,k=(g+1)*n+h,p=new THREE.Vector2(h/b,g/c),m=new THREE.Vector2((h+1)/b,g/c),q=new THREE.Vector2((h+1)/b,(g+1)/c),s=new THREE.Vector2(h/b,(g+1)/c),e.push(new THREE.Face3(a,
+d,k)),f.push([p,m,s]),e.push(new THREE.Face3(d,l,k)),f.push([m.clone(),q,s.clone()]);this.computeFaceNormals();this.computeVertexNormals()};THREE.ParametricGeometry.prototype=Object.create(THREE.Geometry.prototype);THREE.ParametricGeometry.prototype.constructor=THREE.ParametricGeometry;
+THREE.WireframeGeometry=function(a){function b(a,b){return a-b}THREE.BufferGeometry.call(this);var c=[0,0],d={},e=["a","b","c"];if(a instanceof THREE.Geometry){var f=a.vertices,g=a.faces,h=0,k=new Uint32Array(6*g.length);a=0;for(var l=g.length;a<l;a++)for(var n=g[a],p=0;3>p;p++){c[0]=n[e[p]];c[1]=n[e[(p+1)%3]];c.sort(b);var m=c.toString();void 0===d[m]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[m]=!0,h++)}c=new Float32Array(6*h);a=0;for(l=h;a<l;a++)for(p=0;2>p;p++)d=f[k[2*a+p]],h=6*a+3*p,c[h+0]=d.x,c[h+1]=d.y,
+c[h+2]=d.z;this.addAttribute("position",new THREE.BufferAttribute(c,3))}else if(a instanceof THREE.BufferGeometry){if(null!==a.index){l=a.index.array;f=a.attributes.position;e=a.groups;h=0;0===e.length&&a.addGroup(0,l.length);k=new Uint32Array(2*l.length);g=0;for(n=e.length;g<n;++g){a=e[g];p=a.start;m=a.count;a=p;for(var q=p+m;a<q;a+=3)for(p=0;3>p;p++)c[0]=l[a+p],c[1]=l[a+(p+1)%3],c.sort(b),m=c.toString(),void 0===d[m]&&(k[2*h]=c[0],k[2*h+1]=c[1],d[m]=!0,h++)}c=new Float32Array(6*h);a=0;for(l=h;a<
+l;a++)for(p=0;2>p;p++)h=6*a+3*p,d=k[2*a+p],c[h+0]=f.getX(d),c[h+1]=f.getY(d),c[h+2]=f.getZ(d)}else for(f=a.attributes.position.array,h=f.length/3,k=h/3,c=new Float32Array(6*h),a=0,l=k;a<l;a++)for(p=0;3>p;p++)h=18*a+6*p,k=9*a+3*p,c[h+0]=f[k],c[h+1]=f[k+1],c[h+2]=f[k+2],d=9*a+(p+1)%3*3,c[h+3]=f[d],c[h+4]=f[d+1],c[h+5]=f[d+2];this.addAttribute("position",new THREE.BufferAttribute(c,3))}};THREE.WireframeGeometry.prototype=Object.create(THREE.BufferGeometry.prototype);
+THREE.WireframeGeometry.prototype.constructor=THREE.WireframeGeometry;THREE.AxisHelper=function(a){a=a||1;var b=new Float32Array([0,0,0,a,0,0,0,0,0,0,a,0,0,0,0,0,0,a]),c=new Float32Array([1,0,0,1,.6,0,0,1,0,.6,1,0,0,0,1,0,.6,1]);a=new THREE.BufferGeometry;a.addAttribute("position",new THREE.BufferAttribute(b,3));a.addAttribute("color",new THREE.BufferAttribute(c,3));b=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});THREE.LineSegments.call(this,a,b)};THREE.AxisHelper.prototype=Object.create(THREE.LineSegments.prototype);
+THREE.AxisHelper.prototype.constructor=THREE.AxisHelper;
+THREE.ArrowHelper=function(){var a=new THREE.Geometry;a.vertices.push(new THREE.Vector3(0,0,0),new THREE.Vector3(0,1,0));var b=new THREE.CylinderGeometry(0,.5,1,5,1);b.translate(0,-.5,0);return function(c,d,e,f,g,h){THREE.Object3D.call(this);void 0===f&&(f=16776960);void 0===e&&(e=1);void 0===g&&(g=.2*e);void 0===h&&(h=.2*g);this.position.copy(d);this.line=new THREE.Line(a,new THREE.LineBasicMaterial({color:f}));this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new THREE.Mesh(b,new THREE.MeshBasicMaterial({color:f}));
+this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(c);this.setLength(e,g,h)}}();THREE.ArrowHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.ArrowHelper.prototype.constructor=THREE.ArrowHelper;THREE.ArrowHelper.prototype.setDirection=function(){var a=new THREE.Vector3,b;return function(c){.99999<c.y?this.quaternion.set(0,0,0,1):-.99999>c.y?this.quaternion.set(1,0,0,0):(a.set(c.z,0,-c.x).normalize(),b=Math.acos(c.y),this.quaternion.setFromAxisAngle(a,b))}}();
+THREE.ArrowHelper.prototype.setLength=function(a,b,c){void 0===b&&(b=.2*a);void 0===c&&(c=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(c,b,c);this.cone.position.y=a;this.cone.updateMatrix()};THREE.ArrowHelper.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};
+THREE.BoxHelper=function(a){var b=new Uint16Array([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7]),c=new Float32Array(24),d=new THREE.BufferGeometry;d.setIndex(new THREE.BufferAttribute(b,1));d.addAttribute("position",new THREE.BufferAttribute(c,3));THREE.LineSegments.call(this,d,new THREE.LineBasicMaterial({color:16776960}));void 0!==a&&this.update(a)};THREE.BoxHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.BoxHelper.prototype.constructor=THREE.BoxHelper;
+THREE.BoxHelper.prototype.update=function(){var a=new THREE.Box3;return function(b){a.setFromObject(b);if(!a.isEmpty()){b=a.min;var c=a.max,d=this.geometry.attributes.position,e=d.array;e[0]=c.x;e[1]=c.y;e[2]=c.z;e[3]=b.x;e[4]=c.y;e[5]=c.z;e[6]=b.x;e[7]=b.y;e[8]=c.z;e[9]=c.x;e[10]=b.y;e[11]=c.z;e[12]=c.x;e[13]=c.y;e[14]=b.z;e[15]=b.x;e[16]=c.y;e[17]=b.z;e[18]=b.x;e[19]=b.y;e[20]=b.z;e[21]=c.x;e[22]=b.y;e[23]=b.z;d.needsUpdate=!0;this.geometry.computeBoundingSphere()}}}();
+THREE.BoundingBoxHelper=function(a,b){var c=void 0!==b?b:8947848;this.object=a;this.box=new THREE.Box3;THREE.Mesh.call(this,new THREE.BoxGeometry(1,1,1),new THREE.MeshBasicMaterial({color:c,wireframe:!0}))};THREE.BoundingBoxHelper.prototype=Object.create(THREE.Mesh.prototype);THREE.BoundingBoxHelper.prototype.constructor=THREE.BoundingBoxHelper;THREE.BoundingBoxHelper.prototype.update=function(){this.box.setFromObject(this.object);this.box.size(this.scale);this.box.center(this.position)};
+THREE.CameraHelper=function(a){function b(a,b,d){c(a,d);c(b,d)}function c(a,b){d.vertices.push(new THREE.Vector3);d.colors.push(new THREE.Color(b));void 0===f[a]&&(f[a]=[]);f[a].push(d.vertices.length-1)}var d=new THREE.Geometry,e=new THREE.LineBasicMaterial({color:16777215,vertexColors:THREE.FaceColors}),f={};b("n1","n2",16755200);b("n2","n4",16755200);b("n4","n3",16755200);b("n3","n1",16755200);b("f1","f2",16755200);b("f2","f4",16755200);b("f4","f3",16755200);b("f3","f1",16755200);b("n1","f1",16755200);
+b("n2","f2",16755200);b("n3","f3",16755200);b("n4","f4",16755200);b("p","n1",16711680);b("p","n2",16711680);b("p","n3",16711680);b("p","n4",16711680);b("u1","u2",43775);b("u2","u3",43775);b("u3","u1",43775);b("c","t",16777215);b("p","c",3355443);b("cn1","cn2",3355443);b("cn3","cn4",3355443);b("cf1","cf2",3355443);b("cf3","cf4",3355443);THREE.LineSegments.call(this,d,e);this.camera=a;this.camera.updateProjectionMatrix();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.pointMap=f;this.update()};
+THREE.CameraHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.CameraHelper.prototype.constructor=THREE.CameraHelper;
+THREE.CameraHelper.prototype.update=function(){function a(a,g,h,k){d.set(g,h,k).unproject(e);a=c[a];if(void 0!==a)for(g=0,h=a.length;g<h;g++)b.vertices[a[g]].copy(d)}var b,c,d=new THREE.Vector3,e=new THREE.Camera;return function(){b=this.geometry;c=this.pointMap;e.projectionMatrix.copy(this.camera.projectionMatrix);a("c",0,0,-1);a("t",0,0,1);a("n1",-1,-1,-1);a("n2",1,-1,-1);a("n3",-1,1,-1);a("n4",1,1,-1);a("f1",-1,-1,1);a("f2",1,-1,1);a("f3",-1,1,1);a("f4",1,1,1);a("u1",.7,1.1,-1);a("u2",-.7,1.1,
+-1);a("u3",0,2,-1);a("cf1",-1,0,1);a("cf2",1,0,1);a("cf3",0,-1,1);a("cf4",0,1,1);a("cn1",-1,0,-1);a("cn2",1,0,-1);a("cn3",0,-1,-1);a("cn4",0,1,-1);b.verticesNeedUpdate=!0}}();
+THREE.DirectionalLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;b=b||1;var c=new THREE.Geometry;c.vertices.push(new THREE.Vector3(-b,b,0),new THREE.Vector3(b,b,0),new THREE.Vector3(b,-b,0),new THREE.Vector3(-b,-b,0),new THREE.Vector3(-b,b,0));var d=new THREE.LineBasicMaterial({fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.lightPlane=new THREE.Line(c,d);this.add(this.lightPlane);
+c=new THREE.Geometry;c.vertices.push(new THREE.Vector3,new THREE.Vector3);d=new THREE.LineBasicMaterial({fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.targetLine=new THREE.Line(c,d);this.add(this.targetLine);this.update()};THREE.DirectionalLightHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.DirectionalLightHelper.prototype.constructor=THREE.DirectionalLightHelper;
+THREE.DirectionalLightHelper.prototype.dispose=function(){this.lightPlane.geometry.dispose();this.lightPlane.material.dispose();this.targetLine.geometry.dispose();this.targetLine.material.dispose()};
+THREE.DirectionalLightHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Vector3;return function(){a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);c.subVectors(b,a);this.lightPlane.lookAt(c);this.lightPlane.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);this.targetLine.geometry.vertices[1].copy(c);this.targetLine.geometry.verticesNeedUpdate=!0;this.targetLine.material.color.copy(this.lightPlane.material.color)}}();
+THREE.EdgesHelper=function(a,b,c){b=void 0!==b?b:16777215;THREE.LineSegments.call(this,new THREE.EdgesGeometry(a.geometry,c),new THREE.LineBasicMaterial({color:b}));this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1};THREE.EdgesHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.EdgesHelper.prototype.constructor=THREE.EdgesHelper;
+THREE.FaceNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16776960;d=void 0!==d?d:1;b=0;c=this.object.geometry;c instanceof THREE.Geometry?b=c.faces.length:console.warn("THREE.FaceNormalsHelper: only THREE.Geometry is supported. Use THREE.VertexNormalsHelper, instead.");c=new THREE.BufferGeometry;b=new THREE.Float32Attribute(6*b,3);c.addAttribute("position",b);THREE.LineSegments.call(this,c,new THREE.LineBasicMaterial({color:a,linewidth:d}));this.matrixAutoUpdate=
+!1;this.update()};THREE.FaceNormalsHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.FaceNormalsHelper.prototype.constructor=THREE.FaceNormalsHelper;
+THREE.FaceNormalsHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Matrix3;return function(){this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);for(var d=this.object.matrixWorld,e=this.geometry.attributes.position,f=this.object.geometry,g=f.vertices,f=f.faces,h=0,k=0,l=f.length;k<l;k++){var n=f[k],p=n.normal;a.copy(g[n.a]).add(g[n.b]).add(g[n.c]).divideScalar(3).applyMatrix4(d);b.copy(p).applyMatrix3(c).normalize().multiplyScalar(this.size).add(a);
+e.setXYZ(h,a.x,a.y,a.z);h+=1;e.setXYZ(h,b.x,b.y,b.z);h+=1}e.needsUpdate=!0;return this}}();
+THREE.GridHelper=function(a,b){var c=new THREE.Geometry,d=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors});this.color1=new THREE.Color(4473924);this.color2=new THREE.Color(8947848);for(var e=-a;e<=a;e+=b){c.vertices.push(new THREE.Vector3(-a,0,e),new THREE.Vector3(a,0,e),new THREE.Vector3(e,0,-a),new THREE.Vector3(e,0,a));var f=0===e?this.color1:this.color2;c.colors.push(f,f,f,f)}THREE.LineSegments.call(this,c,d)};THREE.GridHelper.prototype=Object.create(THREE.LineSegments.prototype);
+THREE.GridHelper.prototype.constructor=THREE.GridHelper;THREE.GridHelper.prototype.setColors=function(a,b){this.color1.set(a);this.color2.set(b);this.geometry.colorsNeedUpdate=!0};
+THREE.HemisphereLightHelper=function(a,b){THREE.Object3D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;this.colors=[new THREE.Color,new THREE.Color];var c=new THREE.SphereGeometry(b,4,2);c.rotateX(-Math.PI/2);for(var d=0;8>d;d++)c.faces[d].color=this.colors[4>d?0:1];d=new THREE.MeshBasicMaterial({vertexColors:THREE.FaceColors,wireframe:!0});this.lightSphere=new THREE.Mesh(c,d);this.add(this.lightSphere);this.update()};
+THREE.HemisphereLightHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.HemisphereLightHelper.prototype.constructor=THREE.HemisphereLightHelper;THREE.HemisphereLightHelper.prototype.dispose=function(){this.lightSphere.geometry.dispose();this.lightSphere.material.dispose()};
+THREE.HemisphereLightHelper.prototype.update=function(){var a=new THREE.Vector3;return function(){this.colors[0].copy(this.light.color).multiplyScalar(this.light.intensity);this.colors[1].copy(this.light.groundColor).multiplyScalar(this.light.intensity);this.lightSphere.lookAt(a.setFromMatrixPosition(this.light.matrixWorld).negate());this.lightSphere.geometry.colorsNeedUpdate=!0}}();
+THREE.PointLightHelper=function(a,b){this.light=a;this.light.updateMatrixWorld();var c=new THREE.SphereGeometry(b,4,2),d=new THREE.MeshBasicMaterial({wireframe:!0,fog:!1});d.color.copy(this.light.color).multiplyScalar(this.light.intensity);THREE.Mesh.call(this,c,d);this.matrix=this.light.matrixWorld;this.matrixAutoUpdate=!1};THREE.PointLightHelper.prototype=Object.create(THREE.Mesh.prototype);THREE.PointLightHelper.prototype.constructor=THREE.PointLightHelper;
+THREE.PointLightHelper.prototype.dispose=function(){this.geometry.dispose();this.material.dispose()};THREE.PointLightHelper.prototype.update=function(){this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)};
+THREE.SkeletonHelper=function(a){this.bones=this.getBoneList(a);for(var b=new THREE.Geometry,c=0;c<this.bones.length;c++)this.bones[c].parent instanceof THREE.Bone&&(b.vertices.push(new THREE.Vector3),b.vertices.push(new THREE.Vector3),b.colors.push(new THREE.Color(0,0,1)),b.colors.push(new THREE.Color(0,1,0)));b.dynamic=!0;c=new THREE.LineBasicMaterial({vertexColors:THREE.VertexColors,depthTest:!1,depthWrite:!1,transparent:!0});THREE.LineSegments.call(this,b,c);this.root=a;this.matrix=a.matrixWorld;
+this.matrixAutoUpdate=!1;this.update()};THREE.SkeletonHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.SkeletonHelper.prototype.constructor=THREE.SkeletonHelper;THREE.SkeletonHelper.prototype.getBoneList=function(a){var b=[];a instanceof THREE.Bone&&b.push(a);for(var c=0;c<a.children.length;c++)b.push.apply(b,this.getBoneList(a.children[c]));return b};
+THREE.SkeletonHelper.prototype.update=function(){for(var a=this.geometry,b=(new THREE.Matrix4).getInverse(this.root.matrixWorld),c=new THREE.Matrix4,d=0,e=0;e<this.bones.length;e++){var f=this.bones[e];f.parent instanceof THREE.Bone&&(c.multiplyMatrices(b,f.matrixWorld),a.vertices[d].setFromMatrixPosition(c),c.multiplyMatrices(b,f.parent.matrixWorld),a.vertices[d+1].setFromMatrixPosition(c),d+=2)}a.verticesNeedUpdate=!0;a.computeBoundingSphere()};
+THREE.SpotLightHelper=function(a){THREE.Object3D.call(this);this.light=a;this.light.updateMatrixWorld();this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1;a=new THREE.CylinderGeometry(0,1,1,8,1,!0);a.translate(0,-.5,0);a.rotateX(-Math.PI/2);var b=new THREE.MeshBasicMaterial({wireframe:!0,fog:!1});this.cone=new THREE.Mesh(a,b);this.add(this.cone);this.update()};THREE.SpotLightHelper.prototype=Object.create(THREE.Object3D.prototype);THREE.SpotLightHelper.prototype.constructor=THREE.SpotLightHelper;
+THREE.SpotLightHelper.prototype.dispose=function(){this.cone.geometry.dispose();this.cone.material.dispose()};THREE.SpotLightHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3;return function(){var c=this.light.distance?this.light.distance:1E4,d=c*Math.tan(this.light.angle);this.cone.scale.set(d,d,c);a.setFromMatrixPosition(this.light.matrixWorld);b.setFromMatrixPosition(this.light.target.matrixWorld);this.cone.lookAt(b.sub(a));this.cone.material.color.copy(this.light.color).multiplyScalar(this.light.intensity)}}();
+THREE.VertexNormalsHelper=function(a,b,c,d){this.object=a;this.size=void 0!==b?b:1;a=void 0!==c?c:16711680;d=void 0!==d?d:1;b=0;c=this.object.geometry;c instanceof THREE.Geometry?b=3*c.faces.length:c instanceof THREE.BufferGeometry&&(b=c.attributes.normal.count);c=new THREE.BufferGeometry;b=new THREE.Float32Attribute(6*b,3);c.addAttribute("position",b);THREE.LineSegments.call(this,c,new THREE.LineBasicMaterial({color:a,linewidth:d}));this.matrixAutoUpdate=!1;this.update()};
+THREE.VertexNormalsHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.VertexNormalsHelper.prototype.constructor=THREE.VertexNormalsHelper;
+THREE.VertexNormalsHelper.prototype.update=function(){var a=new THREE.Vector3,b=new THREE.Vector3,c=new THREE.Matrix3;return function(){var d=["a","b","c"];this.object.updateMatrixWorld(!0);c.getNormalMatrix(this.object.matrixWorld);var e=this.object.matrixWorld,f=this.geometry.attributes.position,g=this.object.geometry;if(g instanceof THREE.Geometry)for(var h=g.vertices,k=g.faces,l=g=0,n=k.length;l<n;l++)for(var p=k[l],m=0,q=p.vertexNormals.length;m<q;m++){var s=p.vertexNormals[m];a.copy(h[p[d[m]]]).applyMatrix4(e);
+b.copy(s).applyMatrix3(c).normalize().multiplyScalar(this.size).add(a);f.setXYZ(g,a.x,a.y,a.z);g+=1;f.setXYZ(g,b.x,b.y,b.z);g+=1}else if(g instanceof THREE.BufferGeometry)for(d=g.attributes.position,h=g.attributes.normal,m=g=0,q=d.count;m<q;m++)a.set(d.getX(m),d.getY(m),d.getZ(m)).applyMatrix4(e),b.set(h.getX(m),h.getY(m),h.getZ(m)),b.applyMatrix3(c).normalize().multiplyScalar(this.size).add(a),f.setXYZ(g,a.x,a.y,a.z),g+=1,f.setXYZ(g,b.x,b.y,b.z),g+=1;f.needsUpdate=!0;return this}}();
+THREE.WireframeHelper=function(a,b){var c=void 0!==b?b:16777215;THREE.LineSegments.call(this,new THREE.WireframeGeometry(a.geometry),new THREE.LineBasicMaterial({color:c}));this.matrix=a.matrixWorld;this.matrixAutoUpdate=!1};THREE.WireframeHelper.prototype=Object.create(THREE.LineSegments.prototype);THREE.WireframeHelper.prototype.constructor=THREE.WireframeHelper;THREE.ImmediateRenderObject=function(a){THREE.Object3D.call(this);this.material=a;this.render=function(a){}};
+THREE.ImmediateRenderObject.prototype=Object.create(THREE.Object3D.prototype);THREE.ImmediateRenderObject.prototype.constructor=THREE.ImmediateRenderObject;THREE.MorphBlendMesh=function(a,b){THREE.Mesh.call(this,a,b);this.animationsMap={};this.animationsList=[];var c=this.geometry.morphTargets.length;this.createAnimation("__default",0,c-1,c/1);this.setAnimationWeight("__default",1)};THREE.MorphBlendMesh.prototype=Object.create(THREE.Mesh.prototype);THREE.MorphBlendMesh.prototype.constructor=THREE.MorphBlendMesh;
+THREE.MorphBlendMesh.prototype.createAnimation=function(a,b,c,d){b={start:b,end:c,length:c-b+1,fps:d,duration:(c-b)/d,lastFrame:0,currentFrame:0,active:!1,time:0,direction:1,weight:1,directionBackwards:!1,mirroredLoop:!1};this.animationsMap[a]=b;this.animationsList.push(b)};
+THREE.MorphBlendMesh.prototype.autoCreateAnimations=function(a){for(var b=/([a-z]+)_?(\d+)/i,c,d={},e=this.geometry,f=0,g=e.morphTargets.length;f<g;f++){var h=e.morphTargets[f].name.match(b);if(h&&1<h.length){var k=h[1];d[k]||(d[k]={start:Infinity,end:-Infinity});h=d[k];f<h.start&&(h.start=f);f>h.end&&(h.end=f);c||(c=k)}}for(k in d)h=d[k],this.createAnimation(k,h.start,h.end,a);this.firstAnimation=c};
+THREE.MorphBlendMesh.prototype.setAnimationDirectionForward=function(a){if(a=this.animationsMap[a])a.direction=1,a.directionBackwards=!1};THREE.MorphBlendMesh.prototype.setAnimationDirectionBackward=function(a){if(a=this.animationsMap[a])a.direction=-1,a.directionBackwards=!0};THREE.MorphBlendMesh.prototype.setAnimationFPS=function(a,b){var c=this.animationsMap[a];c&&(c.fps=b,c.duration=(c.end-c.start)/c.fps)};
+THREE.MorphBlendMesh.prototype.setAnimationDuration=function(a,b){var c=this.animationsMap[a];c&&(c.duration=b,c.fps=(c.end-c.start)/c.duration)};THREE.MorphBlendMesh.prototype.setAnimationWeight=function(a,b){var c=this.animationsMap[a];c&&(c.weight=b)};THREE.MorphBlendMesh.prototype.setAnimationTime=function(a,b){var c=this.animationsMap[a];c&&(c.time=b)};THREE.MorphBlendMesh.prototype.getAnimationTime=function(a){var b=0;if(a=this.animationsMap[a])b=a.time;return b};
+THREE.MorphBlendMesh.prototype.getAnimationDuration=function(a){var b=-1;if(a=this.animationsMap[a])b=a.duration;return b};THREE.MorphBlendMesh.prototype.playAnimation=function(a){var b=this.animationsMap[a];b?(b.time=0,b.active=!0):console.warn("THREE.MorphBlendMesh: animation["+a+"] undefined in .playAnimation()")};THREE.MorphBlendMesh.prototype.stopAnimation=function(a){if(a=this.animationsMap[a])a.active=!1};
+THREE.MorphBlendMesh.prototype.update=function(a){for(var b=0,c=this.animationsList.length;b<c;b++){var d=this.animationsList[b];if(d.active){var e=d.duration/d.length;d.time+=d.direction*a;if(d.mirroredLoop){if(d.time>d.duration||0>d.time)d.direction*=-1,d.time>d.duration&&(d.time=d.duration,d.directionBackwards=!0),0>d.time&&(d.time=0,d.directionBackwards=!1)}else d.time%=d.duration,0>d.time&&(d.time+=d.duration);var f=d.start+THREE.Math.clamp(Math.floor(d.time/e),0,d.length-1),g=d.weight;f!==d.currentFrame&&
+(this.morphTargetInfluences[d.lastFrame]=0,this.morphTargetInfluences[d.currentFrame]=1*g,this.morphTargetInfluences[f]=0,d.lastFrame=d.currentFrame,d.currentFrame=f);e=d.time%e/e;d.directionBackwards&&(e=1-e);d.currentFrame!==d.lastFrame?(this.morphTargetInfluences[d.currentFrame]=e*g,this.morphTargetInfluences[d.lastFrame]=(1-e)*g):this.morphTargetInfluences[d.currentFrame]=g}}};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/utils/modi.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,941 @@
+/********
+
+	Mouseover DOM Inspector
+	version 2.0.2
+	last rev: 05.12.2005
+
+	steve@slayeroffice.com
+
+	Thanks to Aaron Barker of zelph.com for his additions to v1.x.
+	
+	Should you modify/improve upon this, please let me know about it so that
+	I can update the version hosted on slayeroffice.
+	
+	PLEASE LEAVE THIS NOTICE IN TACT
+	
+TODO:
+	-- add identifiers to MODI created objects to prevent them from appearing during manual DOM walk
+	-- fix firstChild selections
+	-- fix outline reversion
+	- Replace outline's with an abs-pos DIV to emulate the outlines. (maybe)
+********/
+
+// prevent IE from making tons of requests to background images
+if(document.execCommand && document.all && !window.opera) document.execCommand("BackgroundImageCache",false,true);
+
+var d=document;
+var mObj,cssObj;
+var isActive = false;
+var activeObj = null;
+var pause = false;
+
+var treeIndex = 0;
+var clonedObj = null;
+var mDown = false;
+var offsetX,offsetY;
+
+
+if(d.all && !window.opera) {
+	var statusImg = new Array("gray.png","");
+} else {
+	var statusImg = new Array("gray.png","outline.png","");
+}
+var keyboardObjIndex = 0;
+var modiHiddenObjects = new Array();
+var modiFocused = false;
+if(d.contentType) {
+	var isAppXML = document.contentType.indexOf("application/xhtml") > -1;
+} else {
+	var isAppXML = false;
+}
+
+// default preferences
+var pref_showAttr = true;
+var pref_showDim = true;
+var pref_showParents = true;
+var pref_highlights = 0;
+var pref_freeze = true;
+var pref_backgroundHighlightColor = "#C0C0C0";
+var pref_childHighlightColor = "#FAFAFA";
+var pref_outlineColor = "#FF0000";
+var pref_outlineWidth = "2px";
+var pref_visible = true;
+var pref_alwaysTransparent = false;
+var pref_alwaysTransparentValue = 60;
+var pref_allDataListsCollapsed = false;
+var pref_showChildren = true;
+
+var oHighlightColor = pref_backgroundHighlightColor;
+var so_host = "http://slayeroffice.com/tools/modi/v2.0/";
+var so_lbl = new Array();
+
+// See: http://www.quirksmode.org/dom/getstyles.html
+function getStyle(obj,styleProp)
+{
+	if (obj.currentStyle)
+		var y = obj.currentStyle[styleProp];
+	else if (window.getComputedStyle)
+		var y = document.defaultView.getComputedStyle(obj,null).getPropertyValue(styleProp);
+	return y;
+}
+
+function so_init() {
+	try {
+		if(prefFile != "") {
+			nPrefs = d.getElementsByTagName("head")[0].appendChild(d.createElement("script"));
+			nPrefs.type = "text/javascript";
+			nPrefs.src = prefFile;
+			oHighlightColor = pref_backgroundHighlightColor;
+		}
+	} catch(err) { }
+	d.onmousemove = so_captureMouseMoveEvent;
+	d.onkeydown = so_captureKeyDownEvent;
+	window.onscroll = so_keepModiInView;
+	so_prepInputs();
+	
+	all = d.getElementsByTagName("*");
+	for(i=0;i<all.length;i++) {
+		if(all[i].tagName != "HTML" && all[i].tagName != "BODY" && all[i].tagName != "!") {
+		 	so_prepareObjForMODI(all[i]);
+		}
+	}
+
+	cssObj = d.getElementsByTagName("head")[0].appendChild(d.createElement("link"));
+	cssObj.type = "text/css";
+	cssObj.rel = "Stylesheet";
+	cssObj.href = so_host + "modi_v2.0.css";
+	cssObj.id = "modiCSS";
+	cssObj.xid = "modi";
+	
+	mObj = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
+	mObj.id = "modiContainer";
+	mObj.xid = "modi";
+	mObj.style.visibility = pref_visible?"visible":"hidden";
+	mObj.onmouseover = function() { modiFocused = true; so_setOpacity(mObj,99); }
+	mObj.onmouseout = function() { modiFocused = false; }
+	
+	h2 = mObj.appendChild(d.createElement("h2"));
+	h2.appendChild(d.createTextNode("Mouse-over any element to begin."));
+	h2.id = "tmp_h2";
+}
+
+function so_prepInputs() {
+	txtInput = d.getElementsByTagName("input");
+	txtArea = d.getElementsByTagName("textarea");
+	for(i=0;i<txtInput.length;i++) {
+		if(txtInput[i].getAttribute("type")=="text" || txtInput[i].getAttribute("type") == "") {
+			txtInput[i].onfocus = function() { 
+				if(pause)return;
+				pause = true; 
+				// yeah, the innerHTML is cheating. at least i'm only reading, not writing :)
+				if(d.getElementById("so_h2").innerHTML.indexOf("paused")==-1)d.getElementById("so_h2").appendChild(d.createTextNode(" [paused for input focus]"));
+			}
+			txtInput[i].onblur = function() { 
+				pause = false; 
+			}
+		}
+	}
+	for(i=0;i<txtArea.length;i++) {
+		txtArea[i].onfocus = function() {
+			if(pause)return;
+			pause = true; 
+			if(d.getElementById("so_h2").innerHTML.indexOf("paused")==-1)d.getElementById("so_h2").appendChild(d.createTextNode(" [paused for input focus]"));
+		}
+		txtArea[i].onblur = function() { 
+			pause = false; 
+		}
+	}
+}
+
+function so_keepModiInView() {
+	winHeight = d.all && !window.opera?document.documentElement.clientHeight:window.innerHeight;
+	if(mObj.offsetHeight > winHeight) return;
+	if(mObj.offsetTop < _returnScrollDimensions(1)) {
+		mObj.style.top = _returnScrollDimensions(1)+"px";
+	}
+	
+	if(mObj.offsetTop+mObj.offsetHeight > winHeight + _returnScrollDimensions(1)) {
+		mObj.style.top = (_returnScrollDimensions(1) + winHeight) - mObj.offsetHeight + "px";
+	}
+}
+
+function so_captureMouseMoveEvent(e) {
+	x=d.all?window.event.clientX:e.clientX;
+	y=d.all?window.event.clientY:e.pageY;
+
+	if(pause || pref_freeze) {
+		if(mDown) {
+			x-=offsetX;
+			y-=offsetY;
+			if(mDown) {
+				mObj.style.top = y+"px";
+				mObj.style.left = x+"px";
+			}
+			return;
+		}
+	}
+		
+	if(activeObj == null && !modiFocused) {
+		so_setOpacity(mObj,40);
+	} else {
+		so_setOpacity(mObj,99);
+	}
+	
+	if(pref_freeze) {
+		so_keepModiInView();
+		return;
+	}
+	
+	if(d.all && !window.opera) {
+		x+=_returnScrollDimensions(0);
+		y+=_returnScrollDimensions(1);
+	}
+
+	if(x+mObj.offsetWidth > d.getElementsByTagName("body")[0].offsetWidth) {
+		mObj.style.left = (x-mObj.offsetWidth)+"px";
+	} else {
+		mObj.style.left = (x+15) + "px";
+	}
+	if(mObj.offsetLeft < 0) mObj.style.left = "0px"
+	
+	yOffset = _returnScrollDimensions(1);
+	
+	if(y-mObj.offsetHeight<=0 || (y-mObj.offsetHeight)<yOffset) {
+		mObj.style.top=(y+15)+"px";
+	} else {
+		mObj.style.top = (y-mObj.offsetHeight) + "px";
+	}
+
+}
+
+function _returnScrollDimensions(which) {
+	
+	if(which) {
+		if(d.body.scrollTop != 0)return d.body.scrollTop;
+		if(d.documentElement.scrollTop != 0)return d.documentElement.scrollTop;
+	} else {
+		if(d.body.scrollLeft != 0)return d.body.scrollTop;
+		if(d.documentElement.scrollLeft != 0)return d.documentElement.scrollLeft;
+	}
+	return 0;
+}	
+	
+function so_setObjHighlight(obj) {
+	switch(pref_highlights) {
+		case 0:
+			obj.style.backgroundColor = pref_backgroundHighlightColor;
+			break;
+		case 1:
+			//activeObj.prevOutline = 
+			outline = pref_outlineWidth + " solid " + pref_outlineColor;
+			obj.style.MozOutline = outline;
+			obj.style.outline = outline;
+			break;
+		case 2:
+			return;
+			break;
+	}
+}
+
+function so_unsetObjHighlight(obj) {
+	if(!obj)return;
+	switch(pref_highlights) {
+		case 0:
+			if(obj.randomBGColor == null) {
+				obj.style.backgroundColor = obj.so_prevBGColor;
+			} else {
+				obj.style.backgroundColor = obj.randomBGColor;
+			}
+			break;
+		case 1:
+			obj.style.MozOutline = "none";
+			obj.style.outline = "none";
+			break;
+		case 2:
+			return;
+			break;
+	}
+}
+
+function so_captureKeyDownEvent(e) {
+	keyCode = d.all?window.event.keyCode:e.keyCode;
+	if(d.getElementById("htmlView")){ 
+		 switch(keyCode) {
+		 	case 27:
+				so_closeEditWindow();
+				break;
+			case 13:
+				so_applyInnerHTML(d.getElementById("htmlViewText").value,activeObj);
+				break;
+		}
+		return;
+	}
+	
+	if(pause) {
+		if(keyCode == 80) {
+			pause=false;
+			return;
+		}
+	}
+	switch(keyCode) {
+		case 27:
+			so_cleanUp();
+			break;
+		case 49:
+			so_snapWindow(0);
+			break;
+		case 50:
+			//so_snapWindow(1);
+			break;
+		case 65:
+			so_cloneObject();
+			break;
+		case 66:
+			if(pause) return;
+			so_unsetObjHighlight(activeObj);
+			pref_highlights++;
+			if(d.all && !window.opera) {
+				maxValue = 1;
+			} else {
+				maxValue = 2;
+			}
+			if(pref_highlights>maxValue) pref_highlights = 0;
+			if(activeObj) so_setObjHighlight(activeObj);
+			d.getElementById("so_h2").style.backgroundImage = "url(" + so_host +""+ statusImg[pref_highlights] + ")";
+			break;
+		case 67:
+			so_randomColor();
+			break;
+		case 68:
+			if(pause)return;
+			pref_visible = pref_visible?false:true;
+			mObj.style.visibility = pref_visible?"visible":"hidden";
+			break;
+		case 69:
+			so_removeWidth();
+			break;
+		case 70:
+			if(pause)return;
+			pref_freeze = pref_freeze?false:true;
+			if(!pref_freeze)mDown = false;
+			break;
+		case 71:
+			so_changeListState();
+			break;
+		case 72:
+			so_hideObject();
+			break;
+		case 74:
+			so_showModiHiddenObjects();
+			break;
+		case 75:
+			so_removeLables();
+			break;
+		case 76:
+			so_labelObj(activeObj);
+			break;
+		case 78:
+			so_showFirstChild();
+			break;
+		case 79:
+			if(activeObj) so_outlineObj(activeObj);
+			break;
+		case 80:
+			if(!activeObj) return;
+			pause = pause?false:true;
+			if(pause)d.getElementById("so_h2").appendChild(d.createTextNode(" [paused]"));
+			so_setOpacity(mObj,99);
+			break;
+		case 82:
+			so_removeObj();
+			break;
+		case 83:
+			so_insertClonedObj();
+			break;
+		case 84:
+			if(d.getElementsByTagName("*")[treeIndex].xid == "modi") {
+				do {
+					treeIndex++;
+					if(treeIndex>=d.getElementsByTagName("*").length)treeIndex = 0;
+				} while(d.getElementsByTagName("*")[treeIndex].xid == "modi");
+			}
+			so_walkDOMTree();
+			treeIndex++;
+			break;
+		case 85:
+				pref_alwaysTransparent = pref_alwaysTransparent?false:true;
+				so_setOpacity(mObj,pref_alwaysTransparent?60:99);
+				break;
+		case 86:
+			so_createEditWindow(activeObj);
+			break;
+		case 87:
+			so_showParentObj();
+			break;
+		case 89:
+			if(d.getElementsByTagName("*")[treeIndex].xid == "modi") {
+				do {
+					treeIndex--;
+					if(treeIndex<0)treeIndex = d.getElementsByTagName("*").length-1;
+				} while(d.getElementsByTagName("*")[treeIndex].xid == "modi");
+			}
+			so_walkDOMTree();
+			treeIndex--;
+			break;
+	}
+}
+
+function so_snapWindow(corner) {
+	if(!pref_freeze)pref_freeze = true;
+	switch(corner) {
+		case 0:
+			y = _returnScrollDimensions(1);
+			mObj.style.left = "10px";
+			mObj.style.top = y+"px";
+			break;
+		case 1:
+			
+			break;
+	}
+}
+
+function so_changeListState() {
+	if(!pref_allDataListsCollapsed) {
+ 		d.getElementById("attributeData").style.display = "none";
+ 		d.getElementById("parentData").style.display = "none";
+ 		d.getElementById("dimensionData").style.display = "none";
+ 		d.getElementById("childData").style.display = "none";
+ 		pref_showAttr = false; pref_showDim = false; pref_showParents = false; pref_showChildren = false;
+ 		pref_allDataListsCollapsed = true;
+ 	} else {
+ 		d.getElementById("attributeData").style.display = "block";
+ 		d.getElementById("parentData").style.display = "block";
+ 		d.getElementById("dimensionData").style.display = "block";
+ 		d.getElementById("childData").style.display = "block";
+ 		pref_showAttr = true; pref_showDim = true; pref_showParents = true; pref_showChildren = true;
+ 		pref_allDataListsCollapsed = false;
+ 	}
+}
+
+function so_removeLables() {
+	for(i=0;i<so_lbl.length;i++) {
+		try {
+			d.getElementsByTagName("body")[0].removeChild(so_lbl[i]);
+		} catch(err) { }
+	}
+	so_lbl = new Array();
+}
+
+function so_createEditWindow(obj) {
+	if(!activeObj)return;
+	if(pause)return;
+	pause = true;
+	if(d.all && !window.opera) {
+		if(mObj.offsetWidth<315) mObj.style.width = "318px";
+		if(mObj.offsetHeight<215) mObj.style.height = "218px";
+	}
+	editWindow = mObj.appendChild(d.createElement("div"));
+	editWindow.id = "htmlView";
+		
+	h3 = editWindow.appendChild(d.createElement("h3"));
+	h3.appendChild(d.createTextNode("HTML Source for " + obj.tagName.toLowerCase()));		
+
+	txt = editWindow.appendChild(d.createElement("textarea"));
+	txt.setAttribute("id","htmlViewText")
+	txt.value = obj.innerHTML;
+	editWindow.appendChild(d.createElement("br"));
+		
+	a = editWindow.appendChild(d.createElement("a"));
+	a.onclick = so_closeEditWindow;
+	a.className = "btn";
+	if(!isAppXML) {
+		a.appendChild(d.createTextNode("Cancel"));
+	} else {
+		a.appendChild(d.createTextNode("Close"));
+	}
+	if(!isAppXML) {
+		a = editWindow.appendChild(d.createElement("a"));
+		a.onclick = function() { so_applyInnerHTML(d.getElementById("htmlViewText").value,obj); }
+		a.className = "btn";
+		a.appendChild(d.createTextNode("Apply"));
+	}
+}
+
+function so_applyInnerHTML(mHTML,obj) {
+	if(isAppXML) {
+		so_closeEditWindow();
+		return;
+	}
+	try {
+		obj.innerHTML = mHTML;
+		so_closeEditWindow();
+	
+		all = obj.getElementsByTagName("*");
+		for(i=0;i<all.length;i++) {
+			so_prepareObjForMODI(all[i]);
+		}
+	} catch(err) { 
+		alert("An error occured while applying the innerHTML of this object. The most likely culprit is that this site is serving its content as application/xhtml+xml.\nError text was:\n\n" + err.message);
+		so_closeEditWindow();
+	}
+}
+
+
+function so_prepareObjForMODI(dObj) {
+	//dObj.onmouseover = so_showObjInfo;
+	//dObj.onmouseout = so_hideObjInfo;
+	dObj.addEventListener?dObj.addEventListener("mouseover",so_showObjInfo,false):dObj.onmouseover = so_showObjInfo;//dObj.attachEvent("onmouseover",so_showObjInfo);
+	dObj.addEventListener?dObj.addEventListener("mouseout",so_hideObjInfo,false):dObj.onmouseout = so_hideObjInfo;//dObj.attachEvent("onmouseout",so_hideObjInfo);
+	dObj.so_prevBGColor = all[i].style.backgroundColor;
+	dObj.so_prevWidth = all[i].offsetWidth;
+	dObj.so_prevTitle = all[i].getAttribute("title");
+}
+
+function so_closeEditWindow() {
+	document.getElementById("modiContainer").removeChild(document.getElementById("htmlView")) 
+	so_unsetObjHighlight(activeObj);
+	activeObj=null;
+	pause = false;
+}
+
+function so_outlineObj(obj) {
+	if(pause)return;
+	outline = pref_outlineWidth + " solid " + pref_outlineColor;
+	obj.style.MozOutline = outline;
+	obj.style.outline = outline;
+}
+
+function so_setOpacity(obj,op) {
+	if(pref_alwaysTransparent) {
+		op = pref_alwaysTransparentValue;
+	}
+	if(!d.all)op/=100;
+	obj.style.opacity = op;
+	obj.style.MozOpacity = op;
+	obj.style.filter = "alpha(opacity=" + op + ")";
+}
+
+function so_showObjInfo() {
+	if(pause)return;
+	if(isActive)return;
+	//if(pref_visible)mObj.style.display = "block";
+	activeObj = this;
+	isActive = true;
+	so_buildDataDisplay(this);
+	so_setOpacity(mObj,99);
+	so_setObjHighlight(this);
+
+}
+
+function so_hideObjInfo() {
+	if(pause)return;
+	try {
+		so_unsetObjHighlight(this);
+	} catch(err) { }
+	isActive = false;
+	activeObj = null;
+}
+
+function so_buildDataDisplay(obj) {
+	if(pause)return;
+	if(d.getElementById("tmp_h2")) mObj.removeChild(d.getElementById("tmp_h2"));
+	if(d.getElementById("sContainer")) mObj.removeChild(d.getElementById("sContainer"));
+	
+	if(!pref_visible) {
+		ttl = obj.tagName.toLowerCase();
+		if(obj.id) ttl+= " id=\"" + obj.id + "\"";
+		if(obj.className) ttl+= " class=\""+obj.className+"\"";
+		obj.setAttribute("title",ttl);
+		return;
+	}
+	
+	sObj = mObj.appendChild(d.createElement("div"));
+	sObj.setAttribute("id","sContainer");
+
+	h2 = sObj.appendChild(d.createElement("h2"));
+	h2.appendChild(d.createTextNode(obj.tagName.toLowerCase()));
+	if(pause)h2.appendChild(d.createTextNode(" [paused]"));
+	h2.onmousedown =  so_captureOffset;
+	h2.onmouseup = function() {	mDown = false; }
+	h2.id = "so_h2";
+	h2.style.backgroundImage = "url("+so_host+""+ statusImg[pref_highlights] + ")";
+	
+	// attributes
+	h3 = sObj.appendChild(d.createElement("h3"));
+	h3.appendChild(d.createTextNode("attributes"));
+	h3.className = pref_showAttr?"h3_on":"h3_off";
+	h3.onclick = function() { 
+		pref_showAttr = pref_showAttr?false:true;
+		this.className = pref_showAttr?"h3_on":"h3_off";
+		document.getElementById("attributeData").style.display = pref_showAttr?"block":"none"; 
+	}
+	
+	ul = sObj.appendChild(d.createElement("ul"));
+	ul.setAttribute("id","attributeData");
+	ul.style.display = pref_showAttr?"block":"none";
+	
+	attrCount = 0;
+	for(i=0;i<obj.attributes.length;i++) {
+		if(obj.attributes[i].specified) {
+			if(obj.attributes[i].value && obj.attributes[i].name.indexOf("so_")==-1) {
+				attrCount++;
+				li = ul.appendChild(d.createElement("li"));
+				val = so_wrapAttributeValue(obj.attributes[i].value);
+				li.appendChild(d.createTextNode(obj.attributes[i].name.toLowerCase() + " : " + val));
+			}
+		}
+	}
+	
+	if(attrCount == 0) {
+		li = ul.appendChild(d.createElement("li"));
+		li.appendChild(d.createTextNode("None Specified."));
+	}
+
+	// dimensions
+	h3 = sObj.appendChild(d.createElement("h3"));
+	h3.appendChild(d.createTextNode("dimensions"));
+	h3.className = pref_showDim?"h3_on":"h3_off";
+	h3.onclick = function() {
+		pref_showDim = pref_showDim?false:true;
+		this.className = pref_showDim?"h3_on":"h3_off";
+		document.getElementById("dimensionData").style.display = pref_showDim?"block":"none";
+	}
+	ul = sObj.appendChild(d.createElement("ul"));
+	ul.setAttribute("id","dimensionData");
+	ul.style.display = pref_showDim?"block":"none";
+	
+	li = ul.appendChild(d.createElement("li"));
+	li.appendChild(d.createTextNode("Font Size : " + getStyle(obj, 'font-size')));
+	li = ul.appendChild(d.createElement("li"));
+	li.appendChild(d.createTextNode("Width : " + obj.offsetWidth + "px"));
+	li = ul.appendChild(d.createElement("li"));
+	li.appendChild(d.createTextNode("Height : " + obj.offsetHeight + "px"));
+	li = ul.appendChild(d.createElement("li"));
+	li.appendChild(d.createTextNode("Top : " + so_findPosition(obj,0) + "px"));
+	li = ul.appendChild(d.createElement("li"));
+	li.appendChild(d.createTextNode("Left : " + so_findPosition(obj,1) + "px"));
+
+	// parents
+	h3 = sObj.appendChild(d.createElement("h3"));
+	h3.appendChild(d.createTextNode("parent structure"));
+	h3.className = pref_showParents?"h3_on":"h3_off";
+	h3.onclick = function() {
+		pref_showParents = pref_showParents?false:true;
+		this.className = pref_showParents?"h3_on":"h3_off";
+		document.getElementById("parentData").style.display = pref_showParents?"block":"none";
+	}
+	so_getParents(obj,sObj);
+
+	// children
+	if(obj.childNodes.length) {
+		h3 = sObj.appendChild(d.createElement("h3"));
+		h3.appendChild(d.createTextNode("children"));
+		h3.className = pref_showChildren?"h3_on":"h3_off";
+		h3.onclick = function() {
+			pref_showChildren = pref_showChildren?false:true;
+			this.className = pref_showChildren?"h3_on":"h3_off";
+			document.getElementById("childData").style.display = pref_showChildren?"block":"none";
+		}
+		
+		ul = sObj.appendChild(d.createElement("ul"));
+		ul.setAttribute("id","childData");
+		ul.style.display = pref_showChildren?"block":"none";
+		
+		for(i=0;i<obj.childNodes.length;i++) {
+			li = ul.appendChild(d.createElement("li"));
+			if(obj.childNodes[i].nodeType == 1) {
+				li.appendChild(d.createTextNode(obj.childNodes[i].nodeName.toLowerCase()));
+				li.className = "parentStructure";
+				li.myObj = obj.childNodes[i];
+				li.onmouseover = function() {
+					pref_backgroundHighlightColor = pref_childHighlightColor;
+					this.myObj.so_prevBGColor = this.myObj.style.backgroundColor;
+					so_setObjHighlight(this.myObj);
+				}
+				li.onmouseout = function() {
+					pref_backgroundHighlightColor = oHighlightColor;
+					so_unsetObjHighlight(this.myObj);
+				}
+				if(obj.childNodes[i].getAttribute("id")) li.appendChild(d.createTextNode(" id=\"" + obj.childNodes[i].getAttribute("id") + "\""));
+				if(obj.childNodes[i].className) li.appendChild(d.createTextNode(" class=\"" + obj.childNodes[i].className + "\""));
+			} else {
+				nodes = new Array("","Element Node","Attribute Node","#text","CDATA Node","Entity Reference Node","Entity Node","Processing Instruction Node","Comment Node","Document Node","Document Fragment Node","Notation Node");
+				li.appendChild(d.createTextNode(nodes[obj.childNodes[i].nodeType]));
+				li.setAttribute("title",obj.childNodes[i].nodeValue);
+			}
+		}
+	}
+	
+	// credits
+	div = sObj.appendChild(d.createElement("div"));
+	div.setAttribute("id","credits");
+	b = div.appendChild(d.createElement("b"));
+	//b.appendChild(d.createTextNode("[esc] to quit | "));
+	a = d.createElement("a"); 
+	a.setAttribute("href","javascript:so_cleanUp();");
+	a.appendChild(d.createTextNode("[esc] to quit"));
+	b.appendChild(a); 
+	b.appendChild(d.createTextNode(" | "));
+	
+	a = b.appendChild(d.createElement("a"));
+	a.setAttribute("title","Help!");
+	a.setAttribute("href",so_host + "modi_help.html");
+	a.setAttribute("target","_blank");
+	a.appendChild(d.createTextNode("help documentation"));
+	
+	div.appendChild(d.createElement("br"));
+	div.appendChild(d.createTextNode("Mouseover DOM Inspector"));
+	div.appendChild(d.createElement("br"));
+	div.appendChild(d.createTextNode("version 2.0.2 (05.11.2005)"));
+	div.appendChild(d.createElement("br"));
+	div.appendChild(d.createTextNode("slayeroffice.com"));
+	div.appendChild(d.createElement("br"));
+
+	so_tagAsMODI();
+	
+	if(d.all && !window.opera) {
+		// make up for IE's lack of max-width support.
+		if(mObj.offsetWidth>400) mObj.style.width="400px";
+	}
+	
+	function so_wrapAttributeValue(attrValue) {
+		// IE has a word-break css property. no need to do anything if this is IE
+		if(d.all && !window.opera) return attrValue;
+		// attribute value has a space in it. return.
+		if(attrValue.indexOf(" ")>-1) return attrValue;
+		for(ee=0;ee<attrValue.length;ee++) if(ee%50==0) attrValue = attrValue.substring(0,ee) + " " + attrValue.substring(ee,attrValue.length);
+		return attrValue;
+	}
+	
+}
+
+function so_getParents(curNode,dataContainer){
+	parents = new Array();
+	parentObjRef = new Array();
+	while(curNode.parentNode){
+		parents[parents.length] = curNode.tagName.toLowerCase();
+		parentObjRef[parentObjRef.length] = curNode;
+		curNode = curNode.parentNode;
+	}
+
+	ul = dataContainer.appendChild(d.createElement("ul"));
+	ul.setAttribute("id","parentData");
+	ul.style.display = pref_showParents?"block":"none";
+	
+	for(i=parents.length-1; i>0; i--){
+		li = ul.appendChild(d.createElement("li"));
+		li.appendChild(d.createTextNode(parents[i]));
+		if(parentObjRef[i].getAttribute("id")) li.appendChild(d.createTextNode(" id=\"" + parentObjRef[i].getAttribute("id") +"\""));
+		if(parentObjRef[i].className) li.appendChild(d.createTextNode(" class=\"" + parentObjRef[i].className + "\""));
+		
+		li.myObj = parentObjRef[i];
+		li.className = "parentStructure";
+		li.onmouseover = function() {
+			this.myObj.so_prevBGColor = this.myObj.style.backgroundColor;
+			so_setObjHighlight(this.myObj);
+		}
+		li.onmouseout = function() {
+			so_unsetObjHighlight(this.myObj);
+		}
+	}
+
+}
+
+function so_showParentObj() {
+	if(pause)return;
+	so_unsetObjHighlight(activeObj);
+	if(activeObj.parentNode && activeObj.tagName != "HTML") {
+		activeObj = activeObj.parentNode
+		activeObj.so_prevBGColor = activeObj.style.backgroundColor;
+		so_setObjHighlight(activeObj);
+		so_buildDataDisplay(activeObj);
+	}
+}
+
+function so_labelObj(obj) {
+	if(pause || !activeObj) return;
+	lblText = obj.tagName.toLowerCase();
+	len = so_lbl.length;
+	so_lbl[len] = d.getElementsByTagName("body")[0].appendChild(d.createElement("div"));
+	so_lbl[len].appendChild(d.createTextNode(lblText));
+	so_lbl[len].className = "modi_label";
+	so_lbl[len].style.top = so_findPosition(obj,0) + "px";
+	so_lbl[len].style.left = so_findPosition(obj,1) + "px";
+	so_lbl[len].onclick = function() {
+		this.parentNode.removeChild(this);
+	}
+}
+
+function so_removeObj() {
+	if(pause)return;
+	activeObj.parentNode.removeChild(activeObj);
+}
+
+function so_cleanUp() {
+	d.getElementsByTagName("head")[0].removeChild(d.getElementById("modiCSS"));
+	d.getElementsByTagName("body")[0].removeChild(d.getElementById("modiContainer"));
+	// id is "modi" if invoked on its own, "sss" if invoked from the favelet suite
+	if(d.getElementById("modi")) {
+		d.getElementsByTagName("body")[0].removeChild(d.getElementById("modi"));
+	} else {
+		d.getElementsByTagName("body")[0].removeChild(d.getElementById("sss"));
+	}
+	d.onkeydown = null;
+	d.onmousemove = null;
+
+	all = d.getElementsByTagName("*");
+	for(i=0;i<all.length;i++) {
+		//all[i].onmouseover = null;
+		//all[i].onmouseout = null;
+		all[i].removeEventListener?all[i].removeEventListener("mouseover",so_showObjInfo,false):all[i].onmouseover = null;//all[i].detachEvent("onmouseover",so_showObjInfo);
+		all[i].removeEventListener?all[i].removeEventListener("mouseout",so_hideObjInfo,false):all[i].onmouseout = null;//all[i].detachEvent("onmouseout",so_hideObjInfo);
+		all[i].style.backgroundColor = all[i].so_prevBGColor;
+		all[i].so_prevBGColor = null;
+		if(all[i].randomBGColor)all[i].randomBGColor = null;
+		all[i].setAttribute("title",all[i].so_prevTitle); 
+		all[i].style.outline = "none";
+		all[i].style.MozOutline = "none";
+	}
+
+	if(activeObj)activeObj.style.backgroundColor = activeObj.so_prevBGColor;
+}
+
+function so_randomColor() {
+	if(pause)return;
+	if(activeObj == null) return;
+	if(!activeObj.randomBGColor) {
+		r = Math.floor(Math.random() * 256);
+		g = Math.floor(Math.random() * 256);
+		b = Math.floor(Math.random() * 256);
+		rgb = "rgb(" + r + "," + g + "," + b + ")";
+		if(activeObj) {
+			activeObj.style.backgroundColor = rgb;
+			activeObj.randomBGColor = rgb;
+		}
+	} else {
+		if(activeObj.style.backgroundColor == activeObj.so_prevBGColor) {
+			activeObj.style.backgroundColor = activeObj.randomBGColor;
+		} else {
+			activeObj.style.backgroundColor = activeObj.so_prevBGColor;
+			activeObj.randomBGColor = activeObj.so_prevBGColor;
+		}
+	}
+}
+
+function so_walkDOMTree() {
+	if(pause)return;
+	if(activeObj) so_unsetObjHighlight(activeObj);
+	if(treeIndex>=d.getElementsByTagName("*").length) treeIndex = 0;
+	if(treeIndex<0) treeIndex = d.getElementsByTagName("*").length - 1;
+	
+	activeObj = d.getElementsByTagName("*")[treeIndex];
+	if(d.all && !window.opera) {
+		if(activeObj.tagName == "!") {
+			treeIndex++;
+			activeObj = d.getElementsByTagName("*")[treeIndex];
+		}
+	}
+	so_buildDataDisplay(activeObj);
+	so_setObjHighlight(activeObj);
+	if(!pref_freeze) {
+		mObj.style.top = so_findPosition(activeObj,0)+15 + "px";
+		mObj.style.left = so_findPosition(activeObj,1)+15 + "px";
+	}
+}
+
+function so_tagAsMODI() {
+	modiChildren = mObj.getElementsByTagName("*");
+	for(m=0;m<modiChildren.length;m++) modiChildren[m].xid = "modi";
+}
+	
+function so_findPosition(obj,pType) {
+	cur = 0;
+	if(obj.offsetParent) {		
+		while(obj.offsetParent) {
+			cur+=pType?obj.offsetLeft:obj.offsetTop;
+			obj = obj.offsetParent;
+		}
+	}
+	return cur;
+}
+
+function so_cloneObject() {
+	if(pause)return;
+	if(!activeObj)return;
+	clonedObj = activeObj.cloneNode(true);
+}
+
+function so_insertClonedObj() {
+	if(pause)return;
+	if(!activeObj || !clonedObj)return;
+	activeObj.appendChild(clonedObj);
+	so_prepareObjForMODI(clonedObj);
+	
+	c = clonedObj.getElementsByTagName("*");
+	for(i=0;i<c.length;i++) so_prepareObjForMODI(c[i]);
+}
+
+function so_captureOffset(e) {
+	mDown = true;
+	nx = parseInt(mObj.offsetLeft);
+	ny = parseInt(mObj.offsetTop);
+
+	if(d.all) {
+		offsetX=window.event.clientX - nx;
+		offsetY=window.event.clientY - ny;
+	} else {
+		offsetX = e.pageX - nx;
+		offsetY = e.pageY - ny;
+	}
+}
+
+function so_hideObject() {
+	if(pause || !activeObj)return;
+	if(activeObj.style.visibility == "" || activeObj.style.visibility == "visible") {
+		modiHiddenObjects[modiHiddenObjects.length] = activeObj;
+		activeObj.style.visibility = "hidden"
+		activeObj = null;
+	} 
+}
+
+function so_showModiHiddenObjects() {
+if(pause)return;
+	for(w=0;w<modiHiddenObjects.length;w++) {
+		modiHiddenObjects[w].style.visibility = "visible";
+	}
+	modiHiddenObjects = new Array();
+}
+
+function so_removeWidth() {
+	if(pause) return;
+	if(!activeObj) return;
+
+	if(activeObj.so_prevWidth != activeObj.offsetWidth) {
+		activeObj.style.width = activeObj.so_prevWidth + "px";
+		activeObj.so_prevWidth = activeObj.offsetWidth;
+	} else {
+		activeObj.style.width = "auto";
+	}
+}
+
+function so_showFirstChild() {
+	if(pause)return;
+	if(!activeObj) return;
+	n = activeObj.childNodes;
+	if(!n.length)return;
+	m=null;
+	for(k=0;k<n.length;k++) {
+		if(n[k].nodeType == 1) {
+			m = n[k];
+			break;
+		}
+	}
+	
+	if(!m) return;
+	so_unsetObjHighlight(activeObj);
+	activeObj = m;
+	so_buildDataDisplay(activeObj);
+}
+
+
+so_init();
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/wisp/terrain1.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,520 @@
+var width = exports.width = 610;
+var height = exports.height = 400;
+var wireframe = exports.wireframe = true;
+var wireframeWidth = exports.wireframeWidth = 1.2;
+var terrainHeight = exports.terrainHeight = 50;
+var terrainSize = exports.terrainSize = 100;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+var l = exports.l = function l(v) {
+    return console.log(v);
+};
+var midpoint = exports.midpoint = function midpoint(a, b) {
+    return (a + b) / 2;
+};
+var average2 = exports.average2 = function average2(a, b) {
+    return (a + b) / 2;
+};
+var average4 = exports.average4 = function average4(a, b, c, d) {
+    return (a + b + c + d) / 4;
+};
+var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
+    return function () {
+        var totalø1 = 0;
+        var countø1 = 0;
+        a ? (function () {
+            totalø1 = totalø1 + a;
+            return countø1 = countø1 + 1;
+        })() : void 0;
+        b ? (function () {
+            totalø1 = totalø1 + b;
+            return countø1 = countø1 + 1;
+        })() : void 0;
+        c ? (function () {
+            totalø1 = totalø1 + c;
+            return countø1 = countø1 + 1;
+        })() : void 0;
+        d ? (function () {
+            totalø1 = totalø1 + d;
+            return countø1 = countø1 + 1;
+        })() : void 0;
+        return totalø1 / countø1;
+    }.call(this);
+};
+var rand = exports.rand = function rand() {
+    return Math.random();
+};
+var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
+    return spread * rand() * 2 - spread;
+};
+var jitter = exports.jitter = function jitter(value, spread) {
+    return value + randAroundZero(spread);
+};
+void 0;
+var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(hm, x, y) {
+    return 0 <= x && x <= hm.last && (0 <= y && y <= hm.last) ? (function () {
+        return hm[y * hm.resolution + x];
+    })() : void 0;
+};
+void 0;
+var normalize = exports.normalize = function normalize(hm) {
+    return function () {
+        var maxø1 = 0 - Infinity;
+        var minø1 = Infinity;
+        (function () {
+            var G__1ø1 = hm.length;
+            return function loop() {
+                var recur = loop;
+                var iø1 = 0;
+                do {
+                    recur = iø1 < G__1ø1 ? (function () {
+                        (function () {
+                            var elø1 = hm[iø1];
+                            maxø1 < elø1 ? (function () {
+                                return maxø1 = elø1;
+                            })() : void 0;
+                            return minø1 > elø1 ? (function () {
+                                return minø1 = elø1;
+                            })() : void 0;
+                        }.call(this));
+                        return loop[0] = 1 + iø1, loop;
+                    })() : void 0;
+                } while (iø1 = loop[0], recur === loop);
+                return recur;
+            }.call(this);
+        }.call(this));
+        return function () {
+            var spanø1 = maxø1 - minø1;
+            return function () {
+                var G__2ø1 = hm.length;
+                return function loop() {
+                    var recur = loop;
+                    var iø1 = 0;
+                    do {
+                        recur = iø1 < G__2ø1 ? (function () {
+                            hm[iø1] = (hm[iø1] - minø1) / spanø1;
+                            return loop[0] = 1 + iø1, loop;
+                        })() : void 0;
+                    } while (iø1 = loop[0], recur === loop);
+                    return recur;
+                }.call(this);
+            }.call(this);
+        }.call(this);
+    }.call(this);
+};
+var zeroHeightmap = exports.zeroHeightmap = function zeroHeightmap(heightmap) {
+    (function () {
+        var G__3ø1 = heightmap.length;
+        return function loop() {
+            var recur = loop;
+            var iø1 = 0;
+            do {
+                recur = iø1 < G__3ø1 ? (function () {
+                    heightmap[iø1] = 0;
+                    return loop[0] = 1 + iø1, loop;
+                })() : void 0;
+            } while (iø1 = loop[0], recur === loop);
+            return recur;
+        }.call(this);
+    }.call(this));
+    return heightmap;
+};
+var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
+    return function () {
+        var resolutionø1 = 1 + Math.pow(2, exponent);
+        l('Creating ' + resolutionø1 + ' by ' + resolutionø1 + ' heightmap...');
+        var heightmap = new Array(resolutionø1 * resolutionø1);
+        heightmap.resolution = resolutionø1;
+        heightmap.exponent = exponent;
+        heightmap.last = resolutionø1 - 1;
+        return zeroHeightmap(heightmap);
+    }.call(this);
+};
+var randomNoise = exports.randomNoise = function randomNoise(heightmap) {
+    return function () {
+        var G__4ø1 = heightmap.length;
+        return function loop() {
+            var recur = loop;
+            var iø1 = 0;
+            do {
+                recur = iø1 < G__4ø1 ? (function () {
+                    heightmap[iø1] = rand();
+                    return loop[0] = 1 + iø1, loop;
+                })() : void 0;
+            } while (iø1 = loop[0], recur === loop);
+            return recur;
+        }.call(this);
+    }.call(this);
+};
+var mpdInitCorners = exports.mpdInitCorners = function mpdInitCorners(heightmap) {
+    heightmap[0 * heightmap.resolution + 0] = rand();
+    heightmap[heightmap.last * heightmap.resolution + 0] = rand();
+    heightmap[0 * heightmap.resolution + heightmap.last] = rand();
+    return heightmap[heightmap.last * heightmap.resolution + heightmap.last] = rand();
+};
+var mpdDisplace = exports.mpdDisplace = function mpdDisplace(heightmap, lx, rx, by, ty, spread) {
+    return function () {
+        var cxø1 = midpoint(lx, rx);
+        var cyø1 = midpoint(by, ty);
+        var bottomLeftø1 = heightmap[by * heightmap.resolution + lx];
+        var bottomRightø1 = heightmap[by * heightmap.resolution + rx];
+        var topLeftø1 = heightmap[ty * heightmap.resolution + lx];
+        var topRightø1 = heightmap[ty * heightmap.resolution + rx];
+        var topø1 = average2(topLeftø1, topRightø1);
+        var leftø1 = average2(bottomLeftø1, topLeftø1);
+        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
+        var rightø1 = average2(bottomRightø1, topRightø1);
+        var centerø1 = average4(topø1, leftø1, bottomø1, rightø1);
+        heightmap[by * heightmap.resolution + cxø1] = jitter(bottomø1, spread);
+        heightmap[ty * heightmap.resolution + cxø1] = jitter(topø1, spread);
+        heightmap[cyø1 * heightmap.resolution + lx] = jitter(leftø1, spread);
+        heightmap[cyø1 * heightmap.resolution + rx] = jitter(rightø1, spread);
+        return heightmap[cyø1 * heightmap.resolution + cxø1] = jitter(centerø1, spread);
+    }.call(this);
+};
+var midpointDisplacement = exports.midpointDisplacement = function midpointDisplacement(heightmap) {
+    mpdInitCorners(heightmap);
+    (function loop() {
+        var recur = loop;
+        var iterø1 = 0;
+        var spreadø1 = 0.3;
+        do {
+            recur = iterø1 < heightmap.exponent ? (function () {
+                (function () {
+                    var chunksø1 = Math.pow(2, iterø1);
+                    var chunkWidthø1 = (heightmap.resolution - 1) / chunksø1;
+                    return function () {
+                        var G__5ø1 = chunksø1;
+                        return function () {
+                            var G__6ø1 = G__5ø1;
+                            return function loop() {
+                                var recur = loop;
+                                var xchunkø1 = 0;
+                                do {
+                                    recur = xchunkø1 < G__6ø1 ? (function () {
+                                        (function () {
+                                            var G__7ø1 = G__5ø1;
+                                            return function loop() {
+                                                var recur = loop;
+                                                var ychunkø1 = 0;
+                                                do {
+                                                    recur = ychunkø1 < G__7ø1 ? (function () {
+                                                        (function () {
+                                                            var leftXø1 = chunkWidthø1 * xchunkø1;
+                                                            var rightXø1 = leftXø1 + chunkWidthø1;
+                                                            var bottomYø1 = chunkWidthø1 * ychunkø1;
+                                                            var topYø1 = bottomYø1 + chunkWidthø1;
+                                                            return mpdDisplace(heightmap, leftXø1, rightXø1, bottomYø1, topYø1, spreadø1);
+                                                        }.call(this));
+                                                        return loop[0] = 1 + ychunkø1, loop;
+                                                    })() : void 0;
+                                                } while (ychunkø1 = loop[0], recur === loop);
+                                                return recur;
+                                            }.call(this);
+                                        }.call(this));
+                                        return loop[0] = 1 + xchunkø1, loop;
+                                    })() : void 0;
+                                } while (xchunkø1 = loop[0], recur === loop);
+                                return recur;
+                            }.call(this);
+                        }.call(this);
+                    }.call(this);
+                }.call(this));
+                return loop[0] = 1 + iterø1, loop[1] = spreadø1 * 0.5, loop;
+            })() : void 0;
+        } while (iterø1 = loop[0], spreadø1 = loop[1], recur === loop);
+        return recur;
+    }.call(this));
+    return normalize(heightmap);
+};
+var midpointDisplacementFinal = exports.midpointDisplacementFinal = function midpointDisplacementFinal(heightmap) {
+    mpdInitCorners(heightmap);
+    (function loop() {
+        var recur = loop;
+        var iterø1 = 0;
+        var spreadø1 = 0 + $('#input-starting-spread').val();
+        do {
+            recur = iterø1 < heightmap.exponent ? (function () {
+                (function () {
+                    var chunksø1 = Math.pow(2, iterø1);
+                    var chunkWidthø1 = (heightmap.resolution - 1) / chunksø1;
+                    return function () {
+                        var G__8ø1 = chunksø1;
+                        return function () {
+                            var G__9ø1 = G__8ø1;
+                            return function loop() {
+                                var recur = loop;
+                                var xchunkø1 = 0;
+                                do {
+                                    recur = xchunkø1 < G__9ø1 ? (function () {
+                                        (function () {
+                                            var G__10ø1 = G__8ø1;
+                                            return function loop() {
+                                                var recur = loop;
+                                                var ychunkø1 = 0;
+                                                do {
+                                                    recur = ychunkø1 < G__10ø1 ? (function () {
+                                                        (function () {
+                                                            var leftXø1 = chunkWidthø1 * xchunkø1;
+                                                            var rightXø1 = leftXø1 + chunkWidthø1;
+                                                            var bottomYø1 = chunkWidthø1 * ychunkø1;
+                                                            var topYø1 = bottomYø1 + chunkWidthø1;
+                                                            return mpdDisplace(heightmap, leftXø1, rightXø1, bottomYø1, topYø1, spreadø1);
+                                                        }.call(this));
+                                                        return loop[0] = 1 + ychunkø1, loop;
+                                                    })() : void 0;
+                                                } while (ychunkø1 = loop[0], recur === loop);
+                                                return recur;
+                                            }.call(this);
+                                        }.call(this));
+                                        return loop[0] = 1 + xchunkø1, loop;
+                                    })() : void 0;
+                                } while (xchunkø1 = loop[0], recur === loop);
+                                return recur;
+                            }.call(this);
+                        }.call(this);
+                    }.call(this);
+                }.call(this));
+                return loop[0] = 1 + iterø1, loop[1] = spreadø1 * (0 + $('#input-spread-reduction').val()), loop;
+            })() : void 0;
+        } while (iterø1 = loop[0], spreadø1 = loop[1], recur === loop);
+        return recur;
+    }.call(this));
+    return normalize(heightmap);
+};
+var mpdDisplaceD2 = exports.mpdDisplaceD2 = function mpdDisplaceD2(heightmap, lx, rx, by, ty, spread) {
+    return function () {
+        var cxø1 = midpoint(lx, rx);
+        var cyø1 = midpoint(by, ty);
+        var bottomLeftø1 = heightmap[by * heightmap.resolution + lx];
+        var bottomRightø1 = heightmap[by * heightmap.resolution + rx];
+        var topLeftø1 = heightmap[ty * heightmap.resolution + lx];
+        var topRightø1 = heightmap[ty * heightmap.resolution + rx];
+        var topø1 = average2(topLeftø1, topRightø1);
+        var leftø1 = average2(bottomLeftø1, topLeftø1);
+        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
+        var rightø1 = average2(bottomRightø1, topRightø1);
+        heightmap[by * heightmap.resolution + cxø1] = jitter(bottomø1, spread);
+        heightmap[ty * heightmap.resolution + cxø1] = jitter(topø1, spread);
+        heightmap[cyø1 * heightmap.resolution + lx] = jitter(leftø1, spread);
+        return heightmap[cyø1 * heightmap.resolution + rx] = jitter(rightø1, spread);
+    }.call(this);
+};
+var midpointDisplacementD1 = exports.midpointDisplacementD1 = function midpointDisplacementD1(heightmap) {
+    return mpdInitCorners(heightmap);
+};
+var midpointDisplacementD2 = exports.midpointDisplacementD2 = function midpointDisplacementD2(heightmap) {
+    mpdInitCorners(heightmap);
+    return mpdDisplaceD2(heightmap, 0, heightmap.last, 0, heightmap.last, 0.1);
+};
+var midpointDisplacementD3 = exports.midpointDisplacementD3 = function midpointDisplacementD3(heightmap) {
+    mpdInitCorners(heightmap);
+    return mpdDisplace(heightmap, 0, heightmap.last, 0, heightmap.last, 0.1);
+};
+var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
+    return function () {
+        var lightø1 = new THREE.DirectionalLight(16777215, 1);
+        lightø1.position.set(100, 0, 150);
+        return lightø1;
+    }.call(this);
+};
+var makeCamera = exports.makeCamera = function makeCamera() {
+    return function () {
+        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
+        cameraø1.position.set(0, -100, 150);
+        return cameraø1;
+    }.call(this);
+};
+var makeRenderer = exports.makeRenderer = function makeRenderer() {
+    return function () {
+        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
+        rendererø1.setClearColor(16777215);
+        rendererø1.setSize(width, height);
+        rendererø1.setPixelRatio(2);
+        return rendererø1;
+    }.call(this);
+};
+var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
+    return function () {
+        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, heightmap.resolution - 1, heightmap.resolution - 1);
+        geometryø1.dynamic = true;
+        return geometryø1;
+    }.call(this);
+};
+var makeControls = exports.makeControls = function makeControls(camera, renderer) {
+    return function () {
+        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
+        controlsø1.rotateSpeed = 1.4;
+        controlsø1.zoomSpeed = 0.5;
+        controlsø1.staticMoving = true;
+        controlsø1.dynamicDampingFactor = 0.3;
+        return controlsø1;
+    }.call(this);
+};
+var makePlane = exports.makePlane = function makePlane(geometry) {
+    return function () {
+        var materialø1 = new THREE.MeshLambertMaterial({
+            'wireframe': wireframe,
+            'wireframeLinewidth': wireframeWidth,
+            'color': 47872
+        });
+        return new THREE.Mesh(geometry, materialø1);
+    }.call(this);
+};
+var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
+    return function () {
+        var containerø1 = document.getElementById(elName);
+        var settingsø1 = document.createElement('div');
+        var refreshButtonø1 = document.createElement('button');
+        var buttonTextø1 = document.createTextNode('Refresh');
+        var cancelScrollø1 = function (e) {
+            return e.preventDefault();
+        };
+        refreshButtonø1.onclick = refreshFn;
+        renderer.domElement.onmousewheel = cancelScrollø1;
+        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
+        refreshButtonø1.appendChild(buttonTextø1);
+        containerø1.appendChild(renderer.domElement);
+        containerø1.appendChild(settingsø1);
+        return settingsø1.appendChild(refreshButtonø1);
+    }.call(this);
+};
+var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
+    (function () {
+        var G__11ø1 = geometry.vertices.length;
+        return function loop() {
+            var recur = loop;
+            var iø1 = 0;
+            do {
+                recur = iø1 < G__11ø1 ? (function () {
+                    geometry.vertices[iø1].z = terrainHeight * heightmap[iø1];
+                    return loop[0] = 1 + iø1, loop;
+                })() : void 0;
+            } while (iø1 = loop[0], recur === loop);
+            return recur;
+        }.call(this);
+    }.call(this));
+    geometry.verticesNeedUpdate = true;
+    geometry.computeFaceNormals();
+    geometry.computeVertexNormals();
+    geometry.computeMorphNormals();
+    return geometry;
+};
+var makeDemo = exports.makeDemo = function makeDemo(elementId, algorithm, size) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var geometry = makeGeometry(makeHeightmap(size));
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    scene.add(makePlane(geometry));
+    var refresh = function refresh() {
+        l('Refreshing ========================================');
+        return function () {
+            var heightmapø1 = makeHeightmap(size);
+            l('Generating terrain...');
+            (function () {
+                var G__12ø1 = new Date().getTime();
+                var G__14ø1 = (function () {
+                    return algorithm(heightmapø1);
+                })();
+                var G__13ø1 = new Date().getTime();
+                l('Elapsed time: ' + (G__13ø1 - G__12ø1) + 'ms.');
+                return G__14ø1;
+            }.call(this));
+            l('Refreshing geometry...');
+            (function () {
+                var G__15ø1 = new Date().getTime();
+                var G__17ø1 = (function () {
+                    return updateGeometry(geometry, heightmapø1);
+                })();
+                var G__16ø1 = new Date().getTime();
+                l('Elapsed time: ' + (G__16ø1 - G__15ø1) + 'ms.');
+                return G__17ø1;
+            }.call(this));
+            return l('Done!');
+        }.call(this);
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    render();
+    return void 0;
+};
+var makeFinal = exports.makeFinal = function makeFinal(elementId) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var heightmap = makeHeightmap($('#input-exponent').val());
+    var geometry = makeGeometry(heightmap);
+    var plane = makePlane(geometry);
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    scene.add(plane);
+    var refresh = function refresh() {
+        l('Refreshing ========================================');
+        scene.remove(plane);
+        heightmap = makeHeightmap($('#input-exponent').val());
+        geometry = makeGeometry(heightmap);
+        plane = makePlane(geometry);
+        scene.add(plane);
+        l('Generating terrain...');
+        (function () {
+            var G__18ø1 = new Date().getTime();
+            var G__20ø1 = (function () {
+                return midpointDisplacementFinal(heightmap);
+            })();
+            var G__19ø1 = new Date().getTime();
+            l('Elapsed time: ' + (G__19ø1 - G__18ø1) + 'ms.');
+            return G__20ø1;
+        }.call(this));
+        l('Refreshing geometry...');
+        (function () {
+            var G__21ø1 = new Date().getTime();
+            var G__23ø1 = (function () {
+                return updateGeometry(geometry, heightmap);
+            })();
+            var G__22ø1 = new Date().getTime();
+            l('Elapsed time: ' + (G__22ø1 - G__21ø1) + 'ms.');
+            return G__23ø1;
+        }.call(this));
+        return l('Done!');
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    render();
+    return void 0;
+};
+var run = exports.run = function run() {
+    makeDemo('demo-random', randomNoise, 7);
+    makeDemo('demo-mpd-1', midpointDisplacementD1, 2);
+    makeDemo('demo-mpd-2', midpointDisplacementD2, 2);
+    makeDemo('demo-mpd-3', midpointDisplacementD3, 2);
+    makeDemo('demo-mpd-4', midpointDisplacement, 3);
+    return makeFinal('demo-final');
+};
+$(run);
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFub255bW91cy53aXNwIl0sIm5hbWVzIjpbIndpZHRoIiwiZXhwb3J0cyIsImhlaWdodCIsIndpcmVmcmFtZSIsIndpcmVmcmFtZVdpZHRoIiwidGVycmFpbkhlaWdodCIsInRlcnJhaW5TaXplIiwibCIsInYiLCJjb25zb2xlIiwibG9nIiwibWlkcG9pbnQiLCJhIiwiYiIsImF2ZXJhZ2UyI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AgICAgICAgKC8gd2lkdGggaGVpZ2h0KVxuICAgICAgICAgICAgICAgICAgICAwLjEsXG4gICAgICAgICAgICAgICAgICAgIDEwMDApXVxuICAgIChjYW1lcmEucG9zaXRpb24uc2V0IDAgLTEwMCAxNTApXG4gICAgY2FtZXJhKSlcblxuKGRlZm4gbWFrZS1yZW5kZXJlciBbXVxuICAobGV0IFtyZW5kZXJlciAobmV3IFRIUkVFLldlYkdMUmVuZGVyZXIgezphbnRpYWxpYXMgZmFsc2V9KV1cbiAgICAocmVuZGVyZXIuc2V0Q2xlYXJDb2xvciAweGZmZmZmZilcbiAgICAocmVuZGVyZXIuc2V0U2l6ZSB3aWR0aCBoZWlnaHQpXG4gICAgKHJlbmRlcmVyLnNldFBpeGVsUmF0aW8gMilcbiAgICByZW5kZXJlcikpXG5cbihkZWZuIG1ha2UtZ2VvbWV0cnkgW2hlaWdodG1hcF1cbiAgKGxldCBbZ2VvbWV0cnkgKG5ldyBUSFJFRS5QbGFuZUdlb21ldHJ5XG4gICAgICAgICAgICAgICAgICAgICAgdGVycmFpbi1zaXplXG4gICAgICAgICAgICAgICAgICAgICAgdGVycmFpbi1zaXplXG4gICAgICAgICAgICAgICAgICAgICAgKC0gaGVpZ2h0bWFwLnJlc29sdXRpb24gMSlcbiAgICAgICAgICAgICAgICAgICAgICAoLSBoZWlnaHRtYXAucmVzb2x1dGlvbiAxKSldXG4gICAgKHNldCEgZ2VvbWV0cnkuZHluYW1pYyB0cnVlKVxuICAgIGdlb21ldHJ5KSlcblxuKGRlZm4gbWFrZS1jb250cm9scyBbY2FtZXJhIHJlbmRlcmVyXVxuICAobGV0IFtjb250cm9scyAobmV3IFRIUkVFLlRyYWNrYmFsbENvbnRyb2xzIGNhbWVyYSByZW5kZXJlci5kb21FbGVtZW50KV1cbiAgICAoc2V0ISBjb250cm9scy5yb3RhdGVTcGVlZCAxLjQpXG4gICAgKHNldCEgY29udHJvbHMuem9vbVNwZWVkIDAuNSlcbiAgICAoc2V0ISBj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ZW1vLW1pZHBvaW50XCIgbWlkcG9pbnQtZGlzcGxhY2VtZW50KVxuICA7IChtYWtlLWRlbW8gXCJkZW1vLWRpYW1vbmRcIiBkaWFtb25kLXNxdWFyZSlcblxuICApXG5cbigkIHJ1bilcblxuXG47IHZpbTogbHcrPWRvLXRpbWVzIGx3Kz1kby1uZXN0ZWQgOlxuIl19
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/wisp/terrain1.wisp	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,392 @@
+; Constants -------------------------------------------------------------------
+(def width 610)
+(def height 400)
+(def wireframe true)
+(def wireframe-width 1.2)
+(def terrain-height 50)
+(def terrain-size 100)
+
+; General Utilities -----------------------------------------------------------
+(defmacro when [condition & body]
+  `(if ~condition
+     (do ~@body)))
+
+(defmacro do-times [varname limit & body]
+  (let [end (gensym)]
+    `(let [~end ~limit]
+       (loop [~varname 0]
+         (when (< ~varname ~end)
+           ~@body
+           (recur (+ 1 ~varname)))))))
+
+(defmacro do-nested [xname yname width & body]
+  (let [iterations (gensym)]
+    `(let [~iterations ~width]
+       (do-times ~xname ~iterations
+         (do-times ~yname ~iterations
+           ~@body)))))
+
+(defmacro inc! [place]
+  `(set! ~place (+ ~place 1)))
+
+(defmacro add! [place amount]
+  `(set! ~place (+ ~place ~amount)))
+
+(defmacro time [& body]
+  (let [start (gensym)
+        end (gensym)
+        result (gensym)]
+    `(let [~start (.getTime (new Date))
+           ~result (do ~@body)
+           ~end (.getTime (new Date))]
+       (l (+ "Elapsed time: " (- ~end ~start) "ms."))
+       ~result)))
+
+(defn l [v]
+  (console.log v))
+
+
+(defn midpoint [a b]
+  (/ (+ a b) 2))
+
+(defn average2 [a b]
+  (/ (+ a b) 2))
+
+(defn average4 [a b c d]
+  (/ (+ a b c d) 4))
+
+(defn safe-average [a b c d]
+  (let [total 0 count 0]
+    (when a (add! total a) (inc! count))
+    (when b (add! total b) (inc! count))
+    (when c (add! total c) (inc! count))
+    (when d (add! total d) (inc! count))
+    (/ total count)))
+
+
+(defn rand []
+  (Math.random))
+
+(defn rand-around-zero [spread]
+  (- (* spread (rand) 2) spread))
+
+
+(defn jitter [value spread]
+  (+ value (rand-around-zero spread)))
+
+
+; Heightmap Helpers -----------------------------------------------------------
+(defmacro heightmap-get [hm x y]
+  `(aget ~hm (+ (* ~y (.-resolution ~hm)) ~x)))
+
+(defn heightmap-get-safe [hm x y]
+  (when (and (<= 0 x hm.last)
+             (<= 0 y hm.last))
+    (heightmap-get hm x y)))
+
+(defmacro heightmap-set! [hm x y val]
+  `(set! (heightmap-get ~hm ~x ~y) ~val))
+
+
+(defn normalize [hm]
+  (let [max (- Infinity)
+        min Infinity]
+    (do-times i hm.length
+      (let [el (aget hm i)]
+        (when (< max el) (set! max el))
+        (when (> min el) (set! min el))))
+    (let [span (- max min)]
+      (do-times i hm.length
+        (set! (aget hm i)
+          (/ (- (aget hm i) min)
+             span))))))
+
+(defn zero-heightmap [heightmap]
+  (do-times i heightmap.length
+    (set! (aget heightmap i) 0.0))
+  heightmap)
+
+(defn make-heightmap [exponent]
+  (let [resolution (+ 1 (Math.pow 2 exponent))]
+    (l (+ "Creating " resolution " by " resolution " heightmap..."))
+    (def heightmap
+      (new Array (* resolution resolution)))
+    (set! heightmap.resolution resolution)
+    (set! heightmap.exponent exponent)
+    (set! heightmap.last (- resolution 1))
+    (zero-heightmap heightmap)))
+
+
+; Random Noise ----------------------------------------------------------------
+(defn random-noise [heightmap]
+  (do-times i heightmap.length
+    (set! (aget heightmap i) (rand))))
+
+
+; Midpoint Displacement -------------------------------------------------------
+(defn mpd-init-corners [heightmap]
+  (heightmap-set! heightmap 0 0 (rand))
+  (heightmap-set! heightmap 0 heightmap.last (rand))
+  (heightmap-set! heightmap heightmap.last 0 (rand))
+  (heightmap-set! heightmap heightmap.last heightmap.last (rand)))
+
+(defn mpd-displace [heightmap lx rx by ty spread]
+  (let [cx (midpoint lx rx)
+        cy (midpoint by ty)
+
+        bottom-left (heightmap-get heightmap lx by)
+        bottom-right (heightmap-get heightmap rx by)
+        top-left (heightmap-get heightmap lx ty)
+        top-right (heightmap-get heightmap rx ty)
+
+        top (average2 top-left top-right)
+        left (average2 bottom-left top-left)
+        bottom (average2 bottom-left bottom-right)
+        right (average2 bottom-right top-right)
+        center (average4 top left bottom right)]
+    (heightmap-set! heightmap cx by (jitter bottom spread))
+    (heightmap-set! heightmap cx ty (jitter top spread))
+    (heightmap-set! heightmap lx cy (jitter left spread))
+    (heightmap-set! heightmap rx cy (jitter right spread))
+    (heightmap-set! heightmap cx cy (jitter center spread))))
+
+(defn midpoint-displacement [heightmap]
+  (mpd-init-corners heightmap)
+  ; (mpd-displace heightmap 0 heightmap.last 0 heightmap.last 0.1)
+  (loop [iter 0
+         spread 0.3]
+    (when (< iter heightmap.exponent)
+      (let [chunks (Math.pow 2 iter)
+            chunk-width (/ (- heightmap.resolution 1) chunks)]
+        (do-nested xchunk ychunk chunks
+          (let [left-x (* chunk-width xchunk)
+                right-x (+ left-x chunk-width)
+                bottom-y (* chunk-width ychunk)
+                top-y (+ bottom-y chunk-width)]
+            (mpd-displace heightmap left-x right-x bottom-y top-y spread))))
+      (recur (+ 1 iter) (* spread 0.5))))
+  (normalize heightmap))
+
+
+(defn midpoint-displacement-final [heightmap]
+  (mpd-init-corners heightmap)
+  ; (let [spread ])
+  (loop [iter 0
+         spread (+ 0 (.val ($ "#input-starting-spread")))]
+    (when (< iter heightmap.exponent)
+      (let [chunks (Math.pow 2 iter)
+            chunk-width (/ (- heightmap.resolution 1) chunks)]
+        (do-nested xchunk ychunk chunks
+          (let [left-x (* chunk-width xchunk)
+                right-x (+ left-x chunk-width)
+                bottom-y (* chunk-width ychunk)
+                top-y (+ bottom-y chunk-width)]
+            (mpd-displace heightmap left-x right-x bottom-y top-y spread))))
+      (recur (+ 1 iter) (* spread
+                           (+ 0 (.val ($ "#input-spread-reduction")))))))
+  (normalize heightmap))
+
+
+(defn mpd-displace-d2 [heightmap lx rx by ty spread]
+  (let [cx (midpoint lx rx)
+        cy (midpoint by ty)
+
+        bottom-left (heightmap-get heightmap lx by)
+        bottom-right (heightmap-get heightmap rx by)
+        top-left (heightmap-get heightmap lx ty)
+        top-right (heightmap-get heightmap rx ty)
+
+        top (average2 top-left top-right)
+        left (average2 bottom-left top-left)
+        bottom (average2 bottom-left bottom-right)
+        right (average2 bottom-right top-right)]
+    (heightmap-set! heightmap cx by (jitter bottom spread))
+    (heightmap-set! heightmap cx ty (jitter top spread))
+    (heightmap-set! heightmap lx cy (jitter left spread))
+    (heightmap-set! heightmap rx cy (jitter right spread))))
+
+(defn midpoint-displacement-d1 [heightmap]
+  (mpd-init-corners heightmap))
+
+(defn midpoint-displacement-d2 [heightmap]
+  (mpd-init-corners heightmap)
+  (mpd-displace-d2 heightmap
+                   0 heightmap.last
+                   0 heightmap.last
+                   0.1))
+
+(defn midpoint-displacement-d3 [heightmap]
+  (mpd-init-corners heightmap)
+  (mpd-displace heightmap
+                0 heightmap.last
+                0 heightmap.last
+                0.1))
+
+
+
+; Three.js Helpers ------------------------------------------------------------
+(defn make-directional-light []
+  (let [light (new THREE.DirectionalLight 0xffffff 1)]
+    (light.position.set 100 0 150)
+    light))
+
+(defn make-camera []
+  (let [camera (new THREE.PerspectiveCamera
+                    55,
+                    (/ width height)
+                    0.1,
+                    1000)]
+    (camera.position.set 0 -100 150)
+    camera))
+
+(defn make-renderer []
+  (let [renderer (new THREE.WebGLRenderer {:antialias false})]
+    (renderer.setClearColor 0xffffff)
+    (renderer.setSize width height)
+    (renderer.setPixelRatio 2)
+    renderer))
+
+(defn make-geometry [heightmap]
+  (let [geometry (new THREE.PlaneGeometry
+                      terrain-size
+                      terrain-size
+                      (- heightmap.resolution 1)
+                      (- heightmap.resolution 1))]
+    (set! geometry.dynamic true)
+    geometry))
+
+(defn make-controls [camera renderer]
+  (let [controls (new THREE.TrackballControls camera renderer.domElement)]
+    (set! controls.rotateSpeed 1.4)
+    (set! controls.zoomSpeed 0.5)
+    (set! controls.staticMoving true)
+    (set! controls.dynamicDampingFactor 0.3)
+    controls))
+
+(defn make-plane [geometry]
+  (let [material (new THREE.MeshLambertMaterial
+                      {:wireframe wireframe
+                       :wireframeLinewidth wireframe-width
+                       :color 0x00bb00})]
+    (new THREE.Mesh geometry material)))
+
+
+(defn attach-to-dom [renderer el-name refresh-fn]
+  (let [container (document.getElementById el-name)
+        settings (document.createElement "div")
+        refresh-button (document.createElement "button")
+        button-text (document.createTextNode "Refresh")
+        cancel-scroll (fn [e] (.preventDefault e))]
+    (set! refresh-button.onclick refresh-fn)
+    (set! renderer.domElement.onmousewheel cancel-scroll)
+    (renderer.domElement.addEventListener "MozMousePixelScroll" cancel-scroll false)
+    (.appendChild refresh-button button-text)
+    (.appendChild container renderer.domElement)
+    (.appendChild container settings)
+    (.appendChild settings refresh-button)))
+
+(defn update-geometry [geometry heightmap]
+  (do-times i geometry.vertices.length
+    (set! (.-z (aget geometry.vertices i))
+      (* terrain-height (aget heightmap i))))
+  (set! geometry.verticesNeedUpdate true)
+  (geometry.computeFaceNormals)
+  (geometry.computeVertexNormals)
+  (geometry.computeMorphNormals)
+  geometry)
+
+
+; Main ------------------------------------------------------------------------
+(defn make-demo [element-id algorithm size]
+  (def scene (new THREE.Scene))
+  (scene.add (new THREE.AxisHelper 100))
+
+  (def clock (new THREE.Clock))
+  (def camera (make-camera))
+  (def renderer (make-renderer))
+  (def geometry (make-geometry (make-heightmap size)))
+
+  (scene.add (make-directional-light))
+  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
+  (scene.add (make-plane geometry))
+
+  (defn refresh []
+    (l "Refreshing ========================================")
+    (let [heightmap (make-heightmap size)]
+      (l "Generating terrain...")
+      (time (algorithm heightmap))
+      (l "Refreshing geometry...")
+      (time (update-geometry geometry heightmap))
+      (l "Done!")))
+
+  (attach-to-dom renderer element-id refresh)
+  (def controls (make-controls camera renderer))
+
+  (defn render []
+    (let [delta (clock.getDelta)]
+      (requestAnimationFrame render)
+      (.update controls delta)
+      (renderer.render scene camera)))
+
+  (render)
+
+  nil)
+
+(defn make-final [element-id]
+  (def scene (new THREE.Scene))
+  (scene.add (new THREE.AxisHelper 100))
+
+  (def clock (new THREE.Clock))
+  (def camera (make-camera))
+  (def renderer (make-renderer))
+  (def heightmap (make-heightmap (.val ($ "#input-exponent"))))
+  (def geometry (make-geometry heightmap))
+  (def plane (make-plane geometry))
+
+  (scene.add (make-directional-light))
+  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
+  (scene.add plane)
+
+  (defn refresh []
+    (l "Refreshing ========================================")
+    (scene.remove plane)
+    (set! heightmap (make-heightmap (.val ($ "#input-exponent"))))
+    (set! geometry (make-geometry heightmap))
+    (set! plane (make-plane geometry))
+    (scene.add plane)
+    (l "Generating terrain...")
+    (time (midpoint-displacement-final heightmap))
+    (l "Refreshing geometry...")
+    (time (update-geometry geometry heightmap))
+    (l "Done!"))
+
+  (attach-to-dom renderer element-id refresh)
+  (def controls (make-controls camera renderer))
+
+  (defn render []
+    (let [delta (clock.getDelta)]
+      (requestAnimationFrame render)
+      (.update controls delta)
+      (renderer.render scene camera)))
+
+  (render)
+
+  nil)
+
+
+(defn run []
+  (make-demo "demo-random" random-noise 7)
+  (make-demo "demo-mpd-1" midpoint-displacement-d1 2)
+  (make-demo "demo-mpd-2" midpoint-displacement-d2 2)
+  (make-demo "demo-mpd-3" midpoint-displacement-d3 2)
+  (make-demo "demo-mpd-4" midpoint-displacement 3)
+  (make-final "demo-final")
+  ; (make-demo "demo-midpoint" midpoint-displacement)
+  ; (make-demo "demo-diamond" diamond-square)
+
+  )
+
+($ run)
+
+
+; vim: lw+=do-times lw+=do-nested :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/wisp/terrain2.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,404 @@
+{
+    var _ns_ = {
+        id: 'demo',
+        doc: void 0
+    };
+    var ndarray = require('ndarray');
+}
+var width = exports.width = 610;
+var height = exports.height = 400;
+var wireframe = exports.wireframe = true;
+var wireframeWidth = exports.wireframeWidth = 1.2;
+var terrainHeight = exports.terrainHeight = 50;
+var terrainSize = exports.terrainSize = 100;
+void 0;
+void 0;
+void 0;
+var inc = exports.inc = function inc(x) {
+    return x + 1;
+};
+var dec = exports.dec = function dec(x) {
+    return x - 1;
+};
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+var midpoint = exports.midpoint = function midpoint(a, b) {
+    return (a + b) / 2;
+};
+var average2 = exports.average2 = function average2(a, b) {
+    return (a + b) / 2;
+};
+var average4 = exports.average4 = function average4(a, b, c, d) {
+    return (a + b + c + d) / 4;
+};
+var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
+    return function () {
+        var totalø1 = 0;
+        var countø1 = 0;
+        a ? (function () {
+            totalø1 = totalø1 + a;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        b ? (function () {
+            totalø1 = totalø1 + b;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        c ? (function () {
+            totalø1 = totalø1 + c;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        d ? (function () {
+            totalø1 = totalø1 + d;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        return totalø1 / countø1;
+    }.call(this);
+};
+var rand = exports.rand = function rand() {
+    return Math.random();
+};
+var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
+    return spread * rand() * 2 - spread;
+};
+var jitter = exports.jitter = function jitter(value, spread) {
+    return value + randAroundZero(spread);
+};
+var heightmapResolution = exports.heightmapResolution = function heightmapResolution(heightmap) {
+    return heightmap.shape[0];
+};
+var heightmapLastIndex = exports.heightmapLastIndex = function heightmapLastIndex(heightmap) {
+    return dec(heightmapResolution(heightmap));
+};
+var heightmapCenterIndex = exports.heightmapCenterIndex = function heightmapCenterIndex(heightmap) {
+    return midpoint(0, heightmapLastIndex(heightmap));
+};
+var heightmapGet = exports.heightmapGet = function heightmapGet(heightmap, x, y) {
+    return heightmap.get(x, y);
+};
+var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(heightmap, x, y) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        return 0 <= x && x <= lastø1 && (0 <= y && y <= lastø1) ? (function () {
+            return heightmapGet(heightmap, x, y);
+        })() : void 0;
+    }.call(this);
+};
+var heightmapSet = exports.heightmapSet = function heightmapSet(heightmap, x, y, val) {
+    return heightmap.set(x, y, val);
+};
+var heightmapSetIfUnset = exports.heightmapSetIfUnset = function heightmapSetIfUnset(heightmap, x, y, val) {
+    return 0 == heightmapGet(heightmap, x, y) ? (function () {
+        return heightmapSet(heightmap, x, y, val);
+    })() : void 0;
+};
+var normalize = exports.normalize = function normalize(heightmap) {
+    return function () {
+        var maxø1 = 0 - Infinity;
+        var minø1 = Infinity;
+        (function () {
+            var array2ø1 = heightmap;
+            return function () {
+                var G__3ø1 = array2ø1.data.length;
+                return function loop() {
+                    var recur = loop;
+                    var index1ø1 = 0;
+                    do {
+                        recur = index1ø1 < G__3ø1 ? (function () {
+                            (function () {
+                                var elø1 = array2ø1.data[index1ø1];
+                                maxø1 < elø1 ? (function () {
+                                    return maxø1 = elø1;
+                                })() : void 0;
+                                return minø1 > elø1 ? (function () {
+                                    return minø1 = elø1;
+                                })() : void 0;
+                            }.call(this));
+                            return loop[0] = inc(index1ø1), loop;
+                        })() : void 0;
+                    } while (index1ø1 = loop[0], recur === loop);
+                    return recur;
+                }.call(this);
+            }.call(this);
+        }.call(this));
+        return function () {
+            var spanø1 = maxø1 - minø1;
+            return function () {
+                var array4ø1 = heightmap;
+                return function () {
+                    var G__5ø1 = array4ø1.shape[0];
+                    return function loop() {
+                        var recur = loop;
+                        var xø1 = 0;
+                        do {
+                            recur = xø1 < G__5ø1 ? (function () {
+                                (function () {
+                                    var G__6ø1 = array4ø1.shape[1];
+                                    return function loop() {
+                                        var recur = loop;
+                                        var yø1 = 0;
+                                        do {
+                                            recur = yø1 < G__6ø1 ? (function () {
+                                                (function () {
+                                                    return heightmapSet(heightmap, xø1, yø1, (heightmapGet(heightmap, xø1, yø1) - minø1) / spanø1);
+                                                })();
+                                                return loop[0] = inc(yø1), loop;
+                                            })() : void 0;
+                                        } while (yø1 = loop[0], recur === loop);
+                                        return recur;
+                                    }.call(this);
+                                }.call(this));
+                                return loop[0] = inc(xø1), loop;
+                            })() : void 0;
+                        } while (xø1 = loop[0], recur === loop);
+                        return recur;
+                    }.call(this);
+                }.call(this);
+            }.call(this);
+        }.call(this);
+    }.call(this);
+};
+var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
+    return function () {
+        var resolutionø1 = Math.pow(2, exponent) + 1;
+        return function () {
+            var heightmapø1 = ndarray(new Float64Array(resolutionø1 * resolutionø1), [
+                resolutionø1,
+                resolutionø1
+            ]);
+            heightmapø1.exponent = exponent;
+            heightmapø1.resolution = resolutionø1;
+            heightmapø1.last = dec(resolutionø1);
+            return heightmapø1;
+        }.call(this);
+    }.call(this);
+};
+var topLeftCorner = exports.topLeftCorner = function topLeftCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(0, 0).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var topRightCorner = exports.topRightCorner = function topRightCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(centerø1, 0).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var bottomLeftCorner = exports.bottomLeftCorner = function bottomLeftCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(0, centerø1).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var bottomRightCorner = exports.bottomRightCorner = function bottomRightCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(centerø1, centerø1).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var mpdInitCorners = exports.mpdInitCorners = function mpdInitCorners(heightmap) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        heightmapSet(heightmap, 0, 0, rand());
+        heightmapSet(heightmap, 0, lastø1, rand());
+        heightmapSet(heightmap, lastø1, 0, rand());
+        return heightmapSet(heightmap, lastø1, lastø1, rand());
+    }.call(this);
+};
+var mpdDisplace = exports.mpdDisplace = function mpdDisplace(heightmap, spread, spreadReduction) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        var cø1 = midpoint(0, lastø1);
+        var bottomLeftø1 = heightmapGet(heightmap, 0, 0);
+        var bottomRightø1 = heightmapGet(heightmap, lastø1, 0);
+        var topLeftø1 = heightmapGet(heightmap, 0, lastø1);
+        var topRightø1 = heightmapGet(heightmap, lastø1, lastø1);
+        var topø1 = average2(topLeftø1, topRightø1);
+        var leftø1 = average2(bottomLeftø1, topLeftø1);
+        var bottomø1 = average2(bottomLeftø1, bottomRightø1);
+        var rightø1 = average2(bottomRightø1, topRightø1);
+        var centerø1 = average4(topø1, leftø1, bottomø1, rightø1);
+        var nextSpreadø1 = spread * spreadReduction;
+        heightmapSetIfUnset(heightmap, cø1, 0, jitter(bottomø1, spread));
+        heightmapSetIfUnset(heightmap, cø1, lastø1, jitter(topø1, spread));
+        heightmapSetIfUnset(heightmap, 0, cø1, jitter(leftø1, spread));
+        heightmapSetIfUnset(heightmap, lastø1, cø1, jitter(rightø1, spread));
+        heightmapSetIfUnset(heightmap, cø1, cø1, jitter(centerø1, spread));
+        return !(3 == heightmapResolution(heightmap)) ? (function () {
+            heightmapSetIfUnset(heightmap, cø1, 0, jitter(bottomø1, spread));
+            heightmapSetIfUnset(heightmap, cø1, lastø1, jitter(topø1, spread));
+            heightmapSetIfUnset(heightmap, 0, cø1, jitter(leftø1, spread));
+            heightmapSetIfUnset(heightmap, lastø1, cø1, jitter(rightø1, spread));
+            heightmapSetIfUnset(heightmap, cø1, cø1, jitter(centerø1, spread));
+            mpdDisplace(topLeftCorner(heightmap), nextSpreadø1, spreadReduction);
+            mpdDisplace(topRightCorner(heightmap), nextSpreadø1, spreadReduction);
+            mpdDisplace(bottomLeftCorner(heightmap), nextSpreadø1, spreadReduction);
+            return mpdDisplace(bottomRightCorner(heightmap), nextSpreadø1, spreadReduction);
+        })() : void 0;
+    }.call(this);
+};
+var midpointDisplacement = exports.midpointDisplacement = function midpointDisplacement(heightmap) {
+    return function () {
+        var initialSpreadø1 = 0.3;
+        var spreadReductionø1 = 0.55;
+        mpdInitCorners(heightmap);
+        mpdDisplace(heightmap, initialSpreadø1, spreadReductionø1);
+        return normalize(heightmap);
+    }.call(this);
+};
+var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
+    return function () {
+        var lightø1 = new THREE.DirectionalLight(16777215, 1);
+        lightø1.position.set(100, 0, 150);
+        return lightø1;
+    }.call(this);
+};
+var makeCamera = exports.makeCamera = function makeCamera() {
+    return function () {
+        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
+        cameraø1.position.set(0, -100, 150);
+        return cameraø1;
+    }.call(this);
+};
+var makeRenderer = exports.makeRenderer = function makeRenderer() {
+    return function () {
+        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
+        rendererø1.setClearColor(16777215);
+        rendererø1.setSize(width, height);
+        rendererø1.setPixelRatio(2);
+        return rendererø1;
+    }.call(this);
+};
+var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
+    return function () {
+        var resolutionø1 = heightmap.shape[0];
+        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, resolutionø1 - 1, resolutionø1 - 1);
+        return geometryø1;
+    }.call(this);
+};
+var makeControls = exports.makeControls = function makeControls(camera, renderer) {
+    return function () {
+        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
+        controlsø1.rotateSpeed = 1.4;
+        controlsø1.zoomSpeed = 0.5;
+        controlsø1.staticMoving = true;
+        controlsø1.dynamicDampingFactor = 0.3;
+        return controlsø1;
+    }.call(this);
+};
+var makePlane = exports.makePlane = function makePlane(geometry) {
+    return function () {
+        var materialø1 = new THREE.MeshLambertMaterial({
+            'wireframe': wireframe,
+            'wireframeLinewidth': wireframeWidth,
+            'color': 47872
+        });
+        return new THREE.Mesh(geometry, materialø1);
+    }.call(this);
+};
+var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
+    return function () {
+        var containerø1 = document.getElementById(elName);
+        var settingsø1 = document.createElement('div');
+        var refreshButtonø1 = document.createElement('button');
+        var buttonTextø1 = document.createTextNode('Refresh');
+        var cancelScrollø1 = function (e) {
+            return e.preventDefault();
+        };
+        refreshButtonø1.onclick = refreshFn;
+        renderer.domElement.onmousewheel = cancelScrollø1;
+        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
+        refreshButtonø1.appendChild(buttonTextø1);
+        containerø1.appendChild(renderer.domElement);
+        containerø1.appendChild(settingsø1);
+        return settingsø1.appendChild(refreshButtonø1);
+    }.call(this);
+};
+var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
+    (function loop() {
+        var recur = loop;
+        var iø1 = 0;
+        do {
+            recur = iø1 < geometry.vertices.length ? (function () {
+                geometry.vertices[iø1].z = terrainHeight * heightmap.data[iø1];
+                return loop[0] = iø1 + 1, loop;
+            })() : void 0;
+        } while (iø1 = loop[0], recur === loop);
+        return recur;
+    }.call(this));
+    geometry.computeVertexNormals();
+    return geometry;
+};
+var makeFinal = exports.makeFinal = function makeFinal(elementId) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var geometry = void 0;
+    var plane = void 0;
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    var refresh = function refresh() {
+        return function () {
+            var heightmapø1 = makeHeightmap(6);
+            console.log('Generating terrain...');
+            (function () {
+                var G__7ø1 = new Date().getTime();
+                var G__9ø1 = (function () {
+                    return midpointDisplacement(heightmapø1);
+                })();
+                var G__8ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__8ø1 - G__7ø1) + 'ms.');
+                return G__9ø1;
+            }.call(this));
+            console.log('Rebuilding geometry...');
+            (function () {
+                var G__10ø1 = new Date().getTime();
+                var G__12ø1 = (function () {
+                    geometry = makeGeometry(heightmapø1);
+                    return updateGeometry(geometry, heightmapø1);
+                })();
+                var G__11ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__11ø1 - G__10ø1) + 'ms.');
+                return G__12ø1;
+            }.call(this));
+            console.log('Rebuilding plane...');
+            return function () {
+                var G__13ø1 = new Date().getTime();
+                var G__15ø1 = (function () {
+                    scene.remove(plane);
+                    plane = makePlane(geometry);
+                    return scene.add(plane);
+                })();
+                var G__14ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__14ø1 - G__13ø1) + 'ms.');
+                return G__15ø1;
+            }.call(this);
+        }.call(this);
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    refresh();
+    render();
+    return void 0;
+};
+var run = exports.run = function run() {
+    return makeFinal('demo-final');
+};
+$(run);
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFub255bW91cy53aXNwIl0sIm5hbWVzIjpbIl9uc18iLCJpZCIsImRvYyIsIndpZHRoIiwiZXhwb3J0cyIsImhlaWdodCIsIndpcmVmcmFtZSIsIndpcmVmcmFtZVdpZHRoIiwidGVycmFpbkhlaWdodCIsInRlcnJhaW5TaXplIiwiaW5jIiwieCIsImRlYyIsIm1pZHBvaW50IiwiYSIsImIiLCJhdmVyYWdlMiIsImF2ZXJhZ2U0IiwiYyIsImQiLCJzYWZlQXZlcmFnZSIsInRvdGFsw7gxIiwiY291bnTDuDEiLCJyYW5kIiwiTWF0aCIsInJhb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V1cbiAgICAgICAgICAgICAgICAgICAgYChsb29wIFt+dmFybmFtZSB+c3RhcnRdXG4gICAgICAgICAgICAgICAgICAgICAgICh3aGVuICg8IH52YXJuYW1lIH5lbmQpXG4gICAgICAgICAgICAgICAgICAgICAgICAgfihidWlsZCAocmVzdCB2YXJzKSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAocmVjdXIgKCsgfnZhcm5hbWUgfnN0cmlkZSkpKSkpKSldXG4gICAgOyBGaXggdGhlIG51bWJlcnMgb25jZSBvdXRzaWRlIHRoZSBuZXN0ZWQgbG9vcHMsXG4gICAgOyBhbmQgdGhlbiBidWlsZCB0aGUgZ3V0cy5cbiAgICBgKGxldCBbfnN0YXJ0IH5zdGFydC1mb3JtXG4gICAgICAgICAgIH5lbmQgfmVuZC1mb3JtXG4gICAgICAgICAgIH5zdHJpZGUgfnN0cmlkZS1mb3JtXVxuICAgICAgIH4oYnVpbGQgdmFybmFtZXMpKSkpXG5cblxuKGRlZm1hY3JvIGRvLW5kYXJyYXkgW3ZhcnMgYXJyYXktZm9ybSAmIGJvZHldXG4gIChsZXQgW2FycmF5LXZhciAoZ2Vuc3ltIFwiYXJyYXlcIilcbiAgICAgICAgYnVpbGQgKGZuIGJ1aWxkIFt2YXJzIG5dXG4gICAgICAgICAgICAgICAgKGlmIChlbXB0eT8gdmFycylcbiAgICAgICAgICAgICAgICAgIGAoZG8gfkBib2R5KVxuICAgICAgICAgICAgICAgICAgYChkby10aW1lcyB+KGZpcnN0IHZhcnMpIChhZ2V0ICguLXNoYXBlIH5hcnJheS12YXIpIH5uKVxuICAgICAgICAgICAgICAgICAgICAgfihidWlsZCAocmVzdCB2YXJzKSAoaW5jIG4pKSkpKV1cbiAgICBgKGxldCBbfmFycmF5LXZhciB+YXJyYXktZm9ybV1cbiAgICAgICB+KGJ1aWxkIHZhcnMgMCkpKSlcblxuKGRlZm1hY3JvIGRvLW5kYXJyYXktZWwgW2VsZW1lbnQgYXJyYXktZm9ybSAmIGJvZH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ICAoc2NlbmUuYWRkIHBsYW5lKSkpKVxuXG4gIChhdHRhY2gtdG8tZG9tIHJlbmRlcmVyIGVsZW1lbnQtaWQgcmVmcmVzaClcbiAgKGRlZiBjb250cm9scyAobWFrZS1jb250cm9scyBjYW1lcmEgcmVuZGVyZXIpKVxuXG4gIChkZWZuIHJlbmRlciBbXVxuICAgIChsZXQgW2RlbHRhIChjbG9jay5nZXREZWx0YSldXG4gICAgICAocmVxdWVzdEFuaW1hdGlvbkZyYW1lIHJlbmRlcilcbiAgICAgICgudXBkYXRlIGNvbnRyb2xzIGRlbHRhKVxuICAgICAgKHJlbmRlcmVyLnJlbmRlciBzY2VuZSBjYW1lcmEpKSlcblxuICAocmVmcmVzaClcbiAgKHJlbmRlcilcblxuICBuaWwpXG5cbihkZWZuIHJ1biBbXVxuICAobWFrZS1maW5hbCBcImRlbW8tZmluYWxcIikpXG5cbigkIHJ1bilcblxuXG47IHZpbTogbHcrPWRvLXRpbWVzIGx3Kz1kby1uZXN0ZWQgOlxuIl19
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/wisp/terrain2.wisp	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,376 @@
+(ns demo
+  (:require [ndarray]))
+
+; Constants -------------------------------------------------------------------
+(def width 610)
+(def height 400)
+(def wireframe true)
+(def wireframe-width 1.2)
+(def terrain-height 50)
+(def terrain-size 100)
+
+; General Utilities -----------------------------------------------------------
+(defmacro when [condition & body]
+  `(if ~condition
+     (do ~@body)))
+
+(defmacro when-not [condition & body]
+  `(when (not ~condition)
+     ~@body))
+
+(defmacro -> [& operations]
+  (reduce
+    (fn [form operation]
+      (cons (first operation)
+            (cons form (rest operation))))
+    (first operations)
+    (rest operations)))
+
+
+(defn inc [x]
+  (+ x 1))
+
+(defn dec [x]
+  (- x 1))
+
+
+(defmacro do-times [varname limit & body]
+  (let [end (gensym)]
+    `(let [~end ~limit]
+       (loop [~varname 0]
+         (when (< ~varname ~end)
+           ~@body
+           (recur (inc ~varname)))))))
+
+(defmacro do-stride [varnames start-form end-form stride-form & body]
+  (let [stride (gensym "stride")
+        start (gensym "start")
+        end (gensym "end")
+        build (fn build [vars]
+                (if (empty? vars)
+                  `(do ~@body)
+                  (let [varname (first vars)]
+                    `(loop [~varname ~start]
+                       (when (< ~varname ~end)
+                         ~(build (rest vars))
+                         (recur (+ ~varname ~stride)))))))]
+    ; Fix the numbers once outside the nested loops,
+    ; and then build the guts.
+    `(let [~start ~start-form
+           ~end ~end-form
+           ~stride ~stride-form]
+       ~(build varnames))))
+
+
+(defmacro do-ndarray [vars array-form & body]
+  (let [array-var (gensym "array")
+        build (fn build [vars n]
+                (if (empty? vars)
+                  `(do ~@body)
+                  `(do-times ~(first vars) (aget (.-shape ~array-var) ~n)
+                     ~(build (rest vars) (inc n)))))]
+    `(let [~array-var ~array-form]
+       ~(build vars 0))))
+
+(defmacro do-ndarray-el [element array-form & body]
+  (let [index (gensym "index")
+        array (gensym "array")]
+    `(let [~array ~array-form]
+       (do-times ~index (.-length (.-data ~array))
+         (let [~element (aget (.-data ~array) ~index)]
+           ~@body)))))
+
+
+(defmacro inc! [place]
+  `(set! ~place (inc ~place)))
+
+(defmacro add! [place amount]
+  `(set! ~place (+ ~place ~amount)))
+
+
+(defmacro l [& forms]
+  `(console.log ~@forms))
+
+(defmacro time [& body]
+  (let [start (gensym)
+        end (gensym)
+        result (gensym)]
+    `(let [~start (.getTime (new Date))
+           ~result (do ~@body)
+           ~end (.getTime (new Date))]
+       (l (+ "Elapsed time: " (- ~end ~start) "ms."))
+       ~result)))
+
+
+(defn midpoint [a b]
+  (/ (+ a b) 2))
+
+(defn average2 [a b]
+  (/ (+ a b) 2))
+
+(defn average4 [a b c d]
+  (/ (+ a b c d) 4))
+
+(defn safe-average [a b c d]
+  (let [total 0 count 0]
+    (when a (add! total a) (inc! count))
+    (when b (add! total b) (inc! count))
+    (when c (add! total c) (inc! count))
+    (when d (add! total d) (inc! count))
+    (/ total count)))
+
+
+; Randomness ------------------------------------------------------------------
+(defn rand []
+  (Math.random))
+
+(defn rand-around-zero [spread]
+  (- (* spread (rand) 2) spread))
+
+(defn jitter [value spread]
+  (+ value (rand-around-zero spread)))
+
+
+; Heightmap Helpers -----------------------------------------------------------
+(defn heightmap-resolution [heightmap]
+  (aget heightmap.shape 0))
+
+(defn heightmap-last-index [heightmap]
+  (dec (heightmap-resolution heightmap)))
+
+(defn heightmap-center-index [heightmap]
+  (midpoint 0 (heightmap-last-index heightmap)))
+
+
+(defn heightmap-get [heightmap x y]
+  (.get heightmap x y))
+
+(defn heightmap-get-safe [heightmap x y]
+  (let [last (heightmap-last-index heightmap)]
+    (when (and (<= 0 x last)
+               (<= 0 y last))
+      (heightmap-get heightmap x y))))
+
+(defn heightmap-set! [heightmap x y val]
+  (.set heightmap x y val))
+
+(defn heightmap-set-if-unset! [heightmap x y val]
+  (when (== 0 (heightmap-get heightmap x y))
+    (heightmap-set! heightmap x y val)))
+
+
+(defn normalize [heightmap]
+  (let [max (- Infinity)
+        min Infinity]
+    (do-ndarray-el el heightmap
+      (when (< max el) (set! max el))
+      (when (> min el) (set! min el)))
+    (let [span (- max min)]
+      (do-ndarray [x y] heightmap
+        (heightmap-set! heightmap x y
+                        (/ (- (heightmap-get heightmap x y) min)
+                           span))))))
+
+
+(defn make-heightmap [exponent]
+  (let [resolution (+ (Math.pow 2 exponent) 1)]
+    (let [heightmap (ndarray (new Float64Array (* resolution resolution))
+                             [resolution resolution])]
+      (set! heightmap.exponent exponent)
+      (set! heightmap.resolution resolution)
+      (set! heightmap.last (dec resolution))
+      heightmap)))
+
+
+(defn top-left-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo 0 0)
+      (.hi (inc center) (inc center)))))
+
+(defn top-right-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo center 0)
+      (.hi (inc center) (inc center)))))
+
+(defn bottom-left-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo 0 center)
+      (.hi (inc center) (inc center)))))
+
+(defn bottom-right-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo center center)
+      (.hi (inc center) (inc center)))))
+
+
+; Midpoint Displacement -------------------------------------------------------
+(defn mpd-init-corners [heightmap]
+  (let [last (heightmap-last-index heightmap)]
+    (heightmap-set! heightmap 0    0    (rand))
+    (heightmap-set! heightmap 0    last (rand))
+    (heightmap-set! heightmap last 0    (rand))
+    (heightmap-set! heightmap last last (rand))))
+
+(defn mpd-displace [heightmap spread spread-reduction]
+  (let [last (heightmap-last-index heightmap)
+        c (midpoint 0 last)
+
+        bottom-left  (heightmap-get heightmap 0    0)
+        bottom-right (heightmap-get heightmap last 0)
+        top-left     (heightmap-get heightmap 0    last)
+        top-right    (heightmap-get heightmap last last)
+
+        top    (average2 top-left top-right)
+        left   (average2 bottom-left top-left)
+        bottom (average2 bottom-left bottom-right)
+        right  (average2 bottom-right top-right)
+        center (average4 top left bottom right)
+
+        next-spread (* spread spread-reduction)]
+    (heightmap-set-if-unset! heightmap c    0    (jitter bottom spread))
+    (heightmap-set-if-unset! heightmap c    last (jitter top spread))
+    (heightmap-set-if-unset! heightmap 0    c    (jitter left spread))
+    (heightmap-set-if-unset! heightmap last c    (jitter right spread))
+    (heightmap-set-if-unset! heightmap c    c    (jitter center spread))
+    (when-not (== 3 (heightmap-resolution heightmap))
+      (mpd-displace (top-left-corner heightmap) next-spread spread-reduction)
+      (mpd-displace (top-right-corner heightmap) next-spread spread-reduction)
+      (mpd-displace (bottom-left-corner heightmap) next-spread spread-reduction)
+      (mpd-displace (bottom-right-corner heightmap) next-spread spread-reduction))))
+
+(defn midpoint-displacement [heightmap]
+  (let [initial-spread 0.3 
+        spread-reduction 0.55]
+    (mpd-init-corners heightmap)
+    (mpd-displace heightmap initial-spread spread-reduction)
+    (normalize heightmap)))
+
+
+; Three.js Helpers ------------------------------------------------------------
+(defn make-directional-light []
+  (let [light (new THREE.DirectionalLight 0xffffff 1)]
+    (light.position.set 100 0 150)
+    light))
+
+(defn make-camera []
+  (let [camera (new THREE.PerspectiveCamera
+                    55,
+                    (/ width height)
+                    0.1,
+                    1000)]
+    (camera.position.set 0 -100 150)
+    camera))
+
+(defn make-renderer []
+  (let [renderer (new THREE.WebGLRenderer {:antialias false})]
+    (renderer.setClearColor 0xffffff)
+    (renderer.setSize width height)
+    (renderer.setPixelRatio 2)
+    renderer))
+
+(defn make-geometry [heightmap]
+  (let [resolution (aget heightmap.shape 0)
+        geometry (new THREE.PlaneGeometry
+                      terrain-size
+                      terrain-size
+                      (- resolution 1)
+                      (- resolution 1))]
+    geometry))
+
+(defn make-controls [camera renderer]
+  (let [controls (new THREE.TrackballControls camera renderer.domElement)]
+    (set! controls.rotateSpeed 1.4)
+    (set! controls.zoomSpeed 0.5)
+    (set! controls.staticMoving true)
+    (set! controls.dynamicDampingFactor 0.3)
+    controls))
+
+(defn make-plane [geometry]
+  (let [material (new THREE.MeshLambertMaterial
+                      {:wireframe wireframe
+                       :wireframeLinewidth wireframe-width
+                       :color 0x00bb00})]
+    (new THREE.Mesh geometry material)))
+
+
+(defn attach-to-dom [renderer el-name refresh-fn]
+  (let [container (document.getElementById el-name)
+        settings (document.createElement "div")
+        refresh-button (document.createElement "button")
+        button-text (document.createTextNode "Refresh")
+        cancel-scroll (fn [e] (.preventDefault e))]
+    (set! refresh-button.onclick refresh-fn)
+    (set! renderer.domElement.onmousewheel cancel-scroll)
+    (renderer.domElement.addEventListener "MozMousePixelScroll" cancel-scroll false)
+    (.appendChild refresh-button button-text)
+    (.appendChild container renderer.domElement)
+    (.appendChild container settings)
+    (.appendChild settings refresh-button)))
+
+
+(defn update-geometry [geometry heightmap]
+  (loop [i 0]
+    (if (< i geometry.vertices.length)
+      (do (set! (.-z (aget geometry.vertices i))
+                (* terrain-height (aget (.-data heightmap) i)))
+        (recur (+ i 1)))))
+  (geometry.computeVertexNormals)
+  geometry)
+
+
+; Main ------------------------------------------------------------------------
+(defn make-final [element-id]
+  (def scene (new THREE.Scene))
+  (scene.add (new THREE.AxisHelper 100))
+
+  (def clock (new THREE.Clock))
+  (def camera (make-camera))
+  (def renderer (make-renderer))
+
+  (def geometry)
+  (def plane)
+
+  (scene.add (make-directional-light))
+  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
+
+  (defn refresh []
+    (let [heightmap (make-heightmap 6)]
+      (l "Generating terrain...")
+      (time (midpoint-displacement heightmap))
+
+      (l "Rebuilding geometry...")
+      (time
+        (set! geometry (make-geometry heightmap))
+        (update-geometry geometry heightmap))
+
+      (l "Rebuilding plane...")
+      (time
+        (scene.remove plane)
+        (set! plane (make-plane geometry))
+        (scene.add plane))))
+
+  (attach-to-dom renderer element-id refresh)
+  (def controls (make-controls camera renderer))
+
+  (defn render []
+    (let [delta (clock.getDelta)]
+      (requestAnimationFrame render)
+      (.update controls delta)
+      (renderer.render scene camera)))
+
+  (refresh)
+  (render)
+
+  nil)
+
+(defn run []
+  (make-final "demo-final"))
+
+($ run)
+
+
+; vim: lw+=do-times lw+=do-nested :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/wisp/terrain3.js	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,571 @@
+{
+    var _ns_ = {
+        id: 'demo',
+        doc: void 0
+    };
+    var ndarray = require('ndarray');
+}
+var width = exports.width = 610;
+var height = exports.height = 400;
+var wireframe = exports.wireframe = true;
+var wireframeWidth = exports.wireframeWidth = 1.2;
+var terrainHeight = exports.terrainHeight = 50;
+var terrainSize = exports.terrainSize = 100;
+void 0;
+void 0;
+void 0;
+var inc = exports.inc = function inc(x) {
+    return x + 1;
+};
+var dec = exports.dec = function dec(x) {
+    return x - 1;
+};
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+void 0;
+var midpoint = exports.midpoint = function midpoint(a, b) {
+    return (a + b) / 2;
+};
+var average2 = exports.average2 = function average2(a, b) {
+    return (a + b) / 2;
+};
+var average4 = exports.average4 = function average4(a, b, c, d) {
+    return (a + b + c + d) / 4;
+};
+var safeAverage = exports.safeAverage = function safeAverage(a, b, c, d) {
+    return function () {
+        var totalø1 = 0;
+        var countø1 = 0;
+        a ? (function () {
+            totalø1 = totalø1 + a;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        b ? (function () {
+            totalø1 = totalø1 + b;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        c ? (function () {
+            totalø1 = totalø1 + c;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        d ? (function () {
+            totalø1 = totalø1 + d;
+            return countø1 = inc(countø1);
+        })() : void 0;
+        return totalø1 / countø1;
+    }.call(this);
+};
+var isEven = exports.isEven = function isEven(n) {
+    return 0 == n % 2;
+};
+var isOdd = exports.isOdd = function isOdd(n) {
+    return 1 == n % 2;
+};
+var rand = exports.rand = function rand() {
+    return Math.random();
+};
+var randAroundZero = exports.randAroundZero = function randAroundZero(spread) {
+    return spread * rand() * 2 - spread;
+};
+var jitter = exports.jitter = function jitter(value, spread) {
+    return value + randAroundZero(spread);
+};
+var heightmapResolution = exports.heightmapResolution = function heightmapResolution(heightmap) {
+    return heightmap.shape[0];
+};
+var heightmapLastIndex = exports.heightmapLastIndex = function heightmapLastIndex(heightmap) {
+    return dec(heightmapResolution(heightmap));
+};
+var heightmapCenterIndex = exports.heightmapCenterIndex = function heightmapCenterIndex(heightmap) {
+    return midpoint(0, heightmapLastIndex(heightmap));
+};
+var heightmapGet = exports.heightmapGet = function heightmapGet(heightmap, x, y) {
+    return heightmap.get(x, y);
+};
+var heightmapGetSafe = exports.heightmapGetSafe = function heightmapGetSafe(heightmap, x, y) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        return 0 <= x && x <= lastø1 && (0 <= y && y <= lastø1) ? (function () {
+            return heightmapGet(heightmap, x, y);
+        })() : void 0;
+    }.call(this);
+};
+var heightmapSet = exports.heightmapSet = function heightmapSet(heightmap, x, y, val) {
+    return heightmap.set(x, y, val);
+};
+var heightmapSetIfUnset = exports.heightmapSetIfUnset = function heightmapSetIfUnset(heightmap, x, y, val) {
+    return 0 == heightmapGet(heightmap, x, y) ? (function () {
+        return heightmapSet(heightmap, x, y, val);
+    })() : void 0;
+};
+var normalize = exports.normalize = function normalize(heightmap) {
+    return function () {
+        var maxø1 = 0 - Infinity;
+        var minø1 = Infinity;
+        (function () {
+            var array2ø1 = heightmap;
+            return function () {
+                var G__3ø1 = array2ø1.data.length;
+                return function loop() {
+                    var recur = loop;
+                    var index1ø1 = 0;
+                    do {
+                        recur = index1ø1 < G__3ø1 ? (function () {
+                            (function () {
+                                var elø1 = array2ø1.data[index1ø1];
+                                maxø1 < elø1 ? (function () {
+                                    return maxø1 = elø1;
+                                })() : void 0;
+                                return minø1 > elø1 ? (function () {
+                                    return minø1 = elø1;
+                                })() : void 0;
+                            }.call(this));
+                            return loop[0] = inc(index1ø1), loop;
+                        })() : void 0;
+                    } while (index1ø1 = loop[0], recur === loop);
+                    return recur;
+                }.call(this);
+            }.call(this);
+        }.call(this));
+        return function () {
+            var spanø1 = maxø1 - minø1;
+            return function () {
+                var array4ø1 = heightmap;
+                return function () {
+                    var G__5ø1 = array4ø1.shape[0];
+                    return function loop() {
+                        var recur = loop;
+                        var xø1 = 0;
+                        do {
+                            recur = xø1 < G__5ø1 ? (function () {
+                                (function () {
+                                    var G__6ø1 = array4ø1.shape[1];
+                                    return function loop() {
+                                        var recur = loop;
+                                        var yø1 = 0;
+                                        do {
+                                            recur = yø1 < G__6ø1 ? (function () {
+                                                (function () {
+                                                    return heightmapSet(heightmap, xø1, yø1, (heightmapGet(heightmap, xø1, yø1) - minø1) / spanø1);
+                                                })();
+                                                return loop[0] = inc(yø1), loop;
+                                            })() : void 0;
+                                        } while (yø1 = loop[0], recur === loop);
+                                        return recur;
+                                    }.call(this);
+                                }.call(this));
+                                return loop[0] = inc(xø1), loop;
+                            })() : void 0;
+                        } while (xø1 = loop[0], recur === loop);
+                        return recur;
+                    }.call(this);
+                }.call(this);
+            }.call(this);
+        }.call(this);
+    }.call(this);
+};
+var makeHeightmap = exports.makeHeightmap = function makeHeightmap(exponent) {
+    return function () {
+        var resolutionø1 = Math.pow(2, exponent) + 1;
+        return function () {
+            var heightmapø1 = ndarray(new Float64Array(resolutionø1 * resolutionø1), [
+                resolutionø1,
+                resolutionø1
+            ]);
+            heightmapø1.exponent = exponent;
+            heightmapø1.resolution = resolutionø1;
+            heightmapø1.last = dec(resolutionø1);
+            return heightmapø1;
+        }.call(this);
+    }.call(this);
+};
+var topLeftCorner = exports.topLeftCorner = function topLeftCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(0, 0).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var topRightCorner = exports.topRightCorner = function topRightCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(centerø1, 0).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var bottomLeftCorner = exports.bottomLeftCorner = function bottomLeftCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(0, centerø1).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var bottomRightCorner = exports.bottomRightCorner = function bottomRightCorner(heightmap) {
+    return function () {
+        var centerø1 = heightmapCenterIndex(heightmap);
+        return heightmap.lo(centerø1, centerø1).hi(inc(centerø1), inc(centerø1));
+    }.call(this);
+};
+var dsInitCorners = exports.dsInitCorners = function dsInitCorners(heightmap) {
+    return function () {
+        var lastø1 = heightmapLastIndex(heightmap);
+        heightmapSet(heightmap, 0, 0, rand());
+        heightmapSet(heightmap, 0, lastø1, rand());
+        heightmapSet(heightmap, lastø1, 0, rand());
+        return heightmapSet(heightmap, lastø1, lastø1, rand());
+    }.call(this);
+};
+var dsSquare = exports.dsSquare = function dsSquare(heightmap, x, y, radius, spread) {
+    return function () {
+        var newHeightø1 = jitter(average4(heightmapGet(heightmap, x - radius, y - radius), heightmapGet(heightmap, x - radius, y + radius), heightmapGet(heightmap, x + radius, y - radius), heightmapGet(heightmap, x + radius, y + radius)), spread);
+        return heightmapSet(heightmap, x, y, newHeightø1);
+    }.call(this);
+};
+var dsDiamond = exports.dsDiamond = function dsDiamond(heightmap, x, y, radius, spread) {
+    return function () {
+        var newHeightø1 = jitter(safeAverage(heightmapGetSafe(heightmap, x - radius, y), heightmapGetSafe(heightmap, x + radius, y), heightmapGetSafe(heightmap, x, y - radius), heightmapGetSafe(heightmap, x, y + radius)), spread);
+        return heightmapSet(heightmap, x, y, newHeightø1);
+    }.call(this);
+};
+var dsSquares = exports.dsSquares = function dsSquares(heightmap, radius, spread) {
+    return function () {
+        var start8ø1 = radius;
+        var end9ø1 = heightmapResolution(heightmap);
+        var stride7ø1 = 2 * radius;
+        return function loop() {
+            var recur = loop;
+            var xø1 = start8ø1;
+            do {
+                recur = xø1 < end9ø1 ? (function () {
+                    (function loop() {
+                        var recur = loop;
+                        var yø1 = start8ø1;
+                        do {
+                            recur = yø1 < end9ø1 ? (function () {
+                                (function () {
+                                    return dsSquare(heightmap, xø1, yø1, radius, spread);
+                                })();
+                                return loop[0] = yø1 + stride7ø1, loop;
+                            })() : void 0;
+                        } while (yø1 = loop[0], recur === loop);
+                        return recur;
+                    }.call(this));
+                    return loop[0] = xø1 + stride7ø1, loop;
+                })() : void 0;
+            } while (xø1 = loop[0], recur === loop);
+            return recur;
+        }.call(this);
+    }.call(this);
+};
+var dsDiamonds = exports.dsDiamonds = function dsDiamonds(heightmap, radius, spread) {
+    return function () {
+        var sizeø1 = heightmapResolution(heightmap);
+        return function () {
+            var start11ø1 = 0;
+            var end12ø1 = sizeø1;
+            var stride10ø1 = radius;
+            return function loop() {
+                var recur = loop;
+                var yø1 = start11ø1;
+                do {
+                    recur = yø1 < end12ø1 ? (function () {
+                        (function () {
+                            return function () {
+                                var shiftø1 = isEven(yø1 / radius) ? radius : 0;
+                                return function () {
+                                    var start14ø1 = shiftø1;
+                                    var end15ø1 = sizeø1;
+                                    var stride13ø1 = 2 * radius;
+                                    return function loop() {
+                                        var recur = loop;
+                                        var xø1 = start14ø1;
+                                        do {
+                                            recur = xø1 < end15ø1 ? (function () {
+                                                (function () {
+                                                    return dsDiamond(heightmap, xø1, yø1, radius, spread);
+                                                })();
+                                                return loop[0] = xø1 + stride13ø1, loop;
+                                            })() : void 0;
+                                        } while (xø1 = loop[0], recur === loop);
+                                        return recur;
+                                    }.call(this);
+                                }.call(this);
+                            }.call(this);
+                        })();
+                        return loop[0] = yø1 + stride10ø1, loop;
+                    })() : void 0;
+                } while (yø1 = loop[0], recur === loop);
+                return recur;
+            }.call(this);
+        }.call(this);
+    }.call(this);
+};
+var diamondSquare = exports.diamondSquare = function diamondSquare(heightmap) {
+    return function () {
+        var initialSpreadø1 = 0.3;
+        var spreadReductionø1 = 0.5;
+        var centerø1 = heightmapCenterIndex(heightmap);
+        var sizeø1 = heightmap.shape[0];
+        dsInitCorners(heightmap);
+        (function loop() {
+            var recur = loop;
+            var radiusø1 = centerø1;
+            var spreadø1 = initialSpreadø1;
+            do {
+                recur = radiusø1 >= 1 ? (function () {
+                    dsSquares(heightmap, radiusø1, spreadø1);
+                    dsDiamonds(heightmap, radiusø1, spreadø1);
+                    return loop[0] = radiusø1 / 2, loop[1] = spreadø1 * spreadReductionø1, loop;
+                })() : void 0;
+            } while (radiusø1 = loop[0], spreadø1 = loop[1], recur === loop);
+            return recur;
+        }.call(this));
+        return normalize(heightmap);
+    }.call(this);
+};
+var diamondSquare1 = exports.diamondSquare1 = function diamondSquare1(heightmap) {
+    dsInitCorners(heightmap);
+    return normalize(heightmap);
+};
+var diamondSquare2 = exports.diamondSquare2 = function diamondSquare2(heightmap) {
+    return function () {
+        var initialSpreadø1 = 0.3;
+        var spreadReductionø1 = 0.5;
+        var centerø1 = heightmapCenterIndex(heightmap);
+        var sizeø1 = heightmap.shape[0];
+        dsInitCorners(heightmap);
+        dsSquares(heightmap, centerø1, initialSpreadø1);
+        return normalize(heightmap);
+    }.call(this);
+};
+var diamondSquare3 = exports.diamondSquare3 = function diamondSquare3(heightmap) {
+    return function () {
+        var initialSpreadø1 = 0.3;
+        var spreadReductionø1 = 0.5;
+        var centerø1 = heightmapCenterIndex(heightmap);
+        var sizeø1 = heightmap.shape[0];
+        dsInitCorners(heightmap);
+        dsSquares(heightmap, centerø1, initialSpreadø1);
+        dsDiamonds(heightmap, centerø1, initialSpreadø1);
+        dsSquares(heightmap, centerø1 / 2, spreadReductionø1 * initialSpreadø1);
+        dsDiamonds(heightmap, centerø1 / 2, spreadReductionø1 * initialSpreadø1);
+        return normalize(heightmap);
+    }.call(this);
+};
+var makeDirectionalLight = exports.makeDirectionalLight = function makeDirectionalLight() {
+    return function () {
+        var lightø1 = new THREE.DirectionalLight(16777215, 1);
+        lightø1.position.set(100, 0, 150);
+        return lightø1;
+    }.call(this);
+};
+var makeCamera = exports.makeCamera = function makeCamera() {
+    return function () {
+        var cameraø1 = new THREE.PerspectiveCamera(55, width / height, 0.1, 1000);
+        cameraø1.position.set(0, -100, 150);
+        return cameraø1;
+    }.call(this);
+};
+var makeRenderer = exports.makeRenderer = function makeRenderer() {
+    return function () {
+        var rendererø1 = new THREE.WebGLRenderer({ 'antialias': false });
+        rendererø1.setClearColor(16777215);
+        rendererø1.setSize(width, height);
+        rendererø1.setPixelRatio(2);
+        return rendererø1;
+    }.call(this);
+};
+var makeGeometry = exports.makeGeometry = function makeGeometry(heightmap) {
+    return function () {
+        var resolutionø1 = heightmap.shape[0];
+        var geometryø1 = new THREE.PlaneGeometry(terrainSize, terrainSize, resolutionø1 - 1, resolutionø1 - 1);
+        return geometryø1;
+    }.call(this);
+};
+var makeControls = exports.makeControls = function makeControls(camera, renderer) {
+    return function () {
+        var controlsø1 = new THREE.TrackballControls(camera, renderer.domElement);
+        controlsø1.rotateSpeed = 1.4;
+        controlsø1.zoomSpeed = 0.5;
+        controlsø1.staticMoving = true;
+        controlsø1.dynamicDampingFactor = 0.3;
+        return controlsø1;
+    }.call(this);
+};
+var makePlane = exports.makePlane = function makePlane(geometry) {
+    return function () {
+        var materialø1 = new THREE.MeshLambertMaterial({
+            'wireframe': wireframe,
+            'wireframeLinewidth': wireframeWidth,
+            'color': 47872
+        });
+        return new THREE.Mesh(geometry, materialø1);
+    }.call(this);
+};
+var attachToDom = exports.attachToDom = function attachToDom(renderer, elName, refreshFn) {
+    return function () {
+        var containerø1 = document.getElementById(elName);
+        var settingsø1 = document.createElement('div');
+        var refreshButtonø1 = document.createElement('button');
+        var buttonTextø1 = document.createTextNode('Refresh');
+        var cancelScrollø1 = function (e) {
+            return e.preventDefault();
+        };
+        refreshButtonø1.onclick = refreshFn;
+        renderer.domElement.onmousewheel = cancelScrollø1;
+        renderer.domElement.addEventListener('MozMousePixelScroll', cancelScrollø1, false);
+        refreshButtonø1.appendChild(buttonTextø1);
+        containerø1.appendChild(renderer.domElement);
+        containerø1.appendChild(settingsø1);
+        return settingsø1.appendChild(refreshButtonø1);
+    }.call(this);
+};
+var updateGeometry = exports.updateGeometry = function updateGeometry(geometry, heightmap) {
+    (function loop() {
+        var recur = loop;
+        var iø1 = 0;
+        do {
+            recur = iø1 < geometry.vertices.length ? (function () {
+                geometry.vertices[iø1].z = terrainHeight * heightmap.data[iø1];
+                return loop[0] = iø1 + 1, loop;
+            })() : void 0;
+        } while (iø1 = loop[0], recur === loop);
+        return recur;
+    }.call(this));
+    geometry.computeVertexNormals();
+    return geometry;
+};
+var makeDemo = exports.makeDemo = function makeDemo(elementId, algorithm, size) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var geometry = void 0;
+    var plane = void 0;
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    var refresh = function refresh() {
+        return function () {
+            var heightmapø1 = makeHeightmap(size);
+            console.log('Generating terrain...');
+            (function () {
+                var G__16ø1 = new Date().getTime();
+                var G__18ø1 = (function () {
+                    return algorithm(heightmapø1);
+                })();
+                var G__17ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__17ø1 - G__16ø1) + 'ms.');
+                return G__18ø1;
+            }.call(this));
+            console.log('Rebuilding geometry...');
+            (function () {
+                var G__19ø1 = new Date().getTime();
+                var G__21ø1 = (function () {
+                    geometry = makeGeometry(heightmapø1);
+                    return updateGeometry(geometry, heightmapø1);
+                })();
+                var G__20ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__20ø1 - G__19ø1) + 'ms.');
+                return G__21ø1;
+            }.call(this));
+            console.log('Rebuilding plane...');
+            return function () {
+                var G__22ø1 = new Date().getTime();
+                var G__24ø1 = (function () {
+                    scene.remove(plane);
+                    plane = makePlane(geometry);
+                    return scene.add(plane);
+                })();
+                var G__23ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__23ø1 - G__22ø1) + 'ms.');
+                return G__24ø1;
+            }.call(this);
+        }.call(this);
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    refresh();
+    render();
+    return void 0;
+};
+var makeFinal = exports.makeFinal = function makeFinal(elementId) {
+    var scene = new THREE.Scene();
+    scene.add(new THREE.AxisHelper(100));
+    var clock = new THREE.Clock();
+    var camera = makeCamera();
+    var renderer = makeRenderer();
+    var geometry = void 0;
+    var plane = void 0;
+    scene.add(makeDirectionalLight());
+    scene.add(new THREE.AmbientLight(16777215, 0.05));
+    var refresh = function refresh() {
+        return function () {
+            var heightmapø1 = makeHeightmap(6);
+            console.log('Generating terrain...');
+            (function () {
+                var G__25ø1 = new Date().getTime();
+                var G__27ø1 = (function () {
+                    return diamondSquare(heightmapø1);
+                })();
+                var G__26ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__26ø1 - G__25ø1) + 'ms.');
+                return G__27ø1;
+            }.call(this));
+            console.log('Rebuilding geometry...');
+            (function () {
+                var G__28ø1 = new Date().getTime();
+                var G__30ø1 = (function () {
+                    geometry = makeGeometry(heightmapø1);
+                    return updateGeometry(geometry, heightmapø1);
+                })();
+                var G__29ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__29ø1 - G__28ø1) + 'ms.');
+                return G__30ø1;
+            }.call(this));
+            console.log('Rebuilding plane...');
+            return function () {
+                var G__31ø1 = new Date().getTime();
+                var G__33ø1 = (function () {
+                    scene.remove(plane);
+                    plane = makePlane(geometry);
+                    return scene.add(plane);
+                })();
+                var G__32ø1 = new Date().getTime();
+                console.log('Elapsed time: ' + (G__32ø1 - G__31ø1) + 'ms.');
+                return G__33ø1;
+            }.call(this);
+        }.call(this);
+    };
+    attachToDom(renderer, elementId, refresh);
+    var controls = makeControls(camera, renderer);
+    var render = function render() {
+        return function () {
+            var deltaø1 = clock.getDelta();
+            requestAnimationFrame(render);
+            controls.update(deltaø1);
+            return renderer.render(scene, camera);
+        }.call(this);
+    };
+    refresh();
+    render();
+    return void 0;
+};
+var run = exports.run = function run() {
+    makeDemo('demo-1', diamondSquare1, 2);
+    makeDemo('demo-2', diamondSquare2, 4);
+    makeDemo('demo-3', diamondSquare3, 4);
+    return makeFinal('demo-final');
+};
+$(run);
+//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImFub255bW91cy53aXNwIl0sIm5hbWVzIjpbIl9uc18iLCJpZCIsImRvYyIsIndpZHRoIiwiZXhwb3J0cyIsImhlaWdodCIsIndpcmVmcmFtZSIsIndpcmVmcmFtZVdpZHRoIiwidGVycmFpbkhlaWdodCIsInRlcnJhaW5TaXplIiwiaW5jIiwieCIsImRlYyIsIm1pZHBvaW50IiwiYSIsImIiLCJhdmVyYWdlMiIsImF2ZXJhZ2U0IiwiYyIsImQiLCJzYWZlQXZlcm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KCQgcnVuKVxuXG5cbjsgdmltOiBsdys9ZG8tdGltZXMgbHcrPWRvLW5lc3RlZCA6XG4iXX0=
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/static/media/js/wisp/terrain3.wisp	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,470 @@
+(ns demo
+  (:require [ndarray]))
+
+
+; Constants -------------------------------------------------------------------
+(def width 610)
+(def height 400)
+(def wireframe true)
+(def wireframe-width 1.2)
+(def terrain-height 50)
+(def terrain-size 100)
+
+; General Utilities -----------------------------------------------------------
+(defmacro when [condition & body]
+  `(if ~condition
+     (do ~@body)))
+
+(defmacro when-not [condition & body]
+  `(when (not ~condition)
+     ~@body))
+
+(defmacro -> [& operations]
+  (reduce
+    (fn [form operation]
+      (cons (first operation)
+            (cons form (rest operation))))
+    (first operations)
+    (rest operations)))
+
+
+(defn inc [x]
+  (+ x 1))
+
+(defn dec [x]
+  (- x 1))
+
+
+(defmacro do-times [varname limit & body]
+  (let [end (gensym)]
+    `(let [~end ~limit]
+       (loop [~varname 0]
+         (when (< ~varname ~end)
+           ~@body
+           (recur (inc ~varname)))))))
+
+(defmacro do-stride [varnames start-form end-form stride-form & body]
+  (let [stride (gensym "stride")
+        start (gensym "start")
+        end (gensym "end")
+        build (fn build [vars]
+                (if (empty? vars)
+                  `(do ~@body)
+                  (let [varname (first vars)]
+                    `(loop [~varname ~start]
+                       (when (< ~varname ~end)
+                         ~(build (rest vars))
+                         (recur (+ ~varname ~stride)))))))]
+    ; Fix the numbers once outside the nested loops,
+    ; and then build the guts.
+    `(let [~start ~start-form
+           ~end ~end-form
+           ~stride ~stride-form]
+       ~(build varnames))))
+
+
+(defmacro do-ndarray [vars array-form & body]
+  (let [array-var (gensym "array")
+        build (fn build [vars n]
+                (if (empty? vars)
+                  `(do ~@body)
+                  `(do-times ~(first vars) (aget (.-shape ~array-var) ~n)
+                     ~(build (rest vars) (inc n)))))]
+    `(let [~array-var ~array-form]
+       ~(build vars 0))))
+
+(defmacro do-ndarray-el [element array-form & body]
+  (let [index (gensym "index")
+        array (gensym "array")]
+    `(let [~array ~array-form]
+       (do-times ~index (.-length (.-data ~array))
+         (let [~element (aget (.-data ~array) ~index)]
+           ~@body)))))
+
+
+(defmacro inc! [place]
+  `(set! ~place (inc ~place)))
+
+(defmacro add! [place amount]
+  `(set! ~place (+ ~place ~amount)))
+
+
+(defmacro l [& forms]
+  `(console.log ~@forms))
+
+(defmacro time [& body]
+  (let [start (gensym)
+        end (gensym)
+        result (gensym)]
+    `(let [~start (.getTime (new Date))
+           ~result (do ~@body)
+           ~end (.getTime (new Date))]
+       (l (+ "Elapsed time: " (- ~end ~start) "ms."))
+       ~result)))
+
+
+(defn midpoint [a b]
+  (/ (+ a b) 2))
+
+(defn average2 [a b]
+  (/ (+ a b) 2))
+
+(defn average4 [a b c d]
+  (/ (+ a b c d) 4))
+
+(defn safe-average [a b c d]
+  (let [total 0 count 0]
+    (when a (add! total a) (inc! count))
+    (when b (add! total b) (inc! count))
+    (when c (add! total c) (inc! count))
+    (when d (add! total d) (inc! count))
+    (/ total count)))
+
+
+(defn even? [n]
+  (== 0 (mod n 2)))
+
+(defn odd? [n]
+  (== 1 (mod n 2)))
+
+
+; Randomness ------------------------------------------------------------------
+(defn rand []
+  (Math.random))
+
+(defn rand-around-zero [spread]
+  (- (* spread (rand) 2) spread))
+
+(defn jitter [value spread]
+  (+ value (rand-around-zero spread)))
+
+
+; Heightmap Helpers -----------------------------------------------------------
+(defn heightmap-resolution [heightmap]
+  (aget heightmap.shape 0))
+
+(defn heightmap-last-index [heightmap]
+  (dec (heightmap-resolution heightmap)))
+
+(defn heightmap-center-index [heightmap]
+  (midpoint 0 (heightmap-last-index heightmap)))
+
+
+(defn heightmap-get [heightmap x y]
+  (.get heightmap x y))
+
+(defn heightmap-get-safe [heightmap x y]
+  (let [last (heightmap-last-index heightmap)]
+    (when (and (<= 0 x last)
+               (<= 0 y last))
+      (heightmap-get heightmap x y))))
+
+(defn heightmap-set! [heightmap x y val]
+  (.set heightmap x y val))
+
+(defn heightmap-set-if-unset! [heightmap x y val]
+  (when (== 0 (heightmap-get heightmap x y))
+    (heightmap-set! heightmap x y val)))
+
+
+(defn normalize [heightmap]
+  (let [max (- Infinity)
+        min Infinity]
+    (do-ndarray-el el heightmap
+      (when (< max el) (set! max el))
+      (when (> min el) (set! min el)))
+    (let [span (- max min)]
+      (do-ndarray [x y] heightmap
+        (heightmap-set! heightmap x y
+                        (/ (- (heightmap-get heightmap x y) min)
+                           span))))))
+
+
+(defn make-heightmap [exponent]
+  (let [resolution (+ (Math.pow 2 exponent) 1)]
+    (let [heightmap (ndarray (new Float64Array (* resolution resolution))
+                             [resolution resolution])]
+      (set! heightmap.exponent exponent)
+      (set! heightmap.resolution resolution)
+      (set! heightmap.last (dec resolution))
+      heightmap)))
+
+
+(defn top-left-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo 0 0)
+      (.hi (inc center) (inc center)))))
+
+(defn top-right-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo center 0)
+      (.hi (inc center) (inc center)))))
+
+(defn bottom-left-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo 0 center)
+      (.hi (inc center) (inc center)))))
+
+(defn bottom-right-corner [heightmap]
+  (let [center (heightmap-center-index heightmap)]
+    (-> heightmap
+      (.lo center center)
+      (.hi (inc center) (inc center)))))
+
+
+; Diamond-Square --------------------------------------------------------------
+(defn ds-init-corners [heightmap]
+  (let [last (heightmap-last-index heightmap)]
+    (heightmap-set! heightmap 0    0    (rand))
+    (heightmap-set! heightmap 0    last (rand))
+    (heightmap-set! heightmap last 0    (rand))
+    (heightmap-set! heightmap last last (rand))))
+
+(defn ds-square [heightmap x y radius spread]
+  (let [new-height (jitter
+                     (average4
+                       (heightmap-get heightmap (- x radius) (- y radius))
+                       (heightmap-get heightmap (- x radius) (+ y radius))
+                       (heightmap-get heightmap (+ x radius) (- y radius))
+                       (heightmap-get heightmap (+ x radius) (+ y radius)))
+                     spread)]
+    (heightmap-set! heightmap x y new-height)))
+
+(defn ds-diamond [heightmap x y radius spread]
+  (let [new-height (jitter
+                     (safe-average
+                       (heightmap-get-safe heightmap (- x radius) y)
+                       (heightmap-get-safe heightmap (+ x radius) y)
+                       (heightmap-get-safe heightmap x (- y radius))
+                       (heightmap-get-safe heightmap x (+ y radius)))
+                     spread)]
+    (heightmap-set! heightmap x y new-height)))
+
+
+(defn ds-squares [heightmap radius spread]
+  (do-stride [x y] radius (heightmap-resolution heightmap) (* 2 radius)
+    (ds-square heightmap x y radius spread)))
+
+(defn ds-diamonds [heightmap radius spread]
+  (let [size (heightmap-resolution heightmap)]
+    (do-stride [y] 0 size radius
+      (let [shift (if (even? (/ y radius)) radius 0)]
+        (do-stride [x] shift size (* 2 radius)
+          (ds-diamond heightmap x y radius spread))))))
+
+(defn diamond-square [heightmap]
+  (let [initial-spread 0.3
+        spread-reduction 0.5
+        center (heightmap-center-index heightmap)
+        size (aget heightmap.shape 0)]
+    (ds-init-corners heightmap)
+    (loop [radius center
+           spread initial-spread]
+      (when (>= radius 1)
+        (ds-squares heightmap radius spread)
+        (ds-diamonds heightmap radius spread)
+        (recur (/ radius 2)
+               (* spread spread-reduction))))
+    (normalize heightmap)))
+
+
+(defn diamond-square-1 [heightmap]
+  (ds-init-corners heightmap)
+  (normalize heightmap))
+
+(defn diamond-square-2 [heightmap]
+  (let [initial-spread 0.3
+        spread-reduction 0.5
+        center (heightmap-center-index heightmap)
+        size (aget heightmap.shape 0)]
+    (ds-init-corners heightmap)
+    (ds-squares heightmap center initial-spread)
+    (normalize heightmap)))
+
+(defn diamond-square-3 [heightmap]
+  (let [initial-spread 0.3
+        spread-reduction 0.5
+        center (heightmap-center-index heightmap)
+        size (aget heightmap.shape 0)]
+    (ds-init-corners heightmap)
+    (ds-squares heightmap center initial-spread)
+    (ds-diamonds heightmap center initial-spread)
+    (ds-squares heightmap (/ center 2) (* spread-reduction initial-spread))
+    (ds-diamonds heightmap (/ center 2) (* spread-reduction initial-spread))
+    (normalize heightmap)))
+
+
+; Three.js Helpers ------------------------------------------------------------
+(defn make-directional-light []
+  (let [light (new THREE.DirectionalLight 0xffffff 1)]
+    (light.position.set 100 0 150)
+    light))
+
+(defn make-camera []
+  (let [camera (new THREE.PerspectiveCamera
+                    55,
+                    (/ width height)
+                    0.1,
+                    1000)]
+    (camera.position.set 0 -100 150)
+    camera))
+
+(defn make-renderer []
+  (let [renderer (new THREE.WebGLRenderer {:antialias false})]
+    (renderer.setClearColor 0xffffff)
+    (renderer.setSize width height)
+    (renderer.setPixelRatio 2)
+    renderer))
+
+(defn make-geometry [heightmap]
+  (let [resolution (aget heightmap.shape 0)
+        geometry (new THREE.PlaneGeometry
+                      terrain-size
+                      terrain-size
+                      (- resolution 1)
+                      (- resolution 1))]
+    geometry))
+
+(defn make-controls [camera renderer]
+  (let [controls (new THREE.TrackballControls camera renderer.domElement)]
+    (set! controls.rotateSpeed 1.4)
+    (set! controls.zoomSpeed 0.5)
+    (set! controls.staticMoving true)
+    (set! controls.dynamicDampingFactor 0.3)
+    controls))
+
+(defn make-plane [geometry]
+  (let [material (new THREE.MeshLambertMaterial
+                      {:wireframe wireframe
+                       :wireframeLinewidth wireframe-width
+                       :color 0x00bb00})]
+    (new THREE.Mesh geometry material)))
+
+
+(defn attach-to-dom [renderer el-name refresh-fn]
+  (let [container (document.getElementById el-name)
+        settings (document.createElement "div")
+        refresh-button (document.createElement "button")
+        button-text (document.createTextNode "Refresh")
+        cancel-scroll (fn [e] (.preventDefault e))]
+    (set! refresh-button.onclick refresh-fn)
+    (set! renderer.domElement.onmousewheel cancel-scroll)
+    (renderer.domElement.addEventListener "MozMousePixelScroll" cancel-scroll false)
+    (.appendChild refresh-button button-text)
+    (.appendChild container renderer.domElement)
+    (.appendChild container settings)
+    (.appendChild settings refresh-button)))
+
+
+(defn update-geometry [geometry heightmap]
+  (loop [i 0]
+    (if (< i geometry.vertices.length)
+      (do (set! (.-z (aget geometry.vertices i))
+                (* terrain-height (aget (.-data heightmap) i)))
+        (recur (+ i 1)))))
+  (geometry.computeVertexNormals)
+  geometry)
+
+
+; Main ------------------------------------------------------------------------
+(defn make-demo [element-id algorithm size]
+  (def scene (new THREE.Scene))
+  (scene.add (new THREE.AxisHelper 100))
+
+  (def clock (new THREE.Clock))
+  (def camera (make-camera))
+  (def renderer (make-renderer))
+
+  (def geometry)
+  (def plane)
+
+  (scene.add (make-directional-light))
+  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
+
+  (defn refresh []
+    (let [heightmap (make-heightmap size)]
+      (l "Generating terrain...")
+      (time (algorithm heightmap))
+
+      (l "Rebuilding geometry...")
+      (time
+        (set! geometry (make-geometry heightmap))
+        (update-geometry geometry heightmap))
+
+      (l "Rebuilding plane...")
+      (time
+        (scene.remove plane)
+        (set! plane (make-plane geometry))
+        (scene.add plane))))
+
+  (attach-to-dom renderer element-id refresh)
+  (def controls (make-controls camera renderer))
+
+  (defn render []
+    (let [delta (clock.getDelta)]
+      (requestAnimationFrame render)
+      (.update controls delta)
+      (renderer.render scene camera)))
+
+  (refresh)
+  (render)
+
+  nil)
+
+(defn make-final [element-id]
+  (def scene (new THREE.Scene))
+  (scene.add (new THREE.AxisHelper 100))
+
+  (def clock (new THREE.Clock))
+  (def camera (make-camera))
+  (def renderer (make-renderer))
+
+  (def geometry)
+  (def plane)
+
+  (scene.add (make-directional-light))
+  (scene.add (new THREE.AmbientLight 0xffffff 0.05))
+
+  (defn refresh []
+    (let [heightmap (make-heightmap 6)]
+      (l "Generating terrain...")
+      (time (diamond-square heightmap))
+
+      (l "Rebuilding geometry...")
+      (time
+        (set! geometry (make-geometry heightmap))
+        (update-geometry geometry heightmap))
+
+      (l "Rebuilding plane...")
+      (time
+        (scene.remove plane)
+        (set! plane (make-plane geometry))
+        (scene.add plane))))
+
+  (attach-to-dom renderer element-id refresh)
+  (def controls (make-controls camera renderer))
+
+  (defn render []
+    (let [delta (clock.getDelta)]
+      (requestAnimationFrame render)
+      (.update controls delta)
+      (renderer.render scene camera)))
+
+  (refresh)
+  (render)
+
+  nil)
+
+(defn run []
+  (make-demo "demo-1" diamond-square-1 2)
+  (make-demo "demo-2" diamond-square-2 4)
+  (make-demo "demo-3" diamond-square-3 4)
+  (make-final "demo-final"))
+
+($ run)
+
+
+; vim: lw+=do-times lw+=do-nested :
Binary file static/media/midpoint-displacement.monopic has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/LICENSE.md	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2016 Steve Losh
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/archetypes/blog.md	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,3 @@
++++
+snip = "snippet"
++++
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/archetypes/default.md	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,2 @@
++++
++++
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/layouts/404.html	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,7 @@
+{{ partial "header.html" . }}
+
+<h1>404</h1>
+
+<p>I don't know how you got here, but there's nothing to see.</p>
+
+{{ partial "footer.html" . }}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/layouts/_default/list.html	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,18 @@
+{{ partial "header.html" . }}
+
+<div class="section-listing">
+    <ol class="group">
+
+    {{ range .Data.Pages.ByDate.Reverse }}
+        <li>
+            <a href="{{ .Permalink }}">
+                {{ .Title }}
+            </a>
+            <span class="snip">{{ .Params.snip }}</span>
+        </li>
+    {{ end }}
+
+    </ol>
+</div>
+
+{{ partial "footer.html" . }}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/layouts/_default/single.html	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,11 @@
+{{ partial "header.html" . }}
+
+    <div id="leaf-title">
+        <h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
+    </div>
+
+    <div id="leaf-content" class="">
+        {{ .Content }}
+    </div>
+
+{{ partial "footer.html" . }}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/layouts/blog/single.html	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,22 @@
+{{ partial "header.html" . }}
+
+    <div id="leaf-title">
+        <h1><a href="{{ .Permalink }}">{{ .Title }}</a></h1>
+    </div>
+
+
+    <div id="leaf-stats" class="group">
+        <p>
+            Posted
+            <span class="timeago"
+                  title="{{ .Date.Format .Site.Params.DateFormFull }}">
+            </span>
+            on {{ .Date.Format .Site.Params.DateForm }}.
+        </p>
+    </div>
+
+    <div id="leaf-content" class="">
+        {{ .Content }}
+    </div>
+
+{{ partial "footer.html" . }}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/layouts/index.html	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,24 @@
+{{ partial "header.html" . }}
+
+<div class="splash vcard">
+    <p>
+        Hello,
+        I'm
+        <a href="http://stevelosh.com/" class="fn url">Steve<span class="last-name"> Losh</span></a>.
+    </p>
+
+    <p>
+        I'm a
+        <span class="role">programmer, photographer, dancer &amp; bassist</span>
+        currently living in
+        <span class="adr"><span class="locality">Reykjavík</span>, <span class="region">Iceland</span></span>.
+    </p>
+
+    <p>
+        If you want to get in touch with me,
+        <a class="email" href="mailto:steve@stevelosh.com">email</a>
+        is best.
+    </p>
+</div>
+
+{{ partial "footer.html" . }}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/layouts/partials/footer.html	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,19 @@
+            </div>
+
+            <div class="hrb">&nbsp;</div>
+
+            <footer>
+                <p>
+                    <a href="https://bitbucket.org/sjl/">Bitbucket</a> ・ 
+                    <a href="https://github.com/sjl/">GitHub</a> ・ 
+                    <a href="https://twitter.com/stevelosh/">Twitter</a> ・ 
+                    <a href="https://instagram.com/thirtytwobirds/">Instagram</a> ・ 
+                    <a href="https://bitbucket.org/sjl/.plan/#readme">.plan</a>
+                </p>
+
+                <a class="rochester-made" href="http://rochestermade.com" title="Rochester Made"><img src="http://rochestermade.com/media/images/rochester-made-dark-on-light.png" alt="Rochester Made" title="Rochester Made" /></a>
+            </footer>
+        </div>
+
+    </body>
+</html>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/layouts/partials/header.html	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,74 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <link href='http://fonts.googleapis.com/css?family=OFL+Sorts+Mill+Goudy+TT:regular,italic' rel='stylesheet' type='text/css' />
+        <link rel="profile" href="http://microformats.org/profile/hcard" />
+        <meta charset="utf-8">
+
+        <title>
+{{ $url := replace .Permalink ( printf "%s" .Site.BaseURL) "" }}
+{{ if not (or (eq $url "/") (eq $url "")) }}
+    {{ if .Params.heading }}
+        {{ .Params.heading }}
+    {{ else }}
+        {{ .Title }}
+    {{ end }}
+    /
+{{ end }}
+{{ .Site.Title }}
+        </title>
+
+        <link href="http://feeds2.feedburner.com/stevelosh"
+              rel="alternate" title="Steve Losh"
+              type="application/atom+xml" />
+
+        <link rel="stylesheet" href="/media/css/aal.css"   type="text/css" media="screen" charset="utf-8" />
+        <link rel="stylesheet" href="/media/css/sjl.css"   type="text/css" media="screen" charset="utf-8" />
+        <link rel="stylesheet" href="/media/css/print.css" type="text/css" media="print" charset="utf-8" />
+        <link rel="stylesheet" href="/media/css/pygments-clean.css"
+          type="text/css" media="screen" charset="utf-8" />
+
+        <script data-cfasync="false" src="/media/js/jquery.js" type="text/javascript"></script>
+        <script data-cfasync="false" src="/media/js/jquery.timeago.js" type="text/javascript"></script>
+        <script data-cfasync="false" src="/media/js/sjl.js" type="text/javascript"></script>
+        <script data-cfasync="false" src="/media/js/print.js" type="text/javascript"></script>
+        <script data-cfasync="false" type="text/javascript" src="//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
+
+        <link rel="openid.server" href="http://www.myopenid.com/server" />
+        <link rel="openid.delegate" href="http://stevelosh.myopenid.com/" />
+
+        <script type="text/javascript">
+          var _gaq = _gaq || [];
+          _gaq.push(['_setAccount', 'UA-15328874-2']);
+          _gaq.push(['_trackPageview']);
+
+          (function() {
+            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+          })();
+        </script>
+
+    </head>
+
+    <body>
+        <div class="wrap">
+            <div class="top group">
+                <header>
+                    <a href="/">steve losh</a>
+                </header>
+
+                <nav>
+                    <a href="/blog/">Blog</a>
+                    <span class="sep">-</span>
+                    <a href="/links">Links</a>
+                    <span class="sep">-</span>
+                    <a href="/about/">About</a>
+                    <span class="sep">-</span>
+                    <a href="http://feeds2.feedburner.com/stevelosh">Feed</a>
+                </nav>
+            </div>
+
+            <div class="hr">&nbsp;</div>
+
+            <div class="content">
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/stevelosh/theme.toml	Fri Oct 07 12:48:36 2016 +0000
@@ -0,0 +1,8 @@
+name = "Stevelosh"
+license = "MIT"
+homepage = "http://stevelosh.com/"
+min_version = 0.15
+
+[author]
+  name = "Steve Losh"
+  homepage = "http://stevelosh.com/"
Binary file yuicompressor-2.4.2.jar has changed