diff --git a/package.json b/package.json index 340ee26..9b4e295 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vgl", "description": "VTK for the Web.", - "version": "0.3.4", + "version": "0.3.5", "license": "Apache-2.0", "repository": { "type": "git", diff --git a/vgl.js b/vgl.js index fa32c83..fa4cdeb 100644 --- a/vgl.js +++ b/vgl.js @@ -7681,12 +7681,16 @@ inherit(vgl.shader, vgl.object); var getBaseUrl = (function () { 'use strict'; + var baseUrl = '.'; var scripts = document.getElementsByTagName('script'); - var index = scripts.length - 1; - var vglScript = scripts[index]; - index = vglScript.src.lastIndexOf('/'); - var baseUrl = vglScript.src.substring(0, index); - + /* When run in certain environments, there may be no scripts loaded. For + * instance, jQuery's $.getScript won't add it to a script tag. */ + if (scripts.length > 0) { + var index = scripts.length - 1; + var vglScript = scripts[index]; + index = vglScript.src.lastIndexOf('/'); + baseUrl = vglScript.src.substring(0, index); + } return function () { return baseUrl; }; })(); diff --git a/vgl.min.js b/vgl.min.js index 734b301..d21536e 100644 --- a/vgl.min.js +++ b/vgl.min.js @@ -1,5 +1,5 @@ function inherit(a,b){"use strict";var c=function(){};c.prototype=b.prototype,a.prototype=new c,a.uber=b.prototype,a.prototype.constructor=a}if("undefined"==typeof ogs)var ogs={};ogs.namespace=function(a){"use strict";var b,c=a.split("."),d=ogs;for("ogs"===c[0]&&(c=c.slice(1)),b=0;bthis.computeBoundsTimestamp().getMTime()&&this.m_parent.boundsDirtyTimestamp.modified(),this.computeBounds(),b.mode()===b.TraverseAllChildren)for(c=0;cthis.boundsDirtyTimestamp().getMTime()))for(b=0;bb;b+=1)e=2*b,f=2*b+1,d[e]c[f]&&(c[f]=d[f]);this.setBounds(c[0],c[1],c[2],c[3],c[4],c[5])}},this},inherit(vgl.groupNode,vgl.node),vgl.actor=function(){"use strict";if(!(this instanceof vgl.actor))return new vgl.actor;vgl.node.call(this);var a=this,b=mat4.create(),c=vgl.boundingObject.ReferenceFrame.Relative,d=null;return this.matrix=function(){return b},this.setMatrix=function(c){c!==b&&(b=c,a.modified())},this.referenceFrame=function(){return c},this.setReferenceFrame=function(b){return b!==c?(c=b,a.modified(),!0):!1},this.mapper=function(){return d},this.setMapper=function(b){b!==d&&(d=b,a.boundsModified())},this.accept=function(a){a=a},this.ascend=function(a){a=a},this.computeLocalToWorldMatrix=function(a,b){a=a,b=b},this.computeWorldToLocalMatrix=function(a,b){a=a,b=b},this.computeBounds=function(){if(null===d||void 0===d)return void a.resetBounds();var c,e,f,g,h=a.computeBoundsTimestamp();(a.boundsDirtyTimestamp().getMTime()>h.getMTime()||d.boundsDirtyTimestamp().getMTime()>h.getMTime())&&(d.computeBounds(),c=d.bounds(),e=[c[0],c[2],c[4]],f=[c[1],c[3],c[5]],vec3.transformMat4(e,e,b),vec3.transformMat4(f,f,b),g=[e[0]>f[0]?f[0]:e[0],e[0]>f[0]?e[0]:f[0],e[1]>f[1]?f[1]:e[1],e[1]>f[1]?e[1]:f[1],e[2]>f[2]?f[2]:e[2],e[2]>f[2]?e[2]:f[2]],a.setBounds(g[0],g[1],g[2],g[3],g[4],g[5]),h.modified())},a},inherit(vgl.actor,vgl.node),vgl.freezeObject=function(a){"use strict";var b=Object.freeze(a);return"undefined"==typeof b&&(b=function(a){return a}),b},vgl.defaultValue=function(a,b){"use strict";return"undefined"!=typeof a?a:b},vgl.defaultValue.EMPTY_OBJECT=vgl.freezeObject({}),vgl.graphicsObject=function(a){"use strict";if(a=a,!(this instanceof vgl.graphicsObject))return new vgl.graphicsObject;vgl.object.call(this);var b=this;return this._setup=function(a){return a=a,!1},this._cleanup=function(a){return a=a,!1},this.bind=function(a){return a=a,!1},this.undoBind=function(a){return a=a,!1},this.render=function(a){return a=a,!1},this.remove=function(a){b._cleanup(a)},b},inherit(vgl.graphicsObject,vgl.object),vgl.geojsonReader=function(){"use strict";return this instanceof vgl.geojsonReader?(this.readScalars=function(a,b,c,d){var e=null,f=null,g=null,h=null,i=null;"values"===this.m_scalarFormat&&4===a.length?(f=a[3],e=b.sourceData(vgl.vertexAttributeKeys.Scalar),e||(e=new vgl.sourceDataSf,this.m_scalarRange&&e.setScalarRange(this.m_scalarRange[0],this.m_scalarRange[1]),void 0!==c&&(e.data().length=c),b.addSource(e)),void 0===c?e.pushBack(f):e.insertAt(d,f)):"rgb"===this.m_scalarFormat&&6===a.length&&(e=b.sourceData(vgl.vertexAttributeKeys.Color),e||(e=new vgl.sourceDataC3fv,void 0!==c&&(e.length=3*c),b.addSource(e)),g=a[3],h=a[4],i=a[5],void 0===c?e.pushBack([g,h,i]):e.insertAt(d,[g,h,i]))},this.readPoint=function(a){var b=new vgl.geometryData,c=new vgl.points,d=new vgl.sourceDataP3fv,e=new Uint16Array(1),f=null,g=null,h=null,i=null;for(b.addSource(d),i=0;1>i;i+=1)e[i]=i,f=a[0],g=a[1],h=0,a.length>2&&(h=a[2]),d.pushBack([f,g,h]),this.readScalars(a,b);return c.setIndices(e),b.addPrimitive(c),b.setName("aPoint"),b},this.readMultiPoint=function(a){var b,c=new vgl.geometryData,d=new vgl.points,e=new vgl.sourceDataP3fv,f=new Uint16Array(a.length),g=0,h=a.length,i=null,j=null,k=null;for(e.data().length=3*h,b=0;b2&&(k=a[b][2]),e.insertAt(g,[i,j,k]),this.readScalars(a[b],c,h,g),g+=1;return d.setIndices(f),c.addPrimitive(d),c.addSource(e),c.setName("manyPoints"),c},this.readLineString=function(a){var b=new vgl.geometryData,c=new vgl.lineStrip,d=new vgl.sourceDataP3fv,e=[],f=null,g=null,h=null,i=null;for(c.setIndicesPerPrimitive(a.length),f=0;f2&&(i=a[f][2]),d.pushBack([g,h,i]),this.readScalars(a[f],b);return c.setIndices(e),b.addPrimitive(c),b.addSource(d),b.setName("aLineString"),b},this.readMultiLineString=function(a){var b=new vgl.geometryData,c=new vgl.sourceDataP3fv,d=0,e=2*a.length,f=null,g=null,h=null,i=null,j=null,k=null,l=null,m=null;for(c.data().length=3*e,g=0;gf;f+=1)k.push(d),h=a[g][f][0],i=a[g][f][1],j=0,a[g][f].length>2&&(j=a[g][f][2]),c.insertAt(d,[h,i,j]),this.readScalars(a[g][f],b,2*e,d),d+=1;l.setIndices(k),b.addPrimitive(l)}return b.setName("aMultiLineString"),b.addSource(c),b},this.readPolygon=function(a){var b=new vgl.geometryData,c=new vgl.sourceDataP3fv,d=null,e=null,f=null,g=a[0].length,h=1,i=null,j=null,k=null;for(i=0;g>i;i+=1)d=a[0][i][0],e=a[0][i][1],f=0,a[0][i].length>2&&(f=a[0][i][2]),c.pushBack([d,e,f]),this.readScalars(a[0][i],b),i>1&&(j=new Uint16Array([0,h,i]),k=new vgl.triangles,k.setIndices(j),b.addPrimitive(k),h=i);return b.setName("POLY"),b.addSource(c),b},this.readMultiPolygon=function(a){var b=new vgl.geometryData,c=new vgl.sourceDataP3fv,d=0,e=a.length,f=0,g=3*e,h=new vgl.triangles,i=[],j=null,k=null,l=null,m=null,n=null,o=null,p=null,q=null,r=null,s=!1,t=0;for(c.data().length=3*e,k=0;e>k;k+=1)for(o=a[k][0].length,p=d,q=d+1,r=[!1,!1,!1],j=0;o>j;j+=1)l=a[k][0][j][0],m=a[k][0][j][1],n=0,a[k][0][j].length>2&&(n=a[k][0][j][2]),s=!1,l>180&&(s=!0,l-=360),0===j?r[0]=s:r[1+(j-1)%2]=s,c.insertAt(f,[l,m,n]),this.readScalars(a[k][0][j],b,g,f),f+=1,j>1&&(r[0]===r[1]&&r[1]===r[2]&&(i[3*t+0]=p,i[3*t+1]=q,i[3*t+2]=d,t+=1),q=d),d+=1;return h.setIndices(i),b.addPrimitive(h),b.setName("aMultiPoly"),b.addSource(c),b},this.readGJObjectInt=function(a){if(!a.hasOwnProperty("type"))return null;a.properties&&a.properties.ScalarFormat&&"values"===a.properties.ScalarFormat&&(this.m_scalarFormat="values",a.properties.ScalarRange&&(this.m_scalarRange=a.properties.ScalarRange)),a.properties&&a.properties.ScalarFormat&&"rgb"===a.properties.ScalarFormat&&(this.m_scalarFormat="rgb");var b,c=a.type,d=null,e=null,f=null;switch(c){case"Point":b=this.readPoint(a.coordinates);break;case"MultiPoint":b=this.readMultiPoint(a.coordinates);break;case"LineString":b=this.readLineString(a.coordinates);break;case"MultiLineString":b=this.readMultiLineString(a.coordinates);break;case"Polygon":b=this.readPolygon(a.coordinates);break;case"MultiPolygon":b=this.readMultiPolygon(a.coordinates);break;case"GeometryCollection":for(e=[],f=0;fc)&&(c=a),(null===b||b>a)&&(b=a),this.data()[this.data().length]=a},this.insertAt=function(a,d){(null===c||d>c)&&(c=d),(null===b||b>d)&&(b=d),this.data()[a]=d},this.scalarRange=function(){return null===d||null===e?[b,c]:[d,e]},this.setScalarRange=function(a,b){d=a,e=b},this},inherit(vgl.sourceDataSf,vgl.sourceData),vgl.sourceDataDf=function(a){"use strict";return this instanceof vgl.sourceDataDf?(vgl.sourceData.call(this,a),this.addAttribute(vgl.vertexAttributeKeys.Scalar,vgl.GL.FLOAT,4,0,4,1,!1),this.pushBack=function(a){this.data()[this.data().length]=a},this.insertAt=function(a,b){this.data()[a]=b},this):new vgl.sourceDataDf(a)},inherit(vgl.sourceDataDf,vgl.sourceData),vgl.geometryData=function(){"use strict";if(!(this instanceof vgl.geometryData))return new vgl.geometryData;vgl.data.call(this);var a="",b=[],c=[],d=[0,0,0,0,0,0],e=vgl.timestamp(),f=vgl.timestamp();return this.type=function(){return vgl.data.geometry},this.name=function(){return a},this.setName=function(b){a=b},this.addSource=function(a,b){return void 0!==b&&a.setName(b),-1===c.indexOf(a)?(c.push(a),a.hasKey(vgl.vertexAttributeKeys.Position)&&f.modified(),!0):!1},this.source=function(a){return ae.getMTime()&&this.computeBounds(),d},this.boundsDirty=function(a){return a&&f.modified(),f.getMTime()>e.getMTime()},this.resetBounds=function(){d[0]=0,d[1]=0,d[2]=0,d[3]=0,d[4]=0,d[5]=0},this.setBounds=function(a,b,c,f,g,h){return d[0]=a,d[1]=b,d[2]=c,d[3]=f,d[4]=g,d[5]=h,e.modified(),!0},this.computeBounds=function(){if(f.getMTime()>e.getMTime()){var a,b,c,g,h,i,j=vgl.vertexAttributeKeys.Position,k=this.sourceData(j),l=k.data(),m=k.attributeNumberOfComponents(j),n=k.attributeStride(j),o=k.attributeOffset(j),p=k.sizeOfAttributeDataType(j),q=l.length,r=null;for(n/=p,o/=p,this.resetBounds(),a=0;m>a;a+=1){for(b=2*a,c=2*a+1,g=h=q?d[c]=l[o+a]:0,i=o+n+a;q>i;i+=n)r=l[i],r>g&&(g=r),h>r&&(h=r);d[b]=h,d[c]=g}e.modified()}},this.findClosestVertex=function(a){var b,c,d,e,f,g,h,i=vgl.vertexAttributeKeys.Position,j=this.sourceData(i),k=j.sizeOfAttributeDataType(i),l=j.attributeNumberOfComponents(i),m=j.data(),n=j.attributeStride(i)/k,o=j.attributeOffset(i)/k,p=Number.MAX_VALUE,q=null;for(3!==l&&console.log("[warning] Find closest vertex assumes threecomponent vertex "),a.z||(a={x:a.x,y:a.y,z:0}),b=o,h=0;bg&&(p=g,q=h);return q},this.getPosition=function(a){var b=vgl.vertexAttributeKeys.Position,c=this.sourceData(b),d=c.sizeOfAttributeDataType(b),e=c.attributeNumberOfComponents(b),f=c.data(),g=c.attributeStride(b)/d,h=c.attributeOffset(b)/d;return 3!==e&&console.log("[warning] getPosition assumes three component data"),[f[h+a*g],f[h+a*g+1],f[h+a*g+2]]},this.getScalar=function(a){var b,c,d,e,f,g=vgl.vertexAttributeKeys.Scalar,h=this.sourceData(g);return h?(b=h.attributeNumberOfComponents(g),c=h.sizeOfAttributeDataType(g),d=h.data(),e=h.attributeStride(g)/c,f=h.attributeOffset(g)/c,a*e+f>=d.length&&console.log("access out of bounds in getScalar"),d[a*e+f]):null},this},inherit(vgl.geometryData,vgl.data),vgl.mapper=function(a){"use strict";function b(a){if(g){a&&(l=a.m_context);var b,c,d,e,f,m,n,o=g.numberOfSources(),p=null;for(b=0;o>b;b+=1){for(p=l.createBuffer(),l.bindBuffer(vgl.GL.ARRAY_BUFFER,p),n=g.source(b).data(),n instanceof Float32Array||(n=new Float32Array(n)),l.bufferData(vgl.GL.ARRAY_BUFFER,n,j?vgl.GL.DYNAMIC_DRAW:vgl.GL.STATIC_DRAW),e=g.source(b).keys(),f=[],c=0;cd;d+=1)p=l.createBuffer(),l.bindBuffer(vgl.GL.ARRAY_BUFFER,p),l.bufferData(vgl.GL.ARRAY_BUFFER,g.primitive(d).indices(),vgl.GL.STATIC_DRAW),h[b]=p,b+=1;k.modified()}}function c(a){a=a,i={},h=[]}function d(a){m.deleteVertexBufferObjects(a),c(a),b(a),e=!1}if(!(this instanceof vgl.mapper))return new vgl.mapper(a);vgl.boundingObject.call(this),a=a||{};var e=!0,f=[0,1,1],g=null,h=[],i={},j=void 0===a.dynamicDraw?!1:a.dynamicDraw,k=vgl.timestamp(),l=null,m=this;return this.deleteVertexBufferObjects=function(a){var b,c=l;if(a&&(c=a.m_context),c)for(b=0;ba.getMTime()&&(c=g.bounds(),this.setBounds(c[0],c[1],c[2],c[3],c[4],c[5]),a.modified())},this.color=function(){return f},this.setColor=function(a,b,c){f[0]=a,f[1]=b,f[2]=c,this.modified()},this.geometryData=function(){return g},this.setGeometryData=function(a){g!==a&&(g=a,this.modified(),this.boundsDirtyTimestamp().modified())},this.updateSourceBuffer=function(a,b,c){if(c&&(l=c.m_context),!l)return!1;for(var d=-1,e=0;ed||d>=h.length?!1:(b||(b=g.source(e).dataToFloat32Array()), -l.bindBuffer(vgl.GL.ARRAY_BUFFER,h[d]),b instanceof Float32Array?l.bufferSubData(vgl.GL.ARRAY_BUFFER,0,b):l.bufferSubData(vgl.GL.ARRAY_BUFFER,0,new Float32Array(b)),!0)},this.getSourceBuffer=function(a){var b=g.sourceByName(a);return b?b.dataToFloat32Array():new Float32Array},this.render=function(a){(this.getMTime()>k.getMTime()||a.m_contextChanged)&&d(a),l=a.m_context,l.vertexAttrib3fv(vgl.vertexAttributeKeys.Color,this.color());var b,c=0,e=0,f=null,j=null;for(b in i)if(i.hasOwnProperty(b)){for(l.bindBuffer(vgl.GL.ARRAY_BUFFER,h[c]),e=0;ee;e+=1){switch(l.bindBuffer(vgl.GL.ARRAY_BUFFER,h[c]),c+=1,j=g.primitive(e),j.primitiveType()){case vgl.GL.POINTS:l.drawArrays(vgl.GL.POINTS,0,j.numberOfIndices());break;case vgl.GL.LINES:l.drawArrays(vgl.GL.LINES,0,j.numberOfIndices());break;case vgl.GL.LINE_STRIP:l.drawArrays(vgl.GL.LINE_STRIP,0,j.numberOfIndices());break;case vgl.GL.TRIANGLES:l.drawArrays(vgl.GL.TRIANGLES,0,j.numberOfIndices());break;case vgl.GL.TRIANGLE_STRIP:l.drawArrays(vgl.GL.TRIANGLE_STRIP,0,j.numberOfIndices())}l.bindBuffer(vgl.GL.ARRAY_BUFFER,null)}},this},inherit(vgl.mapper,vgl.boundingObject),vgl.groupMapper=function(){"use strict";if(!(this instanceof vgl.groupMapper))return new vgl.groupMapper;vgl.mapper.call(this);var a=vgl.timestamp(),b=[],c=[];return this.geometryData=function(a){return void 0!==a&&a0?c[0]:null},this.setGeometryData=function(a){(1!==c.length||c[0]!==a)&&(c=[],c.push(a),this.modified())},this.geometryDataArray=function(){return c},this.setGeometryDataArray=function(a){if(a instanceof Array){if(c!==a)return c=[],c=a,this.modified(),!0}else console.log("[error] Requies array of geometry data");return!1},this.computeBounds=function(){if(null===c||void 0===c)return void this.resetBounds();var a=this.computeBoundsTimestamp(),b=this.boundsDirtyTimestamp(),d=this.bounds(),e=null,f=null;if(b.getMTime()>a.getMTime()){for(f=0;fe[0]&&(d[0]=e[0]),d[1]e[2]&&(d[2]=e[2]),d[3]e[4]&&(d[4]=e[4]),d[5]a.getMTime()){for(e=0;e0&&b.m_resetScene&&(b.resetCamera(),b.m_resetScene=!1),a=0;a=0&&f.push([e.material().binNumber(),e]);for(f.sort(function(a,b){return a[0]-b[0]}),a=0;ae[1]?e[0]>e[2]?e[0]/2:e[2]/2:e[1]>e[2]?e[1]/2:e[2]/2,h=g>=1?2*Math.atan(Math.tan(.5*h)/g):2*Math.atan(Math.tan(.5*h)*g),i=f/Math.sin(.5*h),j=b.m_camera.viewUpDirection(),Math.abs(vec3.dot(j,a))>.999&&b.m_camera.setViewUpDirection(-j[2],j[0],j[1]),b.m_camera.setFocalPoint(d[0],d[1],d[2]),b.m_camera.setPosition(d[0]+i*-a[0],d[1]+i*-a[1],d[2]+i*-a[2]),b.resetCameraClippingRange(c)},this.hasValidBounds=function(a){return a[0]===Number.MAX_VALUE||a[1]===-Number.MAX_VALUE||a[2]===Number.MAX_VALUE||a[3]===-Number.MAX_VALUE||a[4]===Number.MAX_VALUE||a[5]===-Number.MAX_VALUE?!1:!0},this.resetCameraClippingRange=function(a){if("undefined"==typeof a&&(b.m_camera.computeBounds(),a=b.m_camera.bounds()),b.hasValidBounds(a)){var c=b.m_camera.viewPlaneNormal(),d=b.m_camera.position(),e=-c[0],f=-c[1],g=-c[2],h=-(e*d[0]+f*d[1]+g*d[2]),i=vec2.create(),j=null,k=null,l=null,m=null;if(b.m_resetClippingRange){for(i[0]=e*a[0]+f*a[2]+g*a[4]+h,i[1]=1e-18,m=0;2>m;m+=1)for(l=0;2>l;l+=1)for(k=0;2>k;k+=1)j=e*a[k]+f*a[2+l]+g*a[4+m]+h,i[0]=ji[1]?j:i[1];i[0]<0&&(i[0]=0),i[0]=.99*i[0]-.5*(i[1]-i[0]),i[1]=1.01*i[1]+.5*(i[1]-i[0]),i[0]=i[0]>=i[1]?.01*i[1]:i[0],b.m_nearClippingPlaneTolerance||(b.m_nearClippingPlaneTolerance=.01,b.m_depthBits&&b.m_depthBits>16&&(b.m_nearClippingPlaneTolerance=.001)),i[0]a||0>c||0>=d||0>=e)return void console.log("[error] Invalid position and resize values",a,c,d,e);if(b.m_resizable&&(b.m_width=d,b.m_height=e,b.m_camera.setViewAspect(d/e),b.m_camera.setParallelExtents({width:d,height:e}),b.modified()),b.m_renderPasses)for(f=0;fe||0===i[b].width()||i[b].height()>f||0===i[b].height())&&i[b].resize(c,d,e,f);return!0}catch(h){}return j||console("[ERROR] Unable to initialize WebGL. Your browser may not support it."),!1},this.context=function(){return j},this._cleanup=function(a){var b;for(b=0;bt?(f.x=0,a=!0):f.x=x.x,x.y<0||x.y>u?(f.y=0,a=!0):f.y=x.y,a!==!0?(i=w.focalPoint(),k=vec4.fromValues(i[0],i[1],i[2],1),j=v.worldToDisplay(k,w.viewMatrix(),w.projectionMatrix(),t,u),l=vec4.fromValues(f.x,f.y,j[2],1),m=vec4.fromValues(g.x,g.y,j[2],1),n=v.displayToWorld(l,w.viewMatrix(),w.projectionMatrix(),t,u),o=v.displayToWorld(m,w.viewMatrix(),w.projectionMatrix(),t,u),p=n[0]-o[0],q=n[1]-o[1],r=n[2]-o[2],e&&(w.pan(-p,-q,-r),b.viewer().render()),c&&(w.rotate(g.x-f.x,g.y-f.y),v.resetCameraClippingRange(),b.viewer().render()),d&&(s=2*(f.y-g.y)/u,s>0?w.zoom(1-Math.abs(s)):w.zoom(1+Math.abs(s)),v.resetCameraClippingRange(),b.viewer().render()),g.x=f.x,g.y=f.y,!1):void 0},this.handleMouseDown=function(a){var f;return 0===a.button&&(c=!0),1===a.button&&(e=!0),2===a.button&&(d=!0),f=b.viewer().relMouseCoords(a),f.x<0?g.x=0:g.x=f.x,f.y<0?g.y=0:g.y=f.y,!1},this.handleMouseUp=function(a){return 0===a.button&&(c=!1),1===a.button&&(e=!1),2===a.button&&(d=!1),!1},this.handleMouseWheel=function(a){var c=b.viewer().renderWindow().activeRenderer(),d=c.camera();return a.originalEvent.wheelDelta<0?d.zoom(.9):d.zoom(1.1),c.resetCameraClippingRange(),b.viewer().render(),!0},this},inherit(vgl.trackballInteractorStyle,vgl.interactorStyle),vgl.pvwInteractorStyle=function(){"use strict";function a(){d.resetCameraClippingRange(),t.viewer().render()}if(!(this instanceof vgl.pvwInteractorStyle))return new vgl.pvwInteractorStyle;vgl.trackballInteractorStyle.call(this);var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=this,u=!1,v=!1,w=!1,x={x:0,y:0};return this.handleMouseMove=function(y){var z=[],A=null,B=[],C=null;for(b=t.viewer().renderWindow().windowSize()[0],c=t.viewer().renderWindow().windowSize()[1],d=t.viewer().renderWindow().activeRenderer(),e=d.camera(),f=!1,g=t.viewer().relMouseCoords(y),h={x:0,y:0},z=t.viewer().renderWindow().renderers(),A=0;Ab?(h.x=0,f=!0):h.x=g.x,g.y<0||g.y>c?(h.y=0,f=!0):h.y=g.y,f!==!0){if(i=e.focalPoint(),j=vec4.fromValues(i[0],i[1],i[2],1),k=d.worldToDisplay(j,e.viewMatrix(),e.projectionMatrix(),b,c),l=vec4.fromValues(h.x,h.y,k[2],1),m=vec4.fromValues(x.x,x.y,k[2],1),n=d.displayToWorld(l,e.viewMatrix(),e.projectionMatrix(),b,c),o=d.displayToWorld(m,e.viewMatrix(),e.projectionMatrix(),b,c),p=n[0]-o[0],q=n[1]-o[1],r=n[2]-o[2],w&&(e.pan(-p,-q,-r),a()),u){for(C=[x.x-h.x,x.y-h.y],e.rotate(C[0],C[1]),A=0;A0?e.zoom(1-Math.abs(s)):e.zoom(1+Math.abs(s)),a()),x.x=h.x,x.y=h.y,!1}},this.handleMouseDown=function(a){return 0===a.button&&(u=!0),1===a.button&&(w=!0),2===a.button&&(v=!0),g=t.viewer().relMouseCoords(a),g.x<0?x.x=0:x.x=g.x,g.y<0?x.y=0:x.y=g.y,!1},this.handleMouseUp=function(a){return 0===a.button&&(u=!1),1===a.button&&(w=!1),2===a.button&&(v=!1),!1},this},inherit(vgl.pvwInteractorStyle,vgl.trackballInteractorStyle),vgl.viewer=function(a,b){"use strict";if(!(this instanceof vgl.viewer))return new vgl.viewer(a,b);vgl.object.call(this);var c=this,d=a,e=!0,f=null,g=vgl.renderer(b),h=vgl.renderWindow(d);return this.canvas=function(){return d},this.renderWindow=function(){return h},this.init=function(){null!==h?h._setup():console.log("[ERROR] No render window attached")},this.exit=function(a){null!==h?h._cleanup(a):console.log("[ERROR] No render window attached")},this.interactorStyle=function(){return f},this.setInteractorStyle=function(a){a!==f&&(f=a,f.setViewer(this),this.modified())},this.handleMouseDown=function(a){if(e===!0){var b=$.event.fix(a||window.event);2===a.button&&b.preventDefault(),b.state="down",b.type=vgl.event.mousePress,$(c).trigger(b)}return!0},this.handleMouseUp=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.state="up",b.type=vgl.event.mouseRelease,$(c).trigger(b)}return!0},this.handleMouseMove=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.mouseMove,$(c).trigger(b)}return!0},this.handleMouseWheel=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.mouseWheel,$(c).trigger(b)}return!0},this.handleMouseOut=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.mouseOut,$(c).trigger(b)}return!0},this.handleKeyPress=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.keyPress,$(c).trigger(b)}return!0},this.handleContextMenu=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.contextMenu,$(c).trigger(b)}return!1},this.handleClick=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.click,$(c).trigger(b)}return!1},this.handleDoubleClick=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.dblClick,$(c).trigger(b)}return!1},this.relMouseCoords=function(a){if(void 0===a.pageX||void 0===a.pageY)throw"Missing attributes pageX and pageY on the event";var b=0,c=0,e=0,f=0,g=d;do b+=g.offsetLeft-g.scrollLeft,c+=g.offsetTop-g.scrollTop,g=g.offsetParent;while(g);return e=a.pageX-b,f=a.pageY-c,{x:e,y:f}},this.render=function(){h.render()},this.bindEventHandlers=function(){$(d).on("mousedown",this.handleMouseDown),$(d).on("mouseup",this.handleMouseUp),$(d).on("mousemove",this.handleMouseMove),$(d).on("mousewheel",this.handleMouseWheel),$(d).on("contextmenu",this.handleContextMenu)},this.unbindEventHandlers=function(){$(d).off("mousedown",this.handleMouseDown),$(d).off("mouseup",this.handleMouseUp),$(d).off("mousemove",this.handleMouseMove),$(d).off("mousewheel",this.handleMouseWheel),$(d).off("contextmenu",this.handleContextMenu)},this._init=function(){this.bindEventHandlers(),h.addRenderer(g)},this._init(),this},inherit(vgl.viewer,vgl.object),vgl.shader=function(a){"use strict";if(!(this instanceof vgl.shader))return new vgl.shader(a);vgl.object.call(this);var b=[],c=a,d="";this._getContextEntry=function(a){var c,d,e=a.m_context;for(c=0;c=b&&a.splice(b,a.length-b),g},vgl.clearCachedShaders=function(b){for(var c=a.length-1;c>=0;c-=1)(null===b||void 0===b||a[c].context===b)&&a.splice(c,1)}}();var getBaseUrl=function(){"use strict";var a=document.getElementsByTagName("script"),b=a.length-1,c=a[b];b=c.src.lastIndexOf("/");var d=c.src.substring(0,b);return function(){return d}}();vgl.shaderProgram=function(){"use strict";if(!(this instanceof vgl.shaderProgram))return new vgl.shaderProgram;vgl.materialAttribute.call(this,vgl.materialAttributeType.ShaderProgram);var a=this,b=0,c=vgl.timestamp(),d=vgl.timestamp(),e=[],f=[],g={},h={},i={};return this.loadFromFile=function(b,c){var d;$.ajax({url:c,type:"GET",async:!1,success:function(c){d=vgl.shader(b),d.setShaderSource(c),a.addShader(d)}})},this.loadShader=function(a,b){this.loadFromFile(a,getBaseUrl()+"/shaders/"+b)},this.queryUniformLocation=function(a,c){return a.m_context.getUniformLocation(b,c)},this.queryAttributeLocation=function(a,c){return a.m_context.getAttribLocation(b,c)},this.addShader=function(b){if(e.indexOf(b)>-1)return!1;var c;for(c=0;c-1?!1:(f.push(b),void a.modified())},this.addVertexAttribute=function(b,c){g[c]=b,a.modified()},this.uniformLocation=function(a){return h[a]},this.attributeLocation=function(a){return i[a]},this.uniform=function(a){var b;for(b=0;b=this.getMTime())){for(a._setup(d),f=0;fb.getMTime()&&this.setup(c),a(c),c.m_context.bindTexture(vgl.GL.TEXTURE_2D,this.m_textureHandle)},this.undoBind=function(a){a.m_context.bindTexture(vgl.GL.TEXTURE_2D,null)},this.image=function(){return this.m_image},this.setImage=function(a){return null!==a?(this.m_image=a,this.updateDimensions(),this.modified(),!0):!1},this.nearestPixel=function(){return this.m_nearestPixel},this.setNearestPixel=function(a){return a=a?!0:!1,a!==this.m_nearestPixel?(this.m_nearestPixel=a,this.modified(),!0):!1},this.textureUnit=function(){return this.m_textureUnit},this.setTextureUnit=function(a){return this.m_textureUnit===a?!1:(this.m_textureUnit=a,this.modified(),!0)},this.width=function(){return this.m_width},this.setWidth=function(a){return c.m_width!==a?(c.m_width=a,c.modified(),!0):!1},this.height=function(){return c.m_height},this.setHeight=function(a){return c.m_height!==a?(c.m_height=a,c.modified(),!0):!1},this.depth=function(){return this.m_depth},this.setDepth=function(a){return null===this.m_image?!1:(this.m_depth=a,this.modified(),!0)},this.textureHandle=function(){return this.m_textureHandle},this.internalFormat=function(){return this.m_internalFormat},this.setInternalFormat=function(a){return this.m_internalFormat!==a?(this.m_internalFormat=a,this.modified(),!0):!1},this.pixelFormat=function(){return this.m_pixelFormat},this.setPixelFormat=function(a){return null===this.m_image?!1:(this.m_pixelFormat=a,this.modified(),!0)},this.pixelDataType=function(){return this.m_pixelDataType},this.setPixelDataType=function(a){return null===this.m_image?!1:(this.m_pixelDataType=a,this.modified(),!0)},this.computeInternalFormatUsingImage=function(){this.m_internalFormat=vgl.GL.RGBA,this.m_pixelFormat=vgl.GL.RGBA,this.m_pixelDataType=vgl.GL.UNSIGNED_BYTE},this.updateDimensions=function(){null!==this.m_image&&(this.m_width=this.m_image.width,this.m_height=this.m_image.height,this.m_depth=0)},this},inherit(vgl.texture,vgl.materialAttribute),vgl.lookupTable=function(){"use strict";if(!(this instanceof vgl.lookupTable))return new vgl.lookupTable;vgl.texture.call(this);var a=vgl.timestamp(),b=[0,0];return this.m_colorTable=[.07514311,.468049805,1,1,.247872569,.498782363,1,1,.339526309,.528909511,1,1,.409505078,.558608486,1,1,.468487184,.588057293,1,1,.520796675,.617435078,1,1,.568724526,.646924167,1,1,.613686735,.676713218,1,1,.656658579,.707001303,1,1,.698372844,.738002964,1,1,.739424025,.769954435,1,1,.780330104,.803121429,1,1,.821573924,.837809045,1,1,.863634967,.874374691,1,1,.907017747,.913245283,1,1,.936129275,.938743558,.983038586,1,.943467973,.943498599,.943398095,1,.990146732,.928791426,.917447482,1,1,.88332677,.861943246,1,1,.833985467,.803839606,1,1,.788626485,.750707739,1,1,.746206642,.701389973,1,1,.70590052,.654994046,1,1,.667019783,.610806959,1,1,.6289553,.568237474,1,1,.591130233,.526775617,1,1,.552955184,.485962266,1,1,.513776083,.445364274,1,1,.472800903,.404551679,1,1,.428977855,.363073592,1,1,.380759558,.320428137,1,.961891484,.313155629,.265499262,1,.916482116,.236630659,.209939162,1].map(function(a){return 255*a}),this.setup=function(b){0===this.textureUnit()?b.m_context.activeTexture(vgl.GL.TEXTURE0):1===this.textureUnit()&&b.m_context.activeTexture(vgl.GL.TEXTURE1),b.m_context.deleteTexture(this.m_textureHandle),this.m_textureHandle=b.m_context.createTexture(),b.m_context.bindTexture(vgl.GL.TEXTURE_2D,this.m_textureHandle),b.m_context.texParameteri(vgl.GL.TEXTURE_2D,vgl.GL.TEXTURE_MIN_FILTER,vgl.GL.LINEAR),b.m_context.texParameteri(vgl.GL.TEXTURE_2D,vgl.GL.TEXTURE_MAG_FILTER,vgl.GL.LINEAR),b.m_context.texParameteri(vgl.GL.TEXTURE_2D,vgl.GL.TEXTURE_WRAP_S,vgl.GL.CLAMP_TO_EDGE),b.m_context.texParameteri(vgl.GL.TEXTURE_2D,vgl.GL.TEXTURE_WRAP_T,vgl.GL.CLAMP_TO_EDGE),b.m_context.pixelStorei(vgl.GL.UNPACK_ALIGNMENT,1),this.m_width=this.m_colorTable.length/4,this.m_height=1,this.m_depth=0,b.m_context.texImage2D(vgl.GL.TEXTURE_2D,0,vgl.GL.RGBA,this.m_width,this.m_height,this.m_depth,vgl.GL.RGBA,vgl.GL.UNSIGNED_BYTE,new Uint8Array(this.m_colorTable)),b.m_context.bindTexture(vgl.GL.TEXTURE_2D,null),a.modified()},this.colorTable=function(){return this.m_colorTable},this.setColorTable=function(a){return this.m_colorTable===a?!1:(this.m_colorTable=a,this.modified(),!0)},this.range=function(){return b},this.setRange=function(a){return b===a?!1:(b=a,this.modified(),!0)},this.updateRange=function(a){a instanceof Array||console.log("[error] Invalid data type for range. Requires array [min,max]"),a[0]b[1]&&(b[1]=a[1],this.modified())},this},inherit(vgl.lookupTable,vgl.texture),vgl.uniform=function(a,b){"use strict";if(!(this instanceof vgl.uniform))return new vgl.uniform;this.getTypeNumberOfComponents=function(a){switch(a){case vgl.GL.FLOAT:case vgl.GL.INT:case vgl.GL.BOOL:return 1;case vgl.GL.FLOAT_VEC2:case vgl.GL.INT_VEC2:case vgl.GL.BOOL_VEC2:return 2;case vgl.GL.FLOAT_VEC3:case vgl.GL.INT_VEC3:case vgl.GL.BOOL_VEC3:return 3;case vgl.GL.FLOAT_VEC4:case vgl.GL.INT_VEC4:case vgl.GL.BOOL_VEC4:return 4;case vgl.GL.FLOAT_MAT3:return 9;case vgl.GL.FLOAT_MAT4:return 16;default:return 0}};var c=a,d=b,e=[];return e.length=this.getTypeNumberOfComponents(c),this.name=function(){return d},this.type=function(){return c},this.get=function(){return e},this.set=function(a){var b=0;if(16===e.length)for(b=0;16>b;b+=1)e[b]=a[b];else if(9===e.length)for(b=0;9>b;b+=1)e[b]=a[b];else if(4===e.length)for(b=0;4>b;b+=1)e[b]=a[b];else if(3===e.length)for(b=0;3>b;b+=1)e[b]=a[b];else if(2===e.length)for(b=0;2>b;b+=1)e[b]=a[b];else e[0]=a},this.callGL=function(a,b){if(!(this.m_numberElements<1))switch(c){case vgl.GL.BOOL:case vgl.GL.INT:a.m_context.uniform1iv(b,e);break;case vgl.GL.FLOAT:a.m_context.uniform1fv(b,e);break;case vgl.GL.FLOAT_VEC2:a.m_context.uniform2fv(b,e);break;case vgl.GL.FLOAT_VEC3:a.m_context.uniform3fv(b,e);break;case vgl.GL.FLOAT_VEC4:a.m_context.uniform4fv(b,e);break;case vgl.GL.FLOAT_MAT3:a.m_context.uniformMatrix3fv(b,vgl.GL.FALSE,e);break;case vgl.GL.FLOAT_MAT4:a.m_context.uniformMatrix4fv(b,vgl.GL.FALSE,e)}},this.update=function(a,b){a=a,b=b},this},vgl.modelViewUniform=function(a){"use strict";return this instanceof vgl.modelViewUniform?(0===a.length&&(a="modelViewMatrix"),vgl.uniform.call(this,vgl.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b,this.set(a.m_modelViewMatrix)},this):new vgl.modelViewUniform(a)},inherit(vgl.modelViewUniform,vgl.uniform),vgl.modelViewOriginUniform=function(a,b){"use strict";if(!(this instanceof vgl.modelViewOriginUniform))return new vgl.modelViewOriginUniform(a,b);0===a.length&&(a="modelViewMatrix");var c=[b[0],b[1],b[2]||0];return vgl.uniform.call(this,vgl.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b;var d=mat4.create();if(mat4.translate(d,a.m_modelViewMatrix,c),a.m_modelViewAlignment){var e=a.m_modelViewAlignment;d[12]=Math.round(d[12]/e.roundx)*e.roundx+e.dx,d[13]=Math.round(d[13]/e.roundy)*e.roundy+e.dy}this.set(d)},this},inherit(vgl.modelViewOriginUniform,vgl.uniform),vgl.projectionUniform=function(a){"use strict";return this instanceof vgl.projectionUniform?(0===a.length&&(a="projectionMatrix"),vgl.uniform.call(this,vgl.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b,this.set(a.m_projectionMatrix)},this):new vgl.projectionUniform(a)},inherit(vgl.projectionUniform,vgl.uniform),vgl.floatUniform=function(a,b){"use strict";return this instanceof vgl.floatUniform?(0===a.length&&(a="floatUniform"),b=void 0===b?1:b,vgl.uniform.call(this,vgl.GL.FLOAT,a),void this.set(b)):new vgl.floatUniform(a,b)},inherit(vgl.floatUniform,vgl.uniform),vgl.normalMatrixUniform=function(a){"use strict";return this instanceof vgl.normalMatrixUniform?(0===a.length&&(a="normalMatrix"),vgl.uniform.call(this,vgl.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b,this.set(a.m_normalMatrix)},this):new vgl.normalMatrixUniform(a)},inherit(vgl.normalMatrixUniform,vgl.uniform),vgl.vertexAttributeKeys={Position:0,Normal:1,TextureCoordinate:2,Color:3,Scalar:4,CountAttributeIndex:5},vgl.vertexAttributeKeysIndexed={Zero:0,One:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9},vgl.vertexAttribute=function(a){"use strict";if(!(this instanceof vgl.vertexAttribute))return new vgl.vertexAttribute(a);var b=a;this.name=function(){return b},this.bindVertexData=function(a,c){var d=a.m_mapper.geometryData(),e=d.sourceData(c),f=a.m_material.shaderProgram();a.m_context.vertexAttribPointer(f.attributeLocation(b),e.attributeNumberOfComponents(c),e.attributeDataType(c),e.normalized(c),e.attributeStride(c),e.attributeOffset(c)),a.m_context.enableVertexAttribArray(f.attributeLocation(b))},this.undoBindVertexData=function(a,c){c=c;var d=a.m_material.shaderProgram();a.m_context.disableVertexAttribArray(d.attributeLocation(b))}},vgl.source=function(){"use strict";return this instanceof vgl.source?(vgl.object.call(this),this.create=function(){},this):new vgl.source},inherit(vgl.source,vgl.object),vgl.planeSource=function(){"use strict";if(!(this instanceof vgl.planeSource))return new vgl.planeSource;vgl.source.call(this);var a=[0,0,0],b=[1,0,0],c=[0,1,0],d=[0,0,1],e=1,f=1,g=null;this.setOrigin=function(b,c,d){a[0]=b,a[1]=c,a[2]=d},this.setPoint1=function(a,c,d){b[0]=a,b[1]=c,b[2]=d},this.setPoint2=function(a,b,d){c[0]=a,c[1]=b,c[2]=d},this.create=function(){g=new vgl.geometryData;var h,i,j,k,l,m,n,o=[],p=[],q=[],r=[],s=[],t=0,u=0,v=0,w=0,x=[],y=[],z=[],A=[],B=[],C=null,D=null,E=null;for(o.length=3,p.length=2,q.length=3,r.length=3,s.length=3,h=0;3>h;h+=1)q[h]=b[h]-a[h],r[h]=c[h]-a[h];for(l=(e+1)*(f+1),m=e*f*2,x.length=3*l,y.length=3*l,A.length=2*l,B.length=l,j=0,h=0;f+1>h;h+=1)for(p[1]=h/f,i=0;e+1>i;i+=1){for(p[0]=i/e,k=0;3>k;k+=1)o[k]=a[k]+p[0]*q[k]+p[1]*r[k];x[t++]=o[0],x[t++]=o[1],x[t++]=o[2],z[v++]=1,z[v++]=1,z[v++]=1,y[u++]=d[0],y[u++]=d[1],y[u++]=d[2],A[w++]=p[0],A[w++]=p[1]}for(h=0;f>h;h+=1)for(i=0;e>i;i+=1)s[0]=i+h*(e+1),s[1]=s[0]+1,s[2]=s[0]+e+2,s[3]=s[0]+e+1;for(h=0;l>h;h+=1)B[h]=h;return C=new vgl.triangleStrip,C.setIndices(B),D=vgl.sourceDataP3fv(),D.pushBack(x),E=vgl.sourceDataC3fv(),E.pushBack(z),n=vgl.sourceDataT2fv(),n.pushBack(A),g.addSource(D),g.addSource(E),g.addSource(n),g.addPrimitive(C),g}},inherit(vgl.planeSource,vgl.source),vgl.pointSource=function(){"use strict";if(!(this instanceof vgl.pointSource))return new vgl.pointSource;vgl.source.call(this);var a=this,b=[],c=[],d=[],e=[],f=null;this.getPositions=function(){return b},this.setPositions=function(c){c instanceof Array?b=c:console.log("[ERROR] Invalid data type for positions. Array is required."),a.modified()},this.getColors=function(){return c},this.setColors=function(b){b instanceof Array?c=b:console.log("[ERROR] Invalid data type for colors. Array is required."),a.modified()},this.getSize=function(){return e},this.setSize=function(a){e=a,this.modified()},this.setTextureCoordinates=function(b){b instanceof Array?d=b:console.log("[ERROR] Invalid data type for texture coordinates. Array is required."),a.modified()},this.create=function(){if(f=new vgl.geometryData,b.length%3!==0)return void console.log("[ERROR] Invalid length of the points array");var a,g,h,i,j,k=b.length/3,l=0,m=[];for(m.length=k,l=0;k>l;l+=1)m[l]=l;if(j=vgl.sourceDataDf(),k!==e.length)for(l=0;k>l;l+=1)j.pushBack(e);else j.setData(e);return f.addSource(j),a=new vgl.points,a.setIndices(m),g=vgl.sourceDataP3fv(),g.pushBack(b),f.addSource(g),c.length>0&&c.length===b.length?(h=vgl.sourceDataC3fv(),h.pushBack(c),f.addSource(h)):c.length>0&&c.length!==b.length&&console.log("[ERROR] Number of colors are different than number of points"),d.length>0&&d.length===b.length?(i=vgl.sourceDataT2fv(),i.pushBack(d),f.addSource(i)):d.length>0&&d.length/2!==b.length/3&&console.log("[ERROR] Number of texture coordinates are different than number of points"),f.addPrimitive(a),f}},inherit(vgl.pointSource,vgl.source),vgl.lineSource=function(a,b){"use strict";if(!(this instanceof vgl.lineSource))return new vgl.lineSource;vgl.source.call(this);var c=a,d=b;this.setPositions=function(a){return a instanceof Array?(c=a,this.modified(),!0):(console.log("[ERROR] Invalid data type for positions. Array is required."),!1)},this.setColors=function(a){return a instanceof Array?(d=a,this.modified(),!0):(console.log("[ERROR] Invalid data type for colors. Array is required."),!1)},this.create=function(){if(!c)return void console.log("[error] Invalid positions");if(c.length%3!==0)return void console.log("[error] Line source requires 3d points");if(c.length%3!==0)return void console.log("[ERROR] Invalid length of the points array");var a,b,e,f,g=new vgl.geometryData,h=c.length/3,i=[];for(i.length=h,a=0;h>a;a+=1)i[a]=a;return b=new vgl.lines,b.setIndices(i),e=vgl.sourceDataP3fv(),e.pushBack(c),g.addSource(e),d&&d.length>0&&d.length===c.length?(f=vgl.sourceDataC3fv(),f.pushBack(d),g.addSource(f)):d&&d.length>0&&d.length!==c.length&&console.log("[error] Number of colors are different than number of points"),g.addPrimitive(b),g}},inherit(vgl.lineSource,vgl.source),vgl.utils=function(){"use strict";return this instanceof vgl.utils?(vgl.object.call(this),this):new vgl.utils},inherit(vgl.utils,vgl.object),vgl.utils.computePowerOfTwo=function(a,b){"use strict";for(b=b||1;a>b;)b*=2;return b},vgl.utils.createTextureVertexShader=function(a){"use strict";var b=["attribute vec3 vertexPosition;","attribute vec3 textureCoord;","uniform mediump float pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","varying highp vec3 iTextureCoord;","void main(void)","{","gl_PointSize = pointSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);"," iTextureCoord = textureCoord;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createTextureFragmentShader=function(a){"use strict";var b=["varying highp vec3 iTextureCoord;","uniform sampler2D sampler2d;","uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4(texture2D(sampler2d, vec2(iTextureCoord.s, iTextureCoord.t)).xyz, opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createRgbaTextureFragmentShader=function(a){"use strict";var b=["varying highp vec3 iTextureCoord;","uniform sampler2D sampler2d;","uniform mediump float opacity;","void main(void) {"," mediump vec4 color = vec4(texture2D(sampler2d, vec2(iTextureCoord.s, iTextureCoord.t)).xyzw);"," color.w *= opacity;"," gl_FragColor = color;","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createVertexShader=function(a){"use strict";var b=["attribute vec3 vertexPosition;","attribute vec3 vertexColor;","uniform mediump float pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","varying mediump vec3 iVertexColor;","varying highp vec3 iTextureCoord;","void main(void)","{","gl_PointSize = pointSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);"," iVertexColor = vertexColor;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createPointVertexShader=function(a){"use strict";var b=["attribute vec3 vertexPosition;","attribute vec3 vertexColor;","attribute float vertexSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","varying mediump vec3 iVertexColor;","varying highp vec3 iTextureCoord;","void main(void)","{","gl_PointSize = vertexSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);"," iVertexColor = vertexColor;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createVertexShaderSolidColor=function(a){"use strict";var b=["attribute vec3 vertexPosition;","uniform mediump float pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","void main(void)","{","gl_PointSize = pointSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createVertexShaderColorMap=function(a,b,c){"use strict";b=b,c=c;var d=["attribute vec3 vertexPosition;","attribute float vertexScalar;","uniform mediump float pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float lutMin;","uniform float lutMax;","varying mediump float iVertexScalar;","void main(void)","{","gl_PointSize = pointSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);","iVertexScalar = (vertexScalar-lutMin)/(lutMax-lutMin);","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,d)},vgl.utils.createFragmentShader=function(a){"use strict";var b=["varying mediump vec3 iVertexColor;","uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4(iVertexColor, opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createPhongVertexShader=function(a){"use strict";var b=["attribute highp vec3 vertexPosition;","attribute mediump vec3 vertexNormal;","attribute mediump vec3 vertexColor;","uniform highp mat4 projectionMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 normalMatrix;","varying highp vec4 varPosition;","varying mediump vec3 varNormal;","varying mediump vec3 varVertexColor;","void main(void)","{","varPosition = modelViewMatrix * vec4(vertexPosition, 1.0);","gl_Position = projectionMatrix * varPosition;","varNormal = vec3(normalMatrix * vec4(vertexNormal, 0.0));","varVertexColor = vertexColor;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createPhongFragmentShader=function(a){"use strict";var b=["uniform mediump float opacity;","precision mediump float;","varying vec3 varNormal;","varying vec4 varPosition;","varying mediump vec3 varVertexColor;","const vec3 lightPos = vec3(0.0, 0.0,10000.0);","const vec3 ambientColor = vec3(0.01, 0.01, 0.01);","const vec3 specColor = vec3(0.0, 0.0, 0.0);","void main() {","vec3 normal = normalize(varNormal);","vec3 lightDir = normalize(lightPos);","vec3 reflectDir = -reflect(lightDir, normal);","vec3 viewDir = normalize(-varPosition.xyz);","float lambertian = max(dot(lightDir, normal), 0.0);","vec3 color = vec3(0.0);","if(lambertian > 0.0) {"," color = lambertian * varVertexColor;","}","gl_FragColor = vec4(color * opacity, 1.0 - opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createFragmentShaderSolidColor=function(a,b){"use strict";var c=["uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4("+b[0]+","+b[1]+","+b[2]+", opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,c)},vgl.utils.createFragmentShaderColorMap=function(a){"use strict";var b=["varying mediump float iVertexScalar;","uniform sampler2D sampler2d;","uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4(texture2D(sampler2d, vec2(iVertexScalar, 0.0)).xyz, opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createPointSpritesVertexShader=function(a){"use strict";var b=["attribute vec3 vertexPosition;","attribute vec3 vertexColor;","uniform mediump vec2 pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float height;","varying mediump vec3 iVertexColor;","varying highp float iVertexScalar;","void main(void)","{","mediump float realPointSize = pointSize.y;","if (pointSize.x > pointSize.y) {"," realPointSize = pointSize.x;}","gl_PointSize = realPointSize ;","iVertexScalar = vertexPosition.z;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition.xy, height, 1.0);"," iVertexColor = vertexColor;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createPointSpritesFragmentShader=function(a){"use strict";var b=["varying mediump vec3 iVertexColor;","varying highp float iVertexScalar;","uniform sampler2D opacityLookup;","uniform highp float lutMin;","uniform highp float lutMax;","uniform sampler2D scalarsToColors;","uniform int useScalarsToColors;","uniform int useVertexColors;","uniform mediump vec2 pointSize;","uniform mediump float vertexColorWeight;","void main(void) {","mediump vec2 realTexCoord;","if (pointSize.x > pointSize.y) {"," realTexCoord = vec2(1.0, pointSize.y/pointSize.x) * gl_PointCoord;","} else {"," realTexCoord = vec2(pointSize.x/pointSize.y, 1.0) * gl_PointCoord;","}","highp float texOpacity = texture2D(opacityLookup, realTexCoord).w;","if (useScalarsToColors == 1) {"," gl_FragColor = vec4(texture2D(scalarsToColors, vec2((iVertexScalar - lutMin)/(lutMax - lutMin), 0.0)).xyz, texOpacity);","} else if (useVertexColors == 1) {"," gl_FragColor = vec4(iVertexColor, texOpacity);","} else {"," gl_FragColor = vec4(texture2D(opacityLookup, realTexCoord).xyz, texOpacity);","}}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createTextureMaterial=function(a,b){"use strict";var c,d=new vgl.material,e=new vgl.blend,f=new vgl.shaderProgram,g=vgl.utils.createTextureVertexShader(vgl.GL),h=null,i=new vgl.vertexAttribute("vertexPosition"),j=new vgl.vertexAttribute("textureCoord"),k=new vgl.floatUniform("pointSize",5),l=new vgl.projectionUniform("projectionMatrix"),m=new vgl.uniform(vgl.GL.INT,"sampler2d"),n=null;return c=void 0!==b?new vgl.modelViewOriginUniform("modelViewMatrix",b):new vgl.modelViewUniform("modelViewMatrix"),m.set(0),f.addVertexAttribute(i,vgl.vertexAttributeKeys.Position),f.addVertexAttribute(j,vgl.vertexAttributeKeys.TextureCoordinate),f.addUniform(k),f.addUniform(c),f.addUniform(l),h=a?vgl.utils.createRgbaTextureFragmentShader(vgl.GL):vgl.utils.createTextureFragmentShader(vgl.GL),n=new vgl.floatUniform("opacity",1),f.addUniform(n),f.addShader(h),f.addShader(g),d.addAttribute(f),d.addAttribute(e),d},vgl.utils.createGeometryMaterial=function(){"use strict";var a=new vgl.material,b=new vgl.shaderProgram,c=5,d=1,e=vgl.utils.createVertexShader(vgl.GL),f=vgl.utils.createFragmentShader(vgl.GL),g=new vgl.vertexAttribute("vertexPosition"),h=new vgl.vertexAttribute("vertexColor"),i=new vgl.floatUniform("pointSize",c),j=new vgl.floatUniform("opacity",d),k=new vgl.modelViewUniform("modelViewMatrix"),l=new vgl.projectionUniform("projectionMatrix");return b.addVertexAttribute(g,vgl.vertexAttributeKeys.Position),b.addVertexAttribute(h,vgl.vertexAttributeKeys.Color),b.addUniform(i),b.addUniform(j),b.addUniform(k),b.addUniform(l),b.addShader(f),b.addShader(e),a.addAttribute(b),a},vgl.utils.createPointGeometryMaterial=function(a){"use strict";a=void 0===a?1:a;var b=new vgl.material,c=new vgl.blend,d=new vgl.shaderProgram,e=vgl.utils.createPointVertexShader(vgl.GL),f=vgl.utils.createFragmentShader(vgl.GL),g=new vgl.vertexAttribute("vertexPosition"),h=new vgl.vertexAttribute("vertexColor"),i=new vgl.vertexAttribute("vertexSize"),j=new vgl.floatUniform("opacity",a),k=new vgl.modelViewUniform("modelViewMatrix"),l=new vgl.projectionUniform("projectionMatrix");return d.addVertexAttribute(g,vgl.vertexAttributeKeys.Position),d.addVertexAttribute(h,vgl.vertexAttributeKeys.Color),d.addVertexAttribute(i,vgl.vertexAttributeKeys.Scalar),d.addUniform(j),d.addUniform(k),d.addUniform(l),d.addShader(f),d.addShader(e),b.addAttribute(d),b.addAttribute(c),b},vgl.utils.createPhongMaterial=function(){"use strict";var a=new vgl.material,b=new vgl.shaderProgram,c=vgl.utils.createPhongVertexShader(vgl.GL),d=vgl.utils.createPhongFragmentShader(vgl.GL),e=new vgl.vertexAttribute("vertexPosition"),f=new vgl.vertexAttribute("vertexNormal"),g=new vgl.vertexAttribute("vertexColor"),h=new vgl.floatUniform("opacity",1),i=new vgl.modelViewUniform("modelViewMatrix"),j=new vgl.normalMatrixUniform("normalMatrix"),k=new vgl.projectionUniform("projectionMatrix");return b.addVertexAttribute(e,vgl.vertexAttributeKeys.Position),b.addVertexAttribute(f,vgl.vertexAttributeKeys.Normal),b.addVertexAttribute(g,vgl.vertexAttributeKeys.Color),b.addUniform(h),b.addUniform(i),b.addUniform(k),b.addUniform(j),b.addShader(d),b.addShader(c),a.addAttribute(b),a},vgl.utils.createColorMaterial=function(){"use strict";var a=new vgl.material,b=new vgl.blend,c=new vgl.shaderProgram,d=vgl.utils.createVertexShader(vgl.GL),e=vgl.utils.createFragmentShader(vgl.GL),f=new vgl.vertexAttribute("vertexPosition"),g=new vgl.vertexAttribute("textureCoord"),h=new vgl.vertexAttribute("vertexColor"),i=new vgl.floatUniform("pointSize",5),j=new vgl.floatUniform("opacity",1),k=new vgl.modelViewUniform("modelViewMatrix"),l=new vgl.projectionUniform("projectionMatrix");return c.addVertexAttribute(f,vgl.vertexAttributeKeys.Position),c.addVertexAttribute(h,vgl.vertexAttributeKeys.Color),c.addVertexAttribute(g,vgl.vertexAttributeKeys.TextureCoordinate),c.addUniform(i),c.addUniform(j),c.addUniform(k),c.addUniform(l),c.addShader(e),c.addShader(d),a.addAttribute(c),a.addAttribute(b),a},vgl.utils.createColorMappedMaterial=function(a){"use strict";a||(a=new vgl.lookupTable);var b=a.range(),c=new vgl.material,d=new vgl.blend,e=new vgl.shaderProgram,f=vgl.utils.createVertexShaderColorMap(vgl.GL,b[0],b[1]),g=vgl.utils.createFragmentShaderColorMap(vgl.GL),h=new vgl.vertexAttribute("vertexPosition"),i=new vgl.vertexAttribute("vertexScalar"),j=new vgl.floatUniform("pointSize",5),k=new vgl.floatUniform("opacity",1),l=new vgl.floatUniform("lutMin",b[0]),m=new vgl.floatUniform("lutMax",b[1]),n=new vgl.modelViewUniform("modelViewMatrix"),o=new vgl.projectionUniform("projectionMatrix"),p=new vgl.uniform(vgl.GL.FLOAT,"sampler2d"),q=a;return p.set(0),e.addVertexAttribute(h,vgl.vertexAttributeKeys.Position),e.addVertexAttribute(i,vgl.vertexAttributeKeys.Scalar),e.addUniform(j),e.addUniform(k),e.addUniform(l),e.addUniform(m),e.addUniform(n),e.addUniform(o),e.addShader(g),e.addShader(f),c.addAttribute(e),c.addAttribute(d),c.addAttribute(q),c},vgl.utils.updateColorMappedMaterial=function(a,b){"use strict";if(!a)return void console.log("[warning] Invalid material. Nothing to update.");if(!b)return void console.log("[warning] Invalid lookup table. Nothing to update.");var c=a.shaderProgram().uniform("lutMin"),d=a.shaderProgram().uniform("lutMax");c.set(b.range()[0]),d.set(b.range()[1]),a.setAttribute(b)},vgl.utils.createSolidColorMaterial=function(a){"use strict";a||(a=[1,1,1]);var b=new vgl.material,c=new vgl.blend,d=new vgl.shaderProgram,e=vgl.utils.createVertexShaderSolidColor(vgl.GL),f=vgl.utils.createFragmentShaderSolidColor(vgl.GL,a),g=new vgl.vertexAttribute("vertexPosition"),h=new vgl.floatUniform("pointSize",5),i=new vgl.floatUniform("opacity",1),j=new vgl.modelViewUniform("modelViewMatrix"),k=new vgl.projectionUniform("projectionMatrix");return d.addVertexAttribute(g,vgl.vertexAttributeKeys.Position),d.addUniform(h),d.addUniform(i),d.addUniform(j),d.addUniform(k),d.addShader(f),d.addShader(e),b.addAttribute(d),b.addAttribute(c),b},vgl.utils.createPointSpritesMaterial=function(a,b){"use strict";var c=void 0===b?[0,1]:b.range(),d=new vgl.material,e=new vgl.blend,f=new vgl.shaderProgram,g=vgl.utils.createPointSpritesVertexShader(vgl.GL),h=vgl.utils.createPointSpritesFragmentShader(vgl.GL),i=new vgl.vertexAttribute("vertexPosition"),j=new vgl.vertexAttribute("vertexColor"),k=new vgl.floatUniform("height",0),l=new vgl.floatUniform("vertexColorWeight",0),m=new vgl.floatUniform("lutMin",c[0]),n=new vgl.floatUniform("lutMax",c[1]),o=new vgl.modelViewUniform("modelViewMatrix"),p=new vgl.projectionUniform("projectionMatrix"),q=new vgl.uniform(vgl.GL.INT,"opacityLookup"),r=new vgl.uniform(vgl.GL.INT,"scalarsToColors"),s=new vgl.uniform(vgl.GL.INT,"useScalarsToColors"),t=new vgl.uniform(vgl.GL.INT,"useVertexColors"),u=new vgl.uniform(vgl.GL.FLOAT_VEC2,"pointSize"),v=new vgl.texture;return q.set(0),r.set(1),s.set(0),t.set(0),u.set([1,1]),f.addVertexAttribute(i,vgl.vertexAttributeKeys.Position),f.addVertexAttribute(j,vgl.vertexAttributeKeys.Color),f.addUniform(k),f.addUniform(l),f.addUniform(o),f.addUniform(p),f.addUniform(q),f.addUniform(t),f.addUniform(s),f.addUniform(u),f.addShader(h),f.addShader(g),d.addAttribute(f),d.addAttribute(e),b&&(f.addUniform(r),s.set(1),f.addUniform(m),f.addUniform(n),b.setTextureUnit(1), -d.addAttribute(b)),v.setImage(a),v.setTextureUnit(0),d.addAttribute(v),d},vgl.utils.createPlane=function(a,b,c,d,e,f,g,h,i){"use strict";var j=new vgl.mapper,k=new vgl.planeSource,l=vgl.utils.createGeometryMaterial(),m=new vgl.actor;return k.setOrigin(a,b,c),k.setPoint1(d,e,f),k.setPoint2(g,h,i),j.setGeometryData(k.create()),m.setMapper(j),m.setMaterial(l),m},vgl.utils.createTexturePlane=function(a,b,c,d,e,f,g,h,i,j){"use strict";var k=new vgl.mapper,l=new vgl.planeSource,m=vgl.utils.createTextureMaterial(j,[a,b,c]),n=new vgl.actor;return l.setPoint1(d-a,e-b,f-c),l.setPoint2(g-a,h-b,i-c),k.setGeometryData(l.create()),n.setMapper(k),n.setMaterial(m),n},vgl.utils.createPoints=function(a,b,c,d,e){"use strict";if(!a)return console.log("[ERROR] Cannot create points without positions"),null;e=void 0===e?1:e;var f=new vgl.mapper,g=new vgl.pointSource,h=vgl.utils.createPointGeometryMaterial(e),i=new vgl.actor;return g.setPositions(a),c&&g.setColors(c),d&&g.setTextureCoordinates(d),b?g.setSize(b):g.setSize(1),f.setGeometryData(g.create()),i.setMapper(f),i.setMaterial(h),i},vgl.utils.createPointSprites=function(a,b,c,d){"use strict";if(!a)return console.log("[ERROR] Point sprites requires an image"),null;if(!b)return console.log("[ERROR] Cannot create points without positions"),null;var e=new vgl.mapper,f=new vgl.pointSource,g=vgl.utils.createPointSpritesMaterial(a),h=new vgl.actor;return f.setPositions(b),c&&f.setColors(c),d&&f.setTextureCoordinates(d),e.setGeometryData(f.create()),h.setMapper(e),h.setMaterial(g),h},vgl.utils.createLines=function(a,b){"use strict";if(!a)return console.log("[ERROR] Cannot create points without positions"),null;var c=new vgl.mapper,d=new vgl.lineSource,e=vgl.utils.createGeometryMaterial(),f=new vgl.actor;return d.setPositions(a),b&&d.setColors(b),c.setGeometryData(d.create()),f.setMapper(c),f.setMaterial(e),f},vgl.utils.createColorLegend=function(a,b,c,d,e,f,g){"use strict";function h(a,b,c){if(!b)return void console.log("[error] Create labels requires positions (x,y,z) array");if(b.length%3!==0)return void console.log("[error] Create labels require positions array contain 3d points");if(!c)return void console.log("[error] Create labels requires Valid range");var d,e=null,f=vgl.utils.computePowerOfTwo(48),g=0,h=[],i=[],j=[],k=[],l=b[6]-b[0],m=4;for(i.length=3,j.length=3,k.length=3,d=0;2>d;d+=1)g=d*(b.length-3),i[0]=b[g]-l,i[1]=b[g+1]-2*l,i[2]=b[g+2],j[0]=b[g]+l,j[1]=i[1],j[2]=i[2],k[0]=i[0],k[1]=b[1],k[2]=i[2],e=vgl.utils.createTexturePlane(i[0],i[1],i[2],j[0],j[1],j[2],k[0],k[1],k[2],!0),e.setReferenceFrame(vgl.boundingObject.ReferenceFrame.Absolute),e.material().setBinNumber(vgl.material.RenderBin.Overlay),e.material().addAttribute(vgl.utils.create2DTexture(c[d].toFixed(2).toString(),12,null)),h.push(e);return i[0]=.5*(b[0]+b[b.length-3]-f),i[1]=b[1]+m,i[2]=b[2],j[0]=i[0]+f,j[1]=i[1],j[2]=i[2],k[0]=i[0],k[1]=i[1]+f,k[2]=i[2],e=vgl.utils.createTexturePlane(i[0],i[1],i[2],j[0],j[1],j[2],k[0],k[1],k[2],!0),e.setReferenceFrame(vgl.boundingObject.ReferenceFrame.Absolute),e.material().setBinNumber(vgl.material.RenderBin.Overlay),e.material().addAttribute(vgl.utils.create2DTexture(a,24,null)),h.push(e),h}function i(a,b,c,d,e,f,g,i,j,k,l,m,n,o,p){p=p;var q=j-f,r=null,s=q/m,t=[],u=[];for(r=0;m>=r;r+=1)t.push(f+s*r),t.push(g),t.push(i),t.push(f+s*r),t.push(g+o),t.push(i);return u=u.concat(h(a,t,b.range()))}if(!b)return console.log("[error] Invalid lookup table"),[];var j=c[0]+d,k=c[1],l=0,m=c[0],n=c[1]+e,o=0,p=[],q=null,r=null,s=vgl.groupNode();return q=vgl.utils.createTexturePlane(c[0],c[1],c[2],j,k,l,m,n,o,!0),r=q.material(),r.addAttribute(b),q.setMaterial(r),s.addChild(q),q.material().setBinNumber(vgl.material.RenderBin.Overlay),q.setReferenceFrame(vgl.boundingObject.ReferenceFrame.Absolute),p.push(q),p=p.concat(i(a,b,c[0],c[1],c[1],m,k,l,j,k,l,f,g,5,3))},vgl.utils.create2DTexture=function(a,b,c,d,e,f,g){"use strict";var h=document.getElementById("textRendering"),i=null,j=vgl.texture();return d=d||"sans-serif",e=e||"center",f=f||"bottom","undefined"==typeof g&&(g=!0),h||(h=document.createElement("canvas")),i=h.getContext("2d"),h.setAttribute("id","textRendering"),h.style.display="none",h.height=vgl.utils.computePowerOfTwo(8*b),h.width=h.height,i.fillStyle="rgba(0, 0, 0, 0)",i.fillRect(0,0,i.canvas.width,i.canvas.height),i.fillStyle="rgba(200, 85, 10, 1.0)",i.textAlign=e,i.textBaseline=f,i.font=4*b+"px "+d,g&&(i.font="bold "+i.font),i.fillText(a,h.width/2,h.height/2,h.width),j.setImage(h),j.updateDimensions(),j},vgl.picker=function(){"use strict";if(!(this instanceof vgl.picker))return new vgl.picker;vgl.object.call(this);var a=[];return this.getActors=function(){return a},this.pick=function(b,c,d){if(void 0===b)return 0;if(void 0===c)return 0;if(void 0===d)return 0;a=[];var e,f,g,h,i,j,k,l,m,n,o,p=d.camera(),q=d.width(),r=d.height(),s=p.focalPoint(),t=vec4.fromValues(s[0],s[1],s[2],1),u=d.worldToDisplay(t,p.viewMatrix(),p.projectionMatrix(),q,r),v=vec4.fromValues(b,c,u[2],1),w=d.displayToWorld(v,p.viewMatrix(),p.projectionMatrix(),q,r),x=p.position(),y=[];for(g=0;3>g;g+=1)y[g]=w[g]-x[g];for(e=d.sceneRoot().children(),f=0,g=0;g=0?(i=(h[0]-x[0])/y[0],j=(h[1]-x[0])/y[0]):(i=(h[1]-x[0])/y[0],j=(h[0]-x[0])/y[0]),y[1]>=0?(k=(h[2]-x[1])/y[1],l=(h[3]-x[1])/y[1]):(k=(h[3]-x[1])/y[1],l=(h[2]-x[1])/y[1]),i>l||k>j)continue;if(k>i&&(i=k),j>l&&(j=l),y[2]>=0?(m=(h[4]-x[2])/y[2],n=(h[5]-x[2])/y[2]):(m=(h[5]-x[2])/y[2],n=(h[4]-x[2])/y[2]),i>n||m>j)continue;m>i&&(i=m),j>n&&(j=n),a[f]=o,f+=1}return f},this},inherit(vgl.picker,vgl.object),vgl.shapefileReader=function(){"use strict";if(!(this instanceof vgl.shapefileReader))return new vgl.shapefileReader;var a=this,b=0,c=1,d=5,e=3;return this.int8=function(a,b){return a.charCodeAt(b)},this.bint32=function(a,b){return((255&a.charCodeAt(b))<<24)+((255&a.charCodeAt(b+1))<<16)+((255&a.charCodeAt(b+2))<<8)+(255&a.charCodeAt(b+3))},this.lint32=function(a,b){return((255&a.charCodeAt(b+3))<<24)+((255&a.charCodeAt(b+2))<<16)+((255&a.charCodeAt(b+1))<<8)+(255&a.charCodeAt(b))},this.bint16=function(a,b){return((255&a.charCodeAt(b))<<8)+(255&a.charCodeAt(b+1))},this.lint16=function(a,b){return((255&a.charCodeAt(b+1))<<8)+(255&a.charCodeAt(b))},this.ldbl64=function(a,b){var c=255&a.charCodeAt(b),d=255&a.charCodeAt(b+1),e=255&a.charCodeAt(b+2),f=255&a.charCodeAt(b+3),g=255&a.charCodeAt(b+4),h=255&a.charCodeAt(b+5),i=255&a.charCodeAt(b+6),j=255&a.charCodeAt(b+7),k=1-2*(j>>7),l=((127&j)<<4)+((240&i)>>4)-1023,m=(15&i)*Math.pow(2,48)+h*Math.pow(2,40)+g*Math.pow(2,32)+f*Math.pow(2,24)+e*Math.pow(2,16)+d*Math.pow(2,8)+c;return k*(1+m*Math.pow(2,-52))*Math.pow(2,l)},this.lfloat32=function(a,b){var c=255&a.charCodeAt(b),d=255&a.charCodeAt(b+1),e=255&a.charCodeAt(b+2),f=255&a.charCodeAt(b+3),g=1-2*(f>>7),h=((127&f)<<1)+((254&e)>>7)-127,i=(127&e)*Math.pow(2,16)+d*Math.pow(2,8)+c;return g*(1+i*Math.pow(2,-23))*Math.pow(2,h)},this.str=function(a,b,c){for(var d=[],e=b;b+c>e;){var f=a[e];if(0===f.charCodeAt(0))break;d.push(f),e+=1}return d.join("")},this.readHeader=function(a){var b=this.bint32(a,0),c=this.bint32(a,24),d=this.lint32(a,28),e=this.lint32(a,32);return{code:b,length:c,version:d,shapetype:e}},this.loadShx=function(b){for(var c=[],d=function(d){return c.push(2*a.bint32(b,d)),d+8},e=100;ej;)k.push(c(j)),j+=i;for(var l=[],m=f;f+e*g>m;){var n=a.str(b,m,1);if("*"===n)m+=g;else{m+=1;for(var o={},p=0;p=c;g-=1){var h=a.ldbl64(f,b+16*g),i=a.ldbl64(f,b+16*g+8);e.push([h,i])}return e},m=function(g){var h,i,j,m,n,o,p,q,r,s=g+8,t=a.lint32(f,s);if(t===b)console.log("NULL Shape");else if(t===c){var u=a.ldbl64(f,s+4),v=a.ldbl64(f,s+12);k.push({type:"Point",attr:{},geom:[[u,v]]})}else if(t===d){for(h=a.lint32(f,s+36),i=a.lint32(f,s+40),j=g+52,m=g+52+4*h,r=[],n=0;h>n;n+=1)o=a.lint32(f,j+4*n),p=h>n+1?a.lint32(f,j+4*(n+1)):i,q=l(m,o,p),r.push(q);k.push({type:"Polygon",attr:{},geom:[r]})}else{if(t!==e)throw"Not Implemented: "+t;for(h=a.lint32(f,s+36),i=a.lint32(f,s+40),j=g+52,m=g+52+4*h,r=[],n=0;h>n;n+=1)o=a.lint32(f,j+4*n),p=h>n+1?a.lint32(f,j+4*(n+1)):i,q=l(m,o,p),r.push(q);k.push({type:"Polyline",attr:{},geom:[r]})}},n=this.loadDBF(g);for(j=0;j=h.length)return g;if(a=h.charAt(i),i+=1,b[a])return b[a];if("A"===a)return 0}return g},this.decode64=function(a){var b="",c=new Array(4),d=!1;for(h=a,i=0;!d&&(c[0]=this.readReverseBase64())!==g&&(c[1]=this.readReverseBase64())!==g;)c[2]=this.readReverseBase64(),c[3]=this.readReverseBase64(),b+=this.ntos(c[0]<<2&255|c[1]>>4),c[2]!==g?(b+=this.ntos(c[1]<<4&255|c[2]>>2),c[3]!==g?b+=this.ntos(c[2]<<6&255|c[3]):d=!0):d=!0;return b},this.readNumber=function(a){var b=a[j++]+(a[j++]<<8)+(a[j++]<<16)+(a[j++]<<24);return b},this.readF3Array=function(a,b){var c,d=4*a*3,e=new Int8Array(d),f=null;for(c=0;d>c;c+=1)e[c]=b[j],j+=1;return f=new Float32Array(e.buffer)},this.readColorArray=function(a,b,c){var d,e=0,f=new Array(3*a);for(d=0;a>d;d+=1)f[e++]=b[j++]/255,f[e++]=b[j++]/255,f[e++]=b[j++]/255,j++;c.insert(f)},this.parseObject=function(a){var b,c,d,e,f,g,h,i,m,n,o,p=new vgl.geometryData,q=vgl.mapper(),r=[],s=null,t=null,u=null,v=null;for(t=atob(a.data),l=0;lk;k+=1)p[q++]=e[3*k],p[q++]=e[3*k+1],p[q++]=e[3*k+2];for(l.insert(p),a.addSource(l),m=new vgl.sourceDataC3fv,this.readColorArray(d,b,m),a.addSource(m),n=new vgl.lines,a.addPrimitive(n),c=this.readNumber(b),f=new Int8Array(2*c),k=0;2*c>k;k+=1)f[k]=b[j],j+=1;for(g=new Uint16Array(f.buffer),n.setIndices(g),n.setPrimitiveType(vgl.GL.LINES),h=64,f=new Int8Array(h),k=0;h>k;k+=1)f[k]=b[j],j+=1;return i=new Float32Array(f.buffer),mat4.copy(o,i),o},this.parseMeshData=function(a,b){var c,d,e,f,g,h,i,k,l,m=null,n=null,o=null,p=mat4.create(),q=null,r=null,s=0;for(d=this.readNumber(b),r=new Array(6*d),m=new vgl.sourceDataP3N3f,e=this.readF3Array(d,b),o=this.readF3Array(d,b),k=0;d>k;k+=1)r[s++]=e[3*k],r[s++]=e[3*k+1],r[s++]=e[3*k+2],r[s++]=o[3*k],r[s++]=o[3*k+1],r[s++]=o[3*k+2];for(m.insert(r),a.addSource(m),n=new vgl.sourceDataC3fv,this.readColorArray(d,b,n),a.addSource(n),f=[],q=new vgl.triangles,c=this.readNumber(b),f=new Int8Array(2*c),k=0;2*c>k;k+=1)f[k]=b[j],j+=1;for(g=new Uint16Array(f.buffer),q.setIndices(g),a.addPrimitive(q),h=64,f=new Int8Array(h),k=0;h>k;k+=1)f[k]=b[j],j+=1;return i=new Float32Array(f.buffer),mat4.copy(p,i),l=null,p},this.parsePointData=function(a,b){var c,d,e,f,g,h,i=mat4.create(),k=null,m=null,n=null,o=null,p=0;for(c=this.readNumber(b),o=new Array(3*c),k=new vgl.sourceDataP3fv,d=this.readF3Array(c,b),e=new Uint16Array(c),l=0;c>l;l+=1)e[l]=l,o[p++]=d[3*l],o[p++]=d[3*l+1],o[p++]=d[3*l+2];for(k.insert(o),a.addSource(k),m=new vgl.sourceDataC3fv,this.readColorArray(c,b,m),a.addSource(m),n=new vgl.points,n.setIndices(e),a.addPrimitive(n),g=64,f=new Int8Array(g),l=0;g>l;l+=1)f[l]=b[j],j+=1;return h=new Float32Array(f.buffer),mat4.copy(i,h),i},this.parseColorMapData=function(a,b,c){var d,e,f,g,h,i={};for(i.numOfColors=c,e=8,d=new Int8Array(e),g=0;e>g;g+=1)d[g]=b[j],j+=1;for(i.position=new Float32Array(d.buffer),e=8,d=new Int8Array(e),g=0;e>g;g+=1)d[g]=b[j],j+=1;for(i.size=new Float32Array(d.buffer),i.colors=[],h=0;hg;g+=1)d[g]=b[j],j+=1;f=[new Float32Array(d.buffer)[0],b[j++],b[j++],b[j++]],i.colors[h]=f}for(i.orientation=b[j++],i.numOfLabels=b[j++],i.title="";j=0;b-=1)a=this.getRenderer(b),this.parseSceneMetadata(a,b);return k},this.createViewer=function(a){var b;return null===k&&(f=a,k=vgl.viewer(a),k.init(),k.renderWindow().removeRenderer(k.renderWindow().activeRenderer()),k.renderWindow().addRenderer(new vgl.depthPeelRenderer),c[0]=k.renderWindow().activeRenderer(),k.renderWindow().resize(a.width,a.height),b=vgl.pvwInteractorStyle(),k.setInteractorStyle(b)),k},this.deleteViewer=function(){c={},k=null},this.updateCanvas=function(a){return f=a,k.renderWindow().resize(a.width,a.height),k},this.numObjects=function(){return d},this.getRenderer=function(a){var b;return b=c[a],(null===b||"undefined"==typeof b)&&(b=new vgl.renderer,b.setResetScene(!1),b.setResetClippingRange(!1),k.renderWindow().addRenderer(b),0!==a&&b.camera().setClearMask(vgl.GL.DepthBufferBit),c[a]=b),b},this.setVtkScene=function(a){e=a},this},vgl.DataBuffers=function(a){"use strict";if(!(this instanceof vgl.DataBuffers))return new vgl.DataBuffers(a);var b,c={};b=a||0===a?a:256;var d=0,e=function(a,b,c,d){a||console.log("ack"),c||(c=0),d||(d=b.length);for(var e=0;d>e;e+=1)a[c+e]=b[e]},f=function(a){var d=b;for(a>2*d&&(d=a);a>d;)d*=2;b=d;for(var f in c)if(c.hasOwnProperty(f)){var g=new Float32Array(d*c[f].len),h=c[f].array;e(g,h),c[f].array=g,c[f].dirty=!0}};this.create=function(a,d){if(!d)throw"Length of buffer must be a positive integer";var e=new Float32Array(b*d);return c[a]={array:e,len:d,dirty:!1},c[a].array},this.alloc=function(a){d+a>=b&&f(d+a);var c=d;return d+=a,c},this.get=function(a){return c[a].array},this.write=function(a,b,d,f){e(c[a].array,b,d*c[a].len,f*c[a].len),c[a].dirty=!0},this.repeat=function(a,b,d,f){for(var g=0;f>g;g+=1)e(c[a].array,b,(d+g)*c[a].len,c[a].len);c[a].dirty=!0},this.count=function(){return d},this.data=function(a){return c[a].array}}; +l.bindBuffer(vgl.GL.ARRAY_BUFFER,h[d]),b instanceof Float32Array?l.bufferSubData(vgl.GL.ARRAY_BUFFER,0,b):l.bufferSubData(vgl.GL.ARRAY_BUFFER,0,new Float32Array(b)),!0)},this.getSourceBuffer=function(a){var b=g.sourceByName(a);return b?b.dataToFloat32Array():new Float32Array},this.render=function(a){(this.getMTime()>k.getMTime()||a.m_contextChanged)&&d(a),l=a.m_context,l.vertexAttrib3fv(vgl.vertexAttributeKeys.Color,this.color());var b,c=0,e=0,f=null,j=null;for(b in i)if(i.hasOwnProperty(b)){for(l.bindBuffer(vgl.GL.ARRAY_BUFFER,h[c]),e=0;ee;e+=1){switch(l.bindBuffer(vgl.GL.ARRAY_BUFFER,h[c]),c+=1,j=g.primitive(e),j.primitiveType()){case vgl.GL.POINTS:l.drawArrays(vgl.GL.POINTS,0,j.numberOfIndices());break;case vgl.GL.LINES:l.drawArrays(vgl.GL.LINES,0,j.numberOfIndices());break;case vgl.GL.LINE_STRIP:l.drawArrays(vgl.GL.LINE_STRIP,0,j.numberOfIndices());break;case vgl.GL.TRIANGLES:l.drawArrays(vgl.GL.TRIANGLES,0,j.numberOfIndices());break;case vgl.GL.TRIANGLE_STRIP:l.drawArrays(vgl.GL.TRIANGLE_STRIP,0,j.numberOfIndices())}l.bindBuffer(vgl.GL.ARRAY_BUFFER,null)}},this},inherit(vgl.mapper,vgl.boundingObject),vgl.groupMapper=function(){"use strict";if(!(this instanceof vgl.groupMapper))return new vgl.groupMapper;vgl.mapper.call(this);var a=vgl.timestamp(),b=[],c=[];return this.geometryData=function(a){return void 0!==a&&a0?c[0]:null},this.setGeometryData=function(a){(1!==c.length||c[0]!==a)&&(c=[],c.push(a),this.modified())},this.geometryDataArray=function(){return c},this.setGeometryDataArray=function(a){if(a instanceof Array){if(c!==a)return c=[],c=a,this.modified(),!0}else console.log("[error] Requies array of geometry data");return!1},this.computeBounds=function(){if(null===c||void 0===c)return void this.resetBounds();var a=this.computeBoundsTimestamp(),b=this.boundsDirtyTimestamp(),d=this.bounds(),e=null,f=null;if(b.getMTime()>a.getMTime()){for(f=0;fe[0]&&(d[0]=e[0]),d[1]e[2]&&(d[2]=e[2]),d[3]e[4]&&(d[4]=e[4]),d[5]a.getMTime()){for(e=0;e0&&b.m_resetScene&&(b.resetCamera(),b.m_resetScene=!1),a=0;a=0&&f.push([e.material().binNumber(),e]);for(f.sort(function(a,b){return a[0]-b[0]}),a=0;ae[1]?e[0]>e[2]?e[0]/2:e[2]/2:e[1]>e[2]?e[1]/2:e[2]/2,h=g>=1?2*Math.atan(Math.tan(.5*h)/g):2*Math.atan(Math.tan(.5*h)*g),i=f/Math.sin(.5*h),j=b.m_camera.viewUpDirection(),Math.abs(vec3.dot(j,a))>.999&&b.m_camera.setViewUpDirection(-j[2],j[0],j[1]),b.m_camera.setFocalPoint(d[0],d[1],d[2]),b.m_camera.setPosition(d[0]+i*-a[0],d[1]+i*-a[1],d[2]+i*-a[2]),b.resetCameraClippingRange(c)},this.hasValidBounds=function(a){return a[0]===Number.MAX_VALUE||a[1]===-Number.MAX_VALUE||a[2]===Number.MAX_VALUE||a[3]===-Number.MAX_VALUE||a[4]===Number.MAX_VALUE||a[5]===-Number.MAX_VALUE?!1:!0},this.resetCameraClippingRange=function(a){if("undefined"==typeof a&&(b.m_camera.computeBounds(),a=b.m_camera.bounds()),b.hasValidBounds(a)){var c=b.m_camera.viewPlaneNormal(),d=b.m_camera.position(),e=-c[0],f=-c[1],g=-c[2],h=-(e*d[0]+f*d[1]+g*d[2]),i=vec2.create(),j=null,k=null,l=null,m=null;if(b.m_resetClippingRange){for(i[0]=e*a[0]+f*a[2]+g*a[4]+h,i[1]=1e-18,m=0;2>m;m+=1)for(l=0;2>l;l+=1)for(k=0;2>k;k+=1)j=e*a[k]+f*a[2+l]+g*a[4+m]+h,i[0]=ji[1]?j:i[1];i[0]<0&&(i[0]=0),i[0]=.99*i[0]-.5*(i[1]-i[0]),i[1]=1.01*i[1]+.5*(i[1]-i[0]),i[0]=i[0]>=i[1]?.01*i[1]:i[0],b.m_nearClippingPlaneTolerance||(b.m_nearClippingPlaneTolerance=.01,b.m_depthBits&&b.m_depthBits>16&&(b.m_nearClippingPlaneTolerance=.001)),i[0]a||0>c||0>=d||0>=e)return void console.log("[error] Invalid position and resize values",a,c,d,e);if(b.m_resizable&&(b.m_width=d,b.m_height=e,b.m_camera.setViewAspect(d/e),b.m_camera.setParallelExtents({width:d,height:e}),b.modified()),b.m_renderPasses)for(f=0;fe||0===i[b].width()||i[b].height()>f||0===i[b].height())&&i[b].resize(c,d,e,f);return!0}catch(h){}return j||console("[ERROR] Unable to initialize WebGL. Your browser may not support it."),!1},this.context=function(){return j},this._cleanup=function(a){var b;for(b=0;bt?(f.x=0,a=!0):f.x=x.x,x.y<0||x.y>u?(f.y=0,a=!0):f.y=x.y,a!==!0?(i=w.focalPoint(),k=vec4.fromValues(i[0],i[1],i[2],1),j=v.worldToDisplay(k,w.viewMatrix(),w.projectionMatrix(),t,u),l=vec4.fromValues(f.x,f.y,j[2],1),m=vec4.fromValues(g.x,g.y,j[2],1),n=v.displayToWorld(l,w.viewMatrix(),w.projectionMatrix(),t,u),o=v.displayToWorld(m,w.viewMatrix(),w.projectionMatrix(),t,u),p=n[0]-o[0],q=n[1]-o[1],r=n[2]-o[2],e&&(w.pan(-p,-q,-r),b.viewer().render()),c&&(w.rotate(g.x-f.x,g.y-f.y),v.resetCameraClippingRange(),b.viewer().render()),d&&(s=2*(f.y-g.y)/u,s>0?w.zoom(1-Math.abs(s)):w.zoom(1+Math.abs(s)),v.resetCameraClippingRange(),b.viewer().render()),g.x=f.x,g.y=f.y,!1):void 0},this.handleMouseDown=function(a){var f;return 0===a.button&&(c=!0),1===a.button&&(e=!0),2===a.button&&(d=!0),f=b.viewer().relMouseCoords(a),f.x<0?g.x=0:g.x=f.x,f.y<0?g.y=0:g.y=f.y,!1},this.handleMouseUp=function(a){return 0===a.button&&(c=!1),1===a.button&&(e=!1),2===a.button&&(d=!1),!1},this.handleMouseWheel=function(a){var c=b.viewer().renderWindow().activeRenderer(),d=c.camera();return a.originalEvent.wheelDelta<0?d.zoom(.9):d.zoom(1.1),c.resetCameraClippingRange(),b.viewer().render(),!0},this},inherit(vgl.trackballInteractorStyle,vgl.interactorStyle),vgl.pvwInteractorStyle=function(){"use strict";function a(){d.resetCameraClippingRange(),t.viewer().render()}if(!(this instanceof vgl.pvwInteractorStyle))return new vgl.pvwInteractorStyle;vgl.trackballInteractorStyle.call(this);var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=this,u=!1,v=!1,w=!1,x={x:0,y:0};return this.handleMouseMove=function(y){var z=[],A=null,B=[],C=null;for(b=t.viewer().renderWindow().windowSize()[0],c=t.viewer().renderWindow().windowSize()[1],d=t.viewer().renderWindow().activeRenderer(),e=d.camera(),f=!1,g=t.viewer().relMouseCoords(y),h={x:0,y:0},z=t.viewer().renderWindow().renderers(),A=0;Ab?(h.x=0,f=!0):h.x=g.x,g.y<0||g.y>c?(h.y=0,f=!0):h.y=g.y,f!==!0){if(i=e.focalPoint(),j=vec4.fromValues(i[0],i[1],i[2],1),k=d.worldToDisplay(j,e.viewMatrix(),e.projectionMatrix(),b,c),l=vec4.fromValues(h.x,h.y,k[2],1),m=vec4.fromValues(x.x,x.y,k[2],1),n=d.displayToWorld(l,e.viewMatrix(),e.projectionMatrix(),b,c),o=d.displayToWorld(m,e.viewMatrix(),e.projectionMatrix(),b,c),p=n[0]-o[0],q=n[1]-o[1],r=n[2]-o[2],w&&(e.pan(-p,-q,-r),a()),u){for(C=[x.x-h.x,x.y-h.y],e.rotate(C[0],C[1]),A=0;A0?e.zoom(1-Math.abs(s)):e.zoom(1+Math.abs(s)),a()),x.x=h.x,x.y=h.y,!1}},this.handleMouseDown=function(a){return 0===a.button&&(u=!0),1===a.button&&(w=!0),2===a.button&&(v=!0),g=t.viewer().relMouseCoords(a),g.x<0?x.x=0:x.x=g.x,g.y<0?x.y=0:x.y=g.y,!1},this.handleMouseUp=function(a){return 0===a.button&&(u=!1),1===a.button&&(w=!1),2===a.button&&(v=!1),!1},this},inherit(vgl.pvwInteractorStyle,vgl.trackballInteractorStyle),vgl.viewer=function(a,b){"use strict";if(!(this instanceof vgl.viewer))return new vgl.viewer(a,b);vgl.object.call(this);var c=this,d=a,e=!0,f=null,g=vgl.renderer(b),h=vgl.renderWindow(d);return this.canvas=function(){return d},this.renderWindow=function(){return h},this.init=function(){null!==h?h._setup():console.log("[ERROR] No render window attached")},this.exit=function(a){null!==h?h._cleanup(a):console.log("[ERROR] No render window attached")},this.interactorStyle=function(){return f},this.setInteractorStyle=function(a){a!==f&&(f=a,f.setViewer(this),this.modified())},this.handleMouseDown=function(a){if(e===!0){var b=$.event.fix(a||window.event);2===a.button&&b.preventDefault(),b.state="down",b.type=vgl.event.mousePress,$(c).trigger(b)}return!0},this.handleMouseUp=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.state="up",b.type=vgl.event.mouseRelease,$(c).trigger(b)}return!0},this.handleMouseMove=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.mouseMove,$(c).trigger(b)}return!0},this.handleMouseWheel=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.mouseWheel,$(c).trigger(b)}return!0},this.handleMouseOut=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.mouseOut,$(c).trigger(b)}return!0},this.handleKeyPress=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.keyPress,$(c).trigger(b)}return!0},this.handleContextMenu=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.contextMenu,$(c).trigger(b)}return!1},this.handleClick=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.click,$(c).trigger(b)}return!1},this.handleDoubleClick=function(a){if(e===!0){var b=$.event.fix(a||window.event);b.preventDefault(),b.type=vgl.event.dblClick,$(c).trigger(b)}return!1},this.relMouseCoords=function(a){if(void 0===a.pageX||void 0===a.pageY)throw"Missing attributes pageX and pageY on the event";var b=0,c=0,e=0,f=0,g=d;do b+=g.offsetLeft-g.scrollLeft,c+=g.offsetTop-g.scrollTop,g=g.offsetParent;while(g);return e=a.pageX-b,f=a.pageY-c,{x:e,y:f}},this.render=function(){h.render()},this.bindEventHandlers=function(){$(d).on("mousedown",this.handleMouseDown),$(d).on("mouseup",this.handleMouseUp),$(d).on("mousemove",this.handleMouseMove),$(d).on("mousewheel",this.handleMouseWheel),$(d).on("contextmenu",this.handleContextMenu)},this.unbindEventHandlers=function(){$(d).off("mousedown",this.handleMouseDown),$(d).off("mouseup",this.handleMouseUp),$(d).off("mousemove",this.handleMouseMove),$(d).off("mousewheel",this.handleMouseWheel),$(d).off("contextmenu",this.handleContextMenu)},this._init=function(){this.bindEventHandlers(),h.addRenderer(g)},this._init(),this},inherit(vgl.viewer,vgl.object),vgl.shader=function(a){"use strict";if(!(this instanceof vgl.shader))return new vgl.shader(a);vgl.object.call(this);var b=[],c=a,d="";this._getContextEntry=function(a){var c,d,e=a.m_context;for(c=0;c=b&&a.splice(b,a.length-b),g},vgl.clearCachedShaders=function(b){for(var c=a.length-1;c>=0;c-=1)(null===b||void 0===b||a[c].context===b)&&a.splice(c,1)}}();var getBaseUrl=function(){"use strict";var a=".",b=document.getElementsByTagName("script");if(b.length>0){var c=b.length-1,d=b[c];c=d.src.lastIndexOf("/"),a=d.src.substring(0,c)}return function(){return a}}();vgl.shaderProgram=function(){"use strict";if(!(this instanceof vgl.shaderProgram))return new vgl.shaderProgram;vgl.materialAttribute.call(this,vgl.materialAttributeType.ShaderProgram);var a=this,b=0,c=vgl.timestamp(),d=vgl.timestamp(),e=[],f=[],g={},h={},i={};return this.loadFromFile=function(b,c){var d;$.ajax({url:c,type:"GET",async:!1,success:function(c){d=vgl.shader(b),d.setShaderSource(c),a.addShader(d)}})},this.loadShader=function(a,b){this.loadFromFile(a,getBaseUrl()+"/shaders/"+b)},this.queryUniformLocation=function(a,c){return a.m_context.getUniformLocation(b,c)},this.queryAttributeLocation=function(a,c){return a.m_context.getAttribLocation(b,c)},this.addShader=function(b){if(e.indexOf(b)>-1)return!1;var c;for(c=0;c-1?!1:(f.push(b),void a.modified())},this.addVertexAttribute=function(b,c){g[c]=b,a.modified()},this.uniformLocation=function(a){return h[a]},this.attributeLocation=function(a){return i[a]},this.uniform=function(a){var b;for(b=0;b=this.getMTime())){for(a._setup(d),f=0;fb.getMTime()&&this.setup(c),a(c),c.m_context.bindTexture(vgl.GL.TEXTURE_2D,this.m_textureHandle)},this.undoBind=function(a){a.m_context.bindTexture(vgl.GL.TEXTURE_2D,null)},this.image=function(){return this.m_image},this.setImage=function(a){return null!==a?(this.m_image=a,this.updateDimensions(),this.modified(),!0):!1},this.nearestPixel=function(){return this.m_nearestPixel},this.setNearestPixel=function(a){return a=a?!0:!1,a!==this.m_nearestPixel?(this.m_nearestPixel=a,this.modified(),!0):!1},this.textureUnit=function(){return this.m_textureUnit},this.setTextureUnit=function(a){return this.m_textureUnit===a?!1:(this.m_textureUnit=a,this.modified(),!0)},this.width=function(){return this.m_width},this.setWidth=function(a){return c.m_width!==a?(c.m_width=a,c.modified(),!0):!1},this.height=function(){return c.m_height},this.setHeight=function(a){return c.m_height!==a?(c.m_height=a,c.modified(),!0):!1},this.depth=function(){return this.m_depth},this.setDepth=function(a){return null===this.m_image?!1:(this.m_depth=a,this.modified(),!0)},this.textureHandle=function(){return this.m_textureHandle},this.internalFormat=function(){return this.m_internalFormat},this.setInternalFormat=function(a){return this.m_internalFormat!==a?(this.m_internalFormat=a,this.modified(),!0):!1},this.pixelFormat=function(){return this.m_pixelFormat},this.setPixelFormat=function(a){return null===this.m_image?!1:(this.m_pixelFormat=a,this.modified(),!0)},this.pixelDataType=function(){return this.m_pixelDataType},this.setPixelDataType=function(a){return null===this.m_image?!1:(this.m_pixelDataType=a,this.modified(),!0)},this.computeInternalFormatUsingImage=function(){this.m_internalFormat=vgl.GL.RGBA,this.m_pixelFormat=vgl.GL.RGBA,this.m_pixelDataType=vgl.GL.UNSIGNED_BYTE},this.updateDimensions=function(){null!==this.m_image&&(this.m_width=this.m_image.width,this.m_height=this.m_image.height,this.m_depth=0)},this},inherit(vgl.texture,vgl.materialAttribute),vgl.lookupTable=function(){"use strict";if(!(this instanceof vgl.lookupTable))return new vgl.lookupTable;vgl.texture.call(this);var a=vgl.timestamp(),b=[0,0];return this.m_colorTable=[.07514311,.468049805,1,1,.247872569,.498782363,1,1,.339526309,.528909511,1,1,.409505078,.558608486,1,1,.468487184,.588057293,1,1,.520796675,.617435078,1,1,.568724526,.646924167,1,1,.613686735,.676713218,1,1,.656658579,.707001303,1,1,.698372844,.738002964,1,1,.739424025,.769954435,1,1,.780330104,.803121429,1,1,.821573924,.837809045,1,1,.863634967,.874374691,1,1,.907017747,.913245283,1,1,.936129275,.938743558,.983038586,1,.943467973,.943498599,.943398095,1,.990146732,.928791426,.917447482,1,1,.88332677,.861943246,1,1,.833985467,.803839606,1,1,.788626485,.750707739,1,1,.746206642,.701389973,1,1,.70590052,.654994046,1,1,.667019783,.610806959,1,1,.6289553,.568237474,1,1,.591130233,.526775617,1,1,.552955184,.485962266,1,1,.513776083,.445364274,1,1,.472800903,.404551679,1,1,.428977855,.363073592,1,1,.380759558,.320428137,1,.961891484,.313155629,.265499262,1,.916482116,.236630659,.209939162,1].map(function(a){return 255*a}),this.setup=function(b){0===this.textureUnit()?b.m_context.activeTexture(vgl.GL.TEXTURE0):1===this.textureUnit()&&b.m_context.activeTexture(vgl.GL.TEXTURE1),b.m_context.deleteTexture(this.m_textureHandle),this.m_textureHandle=b.m_context.createTexture(),b.m_context.bindTexture(vgl.GL.TEXTURE_2D,this.m_textureHandle),b.m_context.texParameteri(vgl.GL.TEXTURE_2D,vgl.GL.TEXTURE_MIN_FILTER,vgl.GL.LINEAR),b.m_context.texParameteri(vgl.GL.TEXTURE_2D,vgl.GL.TEXTURE_MAG_FILTER,vgl.GL.LINEAR),b.m_context.texParameteri(vgl.GL.TEXTURE_2D,vgl.GL.TEXTURE_WRAP_S,vgl.GL.CLAMP_TO_EDGE),b.m_context.texParameteri(vgl.GL.TEXTURE_2D,vgl.GL.TEXTURE_WRAP_T,vgl.GL.CLAMP_TO_EDGE),b.m_context.pixelStorei(vgl.GL.UNPACK_ALIGNMENT,1),this.m_width=this.m_colorTable.length/4,this.m_height=1,this.m_depth=0,b.m_context.texImage2D(vgl.GL.TEXTURE_2D,0,vgl.GL.RGBA,this.m_width,this.m_height,this.m_depth,vgl.GL.RGBA,vgl.GL.UNSIGNED_BYTE,new Uint8Array(this.m_colorTable)),b.m_context.bindTexture(vgl.GL.TEXTURE_2D,null),a.modified()},this.colorTable=function(){return this.m_colorTable},this.setColorTable=function(a){return this.m_colorTable===a?!1:(this.m_colorTable=a,this.modified(),!0)},this.range=function(){return b},this.setRange=function(a){return b===a?!1:(b=a,this.modified(),!0)},this.updateRange=function(a){a instanceof Array||console.log("[error] Invalid data type for range. Requires array [min,max]"),a[0]b[1]&&(b[1]=a[1],this.modified())},this},inherit(vgl.lookupTable,vgl.texture),vgl.uniform=function(a,b){"use strict";if(!(this instanceof vgl.uniform))return new vgl.uniform;this.getTypeNumberOfComponents=function(a){switch(a){case vgl.GL.FLOAT:case vgl.GL.INT:case vgl.GL.BOOL:return 1;case vgl.GL.FLOAT_VEC2:case vgl.GL.INT_VEC2:case vgl.GL.BOOL_VEC2:return 2;case vgl.GL.FLOAT_VEC3:case vgl.GL.INT_VEC3:case vgl.GL.BOOL_VEC3:return 3;case vgl.GL.FLOAT_VEC4:case vgl.GL.INT_VEC4:case vgl.GL.BOOL_VEC4:return 4;case vgl.GL.FLOAT_MAT3:return 9;case vgl.GL.FLOAT_MAT4:return 16;default:return 0}};var c=a,d=b,e=[];return e.length=this.getTypeNumberOfComponents(c),this.name=function(){return d},this.type=function(){return c},this.get=function(){return e},this.set=function(a){var b=0;if(16===e.length)for(b=0;16>b;b+=1)e[b]=a[b];else if(9===e.length)for(b=0;9>b;b+=1)e[b]=a[b];else if(4===e.length)for(b=0;4>b;b+=1)e[b]=a[b];else if(3===e.length)for(b=0;3>b;b+=1)e[b]=a[b];else if(2===e.length)for(b=0;2>b;b+=1)e[b]=a[b];else e[0]=a},this.callGL=function(a,b){if(!(this.m_numberElements<1))switch(c){case vgl.GL.BOOL:case vgl.GL.INT:a.m_context.uniform1iv(b,e);break;case vgl.GL.FLOAT:a.m_context.uniform1fv(b,e);break;case vgl.GL.FLOAT_VEC2:a.m_context.uniform2fv(b,e);break;case vgl.GL.FLOAT_VEC3:a.m_context.uniform3fv(b,e);break;case vgl.GL.FLOAT_VEC4:a.m_context.uniform4fv(b,e);break;case vgl.GL.FLOAT_MAT3:a.m_context.uniformMatrix3fv(b,vgl.GL.FALSE,e);break;case vgl.GL.FLOAT_MAT4:a.m_context.uniformMatrix4fv(b,vgl.GL.FALSE,e)}},this.update=function(a,b){a=a,b=b},this},vgl.modelViewUniform=function(a){"use strict";return this instanceof vgl.modelViewUniform?(0===a.length&&(a="modelViewMatrix"),vgl.uniform.call(this,vgl.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b,this.set(a.m_modelViewMatrix)},this):new vgl.modelViewUniform(a)},inherit(vgl.modelViewUniform,vgl.uniform),vgl.modelViewOriginUniform=function(a,b){"use strict";if(!(this instanceof vgl.modelViewOriginUniform))return new vgl.modelViewOriginUniform(a,b);0===a.length&&(a="modelViewMatrix");var c=[b[0],b[1],b[2]||0];return vgl.uniform.call(this,vgl.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b;var d=mat4.create();if(mat4.translate(d,a.m_modelViewMatrix,c),a.m_modelViewAlignment){var e=a.m_modelViewAlignment;d[12]=Math.round(d[12]/e.roundx)*e.roundx+e.dx,d[13]=Math.round(d[13]/e.roundy)*e.roundy+e.dy}this.set(d)},this},inherit(vgl.modelViewOriginUniform,vgl.uniform),vgl.projectionUniform=function(a){"use strict";return this instanceof vgl.projectionUniform?(0===a.length&&(a="projectionMatrix"),vgl.uniform.call(this,vgl.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b,this.set(a.m_projectionMatrix)},this):new vgl.projectionUniform(a)},inherit(vgl.projectionUniform,vgl.uniform),vgl.floatUniform=function(a,b){"use strict";return this instanceof vgl.floatUniform?(0===a.length&&(a="floatUniform"),b=void 0===b?1:b,vgl.uniform.call(this,vgl.GL.FLOAT,a),void this.set(b)):new vgl.floatUniform(a,b)},inherit(vgl.floatUniform,vgl.uniform),vgl.normalMatrixUniform=function(a){"use strict";return this instanceof vgl.normalMatrixUniform?(0===a.length&&(a="normalMatrix"),vgl.uniform.call(this,vgl.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b,this.set(a.m_normalMatrix)},this):new vgl.normalMatrixUniform(a)},inherit(vgl.normalMatrixUniform,vgl.uniform),vgl.vertexAttributeKeys={Position:0,Normal:1,TextureCoordinate:2,Color:3,Scalar:4,CountAttributeIndex:5},vgl.vertexAttributeKeysIndexed={Zero:0,One:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9},vgl.vertexAttribute=function(a){"use strict";if(!(this instanceof vgl.vertexAttribute))return new vgl.vertexAttribute(a);var b=a;this.name=function(){return b},this.bindVertexData=function(a,c){var d=a.m_mapper.geometryData(),e=d.sourceData(c),f=a.m_material.shaderProgram();a.m_context.vertexAttribPointer(f.attributeLocation(b),e.attributeNumberOfComponents(c),e.attributeDataType(c),e.normalized(c),e.attributeStride(c),e.attributeOffset(c)),a.m_context.enableVertexAttribArray(f.attributeLocation(b))},this.undoBindVertexData=function(a,c){c=c;var d=a.m_material.shaderProgram();a.m_context.disableVertexAttribArray(d.attributeLocation(b))}},vgl.source=function(){"use strict";return this instanceof vgl.source?(vgl.object.call(this),this.create=function(){},this):new vgl.source},inherit(vgl.source,vgl.object),vgl.planeSource=function(){"use strict";if(!(this instanceof vgl.planeSource))return new vgl.planeSource;vgl.source.call(this);var a=[0,0,0],b=[1,0,0],c=[0,1,0],d=[0,0,1],e=1,f=1,g=null;this.setOrigin=function(b,c,d){a[0]=b,a[1]=c,a[2]=d},this.setPoint1=function(a,c,d){b[0]=a,b[1]=c,b[2]=d},this.setPoint2=function(a,b,d){c[0]=a,c[1]=b,c[2]=d},this.create=function(){g=new vgl.geometryData;var h,i,j,k,l,m,n,o=[],p=[],q=[],r=[],s=[],t=0,u=0,v=0,w=0,x=[],y=[],z=[],A=[],B=[],C=null,D=null,E=null;for(o.length=3,p.length=2,q.length=3,r.length=3,s.length=3,h=0;3>h;h+=1)q[h]=b[h]-a[h],r[h]=c[h]-a[h];for(l=(e+1)*(f+1),m=e*f*2,x.length=3*l,y.length=3*l,A.length=2*l,B.length=l,j=0,h=0;f+1>h;h+=1)for(p[1]=h/f,i=0;e+1>i;i+=1){for(p[0]=i/e,k=0;3>k;k+=1)o[k]=a[k]+p[0]*q[k]+p[1]*r[k];x[t++]=o[0],x[t++]=o[1],x[t++]=o[2],z[v++]=1,z[v++]=1,z[v++]=1,y[u++]=d[0],y[u++]=d[1],y[u++]=d[2],A[w++]=p[0],A[w++]=p[1]}for(h=0;f>h;h+=1)for(i=0;e>i;i+=1)s[0]=i+h*(e+1),s[1]=s[0]+1,s[2]=s[0]+e+2,s[3]=s[0]+e+1;for(h=0;l>h;h+=1)B[h]=h;return C=new vgl.triangleStrip,C.setIndices(B),D=vgl.sourceDataP3fv(),D.pushBack(x),E=vgl.sourceDataC3fv(),E.pushBack(z),n=vgl.sourceDataT2fv(),n.pushBack(A),g.addSource(D),g.addSource(E),g.addSource(n),g.addPrimitive(C),g}},inherit(vgl.planeSource,vgl.source),vgl.pointSource=function(){"use strict";if(!(this instanceof vgl.pointSource))return new vgl.pointSource;vgl.source.call(this);var a=this,b=[],c=[],d=[],e=[],f=null;this.getPositions=function(){return b},this.setPositions=function(c){c instanceof Array?b=c:console.log("[ERROR] Invalid data type for positions. Array is required."),a.modified()},this.getColors=function(){return c},this.setColors=function(b){b instanceof Array?c=b:console.log("[ERROR] Invalid data type for colors. Array is required."),a.modified()},this.getSize=function(){return e},this.setSize=function(a){e=a,this.modified()},this.setTextureCoordinates=function(b){b instanceof Array?d=b:console.log("[ERROR] Invalid data type for texture coordinates. Array is required."),a.modified()},this.create=function(){if(f=new vgl.geometryData,b.length%3!==0)return void console.log("[ERROR] Invalid length of the points array");var a,g,h,i,j,k=b.length/3,l=0,m=[];for(m.length=k,l=0;k>l;l+=1)m[l]=l;if(j=vgl.sourceDataDf(),k!==e.length)for(l=0;k>l;l+=1)j.pushBack(e);else j.setData(e);return f.addSource(j),a=new vgl.points,a.setIndices(m),g=vgl.sourceDataP3fv(),g.pushBack(b),f.addSource(g),c.length>0&&c.length===b.length?(h=vgl.sourceDataC3fv(),h.pushBack(c),f.addSource(h)):c.length>0&&c.length!==b.length&&console.log("[ERROR] Number of colors are different than number of points"),d.length>0&&d.length===b.length?(i=vgl.sourceDataT2fv(),i.pushBack(d),f.addSource(i)):d.length>0&&d.length/2!==b.length/3&&console.log("[ERROR] Number of texture coordinates are different than number of points"),f.addPrimitive(a),f}},inherit(vgl.pointSource,vgl.source),vgl.lineSource=function(a,b){"use strict";if(!(this instanceof vgl.lineSource))return new vgl.lineSource;vgl.source.call(this);var c=a,d=b;this.setPositions=function(a){return a instanceof Array?(c=a,this.modified(),!0):(console.log("[ERROR] Invalid data type for positions. Array is required."),!1)},this.setColors=function(a){return a instanceof Array?(d=a,this.modified(),!0):(console.log("[ERROR] Invalid data type for colors. Array is required."),!1)},this.create=function(){if(!c)return void console.log("[error] Invalid positions");if(c.length%3!==0)return void console.log("[error] Line source requires 3d points");if(c.length%3!==0)return void console.log("[ERROR] Invalid length of the points array");var a,b,e,f,g=new vgl.geometryData,h=c.length/3,i=[];for(i.length=h,a=0;h>a;a+=1)i[a]=a;return b=new vgl.lines,b.setIndices(i),e=vgl.sourceDataP3fv(),e.pushBack(c),g.addSource(e),d&&d.length>0&&d.length===c.length?(f=vgl.sourceDataC3fv(),f.pushBack(d),g.addSource(f)):d&&d.length>0&&d.length!==c.length&&console.log("[error] Number of colors are different than number of points"),g.addPrimitive(b),g}},inherit(vgl.lineSource,vgl.source),vgl.utils=function(){"use strict";return this instanceof vgl.utils?(vgl.object.call(this),this):new vgl.utils},inherit(vgl.utils,vgl.object),vgl.utils.computePowerOfTwo=function(a,b){"use strict";for(b=b||1;a>b;)b*=2;return b},vgl.utils.createTextureVertexShader=function(a){"use strict";var b=["attribute vec3 vertexPosition;","attribute vec3 textureCoord;","uniform mediump float pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","varying highp vec3 iTextureCoord;","void main(void)","{","gl_PointSize = pointSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);"," iTextureCoord = textureCoord;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createTextureFragmentShader=function(a){"use strict";var b=["varying highp vec3 iTextureCoord;","uniform sampler2D sampler2d;","uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4(texture2D(sampler2d, vec2(iTextureCoord.s, iTextureCoord.t)).xyz, opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createRgbaTextureFragmentShader=function(a){"use strict";var b=["varying highp vec3 iTextureCoord;","uniform sampler2D sampler2d;","uniform mediump float opacity;","void main(void) {"," mediump vec4 color = vec4(texture2D(sampler2d, vec2(iTextureCoord.s, iTextureCoord.t)).xyzw);"," color.w *= opacity;"," gl_FragColor = color;","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createVertexShader=function(a){"use strict";var b=["attribute vec3 vertexPosition;","attribute vec3 vertexColor;","uniform mediump float pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","varying mediump vec3 iVertexColor;","varying highp vec3 iTextureCoord;","void main(void)","{","gl_PointSize = pointSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);"," iVertexColor = vertexColor;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createPointVertexShader=function(a){"use strict";var b=["attribute vec3 vertexPosition;","attribute vec3 vertexColor;","attribute float vertexSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","varying mediump vec3 iVertexColor;","varying highp vec3 iTextureCoord;","void main(void)","{","gl_PointSize = vertexSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);"," iVertexColor = vertexColor;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createVertexShaderSolidColor=function(a){"use strict";var b=["attribute vec3 vertexPosition;","uniform mediump float pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","void main(void)","{","gl_PointSize = pointSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createVertexShaderColorMap=function(a,b,c){"use strict";b=b,c=c;var d=["attribute vec3 vertexPosition;","attribute float vertexScalar;","uniform mediump float pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float lutMin;","uniform float lutMax;","varying mediump float iVertexScalar;","void main(void)","{","gl_PointSize = pointSize;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition, 1.0);","iVertexScalar = (vertexScalar-lutMin)/(lutMax-lutMin);","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,d)},vgl.utils.createFragmentShader=function(a){"use strict";var b=["varying mediump vec3 iVertexColor;","uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4(iVertexColor, opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createPhongVertexShader=function(a){"use strict";var b=["attribute highp vec3 vertexPosition;","attribute mediump vec3 vertexNormal;","attribute mediump vec3 vertexColor;","uniform highp mat4 projectionMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 normalMatrix;","varying highp vec4 varPosition;","varying mediump vec3 varNormal;","varying mediump vec3 varVertexColor;","void main(void)","{","varPosition = modelViewMatrix * vec4(vertexPosition, 1.0);","gl_Position = projectionMatrix * varPosition;","varNormal = vec3(normalMatrix * vec4(vertexNormal, 0.0));","varVertexColor = vertexColor;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createPhongFragmentShader=function(a){"use strict";var b=["uniform mediump float opacity;","precision mediump float;","varying vec3 varNormal;","varying vec4 varPosition;","varying mediump vec3 varVertexColor;","const vec3 lightPos = vec3(0.0, 0.0,10000.0);","const vec3 ambientColor = vec3(0.01, 0.01, 0.01);","const vec3 specColor = vec3(0.0, 0.0, 0.0);","void main() {","vec3 normal = normalize(varNormal);","vec3 lightDir = normalize(lightPos);","vec3 reflectDir = -reflect(lightDir, normal);","vec3 viewDir = normalize(-varPosition.xyz);","float lambertian = max(dot(lightDir, normal), 0.0);","vec3 color = vec3(0.0);","if(lambertian > 0.0) {"," color = lambertian * varVertexColor;","}","gl_FragColor = vec4(color * opacity, 1.0 - opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createFragmentShaderSolidColor=function(a,b){"use strict";var c=["uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4("+b[0]+","+b[1]+","+b[2]+", opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,c)},vgl.utils.createFragmentShaderColorMap=function(a){"use strict";var b=["varying mediump float iVertexScalar;","uniform sampler2D sampler2d;","uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4(texture2D(sampler2d, vec2(iVertexScalar, 0.0)).xyz, opacity);","}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createPointSpritesVertexShader=function(a){"use strict";var b=["attribute vec3 vertexPosition;","attribute vec3 vertexColor;","uniform mediump vec2 pointSize;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform float height;","varying mediump vec3 iVertexColor;","varying highp float iVertexScalar;","void main(void)","{","mediump float realPointSize = pointSize.y;","if (pointSize.x > pointSize.y) {"," realPointSize = pointSize.x;}","gl_PointSize = realPointSize ;","iVertexScalar = vertexPosition.z;","gl_Position = projectionMatrix * modelViewMatrix * vec4(vertexPosition.xy, height, 1.0);"," iVertexColor = vertexColor;","}"].join("\n");return vgl.getCachedShader(vgl.GL.VERTEX_SHADER,a,b)},vgl.utils.createPointSpritesFragmentShader=function(a){"use strict";var b=["varying mediump vec3 iVertexColor;","varying highp float iVertexScalar;","uniform sampler2D opacityLookup;","uniform highp float lutMin;","uniform highp float lutMax;","uniform sampler2D scalarsToColors;","uniform int useScalarsToColors;","uniform int useVertexColors;","uniform mediump vec2 pointSize;","uniform mediump float vertexColorWeight;","void main(void) {","mediump vec2 realTexCoord;","if (pointSize.x > pointSize.y) {"," realTexCoord = vec2(1.0, pointSize.y/pointSize.x) * gl_PointCoord;","} else {"," realTexCoord = vec2(pointSize.x/pointSize.y, 1.0) * gl_PointCoord;","}","highp float texOpacity = texture2D(opacityLookup, realTexCoord).w;","if (useScalarsToColors == 1) {"," gl_FragColor = vec4(texture2D(scalarsToColors, vec2((iVertexScalar - lutMin)/(lutMax - lutMin), 0.0)).xyz, texOpacity);","} else if (useVertexColors == 1) {"," gl_FragColor = vec4(iVertexColor, texOpacity);","} else {"," gl_FragColor = vec4(texture2D(opacityLookup, realTexCoord).xyz, texOpacity);","}}"].join("\n");return vgl.getCachedShader(vgl.GL.FRAGMENT_SHADER,a,b)},vgl.utils.createTextureMaterial=function(a,b){"use strict";var c,d=new vgl.material,e=new vgl.blend,f=new vgl.shaderProgram,g=vgl.utils.createTextureVertexShader(vgl.GL),h=null,i=new vgl.vertexAttribute("vertexPosition"),j=new vgl.vertexAttribute("textureCoord"),k=new vgl.floatUniform("pointSize",5),l=new vgl.projectionUniform("projectionMatrix"),m=new vgl.uniform(vgl.GL.INT,"sampler2d"),n=null;return c=void 0!==b?new vgl.modelViewOriginUniform("modelViewMatrix",b):new vgl.modelViewUniform("modelViewMatrix"),m.set(0),f.addVertexAttribute(i,vgl.vertexAttributeKeys.Position),f.addVertexAttribute(j,vgl.vertexAttributeKeys.TextureCoordinate),f.addUniform(k),f.addUniform(c),f.addUniform(l),h=a?vgl.utils.createRgbaTextureFragmentShader(vgl.GL):vgl.utils.createTextureFragmentShader(vgl.GL),n=new vgl.floatUniform("opacity",1),f.addUniform(n),f.addShader(h),f.addShader(g),d.addAttribute(f),d.addAttribute(e),d},vgl.utils.createGeometryMaterial=function(){"use strict";var a=new vgl.material,b=new vgl.shaderProgram,c=5,d=1,e=vgl.utils.createVertexShader(vgl.GL),f=vgl.utils.createFragmentShader(vgl.GL),g=new vgl.vertexAttribute("vertexPosition"),h=new vgl.vertexAttribute("vertexColor"),i=new vgl.floatUniform("pointSize",c),j=new vgl.floatUniform("opacity",d),k=new vgl.modelViewUniform("modelViewMatrix"),l=new vgl.projectionUniform("projectionMatrix");return b.addVertexAttribute(g,vgl.vertexAttributeKeys.Position),b.addVertexAttribute(h,vgl.vertexAttributeKeys.Color),b.addUniform(i),b.addUniform(j),b.addUniform(k),b.addUniform(l),b.addShader(f),b.addShader(e),a.addAttribute(b),a},vgl.utils.createPointGeometryMaterial=function(a){"use strict";a=void 0===a?1:a;var b=new vgl.material,c=new vgl.blend,d=new vgl.shaderProgram,e=vgl.utils.createPointVertexShader(vgl.GL),f=vgl.utils.createFragmentShader(vgl.GL),g=new vgl.vertexAttribute("vertexPosition"),h=new vgl.vertexAttribute("vertexColor"),i=new vgl.vertexAttribute("vertexSize"),j=new vgl.floatUniform("opacity",a),k=new vgl.modelViewUniform("modelViewMatrix"),l=new vgl.projectionUniform("projectionMatrix");return d.addVertexAttribute(g,vgl.vertexAttributeKeys.Position),d.addVertexAttribute(h,vgl.vertexAttributeKeys.Color),d.addVertexAttribute(i,vgl.vertexAttributeKeys.Scalar),d.addUniform(j),d.addUniform(k),d.addUniform(l),d.addShader(f),d.addShader(e),b.addAttribute(d),b.addAttribute(c),b},vgl.utils.createPhongMaterial=function(){"use strict";var a=new vgl.material,b=new vgl.shaderProgram,c=vgl.utils.createPhongVertexShader(vgl.GL),d=vgl.utils.createPhongFragmentShader(vgl.GL),e=new vgl.vertexAttribute("vertexPosition"),f=new vgl.vertexAttribute("vertexNormal"),g=new vgl.vertexAttribute("vertexColor"),h=new vgl.floatUniform("opacity",1),i=new vgl.modelViewUniform("modelViewMatrix"),j=new vgl.normalMatrixUniform("normalMatrix"),k=new vgl.projectionUniform("projectionMatrix");return b.addVertexAttribute(e,vgl.vertexAttributeKeys.Position),b.addVertexAttribute(f,vgl.vertexAttributeKeys.Normal),b.addVertexAttribute(g,vgl.vertexAttributeKeys.Color),b.addUniform(h),b.addUniform(i),b.addUniform(k),b.addUniform(j),b.addShader(d),b.addShader(c),a.addAttribute(b),a},vgl.utils.createColorMaterial=function(){"use strict";var a=new vgl.material,b=new vgl.blend,c=new vgl.shaderProgram,d=vgl.utils.createVertexShader(vgl.GL),e=vgl.utils.createFragmentShader(vgl.GL),f=new vgl.vertexAttribute("vertexPosition"),g=new vgl.vertexAttribute("textureCoord"),h=new vgl.vertexAttribute("vertexColor"),i=new vgl.floatUniform("pointSize",5),j=new vgl.floatUniform("opacity",1),k=new vgl.modelViewUniform("modelViewMatrix"),l=new vgl.projectionUniform("projectionMatrix");return c.addVertexAttribute(f,vgl.vertexAttributeKeys.Position),c.addVertexAttribute(h,vgl.vertexAttributeKeys.Color),c.addVertexAttribute(g,vgl.vertexAttributeKeys.TextureCoordinate),c.addUniform(i),c.addUniform(j),c.addUniform(k),c.addUniform(l),c.addShader(e),c.addShader(d),a.addAttribute(c),a.addAttribute(b),a},vgl.utils.createColorMappedMaterial=function(a){"use strict";a||(a=new vgl.lookupTable);var b=a.range(),c=new vgl.material,d=new vgl.blend,e=new vgl.shaderProgram,f=vgl.utils.createVertexShaderColorMap(vgl.GL,b[0],b[1]),g=vgl.utils.createFragmentShaderColorMap(vgl.GL),h=new vgl.vertexAttribute("vertexPosition"),i=new vgl.vertexAttribute("vertexScalar"),j=new vgl.floatUniform("pointSize",5),k=new vgl.floatUniform("opacity",1),l=new vgl.floatUniform("lutMin",b[0]),m=new vgl.floatUniform("lutMax",b[1]),n=new vgl.modelViewUniform("modelViewMatrix"),o=new vgl.projectionUniform("projectionMatrix"),p=new vgl.uniform(vgl.GL.FLOAT,"sampler2d"),q=a;return p.set(0),e.addVertexAttribute(h,vgl.vertexAttributeKeys.Position),e.addVertexAttribute(i,vgl.vertexAttributeKeys.Scalar),e.addUniform(j),e.addUniform(k),e.addUniform(l),e.addUniform(m),e.addUniform(n),e.addUniform(o),e.addShader(g),e.addShader(f),c.addAttribute(e),c.addAttribute(d),c.addAttribute(q),c},vgl.utils.updateColorMappedMaterial=function(a,b){"use strict";if(!a)return void console.log("[warning] Invalid material. Nothing to update.");if(!b)return void console.log("[warning] Invalid lookup table. Nothing to update.");var c=a.shaderProgram().uniform("lutMin"),d=a.shaderProgram().uniform("lutMax");c.set(b.range()[0]),d.set(b.range()[1]),a.setAttribute(b)},vgl.utils.createSolidColorMaterial=function(a){"use strict";a||(a=[1,1,1]);var b=new vgl.material,c=new vgl.blend,d=new vgl.shaderProgram,e=vgl.utils.createVertexShaderSolidColor(vgl.GL),f=vgl.utils.createFragmentShaderSolidColor(vgl.GL,a),g=new vgl.vertexAttribute("vertexPosition"),h=new vgl.floatUniform("pointSize",5),i=new vgl.floatUniform("opacity",1),j=new vgl.modelViewUniform("modelViewMatrix"),k=new vgl.projectionUniform("projectionMatrix");return d.addVertexAttribute(g,vgl.vertexAttributeKeys.Position),d.addUniform(h),d.addUniform(i),d.addUniform(j),d.addUniform(k),d.addShader(f),d.addShader(e),b.addAttribute(d),b.addAttribute(c),b},vgl.utils.createPointSpritesMaterial=function(a,b){"use strict";var c=void 0===b?[0,1]:b.range(),d=new vgl.material,e=new vgl.blend,f=new vgl.shaderProgram,g=vgl.utils.createPointSpritesVertexShader(vgl.GL),h=vgl.utils.createPointSpritesFragmentShader(vgl.GL),i=new vgl.vertexAttribute("vertexPosition"),j=new vgl.vertexAttribute("vertexColor"),k=new vgl.floatUniform("height",0),l=new vgl.floatUniform("vertexColorWeight",0),m=new vgl.floatUniform("lutMin",c[0]),n=new vgl.floatUniform("lutMax",c[1]),o=new vgl.modelViewUniform("modelViewMatrix"),p=new vgl.projectionUniform("projectionMatrix"),q=new vgl.uniform(vgl.GL.INT,"opacityLookup"),r=new vgl.uniform(vgl.GL.INT,"scalarsToColors"),s=new vgl.uniform(vgl.GL.INT,"useScalarsToColors"),t=new vgl.uniform(vgl.GL.INT,"useVertexColors"),u=new vgl.uniform(vgl.GL.FLOAT_VEC2,"pointSize"),v=new vgl.texture;return q.set(0),r.set(1),s.set(0),t.set(0),u.set([1,1]),f.addVertexAttribute(i,vgl.vertexAttributeKeys.Position),f.addVertexAttribute(j,vgl.vertexAttributeKeys.Color),f.addUniform(k),f.addUniform(l),f.addUniform(o),f.addUniform(p),f.addUniform(q),f.addUniform(t),f.addUniform(s),f.addUniform(u),f.addShader(h),f.addShader(g),d.addAttribute(f),d.addAttribute(e),b&&(f.addUniform(r),s.set(1),f.addUniform(m), +f.addUniform(n),b.setTextureUnit(1),d.addAttribute(b)),v.setImage(a),v.setTextureUnit(0),d.addAttribute(v),d},vgl.utils.createPlane=function(a,b,c,d,e,f,g,h,i){"use strict";var j=new vgl.mapper,k=new vgl.planeSource,l=vgl.utils.createGeometryMaterial(),m=new vgl.actor;return k.setOrigin(a,b,c),k.setPoint1(d,e,f),k.setPoint2(g,h,i),j.setGeometryData(k.create()),m.setMapper(j),m.setMaterial(l),m},vgl.utils.createTexturePlane=function(a,b,c,d,e,f,g,h,i,j){"use strict";var k=new vgl.mapper,l=new vgl.planeSource,m=vgl.utils.createTextureMaterial(j,[a,b,c]),n=new vgl.actor;return l.setPoint1(d-a,e-b,f-c),l.setPoint2(g-a,h-b,i-c),k.setGeometryData(l.create()),n.setMapper(k),n.setMaterial(m),n},vgl.utils.createPoints=function(a,b,c,d,e){"use strict";if(!a)return console.log("[ERROR] Cannot create points without positions"),null;e=void 0===e?1:e;var f=new vgl.mapper,g=new vgl.pointSource,h=vgl.utils.createPointGeometryMaterial(e),i=new vgl.actor;return g.setPositions(a),c&&g.setColors(c),d&&g.setTextureCoordinates(d),b?g.setSize(b):g.setSize(1),f.setGeometryData(g.create()),i.setMapper(f),i.setMaterial(h),i},vgl.utils.createPointSprites=function(a,b,c,d){"use strict";if(!a)return console.log("[ERROR] Point sprites requires an image"),null;if(!b)return console.log("[ERROR] Cannot create points without positions"),null;var e=new vgl.mapper,f=new vgl.pointSource,g=vgl.utils.createPointSpritesMaterial(a),h=new vgl.actor;return f.setPositions(b),c&&f.setColors(c),d&&f.setTextureCoordinates(d),e.setGeometryData(f.create()),h.setMapper(e),h.setMaterial(g),h},vgl.utils.createLines=function(a,b){"use strict";if(!a)return console.log("[ERROR] Cannot create points without positions"),null;var c=new vgl.mapper,d=new vgl.lineSource,e=vgl.utils.createGeometryMaterial(),f=new vgl.actor;return d.setPositions(a),b&&d.setColors(b),c.setGeometryData(d.create()),f.setMapper(c),f.setMaterial(e),f},vgl.utils.createColorLegend=function(a,b,c,d,e,f,g){"use strict";function h(a,b,c){if(!b)return void console.log("[error] Create labels requires positions (x,y,z) array");if(b.length%3!==0)return void console.log("[error] Create labels require positions array contain 3d points");if(!c)return void console.log("[error] Create labels requires Valid range");var d,e=null,f=vgl.utils.computePowerOfTwo(48),g=0,h=[],i=[],j=[],k=[],l=b[6]-b[0],m=4;for(i.length=3,j.length=3,k.length=3,d=0;2>d;d+=1)g=d*(b.length-3),i[0]=b[g]-l,i[1]=b[g+1]-2*l,i[2]=b[g+2],j[0]=b[g]+l,j[1]=i[1],j[2]=i[2],k[0]=i[0],k[1]=b[1],k[2]=i[2],e=vgl.utils.createTexturePlane(i[0],i[1],i[2],j[0],j[1],j[2],k[0],k[1],k[2],!0),e.setReferenceFrame(vgl.boundingObject.ReferenceFrame.Absolute),e.material().setBinNumber(vgl.material.RenderBin.Overlay),e.material().addAttribute(vgl.utils.create2DTexture(c[d].toFixed(2).toString(),12,null)),h.push(e);return i[0]=.5*(b[0]+b[b.length-3]-f),i[1]=b[1]+m,i[2]=b[2],j[0]=i[0]+f,j[1]=i[1],j[2]=i[2],k[0]=i[0],k[1]=i[1]+f,k[2]=i[2],e=vgl.utils.createTexturePlane(i[0],i[1],i[2],j[0],j[1],j[2],k[0],k[1],k[2],!0),e.setReferenceFrame(vgl.boundingObject.ReferenceFrame.Absolute),e.material().setBinNumber(vgl.material.RenderBin.Overlay),e.material().addAttribute(vgl.utils.create2DTexture(a,24,null)),h.push(e),h}function i(a,b,c,d,e,f,g,i,j,k,l,m,n,o,p){p=p;var q=j-f,r=null,s=q/m,t=[],u=[];for(r=0;m>=r;r+=1)t.push(f+s*r),t.push(g),t.push(i),t.push(f+s*r),t.push(g+o),t.push(i);return u=u.concat(h(a,t,b.range()))}if(!b)return console.log("[error] Invalid lookup table"),[];var j=c[0]+d,k=c[1],l=0,m=c[0],n=c[1]+e,o=0,p=[],q=null,r=null,s=vgl.groupNode();return q=vgl.utils.createTexturePlane(c[0],c[1],c[2],j,k,l,m,n,o,!0),r=q.material(),r.addAttribute(b),q.setMaterial(r),s.addChild(q),q.material().setBinNumber(vgl.material.RenderBin.Overlay),q.setReferenceFrame(vgl.boundingObject.ReferenceFrame.Absolute),p.push(q),p=p.concat(i(a,b,c[0],c[1],c[1],m,k,l,j,k,l,f,g,5,3))},vgl.utils.create2DTexture=function(a,b,c,d,e,f,g){"use strict";var h=document.getElementById("textRendering"),i=null,j=vgl.texture();return d=d||"sans-serif",e=e||"center",f=f||"bottom","undefined"==typeof g&&(g=!0),h||(h=document.createElement("canvas")),i=h.getContext("2d"),h.setAttribute("id","textRendering"),h.style.display="none",h.height=vgl.utils.computePowerOfTwo(8*b),h.width=h.height,i.fillStyle="rgba(0, 0, 0, 0)",i.fillRect(0,0,i.canvas.width,i.canvas.height),i.fillStyle="rgba(200, 85, 10, 1.0)",i.textAlign=e,i.textBaseline=f,i.font=4*b+"px "+d,g&&(i.font="bold "+i.font),i.fillText(a,h.width/2,h.height/2,h.width),j.setImage(h),j.updateDimensions(),j},vgl.picker=function(){"use strict";if(!(this instanceof vgl.picker))return new vgl.picker;vgl.object.call(this);var a=[];return this.getActors=function(){return a},this.pick=function(b,c,d){if(void 0===b)return 0;if(void 0===c)return 0;if(void 0===d)return 0;a=[];var e,f,g,h,i,j,k,l,m,n,o,p=d.camera(),q=d.width(),r=d.height(),s=p.focalPoint(),t=vec4.fromValues(s[0],s[1],s[2],1),u=d.worldToDisplay(t,p.viewMatrix(),p.projectionMatrix(),q,r),v=vec4.fromValues(b,c,u[2],1),w=d.displayToWorld(v,p.viewMatrix(),p.projectionMatrix(),q,r),x=p.position(),y=[];for(g=0;3>g;g+=1)y[g]=w[g]-x[g];for(e=d.sceneRoot().children(),f=0,g=0;g=0?(i=(h[0]-x[0])/y[0],j=(h[1]-x[0])/y[0]):(i=(h[1]-x[0])/y[0],j=(h[0]-x[0])/y[0]),y[1]>=0?(k=(h[2]-x[1])/y[1],l=(h[3]-x[1])/y[1]):(k=(h[3]-x[1])/y[1],l=(h[2]-x[1])/y[1]),i>l||k>j)continue;if(k>i&&(i=k),j>l&&(j=l),y[2]>=0?(m=(h[4]-x[2])/y[2],n=(h[5]-x[2])/y[2]):(m=(h[5]-x[2])/y[2],n=(h[4]-x[2])/y[2]),i>n||m>j)continue;m>i&&(i=m),j>n&&(j=n),a[f]=o,f+=1}return f},this},inherit(vgl.picker,vgl.object),vgl.shapefileReader=function(){"use strict";if(!(this instanceof vgl.shapefileReader))return new vgl.shapefileReader;var a=this,b=0,c=1,d=5,e=3;return this.int8=function(a,b){return a.charCodeAt(b)},this.bint32=function(a,b){return((255&a.charCodeAt(b))<<24)+((255&a.charCodeAt(b+1))<<16)+((255&a.charCodeAt(b+2))<<8)+(255&a.charCodeAt(b+3))},this.lint32=function(a,b){return((255&a.charCodeAt(b+3))<<24)+((255&a.charCodeAt(b+2))<<16)+((255&a.charCodeAt(b+1))<<8)+(255&a.charCodeAt(b))},this.bint16=function(a,b){return((255&a.charCodeAt(b))<<8)+(255&a.charCodeAt(b+1))},this.lint16=function(a,b){return((255&a.charCodeAt(b+1))<<8)+(255&a.charCodeAt(b))},this.ldbl64=function(a,b){var c=255&a.charCodeAt(b),d=255&a.charCodeAt(b+1),e=255&a.charCodeAt(b+2),f=255&a.charCodeAt(b+3),g=255&a.charCodeAt(b+4),h=255&a.charCodeAt(b+5),i=255&a.charCodeAt(b+6),j=255&a.charCodeAt(b+7),k=1-2*(j>>7),l=((127&j)<<4)+((240&i)>>4)-1023,m=(15&i)*Math.pow(2,48)+h*Math.pow(2,40)+g*Math.pow(2,32)+f*Math.pow(2,24)+e*Math.pow(2,16)+d*Math.pow(2,8)+c;return k*(1+m*Math.pow(2,-52))*Math.pow(2,l)},this.lfloat32=function(a,b){var c=255&a.charCodeAt(b),d=255&a.charCodeAt(b+1),e=255&a.charCodeAt(b+2),f=255&a.charCodeAt(b+3),g=1-2*(f>>7),h=((127&f)<<1)+((254&e)>>7)-127,i=(127&e)*Math.pow(2,16)+d*Math.pow(2,8)+c;return g*(1+i*Math.pow(2,-23))*Math.pow(2,h)},this.str=function(a,b,c){for(var d=[],e=b;b+c>e;){var f=a[e];if(0===f.charCodeAt(0))break;d.push(f),e+=1}return d.join("")},this.readHeader=function(a){var b=this.bint32(a,0),c=this.bint32(a,24),d=this.lint32(a,28),e=this.lint32(a,32);return{code:b,length:c,version:d,shapetype:e}},this.loadShx=function(b){for(var c=[],d=function(d){return c.push(2*a.bint32(b,d)),d+8},e=100;ej;)k.push(c(j)),j+=i;for(var l=[],m=f;f+e*g>m;){var n=a.str(b,m,1);if("*"===n)m+=g;else{m+=1;for(var o={},p=0;p=c;g-=1){var h=a.ldbl64(f,b+16*g),i=a.ldbl64(f,b+16*g+8);e.push([h,i])}return e},m=function(g){var h,i,j,m,n,o,p,q,r,s=g+8,t=a.lint32(f,s);if(t===b)console.log("NULL Shape");else if(t===c){var u=a.ldbl64(f,s+4),v=a.ldbl64(f,s+12);k.push({type:"Point",attr:{},geom:[[u,v]]})}else if(t===d){for(h=a.lint32(f,s+36),i=a.lint32(f,s+40),j=g+52,m=g+52+4*h,r=[],n=0;h>n;n+=1)o=a.lint32(f,j+4*n),p=h>n+1?a.lint32(f,j+4*(n+1)):i,q=l(m,o,p),r.push(q);k.push({type:"Polygon",attr:{},geom:[r]})}else{if(t!==e)throw"Not Implemented: "+t;for(h=a.lint32(f,s+36),i=a.lint32(f,s+40),j=g+52,m=g+52+4*h,r=[],n=0;h>n;n+=1)o=a.lint32(f,j+4*n),p=h>n+1?a.lint32(f,j+4*(n+1)):i,q=l(m,o,p),r.push(q);k.push({type:"Polyline",attr:{},geom:[r]})}},n=this.loadDBF(g);for(j=0;j=h.length)return g;if(a=h.charAt(i),i+=1,b[a])return b[a];if("A"===a)return 0}return g},this.decode64=function(a){var b="",c=new Array(4),d=!1;for(h=a,i=0;!d&&(c[0]=this.readReverseBase64())!==g&&(c[1]=this.readReverseBase64())!==g;)c[2]=this.readReverseBase64(),c[3]=this.readReverseBase64(),b+=this.ntos(c[0]<<2&255|c[1]>>4),c[2]!==g?(b+=this.ntos(c[1]<<4&255|c[2]>>2),c[3]!==g?b+=this.ntos(c[2]<<6&255|c[3]):d=!0):d=!0;return b},this.readNumber=function(a){var b=a[j++]+(a[j++]<<8)+(a[j++]<<16)+(a[j++]<<24);return b},this.readF3Array=function(a,b){var c,d=4*a*3,e=new Int8Array(d),f=null;for(c=0;d>c;c+=1)e[c]=b[j],j+=1;return f=new Float32Array(e.buffer)},this.readColorArray=function(a,b,c){var d,e=0,f=new Array(3*a);for(d=0;a>d;d+=1)f[e++]=b[j++]/255,f[e++]=b[j++]/255,f[e++]=b[j++]/255,j++;c.insert(f)},this.parseObject=function(a){var b,c,d,e,f,g,h,i,m,n,o,p=new vgl.geometryData,q=vgl.mapper(),r=[],s=null,t=null,u=null,v=null;for(t=atob(a.data),l=0;lk;k+=1)p[q++]=e[3*k],p[q++]=e[3*k+1],p[q++]=e[3*k+2];for(l.insert(p),a.addSource(l),m=new vgl.sourceDataC3fv,this.readColorArray(d,b,m),a.addSource(m),n=new vgl.lines,a.addPrimitive(n),c=this.readNumber(b),f=new Int8Array(2*c),k=0;2*c>k;k+=1)f[k]=b[j],j+=1;for(g=new Uint16Array(f.buffer),n.setIndices(g),n.setPrimitiveType(vgl.GL.LINES),h=64,f=new Int8Array(h),k=0;h>k;k+=1)f[k]=b[j],j+=1;return i=new Float32Array(f.buffer),mat4.copy(o,i),o},this.parseMeshData=function(a,b){var c,d,e,f,g,h,i,k,l,m=null,n=null,o=null,p=mat4.create(),q=null,r=null,s=0;for(d=this.readNumber(b),r=new Array(6*d),m=new vgl.sourceDataP3N3f,e=this.readF3Array(d,b),o=this.readF3Array(d,b),k=0;d>k;k+=1)r[s++]=e[3*k],r[s++]=e[3*k+1],r[s++]=e[3*k+2],r[s++]=o[3*k],r[s++]=o[3*k+1],r[s++]=o[3*k+2];for(m.insert(r),a.addSource(m),n=new vgl.sourceDataC3fv,this.readColorArray(d,b,n),a.addSource(n),f=[],q=new vgl.triangles,c=this.readNumber(b),f=new Int8Array(2*c),k=0;2*c>k;k+=1)f[k]=b[j],j+=1;for(g=new Uint16Array(f.buffer),q.setIndices(g),a.addPrimitive(q),h=64,f=new Int8Array(h),k=0;h>k;k+=1)f[k]=b[j],j+=1;return i=new Float32Array(f.buffer),mat4.copy(p,i),l=null,p},this.parsePointData=function(a,b){var c,d,e,f,g,h,i=mat4.create(),k=null,m=null,n=null,o=null,p=0;for(c=this.readNumber(b),o=new Array(3*c),k=new vgl.sourceDataP3fv,d=this.readF3Array(c,b),e=new Uint16Array(c),l=0;c>l;l+=1)e[l]=l,o[p++]=d[3*l],o[p++]=d[3*l+1],o[p++]=d[3*l+2];for(k.insert(o),a.addSource(k),m=new vgl.sourceDataC3fv,this.readColorArray(c,b,m),a.addSource(m),n=new vgl.points,n.setIndices(e),a.addPrimitive(n),g=64,f=new Int8Array(g),l=0;g>l;l+=1)f[l]=b[j],j+=1;return h=new Float32Array(f.buffer),mat4.copy(i,h),i},this.parseColorMapData=function(a,b,c){var d,e,f,g,h,i={};for(i.numOfColors=c,e=8,d=new Int8Array(e),g=0;e>g;g+=1)d[g]=b[j],j+=1;for(i.position=new Float32Array(d.buffer),e=8,d=new Int8Array(e),g=0;e>g;g+=1)d[g]=b[j],j+=1;for(i.size=new Float32Array(d.buffer),i.colors=[],h=0;hg;g+=1)d[g]=b[j],j+=1;f=[new Float32Array(d.buffer)[0],b[j++],b[j++],b[j++]],i.colors[h]=f}for(i.orientation=b[j++],i.numOfLabels=b[j++],i.title="";j=0;b-=1)a=this.getRenderer(b),this.parseSceneMetadata(a,b);return k},this.createViewer=function(a){var b;return null===k&&(f=a,k=vgl.viewer(a),k.init(),k.renderWindow().removeRenderer(k.renderWindow().activeRenderer()),k.renderWindow().addRenderer(new vgl.depthPeelRenderer),c[0]=k.renderWindow().activeRenderer(),k.renderWindow().resize(a.width,a.height),b=vgl.pvwInteractorStyle(),k.setInteractorStyle(b)),k},this.deleteViewer=function(){c={},k=null},this.updateCanvas=function(a){return f=a,k.renderWindow().resize(a.width,a.height),k},this.numObjects=function(){return d},this.getRenderer=function(a){var b;return b=c[a],(null===b||"undefined"==typeof b)&&(b=new vgl.renderer,b.setResetScene(!1),b.setResetClippingRange(!1),k.renderWindow().addRenderer(b),0!==a&&b.camera().setClearMask(vgl.GL.DepthBufferBit),c[a]=b),b},this.setVtkScene=function(a){e=a},this},vgl.DataBuffers=function(a){"use strict";if(!(this instanceof vgl.DataBuffers))return new vgl.DataBuffers(a);var b,c={};b=a||0===a?a:256;var d=0,e=function(a,b,c,d){a||console.log("ack"),c||(c=0),d||(d=b.length);for(var e=0;d>e;e+=1)a[c+e]=b[e]},f=function(a){var d=b;for(a>2*d&&(d=a);a>d;)d*=2;b=d;for(var f in c)if(c.hasOwnProperty(f)){var g=new Float32Array(d*c[f].len),h=c[f].array;e(g,h),c[f].array=g,c[f].dirty=!0}};this.create=function(a,d){if(!d)throw"Length of buffer must be a positive integer";var e=new Float32Array(b*d);return c[a]={array:e,len:d,dirty:!1},c[a].array},this.alloc=function(a){d+a>=b&&f(d+a);var c=d;return d+=a,c},this.get=function(a){return c[a].array},this.write=function(a,b,d,f){e(c[a].array,b,d*c[a].len,f*c[a].len),c[a].dirty=!0},this.repeat=function(a,b,d,f){for(var g=0;f>g;g+=1)e(c[a].array,b,(d+g)*c[a].len,c[a].len);c[a].dirty=!0},this.count=function(){return d},this.data=function(a){return c[a].array}}; //# sourceMappingURL=vgl.min.js.map \ No newline at end of file