made with requirebin
Last active
August 29, 2015 14:17
-
-
Save mikolalysenko/0d4c38d1aa80edbe4a28 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var createScene = require('gl-plot3d') | |
var createMesh = require('gl-mesh3d') | |
var bunny = require('bunny') | |
var scene = createScene() | |
var mesh = createMesh({ | |
gl: scene.gl, | |
cells: bunny.cells, | |
positions: bunny.positions, | |
vertexIntensity: bunny.positions.map(function(p) { | |
return Math.cos(p[0]) * Math.sin(0.2 * p[1]) + Math.cos(0.4 * p[2]) | |
}), | |
colormap: 'jet' | |
}) | |
scene.add(mesh) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require=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 base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("is-array");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var kMaxLength=1073741823;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=function(){try{var buf=new ArrayBuffer(0);var arr=new Uint8Array(buf);arr.foo=function(){return 42};return 42===arr.foo()&&typeof arr.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(e){return false}}();function Buffer(subject,encoding,noZero){if(!(this instanceof Buffer))return new Buffer(subject,encoding,noZero);var type=typeof subject;var length;if(type==="number")length=subject>0?subject>>>0:0;else if(type==="string"){length=Buffer.byteLength(subject,encoding)}else if(type==="object"&&subject!==null){if(subject.type==="Buffer"&&isArray(subject.data))subject=subject.data;length=+subject.length>0?Math.floor(+subject.length):0}else throw new TypeError("must start with number, buffer, array or string");if(length>kMaxLength)throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength.toString(16)+" bytes");var buf;if(Buffer.TYPED_ARRAY_SUPPORT){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof subject.byteLength==="number"){buf._set(subject)}else if(isArrayish(subject)){if(Buffer.isBuffer(subject)){for(i=0;i<length;i++)buf[i]=subject.readUInt8(i)}else{for(i=0;i<length;i++)buf[i]=(subject[i]%256+256)%256}}else if(type==="string"){buf.write(subject,0,encoding)}else if(type==="number"&&!Buffer.TYPED_ARRAY_SUPPORT&&!noZero){for(i=0;i<length;i++){buf[i]=0}}if(length>0&&length<=Buffer.poolSize)buf.parent=rootParent;return buf}function SlowBuffer(subject,encoding,noZero){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding,noZero);var buf=new Buffer(subject,encoding,noZero);delete buf.parent;return buf}Buffer.isBuffer=function(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len&&a[i]===b[i];i++){}if(i!==len){x=a[i];y=b[i]}if(x<y)return-1;if(y<x)return 1;return 0};Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function(list,totalLength){if(!isArray(list))throw new TypeError("Usage: Buffer.concat(list[, length])");if(list.length===0){return new Buffer(0)}else if(list.length===1){return list[0]}var i;if(totalLength===undefined){totalLength=0;for(i=0;i<list.length;i++){totalLength+=list[i].length}}var buf=new Buffer(totalLength);var pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos);pos+=item.length}return buf};Buffer.byteLength=function(str,encoding){var ret;str=str+"";switch(encoding||"utf8"){case"ascii":case"binary":case"raw":ret=str.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;case"hex":ret=str.length>>>1;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"base64":ret=base64ToBytes(str).length;break;default:ret=str.length}return ret};Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;Buffer.prototype.toString=function(encoding,start,end){var loweredCase=false;start=start>>>0;end=end===undefined||end===Infinity?this.length:end>>>0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}};Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)};Buffer.prototype.get=function(offset){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(offset)};Buffer.prototype.set=function(v,offset){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(v,offset)};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;i++){var byte=parseInt(string.substr(i*2,2),16);if(isNaN(byte))throw new Error("Invalid hex string");buf[offset+i]=byte}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length);return charsWritten}function asciiWrite(buf,string,offset,length){var charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function binaryWrite(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){var charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function utf16leWrite(buf,string,offset,length){var charsWritten=blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length,2);return charsWritten}Buffer.prototype.write=function(string,offset,length,encoding){if(isFinite(offset)){if(!isFinite(length)){encoding=length;length=undefined}}else{var swap=encoding;encoding=offset;offset=length;length=swap}offset=Number(offset)||0;if(length<0||offset<0||offset>this.length)throw new RangeError("attempt to write outside buffer bounds");var remaining=this.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=utf8Write(this,string,offset,length);break;case"ascii":ret=asciiWrite(this,string,offset,length);break;case"binary":ret=binaryWrite(this,string,offset,length);break;case"base64":ret=base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leWrite(this,string,offset,length);break;default:throw new TypeError("Unknown encoding: "+encoding)}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i]&127)}return ret}function binarySlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i])}return ret}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;i++){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT){newBuf=Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}}if(newBuf.length)newBuf.parent=this.parent||this;return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;return val};Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256))val+=this[offset+--byteLength]*mul;return val};Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256))val+=this[offset+--i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range")}Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=0;var mul=1;var sub=value<0?1:0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=byteLength-1;var mul=1;var sub=value<0?1:0;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};Buffer.prototype.writeInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range");if(offset<0)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38);ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308);ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function(target,target_start,start,end){var source=this;if(!start)start=0;if(!end&&end!==0)end=this.length;if(target_start>=target.length)target_start=target.length;if(!target_start)target_start=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||source.length===0)return 0;if(target_start<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=source.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-target_start<end-start)end=target.length-target_start+start;var len=end-start;if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i<len;i++){target[i+target_start]=this[i+start]}}else{target._set(this.subarray(start,start+len),target_start)}return len};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;if(end<start)throw new RangeError("end < start");if(end===start)return;if(this.length===0)return;if(start<0||start>=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("end out of bounds");var i;if(typeof value==="number"){for(i=start;i<end;i++){this[i]=value}}else{var bytes=utf8ToBytes(value.toString());var len=bytes.length;for(i=start;i<end;i++){this[i]=bytes[i%len]}}return this};Buffer.prototype.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(Buffer.TYPED_ARRAY_SUPPORT){return new Buffer(this).buffer}else{var buf=new Uint8Array(this.length);for(var i=0,len=buf.length;i<len;i+=1){buf[i]=this[i]}return buf.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function(arr){arr.constructor=Buffer;arr._isBuffer=true;arr._get=arr.get;arr._set=arr.set;arr.get=BP.get;arr.set=BP.set;arr.write=BP.write;arr.toString=BP.toString;arr.toLocaleString=BP.toString;arr.toJSON=BP.toJSON;arr.equals=BP.equals;arr.compare=BP.compare;arr.copy=BP.copy;arr.slice=BP.slice;arr.readUIntLE=BP.readUIntLE;arr.readUIntBE=BP.readUIntBE;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readIntLE=BP.readIntLE;arr.readIntBE=BP.readIntBE;arr.readInt8=BP.readInt8;arr.readInt16LE=BP.readInt16LE;arr.readInt16BE=BP.readInt16BE;arr.readInt32LE=BP.readInt32LE;arr.readInt32BE=BP.readInt32BE;arr.readFloatLE=BP.readFloatLE;arr.readFloatBE=BP.readFloatBE;arr.readDoubleLE=BP.readDoubleLE;arr.readDoubleBE=BP.readDoubleBE;arr.writeUInt8=BP.writeUInt8;arr.writeUIntLE=BP.writeUIntLE;arr.writeUIntBE=BP.writeUIntBE;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeIntLE=BP.writeIntLE;arr.writeIntBE=BP.writeIntBE;arr.writeInt8=BP.writeInt8;arr.writeInt16LE=BP.writeInt16LE;arr.writeInt16BE=BP.writeInt16BE;arr.writeInt32LE=BP.writeInt32LE;arr.writeInt32BE=BP.writeInt32BE;arr.writeFloatLE=BP.writeFloatLE;arr.writeFloatBE=BP.writeFloatBE;arr.writeDoubleLE=BP.writeDoubleLE;arr.writeDoubleBE=BP.writeDoubleBE;arr.fill=BP.fill;arr.inspect=BP.inspect;arr.toArrayBuffer=BP.toArrayBuffer;return arr};var INVALID_BASE64_RE=/[^+\/0-9A-z\-]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");if(str.length<2)return"";while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&typeof subject==="object"&&typeof subject.length==="number"}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(string,units){var codePoint,length=string.length;var leadSurrogate=null;units=units||Infinity;var bytes=[];var i=0;for(;i<length;i++){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length,unitSize){if(unitSize)length-=length%unitSize;for(var i=0;i<length;i++){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}},{"base64-js":2,ieee754:3,"is-array":4}],2:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);var PLUS_URL_SAFE="-".charCodeAt(0);var SLASH_URL_SAFE="_".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS||code===PLUS_URL_SAFE)return 62;if(code===SLASH||code===SLASH_URL_SAFE)return 63;if(code<NUMBER)return-1;if(code<NUMBER+10)return code-NUMBER+26+26;if(code<UPPER+26)return code-UPPER;if(code<LOWER+26)return code-LOWER+26}function b64ToByteArray(b64){var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i<l;i+=4,j+=3){tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3));push((tmp&16711680)>>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i<length;i+=3){temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output+=tripletToBase64(temp)}switch(extraBytes){case 1:temp=uint8[uint8.length-1];output+=encode(temp>>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(typeof exports==="undefined"?this.base64js={}:exports)},{}],3:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8);m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8);if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8);e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=s*128}},{}],4:[function(require,module,exports){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},{}],5:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();queue.length=0;queueList.forEach(function(fn){fn()})});observer.observe(hiddenDiv,{attributes:true});return function nextTick(fn){if(!queue.length){hiddenDiv.setAttribute("yes","no")}queue.push(fn)}}if(canPost){window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],6:[function(require,module,exports){var glslify=require("glslify");var createShader=require("gl-shader");var compositeShader=require("glslify/simple-adapter.js")("\n#define GLSLIFY 1\n\nattribute vec2 position;\nvarying vec2 uv;\nvoid main() {\n uv = position;\n gl_Position = vec4(position, 0, 1);\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nuniform sampler2D accumBuffer;\nvarying vec2 uv;\nvoid main() {\n vec4 accum = texture2D(accumBuffer, 0.5 * (uv + 1.0));\n gl_FragColor = min(vec4(1, 1, 1, 1), accum);\n}",[{name:"accumBuffer",type:"sampler2D"}],[{name:"position",type:"vec2"}]);module.exports=function(gl){return createShader(gl,compositeShader)}},{"gl-shader":141,glslify:169,"glslify/simple-adapter.js":175}],7:[function(require,module,exports){"use strict";var pool=require("typedarray-pool");var ops=require("ndarray-ops");var ndarray=require("ndarray");var webglew=require("webglew");var SUPPORTED_TYPES=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"];function GLBuffer(gl,type,handle,length,usage){this.gl=gl;this.type=type;this.handle=handle;this.length=length;this.usage=usage}var proto=GLBuffer.prototype;proto.bind=function(){this.gl.bindBuffer(this.type,this.handle)};proto.unbind=function(){this.gl.bindBuffer(this.type,null)};proto.dispose=function(){this.gl.deleteBuffer(this.handle)};function updateTypeArray(gl,type,len,usage,data,offset){var dataLen=data.length*data.BYTES_PER_ELEMENT;if(offset<0){gl.bufferData(type,data,usage);return dataLen}if(dataLen+offset>len){throw new Error("gl-buffer: If resizing buffer, must not specify offset")}gl.bufferSubData(type,offset,data);return len}function makeScratchTypeArray(array,dtype){ | |
var res=pool.malloc(array.length,dtype);var n=array.length;for(var i=0;i<n;++i){res[i]=array[i]}return res}function isPacked(shape,stride){var n=1;for(var i=stride.length-1;i>=0;--i){if(stride[i]!==n){return false}n*=shape[i]}return true}proto.update=function(array,offset){if(typeof offset!=="number"){offset=-1}this.bind();if(typeof array==="object"&&typeof array.shape!=="undefined"){var dtype=array.dtype;if(SUPPORTED_TYPES.indexOf(dtype)<0){dtype="float32"}if(this.type===this.gl.ELEMENT_ARRAY_BUFFER){var wgl=webglew(this.gl);var ext=wgl.OES_element_index_uint;if(ext&&dtype!=="uint16"){dtype="uint32"}else{dtype="uint16"}}if(dtype===array.dtype&&isPacked(array.shape,array.stride)){if(array.offset===0&&array.data.length===array.shape[0]){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,array.data,offset)}else{this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,array.data.subarray(array.offset,array.shape[0]),offset)}}else{var tmp=pool.malloc(array.size,dtype);var ndt=ndarray(tmp,array.shape);ops.assign(ndt,array);if(offset<0){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,tmp,offset)}else{this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,tmp.subarray(0,array.size),offset)}pool.free(tmp)}}else if(Array.isArray(array)){var t;if(this.type===this.gl.ELEMENT_ARRAY_BUFFER){t=makeScratchTypeArray(array,"uint16")}else{t=makeScratchTypeArray(array,"float32")}if(offset<0){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,t,offset)}else{this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,t.subarray(0,array.length),offset)}pool.free(t)}else if(typeof array==="object"&&typeof array.length==="number"){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,array,offset)}else if(typeof array==="number"||array===undefined){if(offset>=0){throw new Error("gl-buffer: Cannot specify offset when resizing buffer")}array=array|0;if(array<=0){array=1}this.gl.bufferData(this.type,array|0,this.usage);this.length=array}else{throw new Error("gl-buffer: Invalid data type")}};function createBuffer(gl,data,type,usage){webglew(gl);type=type||gl.ARRAY_BUFFER;usage=usage||gl.DYNAMIC_DRAW;if(type!==gl.ARRAY_BUFFER&&type!==gl.ELEMENT_ARRAY_BUFFER){throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER")}if(usage!==gl.DYNAMIC_DRAW&&usage!==gl.STATIC_DRAW&&usage!==gl.STREAM_DRAW){throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW")}var handle=gl.createBuffer();var result=new GLBuffer(gl,type,handle,0,usage);result.update(data);return result}module.exports=createBuffer},{ndarray:178,"ndarray-ops":8,"typedarray-pool":15,webglew:17}],8:[function(require,module,exports){"use strict";var compile=require("cwise-compiler");var EmptyProc={body:"",args:[],thisVars:[],localVars:[]};function fixup(x){if(!x){return EmptyProc}for(var i=0;i<x.args.length;++i){var a=x.args[i];if(i===0){x.args[i]={name:a,lvalue:true,rvalue:!!x.rvalue,count:x.count||1}}else{x.args[i]={name:a,lvalue:false,rvalue:true,count:1}}}if(!x.thisVars){x.thisVars=[]}if(!x.localVars){x.localVars=[]}return x}function pcompile(user_args){return compile({args:user_args.args,pre:fixup(user_args.pre),body:fixup(user_args.body),post:fixup(user_args.proc),funcName:user_args.funcName})}function makeOp(user_args){var args=[];for(var i=0;i<user_args.args.length;++i){args.push("a"+i)}var wrapper=new Function("P",["return function ",user_args.funcName,"_ndarrayops(",args.join(","),") {P(",args.join(","),");return a0}"].join(""));return wrapper(pcompile(user_args))}var assign_ops={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var id in assign_ops){var op=assign_ops[id];exports[id]=makeOp({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+op+"c"},funcName:id});exports[id+"eq"]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a"+op+"=b"},rvalue:true,funcName:id+"eq"});exports[id+"s"]=makeOp({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+op+"s"},funcName:id+"s"});exports[id+"seq"]=makeOp({args:["array","scalar"],body:{args:["a","s"],body:"a"+op+"=s"},rvalue:true,funcName:id+"seq"})}})();var unary_ops={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var id in unary_ops){var op=unary_ops[id];exports[id]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a="+op+"b"},funcName:id});exports[id+"eq"]=makeOp({args:["array"],body:{args:["a"],body:"a="+op+"a"},rvalue:true,count:2,funcName:id+"eq"})}})();var binary_ops={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var id in binary_ops){var op=binary_ops[id];exports[id]=makeOp({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+op+"c"},funcName:id});exports[id+"s"]=makeOp({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+op+"s"},funcName:id+"s"});exports[id+"eq"]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a=a"+op+"b"},rvalue:true,count:2,funcName:id+"eq"});exports[id+"seq"]=makeOp({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+op+"s"},rvalue:true,count:2,funcName:id+"seq"})}})();var math_unary=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var i=0;i<math_unary.length;++i){var f=math_unary[i];exports[f]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:f});exports[f+"eq"]=makeOp({args:["array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"eq"})}})();var math_comm=["max","min","atan2","pow"];(function(){for(var i=0;i<math_comm.length;++i){var f=math_comm[i];exports[f]=makeOp({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:f});exports[f+"s"]=makeOp({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:f+"s"});exports[f+"eq"]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"eq"});exports[f+"seq"]=makeOp({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"seq"})}})();var math_noncomm=["atan2","pow"];(function(){for(var i=0;i<math_noncomm.length;++i){var f=math_noncomm[i];exports[f+"op"]=makeOp({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:f+"op"});exports[f+"ops"]=makeOp({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:f+"ops"});exports[f+"opeq"]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"opeq"});exports[f+"opseq"]=makeOp({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"opseq"})}})();exports.any=compile({args:["array"],pre:EmptyProc,body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});exports.all=compile({args:["array"],pre:EmptyProc,body:{args:[{name:"x",lvalue:false,rvalue:true,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});exports.sum=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});exports.prod=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});exports.norm2squared=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});exports.norm2=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});exports.norminf=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});exports.norm1=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});exports.sup=compile({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});exports.inf=compile({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});exports.argmin=compile({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2},{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});exports.argmax=compile({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2},{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});exports.random=makeOp({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});exports.assign=makeOp({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});exports.assigns=makeOp({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});exports.equals=compile({args:["array","array"],pre:EmptyProc,body:{args:[{name:"x",lvalue:false,rvalue:true,count:1},{name:"y",lvalue:false,rvalue:true,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":9}],9:[function(require,module,exports){"use strict";var createThunk=require("./lib/thunk.js");function Procedure(){this.argTypes=[];this.shimArgs=[];this.arrayArgs=[];this.scalarArgs=[];this.offsetArgs=[];this.offsetArgIndex=[];this.indexArgs=[];this.shapeArgs=[];this.funcName="";this.pre=null;this.body=null;this.post=null;this.debug=false}function compileCwise(user_args){var proc=new Procedure;proc.pre=user_args.pre;proc.body=user_args.body;proc.post=user_args.post;var proc_args=user_args.args.slice(0);proc.argTypes=proc_args;for(var i=0;i<proc_args.length;++i){var arg_type=proc_args[i];if(arg_type==="array"){proc.arrayArgs.push(i);proc.shimArgs.push("array"+i);if(i<proc.pre.args.length&&proc.pre.args[i].count>0){throw new Error("cwise: pre() block may not reference array args")}if(i<proc.post.args.length&&proc.post.args[i].count>0){throw new Error("cwise: post() block may not reference array args")}}else if(arg_type==="scalar"){proc.scalarArgs.push(i);proc.shimArgs.push("scalar"+i)}else if(arg_type==="index"){proc.indexArgs.push(i);if(i<proc.pre.args.length&&proc.pre.args[i].count>0){throw new Error("cwise: pre() block may not reference array index")}if(i<proc.body.args.length&&proc.body.args[i].lvalue){throw new Error("cwise: body() block may not write to array index")}if(i<proc.post.args.length&&proc.post.args[i].count>0){throw new Error("cwise: post() block may not reference array index")}}else if(arg_type==="shape"){proc.shapeArgs.push(i);if(i<proc.pre.args.length&&proc.pre.args[i].lvalue){throw new Error("cwise: pre() block may not write to array shape")}if(i<proc.body.args.length&&proc.body.args[i].lvalue){throw new Error("cwise: body() block may not write to array shape")}if(i<proc.post.args.length&&proc.post.args[i].lvalue){throw new Error("cwise: post() block may not write to array shape")}}else if(typeof arg_type==="object"&&arg_type.offset){proc.argTypes[i]="offset";proc.offsetArgs.push({array:arg_type.array,offset:arg_type.offset});proc.offsetArgIndex.push(i)}else{throw new Error("cwise: Unknown argument type "+proc_args[i])}}if(proc.arrayArgs.length<=0){throw new Error("cwise: No array arguments specified")}if(proc.pre.args.length>proc_args.length){throw new Error("cwise: Too many arguments in pre() block")}if(proc.body.args.length>proc_args.length){throw new Error("cwise: Too many arguments in body() block")}if(proc.post.args.length>proc_args.length){throw new Error("cwise: Too many arguments in post() block")}proc.debug=!!user_args.printCode||!!user_args.debug;proc.funcName=user_args.funcName||"cwise";proc.blockSize=user_args.blockSize||64;return createThunk(proc)}module.exports=compileCwise},{"./lib/thunk.js":11}],10:[function(require,module,exports){"use strict";var uniq=require("uniq");function innerFill(order,proc,body){var dimension=order.length,nargs=proc.arrayArgs.length,has_index=proc.indexArgs.length>0,code=[],vars=[],idx=0,pidx=0,i,j;for(i=0;i<dimension;++i){vars.push(["i",i,"=0"].join(""))}for(j=0;j<nargs;++j){for(i=0;i<dimension;++i){pidx=idx;idx=order[i];if(i===0){vars.push(["d",j,"s",i,"=t",j,"p",idx].join(""))}else{vars.push(["d",j,"s",i,"=(t",j,"p",idx,"-s",pidx,"*t",j,"p",pidx,")"].join(""))}}}code.push("var "+vars.join(","));for(i=dimension-1;i>=0;--i){idx=order[i];code.push(["for(i",i,"=0;i",i,"<s",idx,";++i",i,"){"].join(""))}code.push(body);for(i=0;i<dimension;++i){pidx=idx;idx=order[i];for(j=0;j<nargs;++j){code.push(["p",j,"+=d",j,"s",i].join(""))}if(has_index){if(i>0){code.push(["index[",pidx,"]-=s",pidx].join(""))}code.push(["++index[",idx,"]"].join(""))}code.push("}")}return code.join("\n")}function outerFill(matched,order,proc,body){var dimension=order.length,nargs=proc.arrayArgs.length,blockSize=proc.blockSize,has_index=proc.indexArgs.length>0,code=[];for(var i=0;i<nargs;++i){code.push(["var offset",i,"=p",i].join(""))}for(var i=matched;i<dimension;++i){code.push(["for(var j"+i+"=SS[",order[i],"]|0;j",i,">0;){"].join(""));code.push(["if(j",i,"<",blockSize,"){"].join(""));code.push(["s",order[i],"=j",i].join(""));code.push(["j",i,"=0"].join(""));code.push(["}else{s",order[i],"=",blockSize].join(""));code.push(["j",i,"-=",blockSize,"}"].join(""));if(has_index){code.push(["index[",order[i],"]=j",i].join(""))}}for(var i=0;i<nargs;++i){var indexStr=["offset"+i];for(var j=matched;j<dimension;++j){indexStr.push(["j",j,"*t",i,"p",order[j]].join(""))}code.push(["p",i,"=(",indexStr.join("+"),")"].join(""))}code.push(innerFill(order,proc,body));for(var i=matched;i<dimension;++i){code.push("}")}return code.join("\n")}function countMatches(orders){var matched=0,dimension=orders[0].length;while(matched<dimension){for(var j=1;j<orders.length;++j){if(orders[j][matched]!==orders[0][matched]){return matched}}++matched}return matched}function processBlock(block,proc,dtypes){var code=block.body;var pre=[];var post=[];for(var i=0;i<block.args.length;++i){var carg=block.args[i];if(carg.count<=0){continue}var re=new RegExp(carg.name,"g");var ptrStr="";var arrNum=proc.arrayArgs.indexOf(i);switch(proc.argTypes[i]){case"offset":var offArgIndex=proc.offsetArgIndex.indexOf(i);var offArg=proc.offsetArgs[offArgIndex];arrNum=offArg.array;ptrStr="+q"+offArgIndex;case"array":ptrStr="p"+arrNum+ptrStr;var localStr="l"+i;var arrStr="a"+arrNum;if(carg.count===1){if(dtypes[arrNum]==="generic"){if(carg.lvalue){pre.push(["var ",localStr,"=",arrStr,".get(",ptrStr,")"].join(""));code=code.replace(re,localStr);post.push([arrStr,".set(",ptrStr,",",localStr,")"].join(""))}else{code=code.replace(re,[arrStr,".get(",ptrStr,")"].join(""))}}else{code=code.replace(re,[arrStr,"[",ptrStr,"]"].join(""))}}else if(dtypes[arrNum]==="generic"){pre.push(["var ",localStr,"=",arrStr,".get(",ptrStr,")"].join(""));code=code.replace(re,localStr);if(carg.lvalue){post.push([arrStr,".set(",ptrStr,",",localStr,")"].join(""))}}else{pre.push(["var ",localStr,"=",arrStr,"[",ptrStr,"]"].join(""));code=code.replace(re,localStr);if(carg.lvalue){post.push([arrStr,"[",ptrStr,"]=",localStr].join(""))}}break;case"scalar":code=code.replace(re,"Y"+proc.scalarArgs.indexOf(i));break;case"index":code=code.replace(re,"index");break;case"shape":code=code.replace(re,"shape");break}}return[pre.join("\n"),code,post.join("\n")].join("\n").trim()}function typeSummary(dtypes){var summary=new Array(dtypes.length);var allEqual=true;for(var i=0;i<dtypes.length;++i){var t=dtypes[i];var digits=t.match(/\d+/);if(!digits){digits=""}else{digits=digits[0]}if(t.charAt(0)===0){summary[i]="u"+t.charAt(1)+digits}else{summary[i]=t.charAt(0)+digits}if(i>0){allEqual=allEqual&&summary[i]===summary[i-1]}}if(allEqual){return summary[0]}return summary.join("")}function generateCWiseOp(proc,typesig){var dimension=typesig[1].length|0;var orders=new Array(proc.arrayArgs.length);var dtypes=new Array(proc.arrayArgs.length);var arglist=["SS"];var code=["'use strict'"];var vars=[];for(var j=0;j<dimension;++j){vars.push(["s",j,"=SS[",j,"]"].join(""))}for(var i=0;i<proc.arrayArgs.length;++i){arglist.push("a"+i);arglist.push("t"+i);arglist.push("p"+i);dtypes[i]=typesig[2*i];orders[i]=typesig[2*i+1];for(var j=0;j<dimension;++j){vars.push(["t",i,"p",j,"=t",i,"[",j,"]"].join(""))}}for(var i=0;i<proc.scalarArgs.length;++i){arglist.push("Y"+i)}if(proc.shapeArgs.length>0){vars.push("shape=SS.slice(0)")}if(proc.indexArgs.length>0){var zeros=new Array(dimension);for(var i=0;i<dimension;++i){zeros[i]="0"}vars.push(["index=[",zeros.join(","),"]"].join(""))}for(var i=0;i<proc.offsetArgs.length;++i){var off_arg=proc.offsetArgs[i];var init_string=[];for(var j=0;j<off_arg.offset.length;++j){if(off_arg.offset[j]===0){continue}else if(off_arg.offset[j]===1){init_string.push(["t",off_arg.array,"p",j].join(""))}else{init_string.push([off_arg.offset[j],"*t",off_arg.array,"p",j].join(""))}}if(init_string.length===0){vars.push("q"+i+"=0")}else{vars.push(["q",i,"=",init_string.join("+")].join(""))}}var thisVars=uniq([].concat(proc.pre.thisVars).concat(proc.body.thisVars).concat(proc.post.thisVars));vars=vars.concat(thisVars);code.push("var "+vars.join(","));for(var i=0;i<proc.arrayArgs.length;++i){code.push("p"+i+"|=0")}if(proc.pre.body.length>3){code.push(processBlock(proc.pre,proc,dtypes))}var body=processBlock(proc.body,proc,dtypes);var matched=countMatches(orders);if(matched<dimension){code.push(outerFill(matched,orders[0],proc,body))}else{code.push(innerFill(orders[0],proc,body))}if(proc.post.body.length>3){code.push(processBlock(proc.post,proc,dtypes))}if(proc.debug){console.log("Generated cwise routine for ",typesig,":\n\n",code.join("\n"))}var loopName=[proc.funcName||"unnamed","_cwise_loop_",orders[0].join("s"),"m",matched,typeSummary(dtypes)].join("");var f=new Function(["function ",loopName,"(",arglist.join(","),"){",code.join("\n"),"} return ",loopName].join(""));return f()}module.exports=generateCWiseOp},{uniq:12}],11:[function(require,module,exports){"use strict";var compile=require("./compile.js");function createThunk(proc){var code=["'use strict'","var CACHED={}"];var vars=[];var thunkName=proc.funcName+"_cwise_thunk";code.push(["return function ",thunkName,"(",proc.shimArgs.join(","),"){"].join(""));var typesig=[];var string_typesig=[];var proc_args=[["array",proc.arrayArgs[0],".shape"].join("")];for(var i=0;i<proc.arrayArgs.length;++i){var j=proc.arrayArgs[i];vars.push(["t",j,"=array",j,".dtype,","r",j,"=array",j,".order"].join(""));typesig.push("t"+j);typesig.push("r"+j);string_typesig.push("t"+j);string_typesig.push("r"+j+".join()");proc_args.push("array"+j+".data");proc_args.push("array"+j+".stride");proc_args.push("array"+j+".offset|0")}for(var i=0;i<proc.scalarArgs.length;++i){proc_args.push("scalar"+proc.scalarArgs[i])}vars.push(["type=[",string_typesig.join(","),"].join()"].join(""));vars.push("proc=CACHED[type]");code.push("var "+vars.join(","));code.push(["if(!proc){","CACHED[type]=proc=compile([",typesig.join(","),"])}","return proc(",proc_args.join(","),")}"].join(""));if(proc.debug){console.log("Generated thunk:",code.join("\n"))}var thunk=new Function("compile",code.join("\n"));return thunk(compile.bind(undefined,proc))}module.exports=createThunk},{"./compile.js":10}],12:[function(require,module,exports){"use strict";function unique_pred(list,compare){var ptr=1,len=list.length,a=list[0],b=list[0];for(var i=1;i<len;++i){b=a;a=list[i];if(compare(a,b)){if(i===ptr){ptr++;continue}list[ptr++]=a}}list.length=ptr;return list}function unique_eq(list){var ptr=1,len=list.length,a=list[0],b=list[0];for(var i=1;i<len;++i,b=a){b=a;a=list[i];if(a!==b){if(i===ptr){ptr++;continue}list[ptr++]=a}}list.length=ptr;return list}function unique(list,compare,sorted){if(list.length===0){return list}if(compare){if(!sorted){list.sort(compare)}return unique_pred(list,compare)}if(!sorted){list.sort()}return unique_eq(list)}module.exports=unique},{}],13:[function(require,module,exports){"use strict";"use restrict";var INT_BITS=32;exports.INT_BITS=INT_BITS;exports.INT_MAX=2147483647;exports.INT_MIN=-1<<INT_BITS-1;exports.sign=function(v){return(v>0)-(v<0)};exports.abs=function(v){var mask=v>>INT_BITS-1;return(v^mask)-mask};exports.min=function(x,y){return y^(x^y)&-(x<y)};exports.max=function(x,y){return x^(x^y)&-(x<y)};exports.isPow2=function(v){return!(v&v-1)&&!!v};exports.log2=function(v){var r,shift;r=(v>65535)<<4;v>>>=r;shift=(v>255)<<3;v>>>=shift;r|=shift;shift=(v>15)<<2;v>>>=shift;r|=shift;shift=(v>3)<<1;v>>>=shift;r|=shift;return r|v>>1};exports.log10=function(v){return v>=1e9?9:v>=1e8?8:v>=1e7?7:v>=1e6?6:v>=1e5?5:v>=1e4?4:v>=1e3?3:v>=100?2:v>=10?1:0};exports.popCount=function(v){v=v-(v>>>1&1431655765);v=(v&858993459)+(v>>>2&858993459);return(v+(v>>>4)&252645135)*16843009>>>24};function countTrailingZeros(v){var c=32;v&=-v;if(v)c--;if(v&65535)c-=16;if(v&16711935)c-=8;if(v&252645135)c-=4;if(v&858993459)c-=2;if(v&1431655765)c-=1;return c}exports.countTrailingZeros=countTrailingZeros;exports.nextPow2=function(v){v+=v===0;--v;v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v+1};exports.prevPow2=function(v){v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v-(v>>>1)};exports.parity=function(v){v^=v>>>16;v^=v>>>8;v^=v>>>4;v&=15;return 27030>>>v&1};var REVERSE_TABLE=new Array(256);(function(tab){for(var i=0;i<256;++i){var v=i,r=i,s=7;for(v>>>=1;v;v>>>=1){r<<=1;r|=v&1;--s}tab[i]=r<<s&255}})(REVERSE_TABLE);exports.reverse=function(v){return REVERSE_TABLE[v&255]<<24|REVERSE_TABLE[v>>>8&255]<<16|REVERSE_TABLE[v>>>16&255]<<8|REVERSE_TABLE[v>>>24&255]};exports.interleave2=function(x,y){x&=65535;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y&=65535;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1};exports.deinterleave2=function(v,n){v=v>>>n&1431655765;v=(v|v>>>1)&858993459;v=(v|v>>>2)&252645135;v=(v|v>>>4)&16711935;v=(v|v>>>16)&65535;return v<<16>>16};exports.interleave3=function(x,y,z){x&=1023;x=(x|x<<16)&4278190335;x=(x|x<<8)&251719695;x=(x|x<<4)&3272356035;x=(x|x<<2)&1227133513;y&=1023;y=(y|y<<16)&4278190335;y=(y|y<<8)&251719695;y=(y|y<<4)&3272356035;y=(y|y<<2)&1227133513;x|=y<<1;z&=1023;z=(z|z<<16)&4278190335;z=(z|z<<8)&251719695;z=(z|z<<4)&3272356035;z=(z|z<<2)&1227133513;return x|z<<2};exports.deinterleave3=function(v,n){v=v>>>n&1227133513;v=(v|v>>>2)&3272356035;v=(v|v>>>4)&251719695;v=(v|v>>>8)&4278190335;v=(v|v>>>16)&1023;return v<<22>>22};exports.nextCombination=function(v){var t=v|v-1;return t+1|(~t&-~t)-1>>>countTrailingZeros(v)+1}},{}],14:[function(require,module,exports){"use strict";function dupe_array(count,value,i){var c=count[i]|0;if(c<=0){return[]}var result=new Array(c),j;if(i===count.length-1){for(j=0;j<c;++j){result[j]=value}}else{for(j=0;j<c;++j){result[j]=dupe_array(count,value,i+1)}}return result}function dupe_number(count,value){var result,i;result=new Array(count);for(i=0;i<count;++i){result[i]=value}return result}function dupe(count,value){if(typeof value==="undefined"){value=0}switch(typeof count){case"number":if(count>0){return dupe_number(count|0,value)}break;case"object":if(typeof count.length==="number"){return dupe_array(count,value,0)}break}return[]}module.exports=dupe},{}],15:[function(require,module,exports){(function(global,Buffer){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0]),UINT8C:dup([32,0]),BUFFER:dup([32,0])}}var hasUint8C=typeof Uint8ClampedArray!=="undefined";var POOL=global.__TYPEDARRAY_POOL;if(!POOL.UINT8C){POOL.UINT8C=dup([32,0])}if(!POOL.BUFFER){POOL.BUFFER=dup([32,0])}var DATA=POOL.DATA,BUFFER=POOL.BUFFER;exports.free=function free(array){if(Buffer.isBuffer(array)){BUFFER[bits.log2(array.length)].push(array)}else{if(Object.prototype.toString.call(array)!=="[object ArrayBuffer]"){array=array.buffer}if(!array){return}var n=array.length||array.byteLength;var log_n=bits.log2(n)|0;DATA[log_n].push(array)}};function freeArrayBuffer(buffer){if(!buffer){return}var n=buffer.length||buffer.byteLength;var log_n=bits.log2(n);DATA[log_n].push(buffer)}function freeTypedArray(array){freeArrayBuffer(array.buffer)}exports.freeUint8=exports.freeUint16=exports.freeUint32=exports.freeInt8=exports.freeInt16=exports.freeInt32=exports.freeFloat32=exports.freeFloat=exports.freeFloat64=exports.freeDouble=exports.freeUint8Clamped=exports.freeDataView=freeTypedArray;exports.freeArrayBuffer=freeArrayBuffer;exports.freeBuffer=function freeBuffer(array){BUFFER[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){if(dtype===undefined||dtype==="arraybuffer"){return mallocArrayBuffer(n)}else{switch(dtype){case"uint8":return mallocUint8(n);case"uint16":return mallocUint16(n);case"uint32":return mallocUint32(n);case"int8":return mallocInt8(n);case"int16":return mallocInt16(n);case"int32":return mallocInt32(n);case"float":case"float32":return mallocFloat(n);case"double":case"float64":return mallocDouble(n);case"uint8_clamped":return mallocUint8Clamped(n);case"buffer":return mallocBuffer(n);case"data":case"dataview":return mallocDataView(n);default:return null}}return null};function mallocArrayBuffer(n){var n=bits.nextPow2(n);var log_n=bits.log2(n);var d=DATA[log_n];if(d.length>0){return d.pop()}return new ArrayBuffer(n)}exports.mallocArrayBuffer=mallocArrayBuffer;function mallocUint8(n){return new Uint8Array(mallocArrayBuffer(n),0,n)}exports.mallocUint8=mallocUint8;function mallocUint16(n){return new Uint16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocUint16=mallocUint16;function mallocUint32(n){return new Uint32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocUint32=mallocUint32;function mallocInt8(n){return new Int8Array(mallocArrayBuffer(n),0,n)}exports.mallocInt8=mallocInt8;function mallocInt16(n){return new Int16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocInt16=mallocInt16;function mallocInt32(n){return new Int32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocInt32=mallocInt32;function mallocFloat(n){return new Float32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocFloat32=exports.mallocFloat=mallocFloat;function mallocDouble(n){return new Float64Array(mallocArrayBuffer(8*n),0,n)}exports.mallocFloat64=exports.mallocDouble=mallocDouble;function mallocUint8Clamped(n){if(hasUint8C){return new Uint8ClampedArray(mallocArrayBuffer(n),0,n)}else{return mallocUint8(n)}}exports.mallocUint8Clamped=mallocUint8Clamped;function mallocDataView(n){return new DataView(mallocArrayBuffer(n),0,n)}exports.mallocDataView=mallocDataView;function mallocBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=BUFFER[log_n];if(cache.length>0){return cache.pop()}return new Buffer(n)}exports.mallocBuffer=mallocBuffer;exports.clearCache=function clearCache(){for(var i=0;i<32;++i){POOL.UINT8[i].length=0;POOL.UINT16[i].length=0;POOL.UINT32[i].length=0;POOL.INT8[i].length=0;POOL.INT16[i].length=0;POOL.INT32[i].length=0;POOL.FLOAT[i].length=0;POOL.DOUBLE[i].length=0;POOL.UINT8C[i].length=0;DATA[i].length=0;BUFFER[i].length=0}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"bit-twiddle":13,buffer:1,dup:14}],16:[function(require,module,exports){(function WeakMapModule(){"use strict";if(typeof ses!=="undefined"&&ses.ok&&!ses.ok()){return}function weakMapPermitHostObjects(map){if(map.permitHostObjects___){map.permitHostObjects___(weakMapPermitHostObjects)}}if(typeof ses!=="undefined"){ses.weakMapPermitHostObjects=weakMapPermitHostObjects}var doubleWeakMapCheckSilentFailure=false;if(typeof WeakMap==="function"){var HostWeakMap=WeakMap;if(typeof navigator!=="undefined"&&/Firefox/.test(navigator.userAgent)){}else{var testMap=new HostWeakMap;var testObject=Object.freeze({});testMap.set(testObject,1);if(testMap.get(testObject)!==1){doubleWeakMapCheckSilentFailure=true}else{module.exports=WeakMap;return}}}var hop=Object.prototype.hasOwnProperty;var gopn=Object.getOwnPropertyNames;var defProp=Object.defineProperty;var isExtensible=Object.isExtensible;var HIDDEN_NAME_PREFIX="weakmap:"; | |
var HIDDEN_NAME=HIDDEN_NAME_PREFIX+"ident:"+Math.random()+"___";if(typeof crypto!=="undefined"&&typeof crypto.getRandomValues==="function"&&typeof ArrayBuffer==="function"&&typeof Uint8Array==="function"){var ab=new ArrayBuffer(25);var u8s=new Uint8Array(ab);crypto.getRandomValues(u8s);HIDDEN_NAME=HIDDEN_NAME_PREFIX+"rand:"+Array.prototype.map.call(u8s,function(u8){return(u8%36).toString(36)}).join("")+"___"}function isNotHiddenName(name){return!(name.substr(0,HIDDEN_NAME_PREFIX.length)==HIDDEN_NAME_PREFIX&&name.substr(name.length-3)==="___")}defProp(Object,"getOwnPropertyNames",{value:function fakeGetOwnPropertyNames(obj){return gopn(obj).filter(isNotHiddenName)}});if("getPropertyNames"in Object){var originalGetPropertyNames=Object.getPropertyNames;defProp(Object,"getPropertyNames",{value:function fakeGetPropertyNames(obj){return originalGetPropertyNames(obj).filter(isNotHiddenName)}})}function getHiddenRecord(key){if(key!==Object(key)){throw new TypeError("Not an object: "+key)}var hiddenRecord=key[HIDDEN_NAME];if(hiddenRecord&&hiddenRecord.key===key){return hiddenRecord}if(!isExtensible(key)){return void 0}hiddenRecord={key:key};try{defProp(key,HIDDEN_NAME,{value:hiddenRecord,writable:false,enumerable:false,configurable:false});return hiddenRecord}catch(error){return void 0}}(function(){var oldFreeze=Object.freeze;defProp(Object,"freeze",{value:function identifyingFreeze(obj){getHiddenRecord(obj);return oldFreeze(obj)}});var oldSeal=Object.seal;defProp(Object,"seal",{value:function identifyingSeal(obj){getHiddenRecord(obj);return oldSeal(obj)}});var oldPreventExtensions=Object.preventExtensions;defProp(Object,"preventExtensions",{value:function identifyingPreventExtensions(obj){getHiddenRecord(obj);return oldPreventExtensions(obj)}})})();function constFunc(func){func.prototype=null;return Object.freeze(func)}var calledAsFunctionWarningDone=false;function calledAsFunctionWarning(){if(!calledAsFunctionWarningDone&&typeof console!=="undefined"){calledAsFunctionWarningDone=true;console.warn("WeakMap should be invoked as new WeakMap(), not "+"WeakMap(). This will be an error in the future.")}}var nextId=0;var OurWeakMap=function(){if(!(this instanceof OurWeakMap)){calledAsFunctionWarning()}var keys=[];var values=[];var id=nextId++;function get___(key,opt_default){var index;var hiddenRecord=getHiddenRecord(key);if(hiddenRecord){return id in hiddenRecord?hiddenRecord[id]:opt_default}else{index=keys.indexOf(key);return index>=0?values[index]:opt_default}}function has___(key){var hiddenRecord=getHiddenRecord(key);if(hiddenRecord){return id in hiddenRecord}else{return keys.indexOf(key)>=0}}function set___(key,value){var index;var hiddenRecord=getHiddenRecord(key);if(hiddenRecord){hiddenRecord[id]=value}else{index=keys.indexOf(key);if(index>=0){values[index]=value}else{index=keys.length;values[index]=value;keys[index]=key}}return this}function delete___(key){var hiddenRecord=getHiddenRecord(key);var index,lastIndex;if(hiddenRecord){return id in hiddenRecord&&delete hiddenRecord[id]}else{index=keys.indexOf(key);if(index<0){return false}lastIndex=keys.length-1;keys[index]=void 0;values[index]=values[lastIndex];keys[index]=keys[lastIndex];keys.length=lastIndex;values.length=lastIndex;return true}}return Object.create(OurWeakMap.prototype,{get___:{value:constFunc(get___)},has___:{value:constFunc(has___)},set___:{value:constFunc(set___)},delete___:{value:constFunc(delete___)}})};OurWeakMap.prototype=Object.create(Object.prototype,{get:{value:function get(key,opt_default){return this.get___(key,opt_default)},writable:true,configurable:true},has:{value:function has(key){return this.has___(key)},writable:true,configurable:true},set:{value:function set(key,value){return this.set___(key,value)},writable:true,configurable:true},"delete":{value:function remove(key){return this.delete___(key)},writable:true,configurable:true}});if(typeof HostWeakMap==="function"){(function(){if(doubleWeakMapCheckSilentFailure&&typeof Proxy!=="undefined"){Proxy=undefined}function DoubleWeakMap(){if(!(this instanceof OurWeakMap)){calledAsFunctionWarning()}var hmap=new HostWeakMap;var omap=undefined;var enableSwitching=false;function dget(key,opt_default){if(omap){return hmap.has(key)?hmap.get(key):omap.get___(key,opt_default)}else{return hmap.get(key,opt_default)}}function dhas(key){return hmap.has(key)||(omap?omap.has___(key):false)}var dset;if(doubleWeakMapCheckSilentFailure){dset=function(key,value){hmap.set(key,value);if(!hmap.has(key)){if(!omap){omap=new OurWeakMap}omap.set(key,value)}return this}}else{dset=function(key,value){if(enableSwitching){try{hmap.set(key,value)}catch(e){if(!omap){omap=new OurWeakMap}omap.set___(key,value)}}else{hmap.set(key,value)}return this}}function ddelete(key){var result=!!hmap["delete"](key);if(omap){return omap.delete___(key)||result}return result}return Object.create(OurWeakMap.prototype,{get___:{value:constFunc(dget)},has___:{value:constFunc(dhas)},set___:{value:constFunc(dset)},delete___:{value:constFunc(ddelete)},permitHostObjects___:{value:constFunc(function(token){if(token===weakMapPermitHostObjects){enableSwitching=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}DoubleWeakMap.prototype=OurWeakMap.prototype;module.exports=DoubleWeakMap;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}module.exports=OurWeakMap}})()},{}],17:[function(require,module,exports){"use strict";var weakMap=typeof WeakMap==="undefined"?require("weak-map"):WeakMap;var WebGLEWStruct=new weakMap;function baseName(ext_name){return ext_name.replace(/^[A-Z]+_/,"")}function initWebGLEW(gl){var struct=WebGLEWStruct.get(gl);if(struct){return struct}var extensions={};var supported=gl.getSupportedExtensions();for(var i=0;i<supported.length;++i){var extName=supported[i];if(extName.indexOf("MOZ_")===0){continue}var ext=gl.getExtension(supported[i]);if(!ext){continue}while(true){extensions[extName]=ext;var base=baseName(extName);if(base===extName){break}extName=base}}WebGLEWStruct.set(gl,extensions);return extensions}module.exports=initWebGLEW},{"weak-map":16}],18:[function(require,module,exports){"use strict";function doBind(gl,elements,attributes){if(elements){elements.bind()}else{gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,null)}var nattribs=gl.getParameter(gl.MAX_VERTEX_ATTRIBS)|0;if(attributes){if(attributes.length>nattribs){throw new Error("gl-vao: Too many vertex attributes")}for(var i=0;i<attributes.length;++i){var attrib=attributes[i];if(attrib.buffer){var buffer=attrib.buffer;var size=attrib.size||4;var type=attrib.type||gl.FLOAT;var normalized=!!attrib.normalized;var stride=attrib.stride||0;var offset=attrib.offset||0;buffer.bind();gl.enableVertexAttribArray(i);gl.vertexAttribPointer(i,size,type,normalized,stride,offset)}else{if(typeof attrib==="number"){gl.vertexAttrib1f(i,attrib)}else if(attrib.length===1){gl.vertexAttrib1f(i,attrib[0])}else if(attrib.length===2){gl.vertexAttrib2f(i,attrib[0],attrib[1])}else if(attrib.length===3){gl.vertexAttrib3f(i,attrib[0],attrib[1],attrib[2])}else if(attrib.length===4){gl.vertexAttrib4f(i,attrib[0],attrib[1],attrib[2],attrib[3])}else{throw new Error("gl-vao: Invalid vertex attribute")}gl.disableVertexAttribArray(i)}}for(;i<nattribs;++i){gl.disableVertexAttribArray(i)}}else{gl.bindBuffer(gl.ARRAY_BUFFER,null);for(var i=0;i<nattribs;++i){gl.disableVertexAttribArray(i)}}}module.exports=doBind},{}],19:[function(require,module,exports){"use strict";var bindAttribs=require("./do-bind.js");function VAOEmulated(gl){this.gl=gl;this._elements=null;this._attributes=null;this._elementsType=gl.UNSIGNED_SHORT}VAOEmulated.prototype.bind=function(){bindAttribs(this.gl,this._elements,this._attributes)};VAOEmulated.prototype.update=function(attributes,elements,elementsType){this._elements=elements;this._attributes=attributes;this._elementsType=elementsType||this.gl.UNSIGNED_SHORT};VAOEmulated.prototype.dispose=function(){};VAOEmulated.prototype.unbind=function(){};VAOEmulated.prototype.draw=function(mode,count,offset){offset=offset||0;var gl=this.gl;if(this._elements){gl.drawElements(mode,count,this._elementsType,offset)}else{gl.drawArrays(mode,offset,count)}};function createVAOEmulated(gl){return new VAOEmulated(gl)}module.exports=createVAOEmulated},{"./do-bind.js":18}],20:[function(require,module,exports){"use strict";var bindAttribs=require("./do-bind.js");function VertexAttribute(location,dimension,a,b,c,d){this.location=location;this.dimension=dimension;this.a=a;this.b=b;this.c=c;this.d=d}VertexAttribute.prototype.bind=function(gl){switch(this.dimension){case 1:gl.vertexAttrib1f(this.location,this.a);break;case 2:gl.vertexAttrib2f(this.location,this.a,this.b);break;case 3:gl.vertexAttrib3f(this.location,this.a,this.b,this.c);break;case 4:gl.vertexAttrib4f(this.location,this.a,this.b,this.c,this.d);break}};function VAONative(gl,ext,handle){this.gl=gl;this._ext=ext;this.handle=handle;this._attribs=[];this._useElements=false;this._elementsType=gl.UNSIGNED_SHORT}VAONative.prototype.bind=function(){this._ext.bindVertexArrayOES(this.handle);for(var i=0;i<this._attribs.length;++i){this._attribs[i].bind(this.gl)}};VAONative.prototype.unbind=function(){this._ext.bindVertexArrayOES(null)};VAONative.prototype.dispose=function(){this._ext.deleteVertexArrayOES(this.handle)};VAONative.prototype.update=function(attributes,elements,elementsType){this.bind();bindAttribs(this.gl,elements,attributes);this.unbind();this._attribs.length=0;if(attributes)for(var i=0;i<attributes.length;++i){var a=attributes[i];if(typeof a==="number"){this._attribs.push(new VertexAttribute(i,1,a))}else if(Array.isArray(a)){this._attribs.push(new VertexAttribute(i,a.length,a[0],a[1],a[2],a[3]))}}this._useElements=!!elements;this._elementsType=elementsType||this.gl.UNSIGNED_SHORT};VAONative.prototype.draw=function(mode,count,offset){offset=offset||0;var gl=this.gl;if(this._useElements){gl.drawElements(mode,count,this._elementsType,offset)}else{gl.drawArrays(mode,offset,count)}};function createVAONative(gl,ext){return new VAONative(gl,ext,ext.createVertexArrayOES())}module.exports=createVAONative},{"./do-bind.js":18}],21:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{dup:16}],22:[function(require,module,exports){arguments[4][17][0].apply(exports,arguments)},{dup:17,"weak-map":21}],23:[function(require,module,exports){"use strict";var webglew=require("webglew");var createVAONative=require("./lib/vao-native.js");var createVAOEmulated=require("./lib/vao-emulated.js");function createVAO(gl,attributes,elements,elementsType){var ext=webglew(gl).OES_vertex_array_object;var vao;if(ext){vao=createVAONative(gl,ext)}else{vao=createVAOEmulated(gl)}vao.update(attributes,elements,elementsType);return vao}module.exports=createVAO},{"./lib/vao-emulated.js":19,"./lib/vao-native.js":20,webglew:22}],24:[function(require,module,exports){void function(global,undefined_,undefined){var getProps=Object.getOwnPropertyNames,defProp=Object.defineProperty,toSource=Function.prototype.toString,create=Object.create,hasOwn=Object.prototype.hasOwnProperty,funcName=/^\n?function\s?(\w*)?_?\(/;function define(object,key,value){if(typeof key==="function"){value=key;key=nameOf(value).replace(/_$/,"")}return defProp(object,key,{configurable:true,writable:true,value:value})}function nameOf(func){return typeof func!=="function"?"":"name"in func?func.name:toSource.call(func).match(funcName)[1]}var Data=function(){var dataDesc={value:{writable:true,value:undefined}},datalock="return function(k){if(k===s)return l}",uids=create(null),createUID=function(){var key=Math.random().toString(36).slice(2);return key in uids?createUID():uids[key]=key},globalID=createUID(),storage=function(obj){if(hasOwn.call(obj,globalID))return obj[globalID];if(!Object.isExtensible(obj))throw new TypeError("Object must be extensible");var store=create(null);defProp(obj,globalID,{value:store});return store};define(Object,function getOwnPropertyNames(obj){var props=getProps(obj);if(hasOwn.call(obj,globalID))props.splice(props.indexOf(globalID),1);return props});function Data(){var puid=createUID(),secret={};this.unlock=function(obj){var store=storage(obj);if(hasOwn.call(store,puid))return store[puid](secret);var data=create(null,dataDesc);defProp(store,puid,{value:new Function("s","l",datalock)(secret,data)});return data}}define(Data.prototype,function get(o){return this.unlock(o).value});define(Data.prototype,function set(o,v){this.unlock(o).value=v});return Data}();var WM=function(data){var validate=function(key){if(key==null||typeof key!=="object"&&typeof key!=="function")throw new TypeError("Invalid WeakMap key")};var wrap=function(collection,value){var store=data.unlock(collection);if(store.value)throw new TypeError("Object is already a WeakMap");store.value=value};var unwrap=function(collection){var storage=data.unlock(collection).value;if(!storage)throw new TypeError("WeakMap is not generic");return storage};var initialize=function(weakmap,iterable){if(iterable!==null&&typeof iterable==="object"&&typeof iterable.forEach==="function"){iterable.forEach(function(item,i){if(item instanceof Array&&item.length===2)set.call(weakmap,iterable[i][0],iterable[i][1])})}};function WeakMap(iterable){if(this===global||this==null||this===WeakMap.prototype)return new WeakMap(iterable);wrap(this,new Data);initialize(this,iterable)}function get(key){validate(key);var value=unwrap(this).get(key);return value===undefined_?undefined:value}function set(key,value){validate(key);unwrap(this).set(key,value===undefined?undefined_:value)}function has(key){validate(key);return unwrap(this).get(key)!==undefined}function delete_(key){validate(key);var data=unwrap(this),had=data.get(key)!==undefined;data.set(key,undefined);return had}function toString(){unwrap(this);return"[object WeakMap]"}try{var src=("return "+delete_).replace("e_","\\u0065"),del=new Function("unwrap","validate",src)(unwrap,validate)}catch(e){var del=delete_}var src=(""+Object).split("Object");var stringifier=function toString(){return src[0]+nameOf(this)+src[1]};define(stringifier,stringifier);var prep={__proto__:[]}instanceof Array?function(f){f.__proto__=stringifier}:function(f){define(f,stringifier)};prep(WeakMap);[toString,get,set,has,del].forEach(function(method){define(WeakMap.prototype,method);prep(method)});return WeakMap}(new Data);var defaultCreator=Object.create?function(){return Object.create(null)}:function(){return{}};function createStorage(creator){var weakmap=new WM;creator||(creator=defaultCreator);function storage(object,value){if(value||arguments.length===2){weakmap.set(object,value)}else{value=weakmap.get(object);if(value===undefined){value=creator(object);weakmap.set(object,value)}}return value}return storage}if(typeof module!=="undefined"){module.exports=WM}else if(typeof exports!=="undefined"){exports.WeakMap=WM}else if(!("WeakMap"in global)){global.WeakMap=WM}WM.createStorage=createStorage;if(global.WeakMap)global.WeakMap.createStorage=createStorage}((0,eval)("this"))},{}],25:[function(require,module,exports){"use strict";var weakMap=typeof WeakMap==="undefined"?require("weakmap"):WeakMap;var createBuffer=require("gl-buffer");var createVAO=require("gl-vao");var TriangleCache=new weakMap;function createABigTriangle(gl){var triangleVAO=TriangleCache.get(gl);if(!triangleVAO){var buf=createBuffer(gl,new Float32Array([-1,-1,-1,4,4,-1]));triangleVAO=createVAO(gl,[{buffer:buf,type:gl.FLOAT,size:2}]);TriangleCache.set(gl,triangleVAO)}triangleVAO.bind();gl.drawArrays(gl.TRIANGLES,0,3);triangleVAO.unbind()}module.exports=createABigTriangle},{"gl-buffer":7,"gl-vao":23,weakmap:24}],26:[function(require,module,exports){"use strict";module.exports=createAxes;var createText=require("./lib/text.js");var createLines=require("./lib/lines.js");var createBackground=require("./lib/background.js");var getCubeProperties=require("./lib/cube.js");var Ticks=require("./lib/ticks.js");var identity=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function copyVec3(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];return a}function Axes(gl){this.gl=gl;this.pixelRatio=1;this.bounds=[[-10,-10,-10],[10,10,10]];this.ticks=[[],[],[]];this.autoTicks=true;this.tickSpacing=[1,1,1];this.tickEnable=[true,true,true];this.tickFont=["sans-serif","sans-serif","sans-serif"];this.tickSize=[12,12,12];this.tickAngle=[0,0,0];this.tickColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.tickPad=[.05,.05,.05];this.lastCubeProps={cubeEdges:[0,0,0],axis:[0,0,0]};this.labels=["x","y","z"];this.labelEnable=[true,true,true];this.labelFont="sans-serif";this.labelSize=[20,20,20];this.labelAngle=[0,0,0];this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.labelPad=[.05,.05,.05];this.lineEnable=[true,true,true];this.lineMirror=[false,false,false];this.lineWidth=[1,1,1];this.lineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.lineTickEnable=[true,true,true];this.lineTickMirror=[false,false,false];this.lineTickLength=[0,0,0];this.lineTickWidth=[1,1,1];this.lineTickColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.gridEnable=[true,true,true];this.gridWidth=[1,1,1];this.gridColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.zeroEnable=[true,true,true];this.zeroLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.zeroLineWidth=[2,2,2];this.backgroundEnable=[false,false,false];this.backgroundColor=[[.8,.8,.8,.5],[.8,.8,.8,.5],[.8,.8,.8,.5]];this._firstInit=true;this._text=null;this._lines=null;this._background=createBackground(gl)}var proto=Axes.prototype;proto.update=function(options){options=options||{};function parseOption(nest,cons,name){if(name in options){var opt=options[name];var prev=this[name];var next;if(nest?Array.isArray(opt)&&Array.isArray(opt[0]):Array.isArray(opt)){this[name]=next=[cons(opt[0]),cons(opt[1]),cons(opt[2])]}else{this[name]=next=[cons(opt),cons(opt),cons(opt)]}for(var i=0;i<3;++i){if(next[i]!==prev[i]){return true}}}return false}var NUMBER=parseOption.bind(this,false,Number);var BOOLEAN=parseOption.bind(this,false,Boolean);var STRING=parseOption.bind(this,false,String);var COLOR=parseOption.bind(this,true,function(v){if(Array.isArray(v)){if(v.length===3){return[+v[0],+v[1],+v[2],1]}else if(v.length===4){return[+v[0],+v[1],+v[2],+v[3]]}}return[0,0,0,1]});var nextTicks;var ticksUpdate=false;var boundsChanged=false;if("bounds"in options){var bounds=options.bounds;i_loop:for(var i=0;i<2;++i){for(var j=0;j<3;++j){if(bounds[i][j]!==this.bounds[i][j]){this.bounds=options.bounds;boundsChanged=true;break i_loop}}}}if("ticks"in options){nextTicks=options.ticks;ticksUpdate=true;this.autoTicks=false;for(var i=0;i<3;++i){this.tickSpacing[i]=0}}else if(NUMBER("tickSpacing")){this.autoTicks=true;boundsChanged=true}if(this._firstInit){if(!("ticks"in options||"tickSpacing"in options)){this.autoTicks=true}boundsChanged=true;ticksUpdate=true;this._firstInit=false}if(boundsChanged&&this.autoTicks){nextTicks=Ticks.create(this.bounds,this.tickSpacing);ticksUpdate=true}if(ticksUpdate){for(var i=0;i<3;++i){nextTicks[i].sort(function(a,b){return a.x-b.x})}if(Ticks.equal(nextTicks,this.ticks)){ticksUpdate=false}else{this.ticks=nextTicks}}BOOLEAN("tickEnable");if(STRING("tickFont")){ticksUpdate=true}NUMBER("tickSize");NUMBER("tickAngle");NUMBER("tickPad");COLOR("tickColor");var labelUpdate=STRING("labels");if(STRING("labelFont")){labelUpdate=true}BOOLEAN("labelEnable");NUMBER("labelSize");NUMBER("labelPad");COLOR("labelColor");BOOLEAN("lineEnable");BOOLEAN("lineMirror");NUMBER("lineWidth");COLOR("lineColor");BOOLEAN("lineTickEnable");BOOLEAN("lineTickMirror");NUMBER("lineTickLength");NUMBER("lineTickWidth");COLOR("lineTickColor");BOOLEAN("gridEnable");NUMBER("gridWidth");COLOR("gridColor");BOOLEAN("zeroEnable");COLOR("zeroLineColor");NUMBER("zeroLineWidth");BOOLEAN("backgroundEnable");COLOR("backgroundColor");if(!this._text){this._text=createText(this.gl,this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont)}else if(this._text&&(labelUpdate||ticksUpdate)){this._text.update(this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont)}if(this._lines&&ticksUpdate){this._lines.dispose();this._lines=null}if(!this._lines){this._lines=createLines(this.gl,this.bounds,this.ticks)}};function OffsetInfo(){this.primalOffset=[0,0,0];this.primalMinor=[0,0,0];this.mirrorOffset=[0,0,0];this.mirrorMinor=[0,0,0]}var LINE_OFFSET=[new OffsetInfo,new OffsetInfo,new OffsetInfo];function computeLineOffset(result,i,bounds,cubeEdges,cubeAxis){var primalOffset=result.primalOffset;var primalMinor=result.primalMinor;var dualOffset=result.mirrorOffset;var dualMinor=result.mirrorMinor;var e=cubeEdges[i];for(var j=0;j<3;++j){if(i===j){continue}var a=primalOffset,b=dualOffset,c=primalMinor,d=dualMinor;if(e&1<<j){a=dualOffset;b=primalOffset;c=dualMinor;d=primalMinor}a[j]=bounds[0][j];b[j]=bounds[1][j];if(cubeAxis[j]>0){c[j]=-1;d[j]=0}else{c[j]=0;d[j]=+1}}}var CUBE_ENABLE=[0,0,0];var DEFAULT_PARAMS={model:identity,view:identity,projection:identity};proto.isOpaque=function(){return true};proto.isTransparent=function(){return this.backgroundEnable[0]||this.backgroundEnable[1]||this.backgroundEnable[2]};proto.drawTransparent=function(params){var cubeEnable=CUBE_ENABLE;for(var i=0;i<3;++i){if(this.backgroundEnable[i]){cubeEnable[i]=cubeAxis[i]}else{cubeEnable[i]=0}}this._background.draw(params.model||identity,params.view||identity,params.projection||identity,this.bounds,cubeEnable,this.backgroundColor)};var PRIMAL_MINOR=[0,0,0];var MIRROR_MINOR=[0,0,0];var PRIMAL_OFFSET=[0,0,0];proto.draw=function(params){params=params||DEFAULT_PARAMS;var model=params.model||identity;var view=params.view||identity;var projection=params.projection||identity;var bounds=this.bounds;var cubeParams=getCubeProperties(model,view,projection,bounds);var cubeEdges=cubeParams.cubeEdges;var cubeAxis=cubeParams.axis;for(var i=0;i<3;++i){this.lastCubeProps.cubeEdges[i]=cubeEdges[i];this.lastCubeProps.axis[i]=cubeAxis[i]}var lineOffset=LINE_OFFSET;for(var i=0;i<3;++i){computeLineOffset(LINE_OFFSET[i],i,this.bounds,cubeEdges,cubeAxis)}var gl=this.gl;this._lines.bind(model,view,projection,this);for(var i=0;i<3;++i){var x=[0,0,0];if(cubeAxis[i]>0){x[i]=bounds[1][i]}else{x[i]=bounds[0][i]}for(var j=0;j<2;++j){var u=(i+1+j)%3;var v=(i+1+(j^1))%3;if(this.gridEnable[u]){gl.lineWidth(this.gridWidth[u]);this._lines.drawGrid(u,v,this.bounds,x,this.gridColor[u])}}for(var j=0;j<2;++j){var u=(i+1+j)%3;var v=(i+1+(j^1))%3;if(this.zeroEnable[v]){if(bounds[0][v]<=0&&bounds[1][v]>=0){gl.lineWidth(this.zeroLineWidth[v]);this._lines.drawZero(u,this.bounds,x,this.zeroLineColor[v])}}}}for(var i=0;i<3;++i){gl.lineWidth(this.lineWidth[i]);if(this.lineEnable[i]){this._lines.drawAxisLine(i,this.bounds,lineOffset[i].primalOffset,this.lineColor[i])}if(this.lineMirror[i]){this._lines.drawAxisLine(i,this.bounds,lineOffset[i].mirrorOffset,this.lineColor[i])}var primalMinor=copyVec3(PRIMAL_MINOR,lineOffset[i].primalMinor);var mirrorMinor=copyVec3(MIRROR_MINOR,lineOffset[i].mirrorMinor);var tickLength=this.lineTickLength;for(var j=0;j<3;++j){var scaleFactor=1/model[5*j];primalMinor[j]*=tickLength[j]*scaleFactor;mirrorMinor[j]*=tickLength[j]*scaleFactor}gl.lineWidth(this.lineTickWidth[i]);if(this.lineTickEnable[i]){this._lines.drawAxisTicks(i,lineOffset[i].primalOffset,primalMinor,this.lineTickColor[i])}if(this.lineTickMirror[i]){this._lines.drawAxisTicks(i,lineOffset[i].mirrorOffset,mirrorMinor,this.lineTickColor[i])}}this._text.bind(model,view,projection,this.pixelRatio);for(var i=0;i<3;++i){var minor=lineOffset[i].primalMinor;var offset=copyVec3(PRIMAL_OFFSET,lineOffset[i].primalOffset);for(var j=0;j<3;++j){if(this.lineTickEnable[i]){offset[j]+=minor[j]*Math.max(this.lineTickLength[j],0)}}if(this.tickEnable[i]){for(var j=0;j<3;++j){offset[j]+=minor[j]*this.tickPad[j]/model[5*j]}this._text.drawTicks(i,this.tickSize[i],this.tickAngle[i],offset,this.tickColor[i])}if(this.labelEnable[i]){for(var j=0;j<3;++j){offset[j]+=minor[j]*this.labelPad[j]/model[5*j]}offset[i]+=.5*(bounds[0][i]+bounds[1][i]);this._text.drawLabel(i,this.labelSize[i],this.labelAngle[i],offset,this.labelColor[i])}}};proto.dispose=function(){this._text.dispose();this._lines.dispose();this._background.dispose()};function createAxes(gl,options){var axes=new Axes(gl);axes.update(options);return axes}},{"./lib/background.js":27,"./lib/cube.js":28,"./lib/lines.js":29,"./lib/text.js":30,"./lib/ticks.js":31}],27:[function(require,module,exports){"use strict";module.exports=createBackgroundCube;var createBuffer=require("gl-buffer");var createVAO=require("gl-vao");var glslify=require("glslify");var createShader=require("glslify/adapter.js")("\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec3 normal;\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\nvarying vec3 colorChannel;\nvoid main() {\n if(dot(normal, enable) > 0.0) {\n vec3 nPosition = mix(bounds[0], bounds[1], 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0, 0, 0, 0);\n }\n colorChannel = abs(normal);\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nuniform vec4 colors[3];\nvarying vec3 colorChannel;\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] + colorChannel.y * colors[1] + colorChannel.z * colors[2];\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"enable",type:"vec3"},{name:"bounds[0]",type:"vec3"},{name:"bounds[1]",type:"vec3"},{name:"colors[0]",type:"vec4"},{name:"colors[1]",type:"vec4"},{name:"colors[2]",type:"vec4"}],[{name:"position",type:"vec3"},{name:"normal",type:"vec3"}]);function BackgroundCube(gl,buffer,vao,shader){this.gl=gl;this.buffer=buffer;this.vao=vao;this.shader=shader}var proto=BackgroundCube.prototype;proto.draw=function(model,view,projection,bounds,enable,colors){this.shader.bind();this.shader.uniforms={model:model,view:view,projection:projection,bounds:bounds,enable:enable,colors:colors};this.vao.bind();this.vao.draw(this.gl.TRIANGLES,36)};proto.dispose=function(){this.vao.dispose();this.buffer.dispose();this.shader.dispose()};function createBackgroundCube(gl){var vertices=[];var indices=[];var ptr=0;for(var d=0;d<3;++d){var u=(d+1)%3;var v=(d+2)%3;var x=[0,0,0];var c=[0,0,0];for(var s=-1;s<=1;s+=2){indices.push(ptr,ptr+2,ptr+1,ptr+1,ptr+2,ptr+3);x[d]=s;c[d]=s;for(var i=-1;i<=1;i+=2){x[u]=i;for(var j=-1;j<=1;j+=2){x[v]=j;vertices.push(x[0],x[1],x[2],c[0],c[1],c[2]);ptr+=1}}var tt=u;u=v;v=tt}}var buffer=createBuffer(gl,new Float32Array(vertices));var elements=createBuffer(gl,new Uint16Array(indices),gl.ELEMENT_ARRAY_BUFFER);var vao=createVAO(gl,[{buffer:buffer,type:gl.FLOAT,size:3,offset:0,stride:24},{buffer:buffer,type:gl.FLOAT,size:3,offset:12,stride:24}],elements);var shader=createShader(gl);shader.attributes.position.location=0;shader.attributes.normal.location=1;return new BackgroundCube(gl,buffer,vao,shader)}},{"gl-buffer":35,"gl-vao":50,glslify:169,"glslify/adapter.js":168}],28:[function(require,module,exports){"use strict";module.exports=getCubeEdges;var bits=require("bit-twiddle");var multiply=require("gl-mat4/multiply");var invert=require("gl-mat4/invert");var splitPoly=require("split-polygon");var orient=require("robust-orientation");var mvp=new Array(16);var imvp=new Array(16);var pCubeVerts=new Array(8);var cubeVerts=new Array(8);var x=new Array(3);var zero3=[0,0,0];(function(){for(var i=0;i<8;++i){pCubeVerts[i]=[1,1,1,1];cubeVerts[i]=[1,1,1]}})();function transformHg(result,x,mat){for(var i=0;i<4;++i){result[i]=mat[12+i];for(var j=0;j<3;++j){result[i]+=x[j]*mat[4*j+i]}}}var FRUSTUM_PLANES=[[0,0,1,0,0],[0,0,-1,1,0],[0,-1,0,1,0],[0,1,0,1,0],[-1,0,0,1,0],[1,0,0,1,0]];function polygonArea(p){for(var i=0;i<FRUSTUM_PLANES.length;++i){p=splitPoly.positive(p,FRUSTUM_PLANES[i]);if(p.length<3){return 0}}var base=p[0];var ax=base[0]/base[3];var ay=base[1]/base[3];var area=0;for(var i=1;i+1<p.length;++i){var b=p[i];var c=p[i+1];var bx=b[0]/b[3];var by=b[1]/b[3];var cx=c[0]/c[3];var cy=c[1]/c[3];var ux=bx-ax;var uy=by-ay;var vx=cx-ax;var vy=cy-ay;area+=Math.abs(ux*vy-uy*vx)}return area}var CUBE_EDGES=[1,1,1];var CUBE_AXIS=[0,0,0];var CUBE_RESULT={cubeEdges:CUBE_EDGES,axis:CUBE_AXIS};function getCubeEdges(model,view,projection,bounds){multiply(mvp,view,model);multiply(mvp,projection,mvp);var ptr=0;for(var i=0;i<2;++i){x[2]=bounds[i][2];for(var j=0;j<2;++j){x[1]=bounds[j][1];for(var k=0;k<2;++k){x[0]=bounds[k][0];transformHg(pCubeVerts[ptr],x,mvp);var w=pCubeVerts[ptr][3];for(var l=0;l<3;++l){cubeVerts[ptr][l]=pCubeVerts[ptr][l]/w}ptr+=1}}}var closest=0;for(var d=0;d<3;++d){var u=(d+2)%3;var v=(d+1)%3;var o0=-1;var o1=-1;for(var s=0;s<2;++s){var f0=s<<d;var f1=f0+(s<<u)+(1-s<<v);var f2=f0+(1-s<<u)+(s<<v);if(orient(cubeVerts[f0],cubeVerts[f1],cubeVerts[f2],zero3)<0){continue}if(s){o0=1}else{o1=1}}if(o0<0||o1<0){if(o1>o0){closest|=1<<d}continue}for(var s=0;s<2;++s){var f0=s<<d;var f1=f0+(s<<u)+(1-s<<v);var f2=f0+(1-s<<u)+(s<<v);var o=polygonArea([pCubeVerts[f0],pCubeVerts[f1],pCubeVerts[f2],pCubeVerts[f0+(1<<u)+(1<<v)]]);if(s){o0=o}else{o1=o}}if(o1>o0){closest|=1<<d;continue}}var farthest=7^closest;var bottom=-1;for(var i=0;i<8;++i){if(i===closest||i===farthest){continue}if(bottom<0){bottom=i}else if(cubeVerts[bottom][1]>cubeVerts[i][1]){bottom=i}}var left=-1;for(var i=0;i<3;++i){var idx=bottom^1<<i;if(idx===closest||idx===farthest){continue}if(left<0){left=idx}var v=cubeVerts[idx];if(v[0]<cubeVerts[left][0]){left=idx}}var right=-1;for(var i=0;i<3;++i){var idx=bottom^1<<i;if(idx===closest||idx===farthest||idx===left){continue}if(right<0){right=idx}var v=cubeVerts[idx];if(v[0]>cubeVerts[right][0]){right=idx}}var cubeEdges=CUBE_EDGES;cubeEdges[0]=cubeEdges[1]=cubeEdges[2]=0;cubeEdges[bits.log2(left^bottom)]=bottom&left;cubeEdges[bits.log2(bottom^right)]=bottom&right;var top=right^7;if(top===closest||top===farthest){top=left^7;cubeEdges[bits.log2(right^top)]=top&right}else{cubeEdges[bits.log2(left^top)]=top&left}var axis=CUBE_AXIS;var cutCorner=closest;for(var d=0;d<3;++d){if(cutCorner&1<<d){axis[d]=-1}else{axis[d]=1}}return CUBE_RESULT}},{"bit-twiddle":32,"gl-mat4/invert":128,"gl-mat4/multiply":130,"robust-orientation":56,"split-polygon":57}],29:[function(require,module,exports){"use strict";module.exports=createLines;var createBuffer=require("gl-buffer");var createVAO=require("gl-vao");var glslify=require("glslify");var createShader=require("glslify/adapter.js")("\n#define GLSLIFY 1\n\nattribute vec2 position;\nuniform mat4 model, view, projection;\nuniform vec3 offset, majorAxis, minorAxis;\nvoid main() {\n vec3 vPosition = position.x * majorAxis + position.y * minorAxis + offset;\n gl_Position = projection * view * model * vec4(vPosition, 1.0);\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"offset",type:"vec3"},{name:"majorAxis",type:"vec3"},{name:"minorAxis",type:"vec3"},{name:"color",type:"vec4"}],[{name:"position",type:"vec2"}]);var MAJOR_AXIS=[0,0,0];var MINOR_AXIS=[0,0,0];var OFFSET_VEC=[0,0,0];function zeroVec(a){a[0]=a[1]=a[2]=0;return a}function copyVec(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];return a}function Lines(gl,vertBuffer,vao,shader,tickCount,tickOffset,gridCount,gridOffset){this.gl=gl;this.vertBuffer=vertBuffer;this.vao=vao;this.shader=shader;this.tickCount=tickCount;this.tickOffset=tickOffset;this.gridCount=gridCount;this.gridOffset=gridOffset}var proto=Lines.prototype;proto.bind=function(model,view,projection){this.shader.bind();this.shader.uniforms.model=model;this.shader.uniforms.view=view;this.shader.uniforms.projection=projection;this.vao.bind()};proto.drawAxisLine=function(j,bounds,offset,color){var minorAxis=zeroVec(MINOR_AXIS);this.shader.uniforms.majorAxis=MINOR_AXIS;minorAxis[j]=bounds[1][j]-bounds[0][j];this.shader.uniforms.minorAxis=minorAxis;var noffset=copyVec(OFFSET_VEC,offset);noffset[j]+=bounds[0][j];this.shader.uniforms.offset=noffset; | |
this.shader.uniforms.color=color;this.vao.draw(this.gl.LINES,2)};proto.drawAxisTicks=function(j,offset,minorAxis,color){var majorAxis=zeroVec(MAJOR_AXIS);majorAxis[j]=1;this.shader.uniforms.majorAxis=majorAxis;this.shader.uniforms.offset=offset;this.shader.uniforms.minorAxis=minorAxis;this.shader.uniforms.color=color;this.vao.draw(this.gl.LINES,this.tickCount[j],this.tickOffset[j])};proto.drawGrid=function(i,j,bounds,offset,color){var minorAxis=zeroVec(MINOR_AXIS);minorAxis[j]=bounds[1][j]-bounds[0][j];this.shader.uniforms.minorAxis=minorAxis;var noffset=copyVec(OFFSET_VEC,offset);noffset[j]+=bounds[0][j];this.shader.uniforms.offset=noffset;var majorAxis=zeroVec(MAJOR_AXIS);majorAxis[i]=1;this.shader.uniforms.majorAxis=majorAxis;this.shader.uniforms.color=color;this.vao.draw(this.gl.LINES,this.gridCount[i],this.gridOffset[i])};proto.drawZero=function(j,bounds,offset,color){var minorAxis=zeroVec(MINOR_AXIS);this.shader.uniforms.majorAxis=minorAxis;minorAxis[j]=bounds[1][j]-bounds[0][j];this.shader.uniforms.minorAxis=minorAxis;var noffset=copyVec(OFFSET_VEC,offset);noffset[j]+=bounds[0][j];this.shader.uniforms.offset=noffset;this.shader.uniforms.color=color;this.vao.draw(this.gl.LINES,2)};proto.dispose=function(){this.vao.dispose();this.vertBuffer.dispose();this.shader.dispose()};function createLines(gl,bounds,ticks){var vertices=[];var tickOffset=[0,0,0];var tickCount=[0,0,0];var gridOffset=[0,0,0];var gridCount=[0,0,0];vertices.push(0,0,0,1);for(var i=0;i<3;++i){var start=vertices.length/2|0;for(var j=0;j<ticks[i].length;++j){vertices.push(+ticks[i][j].x,0,+ticks[i][j].x,1)}var end=vertices.length/2|0;tickOffset[i]=start;tickCount[i]=end-start;var start=vertices.length/2|0;for(var k=0;k<ticks[i].length;++k){var tx=+ticks[i][k].x;vertices.push(tx,0,tx,1)}var end=vertices.length/2|0;gridOffset[i]=start;gridCount[i]=end-start}var vertBuf=createBuffer(gl,new Float32Array(vertices));var vao=createVAO(gl,[{buffer:vertBuf,type:gl.FLOAT,size:2,stride:0,offset:0}]);var shader=createShader(gl);shader.attributes.position.location=0;return new Lines(gl,vertBuf,vao,shader,tickCount,tickOffset,gridCount,gridOffset)}},{"gl-buffer":35,"gl-vao":50,glslify:169,"glslify/adapter.js":168}],30:[function(require,module,exports){(function(process){"use strict";module.exports=createTextSprites;var createBuffer=require("gl-buffer");var createVAO=require("gl-vao");var vectorizeText=require("vectorize-text");var glslify=require("glslify");var globals=window||process.global||{};var __TEXT_CACHE=globals.__TEXT_CACHE||{};globals.__TEXT_CACHE={};var createShader=require("glslify/adapter.js")("\n#define GLSLIFY 1\n\nattribute vec3 position;\nuniform mat4 model, view, projection;\nuniform vec3 offset, axis;\nuniform float scale, angle, pixelScale;\nuniform vec2 resolution;\nvoid main() {\n vec2 planeCoord = position.xy * pixelScale;\n mat2 planeXform = scale * mat2(cos(angle), sin(angle), -sin(angle), cos(angle));\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n vec4 worldPosition = model * vec4(dataPosition, 1);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n clipPosition += vec4(viewOffset, 0, 0);\n gl_Position = clipPosition;\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"offset",type:"vec3"},{name:"axis",type:"vec3"},{name:"scale",type:"float"},{name:"angle",type:"float"},{name:"pixelScale",type:"float"},{name:"resolution",type:"vec2"},{name:"color",type:"vec4"}],[{name:"position",type:"vec3"}]);var VERTEX_SIZE=3;var VERTEX_STRIDE=VERTEX_SIZE*4;function TextSprites(gl,shader,buffer,vao){this.gl=gl;this.shader=shader;this.buffer=buffer;this.vao=vao;this.tickOffset=this.tickCount=this.labelOffset=this.labelCount=null}var proto=TextSprites.prototype;var SHAPE=[0,0];proto.bind=function(model,view,projection,pixelScale){this.vao.bind();this.shader.bind();var uniforms=this.shader.uniforms;uniforms.model=model;uniforms.view=view;uniforms.projection=projection;uniforms.pixelScale=pixelScale;SHAPE[0]=this.gl.drawingBufferWidth;SHAPE[1]=this.gl.drawingBufferHeight;this.shader.uniforms.resolution=SHAPE};proto.update=function(bounds,labels,labelFont,ticks,tickFont){var gl=this.gl;var data=[];function addItem(t,text,font){var fontcache=__TEXT_CACHE[font];if(!fontcache){fontcache=__TEXT_CACHE[font]={}}var mesh=fontcache[text];if(!mesh){mesh=fontcache[text]=tryVectorizeText(text,{triangles:true,font:font,textAlign:"center",textBaseline:"middle"})}var positions=mesh.positions;var cells=mesh.cells;var lo=[Infinity,Infinity];var hi=[-Infinity,-Infinity];for(var i=0,nc=cells.length;i<nc;++i){var c=cells[i];for(var j=2;j>=0;--j){var p=positions[c[j]];data.push(p[0],-p[1],t)}}}var tickOffset=[0,0,0];var tickCount=[0,0,0];var labelOffset=[0,0,0];var labelCount=[0,0,0];for(var d=0;d<3;++d){labelOffset[d]=data.length/VERTEX_SIZE|0;addItem(.5*(bounds[0][d]+bounds[1][d]),labels[d],labelFont);labelCount[d]=(data.length/VERTEX_SIZE|0)-labelOffset[d];tickOffset[d]=data.length/VERTEX_SIZE|0;for(var i=0;i<ticks[d].length;++i){if(!ticks[d][i].text){continue}addItem(ticks[d][i].x,ticks[d][i].text,tickFont)}tickCount[d]=(data.length/VERTEX_SIZE|0)-tickOffset[d]}this.buffer.update(data);this.tickOffset=tickOffset;this.tickCount=tickCount;this.labelOffset=labelOffset;this.labelCount=labelCount};var AXIS=[0,0,0];proto.drawTicks=function(d,scale,angle,offset,color){var v=AXIS;v[0]=v[1]=v[2]=0;v[d]=1;this.shader.uniforms.axis=v;this.shader.uniforms.color=color;this.shader.uniforms.angle=angle;this.shader.uniforms.scale=scale;this.shader.uniforms.offset=offset;this.vao.draw(this.gl.TRIANGLES,this.tickCount[d],this.tickOffset[d])};var ZERO=[0,0,0];proto.drawLabel=function(d,scale,angle,offset,color){this.shader.uniforms.axis=ZERO;this.shader.uniforms.color=color;this.shader.uniforms.angle=angle;this.shader.uniforms.scale=scale;this.shader.uniforms.offset=offset;this.vao.draw(this.gl.TRIANGLES,this.labelCount[d],this.labelOffset[d])};proto.dispose=function(){this.shader.dispose();this.vao.dispose();this.buffer.dispose()};function tryVectorizeText(text,options){try{return vectorizeText(text,options)}catch(e){console.warn("error vectorizing text:",e);return{cells:[],positions:[]}}}function createTextSprites(gl,bounds,labels,labelFont,ticks,tickFont){var buffer=createBuffer(gl);var vao=createVAO(gl,[{buffer:buffer,size:3}]);var shader=createShader(gl);shader.attributes.position.location=0;var result=new TextSprites(gl,shader,buffer,vao);result.update(bounds,labels,labelFont,ticks,tickFont);return result}}).call(this,require("_process"))},{_process:5,"gl-buffer":35,"gl-vao":50,glslify:169,"glslify/adapter.js":168,"vectorize-text":61}],31:[function(require,module,exports){"use strict";exports.create=defaultTicks;exports.equal=ticksEqual;function prettyPrint(spacing,i){var stepStr=spacing+"";var u=stepStr.indexOf(".");var sigFigs=0;if(u>=0){sigFigs=stepStr.length-u-1}var shift=Math.pow(10,sigFigs);var x=Math.round(spacing*i*shift);var xstr=x+"";if(xstr.indexOf("e")>=0){return xstr}var xi=x/shift,xf=x%shift;if(x<0){xi=-Math.ceil(xi)|0;xf=-xf|0}else{xi=Math.floor(xi)|0;xf=xf|0}var xis=""+xi;if(x<0){xis="-"+xis}if(sigFigs){var xs=""+xf;while(xs.length<sigFigs){xs="0"+xs}return xis+"."+xs}else{return xis}}function defaultTicks(bounds,tickSpacing){var array=[];for(var d=0;d<3;++d){var ticks=[];var m=.5*(bounds[0][d]+bounds[1][d]);for(var t=0;t*tickSpacing[d]<=bounds[1][d];++t){ticks.push({x:t*tickSpacing[d],text:prettyPrint(tickSpacing[d],t)})}for(var t=-1;t*tickSpacing[d]>=bounds[0][d];--t){ticks.push({x:t*tickSpacing[d],text:prettyPrint(tickSpacing[d],t)})}array.push(ticks)}return array}function ticksEqual(ticksA,ticksB){for(var i=0;i<3;++i){if(ticksA[i].length!==ticksB[i].length){return false}for(var j=0;j<ticksA[i].length;++j){var a=ticksA[i][j];var b=ticksB[i][j];if(a.x!==b.x||a.text!==b.text){return false}}}return true}},{}],32:[function(require,module,exports){arguments[4][13][0].apply(exports,arguments)},{dup:13}],33:[function(require,module,exports){arguments[4][14][0].apply(exports,arguments)},{dup:14}],34:[function(require,module,exports){"use strict";module.exports=extractPlanes;function extractPlanes(M,zNear,zFar){var z=zNear||0;var zf=zFar||1;return[[M[12]+M[0],M[13]+M[1],M[14]+M[2],M[15]+M[3]],[M[12]-M[0],M[13]-M[1],M[14]-M[2],M[15]-M[3]],[M[12]+M[4],M[13]+M[5],M[14]+M[6],M[15]+M[7]],[M[12]-M[4],M[13]-M[5],M[14]-M[6],M[15]-M[7]],[z*M[12]+M[8],z*M[13]+M[9],z*M[14]+M[10],z*M[15]+M[11]],[zf*M[12]-M[8],zf*M[13]-M[9],zf*M[14]-M[10],zf*M[15]-M[11]]]}},{}],35:[function(require,module,exports){arguments[4][7][0].apply(exports,arguments)},{dup:7,ndarray:178,"ndarray-ops":36,"typedarray-pool":41,webglew:43}],36:[function(require,module,exports){arguments[4][8][0].apply(exports,arguments)},{"cwise-compiler":37,dup:8}],37:[function(require,module,exports){arguments[4][9][0].apply(exports,arguments)},{"./lib/thunk.js":39,dup:9}],38:[function(require,module,exports){arguments[4][10][0].apply(exports,arguments)},{dup:10,uniq:40}],39:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{"./compile.js":38,dup:11}],40:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments)},{dup:12}],41:[function(require,module,exports){(function(global,Buffer){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0]),UINT8C:dup([32,0]),BUFFER:dup([32,0])}}var hasUint8C=typeof Uint8ClampedArray!=="undefined";var POOL=global.__TYPEDARRAY_POOL;if(!POOL.UINT8C){POOL.UINT8C=dup([32,0])}if(!POOL.BUFFER){POOL.BUFFER=dup([32,0])}var DATA=POOL.DATA,BUFFER=POOL.BUFFER;exports.free=function free(array){if(Buffer.isBuffer(array)){BUFFER[bits.log2(array.length)].push(array)}else{if(Object.prototype.toString.call(array)!=="[object ArrayBuffer]"){array=array.buffer}if(!array){return}var n=array.length||array.byteLength;var log_n=bits.log2(n)|0;DATA[log_n].push(array)}};function freeArrayBuffer(buffer){if(!buffer){return}var n=buffer.length||buffer.byteLength;var log_n=bits.log2(n);DATA[log_n].push(buffer)}function freeTypedArray(array){freeArrayBuffer(array.buffer)}exports.freeUint8=exports.freeUint16=exports.freeUint32=exports.freeInt8=exports.freeInt16=exports.freeInt32=exports.freeFloat32=exports.freeFloat=exports.freeFloat64=exports.freeDouble=exports.freeUint8Clamped=exports.freeDataView=freeTypedArray;exports.freeArrayBuffer=freeArrayBuffer;exports.freeBuffer=function freeBuffer(array){BUFFER[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){if(dtype===undefined||dtype==="arraybuffer"){return mallocArrayBuffer(n)}else{switch(dtype){case"uint8":return mallocUint8(n);case"uint16":return mallocUint16(n);case"uint32":return mallocUint32(n);case"int8":return mallocInt8(n);case"int16":return mallocInt16(n);case"int32":return mallocInt32(n);case"float":case"float32":return mallocFloat(n);case"double":case"float64":return mallocDouble(n);case"uint8_clamped":return mallocUint8Clamped(n);case"buffer":return mallocBuffer(n);case"data":case"dataview":return mallocDataView(n);default:return null}}return null};function mallocArrayBuffer(n){var n=bits.nextPow2(n);var log_n=bits.log2(n);var d=DATA[log_n];if(d.length>0){return d.pop()}return new ArrayBuffer(n)}exports.mallocArrayBuffer=mallocArrayBuffer;function mallocUint8(n){return new Uint8Array(mallocArrayBuffer(n),0,n)}exports.mallocUint8=mallocUint8;function mallocUint16(n){return new Uint16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocUint16=mallocUint16;function mallocUint32(n){return new Uint32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocUint32=mallocUint32;function mallocInt8(n){return new Int8Array(mallocArrayBuffer(n),0,n)}exports.mallocInt8=mallocInt8;function mallocInt16(n){return new Int16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocInt16=mallocInt16;function mallocInt32(n){return new Int32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocInt32=mallocInt32;function mallocFloat(n){return new Float32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocFloat32=exports.mallocFloat=mallocFloat;function mallocDouble(n){return new Float64Array(mallocArrayBuffer(8*n),0,n)}exports.mallocFloat64=exports.mallocDouble=mallocDouble;function mallocUint8Clamped(n){if(hasUint8C){return new Uint8ClampedArray(mallocArrayBuffer(n),0,n)}else{return mallocUint8(n)}}exports.mallocUint8Clamped=mallocUint8Clamped;function mallocDataView(n){return new DataView(mallocArrayBuffer(n),0,n)}exports.mallocDataView=mallocDataView;function mallocBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=BUFFER[log_n];if(cache.length>0){return cache.pop()}return new Buffer(n)}exports.mallocBuffer=mallocBuffer;exports.clearCache=function clearCache(){for(var i=0;i<32;++i){POOL.UINT8[i].length=0;POOL.UINT16[i].length=0;POOL.UINT32[i].length=0;POOL.INT8[i].length=0;POOL.INT16[i].length=0;POOL.INT32[i].length=0;POOL.FLOAT[i].length=0;POOL.DOUBLE[i].length=0;POOL.UINT8C[i].length=0;DATA[i].length=0;BUFFER[i].length=0}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"bit-twiddle":32,buffer:1,dup:33}],42:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{dup:16}],43:[function(require,module,exports){arguments[4][17][0].apply(exports,arguments)},{dup:17,"weak-map":42}],44:[function(require,module,exports){(function(){"use strict";var shim={};if(typeof exports==="undefined"){if(typeof define=="function"&&typeof define.amd=="object"&&define.amd){shim.exports={};define(function(){return shim.exports})}else{shim.exports=window}}else{shim.exports=exports}(function(exports){if(!GLMAT_EPSILON){var GLMAT_EPSILON=1e-6}if(!GLMAT_ARRAY_TYPE){var GLMAT_ARRAY_TYPE=typeof Float32Array!=="undefined"?Float32Array:Array}var glMatrix={};glMatrix.setMatrixArrayType=function(type){GLMAT_ARRAY_TYPE=type};if(typeof exports!=="undefined"){exports.glMatrix=glMatrix}var vec2={};vec2.create=function(){var out=new GLMAT_ARRAY_TYPE(2);out[0]=0;out[1]=0;return out};vec2.clone=function(a){var out=new GLMAT_ARRAY_TYPE(2);out[0]=a[0];out[1]=a[1];return out};vec2.fromValues=function(x,y){var out=new GLMAT_ARRAY_TYPE(2);out[0]=x;out[1]=y;return out};vec2.copy=function(out,a){out[0]=a[0];out[1]=a[1];return out};vec2.set=function(out,x,y){out[0]=x;out[1]=y;return out};vec2.add=function(out,a,b){out[0]=a[0]+b[0];out[1]=a[1]+b[1];return out};vec2.subtract=function(out,a,b){out[0]=a[0]-b[0];out[1]=a[1]-b[1];return out};vec2.sub=vec2.subtract;vec2.multiply=function(out,a,b){out[0]=a[0]*b[0];out[1]=a[1]*b[1];return out};vec2.mul=vec2.multiply;vec2.divide=function(out,a,b){out[0]=a[0]/b[0];out[1]=a[1]/b[1];return out};vec2.div=vec2.divide;vec2.min=function(out,a,b){out[0]=Math.min(a[0],b[0]);out[1]=Math.min(a[1],b[1]);return out};vec2.max=function(out,a,b){out[0]=Math.max(a[0],b[0]);out[1]=Math.max(a[1],b[1]);return out};vec2.scale=function(out,a,b){out[0]=a[0]*b;out[1]=a[1]*b;return out};vec2.distance=function(a,b){var x=b[0]-a[0],y=b[1]-a[1];return Math.sqrt(x*x+y*y)};vec2.dist=vec2.distance;vec2.squaredDistance=function(a,b){var x=b[0]-a[0],y=b[1]-a[1];return x*x+y*y};vec2.sqrDist=vec2.squaredDistance;vec2.length=function(a){var x=a[0],y=a[1];return Math.sqrt(x*x+y*y)};vec2.len=vec2.length;vec2.squaredLength=function(a){var x=a[0],y=a[1];return x*x+y*y};vec2.sqrLen=vec2.squaredLength;vec2.negate=function(out,a){out[0]=-a[0];out[1]=-a[1];return out};vec2.normalize=function(out,a){var x=a[0],y=a[1];var len=x*x+y*y;if(len>0){len=1/Math.sqrt(len);out[0]=a[0]*len;out[1]=a[1]*len}return out};vec2.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]};vec2.cross=function(out,a,b){var z=a[0]*b[1]-a[1]*b[0];out[0]=out[1]=0;out[2]=z;return out};vec2.lerp=function(out,a,b,t){var ax=a[0],ay=a[1];out[0]=ax+t*(b[0]-ax);out[1]=ay+t*(b[1]-ay);return out};vec2.transformMat2=function(out,a,m){var x=a[0],y=a[1];out[0]=m[0]*x+m[2]*y;out[1]=m[1]*x+m[3]*y;return out};vec2.transformMat2d=function(out,a,m){var x=a[0],y=a[1];out[0]=m[0]*x+m[2]*y+m[4];out[1]=m[1]*x+m[3]*y+m[5];return out};vec2.transformMat3=function(out,a,m){var x=a[0],y=a[1];out[0]=m[0]*x+m[3]*y+m[6];out[1]=m[1]*x+m[4]*y+m[7];return out};vec2.transformMat4=function(out,a,m){var x=a[0],y=a[1];out[0]=m[0]*x+m[4]*y+m[12];out[1]=m[1]*x+m[5]*y+m[13];return out};vec2.forEach=function(){var vec=vec2.create();return function(a,stride,offset,count,fn,arg){var i,l;if(!stride){stride=2}if(!offset){offset=0}if(count){l=Math.min(count*stride+offset,a.length)}else{l=a.length}for(i=offset;i<l;i+=stride){vec[0]=a[i];vec[1]=a[i+1];fn(vec,vec,arg);a[i]=vec[0];a[i+1]=vec[1]}return a}}();vec2.str=function(a){return"vec2("+a[0]+", "+a[1]+")"};if(typeof exports!=="undefined"){exports.vec2=vec2}var vec3={};vec3.create=function(){var out=new GLMAT_ARRAY_TYPE(3);out[0]=0;out[1]=0;out[2]=0;return out};vec3.clone=function(a){var out=new GLMAT_ARRAY_TYPE(3);out[0]=a[0];out[1]=a[1];out[2]=a[2];return out};vec3.fromValues=function(x,y,z){var out=new GLMAT_ARRAY_TYPE(3);out[0]=x;out[1]=y;out[2]=z;return out};vec3.copy=function(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];return out};vec3.set=function(out,x,y,z){out[0]=x;out[1]=y;out[2]=z;return out};vec3.add=function(out,a,b){out[0]=a[0]+b[0];out[1]=a[1]+b[1];out[2]=a[2]+b[2];return out};vec3.subtract=function(out,a,b){out[0]=a[0]-b[0];out[1]=a[1]-b[1];out[2]=a[2]-b[2];return out};vec3.sub=vec3.subtract;vec3.multiply=function(out,a,b){out[0]=a[0]*b[0];out[1]=a[1]*b[1];out[2]=a[2]*b[2];return out};vec3.mul=vec3.multiply;vec3.divide=function(out,a,b){out[0]=a[0]/b[0];out[1]=a[1]/b[1];out[2]=a[2]/b[2];return out};vec3.div=vec3.divide;vec3.min=function(out,a,b){out[0]=Math.min(a[0],b[0]);out[1]=Math.min(a[1],b[1]);out[2]=Math.min(a[2],b[2]);return out};vec3.max=function(out,a,b){out[0]=Math.max(a[0],b[0]);out[1]=Math.max(a[1],b[1]);out[2]=Math.max(a[2],b[2]);return out};vec3.scale=function(out,a,b){out[0]=a[0]*b;out[1]=a[1]*b;out[2]=a[2]*b;return out};vec3.distance=function(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2];return Math.sqrt(x*x+y*y+z*z)};vec3.dist=vec3.distance;vec3.squaredDistance=function(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2];return x*x+y*y+z*z};vec3.sqrDist=vec3.squaredDistance;vec3.length=function(a){var x=a[0],y=a[1],z=a[2];return Math.sqrt(x*x+y*y+z*z)};vec3.len=vec3.length;vec3.squaredLength=function(a){var x=a[0],y=a[1],z=a[2];return x*x+y*y+z*z};vec3.sqrLen=vec3.squaredLength;vec3.negate=function(out,a){out[0]=-a[0];out[1]=-a[1];out[2]=-a[2];return out};vec3.normalize=function(out,a){var x=a[0],y=a[1],z=a[2];var len=x*x+y*y+z*z;if(len>0){len=1/Math.sqrt(len);out[0]=a[0]*len;out[1]=a[1]*len;out[2]=a[2]*len}return out};vec3.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]};vec3.cross=function(out,a,b){var ax=a[0],ay=a[1],az=a[2],bx=b[0],by=b[1],bz=b[2];out[0]=ay*bz-az*by;out[1]=az*bx-ax*bz;out[2]=ax*by-ay*bx;return out};vec3.lerp=function(out,a,b,t){var ax=a[0],ay=a[1],az=a[2];out[0]=ax+t*(b[0]-ax);out[1]=ay+t*(b[1]-ay);out[2]=az+t*(b[2]-az);return out};vec3.transformMat4=function(out,a,m){var x=a[0],y=a[1],z=a[2];out[0]=m[0]*x+m[4]*y+m[8]*z+m[12];out[1]=m[1]*x+m[5]*y+m[9]*z+m[13];out[2]=m[2]*x+m[6]*y+m[10]*z+m[14];return out};vec3.transformQuat=function(out,a,q){var x=a[0],y=a[1],z=a[2],qx=q[0],qy=q[1],qz=q[2],qw=q[3],ix=qw*x+qy*z-qz*y,iy=qw*y+qz*x-qx*z,iz=qw*z+qx*y-qy*x,iw=-qx*x-qy*y-qz*z;out[0]=ix*qw+iw*-qx+iy*-qz-iz*-qy;out[1]=iy*qw+iw*-qy+iz*-qx-ix*-qz;out[2]=iz*qw+iw*-qz+ix*-qy-iy*-qx;return out};vec3.forEach=function(){var vec=vec3.create();return function(a,stride,offset,count,fn,arg){var i,l;if(!stride){stride=3}if(!offset){offset=0}if(count){l=Math.min(count*stride+offset,a.length)}else{l=a.length}for(i=offset;i<l;i+=stride){vec[0]=a[i];vec[1]=a[i+1];vec[2]=a[i+2];fn(vec,vec,arg);a[i]=vec[0];a[i+1]=vec[1];a[i+2]=vec[2]}return a}}();vec3.str=function(a){return"vec3("+a[0]+", "+a[1]+", "+a[2]+")"};if(typeof exports!=="undefined"){exports.vec3=vec3}var vec4={};vec4.create=function(){var out=new GLMAT_ARRAY_TYPE(4);out[0]=0;out[1]=0;out[2]=0;out[3]=0;return out};vec4.clone=function(a){var out=new GLMAT_ARRAY_TYPE(4);out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];return out};vec4.fromValues=function(x,y,z,w){var out=new GLMAT_ARRAY_TYPE(4);out[0]=x;out[1]=y;out[2]=z;out[3]=w;return out};vec4.copy=function(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];return out};vec4.set=function(out,x,y,z,w){out[0]=x;out[1]=y;out[2]=z;out[3]=w;return out};vec4.add=function(out,a,b){out[0]=a[0]+b[0];out[1]=a[1]+b[1];out[2]=a[2]+b[2];out[3]=a[3]+b[3];return out};vec4.subtract=function(out,a,b){out[0]=a[0]-b[0];out[1]=a[1]-b[1];out[2]=a[2]-b[2];out[3]=a[3]-b[3];return out};vec4.sub=vec4.subtract;vec4.multiply=function(out,a,b){out[0]=a[0]*b[0];out[1]=a[1]*b[1];out[2]=a[2]*b[2];out[3]=a[3]*b[3];return out};vec4.mul=vec4.multiply;vec4.divide=function(out,a,b){out[0]=a[0]/b[0];out[1]=a[1]/b[1];out[2]=a[2]/b[2];out[3]=a[3]/b[3];return out};vec4.div=vec4.divide;vec4.min=function(out,a,b){out[0]=Math.min(a[0],b[0]);out[1]=Math.min(a[1],b[1]);out[2]=Math.min(a[2],b[2]);out[3]=Math.min(a[3],b[3]);return out};vec4.max=function(out,a,b){out[0]=Math.max(a[0],b[0]);out[1]=Math.max(a[1],b[1]);out[2]=Math.max(a[2],b[2]);out[3]=Math.max(a[3],b[3]);return out};vec4.scale=function(out,a,b){out[0]=a[0]*b;out[1]=a[1]*b;out[2]=a[2]*b;out[3]=a[3]*b;return out};vec4.distance=function(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2],w=b[3]-a[3];return Math.sqrt(x*x+y*y+z*z+w*w)};vec4.dist=vec4.distance;vec4.squaredDistance=function(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2],w=b[3]-a[3];return x*x+y*y+z*z+w*w};vec4.sqrDist=vec4.squaredDistance;vec4.length=function(a){var x=a[0],y=a[1],z=a[2],w=a[3];return Math.sqrt(x*x+y*y+z*z+w*w)};vec4.len=vec4.length;vec4.squaredLength=function(a){var x=a[0],y=a[1],z=a[2],w=a[3];return x*x+y*y+z*z+w*w};vec4.sqrLen=vec4.squaredLength;vec4.negate=function(out,a){out[0]=-a[0];out[1]=-a[1];out[2]=-a[2];out[3]=-a[3];return out};vec4.normalize=function(out,a){var x=a[0],y=a[1],z=a[2],w=a[3];var len=x*x+y*y+z*z+w*w;if(len>0){len=1/Math.sqrt(len);out[0]=a[0]*len;out[1]=a[1]*len;out[2]=a[2]*len;out[3]=a[3]*len}return out};vec4.dot=function(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]};vec4.lerp=function(out,a,b,t){var ax=a[0],ay=a[1],az=a[2],aw=a[3];out[0]=ax+t*(b[0]-ax);out[1]=ay+t*(b[1]-ay);out[2]=az+t*(b[2]-az);out[3]=aw+t*(b[3]-aw);return out};vec4.transformMat4=function(out,a,m){var x=a[0],y=a[1],z=a[2],w=a[3];out[0]=m[0]*x+m[4]*y+m[8]*z+m[12]*w;out[1]=m[1]*x+m[5]*y+m[9]*z+m[13]*w;out[2]=m[2]*x+m[6]*y+m[10]*z+m[14]*w;out[3]=m[3]*x+m[7]*y+m[11]*z+m[15]*w;return out};vec4.transformQuat=function(out,a,q){var x=a[0],y=a[1],z=a[2],qx=q[0],qy=q[1],qz=q[2],qw=q[3],ix=qw*x+qy*z-qz*y,iy=qw*y+qz*x-qx*z,iz=qw*z+qx*y-qy*x,iw=-qx*x-qy*y-qz*z;out[0]=ix*qw+iw*-qx+iy*-qz-iz*-qy;out[1]=iy*qw+iw*-qy+iz*-qx-ix*-qz;out[2]=iz*qw+iw*-qz+ix*-qy-iy*-qx;return out};vec4.forEach=function(){var vec=vec4.create();return function(a,stride,offset,count,fn,arg){var i,l;if(!stride){stride=4}if(!offset){offset=0}if(count){l=Math.min(count*stride+offset,a.length)}else{l=a.length}for(i=offset;i<l;i+=stride){vec[0]=a[i];vec[1]=a[i+1];vec[2]=a[i+2];vec[3]=a[i+3];fn(vec,vec,arg);a[i]=vec[0];a[i+1]=vec[1];a[i+2]=vec[2];a[i+3]=vec[3]}return a}}();vec4.str=function(a){return"vec4("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"};if(typeof exports!=="undefined"){exports.vec4=vec4}var mat2={};var mat2Identity=new Float32Array([1,0,0,1]);mat2.create=function(){var out=new GLMAT_ARRAY_TYPE(4);out[0]=1;out[1]=0;out[2]=0;out[3]=1;return out};mat2.clone=function(a){var out=new GLMAT_ARRAY_TYPE(4);out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];return out};mat2.copy=function(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];return out};mat2.identity=function(out){out[0]=1;out[1]=0;out[2]=0;out[3]=1;return out};mat2.transpose=function(out,a){if(out===a){var a1=a[1];out[1]=a[2];out[2]=a1}else{out[0]=a[0];out[1]=a[2];out[2]=a[1];out[3]=a[3]}return out};mat2.invert=function(out,a){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],det=a0*a3-a2*a1;if(!det){return null}det=1/det;out[0]=a3*det;out[1]=-a1*det;out[2]=-a2*det;out[3]=a0*det;return out};mat2.adjoint=function(out,a){var a0=a[0];out[0]=a[3];out[1]=-a[1];out[2]=-a[2];out[3]=a0;return out};mat2.determinant=function(a){return a[0]*a[3]-a[2]*a[1]};mat2.multiply=function(out,a,b){var a0=a[0],a1=a[1],a2=a[2],a3=a[3];var b0=b[0],b1=b[1],b2=b[2],b3=b[3];out[0]=a0*b0+a1*b2;out[1]=a0*b1+a1*b3;out[2]=a2*b0+a3*b2;out[3]=a2*b1+a3*b3;return out};mat2.mul=mat2.multiply;mat2.rotate=function(out,a,rad){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],s=Math.sin(rad),c=Math.cos(rad);out[0]=a0*c+a1*s;out[1]=a0*-s+a1*c;out[2]=a2*c+a3*s;out[3]=a2*-s+a3*c;return out};mat2.scale=function(out,a,v){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],v0=v[0],v1=v[1];out[0]=a0*v0;out[1]=a1*v1;out[2]=a2*v0;out[3]=a3*v1;return out};mat2.str=function(a){return"mat2("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"};if(typeof exports!=="undefined"){exports.mat2=mat2}var mat2d={};var mat2dIdentity=new Float32Array([1,0,0,1,0,0]);mat2d.create=function(){var out=new GLMAT_ARRAY_TYPE(6);out[0]=1;out[1]=0;out[2]=0;out[3]=1;out[4]=0;out[5]=0;return out};mat2d.clone=function(a){var out=new GLMAT_ARRAY_TYPE(6);out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];out[4]=a[4];out[5]=a[5];return out};mat2d.copy=function(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];out[4]=a[4];out[5]=a[5];return out};mat2d.identity=function(out){out[0]=1;out[1]=0;out[2]=0;out[3]=1;out[4]=0;out[5]=0;return out};mat2d.invert=function(out,a){var aa=a[0],ab=a[1],ac=a[2],ad=a[3],atx=a[4],aty=a[5];var det=aa*ad-ab*ac;if(!det){return null}det=1/det;out[0]=ad*det;out[1]=-ab*det;out[2]=-ac*det;out[3]=aa*det;out[4]=(ac*aty-ad*atx)*det;out[5]=(ab*atx-aa*aty)*det;return out};mat2d.determinant=function(a){return a[0]*a[3]-a[1]*a[2]};mat2d.multiply=function(out,a,b){var aa=a[0],ab=a[1],ac=a[2],ad=a[3],atx=a[4],aty=a[5],ba=b[0],bb=b[1],bc=b[2],bd=b[3],btx=b[4],bty=b[5];out[0]=aa*ba+ab*bc;out[1]=aa*bb+ab*bd;out[2]=ac*ba+ad*bc;out[3]=ac*bb+ad*bd;out[4]=ba*atx+bc*aty+btx;out[5]=bb*atx+bd*aty+bty;return out};mat2d.mul=mat2d.multiply;mat2d.rotate=function(out,a,rad){var aa=a[0],ab=a[1],ac=a[2],ad=a[3],atx=a[4],aty=a[5],st=Math.sin(rad),ct=Math.cos(rad);out[0]=aa*ct+ab*st;out[1]=-aa*st+ab*ct;out[2]=ac*ct+ad*st;out[3]=-ac*st+ct*ad;out[4]=ct*atx+st*aty;out[5]=ct*aty-st*atx;return out};mat2d.scale=function(out,a,v){var vx=v[0],vy=v[1];out[0]=a[0]*vx;out[1]=a[1]*vy;out[2]=a[2]*vx;out[3]=a[3]*vy;out[4]=a[4]*vx;out[5]=a[5]*vy;return out};mat2d.translate=function(out,a,v){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];out[4]=a[4]+v[0];out[5]=a[5]+v[1];return out};mat2d.str=function(a){return"mat2d("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+")"};if(typeof exports!=="undefined"){exports.mat2d=mat2d}var mat3={};var mat3Identity=new Float32Array([1,0,0,0,1,0,0,0,1]);mat3.create=function(){var out=new GLMAT_ARRAY_TYPE(9);out[0]=1;out[1]=0;out[2]=0;out[3]=0;out[4]=1;out[5]=0;out[6]=0;out[7]=0;out[8]=1;return out};mat3.clone=function(a){var out=new GLMAT_ARRAY_TYPE(9);out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];out[4]=a[4];out[5]=a[5];out[6]=a[6];out[7]=a[7];out[8]=a[8];return out};mat3.copy=function(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];out[4]=a[4];out[5]=a[5];out[6]=a[6];out[7]=a[7];out[8]=a[8];return out};mat3.identity=function(out){out[0]=1;out[1]=0;out[2]=0;out[3]=0;out[4]=1;out[5]=0;out[6]=0;out[7]=0;out[8]=1;return out};mat3.transpose=function(out,a){if(out===a){var a01=a[1],a02=a[2],a12=a[5];out[1]=a[3];out[2]=a[6];out[3]=a01;out[5]=a[7];out[6]=a02;out[7]=a12}else{out[0]=a[0];out[1]=a[3];out[2]=a[6];out[3]=a[1];out[4]=a[4];out[5]=a[7];out[6]=a[2];out[7]=a[5];out[8]=a[8]}return out};mat3.invert=function(out,a){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8],b01=a22*a11-a12*a21,b11=-a22*a10+a12*a20,b21=a21*a10-a11*a20,det=a00*b01+a01*b11+a02*b21;if(!det){return null}det=1/det;out[0]=b01*det;out[1]=(-a22*a01+a02*a21)*det;out[2]=(a12*a01-a02*a11)*det;out[3]=b11*det;out[4]=(a22*a00-a02*a20)*det;out[5]=(-a12*a00+a02*a10)*det;out[6]=b21*det;out[7]=(-a21*a00+a01*a20)*det;out[8]=(a11*a00-a01*a10)*det;return out};mat3.adjoint=function(out,a){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8];out[0]=a11*a22-a12*a21;out[1]=a02*a21-a01*a22;out[2]=a01*a12-a02*a11;out[3]=a12*a20-a10*a22;out[4]=a00*a22-a02*a20;out[5]=a02*a10-a00*a12;out[6]=a10*a21-a11*a20;out[7]=a01*a20-a00*a21;out[8]=a00*a11-a01*a10;return out};mat3.determinant=function(a){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8];return a00*(a22*a11-a12*a21)+a01*(-a22*a10+a12*a20)+a02*(a21*a10-a11*a20)};mat3.multiply=function(out,a,b){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8],b00=b[0],b01=b[1],b02=b[2],b10=b[3],b11=b[4],b12=b[5],b20=b[6],b21=b[7],b22=b[8];out[0]=b00*a00+b01*a10+b02*a20;out[1]=b00*a01+b01*a11+b02*a21;out[2]=b00*a02+b01*a12+b02*a22;out[3]=b10*a00+b11*a10+b12*a20;out[4]=b10*a01+b11*a11+b12*a21;out[5]=b10*a02+b11*a12+b12*a22;out[6]=b20*a00+b21*a10+b22*a20;out[7]=b20*a01+b21*a11+b22*a21;out[8]=b20*a02+b21*a12+b22*a22;return out};mat3.mul=mat3.multiply;mat3.translate=function(out,a,v){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8],x=v[0],y=v[1];out[0]=a00;out[1]=a01;out[2]=a02;out[3]=a10;out[4]=a11;out[5]=a12;out[6]=x*a00+y*a10+a20;out[7]=x*a01+y*a11+a21;out[8]=x*a02+y*a12+a22;return out};mat3.rotate=function(out,a,rad){var a00=a[0],a01=a[1],a02=a[2],a10=a[3],a11=a[4],a12=a[5],a20=a[6],a21=a[7],a22=a[8],s=Math.sin(rad),c=Math.cos(rad);out[0]=c*a00+s*a10;out[1]=c*a01+s*a11;out[2]=c*a02+s*a12;out[3]=c*a10-s*a00;out[4]=c*a11-s*a01;out[5]=c*a12-s*a02;out[6]=a20;out[7]=a21;out[8]=a22;return out};mat3.scale=function(out,a,v){var x=v[0],y=v[2];out[0]=x*a[0];out[1]=x*a[1];out[2]=x*a[2];out[3]=y*a[3];out[4]=y*a[4];out[5]=y*a[5];out[6]=a[6];out[7]=a[7];out[8]=a[8];return out};mat3.fromMat2d=function(out,a){out[0]=a[0];out[1]=a[1];out[2]=0;out[3]=a[2];out[4]=a[3];out[5]=0;out[6]=a[4];out[7]=a[5];out[8]=1;return out};mat3.fromQuat=function(out,q){var x=q[0],y=q[1],z=q[2],w=q[3],x2=x+x,y2=y+y,z2=z+z,xx=x*x2,xy=x*y2,xz=x*z2,yy=y*y2,yz=y*z2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2;out[0]=1-(yy+zz);out[1]=xy+wz;out[2]=xz-wy;out[3]=xy-wz;out[4]=1-(xx+zz);out[5]=yz+wx;out[6]=xz+wy;out[7]=yz-wx;out[8]=1-(xx+yy);return out};mat3.str=function(a){return"mat3("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+", "+a[4]+", "+a[5]+", "+a[6]+", "+a[7]+", "+a[8]+")"};if(typeof exports!=="undefined"){exports.mat3=mat3}var mat4={};var mat4Identity=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);mat4.create=function(){var out=new GLMAT_ARRAY_TYPE(16);out[0]=1;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=1;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[10]=1;out[11]=0;out[12]=0;out[13]=0;out[14]=0;out[15]=1;return out};mat4.clone=function(a){var out=new GLMAT_ARRAY_TYPE(16);out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];out[4]=a[4];out[5]=a[5];out[6]=a[6];out[7]=a[7];out[8]=a[8];out[9]=a[9];out[10]=a[10];out[11]=a[11];out[12]=a[12];out[13]=a[13];out[14]=a[14];out[15]=a[15];return out};mat4.copy=function(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];out[4]=a[4];out[5]=a[5];out[6]=a[6];out[7]=a[7];out[8]=a[8];out[9]=a[9];out[10]=a[10];out[11]=a[11];out[12]=a[12];out[13]=a[13];out[14]=a[14];out[15]=a[15];return out};mat4.identity=function(out){out[0]=1;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=1;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[10]=1;out[11]=0;out[12]=0; | |
out[13]=0;out[14]=0;out[15]=1;return out};mat4.transpose=function(out,a){if(out===a){var a01=a[1],a02=a[2],a03=a[3],a12=a[6],a13=a[7],a23=a[11];out[1]=a[4];out[2]=a[8];out[3]=a[12];out[4]=a01;out[6]=a[9];out[7]=a[13];out[8]=a02;out[9]=a12;out[11]=a[14];out[12]=a03;out[13]=a13;out[14]=a23}else{out[0]=a[0];out[1]=a[4];out[2]=a[8];out[3]=a[12];out[4]=a[1];out[5]=a[5];out[6]=a[9];out[7]=a[13];out[8]=a[2];out[9]=a[6];out[10]=a[10];out[11]=a[14];out[12]=a[3];out[13]=a[7];out[14]=a[11];out[15]=a[15]}return out};mat4.invert=function(out,a){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;if(!det){return null}det=1/det;out[0]=(a11*b11-a12*b10+a13*b09)*det;out[1]=(a02*b10-a01*b11-a03*b09)*det;out[2]=(a31*b05-a32*b04+a33*b03)*det;out[3]=(a22*b04-a21*b05-a23*b03)*det;out[4]=(a12*b08-a10*b11-a13*b07)*det;out[5]=(a00*b11-a02*b08+a03*b07)*det;out[6]=(a32*b02-a30*b05-a33*b01)*det;out[7]=(a20*b05-a22*b02+a23*b01)*det;out[8]=(a10*b10-a11*b08+a13*b06)*det;out[9]=(a01*b08-a00*b10-a03*b06)*det;out[10]=(a30*b04-a31*b02+a33*b00)*det;out[11]=(a21*b02-a20*b04-a23*b00)*det;out[12]=(a11*b07-a10*b09-a12*b06)*det;out[13]=(a00*b09-a01*b07+a02*b06)*det;out[14]=(a31*b01-a30*b03-a32*b00)*det;out[15]=(a20*b03-a21*b01+a22*b00)*det;return out};mat4.adjoint=function(out,a){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15];out[0]=a11*(a22*a33-a23*a32)-a21*(a12*a33-a13*a32)+a31*(a12*a23-a13*a22);out[1]=-(a01*(a22*a33-a23*a32)-a21*(a02*a33-a03*a32)+a31*(a02*a23-a03*a22));out[2]=a01*(a12*a33-a13*a32)-a11*(a02*a33-a03*a32)+a31*(a02*a13-a03*a12);out[3]=-(a01*(a12*a23-a13*a22)-a11*(a02*a23-a03*a22)+a21*(a02*a13-a03*a12));out[4]=-(a10*(a22*a33-a23*a32)-a20*(a12*a33-a13*a32)+a30*(a12*a23-a13*a22));out[5]=a00*(a22*a33-a23*a32)-a20*(a02*a33-a03*a32)+a30*(a02*a23-a03*a22);out[6]=-(a00*(a12*a33-a13*a32)-a10*(a02*a33-a03*a32)+a30*(a02*a13-a03*a12));out[7]=a00*(a12*a23-a13*a22)-a10*(a02*a23-a03*a22)+a20*(a02*a13-a03*a12);out[8]=a10*(a21*a33-a23*a31)-a20*(a11*a33-a13*a31)+a30*(a11*a23-a13*a21);out[9]=-(a00*(a21*a33-a23*a31)-a20*(a01*a33-a03*a31)+a30*(a01*a23-a03*a21));out[10]=a00*(a11*a33-a13*a31)-a10*(a01*a33-a03*a31)+a30*(a01*a13-a03*a11);out[11]=-(a00*(a11*a23-a13*a21)-a10*(a01*a23-a03*a21)+a20*(a01*a13-a03*a11));out[12]=-(a10*(a21*a32-a22*a31)-a20*(a11*a32-a12*a31)+a30*(a11*a22-a12*a21));out[13]=a00*(a21*a32-a22*a31)-a20*(a01*a32-a02*a31)+a30*(a01*a22-a02*a21);out[14]=-(a00*(a11*a32-a12*a31)-a10*(a01*a32-a02*a31)+a30*(a01*a12-a02*a11));out[15]=a00*(a11*a22-a12*a21)-a10*(a01*a22-a02*a21)+a20*(a01*a12-a02*a11);return out};mat4.determinant=function(a){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32;return b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06};mat4.multiply=function(out,a,b){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15];var b0=b[0],b1=b[1],b2=b[2],b3=b[3];out[0]=b0*a00+b1*a10+b2*a20+b3*a30;out[1]=b0*a01+b1*a11+b2*a21+b3*a31;out[2]=b0*a02+b1*a12+b2*a22+b3*a32;out[3]=b0*a03+b1*a13+b2*a23+b3*a33;b0=b[4];b1=b[5];b2=b[6];b3=b[7];out[4]=b0*a00+b1*a10+b2*a20+b3*a30;out[5]=b0*a01+b1*a11+b2*a21+b3*a31;out[6]=b0*a02+b1*a12+b2*a22+b3*a32;out[7]=b0*a03+b1*a13+b2*a23+b3*a33;b0=b[8];b1=b[9];b2=b[10];b3=b[11];out[8]=b0*a00+b1*a10+b2*a20+b3*a30;out[9]=b0*a01+b1*a11+b2*a21+b3*a31;out[10]=b0*a02+b1*a12+b2*a22+b3*a32;out[11]=b0*a03+b1*a13+b2*a23+b3*a33;b0=b[12];b1=b[13];b2=b[14];b3=b[15];out[12]=b0*a00+b1*a10+b2*a20+b3*a30;out[13]=b0*a01+b1*a11+b2*a21+b3*a31;out[14]=b0*a02+b1*a12+b2*a22+b3*a32;out[15]=b0*a03+b1*a13+b2*a23+b3*a33;return out};mat4.mul=mat4.multiply;mat4.translate=function(out,a,v){var x=v[0],y=v[1],z=v[2],a00,a01,a02,a03,a10,a11,a12,a13,a20,a21,a22,a23;if(a===out){out[12]=a[0]*x+a[4]*y+a[8]*z+a[12];out[13]=a[1]*x+a[5]*y+a[9]*z+a[13];out[14]=a[2]*x+a[6]*y+a[10]*z+a[14];out[15]=a[3]*x+a[7]*y+a[11]*z+a[15]}else{a00=a[0];a01=a[1];a02=a[2];a03=a[3];a10=a[4];a11=a[5];a12=a[6];a13=a[7];a20=a[8];a21=a[9];a22=a[10];a23=a[11];out[0]=a00;out[1]=a01;out[2]=a02;out[3]=a03;out[4]=a10;out[5]=a11;out[6]=a12;out[7]=a13;out[8]=a20;out[9]=a21;out[10]=a22;out[11]=a23;out[12]=a00*x+a10*y+a20*z+a[12];out[13]=a01*x+a11*y+a21*z+a[13];out[14]=a02*x+a12*y+a22*z+a[14];out[15]=a03*x+a13*y+a23*z+a[15]}return out};mat4.scale=function(out,a,v){var x=v[0],y=v[1],z=v[2];out[0]=a[0]*x;out[1]=a[1]*x;out[2]=a[2]*x;out[3]=a[3]*x;out[4]=a[4]*y;out[5]=a[5]*y;out[6]=a[6]*y;out[7]=a[7]*y;out[8]=a[8]*z;out[9]=a[9]*z;out[10]=a[10]*z;out[11]=a[11]*z;out[12]=a[12];out[13]=a[13];out[14]=a[14];out[15]=a[15];return out};mat4.rotate=function(out,a,rad,axis){var x=axis[0],y=axis[1],z=axis[2],len=Math.sqrt(x*x+y*y+z*z),s,c,t,a00,a01,a02,a03,a10,a11,a12,a13,a20,a21,a22,a23,b00,b01,b02,b10,b11,b12,b20,b21,b22;if(Math.abs(len)<GLMAT_EPSILON){return null}len=1/len;x*=len;y*=len;z*=len;s=Math.sin(rad);c=Math.cos(rad);t=1-c;a00=a[0];a01=a[1];a02=a[2];a03=a[3];a10=a[4];a11=a[5];a12=a[6];a13=a[7];a20=a[8];a21=a[9];a22=a[10];a23=a[11];b00=x*x*t+c;b01=y*x*t+z*s;b02=z*x*t-y*s;b10=x*y*t-z*s;b11=y*y*t+c;b12=z*y*t+x*s;b20=x*z*t+y*s;b21=y*z*t-x*s;b22=z*z*t+c;out[0]=a00*b00+a10*b01+a20*b02;out[1]=a01*b00+a11*b01+a21*b02;out[2]=a02*b00+a12*b01+a22*b02;out[3]=a03*b00+a13*b01+a23*b02;out[4]=a00*b10+a10*b11+a20*b12;out[5]=a01*b10+a11*b11+a21*b12;out[6]=a02*b10+a12*b11+a22*b12;out[7]=a03*b10+a13*b11+a23*b12;out[8]=a00*b20+a10*b21+a20*b22;out[9]=a01*b20+a11*b21+a21*b22;out[10]=a02*b20+a12*b21+a22*b22;out[11]=a03*b20+a13*b21+a23*b22;if(a!==out){out[12]=a[12];out[13]=a[13];out[14]=a[14];out[15]=a[15]}return out};mat4.rotateX=function(out,a,rad){var s=Math.sin(rad),c=Math.cos(rad),a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11];if(a!==out){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];out[12]=a[12];out[13]=a[13];out[14]=a[14];out[15]=a[15]}out[4]=a10*c+a20*s;out[5]=a11*c+a21*s;out[6]=a12*c+a22*s;out[7]=a13*c+a23*s;out[8]=a20*c-a10*s;out[9]=a21*c-a11*s;out[10]=a22*c-a12*s;out[11]=a23*c-a13*s;return out};mat4.rotateY=function(out,a,rad){var s=Math.sin(rad),c=Math.cos(rad),a00=a[0],a01=a[1],a02=a[2],a03=a[3],a20=a[8],a21=a[9],a22=a[10],a23=a[11];if(a!==out){out[4]=a[4];out[5]=a[5];out[6]=a[6];out[7]=a[7];out[12]=a[12];out[13]=a[13];out[14]=a[14];out[15]=a[15]}out[0]=a00*c-a20*s;out[1]=a01*c-a21*s;out[2]=a02*c-a22*s;out[3]=a03*c-a23*s;out[8]=a00*s+a20*c;out[9]=a01*s+a21*c;out[10]=a02*s+a22*c;out[11]=a03*s+a23*c;return out};mat4.rotateZ=function(out,a,rad){var s=Math.sin(rad),c=Math.cos(rad),a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7];if(a!==out){out[8]=a[8];out[9]=a[9];out[10]=a[10];out[11]=a[11];out[12]=a[12];out[13]=a[13];out[14]=a[14];out[15]=a[15]}out[0]=a00*c+a10*s;out[1]=a01*c+a11*s;out[2]=a02*c+a12*s;out[3]=a03*c+a13*s;out[4]=a10*c-a00*s;out[5]=a11*c-a01*s;out[6]=a12*c-a02*s;out[7]=a13*c-a03*s;return out};mat4.fromRotationTranslation=function(out,q,v){var x=q[0],y=q[1],z=q[2],w=q[3],x2=x+x,y2=y+y,z2=z+z,xx=x*x2,xy=x*y2,xz=x*z2,yy=y*y2,yz=y*z2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2;out[0]=1-(yy+zz);out[1]=xy+wz;out[2]=xz-wy;out[3]=0;out[4]=xy-wz;out[5]=1-(xx+zz);out[6]=yz+wx;out[7]=0;out[8]=xz+wy;out[9]=yz-wx;out[10]=1-(xx+yy);out[11]=0;out[12]=v[0];out[13]=v[1];out[14]=v[2];out[15]=1;return out};mat4.fromQuat=function(out,q){var x=q[0],y=q[1],z=q[2],w=q[3],x2=x+x,y2=y+y,z2=z+z,xx=x*x2,xy=x*y2,xz=x*z2,yy=y*y2,yz=y*z2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2;out[0]=1-(yy+zz);out[1]=xy+wz;out[2]=xz-wy;out[3]=0;out[4]=xy-wz;out[5]=1-(xx+zz);out[6]=yz+wx;out[7]=0;out[8]=xz+wy;out[9]=yz-wx;out[10]=1-(xx+yy);out[11]=0;out[12]=0;out[13]=0;out[14]=0;out[15]=1;return out};mat4.frustum=function(out,left,right,bottom,top,near,far){var rl=1/(right-left),tb=1/(top-bottom),nf=1/(near-far);out[0]=near*2*rl;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=near*2*tb;out[6]=0;out[7]=0;out[8]=(right+left)*rl;out[9]=(top+bottom)*tb;out[10]=(far+near)*nf;out[11]=-1;out[12]=0;out[13]=0;out[14]=far*near*2*nf;out[15]=0;return out};mat4.perspective=function(out,fovy,aspect,near,far){var f=1/Math.tan(fovy/2),nf=1/(near-far);out[0]=f/aspect;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=f;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[10]=(far+near)*nf;out[11]=-1;out[12]=0;out[13]=0;out[14]=2*far*near*nf;out[15]=0;return out};mat4.ortho=function(out,left,right,bottom,top,near,far){var lr=1/(left-right),bt=1/(bottom-top),nf=1/(near-far);out[0]=-2*lr;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=-2*bt;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[10]=2*nf;out[11]=0;out[12]=(left+right)*lr;out[13]=(top+bottom)*bt;out[14]=(far+near)*nf;out[15]=1;return out};mat4.lookAt=function(out,eye,center,up){var x0,x1,x2,y0,y1,y2,z0,z1,z2,len,eyex=eye[0],eyey=eye[1],eyez=eye[2],upx=up[0],upy=up[1],upz=up[2],centerx=center[0],centery=center[1],centerz=center[2];if(Math.abs(eyex-centerx)<GLMAT_EPSILON&&Math.abs(eyey-centery)<GLMAT_EPSILON&&Math.abs(eyez-centerz)<GLMAT_EPSILON){return mat4.identity(out)}z0=eyex-centerx;z1=eyey-centery;z2=eyez-centerz;len=1/Math.sqrt(z0*z0+z1*z1+z2*z2);z0*=len;z1*=len;z2*=len;x0=upy*z2-upz*z1;x1=upz*z0-upx*z2;x2=upx*z1-upy*z0;len=Math.sqrt(x0*x0+x1*x1+x2*x2);if(!len){x0=0;x1=0;x2=0}else{len=1/len;x0*=len;x1*=len;x2*=len}y0=z1*x2-z2*x1;y1=z2*x0-z0*x2;y2=z0*x1-z1*x0;len=Math.sqrt(y0*y0+y1*y1+y2*y2);if(!len){y0=0;y1=0;y2=0}else{len=1/len;y0*=len;y1*=len;y2*=len}out[0]=x0;out[1]=y0;out[2]=z0;out[3]=0;out[4]=x1;out[5]=y1;out[6]=z1;out[7]=0;out[8]=x2;out[9]=y2;out[10]=z2;out[11]=0;out[12]=-(x0*eyex+x1*eyey+x2*eyez);out[13]=-(y0*eyex+y1*eyey+y2*eyez);out[14]=-(z0*eyex+z1*eyey+z2*eyez);out[15]=1;return out};mat4.str=function(a){return"mat4("+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]+")"};if(typeof exports!=="undefined"){exports.mat4=mat4}var quat={};var quatIdentity=new Float32Array([0,0,0,1]);quat.create=function(){var out=new GLMAT_ARRAY_TYPE(4);out[0]=0;out[1]=0;out[2]=0;out[3]=1;return out};quat.clone=vec4.clone;quat.fromValues=vec4.fromValues;quat.copy=vec4.copy;quat.set=vec4.set;quat.identity=function(out){out[0]=0;out[1]=0;out[2]=0;out[3]=1;return out};quat.setAxisAngle=function(out,axis,rad){rad=rad*.5;var s=Math.sin(rad);out[0]=s*axis[0];out[1]=s*axis[1];out[2]=s*axis[2];out[3]=Math.cos(rad);return out};quat.add=vec4.add;quat.multiply=function(out,a,b){var ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=b[0],by=b[1],bz=b[2],bw=b[3];out[0]=ax*bw+aw*bx+ay*bz-az*by;out[1]=ay*bw+aw*by+az*bx-ax*bz;out[2]=az*bw+aw*bz+ax*by-ay*bx;out[3]=aw*bw-ax*bx-ay*by-az*bz;return out};quat.mul=quat.multiply;quat.scale=vec4.scale;quat.rotateX=function(out,a,rad){rad*=.5;var ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=Math.sin(rad),bw=Math.cos(rad);out[0]=ax*bw+aw*bx;out[1]=ay*bw+az*bx;out[2]=az*bw-ay*bx;out[3]=aw*bw-ax*bx;return out};quat.rotateY=function(out,a,rad){rad*=.5;var ax=a[0],ay=a[1],az=a[2],aw=a[3],by=Math.sin(rad),bw=Math.cos(rad);out[0]=ax*bw-az*by;out[1]=ay*bw+aw*by;out[2]=az*bw+ax*by;out[3]=aw*bw-ay*by;return out};quat.rotateZ=function(out,a,rad){rad*=.5;var ax=a[0],ay=a[1],az=a[2],aw=a[3],bz=Math.sin(rad),bw=Math.cos(rad);out[0]=ax*bw+ay*bz;out[1]=ay*bw-ax*bz;out[2]=az*bw+aw*bz;out[3]=aw*bw-az*bz;return out};quat.calculateW=function(out,a){var x=a[0],y=a[1],z=a[2];out[0]=x;out[1]=y;out[2]=z;out[3]=-Math.sqrt(Math.abs(1-x*x-y*y-z*z));return out};quat.dot=vec4.dot;quat.lerp=vec4.lerp;quat.slerp=function(out,a,b,t){var ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=b[0],by=b[1],bz=b[2],bw=b[3];var cosHalfTheta=ax*bx+ay*by+az*bz+aw*bw,halfTheta,sinHalfTheta,ratioA,ratioB;if(Math.abs(cosHalfTheta)>=1){if(out!==a){out[0]=ax;out[1]=ay;out[2]=az;out[3]=aw}return out}halfTheta=Math.acos(cosHalfTheta);sinHalfTheta=Math.sqrt(1-cosHalfTheta*cosHalfTheta);if(Math.abs(sinHalfTheta)<.001){out[0]=ax*.5+bx*.5;out[1]=ay*.5+by*.5;out[2]=az*.5+bz*.5;out[3]=aw*.5+bw*.5;return out}ratioA=Math.sin((1-t)*halfTheta)/sinHalfTheta;ratioB=Math.sin(t*halfTheta)/sinHalfTheta;out[0]=ax*ratioA+bx*ratioB;out[1]=ay*ratioA+by*ratioB;out[2]=az*ratioA+bz*ratioB;out[3]=aw*ratioA+bw*ratioB;return out};quat.invert=function(out,a){var a0=a[0],a1=a[1],a2=a[2],a3=a[3],dot=a0*a0+a1*a1+a2*a2+a3*a3,invDot=dot?1/dot:0;out[0]=-a0*invDot;out[1]=-a1*invDot;out[2]=-a2*invDot;out[3]=a3*invDot;return out};quat.conjugate=function(out,a){out[0]=-a[0];out[1]=-a[1];out[2]=-a[2];out[3]=a[3];return out};quat.length=vec4.length;quat.len=quat.length;quat.squaredLength=vec4.squaredLength;quat.sqrLen=quat.squaredLength;quat.normalize=vec4.normalize;quat.fromMat3=function(){var s_iNext=[1,2,0];return function(out,m){var fTrace=m[0]+m[4]+m[8];var fRoot;if(fTrace>0){fRoot=Math.sqrt(fTrace+1);out[3]=.5*fRoot;fRoot=.5/fRoot;out[0]=(m[7]-m[5])*fRoot;out[1]=(m[2]-m[6])*fRoot;out[2]=(m[3]-m[1])*fRoot}else{var i=0;if(m[4]>m[0])i=1;if(m[8]>m[i*3+i])i=2;var j=s_iNext[i];var k=s_iNext[j];fRoot=Math.sqrt(m[i*3+i]-m[j*3+j]-m[k*3+k]+1);out[i]=.5*fRoot;fRoot=.5/fRoot;out[3]=(m[k*3+j]-m[j*3+k])*fRoot;out[j]=(m[j*3+i]+m[i*3+j])*fRoot;out[k]=(m[k*3+i]+m[i*3+k])*fRoot}return out}}();quat.str=function(a){return"quat("+a[0]+", "+a[1]+", "+a[2]+", "+a[3]+")"};if(typeof exports!=="undefined"){exports.quat=quat}})(shim.exports)})()},{}],45:[function(require,module,exports){arguments[4][18][0].apply(exports,arguments)},{dup:18}],46:[function(require,module,exports){arguments[4][19][0].apply(exports,arguments)},{"./do-bind.js":45,dup:19}],47:[function(require,module,exports){arguments[4][20][0].apply(exports,arguments)},{"./do-bind.js":45,dup:20}],48:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{dup:16}],49:[function(require,module,exports){arguments[4][17][0].apply(exports,arguments)},{dup:17,"weak-map":48}],50:[function(require,module,exports){arguments[4][23][0].apply(exports,arguments)},{"./lib/vao-emulated.js":46,"./lib/vao-native.js":47,dup:23,webglew:49}],51:[function(require,module,exports){"use strict";module.exports=fastTwoSum;function fastTwoSum(a,b,result){var x=a+b;var bv=x-a;var av=x-bv;var br=b-bv;var ar=a-av;if(result){result[0]=ar+br;result[1]=x;return result}return[ar+br,x]}},{}],52:[function(require,module,exports){"use strict";var twoProduct=require("two-product");var twoSum=require("two-sum");module.exports=scaleLinearExpansion;function scaleLinearExpansion(e,scale){var n=e.length;if(n===1){var ts=twoProduct(e[0],scale);if(ts[0]){return ts}return[ts[1]]}var g=new Array(2*n);var q=[.1,.1];var t=[.1,.1];var count=0;twoProduct(e[0],scale,q);if(q[0]){g[count++]=q[0]}for(var i=1;i<n;++i){twoProduct(e[i],scale,t);var pq=q[1];twoSum(pq,t[0],q);if(q[0]){g[count++]=q[0]}var a=t[1];var b=q[1];var x=a+b;var bv=x-a;var y=b-bv;q[1]=x;if(y){g[count++]=y}}if(q[1]){g[count++]=q[1]}if(count===0){g[count++]=0}g.length=count;return g}},{"two-product":55,"two-sum":51}],53:[function(require,module,exports){"use strict";module.exports=robustSubtract;function scalarScalar(a,b){var x=a+b;var bv=x-a;var av=x-bv;var br=b-bv;var ar=a-av;var y=ar+br;if(y){return[y,x]}return[x]}function robustSubtract(e,f){var ne=e.length|0;var nf=f.length|0;if(ne===1&&nf===1){return scalarScalar(e[0],-f[0])}var n=ne+nf;var g=new Array(n);var count=0;var eptr=0;var fptr=0;var abs=Math.abs;var ei=e[eptr];var ea=abs(ei);var fi=-f[fptr];var fa=abs(fi);var a,b;if(ea<fa){b=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{b=fi;fptr+=1;if(fptr<nf){fi=-f[fptr];fa=abs(fi)}}if(eptr<ne&&ea<fa||fptr>=nf){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=-f[fptr];fa=abs(fi)}}var x=a+b;var bv=x-a;var y=b-bv;var q0=y;var q1=x;var _x,_bv,_av,_br,_ar;while(eptr<ne&&fptr<nf){if(ea<fa){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=-f[fptr];fa=abs(fi)}}b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x}while(eptr<ne){a=ei;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;eptr+=1;if(eptr<ne){ei=e[eptr]}}while(fptr<nf){a=fi;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;fptr+=1;if(fptr<nf){fi=-f[fptr]}}if(q0){g[count++]=q0}if(q1){g[count++]=q1}if(!count){g[count++]=0}g.length=count;return g}},{}],54:[function(require,module,exports){"use strict";module.exports=linearExpansionSum;function scalarScalar(a,b){var x=a+b;var bv=x-a;var av=x-bv;var br=b-bv;var ar=a-av;var y=ar+br;if(y){return[y,x]}return[x]}function linearExpansionSum(e,f){var ne=e.length|0;var nf=f.length|0;if(ne===1&&nf===1){return scalarScalar(e[0],f[0])}var n=ne+nf;var g=new Array(n);var count=0;var eptr=0;var fptr=0;var abs=Math.abs;var ei=e[eptr];var ea=abs(ei);var fi=f[fptr];var fa=abs(fi);var a,b;if(ea<fa){b=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{b=fi;fptr+=1;if(fptr<nf){fi=f[fptr];fa=abs(fi)}}if(eptr<ne&&ea<fa||fptr>=nf){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=f[fptr];fa=abs(fi)}}var x=a+b;var bv=x-a;var y=b-bv;var q0=y;var q1=x;var _x,_bv,_av,_br,_ar;while(eptr<ne&&fptr<nf){if(ea<fa){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=f[fptr];fa=abs(fi)}}b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x}while(eptr<ne){a=ei;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;eptr+=1;if(eptr<ne){ei=e[eptr]}}while(fptr<nf){a=fi;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;fptr+=1;if(fptr<nf){fi=f[fptr]}}if(q0){g[count++]=q0}if(q1){g[count++]=q1}if(!count){g[count++]=0}g.length=count;return g}},{}],55:[function(require,module,exports){"use strict";module.exports=twoProduct;var SPLITTER=+(Math.pow(2,27)+1);function twoProduct(a,b,result){var x=a*b;var c=SPLITTER*a;var abig=c-a;var ahi=c-abig;var alo=a-ahi;var d=SPLITTER*b;var bbig=d-b;var bhi=d-bbig;var blo=b-bhi;var err1=x-ahi*bhi;var err2=err1-alo*bhi;var err3=err2-ahi*blo;var y=alo*blo-err3;if(result){result[0]=y;result[1]=x;return result}return[y,x]}},{}],56:[function(require,module,exports){"use strict";var twoProduct=require("two-product");var robustSum=require("robust-sum");var robustScale=require("robust-scale");var robustSubtract=require("robust-subtract");var NUM_EXPAND=5;var EPSILON=1.1102230246251565e-16;var ERRBOUND3=(3+16*EPSILON)*EPSILON;var ERRBOUND4=(7+56*EPSILON)*EPSILON;function cofactor(m,c){var result=new Array(m.length-1);for(var i=1;i<m.length;++i){var r=result[i-1]=new Array(m.length-1);for(var j=0,k=0;j<m.length;++j){if(j===c){continue}r[k++]=m[i][j]}}return result}function matrix(n){var result=new Array(n);for(var i=0;i<n;++i){result[i]=new Array(n);for(var j=0;j<n;++j){result[i][j]=["m",j,"[",n-i-1,"]"].join("")}}return result}function sign(n){if(n&1){return"-"}return""}function generateSum(expr){if(expr.length===1){return expr[0]}else if(expr.length===2){return["sum(",expr[0],",",expr[1],")"].join("")}else{var m=expr.length>>1;return["sum(",generateSum(expr.slice(0,m)),",",generateSum(expr.slice(m)),")"].join("")}}function determinant(m){if(m.length===2){return[["sum(prod(",m[0][0],",",m[1][1],"),prod(-",m[0][1],",",m[1][0],"))"].join("")]}else{var expr=[];for(var i=0;i<m.length;++i){expr.push(["scale(",generateSum(determinant(cofactor(m,i))),",",sign(i),m[0][i],")"].join(""))}return expr}}function orientation(n){var pos=[];var neg=[];var m=matrix(n);var args=[];for(var i=0;i<n;++i){if((i&1)===0){pos.push.apply(pos,determinant(cofactor(m,i)))}else{neg.push.apply(neg,determinant(cofactor(m,i)))}args.push("m"+i)}var posExpr=generateSum(pos);var negExpr=generateSum(neg);var funcName="orientation"+n+"Exact";var code=["function ",funcName,"(",args.join(),"){var p=",posExpr,",n=",negExpr,",d=sub(p,n);return d[d.length-1];};return ",funcName].join("");var proc=new Function("sum","prod","scale","sub",code);return proc(robustSum,twoProduct,robustScale,robustSubtract)}var orientation3Exact=orientation(3);var orientation4Exact=orientation(4);var CACHED=[function orientation0(){return 0},function orientation1(){return 0},function orientation2(a,b){return b[0]-a[0]},function orientation3(a,b,c){var l=(a[1]-c[1])*(b[0]-c[0]);var r=(a[0]-c[0])*(b[1]-c[1]);var det=l-r;var s;if(l>0){if(r<=0){return det}else{s=l+r}}else if(l<0){if(r>=0){return det}else{s=-(l+r)}}else{return det}var tol=ERRBOUND3*s;if(det>=tol||det<=-tol){return det}return orientation3Exact(a,b,c)},function orientation4(a,b,c,d){var adx=a[0]-d[0];var bdx=b[0]-d[0];var cdx=c[0]-d[0];var ady=a[1]-d[1];var bdy=b[1]-d[1];var cdy=c[1]-d[1];var adz=a[2]-d[2];var bdz=b[2]-d[2];var cdz=c[2]-d[2];var bdxcdy=bdx*cdy;var cdxbdy=cdx*bdy;var cdxady=cdx*ady;var adxcdy=adx*cdy;var adxbdy=adx*bdy;var bdxady=bdx*ady;var det=adz*(bdxcdy-cdxbdy)+bdz*(cdxady-adxcdy)+cdz*(adxbdy-bdxady);var permanent=(Math.abs(bdxcdy)+Math.abs(cdxbdy))*Math.abs(adz)+(Math.abs(cdxady)+Math.abs(adxcdy))*Math.abs(bdz)+(Math.abs(adxbdy)+Math.abs(bdxady))*Math.abs(cdz);var tol=ERRBOUND4*permanent;if(det>tol||-det>tol){return det}return orientation4Exact(a,b,c,d)}];function slowOrient(args){var proc=CACHED[args.length];if(!proc){proc=CACHED[args.length]=orientation(args.length)}return proc.apply(undefined,args)}function generateOrientationProc(){while(CACHED.length<=NUM_EXPAND){CACHED.push(orientation(CACHED.length))}var args=[];var procArgs=["slow"];for(var i=0;i<=NUM_EXPAND;++i){args.push("a"+i);procArgs.push("o"+i)}var code=["function getOrientation(",args.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(var i=2;i<=NUM_EXPAND;++i){code.push("case ",i,":return o",i,"(",args.slice(0,i).join(),");")}code.push("}var s=new Array(arguments.length);for(var i=0;i<arguments.length;++i){s[i]=arguments[i]};return slow(s);}return getOrientation");procArgs.push(code.join(""));var proc=Function.apply(undefined,procArgs);module.exports=proc.apply(undefined,[slowOrient].concat(CACHED));for(var i=0;i<=NUM_EXPAND;++i){module.exports[i]=CACHED[i]}}generateOrientationProc()},{"robust-scale":52,"robust-subtract":53,"robust-sum":54,"two-product":55}],57:[function(require,module,exports){"use strict";var robustDot=require("robust-dot-product");var robustSum=require("robust-sum");module.exports=splitPolygon;module.exports.positive=positive;module.exports.negative=negative;function planeT(p,plane){var r=robustSum(robustDot(p,plane),[plane[plane.length-1]]);return r[r.length-1]}function lerpW(a,wa,b,wb){var d=wb-wa;var t=-wa/d;if(t<0){t=0}else if(t>1){t=1}var ti=1-t;var n=a.length;var r=new Array(n);for(var i=0;i<n;++i){r[i]=t*a[i]+ti*b[i]}return r}function splitPolygon(points,plane){var pos=[];var neg=[];var a=planeT(points[points.length-1],plane);for(var s=points[points.length-1],t=points[0],i=0;i<points.length;++i,s=t){t=points[i];var b=planeT(t,plane);if(a<0&&b>0||a>0&&b<0){var p=lerpW(s,b,t,a);pos.push(p);neg.push(p.slice())}if(b<0){neg.push(t.slice())}else if(b>0){pos.push(t.slice())}else{pos.push(t.slice());neg.push(t.slice())}a=b}return{positive:pos,negative:neg}}function positive(points,plane){var pos=[];var a=planeT(points[points.length-1],plane);for(var s=points[points.length-1],t=points[0],i=0;i<points.length;++i,s=t){t=points[i];var b=planeT(t,plane);if(a<0&&b>0||a>0&&b<0){pos.push(lerpW(s,b,t,a))}if(b>=0){pos.push(t.slice())}a=b}return pos}function negative(points,plane){var neg=[];var a=planeT(points[points.length-1],plane);for(var s=points[points.length-1],t=points[0],i=0;i<points.length;++i,s=t){t=points[i];var b=planeT(t,plane);if(a<0&&b>0||a>0&&b<0){neg.push(lerpW(s,b,t,a))}if(b<=0){neg.push(t.slice())}a=b}return neg}},{"robust-dot-product":58,"robust-sum":60}],58:[function(require,module,exports){"use strict";var twoProduct=require("two-product");var robustSum=require("robust-sum");module.exports=robustDotProduct;function robustDotProduct(a,b){var r=twoProduct(a[0],b[0]);for(var i=1;i<a.length;++i){r=robustSum(r,twoProduct(a[i],b[i]))}return r}},{"robust-sum":60,"two-product":59}],59:[function(require,module,exports){arguments[4][55][0].apply(exports,arguments)},{dup:55}],60:[function(require,module,exports){arguments[4][54][0].apply(exports,arguments)},{dup:54}],61:[function(require,module,exports){"use strict";module.exports=createText;var vectorizeText=require("./lib/vtext");var Canvas=require("canvas-browserify");var canvas=new Canvas(8192,256);var context=canvas.getContext("2d");function createText(str,options){if(typeof options!=="object"||options===null){options={}}return vectorizeText(str,canvas,context,options)}},{"./lib/vtext":62,"canvas-browserify":63}],62:[function(require,module,exports){"use strict";module.exports=vectorizeText;module.exports.processPixels=processPixels;var surfaceNets=require("surface-nets");var ndarray=require("ndarray");var simplify=require("simplify-planar-graph");var toPolygons=require("planar-graph-to-polyline");var triangulate=require("triangulate-polyline");function transformPositions(positions,options,size){var align=options.textAlign||"start";var baseline=options.textBaseline||"alphabetic";var lo=[1<<30,1<<30];var hi=[0,0];var n=positions.length;for(var i=0;i<n;++i){var p=positions[i];for(var j=0;j<2;++j){lo[j]=Math.min(lo[j],p[j])|0;hi[j]=Math.max(hi[j],p[j])|0}}var xShift=0;switch(align){case"center":xShift=-.5*(lo[0]+hi[0]);break;case"right":case"end":xShift=-hi[0];break;case"left":case"start":xShift=-lo[0];break;default:throw new Error("vectorize-text: Unrecognized textAlign: '"+align+"'")}var yShift=0;switch(baseline){case"hanging":case"top":yShift=-lo[1];break;case"middle":yShift=-.5*(lo[1]+hi[1]);break;case"alphabetic":case"ideographic":yShift=-3*size;break;case"bottom":yShift=-hi[1];break;default:throw new Error("vectorize-text: Unrecoginized textBaseline: '"+baseline+"'")}var scale=1/size;if("lineHeight"in options){scale*=+options.lineHeight}else if("width"in options){scale=options.width/(hi[0]-lo[0])}else if("height"in options){scale=options.height/(hi[1]-lo[1])}return positions.map(function(p){return[scale*(p[0]+xShift),scale*(p[1]+yShift)]})}function getPixels(canvas,context,str,size){var width=Math.ceil(context.measureText(str).width+10)|0;if(width>8192){throw new Error("vectorize-text: String too long (sorry, this will get fixed later)")}var height=4*size;if(canvas.height<height){canvas.height=height}context.fillStyle="#000";context.fillRect(0,0,canvas.width,canvas.height);context.fillStyle="#fff";context.fillText(str,5,3*size|0);var pixelData=context.getImageData(0,0,width,height);var pixels=ndarray(pixelData.data,[height,width,4]);return pixels.pick(-1,-1,0).transpose(1,0)}function getContour(pixels,doSimplify){var contour=surfaceNets(pixels,128);if(doSimplify){return simplify(contour.cells,contour.positions,.25)}return{edges:contour.cells,positions:contour.positions}}function processPixelsImpl(pixels,options,size,simplify){var contour=getContour(pixels,simplify);var npositions=transformPositions(contour.positions,options,size);var flip="ccw"===options.orientation;if(options.polygons||options.polygon||options.polyline){var polygons=toPolygons(contour.edges,contour.positions);return polygons.map(function(polygon){if(flip){polygon.reverse()}return polygon.map(function(loop){return loop.map(function(v){return npositions[v]})})})}else if(options.triangles||options.triangulate||options.triangle){var polygons=toPolygons(contour.edges,contour.positions);var triangles=[];for(var i=0;i<polygons.length;++i){triangles.push.apply(triangles,triangulate(polygons[i],contour.positions))}if(flip){for(var i=0;i<triangles.length;++i){var c=triangles[i];var tmp=c[0];c[0]=c[2];c[2]=tmp}}return{cells:triangles,positions:npositions}}else{return{edges:contour.edges,positions:npositions}}}function processPixels(pixels,options,size){try{return processPixelsImpl(pixels,options,size,true)}catch(e){}try{return processPixelsImpl(pixels,options,size,false)}catch(e){}if(options.polygons||options.polyline||options.polygon){return[]}if(options.triangles||options.triangulate||options.triangle){return{cells:[],positions:[]}}return{edges:[],positions:[]}}function vectorizeText(str,canvas,context,options){var size=options.size||64;var family=options.font||"normal";context.font=size+"px "+family;context.textAlign="start";context.textBaseline="alphabetic";context.direction="ltr";var pixels=getPixels(canvas,context,str,size);return processPixels(pixels,options,size)}},{ndarray:178,"planar-graph-to-polyline":81,"simplify-planar-graph":85,"surface-nets":101,"triangulate-polyline":112}],63:[function(require,module,exports){var Canvas=module.exports=function Canvas(w,h){var canvas=document.createElement("canvas");canvas.width=w||300;canvas.height=h||150;return canvas};Canvas.Image=function(){var img=document.createElement("img");return img}},{}],64:[function(require,module,exports){"use strict";module.exports=trimLeaves;var e2a=require("edges-to-adjacency-list");function trimLeaves(edges,positions){var adj=e2a(edges,positions.length);var live=new Array(positions.length);var nbhd=new Array(positions.length);var dead=[];for(var i=0;i<positions.length;++i){var count=adj[i].length;nbhd[i]=count;live[i]=true;if(count<=1){dead.push(i)}}while(dead.length>0){var v=dead.pop();live[v]=false;var n=adj[v];for(var i=0;i<n.length;++i){var u=n[i];if(--nbhd[u]===0){dead.push(u)}}}var newIndex=new Array(positions.length);var npositions=[];for(var i=0;i<positions.length;++i){if(live[i]){var v=npositions.length;newIndex[i]=v;npositions.push(positions[i])}else{newIndex[i]=-1}}var nedges=[];for(var i=0;i<edges.length;++i){var e=edges[i];if(live[e[0]]&&live[e[1]]){nedges.push([newIndex[e[0]],newIndex[e[1]]])}}return[nedges,npositions]}},{"edges-to-adjacency-list":65}],65:[function(require,module,exports){"use strict";module.exports=edgeToAdjacency;var uniq=require("uniq");function edgeToAdjacency(edges,numVertices){var numEdges=edges.length;if(typeof numVertices!=="number"){numVertices=0;for(var i=0;i<numEdges;++i){var e=edges[i];numVertices=Math.max(numVertices,e[0],e[1])}numVertices=(numVertices|0)+1}numVertices=numVertices|0;var adj=new Array(numVertices);for(var i=0;i<numVertices;++i){adj[i]=[]}for(var i=0;i<numEdges;++i){var e=edges[i];adj[e[0]].push(e[1]);adj[e[1]].push(e[0])}for(var j=0;j<numVertices;++j){uniq(adj[j],function(a,b){return a-b})}return adj}},{uniq:80}],66:[function(require,module,exports){"use strict";module.exports=planarDual;var compareAngle=require("compare-angle");function planarDual(cells,positions){var numVertices=positions.length|0;var numEdges=cells.length;var adj=[new Array(numVertices),new Array(numVertices)];for(var i=0;i<numVertices;++i){adj[0][i]=[];adj[1][i]=[]}for(var i=0;i<numEdges;++i){var c=cells[i];adj[0][c[0]].push(c);adj[1][c[1]].push(c)}var cycles=[];for(var i=0;i<numVertices;++i){if(adj[0][i].length+adj[1][i].length===0){cycles.push([i])}}function cut(c,i){var a=adj[i][c[i]];a.splice(a.indexOf(c),1)}function next(a,b,noCut){var nextCell,nextVertex,nextDir;for(var i=0;i<2;++i){if(adj[i][b].length>0){nextCell=adj[i][b][0];nextDir=i;break}}nextVertex=nextCell[nextDir^1];for(var dir=0;dir<2;++dir){var nbhd=adj[dir][b];for(var k=0;k<nbhd.length;++k){var e=nbhd[k];var p=e[dir^1];var cmp=compareAngle(positions[a],positions[b],positions[nextVertex],positions[p]);if(cmp>0){nextCell=e; | |
nextVertex=p;nextDir=dir}}}if(noCut){return nextVertex}if(nextCell){cut(nextCell,nextDir)}return nextVertex}function extractCycle(v,dir){var e0=adj[dir][v][0];var cycle=[v];cut(e0,dir);var u=e0[dir^1];var d0=dir;while(true){while(u!==v){cycle.push(u);u=next(cycle[cycle.length-2],u,false)}if(adj[0][v].length+adj[1][v].length===0){break}var a=cycle[cycle.length-1];var b=v;var c=cycle[1];var d=next(a,b,true);if(compareAngle(positions[a],positions[b],positions[c],positions[d])<0){break}cycle.push(v);u=next(a,b)}return cycle}function shouldGlue(pcycle,ncycle){return ncycle[1]===ncycle[ncycle.length-1]}for(var i=0;i<numVertices;++i){for(var j=0;j<2;++j){var pcycle=[];while(adj[j][i].length>0){var ni=adj[0][i].length;var ncycle=extractCycle(i,j);if(shouldGlue(pcycle,ncycle)){pcycle.push.apply(pcycle,ncycle)}else{if(pcycle.length>0){cycles.push(pcycle)}pcycle=ncycle}}if(pcycle.length>0){cycles.push(pcycle)}}}return cycles}},{"compare-angle":67}],67:[function(require,module,exports){"use strict";module.exports=compareAngle;var orient=require("robust-orientation");var sgn=require("signum");var twoSum=require("two-sum");var robustProduct=require("robust-product");var robustSum=require("robust-sum");function testInterior(a,b,c){var x0=twoSum(a[0],-b[0]);var y0=twoSum(a[1],-b[1]);var x1=twoSum(c[0],-b[0]);var y1=twoSum(c[1],-b[1]);var d=robustSum(robustProduct(x0,x1),robustProduct(y0,y1));return d[d.length-1]>=0}function compareAngle(a,b,c,d){var bcd=orient(b,c,d);if(bcd===0){var sabc=sgn(orient(a,b,c));var sabd=sgn(orient(a,b,d));if(sabc===sabd){if(sabc===0){var ic=testInterior(a,b,c);var id=testInterior(a,b,d);if(ic===id){return 0}else if(ic){return 1}else{return-1}}return 0}else if(sabd===0){if(sabc>0){return-1}else if(testInterior(a,b,d)){return-1}else{return 1}}else if(sabc===0){if(sabd>0){return 1}else if(testInterior(a,b,c)){return 1}else{return-1}}return sgn(sabd-sabc)}var abc=orient(a,b,c);if(abc>0){if(bcd>0&&orient(a,b,d)>0){return 1}return-1}else if(abc<0){if(bcd>0||orient(a,b,d)>0){return 1}return-1}else{var abd=orient(a,b,d);if(abd>0){return 1}else{if(testInterior(a,b,c)){return 1}else{return-1}}}}},{"robust-orientation":56,"robust-product":69,"robust-sum":78,signum:70,"two-sum":71}],68:[function(require,module,exports){arguments[4][52][0].apply(exports,arguments)},{dup:52,"two-product":79,"two-sum":71}],69:[function(require,module,exports){"use strict";var robustSum=require("robust-sum");var robustScale=require("robust-scale");module.exports=robustProduct;function robustProduct(a,b){if(a.length===1){return robustScale(b,a[0])}if(b.length===1){return robustScale(a,b[0])}if(a.length===0||b.length===0){return[0]}var r=[0];if(a.length<b.length){for(var i=0;i<a.length;++i){r=robustSum(r,robustScale(b,a[i]))}}else{for(var i=0;i<b.length;++i){r=robustSum(r,robustScale(a,b[i]))}}return r}},{"robust-scale":68,"robust-sum":78}],70:[function(require,module,exports){"use strict";module.exports=function signum(x){if(x<0){return-1}if(x>0){return 1}return 0}},{}],71:[function(require,module,exports){arguments[4][51][0].apply(exports,arguments)},{dup:51}],72:[function(require,module,exports){"use strict";function compileSearch(funcName,predicate,reversed,extraArgs,useNdarray,earlyOut){var code=["function ",funcName,"(a,l,h,",extraArgs.join(","),"){",earlyOut?"":"var i=",reversed?"l-1":"h+1",";while(l<=h){var m=(l+h)>>>1,x=a",useNdarray?".get(m)":"[m]"];if(earlyOut){if(predicate.indexOf("c")<0){code.push(";if(x===y){return m}else if(x<=y){")}else{code.push(";var p=c(x,y);if(p===0){return m}else if(p<=0){")}}else{code.push(";if(",predicate,"){i=m;")}if(reversed){code.push("l=m+1}else{h=m-1}")}else{code.push("h=m-1}else{l=m+1}")}code.push("}");if(earlyOut){code.push("return -1};")}else{code.push("return i};")}return code.join("")}function compileBoundsSearch(predicate,reversed,suffix,earlyOut){var result=new Function([compileSearch("A","x"+predicate+"y",reversed,["y"],false,earlyOut),compileSearch("B","x"+predicate+"y",reversed,["y"],true,earlyOut),compileSearch("P","c(x,y)"+predicate+"0",reversed,["y","c"],false,earlyOut),compileSearch("Q","c(x,y)"+predicate+"0",reversed,["y","c"],true,earlyOut),"function dispatchBsearch",suffix,"(a,y,c,l,h){if(a.shape){if(typeof(c)==='function'){return Q(a,(l===undefined)?0:l|0,(h===undefined)?a.shape[0]-1:h|0,y,c)}else{return B(a,(c===undefined)?0:c|0,(l===undefined)?a.shape[0]-1:l|0,y)}}else{if(typeof(c)==='function'){return P(a,(l===undefined)?0:l|0,(h===undefined)?a.length-1:h|0,y,c)}else{return A(a,(c===undefined)?0:c|0,(l===undefined)?a.length-1:l|0,y)}}}return dispatchBsearch",suffix].join(""));return result()}module.exports={ge:compileBoundsSearch(">=",false,"GE"),gt:compileBoundsSearch(">",false,"GT"),lt:compileBoundsSearch("<",true,"LT"),le:compileBoundsSearch("<=",true,"LE"),eq:compileBoundsSearch("-",true,"EQ",true)}},{}],73:[function(require,module,exports){"use strict";var bounds=require("binary-search-bounds");var NOT_FOUND=0;var SUCCESS=1;var EMPTY=2;module.exports=createWrapper;function IntervalTreeNode(mid,left,right,leftPoints,rightPoints){this.mid=mid;this.left=left;this.right=right;this.leftPoints=leftPoints;this.rightPoints=rightPoints;this.count=(left?left.count:0)+(right?right.count:0)+leftPoints.length}var proto=IntervalTreeNode.prototype;function copy(a,b){a.mid=b.mid;a.left=b.left;a.right=b.right;a.leftPoints=b.leftPoints;a.rightPoints=b.rightPoints;a.count=b.count}function rebuild(node,intervals){var ntree=createIntervalTree(intervals);node.mid=ntree.mid;node.left=ntree.left;node.right=ntree.right;node.leftPoints=ntree.leftPoints;node.rightPoints=ntree.rightPoints;node.count=ntree.count}function rebuildWithInterval(node,interval){var intervals=node.intervals([]);intervals.push(interval);rebuild(node,intervals)}function rebuildWithoutInterval(node,interval){var intervals=node.intervals([]);var idx=intervals.indexOf(interval);if(idx<0){return NOT_FOUND}intervals.splice(idx,1);rebuild(node,intervals);return SUCCESS}proto.intervals=function(result){result.push.apply(result,this.leftPoints);if(this.left){this.left.intervals(result)}if(this.right){this.right.intervals(result)}return result};proto.insert=function(interval){var weight=this.count-this.leftPoints.length;this.count+=1;if(interval[1]<this.mid){if(this.left){if(4*(this.left.count+1)>3*(weight+1)){rebuildWithInterval(this,interval)}else{this.left.insert(interval)}}else{this.left=createIntervalTree([interval])}}else if(interval[0]>this.mid){if(this.right){if(4*(this.right.count+1)>3*(weight+1)){rebuildWithInterval(this,interval)}else{this.right.insert(interval)}}else{this.right=createIntervalTree([interval])}}else{var l=bounds.ge(this.leftPoints,interval,compareBegin);var r=bounds.ge(this.rightPoints,interval,compareEnd);this.leftPoints.splice(l,0,interval);this.rightPoints.splice(r,0,interval)}};proto.remove=function(interval){var weight=this.count-this.leftPoints;if(interval[1]<this.mid){if(!this.left){return NOT_FOUND}var rw=this.right?this.right.count:0;if(4*rw>3*(weight-1)){return rebuildWithoutInterval(this,interval)}var r=this.left.remove(interval);if(r===EMPTY){this.left=null;this.count-=1;return SUCCESS}else if(r===SUCCESS){this.count-=1}return r}else if(interval[0]>this.mid){if(!this.right){return NOT_FOUND}var lw=this.left?this.left.count:0;if(4*lw>3*(weight-1)){return rebuildWithoutInterval(this,interval)}var r=this.right.remove(interval);if(r===EMPTY){this.right=null;this.count-=1;return SUCCESS}else if(r===SUCCESS){this.count-=1}return r}else{if(this.count===1){if(this.leftPoints[0]===interval){return EMPTY}else{return NOT_FOUND}}if(this.leftPoints.length===1&&this.leftPoints[0]===interval){if(this.left&&this.right){var p=this;var n=this.left;while(n.right){p=n;n=n.right}if(p===this){n.right=this.right}else{var l=this.left;var r=this.right;p.count-=n.count;p.right=n.left;n.left=l;n.right=r}copy(this,n);this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else if(this.left){copy(this,this.left)}else{copy(this,this.right)}return SUCCESS}for(var l=bounds.ge(this.leftPoints,interval,compareBegin);l<this.leftPoints.length;++l){if(this.leftPoints[l][0]!==interval[0]){break}if(this.leftPoints[l]===interval){this.count-=1;this.leftPoints.splice(l,1);for(var r=bounds.ge(this.rightPoints,interval,compareEnd);r<this.rightPoints.length;++r){if(this.rightPoints[r][1]!==interval[1]){break}else if(this.rightPoints[r]===interval){this.rightPoints.splice(r,1);return SUCCESS}}throw new Error("This should never happen")}}return NOT_FOUND}};function compareXBegin(x,y){return x[0]-y}function compareXEnd(x,y){return x[1]-y}proto.queryPoint=function(x,cb){if(x<this.mid){if(this.left){var r=this.left.queryPoint(x,cb);if(r){return r}}var i=bounds.le(this.leftPoints,x,compareXBegin);for(;i>=0;--i){var r=cb(this.leftPoints[i]);if(r){return r}}}else if(x>this.mid){var i=bounds.ge(this.rightPoints,x,compareXEnd);for(;i<this.rightPoints.length;++i){var r=cb(this.rightPoints[i]);if(r){return r}}if(this.right){var r=this.right.queryPoint(x,cb);if(r){return r}}}else{for(var i=0;i<this.leftPoints.length;++i){var r=cb(this.leftPoints[i]);if(r){return r}}}};function reportRange(arr,lo,hi,cb,cmp){var a=bounds.ge(arr,lo,cmp);var b=bounds.le(arr,hi,cmp,a);if(b<arr.length&&cmp(hi,arr[b])===0){++b}for(var i=a;i<b;++i){var r=cb(arr[i]);if(r){return r}}}proto.queryInterval=function(lo,hi,cb){if(lo<this.mid&&this.left){var r=this.left.queryInterval(lo,hi,cb);if(r){return r}}if(hi>this.mid&&this.right){var r=this.right.queryInterval(lo,hi,cb);if(r){return r}}if(hi<this.mid){var r=reportRange(this.leftPoints,lo,hi,cb,compareXBegin);if(r){return r}}else if(lo>this.mid){var r=reportRange(this.rightPoints,lo,hi,cb,compareXEnd);if(r){return r}}else{for(var i=0;i<this.leftPoints.length;++i){var r=cb(this.leftPoints[i]);if(r){return r}}}};function compareNumbers(a,b){return a-b}function compareBegin(a,b){var d=a[0]-b[0];if(d){return d}return a[1]-b[1]}function compareEnd(a,b){var d=a[1]-b[1];if(d){return d}return a[0]-b[0]}function createIntervalTree(intervals){if(intervals.length===0){return null}var pts=[];for(var i=0;i<intervals.length;++i){pts.push(intervals[i][0],intervals[i][1])}pts.sort(compareNumbers);var mid=pts[pts.length>>1];var leftIntervals=[];var rightIntervals=[];var centerIntervals=[];for(var i=0;i<intervals.length;++i){var s=intervals[i];if(s[1]<mid){leftIntervals.push(s)}else if(mid<s[0]){rightIntervals.push(s)}else{centerIntervals.push(s)}}var leftPoints=centerIntervals;var rightPoints=centerIntervals.slice();leftPoints.sort(compareBegin);rightPoints.sort(compareEnd);return new IntervalTreeNode(mid,createIntervalTree(leftIntervals),createIntervalTree(rightIntervals),leftPoints,rightPoints)}function IntervalTree(root){this.root=root}var tproto=IntervalTree.prototype;tproto.insert=function(interval){if(this.root){this.root.insert(interval)}else{this.root=new IntervalTreeNode(interval[0],null,null,[interval],[interval])}};tproto.remove=function(interval){if(this.root){var r=this.root.remove(interval);if(r===EMPTY){this.root=null}return r!==NOT_FOUND}return false};tproto.queryPoint=function(p,cb){if(this.root){return this.root.queryPoint(p,cb)}};tproto.queryInterval=function(lo,hi,cb){if(this.root){return this.root.queryInterval(lo,hi,cb)}};Object.defineProperty(tproto,"count",{get:function(){if(this.root){return this.root.count}return 0}});Object.defineProperty(tproto,"intervals",{get:function(){if(this.root){return this.root.intervals([])}return[]}});function createWrapper(intervals){if(intervals.length===0||!intervals){return new IntervalTree(null)}return new IntervalTree(createIntervalTree(intervals))}},{"binary-search-bounds":72}],74:[function(require,module,exports){"use strict";module.exports=orderSegments;var orient=require("robust-orientation");function horizontalOrder(a,b){var bl,br;if(b[0][0]<b[1][0]){bl=b[0];br=b[1]}else if(b[0][0]>b[1][0]){bl=b[1];br=b[0]}else{var alo=Math.min(a[0][1],a[1][1]);var ahi=Math.max(a[0][1],a[1][1]);var blo=Math.min(b[0][1],b[1][1]);var bhi=Math.max(b[0][1],b[1][1]);if(ahi<blo){return ahi-blo}if(alo>bhi){return alo-bhi}return ahi-bhi}var al,ar;if(a[0][1]<a[1][1]){al=a[0];ar=a[1]}else{al=a[1];ar=a[0]}var d=orient(br,bl,al);if(d){return d}d=orient(br,bl,ar);if(d){return d}return ar-br}function orderSegments(b,a){var al,ar;if(a[0][0]<a[1][0]){al=a[0];ar=a[1]}else if(a[0][0]>a[1][0]){al=a[1];ar=a[0]}else{return horizontalOrder(a,b)}var bl,br;if(b[0][0]<b[1][0]){bl=b[0];br=b[1]}else if(b[0][0]>b[1][0]){bl=b[1];br=b[0]}else{return-horizontalOrder(b,a)}var d1=orient(al,ar,br);var d2=orient(al,ar,bl);if(d1<0){if(d2<=0){return d1}}else if(d1>0){if(d2>=0){return d1}}else if(d2){return d2}d1=orient(br,bl,ar);d2=orient(br,bl,al);if(d1<0){if(d2<=0){return d1}}else if(d1>0){if(d2>=0){return d1}}else if(d2){return d2}return ar[0]-br[0]}},{"robust-orientation":56}],75:[function(require,module,exports){"use strict";module.exports=createRBTree;var RED=0;var BLACK=1;function RBNode(color,key,value,left,right,count){this._color=color;this.key=key;this.value=value;this.left=left;this.right=right;this._count=count}function cloneNode(node){return new RBNode(node._color,node.key,node.value,node.left,node.right,node._count)}function repaint(color,node){return new RBNode(color,node.key,node.value,node.left,node.right,node._count)}function recount(node){node._count=1+(node.left?node.left._count:0)+(node.right?node.right._count:0)}function RedBlackTree(compare,root){this._compare=compare;this.root=root}var proto=RedBlackTree.prototype;Object.defineProperty(proto,"keys",{get:function(){var result=[];this.forEach(function(k,v){result.push(k)});return result}});Object.defineProperty(proto,"values",{get:function(){var result=[];this.forEach(function(k,v){result.push(v)});return result}});Object.defineProperty(proto,"length",{get:function(){if(this.root){return this.root._count}return 0}});proto.insert=function(key,value){var cmp=this._compare;var n=this.root;var n_stack=[];var d_stack=[];while(n){var d=cmp(key,n.key);n_stack.push(n);d_stack.push(d);if(d<=0){n=n.left}else{n=n.right}}n_stack.push(new RBNode(RED,key,value,null,null,1));for(var s=n_stack.length-2;s>=0;--s){var n=n_stack[s];if(d_stack[s]<=0){n_stack[s]=new RBNode(n._color,n.key,n.value,n_stack[s+1],n.right,n._count+1)}else{n_stack[s]=new RBNode(n._color,n.key,n.value,n.left,n_stack[s+1],n._count+1)}}for(var s=n_stack.length-1;s>1;--s){var p=n_stack[s-1];var n=n_stack[s];if(p._color===BLACK||n._color===BLACK){break}var pp=n_stack[s-2];if(pp.left===p){if(p.left===n){var y=pp.right;if(y&&y._color===RED){p._color=BLACK;pp.right=repaint(BLACK,y);pp._color=RED;s-=1}else{pp._color=RED;pp.left=p.right;p._color=BLACK;p.right=pp;n_stack[s-2]=p;n_stack[s-1]=n;recount(pp);recount(p);if(s>=3){var ppp=n_stack[s-3];if(ppp.left===pp){ppp.left=p}else{ppp.right=p}}break}}else{var y=pp.right;if(y&&y._color===RED){p._color=BLACK;pp.right=repaint(BLACK,y);pp._color=RED;s-=1}else{p.right=n.left;pp._color=RED;pp.left=n.right;n._color=BLACK;n.left=p;n.right=pp;n_stack[s-2]=n;n_stack[s-1]=p;recount(pp);recount(p);recount(n);if(s>=3){var ppp=n_stack[s-3];if(ppp.left===pp){ppp.left=n}else{ppp.right=n}}break}}}else{if(p.right===n){var y=pp.left;if(y&&y._color===RED){p._color=BLACK;pp.left=repaint(BLACK,y);pp._color=RED;s-=1}else{pp._color=RED;pp.right=p.left;p._color=BLACK;p.left=pp;n_stack[s-2]=p;n_stack[s-1]=n;recount(pp);recount(p);if(s>=3){var ppp=n_stack[s-3];if(ppp.right===pp){ppp.right=p}else{ppp.left=p}}break}}else{var y=pp.left;if(y&&y._color===RED){p._color=BLACK;pp.left=repaint(BLACK,y);pp._color=RED;s-=1}else{p.left=n.right;pp._color=RED;pp.right=n.left;n._color=BLACK;n.right=p;n.left=pp;n_stack[s-2]=n;n_stack[s-1]=p;recount(pp);recount(p);recount(n);if(s>=3){var ppp=n_stack[s-3];if(ppp.right===pp){ppp.right=n}else{ppp.left=n}}break}}}}n_stack[0]._color=BLACK;return new RedBlackTree(cmp,n_stack[0])};function doVisitFull(visit,node){if(node.left){var v=doVisitFull(visit,node.left);if(v){return v}}var v=visit(node.key,node.value);if(v){return v}if(node.right){return doVisitFull(visit,node.right)}}function doVisitHalf(lo,compare,visit,node){var l=compare(lo,node.key);if(l<=0){if(node.left){var v=doVisitHalf(lo,compare,visit,node.left);if(v){return v}}var v=visit(node.key,node.value);if(v){return v}}if(node.right){return doVisitHalf(lo,compare,visit,node.right)}}function doVisit(lo,hi,compare,visit,node){var l=compare(lo,node.key);var h=compare(hi,node.key);var v;if(l<=0){if(node.left){v=doVisit(lo,hi,compare,visit,node.left);if(v){return v}}if(h>0){v=visit(node.key,node.value);if(v){return v}}}if(h>0&&node.right){return doVisit(lo,hi,compare,visit,node.right)}}proto.forEach=function rbTreeForEach(visit,lo,hi){if(!this.root){return}switch(arguments.length){case 1:return doVisitFull(visit,this.root);break;case 2:return doVisitHalf(lo,this._compare,visit,this.root);break;case 3:if(this._compare(lo,hi)>=0){return}return doVisit(lo,hi,this._compare,visit,this.root);break}};Object.defineProperty(proto,"begin",{get:function(){var stack=[];var n=this.root;while(n){stack.push(n);n=n.left}return new RedBlackTreeIterator(this,stack)}});Object.defineProperty(proto,"end",{get:function(){var stack=[];var n=this.root;while(n){stack.push(n);n=n.right}return new RedBlackTreeIterator(this,stack)}});proto.at=function(idx){if(idx<0){return new RedBlackTreeIterator(this,[])}var n=this.root;var stack=[];while(true){stack.push(n);if(n.left){if(idx<n.left._count){n=n.left;continue}idx-=n.left._count}if(!idx){return new RedBlackTreeIterator(this,stack)}idx-=1;if(n.right){if(idx>=n.right._count){break}n=n.right}else{break}}return new RedBlackTreeIterator(this,[])};proto.ge=function(key){var cmp=this._compare;var n=this.root;var stack=[];var last_ptr=0;while(n){var d=cmp(key,n.key);stack.push(n);if(d<=0){last_ptr=stack.length}if(d<=0){n=n.left}else{n=n.right}}stack.length=last_ptr;return new RedBlackTreeIterator(this,stack)};proto.gt=function(key){var cmp=this._compare;var n=this.root;var stack=[];var last_ptr=0;while(n){var d=cmp(key,n.key);stack.push(n);if(d<0){last_ptr=stack.length}if(d<0){n=n.left}else{n=n.right}}stack.length=last_ptr;return new RedBlackTreeIterator(this,stack)};proto.lt=function(key){var cmp=this._compare;var n=this.root;var stack=[];var last_ptr=0;while(n){var d=cmp(key,n.key);stack.push(n);if(d>0){last_ptr=stack.length}if(d<=0){n=n.left}else{n=n.right}}stack.length=last_ptr;return new RedBlackTreeIterator(this,stack)};proto.le=function(key){var cmp=this._compare;var n=this.root;var stack=[];var last_ptr=0;while(n){var d=cmp(key,n.key);stack.push(n);if(d>=0){last_ptr=stack.length}if(d<0){n=n.left}else{n=n.right}}stack.length=last_ptr;return new RedBlackTreeIterator(this,stack)};proto.find=function(key){var cmp=this._compare;var n=this.root;var stack=[];while(n){var d=cmp(key,n.key);stack.push(n);if(d===0){return new RedBlackTreeIterator(this,stack)}if(d<=0){n=n.left}else{n=n.right}}return new RedBlackTreeIterator(this,[])};proto.remove=function(key){var iter=this.find(key);if(iter){return iter.remove()}return this};proto.get=function(key){var cmp=this._compare;var n=this.root;while(n){var d=cmp(key,n.key);if(d===0){return n.value}if(d<=0){n=n.left}else{n=n.right}}return};function RedBlackTreeIterator(tree,stack){this.tree=tree;this._stack=stack}var iproto=RedBlackTreeIterator.prototype;Object.defineProperty(iproto,"valid",{get:function(){return this._stack.length>0}});Object.defineProperty(iproto,"node",{get:function(){if(this._stack.length>0){return this._stack[this._stack.length-1]}return null},enumerable:true});iproto.clone=function(){return new RedBlackTreeIterator(this.tree,this._stack.slice())};function swapNode(n,v){n.key=v.key;n.value=v.value;n.left=v.left;n.right=v.right;n._color=v._color;n._count=v._count}function fixDoubleBlack(stack){var n,p,s,z;for(var i=stack.length-1;i>=0;--i){n=stack[i];if(i===0){n._color=BLACK;return}p=stack[i-1];if(p.left===n){s=p.right;if(s.right&&s.right._color===RED){s=p.right=cloneNode(s);z=s.right=cloneNode(s.right);p.right=s.left;s.left=p;s.right=z;s._color=p._color;n._color=BLACK;p._color=BLACK;z._color=BLACK;recount(p);recount(s);if(i>1){var pp=stack[i-2];if(pp.left===p){pp.left=s}else{pp.right=s}}stack[i-1]=s;return}else if(s.left&&s.left._color===RED){s=p.right=cloneNode(s);z=s.left=cloneNode(s.left);p.right=z.left;s.left=z.right;z.left=p;z.right=s;z._color=p._color;p._color=BLACK;s._color=BLACK;n._color=BLACK;recount(p);recount(s);recount(z);if(i>1){var pp=stack[i-2];if(pp.left===p){pp.left=z}else{pp.right=z}}stack[i-1]=z;return}if(s._color===BLACK){if(p._color===RED){p._color=BLACK;p.right=repaint(RED,s);return}else{p.right=repaint(RED,s);continue}}else{s=cloneNode(s);p.right=s.left;s.left=p;s._color=p._color;p._color=RED;recount(p);recount(s);if(i>1){var pp=stack[i-2];if(pp.left===p){pp.left=s}else{pp.right=s}}stack[i-1]=s;stack[i]=p;if(i+1<stack.length){stack[i+1]=n}else{stack.push(n)}i=i+2}}else{s=p.left;if(s.left&&s.left._color===RED){s=p.left=cloneNode(s);z=s.left=cloneNode(s.left);p.left=s.right;s.right=p;s.left=z;s._color=p._color;n._color=BLACK;p._color=BLACK;z._color=BLACK;recount(p);recount(s);if(i>1){var pp=stack[i-2];if(pp.right===p){pp.right=s}else{pp.left=s}}stack[i-1]=s;return}else if(s.right&&s.right._color===RED){s=p.left=cloneNode(s);z=s.right=cloneNode(s.right);p.left=z.right;s.right=z.left;z.right=p;z.left=s;z._color=p._color;p._color=BLACK;s._color=BLACK;n._color=BLACK;recount(p);recount(s);recount(z);if(i>1){var pp=stack[i-2];if(pp.right===p){pp.right=z}else{pp.left=z}}stack[i-1]=z;return}if(s._color===BLACK){if(p._color===RED){p._color=BLACK;p.left=repaint(RED,s);return}else{p.left=repaint(RED,s);continue}}else{s=cloneNode(s);p.left=s.right;s.right=p;s._color=p._color;p._color=RED;recount(p);recount(s);if(i>1){var pp=stack[i-2];if(pp.right===p){pp.right=s}else{pp.left=s}}stack[i-1]=s;stack[i]=p;if(i+1<stack.length){stack[i+1]=n}else{stack.push(n)}i=i+2}}}}iproto.remove=function(){var stack=this._stack;if(stack.length===0){return this.tree}var cstack=new Array(stack.length);var n=stack[stack.length-1];cstack[cstack.length-1]=new RBNode(n._color,n.key,n.value,n.left,n.right,n._count);for(var i=stack.length-2;i>=0;--i){var n=stack[i];if(n.left===stack[i+1]){cstack[i]=new RBNode(n._color,n.key,n.value,cstack[i+1],n.right,n._count)}else{cstack[i]=new RBNode(n._color,n.key,n.value,n.left,cstack[i+1],n._count)}}n=cstack[cstack.length-1];if(n.left&&n.right){var split=cstack.length;n=n.left;while(n.right){cstack.push(n);n=n.right}var v=cstack[split-1];cstack.push(new RBNode(n._color,v.key,v.value,n.left,n.right,n._count));cstack[split-1].key=n.key;cstack[split-1].value=n.value;for(var i=cstack.length-2;i>=split;--i){n=cstack[i];cstack[i]=new RBNode(n._color,n.key,n.value,n.left,cstack[i+1],n._count)}cstack[split-1].left=cstack[split]}n=cstack[cstack.length-1];if(n._color===RED){var p=cstack[cstack.length-2];if(p.left===n){p.left=null}else if(p.right===n){p.right=null}cstack.pop();for(var i=0;i<cstack.length;++i){cstack[i]._count--}return new RedBlackTree(this.tree._compare,cstack[0])}else{if(n.left||n.right){if(n.left){swapNode(n,n.left)}else if(n.right){swapNode(n,n.right)}n._color=BLACK;for(var i=0;i<cstack.length-1;++i){cstack[i]._count--}return new RedBlackTree(this.tree._compare,cstack[0])}else if(cstack.length===1){return new RedBlackTree(this.tree._compare,null)}else{for(var i=0;i<cstack.length;++i){cstack[i]._count--}var parent=cstack[cstack.length-2];fixDoubleBlack(cstack);if(parent.left===n){parent.left=null}else{parent.right=null}}}return new RedBlackTree(this.tree._compare,cstack[0])};Object.defineProperty(iproto,"key",{get:function(){if(this._stack.length>0){return this._stack[this._stack.length-1].key}return},enumerable:true});Object.defineProperty(iproto,"value",{get:function(){if(this._stack.length>0){return this._stack[this._stack.length-1].value}return},enumerable:true});Object.defineProperty(iproto,"index",{get:function(){var idx=0;var stack=this._stack;if(stack.length===0){var r=this.tree.root;if(r){return r._count}return 0}else if(stack[stack.length-1].left){idx=stack[stack.length-1].left._count}for(var s=stack.length-2;s>=0;--s){if(stack[s+1]===stack[s].right){++idx;if(stack[s].left){idx+=stack[s].left._count}}}return idx},enumerable:true});iproto.next=function(){var stack=this._stack;if(stack.length===0){return}var n=stack[stack.length-1];if(n.right){n=n.right;while(n){stack.push(n);n=n.left}}else{stack.pop();while(stack.length>0&&stack[stack.length-1].right===n){n=stack[stack.length-1];stack.pop()}}};Object.defineProperty(iproto,"hasNext",{get:function(){var stack=this._stack;if(stack.length===0){return false}if(stack[stack.length-1].right){return true}for(var s=stack.length-1;s>0;--s){if(stack[s-1].left===stack[s]){return true}}return false}});iproto.update=function(value){var stack=this._stack;if(stack.length===0){throw new Error("Can't update empty node!")}var cstack=new Array(stack.length);var n=stack[stack.length-1];cstack[cstack.length-1]=new RBNode(n._color,n.key,value,n.left,n.right,n._count);for(var i=stack.length-2;i>=0;--i){n=stack[i];if(n.left===stack[i+1]){cstack[i]=new RBNode(n._color,n.key,n.value,cstack[i+1],n.right,n._count)}else{cstack[i]=new RBNode(n._color,n.key,n.value,n.left,cstack[i+1],n._count)}}return new RedBlackTree(this.tree._compare,cstack[0])};iproto.prev=function(){var stack=this._stack;if(stack.length===0){return}var n=stack[stack.length-1];if(n.left){n=n.left;while(n){stack.push(n);n=n.right}}else{stack.pop();while(stack.length>0&&stack[stack.length-1].left===n){n=stack[stack.length-1];stack.pop()}}};Object.defineProperty(iproto,"hasPrev",{get:function(){var stack=this._stack;if(stack.length===0){return false}if(stack[stack.length-1].left){return true}for(var s=stack.length-1;s>0;--s){if(stack[s-1].right===stack[s]){return true}}return false}});function defaultCompare(a,b){if(a<b){return-1}if(a>b){return 1}return 0}function createRBTree(compare){return new RedBlackTree(compare||defaultCompare,null)}},{}],76:[function(require,module,exports){"use strict";module.exports=createSlabDecomposition;var bounds=require("binary-search-bounds");var createRBTree=require("functional-red-black-tree");var orient=require("robust-orientation");var orderSegments=require("./lib/order-segments");function SlabDecomposition(slabs,coordinates,horizontal){this.slabs=slabs;this.coordinates=coordinates;this.horizontal=horizontal}var proto=SlabDecomposition.prototype;function compareHorizontal(e,y){return e.y-y}function searchBucket(root,p){var lastNode=null;while(root){var seg=root.key;var l,r;if(seg[0][0]<seg[1][0]){l=seg[0];r=seg[1]}else{l=seg[1];r=seg[0]}var o=orient(l,r,p);if(o<0){root=root.left}else if(o>0){if(p[0]!==seg[1][0]){lastNode=root;root=root.right}else{var val=searchBucket(root.right,p);if(val){return val}root=root.left}}else{if(p[0]!==seg[1][0]){return root}else{var val=searchBucket(root.right,p);if(val){return val}root=root.left}}}return lastNode}proto.castUp=function(p){var bucket=bounds.le(this.coordinates,p[0]);if(bucket<0){return-1}var root=this.slabs[bucket];var hitNode=searchBucket(this.slabs[bucket],p);var lastHit=-1;if(hitNode){lastHit=hitNode.value}if(this.coordinates[bucket]===p[0]){var lastSegment=null;if(hitNode){lastSegment=hitNode.key}if(bucket>0){var otherHitNode=searchBucket(this.slabs[bucket-1],p);if(otherHitNode){if(lastSegment){if(orderSegments(otherHitNode.key,lastSegment)>0){lastSegment=otherHitNode.key;lastHit=otherHitNode.value}}else{lastHit=otherHitNode.value;lastSegment=otherHitNode.key}}}var horiz=this.horizontal[bucket];if(horiz.length>0){var hbucket=bounds.ge(horiz,p[1],compareHorizontal);if(hbucket<horiz.length){var e=horiz[hbucket];if(p[1]===e.y){if(e.closed){return e.index}else{while(hbucket<horiz.length-1&&horiz[hbucket+1].y===p[1]){hbucket=hbucket+1;e=horiz[hbucket];if(e.closed){return e.index}}if(e.y===p[1]&&!e.start){hbucket=hbucket+1;if(hbucket>=horiz.length){return lastHit}e=horiz[hbucket]}}}if(e.start){if(lastSegment){var o=orient(lastSegment[0],lastSegment[1],[p[0],e.y]);if(lastSegment[0][0]>lastSegment[1][0]){o=-o}if(o>0){lastHit=e.index}}else{lastHit=e.index}}else if(e.y!==p[1]){lastHit=e.index}}}}return lastHit};function IntervalSegment(y,index,start,closed){this.y=y;this.index=index;this.start=start;this.closed=closed}function Event(x,segment,create,index){this.x=x;this.segment=segment;this.create=create;this.index=index}function createSlabDecomposition(segments){var numSegments=segments.length;var numEvents=2*numSegments;var events=new Array(numEvents);for(var i=0;i<numSegments;++i){var s=segments[i];var f=s[0][0]<s[1][0];events[2*i]=new Event(s[0][0],s,f,i);events[2*i+1]=new Event(s[1][0],s,!f,i)}events.sort(function(a,b){var d=a.x-b.x;if(d){return d}d=a.create-b.create;if(d){return d}return Math.min(a.segment[0][1],a.segment[1][1])-Math.min(b.segment[0][1],b.segment[1][1])});var tree=createRBTree(orderSegments);var slabs=[];var lines=[];var horizontal=[];var lastX=-Infinity;for(var i=0;i<numEvents;){var x=events[i].x;var horiz=[];while(i<numEvents){var e=events[i];if(e.x!==x){break}i+=1;if(e.segment[0][0]===e.x&&e.segment[1][0]===e.x){if(e.create){if(e.segment[0][1]<e.segment[1][1]){horiz.push(new IntervalSegment(e.segment[0][1],e.index,true,true));horiz.push(new IntervalSegment(e.segment[1][1],e.index,false,false))}else{horiz.push(new IntervalSegment(e.segment[1][1],e.index,true,false));horiz.push(new IntervalSegment(e.segment[0][1],e.index,false,true))}}}else{if(e.create){tree=tree.insert(e.segment,e.index)}else{tree=tree.remove(e.segment)}}}slabs.push(tree.root);lines.push(x);horizontal.push(horiz)}return new SlabDecomposition(slabs,lines,horizontal)}},{"./lib/order-segments":74,"binary-search-bounds":72,"functional-red-black-tree":75,"robust-orientation":56}],77:[function(require,module,exports){module.exports=preprocessPolygon;var orient=require("robust-orientation")[3];var makeSlabs=require("slab-decomposition");var makeIntervalTree=require("interval-tree-1d");var bsearch=require("binary-search-bounds");function visitInterval(){return true}function intervalSearch(table){return function(x,y){var tree=table[x];if(tree){return!!tree.queryPoint(y,visitInterval)}return false}}function buildVerticalIndex(segments){var table={};for(var i=0;i<segments.length;++i){var s=segments[i];var x=s[0][0];var y0=s[0][1];var y1=s[1][1];var p=[Math.min(y0,y1),Math.max(y0,y1)];if(x in table){table[x].push(p)}else{table[x]=[p]}}var intervalTable={};var keys=Object.keys(table);for(var i=0;i<keys.length;++i){var segs=table[keys[i]];intervalTable[keys[i]]=makeIntervalTree(segs)}return intervalSearch(intervalTable)}function buildSlabSearch(slabs,coordinates){return function(p){var bucket=bsearch.le(coordinates,p[0]);if(bucket<0){return 1}var root=slabs[bucket];if(!root){if(bucket>0&&coordinates[bucket]===p[0]){root=slabs[bucket-1]}else{return 1}}var lastOrientation=1;while(root){var s=root.key;var o=orient(p,s[0],s[1]);if(s[0][0]<s[1][0]){if(o<0){root=root.left}else if(o>0){lastOrientation=-1;root=root.right}else{return 0}}else{if(o>0){root=root.left}else if(o<0){lastOrientation=1;root=root.right}else{return 0}}}return lastOrientation}}function classifyEmpty(p){return 1}function createClassifyVertical(testVertical){return function classify(p){if(testVertical(p[0],p[1])){return 0}return 1}}function createClassifyPointDegen(testVertical,testNormal){return function classify(p){if(testVertical(p[0],p[1])){return 0}return testNormal(p)}}function preprocessPolygon(loops){var numLoops=loops.length;var segments=[];var vsegments=[];var ptr=0;for(var i=0;i<numLoops;++i){var loop=loops[i];var numVertices=loop.length;for(var s=numVertices-1,t=0;t<numVertices;s=t++){var a=loop[s];var b=loop[t];if(a[0]===b[0]){vsegments.push([a,b])}else{segments.push([a,b])}}}if(segments.length===0){if(vsegments.length===0){return classifyEmpty}else{return createClassifyVertical(buildVerticalIndex(vsegments))}}var slabs=makeSlabs(segments);var testSlab=buildSlabSearch(slabs.slabs,slabs.coordinates);if(vsegments.length===0){ | |
return testSlab}else{return createClassifyPointDegen(buildVerticalIndex(vsegments),testSlab)}}},{"binary-search-bounds":72,"interval-tree-1d":73,"robust-orientation":56,"slab-decomposition":76}],78:[function(require,module,exports){arguments[4][54][0].apply(exports,arguments)},{dup:54}],79:[function(require,module,exports){arguments[4][55][0].apply(exports,arguments)},{dup:55}],80:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments)},{dup:12}],81:[function(require,module,exports){"use strict";module.exports=planarGraphToPolyline;var e2a=require("edges-to-adjacency-list");var planarDual=require("planar-dual");var preprocessPolygon=require("point-in-big-polygon");var twoProduct=require("two-product");var robustSum=require("robust-sum");var uniq=require("uniq");var trimLeaves=require("./lib/trim-leaves");function makeArray(length,fill){var result=new Array(length);for(var i=0;i<length;++i){result[i]=fill}return result}function makeArrayOfArrays(length){var result=new Array(length);for(var i=0;i<length;++i){result[i]=[]}return result}function planarGraphToPolyline(edges,positions){var result=trimLeaves(edges,positions);edges=result[0];positions=result[1];var numVertices=positions.length;var numEdges=edges.length;var adj=e2a(edges,positions.length);for(var i=0;i<numVertices;++i){if(adj[i].length%2===1){throw new Error("planar-graph-to-polyline: graph must be manifold")}}var faces=planarDual(edges,positions);function ccw(c){var n=c.length;var area=[0];for(var j=0;j<n;++j){var a=positions[c[j]];var b=positions[c[(j+1)%n]];var t00=twoProduct(-a[0],a[1]);var t01=twoProduct(-a[0],b[1]);var t10=twoProduct(b[0],a[1]);var t11=twoProduct(b[0],b[1]);area=robustSum(area,robustSum(robustSum(t00,t01),robustSum(t10,t11)))}return area[area.length-1]>0}faces=faces.filter(ccw);var numFaces=faces.length;var parent=new Array(numFaces);var containment=new Array(numFaces);for(var i=0;i<numFaces;++i){parent[i]=i;var row=new Array(numFaces);var loopVertices=faces[i].map(function(v){return positions[v]});var pmc=preprocessPolygon([loopVertices]);var count=0;outer:for(var j=0;j<numFaces;++j){row[j]=0;if(i===j){continue}var c=faces[j];var n=c.length;for(var k=0;k<n;++k){var d=pmc(positions[c[k]]);if(d!==0){if(d<0){row[j]=1;count+=1}continue outer}}row[j]=1;count+=1}containment[i]=[count,i,row]}containment.sort(function(a,b){return b[0]-a[0]});for(var i=0;i<numFaces;++i){var row=containment[i];var idx=row[1];var children=row[2];for(var j=0;j<numFaces;++j){if(children[j]){parent[j]=idx}}}var fadj=makeArrayOfArrays(numFaces);for(var i=0;i<numFaces;++i){fadj[i].push(parent[i]);fadj[parent[i]].push(i)}var edgeAdjacency={};var internalVertices=makeArray(numVertices,false);for(var i=0;i<numFaces;++i){var c=faces[i];var n=c.length;for(var j=0;j<n;++j){var a=c[j];var b=c[(j+1)%n];var key=Math.min(a,b)+":"+Math.max(a,b);if(key in edgeAdjacency){var neighbor=edgeAdjacency[key];fadj[neighbor].push(i);fadj[i].push(neighbor);internalVertices[a]=internalVertices[b]=true}else{edgeAdjacency[key]=i}}}function sharedBoundary(c){var n=c.length;for(var i=0;i<n;++i){if(!internalVertices[c[i]]){return false}}return true}var toVisit=[];var parity=makeArray(numFaces,-1);for(var i=0;i<numFaces;++i){if(parent[i]===i&&!sharedBoundary(faces[i])){toVisit.push(i);parity[i]=0}else{parity[i]=-1}}var result=[];while(toVisit.length>0){var top=toVisit.pop();var nbhd=fadj[top];uniq(nbhd,function(a,b){return a-b});var nnbhr=nbhd.length;var p=parity[top];var polyline;if(p===0){var c=faces[top];polyline=[c]}for(var i=0;i<nnbhr;++i){var f=nbhd[i];if(parity[f]>=0){continue}parity[f]=p^1;toVisit.push(f);if(p===0){var c=faces[f];if(!sharedBoundary(c)){c.reverse();polyline.push(c)}}}if(p===0){result.push(polyline)}}return result}},{"./lib/trim-leaves":64,"edges-to-adjacency-list":65,"planar-dual":66,"point-in-big-polygon":77,"robust-sum":78,"two-product":79,uniq:80}],82:[function(require,module,exports){arguments[4][13][0].apply(exports,arguments)},{dup:13}],83:[function(require,module,exports){"use strict";"use restrict";module.exports=UnionFind;function UnionFind(count){this.roots=new Array(count);this.ranks=new Array(count);for(var i=0;i<count;++i){this.roots[i]=i;this.ranks[i]=0}}UnionFind.prototype.length=function(){return this.roots.length};UnionFind.prototype.makeSet=function(){var n=this.roots.length;this.roots.push(n);this.ranks.push(0);return n};UnionFind.prototype.find=function(x){var roots=this.roots;while(roots[x]!==x){var y=roots[x];roots[x]=roots[y];x=y}return x};UnionFind.prototype.link=function(x,y){var xr=this.find(x),yr=this.find(y);if(xr===yr){return}var ranks=this.ranks,roots=this.roots,xd=ranks[xr],yd=ranks[yr];if(xd<yd){roots[xr]=yr}else if(yd<xd){roots[yr]=xr}else{roots[yr]=xr;++ranks[xr]}}},{}],84:[function(require,module,exports){"use strict";"use restrict";var bits=require("bit-twiddle"),UnionFind=require("union-find");function dimension(cells){var d=0,max=Math.max;for(var i=0,il=cells.length;i<il;++i){d=max(d,cells[i].length)}return d-1}exports.dimension=dimension;function countVertices(cells){var vc=-1,max=Math.max;for(var i=0,il=cells.length;i<il;++i){var c=cells[i];for(var j=0,jl=c.length;j<jl;++j){vc=max(vc,c[j])}}return vc+1}exports.countVertices=countVertices;function cloneCells(cells){var ncells=new Array(cells.length);for(var i=0,il=cells.length;i<il;++i){ncells[i]=cells[i].slice(0)}return ncells}exports.cloneCells=cloneCells;function compareCells(a,b){var n=a.length,t=a.length-b.length,min=Math.min;if(t){return t}switch(n){case 0:return 0;case 1:return a[0]-b[0];case 2:var d=a[0]+a[1]-b[0]-b[1];if(d){return d}return min(a[0],a[1])-min(b[0],b[1]);case 3:var l1=a[0]+a[1],m1=b[0]+b[1];d=l1+a[2]-(m1+b[2]);if(d){return d}var l0=min(a[0],a[1]),m0=min(b[0],b[1]),d=min(l0,a[2])-min(m0,b[2]);if(d){return d}return min(l0+a[2],l1)-min(m0+b[2],m1);default:var as=a.slice(0);as.sort();var bs=b.slice(0);bs.sort();for(var i=0;i<n;++i){t=as[i]-bs[i];if(t){return t}}return 0}}exports.compareCells=compareCells;function compareZipped(a,b){return compareCells(a[0],b[0])}function normalize(cells,attr){if(attr){var len=cells.length;var zipped=new Array(len);for(var i=0;i<len;++i){zipped[i]=[cells[i],attr[i]]}zipped.sort(compareZipped);for(var i=0;i<len;++i){cells[i]=zipped[i][0];attr[i]=zipped[i][1]}return cells}else{cells.sort(compareCells);return cells}}exports.normalize=normalize;function unique(cells){if(cells.length===0){return[]}var ptr=1,len=cells.length;for(var i=1;i<len;++i){var a=cells[i];if(compareCells(a,cells[i-1])){if(i===ptr){ptr++;continue}cells[ptr++]=a}}cells.length=ptr;return cells}exports.unique=unique;function findCell(cells,c){var lo=0,hi=cells.length-1,r=-1;while(lo<=hi){var mid=lo+hi>>1,s=compareCells(cells[mid],c);if(s<=0){if(s===0){r=mid}lo=mid+1}else if(s>0){hi=mid-1}}return r}exports.findCell=findCell;function incidence(from_cells,to_cells){var index=new Array(from_cells.length);for(var i=0,il=index.length;i<il;++i){index[i]=[]}var b=[];for(var i=0,n=to_cells.length;i<n;++i){var c=to_cells[i];var cl=c.length;for(var k=1,kn=1<<cl;k<kn;++k){b.length=bits.popCount(k);var l=0;for(var j=0;j<cl;++j){if(k&1<<j){b[l++]=c[j]}}var idx=findCell(from_cells,b);if(idx<0){continue}while(true){index[idx++].push(i);if(idx>=from_cells.length||compareCells(from_cells[idx],b)!==0){break}}}}return index}exports.incidence=incidence;function dual(cells,vertex_count){if(!vertex_count){return incidence(unique(skeleton(cells,0)),cells,0)}var res=new Array(vertex_count);for(var i=0;i<vertex_count;++i){res[i]=[]}for(var i=0,len=cells.length;i<len;++i){var c=cells[i];for(var j=0,cl=c.length;j<cl;++j){res[c[j]].push(i)}}return res}exports.dual=dual;function explode(cells){var result=[];for(var i=0,il=cells.length;i<il;++i){var c=cells[i],cl=c.length|0;for(var j=1,jl=1<<cl;j<jl;++j){var b=[];for(var k=0;k<cl;++k){if(j>>>k&1){b.push(c[k])}}result.push(b)}}return normalize(result)}exports.explode=explode;function skeleton(cells,n){if(n<0){return[]}var result=[],k0=(1<<n+1)-1;for(var i=0;i<cells.length;++i){var c=cells[i];for(var k=k0;k<1<<c.length;k=bits.nextCombination(k)){var b=new Array(n+1),l=0;for(var j=0;j<c.length;++j){if(k&1<<j){b[l++]=c[j]}}result.push(b)}}return normalize(result)}exports.skeleton=skeleton;function boundary(cells){var res=[];for(var i=0,il=cells.length;i<il;++i){var c=cells[i];for(var j=0,cl=c.length;j<cl;++j){var b=new Array(c.length-1);for(var k=0,l=0;k<cl;++k){if(k!==j){b[l++]=c[k]}}res.push(b)}}return normalize(res)}exports.boundary=boundary;function connectedComponents_dense(cells,vertex_count){var labels=new UnionFind(vertex_count);for(var i=0;i<cells.length;++i){var c=cells[i];for(var j=0;j<c.length;++j){for(var k=j+1;k<c.length;++k){labels.link(c[j],c[k])}}}var components=[],component_labels=labels.ranks;for(var i=0;i<component_labels.length;++i){component_labels[i]=-1}for(var i=0;i<cells.length;++i){var l=labels.find(cells[i][0]);if(component_labels[l]<0){component_labels[l]=components.length;components.push([cells[i].slice(0)])}else{components[component_labels[l]].push(cells[i].slice(0))}}return components}function connectedComponents_sparse(cells){var vertices=unique(normalize(skeleton(cells,0))),labels=new UnionFind(vertices.length);for(var i=0;i<cells.length;++i){var c=cells[i];for(var j=0;j<c.length;++j){var vj=findCell(vertices,[c[j]]);for(var k=j+1;k<c.length;++k){labels.link(vj,findCell(vertices,[c[k]]))}}}var components=[],component_labels=labels.ranks;for(var i=0;i<component_labels.length;++i){component_labels[i]=-1}for(var i=0;i<cells.length;++i){var l=labels.find(findCell(vertices,[cells[i][0]]));if(component_labels[l]<0){component_labels[l]=components.length;components.push([cells[i].slice(0)])}else{components[component_labels[l]].push(cells[i].slice(0))}}return components}function connectedComponents(cells,vertex_count){if(vertex_count){return connectedComponents_dense(cells,vertex_count)}return connectedComponents_sparse(cells)}exports.connectedComponents=connectedComponents},{"bit-twiddle":82,"union-find":83}],85:[function(require,module,exports){"use strict";module.exports=simplifyPolygon;var orient=require("robust-orientation");var sc=require("simplicial-complex");function errorWeight(base,a,b){var area=Math.abs(orient(base,a,b));var perim=Math.sqrt(Math.pow(a[0]-b[0],2)+Math.pow(a[1]-b[1],2));return area/perim}function simplifyPolygon(cells,positions,minArea){var n=positions.length;var nc=cells.length;var inv=new Array(n);var outv=new Array(n);var weights=new Array(n);var dead=new Array(n);for(var i=0;i<n;++i){inv[i]=outv[i]=-1;weights[i]=Infinity;dead[i]=false}for(var i=0;i<nc;++i){var c=cells[i];if(c.length!==2){throw new Error("Input must be a graph")}var s=c[1];var t=c[0];if(outv[t]!==-1){outv[t]=-2}else{outv[t]=s}if(inv[s]!==-1){inv[s]=-2}else{inv[s]=t}}function computeWeight(i){if(dead[i]){return Infinity}var s=inv[i];var t=outv[i];if(s<0||t<0){return Infinity}else{return errorWeight(positions[i],positions[s],positions[t])}}function heapSwap(i,j){var a=heap[i];var b=heap[j];heap[i]=b;heap[j]=a;index[a]=j;index[b]=i}function heapWeight(i){return weights[heap[i]]}function heapParent(i){if(i&1){return i-1>>1}return(i>>1)-1}function heapDown(i){var w=heapWeight(i);while(true){var tw=w;var left=2*i+1;var right=2*(i+1);var next=i;if(left<heapCount){var lw=heapWeight(left);if(lw<tw){next=left;tw=lw}}if(right<heapCount){var rw=heapWeight(right);if(rw<tw){next=right}}if(next===i){return i}heapSwap(i,next);i=next}}function heapUp(i){var w=heapWeight(i);while(i>0){var parent=heapParent(i);if(parent>=0){var pw=heapWeight(parent);if(w<pw){heapSwap(i,parent);i=parent;continue}}return i}}function heapPop(){if(heapCount>0){var head=heap[0];heapSwap(0,heapCount-1);heapCount-=1;heapDown(0);return head}return-1}function heapUpdate(i,w){var a=heap[i];if(weights[a]===w){return i}weights[a]=-Infinity;heapUp(i);heapPop();weights[a]=w;heapCount+=1;return heapUp(heapCount-1)}function kill(i){if(dead[i]){return}dead[i]=true;var s=inv[i];var t=outv[i];if(inv[t]>=0){inv[t]=s}if(outv[s]>=0){outv[s]=t}if(index[s]>=0){heapUpdate(index[s],computeWeight(s))}if(index[t]>=0){heapUpdate(index[t],computeWeight(t))}}var heap=[];var index=new Array(n);for(var i=0;i<n;++i){var w=weights[i]=computeWeight(i);if(w<Infinity){index[i]=heap.length;heap.push(i)}else{index[i]=-1}}var heapCount=heap.length;for(var i=heapCount>>1;i>=0;--i){heapDown(i)}while(true){var hmin=heapPop();if(hmin<0||weights[hmin]>minArea){break}kill(hmin)}var npositions=[];for(var i=0;i<n;++i){if(!dead[i]){index[i]=npositions.length;npositions.push(positions[i].slice())}}var nv=npositions.length;function tortoiseHare(seq,start){if(seq[start]<0){return start}var t=start;var h=start;do{var nh=seq[h];if(!dead[h]||nh<0||nh===h){break}h=nh;nh=seq[h];if(!dead[h]||nh<0||nh===h){break}h=nh;t=seq[t]}while(t!==h);for(var v=start;v!==h;v=seq[v]){seq[v]=h}return h}var ncells=[];cells.forEach(function(c){var tin=tortoiseHare(inv,c[0]);var tout=tortoiseHare(outv,c[1]);if(tin>=0&&tout>=0&&tin!==tout){var cin=index[tin];var cout=index[tout];if(cin!==cout){ncells.push([cin,cout])}}});sc.unique(sc.normalize(ncells));return{positions:npositions,edges:ncells}}},{"robust-orientation":56,"simplicial-complex":84}],86:[function(require,module,exports){"use strict";var pool=require("typedarray-pool");module.exports=createSurfaceExtractor;function array(i){return"a"+i}function data(i){return"d"+i}function cube(i,bitmask){return"c"+i+"_"+bitmask}function shape(i){return"s"+i}function stride(i,j){return"t"+i+"_"+j}function offset(i){return"o"+i}function scalar(i){return"x"+i}function pointer(i){return"p"+i}function delta(i,bitmask){return"d"+i+"_"+bitmask}function index(i){return"i"+i}function step(i,j){return"u"+i+"_"+j}function pcube(bitmask){return"b"+bitmask}function qcube(bitmask){return"y"+bitmask}function pdelta(bitmask){return"e"+bitmask}function vert(i){return"v"+i}var VERTEX_IDS="V";var PHASES="P";var VERTEX_COUNT="N";var POOL_SIZE="Q";var POINTER="X";var TEMPORARY="T";function permBitmask(dimension,mask,order){var r=0;for(var i=0;i<dimension;++i){if(mask&1<<i){r|=1<<order[i]}}return r}function compileSurfaceProcedure(vertexFunc,faceFunc,phaseFunc,scalarArgs,order,typesig){var arrayArgs=typesig.length;var dimension=order.length;if(dimension<2){throw new Error("ndarray-extract-contour: Dimension must be at least 2")}var funcName="extractContour"+order.join("_");var code=[];var vars=[];var args=[];for(var i=0;i<arrayArgs;++i){args.push(array(i))}for(var i=0;i<scalarArgs;++i){args.push(scalar(i))}for(var i=0;i<dimension;++i){vars.push(shape(i)+"="+array(0)+".shape["+i+"]|0")}for(var i=0;i<arrayArgs;++i){vars.push(data(i)+"="+array(i)+".data",offset(i)+"="+array(i)+".offset|0");for(var j=0;j<dimension;++j){vars.push(stride(i,j)+"="+array(i)+".stride["+j+"]|0")}}for(var i=0;i<arrayArgs;++i){vars.push(pointer(i)+"="+offset(i));vars.push(cube(i,0));for(var j=1;j<1<<dimension;++j){var ptrStr=[];for(var k=0;k<dimension;++k){if(j&1<<k){ptrStr.push("-"+stride(i,k))}}vars.push(delta(i,j)+"=("+ptrStr.join("")+")|0");vars.push(cube(i,j)+"=0")}}for(var i=0;i<arrayArgs;++i){for(var j=0;j<dimension;++j){var stepVal=[stride(i,order[j])];if(j>0){stepVal.push(stride(i,order[j-1])+"*"+shape(order[j-1]))}vars.push(step(i,order[j])+"=("+stepVal.join("-")+")|0")}}for(var i=0;i<dimension;++i){vars.push(index(i)+"=0")}vars.push(VERTEX_COUNT+"=0");var sizeVariable=["2"];for(var i=dimension-2;i>=0;--i){sizeVariable.push(shape(order[i]))}vars.push(POOL_SIZE+"=("+sizeVariable.join("*")+")|0",PHASES+"=mallocUint32("+POOL_SIZE+")",VERTEX_IDS+"=mallocUint32("+POOL_SIZE+")",POINTER+"=0");vars.push(pcube(0)+"=0");for(var j=1;j<1<<dimension;++j){var cubeDelta=[];var cubeStep=[];for(var k=0;k<dimension;++k){if(j&1<<k){if(cubeStep.length===0){cubeDelta.push("1")}else{cubeDelta.unshift(cubeStep.join("*"))}}cubeStep.push(shape(order[k]))}var signFlag="";if(cubeDelta[0].indexOf(shape(order[dimension-2]))<0){signFlag="-"}var jperm=permBitmask(dimension,j,order);vars.push(pdelta(jperm)+"=(-"+cubeDelta.join("-")+")|0",qcube(jperm)+"=("+signFlag+cubeDelta.join("-")+")|0",pcube(jperm)+"=0")}vars.push(vert(0)+"=0",TEMPORARY+"=0");function forLoopBegin(i,start){code.push("for(",index(order[i]),"=",start,";",index(order[i]),"<",shape(order[i]),";","++",index(order[i]),"){")}function forLoopEnd(i){for(var j=0;j<arrayArgs;++j){code.push(pointer(j),"+=",step(j,order[i]),";")}code.push("}")}function fillEmptySlice(k){for(var i=k-1;i>=0;--i){forLoopBegin(i,0)}var phaseFuncArgs=[];for(var i=0;i<arrayArgs;++i){if(typesig[i]){phaseFuncArgs.push(data(i)+".get("+pointer(i)+")")}else{phaseFuncArgs.push(data(i)+"["+pointer(i)+"]")}}for(var i=0;i<scalarArgs;++i){phaseFuncArgs.push(scalar(i))}code.push(PHASES,"[",POINTER,"++]=phase(",phaseFuncArgs.join(),");");for(var i=0;i<k;++i){forLoopEnd(i)}for(var j=0;j<arrayArgs;++j){code.push(pointer(j),"+=",step(j,order[k]),";")}}function processGridCell(mask){for(var i=0;i<arrayArgs;++i){if(typesig[i]){code.push(cube(i,0),"=",data(i),".get(",pointer(i),");")}else{code.push(cube(i,0),"=",data(i),"[",pointer(i),"];")}}var phaseFuncArgs=[];for(var i=0;i<arrayArgs;++i){phaseFuncArgs.push(cube(i,0))}for(var i=0;i<scalarArgs;++i){phaseFuncArgs.push(scalar(i))}code.push(pcube(0),"=",PHASES,"[",POINTER,"]=phase(",phaseFuncArgs.join(),");");for(var j=1;j<1<<dimension;++j){code.push(pcube(j),"=",PHASES,"[",POINTER,"+",pdelta(j),"];")}var vertexPredicate=[];for(var j=1;j<1<<dimension;++j){vertexPredicate.push("("+pcube(0)+"!=="+pcube(j)+")")}code.push("if(",vertexPredicate.join("||"),"){");var vertexArgs=[];for(var i=0;i<dimension;++i){vertexArgs.push(index(i))}for(var i=0;i<arrayArgs;++i){vertexArgs.push(cube(i,0));for(var j=1;j<1<<dimension;++j){if(typesig[i]){code.push(cube(i,j),"=",data(i),".get(",pointer(i),"+",delta(i,j),");")}else{code.push(cube(i,j),"=",data(i),"[",pointer(i),"+",delta(i,j),"];")}vertexArgs.push(cube(i,j))}}for(var i=0;i<1<<dimension;++i){vertexArgs.push(pcube(i))}for(var i=0;i<scalarArgs;++i){vertexArgs.push(scalar(i))}code.push("vertex(",vertexArgs.join(),");",vert(0),"=",VERTEX_IDS,"[",POINTER,"]=",VERTEX_COUNT,"++;");var base=(1<<dimension)-1;var corner=pcube(base);for(var j=0;j<dimension;++j){if((mask&~(1<<j))===0){var subset=base^1<<j;var edge=pcube(subset);var faceArgs=[];for(var k=subset;k>0;k=k-1&subset){faceArgs.push(VERTEX_IDS+"["+POINTER+"+"+pdelta(k)+"]")}faceArgs.push(vert(0));for(var k=0;k<arrayArgs;++k){if(j&1){faceArgs.push(cube(k,base),cube(k,subset))}else{faceArgs.push(cube(k,subset),cube(k,base))}}if(j&1){faceArgs.push(corner,edge)}else{faceArgs.push(edge,corner)}for(var k=0;k<scalarArgs;++k){faceArgs.push(scalar(k))}code.push("if(",corner,"!==",edge,"){","face(",faceArgs.join(),")}")}}code.push("}",POINTER,"+=1;")}function flip(){for(var j=1;j<1<<dimension;++j){code.push(TEMPORARY,"=",pdelta(j),";",pdelta(j),"=",qcube(j),";",qcube(j),"=",TEMPORARY,";")}}function createLoop(i,mask){if(i<0){processGridCell(mask);return}fillEmptySlice(i);code.push("if(",shape(order[i]),">0){",index(order[i]),"=1;");createLoop(i-1,mask|1<<order[i]);for(var j=0;j<arrayArgs;++j){code.push(pointer(j),"+=",step(j,order[i]),";")}if(i===dimension-1){code.push(POINTER,"=0;");flip()}forLoopBegin(i,2);createLoop(i-1,mask);if(i===dimension-1){code.push("if(",index(order[dimension-1]),"&1){",POINTER,"=0;}");flip()}forLoopEnd(i);code.push("}")}createLoop(dimension-1,0);code.push("freeUint32(",VERTEX_IDS,");freeUint32(",PHASES,");");var procedureCode=["'use strict';","function ",funcName,"(",args.join(),"){","var ",vars.join(),";",code.join(""),"}","return ",funcName].join("");var proc=new Function("vertex","face","phase","mallocUint32","freeUint32",procedureCode);return proc(vertexFunc,faceFunc,phaseFunc,pool.mallocUint32,pool.freeUint32)}function createSurfaceExtractor(args){function error(msg){throw new Error("ndarray-extract-contour: "+msg)}if(typeof args!=="object"){error("Must specify arguments")}var order=args.order;if(!Array.isArray(order)){error("Must specify order")}var arrays=args.arrayArguments||1;if(arrays<1){error("Must have at least one array argument")}var scalars=args.scalarArguments||0;if(scalars<0){error("Scalar arg count must be > 0")}if(typeof args.vertex!=="function"){error("Must specify vertex creation function")}if(typeof args.cell!=="function"){error("Must specify cell creation function")}if(typeof args.phase!=="function"){error("Must specify phase function")}var getters=args.getters||[];var typesig=new Array(arrays);for(var i=0;i<arrays;++i){if(getters.indexOf(i)>=0){typesig[i]=true}else{typesig[i]=false}}return compileSurfaceProcedure(args.vertex,args.cell,args.phase,scalars,order,typesig)}},{"typedarray-pool":87}],87:[function(require,module,exports){(function(global,Buffer){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0]),UINT8C:dup([32,0]),BUFFER:dup([32,0])}}var hasUint8C=typeof Uint8ClampedArray!=="undefined";var POOL=global.__TYPEDARRAY_POOL;if(!POOL.UINT8C){POOL.UINT8C=dup([32,0])}if(!POOL.BUFFER){POOL.BUFFER=dup([32,0])}var DATA=POOL.DATA,BUFFER=POOL.BUFFER;exports.free=function free(array){if(Buffer.isBuffer(array)){BUFFER[bits.log2(array.length)].push(array)}else{if(Object.prototype.toString.call(array)!=="[object ArrayBuffer]"){array=array.buffer}if(!array){return}var n=array.length||array.byteLength;var log_n=bits.log2(n)|0;DATA[log_n].push(array)}};function freeArrayBuffer(buffer){if(!buffer){return}var n=buffer.length||buffer.byteLength;var log_n=bits.log2(n);DATA[log_n].push(buffer)}function freeTypedArray(array){freeArrayBuffer(array.buffer)}exports.freeUint8=exports.freeUint16=exports.freeUint32=exports.freeInt8=exports.freeInt16=exports.freeInt32=exports.freeFloat32=exports.freeFloat=exports.freeFloat64=exports.freeDouble=exports.freeUint8Clamped=exports.freeDataView=freeTypedArray;exports.freeArrayBuffer=freeArrayBuffer;exports.freeBuffer=function freeBuffer(array){BUFFER[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){if(dtype===undefined||dtype==="arraybuffer"){return mallocArrayBuffer(n)}else{switch(dtype){case"uint8":return mallocUint8(n);case"uint16":return mallocUint16(n);case"uint32":return mallocUint32(n);case"int8":return mallocInt8(n);case"int16":return mallocInt16(n);case"int32":return mallocInt32(n);case"float":case"float32":return mallocFloat(n);case"double":case"float64":return mallocDouble(n);case"uint8_clamped":return mallocUint8Clamped(n);case"buffer":return mallocBuffer(n);case"data":case"dataview":return mallocDataView(n);default:return null}}return null};function mallocArrayBuffer(n){var n=bits.nextPow2(n);var log_n=bits.log2(n);var d=DATA[log_n];if(d.length>0){return d.pop()}return new ArrayBuffer(n)}exports.mallocArrayBuffer=mallocArrayBuffer;function mallocUint8(n){return new Uint8Array(mallocArrayBuffer(n),0,n)}exports.mallocUint8=mallocUint8;function mallocUint16(n){return new Uint16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocUint16=mallocUint16;function mallocUint32(n){return new Uint32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocUint32=mallocUint32;function mallocInt8(n){return new Int8Array(mallocArrayBuffer(n),0,n)}exports.mallocInt8=mallocInt8;function mallocInt16(n){return new Int16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocInt16=mallocInt16;function mallocInt32(n){return new Int32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocInt32=mallocInt32;function mallocFloat(n){return new Float32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocFloat32=exports.mallocFloat=mallocFloat;function mallocDouble(n){return new Float64Array(mallocArrayBuffer(8*n),0,n)}exports.mallocFloat64=exports.mallocDouble=mallocDouble;function mallocUint8Clamped(n){if(hasUint8C){return new Uint8ClampedArray(mallocArrayBuffer(n),0,n)}else{return mallocUint8(n)}}exports.mallocUint8Clamped=mallocUint8Clamped;function mallocDataView(n){return new DataView(mallocArrayBuffer(n),0,n)}exports.mallocDataView=mallocDataView;function mallocBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=BUFFER[log_n];if(cache.length>0){return cache.pop()}return new Buffer(n)}exports.mallocBuffer=mallocBuffer;exports.clearCache=function clearCache(){for(var i=0;i<32;++i){POOL.UINT8[i].length=0;POOL.UINT16[i].length=0;POOL.UINT32[i].length=0;POOL.INT8[i].length=0;POOL.INT16[i].length=0;POOL.INT32[i].length=0;POOL.FLOAT[i].length=0;POOL.DOUBLE[i].length=0;POOL.UINT8C[i].length=0;DATA[i].length=0;BUFFER[i].length=0}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"bit-twiddle":32,buffer:1,dup:33}],88:[function(require,module,exports){var g=7;var p=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,1.5056327351493116e-7];var g_ln=607/128;var p_ln=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22];function lngamma(z){if(z<0)return Number("0/0");var x=p_ln[0];for(var i=p_ln.length-1;i>0;--i)x+=p_ln[i]/(z+i);var t=z+g_ln+.5;return.5*Math.log(2*Math.PI)+(z+.5)*Math.log(t)-t+Math.log(x)-Math.log(z)}module.exports=function gamma(z){if(z<.5){return Math.PI/(Math.sin(Math.PI*z)*gamma(1-z))}else if(z>100)return Math.exp(lngamma(z));else{z-=1;var x=p[0];for(var i=1;i<g+2;i++){x+=p[i]/(z+i)}var t=z+g+.5;return Math.sqrt(2*Math.PI)*Math.pow(t,z+.5)*Math.exp(-t)*x}};module.exports.log=lngamma},{}],89:[function(require,module,exports){(function(global,Buffer){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0]),UINT8C:dup([32,0]),BUFFER:dup([32,0])}}var hasUint8C=typeof Uint8ClampedArray!=="undefined";var POOL=global.__TYPEDARRAY_POOL;if(!POOL.UINT8C){POOL.UINT8C=dup([32,0])}if(!POOL.BUFFER){POOL.BUFFER=dup([32,0])}var DATA=POOL.DATA,BUFFER=POOL.BUFFER;exports.free=function free(array){if(Buffer.isBuffer(array)){BUFFER[bits.log2(array.length)].push(array)}else{if(Object.prototype.toString.call(array)!=="[object ArrayBuffer]"){array=array.buffer}if(!array){return}var n=array.length||array.byteLength;var log_n=bits.log2(n)|0;DATA[log_n].push(array)}};function freeArrayBuffer(buffer){if(!buffer){return}var n=buffer.length||buffer.byteLength;var log_n=bits.log2(n);DATA[log_n].push(buffer)}function freeTypedArray(array){freeArrayBuffer(array.buffer)}exports.freeUint8=exports.freeUint16=exports.freeUint32=exports.freeInt8=exports.freeInt16=exports.freeInt32=exports.freeFloat32=exports.freeFloat=exports.freeFloat64=exports.freeDouble=exports.freeUint8Clamped=exports.freeDataView=freeTypedArray;exports.freeArrayBuffer=freeArrayBuffer;exports.freeBuffer=function freeBuffer(array){BUFFER[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){if(dtype===undefined||dtype==="arraybuffer"){return mallocArrayBuffer(n)}else{switch(dtype){case"uint8":return mallocUint8(n);case"uint16":return mallocUint16(n);case"uint32":return mallocUint32(n);case"int8":return mallocInt8(n);case"int16":return mallocInt16(n);case"int32":return mallocInt32(n);case"float":case"float32":return mallocFloat(n);case"double":case"float64":return mallocDouble(n);case"uint8_clamped":return mallocUint8Clamped(n);case"buffer":return mallocBuffer(n);case"data":case"dataview":return mallocDataView(n);default:return null}}return null};function mallocArrayBuffer(n){var n=bits.nextPow2(n);var log_n=bits.log2(n);var d=DATA[log_n];if(d.length>0){return d.pop()}return new ArrayBuffer(n)}exports.mallocArrayBuffer=mallocArrayBuffer;function mallocUint8(n){return new Uint8Array(mallocArrayBuffer(n),0,n)}exports.mallocUint8=mallocUint8;function mallocUint16(n){return new Uint16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocUint16=mallocUint16;function mallocUint32(n){return new Uint32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocUint32=mallocUint32;function mallocInt8(n){return new Int8Array(mallocArrayBuffer(n),0,n)}exports.mallocInt8=mallocInt8;function mallocInt16(n){return new Int16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocInt16=mallocInt16;function mallocInt32(n){return new Int32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocInt32=mallocInt32;function mallocFloat(n){return new Float32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocFloat32=exports.mallocFloat=mallocFloat;function mallocDouble(n){return new Float64Array(mallocArrayBuffer(8*n),0,n)}exports.mallocFloat64=exports.mallocDouble=mallocDouble;function mallocUint8Clamped(n){if(hasUint8C){return new Uint8ClampedArray(mallocArrayBuffer(n),0,n)}else{return mallocUint8(n)}}exports.mallocUint8Clamped=mallocUint8Clamped;function mallocDataView(n){return new DataView(mallocArrayBuffer(n),0,n)}exports.mallocDataView=mallocDataView;function mallocBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=BUFFER[log_n];if(cache.length>0){return cache.pop()}return new Buffer(n)}exports.mallocBuffer=mallocBuffer;exports.clearCache=function clearCache(){for(var i=0;i<32;++i){POOL.UINT8[i].length=0;POOL.UINT16[i].length=0;POOL.UINT32[i].length=0;POOL.INT8[i].length=0;POOL.INT16[i].length=0;POOL.INT32[i].length=0;POOL.FLOAT[i].length=0;POOL.DOUBLE[i].length=0;POOL.UINT8C[i].length=0;DATA[i].length=0;BUFFER[i].length=0}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"bit-twiddle":32,buffer:1,dup:33}],90:[function(require,module,exports){"use strict";module.exports=permutationSign;var BRUTE_FORCE_CUTOFF=32;var pool=require("typedarray-pool");function permutationSign(p){var n=p.length;if(n<BRUTE_FORCE_CUTOFF){var sgn=1;for(var i=0;i<n;++i){for(var j=0;j<i;++j){if(p[i]<p[j]){sgn=-sgn}else if(p[i]===p[j]){return 0}}}return sgn}else{var visited=pool.mallocUint8(n);for(var i=0;i<n;++i){visited[i]=0}var sgn=1;for(var i=0;i<n;++i){if(!visited[i]){var count=1;visited[i]=1;for(var j=p[i];j!==i;j=p[j]){if(visited[j]){pool.freeUint8(visited);return 0}count+=1;visited[j]=1}if(!(count&1)){sgn=-sgn}}}pool.freeUint8(visited);return sgn}}},{"typedarray-pool":89}],91:[function(require,module,exports){"use strict";var pool=require("typedarray-pool");var inverse=require("invert-permutation");function rank(permutation){var n=permutation.length;switch(n){case 0:case 1:return 0;case 2:return permutation[1];default:break}var p=pool.mallocUint32(n);var pinv=pool.mallocUint32(n);var r=0,s,t,i;inverse(permutation,pinv);for(i=0;i<n;++i){p[i]=permutation[i]}for(i=n-1;i>0;--i){t=pinv[i];s=p[i];p[i]=p[t];p[t]=s;pinv[i]=pinv[s];pinv[s]=t;r=(r+s)*i}pool.freeUint32(pinv);pool.freeUint32(p);return r}function unrank(n,r,p){switch(n){case 0:if(p){return p}return[];case 1:if(p){p[0]=0;return p}else{return[0]}case 2:if(p){if(r){p[0]=0;p[1]=1}else{p[0]=1;p[1]=0}return p}else{return r?[0,1]:[1,0]}default:break}p=p||new Array(n);var s,t,i,nf=1;p[0]=0;for(i=1;i<n;++i){p[i]=i;nf=nf*i|0}for(i=n-1;i>0;--i){s=r/nf|0;r=r-s*nf|0;nf=nf/i|0;t=p[i]|0;p[i]=p[s]|0;p[s]=t|0}return p}exports.rank=rank;exports.unrank=unrank},{"invert-permutation":92,"typedarray-pool":93}],92:[function(require,module,exports){"use strict";function invertPermutation(pi,result){result=result||new Array(pi.length);for(var i=0;i<pi.length;++i){result[pi[i]]=i}return result}module.exports=invertPermutation},{}],93:[function(require,module,exports){(function(global,Buffer){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){ | |
global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0]),UINT8C:dup([32,0]),BUFFER:dup([32,0])}}var hasUint8C=typeof Uint8ClampedArray!=="undefined";var POOL=global.__TYPEDARRAY_POOL;if(!POOL.UINT8C){POOL.UINT8C=dup([32,0])}if(!POOL.BUFFER){POOL.BUFFER=dup([32,0])}var DATA=POOL.DATA,BUFFER=POOL.BUFFER;exports.free=function free(array){if(Buffer.isBuffer(array)){BUFFER[bits.log2(array.length)].push(array)}else{if(Object.prototype.toString.call(array)!=="[object ArrayBuffer]"){array=array.buffer}if(!array){return}var n=array.length||array.byteLength;var log_n=bits.log2(n)|0;DATA[log_n].push(array)}};function freeArrayBuffer(buffer){if(!buffer){return}var n=buffer.length||buffer.byteLength;var log_n=bits.log2(n);DATA[log_n].push(buffer)}function freeTypedArray(array){freeArrayBuffer(array.buffer)}exports.freeUint8=exports.freeUint16=exports.freeUint32=exports.freeInt8=exports.freeInt16=exports.freeInt32=exports.freeFloat32=exports.freeFloat=exports.freeFloat64=exports.freeDouble=exports.freeUint8Clamped=exports.freeDataView=freeTypedArray;exports.freeArrayBuffer=freeArrayBuffer;exports.freeBuffer=function freeBuffer(array){BUFFER[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){if(dtype===undefined||dtype==="arraybuffer"){return mallocArrayBuffer(n)}else{switch(dtype){case"uint8":return mallocUint8(n);case"uint16":return mallocUint16(n);case"uint32":return mallocUint32(n);case"int8":return mallocInt8(n);case"int16":return mallocInt16(n);case"int32":return mallocInt32(n);case"float":case"float32":return mallocFloat(n);case"double":case"float64":return mallocDouble(n);case"uint8_clamped":return mallocUint8Clamped(n);case"buffer":return mallocBuffer(n);case"data":case"dataview":return mallocDataView(n);default:return null}}return null};function mallocArrayBuffer(n){var n=bits.nextPow2(n);var log_n=bits.log2(n);var d=DATA[log_n];if(d.length>0){return d.pop()}return new ArrayBuffer(n)}exports.mallocArrayBuffer=mallocArrayBuffer;function mallocUint8(n){return new Uint8Array(mallocArrayBuffer(n),0,n)}exports.mallocUint8=mallocUint8;function mallocUint16(n){return new Uint16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocUint16=mallocUint16;function mallocUint32(n){return new Uint32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocUint32=mallocUint32;function mallocInt8(n){return new Int8Array(mallocArrayBuffer(n),0,n)}exports.mallocInt8=mallocInt8;function mallocInt16(n){return new Int16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocInt16=mallocInt16;function mallocInt32(n){return new Int32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocInt32=mallocInt32;function mallocFloat(n){return new Float32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocFloat32=exports.mallocFloat=mallocFloat;function mallocDouble(n){return new Float64Array(mallocArrayBuffer(8*n),0,n)}exports.mallocFloat64=exports.mallocDouble=mallocDouble;function mallocUint8Clamped(n){if(hasUint8C){return new Uint8ClampedArray(mallocArrayBuffer(n),0,n)}else{return mallocUint8(n)}}exports.mallocUint8Clamped=mallocUint8Clamped;function mallocDataView(n){return new DataView(mallocArrayBuffer(n),0,n)}exports.mallocDataView=mallocDataView;function mallocBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=BUFFER[log_n];if(cache.length>0){return cache.pop()}return new Buffer(n)}exports.mallocBuffer=mallocBuffer;exports.clearCache=function clearCache(){for(var i=0;i<32;++i){POOL.UINT8[i].length=0;POOL.UINT16[i].length=0;POOL.UINT32[i].length=0;POOL.INT8[i].length=0;POOL.INT16[i].length=0;POOL.INT32[i].length=0;POOL.FLOAT[i].length=0;POOL.DOUBLE[i].length=0;POOL.UINT8C[i].length=0;DATA[i].length=0;BUFFER[i].length=0}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"bit-twiddle":32,buffer:1,dup:33}],94:[function(require,module,exports){"use strict";module.exports=triangulateCube;var perm=require("permutation-rank");var sgn=require("permutation-parity");var gamma=require("gamma");function triangulateCube(dimension){if(dimension<0){return[]}if(dimension===0){return[[0]]}var dfactorial=Math.round(gamma(dimension+1))|0;var result=[];for(var i=0;i<dfactorial;++i){var p=perm.unrank(dimension,i);var cell=[0];var v=0;for(var j=0;j<p.length;++j){v+=1<<p[j];cell.push(v)}if(sgn(p)<1){cell[0]=v;cell[dimension]=0}result.push(cell)}return result}},{gamma:88,"permutation-parity":90,"permutation-rank":91}],95:[function(require,module,exports){module.exports=require("cwise-compiler")({args:["array",{offset:[1],array:0},"scalar","scalar","index"],pre:{body:"{}",args:[],thisVars:[],localVars:[]},post:{body:"{}",args:[],thisVars:[],localVars:[]},body:{body:"{\n var _inline_1_da = _inline_1_arg0_ - _inline_1_arg3_\n var _inline_1_db = _inline_1_arg1_ - _inline_1_arg3_\n if((_inline_1_da >= 0) !== (_inline_1_db >= 0)) {\n _inline_1_arg2_.push(_inline_1_arg4_[0] + 0.5 + 0.5 * (_inline_1_da + _inline_1_db) / (_inline_1_da - _inline_1_db))\n }\n }",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:1},{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:1},{name:"_inline_1_arg2_",lvalue:false,rvalue:true,count:1},{name:"_inline_1_arg3_",lvalue:false,rvalue:true,count:2},{name:"_inline_1_arg4_",lvalue:false,rvalue:true,count:1}],thisVars:[],localVars:["_inline_1_da","_inline_1_db"]},funcName:"zeroCrossings"})},{"cwise-compiler":96}],96:[function(require,module,exports){arguments[4][9][0].apply(exports,arguments)},{"./lib/thunk.js":98,dup:9}],97:[function(require,module,exports){arguments[4][10][0].apply(exports,arguments)},{dup:10,uniq:99}],98:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{"./compile.js":97,dup:11}],99:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments)},{dup:12}],100:[function(require,module,exports){"use strict";module.exports=findZeroCrossings;var core=require("./lib/zc-core");function findZeroCrossings(array,level){var cross=[];level=+level||0;core(array.hi(array.shape[0]-1),cross,level);return cross}},{"./lib/zc-core":95}],101:[function(require,module,exports){"use strict";module.exports=surfaceNets;var generateContourExtractor=require("ndarray-extract-contour");var triangulateCube=require("triangulate-hypercube");var zeroCrossings=require("zero-crossings");function buildSurfaceNets(order,dtype){var dimension=order.length;var code=["'use strict';"];var funcName="surfaceNets"+order.join("_")+"d"+dtype;code.push("var contour=genContour({","order:[",order.join(),"],","scalarArguments: 3,","phase:function phaseFunc(p,a,b,c) { return (p > c)|0 },");if(dtype==="generic"){code.push("getters:[0],")}var cubeArgs=[];var extraArgs=[];for(var i=0;i<dimension;++i){cubeArgs.push("d"+i);extraArgs.push("d"+i)}for(var i=0;i<1<<dimension;++i){cubeArgs.push("v"+i);extraArgs.push("v"+i)}for(var i=0;i<1<<dimension;++i){cubeArgs.push("p"+i);extraArgs.push("p"+i)}cubeArgs.push("a","b","c");extraArgs.push("a","c");code.push("vertex:function vertexFunc(",cubeArgs.join(),"){");var maskStr=[];for(var i=0;i<1<<dimension;++i){maskStr.push("(p"+i+"<<"+i+")")}code.push("var m=(",maskStr.join("+"),")|0;if(m===0||m===",(1<<(1<<dimension))-1,"){return}");var extraFuncs=[];var currentFunc=[];if(1<<(1<<dimension)<=128){code.push("switch(m){");currentFunc=code}else{code.push("switch(m>>>7){")}for(var i=0;i<1<<(1<<dimension);++i){if(1<<(1<<dimension)>128){if(i%128===0){if(extraFuncs.length>0){currentFunc.push("}}")}var efName="vExtra"+extraFuncs.length;code.push("case ",i>>>7,":",efName,"(m&0x7f,",extraArgs.join(),");break;");currentFunc=["function ",efName,"(m,",extraArgs.join(),"){switch(m){"];extraFuncs.push(currentFunc)}}currentFunc.push("case ",i&127,":");var crossings=new Array(dimension);var denoms=new Array(dimension);var crossingCount=new Array(dimension);var bias=new Array(dimension);var totalCrossings=0;for(var j=0;j<dimension;++j){crossings[j]=[];denoms[j]=[];crossingCount[j]=0;bias[j]=0}for(var j=0;j<1<<dimension;++j){for(var k=0;k<dimension;++k){var u=j^1<<k;if(u>j){continue}if(!(i&1<<u)!==!(i&1<<j)){var sign=1;if(i&1<<u){denoms[k].push("v"+u+"-v"+j)}else{denoms[k].push("v"+j+"-v"+u);sign=-sign}if(sign<0){crossings[k].push("-v"+j+"-v"+u);crossingCount[k]+=2}else{crossings[k].push("v"+j+"+v"+u);crossingCount[k]-=2}totalCrossings+=1;for(var l=0;l<dimension;++l){if(l===k){continue}if(u&1<<l){bias[l]+=1}else{bias[l]-=1}}}}}var vertexStr=[];for(var k=0;k<dimension;++k){if(crossings[k].length===0){vertexStr.push("d"+k+"-0.5")}else{var cStr="";if(crossingCount[k]<0){cStr=crossingCount[k]+"*c"}else if(crossingCount[k]>0){cStr="+"+crossingCount[k]+"*c"}var weight=.5*(crossings[k].length/totalCrossings);var shift=.5+.5*(bias[k]/totalCrossings);vertexStr.push("d"+k+"-"+shift+"-"+weight+"*("+crossings[k].join("+")+cStr+")/("+denoms[k].join("+")+")")}}currentFunc.push("a.push([",vertexStr.join(),"]);","break;")}code.push("}},");if(extraFuncs.length>0){currentFunc.push("}}")}var faceArgs=[];for(var i=0;i<1<<dimension-1;++i){faceArgs.push("v"+i)}faceArgs.push("c0","c1","p0","p1","a","b","c");code.push("cell:function cellFunc(",faceArgs.join(),"){");var facets=triangulateCube(dimension-1);code.push("if(p0){b.push(",facets.map(function(f){return"["+f.map(function(v){return"v"+v})+"]"}).join(),")}else{b.push(",facets.map(function(f){var e=f.slice();e.reverse();return"["+e.map(function(v){return"v"+v})+"]"}).join(),")}}});function ",funcName,"(array,level){var verts=[],cells=[];contour(array,verts,cells,level);return {positions:verts,cells:cells};} return ",funcName,";");for(var i=0;i<extraFuncs.length;++i){code.push(extraFuncs[i].join(""))}var proc=new Function("genContour",code.join(""));return proc(generateContourExtractor)}function mesh1D(array,level){var zc=zeroCrossings(array,level);var n=zc.length;var npos=new Array(n);var ncel=new Array(n);for(var i=0;i<n;++i){npos[i]=[zc[i]];ncel[i]=[i]}return{positions:npos,cells:ncel}}var CACHE={};function surfaceNets(array,level){if(array.dimension<=0){return{positions:[],cells:[]}}else if(array.dimension===1){return mesh1D(array,level)}var typesig=array.order.join()+"-"+array.dtype;var proc=CACHE[typesig];var level=+level||0;if(!proc){proc=CACHE[typesig]=buildSurfaceNets(array.order,array.dtype)}return proc(array,level)}},{"ndarray-extract-contour":86,"triangulate-hypercube":94,"zero-crossings":100}],102:[function(require,module,exports){module.exports={version:"1.3.3"}},{}],103:[function(require,module,exports){"use strict";var Node=function(p,t){this.point=p;this.triangle=t||null;this.next=null;this.prev=null;this.value=p.x};var AdvancingFront=function(head,tail){this.head_=head;this.tail_=tail;this.search_node_=head};AdvancingFront.prototype.head=function(){return this.head_};AdvancingFront.prototype.setHead=function(node){this.head_=node};AdvancingFront.prototype.tail=function(){return this.tail_};AdvancingFront.prototype.setTail=function(node){this.tail_=node};AdvancingFront.prototype.search=function(){return this.search_node_};AdvancingFront.prototype.setSearch=function(node){this.search_node_=node};AdvancingFront.prototype.findSearchNode=function(){return this.search_node_};AdvancingFront.prototype.locateNode=function(x){var node=this.search_node_;if(x<node.value){while(node=node.prev){if(x>=node.value){this.search_node_=node;return node}}}else{while(node=node.next){if(x<node.value){this.search_node_=node.prev;return node.prev}}}return null};AdvancingFront.prototype.locatePoint=function(point){var px=point.x;var node=this.findSearchNode(px);var nx=node.point.x;if(px===nx){if(point!==node.point){if(point===node.prev.point){node=node.prev}else if(point===node.next.point){node=node.next}else{throw new Error("poly2tri Invalid AdvancingFront.locatePoint() call")}}}else if(px<nx){while(node=node.prev){if(point===node.point){break}}}else{while(node=node.next){if(point===node.point){break}}}if(node){this.search_node_=node}return node};module.exports=AdvancingFront;module.exports.Node=Node},{}],104:[function(require,module,exports){"use strict";var xy=require("./xy");var Point=function(x,y){this.x=+x||0;this.y=+y||0;this._p2t_edge_list=null};Point.prototype.toString=function(){return xy.toStringBase(this)};Point.prototype.clone=function(){return new Point(this.x,this.y)};Point.prototype.set_zero=function(){this.x=0;this.y=0;return this};Point.prototype.set=function(x,y){this.x=+x||0;this.y=+y||0;return this};Point.prototype.negate=function(){this.x=-this.x;this.y=-this.y;return this};Point.prototype.add=function(n){this.x+=n.x;this.y+=n.y;return this};Point.prototype.sub=function(n){this.x-=n.x;this.y-=n.y;return this};Point.prototype.mul=function(s){this.x*=s;this.y*=s;return this};Point.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)};Point.prototype.normalize=function(){var len=this.length();this.x/=len;this.y/=len;return len};Point.prototype.equals=function(p){return this.x===p.x&&this.y===p.y};Point.negate=function(p){return new Point(-p.x,-p.y)};Point.add=function(a,b){return new Point(a.x+b.x,a.y+b.y)};Point.sub=function(a,b){return new Point(a.x-b.x,a.y-b.y)};Point.mul=function(s,p){return new Point(s*p.x,s*p.y)};Point.cross=function(a,b){if(typeof a==="number"){if(typeof b==="number"){return a*b}else{return new Point(-a*b.y,a*b.x)}}else{if(typeof b==="number"){return new Point(b*a.y,-b*a.x)}else{return a.x*b.y-a.y*b.x}}};Point.toString=xy.toString;Point.compare=xy.compare;Point.cmp=xy.compare;Point.equals=xy.equals;Point.dot=function(a,b){return a.x*b.x+a.y*b.y};module.exports=Point},{"./xy":111}],105:[function(require,module,exports){"use strict";var xy=require("./xy");var PointError=function(message,points){this.name="PointError";this.points=points=points||[];this.message=message||"Invalid Points!";for(var i=0;i<points.length;i++){this.message+=" "+xy.toString(points[i])}};PointError.prototype=new Error;PointError.prototype.constructor=PointError;module.exports=PointError},{"./xy":111}],106:[function(require,module,exports){(function(global){"use strict";var previousPoly2tri=global.poly2tri;exports.noConflict=function(){global.poly2tri=previousPoly2tri;return exports};exports.VERSION=require("../dist/version.json").version;exports.PointError=require("./pointerror");exports.Point=require("./point");exports.Triangle=require("./triangle");exports.SweepContext=require("./sweepcontext");var sweep=require("./sweep");exports.triangulate=sweep.triangulate;exports.sweep={Triangulate:sweep.triangulate}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"../dist/version.json":102,"./point":104,"./pointerror":105,"./sweep":107,"./sweepcontext":108,"./triangle":109}],107:[function(require,module,exports){"use strict";var PointError=require("./pointerror");var Triangle=require("./triangle");var Node=require("./advancingfront").Node;var utils=require("./utils");var PI_3div4=3*Math.PI/4;var PI_div2=Math.PI/2;var EPSILON=utils.EPSILON;var Orientation=utils.Orientation;var orient2d=utils.orient2d;var inScanArea=utils.inScanArea;function triangulate(tcx){tcx.initTriangulation();tcx.createAdvancingFront();sweepPoints(tcx);finalizationPolygon(tcx)}function sweepPoints(tcx){var i,len=tcx.pointCount();for(i=1;i<len;++i){var point=tcx.getPoint(i);var node=pointEvent(tcx,point);var edges=point._p2t_edge_list;for(var j=0;edges&&j<edges.length;++j){edgeEventByEdge(tcx,edges[j],node)}}}function finalizationPolygon(tcx){var t=tcx.front().head().next.triangle;var p=tcx.front().head().next.point;while(!t.getConstrainedEdgeCW(p)){t=t.neighborCCW(p)}tcx.meshClean(t)}function pointEvent(tcx,point){var node=tcx.locateNode(point);var new_node=newFrontTriangle(tcx,point,node);if(point.x<=node.point.x+EPSILON){fill(tcx,node)}fillAdvancingFront(tcx,new_node);return new_node}function edgeEventByEdge(tcx,edge,node){tcx.edge_event.constrained_edge=edge;tcx.edge_event.right=edge.p.x>edge.q.x;if(isEdgeSideOfTriangle(node.triangle,edge.p,edge.q)){return}fillEdgeEvent(tcx,edge,node);edgeEventByPoints(tcx,edge.p,edge.q,node.triangle,edge.q)}function edgeEventByPoints(tcx,ep,eq,triangle,point){if(isEdgeSideOfTriangle(triangle,ep,eq)){return}var p1=triangle.pointCCW(point);var o1=orient2d(eq,p1,ep);if(o1===Orientation.COLLINEAR){throw new PointError("poly2tri EdgeEvent: Collinear not supported!",[eq,p1,ep])}var p2=triangle.pointCW(point);var o2=orient2d(eq,p2,ep);if(o2===Orientation.COLLINEAR){throw new PointError("poly2tri EdgeEvent: Collinear not supported!",[eq,p2,ep])}if(o1===o2){if(o1===Orientation.CW){triangle=triangle.neighborCCW(point)}else{triangle=triangle.neighborCW(point)}edgeEventByPoints(tcx,ep,eq,triangle,point)}else{flipEdgeEvent(tcx,ep,eq,triangle,point)}}function isEdgeSideOfTriangle(triangle,ep,eq){var index=triangle.edgeIndex(ep,eq);if(index!==-1){triangle.markConstrainedEdgeByIndex(index);var t=triangle.getNeighbor(index);if(t){t.markConstrainedEdgeByPoints(ep,eq)}return true}return false}function newFrontTriangle(tcx,point,node){var triangle=new Triangle(point,node.point,node.next.point);triangle.markNeighbor(node.triangle);tcx.addToMap(triangle);var new_node=new Node(point);new_node.next=node.next;new_node.prev=node;node.next.prev=new_node;node.next=new_node;if(!legalize(tcx,triangle)){tcx.mapTriangleToNodes(triangle)}return new_node}function fill(tcx,node){var triangle=new Triangle(node.prev.point,node.point,node.next.point);triangle.markNeighbor(node.prev.triangle);triangle.markNeighbor(node.triangle);tcx.addToMap(triangle);node.prev.next=node.next;node.next.prev=node.prev;if(!legalize(tcx,triangle)){tcx.mapTriangleToNodes(triangle)}}function fillAdvancingFront(tcx,n){var node=n.next;var angle;while(node.next){angle=holeAngle(node);if(angle>PI_div2||angle<-PI_div2){break}fill(tcx,node);node=node.next}node=n.prev;while(node.prev){angle=holeAngle(node);if(angle>PI_div2||angle<-PI_div2){break}fill(tcx,node);node=node.prev}if(n.next&&n.next.next){angle=basinAngle(n);if(angle<PI_3div4){fillBasin(tcx,n)}}}function basinAngle(node){var ax=node.point.x-node.next.next.point.x;var ay=node.point.y-node.next.next.point.y;return Math.atan2(ay,ax)}function holeAngle(node){var ax=node.next.point.x-node.point.x;var ay=node.next.point.y-node.point.y;var bx=node.prev.point.x-node.point.x;var by=node.prev.point.y-node.point.y;return Math.atan2(ax*by-ay*bx,ax*bx+ay*by)}function legalize(tcx,t){for(var i=0;i<3;++i){if(t.delaunay_edge[i]){continue}var ot=t.getNeighbor(i);if(ot){var p=t.getPoint(i);var op=ot.oppositePoint(t,p);var oi=ot.index(op);if(ot.constrained_edge[oi]||ot.delaunay_edge[oi]){t.constrained_edge[i]=ot.constrained_edge[oi];continue}var inside=inCircle(p,t.pointCCW(p),t.pointCW(p),op);if(inside){t.delaunay_edge[i]=true;ot.delaunay_edge[oi]=true;rotateTrianglePair(t,p,ot,op);var not_legalized=!legalize(tcx,t);if(not_legalized){tcx.mapTriangleToNodes(t)}not_legalized=!legalize(tcx,ot);if(not_legalized){tcx.mapTriangleToNodes(ot)}t.delaunay_edge[i]=false;ot.delaunay_edge[oi]=false;return true}}}return false}function inCircle(pa,pb,pc,pd){var adx=pa.x-pd.x;var ady=pa.y-pd.y;var bdx=pb.x-pd.x;var bdy=pb.y-pd.y;var adxbdy=adx*bdy;var bdxady=bdx*ady;var oabd=adxbdy-bdxady;if(oabd<=0){return false}var cdx=pc.x-pd.x;var cdy=pc.y-pd.y;var cdxady=cdx*ady;var adxcdy=adx*cdy;var ocad=cdxady-adxcdy;if(ocad<=0){return false}var bdxcdy=bdx*cdy;var cdxbdy=cdx*bdy;var alift=adx*adx+ady*ady;var blift=bdx*bdx+bdy*bdy;var clift=cdx*cdx+cdy*cdy;var det=alift*(bdxcdy-cdxbdy)+blift*ocad+clift*oabd;return det>0}function rotateTrianglePair(t,p,ot,op){var n1,n2,n3,n4;n1=t.neighborCCW(p);n2=t.neighborCW(p);n3=ot.neighborCCW(op);n4=ot.neighborCW(op);var ce1,ce2,ce3,ce4;ce1=t.getConstrainedEdgeCCW(p);ce2=t.getConstrainedEdgeCW(p);ce3=ot.getConstrainedEdgeCCW(op);ce4=ot.getConstrainedEdgeCW(op);var de1,de2,de3,de4;de1=t.getDelaunayEdgeCCW(p);de2=t.getDelaunayEdgeCW(p);de3=ot.getDelaunayEdgeCCW(op);de4=ot.getDelaunayEdgeCW(op);t.legalize(p,op);ot.legalize(op,p);ot.setDelaunayEdgeCCW(p,de1);t.setDelaunayEdgeCW(p,de2);t.setDelaunayEdgeCCW(op,de3);ot.setDelaunayEdgeCW(op,de4);ot.setConstrainedEdgeCCW(p,ce1);t.setConstrainedEdgeCW(p,ce2);t.setConstrainedEdgeCCW(op,ce3);ot.setConstrainedEdgeCW(op,ce4);t.clearNeigbors();ot.clearNeigbors();if(n1){ot.markNeighbor(n1)}if(n2){t.markNeighbor(n2)}if(n3){t.markNeighbor(n3)}if(n4){ot.markNeighbor(n4)}t.markNeighbor(ot)}function fillBasin(tcx,node){if(orient2d(node.point,node.next.point,node.next.next.point)===Orientation.CCW){tcx.basin.left_node=node.next.next}else{tcx.basin.left_node=node.next}tcx.basin.bottom_node=tcx.basin.left_node;while(tcx.basin.bottom_node.next&&tcx.basin.bottom_node.point.y>=tcx.basin.bottom_node.next.point.y){tcx.basin.bottom_node=tcx.basin.bottom_node.next}if(tcx.basin.bottom_node===tcx.basin.left_node){return}tcx.basin.right_node=tcx.basin.bottom_node;while(tcx.basin.right_node.next&&tcx.basin.right_node.point.y<tcx.basin.right_node.next.point.y){tcx.basin.right_node=tcx.basin.right_node.next}if(tcx.basin.right_node===tcx.basin.bottom_node){return}tcx.basin.width=tcx.basin.right_node.point.x-tcx.basin.left_node.point.x;tcx.basin.left_highest=tcx.basin.left_node.point.y>tcx.basin.right_node.point.y;fillBasinReq(tcx,tcx.basin.bottom_node)}function fillBasinReq(tcx,node){if(isShallow(tcx,node)){return}fill(tcx,node);var o;if(node.prev===tcx.basin.left_node&&node.next===tcx.basin.right_node){return}else if(node.prev===tcx.basin.left_node){o=orient2d(node.point,node.next.point,node.next.next.point);if(o===Orientation.CW){return}node=node.next}else if(node.next===tcx.basin.right_node){o=orient2d(node.point,node.prev.point,node.prev.prev.point);if(o===Orientation.CCW){return}node=node.prev}else{if(node.prev.point.y<node.next.point.y){node=node.prev}else{node=node.next}}fillBasinReq(tcx,node)}function isShallow(tcx,node){var height;if(tcx.basin.left_highest){height=tcx.basin.left_node.point.y-node.point.y}else{height=tcx.basin.right_node.point.y-node.point.y}if(tcx.basin.width>height){return true}return false}function fillEdgeEvent(tcx,edge,node){if(tcx.edge_event.right){fillRightAboveEdgeEvent(tcx,edge,node)}else{fillLeftAboveEdgeEvent(tcx,edge,node)}}function fillRightAboveEdgeEvent(tcx,edge,node){while(node.next.point.x<edge.p.x){if(orient2d(edge.q,node.next.point,edge.p)===Orientation.CCW){fillRightBelowEdgeEvent(tcx,edge,node)}else{node=node.next}}}function fillRightBelowEdgeEvent(tcx,edge,node){if(node.point.x<edge.p.x){if(orient2d(node.point,node.next.point,node.next.next.point)===Orientation.CCW){fillRightConcaveEdgeEvent(tcx,edge,node)}else{fillRightConvexEdgeEvent(tcx,edge,node);fillRightBelowEdgeEvent(tcx,edge,node)}}}function fillRightConcaveEdgeEvent(tcx,edge,node){fill(tcx,node.next);if(node.next.point!==edge.p){if(orient2d(edge.q,node.next.point,edge.p)===Orientation.CCW){if(orient2d(node.point,node.next.point,node.next.next.point)===Orientation.CCW){fillRightConcaveEdgeEvent(tcx,edge,node)}else{}}}}function fillRightConvexEdgeEvent(tcx,edge,node){if(orient2d(node.next.point,node.next.next.point,node.next.next.next.point)===Orientation.CCW){fillRightConcaveEdgeEvent(tcx,edge,node.next)}else{if(orient2d(edge.q,node.next.next.point,edge.p)===Orientation.CCW){fillRightConvexEdgeEvent(tcx,edge,node.next)}else{}}}function fillLeftAboveEdgeEvent(tcx,edge,node){while(node.prev.point.x>edge.p.x){if(orient2d(edge.q,node.prev.point,edge.p)===Orientation.CW){fillLeftBelowEdgeEvent(tcx,edge,node)}else{node=node.prev}}}function fillLeftBelowEdgeEvent(tcx,edge,node){if(node.point.x>edge.p.x){if(orient2d(node.point,node.prev.point,node.prev.prev.point)===Orientation.CW){fillLeftConcaveEdgeEvent(tcx,edge,node)}else{fillLeftConvexEdgeEvent(tcx,edge,node);fillLeftBelowEdgeEvent(tcx,edge,node)}}}function fillLeftConvexEdgeEvent(tcx,edge,node){if(orient2d(node.prev.point,node.prev.prev.point,node.prev.prev.prev.point)===Orientation.CW){fillLeftConcaveEdgeEvent(tcx,edge,node.prev)}else{if(orient2d(edge.q,node.prev.prev.point,edge.p)===Orientation.CW){fillLeftConvexEdgeEvent(tcx,edge,node.prev)}else{}}}function fillLeftConcaveEdgeEvent(tcx,edge,node){fill(tcx,node.prev);if(node.prev.point!==edge.p){if(orient2d(edge.q,node.prev.point,edge.p)===Orientation.CW){if(orient2d(node.point,node.prev.point,node.prev.prev.point)===Orientation.CW){fillLeftConcaveEdgeEvent(tcx,edge,node)}else{}}}}function flipEdgeEvent(tcx,ep,eq,t,p){var ot=t.neighborAcross(p);if(!ot){throw new Error("poly2tri [BUG:FIXME] FLIP failed due to missing triangle!")}var op=ot.oppositePoint(t,p);if(t.getConstrainedEdgeAcross(p)){var index=t.index(p);throw new PointError("poly2tri Intersecting Constraints",[p,op,t.getPoint((index+1)%3),t.getPoint((index+2)%3)])}if(inScanArea(p,t.pointCCW(p),t.pointCW(p),op)){rotateTrianglePair(t,p,ot,op);tcx.mapTriangleToNodes(t);tcx.mapTriangleToNodes(ot);if(p===eq&&op===ep){if(eq===tcx.edge_event.constrained_edge.q&&ep===tcx.edge_event.constrained_edge.p){t.markConstrainedEdgeByPoints(ep,eq);ot.markConstrainedEdgeByPoints(ep,eq);legalize(tcx,t);legalize(tcx,ot)}else{}}else{var o=orient2d(eq,op,ep);t=nextFlipTriangle(tcx,o,t,ot,p,op);flipEdgeEvent(tcx,ep,eq,t,p)}}else{var newP=nextFlipPoint(ep,eq,ot,op);flipScanEdgeEvent(tcx,ep,eq,t,ot,newP);edgeEventByPoints(tcx,ep,eq,t,p)}}function nextFlipTriangle(tcx,o,t,ot,p,op){var edge_index;if(o===Orientation.CCW){edge_index=ot.edgeIndex(p,op);ot.delaunay_edge[edge_index]=true;legalize(tcx,ot);ot.clearDelunayEdges();return t}edge_index=t.edgeIndex(p,op);t.delaunay_edge[edge_index]=true;legalize(tcx,t);t.clearDelunayEdges();return ot}function nextFlipPoint(ep,eq,ot,op){var o2d=orient2d(eq,op,ep);if(o2d===Orientation.CW){return ot.pointCCW(op)}else if(o2d===Orientation.CCW){return ot.pointCW(op)}else{throw new PointError("poly2tri [Unsupported] nextFlipPoint: opposing point on constrained edge!",[eq,op,ep])}}function flipScanEdgeEvent(tcx,ep,eq,flip_triangle,t,p){var ot=t.neighborAcross(p);if(!ot){throw new Error("poly2tri [BUG:FIXME] FLIP failed due to missing triangle")}var op=ot.oppositePoint(t,p);if(inScanArea(eq,flip_triangle.pointCCW(eq),flip_triangle.pointCW(eq),op)){flipEdgeEvent(tcx,eq,op,ot,op)}else{var newP=nextFlipPoint(ep,eq,ot,op);flipScanEdgeEvent(tcx,ep,eq,flip_triangle,ot,newP)}}exports.triangulate=triangulate},{"./advancingfront":103,"./pointerror":105,"./triangle":109,"./utils":110}],108:[function(require,module,exports){"use strict";var PointError=require("./pointerror");var Point=require("./point");var Triangle=require("./triangle");var sweep=require("./sweep");var AdvancingFront=require("./advancingfront");var Node=AdvancingFront.Node;var kAlpha=.3;var Edge=function(p1,p2){this.p=p1;this.q=p2;if(p1.y>p2.y){this.q=p1;this.p=p2}else if(p1.y===p2.y){if(p1.x>p2.x){this.q=p1;this.p=p2}else if(p1.x===p2.x){throw new PointError("poly2tri Invalid Edge constructor: repeated points!",[p1])}}if(!this.q._p2t_edge_list){this.q._p2t_edge_list=[]}this.q._p2t_edge_list.push(this)};var Basin=function(){this.left_node=null;this.bottom_node=null;this.right_node=null;this.width=0;this.left_highest=false};Basin.prototype.clear=function(){this.left_node=null;this.bottom_node=null;this.right_node=null;this.width=0;this.left_highest=false};var EdgeEvent=function(){this.constrained_edge=null;this.right=false};var SweepContext=function(contour,options){options=options||{};this.triangles_=[];this.map_=[];this.points_=options.cloneArrays?contour.slice(0):contour;this.edge_list=[];this.pmin_=this.pmax_=null;this.front_=null;this.head_=null;this.tail_=null;this.af_head_=null;this.af_middle_=null;this.af_tail_=null;this.basin=new Basin;this.edge_event=new EdgeEvent;this.initEdges(this.points_)};SweepContext.prototype.addHole=function(polyline){this.initEdges(polyline);var i,len=polyline.length;for(i=0;i<len;i++){this.points_.push(polyline[i])}return this};SweepContext.prototype.AddHole=SweepContext.prototype.addHole;SweepContext.prototype.addPoint=function(point){this.points_.push(point);return this};SweepContext.prototype.AddPoint=SweepContext.prototype.addPoint;SweepContext.prototype.addPoints=function(points){this.points_=this.points_.concat(points);return this};SweepContext.prototype.triangulate=function(){sweep.triangulate(this);return this};SweepContext.prototype.getBoundingBox=function(){return{min:this.pmin_,max:this.pmax_}};SweepContext.prototype.getTriangles=function(){return this.triangles_};SweepContext.prototype.GetTriangles=SweepContext.prototype.getTriangles;SweepContext.prototype.front=function(){return this.front_};SweepContext.prototype.pointCount=function(){return this.points_.length};SweepContext.prototype.head=function(){return this.head_};SweepContext.prototype.setHead=function(p1){this.head_=p1};SweepContext.prototype.tail=function(){return this.tail_};SweepContext.prototype.setTail=function(p1){this.tail_=p1};SweepContext.prototype.getMap=function(){return this.map_};SweepContext.prototype.initTriangulation=function(){var xmax=this.points_[0].x;var xmin=this.points_[0].x;var ymax=this.points_[0].y;var ymin=this.points_[0].y;var i,len=this.points_.length;for(i=1;i<len;i++){var p=this.points_[i];p.x>xmax&&(xmax=p.x);p.x<xmin&&(xmin=p.x);p.y>ymax&&(ymax=p.y);p.y<ymin&&(ymin=p.y)}this.pmin_=new Point(xmin,ymin);this.pmax_=new Point(xmax,ymax);var dx=kAlpha*(xmax-xmin);var dy=kAlpha*(ymax-ymin);this.head_=new Point(xmax+dx,ymin-dy);this.tail_=new Point(xmin-dx,ymin-dy);this.points_.sort(Point.compare)};SweepContext.prototype.initEdges=function(polyline){var i,len=polyline.length;for(i=0;i<len;++i){this.edge_list.push(new Edge(polyline[i],polyline[(i+1)%len]))}};SweepContext.prototype.getPoint=function(index){return this.points_[index]};SweepContext.prototype.addToMap=function(triangle){this.map_.push(triangle)};SweepContext.prototype.locateNode=function(point){return this.front_.locateNode(point.x)};SweepContext.prototype.createAdvancingFront=function(){var head;var middle;var tail;var triangle=new Triangle(this.points_[0],this.tail_,this.head_);this.map_.push(triangle);head=new Node(triangle.getPoint(1),triangle);middle=new Node(triangle.getPoint(0),triangle);tail=new Node(triangle.getPoint(2));this.front_=new AdvancingFront(head,tail);head.next=middle;middle.next=tail;middle.prev=head;tail.prev=middle};SweepContext.prototype.removeNode=function(node){};SweepContext.prototype.mapTriangleToNodes=function(t){for(var i=0;i<3;++i){if(!t.getNeighbor(i)){var n=this.front_.locatePoint(t.pointCW(t.getPoint(i)));if(n){n.triangle=t}}}};SweepContext.prototype.removeFromMap=function(triangle){var i,map=this.map_,len=map.length;for(i=0;i<len;i++){if(map[i]===triangle){map.splice(i,1);break}}};SweepContext.prototype.meshClean=function(triangle){var triangles=[triangle],t,i;while(t=triangles.pop()){if(!t.isInterior()){t.setInterior(true);this.triangles_.push(t);for(i=0;i<3;i++){if(!t.constrained_edge[i]){triangles.push(t.getNeighbor(i))}}}}};module.exports=SweepContext},{"./advancingfront":103,"./point":104,"./pointerror":105,"./sweep":107,"./triangle":109}],109:[function(require,module,exports){"use strict";var xy=require("./xy");var Triangle=function(a,b,c){this.points_=[a,b,c];this.neighbors_=[null,null,null];this.interior_=false;this.constrained_edge=[false,false,false];this.delaunay_edge=[false,false,false]};var p2s=xy.toString;Triangle.prototype.toString=function(){return"["+p2s(this.points_[0])+p2s(this.points_[1])+p2s(this.points_[2])+"]"};Triangle.prototype.getPoint=function(index){return this.points_[index]};Triangle.prototype.GetPoint=Triangle.prototype.getPoint;Triangle.prototype.getPoints=function(){return this.points_};Triangle.prototype.getNeighbor=function(index){return this.neighbors_[index]};Triangle.prototype.containsPoint=function(point){var points=this.points_;return point===points[0]||point===points[1]||point===points[2]};Triangle.prototype.containsEdge=function(edge){return this.containsPoint(edge.p)&&this.containsPoint(edge.q); | |
};Triangle.prototype.containsPoints=function(p1,p2){return this.containsPoint(p1)&&this.containsPoint(p2)};Triangle.prototype.isInterior=function(){return this.interior_};Triangle.prototype.setInterior=function(interior){this.interior_=interior;return this};Triangle.prototype.markNeighborPointers=function(p1,p2,t){var points=this.points_;if(p1===points[2]&&p2===points[1]||p1===points[1]&&p2===points[2]){this.neighbors_[0]=t}else if(p1===points[0]&&p2===points[2]||p1===points[2]&&p2===points[0]){this.neighbors_[1]=t}else if(p1===points[0]&&p2===points[1]||p1===points[1]&&p2===points[0]){this.neighbors_[2]=t}else{throw new Error("poly2tri Invalid Triangle.markNeighborPointers() call")}};Triangle.prototype.markNeighbor=function(t){var points=this.points_;if(t.containsPoints(points[1],points[2])){this.neighbors_[0]=t;t.markNeighborPointers(points[1],points[2],this)}else if(t.containsPoints(points[0],points[2])){this.neighbors_[1]=t;t.markNeighborPointers(points[0],points[2],this)}else if(t.containsPoints(points[0],points[1])){this.neighbors_[2]=t;t.markNeighborPointers(points[0],points[1],this)}};Triangle.prototype.clearNeigbors=function(){this.neighbors_[0]=null;this.neighbors_[1]=null;this.neighbors_[2]=null};Triangle.prototype.clearDelunayEdges=function(){this.delaunay_edge[0]=false;this.delaunay_edge[1]=false;this.delaunay_edge[2]=false};Triangle.prototype.pointCW=function(p){var points=this.points_;if(p===points[0]){return points[2]}else if(p===points[1]){return points[0]}else if(p===points[2]){return points[1]}else{return null}};Triangle.prototype.pointCCW=function(p){var points=this.points_;if(p===points[0]){return points[1]}else if(p===points[1]){return points[2]}else if(p===points[2]){return points[0]}else{return null}};Triangle.prototype.neighborCW=function(p){if(p===this.points_[0]){return this.neighbors_[1]}else if(p===this.points_[1]){return this.neighbors_[2]}else{return this.neighbors_[0]}};Triangle.prototype.neighborCCW=function(p){if(p===this.points_[0]){return this.neighbors_[2]}else if(p===this.points_[1]){return this.neighbors_[0]}else{return this.neighbors_[1]}};Triangle.prototype.getConstrainedEdgeCW=function(p){if(p===this.points_[0]){return this.constrained_edge[1]}else if(p===this.points_[1]){return this.constrained_edge[2]}else{return this.constrained_edge[0]}};Triangle.prototype.getConstrainedEdgeCCW=function(p){if(p===this.points_[0]){return this.constrained_edge[2]}else if(p===this.points_[1]){return this.constrained_edge[0]}else{return this.constrained_edge[1]}};Triangle.prototype.getConstrainedEdgeAcross=function(p){if(p===this.points_[0]){return this.constrained_edge[0]}else if(p===this.points_[1]){return this.constrained_edge[1]}else{return this.constrained_edge[2]}};Triangle.prototype.setConstrainedEdgeCW=function(p,ce){if(p===this.points_[0]){this.constrained_edge[1]=ce}else if(p===this.points_[1]){this.constrained_edge[2]=ce}else{this.constrained_edge[0]=ce}};Triangle.prototype.setConstrainedEdgeCCW=function(p,ce){if(p===this.points_[0]){this.constrained_edge[2]=ce}else if(p===this.points_[1]){this.constrained_edge[0]=ce}else{this.constrained_edge[1]=ce}};Triangle.prototype.getDelaunayEdgeCW=function(p){if(p===this.points_[0]){return this.delaunay_edge[1]}else if(p===this.points_[1]){return this.delaunay_edge[2]}else{return this.delaunay_edge[0]}};Triangle.prototype.getDelaunayEdgeCCW=function(p){if(p===this.points_[0]){return this.delaunay_edge[2]}else if(p===this.points_[1]){return this.delaunay_edge[0]}else{return this.delaunay_edge[1]}};Triangle.prototype.setDelaunayEdgeCW=function(p,e){if(p===this.points_[0]){this.delaunay_edge[1]=e}else if(p===this.points_[1]){this.delaunay_edge[2]=e}else{this.delaunay_edge[0]=e}};Triangle.prototype.setDelaunayEdgeCCW=function(p,e){if(p===this.points_[0]){this.delaunay_edge[2]=e}else if(p===this.points_[1]){this.delaunay_edge[0]=e}else{this.delaunay_edge[1]=e}};Triangle.prototype.neighborAcross=function(p){if(p===this.points_[0]){return this.neighbors_[0]}else if(p===this.points_[1]){return this.neighbors_[1]}else{return this.neighbors_[2]}};Triangle.prototype.oppositePoint=function(t,p){var cw=t.pointCW(p);return this.pointCW(cw)};Triangle.prototype.legalize=function(opoint,npoint){var points=this.points_;if(opoint===points[0]){points[1]=points[0];points[0]=points[2];points[2]=npoint}else if(opoint===points[1]){points[2]=points[1];points[1]=points[0];points[0]=npoint}else if(opoint===points[2]){points[0]=points[2];points[2]=points[1];points[1]=npoint}else{throw new Error("poly2tri Invalid Triangle.legalize() call")}};Triangle.prototype.index=function(p){var points=this.points_;if(p===points[0]){return 0}else if(p===points[1]){return 1}else if(p===points[2]){return 2}else{throw new Error("poly2tri Invalid Triangle.index() call")}};Triangle.prototype.edgeIndex=function(p1,p2){var points=this.points_;if(p1===points[0]){if(p2===points[1]){return 2}else if(p2===points[2]){return 1}}else if(p1===points[1]){if(p2===points[2]){return 0}else if(p2===points[0]){return 2}}else if(p1===points[2]){if(p2===points[0]){return 1}else if(p2===points[1]){return 0}}return-1};Triangle.prototype.markConstrainedEdgeByIndex=function(index){this.constrained_edge[index]=true};Triangle.prototype.markConstrainedEdgeByEdge=function(edge){this.markConstrainedEdgeByPoints(edge.p,edge.q)};Triangle.prototype.markConstrainedEdgeByPoints=function(p,q){var points=this.points_;if(q===points[0]&&p===points[1]||q===points[1]&&p===points[0]){this.constrained_edge[2]=true}else if(q===points[0]&&p===points[2]||q===points[2]&&p===points[0]){this.constrained_edge[1]=true}else if(q===points[1]&&p===points[2]||q===points[2]&&p===points[1]){this.constrained_edge[0]=true}};module.exports=Triangle},{"./xy":111}],110:[function(require,module,exports){"use strict";var EPSILON=1e-12;var Orientation={CW:1,CCW:-1,COLLINEAR:0};function orient2d(pa,pb,pc){var detleft=(pa.x-pc.x)*(pb.y-pc.y);var detright=(pa.y-pc.y)*(pb.x-pc.x);var val=detleft-detright;if(val>-EPSILON&&val<EPSILON){return Orientation.COLLINEAR}else if(val>0){return Orientation.CCW}else{return Orientation.CW}}function inScanArea(pa,pb,pc,pd){var oadb=(pa.x-pb.x)*(pd.y-pb.y)-(pd.x-pb.x)*(pa.y-pb.y);if(oadb>=-EPSILON){return false}var oadc=(pa.x-pc.x)*(pd.y-pc.y)-(pd.x-pc.x)*(pa.y-pc.y);if(oadc<=EPSILON){return false}return true}module.exports={EPSILON:EPSILON,Orientation:Orientation,orient2d:orient2d,inScanArea:inScanArea}},{}],111:[function(require,module,exports){"use strict";function toStringBase(p){return"("+p.x+";"+p.y+")"}function toString(p){var s=p.toString();return s==="[object Object]"?toStringBase(p):s}function compare(a,b){if(a.y===b.y){return a.x-b.x}else{return a.y-b.y}}function equals(a,b){return a.x===b.x&&a.y===b.y}module.exports={toString:toString,toStringBase:toStringBase,compare:compare,equals:equals}},{}],112:[function(require,module,exports){"use strict";module.exports=triangulateLoop;var poly2tri=require("poly2tri");function PointWrapper(x,y,idx){this.x=x;this.y=y;this.idx=idx}function triangulatePolyline(loops,positions,perturb){function convertLoop(loop){return loop.map(function(v){var p=positions[v];return new PointWrapper(p[0]+(.5-Math.random())*perturb*(1+Math.abs(p[0])),p[1]+(.5-Math.random())*perturb*(1+Math.abs(p[1])),v)})}var numLoops=loops.length;var outerLoop=0;var outerPoint=positions[loops[0][0]];for(var i=0;i<numLoops;++i){var loop=loops[i];var n=loop.length;for(var j=0;j<n;++j){var p=positions[loop[j]];var d=p[1]-outerPoint[1];if(d===0){d=p[0]-outerPoint[0]}if(d<0){outerPoint=p;outerLoop=i}}}var ctx=new poly2tri.SweepContext(convertLoop(loops[outerLoop]));for(var i=0;i<numLoops;++i){if(i===outerLoop){continue}ctx.addHole(convertLoop(loops[i]))}ctx.triangulate();var triangles=ctx.getTriangles();return triangles.map(function(tri){return[tri.getPoint(0).idx,tri.getPoint(1).idx,tri.getPoint(2).idx]})}function triangulateLoop(loops,positions){var p=0;for(var i=0;i<10;++i){try{return triangulatePolyline(loops,positions,p)}catch(e){}p=(p+1e-8)*2}return[]}},{poly2tri:106}],113:[function(require,module,exports){"use strict";module.exports=axesProperties;var glm=require("gl-matrix");var getPlanes=require("extract-frustum-planes");var splitPoly=require("split-polygon");var cubeParams=require("./lib/cube.js");var mat4=glm.mat4;var vec4=glm.vec4;var identity=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);var mvp=new Float32Array(16);function AxesRange3D(lo,hi,pixelsPerDataUnit){this.lo=lo;this.hi=hi;this.pixelsPerDataUnit=pixelsPerDataUnit}var SCRATCH_P=[0,0,0,1];var SCRATCH_Q=[0,0,0,1];function gradient(result,M,v,width,height){for(var i=0;i<3;++i){var p=SCRATCH_P;var q=SCRATCH_Q;for(var j=0;j<3;++j){q[j]=p[j]=v[j]}q[3]=p[3]=1;q[i]+=1;vec4.transformMat4(q,q,M);if(q[3]<0){result[i]=Infinity}p[i]-=1;vec4.transformMat4(p,p,M);if(p[3]<0){result[i]=Infinity}var dx=(p[0]/p[3]-q[0]/q[3])*width;var dy=(p[1]/p[3]-q[1]/q[3])*height;result[i]=.25*Math.sqrt(dx*dx+dy*dy)}return result}var RANGES=[new AxesRange3D(Infinity,-Infinity,Infinity),new AxesRange3D(Infinity,-Infinity,Infinity),new AxesRange3D(Infinity,-Infinity,Infinity)];var SCRATCH_X=[0,0,0];function axesProperties(axes,camera,width,height,params){var model=camera.model||identity;var view=camera.view||identity;var projection=camera.projection||identity;var bounds=axes.bounds;var params=params||cubeParams(model,view,projection,bounds);var axis=params.axis;var edges=params.edges;mat4.mul(mvp,view,model);mat4.mul(mvp,projection,mvp);var ranges=RANGES;for(var i=0;i<3;++i){ranges[i].lo=Infinity;ranges[i].hi=-Infinity;ranges[i].pixelsPerDataUnit=Infinity}var frustum=getPlanes(mat4.transpose(mvp,mvp));mat4.transpose(mvp,mvp);for(var d=0;d<3;++d){var u=(d+1)%3;var v=(d+2)%3;var x=SCRATCH_X;i_loop:for(var i=0;i<2;++i){var poly=[];if(axis[d]<0===!!i){continue}x[d]=bounds[i][d];for(var j=0;j<2;++j){x[u]=bounds[j^i][u];for(var k=0;k<2;++k){x[v]=bounds[k^j^i][v];poly.push(x.slice())}}for(var j=0;j<frustum.length;++j){if(poly.length===0){continue i_loop}poly=splitPoly.positive(poly,frustum[j])}for(var j=0;j<poly.length;++j){var v=poly[j];var grad=gradient(SCRATCH_X,mvp,v,width,height);for(var k=0;k<3;++k){ranges[k].lo=Math.min(ranges[k].lo,v[k]);ranges[k].hi=Math.max(ranges[k].hi,v[k]);if(k!==d){ranges[k].pixelsPerDataUnit=Math.min(ranges[k].pixelsPerDataUnit,Math.abs(grad[k]))}}}}}return ranges}},{"./lib/cube.js":28,"extract-frustum-planes":34,"gl-matrix":44,"split-polygon":57}],114:[function(require,module,exports){"use strict";var webglew=require("webglew");var createTexture=require("gl-texture2d");module.exports=createFBO;var colorAttachmentArrays=null;var FRAMEBUFFER_UNSUPPORTED;var FRAMEBUFFER_INCOMPLETE_ATTACHMENT;var FRAMEBUFFER_INCOMPLETE_DIMENSIONS;var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;function saveFBOState(gl){var fbo=gl.getParameter(gl.FRAMEBUFFER_BINDING);var rbo=gl.getParameter(gl.RENDERBUFFER_BINDING);var tex=gl.getParameter(gl.TEXTURE_BINDING_2D);return[fbo,rbo,tex]}function restoreFBOState(gl,data){gl.bindFramebuffer(gl.FRAMEBUFFER,data[0]);gl.bindRenderbuffer(gl.RENDERBUFFER,data[1]);gl.bindTexture(gl.TEXTURE_2D,data[2])}function lazyInitColorAttachments(gl,ext){var maxColorAttachments=gl.getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL);colorAttachmentArrays=new Array(maxColorAttachments+1);for(var i=0;i<=maxColorAttachments;++i){var x=new Array(maxColorAttachments);for(var j=0;j<i;++j){x[j]=gl.COLOR_ATTACHMENT0+j}for(var j=i;j<maxColorAttachments;++j){x[j]=gl.NONE}colorAttachmentArrays[i]=x}}function throwFBOError(status){switch(status){case FRAMEBUFFER_UNSUPPORTED:throw new Error("gl-fbo: Framebuffer unsupported");case FRAMEBUFFER_INCOMPLETE_ATTACHMENT:throw new Error("gl-fbo: Framebuffer incomplete attachment");case FRAMEBUFFER_INCOMPLETE_DIMENSIONS:throw new Error("gl-fbo: Framebuffer incomplete dimensions");case FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:throw new Error("gl-fbo: Framebuffer incomplete missing attachment");default:throw new Error("gl-fbo: Framebuffer failed for unspecified reason")}}function initTexture(gl,width,height,type,format,attachment){if(!type){return null}var result=createTexture(gl,width,height,format,type);result.magFilter=gl.NEAREST;result.minFilter=gl.NEAREST;result.mipSamples=1;result.bind();gl.framebufferTexture2D(gl.FRAMEBUFFER,attachment,gl.TEXTURE_2D,result.handle,0);return result}function initRenderBuffer(gl,width,height,component,attachment){var result=gl.createRenderbuffer();gl.bindRenderbuffer(gl.RENDERBUFFER,result);gl.renderbufferStorage(gl.RENDERBUFFER,component,width,height);gl.framebufferRenderbuffer(gl.FRAMEBUFFER,attachment,gl.RENDERBUFFER,result);return result}function rebuildFBO(fbo){var state=saveFBOState(fbo.gl);var gl=fbo.gl;var handle=fbo.handle=gl.createFramebuffer();var width=fbo._shape[0];var height=fbo._shape[1];var numColors=fbo.color.length;var ext=fbo._ext;var useStencil=fbo._useStencil;var useDepth=fbo._useDepth;var colorType=fbo._colorType;var extensions=webglew(gl);gl.bindFramebuffer(gl.FRAMEBUFFER,handle);for(var i=0;i<numColors;++i){fbo.color[i]=initTexture(gl,width,height,colorType,gl.RGBA,gl.COLOR_ATTACHMENT0+i)}if(numColors===0){fbo._color_rb=initRenderBuffer(gl,width,height,gl.RGBA4,gl.COLOR_ATTACHMENT0);if(ext){ext.drawBuffersWEBGL(colorAttachmentArrays[0])}}else if(numColors>1){ext.drawBuffersWEBGL(colorAttachmentArrays[numColor])}if(extensions.WEBGL_depth_texture){if(useStencil){fbo.depth=initTexture(gl,width,height,extensions.WEBGL_depth_texture.UNSIGNED_INT_24_8_WEBGL,gl.DEPTH_STENCIL,gl.DEPTH_STENCIL_ATTACHMENT)}else if(useDepth){fbo.depth=initTexture(gl,width,height,gl.UNSIGNED_SHORT,gl.DEPTH_COMPONENT,gl.DEPTH_ATTACHMENT)}}else{if(useDepth&&useStencil){fbo._depth_rb=initRenderBuffer(gl,width,height,gl.DEPTH_STENCIL,gl.DEPTH_STENCIL_ATTACHMENT)}else if(useDepth){fbo._depth_rb=initRenderBuffer(gl,width,height,gl.DEPTH_COMPONENT16,gl.DEPTH_ATTACHMENT)}else if(useStencil){fbo._depth_rb=initRenderBuffer(gl,width,height,gl.STENCIL_INDEX,gl.STENCIL_ATTACHMENT)}}var status=gl.checkFramebufferStatus(gl.FRAMEBUFFER);if(status!==gl.FRAMEBUFFER_COMPLETE){fbo._destroyed=true;gl.bindFramebuffer(gl.FRAMEBUFFER,null);gl.deleteFramebuffer(fbo.handle);fbo.handle=null;if(fbo.depth){fbo.depth.dispose();fbo.depth=null}if(fbo._depth_rb){gl.deleteRenderbuffer(fbo._depth_rb);fbo._depth_rb=null}for(var i=0;i<fbo.color.length;++i){fbo.color[i].dispose();fbo.color[i]=null}if(fbo._color_rb){gl.deleteRenderbuffer(fbo._color_rb);fbo._color_rb=null}restoreFBOState(gl,state);throwFBOError(status)}restoreFBOState(gl,state)}function Framebuffer(gl,width,height,colorType,numColors,useDepth,useStencil,ext){var extensions=webglew(gl);this.gl=gl;this._shape=[width|0,height|0];this._destroyed=false;this._ext=ext;this.color=new Array(numColors);for(var i=0;i<numColors;++i){this.color[i]=null}this._color_rb=null;this.depth=null;this._depth_rb=null;this._colorType=colorType;this._useDepth=useDepth;this._useStencil=useStencil;var parent=this;var shapeVector=[width|0,height|0];Object.defineProperties(shapeVector,{0:{get:function(){return parent._shape[0]},set:function(w){return parent.width=w}},1:{get:function(){return parent._shape[1]},set:function(h){return parent.height=h}}});this._shapeVector=shapeVector;rebuildFBO(this)}var proto=Framebuffer.prototype;function reshapeFBO(fbo,w,h){if(fbo._destroyed){throw new Error("gl-fbo: Can't resize destroyed FBO")}if(fbo._shape[0]===w&&fbo._shape[1]===h){return}var gl=fbo.gl;var maxFBOSize=gl.getParameter(gl.MAX_RENDERBUFFER_SIZE);if(w<0||w>maxFBOSize||h<0||h>maxFBOSize){throw new Error("gl-fbo: Can't resize FBO, invalid dimensions")}fbo._shape[0]=w;fbo._shape[1]=h;var state=saveFBOState(gl);for(var i=0;i<fbo.color.length;++i){fbo.color[i].shape=fbo._shape}if(fbo._color_rb){gl.bindRenderbuffer(gl.RENDERBUFFER,fbo._color_rb);gl.renderbufferStorage(gl.RENDERBUFFER,gl.RGBA4,fbo._shape[0],fbo._shape[1])}if(fbo.depth){fbo.depth.shape=fbo._shape}if(fbo._depth_rb){gl.bindRenderbuffer(gl.RENDERBUFFER,fbo._depth_rb);if(fbo._useDepth&&fbo._useStencil){gl.renderbufferStorage(gl.RENDERBUFFER,gl.DEPTH_STENCIL,fbo._shape[0],fbo._shape[1])}else if(fbo._useDepth){gl.renderbufferStorage(gl.RENDERBUFFER,gl.DEPTH_COMPONENT16,fbo._shape[0],fbo._shape[1])}else if(fbo._useStencil){gl.renderbufferStorage(gl.RENDERBUFFER,gl.STENCIL_INDEX,fbo._shape[0],fbo._shape[1])}}gl.bindFramebuffer(gl.FRAMEBUFFER,fbo.handle);var status=gl.checkFramebufferStatus(gl.FRAMEBUFFER);if(status!==gl.FRAMEBUFFER_COMPLETE){fbo.dispose();restoreFBOState(gl,state);throwFBOError(status)}restoreFBOState(gl,state)}Object.defineProperties(proto,{shape:{get:function(){if(this._destroyed){return[0,0]}return this._shapeVector},set:function(x){if(!Array.isArray(x)){x=[x|0,x|0]}if(x.length!==2){throw new Error("gl-fbo: Shape vector must be length 2")}var w=x[0]|0;var h=x[1]|0;reshapeFBO(this,w,h);return[w,h]},enumerable:false},width:{get:function(){if(this._destroyed){return 0}return this._shape[0]},set:function(w){w=w|0;reshapeFBO(this,w,this._shape[1]);return w},enumerable:false},height:{get:function(){if(this._destroyed){return 0}return this._shape[1]},set:function(h){h=h|0;reshapeFBO(this,this._shape[0],h);return h},enumerable:false}});proto.bind=function(){if(this._destroyed){return}var gl=this.gl;gl.bindFramebuffer(gl.FRAMEBUFFER,this.handle);gl.viewport(0,0,this._shape[0],this._shape[1])};proto.dispose=function(){if(this._destroyed){return}this._destroyed=true;var gl=this.gl;gl.deleteFramebuffer(this.handle);this.handle=null;if(this.depth){this.depth.dispose();this.depth=null}if(this._depth_rb){gl.deleteRenderbuffer(this._depth_rb);this._depth_rb=null}for(var i=0;i<this.color.length;++i){this.color[i].dispose();this.color[i]=null}if(this._color_rb){gl.deleteRenderbuffer(this._color_rb);this._color_rb=null}};function createFBO(gl,width,height,options){if(!FRAMEBUFFER_UNSUPPORTED){FRAMEBUFFER_UNSUPPORTED=gl.FRAMEBUFFER_UNSUPPORTED;FRAMEBUFFER_INCOMPLETE_ATTACHMENT=gl.FRAMEBUFFER_INCOMPLETE_ATTACHMENT;FRAMEBUFFER_INCOMPLETE_DIMENSIONS=gl.FRAMEBUFFER_INCOMPLETE_DIMENSIONS;FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=gl.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT}var extensions=webglew(gl);if(!colorAttachmentArrays&&extensions.WEBGL_draw_buffers){lazyInitColorAttachments(gl,extensions.WEBGL_draw_buffers)}if(Array.isArray(width)){options=height;height=width[1]|0;width=width[0]|0}if(typeof width!=="number"){throw new Error("gl-fbo: Missing shape parameter")}var maxFBOSize=gl.getParameter(gl.MAX_RENDERBUFFER_SIZE);if(width<0||width>maxFBOSize||height<0||height>maxFBOSize){throw new Error("gl-fbo: Parameters are too large for FBO")}options=options||{};var numColors=1;if("color"in options){numColors=Math.max(options.color|0,0);if(numColors<0){throw new Error("gl-fbo: Must specify a nonnegative number of colors")}if(numColors>1){var mrtext=extensions.WEBGL_draw_buffers;if(!mrtext){throw new Error("gl-fbo: Multiple draw buffer extension not supported")}else if(numColors>gl.getParameter(mrtext.MAX_COLOR_ATTACHMENTS_WEBGL)){throw new Error("gl-fbo: Context does not support "+numColors+" draw buffers")}}}var colorType=gl.UNSIGNED_BYTE;if(options.float&&numColors>0){if(!extensions.OES_texture_float){throw new Error("gl-fbo: Context does not support floating point textures")}colorType=gl.FLOAT}else if(options.preferFloat&&numColors>0){if(extensions.OES_texture_float){colorType=gl.FLOAT}}var useDepth=true;if("depth"in options){useDepth=!!options.depth}var useStencil=false;if("stencil"in options){useStencil=!!options.stencil}return new Framebuffer(gl,width,height,colorType,numColors,useDepth,useStencil,extensions.WEBGL_draw_buffers)}},{"gl-texture2d":123,webglew:125}],115:[function(require,module,exports){arguments[4][8][0].apply(exports,arguments)},{"cwise-compiler":116,dup:8}],116:[function(require,module,exports){arguments[4][9][0].apply(exports,arguments)},{"./lib/thunk.js":118,dup:9}],117:[function(require,module,exports){arguments[4][10][0].apply(exports,arguments)},{dup:10,uniq:119}],118:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{"./compile.js":117,dup:11}],119:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments)},{dup:12}],120:[function(require,module,exports){arguments[4][13][0].apply(exports,arguments)},{dup:13}],121:[function(require,module,exports){arguments[4][14][0].apply(exports,arguments)},{dup:14}],122:[function(require,module,exports){(function(global,Buffer){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0]),UINT8C:dup([32,0]),BUFFER:dup([32,0])}}var hasUint8C=typeof Uint8ClampedArray!=="undefined";var POOL=global.__TYPEDARRAY_POOL;if(!POOL.UINT8C){POOL.UINT8C=dup([32,0])}if(!POOL.BUFFER){POOL.BUFFER=dup([32,0])}var DATA=POOL.DATA,BUFFER=POOL.BUFFER;exports.free=function free(array){if(Buffer.isBuffer(array)){BUFFER[bits.log2(array.length)].push(array)}else{if(Object.prototype.toString.call(array)!=="[object ArrayBuffer]"){array=array.buffer}if(!array){return}var n=array.length||array.byteLength;var log_n=bits.log2(n)|0;DATA[log_n].push(array)}};function freeArrayBuffer(buffer){if(!buffer){return}var n=buffer.length||buffer.byteLength;var log_n=bits.log2(n);DATA[log_n].push(buffer)}function freeTypedArray(array){freeArrayBuffer(array.buffer)}exports.freeUint8=exports.freeUint16=exports.freeUint32=exports.freeInt8=exports.freeInt16=exports.freeInt32=exports.freeFloat32=exports.freeFloat=exports.freeFloat64=exports.freeDouble=exports.freeUint8Clamped=exports.freeDataView=freeTypedArray;exports.freeArrayBuffer=freeArrayBuffer;exports.freeBuffer=function freeBuffer(array){BUFFER[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){if(dtype===undefined||dtype==="arraybuffer"){return mallocArrayBuffer(n)}else{switch(dtype){case"uint8":return mallocUint8(n);case"uint16":return mallocUint16(n);case"uint32":return mallocUint32(n);case"int8":return mallocInt8(n);case"int16":return mallocInt16(n);case"int32":return mallocInt32(n);case"float":case"float32":return mallocFloat(n);case"double":case"float64":return mallocDouble(n);case"uint8_clamped":return mallocUint8Clamped(n);case"buffer":return mallocBuffer(n);case"data":case"dataview":return mallocDataView(n);default:return null}}return null};function mallocArrayBuffer(n){var n=bits.nextPow2(n);var log_n=bits.log2(n);var d=DATA[log_n];if(d.length>0){return d.pop()}return new ArrayBuffer(n)}exports.mallocArrayBuffer=mallocArrayBuffer;function mallocUint8(n){return new Uint8Array(mallocArrayBuffer(n),0,n)}exports.mallocUint8=mallocUint8;function mallocUint16(n){return new Uint16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocUint16=mallocUint16;function mallocUint32(n){return new Uint32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocUint32=mallocUint32;function mallocInt8(n){return new Int8Array(mallocArrayBuffer(n),0,n)}exports.mallocInt8=mallocInt8;function mallocInt16(n){return new Int16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocInt16=mallocInt16;function mallocInt32(n){return new Int32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocInt32=mallocInt32;function mallocFloat(n){return new Float32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocFloat32=exports.mallocFloat=mallocFloat;function mallocDouble(n){return new Float64Array(mallocArrayBuffer(8*n),0,n)}exports.mallocFloat64=exports.mallocDouble=mallocDouble;function mallocUint8Clamped(n){if(hasUint8C){return new Uint8ClampedArray(mallocArrayBuffer(n),0,n)}else{return mallocUint8(n)}}exports.mallocUint8Clamped=mallocUint8Clamped;function mallocDataView(n){return new DataView(mallocArrayBuffer(n),0,n)}exports.mallocDataView=mallocDataView;function mallocBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=BUFFER[log_n];if(cache.length>0){return cache.pop()}return new Buffer(n)}exports.mallocBuffer=mallocBuffer;exports.clearCache=function clearCache(){for(var i=0;i<32;++i){POOL.UINT8[i].length=0;POOL.UINT16[i].length=0;POOL.UINT32[i].length=0;POOL.INT8[i].length=0;POOL.INT16[i].length=0;POOL.INT32[i].length=0;POOL.FLOAT[i].length=0;POOL.DOUBLE[i].length=0;POOL.UINT8C[i].length=0;DATA[i].length=0;BUFFER[i].length=0}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"bit-twiddle":120,buffer:1,dup:121}],123:[function(require,module,exports){"use strict";var ndarray=require("ndarray");var ops=require("ndarray-ops");var pool=require("typedarray-pool");var webglew=require("webglew");module.exports=createTexture2D;var linearTypes=null;var filterTypes=null;var wrapTypes=null;function lazyInitLinearTypes(gl){linearTypes=[gl.LINEAR,gl.NEAREST_MIPMAP_LINEAR,gl.LINEAR_MIPMAP_NEAREST,gl.LINEAR_MIPMAP_NEAREST];filterTypes=[gl.NEAREST,gl.LINEAR,gl.NEAREST_MIPMAP_NEAREST,gl.NEAREST_MIPMAP_LINEAR,gl.LINEAR_MIPMAP_NEAREST,gl.LINEAR_MIPMAP_LINEAR];wrapTypes=[gl.REPEAT,gl.CLAMP_TO_EDGE,gl.MIRRORED_REPEAT]}var convertFloatToUint8=function(out,inp){ops.muls(out,inp,255)};function reshapeTexture(tex,w,h){var gl=tex.gl;var maxSize=gl.getParameter(gl.MAX_TEXTURE_SIZE);if(w<0||w>maxSize||h<0||h>maxSize){throw new Error("gl-texture2d: Invalid texture size")}tex._shape=[w,h];tex.bind();gl.texImage2D(gl.TEXTURE_2D,0,tex.format,w,h,0,tex.format,tex.type,null);tex._mipLevels=[0];return tex}function Texture2D(gl,handle,width,height,format,type){this.gl=gl;this.handle=handle;this.format=format;this.type=type;this._shape=[width,height];this._mipLevels=[0];this._magFilter=gl.NEAREST;this._minFilter=gl.NEAREST;this._wrapS=gl.CLAMP_TO_EDGE;this._wrapT=gl.CLAMP_TO_EDGE;this._anisoSamples=1;var parent=this;var wrapVector=[this._wrapS,this._wrapT];Object.defineProperties(wrapVector,[{get:function(){return parent._wrapS},set:function(v){return parent.wrapS=v}},{get:function(){return parent._wrapT},set:function(v){return parent.wrapT=v}}]);this._wrapVector=wrapVector;var shapeVector=[this._shape[0],this._shape[1]];Object.defineProperties(shapeVector,[{get:function(){return parent._shape[0]},set:function(v){return parent.width=v}},{get:function(){return parent._shape[1]},set:function(v){return parent.height=v}}]);this._shapeVector=shapeVector}var proto=Texture2D.prototype;Object.defineProperties(proto,{minFilter:{get:function(){return this._minFilter},set:function(v){this.bind();var gl=this.gl;if(this.type===gl.FLOAT&&linearTypes.indexOf(v)>=0){if(!webglew(gl).texture_float_linear){v=gl.NEAREST}}if(filterTypes.indexOf(v)<0){throw new Error("gl-texture2d: Unknown filter mode "+v)}gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,v);return this._minFilter=v}},magFilter:{get:function(){return this._magFilter},set:function(v){this.bind();var gl=this.gl;if(this.type===gl.FLOAT&&linearTypes.indexOf(v)>=0){if(!webglew(gl).texture_float_linear){v=gl.NEAREST}}if(filterTypes.indexOf(v)<0){throw new Error("gl-texture2d: Unknown filter mode "+v)}gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,v);return this._magFilter=v}},mipSamples:{get:function(){return this._anisoSamples},set:function(i){var psamples=this._anisoSamples;this._anisoSamples=Math.max(i,1)|0;if(psamples!==this._anisoSamples){var ext=webglew(this.gl).EXT_texture_filter_anisotropic;if(ext){this.gl.texParameterf(this.gl.TEXTURE_2D,ext.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(v){this.bind();if(wrapTypes.indexOf(v)<0){throw new Error("gl-texture2d: Unknown wrap mode "+v)}this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,v);return this._wrapS=v}},wrapT:{get:function(){return this._wrapT},set:function(v){this.bind();if(wrapTypes.indexOf(v)<0){throw new Error("gl-texture2d: Unknown wrap mode "+v)}this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,v);return this._wrapT=v}},wrap:{get:function(){return this._wrapVector},set:function(v){if(!Array.isArray(v)){v=[v,v]}if(v.length!==2){throw new Error("gl-texture2d: Must specify wrap mode for rows and columns")}for(var i=0;i<2;++i){if(wrapTypes.indexOf(v[i])<0){throw new Error("gl-texture2d: Unknown wrap mode "+v)}}this._wrapS=v[0];this._wrapT=v[1];var gl=this.gl;this.bind();gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,this._wrapS);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,this._wrapT);return v}},shape:{get:function(){return this._shapeVector},set:function(x){if(!Array.isArray(x)){x=[x|0,x|0]}else{if(x.length!==2){throw new Error("gl-texture2d: Invalid texture shape")}}reshapeTexture(this,x[0]|0,x[1]|0);return[x[0]|0,x[1]|0]}},width:{get:function(){return this._shape[0]},set:function(w){w=w|0;reshapeTexture(this,w,this._shape[1]);return w}},height:{get:function(){return this._shape[1]},set:function(h){h=h|0;reshapeTexture(this,this._shape[0],h);return h}}});proto.bind=function(unit){var gl=this.gl;if(unit!==undefined){gl.activeTexture(gl.TEXTURE0+(unit|0))}gl.bindTexture(gl.TEXTURE_2D,this.handle);if(unit!==undefined){return unit|0}return gl.getParameter(gl.ACTIVE_TEXTURE)-gl.TEXTURE0};proto.dispose=function(){this.gl.deleteTexture(this.handle)};proto.generateMipmap=function(){this.bind();this.gl.generateMipmap(this.gl.TEXTURE_2D);var l=Math.min(this._shape[0],this._shape[1]);for(var i=0;l>0;++i,l>>>=1){if(this._mipLevels.indexOf(i)<0){this._mipLevels.push(i)}}};proto.setPixels=function(data,x_off,y_off,mip_level){var gl=this.gl;this.bind();if(Array.isArray(x_off)){mip_level=y_off;y_off=x_off[1]|0;x_off=x_off[0]|0}else{x_off=x_off||0;y_off=y_off||0}mip_level=mip_level||0;if(data instanceof HTMLCanvasElement||data instanceof ImageData||data instanceof HTMLImageElement||data instanceof HTMLVideoElement){var needsMip=this._mipLevels.indexOf(mip_level)<0;if(needsMip){gl.texImage2D(gl.TEXTURE_2D,0,this.format,this.format,this.type,data);this._mipLevels.push(mip_level)}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,this.format,this.type,data)}}else if(data.shape&&data.stride&&data.data){if(data.shape.length<2||x_off+data.shape[1]>this._shape[1]>>>mip_level||y_off+data.shape[0]>this._shape[0]>>>mip_level||x_off<0||y_off<0){throw new Error("gl-texture2d: Texture dimensions are out of bounds")}texSubImageArray(gl,x_off,y_off,mip_level,this.format,this.type,this._mipLevels,data)}else{throw new Error("gl-texture2d: Unsupported data type")}};function isPacked(shape,stride){if(shape.length===3){return stride[2]===1&&stride[1]===shape[0]*shape[2]&&stride[0]===shape[2]}return stride[0]===1&&stride[1]===shape[0]}function texSubImageArray(gl,x_off,y_off,mip_level,cformat,ctype,mipLevels,array){var dtype=array.dtype;var shape=array.shape.slice();if(shape.length<2||shape.length>3){throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d")}var type=0,format=0;var packed=isPacked(shape,array.stride.slice());if(dtype==="float32"){type=gl.FLOAT}else if(dtype==="float64"){type=gl.FLOAT;packed=false;dtype="float32"}else if(dtype==="uint8"){type=gl.UNSIGNED_BYTE}else{type=gl.UNSIGNED_BYTE;packed=false;dtype="uint8"}var channels=1;if(shape.length===2){format=gl.LUMINANCE;shape=[shape[0],shape[1],1];array=ndarray(array.data,shape,[array.stride[0],array.stride[1],1],array.offset)}else if(shape.length===3){if(shape[2]===1){format=gl.ALPHA}else if(shape[2]===2){format=gl.LUMINANCE_ALPHA}else if(shape[2]===3){format=gl.RGB}else if(shape[2]===4){format=gl.RGBA}else{throw new Error("gl-texture2d: Invalid shape for pixel coords")}channels=shape[2]}else{throw new Error("gl-texture2d: Invalid shape for texture")}if((format===gl.LUMINANCE||format===gl.ALPHA)&&(cformat===gl.LUMINANCE||cformat===gl.ALPHA)){format=cformat}if(format!==cformat){throw new Error("gl-texture2d: Incompatible texture format for setPixels")}var size=array.size;var needsMip=mipLevels.indexOf(mip_level)<0;if(needsMip){mipLevels.push(mip_level)}if(type===ctype&&packed){if(array.offset===0&&array.data.length===size){if(needsMip){gl.texImage2D(gl.TEXTURE_2D,mip_level,cformat,shape[0],shape[1],0,cformat,ctype,array.data); | |
}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,shape[0],shape[1],cformat,ctype,array.data)}}else{if(needsMip){gl.texImage2D(gl.TEXTURE_2D,mip_level,cformat,shape[0],shape[1],0,cformat,ctype,array.data.subarray(array.offset,array.offset+size))}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,shape[0],shape[1],cformat,ctype,array.data.subarray(array.offset,array.offset+size))}}}else{var pack_buffer;if(ctype===gl.FLOAT){pack_buffer=pool.mallocFloat32(size)}else{pack_buffer=pool.mallocUint8(size)}var pack_view=ndarray(pack_buffer,shape,[shape[2],shape[2]*shape[0],1]);if(type===gl.FLOAT&&ctype===gl.UNSIGNED_BYTE){convertFloatToUint8(pack_view,array)}else{ops.assign(pack_view,array)}if(needsMip){gl.texImage2D(gl.TEXTURE_2D,mip_level,cformat,shape[0],shape[1],0,cformat,ctype,pack_buffer.subarray(0,size))}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,shape[0],shape[1],cformat,ctype,pack_buffer.subarray(0,size))}if(ctype===gl.FLOAT){pool.freeFloat32(pack_buffer)}else{pool.freeUint8(pack_buffer)}}}function initTexture(gl){var tex=gl.createTexture();gl.bindTexture(gl.TEXTURE_2D,tex);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);return tex}function createTextureShape(gl,width,height,format,type){var maxTextureSize=gl.getParameter(gl.MAX_TEXTURE_SIZE);if(width<0||width>maxTextureSize||height<0||height>maxTextureSize){throw new Error("gl-texture2d: Invalid texture shape")}if(type===gl.FLOAT&&!webglew(gl).texture_float){throw new Error("gl-texture2d: Floating point textures not supported on this platform")}var tex=initTexture(gl);gl.texImage2D(gl.TEXTURE_2D,0,format,width,height,0,format,type,null);return new Texture2D(gl,tex,width,height,format,type)}function createTextureDOM(gl,element,format,type){var tex=initTexture(gl);gl.texImage2D(gl.TEXTURE_2D,0,format,format,type,element);return new Texture2D(gl,tex,element.width|0,element.height|0,format,type)}function createTextureArray(gl,array){var dtype=array.dtype;var shape=array.shape.slice();var maxSize=gl.getParameter(gl.MAX_TEXTURE_SIZE);if(shape[0]<0||shape[0]>maxSize||shape[1]<0||shape[1]>maxSize){throw new Error("gl-texture2d: Invalid texture size")}var packed=isPacked(shape,array.stride.slice());var type=0;if(dtype==="float32"){type=gl.FLOAT}else if(dtype==="float64"){type=gl.FLOAT;packed=false;dtype="float32"}else if(dtype==="uint8"){type=gl.UNSIGNED_BYTE}else{type=gl.UNSIGNED_BYTE;packed=false;dtype="uint8"}var format=0;if(shape.length===2){format=gl.LUMINANCE;shape=[shape[0],shape[1],1];array=ndarray(array.data,shape,[array.stride[0],array.stride[1],1],array.offset)}else if(shape.length===3){if(shape[2]===1){format=gl.ALPHA}else if(shape[2]===2){format=gl.LUMINANCE_ALPHA}else if(shape[2]===3){format=gl.RGB}else if(shape[2]===4){format=gl.RGBA}else{throw new Error("gl-texture2d: Invalid shape for pixel coords")}}else{throw new Error("gl-texture2d: Invalid shape for texture")}if(type===gl.FLOAT&&!webglew(gl).texture_float){type=gl.UNSIGNED_BYTE;packed=false}var buffer,buf_store;var size=array.size;if(!packed){var stride=[shape[2],shape[2]*shape[0],1];buf_store=pool.malloc(size,dtype);var buf_array=ndarray(buf_store,shape,stride,0);if((dtype==="float32"||dtype==="float64")&&type===gl.UNSIGNED_BYTE){convertFloatToUint8(buf_array,array)}else{ops.assign(buf_array,array)}buffer=buf_store.subarray(0,size)}else if(array.offset===0&&array.data.length===size){buffer=array.data}else{buffer=array.data.subarray(array.offset,array.offset+size)}var tex=initTexture(gl);gl.texImage2D(gl.TEXTURE_2D,0,format,shape[0],shape[1],0,format,type,buffer);if(!packed){pool.free(buf_store)}return new Texture2D(gl,tex,shape[0],shape[1],format,type)}function createTexture2D(gl){if(arguments.length<=1){throw new Error("gl-texture2d: Missing arguments for texture2d constructor")}if(!linearTypes){lazyInitLinearTypes(gl)}if(typeof arguments[1]==="number"){return createTextureShape(gl,arguments[1],arguments[2],arguments[3]||gl.RGBA,arguments[4]||gl.UNSIGNED_BYTE)}if(Array.isArray(arguments[1])){return createTextureShape(gl,arguments[1][0]|0,arguments[1][1]|0,arguments[2]||gl.RGBA,arguments[3]||gl.UNSIGNED_BYTE)}if(typeof arguments[1]==="object"){var obj=arguments[1];if(obj instanceof HTMLCanvasElement||obj instanceof HTMLImageElement||obj instanceof HTMLVideoElement||obj instanceof ImageData){return createTextureDOM(gl,obj,arguments[2]||gl.RGBA,arguments[3]||gl.UNSIGNED_BYTE)}else if(obj.shape&&obj.data&&obj.stride){return createTextureArray(gl,obj)}}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}},{ndarray:178,"ndarray-ops":115,"typedarray-pool":122,webglew:125}],124:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{dup:16}],125:[function(require,module,exports){arguments[4][17][0].apply(exports,arguments)},{dup:17,"weak-map":124}],126:[function(require,module,exports){module.exports=fromQuat;function fromQuat(out,q){var x=q[0],y=q[1],z=q[2],w=q[3],x2=x+x,y2=y+y,z2=z+z,xx=x*x2,yx=y*x2,yy=y*y2,zx=z*x2,zy=z*y2,zz=z*z2,wx=w*x2,wy=w*y2,wz=w*z2;out[0]=1-yy-zz;out[1]=yx+wz;out[2]=zx-wy;out[3]=0;out[4]=yx-wz;out[5]=1-xx-zz;out[6]=zy+wx;out[7]=0;out[8]=zx+wy;out[9]=zy-wx;out[10]=1-xx-yy;out[11]=0;out[12]=0;out[13]=0;out[14]=0;out[15]=1;return out}},{}],127:[function(require,module,exports){module.exports=identity;function identity(out){out[0]=1;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=1;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[10]=1;out[11]=0;out[12]=0;out[13]=0;out[14]=0;out[15]=1;return out}},{}],128:[function(require,module,exports){module.exports=invert;function invert(out,a){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;if(!det){return null}det=1/det;out[0]=(a11*b11-a12*b10+a13*b09)*det;out[1]=(a02*b10-a01*b11-a03*b09)*det;out[2]=(a31*b05-a32*b04+a33*b03)*det;out[3]=(a22*b04-a21*b05-a23*b03)*det;out[4]=(a12*b08-a10*b11-a13*b07)*det;out[5]=(a00*b11-a02*b08+a03*b07)*det;out[6]=(a32*b02-a30*b05-a33*b01)*det;out[7]=(a20*b05-a22*b02+a23*b01)*det;out[8]=(a10*b10-a11*b08+a13*b06)*det;out[9]=(a01*b08-a00*b10-a03*b06)*det;out[10]=(a30*b04-a31*b02+a33*b00)*det;out[11]=(a21*b02-a20*b04-a23*b00)*det;out[12]=(a11*b07-a10*b09-a12*b06)*det;out[13]=(a00*b09-a01*b07+a02*b06)*det;out[14]=(a31*b01-a30*b03-a32*b00)*det;out[15]=(a20*b03-a21*b01+a22*b00)*det;return out}},{}],129:[function(require,module,exports){var identity=require("./identity");module.exports=lookAt;function lookAt(out,eye,center,up){var x0,x1,x2,y0,y1,y2,z0,z1,z2,len,eyex=eye[0],eyey=eye[1],eyez=eye[2],upx=up[0],upy=up[1],upz=up[2],centerx=center[0],centery=center[1],centerz=center[2];if(Math.abs(eyex-centerx)<1e-6&&Math.abs(eyey-centery)<1e-6&&Math.abs(eyez-centerz)<1e-6){return identity(out)}z0=eyex-centerx;z1=eyey-centery;z2=eyez-centerz;len=1/Math.sqrt(z0*z0+z1*z1+z2*z2);z0*=len;z1*=len;z2*=len;x0=upy*z2-upz*z1;x1=upz*z0-upx*z2;x2=upx*z1-upy*z0;len=Math.sqrt(x0*x0+x1*x1+x2*x2);if(!len){x0=0;x1=0;x2=0}else{len=1/len;x0*=len;x1*=len;x2*=len}y0=z1*x2-z2*x1;y1=z2*x0-z0*x2;y2=z0*x1-z1*x0;len=Math.sqrt(y0*y0+y1*y1+y2*y2);if(!len){y0=0;y1=0;y2=0}else{len=1/len;y0*=len;y1*=len;y2*=len}out[0]=x0;out[1]=y0;out[2]=z0;out[3]=0;out[4]=x1;out[5]=y1;out[6]=z1;out[7]=0;out[8]=x2;out[9]=y2;out[10]=z2;out[11]=0;out[12]=-(x0*eyex+x1*eyey+x2*eyez);out[13]=-(y0*eyex+y1*eyey+y2*eyez);out[14]=-(z0*eyex+z1*eyey+z2*eyez);out[15]=1;return out}},{"./identity":127}],130:[function(require,module,exports){module.exports=multiply;function multiply(out,a,b){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15];var b0=b[0],b1=b[1],b2=b[2],b3=b[3];out[0]=b0*a00+b1*a10+b2*a20+b3*a30;out[1]=b0*a01+b1*a11+b2*a21+b3*a31;out[2]=b0*a02+b1*a12+b2*a22+b3*a32;out[3]=b0*a03+b1*a13+b2*a23+b3*a33;b0=b[4];b1=b[5];b2=b[6];b3=b[7];out[4]=b0*a00+b1*a10+b2*a20+b3*a30;out[5]=b0*a01+b1*a11+b2*a21+b3*a31;out[6]=b0*a02+b1*a12+b2*a22+b3*a32;out[7]=b0*a03+b1*a13+b2*a23+b3*a33;b0=b[8];b1=b[9];b2=b[10];b3=b[11];out[8]=b0*a00+b1*a10+b2*a20+b3*a30;out[9]=b0*a01+b1*a11+b2*a21+b3*a31;out[10]=b0*a02+b1*a12+b2*a22+b3*a32;out[11]=b0*a03+b1*a13+b2*a23+b3*a33;b0=b[12];b1=b[13];b2=b[14];b3=b[15];out[12]=b0*a00+b1*a10+b2*a20+b3*a30;out[13]=b0*a01+b1*a11+b2*a21+b3*a31;out[14]=b0*a02+b1*a12+b2*a22+b3*a32;out[15]=b0*a03+b1*a13+b2*a23+b3*a33;return out}},{}],131:[function(require,module,exports){module.exports=perspective;function perspective(out,fovy,aspect,near,far){var f=1/Math.tan(fovy/2),nf=1/(near-far);out[0]=f/aspect;out[1]=0;out[2]=0;out[3]=0;out[4]=0;out[5]=f;out[6]=0;out[7]=0;out[8]=0;out[9]=0;out[10]=(far+near)*nf;out[11]=-1;out[12]=0;out[13]=0;out[14]=2*far*near*nf;out[15]=0;return out}},{}],132:[function(require,module,exports){arguments[4][13][0].apply(exports,arguments)},{dup:13}],133:[function(require,module,exports){module.exports=require("cwise-compiler")},{"cwise-compiler":134}],134:[function(require,module,exports){arguments[4][9][0].apply(exports,arguments)},{"./lib/thunk.js":136,dup:9}],135:[function(require,module,exports){arguments[4][10][0].apply(exports,arguments)},{dup:10,uniq:137}],136:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{"./compile.js":135,dup:11}],137:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments)},{dup:12}],138:[function(require,module,exports){arguments[4][14][0].apply(exports,arguments)},{dup:14}],139:[function(require,module,exports){(function(global,Buffer){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0]),UINT8C:dup([32,0]),BUFFER:dup([32,0])}}var hasUint8C=typeof Uint8ClampedArray!=="undefined";var POOL=global.__TYPEDARRAY_POOL;if(!POOL.UINT8C){POOL.UINT8C=dup([32,0])}if(!POOL.BUFFER){POOL.BUFFER=dup([32,0])}var DATA=POOL.DATA,BUFFER=POOL.BUFFER;exports.free=function free(array){if(Buffer.isBuffer(array)){BUFFER[bits.log2(array.length)].push(array)}else{if(Object.prototype.toString.call(array)!=="[object ArrayBuffer]"){array=array.buffer}if(!array){return}var n=array.length||array.byteLength;var log_n=bits.log2(n)|0;DATA[log_n].push(array)}};function freeArrayBuffer(buffer){if(!buffer){return}var n=buffer.length||buffer.byteLength;var log_n=bits.log2(n);DATA[log_n].push(buffer)}function freeTypedArray(array){freeArrayBuffer(array.buffer)}exports.freeUint8=exports.freeUint16=exports.freeUint32=exports.freeInt8=exports.freeInt16=exports.freeInt32=exports.freeFloat32=exports.freeFloat=exports.freeFloat64=exports.freeDouble=exports.freeUint8Clamped=exports.freeDataView=freeTypedArray;exports.freeArrayBuffer=freeArrayBuffer;exports.freeBuffer=function freeBuffer(array){BUFFER[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){if(dtype===undefined||dtype==="arraybuffer"){return mallocArrayBuffer(n)}else{switch(dtype){case"uint8":return mallocUint8(n);case"uint16":return mallocUint16(n);case"uint32":return mallocUint32(n);case"int8":return mallocInt8(n);case"int16":return mallocInt16(n);case"int32":return mallocInt32(n);case"float":case"float32":return mallocFloat(n);case"double":case"float64":return mallocDouble(n);case"uint8_clamped":return mallocUint8Clamped(n);case"buffer":return mallocBuffer(n);case"data":case"dataview":return mallocDataView(n);default:return null}}return null};function mallocArrayBuffer(n){var n=bits.nextPow2(n);var log_n=bits.log2(n);var d=DATA[log_n];if(d.length>0){return d.pop()}return new ArrayBuffer(n)}exports.mallocArrayBuffer=mallocArrayBuffer;function mallocUint8(n){return new Uint8Array(mallocArrayBuffer(n),0,n)}exports.mallocUint8=mallocUint8;function mallocUint16(n){return new Uint16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocUint16=mallocUint16;function mallocUint32(n){return new Uint32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocUint32=mallocUint32;function mallocInt8(n){return new Int8Array(mallocArrayBuffer(n),0,n)}exports.mallocInt8=mallocInt8;function mallocInt16(n){return new Int16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocInt16=mallocInt16;function mallocInt32(n){return new Int32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocInt32=mallocInt32;function mallocFloat(n){return new Float32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocFloat32=exports.mallocFloat=mallocFloat;function mallocDouble(n){return new Float64Array(mallocArrayBuffer(8*n),0,n)}exports.mallocFloat64=exports.mallocDouble=mallocDouble;function mallocUint8Clamped(n){if(hasUint8C){return new Uint8ClampedArray(mallocArrayBuffer(n),0,n)}else{return mallocUint8(n)}}exports.mallocUint8Clamped=mallocUint8Clamped;function mallocDataView(n){return new DataView(mallocArrayBuffer(n),0,n)}exports.mallocDataView=mallocDataView;function mallocBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=BUFFER[log_n];if(cache.length>0){return cache.pop()}return new Buffer(n)}exports.mallocBuffer=mallocBuffer;exports.clearCache=function clearCache(){for(var i=0;i<32;++i){POOL.UINT8[i].length=0;POOL.UINT16[i].length=0;POOL.UINT32[i].length=0;POOL.INT8[i].length=0;POOL.INT16[i].length=0;POOL.INT32[i].length=0;POOL.FLOAT[i].length=0;POOL.DOUBLE[i].length=0;POOL.UINT8C[i].length=0;DATA[i].length=0;BUFFER[i].length=0}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"bit-twiddle":132,buffer:1,dup:138}],140:[function(require,module,exports){"use strict";module.exports=createSelectBuffer;var createFBO=require("gl-fbo");var pool=require("typedarray-pool");var ndarray=require("ndarray");var nextPow2=require("bit-twiddle").nextPow2;var selectRange=require("cwise/lib/wrapper")({args:["array",{offset:[0,0,1],array:0},{offset:[0,0,2],array:0},{offset:[0,0,3],array:0},"scalar","scalar","scalar","index"],pre:{body:"{this_closestX=-1,this_closestY=-1,this_closestD2=1e8}",args:[],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},body:{body:"{if(255>_inline_1_arg0_){var _inline_1_a=_inline_1_arg4_-_inline_1_arg7_[0],_inline_1_f=_inline_1_arg5_-_inline_1_arg7_[1],_inline_1_n=_inline_1_a*_inline_1_a+_inline_1_f*_inline_1_f;_inline_1_n<this_closestD2&&(this_closestD2=_inline_1_n,this_closestX=_inline_1_arg7_[0],this_closestY=_inline_1_arg7_[1])}}",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:1},{name:"_inline_1_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_1_arg2_",lvalue:false,rvalue:false,count:0},{name:"_inline_1_arg3_",lvalue:false,rvalue:false,count:0},{name:"_inline_1_arg4_",lvalue:false,rvalue:true,count:1},{name:"_inline_1_arg5_",lvalue:false,rvalue:true,count:1},{name:"_inline_1_arg6_",lvalue:false,rvalue:false,count:0},{name:"_inline_1_arg7_",lvalue:false,rvalue:true,count:4}],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:["_inline_1_a","_inline_1_f","_inline_1_n"]},post:{body:"{_inline_2_arg6_[0]=this_closestX,_inline_2_arg6_[1]=this_closestY,_inline_2_arg6_[2]=this_closestD2}",args:[{name:"_inline_2_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_2_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_2_arg2_",lvalue:false,rvalue:false,count:0},{name:"_inline_2_arg3_",lvalue:false,rvalue:false,count:0},{name:"_inline_2_arg4_",lvalue:false,rvalue:false,count:0},{name:"_inline_2_arg5_",lvalue:false,rvalue:false,count:0},{name:"_inline_2_arg6_",lvalue:false,rvalue:true,count:3}],thisVars:["this_closestD2","this_closestX","this_closestY"],localVars:[]},debug:false,funcName:"cwise",blockSize:64});function SelectResult(x,y,id,value,distance){this.coord=[x,y];this.id=id;this.value=value;this.distance=distance}function SelectBuffer(gl,fbo,buffer){this.gl=gl;this.fbo=fbo;this.buffer=buffer;this._readTimeout=null;this._selectResult=new SelectResult(0,0,0,[0,0,0],Infinity);this._region=ndarray(this.buffer,[fbo.width,fbo.height,4],[4,4*fbo.width,1],0);var self=this;this._readCallback=function(){fbo.bind();gl.readPixels(0,0,fbo.shape[0],fbo.shape[1],gl.RGBA,gl.UNSIGNED_BYTE,self.buffer);self._readTimeout=null}}var proto=SelectBuffer.prototype;Object.defineProperty(proto,"shape",{get:function(){return this.fbo.shape.slice()},set:function(v){this.fbo.shape=v;var c=this.fbo.shape[0];var r=this.fbo.shape[1];if(r*c*4>this.buffer.length){pool.free(this.buffer);var buffer=this.buffer=pool.mallocUint8(nextPow2(r*c*4));for(var i=0;i<r*c*4;++i){buffer[i]=255}}return v}});proto.begin=function(){var gl=this.gl;var shape=this.shape;this.fbo.bind();gl.clearColor(1,1,1,1);gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT)};proto.end=function(){var gl=this.gl;gl.bindFramebuffer(gl.FRAMEBUFFER,null);if(!this._readTimeout){clearTimeout(this._readTimeout)}this._readTimeout=setTimeout(this._readCallback,1)};var QUERY_RESULT=[0,0,0];proto.query=function(x,y,radius){var w=this.fbo.width;var h=this.fbo.height;x=x|0;y=y|0;if(typeof radius!=="number"){radius=1}var x0=Math.min(x-radius,w)|0;var x1=Math.min(Math.max(x+radius,0),w)|0;var y0=Math.min(y-radius,h)|0;var y1=Math.min(Math.max(y+radius,0),h)|0;var xr=radius;if(x0<0){xr+=x0;x0=0}var yr=radius;if(y0<0){yr+=y0;y0=0}if(x1<=x0||y1<=y0){return null}var region=this._region;region.data=this.buffer;region.shape[0]=x1-x0|0;region.shape[1]=y1-y0|0;region.shape[2]=4;region.stride[0]=4;region.stride[1]=4*w;region.stride[2]=1;region.offset=4*(x0+w*y0);selectRange(region,xr,yr,QUERY_RESULT);var dx=QUERY_RESULT[0];var dy=QUERY_RESULT[1];var d2=QUERY_RESULT[2];if(dx<0||Math.pow(radius,2)<d2){return null}var xc=x0+dx|0;var yc=y0+dy|0;var result=this._selectResult;result.coord[0]=xc;result.coord[1]=yc;result.id=region.get(dx,dy,0);result.value[0]=region.get(dx,dy,1);result.value[1]=region.get(dx,dy,2);result.value[2]=region.get(dx,dy,3);result.distance=Math.sqrt(d2);return result};proto.dispose=function(){this.fbo.dispose();pool.free(this.buffer)};function createSelectBuffer(gl,shape){var fbo=createFBO(gl,shape);var buffer=pool.mallocUint8(shape[0]*shape[1]*4);return new SelectBuffer(gl,fbo,buffer)}},{"bit-twiddle":132,"cwise/lib/wrapper":133,"gl-fbo":114,ndarray:178,"typedarray-pool":139}],141:[function(require,module,exports){"use strict";var createUniformWrapper=require("./lib/create-uniforms");var createAttributeWrapper=require("./lib/create-attributes");var makeReflect=require("./lib/reflect");var shaderCache=require("./lib/shader-cache");var runtime=require("./lib/runtime-reflect");function Shader(gl){this.gl=gl;this._vref=this._fref=this._relink=this.vertShader=this.fragShader=this.program=this.attributes=this.uniforms=this.types=null}var proto=Shader.prototype;proto.bind=function(){if(!this.program){this._relink()}this.gl.useProgram(this.program)};proto.dispose=function(){if(this._fref){this._fref.dispose()}if(this._vref){this._vref.dispose()}this.attributes=this.types=this.vertShader=this.fragShader=this.program=this._relink=this._fref=this._vref=null};function compareAttributes(a,b){if(a.name<b.name){return-1}return 1}proto.update=function(vertSource,fragSource,uniforms,attributes){if(!fragSource||arguments.length===1){var obj=vertSource;vertSource=obj.vertex;fragSource=obj.fragment;uniforms=obj.uniforms;attributes=obj.attributes}var wrapper=this;var gl=wrapper.gl;var pvref=wrapper._vref;wrapper._vref=shaderCache.shader(gl,gl.VERTEX_SHADER,vertSource);if(pvref){pvref.dispose()}wrapper.vertShader=wrapper._vref.shader;var pfref=this._fref;wrapper._fref=shaderCache.shader(gl,gl.FRAGMENT_SHADER,fragSource);if(pfref){pfref.dispose()}wrapper.fragShader=wrapper._fref.shader;if(!uniforms||!attributes){var testProgram=gl.createProgram();gl.attachShader(testProgram,wrapper.fragShader);gl.attachShader(testProgram,wrapper.vertShader);gl.linkProgram(testProgram);if(!gl.getProgramParameter(testProgram,gl.LINK_STATUS)){var errLog=gl.getProgramInfoLog(testProgram);console.error("gl-shader: Error linking program:",errLog);throw new Error("gl-shader: Error linking program:"+errLog)}uniforms=uniforms||runtime.uniforms(gl,testProgram);attributes=attributes||runtime.attributes(gl,testProgram);gl.deleteProgram(testProgram)}attributes=attributes.slice();attributes.sort(compareAttributes);var attributeUnpacked=[];var attributeNames=[];var attributeLocations=[];for(var i=0;i<attributes.length;++i){var attr=attributes[i];if(attr.type.indexOf("mat")>=0){var size=attr.type.charAt(attr.type.length-1)|0;var locVector=new Array(size);for(var j=0;j<size;++j){locVector[j]=attributeLocations.length;attributeNames.push(attr.name+"["+j+"]");if(typeof attr.location==="number"){attributeLocations.push(attr.location+j)}else if(Array.isArray(attr.location)&&attr.location.length===size&&typeof attr.location[j]==="number"){attributeLocations.push(attr.location[j]|0)}else{attributeLocations.push(-1)}}attributeUnpacked.push({name:attr.name,type:attr.type,locations:locVector})}else{attributeUnpacked.push({name:attr.name,type:attr.type,locations:[attributeLocations.length]});attributeNames.push(attr.name);if(typeof attr.location==="number"){attributeLocations.push(attr.location|0)}else{attributeLocations.push(-1)}}}var curLocation=0;for(var i=0;i<attributeLocations.length;++i){if(attributeLocations[i]<0){while(attributeLocations.indexOf(curLocation)>=0){curLocation+=1}attributeLocations[i]=curLocation}}var uniformLocations=new Array(uniforms.length);function relink(){wrapper.program=shaderCache.program(gl,wrapper._vref,wrapper._fref,attributeNames,attributeLocations);for(var i=0;i<uniforms.length;++i){uniformLocations[i]=gl.getUniformLocation(wrapper.program,uniforms[i].name)}}relink();wrapper._relink=relink;wrapper.types={uniforms:makeReflect(uniforms),attributes:makeReflect(attributes)};wrapper.attributes=createAttributeWrapper(gl,wrapper,attributeUnpacked,attributeLocations);Object.defineProperty(wrapper,"uniforms",createUniformWrapper(gl,wrapper,uniforms,uniformLocations))};function createShader(gl,vertSource,fragSource,uniforms,attributes){var shader=new Shader(gl);shader.update(vertSource,fragSource,uniforms,attributes);return shader}module.exports=createShader},{"./lib/create-attributes":142,"./lib/create-uniforms":143,"./lib/reflect":144,"./lib/runtime-reflect":145,"./lib/shader-cache":146}],142:[function(require,module,exports){"use strict";module.exports=createAttributeWrapper;function ShaderAttribute(gl,wrapper,index,locations,dimension,constFunc){this._gl=gl;this._wrapper=wrapper;this._index=index;this._locations=locations;this._dimension=dimension;this._constFunc=constFunc}var proto=ShaderAttribute.prototype;proto.pointer=function setAttribPointer(type,normalized,stride,offset){var self=this;var gl=self._gl;var location=self._locations[self._index];gl.vertexAttribPointer(location,self._dimension,type||gl.FLOAT,!!normalized,stride||0,offset||0);gl.enableVertexAttribArray(location)};proto.set=function(x0,x1,x2,x3){return this._constFunc(this._locations[this._index],x0,x1,x2,x3)};Object.defineProperty(proto,"location",{get:function(){return this._locations[this._index]},set:function(v){if(v!==this._locations[this._index]){this._locations[this._index]=v|0;this._wrapper.program=null}return v|0}});function addVectorAttribute(gl,wrapper,index,locations,dimension,obj,name){var constFuncArgs=["gl","v"];var varNames=[];for(var i=0;i<dimension;++i){constFuncArgs.push("x"+i);varNames.push("x"+i)}constFuncArgs.push("if(x0.length===void 0){return gl.vertexAttrib"+dimension+"f(v,"+varNames.join()+")}else{return gl.vertexAttrib"+dimension+"fv(v,x0)}");var constFunc=Function.apply(null,constFuncArgs);var attr=new ShaderAttribute(gl,wrapper,index,locations,dimension,constFunc);Object.defineProperty(obj,name,{set:function(x){gl.disableVertexAttribArray(locations[index]);constFunc(gl,locations[index],x);return x},get:function(){return attr},enumerable:true})}function addMatrixAttribute(gl,wrapper,index,locations,dimension,obj,name){var parts=new Array(dimension);var attrs=new Array(dimension);for(var i=0;i<dimension;++i){addVectorAttribute(gl,wrapper,index[i],locations,dimension,parts,i);attrs[i]=parts[i]}Object.defineProperty(parts,"location",{set:function(v){if(Array.isArray){for(var i=0;i<dimension;++i){attrs[i].location=v[i]}}else{for(var i=0;i<dimension;++i){result[i]=attrs[i].location=v+i}}return v},get:function(){var result=new Array(dimension);for(var i=0;i<dimension;++i){result[i]=locations[index[i]]}return result},enumerable:true});parts.pointer=function(type,normalized,stride,offset){type=type||gl.FLOAT;normalized=!!normalized;stride=stride||dimension*dimension;offset=offset||0;for(var i=0;i<dimension;++i){var location=locations[index[i]];gl.vertexAttribPointer(location,dimension,type,normalized,stride,offset+i*dimension);gl.enableVertexAttribArray(location)}};var scratch=new Array(dimension);var vertexAttrib=gl["vertexAttrib"+dimension+"fv"];Object.defineProperty(obj,name,{set:function(x){for(var i=0;i<dimension;++i){var loc=locations[index[i]];gl.disableVertexAttribArray(loc);if(Array.isArray(x[0])){vertexAttrib.call(gl,loc,x[i])}else{for(var j=0;j<dimension;++j){scratch[j]=x[dimension*i+j]}vertexAttrib.call(gl,loc,scratch)}}return x},get:function(){return parts},enumerable:true})}function createAttributeWrapper(gl,wrapper,attributes,locations){var obj={};for(var i=0,n=attributes.length;i<n;++i){var a=attributes[i];var name=a.name;var type=a.type;var locs=a.locations;switch(type){case"bool":case"int":case"float":addVectorAttribute(gl,wrapper,locs[0],locations,1,obj,name);break;default:if(type.indexOf("vec")>=0){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type for attribute "+name+": "+type)}addVectorAttribute(gl,wrapper,locs[0],locations,d,obj,name)}else if(type.indexOf("mat")>=0){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type for attribute "+name+": "+type)}addMatrixAttribute(gl,wrapper,locs,locations,d,obj,name)}else{throw new Error("gl-shader: Unknown data type for attribute "+name+": "+type)}break}}return obj}},{}],143:[function(require,module,exports){"use strict";var coallesceUniforms=require("./reflect");module.exports=createUniformWrapper;function identity(x){var c=new Function("y","return function(){return y}");return c(x)}function makeVector(length,fill){var result=new Array(length);for(var i=0;i<length;++i){result[i]=fill}return result}function createUniformWrapper(gl,wrapper,uniforms,locations){function makeGetter(index){var proc=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+index+"])}");return proc(gl,wrapper,locations)}function makePropSetter(path,index,type){switch(type){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+index+"],obj"+path+")";case"float":return"gl.uniform1f(locations["+index+"],obj"+path+")";default:var vidx=type.indexOf("vec");if(0<=vidx&&vidx<=1&&type.length===4+vidx){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type")}switch(type.charAt(0)){case"b":case"i":return"gl.uniform"+d+"iv(locations["+index+"],obj"+path+")";case"v":return"gl.uniform"+d+"fv(locations["+index+"],obj"+path+")";default:throw new Error("gl-shader: Unrecognized data type for vector "+name+": "+type)}}else if(type.indexOf("mat")===0&&type.length===4){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+type)}return"gl.uniformMatrix"+d+"fv(locations["+index+"],false,obj"+path+")"}else{throw new Error("gl-shader: Unknown uniform data type for "+name+": "+type)}break}}function enumerateIndices(prefix,type){if(typeof type!=="object"){return[[prefix,type]]}var indices=[];for(var id in type){var prop=type[id];var tprefix=prefix;if(parseInt(id)+""===id){tprefix+="["+id+"]"}else{tprefix+="."+id}if(typeof prop==="object"){indices.push.apply(indices,enumerateIndices(tprefix,prop))}else{indices.push([tprefix,prop])}}return indices}function makeSetter(type){var code=["return function updateProperty(obj){"];var indices=enumerateIndices("",type);for(var i=0;i<indices.length;++i){var item=indices[i];var path=item[0];var idx=item[1];if(locations[idx]){code.push(makePropSetter(path,idx,uniforms[idx].type))}}code.push("return obj}");var proc=new Function("gl","locations",code.join("\n"));return proc(gl,locations)}function defaultValue(type){switch(type){case"bool":return false;case"int":case"sampler2D":case"samplerCube":return 0;case"float":return 0;default:var vidx=type.indexOf("vec");if(0<=vidx&&vidx<=1&&type.length===4+vidx){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type")}if(type.charAt(0)==="b"){return makeVector(d,false)}return makeVector(d,0)}else if(type.indexOf("mat")===0&&type.length===4){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+type)}return makeVector(d*d,0)}else{throw new Error("gl-shader: Unknown uniform data type for "+name+": "+type)}break}}function storeProperty(obj,prop,type){if(typeof type==="object"){var child=processObject(type);Object.defineProperty(obj,prop,{get:identity(child),set:makeSetter(type),enumerable:true,configurable:false})}else{if(locations[type]){Object.defineProperty(obj,prop,{get:makeGetter(type),set:makeSetter(type),enumerable:true,configurable:false})}else{obj[prop]=defaultValue(uniforms[type].type)}}}function processObject(obj){var result;if(Array.isArray(obj)){result=new Array(obj.length);for(var i=0;i<obj.length;++i){storeProperty(result,i,obj[i])}}else{result={};for(var id in obj){storeProperty(result,id,obj[id])}}return result}var coallesced=coallesceUniforms(uniforms,true);return{get:identity(processObject(coallesced)),set:makeSetter(coallesced),enumerable:true,configurable:true}}},{"./reflect":144}],144:[function(require,module,exports){"use strict";module.exports=makeReflectTypes;function makeReflectTypes(uniforms,useIndex){var obj={};for(var i=0;i<uniforms.length;++i){var n=uniforms[i].name;var parts=n.split(".");var o=obj;for(var j=0;j<parts.length;++j){var x=parts[j].split("[");if(x.length>1){if(!(x[0]in o)){o[x[0]]=[]}o=o[x[0]];for(var k=1;k<x.length;++k){var y=parseInt(x[k]);if(k<x.length-1||j<parts.length-1){if(!(y in o)){if(k<x.length-1){o[y]=[]}else{o[y]={}}}o=o[y]}else{if(useIndex){o[y]=i}else{o[y]=uniforms[i].type}}}}else if(j<parts.length-1){if(!(x[0]in o)){o[x[0]]={}}o=o[x[0]]}else{if(useIndex){o[x[0]]=i}else{o[x[0]]=uniforms[i].type}}}}return obj}},{}],145:[function(require,module,exports){"use strict";exports.uniforms=runtimeUniforms;exports.attributes=runtimeAttributes;var GL_TO_GLSL_TYPES={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"};var GL_TABLE=null;function getType(gl,type){if(!GL_TABLE){var typeNames=Object.keys(GL_TO_GLSL_TYPES);GL_TABLE={};for(var i=0;i<typeNames.length;++i){var tn=typeNames[i];GL_TABLE[gl[tn]]=GL_TO_GLSL_TYPES[tn]}}return GL_TABLE[type]}function runtimeUniforms(gl,program){var numUniforms=gl.getProgramParameter(program,gl.ACTIVE_UNIFORMS);var result=[];for(var i=0;i<numUniforms;++i){var info=gl.getActiveUniform(program,i); | |
if(info){result.push({name:info.name,type:getType(gl,info.type)})}}return result}function runtimeAttributes(gl,program){var numAttributes=gl.getProgramParameter(program,gl.ACTIVE_ATTRIBUTES);var result=[];for(var i=0;i<numAttributes;++i){var info=gl.getActiveAttrib(program,i);if(info){result.push({name:info.name,type:getType(gl,info.type)})}}return result}},{}],146:[function(require,module,exports){"use strict";exports.shader=getShaderReference;exports.program=createProgram;var weakMap=typeof WeakMap==="undefined"?require("weakmap-shim"):WeakMap;var CACHE=new weakMap;var SHADER_COUNTER=0;function ShaderReference(id,src,type,shader,programs,count,cache){this.id=id;this.src=src;this.type=type;this.shader=shader;this.count=count;this.programs=[];this.cache=cache}ShaderReference.prototype.dispose=function(){if(--this.count===0){var cache=this.cache;var gl=cache.gl;var programs=this.programs;for(var i=0,n=programs.length;i<n;++i){var p=cache.programs[programs[i]];if(p){delete cache.programs[i];gl.deleteProgram(p)}}gl.deleteShader(this.shader);delete cache.shaders[this.type===gl.FRAGMENT_SHADER|0][this.src]}};function ContextCache(gl){this.gl=gl;this.shaders=[{},{}];this.programs={}}var proto=ContextCache.prototype;function compileShader(gl,type,src){var shader=gl.createShader(type);gl.shaderSource(shader,src);gl.compileShader(shader);if(!gl.getShaderParameter(shader,gl.COMPILE_STATUS)){var errLog=gl.getShaderInfoLog(shader);console.error("gl-shader: Error compiling shader:",errLog);throw new Error("gl-shader: Error compiling shader:"+errLog)}return shader}proto.getShaderReference=function(type,src){var gl=this.gl;var shaders=this.shaders[type===gl.FRAGMENT_SHADER|0];var shader=shaders[src];if(!shader){var shaderObj=compileShader(gl,type,src);shader=shaders[src]=new ShaderReference(SHADER_COUNTER++,src,type,shaderObj,[],1,this)}else{shader.count+=1}return shader};function linkProgram(gl,vshader,fshader,attribs,locations){var program=gl.createProgram();gl.attachShader(program,vshader);gl.attachShader(program,fshader);for(var i=0;i<attribs.length;++i){gl.bindAttribLocation(program,locations[i],attribs[i])}gl.linkProgram(program);if(!gl.getProgramParameter(program,gl.LINK_STATUS)){var errLog=gl.getProgramInfoLog(program);console.error("gl-shader: Error linking program:",errLog);throw new Error("gl-shader: Error linking program:"+errLog)}return program}proto.getProgram=function(vref,fref,attribs,locations){var token=[vref.id,fref.id,attribs.join(":"),locations.join(":")].join("@");var prog=this.programs[token];if(!prog){this.programs[token]=prog=linkProgram(this.gl,vref.shader,fref.shader,attribs,locations);vref.programs.push(token);fref.programs.push(token)}return prog};function getCache(gl){var ctxCache=CACHE.get(gl);if(!ctxCache){ctxCache=new ContextCache(gl);CACHE.set(gl,ctxCache)}return ctxCache}function getShaderReference(gl,type,src){return getCache(gl).getShaderReference(type,src)}function createProgram(gl,vref,fref,attribs,locations){return getCache(gl).getProgram(vref,fref,attribs,locations)}},{"weakmap-shim":149}],147:[function(require,module,exports){var hiddenStore=require("./hidden-store.js");module.exports=createStore;function createStore(){var key={};return function(obj){if((typeof obj!=="object"||obj===null)&&typeof obj!=="function"){throw new Error("Weakmap-shim: Key must be object")}var store=obj.valueOf(key);return store&&store.identity===key?store:hiddenStore(obj,key)}}},{"./hidden-store.js":148}],148:[function(require,module,exports){module.exports=hiddenStore;function hiddenStore(obj,key){var store={identity:key};var valueOf=obj.valueOf;Object.defineProperty(obj,"valueOf",{value:function(value){return value!==key?valueOf.apply(this,arguments):store},writable:true});return store}},{}],149:[function(require,module,exports){var createStore=require("./create-store.js");module.exports=weakMap;function weakMap(){var privates=createStore();return{get:function(key,fallback){var store=privates(key);return store.hasOwnProperty("value")?store.value:fallback},set:function(key,value){privates(key).value=value},has:function(key){return"value"in privates(key)},"delete":function(key){return delete privates(key).value}}}},{"./create-store.js":147}],150:[function(require,module,exports){arguments[4][7][0].apply(exports,arguments)},{dup:7,ndarray:178,"ndarray-ops":151,"typedarray-pool":158,webglew:160}],151:[function(require,module,exports){arguments[4][8][0].apply(exports,arguments)},{"cwise-compiler":152,dup:8}],152:[function(require,module,exports){arguments[4][9][0].apply(exports,arguments)},{"./lib/thunk.js":154,dup:9}],153:[function(require,module,exports){arguments[4][10][0].apply(exports,arguments)},{dup:10,uniq:155}],154:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{"./compile.js":153,dup:11}],155:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments)},{dup:12}],156:[function(require,module,exports){arguments[4][13][0].apply(exports,arguments)},{dup:13}],157:[function(require,module,exports){arguments[4][14][0].apply(exports,arguments)},{dup:14}],158:[function(require,module,exports){(function(global,Buffer){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0]),UINT8C:dup([32,0]),BUFFER:dup([32,0])}}var hasUint8C=typeof Uint8ClampedArray!=="undefined";var POOL=global.__TYPEDARRAY_POOL;if(!POOL.UINT8C){POOL.UINT8C=dup([32,0])}if(!POOL.BUFFER){POOL.BUFFER=dup([32,0])}var DATA=POOL.DATA,BUFFER=POOL.BUFFER;exports.free=function free(array){if(Buffer.isBuffer(array)){BUFFER[bits.log2(array.length)].push(array)}else{if(Object.prototype.toString.call(array)!=="[object ArrayBuffer]"){array=array.buffer}if(!array){return}var n=array.length||array.byteLength;var log_n=bits.log2(n)|0;DATA[log_n].push(array)}};function freeArrayBuffer(buffer){if(!buffer){return}var n=buffer.length||buffer.byteLength;var log_n=bits.log2(n);DATA[log_n].push(buffer)}function freeTypedArray(array){freeArrayBuffer(array.buffer)}exports.freeUint8=exports.freeUint16=exports.freeUint32=exports.freeInt8=exports.freeInt16=exports.freeInt32=exports.freeFloat32=exports.freeFloat=exports.freeFloat64=exports.freeDouble=exports.freeUint8Clamped=exports.freeDataView=freeTypedArray;exports.freeArrayBuffer=freeArrayBuffer;exports.freeBuffer=function freeBuffer(array){BUFFER[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){if(dtype===undefined||dtype==="arraybuffer"){return mallocArrayBuffer(n)}else{switch(dtype){case"uint8":return mallocUint8(n);case"uint16":return mallocUint16(n);case"uint32":return mallocUint32(n);case"int8":return mallocInt8(n);case"int16":return mallocInt16(n);case"int32":return mallocInt32(n);case"float":case"float32":return mallocFloat(n);case"double":case"float64":return mallocDouble(n);case"uint8_clamped":return mallocUint8Clamped(n);case"buffer":return mallocBuffer(n);case"data":case"dataview":return mallocDataView(n);default:return null}}return null};function mallocArrayBuffer(n){var n=bits.nextPow2(n);var log_n=bits.log2(n);var d=DATA[log_n];if(d.length>0){return d.pop()}return new ArrayBuffer(n)}exports.mallocArrayBuffer=mallocArrayBuffer;function mallocUint8(n){return new Uint8Array(mallocArrayBuffer(n),0,n)}exports.mallocUint8=mallocUint8;function mallocUint16(n){return new Uint16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocUint16=mallocUint16;function mallocUint32(n){return new Uint32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocUint32=mallocUint32;function mallocInt8(n){return new Int8Array(mallocArrayBuffer(n),0,n)}exports.mallocInt8=mallocInt8;function mallocInt16(n){return new Int16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocInt16=mallocInt16;function mallocInt32(n){return new Int32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocInt32=mallocInt32;function mallocFloat(n){return new Float32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocFloat32=exports.mallocFloat=mallocFloat;function mallocDouble(n){return new Float64Array(mallocArrayBuffer(8*n),0,n)}exports.mallocFloat64=exports.mallocDouble=mallocDouble;function mallocUint8Clamped(n){if(hasUint8C){return new Uint8ClampedArray(mallocArrayBuffer(n),0,n)}else{return mallocUint8(n)}}exports.mallocUint8Clamped=mallocUint8Clamped;function mallocDataView(n){return new DataView(mallocArrayBuffer(n),0,n)}exports.mallocDataView=mallocDataView;function mallocBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=BUFFER[log_n];if(cache.length>0){return cache.pop()}return new Buffer(n)}exports.mallocBuffer=mallocBuffer;exports.clearCache=function clearCache(){for(var i=0;i<32;++i){POOL.UINT8[i].length=0;POOL.UINT16[i].length=0;POOL.UINT32[i].length=0;POOL.INT8[i].length=0;POOL.INT16[i].length=0;POOL.INT32[i].length=0;POOL.FLOAT[i].length=0;POOL.DOUBLE[i].length=0;POOL.UINT8C[i].length=0;DATA[i].length=0;BUFFER[i].length=0}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"bit-twiddle":156,buffer:1,dup:157}],159:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{dup:16}],160:[function(require,module,exports){arguments[4][17][0].apply(exports,arguments)},{dup:17,"weak-map":159}],161:[function(require,module,exports){arguments[4][18][0].apply(exports,arguments)},{dup:18}],162:[function(require,module,exports){arguments[4][19][0].apply(exports,arguments)},{"./do-bind.js":161,dup:19}],163:[function(require,module,exports){arguments[4][20][0].apply(exports,arguments)},{"./do-bind.js":161,dup:20}],164:[function(require,module,exports){arguments[4][16][0].apply(exports,arguments)},{dup:16}],165:[function(require,module,exports){arguments[4][17][0].apply(exports,arguments)},{dup:17,"weak-map":164}],166:[function(require,module,exports){arguments[4][23][0].apply(exports,arguments)},{"./lib/vao-emulated.js":162,"./lib/vao-native.js":163,dup:23,webglew:165}],167:[function(require,module,exports){"use strict";var createBuffer=require("gl-buffer");var createVAO=require("gl-vao");var glslify=require("glslify");module.exports=createSpikes;var createShader=require("glslify/adapter.js")("\n#define GLSLIFY 1\n\nprecision mediump float;\nattribute vec3 position, color;\nuniform mat4 model, view, projection;\nuniform vec3 coordinates[3];\nuniform vec4 colors[3];\nvarying vec4 fragColor;\nvoid main() {\n vec3 vertexPosition = mix(coordinates[0], mix(coordinates[2], coordinates[1], 0.5 * (position + 1.0)), abs(position));\n vec4 worldCoordinate = model * vec4(vertexPosition, 1.0);\n vec4 viewCoordinate = view * worldCoordinate;\n vec4 clipCoordinate = projection * viewCoordinate;\n gl_Position = clipCoordinate;\n fragColor = color.x * colors[0] + color.y * colors[1] + color.z * colors[2];\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nvarying vec4 fragColor;\nvoid main() {\n gl_FragColor = fragColor;\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"coordinates[0]",type:"vec3"},{name:"coordinates[1]",type:"vec3"},{name:"coordinates[2]",type:"vec3"},{name:"colors[0]",type:"vec4"},{name:"colors[1]",type:"vec4"},{name:"colors[2]",type:"vec4"}],[{name:"position",type:"vec3"},{name:"color",type:"vec3"}]);var identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function AxisSpikes(gl,buffer,vao,shader){this.gl=gl;this.buffer=buffer;this.vao=vao;this.shader=shader;this.bounds=[[-1e3,-1e3,-1e3],[1e3,1e3,1e3]];this.position=[0,0,0];this.lineWidth=[2,2,2];this.colors=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.enabled=[true,true,true];this.drawSides=[true,true,true];this.axes=null}var proto=AxisSpikes.prototype;var OUTER_FACE=[0,0,0];var INNER_FACE=[0,0,0];proto.isTransparent=function(){return false};proto.drawTransparent=function(camera){};proto.draw=function(camera){var gl=this.gl;var vao=this.vao;var shader=this.shader;vao.bind();shader.bind();var model=camera.model||identity;var view=camera.view||identity;var projection=camera.projection||identity;var axis;if(this.axes){axis=this.axes.lastCubeProps.axis}var outerFace=OUTER_FACE;var innerFace=INNER_FACE;for(var i=0;i<3;++i){if(axis&&axis[i]<0){outerFace[i]=this.bounds[0][i];innerFace[i]=this.bounds[1][i]}else{outerFace[i]=this.bounds[1][i];innerFace[i]=this.bounds[0][i]}}shader.uniforms.model=model;shader.uniforms.view=view;shader.uniforms.projection=projection;shader.uniforms.coordinates=[this.position,outerFace,innerFace];shader.uniforms.colors=this.colors;for(var i=0;i<3;++i){gl.lineWidth(this.lineWidth[i]);if(this.enabled[i]){vao.draw(gl.LINES,2,2*i);if(this.drawSides[i]){vao.draw(gl.LINES,4,6+4*i)}}}vao.unbind()};proto.update=function(options){if(!options){return}if("bounds"in options){this.bounds=options.bounds}if("position"in options){this.position=options.position}if("lineWidth"in options){this.lineWidth=options.lineWidth}if("colors"in options){this.colors=options.colors}if("enabled"in options){this.enabled=options.enabled}if("drawSides"in options){this.drawSides=options.drawSides}};proto.dispose=function(){this.vao.dispose();this.buffer.dispose();this.shader.dispose()};function createSpikes(gl,options){var data=[0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,1,0,0,0,0,0,0,1,0,0,1,0,0,1,1,-1,0,1,0,0,1,1,0,1,0,0,1,0,-1,1,0,0,1,0,1,1,0,0,-1,1,0,0,1,0,1,1,0,0,1,0,0,1,-1,0,1,0,0,1,1,0,1,0,-1,0,1,0,0,1,1,0,1,0,0,1,0,-1,1,0,0,1,0,1,1,0,0,1];var buffer=createBuffer(gl,data);var vao=createVAO(gl,[{type:gl.FLOAT,buffer:buffer,size:3,offset:0,stride:24},{type:gl.FLOAT,buffer:buffer,size:3,offset:12,stride:24}]);var shader=createShader(gl);shader.attributes.position.location=0;shader.attributes.color.location=1;var spikes=new AxisSpikes(gl,buffer,vao,shader);spikes.update(options);return spikes}},{"gl-buffer":150,"gl-vao":166,glslify:169,"glslify/adapter.js":168}],168:[function(require,module,exports){module.exports=programify;var shader=require("gl-shader-core");function programify(vertex,fragment,uniforms,attributes){return function(gl){return shader(gl,vertex,fragment,uniforms,attributes)}}},{"gl-shader-core":174}],169:[function(require,module,exports){module.exports=noop;function noop(){throw new Error("You should bundle your code "+"using `glslify` as a transform.")}},{}],170:[function(require,module,exports){"use strict";module.exports=createAttributeWrapper;function ShaderAttribute(gl,program,location,dimension,name,constFunc,relink){this._gl=gl;this._program=program;this._location=location;this._dimension=dimension;this._name=name;this._constFunc=constFunc;this._relink=relink}var proto=ShaderAttribute.prototype;proto.pointer=function setAttribPointer(type,normalized,stride,offset){var gl=this._gl;gl.vertexAttribPointer(this._location,this._dimension,type||gl.FLOAT,!!normalized,stride||0,offset||0);this._gl.enableVertexAttribArray(this._location)};Object.defineProperty(proto,"location",{get:function(){return this._location},set:function(v){if(v!==this._location){this._location=v;this._gl.bindAttribLocation(this._program,v,this._name);this._gl.linkProgram(this._program);this._relink()}}});function addVectorAttribute(gl,program,location,dimension,obj,name,doLink){var constFuncArgs=["gl","v"];var varNames=[];for(var i=0;i<dimension;++i){constFuncArgs.push("x"+i);varNames.push("x"+i)}constFuncArgs.push(["if(x0.length===void 0){return gl.vertexAttrib",dimension,"f(v,",varNames.join(),")}else{return gl.vertexAttrib",dimension,"fv(v,x0)}"].join(""));var constFunc=Function.apply(undefined,constFuncArgs);var attr=new ShaderAttribute(gl,program,location,dimension,name,constFunc,doLink);Object.defineProperty(obj,name,{set:function(x){gl.disableVertexAttribArray(attr._location);constFunc(gl,attr._location,x);return x},get:function(){return attr},enumerable:true})}function createAttributeWrapper(gl,program,attributes,doLink){var obj={};for(var i=0,n=attributes.length;i<n;++i){var a=attributes[i];var name=a.name;var type=a.type;var location=gl.getAttribLocation(program,name);switch(type){case"bool":case"int":case"float":addVectorAttribute(gl,program,location,1,obj,name,doLink);break;default:if(type.indexOf("vec")>=0){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type for attribute "+name+": "+type)}addVectorAttribute(gl,program,location,d,obj,name,doLink)}else{throw new Error("gl-shader: Unknown data type for attribute "+name+": "+type)}break}}return obj}},{}],171:[function(require,module,exports){"use strict";var dup=require("dup");var coallesceUniforms=require("./reflect");module.exports=createUniformWrapper;function identity(x){var c=new Function("y","return function(){return y}");return c(x)}function createUniformWrapper(gl,program,uniforms,locations){function makeGetter(index){var proc=new Function("gl","prog","locations","return function(){return gl.getUniform(prog,locations["+index+"])}");return proc(gl,program,locations)}function makePropSetter(path,index,type){switch(type){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+index+"],obj"+path+")";case"float":return"gl.uniform1f(locations["+index+"],obj"+path+")";default:var vidx=type.indexOf("vec");if(0<=vidx&&vidx<=1&&type.length===4+vidx){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type")}switch(type.charAt(0)){case"b":case"i":return"gl.uniform"+d+"iv(locations["+index+"],obj"+path+")";case"v":return"gl.uniform"+d+"fv(locations["+index+"],obj"+path+")";default:throw new Error("gl-shader: Unrecognized data type for vector "+name+": "+type)}}else if(type.indexOf("mat")===0&&type.length===4){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+type)}return"gl.uniformMatrix"+d+"fv(locations["+index+"],false,obj"+path+")"}else{throw new Error("gl-shader: Unknown uniform data type for "+name+": "+type)}break}}function enumerateIndices(prefix,type){if(typeof type!=="object"){return[[prefix,type]]}var indices=[];for(var id in type){var prop=type[id];var tprefix=prefix;if(parseInt(id)+""===id){tprefix+="["+id+"]"}else{tprefix+="."+id}if(typeof prop==="object"){indices.push.apply(indices,enumerateIndices(tprefix,prop))}else{indices.push([tprefix,prop])}}return indices}function makeSetter(type){var code=["return function updateProperty(obj){"];var indices=enumerateIndices("",type);for(var i=0;i<indices.length;++i){var item=indices[i];var path=item[0];var idx=item[1];if(locations[idx]){code.push(makePropSetter(path,idx,uniforms[idx].type))}}code.push("return obj}");var proc=new Function("gl","prog","locations",code.join("\n"));return proc(gl,program,locations)}function defaultValue(type){switch(type){case"bool":return false;case"int":case"sampler2D":case"samplerCube":return 0;case"float":return 0;default:var vidx=type.indexOf("vec");if(0<=vidx&&vidx<=1&&type.length===4+vidx){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type")}if(type.charAt(0)==="b"){return dup(d,false)}return dup(d)}else if(type.indexOf("mat")===0&&type.length===4){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+type)}return dup([d,d])}else{throw new Error("gl-shader: Unknown uniform data type for "+name+": "+type)}break}}function storeProperty(obj,prop,type){if(typeof type==="object"){var child=processObject(type);Object.defineProperty(obj,prop,{get:identity(child),set:makeSetter(type),enumerable:true,configurable:false})}else{if(locations[type]){Object.defineProperty(obj,prop,{get:makeGetter(type),set:makeSetter(type),enumerable:true,configurable:false})}else{obj[prop]=defaultValue(uniforms[type].type)}}}function processObject(obj){var result;if(Array.isArray(obj)){result=new Array(obj.length);for(var i=0;i<obj.length;++i){storeProperty(result,i,obj[i])}}else{result={};for(var id in obj){storeProperty(result,id,obj[id])}}return result}var coallesced=coallesceUniforms(uniforms,true);return{get:identity(processObject(coallesced)),set:makeSetter(coallesced),enumerable:true,configurable:true}}},{"./reflect":172,dup:173}],172:[function(require,module,exports){arguments[4][144][0].apply(exports,arguments)},{dup:144}],173:[function(require,module,exports){arguments[4][14][0].apply(exports,arguments)},{dup:14}],174:[function(require,module,exports){"use strict";var createUniformWrapper=require("./lib/create-uniforms");var createAttributeWrapper=require("./lib/create-attributes");var makeReflect=require("./lib/reflect");function Shader(gl,prog,vertShader,fragShader){this.gl=gl;this.handle=prog;this.attributes=null;this.uniforms=null;this.types=null;this.vertexShader=vertShader;this.fragmentShader=fragShader}Shader.prototype.bind=function(){this.gl.useProgram(this.handle)};Shader.prototype.dispose=function(){var gl=this.gl;gl.deleteShader(this.vertexShader);gl.deleteShader(this.fragmentShader);gl.deleteProgram(this.handle)};Shader.prototype.updateExports=function(uniforms,attributes){var locations=new Array(uniforms.length);var program=this.handle;var gl=this.gl;var doLink=relinkUniforms.bind(void 0,gl,program,locations,uniforms);doLink();this.types={uniforms:makeReflect(uniforms),attributes:makeReflect(attributes)};this.attributes=createAttributeWrapper(gl,program,attributes,doLink);Object.defineProperty(this,"uniforms",createUniformWrapper(gl,program,uniforms,locations))};function relinkUniforms(gl,program,locations,uniforms){for(var i=0;i<uniforms.length;++i){locations[i]=gl.getUniformLocation(program,uniforms[i].name)}}function createShader(gl,vertSource,fragSource,uniforms,attributes){var vertShader=gl.createShader(gl.VERTEX_SHADER);gl.shaderSource(vertShader,vertSource);gl.compileShader(vertShader);if(!gl.getShaderParameter(vertShader,gl.COMPILE_STATUS)){var errLog=gl.getShaderInfoLog(vertShader);console.error("gl-shader: Error compling vertex shader:",errLog);throw new Error("gl-shader: Error compiling vertex shader:"+errLog)}var fragShader=gl.createShader(gl.FRAGMENT_SHADER);gl.shaderSource(fragShader,fragSource);gl.compileShader(fragShader);if(!gl.getShaderParameter(fragShader,gl.COMPILE_STATUS)){var errLog=gl.getShaderInfoLog(fragShader);console.error("gl-shader: Error compiling fragment shader:",errLog);throw new Error("gl-shader: Error compiling fragment shader:"+errLog)}var program=gl.createProgram();gl.attachShader(program,fragShader);gl.attachShader(program,vertShader);attributes.forEach(function(a){if(typeof a.location==="number")gl.bindAttribLocation(program,a.location,a.name)});gl.linkProgram(program);if(!gl.getProgramParameter(program,gl.LINK_STATUS)){var errLog=gl.getProgramInfoLog(program);console.error("gl-shader: Error linking shader program:",errLog);throw new Error("gl-shader: Error linking shader program:"+errLog)}var shader=new Shader(gl,program,vertShader,fragShader);shader.updateExports(uniforms,attributes);return shader}module.exports=createShader},{"./lib/create-attributes":170,"./lib/create-uniforms":171,"./lib/reflect":172}],175:[function(require,module,exports){module.exports=programify;function programify(vertex,fragment,uniforms,attributes){return{vertex:vertex,fragment:fragment,uniforms:uniforms,attributes:attributes}}},{}],176:[function(require,module,exports){"use strict";module.exports=mouseListen;var mouse=require("mouse-event");function mouseListen(element,callback){if(!callback){callback=element;element=window}var buttonState=0;var x=0;var y=0;var mods={shift:false,alt:false,control:false,meta:false};function updateMods(ev){var changed=false;if("altKey"in ev){changed=changed||ev.altKey!==mods.alt;mods.alt=!!ev.altKey}if("shiftKey"in ev){changed=changed||ev.shiftKey!==mods.shift;mods.shift=!!ev.shiftKey}if("ctrlKey"in ev){changed=changed||ev.ctrlKey!==mods.control;mods.control=!!ev.ctrlKey}if("metaKey"in ev){changed=changed||ev.metaKey!==mods.meta;mods.meta=!!ev.metaKey}return changed}function handleEvent(nextButtons,ev){var nextX=mouse.x(ev);var nextY=mouse.y(ev);if("buttons"in ev){nextButtons=ev.buttons|0}if(nextButtons!==buttonState||nextX!==x||nextY!==y||updateMods(ev)){buttonState=nextButtons|0;x=nextX||0;y=nextY||0;callback(buttonState,x,y,mods)}}function clearState(ev){handleEvent(0,ev)}function handleBlur(){if(buttonState||x||y||mods.shift||mods.alt||mods.meta||mods.control){x=y=0;buttonState=0;mods.shift=mods.alt=mods.control=mods.meta=false;callback(0,0,0,mods)}}function handleMods(ev){if(updateMods(ev)){callback(buttonState,x,y,mods)}}element.addEventListener("mousemove",function(ev){if(mouse.buttons(ev)===0){handleEvent(0,ev)}else{handleEvent(buttonState,ev)}});element.addEventListener("mousedown",function(ev){handleEvent(buttonState|mouse.buttons(ev),ev)});element.addEventListener("mouseup",function(ev){handleEvent(buttonState&~mouse.buttons(ev),ev)});element.addEventListener("mouseleave",clearState);element.addEventListener("mouseenter",clearState);element.addEventListener("mouseout",clearState);element.addEventListener("mouseover",clearState);element.addEventListener("blur",handleBlur);element.addEventListener("keyup",handleMods);element.addEventListener("keydown",handleMods);element.addEventListener("keypress",handleMods);if(element!==window){window.addEventListener("blur",handleBlur);window.addEventListener("keyup",handleMods);window.addEventListener("keydown",handleMods);window.addEventListener("keypress",handleMods)}}},{"mouse-event":177}],177:[function(require,module,exports){"use strict";function mouseButtons(ev){if(typeof ev==="object"){if("buttons"in ev){return ev.buttons}else if("which"in ev){var b=ev.which;if(b===2){return 4}else if(b===3){return 2}else if(b>0){return 1<<b-1}}else if("button"in ev){var b=ev.button;if(b===1){return 4}else if(b===2){return 2}else if(b>=0){return 1<<b}}}return 0}exports.buttons=mouseButtons;function mouseElement(ev){return ev.target||ev.srcElement||window}exports.element=mouseElement;function mouseRelativeX(ev){if(typeof ev==="object"){if("offsetX"in ev){return ev.offsetX}var target=mouseElement(ev);if("clientX"in ev){return ev.clientX-target.clientLeft}if("pageX"in ev){return ev.pageX-target.offsetLeft}}return 0}exports.x=mouseRelativeX;function mouseRelativeY(ev){if(typeof ev==="object"){if("offsetY"in ev){return ev.offsetY}var target=mouseElement(ev);if("clientY"in ev){return ev.clientY-target.clientTop}if("pageX"in ev){return ev.pageY-target.offsetTop}}return 0}exports.y=mouseRelativeY},{}],178:[function(require,module,exports){(function(Buffer){var iota=require("iota-array");var hasTypedArrays=typeof Float64Array!=="undefined";var hasBuffer=typeof Buffer!=="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){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){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'"];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);code.push("Object.defineProperty(proto,'size',{get:function "+className+"_size(){return "+indices.map(function(i){return"this.shape["+i+"]"}).join("*"),"}})");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})")}}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}")}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+"]}")}code.push("proto.index=function "+className+"_index(",args.join(),"){return "+index_str+"}");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)}");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)}");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)}");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)}");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)}");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)}");var procedure=new Function("CTOR_LIST","ORDER",code.join("\n"));return procedure(CACHED_CONSTRUCTORS[dtype],order)}function arrayDType(data){if(hasBuffer){if(Buffer.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}).call(this,require("buffer").Buffer)},{buffer:1,"iota-array":179}],179:[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},{}],180:[function(require,module,exports){module.exports=function parseUnit(str,out){if(!out)out=[0,""];str=String(str);var num=parseFloat(str,10);out[0]=num;out[1]=str.match(/[\d.\-\+]*\s*(.*)/)[1]||"";return out}},{}],181:[function(require,module,exports){"use strict";var parseUnit=require("parse-unit");module.exports=toPX;var PIXELS_PER_INCH=96;function getPropertyInPX(element,prop){var parts=parseUnit(getComputedStyle(element).getPropertyValue(prop));return parts[0]*toPX(parts[1],element)}function getSizeBrutal(unit,element){var testDIV=document.createElement("div");testDIV.style["font-size"]="128"+unit;element.appendChild(testDIV);var size=getPropertyInPX(testDIV,"font-size")/128;element.removeChild(testDIV);return size}function toPX(str,element){element=element||document.body;str=(str||"px").trim().toLowerCase();if(element===window||element===document){element=document.body}switch(str){case"%":return element.clientHeight/100;case"ch":case"ex":return getSizeBrutal(str,element);case"em":return getPropertyInPX(element,"font-size");case"rem":return getPropertyInPX(document.body,"font-size");case"vw":return window.innerWidth/100;case"vh":return window.innerHeight/100;case"vmin":return Math.min(window.innerWidth,window.innerHeight)/100;case"vmax":return Math.max(window.innerWidth,window.innerHeight)/100;case"in":return PIXELS_PER_INCH;case"cm":return PIXELS_PER_INCH/2.54;case"mm":return PIXELS_PER_INCH/25.4;case"pt":return PIXELS_PER_INCH/72;case"pc":return PIXELS_PER_INCH/6}return 1}},{"parse-unit":180}],182:[function(require,module,exports){"use strict";var toPX=require("to-px");module.exports=mouseWheelListen;function mouseWheelListen(element,callback,noScroll){if(typeof element==="function"){noScroll=!!callback;callback=element;element=window}var lineHeight=toPX("ex",element);element.addEventListener("wheel",function(ev){if(noScroll){ev.preventDefault()}var dx=ev.deltaX||0;var dy=ev.deltaY||0;var dz=ev.deltaZ||0;var mode=ev.deltaMode;var scale=1;switch(mode){case 1:scale=lineHeight;break;case 2:scale=window.innerHeight;break}dx*=scale;dy*=scale;dz*=scale;if(dx||dy||dz){return callback(dx,dy,dz)}})}},{"to-px":181}],183:[function(require,module,exports){"use strict";module.exports=quatFromFrame;function quatFromFrame(out,rx,ry,rz,ux,uy,uz,fx,fy,fz){var tr=rx+uy+fz;if(l>0){var l=Math.sqrt(tr+1);out[0]=.5*(uz-fy)/l;out[1]=.5*(fx-rz)/l;out[2]=.5*(ry-uy)/l;out[3]=.5*l}else{var tf=Math.max(rx,uy,fz);var l=Math.sqrt(2*tf-tr+1);if(rx>=tf){out[0]=.5*l;out[1]=.5*(ux+ry)/l;out[2]=.5*(fx+rz)/l;out[3]=.5*(uz-fy)/l}else if(uy>=tf){out[0]=.5*(ry+ux)/l;out[1]=.5*l;out[2]=.5*(fy+uz)/l;out[3]=.5*(fx-rz)/l}else{out[0]=.5*(rz+fx)/l;out[1]=.5*(uz+fy)/l;out[2]=.5*l;out[3]=.5*(ry-ux)/l}}return out}},{}],184:[function(require,module,exports){"use strict";module.exports=createFilteredVector;var cubicHermite=require("cubic-hermite");var bsearch=require("binary-search-bounds");function clamp(lo,hi,x){return Math.min(hi,Math.max(lo,x))}function FilteredVector(state0,velocity0,t0){this.dimension=state0.length;this.bounds=[new Array(this.dimension),new Array(this.dimension)];for(var i=0;i<this.dimension;++i){this.bounds[0][i]=-Infinity;this.bounds[1][i]=Infinity}this._state=state0.slice().reverse();this._velocity=velocity0.slice().reverse();this._time=[t0];this._scratch=[state0.slice(),state0.slice(),state0.slice(),state0.slice(),state0.slice()]}var proto=FilteredVector.prototype;proto.flush=function(t){var idx=bsearch.gt(this._time,t)-1;if(idx<=0){return}this._time.splice(0,idx);this._state.splice(0,idx*this.dimension);this._velocity.splice(0,idx*this.dimension)};proto.curve=function(t){var time=this._time;var n=time.length;var idx=bsearch.le(time,t);var result=this._scratch[0];var state=this._state;var velocity=this._velocity;var d=this.dimension;var bounds=this.bounds;if(idx>=n-1){var ptr=state.length-1;var tf=t-time[n-1];for(var i=0;i<d;++i,--ptr){result[i]=state[ptr]+tf*velocity[ptr]}}else{var ptr=d*(idx+1)-1;var t0=time[idx];var t1=time[idx+1];var dt=t1-t0||1;var x0=this._scratch[1];var x1=this._scratch[2];var v0=this._scratch[3];var v1=this._scratch[4];var steady=true;for(var i=0;i<d;++i,--ptr){x0[i]=state[ptr];v0[i]=velocity[ptr]*dt;x1[i]=state[ptr+d];v1[i]=velocity[ptr+d]*dt;steady=steady&&(x0[i]===x1[i]&&v0[i]===v1[i]&&v0[i]===0)}if(steady){for(var i=0;i<d;++i){result[i]=x0[i]}}else{cubicHermite(x0,v0,x1,v1,(t-t0)/dt,result)}}var lo=bounds[0];var hi=bounds[1];for(var i=0;i<d;++i){result[i]=clamp(lo[i],hi[i],result[i])}return result};proto.dcurve=function(t){var time=this._time;var n=time.length;var idx=bsearch.le(time,t);var result=this._scratch[0];var state=this._state;var velocity=this._velocity;var d=this.dimension;if(idx>=n-1){var ptr=state.length-1;var tf=t-time[n-1];for(var i=0;i<d;++i,--ptr){result[i]=velocity[ptr]}}else{var ptr=d*(idx+1)-1;var t0=time[idx];var t1=time[idx+1];var dt=t1-t0||1;var x0=this._scratch[1];var x1=this._scratch[2];var v0=this._scratch[3];var v1=this._scratch[4];var steady=true;for(var i=0;i<d;++i,--ptr){x0[i]=state[ptr];v0[i]=velocity[ptr]*dt;x1[i]=state[ptr+d];v1[i]=velocity[ptr+d]*dt;steady=steady&&(x0[i]===x1[i]&&v0[i]===v1[i]&&v0[i]===0)}if(steady){for(var i=0;i<d;++i){result[i]=0}}else{cubicHermite.derivative(x0,v0,x1,v1,(t-t0)/dt,result);for(var i=0;i<d;++i){result[i]/=dt}}}return result};proto.lastT=function(){var time=this._time;return time[time.length-1]};proto.stable=function(){var velocity=this._velocity;var ptr=velocity.length;for(var i=this.dimension-1;i>=0;--i){if(velocity[--ptr]){return false}}return true};proto.jump=function(t){var t0=this.lastT();var d=this.dimension;if(t<t0||arguments.length!==d+1){return}var state=this._state;var velocity=this._velocity;var ptr=state.length-this.dimension;var bounds=this.bounds;var lo=bounds[0];var hi=bounds[1];this._time.push(t0,t);for(var j=0;j<2;++j){for(var i=0;i<d;++i){state.push(state[ptr++]);velocity.push(0)}}this._time.push(t);for(var i=d;i>0;--i){state.push(clamp(lo[i-1],hi[i-1],arguments[i]));velocity.push(0)}};proto.push=function(t){var t0=this.lastT();var d=this.dimension;if(t<t0||arguments.length!==d+1){return}var state=this._state;var velocity=this._velocity;var ptr=state.length-this.dimension;var dt=t-t0;var bounds=this.bounds;var lo=bounds[0];var hi=bounds[1];var sf=dt>1e-6?1/dt:0;this._time.push(t);for(var i=d;i>0;--i){var xc=clamp(lo[i-1],hi[i-1],arguments[i]);state.push(xc);velocity.push((xc-state[ptr++])*sf)}};proto.set=function(t){var d=this.dimension;if(t<this.lastT()||arguments.length!==d+1){return}var state=this._state;var velocity=this._velocity;var bounds=this.bounds;var lo=bounds[0];var hi=bounds[1];this._time.push(t);for(var i=d;i>0;--i){state.push(clamp(lo[i-1],hi[i-1],arguments[i]));velocity.push(0)}};proto.move=function(t){var t0=this.lastT();var d=this.dimension;if(t<=t0||arguments.length!==d+1){return}var state=this._state;var velocity=this._velocity;var statePtr=state.length-this.dimension;var bounds=this.bounds;var lo=bounds[0];var hi=bounds[1];var dt=t-t0;var sf=dt>1e-6?1/dt:0;this._time.push(t);for(var i=d;i>0;--i){var dx=arguments[i];state.push(clamp(lo[i-1],hi[i-1],state[statePtr++]+dx));velocity.push(dx*sf)}};proto.idle=function(t){var t0=this.lastT();if(t<t0){return}var d=this.dimension;var state=this._state;var velocity=this._velocity;var statePtr=state.length-d;var bounds=this.bounds;var lo=bounds[0];var hi=bounds[1];var dt=t-t0;this._time.push(t);for(var i=d-1;i>=0;--i){state.push(clamp(lo[i],hi[i],state[statePtr]+dt*velocity[statePtr]));velocity.push(0);statePtr+=1}};function getZero(d){var result=new Array(d);for(var i=0;i<d;++i){result[i]=0}return result}function createFilteredVector(initState,initVelocity,initTime){switch(arguments.length){case 0:return new FilteredVector([0],[0],0);case 1:if(typeof initState==="number"){var zero=getZero(initState);return new FilteredVector(zero,zero,0)}else{return new FilteredVector(initState,getZero(initState.length),0)}case 2:if(typeof initVelocity==="number"){var zero=getZero(initState.length);return new FilteredVector(initState,zero,+initVelocity)}else{initTime=0}case 3:if(initState.length!==initVelocity.length){throw new Error("state and velocity lengths must match")}return new FilteredVector(initState,initVelocity,initTime)}}},{"binary-search-bounds":185,"cubic-hermite":186}],185:[function(require,module,exports){arguments[4][72][0].apply(exports,arguments)},{dup:72}],186:[function(require,module,exports){"use strict";function dcubicHermite(p0,v0,p1,v1,t,f){var dh00=6*t*t-6*t,dh10=3*t*t-4*t+1,dh01=-6*t*t+6*t,dh11=3*t*t-2*t;if(p0.length){if(!f){f=new Array(p0.length)}for(var i=p0.length-1;i>=0;--i){f[i]=dh00*p0[i]+dh10*v0[i]+dh01*p1[i]+dh11*v1[i]}return f}return dh00*p0+dh10*v0+dh01*p1[i]+dh11*v1}function cubicHermite(p0,v0,p1,v1,t,f){var ti=t-1,t2=t*t,ti2=ti*ti,h00=(1+2*t)*ti2,h10=t*ti2,h01=t2*(3-2*t),h11=t2*ti;if(p0.length){if(!f){f=new Array(p0.length)}for(var i=p0.length-1;i>=0;--i){f[i]=h00*p0[i]+h10*v0[i]+h01*p1[i]+h11*v1[i]}return f}return h00*p0+h10*v0+h01*p1+h11*v1}module.exports=cubicHermite;module.exports.derivative=dcubicHermite},{}],187:[function(require,module,exports){"use strict";module.exports=createOrbitController;var filterVector=require("filtered-vector");var lookAt=require("gl-mat4/lookAt");var mat4FromQuat=require("gl-mat4/fromQuat");var invert44=require("gl-mat4/invert");var quatFromFrame=require("./lib/quatFromFrame");function len3(x,y,z){return Math.sqrt(Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2))}function len4(w,x,y,z){return Math.sqrt(Math.pow(w,2)+Math.pow(x,2)+Math.pow(y,2)+Math.pow(z,2))}function normalize4(out,a){var ax=a[0];var ay=a[1];var az=a[2];var aw=a[3];var al=len4(ax,ay,az,aw);if(al>1e-6){out[0]=ax/al;out[1]=ay/al;out[2]=az/al;out[3]=aw/al}else{out[0]=out[1]=out[2]=0;out[3]=1}}function OrbitCameraController(initQuat,initCenter,initRadius){this.radius=filterVector([initRadius]);this.center=filterVector(initCenter);this.rotation=filterVector(initQuat);this.computedRadius=this.radius.curve(0);this.computedCenter=this.center.curve(0);this.computedRotation=this.rotation.curve(0);this.computedUp=[.1,0,0];this.computedEye=[.1,0,0];this.computedMatrix=[.1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];this.recalcMatrix(0)}var proto=OrbitCameraController.prototype;proto.lastT=function(){return Math.max(this.radius.lastT(),this.center.lastT(),this.rotation.lastT())};proto.recalcMatrix=function(t){this.radius.curve(t);this.center.curve(t);this.rotation.curve(t);var quat=this.computedRotation;normalize4(quat,quat);var mat=this.computedMatrix;mat4FromQuat(mat,quat);var center=this.computedCenter;var eye=this.computedEye;var up=this.computedUp;var radius=Math.exp(this.computedRadius[0]);eye[0]=center[0]+radius*mat[2];eye[1]=center[1]+radius*mat[6];eye[2]=center[2]+radius*mat[10];up[0]=mat[1];up[1]=mat[5];up[2]=mat[9];for(var i=0;i<3;++i){var rr=0;for(var j=0;j<3;++j){rr+=mat[i+4*j]*eye[j]}mat[12+i]=-rr}};proto.getMatrix=function(t,result){this.recalcMatrix(t);var m=this.computedMatrix;if(result){for(var i=0;i<16;++i){result[i]=m[i]}return result}return m};proto.idle=function(t){this.center.idle(t);this.radius.idle(t);this.rotation.idle(t)};proto.flush=function(t){this.center.flush(t);this.radius.flush(t);this.rotation.flush(t)};proto.pan=function(t,dx,dy,dz){dx=dx||0;dy=dy||0;dz=dz||0;this.recalcMatrix(t);var mat=this.computedMatrix;var ux=mat[1];var uy=mat[5];var uz=mat[9];var ul=len3(ux,uy,uz);ux/=ul;uy/=ul;uz/=ul;var rx=mat[0];var ry=mat[4];var rz=mat[8];var ru=rx*ux+ry*uy+rz*uz;rx-=ux*ru;ry-=uy*ru;rz-=uz*ru;var rl=len3(rx,ry,rz);rx/=rl;ry/=rl;rz/=rl;var fx=mat[2];var fy=mat[6];var fz=mat[10];var fu=fx*ux+fy*uy+fz*uz;var fr=fx*rx+fy*ry+fz*rz;fx-=fu*ux+fr*rx;fy-=fu*uy+fr*ry;fz-=fu*uz+fr*rz;var fl=len3(fx,fy,fz);fx/=fl;fy/=fl;fz/=fl;var vx=rx*dx+ux*dy;var vy=ry*dx+uy*dy;var vz=rz*dx+uz*dy;this.center.move(t,vx,vy,vz);var radius=Math.exp(this.computedRadius[0]);radius=Math.max(1e-4,radius+dz);this.radius.set(t,Math.log(radius))};proto.rotate=function(t,dx,dy,dz){this.recalcMatrix(t);dx=dx||0;dy=dy||0;var mat=this.computedMatrix;var rx=mat[0];var ry=mat[4];var rz=mat[8];var ux=mat[1];var uy=mat[5];var uz=mat[9];var fx=mat[2];var fy=mat[6];var fz=mat[10];var qx=dx*rx+dy*ux;var qy=dx*ry+dy*uy;var qz=dx*rz+dy*uz;var bx=-(fy*qz-fz*qy);var by=-(fz*qx-fx*qz);var bz=-(fx*qy-fy*qx);var bw=Math.sqrt(Math.max(0,1-Math.pow(bx,2)-Math.pow(by,2)-Math.pow(bz,2)));var bl=len4(bx,by,bz,bw);if(bl>1e-6){bx/=bl;by/=bl;bz/=bl;bw/=bl}else{bx=by=bz=0;bw=1}var rotation=this.computedRotation;var ax=rotation[0];var ay=rotation[1];var az=rotation[2];var aw=rotation[3];var cx=ax*bw+aw*bx+ay*bz-az*by;var cy=ay*bw+aw*by+az*bx-ax*bz;var cz=az*bw+aw*bz+ax*by-ay*bx;var cw=aw*bw-ax*bx-ay*by-az*bz;if(dz){bx=fx;by=fy;bz=fz;var s=Math.sin(dz)/len3(bx,by,bz);bx*=s;by*=s;bz*=s;bw=Math.cos(dx);cx=cx*bw+cw*bx+cy*bz-cz*by;cy=cy*bw+cw*by+cz*bx-cx*bz;cz=cz*bw+cw*bz+cx*by-cy*bx;cw=cw*bw-cx*bx-cy*by-cz*bz}var cl=len4(cx,cy,cz,cw);if(cl>1e-6){cx/=cl;cy/=cl;cz/=cl;cw/=cl}else{cx=cy=cz=0;cw=1}this.rotation.set(t,cx,cy,cz,cw)};proto.lookAt=function(t,eye,center,up){this.recalcMatrix(t);center=center||this.computedCenter;eye=eye||this.computedEye;up=up||this.computedUp;var mat=this.computedMatrix;lookAt(mat,eye,center,up);var rotation=this.computedRotation;quatFromFrame(rotation,mat[0],mat[1],mat[2],mat[4],mat[5],mat[6],mat[8],mat[9],mat[10]);normalize4(rotation,rotation);this.rotation.set(t,rotation[0],rotation[1],rotation[2],rotation[3]);var fl=0;for(var i=0;i<3;++i){fl+=Math.pow(center[i]-eye[i],2)}this.radius.set(t,.5*Math.log(Math.max(fl,1e-6)));this.center.set(t,center[0],center[1],center[2])};proto.translate=function(t,dx,dy,dz){this.center.move(t,dx||0,dy||0,dz||0)};proto.setMatrix=function(t,matrix){this.recalcMatrix(t);var rotation=this.computedRotation;quatFromFrame(rotation,matrix[0],matrix[1],matrix[2],matrix[4],matrix[5],matrix[6],matrix[8],matrix[9],matrix[10]);normalize4(rotation,rotation);this.rotation.set(t,rotation[0],rotation[1],rotation[2],rotation[3]);var mat=this.computedMatrix;invert44(mat,matrix);var w=-mat[15];if(Math.abs(w)>1e-6){var cx=mat[12]/w;var cy=mat[13]/w;var cz=mat[14]/w;var fx=mat[8];var fy=mat[9];var fz=mat[10];var fl=len3(fx,fy,fz);var r=Math.exp(this.computedRadius[0]);cx-=fx*r/fl;cy-=fy*r/fl;cz-=fz*r/fl;this.center.set(t,cx,cy,cz);this.radius.idle(t)}else{this.center.idle(t);this.radius.idle(t)}};proto.setDistance=function(t,d){if(d>0){this.radius.set(t,Math.log(d))}};proto.setDistanceLimits=function(lo,hi){if(lo>0){lo=Math.log(lo)}else{lo=-Infinity}if(hi>0){hi=Math.log(hi)}hi=Math.max(hi,lo);this.radius.bounds[0][0]=lo;this.radius.bounds[1][0]=hi};proto.getDistanceLimits=function(out){var bounds=this.radius.bounds;if(out){out[0]=Math.exp(bounds[0][0]);out[1]=Math.exp(bounds[1][0]);return out}return[Math.exp(bounds[0][0]),Math.exp(bounds[1][0])]};proto.toJSON=function(){this.recalcMatrix(this.lastT());return{center:this.computedCenter.slice(),rotation:this.computedRotation.slice(),distance:Math.log(this.computedRadius[0]),zoomMin:this.radius.bounds[0][0],zoomMax:this.radius.bounds[1][0]}};proto.fromJSON=function(options){var t=this.lastT();var c=options.centers;if(c){this.center.set(t,c[0],c[1],c[2])}var r=options.rotation;if(r){this.rotation.set(t,r[0],r[1],r[2],r[3])}var d=options.distance;if(d&&d>0){this.radius.set(t,Math.log(d))}this.setDistanceLimits(options.zoomMin,options.zoomMax)};function createOrbitController(options){options=options||{};var center=options.center||[0,0,0];var rotation=options.rotation||[0,0,0,1];var radius=options.radius||1;center=[].slice.call(center,0,3);rotation=[].slice.call(rotation,0,4);normalize4(rotation,rotation);var result=new OrbitCameraController(rotation,center,Math.log(radius));result.setDistanceLimits(options.zoomMin,options.zoomMax);if("eye"in options||"up"in options){result.lookAt(0,options.eye,options.center,options.up)}return result}},{"./lib/quatFromFrame":183,"filtered-vector":184,"gl-mat4/fromQuat":126,"gl-mat4/invert":128,"gl-mat4/lookAt":129}],188:[function(require,module,exports){(function(global){module.exports=global.performance&&global.performance.now?function now(){return performance.now()}:Date.now||function now(){return+new Date}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{}],189:[function(require,module,exports){"use strict";module.exports=createOrbiter;var createController=require("orbit-camera-controller");var mouseChange=require("mouse-change");var mouseWheel=require("mouse-wheel");var now=require("right-now");function copyVec(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2]}function Orbiter(element,controller){this.element=element;this.controller=controller;this.matrix=new Array(16);this.rotation=new Array(4);this.up=new Array(3);this.eye=new Array(3);this.center=new Array(3);this.distance=0;this.delay=40;this.inputEnabled=true;this.flipX=false;this.flipY=false;this.translateSpeed=1;this.zoomSpeed=1;this.rotateSpeed=1;this.changed=true}var proto=Orbiter.prototype;proto.toJSON=function(){var t=this.lastT();controller.recalcMatrix(t);return{camera:this.controller.toJSON(),delay:this.delay,flipX:this.flipX,flipY:this.flipY,translateSpeed:this.translateSpeed,zoomSpeed:this.zoomSpeed,rotateSpeed:this.rotateSpeed}};proto.fromJSON=function(options){if("camera"in options){this.controller.fromJSON(options.camera)}var self=this;function handleOption(prop){if(prop in options){self[prop]=options[prop]}}handleOption("delay");handleOption("inputEnabled");handleOption("flipX");handleOption("flipY");handleOption("translateSpeed");handleOption("zoomSpeed");handleOption("rotateSpeed");this.changed=true};proto.tick=function(){var t=now();var delay=this.delay;var controller=this.controller;controller.idle(t-.5*delay);controller.flush(t-1e3*(1+Math.min(delay,0)));controller.recalcMatrix(t-delay);var prevMat=this.matrix;var nextMat=controller.computedMatrix;var changed=this.changed;for(var i=0;i<16;++i){changed=changed||Math.abs(nextMat[i]-prevMat[i])>1e-5;prevMat[i]=nextMat[i]}var prevRot=this.rotation;var nextRot=controller.computedRotation;for(var i=0;i<4;++i){prevRot[i]=nextRot[i]}copyVec(this.eye,controller.computedEye);copyVec(this.up,controller.computedUp);copyVec(this.center,controller.computedCenter);this.distance=Math.exp(controller.computedRadius[0]);this.changed=false;return changed};proto.lookAt=function(eye,center,up){this.controller.lookAt(this.lastT(),eye,center,up)};var scratchEye=[0,0,0];var scratchCenter=[0,0,0];var scratchUp=[0,1,0];proto.box=function(lo,hi){var diam=0;for(var i=0;i<3;++i){eye[i]=center[i]=.5*(lo[i]+hi[i]);diam=Math.max(diam,hi[i]-lo[i])}eye[1]=hi[1]+2*diam;this.controller.lookAt(now(),eye,center,up)};proto.setMatrix=function(mat){this.controller.setMatrix(this.lastT(),mat)};proto.setDistance=function(d){this.controller.setDistance(this.lastT(),d)};proto.setDistanceLimits=function(lo,hi){this.controller.setDistanceLimits(lo,hi)};proto.rotate=function(pitch,yaw,roll){this.controller.rotate(now(),pitch,yaw,roll)};proto.pan=function(dx,dy,dz){this.controller.pan(now(),dx,dy,dz)};proto.translate=function(dx,dy,dz){this.controller.translate(now(),dx,dy,dz)};proto.lastT=function(){return this.controller.lastT()};function createOrbiter(element,options){var controller=createController(options);var orbiter=new Orbiter(element,controller);orbiter.fromJSON(options);orbiter.tick();orbiter.changed=true;var lastX=0,lastY=0;mouseChange(element,function(buttons,x,y,mods){if(!orbiter.inputEnabled){return}var height=element.clientHeight;var width=element.clientWidth;var scale=1/height;var dx=scale*(x-lastX);var dy=scale*(y-lastY);var t=now();var flipX=orbiter.flipX?1:-1;var flipY=orbiter.flipY?1:-1;var vrot=Math.PI*orbiter.rotateSpeed;var vpan=+orbiter.translateSpeed;var vzoom=+orbiter.zoomSpeed;var distance=orbiter.distance;if(buttons&1){if(mods.shift){controller.rotate(t,0,0,-dx*drot)}else{controller.rotate(t,flipX*vrot*dx,-flipY*vrot*dy,0)}}else if(buttons&2){controller.pan(t,-vpan*dx*distance*height/width,vpan*dy*distance,0)}else if(buttons&4){controller.pan(t,0,0,vzoom*dy*distance)}lastX=x;lastY=y});mouseWheel(element,function(dx,dy,dz){if(!orbiter.inputEnabled){return}var t=now();var flipX=orbiter.flipX?1:-1;var vrot=Math.PI*orbiter.rotateSpeed;var vzoom=+orbiter.zoomSpeed;var distance=orbiter.distance;if(Math.abs(dx)>Math.abs(dy)){controller.rotate(t,0,0,-dx*flipX*vrot/window.innerWidth)}else{controller.pan(t,0,0,vzoom*dy/window.innerHeight*distance)}},true);element.addEventListener("contextmenu",function(ev){if(orbiter.inputEnabled){ev.preventDefault();return false}});return orbiter}},{"mouse-change":176,"mouse-wheel":182,"orbit-camera-controller":187,"right-now":188}],"gl-plot3d":[function(require,module,exports){"use strict";module.exports=createScene;var createCamera=require("orbiter");var createAxes=require("gl-axes3d");var axesRanges=require("gl-axes3d/properties");var createSpikes=require("gl-spikes3d");var createSelect=require("gl-select-static");var createFBO=require("gl-fbo");var drawTriangle=require("a-big-triangle");var mouseChange=require("mouse-change");var perspective=require("gl-mat4/perspective");var createShader=require("./lib/shader");function MouseSelect(){this.mouse=[-1,-1];this.screen=null;this.distance=Infinity;this.index=null;this.dataCoordinate=null;this.dataPosition=null;this.object=null;this.data=null}function roundUpPow10(x){var y=Math.round(Math.log(Math.abs(x))/Math.log(10));if(y<0){var base=Math.round(Math.pow(10,-y));return Math.ceil(x*base)/base}else if(y>0){var base=Math.round(Math.pow(10,y));return Math.ceil(x/base)*base}return Math.ceil(x)}function defaultBool(x){if(typeof x==="boolean"){return x}return true}function createScene(options){options=options||{};var stopped=false;var pixelRatio=options.pixelRatio||parseFloat(window.devicePixelRatio);var canvas=options.canvas;if(!canvas){canvas=document.createElement("canvas");if(options.container){canvas.width=container.clientWidth*pixelRatio;canvas.height=container.clientHeight*pixelRatio;options.container.appendChild(canvas)}else{canvas.width=window.innerWidth*pixelRatio;canvas.height=window.innerHeight*pixelRatio;document.body.appendChild(canvas)}}var gl=options.gl;if(!gl){var glOptions=options.glOptions||{premultipliedAlpha:true};gl=canvas.getContext("webgl",glOptions)}if(!gl){throw new Error("webgl not supported")}var bounds=options.bounds||[[-10,-10,-10],[10,10,10]];var selection=new MouseSelect;var accumBuffer=createFBO(gl,[gl.drawingBufferWidth,gl.drawingBufferHeight],{preferFloat:true});var accumShader=createShader(gl);var cameraOptions=options.camera||{eye:[0,0,2],center:[0,0,0],up:[0,1,0],zoomMin:.1,zoomMax:100};var camera=createCamera(canvas,cameraOptions);var axesOptions=options.axes||{};var axes=createAxes(gl,axesOptions);axes.enable=!axesOptions.disable;var spikeOptions=options.spikes||{};var spikes=createSpikes(gl,spikeOptions);var objects=[];var pickBufferIds=[];var pickBufferCount=[];var pickBuffers=[];var dirty=true;var pickDirty=true;var projection=new Array(16);var model=new Array(16);var cameraParams={view:camera.matrix,projection:projection,model:model};var pickDirty=true;var scene={gl:gl,pixelRatio:options.pixelRatio||parseFloat(window.devicePixelRatio),canvas:canvas,selection:selection,camera:camera,axes:axes,axesPixels:null,spikes:spikes,bounds:bounds,objects:objects,pickRadius:options.pickRadius||10,zNear:options.zNear||.01,zFar:options.zFar||1e3,fovy:options.fovy||Math.PI/4,clearColor:options.clearColor||[0,0,0,0],autoResize:defaultBool(options.autoResize),autoBounds:defaultBool(options.autoBounds),autoScale:defaultBool(options.autoScale),autoCenter:defaultBool(options.autoCenter),clipToBounds:defaultBool(options.clipToBounds),snapToData:!!options.snapToData,onselect:options.onselect||null,onrender:options.onrender||null,onclick:options.onclick||null,shape:viewShape,cameraParams:cameraParams};var viewShape=[gl.drawingBufferWidth,gl.drawingBufferHeight];var pickShape=[gl.drawingBufferWidth/scene.pixelRatio|0,gl.drawingBufferHeight/scene.pixelRatio|0];function resizeListener(){if(!scene.autoResize){return}var style=canvas.style;style.position=style.position||"absolute";style.left="0px";style.top="0px";var parent=canvas.parentNode;var width=1;var height=1;if(parent&&parent!==document.body){width=parent.clientWidth;height=parent.clientHeight}else{width=window.innerWidth;height=window.innerHeight}canvas.width=Math.ceil(width*scene.pixelRatio)|0;canvas.height=Math.ceil(height*scene.pixelRatio)|0;style.width=width+"px";style.height=height+"px"}if(scene.autoResize){resizeListener()}window.addEventListener("resize",resizeListener);function reallocPickIds(){var numObjs=objects.length;var numPick=pickBuffers.length;for(var i=0;i<numPick;++i){pickBufferCount[i]=0}obj_loop:for(var i=0;i<numObjs;++i){var obj=objects[i];var pickCount=obj.pickSlots;if(!pickCount){pickBufferIds[i]=-1;continue}for(var j=0;j<numPick;++j){if(pickBufferCount[j]+pickCount<255){pickBufferIds[i]=j;obj.setPickBase(pickBufferCount[j]+1);pickBufferCount[j]+=pickCount;continue obj_loop}}var nbuffer=createSelect(gl,viewShape);pickBufferIds[i]=numPick;pickBuffers.push(nbuffer);pickBufferCount.push(pickCount);obj.setPickBase(1);numPick+=1}while(numPick>0&&pickBufferCount[numPick-1]===0){pickBufferCount.pop();pickBuffers.pop().dispose()}}scene.update=function(options){options=options||{}};scene.add=function(obj){obj.axes=axes;objects.push(obj);pickBufferIds.push(-1);dirty=true;pickDirty=true;reallocPickIds()};scene.remove=function(obj){var idx=objects.indexOf(obj);if(idx<0){return}objects.splice(idx,1);pickBufferIds.pop();dirty=true;pickDirty=true;reallocPickIds()};scene.dispose=function(){stopped=true;window.removeEventListener("resize",resizeListener);axes.dispose();spikes.dispose();for(var i=0;i<objects.length;++i){objects[i].dispose()}};var mouseRotating=false;var prevButtons=0;mouseChange(canvas,function(buttons,x,y){var numPick=pickBuffers.length;var numObjs=objects.length;var prevObj=selection.object;selection.distance=Infinity;selection.mouse[0]=x;selection.mouse[1]=y;selection.object=null;selection.screen=null;selection.dataCoordinate=selection.dataPosition=null;var change=false;if(buttons){mouseRotating=true}else{if(mouseRotating){pickDirty=true}mouseRotating=false;for(var i=0;i<numPick;++i){var result=pickBuffers[i].query(x,pickShape[1]-y-1,scene.pickRadius);if(result){if(result.distance>selection.distance){continue}for(var j=0;j<numObjs;++j){var obj=objects[j];if(pickBufferIds[j]!==i){continue}var objPick=obj.pick(result);if(objPick){selection.screen=result.coord;selection.distance=result.distance;selection.object=obj;selection.index=objPick.distance;selection.dataPosition=objPick.position;selection.dataCoordinate=objPick.dataCoordinate;selection.data=objPick;change=true}}}}}if(prevObj&&prevObj!==selection.object){if(prevObj.highlight){prevObj.highlight(null)}dirty=true}if(selection.object){if(selection.object.highlight){selection.object.highlight(selection.data)}dirty=true}change=change||selection.object!==prevObj;if(change&&scene.onselect){scene.onselect(selection)}if(buttons&1&&!(prevButtons&1)&&scene.onclick){scene.onclick(selection)}prevButtons=buttons});function renderPick(){gl.colorMask(true,true,true,true);gl.depthMask(true);gl.disable(gl.BLEND);gl.enable(gl.DEPTH_TEST);var numObjs=objects.length;var numPick=pickBuffers.length;for(var j=0;j<numPick;++j){var buf=pickBuffers[j];buf.shape=pickShape;buf.begin();for(var i=0;i<numObjs;++i){if(pickBufferIds[i]!==j){continue}var obj=objects[i];if(obj.drawPick){obj.pixelRatio=1;obj.drawPick(cameraParams)}}buf.end()}}var nBounds=[[Infinity,Infinity,Infinity],[-Infinity,-Infinity,-Infinity]];function render(){if(stopped){return}requestAnimationFrame(render);var cameraMoved=camera.tick();dirty=dirty||cameraMoved;pickDirty=pickDirty||cameraMoved;axes.pixelRatio=scene.pixelRatio;spikes.pixelRatio=scene.pixelRatio;var numObjs=objects.length;var lo=nBounds[0];var hi=nBounds[1];lo[0]=lo[1]=lo[2]=Infinity;hi[0]=hi[1]=hi[2]=-Infinity;for(var i=0;i<numObjs;++i){var obj=objects[i];obj.pixelRatio=scene.pixelRatio;obj.axes=scene.axes;dirty=dirty||!!obj.dirty;pickDirty=pickDirty||!!obj.dirty;var obb=obj.bounds;if(obb){var olo=obb[0];var ohi=obb[1];for(var j=0;j<3;++j){lo[j]=Math.min(lo[j],olo[j]);hi[j]=Math.max(hi[j],ohi[j])}}}var bounds=scene.bounds;if(scene.autoBounds){var boundsChanged=false;for(var j=0;j<3;++j){if(lo[j]===Infinity||hi[j]===-Infinity){lo[j]=-1;hi[j]=1}else{var padding=.05*(hi[j]-lo[j]);lo[j]=lo[j]-padding;hi[j]=hi[j]+padding}boundsChanged=boundsChanged||lo[j]!==bounds[0][j]||hi[j]!==bounds[1][j]}if(boundsChanged){var tickSpacing=[0,0,0];for(var i=0;i<3;++i){bounds[0][i]=lo[i];bounds[1][i]=hi[i];tickSpacing[i]=roundUpPow10((hi[i]-lo[i])/10)}if(axes.autoTicks){axes.update({bounds:bounds,tickSpacing:tickSpacing})}else{axes.update({bounds:bounds})}}}pickDirty=pickDirty||boundsChanged;dirty=dirty||boundsChanged;var width=gl.drawingBufferWidth;var height=gl.drawingBufferHeight;viewShape[0]=width;viewShape[1]=height;pickShape[0]=Math.max(width/scene.pixelRatio,1)|0;pickShape[1]=Math.max(height/scene.pixelRatio,1)|0;perspective(projection,scene.fovy,width/height,scene.zNear,scene.zFar);for(var i=0;i<16;++i){model[i]=0}model[15]=1;var diameter=0;for(var i=0;i<3;++i){ | |
diameter=Math.max(bounds[1][i]-bounds[0][i])}for(var i=0;i<3;++i){if(scene.autoScale){model[5*i]=.5/diameter}else{model[5*i]=1}if(scene.autoCenter){model[12+i]=-model[5*i]*.5*(bounds[0][i]+bounds[1][i])}}for(var i=0;i<numObjs;++i){var obj=objects[i];obj.axesBounds=bounds;if(scene.clipToBounds){obj.clipBounds=bounds}}if(selection.object){if(scene.snapToData){spikes.position=selection.dataCoordinate}else{spikes.position=selection.dataPosition}spikes.bounds=bounds}if(pickDirty){pickDirty=false;renderPick()}if(!dirty){return}scene.axesPixels=axesRanges(scene.axes,cameraParams,width,height);if(scene.onrender){scene.onrender()}gl.bindFramebuffer(gl.FRAMEBUFFER,null);gl.viewport(0,0,width,height);var clearColor=scene.clearColor;gl.clearColor(clearColor[0],clearColor[1],clearColor[2],clearColor[3]);gl.clear(gl.COLOR_BUFFER_BIT|gl.DEPTH_BUFFER_BIT);gl.depthMask(true);gl.colorMask(true,true,true,true);gl.enable(gl.DEPTH_TEST);gl.depthFunc(gl.LEQUAL);gl.disable(gl.BLEND);gl.disable(gl.CULL_FACE);var hasTransparent=false;if(axes.enable){hasTransparent=hasTransparent||axes.isTransparent();axes.draw(cameraParams)}spikes.axes=axes;if(selection.object){spikes.draw(cameraParams)}gl.disable(gl.CULL_FACE);for(var i=0;i<numObjs;++i){var obj=objects[i];obj.axes=axes;obj.pixelRatio=scene.pixelRatio;if(obj.isOpaque&&obj.isOpaque()){obj.draw(cameraParams)}if(obj.isTransparent&&obj.isTransparent()){hasTransparent=true}}if(hasTransparent){accumBuffer.shape=viewShape;accumBuffer.bind();gl.clear(gl.DEPTH_BUFFER_BIT);gl.colorMask(false,false,false,false);gl.depthMask(true);gl.depthFunc(gl.LESS);if(axes.enable&&axes.isTransparent()){axes.drawTransparent(cameraParams)}for(var i=0;i<numObjs;++i){var obj=objects[i];if(obj.isOpaque&&obj.isOpaque()){obj.draw(cameraParams)}}gl.enable(gl.BLEND);gl.blendEquation(gl.FUNC_ADD);gl.blendFunc(gl.ONE,gl.ONE);gl.colorMask(true,true,true,true);gl.depthMask(false);gl.clearColor(0,0,0,0);gl.clear(gl.COLOR_BUFFER_BIT);if(axes.isTransparent()){axes.drawTransparent(cameraParams)}for(var i=0;i<numObjs;++i){var obj=objects[i];if(obj.isTransparent&&obj.isTransparent()){obj.drawTransparent(cameraParams)}}gl.bindFramebuffer(gl.FRAMEBUFFER,null);gl.blendFunc(gl.ONE,gl.ONE_MINUS_SRC_ALPHA);gl.disable(gl.DEPTH_TEST);accumShader.bind();accumBuffer.color[0].bind(0);accumShader.uniforms.accumBuffer=0;drawTriangle(gl);gl.disable(gl.BLEND)}dirty=false;for(var i=0;i<numObjs;++i){objects[i].dirty=false}}render();return scene}},{"./lib/shader":6,"a-big-triangle":25,"gl-axes3d":26,"gl-axes3d/properties":113,"gl-fbo":114,"gl-mat4/perspective":131,"gl-select-static":140,"gl-spikes3d":167,"mouse-change":176,orbiter:189}]},{},[]);require=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 base64=require("base64-js");var ieee754=require("ieee754");var isArray=require("is-array");exports.Buffer=Buffer;exports.SlowBuffer=SlowBuffer;exports.INSPECT_MAX_BYTES=50;Buffer.poolSize=8192;var kMaxLength=1073741823;var rootParent={};Buffer.TYPED_ARRAY_SUPPORT=function(){try{var buf=new ArrayBuffer(0);var arr=new Uint8Array(buf);arr.foo=function(){return 42};return 42===arr.foo()&&typeof arr.subarray==="function"&&new Uint8Array(1).subarray(1,1).byteLength===0}catch(e){return false}}();function Buffer(subject,encoding,noZero){if(!(this instanceof Buffer))return new Buffer(subject,encoding,noZero);var type=typeof subject;var length;if(type==="number")length=subject>0?subject>>>0:0;else if(type==="string"){length=Buffer.byteLength(subject,encoding)}else if(type==="object"&&subject!==null){if(subject.type==="Buffer"&&isArray(subject.data))subject=subject.data;length=+subject.length>0?Math.floor(+subject.length):0}else throw new TypeError("must start with number, buffer, array or string");if(length>kMaxLength)throw new RangeError("Attempt to allocate Buffer larger than maximum "+"size: 0x"+kMaxLength.toString(16)+" bytes");var buf;if(Buffer.TYPED_ARRAY_SUPPORT){buf=Buffer._augment(new Uint8Array(length))}else{buf=this;buf.length=length;buf._isBuffer=true}var i;if(Buffer.TYPED_ARRAY_SUPPORT&&typeof subject.byteLength==="number"){buf._set(subject)}else if(isArrayish(subject)){if(Buffer.isBuffer(subject)){for(i=0;i<length;i++)buf[i]=subject.readUInt8(i)}else{for(i=0;i<length;i++)buf[i]=(subject[i]%256+256)%256}}else if(type==="string"){buf.write(subject,0,encoding)}else if(type==="number"&&!Buffer.TYPED_ARRAY_SUPPORT&&!noZero){for(i=0;i<length;i++){buf[i]=0}}if(length>0&&length<=Buffer.poolSize)buf.parent=rootParent;return buf}function SlowBuffer(subject,encoding,noZero){if(!(this instanceof SlowBuffer))return new SlowBuffer(subject,encoding,noZero);var buf=new Buffer(subject,encoding,noZero);delete buf.parent;return buf}Buffer.isBuffer=function(b){return!!(b!=null&&b._isBuffer)};Buffer.compare=function(a,b){if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b))throw new TypeError("Arguments must be Buffers");var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);i<len&&a[i]===b[i];i++){}if(i!==len){x=a[i];y=b[i]}if(x<y)return-1;if(y<x)return 1;return 0};Buffer.isEncoding=function(encoding){switch(String(encoding).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return true;default:return false}};Buffer.concat=function(list,totalLength){if(!isArray(list))throw new TypeError("Usage: Buffer.concat(list[, length])");if(list.length===0){return new Buffer(0)}else if(list.length===1){return list[0]}var i;if(totalLength===undefined){totalLength=0;for(i=0;i<list.length;i++){totalLength+=list[i].length}}var buf=new Buffer(totalLength);var pos=0;for(i=0;i<list.length;i++){var item=list[i];item.copy(buf,pos);pos+=item.length}return buf};Buffer.byteLength=function(str,encoding){var ret;str=str+"";switch(encoding||"utf8"){case"ascii":case"binary":case"raw":ret=str.length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=str.length*2;break;case"hex":ret=str.length>>>1;break;case"utf8":case"utf-8":ret=utf8ToBytes(str).length;break;case"base64":ret=base64ToBytes(str).length;break;default:ret=str.length}return ret};Buffer.prototype.length=undefined;Buffer.prototype.parent=undefined;Buffer.prototype.toString=function(encoding,start,end){var loweredCase=false;start=start>>>0;end=end===undefined||end===Infinity?this.length:end>>>0;if(!encoding)encoding="utf8";if(start<0)start=0;if(end>this.length)end=this.length;if(end<=start)return"";while(true){switch(encoding){case"hex":return hexSlice(this,start,end);case"utf8":case"utf-8":return utf8Slice(this,start,end);case"ascii":return asciiSlice(this,start,end);case"binary":return binarySlice(this,start,end);case"base64":return base64Slice(this,start,end);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError("Unknown encoding: "+encoding);encoding=(encoding+"").toLowerCase();loweredCase=true}}};Buffer.prototype.equals=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)===0};Buffer.prototype.inspect=function(){var str="";var max=exports.INSPECT_MAX_BYTES;if(this.length>0){str=this.toString("hex",0,max).match(/.{2}/g).join(" ");if(this.length>max)str+=" ... "}return"<Buffer "+str+">"};Buffer.prototype.compare=function(b){if(!Buffer.isBuffer(b))throw new TypeError("Argument must be a Buffer");return Buffer.compare(this,b)};Buffer.prototype.get=function(offset){console.log(".get() is deprecated. Access using array indexes instead.");return this.readUInt8(offset)};Buffer.prototype.set=function(v,offset){console.log(".set() is deprecated. Access using array indexes instead.");return this.writeUInt8(v,offset)};function hexWrite(buf,string,offset,length){offset=Number(offset)||0;var remaining=buf.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}var strLen=string.length;if(strLen%2!==0)throw new Error("Invalid hex string");if(length>strLen/2){length=strLen/2}for(var i=0;i<length;i++){var byte=parseInt(string.substr(i*2,2),16);if(isNaN(byte))throw new Error("Invalid hex string");buf[offset+i]=byte}return i}function utf8Write(buf,string,offset,length){var charsWritten=blitBuffer(utf8ToBytes(string,buf.length-offset),buf,offset,length);return charsWritten}function asciiWrite(buf,string,offset,length){var charsWritten=blitBuffer(asciiToBytes(string),buf,offset,length);return charsWritten}function binaryWrite(buf,string,offset,length){return asciiWrite(buf,string,offset,length)}function base64Write(buf,string,offset,length){var charsWritten=blitBuffer(base64ToBytes(string),buf,offset,length);return charsWritten}function utf16leWrite(buf,string,offset,length){var charsWritten=blitBuffer(utf16leToBytes(string,buf.length-offset),buf,offset,length,2);return charsWritten}Buffer.prototype.write=function(string,offset,length,encoding){if(isFinite(offset)){if(!isFinite(length)){encoding=length;length=undefined}}else{var swap=encoding;encoding=offset;offset=length;length=swap}offset=Number(offset)||0;if(length<0||offset<0||offset>this.length)throw new RangeError("attempt to write outside buffer bounds");var remaining=this.length-offset;if(!length){length=remaining}else{length=Number(length);if(length>remaining){length=remaining}}encoding=String(encoding||"utf8").toLowerCase();var ret;switch(encoding){case"hex":ret=hexWrite(this,string,offset,length);break;case"utf8":case"utf-8":ret=utf8Write(this,string,offset,length);break;case"ascii":ret=asciiWrite(this,string,offset,length);break;case"binary":ret=binaryWrite(this,string,offset,length);break;case"base64":ret=base64Write(this,string,offset,length);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":ret=utf16leWrite(this,string,offset,length);break;default:throw new TypeError("Unknown encoding: "+encoding)}return ret};Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf)}else{return base64.fromByteArray(buf.slice(start,end))}}function utf8Slice(buf,start,end){var res="";var tmp="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){if(buf[i]<=127){res+=decodeUtf8Char(tmp)+String.fromCharCode(buf[i]);tmp=""}else{tmp+="%"+buf[i].toString(16)}}return res+decodeUtf8Char(tmp)}function asciiSlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i]&127)}return ret}function binarySlice(buf,start,end){var ret="";end=Math.min(buf.length,end);for(var i=start;i<end;i++){ret+=String.fromCharCode(buf[i])}return ret}function hexSlice(buf,start,end){var len=buf.length;if(!start||start<0)start=0;if(!end||end<0||end>len)end=len;var out="";for(var i=start;i<end;i++){out+=toHex(buf[i])}return out}function utf16leSlice(buf,start,end){var bytes=buf.slice(start,end);var res="";for(var i=0;i<bytes.length;i+=2){res+=String.fromCharCode(bytes[i]+bytes[i+1]*256)}return res}Buffer.prototype.slice=function(start,end){var len=this.length;start=~~start;end=end===undefined?len:~~end;if(start<0){start+=len;if(start<0)start=0}else if(start>len){start=len}if(end<0){end+=len;if(end<0)end=0}else if(end>len){end=len}if(end<start)end=start;var newBuf;if(Buffer.TYPED_ARRAY_SUPPORT){newBuf=Buffer._augment(this.subarray(start,end))}else{var sliceLen=end-start;newBuf=new Buffer(sliceLen,undefined,true);for(var i=0;i<sliceLen;i++){newBuf[i]=this[i+start]}}if(newBuf.length)newBuf.parent=this.parent||this;return newBuf};function checkOffset(offset,ext,length){if(offset%1!==0||offset<0)throw new RangeError("offset is not uint");if(offset+ext>length)throw new RangeError("Trying to access beyond buffer length")}Buffer.prototype.readUIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;return val};Buffer.prototype.readUIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=256))val+=this[offset+--byteLength]*mul;return val};Buffer.prototype.readUInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);return this[offset]};Buffer.prototype.readUInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8};Buffer.prototype.readUInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1]};Buffer.prototype.readUInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*16777216};Buffer.prototype.readUInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*16777216+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3])};Buffer.prototype.readIntLE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i<byteLength&&(mul*=256))val+=this[offset+i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readIntBE=function(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=256))val+=this[offset+--i]*mul;mul*=128;if(val>=mul)val-=Math.pow(2,8*byteLength);return val};Buffer.prototype.readInt8=function(offset,noAssert){if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&128))return this[offset];return(255-this[offset]+1)*-1};Buffer.prototype.readInt16LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt16BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&32768?val|4294901760:val};Buffer.prototype.readInt32LE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24};Buffer.prototype.readInt32BE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3]};Buffer.prototype.readFloatLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4)};Buffer.prototype.readFloatBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4)};Buffer.prototype.readDoubleLE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8)};Buffer.prototype.readDoubleBE=function(offset,noAssert){if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8)};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError("buffer must be a Buffer instance");if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range")}Buffer.prototype.writeUIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var mul=1;var i=0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength),0);var i=byteLength-1;var mul=1;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=value/mul>>>0&255;return offset+byteLength};Buffer.prototype.writeUInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,255,0);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);this[offset]=value;return offset+1};function objectWriteUInt16(buf,value,offset,littleEndian){if(value<0)value=65535+value+1;for(var i=0,j=Math.min(buf.length-offset,2);i<j;i++){buf[offset+i]=(value&255<<8*(littleEndian?i:1-i))>>>(littleEndian?i:1-i)*8}}Buffer.prototype.writeUInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeUInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,65535,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};function objectWriteUInt32(buf,value,offset,littleEndian){if(value<0)value=4294967295+value+1;for(var i=0,j=Math.min(buf.length-offset,4);i<j;i++){buf[offset+i]=value>>>(littleEndian?i:3-i)*8&255}}Buffer.prototype.writeUInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeUInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,4294967295,0);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};Buffer.prototype.writeIntLE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=0;var mul=1;var sub=value<0?1:0;this[offset]=value&255;while(++i<byteLength&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeIntBE=function(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkInt(this,value,offset,byteLength,Math.pow(2,8*byteLength-1)-1,-Math.pow(2,8*byteLength-1))}var i=byteLength-1;var mul=1;var sub=value<0?1:0;this[offset+i]=value&255;while(--i>=0&&(mul*=256))this[offset+i]=(value/mul>>0)-sub&255;return offset+byteLength};Buffer.prototype.writeInt8=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,127,-128);if(!Buffer.TYPED_ARRAY_SUPPORT)value=Math.floor(value);if(value<0)value=255+value+1;this[offset]=value;return offset+1};Buffer.prototype.writeInt16LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8}else objectWriteUInt16(this,value,offset,true);return offset+2};Buffer.prototype.writeInt16BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,32767,-32768);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>8;this[offset+1]=value}else objectWriteUInt16(this,value,offset,false);return offset+2};Buffer.prototype.writeInt32LE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24}else objectWriteUInt32(this,value,offset,true);return offset+4};Buffer.prototype.writeInt32BE=function(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,2147483647,-2147483648);if(value<0)value=4294967295+value+1;if(Buffer.TYPED_ARRAY_SUPPORT){this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value}else objectWriteUInt32(this,value,offset,false);return offset+4};function checkIEEE754(buf,value,offset,ext,max,min){if(value>max||value<min)throw new RangeError("value is out of bounds");if(offset+ext>buf.length)throw new RangeError("index out of range");if(offset<0)throw new RangeError("index out of range")}function writeFloat(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,4,3.4028234663852886e38,-3.4028234663852886e38);ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4}Buffer.prototype.writeFloatLE=function(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert)};Buffer.prototype.writeFloatBE=function(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert)};function writeDouble(buf,value,offset,littleEndian,noAssert){if(!noAssert)checkIEEE754(buf,value,offset,8,1.7976931348623157e308,-1.7976931348623157e308);ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8}Buffer.prototype.writeDoubleLE=function(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert)};Buffer.prototype.writeDoubleBE=function(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert)};Buffer.prototype.copy=function(target,target_start,start,end){var source=this;if(!start)start=0;if(!end&&end!==0)end=this.length;if(target_start>=target.length)target_start=target.length;if(!target_start)target_start=0;if(end>0&&end<start)end=start;if(end===start)return 0;if(target.length===0||source.length===0)return 0;if(target_start<0)throw new RangeError("targetStart out of bounds");if(start<0||start>=source.length)throw new RangeError("sourceStart out of bounds");if(end<0)throw new RangeError("sourceEnd out of bounds");if(end>this.length)end=this.length;if(target.length-target_start<end-start)end=target.length-target_start+start;var len=end-start;if(len<1e3||!Buffer.TYPED_ARRAY_SUPPORT){for(var i=0;i<len;i++){target[i+target_start]=this[i+start]}}else{target._set(this.subarray(start,start+len),target_start)}return len};Buffer.prototype.fill=function(value,start,end){if(!value)value=0;if(!start)start=0;if(!end)end=this.length;if(end<start)throw new RangeError("end < start");if(end===start)return;if(this.length===0)return;if(start<0||start>=this.length)throw new RangeError("start out of bounds");if(end<0||end>this.length)throw new RangeError("end out of bounds");var i;if(typeof value==="number"){for(i=start;i<end;i++){this[i]=value}}else{var bytes=utf8ToBytes(value.toString());var len=bytes.length;for(i=start;i<end;i++){this[i]=bytes[i%len]}}return this};Buffer.prototype.toArrayBuffer=function(){if(typeof Uint8Array!=="undefined"){if(Buffer.TYPED_ARRAY_SUPPORT){return new Buffer(this).buffer}else{var buf=new Uint8Array(this.length);for(var i=0,len=buf.length;i<len;i+=1){buf[i]=this[i]}return buf.buffer}}else{throw new TypeError("Buffer.toArrayBuffer not supported in this browser")}};var BP=Buffer.prototype;Buffer._augment=function(arr){arr.constructor=Buffer;arr._isBuffer=true;arr._get=arr.get;arr._set=arr.set;arr.get=BP.get;arr.set=BP.set;arr.write=BP.write;arr.toString=BP.toString;arr.toLocaleString=BP.toString;arr.toJSON=BP.toJSON;arr.equals=BP.equals;arr.compare=BP.compare;arr.copy=BP.copy;arr.slice=BP.slice;arr.readUIntLE=BP.readUIntLE;arr.readUIntBE=BP.readUIntBE;arr.readUInt8=BP.readUInt8;arr.readUInt16LE=BP.readUInt16LE;arr.readUInt16BE=BP.readUInt16BE;arr.readUInt32LE=BP.readUInt32LE;arr.readUInt32BE=BP.readUInt32BE;arr.readIntLE=BP.readIntLE;arr.readIntBE=BP.readIntBE;arr.readInt8=BP.readInt8;arr.readInt16LE=BP.readInt16LE;arr.readInt16BE=BP.readInt16BE;arr.readInt32LE=BP.readInt32LE;arr.readInt32BE=BP.readInt32BE;arr.readFloatLE=BP.readFloatLE;arr.readFloatBE=BP.readFloatBE;arr.readDoubleLE=BP.readDoubleLE;arr.readDoubleBE=BP.readDoubleBE;arr.writeUInt8=BP.writeUInt8;arr.writeUIntLE=BP.writeUIntLE;arr.writeUIntBE=BP.writeUIntBE;arr.writeUInt16LE=BP.writeUInt16LE;arr.writeUInt16BE=BP.writeUInt16BE;arr.writeUInt32LE=BP.writeUInt32LE;arr.writeUInt32BE=BP.writeUInt32BE;arr.writeIntLE=BP.writeIntLE;arr.writeIntBE=BP.writeIntBE;arr.writeInt8=BP.writeInt8;arr.writeInt16LE=BP.writeInt16LE;arr.writeInt16BE=BP.writeInt16BE;arr.writeInt32LE=BP.writeInt32LE;arr.writeInt32BE=BP.writeInt32BE;arr.writeFloatLE=BP.writeFloatLE;arr.writeFloatBE=BP.writeFloatBE;arr.writeDoubleLE=BP.writeDoubleLE;arr.writeDoubleBE=BP.writeDoubleBE;arr.fill=BP.fill;arr.inspect=BP.inspect;arr.toArrayBuffer=BP.toArrayBuffer;return arr};var INVALID_BASE64_RE=/[^+\/0-9A-z\-]/g;function base64clean(str){str=stringtrim(str).replace(INVALID_BASE64_RE,"");if(str.length<2)return"";while(str.length%4!==0){str=str+"="}return str}function stringtrim(str){if(str.trim)return str.trim();return str.replace(/^\s+|\s+$/g,"")}function isArrayish(subject){return isArray(subject)||Buffer.isBuffer(subject)||subject&&typeof subject==="object"&&typeof subject.length==="number"}function toHex(n){if(n<16)return"0"+n.toString(16);return n.toString(16)}function utf8ToBytes(string,units){var codePoint,length=string.length;var leadSurrogate=null;units=units||Infinity;var bytes=[];var i=0;for(;i<length;i++){codePoint=string.charCodeAt(i);if(codePoint>55295&&codePoint<57344){if(leadSurrogate){if(codePoint<56320){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=codePoint;continue}else{codePoint=leadSurrogate-55296<<10|codePoint-56320|65536;leadSurrogate=null}}else{if(codePoint>56319){if((units-=3)>-1)bytes.push(239,191,189);continue}else if(i+1===length){if((units-=3)>-1)bytes.push(239,191,189);continue}else{leadSurrogate=codePoint;continue}}}else if(leadSurrogate){if((units-=3)>-1)bytes.push(239,191,189);leadSurrogate=null}if(codePoint<128){if((units-=1)<0)break;bytes.push(codePoint)}else if(codePoint<2048){if((units-=2)<0)break;bytes.push(codePoint>>6|192,codePoint&63|128)}else if(codePoint<65536){if((units-=3)<0)break;bytes.push(codePoint>>12|224,codePoint>>6&63|128,codePoint&63|128)}else if(codePoint<2097152){if((units-=4)<0)break;bytes.push(codePoint>>18|240,codePoint>>12&63|128,codePoint>>6&63|128,codePoint&63|128)}else{throw new Error("Invalid code point")}}return bytes}function asciiToBytes(str){var byteArray=[];for(var i=0;i<str.length;i++){byteArray.push(str.charCodeAt(i)&255)}return byteArray}function utf16leToBytes(str,units){var c,hi,lo;var byteArray=[];for(var i=0;i<str.length;i++){if((units-=2)<0)break;c=str.charCodeAt(i);hi=c>>8;lo=c%256;byteArray.push(lo);byteArray.push(hi)}return byteArray}function base64ToBytes(str){return base64.toByteArray(base64clean(str))}function blitBuffer(src,dst,offset,length,unitSize){if(unitSize)length-=length%unitSize;for(var i=0;i<length;i++){if(i+offset>=dst.length||i>=src.length)break;dst[i+offset]=src[i]}return i}function decodeUtf8Char(str){try{return decodeURIComponent(str)}catch(err){return String.fromCharCode(65533)}}},{"base64-js":2,ieee754:3,"is-array":4}],2:[function(require,module,exports){var lookup="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";(function(exports){"use strict";var Arr=typeof Uint8Array!=="undefined"?Uint8Array:Array;var PLUS="+".charCodeAt(0);var SLASH="/".charCodeAt(0);var NUMBER="0".charCodeAt(0);var LOWER="a".charCodeAt(0);var UPPER="A".charCodeAt(0);var PLUS_URL_SAFE="-".charCodeAt(0);var SLASH_URL_SAFE="_".charCodeAt(0);function decode(elt){var code=elt.charCodeAt(0);if(code===PLUS||code===PLUS_URL_SAFE)return 62;if(code===SLASH||code===SLASH_URL_SAFE)return 63;if(code<NUMBER)return-1;if(code<NUMBER+10)return code-NUMBER+26+26;if(code<UPPER+26)return code-UPPER;if(code<LOWER+26)return code-LOWER+26}function b64ToByteArray(b64){var i,j,l,tmp,placeHolders,arr;if(b64.length%4>0){throw new Error("Invalid string. Length must be a multiple of 4")}var len=b64.length;placeHolders="="===b64.charAt(len-2)?2:"="===b64.charAt(len-1)?1:0;arr=new Arr(b64.length*3/4-placeHolders);l=placeHolders>0?b64.length-4:b64.length;var L=0;function push(v){arr[L++]=v}for(i=0,j=0;i<l;i+=4,j+=3){tmp=decode(b64.charAt(i))<<18|decode(b64.charAt(i+1))<<12|decode(b64.charAt(i+2))<<6|decode(b64.charAt(i+3));push((tmp&16711680)>>16);push((tmp&65280)>>8);push(tmp&255)}if(placeHolders===2){tmp=decode(b64.charAt(i))<<2|decode(b64.charAt(i+1))>>4;push(tmp&255)}else if(placeHolders===1){tmp=decode(b64.charAt(i))<<10|decode(b64.charAt(i+1))<<4|decode(b64.charAt(i+2))>>2;push(tmp>>8&255);push(tmp&255)}return arr}function uint8ToBase64(uint8){var i,extraBytes=uint8.length%3,output="",temp,length;function encode(num){return lookup.charAt(num)}function tripletToBase64(num){return encode(num>>18&63)+encode(num>>12&63)+encode(num>>6&63)+encode(num&63)}for(i=0,length=uint8.length-extraBytes;i<length;i+=3){temp=(uint8[i]<<16)+(uint8[i+1]<<8)+uint8[i+2];output+=tripletToBase64(temp)}switch(extraBytes){case 1:temp=uint8[uint8.length-1];output+=encode(temp>>2);output+=encode(temp<<4&63);output+="==";break;case 2:temp=(uint8[uint8.length-2]<<8)+uint8[uint8.length-1];output+=encode(temp>>10);output+=encode(temp>>4&63);output+=encode(temp<<2&63);output+="=";break}return output}exports.toByteArray=b64ToByteArray;exports.fromByteArray=uint8ToBase64})(typeof exports==="undefined"?this.base64js={}:exports)},{}],3:[function(require,module,exports){exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,nBits=-7,i=isLE?nBytes-1:0,d=isLE?-1:1,s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8);m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8);if(e===0){e=1-eBias}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity}else{m=m+Math.pow(2,mLen);e=e-eBias}return(s?-1:1)*m*Math.pow(2,e-mLen)};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c,eLen=nBytes*8-mLen-1,eMax=(1<<eLen)-1,eBias=eMax>>1,rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0,i=isLE?0:nBytes-1,d=isLE?1:-1,s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2}if(e+eBias>=1){value+=rt/c}else{value+=rt*Math.pow(2,1-eBias)}if(value*c>=2){e++;c/=2}if(e+eBias>=eMax){m=0;e=eMax}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0}}for(;mLen>=8;buffer[offset+i]=m&255,i+=d,m/=256,mLen-=8);e=e<<mLen|m;eLen+=mLen;for(;eLen>0;buffer[offset+i]=e&255,i+=d,e/=256,eLen-=8);buffer[offset+i-d]|=s*128}},{}],4:[function(require,module,exports){var isArray=Array.isArray;var str=Object.prototype.toString;module.exports=isArray||function(val){return!!val&&"[object Array]"==str.call(val)}},{}],5:[function(require,module,exports){"use strict";var barycentric=require("barycentric");var closestPointToTriangle=require("polytope-closest-point/lib/closest_point_2d.js");module.exports=closestPointToPickLocation;function xformMatrix(m,v){var out=[0,0,0,0];for(var i=0;i<4;++i){for(var j=0;j<4;++j){out[j]+=m[4*i+j]*v[i]}}return out}function projectVertex(v,model,view,projection,resolution){var p=xformMatrix(projection,xformMatrix(view,xformMatrix(model,[v[0],v[1],v[2],1])));for(var i=0;i<3;++i){p[i]/=p[3]}return[.5*resolution[0]*(1+p[0]),.5*resolution[1]*(1-p[1])]}function barycentricCoord(simplex,point){ | |
if(simplex.length===2){var d0=0;var d1=0;for(var i=0;i<2;++i){d0+=Math.pow(point[i]-simplex[0][i],2);d1+=Math.pow(point[i]-simplex[1][i],2)}d0=Math.sqrt(d0);d1=Math.sqrt(d1);if(d0+d1<1e-6){return[1,0]}return[d1/(d0+d1),d0/(d1+d0)]}else if(simplex.length===3){var closestPoint=[0,0];closestPointToTriangle(simplex[0],simplex[1],simplex[2],point,closestPoint);return barycentric(simplex,closestPoint)}return[]}function interpolate(simplex,weights){var result=[0,0,0];for(var i=0;i<simplex.length;++i){var p=simplex[i];var w=weights[i];for(var j=0;j<3;++j){result[j]+=w*p[j]}}return result}function closestPointToPickLocation(simplex,pixelCoord,model,view,projection,resolution){if(simplex.length===1){return[0,simplex[0].slice()]}var simplex2D=new Array(simplex.length);for(var i=0;i<simplex.length;++i){simplex2D[i]=projectVertex(simplex[i],model,view,projection,resolution)}var closestIndex=0;var closestDist=Infinity;for(var i=0;i<simplex2D.length;++i){var d2=0;for(var j=0;j<2;++j){d2+=Math.pow(simplex2D[i][j]-pixelCoord[j],2)}if(d2<closestDist){closestDist=d2;closestIndex=i}}var weights=barycentricCoord(simplex2D,pixelCoord);var s=0;for(var i=0;i<3;++i){if(weights[i]<-.001||weights[i]>1.0001){return null}s+=weights[i]}if(Math.abs(s-1)>.001){return null}return[closestIndex,interpolate(simplex,weights),weights]}},{barycentric:7,"polytope-closest-point/lib/closest_point_2d.js":56}],6:[function(require,module,exports){var glslify=require("glslify");exports.meshShader=require("glslify/simple-adapter.js")("\n#define GLSLIFY 1\n\nprecision mediump float;\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\nuniform mat4 model, view, projection;\nuniform vec3 eyePosition, lightPosition;\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\nvoid main() {\n vec4 m_position = model * vec4(position, 1.0);\n vec4 t_position = view * m_position;\n gl_Position = projection * t_position;\n f_color = color;\n f_normal = normal;\n f_data = position;\n f_eyeDirection = eyePosition - position;\n f_lightDirection = lightPosition - position;\n f_uv = uv;\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nfloat b_x_beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\nfloat a_x_cookTorranceSpecular(vec3 lightDirection, vec3 viewDirection, vec3 surfaceNormal, float roughness, float fresnel) {\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n vec3 H = normalize(lightDirection + viewDirection);\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n float D = b_x_beckmannDistribution(NdotH, roughness);\n float F = pow(1.0 - VdotN, fresnel);\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform sampler2D texture;\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\nvoid main() {\n if(any(lessThan(f_data, clipBounds[0])) || any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n if(!gl_FrontFacing) {\n N = -N;\n }\n float specular = a_x_cookTorranceSpecular(L, V, N, roughness, fresnel);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1, 1, 1) * specular, 1.0);\n gl_FragColor = litColor * opacity;\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"eyePosition",type:"vec3"},{name:"lightPosition",type:"vec3"},{name:"clipBounds[0]",type:"vec3"},{name:"clipBounds[1]",type:"vec3"},{name:"roughness",type:"float"},{name:"fresnel",type:"float"},{name:"kambient",type:"float"},{name:"kdiffuse",type:"float"},{name:"kspecular",type:"float"},{name:"opacity",type:"float"},{name:"texture",type:"sampler2D"}],[{name:"position",type:"vec3"},{name:"normal",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]);exports.wireShader=require("glslify/simple-adapter.js")("\n#define GLSLIFY 1\n\nprecision mediump float;\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nuniform mat4 model, view, projection;\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\nvoid main() {\n if(any(lessThan(f_data, clipBounds[0])) || any(greaterThan(f_data, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"clipBounds[0]",type:"vec3"},{name:"clipBounds[1]",type:"vec3"},{name:"texture",type:"sampler2D"},{name:"opacity",type:"float"}],[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"}]);exports.pointShader=require("glslify/simple-adapter.js")("\n#define GLSLIFY 1\n\nprecision mediump float;\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\nvarying vec4 f_color;\nvarying vec2 f_uv;\nvoid main() {\n if(any(lessThan(position, clipBounds[0])) || any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(0, 0, 0, 0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nuniform sampler2D texture;\nuniform float opacity;\nvarying vec4 f_color;\nvarying vec2 f_uv;\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5, 0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"clipBounds[0]",type:"vec3"},{name:"clipBounds[1]",type:"vec3"},{name:"texture",type:"sampler2D"},{name:"opacity",type:"float"}],[{name:"position",type:"vec3"},{name:"color",type:"vec4"},{name:"uv",type:"vec2"},{name:"pointSize",type:"float"}]);exports.pickShader=require("glslify/simple-adapter.js")("\n#define GLSLIFY 1\n\nprecision mediump float;\nattribute vec3 position;\nattribute vec4 id;\nuniform mat4 model, view, projection;\nvarying vec3 f_position;\nvarying vec4 f_id;\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nuniform vec3 clipBounds[2];\nuniform float pickId;\nvarying vec3 f_position;\nvarying vec4 f_id;\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"clipBounds[0]",type:"vec3"},{name:"clipBounds[1]",type:"vec3"},{name:"pickId",type:"float"}],[{name:"position",type:"vec3"},{name:"id",type:"vec4"}]);exports.pointPickShader=require("glslify/simple-adapter.js")("\n#define GLSLIFY 1\n\nprecision mediump float;\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\nvarying vec3 f_position;\nvarying vec4 f_id;\nvoid main() {\n if(any(lessThan(position, clipBounds[0])) || any(greaterThan(position, clipBounds[1]))) {\n gl_Position = vec4(0, 0, 0, 0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nuniform vec3 clipBounds[2];\nuniform float pickId;\nvarying vec3 f_position;\nvarying vec4 f_id;\nvoid main() {\n if(any(lessThan(f_position, clipBounds[0])) || any(greaterThan(f_position, clipBounds[1]))) {\n discard;\n }\n gl_FragColor = vec4(pickId, f_id.xyz);\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"clipBounds[0]",type:"vec3"},{name:"clipBounds[1]",type:"vec3"},{name:"clipBounds[0]",type:"vec3"},{name:"clipBounds[1]",type:"vec3"},{name:"pickId",type:"float"}],[{name:"position",type:"vec3"},{name:"pointSize",type:"float"},{name:"id",type:"vec4"}]);exports.contourShader=require("glslify/simple-adapter.js")("\n#define GLSLIFY 1\n\nprecision mediump float;\nattribute vec3 position;\nuniform mat4 model, view, projection;\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}","\n#define GLSLIFY 1\n\nprecision mediump float;\nuniform vec3 contourColor;\nvoid main() {\n gl_FragColor = vec4(contourColor, 1);\n}",[{name:"model",type:"mat4"},{name:"view",type:"mat4"},{name:"projection",type:"mat4"},{name:"contourColor",type:"vec3"}],[{name:"position",type:"vec3"}])},{glslify:51,"glslify/simple-adapter.js":52}],7:[function(require,module,exports){"use strict";module.exports=barycentric;var solve=require("robust-linear-solve");function reduce(x){var r=0;for(var i=0;i<x.length;++i){r+=x[i]}return r}function barycentric(simplex,point){var d=point.length;var A=new Array(d+1);for(var i=0;i<d;++i){var row=new Array(d+1);for(var j=0;j<=d;++j){row[j]=simplex[j][i]}A[i]=row}A[d]=new Array(d+1);for(var i=0;i<=d;++i){A[d][i]=1}var b=new Array(d+1);for(var i=0;i<d;++i){b[i]=point[i]}b[d]=1;var x=solve(A,b);var w=reduce(x[d+1]);if(w===0){w=1}var y=new Array(d+1);for(var i=0;i<=d;++i){y[i]=reduce(x[i])/w}return y}},{"robust-linear-solve":8}],8:[function(require,module,exports){"use strict";var determinant=require("robust-determinant");var NUM_EXPAND=6;function generateSolver(n){var funcName="robustLinearSolve"+n+"d";var code=["function ",funcName,"(A,b){return ["];for(var i=0;i<n;++i){code.push("det([");for(var j=0;j<n;++j){if(j>0){code.push(",")}code.push("[");for(var k=0;k<n;++k){if(k>0){code.push(",")}if(k===i){code.push("+b[",j,"]")}else{code.push("+A[",j,"][",k,"]")}}code.push("]")}code.push("]),")}code.push("det(A)]}return ",funcName);var proc=new Function("det",code.join(""));if(n<6){return proc(determinant[n])}return proc(determinant)}function robustLinearSolve0d(){return[0]}function robustLinearSolve1d(A,b){return[[b[0]],[A[0][0]]]}var CACHE=[robustLinearSolve0d,robustLinearSolve1d];function generateDispatch(){while(CACHE.length<NUM_EXPAND){CACHE.push(generateSolver(CACHE.length))}var procArgs=[];var code=["function dispatchLinearSolve(A,b){switch(A.length){"];for(var i=0;i<NUM_EXPAND;++i){procArgs.push("s"+i);code.push("case ",i,":return s",i,"(A,b);")}code.push("}var s=CACHE[A.length];if(!s)s=CACHE[A.length]=g(A.length);return s(A,b)}return dispatchLinearSolve");procArgs.push("CACHE","g",code.join(""));var proc=Function.apply(undefined,procArgs);module.exports=proc.apply(undefined,CACHE.concat([CACHE,generateSolver]));for(var i=0;i<NUM_EXPAND;++i){module.exports[i]=CACHE[i]}}generateDispatch()},{"robust-determinant":14}],9:[function(require,module,exports){"use strict";module.exports=compressExpansion;function compressExpansion(e){var m=e.length;var Q=e[e.length-1];var bottom=m;for(var i=m-2;i>=0;--i){var a=Q;var b=e[i];Q=a+b;var bv=Q-a;var q=b-bv;if(q){e[--bottom]=Q;Q=q}}var top=0;for(var i=bottom;i<m;++i){var a=e[i];var b=Q;Q=a+b;var bv=Q-a;var q=b-bv;if(q){e[top++]=q}}e[top++]=Q;e.length=top;return e}},{}],10:[function(require,module,exports){"use strict";module.exports=fastTwoSum;function fastTwoSum(a,b,result){var x=a+b;var bv=x-a;var av=x-bv;var br=b-bv;var ar=a-av;if(result){result[0]=ar+br;result[1]=x;return result}return[ar+br,x]}},{}],11:[function(require,module,exports){"use strict";var twoProduct=require("two-product");var twoSum=require("two-sum");module.exports=scaleLinearExpansion;function scaleLinearExpansion(e,scale){var n=e.length;if(n===1){var ts=twoProduct(e[0],scale);if(ts[0]){return ts}return[ts[1]]}var g=new Array(2*n);var q=[.1,.1];var t=[.1,.1];var count=0;twoProduct(e[0],scale,q);if(q[0]){g[count++]=q[0]}for(var i=1;i<n;++i){twoProduct(e[i],scale,t);var pq=q[1];twoSum(pq,t[0],q);if(q[0]){g[count++]=q[0]}var a=t[1];var b=q[1];var x=a+b;var bv=x-a;var y=b-bv;q[1]=x;if(y){g[count++]=y}}if(q[1]){g[count++]=q[1]}if(count===0){g[count++]=0}g.length=count;return g}},{"two-product":13,"two-sum":10}],12:[function(require,module,exports){"use strict";module.exports=linearExpansionSum;function scalarScalar(a,b){var x=a+b;var bv=x-a;var av=x-bv;var br=b-bv;var ar=a-av;var y=ar+br;if(y){return[y,x]}return[x]}function linearExpansionSum(e,f){var ne=e.length|0;var nf=f.length|0;if(ne===1&&nf===1){return scalarScalar(e[0],f[0])}var n=ne+nf;var g=new Array(n);var count=0;var eptr=0;var fptr=0;var abs=Math.abs;var ei=e[eptr];var ea=abs(ei);var fi=f[fptr];var fa=abs(fi);var a,b;if(ea<fa){b=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{b=fi;fptr+=1;if(fptr<nf){fi=f[fptr];fa=abs(fi)}}if(eptr<ne&&ea<fa||fptr>=nf){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=f[fptr];fa=abs(fi)}}var x=a+b;var bv=x-a;var y=b-bv;var q0=y;var q1=x;var _x,_bv,_av,_br,_ar;while(eptr<ne&&fptr<nf){if(ea<fa){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=f[fptr];fa=abs(fi)}}b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x}while(eptr<ne){a=ei;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;eptr+=1;if(eptr<ne){ei=e[eptr]}}while(fptr<nf){a=fi;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;fptr+=1;if(fptr<nf){fi=f[fptr]}}if(q0){g[count++]=q0}if(q1){g[count++]=q1}if(!count){g[count++]=0}g.length=count;return g}},{}],13:[function(require,module,exports){"use strict";module.exports=twoProduct;var SPLITTER=+(Math.pow(2,27)+1);function twoProduct(a,b,result){var x=a*b;var c=SPLITTER*a;var abig=c-a;var ahi=c-abig;var alo=a-ahi;var d=SPLITTER*b;var bbig=d-b;var bhi=d-bbig;var blo=b-bhi;var err1=x-ahi*bhi;var err2=err1-alo*bhi;var err3=err2-ahi*blo;var y=alo*blo-err3;if(result){result[0]=y;result[1]=x;return result}return[y,x]}},{}],14:[function(require,module,exports){"use strict";var twoProduct=require("two-product");var robustSum=require("robust-sum");var robustScale=require("robust-scale");var compress=require("robust-compress");var NUM_EXPANDED=6;function cofactor(m,c){var result=new Array(m.length-1);for(var i=1;i<m.length;++i){var r=result[i-1]=new Array(m.length-1);for(var j=0,k=0;j<m.length;++j){if(j===c){continue}r[k++]=m[i][j]}}return result}function matrix(n){var result=new Array(n);for(var i=0;i<n;++i){result[i]=new Array(n);for(var j=0;j<n;++j){result[i][j]=["m[",i,"][",j,"]"].join("")}}return result}function sign(n){if(n&1){return"-"}return""}function generateSum(expr){if(expr.length===1){return expr[0]}else if(expr.length===2){return["sum(",expr[0],",",expr[1],")"].join("")}else{var m=expr.length>>1;return["sum(",generateSum(expr.slice(0,m)),",",generateSum(expr.slice(m)),")"].join("")}}function determinant(m){if(m.length===2){return["sum(prod(",m[0][0],",",m[1][1],"),prod(-",m[0][1],",",m[1][0],"))"].join("")}else{var expr=[];for(var i=0;i<m.length;++i){expr.push(["scale(",determinant(cofactor(m,i)),",",sign(i),m[0][i],")"].join(""))}return generateSum(expr)}}function compileDeterminant(n){var proc=new Function("sum","scale","prod","compress",["function robustDeterminant",n,"(m){return compress(",determinant(matrix(n)),")};return robustDeterminant",n].join(""));return proc(robustSum,robustScale,twoProduct,compress)}var CACHE=[function robustDeterminant0(){return[0]},function robustDeterminant1(m){return[m[0][0]]}];function generateDispatch(){while(CACHE.length<NUM_EXPANDED){CACHE.push(compileDeterminant(CACHE.length))}var procArgs=[];var code=["function robustDeterminant(m){switch(m.length){"];for(var i=0;i<NUM_EXPANDED;++i){procArgs.push("det"+i);code.push("case ",i,":return det",i,"(m);")}code.push("}var det=CACHE[m.length];if(!det)det=CACHE[m.length]=gen(m.length);return det(m);}return robustDeterminant");procArgs.push("CACHE","gen",code.join(""));var proc=Function.apply(undefined,procArgs);module.exports=proc.apply(undefined,CACHE.concat([CACHE,compileDeterminant]));for(var i=0;i<CACHE.length;++i){module.exports[i]=CACHE[i]}}generateDispatch()},{"robust-compress":9,"robust-scale":11,"robust-sum":12,"two-product":13}],15:[function(require,module,exports){module.exports={jet:[{index:0,rgb:[0,0,131]},{index:.125,rgb:[0,60,170]},{index:.375,rgb:[5,255,255]},{index:.625,rgb:[255,255,0]},{index:.875,rgb:[250,0,0]},{index:1,rgb:[128,0,0]}],hsv:[{index:0,rgb:[255,0,0]},{index:.169,rgb:[253,255,2]},{index:.173,rgb:[247,255,2]},{index:.337,rgb:[0,252,4]},{index:.341,rgb:[0,252,10]},{index:.506,rgb:[1,249,255]},{index:.671,rgb:[2,0,253]},{index:.675,rgb:[8,0,253]},{index:.839,rgb:[255,0,251]},{index:.843,rgb:[255,0,245]},{index:1,rgb:[255,0,6]}],hot:[{index:0,rgb:[0,0,0]},{index:.3,rgb:[230,0,0]},{index:.6,rgb:[255,210,0]},{index:1,rgb:[255,255,255]}],cool:[{index:0,rgb:[0,255,255]},{index:1,rgb:[255,0,255]}],spring:[{index:0,rgb:[255,0,255]},{index:1,rgb:[255,255,0]}],summer:[{index:0,rgb:[0,128,102]},{index:1,rgb:[255,255,102]}],autumn:[{index:0,rgb:[255,0,0]},{index:1,rgb:[255,255,0]}],winter:[{index:0,rgb:[0,0,255]},{index:1,rgb:[0,255,128]}],bone:[{index:0,rgb:[0,0,0]},{index:.376,rgb:[84,84,116]},{index:.753,rgb:[169,200,200]},{index:1,rgb:[255,255,255]}],copper:[{index:0,rgb:[0,0,0]},{index:.804,rgb:[255,160,102]},{index:1,rgb:[255,199,127]}],greys:[{index:0,rgb:[0,0,0]},{index:1,rgb:[255,255,255]}],yignbu:[{index:0,rgb:[8,29,88]},{index:.125,rgb:[37,52,148]},{index:.25,rgb:[34,94,168]},{index:.375,rgb:[29,145,192]},{index:.5,rgb:[65,182,196]},{index:.625,rgb:[127,205,187]},{index:.75,rgb:[199,233,180]},{index:.875,rgb:[237,248,217]},{index:1,rgb:[255,255,217]}],greens:[{index:0,rgb:[0,68,27]},{index:.125,rgb:[0,109,44]},{index:.25,rgb:[35,139,69]},{index:.375,rgb:[65,171,93]},{index:.5,rgb:[116,196,118]},{index:.625,rgb:[161,217,155]},{index:.75,rgb:[199,233,192]},{index:.875,rgb:[229,245,224]},{index:1,rgb:[247,252,245]}],yiorrd:[{index:0,rgb:[128,0,38]},{index:.125,rgb:[189,0,38]},{index:.25,rgb:[227,26,28]},{index:.375,rgb:[252,78,42]},{index:.5,rgb:[253,141,60]},{index:.625,rgb:[254,178,76]},{index:.75,rgb:[254,217,118]},{index:.875,rgb:[255,237,160]},{index:1,rgb:[255,255,204]}],bluered:[{index:0,rgb:[0,0,255]},{index:1,rgb:[255,0,0]}],rdbu:[{index:0,rgb:[5,10,172]},{index:.35,rgb:[106,137,247]},{index:.5,rgb:[190,190,190]},{index:.6,rgb:[220,170,132]},{index:.7,rgb:[230,145,90]},{index:1,rgb:[178,10,28]}],picnic:[{index:0,rgb:[0,0,255]},{index:.1,rgb:[51,153,255]},{index:.2,rgb:[102,204,255]},{index:.3,rgb:[153,204,255]},{index:.4,rgb:[204,204,255]},{index:.5,rgb:[255,255,255]},{index:.6,rgb:[255,204,255]},{index:.7,rgb:[255,153,255]},{index:.8,rgb:[255,102,204]},{index:.9,rgb:[255,102,102]},{index:1,rgb:[255,0,0]}],rainbow:[{index:0,rgb:[150,0,90]},{index:.125,rgb:[0,0,200]},{index:.25,rgb:[0,25,255]},{index:.375,rgb:[0,152,255]},{index:.5,rgb:[44,255,150]},{index:.625,rgb:[151,255,0]},{index:.75,rgb:[255,234,0]},{index:.875,rgb:[255,111,0]},{index:1,rgb:[255,0,0]}],portland:[{index:0,rgb:[12,51,131]},{index:.25,rgb:[10,136,186]},{index:.5,rgb:[242,211,56]},{index:.75,rgb:[242,143,56]},{index:1,rgb:[217,30,30]}],blackbody:[{index:0,rgb:[0,0,0]},{index:.2,rgb:[230,0,0]},{index:.4,rgb:[230,210,0]},{index:.7,rgb:[255,255,255]},{index:1,rgb:[160,200,255]}],earth:[{index:0,rgb:[0,0,130]},{index:.1,rgb:[0,180,180]},{index:.2,rgb:[40,210,40]},{index:.4,rgb:[230,230,50]},{index:.6,rgb:[120,70,20]},{index:1,rgb:[255,255,255]}],electric:[{index:0,rgb:[0,0,0]},{index:.15,rgb:[30,0,100]},{index:.4,rgb:[120,0,100]},{index:.6,rgb:[160,90,0]},{index:.8,rgb:[230,200,0]},{index:1,rgb:[255,250,220]}],alpha:[{index:0,rgb:[255,255,255,0]},{index:0,rgb:[255,255,255,1]}]}},{}],16:[function(require,module,exports){"use strict";var at=require("arraytools");var colorScale=require("./colorScales.json");module.exports=function(spec){var indicies,rgba,fromrgba,torgba,nsteps,cmap,colormap,format,nshades,colors,alpha,index,i,r=[],g=[],b=[],a=[];if(!at.isPlainObject(spec))spec={};if(!spec.colormap)colormap="jet";if(!Array.isArray(spec.alpha)){if(typeof spec.alpha==="number")spec.alpha=[spec.alpha,spec.alpha];else spec.alpha=[1,1]}else if(spec.alpha.length!==2)spec.alpha=[1,1];if(typeof spec.colormap==="string"){colormap=spec.colormap.toLowerCase();if(!(colormap in colorScale)){throw Error(colormap+" not a supported colorscale")}cmap=colorScale[colormap]}else if(Array.isArray(spec.colormap)){cmap=spec.colormap}nshades=spec.nshades||72;format=spec.format||"hex";alpha=spec.alpha;if(cmap.length>nshades){throw new Error(colormap+" map requires nshades to be at least size "+cmap.length)}indicies=cmap.map(function(c){return Math.round(c.index*nshades)});if(alpha[0]<0)alpha[0]=0;if(alpha[1]<0)alpha[0]=0;if(alpha[0]>1)alpha[0]=1;if(alpha[1]>1)alpha[0]=1;for(i=0;i<indicies.length;++i){index=cmap[i].index;rgba=cmap[i].rgb;if(rgba.length===4&&rgba[3]>=0&&rgba[3]<=1)continue;rgba[3]=alpha[0]+(alpha[1]-alpha[0])*index}for(i=0;i<indicies.length-1;++i){nsteps=indicies[i+1]-indicies[i];fromrgba=cmap[i].rgb;torgba=cmap[i+1].rgb;r=r.concat(at.linspace(fromrgba[0],torgba[0],nsteps));g=g.concat(at.linspace(fromrgba[1],torgba[1],nsteps));b=b.concat(at.linspace(fromrgba[2],torgba[2],nsteps));a=a.concat(at.linspace(fromrgba[3],torgba[3],nsteps))}r=r.map(Math.round);g=g.map(Math.round);b=b.map(Math.round);colors=at.zip(r,g,b,a);if(format==="hex")colors=colors.map(rgb2hex);if(format==="rgbaString")colors=colors.map(rgbaStr);return colors};function rgb2hex(rgba){var dig,hex="#";for(var i=0;i<3;++i){dig=rgba[i];dig=dig.toString(16);hex+=("00"+dig).substr(dig.length)}return hex}function rgbaStr(rgba){return"rgba("+rgba.join(",")+")"}},{"./colorScales.json":15,arraytools:17}],17:[function(require,module,exports){"use strict";var arraytools=function(){var that={};var RGB_REGEX=/^rgba?\(\s*\d{1,3}\s*,\s*\d{1,3}\s*,\s*\d{1,3}\s*(,.*)?\)$/;var RGB_GROUP_REGEX=/^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,?\s*(.*)?\)$/;function isPlainObject(v){return!Array.isArray(v)&&v!==null&&typeof v==="object"}function linspace(start,end,num){var inc=(end-start)/(num-1);var a=[];for(var ii=0;ii<num;ii++)a.push(start+ii*inc);return a}function zip(){var arrays=[].slice.call(arguments);var lengths=arrays.map(function(a){return a.length});var len=Math.min.apply(null,lengths);var zipped=[];for(var i=0;i<len;i++){zipped[i]=[];for(var j=0;j<arrays.length;++j){zipped[i][j]=arrays[j][i]}}return zipped}function zip3(a,b,c){var len=Math.min.apply(null,[a.length,b.length,c.length]);var result=[];for(var n=0;n<len;n++){result.push([a[n],b[n],c[n]])}return result}function sum(A){var acc=0;accumulate(A,acc);function accumulate(x){for(var i=0;i<x.length;i++){if(Array.isArray(x[i]))accumulate(x[i],acc);else acc+=x[i]}}return acc}function copy2D(arr){var carr=[];for(var i=0;i<arr.length;++i){carr[i]=[];for(var j=0;j<arr[i].length;++j){carr[i][j]=arr[i][j]}}return carr}function copy1D(arr){var carr=[];for(var i=0;i<arr.length;++i){carr[i]=arr[i]}return carr}function isEqual(arr1,arr2){if(arr1.length!==arr2.length)return false;for(var i=arr1.length;i--;){if(arr1[i]!==arr2[i])return false}return true}function str2RgbArray(str,twoFiftySix){var rgb,match;if(typeof str!=="string")return str;rgb=[];if(str[0]==="#"){str=str.substr(1);if(str.length===3)str+=str;match=parseInt(str,16);rgb[0]=match>>16&255;rgb[1]=match>>8&255;rgb[2]=match&255}else if(RGB_REGEX.test(str)){match=str.match(RGB_GROUP_REGEX);rgb[0]=parseInt(match[1]);rgb[1]=parseInt(match[2]);rgb[2]=parseInt(match[3])}if(!twoFiftySix){for(var j=0;j<3;++j)rgb[j]=rgb[j]/255}return rgb}function str2RgbaArray(str,twoFiftySix){var rgb,match;if(typeof str!=="string")return str;rgb=[];if(str[0]==="#"){str=str.substr(1);if(str.length===3)str+=str;match=parseInt(str,16);rgb[0]=match>>16&255;rgb[1]=match>>8&255;rgb[2]=match&255}else if(RGB_REGEX.test(str)){match=str.match(RGB_GROUP_REGEX);rgb[0]=parseInt(match[1]);rgb[1]=parseInt(match[2]);rgb[2]=parseInt(match[3]);if(match[4])rgb[3]=parseFloat(match[4]);else rgb[3]=1}if(!twoFiftySix){for(var j=0;j<3;++j)rgb[j]=rgb[j]/255}return rgb}that.isPlainObject=isPlainObject;that.linspace=linspace;that.zip3=zip3;that.sum=sum;that.zip=zip;that.isEqual=isEqual;that.copy2D=copy2D;that.copy1D=copy1D;that.str2RgbArray=str2RgbArray;that.str2RgbaArray=str2RgbaArray;return that};module.exports=arraytools()},{}],18:[function(require,module,exports){"use strict";var pool=require("typedarray-pool");var ops=require("ndarray-ops");var ndarray=require("ndarray");var webglew=require("webglew");var SUPPORTED_TYPES=["uint8","uint8_clamped","uint16","uint32","int8","int16","int32","float32"];function GLBuffer(gl,type,handle,length,usage){this.gl=gl;this.type=type;this.handle=handle;this.length=length;this.usage=usage}var proto=GLBuffer.prototype;proto.bind=function(){this.gl.bindBuffer(this.type,this.handle)};proto.unbind=function(){this.gl.bindBuffer(this.type,null)};proto.dispose=function(){this.gl.deleteBuffer(this.handle)};function updateTypeArray(gl,type,len,usage,data,offset){var dataLen=data.length*data.BYTES_PER_ELEMENT;if(offset<0){gl.bufferData(type,data,usage);return dataLen}if(dataLen+offset>len){throw new Error("gl-buffer: If resizing buffer, must not specify offset")}gl.bufferSubData(type,offset,data);return len}function makeScratchTypeArray(array,dtype){var res=pool.malloc(array.length,dtype);var n=array.length;for(var i=0;i<n;++i){res[i]=array[i]}return res}function isPacked(shape,stride){var n=1;for(var i=stride.length-1;i>=0;--i){if(stride[i]!==n){return false}n*=shape[i]}return true}proto.update=function(array,offset){if(typeof offset!=="number"){offset=-1}this.bind();if(typeof array==="object"&&typeof array.shape!=="undefined"){var dtype=array.dtype;if(SUPPORTED_TYPES.indexOf(dtype)<0){dtype="float32"}if(this.type===this.gl.ELEMENT_ARRAY_BUFFER){var wgl=webglew(this.gl);var ext=wgl.OES_element_index_uint;if(ext&&dtype!=="uint16"){dtype="uint32"}else{dtype="uint16"}}if(dtype===array.dtype&&isPacked(array.shape,array.stride)){if(array.offset===0&&array.data.length===array.shape[0]){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,array.data,offset)}else{this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,array.data.subarray(array.offset,array.shape[0]),offset)}}else{var tmp=pool.malloc(array.size,dtype);var ndt=ndarray(tmp,array.shape);ops.assign(ndt,array);if(offset<0){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,tmp,offset)}else{this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,tmp.subarray(0,array.size),offset)}pool.free(tmp)}}else if(Array.isArray(array)){var t;if(this.type===this.gl.ELEMENT_ARRAY_BUFFER){t=makeScratchTypeArray(array,"uint16")}else{t=makeScratchTypeArray(array,"float32")}if(offset<0){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,t,offset)}else{this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,t.subarray(0,array.length),offset)}pool.free(t)}else if(typeof array==="object"&&typeof array.length==="number"){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,array,offset)}else if(typeof array==="number"||array===undefined){if(offset>=0){throw new Error("gl-buffer: Cannot specify offset when resizing buffer")}array=array|0;if(array<=0){array=1}this.gl.bufferData(this.type,array|0,this.usage);this.length=array}else{throw new Error("gl-buffer: Invalid data type")}};function createBuffer(gl,data,type,usage){webglew(gl);type=type||gl.ARRAY_BUFFER;usage=usage||gl.DYNAMIC_DRAW;if(type!==gl.ARRAY_BUFFER&&type!==gl.ELEMENT_ARRAY_BUFFER){throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER")}if(usage!==gl.DYNAMIC_DRAW&&usage!==gl.STATIC_DRAW&&usage!==gl.STREAM_DRAW){throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW")}var handle=gl.createBuffer();var result=new GLBuffer(gl,type,handle,0,usage);result.update(data);return result}module.exports=createBuffer},{ndarray:53,"ndarray-ops":19,"typedarray-pool":92,webglew:25}],19:[function(require,module,exports){"use strict";var compile=require("cwise-compiler");var EmptyProc={body:"",args:[],thisVars:[],localVars:[]};function fixup(x){if(!x){return EmptyProc}for(var i=0;i<x.args.length;++i){var a=x.args[i];if(i===0){x.args[i]={name:a,lvalue:true,rvalue:!!x.rvalue,count:x.count||1}}else{x.args[i]={name:a,lvalue:false,rvalue:true,count:1}}}if(!x.thisVars){x.thisVars=[]}if(!x.localVars){x.localVars=[]}return x}function pcompile(user_args){return compile({args:user_args.args,pre:fixup(user_args.pre),body:fixup(user_args.body),post:fixup(user_args.proc),funcName:user_args.funcName})}function makeOp(user_args){var args=[];for(var i=0;i<user_args.args.length;++i){args.push("a"+i)}var wrapper=new Function("P",["return function ",user_args.funcName,"_ndarrayops(",args.join(","),") {P(",args.join(","),");return a0}"].join(""));return wrapper(pcompile(user_args))}var assign_ops={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var id in assign_ops){var op=assign_ops[id];exports[id]=makeOp({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+op+"c"},funcName:id});exports[id+"eq"]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a"+op+"=b"},rvalue:true,funcName:id+"eq"});exports[id+"s"]=makeOp({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+op+"s"},funcName:id+"s"});exports[id+"seq"]=makeOp({args:["array","scalar"],body:{args:["a","s"],body:"a"+op+"=s"},rvalue:true,funcName:id+"seq"})}})();var unary_ops={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var id in unary_ops){var op=unary_ops[id];exports[id]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a="+op+"b"},funcName:id});exports[id+"eq"]=makeOp({args:["array"],body:{args:["a"],body:"a="+op+"a"},rvalue:true,count:2,funcName:id+"eq"})}})();var binary_ops={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var id in binary_ops){var op=binary_ops[id];exports[id]=makeOp({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+op+"c"},funcName:id});exports[id+"s"]=makeOp({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+op+"s"},funcName:id+"s"});exports[id+"eq"]=makeOp({args:["array","array"],body:{args:["a","b"],body:"a=a"+op+"b"},rvalue:true,count:2,funcName:id+"eq"});exports[id+"seq"]=makeOp({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+op+"s"},rvalue:true,count:2,funcName:id+"seq"})}})();var math_unary=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var i=0;i<math_unary.length;++i){var f=math_unary[i]; | |
exports[f]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:f});exports[f+"eq"]=makeOp({args:["array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"eq"})}})();var math_comm=["max","min","atan2","pow"];(function(){for(var i=0;i<math_comm.length;++i){var f=math_comm[i];exports[f]=makeOp({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:f});exports[f+"s"]=makeOp({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:f+"s"});exports[f+"eq"]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"eq"});exports[f+"seq"]=makeOp({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"seq"})}})();var math_noncomm=["atan2","pow"];(function(){for(var i=0;i<math_noncomm.length;++i){var f=math_noncomm[i];exports[f+"op"]=makeOp({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:f+"op"});exports[f+"ops"]=makeOp({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:f+"ops"});exports[f+"opeq"]=makeOp({args:["array","array"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"opeq"});exports[f+"opseq"]=makeOp({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+f,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:true,count:2,funcName:f+"opseq"})}})();exports.any=compile({args:["array"],pre:EmptyProc,body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"});exports.all=compile({args:["array"],pre:EmptyProc,body:{args:[{name:"x",lvalue:false,rvalue:true,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"});exports.sum=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"});exports.prod=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"});exports.norm2squared=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"});exports.norm2=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"});exports.norminf=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"});exports.norm1=compile({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:false,rvalue:true,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"});exports.sup=compile({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});exports.inf=compile({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}});exports.argmin=compile({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2},{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});exports.argmax=compile({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg1_",lvalue:false,rvalue:false,count:0},{name:"_inline_0_arg2_",lvalue:false,rvalue:true,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:false,rvalue:true,count:2},{name:"_inline_1_arg1_",lvalue:false,rvalue:true,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}});exports.random=makeOp({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"});exports.assign=makeOp({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"});exports.assigns=makeOp({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"});exports.equals=compile({args:["array","array"],pre:EmptyProc,body:{args:[{name:"x",lvalue:false,rvalue:true,count:1},{name:"y",lvalue:false,rvalue:true,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})},{"cwise-compiler":20}],20:[function(require,module,exports){"use strict";var createThunk=require("./lib/thunk.js");function Procedure(){this.argTypes=[];this.shimArgs=[];this.arrayArgs=[];this.scalarArgs=[];this.offsetArgs=[];this.offsetArgIndex=[];this.indexArgs=[];this.shapeArgs=[];this.funcName="";this.pre=null;this.body=null;this.post=null;this.debug=false}function compileCwise(user_args){var proc=new Procedure;proc.pre=user_args.pre;proc.body=user_args.body;proc.post=user_args.post;var proc_args=user_args.args.slice(0);proc.argTypes=proc_args;for(var i=0;i<proc_args.length;++i){var arg_type=proc_args[i];if(arg_type==="array"){proc.arrayArgs.push(i);proc.shimArgs.push("array"+i);if(i<proc.pre.args.length&&proc.pre.args[i].count>0){throw new Error("cwise: pre() block may not reference array args")}if(i<proc.post.args.length&&proc.post.args[i].count>0){throw new Error("cwise: post() block may not reference array args")}}else if(arg_type==="scalar"){proc.scalarArgs.push(i);proc.shimArgs.push("scalar"+i)}else if(arg_type==="index"){proc.indexArgs.push(i);if(i<proc.pre.args.length&&proc.pre.args[i].count>0){throw new Error("cwise: pre() block may not reference array index")}if(i<proc.body.args.length&&proc.body.args[i].lvalue){throw new Error("cwise: body() block may not write to array index")}if(i<proc.post.args.length&&proc.post.args[i].count>0){throw new Error("cwise: post() block may not reference array index")}}else if(arg_type==="shape"){proc.shapeArgs.push(i);if(i<proc.pre.args.length&&proc.pre.args[i].lvalue){throw new Error("cwise: pre() block may not write to array shape")}if(i<proc.body.args.length&&proc.body.args[i].lvalue){throw new Error("cwise: body() block may not write to array shape")}if(i<proc.post.args.length&&proc.post.args[i].lvalue){throw new Error("cwise: post() block may not write to array shape")}}else if(typeof arg_type==="object"&&arg_type.offset){proc.argTypes[i]="offset";proc.offsetArgs.push({array:arg_type.array,offset:arg_type.offset});proc.offsetArgIndex.push(i)}else{throw new Error("cwise: Unknown argument type "+proc_args[i])}}if(proc.arrayArgs.length<=0){throw new Error("cwise: No array arguments specified")}if(proc.pre.args.length>proc_args.length){throw new Error("cwise: Too many arguments in pre() block")}if(proc.body.args.length>proc_args.length){throw new Error("cwise: Too many arguments in body() block")}if(proc.post.args.length>proc_args.length){throw new Error("cwise: Too many arguments in post() block")}proc.debug=!!user_args.printCode||!!user_args.debug;proc.funcName=user_args.funcName||"cwise";proc.blockSize=user_args.blockSize||64;return createThunk(proc)}module.exports=compileCwise},{"./lib/thunk.js":22}],21:[function(require,module,exports){"use strict";var uniq=require("uniq");function innerFill(order,proc,body){var dimension=order.length,nargs=proc.arrayArgs.length,has_index=proc.indexArgs.length>0,code=[],vars=[],idx=0,pidx=0,i,j;for(i=0;i<dimension;++i){vars.push(["i",i,"=0"].join(""))}for(j=0;j<nargs;++j){for(i=0;i<dimension;++i){pidx=idx;idx=order[i];if(i===0){vars.push(["d",j,"s",i,"=t",j,"p",idx].join(""))}else{vars.push(["d",j,"s",i,"=(t",j,"p",idx,"-s",pidx,"*t",j,"p",pidx,")"].join(""))}}}code.push("var "+vars.join(","));for(i=dimension-1;i>=0;--i){idx=order[i];code.push(["for(i",i,"=0;i",i,"<s",idx,";++i",i,"){"].join(""))}code.push(body);for(i=0;i<dimension;++i){pidx=idx;idx=order[i];for(j=0;j<nargs;++j){code.push(["p",j,"+=d",j,"s",i].join(""))}if(has_index){if(i>0){code.push(["index[",pidx,"]-=s",pidx].join(""))}code.push(["++index[",idx,"]"].join(""))}code.push("}")}return code.join("\n")}function outerFill(matched,order,proc,body){var dimension=order.length,nargs=proc.arrayArgs.length,blockSize=proc.blockSize,has_index=proc.indexArgs.length>0,code=[];for(var i=0;i<nargs;++i){code.push(["var offset",i,"=p",i].join(""))}for(var i=matched;i<dimension;++i){code.push(["for(var j"+i+"=SS[",order[i],"]|0;j",i,">0;){"].join(""));code.push(["if(j",i,"<",blockSize,"){"].join(""));code.push(["s",order[i],"=j",i].join(""));code.push(["j",i,"=0"].join(""));code.push(["}else{s",order[i],"=",blockSize].join(""));code.push(["j",i,"-=",blockSize,"}"].join(""));if(has_index){code.push(["index[",order[i],"]=j",i].join(""))}}for(var i=0;i<nargs;++i){var indexStr=["offset"+i];for(var j=matched;j<dimension;++j){indexStr.push(["j",j,"*t",i,"p",order[j]].join(""))}code.push(["p",i,"=(",indexStr.join("+"),")"].join(""))}code.push(innerFill(order,proc,body));for(var i=matched;i<dimension;++i){code.push("}")}return code.join("\n")}function countMatches(orders){var matched=0,dimension=orders[0].length;while(matched<dimension){for(var j=1;j<orders.length;++j){if(orders[j][matched]!==orders[0][matched]){return matched}}++matched}return matched}function processBlock(block,proc,dtypes){var code=block.body;var pre=[];var post=[];for(var i=0;i<block.args.length;++i){var carg=block.args[i];if(carg.count<=0){continue}var re=new RegExp(carg.name,"g");var ptrStr="";var arrNum=proc.arrayArgs.indexOf(i);switch(proc.argTypes[i]){case"offset":var offArgIndex=proc.offsetArgIndex.indexOf(i);var offArg=proc.offsetArgs[offArgIndex];arrNum=offArg.array;ptrStr="+q"+offArgIndex;case"array":ptrStr="p"+arrNum+ptrStr;var localStr="l"+i;var arrStr="a"+arrNum;if(carg.count===1){if(dtypes[arrNum]==="generic"){if(carg.lvalue){pre.push(["var ",localStr,"=",arrStr,".get(",ptrStr,")"].join(""));code=code.replace(re,localStr);post.push([arrStr,".set(",ptrStr,",",localStr,")"].join(""))}else{code=code.replace(re,[arrStr,".get(",ptrStr,")"].join(""))}}else{code=code.replace(re,[arrStr,"[",ptrStr,"]"].join(""))}}else if(dtypes[arrNum]==="generic"){pre.push(["var ",localStr,"=",arrStr,".get(",ptrStr,")"].join(""));code=code.replace(re,localStr);if(carg.lvalue){post.push([arrStr,".set(",ptrStr,",",localStr,")"].join(""))}}else{pre.push(["var ",localStr,"=",arrStr,"[",ptrStr,"]"].join(""));code=code.replace(re,localStr);if(carg.lvalue){post.push([arrStr,"[",ptrStr,"]=",localStr].join(""))}}break;case"scalar":code=code.replace(re,"Y"+proc.scalarArgs.indexOf(i));break;case"index":code=code.replace(re,"index");break;case"shape":code=code.replace(re,"shape");break}}return[pre.join("\n"),code,post.join("\n")].join("\n").trim()}function typeSummary(dtypes){var summary=new Array(dtypes.length);var allEqual=true;for(var i=0;i<dtypes.length;++i){var t=dtypes[i];var digits=t.match(/\d+/);if(!digits){digits=""}else{digits=digits[0]}if(t.charAt(0)===0){summary[i]="u"+t.charAt(1)+digits}else{summary[i]=t.charAt(0)+digits}if(i>0){allEqual=allEqual&&summary[i]===summary[i-1]}}if(allEqual){return summary[0]}return summary.join("")}function generateCWiseOp(proc,typesig){var dimension=typesig[1].length|0;var orders=new Array(proc.arrayArgs.length);var dtypes=new Array(proc.arrayArgs.length);var arglist=["SS"];var code=["'use strict'"];var vars=[];for(var j=0;j<dimension;++j){vars.push(["s",j,"=SS[",j,"]"].join(""))}for(var i=0;i<proc.arrayArgs.length;++i){arglist.push("a"+i);arglist.push("t"+i);arglist.push("p"+i);dtypes[i]=typesig[2*i];orders[i]=typesig[2*i+1];for(var j=0;j<dimension;++j){vars.push(["t",i,"p",j,"=t",i,"[",j,"]"].join(""))}}for(var i=0;i<proc.scalarArgs.length;++i){arglist.push("Y"+i)}if(proc.shapeArgs.length>0){vars.push("shape=SS.slice(0)")}if(proc.indexArgs.length>0){var zeros=new Array(dimension);for(var i=0;i<dimension;++i){zeros[i]="0"}vars.push(["index=[",zeros.join(","),"]"].join(""))}for(var i=0;i<proc.offsetArgs.length;++i){var off_arg=proc.offsetArgs[i];var init_string=[];for(var j=0;j<off_arg.offset.length;++j){if(off_arg.offset[j]===0){continue}else if(off_arg.offset[j]===1){init_string.push(["t",off_arg.array,"p",j].join(""))}else{init_string.push([off_arg.offset[j],"*t",off_arg.array,"p",j].join(""))}}if(init_string.length===0){vars.push("q"+i+"=0")}else{vars.push(["q",i,"=",init_string.join("+")].join(""))}}var thisVars=uniq([].concat(proc.pre.thisVars).concat(proc.body.thisVars).concat(proc.post.thisVars));vars=vars.concat(thisVars);code.push("var "+vars.join(","));for(var i=0;i<proc.arrayArgs.length;++i){code.push("p"+i+"|=0")}if(proc.pre.body.length>3){code.push(processBlock(proc.pre,proc,dtypes))}var body=processBlock(proc.body,proc,dtypes);var matched=countMatches(orders);if(matched<dimension){code.push(outerFill(matched,orders[0],proc,body))}else{code.push(innerFill(orders[0],proc,body))}if(proc.post.body.length>3){code.push(processBlock(proc.post,proc,dtypes))}if(proc.debug){console.log("Generated cwise routine for ",typesig,":\n\n",code.join("\n"))}var loopName=[proc.funcName||"unnamed","_cwise_loop_",orders[0].join("s"),"m",matched,typeSummary(dtypes)].join("");var f=new Function(["function ",loopName,"(",arglist.join(","),"){",code.join("\n"),"} return ",loopName].join(""));return f()}module.exports=generateCWiseOp},{uniq:23}],22:[function(require,module,exports){"use strict";var compile=require("./compile.js");function createThunk(proc){var code=["'use strict'","var CACHED={}"];var vars=[];var thunkName=proc.funcName+"_cwise_thunk";code.push(["return function ",thunkName,"(",proc.shimArgs.join(","),"){"].join(""));var typesig=[];var string_typesig=[];var proc_args=[["array",proc.arrayArgs[0],".shape"].join("")];for(var i=0;i<proc.arrayArgs.length;++i){var j=proc.arrayArgs[i];vars.push(["t",j,"=array",j,".dtype,","r",j,"=array",j,".order"].join(""));typesig.push("t"+j);typesig.push("r"+j);string_typesig.push("t"+j);string_typesig.push("r"+j+".join()");proc_args.push("array"+j+".data");proc_args.push("array"+j+".stride");proc_args.push("array"+j+".offset|0")}for(var i=0;i<proc.scalarArgs.length;++i){proc_args.push("scalar"+proc.scalarArgs[i])}vars.push(["type=[",string_typesig.join(","),"].join()"].join(""));vars.push("proc=CACHED[type]");code.push("var "+vars.join(","));code.push(["if(!proc){","CACHED[type]=proc=compile([",typesig.join(","),"])}","return proc(",proc_args.join(","),")}"].join(""));if(proc.debug){console.log("Generated thunk:",code.join("\n"))}var thunk=new Function("compile",code.join("\n"));return thunk(compile.bind(undefined,proc))}module.exports=createThunk},{"./compile.js":21}],23:[function(require,module,exports){"use strict";function unique_pred(list,compare){var ptr=1,len=list.length,a=list[0],b=list[0];for(var i=1;i<len;++i){b=a;a=list[i];if(compare(a,b)){if(i===ptr){ptr++;continue}list[ptr++]=a}}list.length=ptr;return list}function unique_eq(list){var ptr=1,len=list.length,a=list[0],b=list[0];for(var i=1;i<len;++i,b=a){b=a;a=list[i];if(a!==b){if(i===ptr){ptr++;continue}list[ptr++]=a}}list.length=ptr;return list}function unique(list,compare,sorted){if(list.length===0){return list}if(compare){if(!sorted){list.sort(compare)}return unique_pred(list,compare)}if(!sorted){list.sort()}return unique_eq(list)}module.exports=unique},{}],24:[function(require,module,exports){(function WeakMapModule(){"use strict";if(typeof ses!=="undefined"&&ses.ok&&!ses.ok()){return}function weakMapPermitHostObjects(map){if(map.permitHostObjects___){map.permitHostObjects___(weakMapPermitHostObjects)}}if(typeof ses!=="undefined"){ses.weakMapPermitHostObjects=weakMapPermitHostObjects}var doubleWeakMapCheckSilentFailure=false;if(typeof WeakMap==="function"){var HostWeakMap=WeakMap;if(typeof navigator!=="undefined"&&/Firefox/.test(navigator.userAgent)){}else{var testMap=new HostWeakMap;var testObject=Object.freeze({});testMap.set(testObject,1);if(testMap.get(testObject)!==1){doubleWeakMapCheckSilentFailure=true}else{module.exports=WeakMap;return}}}var hop=Object.prototype.hasOwnProperty;var gopn=Object.getOwnPropertyNames;var defProp=Object.defineProperty;var isExtensible=Object.isExtensible;var HIDDEN_NAME_PREFIX="weakmap:";var HIDDEN_NAME=HIDDEN_NAME_PREFIX+"ident:"+Math.random()+"___";if(typeof crypto!=="undefined"&&typeof crypto.getRandomValues==="function"&&typeof ArrayBuffer==="function"&&typeof Uint8Array==="function"){var ab=new ArrayBuffer(25);var u8s=new Uint8Array(ab);crypto.getRandomValues(u8s);HIDDEN_NAME=HIDDEN_NAME_PREFIX+"rand:"+Array.prototype.map.call(u8s,function(u8){return(u8%36).toString(36)}).join("")+"___"}function isNotHiddenName(name){return!(name.substr(0,HIDDEN_NAME_PREFIX.length)==HIDDEN_NAME_PREFIX&&name.substr(name.length-3)==="___")}defProp(Object,"getOwnPropertyNames",{value:function fakeGetOwnPropertyNames(obj){return gopn(obj).filter(isNotHiddenName)}});if("getPropertyNames"in Object){var originalGetPropertyNames=Object.getPropertyNames;defProp(Object,"getPropertyNames",{value:function fakeGetPropertyNames(obj){return originalGetPropertyNames(obj).filter(isNotHiddenName)}})}function getHiddenRecord(key){if(key!==Object(key)){throw new TypeError("Not an object: "+key)}var hiddenRecord=key[HIDDEN_NAME];if(hiddenRecord&&hiddenRecord.key===key){return hiddenRecord}if(!isExtensible(key)){return void 0}hiddenRecord={key:key};try{defProp(key,HIDDEN_NAME,{value:hiddenRecord,writable:false,enumerable:false,configurable:false});return hiddenRecord}catch(error){return void 0}}(function(){var oldFreeze=Object.freeze;defProp(Object,"freeze",{value:function identifyingFreeze(obj){getHiddenRecord(obj);return oldFreeze(obj)}});var oldSeal=Object.seal;defProp(Object,"seal",{value:function identifyingSeal(obj){getHiddenRecord(obj);return oldSeal(obj)}});var oldPreventExtensions=Object.preventExtensions;defProp(Object,"preventExtensions",{value:function identifyingPreventExtensions(obj){getHiddenRecord(obj);return oldPreventExtensions(obj)}})})();function constFunc(func){func.prototype=null;return Object.freeze(func)}var calledAsFunctionWarningDone=false;function calledAsFunctionWarning(){if(!calledAsFunctionWarningDone&&typeof console!=="undefined"){calledAsFunctionWarningDone=true;console.warn("WeakMap should be invoked as new WeakMap(), not "+"WeakMap(). This will be an error in the future.")}}var nextId=0;var OurWeakMap=function(){if(!(this instanceof OurWeakMap)){calledAsFunctionWarning()}var keys=[];var values=[];var id=nextId++;function get___(key,opt_default){var index;var hiddenRecord=getHiddenRecord(key);if(hiddenRecord){return id in hiddenRecord?hiddenRecord[id]:opt_default}else{index=keys.indexOf(key);return index>=0?values[index]:opt_default}}function has___(key){var hiddenRecord=getHiddenRecord(key);if(hiddenRecord){return id in hiddenRecord}else{return keys.indexOf(key)>=0}}function set___(key,value){var index;var hiddenRecord=getHiddenRecord(key);if(hiddenRecord){hiddenRecord[id]=value}else{index=keys.indexOf(key);if(index>=0){values[index]=value}else{index=keys.length;values[index]=value;keys[index]=key}}return this}function delete___(key){var hiddenRecord=getHiddenRecord(key);var index,lastIndex;if(hiddenRecord){return id in hiddenRecord&&delete hiddenRecord[id]}else{index=keys.indexOf(key);if(index<0){return false}lastIndex=keys.length-1;keys[index]=void 0;values[index]=values[lastIndex];keys[index]=keys[lastIndex];keys.length=lastIndex;values.length=lastIndex;return true}}return Object.create(OurWeakMap.prototype,{get___:{value:constFunc(get___)},has___:{value:constFunc(has___)},set___:{value:constFunc(set___)},delete___:{value:constFunc(delete___)}})};OurWeakMap.prototype=Object.create(Object.prototype,{get:{value:function get(key,opt_default){return this.get___(key,opt_default)},writable:true,configurable:true},has:{value:function has(key){return this.has___(key)},writable:true,configurable:true},set:{value:function set(key,value){return this.set___(key,value)},writable:true,configurable:true},"delete":{value:function remove(key){return this.delete___(key)},writable:true,configurable:true}});if(typeof HostWeakMap==="function"){(function(){if(doubleWeakMapCheckSilentFailure&&typeof Proxy!=="undefined"){Proxy=undefined}function DoubleWeakMap(){if(!(this instanceof OurWeakMap)){calledAsFunctionWarning()}var hmap=new HostWeakMap;var omap=undefined;var enableSwitching=false;function dget(key,opt_default){if(omap){return hmap.has(key)?hmap.get(key):omap.get___(key,opt_default)}else{return hmap.get(key,opt_default)}}function dhas(key){return hmap.has(key)||(omap?omap.has___(key):false)}var dset;if(doubleWeakMapCheckSilentFailure){dset=function(key,value){hmap.set(key,value);if(!hmap.has(key)){if(!omap){omap=new OurWeakMap}omap.set(key,value)}return this}}else{dset=function(key,value){if(enableSwitching){try{hmap.set(key,value)}catch(e){if(!omap){omap=new OurWeakMap}omap.set___(key,value)}}else{hmap.set(key,value)}return this}}function ddelete(key){var result=!!hmap["delete"](key);if(omap){return omap.delete___(key)||result}return result}return Object.create(OurWeakMap.prototype,{get___:{value:constFunc(dget)},has___:{value:constFunc(dhas)},set___:{value:constFunc(dset)},delete___:{value:constFunc(ddelete)},permitHostObjects___:{value:constFunc(function(token){if(token===weakMapPermitHostObjects){enableSwitching=true}else{throw new Error("bogus call to permitHostObjects___")}})}})}DoubleWeakMap.prototype=OurWeakMap.prototype;module.exports=DoubleWeakMap;Object.defineProperty(WeakMap.prototype,"constructor",{value:WeakMap,enumerable:false,configurable:true,writable:true})})()}else{if(typeof Proxy!=="undefined"){Proxy=undefined}module.exports=OurWeakMap}})()},{}],25:[function(require,module,exports){"use strict";var weakMap=typeof WeakMap==="undefined"?require("weak-map"):WeakMap;var WebGLEWStruct=new weakMap;function baseName(ext_name){return ext_name.replace(/^[A-Z]+_/,"")}function initWebGLEW(gl){var struct=WebGLEWStruct.get(gl);if(struct){return struct}var extensions={};var supported=gl.getSupportedExtensions();for(var i=0;i<supported.length;++i){var extName=supported[i];if(extName.indexOf("MOZ_")===0){continue}var ext=gl.getExtension(supported[i]);if(!ext){continue}while(true){extensions[extName]=ext;var base=baseName(extName);if(base===extName){break}extName=base}}WebGLEWStruct.set(gl,extensions);return extensions}module.exports=initWebGLEW},{"weak-map":24}],26:[function(require,module,exports){module.exports=invert;function invert(out,a){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15],b00=a00*a11-a01*a10,b01=a00*a12-a02*a10,b02=a00*a13-a03*a10,b03=a01*a12-a02*a11,b04=a01*a13-a03*a11,b05=a02*a13-a03*a12,b06=a20*a31-a21*a30,b07=a20*a32-a22*a30,b08=a20*a33-a23*a30,b09=a21*a32-a22*a31,b10=a21*a33-a23*a31,b11=a22*a33-a23*a32,det=b00*b11-b01*b10+b02*b09+b03*b08-b04*b07+b05*b06;if(!det){return null}det=1/det;out[0]=(a11*b11-a12*b10+a13*b09)*det;out[1]=(a02*b10-a01*b11-a03*b09)*det;out[2]=(a31*b05-a32*b04+a33*b03)*det;out[3]=(a22*b04-a21*b05-a23*b03)*det;out[4]=(a12*b08-a10*b11-a13*b07)*det;out[5]=(a00*b11-a02*b08+a03*b07)*det;out[6]=(a32*b02-a30*b05-a33*b01)*det;out[7]=(a20*b05-a22*b02+a23*b01)*det;out[8]=(a10*b10-a11*b08+a13*b06)*det;out[9]=(a01*b08-a00*b10-a03*b06)*det;out[10]=(a30*b04-a31*b02+a33*b00)*det;out[11]=(a21*b02-a20*b04-a23*b00)*det;out[12]=(a11*b07-a10*b09-a12*b06)*det;out[13]=(a00*b09-a01*b07+a02*b06)*det;out[14]=(a31*b01-a30*b03-a32*b00)*det;out[15]=(a20*b03-a21*b01+a22*b00)*det;return out}},{}],27:[function(require,module,exports){module.exports=multiply;function multiply(out,a,b){var a00=a[0],a01=a[1],a02=a[2],a03=a[3],a10=a[4],a11=a[5],a12=a[6],a13=a[7],a20=a[8],a21=a[9],a22=a[10],a23=a[11],a30=a[12],a31=a[13],a32=a[14],a33=a[15];var b0=b[0],b1=b[1],b2=b[2],b3=b[3];out[0]=b0*a00+b1*a10+b2*a20+b3*a30;out[1]=b0*a01+b1*a11+b2*a21+b3*a31;out[2]=b0*a02+b1*a12+b2*a22+b3*a32;out[3]=b0*a03+b1*a13+b2*a23+b3*a33;b0=b[4];b1=b[5];b2=b[6];b3=b[7];out[4]=b0*a00+b1*a10+b2*a20+b3*a30;out[5]=b0*a01+b1*a11+b2*a21+b3*a31;out[6]=b0*a02+b1*a12+b2*a22+b3*a32;out[7]=b0*a03+b1*a13+b2*a23+b3*a33;b0=b[8];b1=b[9];b2=b[10];b3=b[11];out[8]=b0*a00+b1*a10+b2*a20+b3*a30;out[9]=b0*a01+b1*a11+b2*a21+b3*a31;out[10]=b0*a02+b1*a12+b2*a22+b3*a32;out[11]=b0*a03+b1*a13+b2*a23+b3*a33;b0=b[12];b1=b[13];b2=b[14];b3=b[15];out[12]=b0*a00+b1*a10+b2*a20+b3*a30;out[13]=b0*a01+b1*a11+b2*a21+b3*a31;out[14]=b0*a02+b1*a12+b2*a22+b3*a32;out[15]=b0*a03+b1*a13+b2*a23+b3*a33;return out}},{}],28:[function(require,module,exports){"use strict";var createUniformWrapper=require("./lib/create-uniforms");var createAttributeWrapper=require("./lib/create-attributes");var makeReflect=require("./lib/reflect");var shaderCache=require("./lib/shader-cache");var runtime=require("./lib/runtime-reflect");function Shader(gl){this.gl=gl;this._vref=this._fref=this._relink=this.vertShader=this.fragShader=this.program=this.attributes=this.uniforms=this.types=null}var proto=Shader.prototype;proto.bind=function(){if(!this.program){this._relink()}this.gl.useProgram(this.program)};proto.dispose=function(){if(this._fref){this._fref.dispose()}if(this._vref){this._vref.dispose()}this.attributes=this.types=this.vertShader=this.fragShader=this.program=this._relink=this._fref=this._vref=null};function compareAttributes(a,b){if(a.name<b.name){return-1}return 1}proto.update=function(vertSource,fragSource,uniforms,attributes){if(!fragSource||arguments.length===1){var obj=vertSource;vertSource=obj.vertex;fragSource=obj.fragment;uniforms=obj.uniforms;attributes=obj.attributes}var wrapper=this;var gl=wrapper.gl;var pvref=wrapper._vref;wrapper._vref=shaderCache.shader(gl,gl.VERTEX_SHADER,vertSource);if(pvref){pvref.dispose()}wrapper.vertShader=wrapper._vref.shader;var pfref=this._fref;wrapper._fref=shaderCache.shader(gl,gl.FRAGMENT_SHADER,fragSource);if(pfref){pfref.dispose()}wrapper.fragShader=wrapper._fref.shader;if(!uniforms||!attributes){var testProgram=gl.createProgram();gl.attachShader(testProgram,wrapper.fragShader);gl.attachShader(testProgram,wrapper.vertShader);gl.linkProgram(testProgram);if(!gl.getProgramParameter(testProgram,gl.LINK_STATUS)){var errLog=gl.getProgramInfoLog(testProgram);console.error("gl-shader: Error linking program:",errLog);throw new Error("gl-shader: Error linking program:"+errLog)}uniforms=uniforms||runtime.uniforms(gl,testProgram);attributes=attributes||runtime.attributes(gl,testProgram);gl.deleteProgram(testProgram)}attributes=attributes.slice();attributes.sort(compareAttributes);var attributeUnpacked=[];var attributeNames=[];var attributeLocations=[];for(var i=0;i<attributes.length;++i){var attr=attributes[i];if(attr.type.indexOf("mat")>=0){var size=attr.type.charAt(attr.type.length-1)|0;var locVector=new Array(size);for(var j=0;j<size;++j){locVector[j]=attributeLocations.length;attributeNames.push(attr.name+"["+j+"]");if(typeof attr.location==="number"){attributeLocations.push(attr.location+j)}else if(Array.isArray(attr.location)&&attr.location.length===size&&typeof attr.location[j]==="number"){attributeLocations.push(attr.location[j]|0)}else{attributeLocations.push(-1)}}attributeUnpacked.push({name:attr.name,type:attr.type,locations:locVector})}else{attributeUnpacked.push({name:attr.name,type:attr.type,locations:[attributeLocations.length]});attributeNames.push(attr.name);if(typeof attr.location==="number"){attributeLocations.push(attr.location|0)}else{attributeLocations.push(-1)}}}var curLocation=0;for(var i=0;i<attributeLocations.length;++i){if(attributeLocations[i]<0){while(attributeLocations.indexOf(curLocation)>=0){curLocation+=1}attributeLocations[i]=curLocation}}var uniformLocations=new Array(uniforms.length);function relink(){wrapper.program=shaderCache.program(gl,wrapper._vref,wrapper._fref,attributeNames,attributeLocations);for(var i=0;i<uniforms.length;++i){uniformLocations[i]=gl.getUniformLocation(wrapper.program,uniforms[i].name)}}relink();wrapper._relink=relink;wrapper.types={uniforms:makeReflect(uniforms),attributes:makeReflect(attributes)};wrapper.attributes=createAttributeWrapper(gl,wrapper,attributeUnpacked,attributeLocations);Object.defineProperty(wrapper,"uniforms",createUniformWrapper(gl,wrapper,uniforms,uniformLocations))};function createShader(gl,vertSource,fragSource,uniforms,attributes){var shader=new Shader(gl);shader.update(vertSource,fragSource,uniforms,attributes);return shader}module.exports=createShader},{"./lib/create-attributes":29,"./lib/create-uniforms":30,"./lib/reflect":31,"./lib/runtime-reflect":32,"./lib/shader-cache":33}],29:[function(require,module,exports){"use strict";module.exports=createAttributeWrapper;function ShaderAttribute(gl,wrapper,index,locations,dimension,constFunc){this._gl=gl;this._wrapper=wrapper;this._index=index;this._locations=locations;this._dimension=dimension;this._constFunc=constFunc}var proto=ShaderAttribute.prototype;proto.pointer=function setAttribPointer(type,normalized,stride,offset){var self=this;var gl=self._gl;var location=self._locations[self._index];gl.vertexAttribPointer(location,self._dimension,type||gl.FLOAT,!!normalized,stride||0,offset||0); | |
gl.enableVertexAttribArray(location)};proto.set=function(x0,x1,x2,x3){return this._constFunc(this._locations[this._index],x0,x1,x2,x3)};Object.defineProperty(proto,"location",{get:function(){return this._locations[this._index]},set:function(v){if(v!==this._locations[this._index]){this._locations[this._index]=v|0;this._wrapper.program=null}return v|0}});function addVectorAttribute(gl,wrapper,index,locations,dimension,obj,name){var constFuncArgs=["gl","v"];var varNames=[];for(var i=0;i<dimension;++i){constFuncArgs.push("x"+i);varNames.push("x"+i)}constFuncArgs.push("if(x0.length===void 0){return gl.vertexAttrib"+dimension+"f(v,"+varNames.join()+")}else{return gl.vertexAttrib"+dimension+"fv(v,x0)}");var constFunc=Function.apply(null,constFuncArgs);var attr=new ShaderAttribute(gl,wrapper,index,locations,dimension,constFunc);Object.defineProperty(obj,name,{set:function(x){gl.disableVertexAttribArray(locations[index]);constFunc(gl,locations[index],x);return x},get:function(){return attr},enumerable:true})}function addMatrixAttribute(gl,wrapper,index,locations,dimension,obj,name){var parts=new Array(dimension);var attrs=new Array(dimension);for(var i=0;i<dimension;++i){addVectorAttribute(gl,wrapper,index[i],locations,dimension,parts,i);attrs[i]=parts[i]}Object.defineProperty(parts,"location",{set:function(v){if(Array.isArray){for(var i=0;i<dimension;++i){attrs[i].location=v[i]}}else{for(var i=0;i<dimension;++i){result[i]=attrs[i].location=v+i}}return v},get:function(){var result=new Array(dimension);for(var i=0;i<dimension;++i){result[i]=locations[index[i]]}return result},enumerable:true});parts.pointer=function(type,normalized,stride,offset){type=type||gl.FLOAT;normalized=!!normalized;stride=stride||dimension*dimension;offset=offset||0;for(var i=0;i<dimension;++i){var location=locations[index[i]];gl.vertexAttribPointer(location,dimension,type,normalized,stride,offset+i*dimension);gl.enableVertexAttribArray(location)}};var scratch=new Array(dimension);var vertexAttrib=gl["vertexAttrib"+dimension+"fv"];Object.defineProperty(obj,name,{set:function(x){for(var i=0;i<dimension;++i){var loc=locations[index[i]];gl.disableVertexAttribArray(loc);if(Array.isArray(x[0])){vertexAttrib.call(gl,loc,x[i])}else{for(var j=0;j<dimension;++j){scratch[j]=x[dimension*i+j]}vertexAttrib.call(gl,loc,scratch)}}return x},get:function(){return parts},enumerable:true})}function createAttributeWrapper(gl,wrapper,attributes,locations){var obj={};for(var i=0,n=attributes.length;i<n;++i){var a=attributes[i];var name=a.name;var type=a.type;var locs=a.locations;switch(type){case"bool":case"int":case"float":addVectorAttribute(gl,wrapper,locs[0],locations,1,obj,name);break;default:if(type.indexOf("vec")>=0){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type for attribute "+name+": "+type)}addVectorAttribute(gl,wrapper,locs[0],locations,d,obj,name)}else if(type.indexOf("mat")>=0){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type for attribute "+name+": "+type)}addMatrixAttribute(gl,wrapper,locs,locations,d,obj,name)}else{throw new Error("gl-shader: Unknown data type for attribute "+name+": "+type)}break}}return obj}},{}],30:[function(require,module,exports){"use strict";var coallesceUniforms=require("./reflect");module.exports=createUniformWrapper;function identity(x){var c=new Function("y","return function(){return y}");return c(x)}function makeVector(length,fill){var result=new Array(length);for(var i=0;i<length;++i){result[i]=fill}return result}function createUniformWrapper(gl,wrapper,uniforms,locations){function makeGetter(index){var proc=new Function("gl","wrapper","locations","return function(){return gl.getUniform(wrapper.program,locations["+index+"])}");return proc(gl,wrapper,locations)}function makePropSetter(path,index,type){switch(type){case"bool":case"int":case"sampler2D":case"samplerCube":return"gl.uniform1i(locations["+index+"],obj"+path+")";case"float":return"gl.uniform1f(locations["+index+"],obj"+path+")";default:var vidx=type.indexOf("vec");if(0<=vidx&&vidx<=1&&type.length===4+vidx){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type")}switch(type.charAt(0)){case"b":case"i":return"gl.uniform"+d+"iv(locations["+index+"],obj"+path+")";case"v":return"gl.uniform"+d+"fv(locations["+index+"],obj"+path+")";default:throw new Error("gl-shader: Unrecognized data type for vector "+name+": "+type)}}else if(type.indexOf("mat")===0&&type.length===4){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+type)}return"gl.uniformMatrix"+d+"fv(locations["+index+"],false,obj"+path+")"}else{throw new Error("gl-shader: Unknown uniform data type for "+name+": "+type)}break}}function enumerateIndices(prefix,type){if(typeof type!=="object"){return[[prefix,type]]}var indices=[];for(var id in type){var prop=type[id];var tprefix=prefix;if(parseInt(id)+""===id){tprefix+="["+id+"]"}else{tprefix+="."+id}if(typeof prop==="object"){indices.push.apply(indices,enumerateIndices(tprefix,prop))}else{indices.push([tprefix,prop])}}return indices}function makeSetter(type){var code=["return function updateProperty(obj){"];var indices=enumerateIndices("",type);for(var i=0;i<indices.length;++i){var item=indices[i];var path=item[0];var idx=item[1];if(locations[idx]){code.push(makePropSetter(path,idx,uniforms[idx].type))}}code.push("return obj}");var proc=new Function("gl","locations",code.join("\n"));return proc(gl,locations)}function defaultValue(type){switch(type){case"bool":return false;case"int":case"sampler2D":case"samplerCube":return 0;case"float":return 0;default:var vidx=type.indexOf("vec");if(0<=vidx&&vidx<=1&&type.length===4+vidx){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid data type")}if(type.charAt(0)==="b"){return makeVector(d,false)}return makeVector(d,0)}else if(type.indexOf("mat")===0&&type.length===4){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new Error("gl-shader: Invalid uniform dimension type for matrix "+name+": "+type)}return makeVector(d*d,0)}else{throw new Error("gl-shader: Unknown uniform data type for "+name+": "+type)}break}}function storeProperty(obj,prop,type){if(typeof type==="object"){var child=processObject(type);Object.defineProperty(obj,prop,{get:identity(child),set:makeSetter(type),enumerable:true,configurable:false})}else{if(locations[type]){Object.defineProperty(obj,prop,{get:makeGetter(type),set:makeSetter(type),enumerable:true,configurable:false})}else{obj[prop]=defaultValue(uniforms[type].type)}}}function processObject(obj){var result;if(Array.isArray(obj)){result=new Array(obj.length);for(var i=0;i<obj.length;++i){storeProperty(result,i,obj[i])}}else{result={};for(var id in obj){storeProperty(result,id,obj[id])}}return result}var coallesced=coallesceUniforms(uniforms,true);return{get:identity(processObject(coallesced)),set:makeSetter(coallesced),enumerable:true,configurable:true}}},{"./reflect":31}],31:[function(require,module,exports){"use strict";module.exports=makeReflectTypes;function makeReflectTypes(uniforms,useIndex){var obj={};for(var i=0;i<uniforms.length;++i){var n=uniforms[i].name;var parts=n.split(".");var o=obj;for(var j=0;j<parts.length;++j){var x=parts[j].split("[");if(x.length>1){if(!(x[0]in o)){o[x[0]]=[]}o=o[x[0]];for(var k=1;k<x.length;++k){var y=parseInt(x[k]);if(k<x.length-1||j<parts.length-1){if(!(y in o)){if(k<x.length-1){o[y]=[]}else{o[y]={}}}o=o[y]}else{if(useIndex){o[y]=i}else{o[y]=uniforms[i].type}}}}else if(j<parts.length-1){if(!(x[0]in o)){o[x[0]]={}}o=o[x[0]]}else{if(useIndex){o[x[0]]=i}else{o[x[0]]=uniforms[i].type}}}}return obj}},{}],32:[function(require,module,exports){"use strict";exports.uniforms=runtimeUniforms;exports.attributes=runtimeAttributes;var GL_TO_GLSL_TYPES={FLOAT:"float",FLOAT_VEC2:"vec2",FLOAT_VEC3:"vec3",FLOAT_VEC4:"vec4",INT:"int",INT_VEC2:"ivec2",INT_VEC3:"ivec3",INT_VEC4:"ivec4",BOOL:"bool",BOOL_VEC2:"bvec2",BOOL_VEC3:"bvec3",BOOL_VEC4:"bvec4",FLOAT_MAT2:"mat2",FLOAT_MAT3:"mat3",FLOAT_MAT4:"mat4",SAMPLER_2D:"sampler2D",SAMPLER_CUBE:"samplerCube"};var GL_TABLE=null;function getType(gl,type){if(!GL_TABLE){var typeNames=Object.keys(GL_TO_GLSL_TYPES);GL_TABLE={};for(var i=0;i<typeNames.length;++i){var tn=typeNames[i];GL_TABLE[gl[tn]]=GL_TO_GLSL_TYPES[tn]}}return GL_TABLE[type]}function runtimeUniforms(gl,program){var numUniforms=gl.getProgramParameter(program,gl.ACTIVE_UNIFORMS);var result=[];for(var i=0;i<numUniforms;++i){var info=gl.getActiveUniform(program,i);if(info){result.push({name:info.name,type:getType(gl,info.type)})}}return result}function runtimeAttributes(gl,program){var numAttributes=gl.getProgramParameter(program,gl.ACTIVE_ATTRIBUTES);var result=[];for(var i=0;i<numAttributes;++i){var info=gl.getActiveAttrib(program,i);if(info){result.push({name:info.name,type:getType(gl,info.type)})}}return result}},{}],33:[function(require,module,exports){"use strict";exports.shader=getShaderReference;exports.program=createProgram;var weakMap=typeof WeakMap==="undefined"?require("weakmap-shim"):WeakMap;var CACHE=new weakMap;var SHADER_COUNTER=0;function ShaderReference(id,src,type,shader,programs,count,cache){this.id=id;this.src=src;this.type=type;this.shader=shader;this.count=count;this.programs=[];this.cache=cache}ShaderReference.prototype.dispose=function(){if(--this.count===0){var cache=this.cache;var gl=cache.gl;var programs=this.programs;for(var i=0,n=programs.length;i<n;++i){var p=cache.programs[programs[i]];if(p){delete cache.programs[i];gl.deleteProgram(p)}}gl.deleteShader(this.shader);delete cache.shaders[this.type===gl.FRAGMENT_SHADER|0][this.src]}};function ContextCache(gl){this.gl=gl;this.shaders=[{},{}];this.programs={}}var proto=ContextCache.prototype;function compileShader(gl,type,src){var shader=gl.createShader(type);gl.shaderSource(shader,src);gl.compileShader(shader);if(!gl.getShaderParameter(shader,gl.COMPILE_STATUS)){var errLog=gl.getShaderInfoLog(shader);console.error("gl-shader: Error compiling shader:",errLog);throw new Error("gl-shader: Error compiling shader:"+errLog)}return shader}proto.getShaderReference=function(type,src){var gl=this.gl;var shaders=this.shaders[type===gl.FRAGMENT_SHADER|0];var shader=shaders[src];if(!shader){var shaderObj=compileShader(gl,type,src);shader=shaders[src]=new ShaderReference(SHADER_COUNTER++,src,type,shaderObj,[],1,this)}else{shader.count+=1}return shader};function linkProgram(gl,vshader,fshader,attribs,locations){var program=gl.createProgram();gl.attachShader(program,vshader);gl.attachShader(program,fshader);for(var i=0;i<attribs.length;++i){gl.bindAttribLocation(program,locations[i],attribs[i])}gl.linkProgram(program);if(!gl.getProgramParameter(program,gl.LINK_STATUS)){var errLog=gl.getProgramInfoLog(program);console.error("gl-shader: Error linking program:",errLog);throw new Error("gl-shader: Error linking program:"+errLog)}return program}proto.getProgram=function(vref,fref,attribs,locations){var token=[vref.id,fref.id,attribs.join(":"),locations.join(":")].join("@");var prog=this.programs[token];if(!prog){this.programs[token]=prog=linkProgram(this.gl,vref.shader,fref.shader,attribs,locations);vref.programs.push(token);fref.programs.push(token)}return prog};function getCache(gl){var ctxCache=CACHE.get(gl);if(!ctxCache){ctxCache=new ContextCache(gl);CACHE.set(gl,ctxCache)}return ctxCache}function getShaderReference(gl,type,src){return getCache(gl).getShaderReference(type,src)}function createProgram(gl,vref,fref,attribs,locations){return getCache(gl).getProgram(vref,fref,attribs,locations)}},{"weakmap-shim":36}],34:[function(require,module,exports){var hiddenStore=require("./hidden-store.js");module.exports=createStore;function createStore(){var key={};return function(obj){if((typeof obj!=="object"||obj===null)&&typeof obj!=="function"){throw new Error("Weakmap-shim: Key must be object")}var store=obj.valueOf(key);return store&&store.identity===key?store:hiddenStore(obj,key)}}},{"./hidden-store.js":35}],35:[function(require,module,exports){module.exports=hiddenStore;function hiddenStore(obj,key){var store={identity:key};var valueOf=obj.valueOf;Object.defineProperty(obj,"valueOf",{value:function(value){return value!==key?valueOf.apply(this,arguments):store},writable:true});return store}},{}],36:[function(require,module,exports){var createStore=require("./create-store.js");module.exports=weakMap;function weakMap(){var privates=createStore();return{get:function(key,fallback){var store=privates(key);return store.hasOwnProperty("value")?store.value:fallback},set:function(key,value){privates(key).value=value},has:function(key){return"value"in privates(key)},"delete":function(key){return delete privates(key).value}}}},{"./create-store.js":34}],37:[function(require,module,exports){arguments[4][19][0].apply(exports,arguments)},{"cwise-compiler":38,dup:19}],38:[function(require,module,exports){arguments[4][20][0].apply(exports,arguments)},{"./lib/thunk.js":40,dup:20}],39:[function(require,module,exports){arguments[4][21][0].apply(exports,arguments)},{dup:21,uniq:41}],40:[function(require,module,exports){arguments[4][22][0].apply(exports,arguments)},{"./compile.js":39,dup:22}],41:[function(require,module,exports){arguments[4][23][0].apply(exports,arguments)},{dup:23}],42:[function(require,module,exports){arguments[4][24][0].apply(exports,arguments)},{dup:24}],43:[function(require,module,exports){arguments[4][25][0].apply(exports,arguments)},{dup:25,"weak-map":42}],44:[function(require,module,exports){"use strict";var ndarray=require("ndarray");var ops=require("ndarray-ops");var pool=require("typedarray-pool");var webglew=require("webglew");module.exports=createTexture2D;var linearTypes=null;var filterTypes=null;var wrapTypes=null;function lazyInitLinearTypes(gl){linearTypes=[gl.LINEAR,gl.NEAREST_MIPMAP_LINEAR,gl.LINEAR_MIPMAP_NEAREST,gl.LINEAR_MIPMAP_NEAREST];filterTypes=[gl.NEAREST,gl.LINEAR,gl.NEAREST_MIPMAP_NEAREST,gl.NEAREST_MIPMAP_LINEAR,gl.LINEAR_MIPMAP_NEAREST,gl.LINEAR_MIPMAP_LINEAR];wrapTypes=[gl.REPEAT,gl.CLAMP_TO_EDGE,gl.MIRRORED_REPEAT]}var convertFloatToUint8=function(out,inp){ops.muls(out,inp,255)};function reshapeTexture(tex,w,h){var gl=tex.gl;var maxSize=gl.getParameter(gl.MAX_TEXTURE_SIZE);if(w<0||w>maxSize||h<0||h>maxSize){throw new Error("gl-texture2d: Invalid texture size")}tex._shape=[w,h];tex.bind();gl.texImage2D(gl.TEXTURE_2D,0,tex.format,w,h,0,tex.format,tex.type,null);tex._mipLevels=[0];return tex}function Texture2D(gl,handle,width,height,format,type){this.gl=gl;this.handle=handle;this.format=format;this.type=type;this._shape=[width,height];this._mipLevels=[0];this._magFilter=gl.NEAREST;this._minFilter=gl.NEAREST;this._wrapS=gl.CLAMP_TO_EDGE;this._wrapT=gl.CLAMP_TO_EDGE;this._anisoSamples=1;var parent=this;var wrapVector=[this._wrapS,this._wrapT];Object.defineProperties(wrapVector,[{get:function(){return parent._wrapS},set:function(v){return parent.wrapS=v}},{get:function(){return parent._wrapT},set:function(v){return parent.wrapT=v}}]);this._wrapVector=wrapVector;var shapeVector=[this._shape[0],this._shape[1]];Object.defineProperties(shapeVector,[{get:function(){return parent._shape[0]},set:function(v){return parent.width=v}},{get:function(){return parent._shape[1]},set:function(v){return parent.height=v}}]);this._shapeVector=shapeVector}var proto=Texture2D.prototype;Object.defineProperties(proto,{minFilter:{get:function(){return this._minFilter},set:function(v){this.bind();var gl=this.gl;if(this.type===gl.FLOAT&&linearTypes.indexOf(v)>=0){if(!webglew(gl).texture_float_linear){v=gl.NEAREST}}if(filterTypes.indexOf(v)<0){throw new Error("gl-texture2d: Unknown filter mode "+v)}gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,v);return this._minFilter=v}},magFilter:{get:function(){return this._magFilter},set:function(v){this.bind();var gl=this.gl;if(this.type===gl.FLOAT&&linearTypes.indexOf(v)>=0){if(!webglew(gl).texture_float_linear){v=gl.NEAREST}}if(filterTypes.indexOf(v)<0){throw new Error("gl-texture2d: Unknown filter mode "+v)}gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,v);return this._magFilter=v}},mipSamples:{get:function(){return this._anisoSamples},set:function(i){var psamples=this._anisoSamples;this._anisoSamples=Math.max(i,1)|0;if(psamples!==this._anisoSamples){var ext=webglew(this.gl).EXT_texture_filter_anisotropic;if(ext){this.gl.texParameterf(this.gl.TEXTURE_2D,ext.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples)}}return this._anisoSamples}},wrapS:{get:function(){return this._wrapS},set:function(v){this.bind();if(wrapTypes.indexOf(v)<0){throw new Error("gl-texture2d: Unknown wrap mode "+v)}this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,v);return this._wrapS=v}},wrapT:{get:function(){return this._wrapT},set:function(v){this.bind();if(wrapTypes.indexOf(v)<0){throw new Error("gl-texture2d: Unknown wrap mode "+v)}this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,v);return this._wrapT=v}},wrap:{get:function(){return this._wrapVector},set:function(v){if(!Array.isArray(v)){v=[v,v]}if(v.length!==2){throw new Error("gl-texture2d: Must specify wrap mode for rows and columns")}for(var i=0;i<2;++i){if(wrapTypes.indexOf(v[i])<0){throw new Error("gl-texture2d: Unknown wrap mode "+v)}}this._wrapS=v[0];this._wrapT=v[1];var gl=this.gl;this.bind();gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,this._wrapS);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,this._wrapT);return v}},shape:{get:function(){return this._shapeVector},set:function(x){if(!Array.isArray(x)){x=[x|0,x|0]}else{if(x.length!==2){throw new Error("gl-texture2d: Invalid texture shape")}}reshapeTexture(this,x[0]|0,x[1]|0);return[x[0]|0,x[1]|0]}},width:{get:function(){return this._shape[0]},set:function(w){w=w|0;reshapeTexture(this,w,this._shape[1]);return w}},height:{get:function(){return this._shape[1]},set:function(h){h=h|0;reshapeTexture(this,this._shape[0],h);return h}}});proto.bind=function(unit){var gl=this.gl;if(unit!==undefined){gl.activeTexture(gl.TEXTURE0+(unit|0))}gl.bindTexture(gl.TEXTURE_2D,this.handle);if(unit!==undefined){return unit|0}return gl.getParameter(gl.ACTIVE_TEXTURE)-gl.TEXTURE0};proto.dispose=function(){this.gl.deleteTexture(this.handle)};proto.generateMipmap=function(){this.bind();this.gl.generateMipmap(this.gl.TEXTURE_2D);var l=Math.min(this._shape[0],this._shape[1]);for(var i=0;l>0;++i,l>>>=1){if(this._mipLevels.indexOf(i)<0){this._mipLevels.push(i)}}};proto.setPixels=function(data,x_off,y_off,mip_level){var gl=this.gl;this.bind();if(Array.isArray(x_off)){mip_level=y_off;y_off=x_off[1]|0;x_off=x_off[0]|0}else{x_off=x_off||0;y_off=y_off||0}mip_level=mip_level||0;if(data instanceof HTMLCanvasElement||data instanceof ImageData||data instanceof HTMLImageElement||data instanceof HTMLVideoElement){var needsMip=this._mipLevels.indexOf(mip_level)<0;if(needsMip){gl.texImage2D(gl.TEXTURE_2D,0,this.format,this.format,this.type,data);this._mipLevels.push(mip_level)}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,this.format,this.type,data)}}else if(data.shape&&data.stride&&data.data){if(data.shape.length<2||x_off+data.shape[1]>this._shape[1]>>>mip_level||y_off+data.shape[0]>this._shape[0]>>>mip_level||x_off<0||y_off<0){throw new Error("gl-texture2d: Texture dimensions are out of bounds")}texSubImageArray(gl,x_off,y_off,mip_level,this.format,this.type,this._mipLevels,data)}else{throw new Error("gl-texture2d: Unsupported data type")}};function isPacked(shape,stride){if(shape.length===3){return stride[2]===1&&stride[1]===shape[0]*shape[2]&&stride[0]===shape[2]}return stride[0]===1&&stride[1]===shape[0]}function texSubImageArray(gl,x_off,y_off,mip_level,cformat,ctype,mipLevels,array){var dtype=array.dtype;var shape=array.shape.slice();if(shape.length<2||shape.length>3){throw new Error("gl-texture2d: Invalid ndarray, must be 2d or 3d")}var type=0,format=0;var packed=isPacked(shape,array.stride.slice());if(dtype==="float32"){type=gl.FLOAT}else if(dtype==="float64"){type=gl.FLOAT;packed=false;dtype="float32"}else if(dtype==="uint8"){type=gl.UNSIGNED_BYTE}else{type=gl.UNSIGNED_BYTE;packed=false;dtype="uint8"}var channels=1;if(shape.length===2){format=gl.LUMINANCE;shape=[shape[0],shape[1],1];array=ndarray(array.data,shape,[array.stride[0],array.stride[1],1],array.offset)}else if(shape.length===3){if(shape[2]===1){format=gl.ALPHA}else if(shape[2]===2){format=gl.LUMINANCE_ALPHA}else if(shape[2]===3){format=gl.RGB}else if(shape[2]===4){format=gl.RGBA}else{throw new Error("gl-texture2d: Invalid shape for pixel coords")}channels=shape[2]}else{throw new Error("gl-texture2d: Invalid shape for texture")}if((format===gl.LUMINANCE||format===gl.ALPHA)&&(cformat===gl.LUMINANCE||cformat===gl.ALPHA)){format=cformat}if(format!==cformat){throw new Error("gl-texture2d: Incompatible texture format for setPixels")}var size=array.size;var needsMip=mipLevels.indexOf(mip_level)<0;if(needsMip){mipLevels.push(mip_level)}if(type===ctype&&packed){if(array.offset===0&&array.data.length===size){if(needsMip){gl.texImage2D(gl.TEXTURE_2D,mip_level,cformat,shape[0],shape[1],0,cformat,ctype,array.data)}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,shape[0],shape[1],cformat,ctype,array.data)}}else{if(needsMip){gl.texImage2D(gl.TEXTURE_2D,mip_level,cformat,shape[0],shape[1],0,cformat,ctype,array.data.subarray(array.offset,array.offset+size))}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,shape[0],shape[1],cformat,ctype,array.data.subarray(array.offset,array.offset+size))}}}else{var pack_buffer;if(ctype===gl.FLOAT){pack_buffer=pool.mallocFloat32(size)}else{pack_buffer=pool.mallocUint8(size)}var pack_view=ndarray(pack_buffer,shape,[shape[2],shape[2]*shape[0],1]);if(type===gl.FLOAT&&ctype===gl.UNSIGNED_BYTE){convertFloatToUint8(pack_view,array)}else{ops.assign(pack_view,array)}if(needsMip){gl.texImage2D(gl.TEXTURE_2D,mip_level,cformat,shape[0],shape[1],0,cformat,ctype,pack_buffer.subarray(0,size))}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,shape[0],shape[1],cformat,ctype,pack_buffer.subarray(0,size))}if(ctype===gl.FLOAT){pool.freeFloat32(pack_buffer)}else{pool.freeUint8(pack_buffer)}}}function initTexture(gl){var tex=gl.createTexture();gl.bindTexture(gl.TEXTURE_2D,tex);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);return tex}function createTextureShape(gl,width,height,format,type){var maxTextureSize=gl.getParameter(gl.MAX_TEXTURE_SIZE);if(width<0||width>maxTextureSize||height<0||height>maxTextureSize){throw new Error("gl-texture2d: Invalid texture shape")}if(type===gl.FLOAT&&!webglew(gl).texture_float){throw new Error("gl-texture2d: Floating point textures not supported on this platform")}var tex=initTexture(gl);gl.texImage2D(gl.TEXTURE_2D,0,format,width,height,0,format,type,null);return new Texture2D(gl,tex,width,height,format,type)}function createTextureDOM(gl,element,format,type){var tex=initTexture(gl);gl.texImage2D(gl.TEXTURE_2D,0,format,format,type,element);return new Texture2D(gl,tex,element.width|0,element.height|0,format,type)}function createTextureArray(gl,array){var dtype=array.dtype;var shape=array.shape.slice();var maxSize=gl.getParameter(gl.MAX_TEXTURE_SIZE);if(shape[0]<0||shape[0]>maxSize||shape[1]<0||shape[1]>maxSize){throw new Error("gl-texture2d: Invalid texture size")}var packed=isPacked(shape,array.stride.slice());var type=0;if(dtype==="float32"){type=gl.FLOAT}else if(dtype==="float64"){type=gl.FLOAT;packed=false;dtype="float32"}else if(dtype==="uint8"){type=gl.UNSIGNED_BYTE}else{type=gl.UNSIGNED_BYTE;packed=false;dtype="uint8"}var format=0;if(shape.length===2){format=gl.LUMINANCE;shape=[shape[0],shape[1],1];array=ndarray(array.data,shape,[array.stride[0],array.stride[1],1],array.offset)}else if(shape.length===3){if(shape[2]===1){format=gl.ALPHA}else if(shape[2]===2){format=gl.LUMINANCE_ALPHA}else if(shape[2]===3){format=gl.RGB}else if(shape[2]===4){format=gl.RGBA}else{throw new Error("gl-texture2d: Invalid shape for pixel coords")}}else{throw new Error("gl-texture2d: Invalid shape for texture")}if(type===gl.FLOAT&&!webglew(gl).texture_float){type=gl.UNSIGNED_BYTE;packed=false}var buffer,buf_store;var size=array.size;if(!packed){var stride=[shape[2],shape[2]*shape[0],1];buf_store=pool.malloc(size,dtype);var buf_array=ndarray(buf_store,shape,stride,0);if((dtype==="float32"||dtype==="float64")&&type===gl.UNSIGNED_BYTE){convertFloatToUint8(buf_array,array)}else{ops.assign(buf_array,array)}buffer=buf_store.subarray(0,size)}else if(array.offset===0&&array.data.length===size){buffer=array.data}else{buffer=array.data.subarray(array.offset,array.offset+size)}var tex=initTexture(gl);gl.texImage2D(gl.TEXTURE_2D,0,format,shape[0],shape[1],0,format,type,buffer);if(!packed){pool.free(buf_store)}return new Texture2D(gl,tex,shape[0],shape[1],format,type)}function createTexture2D(gl){if(arguments.length<=1){throw new Error("gl-texture2d: Missing arguments for texture2d constructor")}if(!linearTypes){lazyInitLinearTypes(gl)}if(typeof arguments[1]==="number"){return createTextureShape(gl,arguments[1],arguments[2],arguments[3]||gl.RGBA,arguments[4]||gl.UNSIGNED_BYTE)}if(Array.isArray(arguments[1])){return createTextureShape(gl,arguments[1][0]|0,arguments[1][1]|0,arguments[2]||gl.RGBA,arguments[3]||gl.UNSIGNED_BYTE)}if(typeof arguments[1]==="object"){var obj=arguments[1];if(obj instanceof HTMLCanvasElement||obj instanceof HTMLImageElement||obj instanceof HTMLVideoElement||obj instanceof ImageData){return createTextureDOM(gl,obj,arguments[2]||gl.RGBA,arguments[3]||gl.UNSIGNED_BYTE)}else if(obj.shape&&obj.data&&obj.stride){return createTextureArray(gl,obj)}}throw new Error("gl-texture2d: Invalid arguments for texture2d constructor")}},{ndarray:53,"ndarray-ops":37,"typedarray-pool":92,webglew:43}],45:[function(require,module,exports){"use strict";function doBind(gl,elements,attributes){if(elements){elements.bind()}else{gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,null)}var nattribs=gl.getParameter(gl.MAX_VERTEX_ATTRIBS)|0;if(attributes){if(attributes.length>nattribs){throw new Error("gl-vao: Too many vertex attributes")}for(var i=0;i<attributes.length;++i){var attrib=attributes[i];if(attrib.buffer){var buffer=attrib.buffer;var size=attrib.size||4;var type=attrib.type||gl.FLOAT;var normalized=!!attrib.normalized;var stride=attrib.stride||0;var offset=attrib.offset||0;buffer.bind();gl.enableVertexAttribArray(i);gl.vertexAttribPointer(i,size,type,normalized,stride,offset)}else{if(typeof attrib==="number"){gl.vertexAttrib1f(i,attrib)}else if(attrib.length===1){gl.vertexAttrib1f(i,attrib[0])}else if(attrib.length===2){gl.vertexAttrib2f(i,attrib[0],attrib[1])}else if(attrib.length===3){gl.vertexAttrib3f(i,attrib[0],attrib[1],attrib[2])}else if(attrib.length===4){gl.vertexAttrib4f(i,attrib[0],attrib[1],attrib[2],attrib[3])}else{throw new Error("gl-vao: Invalid vertex attribute")}gl.disableVertexAttribArray(i)}}for(;i<nattribs;++i){gl.disableVertexAttribArray(i)}}else{gl.bindBuffer(gl.ARRAY_BUFFER,null);for(var i=0;i<nattribs;++i){gl.disableVertexAttribArray(i)}}}module.exports=doBind},{}],46:[function(require,module,exports){"use strict";var bindAttribs=require("./do-bind.js");function VAOEmulated(gl){this.gl=gl;this._elements=null;this._attributes=null;this._elementsType=gl.UNSIGNED_SHORT}VAOEmulated.prototype.bind=function(){bindAttribs(this.gl,this._elements,this._attributes)};VAOEmulated.prototype.update=function(attributes,elements,elementsType){this._elements=elements;this._attributes=attributes;this._elementsType=elementsType||this.gl.UNSIGNED_SHORT};VAOEmulated.prototype.dispose=function(){};VAOEmulated.prototype.unbind=function(){};VAOEmulated.prototype.draw=function(mode,count,offset){offset=offset||0;var gl=this.gl;if(this._elements){gl.drawElements(mode,count,this._elementsType,offset)}else{gl.drawArrays(mode,offset,count)}};function createVAOEmulated(gl){return new VAOEmulated(gl)}module.exports=createVAOEmulated},{"./do-bind.js":45}],47:[function(require,module,exports){"use strict";var bindAttribs=require("./do-bind.js");function VertexAttribute(location,dimension,a,b,c,d){this.location=location;this.dimension=dimension;this.a=a;this.b=b;this.c=c;this.d=d}VertexAttribute.prototype.bind=function(gl){switch(this.dimension){case 1:gl.vertexAttrib1f(this.location,this.a);break;case 2:gl.vertexAttrib2f(this.location,this.a,this.b);break;case 3:gl.vertexAttrib3f(this.location,this.a,this.b,this.c);break;case 4:gl.vertexAttrib4f(this.location,this.a,this.b,this.c,this.d);break}};function VAONative(gl,ext,handle){this.gl=gl;this._ext=ext;this.handle=handle;this._attribs=[];this._useElements=false;this._elementsType=gl.UNSIGNED_SHORT}VAONative.prototype.bind=function(){this._ext.bindVertexArrayOES(this.handle);for(var i=0;i<this._attribs.length;++i){this._attribs[i].bind(this.gl)}};VAONative.prototype.unbind=function(){this._ext.bindVertexArrayOES(null)};VAONative.prototype.dispose=function(){this._ext.deleteVertexArrayOES(this.handle)};VAONative.prototype.update=function(attributes,elements,elementsType){this.bind();bindAttribs(this.gl,elements,attributes);this.unbind();this._attribs.length=0;if(attributes)for(var i=0;i<attributes.length;++i){var a=attributes[i];if(typeof a==="number"){this._attribs.push(new VertexAttribute(i,1,a))}else if(Array.isArray(a)){this._attribs.push(new VertexAttribute(i,a.length,a[0],a[1],a[2],a[3]))}}this._useElements=!!elements;this._elementsType=elementsType||this.gl.UNSIGNED_SHORT};VAONative.prototype.draw=function(mode,count,offset){offset=offset||0;var gl=this.gl;if(this._useElements){gl.drawElements(mode,count,this._elementsType,offset)}else{gl.drawArrays(mode,offset,count)}};function createVAONative(gl,ext){return new VAONative(gl,ext,ext.createVertexArrayOES())}module.exports=createVAONative},{"./do-bind.js":45}],48:[function(require,module,exports){arguments[4][24][0].apply(exports,arguments)},{dup:24}],49:[function(require,module,exports){arguments[4][25][0].apply(exports,arguments)},{dup:25,"weak-map":48}],50:[function(require,module,exports){"use strict";var webglew=require("webglew");var createVAONative=require("./lib/vao-native.js");var createVAOEmulated=require("./lib/vao-emulated.js");function createVAO(gl,attributes,elements,elementsType){var ext=webglew(gl).OES_vertex_array_object;var vao;if(ext){vao=createVAONative(gl,ext)}else{vao=createVAOEmulated(gl)}vao.update(attributes,elements,elementsType);return vao}module.exports=createVAO},{"./lib/vao-emulated.js":46,"./lib/vao-native.js":47,webglew:49}],51:[function(require,module,exports){module.exports=noop;function noop(){throw new Error("You should bundle your code "+"using `glslify` as a transform.")}},{}],52:[function(require,module,exports){module.exports=programify;function programify(vertex,fragment,uniforms,attributes){return{vertex:vertex,fragment:fragment,uniforms:uniforms,attributes:attributes}}},{}],53:[function(require,module,exports){(function(Buffer){var iota=require("iota-array");var hasTypedArrays=typeof Float64Array!=="undefined";var hasBuffer=typeof Buffer!=="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){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){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'"];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);code.push("Object.defineProperty(proto,'size',{get:function "+className+"_size(){return "+indices.map(function(i){return"this.shape["+i+"]"}).join("*"),"}})");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})")}}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}")}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+"]}")}code.push("proto.index=function "+className+"_index(",args.join(),"){return "+index_str+"}");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)}");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)}");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)}");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)}");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)}");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)}");var procedure=new Function("CTOR_LIST","ORDER",code.join("\n"));return procedure(CACHED_CONSTRUCTORS[dtype],order)}function arrayDType(data){if(hasBuffer){if(Buffer.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}).call(this,require("buffer").Buffer)},{buffer:1,"iota-array":54}],54:[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},{}],55:[function(require,module,exports){var EPSILON=1e-6;exports.vertexNormals=function(faces,positions){var N=positions.length;var normals=new Array(N);for(var i=0;i<N;++i){normals[i]=[0,0,0]}for(var i=0;i<faces.length;++i){var f=faces[i];var p=0;var c=f[f.length-1];var n=f[0];for(var j=0;j<f.length;++j){p=c;c=n;n=f[(j+1)%f.length];var v0=positions[p];var v1=positions[c];var v2=positions[n];var d01=new Array(3);var m01=0;var d21=new Array(3);var m21=0;for(var k=0;k<3;++k){d01[k]=v0[k]-v1[k];m01+=d01[k]*d01[k];d21[k]=v2[k]-v1[k];m21+=d21[k]*d21[k]}if(m01*m21>EPSILON){var norm=normals[c];var w=1/Math.sqrt(m01*m21);for(var k=0;k<3;++k){var u=(k+1)%3;var v=(k+2)%3;norm[k]+=w*(d21[u]*d01[v]-d21[v]*d01[u])}}}}for(var i=0;i<N;++i){var norm=normals[i];var m=0;for(var k=0;k<3;++k){m+=norm[k]*norm[k]}if(m>EPSILON){var w=1/Math.sqrt(m);for(var k=0;k<3;++k){norm[k]*=w}}else{for(var k=0;k<3;++k){norm[k]=0}}}return normals};exports.faceNormals=function(faces,positions){var N=faces.length;var normals=new Array(N);for(var i=0;i<N;++i){var f=faces[i];var pos=new Array(3);for(var j=0;j<3;++j){pos[j]=positions[f[j]]}var d01=new Array(3);var d21=new Array(3);for(var j=0;j<3;++j){d01[j]=pos[1][j]-pos[0][j];d21[j]=pos[2][j]-pos[0][j]}var n=new Array(3);var l=0;for(var j=0;j<3;++j){var u=(j+1)%3;var v=(j+2)%3;n[j]=d01[u]*d21[v]-d01[v]*d21[u];l+=n[j]*n[j]}if(l>EPSILON){l=1/Math.sqrt(l)}else{l=0}for(var j=0;j<3;++j){n[j]*=l}normals[i]=n}return normals}},{}],56:[function(require,module,exports){"use strict";var diff=new Float64Array(4);var edge0=new Float64Array(4);var edge1=new Float64Array(4);function closestPoint2d(V0,V1,V2,point,result){if(diff.length<point.length){diff=new Float64Array(point.length);edge0=new Float64Array(point.length);edge1=new Float64Array(point.length)}for(var i=0;i<point.length;++i){diff[i]=V0[i]-point[i];edge0[i]=V1[i]-V0[i];edge1[i]=V2[i]-V0[i]}var a00=0,a01=0,a11=0,b0=0,b1=0,c=0;for(var i=0;i<point.length;++i){var e0=edge0[i],e1=edge1[i],d=diff[i];a00+=e0*e0;a01+=e0*e1;a11+=e1*e1;b0+=d*e0;b1+=d*e1;c+=d*d}var det=Math.abs(a00*a11-a01*a01);var s=a01*b1-a11*b0;var t=a01*b0-a00*b1;var sqrDistance;if(s+t<=det){if(s<0){if(t<0){if(b0<0){t=0;if(-b0>=a00){s=1;sqrDistance=a00+2*b0+c}else{s=-b0/a00;sqrDistance=b0*s+c}}else{s=0;if(b1>=0){t=0;sqrDistance=c}else if(-b1>=a11){t=1;sqrDistance=a11+2*b1+c}else{t=-b1/a11;sqrDistance=b1*t+c}}}else{s=0;if(b1>=0){t=0;sqrDistance=c}else if(-b1>=a11){t=1;sqrDistance=a11+2*b1+c}else{t=-b1/a11;sqrDistance=b1*t+c}}}else if(t<0){t=0;if(b0>=0){s=0;sqrDistance=c}else if(-b0>=a00){s=1;sqrDistance=a00+2*b0+c}else{s=-b0/a00;sqrDistance=b0*s+c}}else{var invDet=1/det;s*=invDet;t*=invDet;sqrDistance=s*(a00*s+a01*t+2*b0)+t*(a01*s+a11*t+2*b1)+c}}else{var tmp0,tmp1,numer,denom;if(s<0){tmp0=a01+b0;tmp1=a11+b1;if(tmp1>tmp0){numer=tmp1-tmp0;denom=a00-2*a01+a11;if(numer>=denom){s=1;t=0;sqrDistance=a00+2*b0+c}else{s=numer/denom;t=1-s;sqrDistance=s*(a00*s+a01*t+2*b0)+t*(a01*s+a11*t+2*b1)+c}}else{s=0;if(tmp1<=0){t=1;sqrDistance=a11+2*b1+c}else if(b1>=0){t=0;sqrDistance=c}else{t=-b1/a11;sqrDistance=b1*t+c}}}else if(t<0){tmp0=a01+b1;tmp1=a00+b0;if(tmp1>tmp0){numer=tmp1-tmp0;denom=a00-2*a01+a11;if(numer>=denom){t=1;s=0;sqrDistance=a11+2*b1+c}else{t=numer/denom;s=1-t;sqrDistance=s*(a00*s+a01*t+2*b0)+t*(a01*s+a11*t+2*b1)+c}}else{t=0;if(tmp1<=0){s=1;sqrDistance=a00+2*b0+c}else if(b0>=0){s=0;sqrDistance=c}else{s=-b0/a00;sqrDistance=b0*s+c}}}else{numer=a11+b1-a01-b0;if(numer<=0){s=0;t=1;sqrDistance=a11+2*b1+c}else{denom=a00-2*a01+a11;if(numer>=denom){s=1;t=0;sqrDistance=a00+2*b0+c}else{s=numer/denom;t=1-s;sqrDistance=s*(a00*s+a01*t+2*b0)+t*(a01*s+a11*t+2*b1)+c}}}}var u=1-s-t;for(var i=0;i<point.length;++i){result[i]=u*V0[i]+s*V1[i]+t*V2[i]}if(sqrDistance<0){return 0}return sqrDistance}module.exports=closestPoint2d},{}],57:[function(require,module,exports){"use strict";module.exports=extractContour;var ndarray=require("ndarray");var pool=require("typedarray-pool");var ndsort=require("ndarray-sort");var contourAlgorithm=require("./lib/codegen");function getDimension(cells){var numCells=cells.length;var d=0;for(var i=0;i<numCells;++i){d=Math.max(d,cells[i].length)|0}return d-1}function getSigns(values,level){var numVerts=values.length;var vertexSigns=pool.mallocUint8(numVerts);for(var i=0;i<numVerts;++i){vertexSigns[i]=values[i]<level|0}return vertexSigns}function getEdges(cells,d){var numCells=cells.length;var maxEdges=d*(d+1)/2*numCells|0;var edges=pool.mallocUint32(maxEdges*2);var ePtr=0;for(var i=0;i<numCells;++i){var c=cells[i];var d=c.length;for(var j=0;j<d;++j){for(var k=0;k<j;++k){var a=c[k];var b=c[j];edges[ePtr++]=Math.min(a,b)|0;edges[ePtr++]=Math.max(a,b)|0}}}var nedges=ePtr/2|0;ndsort(ndarray(edges,[nedges,2]));var ptr=2;for(var i=2;i<ePtr;i+=2){if(edges[i-2]===edges[i]&&edges[i-1]===edges[i+1]){continue}edges[ptr++]=edges[i];edges[ptr++]=edges[i+1]}return ndarray(edges,[ptr/2|0,2])}function getCrossingWeights(edges,values,signs,level){var edata=edges.data;var numEdges=edges.shape[0];var weights=pool.mallocDouble(numEdges);var ptr=0;for(var i=0;i<numEdges;++i){var a=edata[2*i];var b=edata[2*i+1];if(signs[a]===signs[b]){continue}var va=values[a];var vb=values[b];edata[2*ptr]=a;edata[2*ptr+1]=b;weights[ptr++]=(vb-level)/(vb-va)}edges.shape[0]=ptr;return ndarray(weights,[ptr])}function getCascade(edges,numVerts){var result=pool.mallocInt32(numVerts*2);var numEdges=edges.shape[0];var edata=edges.data;result[0]=0;var lastV=0;for(var i=0;i<numEdges;++i){var a=edata[2*i];if(a!==lastV){result[2*lastV+1]=i;while(++lastV<a){result[2*lastV]=i;result[2*lastV+1]=i}result[2*lastV]=i}}result[2*lastV+1]=numEdges;while(++lastV<numVerts){result[2*lastV]=result[2*lastV+1]=numEdges}return result}function unpackEdges(edges){var ne=edges.shape[0]|0;var edata=edges.data;var result=new Array(ne);for(var i=0;i<ne;++i){result[i]=[edata[2*i],edata[2*i+1]]}return result}function extractContour(cells,values,level,d){level=level||0;if(typeof d==="undefined"){d=getDimension(cells)}if(d<=1){return}var numCells=cells.length;if(numCells===0){return{cells:[],vertexIds:[],vertexWeights:[]}}var vertexSigns=getSigns(values,+level);var edges=getEdges(cells,d);var weights=getCrossingWeights(edges,values,vertexSigns,+level);var vcascade=getCascade(edges,values.length|0);var faces=contourAlgorithm(d)(cells,edges.data,vcascade,vertexSigns);var uedges=unpackEdges(edges);var uweights=[].slice.call(weights.data,0,weights.shape[0]);pool.free(vertexSigns);pool.free(edges.data);pool.free(weights.data);pool.free(vcascade);return{cells:faces,vertexIds:uedges,vertexWeights:uweights}}},{"./lib/codegen":58,ndarray:53,"ndarray-sort":89,"typedarray-pool":92}],58:[function(require,module,exports){"use strict";module.exports=getPolygonizer;var pool=require("typedarray-pool");var createMSTable=require("marching-simplex-table");var CACHE={};function createCellPolygonizer(d){var maxCellSize=0;var tables=new Array(d+1);tables[0]=[[]];for(var i=1;i<=d;++i){var tab=tables[i]=createMSTable(i);for(var j=0;j<tab.length;++j){maxCellSize=Math.max(maxCellSize,tab[i].length)}}var code=["function B(C,E,i,j){","var a=Math.min(i,j)|0,b=Math.max(i,j)|0,l=C[2*a],h=C[2*a+1];","while(l<h){","var m=(l+h)>>1,v=E[2*m+1];","if(v===b){return m}","if(b<v){h=m}else{l=m+1}","}","return l;","};","function getContour",d,"d(F,E,C,S){","var n=F.length,R=[];","for(var i=0;i<n;++i){var c=F[i],l=c.length;"];function generateCase(facets){if(facets.length<=0){return}code.push("R.push(");for(var i=0;i<facets.length;++i){var facet=facets[i];if(i>0){code.push(",")}code.push("[");for(var j=0;j<facet.length;++j){var f=facet[j];if(j>0){code.push(",")}code.push("B(C,E,c[",f[0],"],c[",f[1],"])")}code.push("]")}code.push(");")}for(var i=d+1;i>1;--i){if(i<d+1){code.push("else ")}code.push("if(l===",i,"){");var maskStr=[];for(var j=0;j<i;++j){maskStr.push("(S[c["+j+"]]<<"+j+")")}code.push("var M=",maskStr.join("+"),";if(M===0||M===",(1<<i)-1,"){continue}switch(M){");var tab=tables[i-1];for(var j=0;j<tab.length;++j){code.push("case ",j,":");generateCase(tab[j]);code.push("break;")}code.push("}}")}code.push("}return R;};return getContour",d,"d");var proc=new Function("pool",code.join(""));return proc(pool)}function getPolygonizer(d){var alg=CACHE[d];if(!alg){alg=CACHE[d]=createCellPolygonizer(d)}return alg}},{"marching-simplex-table":59,"typedarray-pool":92}],59:[function(require,module,exports){"use strict";module.exports=createTable;var chull=require("convex-hull");function constructVertex(d,a,b){var x=new Array(d);for(var i=0;i<d;++i){x[i]=0;if(i===a){x[i]+=.5}if(i===b){x[i]+=.5}}return x}function constructCell(dimension,mask){if(mask===0||mask===(1<<dimension+1)-1){return[]}var points=[];var index=[];for(var i=0;i<=dimension;++i){if(mask&1<<i){points.push(constructVertex(dimension,i-1,i-1));index.push(null);for(var j=0;j<=dimension;++j){if(~mask&1<<j){points.push(constructVertex(dimension,i-1,j-1));index.push([i,j])}}}}var hull=chull(points);var faces=[];i_loop:for(var i=0;i<hull.length;++i){var face=hull[i];var nface=[];for(var j=0;j<face.length;++j){if(!index[face[j]]){continue i_loop}nface.push(index[face[j]].slice())}faces.push(nface)}return faces}function createTable(dimension){var numCells=1<<dimension+1;var result=new Array(numCells);for(var i=0;i<numCells;++i){result[i]=constructCell(dimension,i)}return result}},{"convex-hull":60}],60:[function(require,module,exports){"use strict";var convexHull1d=require("./lib/ch1d");var convexHull2d=require("./lib/ch2d");var convexHullnd=require("./lib/chnd");module.exports=convexHull;function convexHull(points){var n=points.length;if(n===0){return[]}else if(n===1){return[[0]]}var d=points[0].length;if(d===0){return[]}else if(d===1){return convexHull1d(points)}else if(d===2){return convexHull2d(points)}return convexHullnd(points,d)}},{"./lib/ch1d":61,"./lib/ch2d":62,"./lib/chnd":63}],61:[function(require,module,exports){"use strict";module.exports=convexHull1d;function convexHull1d(points){var lo=0;var hi=0;for(var i=1;i<points.length;++i){if(points[i][0]<points[lo][0]){lo=i}if(points[i][0]>points[hi][0]){hi=i}}if(lo<hi){return[[lo],[hi]]}else if(lo>hi){return[[hi],[lo]]}else{return[[lo]]}}},{}],62:[function(require,module,exports){"use strict";module.exports=convexHull2D;var monotoneHull=require("monotone-convex-hull-2d");function convexHull2D(points){var hull=monotoneHull(points);var h=hull.length;if(h<=2){return[]}var edges=new Array(h);var a=hull[h-1];for(var i=0;i<h;++i){var b=hull[i];edges[i]=[a,b];a=b}return edges}},{"monotone-convex-hull-2d":81}],63:[function(require,module,exports){"use strict";module.exports=convexHullnD;var ich=require("incremental-convex-hull");var aff=require("affine-hull");function permute(points,front){var n=points.length;var npoints=new Array(n);for(var i=0;i<front.length;++i){npoints[i]=points[front[i]]}var ptr=front.length;for(var i=0;i<n;++i){if(front.indexOf(i)<0){npoints[ptr++]=points[i]}}return npoints}function invPermute(cells,front){var nc=cells.length;var nf=front.length;for(var i=0;i<nc;++i){var c=cells[i];for(var j=0;j<c.length;++j){var x=c[j];if(x<nf){c[j]=front[x]}else{x=x-nf;for(var k=0;k<nf;++k){if(x>=front[k]){x+=1}}c[j]=x}}}return cells}function convexHullnD(points,d){try{return ich(points,true)}catch(e){var ah=aff(points);if(ah.length<=d){return[]}var npoints=permute(points,ah);var nhull=ich(npoints,true);return invPermute(nhull,ah)}}},{"affine-hull":64,"incremental-convex-hull":71}],64:[function(require,module,exports){"use strict";module.exports=affineHull;var orient=require("robust-orientation");function linearlyIndependent(points,d){var nhull=new Array(d+1);for(var i=0;i<points.length;++i){nhull[i]=points[i]}for(var i=0;i<=points.length;++i){for(var j=points.length;j<=d;++j){var x=new Array(d);for(var k=0;k<d;++k){x[k]=Math.pow(j+1-i,k)}nhull[j]=x}var o=orient.apply(void 0,nhull);if(o){return true}}return false}function affineHull(points){var n=points.length;if(n===0){return[]}if(n===1){return[0]}var d=points[0].length;var frame=[points[0]];var index=[0];for(var i=1;i<n;++i){frame.push(points[i]);if(!linearlyIndependent(frame,d)){frame.pop();continue}index.push(i);if(index.length===d+1){return index}}return index}},{"robust-orientation":70}],65:[function(require,module,exports){arguments[4][10][0].apply(exports,arguments)},{dup:10}],66:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{dup:11,"two-product":69,"two-sum":65}],67:[function(require,module,exports){"use strict";module.exports=robustSubtract;function scalarScalar(a,b){var x=a+b;var bv=x-a;var av=x-bv;var br=b-bv;var ar=a-av;var y=ar+br;if(y){return[y,x]}return[x]}function robustSubtract(e,f){var ne=e.length|0;var nf=f.length|0;if(ne===1&&nf===1){return scalarScalar(e[0],-f[0])}var n=ne+nf;var g=new Array(n);var count=0;var eptr=0;var fptr=0;var abs=Math.abs;var ei=e[eptr];var ea=abs(ei);var fi=-f[fptr];var fa=abs(fi);var a,b;if(ea<fa){b=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{b=fi;fptr+=1;if(fptr<nf){fi=-f[fptr];fa=abs(fi)}}if(eptr<ne&&ea<fa||fptr>=nf){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=-f[fptr];fa=abs(fi)}}var x=a+b;var bv=x-a;var y=b-bv;var q0=y;var q1=x;var _x,_bv,_av,_br,_ar;while(eptr<ne&&fptr<nf){if(ea<fa){a=ei;eptr+=1;if(eptr<ne){ei=e[eptr];ea=abs(ei)}}else{a=fi;fptr+=1;if(fptr<nf){fi=-f[fptr];fa=abs(fi)}}b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x}while(eptr<ne){a=ei;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;eptr+=1;if(eptr<ne){ei=e[eptr]}}while(fptr<nf){a=fi;b=q0;x=a+b;bv=x-a;y=b-bv;if(y){g[count++]=y}_x=q1+x;_bv=_x-q1;_av=_x-_bv;_br=x-_bv;_ar=q1-_av;q0=_ar+_br;q1=_x;fptr+=1;if(fptr<nf){fi=-f[fptr]}}if(q0){g[count++]=q0}if(q1){g[count++]=q1}if(!count){g[count++]=0}g.length=count;return g}},{}],68:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments)},{dup:12}],69:[function(require,module,exports){arguments[4][13][0].apply(exports,arguments)},{dup:13}],70:[function(require,module,exports){"use strict";var twoProduct=require("two-product");var robustSum=require("robust-sum");var robustScale=require("robust-scale");var robustSubtract=require("robust-subtract");var NUM_EXPAND=5;var EPSILON=1.1102230246251565e-16;var ERRBOUND3=(3+16*EPSILON)*EPSILON;var ERRBOUND4=(7+56*EPSILON)*EPSILON;function cofactor(m,c){var result=new Array(m.length-1);for(var i=1;i<m.length;++i){var r=result[i-1]=new Array(m.length-1);for(var j=0,k=0;j<m.length;++j){if(j===c){continue}r[k++]=m[i][j]}}return result}function matrix(n){var result=new Array(n);for(var i=0;i<n;++i){result[i]=new Array(n);for(var j=0;j<n;++j){result[i][j]=["m",j,"[",n-i-1,"]"].join("")}}return result}function sign(n){if(n&1){return"-"}return""}function generateSum(expr){if(expr.length===1){return expr[0]}else if(expr.length===2){return["sum(",expr[0],",",expr[1],")"].join("")}else{var m=expr.length>>1;return["sum(",generateSum(expr.slice(0,m)),",",generateSum(expr.slice(m)),")"].join("")}}function determinant(m){if(m.length===2){return[["sum(prod(",m[0][0],",",m[1][1],"),prod(-",m[0][1],",",m[1][0],"))"].join("")]}else{var expr=[];for(var i=0;i<m.length;++i){expr.push(["scale(",generateSum(determinant(cofactor(m,i))),",",sign(i),m[0][i],")"].join(""))}return expr}}function orientation(n){var pos=[];var neg=[];var m=matrix(n);var args=[];for(var i=0;i<n;++i){if((i&1)===0){pos.push.apply(pos,determinant(cofactor(m,i)))}else{neg.push.apply(neg,determinant(cofactor(m,i)))}args.push("m"+i)}var posExpr=generateSum(pos);var negExpr=generateSum(neg);var funcName="orientation"+n+"Exact";var code=["function ",funcName,"(",args.join(),"){var p=",posExpr,",n=",negExpr,",d=sub(p,n);return d[d.length-1];};return ",funcName].join("");var proc=new Function("sum","prod","scale","sub",code);return proc(robustSum,twoProduct,robustScale,robustSubtract)}var orientation3Exact=orientation(3);var orientation4Exact=orientation(4);var CACHED=[function orientation0(){return 0},function orientation1(){return 0},function orientation2(a,b){return b[0]-a[0]},function orientation3(a,b,c){var l=(a[1]-c[1])*(b[0]-c[0]);var r=(a[0]-c[0])*(b[1]-c[1]);var det=l-r;var s;if(l>0){if(r<=0){return det}else{s=l+r}}else if(l<0){if(r>=0){return det}else{s=-(l+r)}}else{return det}var tol=ERRBOUND3*s;if(det>=tol||det<=-tol){return det}return orientation3Exact(a,b,c)},function orientation4(a,b,c,d){var adx=a[0]-d[0];var bdx=b[0]-d[0];var cdx=c[0]-d[0];var ady=a[1]-d[1];var bdy=b[1]-d[1];var cdy=c[1]-d[1];var adz=a[2]-d[2];var bdz=b[2]-d[2];var cdz=c[2]-d[2];var bdxcdy=bdx*cdy;var cdxbdy=cdx*bdy;var cdxady=cdx*ady;var adxcdy=adx*cdy;var adxbdy=adx*bdy;var bdxady=bdx*ady;var det=adz*(bdxcdy-cdxbdy)+bdz*(cdxady-adxcdy)+cdz*(adxbdy-bdxady);var permanent=(Math.abs(bdxcdy)+Math.abs(cdxbdy))*Math.abs(adz)+(Math.abs(cdxady)+Math.abs(adxcdy))*Math.abs(bdz)+(Math.abs(adxbdy)+Math.abs(bdxady))*Math.abs(cdz);var tol=ERRBOUND4*permanent;if(det>tol||-det>tol){return det}return orientation4Exact(a,b,c,d)}];function slowOrient(args){var proc=CACHED[args.length];if(!proc){proc=CACHED[args.length]=orientation(args.length)}return proc.apply(undefined,args)}function generateOrientationProc(){while(CACHED.length<=NUM_EXPAND){CACHED.push(orientation(CACHED.length))}var args=[];var procArgs=["slow"];for(var i=0;i<=NUM_EXPAND;++i){args.push("a"+i);procArgs.push("o"+i)}var code=["function getOrientation(",args.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(var i=2;i<=NUM_EXPAND;++i){code.push("case ",i,":return o",i,"(",args.slice(0,i).join(),");")}code.push("}var s=new Array(arguments.length);for(var i=0;i<arguments.length;++i){s[i]=arguments[i]};return slow(s);}return getOrientation");procArgs.push(code.join(""));var proc=Function.apply(undefined,procArgs);module.exports=proc.apply(undefined,[slowOrient].concat(CACHED));for(var i=0;i<=NUM_EXPAND;++i){module.exports[i]=CACHED[i]}}generateOrientationProc()},{"robust-scale":66,"robust-subtract":67,"robust-sum":68,"two-product":69}],71:[function(require,module,exports){"use strict";module.exports=incrementalConvexHull;var orient=require("robust-orientation");var compareCell=require("simplicial-complex").compareCells;function compareInt(a,b){return a-b}function Simplex(vertices,adjacent,boundary){this.vertices=vertices;this.adjacent=adjacent;this.boundary=boundary;this.lastVisited=-1}Simplex.prototype.flip=function(){var t=this.vertices[0];this.vertices[0]=this.vertices[1];this.vertices[1]=t;var u=this.adjacent[0];this.adjacent[0]=this.adjacent[1];this.adjacent[1]=u};function GlueFacet(vertices,cell,index){this.vertices=vertices;this.cell=cell;this.index=index}function compareGlue(a,b){return compareCell(a.vertices,b.vertices)}function bakeOrient(d){var code=["function orient(){var tuple=this.tuple;return test("];for(var i=0;i<=d;++i){if(i>0){code.push(",")}code.push("tuple[",i,"]")}code.push(")}return orient");var proc=new Function("test",code.join(""));var test=orient[d+1];if(!test){test=orient}return proc(test)}var BAKED=[];function Triangulation(dimension,vertices,simplices){this.dimension=dimension;this.vertices=vertices;this.simplices=simplices;this.interior=simplices.filter(function(c){return!c.boundary});this.tuple=new Array(dimension+1);for(var i=0;i<=dimension;++i){this.tuple[i]=this.vertices[i]}var o=BAKED[dimension];if(!o){o=BAKED[dimension]=bakeOrient(dimension)}this.orient=o}var proto=Triangulation.prototype;proto.handleBoundaryDegeneracy=function(cell,point){var d=this.dimension;var n=this.vertices.length-1;var tuple=this.tuple;var verts=this.vertices;var toVisit=[cell];cell.lastVisited=-n;while(toVisit.length>0){cell=toVisit.pop();var cellVerts=cell.vertices;var cellAdj=cell.adjacent;for(var i=0;i<=d;++i){var neighbor=cellAdj[i];if(!neighbor.boundary||neighbor.lastVisited<=-n){continue}var nv=neighbor.vertices;for(var j=0;j<=d;++j){var vv=nv[j];if(vv<0){tuple[j]=point}else{tuple[j]=verts[vv]}}var o=this.orient();if(o>0){return neighbor}neighbor.lastVisited=-n;if(o===0){toVisit.push(neighbor)}}}return null};proto.walk=function(point,random){var n=this.vertices.length-1;var d=this.dimension;var verts=this.vertices;var tuple=this.tuple;var initIndex=random?this.interior.length*Math.random()|0:this.interior.length-1;var cell=this.interior[initIndex];outerLoop:while(!cell.boundary){var cellVerts=cell.vertices;var cellAdj=cell.adjacent;for(var i=0;i<=d;++i){tuple[i]=verts[cellVerts[i]]}cell.lastVisited=n;for(var i=0;i<=d;++i){var neighbor=cellAdj[i];if(neighbor.lastVisited>=n){continue}var prev=tuple[i];tuple[i]=point;var o=this.orient();tuple[i]=prev;if(o<0){cell=neighbor;continue outerLoop}else{if(!neighbor.boundary){neighbor.lastVisited=n}else{neighbor.lastVisited=-n}}}return}return cell};proto.addPeaks=function(point,cell){var n=this.vertices.length-1;var d=this.dimension;var verts=this.vertices;var tuple=this.tuple;var interior=this.interior;var simplices=this.simplices;var tovisit=[cell];cell.lastVisited=n;cell.vertices[cell.vertices.indexOf(-1)]=n;cell.boundary=false;interior.push(cell);var glueFacets=[];while(tovisit.length>0){var cell=tovisit.pop();var cellVerts=cell.vertices;var cellAdj=cell.adjacent;var indexOfN=cellVerts.indexOf(n);if(indexOfN<0){continue}for(var i=0;i<=d;++i){if(i===indexOfN){continue}var neighbor=cellAdj[i];if(!neighbor.boundary||neighbor.lastVisited>=n){continue}var nv=neighbor.vertices;if(neighbor.lastVisited!==-n){var indexOfNeg1=0;for(var j=0;j<=d;++j){if(nv[j]<0){indexOfNeg1=j;tuple[j]=point}else{tuple[j]=verts[nv[j]]}}var o=this.orient();if(o>0){nv[indexOfNeg1]=n;neighbor.boundary=false;interior.push(neighbor);tovisit.push(neighbor);neighbor.lastVisited=n;continue}else{neighbor.lastVisited=-n}}var na=neighbor.adjacent;var vverts=cellVerts.slice();var vadj=cellAdj.slice();var ncell=new Simplex(vverts,vadj,true);simplices.push(ncell);var opposite=na.indexOf(cell);if(opposite<0){continue}na[opposite]=ncell;vadj[indexOfN]=neighbor;vverts[i]=-1;vadj[i]=cell;cellAdj[i]=ncell;ncell.flip();for(var j=0;j<=d;++j){var uu=vverts[j];if(uu<0||uu===n){continue}var nface=new Array(d-1);var nptr=0;for(var k=0;k<=d;++k){var vv=vverts[k];if(vv<0||k===j){continue}nface[nptr++]=vv}glueFacets.push(new GlueFacet(nface,ncell,j))}}}glueFacets.sort(compareGlue);for(var i=0;i+1<glueFacets.length;i+=2){var a=glueFacets[i];var b=glueFacets[i+1];var ai=a.index;var bi=b.index;if(ai<0||bi<0){continue}a.cell.adjacent[a.index]=b.cell;b.cell.adjacent[b.index]=a.cell}};proto.insert=function(point,random){var verts=this.vertices;verts.push(point);var cell=this.walk(point,random);if(!cell){return}var d=this.dimension;var tuple=this.tuple;for(var i=0;i<=d;++i){var vv=cell.vertices[i];if(vv<0){tuple[i]=point}else{tuple[i]=verts[vv]}}var o=this.orient(tuple);if(o<0){return}else if(o===0){cell=this.handleBoundaryDegeneracy(cell,point);if(!cell){return}}this.addPeaks(point,cell)};proto.boundary=function(){var d=this.dimension;var boundary=[];var cells=this.simplices;var nc=cells.length;for(var i=0;i<nc;++i){var c=cells[i];if(c.boundary){var bcell=new Array(d);var cv=c.vertices;var ptr=0;var parity=0;for(var j=0;j<=d;++j){if(cv[j]>=0){bcell[ptr++]=cv[j]}else{parity=j&1}}if(parity===(d&1)){var t=bcell[0];bcell[0]=bcell[1];bcell[1]=t}boundary.push(bcell)}}return boundary};function incrementalConvexHull(points,randomSearch){var n=points.length;if(n===0){throw new Error("Must have at least d+1 points")}var d=points[0].length;if(n<=d){throw new Error("Must input at least d+1 points")}var initialSimplex=points.slice(0,d+1);var o=orient.apply(void 0,initialSimplex);if(o===0){throw new Error("Input not in general position")}var initialCoords=new Array(d+1);for(var i=0;i<=d;++i){initialCoords[i]=i}if(o<0){initialCoords[0]=1;initialCoords[1]=0}var initialCell=new Simplex(initialCoords,new Array(d+1),false);var boundary=initialCell.adjacent;var list=new Array(d+2);for(var i=0;i<=d;++i){var verts=initialCoords.slice();for(var j=0;j<=d;++j){if(j===i){verts[j]=-1}}var t=verts[0];verts[0]=verts[1];verts[1]=t;var cell=new Simplex(verts,new Array(d+1),true);boundary[i]=cell;list[i]=cell}list[d+1]=initialCell;for(var i=0;i<=d;++i){var verts=boundary[i].vertices;var adj=boundary[i].adjacent;for(var j=0;j<=d;++j){var v=verts[j];if(v<0){adj[j]=initialCell;continue}for(var k=0;k<=d;++k){if(boundary[k].vertices.indexOf(v)<0){adj[j]=boundary[k]}}}}var triangles=new Triangulation(d,initialSimplex,list);var useRandom=!!randomSearch;for(var i=d+1;i<n;++i){triangles.insert(points[i],useRandom)}return triangles.boundary()}},{"robust-orientation":77,"simplicial-complex":80}],72:[function(require,module,exports){arguments[4][10][0].apply(exports,arguments)},{dup:10}],73:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{dup:11,"two-product":76,"two-sum":72}],74:[function(require,module,exports){arguments[4][67][0].apply(exports,arguments)},{dup:67}],75:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments); | |
},{dup:12}],76:[function(require,module,exports){arguments[4][13][0].apply(exports,arguments)},{dup:13}],77:[function(require,module,exports){arguments[4][70][0].apply(exports,arguments)},{dup:70,"robust-scale":73,"robust-subtract":74,"robust-sum":75,"two-product":76}],78:[function(require,module,exports){"use strict";"use restrict";var INT_BITS=32;exports.INT_BITS=INT_BITS;exports.INT_MAX=2147483647;exports.INT_MIN=-1<<INT_BITS-1;exports.sign=function(v){return(v>0)-(v<0)};exports.abs=function(v){var mask=v>>INT_BITS-1;return(v^mask)-mask};exports.min=function(x,y){return y^(x^y)&-(x<y)};exports.max=function(x,y){return x^(x^y)&-(x<y)};exports.isPow2=function(v){return!(v&v-1)&&!!v};exports.log2=function(v){var r,shift;r=(v>65535)<<4;v>>>=r;shift=(v>255)<<3;v>>>=shift;r|=shift;shift=(v>15)<<2;v>>>=shift;r|=shift;shift=(v>3)<<1;v>>>=shift;r|=shift;return r|v>>1};exports.log10=function(v){return v>=1e9?9:v>=1e8?8:v>=1e7?7:v>=1e6?6:v>=1e5?5:v>=1e4?4:v>=1e3?3:v>=100?2:v>=10?1:0};exports.popCount=function(v){v=v-(v>>>1&1431655765);v=(v&858993459)+(v>>>2&858993459);return(v+(v>>>4)&252645135)*16843009>>>24};function countTrailingZeros(v){var c=32;v&=-v;if(v)c--;if(v&65535)c-=16;if(v&16711935)c-=8;if(v&252645135)c-=4;if(v&858993459)c-=2;if(v&1431655765)c-=1;return c}exports.countTrailingZeros=countTrailingZeros;exports.nextPow2=function(v){v+=v===0;--v;v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v+1};exports.prevPow2=function(v){v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v-(v>>>1)};exports.parity=function(v){v^=v>>>16;v^=v>>>8;v^=v>>>4;v&=15;return 27030>>>v&1};var REVERSE_TABLE=new Array(256);(function(tab){for(var i=0;i<256;++i){var v=i,r=i,s=7;for(v>>>=1;v;v>>>=1){r<<=1;r|=v&1;--s}tab[i]=r<<s&255}})(REVERSE_TABLE);exports.reverse=function(v){return REVERSE_TABLE[v&255]<<24|REVERSE_TABLE[v>>>8&255]<<16|REVERSE_TABLE[v>>>16&255]<<8|REVERSE_TABLE[v>>>24&255]};exports.interleave2=function(x,y){x&=65535;x=(x|x<<8)&16711935;x=(x|x<<4)&252645135;x=(x|x<<2)&858993459;x=(x|x<<1)&1431655765;y&=65535;y=(y|y<<8)&16711935;y=(y|y<<4)&252645135;y=(y|y<<2)&858993459;y=(y|y<<1)&1431655765;return x|y<<1};exports.deinterleave2=function(v,n){v=v>>>n&1431655765;v=(v|v>>>1)&858993459;v=(v|v>>>2)&252645135;v=(v|v>>>4)&16711935;v=(v|v>>>16)&65535;return v<<16>>16};exports.interleave3=function(x,y,z){x&=1023;x=(x|x<<16)&4278190335;x=(x|x<<8)&251719695;x=(x|x<<4)&3272356035;x=(x|x<<2)&1227133513;y&=1023;y=(y|y<<16)&4278190335;y=(y|y<<8)&251719695;y=(y|y<<4)&3272356035;y=(y|y<<2)&1227133513;x|=y<<1;z&=1023;z=(z|z<<16)&4278190335;z=(z|z<<8)&251719695;z=(z|z<<4)&3272356035;z=(z|z<<2)&1227133513;return x|z<<2};exports.deinterleave3=function(v,n){v=v>>>n&1227133513;v=(v|v>>>2)&3272356035;v=(v|v>>>4)&251719695;v=(v|v>>>8)&4278190335;v=(v|v>>>16)&1023;return v<<22>>22};exports.nextCombination=function(v){var t=v|v-1;return t+1|(~t&-~t)-1>>>countTrailingZeros(v)+1}},{}],79:[function(require,module,exports){"use strict";"use restrict";module.exports=UnionFind;function UnionFind(count){this.roots=new Array(count);this.ranks=new Array(count);for(var i=0;i<count;++i){this.roots[i]=i;this.ranks[i]=0}}var proto=UnionFind.prototype;Object.defineProperty(proto,"length",{get:function(){return this.roots.length}});proto.makeSet=function(){var n=this.roots.length;this.roots.push(n);this.ranks.push(0);return n};proto.find=function(x){var x0=x;var roots=this.roots;while(roots[x]!==x){x=roots[x]}while(roots[x0]!==x){var y=roots[x0];roots[x0]=x;x0=y}return x};proto.link=function(x,y){var xr=this.find(x),yr=this.find(y);if(xr===yr){return}var ranks=this.ranks,roots=this.roots,xd=ranks[xr],yd=ranks[yr];if(xd<yd){roots[xr]=yr}else if(yd<xd){roots[yr]=xr}else{roots[yr]=xr;++ranks[xr]}}},{}],80:[function(require,module,exports){"use strict";"use restrict";var bits=require("bit-twiddle"),UnionFind=require("union-find");function dimension(cells){var d=0,max=Math.max;for(var i=0,il=cells.length;i<il;++i){d=max(d,cells[i].length)}return d-1}exports.dimension=dimension;function countVertices(cells){var vc=-1,max=Math.max;for(var i=0,il=cells.length;i<il;++i){var c=cells[i];for(var j=0,jl=c.length;j<jl;++j){vc=max(vc,c[j])}}return vc+1}exports.countVertices=countVertices;function cloneCells(cells){var ncells=new Array(cells.length);for(var i=0,il=cells.length;i<il;++i){ncells[i]=cells[i].slice(0)}return ncells}exports.cloneCells=cloneCells;function compareCells(a,b){var n=a.length,t=a.length-b.length,min=Math.min;if(t){return t}switch(n){case 0:return 0;case 1:return a[0]-b[0];case 2:var d=a[0]+a[1]-b[0]-b[1];if(d){return d}return min(a[0],a[1])-min(b[0],b[1]);case 3:var l1=a[0]+a[1],m1=b[0]+b[1];d=l1+a[2]-(m1+b[2]);if(d){return d}var l0=min(a[0],a[1]),m0=min(b[0],b[1]),d=min(l0,a[2])-min(m0,b[2]);if(d){return d}return min(l0+a[2],l1)-min(m0+b[2],m1);default:var as=a.slice(0);as.sort();var bs=b.slice(0);bs.sort();for(var i=0;i<n;++i){t=as[i]-bs[i];if(t){return t}}return 0}}exports.compareCells=compareCells;function compareZipped(a,b){return compareCells(a[0],b[0])}function normalize(cells,attr){if(attr){var len=cells.length;var zipped=new Array(len);for(var i=0;i<len;++i){zipped[i]=[cells[i],attr[i]]}zipped.sort(compareZipped);for(var i=0;i<len;++i){cells[i]=zipped[i][0];attr[i]=zipped[i][1]}return cells}else{cells.sort(compareCells);return cells}}exports.normalize=normalize;function unique(cells){if(cells.length===0){return[]}var ptr=1,len=cells.length;for(var i=1;i<len;++i){var a=cells[i];if(compareCells(a,cells[i-1])){if(i===ptr){ptr++;continue}cells[ptr++]=a}}cells.length=ptr;return cells}exports.unique=unique;function findCell(cells,c){var lo=0,hi=cells.length-1,r=-1;while(lo<=hi){var mid=lo+hi>>1,s=compareCells(cells[mid],c);if(s<=0){if(s===0){r=mid}lo=mid+1}else if(s>0){hi=mid-1}}return r}exports.findCell=findCell;function incidence(from_cells,to_cells){var index=new Array(from_cells.length);for(var i=0,il=index.length;i<il;++i){index[i]=[]}var b=[];for(var i=0,n=to_cells.length;i<n;++i){var c=to_cells[i];var cl=c.length;for(var k=1,kn=1<<cl;k<kn;++k){b.length=bits.popCount(k);var l=0;for(var j=0;j<cl;++j){if(k&1<<j){b[l++]=c[j]}}var idx=findCell(from_cells,b);if(idx<0){continue}while(true){index[idx++].push(i);if(idx>=from_cells.length||compareCells(from_cells[idx],b)!==0){break}}}}return index}exports.incidence=incidence;function dual(cells,vertex_count){if(!vertex_count){return incidence(unique(skeleton(cells,0)),cells,0)}var res=new Array(vertex_count);for(var i=0;i<vertex_count;++i){res[i]=[]}for(var i=0,len=cells.length;i<len;++i){var c=cells[i];for(var j=0,cl=c.length;j<cl;++j){res[c[j]].push(i)}}return res}exports.dual=dual;function explode(cells){var result=[];for(var i=0,il=cells.length;i<il;++i){var c=cells[i],cl=c.length|0;for(var j=1,jl=1<<cl;j<jl;++j){var b=[];for(var k=0;k<cl;++k){if(j>>>k&1){b.push(c[k])}}result.push(b)}}return normalize(result)}exports.explode=explode;function skeleton(cells,n){if(n<0){return[]}var result=[],k0=(1<<n+1)-1;for(var i=0;i<cells.length;++i){var c=cells[i];for(var k=k0;k<1<<c.length;k=bits.nextCombination(k)){var b=new Array(n+1),l=0;for(var j=0;j<c.length;++j){if(k&1<<j){b[l++]=c[j]}}result.push(b)}}return normalize(result)}exports.skeleton=skeleton;function boundary(cells){var res=[];for(var i=0,il=cells.length;i<il;++i){var c=cells[i];for(var j=0,cl=c.length;j<cl;++j){var b=new Array(c.length-1);for(var k=0,l=0;k<cl;++k){if(k!==j){b[l++]=c[k]}}res.push(b)}}return normalize(res)}exports.boundary=boundary;function connectedComponents_dense(cells,vertex_count){var labels=new UnionFind(vertex_count);for(var i=0;i<cells.length;++i){var c=cells[i];for(var j=0;j<c.length;++j){for(var k=j+1;k<c.length;++k){labels.link(c[j],c[k])}}}var components=[],component_labels=labels.ranks;for(var i=0;i<component_labels.length;++i){component_labels[i]=-1}for(var i=0;i<cells.length;++i){var l=labels.find(cells[i][0]);if(component_labels[l]<0){component_labels[l]=components.length;components.push([cells[i].slice(0)])}else{components[component_labels[l]].push(cells[i].slice(0))}}return components}function connectedComponents_sparse(cells){var vertices=unique(normalize(skeleton(cells,0))),labels=new UnionFind(vertices.length);for(var i=0;i<cells.length;++i){var c=cells[i];for(var j=0;j<c.length;++j){var vj=findCell(vertices,[c[j]]);for(var k=j+1;k<c.length;++k){labels.link(vj,findCell(vertices,[c[k]]))}}}var components=[],component_labels=labels.ranks;for(var i=0;i<component_labels.length;++i){component_labels[i]=-1}for(var i=0;i<cells.length;++i){var l=labels.find(findCell(vertices,[cells[i][0]]));if(component_labels[l]<0){component_labels[l]=components.length;components.push([cells[i].slice(0)])}else{components[component_labels[l]].push(cells[i].slice(0))}}return components}function connectedComponents(cells,vertex_count){if(vertex_count){return connectedComponents_dense(cells,vertex_count)}return connectedComponents_sparse(cells)}exports.connectedComponents=connectedComponents},{"bit-twiddle":78,"union-find":79}],81:[function(require,module,exports){"use strict";module.exports=monotoneConvexHull2D;var orient=require("robust-orientation")[3];function monotoneConvexHull2D(points){var n=points.length;if(n<3){var result=new Array(n);for(var i=0;i<n;++i){result[i]=i}if(n===2&&points[0][0]===points[1][0]&&points[0][1]===points[1][1]){return[0]}return result}var sorted=new Array(n);for(var i=0;i<n;++i){sorted[i]=i}sorted.sort(function(a,b){var d=points[a][0]-points[b][0];if(d){return d}return points[a][1]-points[b][1]});var lower=[sorted[0],sorted[1]];var upper=[sorted[0],sorted[1]];for(var i=2;i<n;++i){var idx=sorted[i];var p=points[idx];var m=lower.length;while(m>1&&orient(points[lower[m-2]],points[lower[m-1]],p)<=0){m-=1;lower.pop()}lower.push(idx);m=upper.length;while(m>1&&orient(points[upper[m-2]],points[upper[m-1]],p)>=0){m-=1;upper.pop()}upper.push(idx)}var result=new Array(upper.length+lower.length-2);var ptr=0;for(var i=0,nl=lower.length;i<nl;++i){result[ptr++]=lower[i]}for(var j=upper.length-2;j>0;--j){result[ptr++]=upper[j]}return result}},{"robust-orientation":87}],82:[function(require,module,exports){arguments[4][10][0].apply(exports,arguments)},{dup:10}],83:[function(require,module,exports){arguments[4][11][0].apply(exports,arguments)},{dup:11,"two-product":86,"two-sum":82}],84:[function(require,module,exports){arguments[4][67][0].apply(exports,arguments)},{dup:67}],85:[function(require,module,exports){arguments[4][12][0].apply(exports,arguments)},{dup:12}],86:[function(require,module,exports){arguments[4][13][0].apply(exports,arguments)},{dup:13}],87:[function(require,module,exports){arguments[4][70][0].apply(exports,arguments)},{dup:70,"robust-scale":83,"robust-subtract":84,"robust-sum":85,"two-product":86}],88:[function(require,module,exports){"use strict";var pool=require("typedarray-pool");var INSERTION_SORT_THRESHOLD=32;function getMallocFree(dtype){switch(dtype){case"uint8":return[pool.mallocUint8,pool.freeUint8];case"uint16":return[pool.mallocUint16,pool.freeUint16];case"uint32":return[pool.mallocUint32,pool.freeUint32];case"int8":return[pool.mallocInt8,pool.freeInt8];case"int16":return[pool.mallocInt16,pool.freeInt16];case"int32":return[pool.mallocInt32,pool.freeInt32];case"float32":return[pool.mallocFloat,pool.freeFloat];case"float64":return[pool.mallocDouble,pool.freeDouble];default:return null}}function shapeArgs(dimension){var args=[];for(var i=0;i<dimension;++i){args.push("s"+i)}for(var i=0;i<dimension;++i){args.push("n"+i)}for(var i=1;i<dimension;++i){args.push("d"+i)}for(var i=1;i<dimension;++i){args.push("e"+i)}for(var i=1;i<dimension;++i){args.push("f"+i)}return args}function createInsertionSort(order,dtype){var code=["'use strict'"];var funcName=["ndarrayInsertionSort",order.join("d"),dtype].join("");var funcArgs=["left","right","data","offset"].concat(shapeArgs(order.length));var allocator=getMallocFree(dtype);var vars=["i,j,cptr,ptr=left*s0+offset"];if(order.length>1){var scratch_shape=[];for(var i=1;i<order.length;++i){vars.push("i"+i);scratch_shape.push("n"+i)}if(allocator){vars.push("scratch=malloc("+scratch_shape.join("*")+")")}else{vars.push("scratch=new Array("+scratch_shape.join("*")+")")}vars.push("dptr","sptr","a","b")}else{vars.push("scratch")}function dataRead(ptr){if(dtype==="generic"){return["data.get(",ptr,")"].join("")}return["data[",ptr,"]"].join("")}function dataWrite(ptr,v){if(dtype==="generic"){return["data.set(",ptr,",",v,")"].join("")}return["data[",ptr,"]=",v].join("")}code.push(["function ",funcName,"(",funcArgs.join(","),"){var ",vars.join(",")].join(""),"for(i=left+1;i<=right;++i){","j=i;ptr+=s0","cptr=ptr");if(order.length>1){code.push("dptr=0;sptr=ptr");for(var i=order.length-1;i>=0;--i){var j=order[i];if(j===0){continue}code.push(["for(i",j,"=0;i",j,"<n",j,";++i",j,"){"].join(""))}code.push("scratch[dptr++]=",dataRead("sptr"));for(var i=0;i<order.length;++i){var j=order[i];if(j===0){continue}code.push("sptr+=d"+j,"}")}code.push("__g:while(j-->left){","dptr=0","sptr=cptr-s0");for(var i=1;i<order.length;++i){if(i===1){code.push("__l:")}code.push(["for(i",i,"=0;i",i,"<n",i,";++i",i,"){"].join(""))}code.push(["a=",dataRead("sptr"),"\nb=scratch[dptr]\nif(a<b){break __g}\nif(a>b){break __l}"].join(""));for(var i=order.length-1;i>=1;--i){code.push("sptr+=e"+i,"dptr+=f"+i,"}")}code.push("dptr=cptr;sptr=cptr-s0");for(var i=order.length-1;i>=0;--i){var j=order[i];if(j===0){continue}code.push(["for(i",j,"=0;i",j,"<n",j,";++i",j,"){"].join(""))}code.push(dataWrite("dptr",dataRead("sptr")));for(var i=0;i<order.length;++i){var j=order[i];if(j===0){continue}code.push(["dptr+=d",j,";sptr+=d",j].join(""),"}")}code.push("cptr-=s0\n}");code.push("dptr=cptr;sptr=0");for(var i=order.length-1;i>=0;--i){var j=order[i];if(j===0){continue}code.push(["for(i",j,"=0;i",j,"<n",j,";++i",j,"){"].join(""))}code.push(dataWrite("dptr","scratch[sptr++]"));for(var i=0;i<order.length;++i){var j=order[i];if(j===0){continue}code.push("dptr+=d"+j,"}")}}else{code.push("scratch="+dataRead("ptr"),"while((j-->left)&&("+dataRead("cptr-s0")+">scratch)){",dataWrite("cptr",dataRead("cptr-s0")),"cptr-=s0","}",dataWrite("cptr","scratch"))}code.push("}");if(order.length>1&&allocator){code.push("free(scratch)")}code.push("} return "+funcName);if(allocator){var result=new Function("malloc","free",code.join("\n"));return result(allocator[0],allocator[1])}else{var result=new Function(code.join("\n"));return result()}}function createQuickSort(order,dtype,insertionSort){var code=["'use strict'"];var funcName=["ndarrayQuickSort",order.join("d"),dtype].join("");var funcArgs=["left","right","data","offset"].concat(shapeArgs(order.length));var allocator=getMallocFree(dtype);var labelCounter=0;code.push(["function ",funcName,"(",funcArgs.join(","),"){"].join(""));var vars=["sixth=((right-left+1)/6)|0","index1=left+sixth","index5=right-sixth","index3=(left+right)>>1","index2=index3-sixth","index4=index3+sixth","el1=index1","el2=index2","el3=index3","el4=index4","el5=index5","less=left+1","great=right-1","pivots_are_equal=true","tmp","tmp0","x","y","z","k","ptr0","ptr1","ptr2","comp_pivot1","comp_pivot2","comp"];if(order.length>1){var ele_size=[];for(var i=1;i<order.length;++i){ele_size.push("n"+i);vars.push("i"+i)}for(var i=0;i<8;++i){vars.push("b_ptr"+i)}vars.push("ptr3","ptr4","ptr5","ptr6","ptr7","pivot_ptr","ptr_shift","elementSize="+ele_size.join("*"));if(allocator){vars.push("pivot1=malloc(elementSize)","pivot2=malloc(elementSize)")}else{vars.push("pivot1=new Array(elementSize),pivot2=new Array(elementSize)")}}else{vars.push("pivot1","pivot2")}code.push("var "+vars.join(","));function toPointer(v){return["(offset+",v,"*s0)"].join("")}function dataRead(ptr){if(dtype==="generic"){return["data.get(",ptr,")"].join("")}return["data[",ptr,"]"].join("")}function dataWrite(ptr,v){if(dtype==="generic"){return["data.set(",ptr,",",v,")"].join("")}return["data[",ptr,"]=",v].join("")}function cacheLoop(ptrs,usePivot,body){if(ptrs.length===1){code.push("ptr0="+toPointer(ptrs[0]))}else{for(var i=0;i<ptrs.length;++i){code.push(["b_ptr",i,"=s0*",ptrs[i]].join(""))}}if(usePivot){code.push("pivot_ptr=0")}code.push("ptr_shift=offset");for(var i=order.length-1;i>=0;--i){var j=order[i];if(j===0){continue}code.push(["for(i",j,"=0;i",j,"<n",j,";++i",j,"){"].join(""))}if(ptrs.length>1){for(var i=0;i<ptrs.length;++i){code.push(["ptr",i,"=b_ptr",i,"+ptr_shift"].join(""))}}code.push(body);if(usePivot){code.push("++pivot_ptr")}for(var i=0;i<order.length;++i){var j=order[i];if(j===0){continue}if(ptrs.length>1){code.push("ptr_shift+=d"+j)}else{code.push("ptr0+=d"+j)}code.push("}")}}function lexicoLoop(label,ptrs,usePivot,body){if(ptrs.length===1){code.push("ptr0="+toPointer(ptrs[0]))}else{for(var i=0;i<ptrs.length;++i){code.push(["b_ptr",i,"=s0*",ptrs[i]].join(""))}code.push("ptr_shift=offset")}if(usePivot){code.push("pivot_ptr=0")}if(label){code.push(label+":")}for(var i=1;i<order.length;++i){code.push(["for(i",i,"=0;i",i,"<n",i,";++i",i,"){"].join(""))}if(ptrs.length>1){for(var i=0;i<ptrs.length;++i){code.push(["ptr",i,"=b_ptr",i,"+ptr_shift"].join(""))}}code.push(body);for(var i=order.length-1;i>=1;--i){if(usePivot){code.push("pivot_ptr+=f"+i)}if(ptrs.length>1){code.push("ptr_shift+=e"+i)}else{code.push("ptr0+=e"+i)}code.push("}")}}function cleanUp(){if(order.length>1&&allocator){code.push("free(pivot1)","free(pivot2)")}}function compareSwap(a_id,b_id){var a="el"+a_id;var b="el"+b_id;if(order.length>1){var lbl="__l"+ ++labelCounter;lexicoLoop(lbl,[a,b],false,["comp=",dataRead("ptr0"),"-",dataRead("ptr1"),"\n","if(comp>0){tmp0=",a,";",a,"=",b,";",b,"=tmp0;break ",lbl,"}\n","if(comp<0){break ",lbl,"}"].join(""))}else{code.push(["if(",dataRead(toPointer(a)),">",dataRead(toPointer(b)),"){tmp0=",a,";",a,"=",b,";",b,"=tmp0}"].join(""))}}compareSwap(1,2);compareSwap(4,5);compareSwap(1,3);compareSwap(2,3);compareSwap(1,4);compareSwap(3,4);compareSwap(2,5);compareSwap(2,3);compareSwap(4,5);if(order.length>1){cacheLoop(["el1","el2","el3","el4","el5","index1","index3","index5"],true,["pivot1[pivot_ptr]=",dataRead("ptr1"),"\n","pivot2[pivot_ptr]=",dataRead("ptr3"),"\n","pivots_are_equal=pivots_are_equal&&(pivot1[pivot_ptr]===pivot2[pivot_ptr])\n","x=",dataRead("ptr0"),"\n","y=",dataRead("ptr2"),"\n","z=",dataRead("ptr4"),"\n",dataWrite("ptr5","x"),"\n",dataWrite("ptr6","y"),"\n",dataWrite("ptr7","z")].join(""))}else{code.push(["pivot1=",dataRead(toPointer("el2")),"\n","pivot2=",dataRead(toPointer("el4")),"\n","pivots_are_equal=pivot1===pivot2\n","x=",dataRead(toPointer("el1")),"\n","y=",dataRead(toPointer("el3")),"\n","z=",dataRead(toPointer("el5")),"\n",dataWrite(toPointer("index1"),"x"),"\n",dataWrite(toPointer("index3"),"y"),"\n",dataWrite(toPointer("index5"),"z")].join(""))}function moveElement(dst,src){if(order.length>1){cacheLoop([dst,src],false,dataWrite("ptr0",dataRead("ptr1")))}else{code.push(dataWrite(toPointer(dst),dataRead(toPointer(src))))}}moveElement("index2","left");moveElement("index4","right");function comparePivot(result,ptr,n){if(order.length>1){var lbl="__l"+ ++labelCounter;lexicoLoop(lbl,[ptr],true,[result,"=",dataRead("ptr0"),"-pivot",n,"[pivot_ptr]\n","if(",result,"!==0){break ",lbl,"}"].join(""))}else{code.push([result,"=",dataRead(toPointer(ptr)),"-pivot",n].join(""))}}function swapElements(a,b){if(order.length>1){cacheLoop([a,b],false,["tmp=",dataRead("ptr0"),"\n",dataWrite("ptr0",dataRead("ptr1")),"\n",dataWrite("ptr1","tmp")].join(""))}else{code.push(["ptr0=",toPointer(a),"\n","ptr1=",toPointer(b),"\n","tmp=",dataRead("ptr0"),"\n",dataWrite("ptr0",dataRead("ptr1")),"\n",dataWrite("ptr1","tmp")].join(""))}}function tripleSwap(k,less,great){if(order.length>1){cacheLoop([k,less,great],false,["tmp=",dataRead("ptr0"),"\n",dataWrite("ptr0",dataRead("ptr1")),"\n",dataWrite("ptr1",dataRead("ptr2")),"\n",dataWrite("ptr2","tmp")].join(""));code.push("++"+less,"--"+great)}else{code.push(["ptr0=",toPointer(k),"\n","ptr1=",toPointer(less),"\n","ptr2=",toPointer(great),"\n","++",less,"\n","--",great,"\n","tmp=",dataRead("ptr0"),"\n",dataWrite("ptr0",dataRead("ptr1")),"\n",dataWrite("ptr1",dataRead("ptr2")),"\n",dataWrite("ptr2","tmp")].join(""))}}function swapAndDecrement(k,great){swapElements(k,great);code.push("--"+great)}code.push("if(pivots_are_equal){");code.push("for(k=less;k<=great;++k){");comparePivot("comp","k",1);code.push("if(comp===0){continue}");code.push("if(comp<0){");code.push("if(k!==less){");swapElements("k","less");code.push("}");code.push("++less");code.push("}else{");code.push("while(true){");comparePivot("comp","great",1);code.push("if(comp>0){");code.push("great--");code.push("}else if(comp<0){");tripleSwap("k","less","great");code.push("break");code.push("}else{");swapAndDecrement("k","great");code.push("break");code.push("}");code.push("}");code.push("}");code.push("}");code.push("}else{");code.push("for(k=less;k<=great;++k){");comparePivot("comp_pivot1","k",1);code.push("if(comp_pivot1<0){");code.push("if(k!==less){");swapElements("k","less");code.push("}");code.push("++less");code.push("}else{");comparePivot("comp_pivot2","k",2);code.push("if(comp_pivot2>0){");code.push("while(true){");comparePivot("comp","great",2);code.push("if(comp>0){");code.push("if(--great<k){break}");code.push("continue");code.push("}else{");comparePivot("comp","great",1);code.push("if(comp<0){");tripleSwap("k","less","great");code.push("}else{");swapAndDecrement("k","great");code.push("}");code.push("break");code.push("}");code.push("}");code.push("}");code.push("}");code.push("}");code.push("}");function storePivot(mem_dest,pivot_dest,pivot){if(order.length>1){cacheLoop([mem_dest,pivot_dest],true,[dataWrite("ptr0",dataRead("ptr1")),"\n",dataWrite("ptr1",["pivot",pivot,"[pivot_ptr]"].join(""))].join(""))}else{code.push(dataWrite(toPointer(mem_dest),dataRead(toPointer(pivot_dest))),dataWrite(toPointer(pivot_dest),"pivot"+pivot))}}storePivot("left","(less-1)",1);storePivot("right","(great+1)",2);function doSort(left,right){code.push(["if((",right,"-",left,")<=",INSERTION_SORT_THRESHOLD,"){\n","insertionSort(",left,",",right,",data,offset,",shapeArgs(order.length).join(","),")\n","}else{\n",funcName,"(",left,",",right,",data,offset,",shapeArgs(order.length).join(","),")\n","}"].join(""))}doSort("left","(less-2)");doSort("(great+2)","right");code.push("if(pivots_are_equal){");cleanUp();code.push("return");code.push("}");function walkPointer(ptr,pivot,body){if(order.length>1){code.push(["__l",++labelCounter,":while(true){"].join(""));cacheLoop([ptr],true,["if(",dataRead("ptr0"),"!==pivot",pivot,"[pivot_ptr]){break __l",labelCounter,"}"].join(""));code.push(body,"}")}else{code.push(["while(",dataRead(toPointer(ptr)),"===pivot",pivot,"){",body,"}"].join(""))}}code.push("if(less<index1&&great>index5){");walkPointer("less",1,"++less");walkPointer("great",2,"--great");code.push("for(k=less;k<=great;++k){");comparePivot("comp_pivot1","k",1);code.push("if(comp_pivot1===0){");code.push("if(k!==less){");swapElements("k","less");code.push("}");code.push("++less");code.push("}else{");comparePivot("comp_pivot2","k",2);code.push("if(comp_pivot2===0){");code.push("while(true){");comparePivot("comp","great",2);code.push("if(comp===0){");code.push("if(--great<k){break}");code.push("continue");code.push("}else{");comparePivot("comp","great",1);code.push("if(comp<0){");tripleSwap("k","less","great");code.push("}else{");swapAndDecrement("k","great");code.push("}");code.push("break");code.push("}");code.push("}");code.push("}");code.push("}");code.push("}");code.push("}");cleanUp();doSort("less","great");code.push("}return "+funcName);if(order.length>1&&allocator){var compiled=new Function("insertionSort","malloc","free",code.join("\n"));return compiled(insertionSort,allocator[0],allocator[1])}var compiled=new Function("insertionSort",code.join("\n"));return compiled(insertionSort)}function compileSort(order,dtype){var code=["'use strict'"];var funcName=["ndarraySortWrapper",order.join("d"),dtype].join("");var funcArgs=["array"];code.push(["function ",funcName,"(",funcArgs.join(","),"){"].join(""));var vars=["data=array.data,offset=array.offset|0,shape=array.shape,stride=array.stride"];for(var i=0;i<order.length;++i){vars.push(["s",i,"=stride[",i,"]|0,n",i,"=shape[",i,"]|0"].join(""))}var scratch_stride=new Array(order.length);var nprod=[];for(var i=0;i<order.length;++i){var k=order[i];if(k===0){continue}if(nprod.length===0){scratch_stride[k]="1"}else{scratch_stride[k]=nprod.join("*")}nprod.push("n"+k)}var p=-1,q=-1;for(var i=0;i<order.length;++i){var j=order[i];if(j!==0){if(p>0){vars.push(["d",j,"=s",j,"-d",p,"*n",p].join(""))}else{vars.push(["d",j,"=s",j].join(""))}p=j}var k=order.length-1-i;if(k!==0){if(q>0){vars.push(["e",k,"=s",k,"-e",q,"*n",q,",f",k,"=",scratch_stride[k],"-f",q,"*n",q].join(""))}else{vars.push(["e",k,"=s",k,",f",k,"=",scratch_stride[k]].join(""))}q=k}}code.push("var "+vars.join(","));var sortArgs=["0","n0-1","data","offset"].concat(shapeArgs(order.length));code.push(["if(n0<=",INSERTION_SORT_THRESHOLD,"){","insertionSort(",sortArgs.join(","),")}else{","quickSort(",sortArgs.join(","),")}"].join(""));code.push("}return "+funcName);var result=new Function("insertionSort","quickSort",code.join("\n"));var insertionSort=createInsertionSort(order,dtype);var quickSort=createQuickSort(order,dtype,insertionSort);return result(insertionSort,quickSort)}module.exports=compileSort},{"typedarray-pool":92}],89:[function(require,module,exports){"use strict";var compile=require("./lib/compile_sort.js");var CACHE={};function sort(array){var order=array.order;var dtype=array.dtype;var typeSig=[order,dtype];var typeName=typeSig.join(":");var compiled=CACHE[typeName];if(!compiled){CACHE[typeName]=compiled=compile(order,dtype)}compiled(array);return array}module.exports=sort},{"./lib/compile_sort.js":88}],90:[function(require,module,exports){arguments[4][78][0].apply(exports,arguments)},{dup:78}],91:[function(require,module,exports){"use strict";function dupe_array(count,value,i){var c=count[i]|0;if(c<=0){return[]}var result=new Array(c),j;if(i===count.length-1){for(j=0;j<c;++j){result[j]=value}}else{for(j=0;j<c;++j){result[j]=dupe_array(count,value,i+1)}}return result}function dupe_number(count,value){var result,i;result=new Array(count);for(i=0;i<count;++i){result[i]=value}return result}function dupe(count,value){if(typeof value==="undefined"){value=0}switch(typeof count){case"number":if(count>0){return dupe_number(count|0,value)}break;case"object":if(typeof count.length==="number"){return dupe_array(count,value,0)}break}return[]}module.exports=dupe},{}],92:[function(require,module,exports){(function(global,Buffer){"use strict";var bits=require("bit-twiddle");var dup=require("dup");if(!global.__TYPEDARRAY_POOL){global.__TYPEDARRAY_POOL={UINT8:dup([32,0]),UINT16:dup([32,0]),UINT32:dup([32,0]),INT8:dup([32,0]),INT16:dup([32,0]),INT32:dup([32,0]),FLOAT:dup([32,0]),DOUBLE:dup([32,0]),DATA:dup([32,0]),UINT8C:dup([32,0]),BUFFER:dup([32,0])}}var hasUint8C=typeof Uint8ClampedArray!=="undefined";var POOL=global.__TYPEDARRAY_POOL;if(!POOL.UINT8C){POOL.UINT8C=dup([32,0])}if(!POOL.BUFFER){POOL.BUFFER=dup([32,0])}var DATA=POOL.DATA,BUFFER=POOL.BUFFER;exports.free=function free(array){if(Buffer.isBuffer(array)){BUFFER[bits.log2(array.length)].push(array)}else{if(Object.prototype.toString.call(array)!=="[object ArrayBuffer]"){array=array.buffer}if(!array){return}var n=array.length||array.byteLength;var log_n=bits.log2(n)|0;DATA[log_n].push(array)}};function freeArrayBuffer(buffer){if(!buffer){return}var n=buffer.length||buffer.byteLength;var log_n=bits.log2(n);DATA[log_n].push(buffer)}function freeTypedArray(array){freeArrayBuffer(array.buffer)}exports.freeUint8=exports.freeUint16=exports.freeUint32=exports.freeInt8=exports.freeInt16=exports.freeInt32=exports.freeFloat32=exports.freeFloat=exports.freeFloat64=exports.freeDouble=exports.freeUint8Clamped=exports.freeDataView=freeTypedArray;exports.freeArrayBuffer=freeArrayBuffer;exports.freeBuffer=function freeBuffer(array){BUFFER[bits.log2(array.length)].push(array)};exports.malloc=function malloc(n,dtype){if(dtype===undefined||dtype==="arraybuffer"){return mallocArrayBuffer(n)}else{switch(dtype){case"uint8":return mallocUint8(n);case"uint16":return mallocUint16(n);case"uint32":return mallocUint32(n);case"int8":return mallocInt8(n);case"int16":return mallocInt16(n);case"int32":return mallocInt32(n);case"float":case"float32":return mallocFloat(n);case"double":case"float64":return mallocDouble(n);case"uint8_clamped":return mallocUint8Clamped(n);case"buffer":return mallocBuffer(n);case"data":case"dataview":return mallocDataView(n);default:return null}}return null};function mallocArrayBuffer(n){var n=bits.nextPow2(n);var log_n=bits.log2(n);var d=DATA[log_n];if(d.length>0){return d.pop()}return new ArrayBuffer(n)}exports.mallocArrayBuffer=mallocArrayBuffer;function mallocUint8(n){return new Uint8Array(mallocArrayBuffer(n),0,n)}exports.mallocUint8=mallocUint8;function mallocUint16(n){return new Uint16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocUint16=mallocUint16;function mallocUint32(n){return new Uint32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocUint32=mallocUint32;function mallocInt8(n){return new Int8Array(mallocArrayBuffer(n),0,n)}exports.mallocInt8=mallocInt8;function mallocInt16(n){return new Int16Array(mallocArrayBuffer(2*n),0,n)}exports.mallocInt16=mallocInt16;function mallocInt32(n){return new Int32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocInt32=mallocInt32;function mallocFloat(n){return new Float32Array(mallocArrayBuffer(4*n),0,n)}exports.mallocFloat32=exports.mallocFloat=mallocFloat;function mallocDouble(n){return new Float64Array(mallocArrayBuffer(8*n),0,n)}exports.mallocFloat64=exports.mallocDouble=mallocDouble;function mallocUint8Clamped(n){if(hasUint8C){return new Uint8ClampedArray(mallocArrayBuffer(n),0,n)}else{return mallocUint8(n)}}exports.mallocUint8Clamped=mallocUint8Clamped;function mallocDataView(n){return new DataView(mallocArrayBuffer(n),0,n)}exports.mallocDataView=mallocDataView;function mallocBuffer(n){n=bits.nextPow2(n);var log_n=bits.log2(n);var cache=BUFFER[log_n];if(cache.length>0){return cache.pop()}return new Buffer(n)}exports.mallocBuffer=mallocBuffer;exports.clearCache=function clearCache(){for(var i=0;i<32;++i){POOL.UINT8[i].length=0;POOL.UINT16[i].length=0;POOL.UINT32[i].length=0;POOL.INT8[i].length=0;POOL.INT16[i].length=0;POOL.INT32[i].length=0;POOL.FLOAT[i].length=0;POOL.DOUBLE[i].length=0;POOL.UINT8C[i].length=0;DATA[i].length=0;BUFFER[i].length=0}}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{},require("buffer").Buffer)},{"bit-twiddle":90,buffer:1,dup:91}],"gl-mesh3d":[function(require,module,exports){"use strict";var createBuffer=require("gl-buffer");var createVAO=require("gl-vao");var createTexture=require("gl-texture2d");var createShader=require("gl-shader");var normals=require("normals");var multiply=require("gl-mat4/multiply");var invert=require("gl-mat4/invert");var ndarray=require("ndarray");var colormap=require("colormap");var getContour=require("simplicial-complex-contour");var pool=require("typedarray-pool");var shaders=require("./lib/shaders");var closestPoint=require("./lib/closest-point");var meshShader=shaders.meshShader;var wireShader=shaders.wireShader;var pointShader=shaders.pointShader;var pickShader=shaders.pickShader;var pointPickShader=shaders.pointPickShader;var contourShader=shaders.contourShader;var identityMatrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function SimplicialMesh(gl,texture,triShader,lineShader,pointShader,pickShader,pointPickShader,contourShader,trianglePositions,triangleIds,triangleColors,triangleUVs,triangleNormals,triangleVAO,edgePositions,edgeIds,edgeColors,edgeUVs,edgeVAO,pointPositions,pointIds,pointColors,pointUVs,pointSizes,pointVAO,contourPositions,contourVAO){this.gl=gl;this.cells=[];this.positions=[];this.intensity=[];this.texture=texture;this.dirty=true;this.triShader=triShader;this.lineShader=lineShader;this.pointShader=pointShader;this.pickShader=pickShader; | |
this.pointPickShader=pointPickShader;this.contourShader=contourShader;this.trianglePositions=trianglePositions;this.triangleColors=triangleColors;this.triangleNormals=triangleNormals;this.triangleUVs=triangleUVs;this.triangleIds=triangleIds;this.triangleVAO=triangleVAO;this.triangleCount=0;this.lineWidth=1;this.edgePositions=edgePositions;this.edgeColors=edgeColors;this.edgeUVs=edgeUVs;this.edgeIds=edgeIds;this.edgeVAO=edgeVAO;this.edgeCount=0;this.pointPositions=pointPositions;this.pointColors=pointColors;this.pointUVs=pointUVs;this.pointSizes=pointSizes;this.pointIds=pointIds;this.pointVAO=pointVAO;this.pointCount=0;this.contourLineWidth=1;this.contourPositions=contourPositions;this.contourVAO=contourVAO;this.contourCount=0;this.contourColor=[0,0,0];this.contourEnable=true;this.pickId=1;this.bounds=[[Infinity,Infinity,Infinity],[-Infinity,-Infinity,-Infinity]];this.clipBounds=[[-Infinity,-Infinity,-Infinity],[Infinity,Infinity,Infinity]];this.lightPosition=[1e5,1e5,0];this.ambientLight=.8;this.diffuseLight=.8;this.specularLight=2;this.roughness=.5;this.fresnel=1.5;this.opacity=1;this._model=identityMatrix;this._view=identityMatrix;this._projection=identityMatrix;this._resolution=[1,1]}var proto=SimplicialMesh.prototype;proto.isOpaque=function(){return this.opacity>=1};proto.isTransparent=function(){return this.opacity<1};proto.pickSlots=1;proto.setPickBase=function(id){this.pickId=id};function genColormap(param){var colors=colormap({colormap:param,nshades:256,format:"rgba"});var result=new Uint8Array(256*4);for(var i=0;i<256;++i){var c=colors[i];for(var j=0;j<3;++j){result[4*i+j]=c[j]}result[4*i+3]=c[3]*255}return ndarray(result,[256,256,4],[4,0,1])}function unpackIntensity(cells,numVerts,cellIntensity){var result=new Array(numVerts);for(var i=0;i<numVerts;++i){result[i]=0}var numCells=cells.length;for(var i=0;i<numCells;++i){var c=cells[i];for(var j=0;j<c.length;++j){result[c[j]]=cellIntensity[i]}}return result}function takeZComponent(array){var n=array.length;var result=new Array(n);for(var i=0;i<n;++i){result[i]=array[i][2]}return result}proto.highlight=function(selection){if(!selection||!this.contourEnable){this.contourCount=0;return}var level=getContour(this.cells,this.intensity,selection.intensity);var cells=level.cells;var vertexIds=level.vertexIds;var vertexWeights=level.vertexWeights;var numCells=cells.length;var result=pool.mallocFloat32(2*3*numCells);var ptr=0;for(var i=0;i<numCells;++i){var c=cells[i];for(var j=0;j<2;++j){var v=c[0];if(c.length===2){v=c[j]}var a=vertexIds[v][0];var b=vertexIds[v][1];var w=vertexWeights[v];var wi=1-w;var pa=this.positions[a];var pb=this.positions[b];for(var k=0;k<3;++k){result[ptr++]=w*pa[k]+wi*pb[k]}}}this.contourCount=ptr/3|0;this.contourPositions.update(result.subarray(0,ptr));pool.free(result)};proto.update=function(params){params=params||{};var gl=this.gl;this.dirty=true;if("contourEnable"in params){this.contourEnable=params.contourEnable}if("contourColor"in params){this.contourColor=params.contourColor}if("lineWidth"in params){this.lineWidth=params.lineWidth}if("opacity"in params){this.opacity=params.opacity}if(params.texture){this.texture.dispose();this.texture=createTexture(gl,params.texture)}else if(params.colormap){this.texture.shape=[256,256];this.texture.minFilter=gl.LINEAR_MIPMAP_LINEAR;this.texture.magFilter=gl.LINEAR;this.texture.setPixels(genColormap(params.colormap));this.texture.generateMipmap()}var cells=params.cells;var positions=params.positions;if(!positions||!cells){return}var tPos=[];var tCol=[];var tNor=[];var tUVs=[];var tIds=[];var ePos=[];var eCol=[];var eUVs=[];var eIds=[];var pPos=[];var pCol=[];var pUVs=[];var pSiz=[];var pIds=[];this.cells=cells;this.positions=positions;var vertexNormals=params.vertexNormals;var cellNormals=params.cellNormals;if(params.useFacetNormals&&!cellNormals){cellNormals=normals.faceNormals(cells,positions)}if(!cellNormals&&!vertexNormals){vertexNormals=normals.vertexNormals(cells,positions)}var vertexColors=params.vertexColors;var cellColors=params.cellColors;var meshColor=params.meshColor||[1,1,1,1];var vertexUVs=params.vertexUVs;var vertexIntensity=params.vertexIntensity;var cellUVs=params.cellUVs;var cellIntensity=params.cellIntensity;var intensityLo=Infinity;var intensityHi=-Infinity;if(!vertexUVs&&!cellUVs){if(vertexIntensity){for(var i=0;i<vertexIntensity.length;++i){var f=vertexIntensity[i];intensityLo=Math.min(intensityLo,f);intensityHi=Math.max(intensityHi,f)}}else if(cellIntensity){for(var i=0;i<cellIntensity.length;++i){var f=cellIntensity[i];intensityLo=Math.min(intensityLo,f);intensityHi=Math.max(intensityHi,f)}}else{for(var i=0;i<positions.length;++i){var f=positions[i][2];intensityLo=Math.min(intensityLo,f);intensityHi=Math.max(intensityHi,f)}}}if(vertexIntensity){this.intensity=vertexIntensity}else if(cellIntensity){this.intensity=unpackIntensity(cells,positions.length,cellIntensity)}else{this.intensity=takeZComponent(positions)}var pointSizes=params.pointSizes;var meshPointSize=params.pointSize||1;this.bounds=[[Infinity,Infinity,Infinity],[-Infinity,-Infinity,-Infinity]];for(var i=0;i<positions.length;++i){var p=positions[i];for(var j=0;j<3;++j){if(isNaN(p[j])||!isFinite(p[j])){continue}this.bounds[0][j]=Math.min(this.bounds[0][j],p[j]);this.bounds[1][j]=Math.max(this.bounds[1][j],p[j])}}var triangleCount=0;var edgeCount=0;var pointCount=0;fill_loop:for(var i=0;i<cells.length;++i){var cell=cells[i];switch(cell.length){case 1:var v=cell[0];var p=positions[v];for(var j=0;j<3;++j){if(isNaN(p[j])||!isFinite(p[j])){continue fill_loop}}pPos.push(p[0],p[1],p[2]);var c;if(vertexColors){c=vertexColors[v]}else if(cellColors){c=cellColors[i]}else{c=meshColor}if(c.length===3){pCol.push(c[0],c[1],c[2],1)}else{pCol.push(c[0],c[1],c[2],c[3])}var uv;if(vertexUVs){uv=vertexUVs[v]}else if(vertexIntensity){uv=[(vertexIntensity[v]-intensityLo)/(intensityHi-intensityLo),0]}else if(cellUVs){uv=cellUVs[i]}else if(cellIntensity){uv=[(cellIntensity[i]-intensityLo)/(intensityHi-intensityLo),0]}else{uv=[(p[2]-intensityLo)/(intensityHi-intensityLo),0]}pUVs.push(uv[0],uv[1]);if(pointSizes){pSiz.push(pointSizes[v])}else{pSiz.push(meshPointSize)}pIds.push(i);pointCount+=1;break;case 2:for(var j=0;j<2;++j){var v=cell[j];var p=positions[v];for(var k=0;k<3;++k){if(isNaN(p[k])||!isFinite(p[k])){continue fill_loop}}}for(var j=0;j<2;++j){var v=cell[j];var p=positions[v];ePos.push(p[0],p[1],p[2]);var c;if(vertexColors){c=vertexColors[v]}else if(cellColors){c=cellColors[i]}else{c=meshColor}if(c.length===3){eCol.push(c[0],c[1],c[2],1)}else{eCol.push(c[0],c[1],c[2],c[3])}var uv;if(vertexUVs){uv=vertexUVs[v]}else if(vertexIntensity){uv=[(vertexIntensity[v]-intensityLo)/(intensityHi-intensityLo),0]}else if(cellUVs){uv=cellUVs[i]}else if(cellIntensity){uv=[(cellIntensity[i]-intensityLo)/(intensityHi-intensityLo),0]}else{uv=[(p[2]-intensityLo)/(intensityHi-intensityLo),0]}eUVs.push(uv[0],uv[1]);eIds.push(i)}edgeCount+=1;break;case 3:for(var j=0;j<3;++j){var v=cell[j];var p=positions[v];for(var k=0;k<3;++k){if(isNaN(p[k])||!isFinite(p[k])){continue fill_loop}}}for(var j=0;j<3;++j){var v=cell[j];var p=positions[v];tPos.push(p[0],p[1],p[2]);var c;if(vertexColors){c=vertexColors[v]}else if(cellColors){c=cellColors[i]}else{c=meshColor}if(c.length===3){tCol.push(c[0],c[1],c[2],1)}else{tCol.push(c[0],c[1],c[2],c[3])}var uv;if(vertexUVs){uv=vertexUVs[v]}else if(vertexIntensity){uv=[(vertexIntensity[v]-intensityLo)/(intensityHi-intensityLo),0]}else if(cellUVs){uv=cellUVs[i]}else if(cellIntensity){uv=[(cellIntensity[i]-intensityLo)/(intensityHi-intensityLo),0]}else{uv=[(p[2]-intensityLo)/(intensityHi-intensityLo),0]}tUVs.push(uv[0],uv[1]);var q;if(vertexNormals){q=vertexNormals[v]}else{q=cellNormals[i]}tNor.push(q[0],q[1],q[2]);tIds.push(i)}triangleCount+=1;break;default:break}}this.pointCount=pointCount;this.edgeCount=edgeCount;this.triangleCount=triangleCount;this.pointPositions.update(pPos);this.pointColors.update(pCol);this.pointUVs.update(pUVs);this.pointSizes.update(pSiz);this.pointIds.update(new Uint32Array(pIds));this.edgePositions.update(ePos);this.edgeColors.update(eCol);this.edgeUVs.update(eUVs);this.edgeIds.update(new Uint32Array(eIds));this.trianglePositions.update(tPos);this.triangleColors.update(tCol);this.triangleUVs.update(tUVs);this.triangleNormals.update(tNor);this.triangleIds.update(new Uint32Array(tIds))};proto.drawTransparent=proto.draw=function(params){params=params||{};var gl=this.gl;var model=params.model||identityMatrix;var view=params.view||identityMatrix;var projection=params.projection||identityMatrix;var clipBounds=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]];for(var i=0;i<3;++i){clipBounds[0][i]=Math.max(clipBounds[0][i],this.clipBounds[0][i]);clipBounds[1][i]=Math.min(clipBounds[1][i],this.clipBounds[1][i])}var uniforms={model:model,view:view,projection:projection,clipBounds:clipBounds,kambient:this.ambientLight,kdiffuse:this.diffuseLight,kspecular:this.specularLight,roughness:this.roughness,fresnel:this.fresnel,eyePosition:[0,0,0],lightPosition:[0,0,0],opacity:this.opacity,contourColor:this.contourColor,texture:0};this.texture.bind(0);var invCameraMatrix=new Array(16);multiply(invCameraMatrix,uniforms.view,uniforms.model);multiply(invCameraMatrix,uniforms.projection,invCameraMatrix);invert(invCameraMatrix,invCameraMatrix);for(var i=0;i<3;++i){uniforms.eyePosition[i]=invCameraMatrix[12+i]/invCameraMatrix[15]}var w=invCameraMatrix[15];for(var i=0;i<3;++i){w+=this.lightPosition[i]*invCameraMatrix[4*i+3]}for(var i=0;i<3;++i){var s=invCameraMatrix[12+i];for(var j=0;j<3;++j){s+=invCameraMatrix[4*j+i]*this.lightPosition[j]}uniforms.lightPosition[i]=s/w}if(this.triangleCount>0){var shader=this.triShader;shader.bind();shader.uniforms=uniforms;this.triangleVAO.bind();gl.drawArrays(gl.TRIANGLES,0,this.triangleCount*3);this.triangleVAO.unbind()}if(this.edgeCount>0&&this.lineWidth>0){var shader=this.lineShader;shader.bind();shader.uniforms=uniforms;this.edgeVAO.bind();gl.lineWidth(this.lineWidth);gl.drawArrays(gl.LINES,0,this.edgeCount*2);this.edgeVAO.unbind()}if(this.pointCount>0){var shader=this.pointShader;shader.bind();shader.uniforms=uniforms;this.pointVAO.bind();gl.drawArrays(gl.POINTS,0,this.pointCount);this.pointVAO.unbind()}if(this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0){var shader=this.contourShader;shader.bind();shader.uniforms=uniforms;this.contourVAO.bind();gl.drawArrays(gl.LINES,0,this.contourCount);this.contourVAO.unbind()}};proto.drawPick=function(params){params=params||{};var gl=this.gl;var model=params.model||identityMatrix;var view=params.view||identityMatrix;var projection=params.projection||identityMatrix;var clipBounds=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]];for(var i=0;i<3;++i){clipBounds[0][i]=Math.max(clipBounds[0][i],this.clipBounds[0][i]);clipBounds[1][i]=Math.min(clipBounds[1][i],this.clipBounds[1][i])}this._model=[].slice.call(model);this._view=[].slice.call(view);this._projection=[].slice.call(projection);this._resolution=[gl.drawingBufferWidth,gl.drawingBufferHeight];var uniforms={model:model,view:view,projection:projection,clipBounds:clipBounds,pickId:this.pickId/255};var shader=this.pickShader;shader.bind();shader.uniforms=uniforms;if(this.triangleCount>0){this.triangleVAO.bind();gl.drawArrays(gl.TRIANGLES,0,this.triangleCount*3);this.triangleVAO.unbind()}if(this.edgeCount>0){this.edgeVAO.bind();gl.lineWidth(this.lineWidth);gl.drawArrays(gl.LINES,0,this.edgeCount*2);this.edgeVAO.unbind()}if(this.pointCount>0){var shader=this.pointPickShader;shader.bind();shader.uniforms=uniforms;this.pointVAO.bind();gl.drawArrays(gl.POINTS,0,this.pointCount);this.pointVAO.unbind()}};proto.pick=function(pickData){if(!pickData){return null}if(pickData.id!==this.pickId){return null}var cellId=pickData.value[0]+256*pickData.value[1]+65536*pickData.value[2];var cell=this.cells[cellId];var positions=this.positions;var simplex=new Array(cell.length);for(var i=0;i<cell.length;++i){simplex[i]=positions[cell[i]]}var data=closestPoint(simplex,[pickData.coord[0],this._resolution[1]-pickData.coord[1]],this._model,this._view,this._projection,this._resolution);if(!data){return null}var weights=data[2];var interpIntensity=0;for(var i=0;i<cell.length;++i){interpIntensity+=weights[i]*this.intensity[cell[i]]}return{position:data[1],index:cell[data[0]],cell:cell,cellId:cellId,intensity:interpIntensity}};proto.dispose=function(){this.texture.dispose();this.triShader.dispose();this.lineShader.dispose();this.pointShader.dispose();this.pickShader.dispose();this.pointPickShader.dispose();this.triangleVAO.dispose();this.trianglePositions.dispose();this.triangleColors.dispose();this.triangleUVs.dispose();this.triangleNormals.dispose();this.triangleIds.dispose();this.edgeVAO.dispose();this.edgePositions.dispose();this.edgeColors.dispose();this.edgeUVs.dispose();this.edgeIds.dispose();this.pointVAO.dispose();this.pointPositions.dispose();this.pointColors.dispose();this.pointUVs.dispose();this.pointSizes.dispose();this.pointIds.dispose();this.contourVAO.dispose();this.contourPoints.dispose();this.contourShader.dispose()};function createMeshShader(gl){var shader=createShader(gl,meshShader);shader.attributes.position.location=0;shader.attributes.color.location=2;shader.attributes.uv.location=3;shader.attributes.normal.location=4;return shader}function createWireShader(gl){var shader=createShader(gl,wireShader);shader.attributes.position.location=0;shader.attributes.color.location=2;shader.attributes.uv.location=3;return shader}function createPointShader(gl){var shader=createShader(gl,pointShader);shader.attributes.position.location=0;shader.attributes.color.location=2;shader.attributes.uv.location=3;shader.attributes.pointSize.location=4;return shader}function createPickShader(gl){var shader=createShader(gl,pickShader);shader.attributes.position.location=0;shader.attributes.id.location=1;return shader}function createPointPickShader(gl){var shader=createShader(gl,pointPickShader);shader.attributes.position.location=0;shader.attributes.id.location=1;shader.attributes.pointSize.location=4;return shader}function createContourShader(gl){var shader=createShader(gl,contourShader);shader.attributes.position.location=0;return shader}function createSimplicialMesh(params){var gl=params.gl;var triShader=createMeshShader(gl);var lineShader=createWireShader(gl);var pointShader=createPointShader(gl);var pickShader=createPickShader(gl);var pointPickShader=createPointPickShader(gl);var contourShader=createContourShader(gl);var meshTexture=createTexture(gl,ndarray(new Uint8Array([255,255,255,255]),[1,1,4]));meshTexture.generateMipmap();meshTexture.minFilter=gl.LINEAR_MIPMAP_LINEAR;meshTexture.magFilter=gl.LINEAR;var trianglePositions=createBuffer(gl);var triangleColors=createBuffer(gl);var triangleUVs=createBuffer(gl);var triangleNormals=createBuffer(gl);var triangleIds=createBuffer(gl);var triangleVAO=createVAO(gl,[{buffer:trianglePositions,type:gl.FLOAT,size:3},{buffer:triangleIds,type:gl.UNSIGNED_BYTE,size:4,normalized:true},{buffer:triangleColors,type:gl.FLOAT,size:4},{buffer:triangleUVs,type:gl.FLOAT,size:2},{buffer:triangleNormals,type:gl.FLOAT,size:3}]);var edgePositions=createBuffer(gl);var edgeColors=createBuffer(gl);var edgeUVs=createBuffer(gl);var edgeIds=createBuffer(gl);var edgeVAO=createVAO(gl,[{buffer:edgePositions,type:gl.FLOAT,size:3},{buffer:edgeIds,type:gl.UNSIGNED_BYTE,size:4,normalized:true},{buffer:edgeColors,type:gl.FLOAT,size:4},{buffer:edgeUVs,type:gl.FLOAT,size:2}]);var pointPositions=createBuffer(gl);var pointColors=createBuffer(gl);var pointUVs=createBuffer(gl);var pointSizes=createBuffer(gl);var pointIds=createBuffer(gl);var pointVAO=createVAO(gl,[{buffer:pointPositions,type:gl.FLOAT,size:3},{buffer:pointIds,type:gl.UNSIGNED_BYTE,size:4,normalized:true},{buffer:pointColors,type:gl.FLOAT,size:4},{buffer:pointUVs,type:gl.FLOAT,size:2},{buffer:pointSizes,type:gl.FLOAT,size:1}]);var contourPositions=createBuffer(gl);var contourVAO=createVAO(gl,[{buffer:contourPositions,type:gl.FLOAT,size:3}]);var mesh=new SimplicialMesh(gl,meshTexture,triShader,lineShader,pointShader,pickShader,pointPickShader,contourShader,trianglePositions,triangleIds,triangleColors,triangleUVs,triangleNormals,triangleVAO,edgePositions,edgeIds,edgeColors,edgeUVs,edgeVAO,pointPositions,pointIds,pointColors,pointUVs,pointSizes,pointVAO,contourPositions,contourVAO);mesh.update(params);return mesh}module.exports=createSimplicialMesh},{"./lib/closest-point":5,"./lib/shaders":6,colormap:16,"gl-buffer":18,"gl-mat4/invert":26,"gl-mat4/multiply":27,"gl-shader":28,"gl-texture2d":44,"gl-vao":50,ndarray:53,normals:55,"simplicial-complex-contour":57,"typedarray-pool":92}]},{},[]);require=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}({bunny:[function(require,module,exports){exports.positions=[[1.301895,.122622,2.550061],[1.045326,.139058,2.835156],[.569251,.155925,2.805125],[.251886,.144145,2.82928],[.063033,.131726,3.01408],[-.277753,.135892,3.10716],[-.441048,.277064,2.594331],[-1.010956,.095285,2.668983],[-1.317639,.069897,2.325448],[-.751691,.264681,2.381496],[.684137,.31134,2.364574],[1.347931,.302882,2.201434],[-1.736903,.029894,1.724111],[-1.319986,.11998,.912925],[1.538077,.157372,.481711],[1.951975,.081742,1.1641],[1.834768,.095832,1.602682],[2.446122,.091817,1.37558],[2.617615,.078644,.742801],[-1.609748,.04973,-.238721],[-1.281973,.230984,-.180916],[-1.074501,.248204,.034007],[-1.201734,.058499,.402234],[-1.444454,.054783,.149579],[-4.694605,5.075882,1.043427],[-3.95963,7.767394,.758447],[-4.753339,5.339817,.665061],[-1.150325,9.133327,-.368552],[-4.316107,2.893611,.44399],[-.809202,9.312575,-.466061],[.085626,5.963693,1.685666],[-1.314853,9.00142,-.1339],[-4.364182,3.072556,1.436712],[-2.022074,7.323396,.678657],[1.990887,6.13023,.479643],[-3.295525,7.878917,1.409353],[.571308,6.197569,.670657],[.89661,6.20018,.337056],[.331851,6.162372,1.186371],[-4.840066,5.599874,2.296069],[2.138989,6.031291,.228335],[.678923,6.026173,1.894052],[-.781682,5.601573,1.836738],[1.181315,6.239007,.393293],[-3.606308,7.376476,2.661452],[-.579059,4.042511,-1.540883],[-3.064069,8.630253,-2.597539],[-2.157271,6.837012,.300191],[-2.966013,7.821581,-1.13697],[-2.34426,8.122965,.409043],[-.951684,5.874251,1.415119],[-2.834853,7.748319,.182406],[-3.242493,7.820096,.373674],[-.208532,5.992846,1.252084],[-3.048085,8.431527,-2.129795],[1.413245,5.806324,2.243906],[-.051222,6.064901,.696093],[-4.204306,2.700062,.713875],[-4.610997,6.343405,.344272],[-3.291336,9.30531,-3.340445],[-3.27211,7.559239,-2.324016],[-4.23882,6.498344,3.18452],[-3.945317,6.377804,3.38625],[-4.906378,5.472265,1.315193],[-3.580131,7.846717,.709666],[-1.995504,6.645459,.688487],[-2.595651,7.86054,.793351],[-.008849,.305871,.184484],[-.029011,.314116,-.257312],[-2.522424,7.565392,1.804212],[-1.022993,8.650826,-.855609],[-3.831265,6.595426,3.266783],[-4.042525,6.855724,3.060663],[-4.17126,7.404742,2.391387],[3.904526,3.767693,.092179],[.268076,6.086802,1.469223],[-3.320456,8.753222,-2.08969],[1.203048,6.26925,.612407],[-4.406479,2.985974,.853691],[-3.226889,6.615215,-.404243],[.346326,1.60211,3.509858],[-3.955476,7.253323,2.722392],[-1.23204,.068935,1.68794],[.625436,6.196455,1.333156],[4.469132,2.165298,1.70525],[.950053,6.262899,.922441],[-2.980404,5.25474,-.663155],[-4.859043,6.28741,1.537081],[-3.077453,4.641475,-.892167],[-.44002,8.222503,-.771454],[-4.034112,7.639786,.389935],[-3.696045,6.242042,3.394679],[-1.221806,7.783617,.196451],[.71461,6.149895,1.656636],[-4.713539,6.163154,.495369],[-1.509869,.913044,-.832413],[-1.547249,2.066753,-.852669],[-3.757734,5.793742,3.455794],[-.831911,.199296,1.718536],[-3.062763,7.52718,-1.550559],[.938688,6.103354,1.820958],[-4.037033,2.412311,.988026],[-4.130746,2.571806,1.101689],[-.693664,9.174283,-.952323],[-1.286742,1.079679,-.751219],[1.543185,1.408925,3.483132],[1.535973,2.047979,3.655029],[.93844,5.84101,2.195219],[-.684401,5.918492,1.20109],[1.28844,2.008676,3.710781],[-3.586722,7.435506,-1.454737],[-.129975,4.384192,2.930593],[-1.030531,.281374,3.214273],[-3.058751,8.137238,-3.227714],[3.649524,4.592226,1.340021],[-3.354828,7.322425,-1.412086],[.936449,6.209237,1.512693],[-1.001832,3.590411,-1.545892],[-3.770486,4.593242,2.477056],[-.971925,.067797,.921384],[-4.639832,6.865407,2.311791],[-.441014,8.093595,-.595999],[-2.004852,6.37142,1.635383],[4.759591,1.92818,.328328],[3.748064,1.224074,2.140484],[-.703601,5.285476,2.251988],[.59532,6.21893,.981004],[.980799,6.257026,1.24223],[1.574697,6.204981,.381628],[1.149594,6.173608,1.660763],[-3.501963,5.895989,3.456576],[1.071122,5.424198,2.588717],[-.774693,8.473335,-.276957],[3.849959,4.15542,.396742],[-.801715,4.973149,-1.068582],[-2.927676,.625112,2.326393],[2.669682,4.045542,2.971184],[-4.391324,4.74086,.343463],[1.520129,6.270031,.775471],[1.837586,6.084731,.109188],[1.271475,5.975024,2.032355],[-3.487968,4.513249,2.605871],[-1.32234,1.517264,-.691879],[-1.080301,1.648226,-.805526],[-3.365703,6.910166,-.454902],[1.36034,.432238,3.075004],[-3.305013,5.774685,3.39142],[3.88432,.654141,.12574],[3.57254,.377934,.302501],[4.196136,.807999,.212229],[3.932997,.543123,.380579],[4.023704,3.286125,.537597],[1.864455,4.916544,2.691677],[-4.775427,6.499498,1.440153],[-3.464928,3.68234,2.766356],[3.648972,1.751262,2.157485],[1.179111,3.238846,3.774796],[-.171164,.299126,-.592669],[-4.502912,3.316656,.875188],[-.948454,9.214025,-.679508],[1.237665,6.288593,1.046],[1.523423,6.268963,1.139544],[1.436519,6.140608,1.739316],[3.723607,1.504355,2.136762],[2.009495,4.045514,3.22053],[-1.921944,7.249905,.213973],[1.254068,1.205518,3.474709],[-.317087,5.996269,.525872],[-2.996914,3.934607,2.900178],[-3.316873,4.028154,2.785696],[-3.400267,4.280157,2.689268],[-3.134842,4.564875,2.697192],[1.480563,4.692567,2.834068],[.873682,1.315452,3.541585],[1.599355,.91622,3.246769],[-3.292102,7.125914,2.768515],[3.74296,4.511299,.616539],[4.698935,1.55336,.26921],[-3.274387,3.299421,2.823946],[-2.88809,3.410699,2.955248],[1.171407,1.76905,3.688472],[1.430276,3.92483,3.473666],[3.916941,2.553308,.018941],[.701632,2.442372,3.778639],[1.562657,2.302778,3.660957],[4.476622,1.152407,.182131],[-.61136,5.761367,1.598838],[-3.102154,3.691687,2.903738],[1.816012,5.546167,2.380308],[3.853928,4.25066,.750017],[1.234681,3.581665,3.673723],[1.862271,1.361863,3.355209],[1.346844,4.146995,3.327877],[1.70672,4.080043,3.274307],[.897242,1.908983,3.6969],[-.587022,9.191132,-.565301],[-.217426,5.674606,2.019968],[.278925,6.120777,.485403],[1.463328,3.578742,-2.001464],[-3.072985,4.264581,2.789502],[3.62353,4.673843,.383452],[-3.053491,8.752377,-2.908434],[-2.628687,4.505072,2.755601],[.891047,5.113781,2.748272],[-2.923732,3.06515,2.866368],[.848008,4.754252,2.896972],[-3.319184,8.811641,-2.327412],[.12864,8.814781,-1.334456],[1.549501,4.549331,-1.28243],[1.647161,3.738973,3.507719],[1.250888,.945599,3.348739],[3.809662,4.038822,.053142],[1.483166,.673327,3.09156],[.829726,3.635921,3.713103],[1.352914,5.226651,2.668113],[2.237352,4.37414,3.016386],[4.507929,.889447,.744249],[4.57304,1.010981,.496588],[3.931422,1.720989,2.088175],[-.463177,5.989835,.834346],[-2.811236,3.745023,2.969587],[-2.805135,4.219721,2.841108],[-2.836842,4.802543,2.60826],[1.776716,2.084611,3.568638],[4.046881,1.463478,2.106273],[.316265,5.944313,1.892785],[-2.86347,2.776049,2.77242],[-2.673644,3.116508,2.907104],[-2.621149,4.018502,2.903409],[-2.573447,5.198013,2.477481],[1.104039,2.278985,3.722469],[-4.602743,4.306413,.902296],[-2.684878,1.510731,.535039],[.092036,8.473269,-.99413],[-1.280472,5.602393,1.928105],[-1.0279,4.121582,-1.403103],[-2.461081,3.304477,2.957317],[-2.375929,3.659383,2.953233],[1.417579,2.715389,3.718767],[.819727,2.948823,3.810639],[1.329962,.761779,3.203724],[1.73952,5.295229,2.537725],[.952523,3.945016,3.548229],[-2.569498,.633669,2.84818],[-2.276676,.757013,2.780717],[-2.013147,7.354429,-.003202],[.93143,1.565913,3.600325],[1.249014,1.550556,3.585842],[2.287252,4.072353,3.124544],[-4.7349,7.006244,1.690653],[-3.500602,8.80386,-2.009196],[-.582629,5.549138,2.000923],[-1.865297,6.356066,1.313593],[-3.212154,2.376143,-.565593],[2.092889,3.493536,-1.727931],[-2.528501,2.784531,2.833758],[-2.565697,4.893154,2.559605],[-2.153366,5.04584,2.465215],[1.631311,2.568241,3.681445],[2.150193,4.699227,2.807505],[.507599,5.01813,2.775892],[4.129862,1.863698,2.015101],[3.578279,4.50766,-.009598],[3.491023,4.806749,1.549265],[.619485,1.625336,3.605125],[1.107499,2.932557,3.790061],[-2.082292,6.99321,.742601],[4.839909,1.379279,.945274],[3.591328,4.322645,-.259497],[1.055245,.710686,3.16553],[-3.026494,7.842227,1.624553],[.146569,6.119214,.981673],[-2.043687,2.614509,2.785526],[-2.302242,3.047775,2.936355],[-2.245686,4.100424,2.87794],[2.116148,5.063507,2.572204],[-1.448406,7.64559,.251692],[2.550717,4.9268,2.517526],[-2.955456,7.80293,-1.782407],[1.882995,4.637167,2.895436],[-2.014924,3.398262,2.954896],[-2.273654,4.771227,2.611418],[-2.162723,7.876761,.702473],[-.198659,5.823062,1.739272],[-1.280908,2.133189,-.921241],[2.039932,4.251568,3.136579],[1.477815,4.354333,3.108325],[.560504,3.744128,3.6913],[-2.234018,1.054373,2.352782],[-3.189156,7.686661,-2.514955],[-3.744736,7.69963,2.116973],[-2.283366,2.878365,2.87882],[-2.153786,4.457481,2.743529],[4.933978,1.677287,.713773],[3.502146,.535336,1.752511],[1.825169,4.419253,3.081198],[3.072331,.280979,.106534],[-.508381,1.220392,2.878049],[-3.138824,8.445394,-1.659711],[-2.056425,2.954815,2.897241],[-2.035343,5.398477,2.215842],[-3.239915,7.126798,-.712547],[-1.867923,7.989805,.526518],[1.23405,6.248973,1.387189],[-.216492,8.320933,-.862495],[-2.079659,3.755709,2.928563],[-1.78595,4.300374,2.805295],[-1.856589,5.10678,2.386572],[-1.714362,5.544778,2.004623],[1.722403,4.200291,-1.408161],[.195386,.086928,-1.318006],[1.393693,3.013404,3.710686],[-.415307,8.508471,-.996883],[-1.853777,.755635,2.757275],[-1.724057,3.64533,2.884251],[-1.884511,4.927802,2.530885],[-1.017174,7.783908,-.227078],[-1.7798,2.342513,2.741749],[-1.841329,3.943996,2.88436],[1.430388,5.468067,2.503467],[-2.030296,.940028,2.611088],[-1.677028,1.215666,2.607771],[-1.74092,2.832564,2.827295],[4.144673,.631374,.503358],[4.238811,.653992,.762436],[-1.847016,2.082815,2.642674],[4.045764,3.194073,.852117],[-1.563989,8.112739,.303102],[-1.781627,1.794836,2.602338],[-1.493749,2.533799,2.797251],[-1.934496,4.690689,2.658999],[-1.499174,5.777946,1.747498],[-2.387409,.851291,1.500524],[-1.872211,8.269987,.392533],[-4.647726,6.765771,.833653],[-3.157482,.341958,-.20671],[-1.725766,3.24703,2.883579],[-1.458199,4.079031,2.836325],[-1.621548,4.515869,2.719266],[-1.607292,4.918914,2.505881],[-1.494661,5.556239,1.991599],[-1.727269,7.423769,.012337],[-1.382497,1.161322,2.640222],[-1.52129,4.681714,2.615467],[-4.247127,2.792812,1.250843],[-1.576338,.742947,2.769799],[-1.499257,2.172763,2.743142],[-1.480392,3.103261,2.862262],[1.049137,2.625836,3.775384],[-1.368063,1.791587,2.695516],[-1.307839,2.344534,2.767575],[-1.336758,5.092221,2.355225],[-1.5617,5.301749,2.21625],[-1.483362,8.537704,.196752],[-1.517348,8.773614,.074053],[-1.474302,1.492731,2.641433],[2.48718,.644247,-.920226],[.818091,.422682,3.171218],[-3.623398,6.930094,3.033045],[1.676333,3.531039,3.591591],[1.199939,5.683873,2.365623],[-1.223851,8.841201,.025414],[-1.286307,3.847643,2.918044],[-1.25857,4.810831,2.543605],[2.603662,5.572146,1.991854],[.138984,5.779724,2.077834],[-1.267039,3.175169,2.890889],[-1.293616,3.454612,2.911774],[-2.60112,1.277184,.07724],[2.552779,3.649877,3.163643],[-1.038983,1.248011,2.605933],[-1.288709,4.390967,2.761214],[-1.034218,5.485963,2.011467],[-1.185576,1.464842,2.624335],[-1.045682,2.54896,2.761102],[4.259176,1.660627,2.018096],[-.961707,1.717183,2.598342],[-1.044603,3.147464,2.855335],[-.891998,4.685429,2.669696],[-1.027561,5.081672,2.377939],[4.386506,.832434,.510074],[-1.014225,9.064991,-.175352],[-1.218752,2.895443,2.823785],[-.972075,4.432669,2.788005],[-2.714986,.52425,1.509798],[-.699248,1.517219,2.645738],[-1.161581,2.078852,2.722795],[-.845249,3.286247,2.996471],[1.068329,4.443444,2.993863],[3.98132,3.715557,1.027775],[1.658097,3.982428,-1.651688],[-4.053701,2.449888,.734746],[-.910935,2.214149,2.702393],[.087824,3.96165,3.439344],[-.779714,3.724134,2.993429],[-1.051093,3.810797,2.941957],[-.644941,4.3859,2.870863],[-2.98403,8.666895,-3.691888],[-.754304,2.508325,2.812999],[-4.635524,3.662891,.913005],[-.983299,4.125978,2.915378],[4.916497,1.905209,.621315],[4.874983,1.728429,.468521],[2.33127,5.181957,2.441697],[-.653711,2.253387,2.7949],[-3.623744,8.978795,-2.46192],[-4.555927,6.160279,.215755],[-4.940628,5.806712,1.18383],[3.308506,2.40326,-.910776],[.58835,5.251928,-.992886],[2.152215,5.449733,2.331679],[-.712755,.766765,3.280375],[-.741771,1.9716,2.657235],[-4.828957,5.566946,2.635623],[-3.474788,8.696771,-1.776121],[1.770417,6.205561,1.331627],[-.620626,4.064721,2.968972],[-1.499187,2.307735,-.978901],[4.098793,2.330245,1.667951],[1.940444,6.167057,.935904],[-2.314436,1.104995,1.681277],[-2.733629,7.742793,1.7705],[-.452248,4.719868,2.740834],[-.649143,4.951713,2.541296],[-.479417,9.43959,-.676324],[-2.251853,6.559275,.046819],[.033531,8.316907,-.789939],[-.513125,.995673,3.125462],[-2.637602,1.039747,.602434],[1.527513,6.230089,1.430903],[4.036124,2.609846,1.506498],[-3.559828,7.877892,1.228076],[-4.570736,4.960193,.838201],[-.432121,5.157731,2.467518],[-1.206735,4.562511,-1.237054],[-.823768,3.788746,-1.567481],[-3.095544,7.353613,-1.024577],[-4.056088,7.631119,2.062001],[-.289385,5.382261,2.329421],[1.69752,6.136483,1.667037],[-.168758,5.061138,2.617453],[2.853576,1.605528,-1.229958],[-4.514319,6.586675,.352756],[-2.558081,7.741151,1.29295],[1.61116,5.92358,2.071534],[3.936921,3.354857,.091755],[-.1633,1.119272,3.147975],[.067551,1.593475,3.38212],[-1.303239,2.328184,-1.011672],[-.438093,.73423,3.398384],[-4.62767,3.898187,.849573],[.286853,4.165281,3.284834],[-2.968052,8.492812,-3.493693],[-.111896,3.696111,3.53791],[-3.808245,8.451731,-1.574742],[.053416,5.558764,2.31107],[3.956269,3.012071,.11121],[-.710956,8.106561,-.665154],[.234725,2.717326,3.722379],[-.031594,2.76411,3.657347],[-.017371,4.700633,2.81911],[.215064,5.034859,2.721426],[-.111151,8.480333,-.649399],[3.97942,3.575478,.362219],[.392962,4.735392,2.874321],[4.17015,2.085087,1.865999],[.169054,1.244786,3.337709],[.020049,3.165818,3.721736],[.248212,3.595518,3.698376],[.130706,5.295541,2.540034],[-4.541357,4.798332,1.026866],[-1.277485,1.289518,-.667272],[3.892133,3.54263,-.078056],[4.057379,3.03669,.997913],[.287719,.884758,3.251787],[.535771,1.144701,3.400096],[.585303,1.399362,3.505353],[.191551,2.076246,3.549355],[.328656,2.394576,3.649623],[.413124,3.240728,3.771515],[.630361,4.501549,2.963623],[.529441,5.854392,2.120225],[3.805796,3.769958,-.162079],[3.447279,4.344846,-.467276],[.377618,5.551116,2.426017],[.409355,1.821269,3.606333],[.719959,2.194726,3.703851],[.495922,3.501519,3.755661],[.603408,5.354097,2.603088],[-4.605056,7.531978,1.19579],[.907972,.973128,3.356513],[.750134,3.356137,3.765847],[.4496,3.993244,3.504544],[-3.030738,7.48947,-1.259169],[.707505,5.602005,2.43476],[.668944,.654891,3.213797],[.593244,2.700978,3.791427],[1.467759,3.30327,3.71035],[3.316249,2.436388,2.581175],[3.26138,1.724425,2.539028],[-1.231292,7.968263,.281414],[-.108773,8.712307,-.790607],[4.445684,1.819442,1.896988],[1.998959,2.281499,3.49447],[2.162269,2.113817,3.365449],[4.363397,1.406731,1.922714],[4.808,2.225842,.611127],[2.735919,.771812,-.701142],[1.897735,2.878428,3.583482],[-3.31616,5.331985,3.212394],[-3.3314,6.018137,3.313018],[-3.503183,6.480103,3.222216],[-1.904453,5.750392,1.913324],[-1.339735,3.559592,-1.421817],[-1.044242,8.22539,.037414],[1.643492,3.110676,3.647424],[3.992832,3.686244,.710946],[1.774207,1.71842,3.475768],[-3.438842,5.5713,3.427818],[4.602447,1.2583,1.619528],[-.925516,7.930042,.072336],[-1.252093,3.846565,-1.420761],[-3.426857,5.072419,2.97806],[-3.160408,6.152629,3.061869],[3.739931,3.367082,2.041273],[1.027419,4.235891,3.251253],[4.777703,1.887452,1.560409],[-3.318528,6.733796,2.982968],[2.929265,4.962579,2.271079],[3.449761,2.838629,2.474576],[-3.280159,5.029875,2.787514],[4.068939,2.993629,.741567],[.303312,8.70927,-1.121972],[.229852,8.981322,-1.186075],[-.011045,9.148156,-1.047057],[-2.942683,5.579613,2.929297],[-3.145409,5.698727,3.205778],[-3.019089,6.30887,2.794323],[-3.217135,6.468191,2.970032],[-3.048298,6.993641,2.623378],[-3.07429,6.660982,2.702434],[3.612011,2.5574,2.25349],[2.54516,4.553967,2.75884],[-1.683759,7.400787,.250868],[-1.756066,7.463557,.448031],[-3.023761,5.149697,2.673539],[3.112376,2.677218,2.782378],[2.835327,4.581196,2.567146],[-2.973799,7.225458,2.506988],[-.591645,8.740662,-.505845],[3.782861,2.04337,2.03066],[3.331604,3.36343,2.605047],[2.966866,1.205497,2.537432],[.002669,9.654748,-1.355559],[2.632801,.58497,2.540311],[-2.819398,5.087372,2.521098],[2.616193,5.332961,2.194288],[-3.193973,4.925634,2.607924],[-3.12618,5.27524,2.944544],[-.426003,8.516354,-.501528],[2.802717,1.387643,2.751649],[-3.120597,7.889111,-2.75431],[2.636648,1.71702,2.991302],[-2.853151,6.711792,2.430276],[-2.843836,6.962865,2.400842],[1.9696,3.199023,3.504514],[-2.461751,.386352,3.008994],[1.64127,.495758,3.02958],[-4.330472,5.409831,.025287],[-2.912387,5.980416,2.844261],[-2.490069,.211078,2.985391],[3.581816,4.809118,.733728],[2.693199,2.647213,3.126709],[-.182964,8.184108,-.638459],[-2.226855,.444711,2.946552],[-.720175,8.115055,.017689],[2.645302,4.316212,2.850139],[-.232764,9.329503,-.918639],[4.852365,1.471901,.65275],[2.76229,2.014994,2.957755],[-2.808374,5.354301,2.644695],[-2.790967,6.406963,2.547985],[-1.342684,.418488,-1.669183],[2.690675,5.593587,-.041236],[4.660146,1.6318,1.713314],[2.775667,3.007229,3.111332],[-.396696,8.963432,-.706202],[2.446707,2.740617,3.321433],[-4.803209,5.884634,2.603672],[-2.652003,1.6541,1.5078],[3.932327,3.972874,.831924],[2.135906,.955587,2.986608],[2.486131,2.053802,3.124115],[-.386706,8.115753,-.37565],[-2.720727,7.325044,2.224878],[-1.396946,7.638016,-.16486],[-.62083,7.989771,-.144413],[-2.653272,5.729684,2.667679],[3.038188,4.65835,2.364142],[2.381721,.739472,2.788992],[-2.345829,5.474929,2.380633],[-2.518983,6.080562,2.479383],[-2.615793,6.839622,2.186116],[-2.286566,.143752,2.766848],[-4.771219,6.508766,1.070797],[3.717308,2.905019,2.097994],[2.50521,3.016743,3.295898],[2.208448,1.56029,3.216806],[3.346783,1.01254,2.119951],[2.653503,3.26122,3.175738],[-2.359636,5.827519,2.402297],[-1.952693,.558102,2.853307],[-.321562,9.414885,-1.187501],[3.138923,1.405072,2.520765],[1.493728,1.780051,3.621969],[3.01817,.907291,2.336909],[3.183548,1.185297,2.352175],[1.608619,5.006753,2.695131],[-4.723919,6.836107,1.095288],[-1.017586,8.865429,-.149328],[4.730762,1.214014,.64008],[-2.135182,6.647907,1.495471],[-2.420382,6.546114,2.108209],[-2.458053,7.186346,1.896623],[3.437124,.275798,1.138203],[.095925,8.725832,-.926481],[2.417376,2.429869,3.287659],[2.279951,1.200317,3.049994],[2.674753,2.326926,3.044059],[-2.328123,6.849164,1.75751],[-3.418616,7.853407,.126248],[-3.151587,7.77543,-.110889],[2.349144,5.653242,2.05869],[-2.273236,6.085631,2.242888],[-4.560601,4.525342,1.261241],[2.866334,3.796067,2.934717],[-2.17493,6.505518,1.791367],[3.12059,3.283157,2.818869],[3.037703,3.562356,2.866653],[.066233,9.488418,-1.248237],[2.749941,.975018,2.573371],[-2.155749,5.801033,2.204009],[-2.162778,6.261889,2.028596],[1.936874,.459142,2.956718],[3.176249,4.335541,2.440447],[4.356599,1.029423,1.700589],[3.873502,3.082678,1.80431],[2.895489,4.243034,2.735259],[-.095774,9.468195,-1.07451],[-1.124982,7.886808,-.480851],[3.032304,3.065454,2.897927],[3.692687,4.5961,.957858],[-3.013045,3.807235,-1.098381],[-.790012,8.92912,-.367572],[1.905793,.73179,2.996728],[3.530396,3.426233,2.356583],[2.12299,.624933,2.929167],[-2.069196,6.039284,2.01251],[-3.565623,7.182525,2.850039],[2.959264,2.376337,2.829242],[2.949071,1.822483,2.793933],[4.036142,.763803,1.703744],[-1.993527,6.180318,1.804936],[-.030987,.766389,3.344766],[-.549683,8.225193,-.189341],[-.765469,8.272246,-.127174],[-2.947047,7.541648,-.414113],[-3.050327,9.10114,-3.435619],[3.488566,2.231807,2.399836],[3.352283,4.727851,1.946438],[4.741011,2.162773,1.499574],[-1.815093,6.072079,1.580722],[-3.720969,8.267927,-.984713],[1.932826,3.714052,3.427488],[3.323617,4.438961,2.20732],[.254111,9.26364,-1.373244],[-1.493384,7.868585,-.450051],[-.841901,.776135,-1.619467],[.243537,6.027668,.091687],[.303057,.313022,-.531105],[-.435273,.474098,3.481552],[2.121507,2.622389,3.486293],[1.96194,1.101753,3.159584],[3.937991,3.407551,1.551392],[.070906,.295753,1.377185],[-1.93588,7.631764,.651674],[-2.523531,.744818,-.30985],[2.891496,3.319875,2.983079],[4.781765,1.547061,1.523129],[-2.256064,7.571251,.973716],[3.244861,3.058249,2.724392],[-.145855,.437775,3.433662],[1.586296,5.658538,2.358487],[3.658336,3.774921,2.071837],[2.840463,4.817098,2.46376],[-1.219464,8.122542,-.672808],[-2.520906,2.664486,-1.034346],[-1.315417,8.471365,-.709557],[3.429165,3.74686,2.446169],[3.074579,3.840758,2.767409],[3.569443,3.166337,2.333647],[2.294337,3.280051,3.359346],[2.21816,3.66578,3.269222],[2.158662,4.151444,-1.357919],[1.13862,4.380986,-1.404565],[3.388382,2.749931,-.840949],[3.059892,5.084848,2.026066],[3.204739,2.075145,2.640706],[3.387065,1.42617,2.305275],[3.910398,2.670742,1.750179],[3.471512,1.945821,2.395881],[4.08082,1.070654,1.960171],[-1.057861,.133036,2.146707],[-.151749,5.53551,-.624323],[3.233099,4.003778,2.571172],[2.611726,5.319199,-.499388],[2.682909,1.094499,-1.206247],[-1.22823,7.656887,.041409],[-2.293247,7.259189,.013844],[.081315,.202174,3.286381],[-1.002038,5.794454,-.187194],[3.448856,4.08091,2.258325],[.287883,9.006888,-1.550641],[-3.851019,4.059839,-.646922],[3.610966,4.205438,1.913129],[2.239042,2.950872,3.449959],[.216305,.442843,3.328052],[1.87141,2.470745,3.574559],[3.811378,2.768718,-.228364],[2.511081,1.362724,2.969349],[-1.59813,7.866506,.440184],[-3.307975,2.851072,-.894978],[-.107011,8.90573,-.884399],[-3.855315,2.842597,-.434541],[2.517853,1.090768,2.799687],[3.791709,2.36685,2.002703],[4.06294,2.773922,.452723],[-2.973289,7.61703,-.623653],[-2.95509,8.924462,-3.446319],[2.861402,.562592,2.184397],[-1.109725,8.594206,-.076812],[-.725722,7.924485,-.381133],[-1.485587,1.329994,-.654405],[-4.342113,3.233735,1.752922],[-2.968049,7.955519,-2.09405],[-3.130948,.446196,.85287],[-4.958475,5.757329,1.447055],[-3.086547,7.615193,-1.953168],[-3.751923,5.412821,3.373373],[-4.599645,7.480953,1.677134],[1.133992,.274871,.032249],[-2.956512,8.126905,-1.785461],[-.960645,4.73065,-1.191786],[-2.871064,.875559,.424881],[-4.932114,5.99614,1.483845],[-2.981761,8.124612,-1.387276],[.362298,8.978545,-1.368024],[-4.408375,3.046271,.602373],[2.865841,2.322263,-1.344625],[-4.7848,5.620895,.594432],[-2.88322,.338931,1.67231],[-4.688101,6.772931,1.872318],[-4.903948,6.164698,1.27135],[2.85663,1.005647,-.906843],[2.691286,.209811,.050512],[-4.693636,6.477556,.665796],[-4.472331,6.861067,.477318],[.883065,.204907,3.073933],[-.995867,8.048729,-.653897],[-.794663,5.670397,-.390119],[3.313153,1.638006,-.722289],[-4.856459,5.394758,1.032591],[-3.005448,7.783023,-.819641],[3.11891,2.036974,-1.08689],[-2.364319,2.408419,2.63419],[-2.927132,8.75435,-3.537159],[-3.296222,7.964629,-3.134625],[-1.642041,4.13417,-1.301665],[2.030759,.176372,-1.030923],[-4.559069,3.751053,.548453],[3.438385,4.59454,-.243215],[-2.561769,7.93935,.177696],[2.990593,1.335314,-.943177],[1.2808,.276396,-.49072],[-.318889,.290684,.211143],[3.54614,3.342635,-.767878],[-3.073372,7.780018,-2.357807],[-4.455388,4.387245,.361038],[-4.659393,6.276064,2.767014],[.636799,4.482223,-1.426284],[-2.987681,8.072969,-2.45245],[-2.610445,.763554,1.792054],[3.358241,2.006707,-.802973],[-.498347,.251594,.962885],[3.1322,.683312,2.038777],[-4.389801,7.493776,.690247],[.431467,4.22119,-1.614215],[-4.376181,3.213141,.273255],[-4.872319,5.715645,.829714],[-4.826893,6.195334,.849912],[3.516562,2.23732,-.677597],[3.131656,1.698841,-.975761],[-4.754925,5.411666,1.989303],[-2.987299,7.320765,-.629479],[-3.757635,3.274862,-.744022],[3.487044,2.541999,-.699933],[-4.53274,4.649505,.77093],[-1.424192,.099423,2.633327],[3.090867,2.476975,-1.146957],[-2.713256,.815622,2.17311],[3.348121,3.254167,-.984896],[-3.031379,.16453,-.309937],[-.949757,4.518137,-1.309172],[-.889509,.095256,1.288803],[3.539594,1.966105,-.553965],[-4.60612,7.127749,.811958],[-2.332953,1.444713,1.624548],[3.136293,2.95805,-1.138272],[3.540808,3.069058,-.735285],[3.678852,2.362375,-.452543],[-4.648898,7.37438,.954791],[-.646871,.19037,3.344746],[2.2825,.29343,-.826273],[-4.422291,7.183959,.557517],[-4.694668,5.246103,2.541768],[-4.583691,4.145486,.600207],[-2.934854,7.912513,-1.539269],[-3.067861,7.817472,-.546501],[3.825095,3.229512,-.237547],[2.532494,.323059,2.387105],[-2.514583,.692857,1.23597],[-4.736805,7.214384,1.259421],[-2.98071,8.409903,-2.468199],[2.621468,1.385844,-1.406355],[3.811447,3.560855,1.847828],[3.432925,1.497205,-.489784],[3.746609,3.631538,-.39067],[3.594909,2.832257,-.576012],[-.404192,5.300188,-.856561],[-4.762996,6.483774,1.702648],[-4.756612,6.786223,1.43682],[-2.965309,8.437217,-2.785495],[2.863867,.74087,-.429684],[4.02503,2.968753,1.392419],[3.669036,1.833858,-.304971],[-2.888864,.720537,.778057],[-2.36982,.979443,1.054447],[-2.959259,8.222303,-2.659724],[-3.467825,7.545739,-2.333445],[2.153426,.446256,-1.20523],[-3.229807,9.189699,-3.596609],[-3.72486,8.773707,-2.046671],[3.687218,3.297751,-.523746],[1.381025,.08815,-1.185668],[-2.796828,7.205622,-.208783],[3.647194,4.066232,-.291507],[-4.578376,3.885556,1.52546],[-2.840262,.63094,1.89499],[-2.429514,.922118,1.820781],[-4.675079,6.573925,2.423363],[2.806207,4.320188,-1.027372],[-1.289608,.097241,1.321661],[-3.010731,8.141334,-2.866148],[3.202291,1.235617,-.549025],[4.094792,2.477519,.304581],[2.948403,.966873,-.664857],[-4.83297,5.920587,2.095461],[-2.169693,7.257277,.946184],[-1.335807,3.057597,-1.303166],[-1.037877,.64151,-1.685271],[2.627919,.089814,.439074],[3.815794,3.808102,1.730493],[-2.973455,8.433141,-3.08872],[-2.391558,7.331428,1.658264],[-4.333107,4.529978,1.850516],[-4.640293,3.767107,1.168841],[3.600716,4.46931,1.734024],[3.880803,1.730158,-.172736],[3.814183,4.262372,1.167042],[4.37325,.829542,1.413729],[2.490447,5.75111,.011492],[3.460003,4.962436,1.188971],[3.918419,3.814234,1.358271],[-.807595,8.840504,-.953711],[3.752855,4.20577,1.57177],[-2.991085,8.816501,-3.244595],[-2.333196,7.128889,1.551985],[3.977718,3.570941,1.25937],[4.360071,.755579,1.079916],[4.637579,1.027973,1.032567],[-2.317,7.421066,1.329589],[-1.013404,8.293662,-.7823],[4.548023,1.020644,1.420462],[4.763258,1.266798,1.296203],[4.896,2.073084,1.255213],[4.015005,3.325226,1.093879],[4.94885,1.860936,.894463],[-2.189645,6.954634,1.270077],[4.887442,1.720992,1.288526],[-3.184068,7.871802,.956189],[-1.274318,.839887,-1.224389],[-2.919521,7.84432,.541629],[-2.994586,7.766102,1.96867],[-3.417504,9.241714,-3.093201],[-3.174563,7.466456,2.473617],[-3.263067,9.069412,-3.003459],[-2.841592,.529833,2.693434],[-3.611069,9.158804,-2.829871],[-4.642828,5.927526,.320549],[-3.809308,9.051035,-2.692749],[-2.837582,7.487987,-.106206],[4.773025,2.330442,1.213899],[4.897435,2.209906,.966657],[-3.067637,8.164062,-1.12661],[-3.122129,8.08074,-.899194],[4.571019,2.358113,1.462054],[4.584884,2.454418,.709466],[-3.661093,7.146581,-.475948],[4.735131,2.415859,.933939],[4.207556,2.540018,1.218293],[-3.607595,7.89161,-.121172],[-1.527952,.775564,-1.061903],[4.53874,2.503273,1.099583],[-3.938837,7.587988,.082449],[-4.853582,6.152409,1.787943],[-4.752214,6.247234,2.296873],[4.602935,2.363955,.488901],[-1.81638,6.365879,.868272],[.595467,4.744074,-1.32483],[1.87635,3.511986,-1.842924],[4.330947,2.534326,.720503],[4.108736,2.750805,.904552],[-1.890939,8.492628,-.290768],[-3.504309,6.173058,-.422804],[-1.611992,6.196732,.648736],[-3.899149,7.826123,1.088845],[-3.078303,3.008813,-1.035784],[-2.798999,7.844899,1.340061],[-1.248839,5.959105,.041761],[.767779,4.337318,3.090817],[-3.831177,7.515605,2.432261],[-1.667528,6.156208,.365267],[-1.726078,6.237384,1.100059],[-3.972037,4.520832,-.370756],[-4.40449,7.636357,1.520425],[-1.34506,6.004054,1.293159],[-1.233556,6.049933,.500651],[-3.696869,7.79732,.37979],[-3.307798,8.949964,-2.698113],[-1.997295,6.615056,1.103691],[-3.219222,8.336394,-1.150614],[-3.452623,8.31866,-.9417],[-3.94641,2.990494,2.212592],[-3.250025,8.030414,-.596097],[-2.02375,1.571333,2.397939],[-3.190358,7.665013,2.268183],[-2.811918,7.618526,2.145587],[-1.005265,5.892303,.072158],[-.93721,5.974148,.906669],[-4.646072,7.492193,1.45312],[-.252931,1.797654,3.140638],[-1.076064,5.738433,1.695953],[-3.980534,7.744391,1.735791],[-.721187,5.939396,.526032],[-.42818,5.919755,.229001],[-1.43429,6.11622,.93863],[-.985638,5.939683,.290636],[-4.433836,7.461372,1.966437],[-3.696398,7.844859,1.547325],[-3.390772,7.820186,1.812204],[-2.916787,7.864019,.804341],[-3.715952,8.037269,-.591341],[-4.204634,7.72919,1.119866],[-4.592233,5.592883,.246264],[3.307299,5.061701,1.622917],[-3.515159,7.601467,2.368914],[-3.435742,8.533457,-1.37916],[-.269421,4.545635,-1.366445],[-2.542124,3.768736,-1.258512],[-3.034003,7.873773,1.256854],[-2.801399,7.856028,1.080137],[3.29354,5.220894,1.081767],[-2.35109,1.299486,1.01206],[-3.232213,7.768136,2.047563],[3.290415,5.217525,.68019],[-3.415109,7.731034,2.144326],[3.440357,4.962463,.373387],[3.147346,5.352121,1.386923],[2.847252,5.469051,1.831981],[3.137682,5.410222,1.050188],[3.102694,5.310456,1.676434],[-3.044601,.39515,1.994084],[2.903647,5.561338,1.518598],[-3.810148,8.093598,-.889131],[4.234835,.803054,1.593271],[3.240165,5.228747,.325955],[3.037452,5.509825,.817137],[2.635031,5.795187,1.439724],[3.071607,5.318303,.080142],[2.909167,5.611751,1.155874],[3.044889,5.465928,.486566],[2.502256,5.770673,1.740054],[-.067497,.086416,-1.190239],[2.33326,5.906051,.138295],[.65096,4.205423,3.308767],[-2.671137,7.936535,.432731],[2.14463,5.879214,1.866047],[-4.776469,5.890689,.561986],[2.72432,5.655145,.211951],[2.730488,5.751455,.695894],[2.572682,5.869295,1.152663],[1.906776,5.739123,2.196551],[2.344414,5.999961,.772922],[-3.377905,7.448708,-1.863251],[2.285149,5.968156,1.459258],[2.385989,5.928974,.3689],[2.192111,6.087516,.959901],[2.36372,6.001101,1.074346],[1.972022,6.079603,1.591175],[1.87615,5.976698,1.91554],[-3.824761,9.05372,-2.928615],[2.044704,6.129704,1.263111],[-2.583046,.849537,2.497344],[-.078825,2.342205,3.520322],[-.704686,.537165,3.397194],[-.257449,3.235334,3.647545],[-.332064,1.448284,3.022583],[-2.200146,.898284,-.447212],[-2.497508,1.745446,1.829167],[.30702,4.416315,2.978956],[-3.205197,3.479307,-1.040582],[.110069,9.347725,-1.563686],[-.82754,.883886,3.065838],[-2.017103,1.244785,2.42512],[-.421091,2.309929,3.153898],[-.491604,3.796072,3.16245],[2.786955,3.501241,-1.340214],[-3.229055,4.380713,-.899241],[3.730768,.76845,1.90312],[-.561079,2.652382,3.152463],[-3.461471,3.086496,2.662505],[-.661405,3.446009,3.179939],[-.915351,.636755,3.243708],[-2.992964,8.915628,-3.729833],[-.439627,3.502104,3.42665],[-1.154217,.883181,2.800835],[-1.736193,1.465474,2.595489],[-.423928,3.24435,3.548277],[-.511153,2.871046,3.379749],[-.675722,2.991756,3.143262],[-1.092602,.599103,3.090639],[-.89821,2.836952,2.840023],[-2.658412,.781376,.960575],[-2.271455,1.222857,1.330478],[-.877861,1.111222,2.72263],[-.306959,2.876987,3.556044],[-3.839274,7.84138,-.918404],[-.172094,4.083799,3.141708],[-1.548332,.2529,2.864655],[-.217353,4.873911,-1.223104],[-3.384242,3.181056,-.95579],[-2.731704,.382421,2.895502],[-1.285037,.551267,2.947675],[.077224,4.246579,3.066738],[-.479979,1.77955,2.860011],[-.716375,1.224694,2.666751],[-.54622,3.138255,3.393457],[-2.33413,1.821222,2.124883],[-.50653,2.037147,2.897465],[2.451291,1.211389,-1.466589],[-3.160047,2.894081,2.724286],[-4.137258,5.433431,3.21201],[.462896,.320456,-.174837],[-.37458,2.609447,3.379253],[-3.095244,.256205,2.196446],[-4.197985,5.732991,3.262924],[-.729747,.246036,.497036],[-2.356189,5.062,-.965619],[-1.609036,.25962,-1.487367],[-4.074381,6.074061,3.409459],[-3.619304,4.0022,2.65705],[-.543393,8.742896,-1.056622],[-4.30356,6.858934,2.879642],[-.716688,2.901831,-2.11202],[1.547362,.083189,1.138764],[-.250916,.275268,1.201344],[-3.778035,3.13624,2.466177],[-4.594316,5.771342,3.01694],[-3.717706,3.442887,2.603344],[-4.311163,5.224669,3.019373],[-.610389,2.095161,-1.923515],[-3.040086,6.196918,-.429149],[-3.802695,3.768247,2.545523],[-.159541,2.043362,3.328549],[-3.744329,4.31785,2.491889],[-3.047939,.214155,1.873639],[-4.41685,6.113058,3.166774],[-1.165133,.460692,-1.742134],[-1.371289,4.249996,-1.317935],[-3.447883,.3521,.466205],[-4.495555,6.465548,2.944147],[-3.455335,.171653,.390816],[-3.964028,4.017196,2.376009],[-1.323595,1.763126,-.750772],[-3.971142,5.277524,-.19496],[-3.222052,.237723,.872229],[-4.403784,3.89107,1.872077],[-3.333311,.342997,.661016],[-4.495871,4.29606,1.63608],[-3.636081,2.760711,2.361949],[-4.487235,3.559608,1.66737],[-4.719787,7.26888,1.658722],[-1.086143,9.035741,-.707144],[-2.339693,1.600485,-.404817],[-4.642011,7.123829,1.990987],[-1.498077,3.854035,-1.369787],[-4.188372,4.729363,2.02983],[-3.116344,5.882284,-.468884],[-4.305236,4.246417,1.976991],[-3.022509,.22819,1.065688],[-2.799916,.52022,1.128319],[-4.262823,3.534409,2.020383],[-4.221533,3.947676,2.11735],[-3.744353,4.391712,-.6193],[-1.272905,.156694,-1.741753],[-3.62491,2.669825,-.549664],[-4.180756,3.096179,1.987215],[-4.059276,4.305313,2.232924],[-2.812753,.183226,1.370267],[-4.032437,3.512234,2.309985],[-.03787,.28188,.530391],[-4.711562,5.468653,2.822838],[-4.500636,6.953314,2.564445],[-4.479433,7.216991,2.270682],[3.990562,.50522,.716309],[-2.512229,6.863447,-.100658],[-2.968058,6.956639,-.37061],[2.550375,3.142683,-1.54068],[-2.320059,3.521605,-1.279397],[-4.556319,6.64662,2.745363],[-4.281091,7.108116,2.667598],[-2.050095,8.411689,.121353],[-2.44854,1.135487,.851875],[3.121815,.699943,-.277167],[-4.69877,6.00376,2.843035],[-1.360599,8.824742,-.595597],[1.128437,.171611,.301691],[-4.360146,6.289423,.042233],[1.400795,4.088829,-1.620409],[-3.193462,8.460137,-3.559446],[-3.168771,8.878431,-3.635795],[-3.434275,9.304302,-3.460878],[-3.349993,8.808093,-3.38179],[-3.304823,8.323865,-3.325905],[-3.572607,9.308843,-3.207672],[-3.166393,8.201215,-3.43014],[-3.451638,9.05331,-3.351345],[-3.309591,8.549758,-3.375055],[-3.527992,8.793926,-3.100376],[-3.6287,8.981677,-3.076319],[-3.445505,8.001887,-2.8273],[-3.408011,8.221014,-3.039237],[-3.65928,8.740382,-2.808856],[-3.878019,8.797295,-2.462866],[-3.515132,8.232341,-2.747739],[-3.460331,8.51524,-3.06818],[-3.403703,7.658628,-2.648789],[-3.507113,8.00159,-2.582275],[-3.607373,8.174737,-2.401723],[-3.749043,8.378084,-2.226959],[-3.648514,8.502213,-2.6138],[-2.534199,.904753,2.021148],[1.4083,5.744252,-.571402],[-3.852536,8.571009,-2.352358],[2.868255,5.373126,-.163705],[2.224363,4.669891,-1.061586],[-4.528281,4.885838,1.340274],[1.30817,4.609629,-1.28762],[-4.519698,3.422501,1.354826],[-3.549955,7.783228,-2.332859],[1.12313,6.120856,.045115],[-3.620324,7.57716,-2.033423],[-.798833,2.624133,-1.992682],[-3.617587,7.783148,-2.051383],[-3.669293,8.103776,-2.10227],[-3.892417,8.667436,-2.167288],[-.537435,.285345,-.176267],[-.841522,3.299866,-1.887861],[-.761547,3.647082,-1.798953],[-3.661544,7.85708,-1.867924],[-3.886763,8.551783,-1.889171],[-.591244,1.549749,-1.714784],[-.775276,1.908218,-1.597609],[-.961458,2.573273,-1.695549],[-2.215672,1.335009,2.143031],[-4.622674,4.130242,1.220683],[1.07344,.290099,1.584734],[-.976906,2.92171,-1.76667],[-1.13696,3.194401,-1.513455],[-3.743262,7.99949,-1.629286],[-2.876359,4.900986,-.879556],[.550835,3.905557,-2.031372],[.777647,4.992314,-1.215703],[1.445881,4.266201,-1.414663],[1.274222,5.510543,-.824495],[-.864685,2.318581,-1.702389],[-.627458,3.820722,-1.743153],[-3.867699,8.30866,-1.850066],[1.635287,5.45587,-.83844],[-1.037876,2.538589,-1.513504],[-4.38993,4.73926,1.699639],[.048709,4.765232,-1.279506],[-.626548,1.339887,-1.595114],[-3.682827,7.643453,-1.723398],[-3.868783,8.180191,-1.511743],[-.76988,1.508373,-1.419599],[-1.138374,2.766765,-1.448163],[1.699883,5.780752,-.475361],[1.214305,.308517,1.866405],[-1.713642,.373461,-1.265204],[-1.582388,.58294,-1.267977],[-.879549,1.821581,-1.313787],[.519057,5.858757,-.381397],[-3.770989,2.449208,-.132655],[.087576,.156713,-1.53616],[-.942622,2.146534,-1.421494],[-1.026192,1.022164,-1.145423],[-.964079,1.645473,-1.067631],[-1.109128,2.458789,-1.29106],[-1.037478,.209489,-1.805424],[-3.724391,7.599686,-1.273458],[-3.787898,7.951792,-1.304794],[3.821677,2.165581,-.181535],[-2.39467,.304606,-.570375],[-2.352928,1.0439,2.079369],[-.288899,9.640684,-1.006079],[-3.472118,7.263001,-1.080326],[-1.240769,.972352,-.976446],[-1.845253,.356801,-.995574],[-2.32279,7.915361,-.057477],[-1.08092,2.179315,-1.168821],[4.598833,2.156768,.280264],[-4.725417,6.442373,2.056809],[-.490347,9.46429,-.981092],[-1.99652,.09737,-.765828],[-1.137793,1.888846,-.894165],[-.37247,4.29661,-1.465199],[-.184631,5.692946,-.421398],[-3.751694,7.742231,-1.086908],[-1.001416,1.298225,-.904674],[-3.536884,7.190777,-.788609],[-3.737597,7.511281,-.940052],[-1.766651,.669388,-.873054],[3.112245,3.474345,-1.129672],[-.175504,3.81298,-2.0479],[-3.766762,7.412514,-.681569],[-.63375,9.439424,-.785128],[-.518199,4.768982,-1.258625],[.790619,4.212759,-1.610218],[-3.761951,3.742528,-.756283],[.897483,5.679808,-.612423],[2.221126,4.427468,-1.252155],[-.728577,5.846457,.062702],[.194451,9.503908,-1.482461],[-.099243,9.385459,-1.39564],[.643185,3.636855,-2.180247],[.894522,5.900601,-.356935],[2.595516,4.75731,-.893245],[1.108497,3.936893,-1.905098],[1.989894,5.789726,-.343268],[-3.802345,7.655508,-.613817],[2.339353,4.96257,-.90308],[.12564,4.013324,-1.879236],[-4.078965,3.683254,-.445439],[2.092899,5.256128,-.831607],[.427571,.291769,1.272964],[2.335549,3.480056,-1.581949],[-.15687,.324827,-1.648922],[-.536522,5.760786,-.203535],[1.507082,.078251,-.923109],[-1.854742,.134826,2.698774],[-3.939827,3.168498,-.526144],[-3.98461,3.39869,-.533212],[-3.961738,4.217132,-.489147],[4.273789,2.181164,.153786],[-.470498,5.645664,-.439079],[-.414539,5.488017,-.673379],[-.097462,5.062739,-1.114863],[1.198092,5.882232,-.391699],[2.855834,5.085022,-.498678],[1.037998,4.129757,-1.701811],[1.728091,5.068444,-1.063761],[-3.832258,2.625141,-.311384],[-4.078526,3.070256,-.284362],[-4.080365,3.954243,-.440471],[-.152578,5.276267,-.929815],[-1.489635,8.928082,-.295891],[.759294,5.15585,-1.087374],[-4.000338,2.801647,-.235135],[-4.290801,3.823209,-.19374],[-4.221493,4.25618,-.189894],[-4.066195,4.71916,-.201724],[-.155386,4.076396,-1.662865],[3.054571,4.414305,-.825985],[-1.652919,8.726499,-.388504],[-3.042753,.560068,-.126425],[-2.434456,1.118088,-.213563],[-2.623502,1.845062,-.283697],[-4.233371,3.43941,-.202918],[2.726702,3.82071,-1.280097],[.184199,4.14639,-1.673653],[-1.289203,.624562,-1.560929],[-3.823676,7.382458,-.407223],[.476667,5.064419,-1.143742],[-3.873651,4.955112,-.269389],[1.349666,5.312227,-1.000274],[-2.043776,8.434488,-.108891],[-2.763964,.733395,-.129294],[-4.380505,3.664409,-.024546],[-.71211,5.341811,-.803281],[-3.960858,7.183112,-.118407],[-3.822277,7.712853,-.263221],[-2.346808,8.108588,.063244],[-1.841731,8.642999,-.142496],[-2.600055,.985604,-.043595],[-3.513057,2.213243,-.044151],[-3.963492,2.603055,-.080898],[-4.258066,3.14537,-.027046],[-4.261572,5.00334,.13004],[.795464,3.99873,-1.905688],[-3.300873,.384761,.013271],[-2.770244,.881942,.077313],[-3.456227,1.993871,.301054],[-4.441987,3.914144,.177867],[-4.367075,6.611414,.165312],[-3.201767,.576292,.105769],[-3.174354,.645009,.440373],[-2.996576,.74262,.161325],[-2.724979,1.656497,.092983],[-3.261757,2.017742,-.070763],[-4.280173,4.518235,-.002999],[-4.471073,5.945358,.05202],[-3.877137,2.40743,.274928],[-4.371219,4.252758,.078039],[-3.400914,.40983,.238599],[-4.44293,3.523242,.146339],[-4.574528,5.279761,.353923],[-4.226643,7.191282,.269256],[-4.16361,2.843204,.097727],[-4.528506,5.011661,.536625],[.35514,5.664802,-.572814],[2.508711,5.580976,-.266636],[2.556226,3.633779,-1.426362],[1.878456,4.533714,-1.223744],[2.460709,4.440241,-1.1395],[2.218589,5.514603,-.560066],[2.263712,5.737023,-.250694],[2.964981,3.814858,-1.139927],[.991384,5.304131,-.999867],[2.81187,4.547292,-.916025],[2.918089,4.768382,-.702808],[3.262403,4.414286,-.657935],[.652136,6.089113,.069089],[3.361389,3.5052,-.946123],[2.613042,5.037192,-.697153],[.094339,4.36858,-1.451238],[3.290862,4.155716,-.732318],[2.658063,4.073614,-1.217455],[3.260349,3.753257,-.946819],[1.124268,4.862463,-1.207855],[3.35158,4.899247,-.027586],[3.194057,4.691257,-.524566],[3.090119,5.116085,-.23255],[2.418965,3.811753,-1.419399],[2.191789,3.877038,-1.47023],[4.043166,2.034188,.015477],[-1.026966,.86766,-1.410912],[1.937563,3.860005,-1.617465],[2.98904,4.101806,-.998132],[-.142611,5.865305,-.100872],[3.972673,2.292069,.089463],[3.23349,3.959925,-.849829],[.16304,5.857276,-.216704],[4.122964,1.770061,-.114906],[2.099057,4.978374,-.98449],[3.502411,3.76181,-.667502],[2.079484,5.939614,-.036205],[-.084568,3.525193,-2.253506],[.423859,4.06095,-1.845327],[1.6013,6.006466,-.153429],[.271701,3.844964,-2.078748],[.273577,5.218904,-.994711],[-.410578,3.92165,-1.773635],[1.941954,5.60041,-.621569],[.100825,5.462131,-.774256],[-.53016,3.619892,-2.027451],[-.822371,5.517453,-.605747],[-2.474925,7.670892,-.020174],[4.01571,.830194,-.013793],[-.400092,5.094112,-1.041992],[-2.887284,5.581246,-.525324],[-1.559841,6.050972,.079301],[-.469317,3.291673,-2.235211],[.337397,3.467926,-2.295458],[-2.632074,5.573701,-.582717],[-.030318,6.011395,.276616],[-.934373,.388987,-1.780523],[-2.661263,5.844838,-.425966],[.549353,5.489646,-.807268],[-2.194355,6.197491,-.109322],[-2.289618,5.664813,-.581098],[1.583583,3.796366,-1.844498],[.855295,.215979,-1.425557],[-2.627569,5.300236,-.767174],[4.333347,2.384332,.399129],[-1.880401,5.583843,-.696561],[-2.172346,5.324859,-.846246],[-2.27058,5.906265,-.388373],[-1.960049,5.889346,-.397593],[.965756,3.67547,-2.105671],[-2.014066,6.431125,.287254],[-1.776173,5.287097,-.89091],[-2.025852,5.089562,-.980218],[-1.886418,6.108358,-667e-6],[-1.600803,5.785347,-.491069],[-1.66188,4.968053,-1.042535],[-1.600621,5.962818,-.188044],[-1.588831,5.615418,-.665456],[4.46901,1.880138,.057248],[-1.978845,.927399,-.554856],[-1.408074,5.325266,-.83967],[1.923123,4.843955,-1.101389],[-2.87378,.117106,-.412735],[-1.222193,5.62638,-.539981],[-2.632537,.166349,-.489218],[-1.370865,5.838832,-.341026],[-1.067742,5.448874,-.692701],[-1.073798,5.220878,-.908779],[-1.147562,4.950417,-1.079727],[-2.789115,4.531047,-1.042713],[-3.550826,4.170487,-.806058],[-3.331694,4.798177,-.69568],[-3.689404,4.688543,-.534317],[-3.511509,5.106246,-.483632],[1.796344,.076137,.080455],[-3.306354,5.473605,-.478764],[-2.692503,3.346604,-1.20959],[-3.963056,5.187462,3.113156],[-3.901231,6.391477,-.246984],[4.484234,1.518638,-.001617],[4.308829,1.657716,-.119275],[4.290045,1.339528,-.110626],[-3.514938,3.524974,-.909109],[-2.1943,2.12163,-.71966],[4.108206,1.091087,-.11416],[3.785312,1.392435,-.28588],[4.092886,1.480476,-.210655],[-2.965937,6.469006,-.379085],[-3.708581,2.962974,-.63979],[-3.297971,2.218917,-.299872],[3.806949,.804703,-.11438],[3.747957,1.059258,-.273069],[-3.101827,4.111444,-1.006255],[-1.536445,4.658913,-1.195049],[-3.549826,2.450555,-.375694],[-3.676495,2.108366,.534323],[-3.674738,5.925075,-.400011],[-2.250115,2.848335,-1.121174],[-3.698062,5.667567,-.381396],[3.468966,.734643,-.190624],[-3.97972,5.670078,-.26874],[-3.002087,4.337837,-1.033421],[-3.356392,2.608308,-.713323],[-1.833016,3.359983,-1.28775],[-1.989069,3.632416,-1.305607],[3.591254,.542371,.026146],[3.364927,1.082572,-.342613],[-3.393759,3.866801,-.937266],[-4.124865,5.549529,-.161729],[-4.423423,5.687223,103e-6],[-1.496881,2.601785,-1.114328],[-2.642297,6.496932,-.264175],[-3.684236,6.819423,-.320233],[-2.286996,3.167067,-1.246651],[-1.624896,8.44848,-.530014],[-3.666787,2.159266,.268149],[-2.402625,2.011243,-.56446],[-2.736166,2.259839,-.6943],[-2.168611,3.89078,-1.292206],[-2.065956,3.345708,-1.281346],[-2.778147,2.675605,-.995706],[-3.507431,4.513272,-.71829],[-2.301184,4.293911,-1.238182],[3.205808,.211078,.394349],[-2.129936,4.870577,-1.080781],[-2.287977,2.496593,-.934069],[-2.701833,2.931814,-1.114509],[3.294795,.50631,-.081062],[-2.552829,7.468771,-.021541],[3.06721,.944066,-.43074],[-2.86086,1.973622,-.303132],[-3.598818,5.419613,-.401645],[-1.524381,.080156,-1.61662],[-1.907291,2.646274,-1.039438],[2.950783,.407562,-.105407],[-1.663048,1.655038,-.689787],[-1.728102,1.110064,-.635963],[-2.085823,7.686296,-.159745],[2.883518,3.157009,-1.30858],[-2.724116,.417169,-.389719],[-1.788636,7.862672,-.346413],[-2.186418,1.249609,-.434583],[-3.092434,2.606657,-.860002],[-1.737314,3.874201,-1.330986],[2.564522,.422967,-.390903],[1.670782,3.538432,-1.924753],[-2.338131,4.02578,-1.286673],[-1.916516,4.054121,-1.301788],[2.87159,2.034949,-1.267139],[-1.931518,3.062883,-1.197227],[-.816602,.135682,3.104104],[.469392,.213916,-1.489608],[2.574055,1.950091,-1.514427],[2.733595,2.682546,-1.461213],[-1.915407,4.693647,-1.151721],[-3.412883,5.867094,-.450528],[2.28822,.120432,-.04102],[2.244477,.14424,-.376933],[-1.676198,3.570698,-1.328031],[-1.821193,4.366982,-1.266271],[-1.552208,8.099221,-.53262],[-1.727419,2.39097,-.989456],[-2.468226,4.711663,-1.069766],[-2.451669,6.113319,-.273788],[2.635447,2.295842,-1.518361],[-2.020809,8.150253,-.246714],[2.292455,.805596,-1.3042],[2.641556,1.65665,-1.466962],[2.409062,2.842538,-1.635025],[2.456682,1.459484,-1.57543],[-1.691047,3.173582,-1.247082],[-1.865642,1.957608,-.768683],[-3.401579,.20407,.100932],[2.301981,1.7102,-1.650461],[2.342929,2.611944,-1.690713],[-1.676111,2.923894,-1.17835],[-2.992039,3.547631,-1.118945],[-3.571677,6.504634,-.375455],[2.141764,1.460869,-1.702464],[-3.221958,5.146049,-.615632],[2.19238,2.949367,-1.747242],[2.320791,2.232971,-1.706842],[2.088678,2.585235,-1.813159],[-2.196404,.592218,-.569709],[-2.120811,1.836483,-.62338],[-1.949935,2.271249,-.874128],[2.235901,1.110183,-1.510719],[2.020157,3.241128,-1.803917],[2.054336,1.949394,-1.792332],[-3.094117,4.996595,-.740238],[2.038063,.635949,-1.402041],[1.980644,1.684408,-1.76778],[1.587432,3.306542,-1.991131],[1.935322,.976267,-1.602208],[1.922621,1.235522,-1.698813],[1.712495,1.911874,-1.903234],[1.912802,2.259273,-1.888698],[1.884367,.355453,-1.312633],[1.676427,.76283,-1.539455],[1.78453,2.83662,-1.943035],[1.697312,.120281,-1.150324],[1.648318,2.484973,-1.999505],[-4.051804,5.958472,-.231731],[-1.964823,1.464607,-.58115],[1.55996,2.183486,-1.971378],[1.628125,1.045912,-1.707832],[1.701684,1.540428,-1.827156],[1.567475,4.869481,-1.184665],[1.432492,.843779,-1.648083],[1.173837,2.978983,-2.156687],[1.235287,3.37975,-2.09515],[1.252589,1.525293,-1.949205],[1.159334,2.336379,-2.105361],[1.49061,2.695263,-2.083216],[-4.122486,6.782604,-.02545],[1.173388,.279193,-1.423418],[1.505684,.380815,-1.414395],[1.391423,1.343031,-1.843557],[1.263449,2.73225,-2.144961],[1.295858,.597122,-1.515628],[1.245851,3.729126,-1.993015],[-2.761439,6.23717,-.365856],[.978887,1.664888,-2.046633],[1.219542,.982729,-1.785486],[1.315915,1.91748,-2.02788],[-3.052746,2.127222,-.369082],[.977656,1.36223,-1.944119],[.936122,3.39447,-2.203007],[-2.740036,4.184702,-1.122849],[.853581,2.864694,-2.260847],[.719569,.818762,-1.763618],[.839115,1.159359,-1.907943],[.932069,1.94559,-2.117962],[.579321,3.326747,-2.299369],[.86324,.597822,-1.565106],[.574567,1.158452,-1.943123],[.525138,2.137252,-2.213867],[.779941,2.342019,-2.206157],[.915255,2.618102,-2.209041],[.526426,3.02241,-2.321826],[.495431,2.521396,-2.295905],[.80799,3.156817,-2.286432],[.273556,1.304936,-2.012509],[.664326,1.530024,-2.048722],[.219173,2.32907,-2.323212],[.405324,.695359,-1.704884],[.398827,.946649,-1.843899],[.345109,1.608829,-2.100174],[-2.356743,.062032,-.4947],[-3.001084,.27146,2.560034],[-2.064663,.303055,-.697324],[.221271,3.174023,-2.374399],[.195842,.437865,-1.621473],[-.385613,.297763,1.960096],[1.999609,.108928,-.79125],[.351698,9.227494,-1.57565],[.021477,2.191913,-2.309353],[.246381,2.836575,-2.356365],[1.543281,.237539,1.901906],[.031881,9.147022,-1.454203],[-.001881,1.648503,-2.108044],[.333423,1.907088,-2.204533],[.044063,2.634032,-2.368412],[-.028148,3.053684,-2.390082],[.02413,3.34297,-2.36544],[-.272645,9.02879,-1.238685],[-.006348,.832044,-1.758222],[-.321105,1.458754,-1.886313],[-.153948,8.618809,-1.105353],[-.409303,1.137783,-1.720556],[-.410054,1.742789,-1.957989],[-.287905,2.380404,-2.294509],[-.261375,2.646629,-2.356322],[-.221986,3.215303,-2.345844],[-.31608,.687581,-1.71901],[-.537705,.855802,-1.648585],[-.142834,1.193053,-1.87371],[-.24371,2.044435,-2.176958],[-.437999,2.959748,-2.299698],[-.78895,.176226,-1.729046],[-.608509,.546932,-1.734032],[-.693698,4.478782,-1.369372],[-.669153,8.469645,-.911149],[-.741857,1.082705,-1.458474],[-.554059,2.440325,-2.141785],[2.09261,.153182,2.57581],[1.792547,.111794,2.563777],[1.855787,.189541,2.835089],[1.492601,.232246,2.987681],[-.284918,.236687,3.429738],[2.604841,.11997,1.01506],[.331271,.168113,3.124031],[.280606,.308368,2.495937],[.544591,.325711,2.081274],[.193145,.19154,-.977556],[3.810099,.42324,1.032202],[3.54622,.379245,1.392814],[.61402,.276328,.849356],[-1.198628,.144953,2.911457],[4.17199,.68037,1.391526],[.88279,.321339,2.059129],[1.93035,.109992,2.054154],[1.620331,.121986,2.37203],[2.374812,.10921,1.734876],[-.031227,.294412,2.593687],[4.075018,.561914,1.038065],[-.570366,.126583,2.975558],[.950052,.318463,1.804012],[1.130034,.117125,.98385],[2.123049,.08946,1.665911],[2.087572,.068621,.335013],[2.927337,.167117,.289611],[.528876,.313434,3.205969],[1.174911,.162744,1.328262],[-4.88844,5.59535,1.661134],[-4.709607,5.165338,1.324082],[.871199,.277021,1.263831],[-3.910877,2.349318,1.272269],[1.56824,.118605,2.768112],[1.179176,.152617,-.858003],[1.634629,.247872,2.128625],[-4.627425,5.126935,1.617836],[3.845542,.54907,1.45601],[2.654006,.165508,1.637169],[-.678324,.26488,1.974741],[2.451139,.100377,.213768],[.633199,.286719,.403357],[-.533042,.2524,1.373267],[.99317,.171106,.624966],[-.100063,.306466,2.170225],[1.245943,.092351,.661031],[1.390414,.198996,-.0864],[-4.457265,5.030531,2.138242],[2.89776,.146575,1.297468],[1.802703,.088824,-.490405],[1.055447,.309261,2.392437],[2.300436,.142429,2.104254],[2.33399,.187756,2.416935],[2.325183,.134349,.574063],[2.410924,.370971,2.637115],[1.132924,.290511,3.061],[1.764028,.070212,-.80535],[2.156994,.397657,2.844061],[.920711,.225527,-.882456],[-4.552135,5.24096,2.85514],[.210016,.309396,2.064296],[.612067,.136815,-1.086002],[3.150236,.426757,1.802703],[-.24824,.282258,1.470997],[.974269,.301311,-.640898],[-4.401413,5.03966,2.535553],[.644319,.274006,-.817806],[.332922,.309077,.108474],[3.610001,.317447,.689353],[3.335681,.358195,.118477],[.623544,.318983,-.4193],[-.11012,.307747,1.831331],[-.407528,.291044,2.282935],[.069783,.285095,.950289],[.970135,.310392,-.283742],[.840564,.306898,.098854],[-.541827,.267753,1.683795],[-3.956082,4.55713,2.297164],[-4.161036,2.834481,1.64183],[-4.093952,4.977551,2.747747],[2.661819,.261867,1.926145],[-3.749926,2.161875,.895238],[-2.497776,1.3629,.791855],[.691482,.304968,1.582939],[-4.013193,4.830963,2.4769],[-3.639585,2.091265,1.304415],[-3.9767,2.563053,1.6284],[-3.979915,2.788616,1.977977],[.388782,.312656,1.709168],[-3.40873,1.877324,.851652],[-3.671637,5.136974,3.170734],[-3.12964,1.852012,.157682],[-3.629687,4.852698,2.686837],[-3.196164,1.793459,.452804],[-3.746338,2.31357,1.648551],[2.992192,.125251,.575976],[-3.254051,.054431,.314152],[-3.474644,1.925288,1.134116],[-3.418372,2.022882,1.578901],[-2.920955,1.705403,.29842],[-3.57229,2.152022,1.607572],[-3.251259,.09013,-.106174],[-3.299952,1.877781,1.348623],[-3.666819,2.441459,2.004838],[-2.912646,1.824748,-.045348],[-3.399511,2.479484,2.340393],[-3.009754,.015286,.075567],[-3.381443,2.316937,2.156923],[-3.352801,2.133341,1.857366],[-3.01788,1.687685,.645867],[-2.931857,1.678712,1.158472],[-3.301008,.08836,.591001],[1.358025,.19795,1.599144],[-2.999565,1.845016,1.618396],[-2.767957,.028397,-.196436],[-2.93962,2.078779,2.140593],[-3.346648,2.674056,2.518097],[3.324322,.20822,.628605],[3.091677,.137202,.9345],[-2.881807,.009952,.318439],[-2.764946,1.786619,1.693439],[-2.905542,1.932343,1.900002],[-3.140854,2.271384,2.274946],[-2.88995,2.487856,2.574759],[-2.367194,-943e-6,-.15576],[-3.050738,.068703,.742988],[-2.759525,1.55679,.877782],[-3.151775,2.48054,2.482749],[-2.578618,-.002885,.165716],[-2.651618,1.877246,1.981189],[-2.933973,.133731,1.631023],[1.047628,.100284,-1.085248],[-1.585123,.062083,-1.394896],[-2.287917,-.002671,.214434],[-2.524899,.007481,.471788],[-2.815492,2.188198,2.343294],[-2.095142,-.003149,-.094574],[-2.172686,-133e-6,.47963],[-2.732704,.074306,1.742079],[-2.49653,2.145668,2.42691],[-1.343683,.047721,-1.506391],[-2.581185,.048703,.975528],[-2.905101,.083158,2.010052],[-2.601514,2.007801,2.223089],[-2.339464,.02634,1.484304],[-2.907873,.10367,2.378149],[-1.368796,.062516,-1.049125],[-1.93244,.02443,-.427603],[-2.705081,.060513,2.303802],[3.372155,.206274,.892293],[-1.761827,.093202,-1.037404],[-1.700667,.0397,-.614221],[-1.872291,.011979,-.135753],[-1.929257,.074005,.728999],[-2.520128,.049665,1.99054],[-2.699411,.10092,2.603116],[3.211701,.27302,1.423357],[-1.445362,.1371,-.626491],[2.921332,.259112,1.645525],[-.993242,.058686,-1.408916],[-.944986,.157541,-1.097665],[-2.154301,.032749,1.882001],[-2.108789,1.988557,2.442673],[-1.015659,.25497,-.416665],[-1.898411,.015872,.16715],[-1.585517,.027121,.453445],[-2.311105,.061264,2.327061],[-2.637042,.152224,2.832201],[-2.087515,2.292972,2.617585],[-.750611,.056697,-1.504516],[-.472029,.075654,-1.360203],[-.710798,.139244,-1.183863],[-.97755,.26052,-.831167],[-.655814,.260843,-.880068],[-.897513,.275537,-.133042],[-2.049194,.084947,2.455422],[-.177837,.076362,-1.449009],[-.553393,.279083,-.59573],[-1.788636,.06163,2.231198],[-.34761,.255578,-.999614],[-1.398589,.036482,.65871],[-1.133918,.05617,.69473],[-1.43369,.058226,1.977865],[-2.505459,1.492266,1.19295]]; | |
exports.cells=[[2,1661,3],[1676,7,6],[712,1694,9],[3,1674,1662],[11,1672,0],[1705,0,1],[5,6,1674],[4,5,1674],[7,8,712],[2,1662,10],[1,10,1705],[11,1690,1672],[1705,11,0],[5,1676,6],[7,9,6],[7,712,9],[2,3,1662],[3,4,1674],[1,2,10],[12,82,1837],[1808,12,1799],[1808,1799,1796],[12,861,82],[861,1808,13],[1808,861,12],[1799,12,1816],[1680,14,1444],[15,17,16],[14,1678,1700],[16,17,1679],[15,1660,17],[14,1084,1678],[15,1708,18],[15,18,1660],[1680,1084,14],[1680,15,1084],[15,1680,1708],[793,813,119],[1076,793,119],[1076,1836,22],[23,19,20],[21,1076,22],[21,22,23],[23,20,21],[1076,119,1836],[806,634,470],[432,1349,806],[251,42,125],[809,1171,791],[953,631,827],[634,1210,1176],[157,1832,1834],[56,219,53],[126,38,83],[37,85,43],[59,1151,1154],[83,75,41],[77,85,138],[201,948,46],[1362,36,37],[452,775,885],[1237,95,104],[966,963,1262],[85,77,43],[36,85,37],[1018,439,1019],[41,225,481],[85,83,127],[93,83,41],[935,972,962],[116,93,100],[98,82,813],[41,75,225],[298,751,54],[1021,415,1018],[77,138,128],[766,823,1347],[593,121,573],[905,885,667],[786,744,747],[100,41,107],[604,334,765],[779,450,825],[968,962,969],[225,365,481],[365,283,196],[161,160,303],[875,399,158],[328,1817,954],[62,61,1079],[358,81,72],[74,211,133],[160,161,138],[91,62,1079],[167,56,1405],[56,167,219],[913,914,48],[344,57,102],[43,77,128],[1075,97,1079],[389,882,887],[219,108,53],[1242,859,120],[604,840,618],[754,87,762],[197,36,1362],[1439,88,1200],[1652,304,89],[81,44,940],[445,463,151],[717,520,92],[129,116,100],[1666,1811,624],[1079,97,91],[62,91,71],[688,898,526],[463,74,133],[278,826,99],[961,372,42],[799,94,1007],[100,93,41],[1314,943,1301],[184,230,109],[875,1195,231],[133,176,189],[751,755,826],[101,102,57],[1198,513,117],[748,518,97],[1145,1484,1304],[358,658,81],[971,672,993],[445,151,456],[252,621,122],[36,271,126],[85,36,126],[116,83,93],[141,171,1747],[1081,883,103],[1398,1454,149],[457,121,593],[127,116,303],[697,70,891],[457,891,1652],[1058,1668,112],[518,130,97],[214,319,131],[185,1451,1449],[463,133,516],[1428,123,177],[113,862,561],[215,248,136],[186,42,251],[127,83,116],[160,85,127],[162,129,140],[154,169,1080],[169,170,1080],[210,174,166],[1529,1492,1524],[450,875,231],[399,875,450],[171,141,170],[113,1155,452],[131,319,360],[44,175,904],[452,872,113],[746,754,407],[147,149,150],[309,390,1148],[53,186,283],[757,158,797],[303,129,162],[429,303,162],[154,168,169],[673,164,193],[38,271,75],[320,288,1022],[246,476,173],[175,548,904],[182,728,456],[199,170,169],[168,199,169],[199,171,170],[184,238,230],[246,247,180],[1496,1483,1467],[147,150,148],[828,472,445],[53,108,186],[56,53,271],[186,961,42],[1342,391,57],[1664,157,1834],[1070,204,178],[178,204,179],[285,215,295],[692,55,360],[192,193,286],[359,673,209],[586,195,653],[121,89,573],[202,171,199],[238,515,311],[174,210,240],[174,105,166],[717,276,595],[1155,1149,452],[1405,56,197],[53,283,30],[75,53,30],[45,235,1651],[210,166,490],[181,193,192],[185,620,217],[26,798,759],[1070,226,204],[220,187,179],[220,168,187],[202,222,171],[359,209,181],[182,456,736],[964,167,1405],[76,250,414],[807,1280,1833],[70,883,1652],[227,179,204],[221,199,168],[221,202,199],[360,494,131],[214,241,319],[105,247,166],[205,203,260],[388,480,939],[482,855,211],[8,807,1833],[226,255,204],[228,221,168],[166,173,490],[701,369,702],[211,855,262],[631,920,630],[1448,1147,1584],[255,227,204],[237,220,179],[228,168,220],[222,256,555],[215,259,279],[126,271,38],[108,50,186],[227,236,179],[236,237,179],[220,237,228],[228,202,221],[256,222,202],[555,256,229],[259,152,279],[27,1296,31],[186,50,961],[961,234,372],[1651,235,812],[1572,1147,1448],[255,226,1778],[255,236,227],[256,257,229],[106,184,109],[241,410,188],[177,578,620],[209,673,181],[1136,1457,79],[1507,245,718],[255,273,236],[275,410,241],[206,851,250],[1459,253,1595],[1406,677,1650],[228,274,202],[202,281,256],[348,239,496],[205,172,203],[369,248,702],[261,550,218],[261,465,550],[574,243,566],[921,900,1220],[291,273,255],[348,238,265],[109,230,194],[149,380,323],[443,270,421],[272,291,255],[274,228,237],[274,292,202],[281,257,256],[276,543,341],[152,259,275],[1111,831,249],[632,556,364],[299,273,291],[299,236,273],[280,237,236],[202,292,281],[247,246,173],[282,49,66],[1620,1233,1553],[299,280,236],[280,305,237],[237,305,274],[306,292,274],[330,257,281],[246,194,264],[166,247,173],[912,894,896],[611,320,244],[1154,1020,907],[969,962,290],[272,299,291],[305,318,274],[145,212,240],[164,248,285],[259,277,275],[193,164,295],[269,240,210],[1033,288,320],[46,948,206],[336,280,299],[330,281,292],[257,307,300],[369,136,248],[145,240,269],[502,84,465],[193,295,286],[164,285,295],[282,302,49],[161,303,429],[318,306,274],[306,330,292],[315,257,330],[315,307,257],[307,352,300],[300,352,308],[275,277,403],[353,1141,333],[1420,425,47],[611,313,320],[85,126,83],[128,1180,43],[303,116,129],[280,314,305],[314,318,305],[190,181,242],[203,214,131],[820,795,815],[322,299,272],[322,336,299],[315,339,307],[172,152,617],[172,214,203],[321,1033,320],[1401,941,946],[85,160,138],[976,454,951],[747,60,786],[317,322,272],[339,352,307],[266,33,867],[163,224,218],[247,614,180],[648,639,553],[388,172,205],[611,345,313],[313,345,320],[160,127,303],[454,672,951],[317,329,322],[314,280,336],[306,338,330],[330,339,315],[1236,115,436],[342,321,320],[1046,355,328],[328,346,325],[325,346,317],[367,314,336],[314,337,318],[337,306,318],[338,343,330],[342,320,345],[355,349,328],[346,329,317],[347,336,322],[314,362,337],[330,343,339],[340,308,352],[135,906,1022],[239,156,491],[194,230,486],[40,1015,1003],[321,355,1046],[329,382,322],[382,347,322],[347,367,336],[337,371,306],[306,371,338],[1681,296,1493],[286,172,388],[230,348,486],[348,183,486],[384,332,830],[328,349,346],[367,362,314],[371,343,338],[339,351,352],[57,344,78],[342,355,321],[386,346,349],[386,350,346],[346,350,329],[347,366,367],[343,363,339],[323,380,324],[152,275,241],[345,1045,342],[350,374,329],[339,363,351],[234,340,352],[353,361,354],[40,34,1015],[373,355,342],[373,349,355],[374,382,329],[366,347,382],[371,363,343],[351,379,352],[379,372,352],[372,234,352],[156,190,491],[319,241,692],[354,361,31],[366,377,367],[363,379,351],[133,590,516],[197,56,271],[1045,370,342],[370,373,342],[374,350,386],[377,366,382],[367,395,362],[400,337,362],[400,371,337],[378,363,371],[106,109,614],[181,673,193],[953,920,631],[376,349,373],[376,386,349],[378,379,363],[224,375,218],[279,152,172],[361,619,381],[1347,823,795],[760,857,384],[392,374,386],[394,395,367],[383,371,400],[383,378,371],[218,375,261],[197,271,36],[414,454,976],[385,376,373],[1051,382,374],[387,394,367],[377,387,367],[395,400,362],[279,172,295],[30,365,225],[450,231,825],[385,373,370],[398,374,392],[1051,377,382],[396,378,383],[348,496,183],[295,172,286],[357,269,495],[1148,390,1411],[75,30,225],[206,76,54],[412,386,376],[412,392,386],[396,383,400],[651,114,878],[123,1241,506],[238,311,265],[381,653,29],[618,815,334],[427,1032,411],[298,414,976],[791,332,384],[129,100,140],[412,404,392],[392,404,398],[140,107,360],[395,394,400],[423,379,378],[385,412,376],[406,94,58],[419,415,1021],[422,423,378],[423,125,379],[258,508,238],[311,156,265],[213,287,491],[449,411,1024],[412,1068,404],[55,140,360],[76,414,54],[394,416,400],[400,416,396],[422,378,396],[1258,796,789],[427,411,449],[427,297,1032],[1385,1366,483],[417,448,284],[1507,341,245],[162,140,444],[658,44,81],[433,125,423],[438,251,125],[429,162,439],[1342,57,1348],[765,766,442],[697,891,695],[1057,396,416],[440,423,422],[440,433,423],[433,438,125],[438,196,251],[74,482,211],[1136,79,144],[29,195,424],[242,1004,492],[57,757,28],[414,298,54],[238,348,230],[224,163,124],[295,215,279],[495,269,490],[449,446,427],[446,297,427],[1020,1163,909],[128,138,419],[66,980,443],[415,439,1018],[111,396,1057],[111,422,396],[840,249,831],[593,664,596],[218,550,155],[109,194,180],[483,268,855],[161,415,419],[1737,232,428],[360,107,494],[1006,1011,410],[444,140,55],[919,843,430],[190,242,213],[275,403,410],[131,494,488],[449,663,446],[138,161,419],[128,419,34],[439,162,444],[460,440,422],[440,438,433],[472,74,445],[491,190,213],[238,508,515],[46,206,54],[972,944,962],[1241,1428,1284],[111,460,422],[470,432,806],[248,164,702],[1025,467,453],[553,1235,648],[263,114,881],[267,293,896],[469,438,440],[455,196,438],[287,242,492],[239,265,156],[213,242,287],[1684,746,63],[663,474,446],[415,161,429],[140,100,107],[1055,459,467],[469,455,438],[259,542,277],[446,474,466],[446,466,447],[439,444,1019],[614,109,180],[190,359,181],[156,497,190],[726,474,663],[1023,458,459],[461,440,460],[269,210,490],[246,180,194],[590,133,189],[163,218,155],[467,468,453],[1063,1029,111],[111,1029,460],[1029,464,460],[461,469,440],[150,149,323],[828,445,456],[375,502,261],[474,475,466],[573,426,462],[478,1023,477],[478,458,1023],[458,479,467],[459,458,467],[468,393,453],[464,461,460],[484,365,455],[1232,182,1380],[172,617,214],[547,694,277],[542,547,277],[184,258,238],[261,502,465],[467,479,468],[484,455,469],[1380,182,864],[475,476,466],[80,447,476],[466,476,447],[415,429,439],[479,487,468],[487,287,468],[492,393,468],[260,469,461],[481,365,484],[531,473,931],[692,360,319],[726,495,474],[468,287,492],[480,464,1029],[260,461,464],[494,481,484],[74,472,482],[174,240,212],[223,106,614],[486,477,485],[478,496,458],[491,487,479],[123,402,177],[488,469,260],[488,484,469],[265,239,348],[248,215,285],[474,490,475],[477,486,478],[458,496,479],[239,491,479],[1584,1147,1334],[488,494,484],[401,123,506],[495,490,474],[490,173,475],[80,476,264],[491,287,487],[480,1029,1004],[480,205,464],[173,476,475],[485,194,486],[486,183,478],[478,183,496],[496,239,479],[848,1166,60],[268,262,855],[205,260,464],[260,203,488],[203,131,488],[246,264,476],[194,485,264],[1002,310,1664],[311,515,497],[515,359,497],[565,359,515],[1250,1236,301],[736,456,151],[654,174,567],[577,534,648],[519,505,645],[725,565,508],[150,1723,148],[584,502,505],[584,526,502],[502,526,84],[607,191,682],[560,499,660],[607,517,191],[1038,711,124],[951,672,971],[716,507,356],[868,513,1198],[615,794,608],[682,191,174],[1313,928,1211],[617,241,214],[511,71,91],[408,800,792],[192,286,525],[80,485,447],[91,97,130],[1675,324,888],[207,756,532],[582,1097,1124],[311,497,156],[510,130,146],[523,511,510],[608,708,616],[546,690,650],[511,527,358],[536,146,518],[465,418,550],[418,709,735],[520,514,500],[584,505,519],[536,518,509],[146,536,510],[538,527,511],[876,263,669],[646,524,605],[510,536,523],[527,175,358],[724,876,669],[721,724,674],[524,683,834],[558,509,522],[558,536,509],[523,538,511],[611,243,574],[528,706,556],[668,541,498],[523,537,538],[527,540,175],[532,756,533],[1013,60,747],[551,698,699],[92,520,500],[535,536,558],[536,569,523],[538,540,527],[539,548,175],[567,212,145],[401,896,293],[534,675,639],[1510,595,1507],[557,545,530],[569,536,535],[537,540,538],[540,539,175],[569,537,523],[1135,718,47],[587,681,626],[580,535,558],[99,747,278],[701,565,725],[665,132,514],[665,514,575],[132,549,653],[176,651,189],[65,47,266],[597,569,535],[569,581,537],[537,581,540],[563,539,540],[539,564,548],[1509,1233,1434],[132,653,740],[550,710,155],[714,721,644],[410,1011,188],[732,534,586],[560,562,729],[555,557,222],[580,558,545],[597,535,580],[581,563,540],[5,821,1676],[576,215,136],[649,457,741],[564,539,563],[124,711,224],[550,668,710],[550,541,668],[565,701,673],[560,613,499],[233,532,625],[545,555,580],[601,581,569],[594,904,548],[1463,1425,434],[185,149,1454],[721,674,644],[185,380,149],[577,424,586],[462,586,559],[597,601,569],[594,548,564],[566,603,574],[165,543,544],[457,89,121],[586,424,195],[725,587,606],[1078,582,1124],[588,925,866],[462,559,593],[189,878,590],[555,229,580],[602,563,581],[904,594,956],[434,1425,1438],[1024,112,821],[572,587,626],[600,597,580],[599,591,656],[600,580,229],[601,622,581],[581,622,602],[602,564,563],[602,594,564],[603,611,574],[498,529,546],[697,1145,70],[592,628,626],[610,597,600],[597,610,601],[222,557,171],[604,765,799],[573,462,593],[133,200,176],[729,607,627],[1011,692,188],[518,146,130],[585,687,609],[682,627,607],[1712,599,656],[562,592,607],[643,656,654],[257,600,229],[601,633,622],[623,594,602],[174,212,567],[725,606,701],[609,701,606],[610,633,601],[633,642,622],[380,216,324],[142,143,1249],[501,732,586],[534,577,586],[648,1235,577],[610,641,633],[310,1002,1831],[618,334,604],[1710,145,269],[707,498,659],[501,586,462],[625,501,462],[726,663,691],[300,600,257],[641,610,600],[622,629,602],[602,629,623],[55,692,444],[518,748,509],[929,1515,1411],[620,578,267],[71,511,358],[707,668,498],[650,687,585],[600,300,641],[641,657,633],[1675,888,1669],[622,636,629],[505,502,375],[541,529,498],[332,420,1053],[637,551,638],[534,639,648],[69,623,873],[300,512,641],[633,657,642],[562,660,579],[687,637,638],[709,646,605],[775,738,885],[559,549,132],[646,683,524],[641,512,657],[266,897,949],[1712,643,1657],[184,727,258],[674,724,669],[699,714,647],[628,659,572],[657,662,642],[571,881,651],[517,607,504],[598,706,528],[598,694,547],[640,552,560],[655,693,698],[698,693,721],[91,510,511],[144,301,1136],[324,216,888],[870,764,1681],[575,514,520],[276,544,543],[658,175,44],[645,505,711],[659,546,572],[700,524,655],[605,700,529],[266,867,897],[1695,1526,764],[579,659,628],[654,591,682],[586,549,559],[698,721,714],[896,401,506],[640,734,599],[664,665,575],[621,629,636],[1712,656,643],[547,644,598],[710,668,707],[640,560,734],[655,698,551],[694,528,277],[512,662,657],[504,592,626],[688,584,519],[152,241,617],[587,725,681],[598,669,706],[526,670,84],[598,528,694],[710,707,499],[579,592,562],[660,659,579],[323,324,1134],[326,895,473],[195,29,653],[84,670,915],[560,660,562],[504,626,681],[711,505,224],[651,881,114],[216,620,889],[1362,678,197],[493,99,48],[1659,691,680],[529,690,546],[430,843,709],[655,524,693],[174,191,105],[674,669,598],[98,712,82],[572,546,585],[72,61,71],[912,911,894],[106,223,184],[664,132,665],[843,646,709],[635,699,136],[699,698,714],[593,132,664],[688,526,584],[185,177,620],[533,675,534],[687,638,635],[1652,89,457],[896,506,912],[132,740,514],[689,685,282],[691,449,680],[48,436,493],[136,699,647],[739,640,554],[549,586,653],[532,533,625],[1530,695,649],[653,381,619],[736,151,531],[188,692,241],[177,402,578],[33,689,867],[689,33,685],[593,559,132],[949,65,266],[711,1038,661],[939,480,1004],[609,369,701],[616,552,615],[619,361,740],[151,463,516],[513,521,117],[691,663,449],[186,251,196],[333,302,327],[613,560,552],[616,613,552],[690,551,637],[660,707,659],[704,208,1203],[418,735,550],[163,708,124],[524,834,693],[554,640,599],[245,341,165],[565,673,359],[155,710,708],[105,191,517],[1515,198,1411],[1709,554,599],[60,289,786],[838,1295,1399],[533,534,625],[710,499,708],[556,632,410],[217,620,216],[591,627,682],[504,503,223],[643,654,567],[690,637,650],[545,557,555],[174,654,682],[719,691,1659],[727,681,508],[645,711,661],[794,615,739],[565,515,508],[282,685,302],[1150,397,1149],[638,699,635],[544,685,33],[719,726,691],[1742,1126,1733],[1724,1475,148],[556,410,403],[185,217,380],[503,504,681],[277,556,403],[32,1178,158],[1712,1709,599],[605,529,541],[635,136,369],[687,635,369],[529,700,690],[700,551,690],[89,304,573],[625,534,732],[730,302,685],[503,681,727],[702,673,701],[730,327,302],[327,353,333],[596,664,575],[660,499,707],[585,546,650],[560,729,734],[700,655,551],[176,571,651],[517,504,223],[730,685,544],[1661,1682,726],[1682,495,726],[1250,301,917],[605,524,700],[609,687,369],[516,389,895],[1553,686,1027],[673,702,164],[656,591,654],[520,596,575],[402,123,401],[828,456,728],[1645,677,1653],[528,556,277],[638,551,699],[190,497,359],[276,730,544],[1117,1525,933],[1027,686,1306],[155,708,163],[709,605,541],[647,644,547],[650,637,687],[599,734,591],[578,293,267],[1682,357,495],[510,91,130],[734,729,627],[576,542,215],[709,541,735],[735,541,550],[276,500,730],[500,327,730],[653,619,740],[414,851,454],[734,627,591],[729,562,607],[615,552,640],[525,181,192],[308,512,300],[223,503,727],[266,165,33],[92,500,276],[321,1046,1033],[585,609,606],[1200,1559,86],[628,572,626],[301,436,803],[714,644,647],[708,499,613],[721,693,724],[514,353,327],[353,740,361],[344,158,78],[708,613,616],[615,640,739],[500,514,327],[514,740,353],[1449,177,185],[462,233,625],[851,405,1163],[608,616,615],[647,542,576],[625,732,501],[1097,582,1311],[1235,424,577],[579,628,592],[607,592,504],[24,432,470],[105,614,247],[104,742,471],[542,259,215],[365,196,455],[1420,47,65],[223,727,184],[547,542,647],[572,585,606],[587,572,606],[262,780,1370],[647,576,136],[644,674,598],[271,53,75],[727,508,258],[471,742,142],[505,375,224],[357,1710,269],[725,508,681],[659,498,546],[743,1178,32],[1195,634,231],[1176,24,470],[743,1110,1178],[135,809,857],[63,746,407],[634,1176,470],[159,1112,27],[1176,1685,24],[399,450,779],[1178,856,875],[751,744,54],[436,48,772],[634,1108,1210],[769,1285,1286],[751,298,755],[746,1684,754],[754,924,87],[722,1625,756],[87,839,153],[489,795,820],[758,808,1518],[839,840,153],[831,1111,959],[1111,749,959],[810,1253,1363],[1247,1394,713],[1388,1329,1201],[1242,120,761],[857,791,384],[758,1523,808],[296,764,1504],[70,1652,891],[207,233,1638],[1348,57,28],[858,420,332],[964,1379,1278],[420,1194,816],[784,1076,1186],[1076,21,1186],[1710,767,1],[849,822,778],[806,137,787],[786,790,744],[790,54,744],[771,63,407],[785,852,818],[774,1823,272],[895,151,516],[135,1022,809],[99,826,48],[48,826,755],[808,705,408],[833,441,716],[1733,743,32],[1385,836,852],[772,827,737],[1005,49,781],[793,1697,813],[1518,441,1537],[1139,1132,859],[782,801,770],[1510,1530,676],[770,814,835],[231,787,825],[207,722,756],[26,771,798],[782,863,865],[832,54,790],[865,842,507],[799,765,94],[1175,1261,1353],[800,408,805],[262,986,200],[792,800,814],[801,792,770],[704,1203,1148],[356,1514,822],[165,544,33],[561,776,113],[1043,738,775],[815,831,820],[773,792,801],[772,48,914],[772,737,803],[436,772,803],[808,817,705],[1624,822,1527],[588,1144,788],[799,762,604],[821,1520,1676],[854,803,666],[828,482,472],[445,74,463],[831,489,820],[828,836,482],[716,782,763],[334,815,766],[815,823,766],[334,766,765],[819,805,837],[1716,1521,1412],[1684,924,754],[800,805,819],[1709,829,554],[806,1349,137],[99,1013,747],[341,595,276],[817,810,818],[1176,1691,1685],[763,782,865],[830,846,1052],[865,1499,842],[982,846,1053],[847,832,790],[1178,875,158],[817,818,705],[1302,1392,45],[96,417,284],[223,614,517],[356,507,1514],[1166,848,1179],[1349,432,26],[717,92,276],[770,835,863],[522,509,1745],[847,841,832],[832,841,46],[829,739,554],[802,824,39],[397,1043,775],[1567,849,778],[1385,483,855],[1349,26,1346],[441,801,782],[402,401,293],[1043,667,738],[759,798,1007],[819,837,728],[728,837,828],[837,852,828],[1537,441,833],[148,1475,147],[805,705,837],[716,441,782],[483,1371,780],[814,819,844],[845,753,1336],[1661,719,4],[862,847,790],[737,827,666],[201,46,841],[810,785,818],[408,705,805],[1560,1536,849],[1585,853,1786],[7,1668,807],[7,807,8],[822,1514,1527],[800,819,814],[847,862,841],[991,857,760],[705,818,837],[808,408,773],[402,293,578],[791,858,332],[1480,1228,1240],[814,844,835],[785,1385,852],[1132,120,859],[1743,1726,684],[1704,783,1279],[1623,1694,1731],[959,489,831],[1518,808,773],[862,872,841],[441,773,801],[331,512,308],[380,217,216],[841,872,201],[818,852,837],[448,1480,1240],[856,1108,1195],[1527,1514,1526],[819,182,1232],[871,724,693],[852,836,828],[770,792,814],[803,737,666],[751,826,278],[1674,1727,1699],[849,356,822],[871,693,834],[507,842,1514],[1406,1097,869],[1328,1349,1346],[823,815,795],[744,751,278],[1110,856,1178],[520,717,316],[871,834,683],[884,876,724],[165,266,47],[716,763,507],[216,889,888],[853,1585,1570],[1536,716,356],[886,873,623],[782,770,863],[432,24,26],[683,882,871],[884,724,871],[114,876,884],[516,590,389],[11,1218,1628],[862,113,872],[886,623,629],[830,1052,1120],[762,153,604],[773,408,792],[763,865,507],[153,840,604],[882,884,871],[531,151,326],[886,890,873],[133,262,200],[819,1232,844],[621,636,122],[645,892,519],[1130,1076,784],[114,263,876],[1670,10,1663],[911,670,894],[452,885,872],[872,885,201],[887,882,683],[878,884,882],[590,878,882],[890,867,689],[897,629,621],[897,886,629],[819,728,182],[519,893,688],[894,670,526],[898,894,526],[1536,356,849],[810,1363,785],[878,114,884],[879,888,892],[892,889,893],[893,898,688],[895,683,843],[895,887,683],[889,620,267],[590,882,389],[418,465,84],[949,897,621],[897,890,886],[889,267,893],[898,267,896],[531,326,473],[189,651,878],[843,683,646],[897,867,890],[888,889,892],[893,267,898],[896,894,898],[473,895,843],[895,389,887],[974,706,669],[513,1115,521],[326,151,895],[809,791,857],[211,262,133],[920,923,947],[923,90,947],[90,25,947],[25,972,935],[64,431,899],[52,899,901],[903,905,59],[437,967,73],[839,1242,761],[904,975,44],[917,301,144],[915,670,911],[905,201,885],[1684,63,1685],[1033,1194,288],[950,913,755],[912,918,911],[950,914,913],[506,918,912],[922,919,915],[911,922,915],[1004,451,492],[1263,553,639],[922,911,918],[630,920,947],[916,506,926],[916,918,506],[521,1115,1098],[916,922,918],[919,418,915],[83,38,75],[24,1685,771],[110,1230,1213],[712,8,1837],[922,930,919],[919,430,418],[1395,1402,1187],[930,922,916],[594,623,69],[35,431,968],[35,968,969],[866,924,1684],[1625,1263,675],[631,630,52],[930,931,919],[430,709,418],[302,333,49],[1446,978,1138],[799,1007,798],[931,843,919],[947,25,64],[885,738,667],[1262,963,964],[899,970,901],[1401,946,938],[1117,933,1091],[1685,63,771],[905,948,201],[979,937,980],[951,953,950],[937,270,443],[1154,903,59],[1194,954,1067],[909,405,907],[850,1151,59],[1769,811,1432],[76,206,250],[938,946,966],[965,927,942],[938,966,957],[955,975,904],[927,965,934],[52,51,631],[59,905,667],[431,935,968],[786,289,561],[252,122,671],[481,494,107],[954,1817,1067],[795,25,90],[958,965,945],[795,972,25],[902,983,955],[972,489,944],[1256,29,424],[671,331,945],[946,958,963],[956,955,904],[902,955,956],[671,512,331],[945,331,961],[662,671,122],[671,662,512],[934,65,927],[630,947,52],[666,631,910],[850,59,667],[961,331,234],[1024,411,1042],[890,69,873],[252,671,945],[975,290,940],[283,186,196],[30,283,365],[950,755,298],[946,965,958],[985,290,975],[969,290,985],[405,851,206],[935,431,64],[941,1423,1420],[964,963,167],[942,252,945],[78,757,57],[49,1005,66],[937,979,270],[631,666,827],[980,937,443],[66,689,282],[421,902,956],[947,64,52],[35,979,899],[951,971,953],[762,87,153],[27,31,381],[924,839,87],[946,963,966],[331,308,340],[957,966,1262],[473,843,931],[953,971,920],[270,969,902],[935,962,968],[51,1005,781],[969,983,902],[437,73,940],[69,421,956],[761,249,840],[263,974,669],[962,944,967],[962,437,290],[985,975,955],[907,405,948],[720,957,1262],[25,935,64],[176,200,571],[108,945,50],[250,851,414],[200,986,571],[881,974,263],[827,772,953],[970,899,980],[29,159,27],[234,331,340],[948,405,206],[980,899,979],[986,984,571],[571,984,881],[990,706,974],[946,934,965],[970,980,66],[1113,1486,1554],[984,981,881],[881,987,974],[689,66,443],[1005,901,66],[983,985,955],[165,47,718],[987,990,974],[1370,986,262],[901,970,66],[51,901,1005],[981,987,881],[988,706,990],[942,945,965],[290,437,940],[64,899,52],[988,556,706],[941,934,946],[431,35,899],[996,989,984],[984,989,981],[981,989,987],[35,969,270],[1370,995,986],[986,995,984],[989,999,987],[987,992,990],[992,988,990],[962,967,437],[951,950,976],[979,35,270],[421,270,902],[998,995,1370],[987,999,992],[988,364,556],[969,985,983],[689,443,890],[995,1e3,984],[219,958,108],[998,1e3,995],[999,997,992],[914,953,772],[845,1336,745],[806,787,231],[1e3,996,984],[989,996,999],[50,945,961],[443,421,69],[797,158,779],[1098,1463,434],[996,1009,999],[1001,988,992],[1001,364,988],[903,907,905],[26,759,973],[997,1001,992],[632,364,1001],[1346,26,973],[998,1008,1e3],[1e3,1009,996],[531,931,736],[252,949,621],[286,388,525],[1174,1008,998],[1009,1010,999],[999,1010,997],[1014,1001,997],[614,105,517],[958,945,108],[525,1004,242],[963,958,219],[233,426,304],[1e3,1008,1009],[1010,1014,997],[1001,1006,632],[824,413,39],[642,636,622],[480,388,205],[28,757,797],[1014,1006,1001],[1006,410,632],[975,940,44],[1234,420,858],[54,832,46],[1009,1012,1010],[167,963,219],[41,481,107],[1017,1010,1012],[122,636,662],[939,525,388],[525,939,1004],[950,953,914],[829,1735,739],[1008,880,1015],[1008,1015,1009],[1263,639,675],[956,594,69],[795,90,1347],[1179,848,1013],[759,1007,973],[1009,1015,1012],[1012,1016,1017],[1017,1014,1010],[1019,1011,1006],[927,65,949],[649,316,595],[913,48,755],[976,950,298],[1003,1015,880],[1018,1006,1014],[1021,1018,1014],[444,692,1011],[451,1029,1063],[1185,851,1163],[29,27,381],[181,525,242],[1021,1014,1017],[1016,1021,1017],[1018,1019,1006],[1019,444,1011],[927,949,942],[451,393,492],[903,1154,907],[391,101,57],[94,765,58],[419,1016,1012],[949,252,942],[907,1020,909],[765,442,58],[94,406,908],[1007,94,908],[34,1012,1015],[34,419,1012],[419,1021,1016],[451,1057,393],[907,948,905],[1034,1073,1039],[1061,906,1619],[1068,960,1034],[471,1249,104],[112,1024,1042],[372,379,125],[341,543,165],[141,1094,170],[566,243,1061],[398,1034,1039],[325,317,1823],[1493,296,1724],[850,667,1043],[1054,297,1065],[1619,135,1074],[1061,243,906],[680,1024,821],[1103,96,1245],[1440,1123,1491],[1047,1025,1044],[672,454,1231],[1484,697,1530],[993,672,1231],[178,154,1088],[1044,1041,1066],[112,1062,1058],[1530,649,676],[178,1088,1040],[1046,328,954],[243,244,1022],[954,1194,1033],[1042,411,1032],[971,993,1056],[960,1093,1034],[1754,1338,232],[385,1064,412],[1057,1063,111],[748,1071,1447],[1530,697,695],[971,1056,1270],[977,1059,1211],[649,741,316],[1060,1452,1030],[353,354,1323],[695,768,649],[398,404,1034],[596,316,741],[1836,119,13],[1513,1115,1528],[883,1081,1652],[1039,1073,1048],[462,426,233],[31,1296,354],[1055,1047,1066],[1032,1054,1045],[1521,310,1224],[119,861,13],[1194,1234,288],[1109,1771,1070],[1166,1160,776],[1044,1035,1041],[1026,960,1064],[1050,1032,1045],[1049,1041,387],[115,1013,99],[1046,954,1033],[1321,920,971],[611,1058,345],[1048,1066,1049],[1023,1055,1073],[1029,451,1004],[118,1094,141],[1094,1080,170],[1042,1032,1050],[1026,1064,385],[15,16,1084],[1096,1079,61],[1075,1071,748],[325,1817,328],[909,1163,405],[1022,1234,809],[374,398,1051],[1082,72,81],[1023,1034,1093],[1817,1794,1067],[86,1445,1400],[1507,1535,1510],[1079,1096,1075],[568,1478,1104],[1070,178,1040],[1034,1023,1073],[776,1155,113],[1103,143,142],[1140,81,73],[1082,81,1140],[1060,1030,936],[1040,1086,1109],[370,1065,385],[61,72,1082],[1087,1096,1144],[1040,1088,1086],[1651,812,752],[1062,1050,1045],[187,154,178],[179,187,178],[1099,1344,1101],[1668,1058,807],[1073,1055,1048],[1099,1336,1344],[1283,943,1123],[1049,387,1051],[1024,680,449],[61,1082,1100],[967,749,1111],[1439,1037,88],[742,1505,142],[398,1039,1051],[1107,1336,1099],[1344,1542,1101],[142,1505,1103],[477,1093,447],[477,1023,1093],[471,142,1249],[1041,1035,394],[1328,568,1104],[61,1100,1096],[154,1092,1088],[112,1042,1050],[154,187,168],[435,235,45],[1075,1096,1087],[97,1075,748],[1049,1066,1041],[816,1067,1028],[846,982,1142],[1245,96,284],[1092,154,1080],[1057,451,1063],[387,377,1051],[1055,1025,1047],[1075,1087,1089],[1106,1108,856],[1068,1034,404],[1480,1545,868],[906,135,1619],[1074,991,1095],[570,566,1061],[1025,453,1044],[745,1336,1107],[1035,1057,416],[1092,1102,1129],[1074,135,991],[1105,745,1107],[447,1026,446],[394,387,1041],[73,81,940],[1118,1108,1106],[1210,1108,874],[243,1022,906],[412,1064,1068],[1280,611,603],[960,447,1093],[1051,1039,1049],[1040,1109,1070],[1471,1037,1439],[69,890,443],[1377,703,1374],[1092,1080,1102],[1096,1100,788],[1096,788,1144],[1114,967,1111],[446,1026,297],[70,1112,883],[453,393,1057],[1118,874,1108],[1054,370,1045],[1080,1094,1102],[1039,1048,1049],[428,753,845],[1047,1044,1066],[1044,453,1035],[1472,731,1512],[1126,1121,743],[743,1121,1110],[1032,297,1054],[1480,868,1216],[71,358,72],[1133,967,1114],[1105,1119,745],[1035,453,1057],[1026,447,960],[454,851,1190],[1030,1477,652],[589,816,1028],[1110,1121,1106],[1122,1118,1106],[1116,874,1118],[1048,1055,1066],[1194,1067,816],[744,278,747],[745,1120,845],[845,1052,428],[1105,1780,1119],[1065,297,385],[1098,1529,1463],[731,1060,936],[235,434,812],[1445,1525,1117],[1106,1121,1122],[1122,1127,1118],[1127,1116,1118],[1094,118,1732],[1119,1120,745],[1406,1124,1097],[435,117,235],[1462,1440,1037],[1126,1129,1121],[1088,1092,1129],[1133,73,967],[1120,1052,845],[812,434,752],[1441,1559,1200],[1131,588,413],[1054,1065,370],[235,1098,434],[1052,1142,428],[1737,428,1142],[1496,1446,1483],[1182,1083,1654],[1121,1129,1122],[1732,1116,1127],[768,457,649],[761,1114,249],[1064,960,1068],[1135,1481,1136],[1126,952,1129],[1087,588,1131],[1087,1144,588],[859,788,1139],[1140,1133,1132],[1133,1140,73],[1822,570,1061],[394,1035,416],[1055,1023,459],[80,264,485],[1119,1128,1120],[145,1658,567],[695,891,768],[1129,1102,1122],[1122,1102,1127],[1416,1077,1413],[297,1026,385],[1052,846,1142],[1445,1117,1400],[952,1086,1129],[1714,1089,1131],[1131,1089,1087],[1100,1139,788],[112,1050,1062],[1323,354,1296],[49,333,1141],[1142,982,1737],[79,1457,1091],[1088,1129,1086],[1102,1094,1127],[1127,1094,1732],[1100,1082,1139],[1082,1132,1139],[1082,1140,1132],[1150,1043,397],[60,1166,289],[1696,1146,1698],[1297,1202,1313],[409,1297,1313],[1234,1194,420],[1408,1391,1394],[424,1235,1243],[1203,309,1148],[485,477,447],[1152,1156,850],[1153,1149,1155],[1153,1157,1149],[1149,1152,1150],[1156,1154,1151],[776,1153,1155],[1157,1152,1149],[1217,1393,1208],[1156,1159,1154],[1153,1165,1157],[1165,1152,1157],[1159,1020,1154],[1161,1153,776],[1161,1165,1153],[1165,1158,1152],[1152,1158,1156],[1158,1159,1156],[1166,776,561],[1160,1161,776],[1161,1164,1165],[1161,1160,1164],[1158,1162,1159],[1159,1162,1020],[1270,1321,971],[1164,1170,1165],[1165,1162,1158],[1162,1163,1020],[588,788,925],[1166,1167,1160],[1165,1170,1162],[1160,1167,1164],[1162,1170,1163],[1179,1167,1166],[1167,1168,1164],[1164,1168,1170],[1168,1169,1170],[1234,1022,288],[802,39,866],[1179,1168,1167],[1169,1173,1170],[1170,1173,1163],[1173,1185,1163],[1360,1267,1364],[1169,1185,1173],[611,244,243],[900,1226,1376],[1260,1408,1350],[618,840,831],[1181,1183,1179],[1179,1184,1168],[1208,1274,1291],[1183,1184,1179],[1168,1184,1169],[1387,1395,1254],[1208,1204,1172],[1182,1197,1083],[1187,1083,1197],[1213,1183,1181],[1169,1207,1185],[135,857,991],[1013,1213,1181],[1189,1183,1213],[1183,1189,1184],[1169,1184,1207],[1207,1190,1185],[1180,1389,1288],[1191,1192,1640],[1640,1192,1090],[1090,1205,1654],[1654,1205,1182],[1188,1395,1187],[1126,743,1733],[788,859,925],[809,1234,1171],[1193,1197,1182],[1189,1199,1184],[1639,1191,1637],[1639,1212,1191],[1205,1193,1182],[1198,1187,1197],[1199,1207,1184],[332,1053,846],[1090,1192,1205],[117,1188,1187],[435,1188,117],[435,1206,1188],[1199,1189,1213],[420,816,1053],[1212,1215,1191],[117,1187,1198],[45,1206,435],[120,1132,1133],[874,1116,1210],[1191,1215,1192],[1193,1216,1197],[1216,1198,1197],[1199,1214,1207],[117,521,235],[1220,1311,1078],[1220,900,1311],[1653,1215,1212],[1192,1225,1205],[1205,1209,1193],[1209,1216,1193],[1389,1217,1172],[1207,1214,454],[171,557,1747],[1805,1078,1787],[1805,1219,1078],[1198,1216,868],[666,910,854],[1230,1231,1213],[1213,1231,1199],[1199,1231,1214],[1219,1220,1078],[1215,1221,1192],[1192,1221,1225],[1225,1228,1205],[1205,1228,1209],[1209,1228,1216],[1464,1325,1223],[1215,1227,1221],[1228,1480,1216],[1226,1653,1376],[1653,1249,1215],[1221,1240,1225],[1225,1240,1228],[839,761,840],[1238,1219,1805],[1238,1220,1219],[1232,1380,1375],[1226,1249,1653],[1221,1227,1240],[233,207,532],[110,1236,1230],[1248,1231,1230],[1231,454,1214],[1249,1227,1215],[1248,1056,1231],[489,959,944],[448,1240,284],[925,859,1242],[1805,1244,1238],[1252,1220,1238],[1252,921,1220],[1236,1251,1230],[1230,1251,1248],[1056,993,1231],[1031,1264,1263],[68,1186,157],[1227,1245,1240],[1103,1245,143],[1243,1235,612],[1252,95,921],[1249,1226,1237],[1390,1387,1254],[1120,384,830],[830,332,846],[1227,143,1245],[1315,1369,1358],[1356,1269,1386],[972,795,489],[1831,1224,310],[1250,1255,1251],[1251,1056,1248],[1256,1243,103],[658,358,175],[1620,1238,1244],[1620,1252,1238],[1506,95,1252],[104,1249,1237],[1249,143,1227],[1268,1419,1329],[634,806,231],[618,831,815],[924,1242,839],[1255,1270,1251],[1251,1270,1056],[866,925,1242],[103,29,1256],[424,1243,1256],[134,1651,752],[1250,917,1255],[1172,1204,1260],[1352,1036,1276],[1265,1201,1329],[804,1282,1259],[1259,1294,723],[335,1330,1305],[407,762,799],[875,856,1195],[32,158,344],[967,944,749],[372,125,42],[1175,1354,1261],[553,612,1235],[1259,1273,1294],[1294,1283,723],[757,78,158],[407,799,798],[901,51,52],[139,1386,1389],[1386,1269,1389],[1389,1269,1217],[1148,1590,1268],[1428,1449,1450],[804,1281,1282],[1273,1259,1282],[158,399,779],[771,407,798],[521,1098,235],[917,1312,1255],[1312,1270,1255],[1217,1269,1393],[1195,1108,634],[1110,1106,856],[1210,1691,1176],[27,1112,1145],[1296,27,1145],[1171,858,791],[704,1148,1290],[1430,1436,1437],[1282,1308,1273],[1300,943,1283],[1393,1355,1274],[720,1278,769],[1287,1059,1399],[1310,1388,1272],[1312,1321,1270],[851,1185,1190],[1296,1145,1304],[26,24,771],[51,910,631],[1329,1290,1268],[1290,1148,1268],[1298,1293,733],[1281,1293,1282],[1282,1293,1308],[1308,1299,1273],[1300,1283,1294],[1340,943,1300],[1340,1301,943],[407,754,762],[1287,1399,1295],[34,139,128],[1288,1172,1260],[120,1133,1114],[1306,1113,1511],[1464,1223,1292],[1299,1294,1273],[1299,1300,1294],[1286,1295,838],[1285,1247,1286],[1247,713,1286],[1201,1265,1390],[1378,1368,1357],[1482,1320,917],[917,1320,1312],[850,1156,1151],[588,39,413],[1324,1306,686],[789,1365,928],[1223,1326,1292],[1292,1326,1298],[869,1097,1311],[790,786,561],[1323,1304,932],[1323,1296,1304],[1317,1324,686],[1306,368,1113],[1325,1342,1223],[1326,1348,1298],[1293,1327,1308],[1308,1318,1299],[704,1290,1258],[1320,1321,1312],[761,120,1114],[1684,802,866],[1674,6,1727],[1316,1323,932],[1335,1337,1305],[1348,1327,1293],[1298,1348,1293],[1333,1300,1299],[1333,1343,1300],[1328,1301,1340],[1328,1314,1301],[838,1399,1319],[921,1237,900],[409,1391,1408],[1376,1653,677],[1281,804,1458],[1331,1324,1317],[1324,368,1306],[368,1338,1307],[1327,797,1308],[797,1345,1308],[1308,1345,1318],[1318,1333,1299],[1341,1147,1572],[923,1321,1320],[923,920,1321],[39,588,866],[1141,1323,1316],[1330,1335,1305],[1337,1335,1336],[1339,1332,1325],[1223,1342,1326],[1342,1348,1326],[1348,797,1327],[1345,1333,1318],[1343,1340,1300],[1419,1265,1329],[1347,1320,1584],[1535,1141,1316],[1078,1311,582],[1344,1335,1330],[753,1331,1337],[368,1324,1331],[753,368,1331],[1332,1485,1325],[1325,1485,1342],[787,1343,1333],[137,1328,1340],[973,1341,1479],[406,1147,1341],[1171,1234,858],[1141,1535,1322],[49,1141,1322],[1344,1336,1335],[973,908,1341],[766,1347,1584],[1347,923,1320],[781,49,1322],[368,232,1338],[787,1340,1343],[787,137,1340],[568,1346,973],[58,1147,406],[442,1334,1147],[58,442,1147],[442,766,1334],[90,923,1347],[428,368,753],[779,1333,1345],[825,787,1333],[137,1349,1328],[1328,1346,568],[908,406,1341],[924,866,1242],[1336,753,1337],[428,232,368],[1115,777,1098],[1348,28,797],[797,779,1345],[779,825,1333],[1007,908,973],[583,1351,880],[1365,1246,977],[1658,145,1710],[1310,796,1388],[718,245,165],[1302,1272,1254],[1174,1351,583],[1174,715,1351],[1358,1260,1204],[1374,1373,1276],[1377,1374,1276],[678,1362,1382],[1377,1276,254],[139,34,40],[1008,1174,583],[1396,1286,1319],[768,891,457],[1316,932,1535],[1289,1371,1360],[182,736,864],[1355,1364,1274],[860,1367,1354],[1362,1222,1382],[1376,869,1311],[1590,1411,198],[1232,1375,877],[1394,1295,1286],[880,1356,1386],[880,1351,1356],[1211,1059,1287],[197,678,1405],[880,1386,1003],[1368,1253,1357],[1357,1253,1036],[715,1289,1364],[1354,1367,703],[1383,877,1375],[1266,1288,1260],[1373,1374,703],[1372,1289,1174],[1303,1366,1378],[1351,715,1355],[1665,1666,624],[1309,1357,1036],[900,1237,1226],[1174,1289,715],[1337,1331,1317],[1360,1303,1359],[1267,1354,1175],[1241,1284,1414],[1377,254,929],[1385,855,836],[1396,1319,1436],[1361,1366,1303],[1381,1368,1378],[1313,1211,1391],[1368,1385,1363],[813,82,861],[1058,1280,807],[893,519,892],[1359,1303,860],[1382,1350,1247],[1371,1303,1360],[1267,1175,1271],[769,1286,1396],[712,1837,82],[1366,1385,1381],[1365,796,1310],[1003,1386,40],[780,1371,1370],[561,862,790],[1284,1380,864],[1449,1428,177],[611,1280,1058],[1284,1375,1380],[926,506,1241],[1305,1337,1317],[309,1203,208],[1388,1201,1390],[1309,1036,1352],[1377,929,1411],[1399,1059,1257],[1112,70,1145],[289,1166,561],[1288,1389,1172],[1362,37,1180],[713,1394,1286],[1355,1393,1269],[1401,1423,941],[1274,1271,1384],[860,1378,1367],[715,1364,1355],[677,1406,869],[1297,1358,1202],[1388,1258,1329],[1180,1288,1266],[1008,583,880],[1524,1425,1463],[1390,1403,1387],[1278,1379,1247],[1278,1247,1285],[964,1278,1262],[1358,1369,1202],[1715,1699,1726],[926,1241,1414],[1341,1572,1479],[926,930,916],[1397,51,781],[409,1358,1297],[1236,436,301],[1376,677,869],[1351,1355,1356],[758,1534,1523],[1378,1357,1367],[977,1211,1365],[1135,1136,854],[1394,1391,1295],[1266,1260,1222],[1365,1302,1246],[1232,877,844],[736,930,864],[1408,1358,409],[1508,817,1523],[1381,1385,1368],[718,854,910],[854,718,1135],[1382,1222,1350],[1391,1211,1287],[1391,1287,1295],[1257,1651,134],[1414,1284,864],[1291,1369,1315],[1202,928,1313],[86,1400,1413],[1413,1200,86],[1263,1625,1031],[1413,1400,1404],[1002,1664,1834],[930,926,1414],[1399,1257,134],[520,316,596],[1393,1274,1208],[1657,1655,1712],[1407,1404,1400],[1404,1410,1413],[1649,1229,1406],[1362,1266,1222],[1384,1271,1175],[900,1376,1311],[1274,1384,1291],[1291,1384,1431],[1433,1396,1436],[1267,1359,1354],[309,1353,703],[838,1319,1286],[1407,1410,1404],[441,1518,773],[1241,123,1428],[1622,1521,1224],[1217,1208,1172],[1130,793,1076],[425,1409,1481],[1481,1409,1533],[1303,1378,860],[1350,1408,1394],[1246,1651,977],[1289,1360,1364],[1727,1694,1623],[1417,1407,1533],[1417,1410,1407],[1406,1650,1649],[1319,134,1437],[1414,864,930],[1406,1229,1124],[1354,1359,860],[1433,769,1396],[1417,1533,1409],[1416,1413,1410],[1415,1416,1410],[95,1237,921],[1392,1254,1395],[1360,1359,1267],[1258,1290,1329],[1180,128,1389],[1420,1409,425],[1417,1418,1410],[1418,1415,1410],[1422,1077,1416],[1247,1350,1394],[37,43,1180],[1204,1315,1358],[1428,1383,1375],[1356,1355,1269],[1409,1418,1417],[1302,45,1246],[1421,1416,1415],[1421,1422,1416],[1422,1494,1077],[957,720,938],[1423,1409,1420],[1423,1418,1409],[752,434,1438],[1260,1358,1408],[1363,1385,785],[1423,1426,1418],[1426,1424,1418],[1229,1649,1124],[1222,1260,1350],[1508,1523,1137],[1278,1285,769],[1482,917,144],[1418,1424,1415],[1425,1422,1421],[1425,1524,1422],[1272,1388,1390],[1391,409,1313],[1378,1366,1381],[1371,483,1361],[720,1262,1278],[29,103,159],[1271,1364,1267],[1424,1427,1415],[1537,1522,1518],[134,752,1438],[1420,934,941],[1428,1375,1284],[1277,1224,1831],[1362,1180,1266],[1401,1426,1423],[1577,1369,1291],[268,483,262],[1383,1450,1456],[1384,1175,1431],[1430,1415,1427],[1430,1421,1415],[1430,1425,1421],[1379,1382,1247],[1252,1553,1429],[1206,1392,1395],[1433,1430,1427],[309,208,1353],[1272,1390,1254],[1361,483,1366],[1523,817,808],[1302,1254,1392],[1371,1361,1303],[1426,1435,1424],[1435,1433,1424],[1433,1427,1424],[720,769,1433],[796,1258,1388],[1590,1419,1268],[1289,1372,1371],[1305,1317,1509],[998,1372,1174],[40,1386,139],[1261,1354,703],[1364,1271,1274],[134,1438,1437],[1436,1319,1437],[1317,686,1509],[1484,932,1304],[1434,1432,1509],[1420,65,934],[931,930,736],[1367,1357,1309],[1372,1370,1371],[1204,1208,1315],[1426,938,1435],[1368,1363,1253],[1207,454,1190],[1302,1310,1272],[309,1377,390],[390,1377,1411],[1370,1372,998],[1411,1590,1148],[720,1433,1435],[1450,1383,1428],[1379,678,1382],[1405,678,1379],[1208,1291,1315],[1399,134,1319],[1367,1309,1373],[1373,1352,1276],[596,741,593],[553,1264,612],[1433,1436,1430],[1437,1438,1430],[964,1405,1379],[1373,1309,1352],[1265,1403,1390],[1233,1618,1434],[1365,1310,1302],[789,796,1365],[720,1435,938],[128,139,1389],[1466,933,1525],[1191,1640,1637],[1314,1442,943],[1141,353,1323],[1489,1138,1474],[1462,1477,1440],[1474,1138,1488],[1442,1314,1443],[1446,1030,1546],[1484,1145,697],[1549,1443,1445],[1470,1572,1468],[1397,1239,1507],[1649,1825,1824],[1259,1440,1477],[1451,1450,1449],[978,1446,652],[1454,1456,1451],[1451,1456,1450],[341,1507,595],[933,1547,79],[804,1452,1060],[1454,1455,1456],[1398,1460,1454],[1455,877,1456],[1277,1831,1825],[804,1060,1458],[1339,1459,1595],[1314,1104,1443],[933,1448,1547],[147,1460,1398],[1460,1461,1454],[1454,1461,1455],[1292,1125,1464],[417,1531,1480],[1459,1339,1325],[811,1756,335],[1512,936,1490],[777,1529,1098],[147,1475,1460],[1464,253,1459],[836,855,482],[1487,1486,1307],[1104,1501,1443],[1439,1200,1532],[1475,1469,1460],[1460,1469,1461],[1325,1464,1459],[1277,1825,1649],[1532,1200,1077],[844,877,1455],[1572,933,1466],[1479,568,973],[1509,335,1305],[1339,1595,1759],[1469,1476,1461],[1461,1476,1455],[1104,1470,1468],[1464,1472,253],[1117,1091,1407],[1756,1542,335],[1206,1395,1188],[335,1542,1330],[835,844,1455],[1471,1598,1462],[1491,1442,1441],[835,1455,1476],[1441,1442,1443],[1489,1474,1473],[1251,1236,1250],[1030,1452,1477],[1598,1439,1532],[978,1598,1492],[1426,1401,938],[1448,1584,1482],[1724,1497,1475],[1475,1497,1469],[1484,1535,932],[1307,1486,1113],[1487,696,1495],[1037,1491,1441],[1030,1446,936],[1453,1487,1495],[696,1467,1495],[1138,1489,1483],[1497,1143,1469],[1469,1143,1476],[652,1598,978],[850,1043,1150],[1482,1584,1320],[1731,98,1697],[1113,1554,1573],[1524,1532,1494],[1496,1467,696],[1452,1259,1477],[296,1504,1497],[1504,1143,1497],[1143,1499,1476],[718,910,1498],[868,1540,1528],[817,1253,810],[1490,696,1487],[1440,1491,1037],[1510,676,595],[1488,1492,1517],[781,1239,1397],[1467,1519,1503],[1500,1307,1759],[1149,397,452],[1504,1514,1143],[1514,842,1143],[1125,733,1458],[1503,1531,1555],[1276,1036,1137],[1440,723,1123],[1036,1508,1137],[817,1508,1253],[103,883,1112],[1458,731,1472],[1512,1490,1487],[1487,1453,1486],[1138,978,1488],[1036,1253,1508],[1398,149,147],[1474,1517,1513],[1125,1458,1472],[1486,1453,1554],[1518,1534,758],[345,1058,1062],[928,1202,1369],[1554,1541,1505],[1464,1125,1472],[1504,764,1514],[304,426,573],[1505,742,1506],[1479,1572,1478],[1519,1483,1489],[833,716,1069],[1522,1534,1518],[1115,1513,777],[811,335,1432],[1591,1533,1407],[777,1517,1529],[1513,1517,777],[1498,910,1397],[1069,1539,833],[833,1539,1537],[1522,1551,1534],[1534,1551,1523],[1538,1137,1523],[910,51,1397],[1367,1373,703],[1466,1525,1468],[157,1186,1832],[1429,1511,1506],[1573,1505,1506],[1259,1452,804],[1503,1495,1467],[262,483,780],[1572,1466,1468],[1536,1556,716],[716,1556,1069],[1544,1523,1551],[1544,1538,1523],[1511,1573,1506],[933,1572,1448],[1543,1537,1539],[1537,1543,1522],[1091,933,79],[1519,1540,1545],[1549,1445,86],[1069,1548,1539],[1548,1543,1539],[1543,1551,1522],[1500,1487,1307],[68,784,1186],[1552,1544,1551],[1550,1538,1544],[1538,1550,1137],[1519,1473,1540],[1547,1448,1482],[1560,1563,1536],[1536,1563,1556],[1556,1548,1069],[1543,1558,1551],[1137,1550,1276],[1453,1495,1555],[1561,1543,1548],[1543,1561,1558],[1558,1566,1551],[1552,1550,1544],[1569,1557,1550],[1557,1276,1550],[1276,1557,254],[1531,1503,1480],[1535,1530,1510],[1545,1503,1519],[1547,1482,79],[1566,1552,1551],[1552,1569,1550],[1503,1545,1480],[703,1377,309],[1625,675,756],[1037,1441,88],[929,254,1557],[849,1567,1560],[1556,1564,1548],[1492,1529,1517],[1252,1429,1506],[1553,1027,1429],[1453,1555,1541],[1554,1453,1541],[1233,686,1553],[1328,1104,1314],[1564,1576,1548],[1548,1576,1561],[1557,1562,929],[1520,112,1668],[1483,1446,1138],[778,1570,1567],[1563,1564,1556],[1561,1565,1558],[1565,1566,1558],[1569,1552,1566],[1562,1557,1569],[1530,1535,1484],[1387,1402,1395],[1621,1634,1387],[1567,1568,1560],[1560,1568,1563],[1571,1569,1566],[1344,1330,1542],[1577,1431,1353],[1638,233,304],[1524,1463,1529],[1353,1431,1175],[1077,1200,1413],[1478,1470,1104],[1568,1575,1563],[1563,1575,1564],[1575,1576,1564],[1561,1576,1565],[1565,1574,1566],[1562,1515,929],[1555,96,1541],[1531,417,96],[1555,1531,96],[1246,45,1651],[208,1577,1353],[1586,1568,1567],[1574,1571,1566],[1571,1583,1569],[1474,1513,1528],[1239,1322,1535],[1478,1572,1470],[1570,1586,1567],[1488,1517,1474],[8,1833,1837],[1123,1442,1491],[1589,1568,1586],[1576,1594,1565],[1565,1594,1574],[1562,198,1515],[1559,1441,1549],[1441,1443,1549],[1135,425,1481],[1239,1535,1507],[1595,1487,1500],[1570,1585,1586],[1589,1578,1568],[1568,1578,1575],[1579,1569,1583],[1177,1577,208],[115,1236,110],[1578,1593,1575],[1587,1576,1575],[1576,1581,1594],[1571,1582,1583],[1588,1579,1583],[1579,1580,1562],[1569,1579,1562],[1562,1580,198],[1027,1511,1429],[1589,1593,1578],[1587,1581,1576],[1582,1574,1594],[1574,1582,1571],[1575,1593,1587],[1583,1582,1588],[1580,1590,198],[1587,1593,1581],[1505,1541,96],[1369,1577,1177],[1573,1554,1505],[1479,1478,568],[1585,1589,1586],[1369,1177,704],[766,1584,1334],[977,1257,1059],[1091,1591,1407],[1591,1091,1457],[1585,1604,1589],[1581,1592,1594],[1602,1582,1594],[1582,1608,1588],[1608,1579,1588],[1579,1597,1580],[1419,1590,1580],[1597,1419,1580],[1431,1577,1291],[1589,1604,1593],[1601,1596,1593],[1593,1596,1581],[1306,1511,1027],[1511,1113,1573],[1786,1412,1585],[1412,1604,1585],[1581,1596,1592],[1592,1602,1594],[1608,1599,1579],[1599,1611,1579],[1579,1611,1597],[1512,1487,253],[1519,1489,1473],[1545,1540,868],[1083,1187,1402],[1117,1407,1400],[1292,733,1125],[284,1240,1245],[1604,1600,1593],[1600,1601,1593],[1582,1607,1608],[789,1369,704],[1467,1483,1519],[1601,1613,1596],[1596,1613,1592],[1602,1607,1582],[1620,1553,1252],[1601,1605,1613],[1592,1613,1602],[1602,1606,1607],[1608,1609,1599],[1599,1609,1611],[1603,1597,1611],[1265,1419,1597],[1603,1265,1597],[1392,1206,45],[928,1369,789],[1474,1528,1473],[1104,1468,1501],[1412,1521,1604],[1613,1631,1602],[1607,1610,1608],[1608,1610,1609],[1476,863,835],[1495,1503,1555],[1498,1397,718],[1520,1668,7],[1604,1615,1600],[1605,1601,1600],[1602,1631,1606],[1606,1610,1607],[1759,1595,1500],[1292,1298,733],[1615,1604,1521],[1609,1603,1611],[652,1462,1598],[1468,1525,1445],[1443,1501,1445],[1134,1723,150],[1521,1622,1615],[1615,1616,1600],[1616,1605,1600],[1605,1616,1612],[1605,1612,1613],[1612,1617,1613],[1613,1617,1631],[1606,1614,1610],[1265,1603,1403],[448,417,1480],[1595,253,1487],[1501,1468,1445],[1383,1456,877],[1490,1496,696],[1610,1627,1609],[1627,1621,1609],[1591,1481,1533],[1598,1471,1439],[1353,1261,703],[1606,1631,1614],[1609,1621,1403],[1532,1077,1494],[1528,1115,513],[1546,652,1446],[1211,928,1365],[1540,1473,1528],[1078,1502,1787],[1425,1430,1438],[1617,1630,1631],[959,749,944],[566,570,603],[1716,310,1521],[775,452,397],[1615,1636,1616],[1616,1636,1612],[1610,1632,1627],[789,704,1258],[1457,1481,1591],[1769,1756,811],[207,1629,722],[1629,1625,722],[1224,1277,1622],[1622,1636,1615],[1636,1646,1612],[1612,1630,1617],[1631,1626,1614],[1614,1632,1610],[1506,104,95],[1481,1457,1136],[1123,943,1442],[936,1446,1496],[1499,863,1476],[1629,1031,1625],[1233,1509,686],[1633,1634,1621],[1621,1387,1403],[1472,1512,253],[1177,208,704],[1277,1636,1622],[1626,1632,1614],[1627,1633,1621],[936,1496,1490],[185,1454,1451],[731,936,1512],[1638,1635,207],[553,1263,1264],[1653,1212,1639],[1633,1627,1632],[1633,1387,1634],[1458,1060,731],[368,1307,1113],[1264,1031,1629],[1152,850,1150],[1277,1644,1636],[1646,1637,1612],[1637,1630,1612],[1647,1631,1630],[1647,1626,1631],[1422,1524,1494],[1030,652,1546],[1635,1629,207],[1635,1264,1629],[1639,1646,1636],[1637,1640,1630],[1641,1632,1626],[1632,1642,1633],[1633,1643,1387],[842,1499,1143],[865,863,1499],[1516,978,1492],[67,1130,784],[1103,1505,96],[88,1441,1200],[1644,1639,1636],[1640,1647,1630],[1647,1641,1626],[1633,1648,1643],[1492,1532,1524],[1488,1516,1492],[1037,1471,1462],[612,1264,1635],[1502,1078,1124],[1641,1642,1632],[1648,1633,1642],[1528,513,868],[1492,1598,1532],[1095,991,760],[679,157,1664],[760,1128,1785],[1277,1650,1644],[320,1022,244],[1559,1549,86],[1676,1520,7],[1488,978,1516],[1095,760,1785],[1128,384,1120],[304,312,1638],[1081,1638,312],[1081,1635,1638],[103,612,1635],[652,1477,1462],[1650,1645,1644],[1645,1639,1644],[1639,1637,1646],[1640,1090,1647],[1654,1641,1647],[1654,1642,1641],[1654,1648,1642],[1643,1402,1387],[1432,335,1509],[384,1128,760],[1652,312,304],[103,1243,612],[1277,1649,1650],[1090,1654,1647],[1643,1648,1402],[1134,324,1675],[679,68,157],[1652,1081,312],[1136,301,803],[1653,1639,1645],[723,1440,1259],[803,854,1136],[104,1506,742],[1112,159,103],[1654,1083,1648],[977,1651,1257],[1397,1507,718],[1081,103,1635],[1650,677,1645],[1083,1402,1648],[1706,1655,1671],[1624,1704,1711],[767,2,1],[608,794,294],[1678,1683,1686],[767,1682,2],[1669,1692,1675],[296,1681,764],[1671,1656,1672],[17,1673,1679],[1706,1671,1673],[1662,1674,1699],[1655,1657,1656],[418,84,915],[1526,1514,764],[1658,1657,567],[870,1695,764],[813,1697,98],[1659,821,5],[60,1013,848],[1013,110,1213],[661,1038,1692],[1660,1703,17],[1693,1673,17],[1663,1715,1743],[1013,115,110],[344,1733,32],[1670,1663,1743],[1670,1743,1738],[1677,1670,1738],[1661,4,3],[1084,1683,1678],[1728,793,1130],[1683,1767,1196],[1677,1738,1196],[1279,1786,853],[294,1038,608],[1279,1689,1786],[870,18,1708],[870,1680,1695],[1705,10,1670],[1084,1767,1683],[1196,1738,1686],[1750,870,1681],[1750,18,870],[1773,1703,1660],[1135,47,425],[150,323,1134],[1707,1655,1706],[1741,344,1687],[1685,1691,1684],[1684,1691,802],[1672,1656,0],[1038,124,608],[1671,1672,1690],[1628,1218,1767],[1686,1275,1667],[1493,1750,1681],[1773,18,1750],[1773,1660,18],[1679,1671,16],[1735,1706,1673],[1667,1678,1686],[1688,1658,1],[1656,1688,0],[1293,1281,1458],[1698,1678,1667],[1696,1130,1722],[1698,1667,1696],[1715,1662,1699],[1692,1038,294],[1682,767,357],[1669,661,1692],[802,1702,824],[1028,1067,1784],[822,1624,778],[119,813,861],[1218,1670,1677],[1703,1693,17],[1658,1710,1],[750,1730,1729],[1701,750,1729],[1693,1735,1673],[1731,1694,98],[1691,1702,802],[783,1729,1719],[1680,870,1708],[1707,1709,1655],[533,756,675],[1691,1210,1702],[11,1705,1670],[1767,1218,1196],[1218,1677,1196],[1664,1716,1721],[1729,1725,1719],[1729,1072,1725],[1210,1116,1702],[1702,1720,824],[1682,1661,2],[1713,1719,1721],[1716,1786,1713],[1730,1722,1072],[294,1717,1811],[1692,294,1666],[1659,680,821],[824,1720,1714],[1726,1731,1718],[345,1062,1045],[1738,1743,1275],[1075,1089,1071],[783,1719,1689],[1275,684,1728],[1692,1666,1665],[1675,1692,1665],[294,1811,1666],[1716,1664,310],[1678,1698,1700],[6,9,1727],[676,649,595],[381,31,361],[1723,1804,1772],[1727,9,1694],[1720,1089,1714],[1786,1716,1412],[1683,1196,1686],[1718,1697,1085],[1116,1739,1702],[1739,1734,1720],[1702,1739,1720],[1089,1720,1734],[509,748,1745],[1743,1715,1726],[1717,294,794],[1116,1732,1739],[1718,1731,1697],[1696,1667,1130],[1134,1665,1723],[1694,712,98],[101,1687,102],[391,1736,101],[662,636,642],[1734,1447,1089],[1089,1447,1071],[436,99,493],[1689,1279,783],[1485,1465,1342],[1736,1687,101],[344,1741,1733],[1741,1742,1733],[1735,829,1706],[829,1707,1706],[1485,1332,1465],[952,1126,1742],[1747,1447,1734],[879,892,645],[1730,1146,1696],[829,1709,1707],[1709,1712,1655],[118,1739,1732],[1332,1744,1465],[1687,1749,1741],[1741,1758,1742],[679,1072,68],[1072,1722,68],[118,1747,1739],[1747,1734,1739],[1465,1744,1736],[1736,1740,1687],[1704,1701,783],[1665,624,1723],[1722,1130,67],[1025,1055,467],[1444,14,1701],[558,522,530],[1657,1658,1688],[1339,1746,1332],[1332,1748,1744],[1687,1740,1749],[1741,1749,1758],[1109,952,1742],[1747,118,141],[1671,1690,1628],[1671,1628,16],[1657,1688,1656],[1745,748,1447],[357,767,1710],[1746,1748,1332],[1146,1700,1698],[1759,1307,1338],[1239,781,1322],[1745,1447,1747],[522,1745,1747],[316,717,595],[148,1493,1724],[1758,1109,1742],[1725,1072,679],[726,719,1661],[1695,1680,1526],[1772,1750,1493],[148,1772,1493],[1542,1751,1101],[952,1109,1086],[1744,1752,1736],[1736,1752,1740],[1753,1755,1740],[391,1342,1736],[821,112,1520],[557,530,1747],[530,522,1747],[994,879,645],[1542,1756,1751],[1813,1693,1703],[1746,1754,1748],[1748,1764,1744],[1752,1757,1740],[1740,1757,1753],[1749,1740,1755],[1755,1763,1749],[1763,1758,1749],[1275,1743,684],[1813,1735,1693],[1107,1099,1101],[1723,624,1804],[1403,1603,1609],[1748,1754,1764],[1744,1757,1752],[1760,1109,1758],[1465,1736,1342],[436,115,99],[1686,1738,1275],[1751,1766,1101],[1759,1754,1746],[1755,1753,1763],[1570,1279,853],[1701,1146,750],[1655,1656,1671],[11,1670,1218],[1761,1751,1756],[1766,1107,1101],[1726,1623,1731],[1711,1704,1279],[67,784,68],[558,530,545],[1620,1618,1233],[1769,1761,1756],[102,1687,344],[1338,1754,1759],[1754,232,1764],[1744,1765,1757],[1757,1763,1753],[1762,1760,1758],[1760,1771,1109],[1339,1759,1746],[1675,1665,1134],[1730,1696,1722],[1774,1751,1761],[1766,1780,1107],[1780,1105,1107],[1764,1765,1744],[1763,1762,1758],[1772,1773,1750],[1811,1813,1703],[1434,1769,1432],[1780,1766,1751],[232,1781,1764],[1711,1279,1570],[1688,1,0],[1774,1780,1751],[1764,1781,1765],[1765,1768,1757],[1757,1768,1763],[1777,1782,1760],[1762,1777,1760],[1769,1774,1761],[1763,1777,1762],[1760,1782,1771],[232,1737,1781],[1768,1776,1763],[272,255,774],[1669,994,661],[1618,1769,1434],[1765,589,1768],[1770,1777,1763],[1701,1729,783],[1783,1774,1769],[1789,1780,1774],[589,1775,1768],[1776,1770,1763],[1782,1778,1771],[1771,1778,1070],[624,1703,1773],[624,1811,1703],[1620,1244,1618],[1779,1769,1618],[1779,1783,1769],[739,1735,1813],[1775,1776,1768],[1790,1777,1770],[1777,1778,1782],[1725,679,1721],[733,1293,1458],[1802,1618,1244],[1802,1779,1618],[1788,1783,1779],[1789,1774,1783],[1796,1780,1789],[1796,1119,1780],[1823,1817,325],[1699,1727,1623],[750,1146,1730],[1497,1724,296],[1128,1119,1796],[61,62,71],[1131,413,824],[1114,1111,249],[1784,1776,1775],[1123,723,1283],[1791,1788,1779],[1788,1789,1783],[1095,1797,1074],[1028,1784,1775],[1784,1770,1776],[1777,1790,1778],[1793,1797,1095],[1797,1800,1074],[1798,1790,1770],[1805,1802,1244],[1802,1791,1779],[1792,1789,1788],[1793,1785,1128],[1793,1095,1785],[1074,1800,1619],[741,457,593],[1798,1770,1784],[1798,1794,1790],[1786,1689,1713],[684,1726,1718],[1728,1085,793],[1795,1787,1502],[1806,1802,1805],[1819,1788,1791],[1067,1798,1784],[1790,1794,1778],[1795,1502,1124],[1801,1805,1787],[1807,1791,1802],[1807,1819,1791],[1819,1792,1788],[1799,1128,1796],[994,645,661],[684,1085,1728],[684,1718,1085],[1699,1623,1726],[1801,1787,1795],[1808,1789,1792],[1808,1796,1789],[1799,1793,1128],[1809,1797,1793],[1809,1803,1797],[1803,1800,1797],[1067,1794,1798],[774,255,1778],[1673,1671,1679],[879,1669,888],[19,1807,1802],[1810,1619,1800],[879,994,1669],[1794,774,1778],[1723,1772,148],[1804,1773,1772],[1814,1795,1124],[1649,1814,1124],[1814,1801,1795],[1812,1806,1805],[19,1802,1806],[19,1819,1807],[1810,1800,1803],[1804,624,1773],[1714,1131,824],[1801,1812,1805],[1812,19,1806],[1808,1792,1819],[1799,1809,1793],[1821,1810,1803],[1717,739,1813],[1061,1619,1822],[1794,1817,774],[79,1482,144],[1815,1801,1814],[23,1819,19],[589,1028,1775],[1817,1823,774],[1689,1719,1713],[1824,1814,1649],[1827,1818,1801],[1818,1812,1801],[1818,19,1812],[1818,20,19],[1816,1809,1799],[1821,1803,1809],[1822,1619,1810],[124,708,608],[1663,10,1715],[1815,1827,1801],[1820,1808,1819],[23,1820,1819],[603,1810,1821],[603,1822,1810],[1085,1697,793],[1628,1690,11],[1527,1704,1624],[1730,1072,1729],[1526,1444,1704],[1526,1680,1444],[1704,1444,1701],[1816,1821,1809],[1722,67,68],[317,272,1823],[1716,1713,1721],[16,1628,1767],[1527,1526,1704],[1824,1826,1814],[1814,1826,1815],[1818,21,20],[1835,1808,1820],[603,570,1822],[226,1070,1778],[1013,1181,1179],[1721,679,1664],[1717,1813,1811],[1828,1827,1815],[22,1820,23],[22,1835,1820],[1830,603,1821],[719,1659,5],[643,567,1657],[1717,794,739],[1825,1826,1824],[1828,1815,1826],[1829,21,1818],[1808,1835,13],[4,719,5],[10,1662,1715],[1828,1832,1827],[1832,1818,1827],[12,1833,1816],[1833,1821,1816],[1833,1830,1821],[14,1146,1701],[1186,1829,1818],[1280,603,1830],[14,1700,1146],[1667,1728,1130],[1825,1834,1826],[1834,1828,1826],[1832,1186,1818],[1836,13,1835],[1624,1711,1570],[778,1624,1570],[1719,1725,1721],[1002,1825,1831],[1002,1834,1825],[1834,1832,1828],[1186,21,1829],[1836,1835,22],[1837,1833,12],[1280,1830,1833],[1667,1275,1728],[16,1767,1084],[589,1765,1838],[1765,1781,1838],[1781,1737,1838],[1737,982,1838],[982,1053,1838],[1053,816,1838],[816,589,1838]]; | |
},{}]},{},[]);var createScene=require("gl-plot3d");var createMesh=require("gl-mesh3d");var bunny=require("bunny");var scene=createScene();var mesh=createMesh({gl:scene.gl,cells:bunny.cells,positions:bunny.positions,vertexIntensity:bunny.positions.map(function(p){return Math.cos(p[0])*Math.sin(.2*p[1])+Math.cos(.4*p[2])}),colormap:"jet"});scene.add(mesh); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "requirebin-sketch", | |
"version": "1.0.0", | |
"dependencies": { | |
"gl-plot3d": "1.0.2", | |
"gl-mesh3d": "1.0.2", | |
"bunny": "1.0.1" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <body> --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <head> --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment