From 48af2e2fe262fb073283fb5a0267f71d8e3faa46 Mon Sep 17 00:00:00 2001 From: David Manthey Date: Mon, 11 Jul 2016 15:02:14 -0400 Subject: [PATCH] Version 0.3.8. I failed to update the npm package properly on 0.3.7. --- package.json | 4 ++-- vgl.js | 2 +- vgl.min.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index bea2225..1c1d679 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "vgl", "description": "VTK for the Web.", - "version": "0.3.7", + "version": "0.3.8", "license": "Apache-2.0", "repository": { "type": "git", @@ -37,7 +37,7 @@ "xmlbuilder": "^4.1.0" }, "scripts": { - "mypublish": "grunt default test && cp dist/vgl* . && npm publish", + "mypublish": "grunt default && cp dist/vgl{.min,}.js . && npm publish", "test": "grunt test", "build": "grunt default", "lint": "eslint --cache src Gruntfile.js" diff --git a/vgl.js b/vgl.js index 8c5bbd4..442bfe5 100644 --- a/vgl.js +++ b/vgl.js @@ -104,7 +104,7 @@ if (!Math.log2) { }; } -vgl.version = '0.3.7'; +vgl.version = '0.3.8'; ////////////////////////////////////////////////////////////////////////////// /** diff --git a/vgl.min.js b/vgl.min.js index 2066de6..c30aee5 100644 --- a/vgl.min.js +++ b/vgl.min.js @@ -1,4 +1,4 @@ -!function(a,b){"function"==typeof define&&define.amd?define("vgl",[],function(){return a.vgl=b()}):"object"==typeof exports?module.exports=b():a.vgl=b()}(this,function(){if("undefined"==typeof a)var a={};a.namespace=function(b){"use strict";var c,d=b.split("."),e=a;for("ogs"===d[0]&&(d=d.slice(1)),c=0;c=0)return a.splice(c,1),b.setParent(null),this.boundsDirtyTimestamp().modified(),!0}},this.removeChildren=function(){for(;a.length;)this.removeChild(a[0]);this.modified()},this.children=function(){return a},this.hasChild=function(b){var c=0,d=!1;for(c=0;cthis.computeBoundsTimestamp().getMTime()&&this.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(b.groupNode,b.node),b.actor=function(){"use strict";if(!(this instanceof b.actor))return new b.actor;b.node.call(this);var a=this,c=mat4.create(),d=b.boundingObject.ReferenceFrame.Relative,e=null;return this.matrix=function(){return c},this.setMatrix=function(b){b!==c&&(c=b,a.modified())},this.referenceFrame=function(){return d},this.setReferenceFrame=function(b){return b!==d?(d=b,a.modified(),!0):!1},this.mapper=function(){return e},this.setMapper=function(b){b!==e&&(e=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===e||void 0===e)return void a.resetBounds();var b,d,f,g,h=a.computeBoundsTimestamp();(a.boundsDirtyTimestamp().getMTime()>h.getMTime()||e.boundsDirtyTimestamp().getMTime()>h.getMTime())&&(e.computeBounds(),b=e.bounds(),d=[b[0],b[2],b[4]],f=[b[1],b[3],b[5]],vec3.transformMat4(d,d,c),vec3.transformMat4(f,f,c),g=[d[0]>f[0]?f[0]:d[0],d[0]>f[0]?d[0]:f[0],d[1]>f[1]?f[1]:d[1],d[1]>f[1]?d[1]:f[1],d[2]>f[2]?f[2]:d[2],d[2]>f[2]?d[2]:f[2]],a.setBounds(g[0],g[1],g[2],g[3],g[4],g[5]),h.modified())},a},inherit(b.actor,b.node),b.freezeObject=function(a){"use strict";var b=Object.freeze?Object.freeze(a):void 0;return"undefined"==typeof b?a:b},b.defaultValue=function(a,b){"use strict";return"undefined"!=typeof a?a:b},b.defaultValue.EMPTY_OBJECT=b.freezeObject({}),b.graphicsObject=function(a){"use strict";if(a=a,!(this instanceof b.graphicsObject))return new b.graphicsObject;b.object.call(this);var c=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){c._cleanup(a)},c},inherit(b.graphicsObject,b.object),b.geojsonReader=function(){"use strict";return this instanceof b.geojsonReader?(this.readScalars=function(a,c,d,e){var f=null,g=null,h=null,i=null,j=null;"values"===this.m_scalarFormat&&4===a.length?(g=a[3],f=c.sourceData(b.vertexAttributeKeys.Scalar),f||(f=new b.sourceDataSf,this.m_scalarRange&&f.setScalarRange(this.m_scalarRange[0],this.m_scalarRange[1]),void 0!==d&&(f.data().length=d),c.addSource(f)),void 0===d?f.pushBack(g):f.insertAt(e,g)):"rgb"===this.m_scalarFormat&&6===a.length&&(f=c.sourceData(b.vertexAttributeKeys.Color),f||(f=new b.sourceDataC3fv,void 0!==d&&(f.length=3*d),c.addSource(f)),h=a[3],i=a[4],j=a[5],void 0===d?f.pushBack([h,i,j]):f.insertAt(e,[h,i,j]))},this.readPoint=function(a){var c=new b.geometryData,d=new b.points,e=new b.sourceDataP3fv,f=new Uint16Array(1),g=null,h=null,i=null,j=null;for(c.addSource(e),j=0;1>j;j+=1)f[j]=j,g=a[0],h=a[1],i=0,a.length>2&&(i=a[2]),e.pushBack([g,h,i]),this.readScalars(a,c);return d.setIndices(f),c.addPrimitive(d),c.setName("aPoint"),c},this.readMultiPoint=function(a){var c,d=new b.geometryData,e=new b.points,f=new b.sourceDataP3fv,g=new Uint16Array(a.length),h=0,i=a.length,j=null,k=null,l=null;for(f.data().length=3*i,c=0;c2&&(l=a[c][2]),f.insertAt(h,[j,k,l]),this.readScalars(a[c],d,i,h),h+=1;return e.setIndices(g),d.addPrimitive(e),d.addSource(f),d.setName("manyPoints"),d},this.readLineString=function(a){var c=new b.geometryData,d=new b.lineStrip,e=new b.sourceDataP3fv,f=[],g=null,h=null,i=null,j=null;for(d.setIndicesPerPrimitive(a.length),g=0;g2&&(j=a[g][2]),e.pushBack([h,i,j]),this.readScalars(a[g],c);return d.setIndices(f),c.addPrimitive(d),c.addSource(e),c.setName("aLineString"),c},this.readMultiLineString=function(a){var c=new b.geometryData,d=new b.sourceDataP3fv,e=0,f=2*a.length,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=null;for(d.data().length=3*f,h=0;hg;g+=1)l.push(e),i=a[h][g][0],j=a[h][g][1],k=0,a[h][g].length>2&&(k=a[h][g][2]),d.insertAt(e,[i,j,k]),this.readScalars(a[h][g],c,2*f,e),e+=1;m.setIndices(l),c.addPrimitive(m)}return c.setName("aMultiLineString"),c.addSource(d),c},this.readPolygon=function(a){var c=new b.geometryData,d=new b.sourceDataP3fv,e=null,f=null,g=null,h=a[0].length,i=1,j=null,k=null,l=null;for(j=0;h>j;j+=1)e=a[0][j][0],f=a[0][j][1],g=0,a[0][j].length>2&&(g=a[0][j][2]),d.pushBack([e,f,g]),this.readScalars(a[0][j],c),j>1&&(k=new Uint16Array([0,i,j]),l=new b.triangles,l.setIndices(k),c.addPrimitive(l),i=j);return c.setName("POLY"),c.addSource(d),c},this.readMultiPolygon=function(a){var c=new b.geometryData,d=new b.sourceDataP3fv,e=0,f=a.length,g=0,h=3*f,i=new b.triangles,j=[],k=null,l=null,m=null,n=null,o=null,p=null,q=null,r=null,s=null,t=!1,u=0;for(d.data().length=3*f,l=0;f>l;l+=1)for(p=a[l][0].length,q=e,r=e+1,s=[!1,!1,!1],k=0;p>k;k+=1)m=a[l][0][k][0],n=a[l][0][k][1],o=0,a[l][0][k].length>2&&(o=a[l][0][k][2]),t=!1,m>180&&(t=!0,m-=360),0===k?s[0]=t:s[1+(k-1)%2]=t,d.insertAt(g,[m,n,o]),this.readScalars(a[l][0][k],c,h,g),g+=1,k>1&&(s[0]===s[1]&&s[1]===s[2]&&(j[3*u+0]=q,j[3*u+1]=r,j[3*u+2]=e,u+=1),r=e),e+=1;return i.setIndices(j),c.addPrimitive(i),c.setName("aMultiPoly"),c.addSource(d),c},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;fd)&&(d=a),(null===c||c>a)&&(c=a),this.data()[this.data().length]=a},this.insertAt=function(a,b){(null===d||b>d)&&(d=b),(null===c||c>b)&&(c=b),this.data()[a]=b},this.scalarRange=function(){return null===e||null===f?[c,d]:[e,f]},this.setScalarRange=function(a,b){e=a,f=b},this},inherit(b.sourceDataSf,b.sourceData),b.sourceDataDf=function(a){"use strict";return this instanceof b.sourceDataDf?(b.sourceData.call(this,a),this.addAttribute(b.vertexAttributeKeys.Scalar,b.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 b.sourceDataDf(a)},inherit(b.sourceDataDf,b.sourceData),b.geometryData=function(){"use strict";if(!(this instanceof b.geometryData))return new b.geometryData;b.data.call(this);var a="",c=[],d=[],e=[0,0,0,0,0,0],f=b.timestamp(),g=b.timestamp();return this.type=function(){return b.data.geometry},this.name=function(){return a},this.setName=function(b){a=b},this.addSource=function(a,c){return void 0!==c&&a.setName(c),-1===d.indexOf(a)?(d.push(a),a.hasKey(b.vertexAttributeKeys.Position)&&g.modified(),!0):!1},this.source=function(a){return af.getMTime()&&this.computeBounds(),e},this.boundsDirty=function(a){return a&&g.modified(),g.getMTime()>f.getMTime()},this.resetBounds=function(){e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0},this.setBounds=function(a,b,c,d,g,h){return e[0]=a,e[1]=b,e[2]=c,e[3]=d,e[4]=g,e[5]=h,f.modified(),!0},this.computeBounds=function(){if(g.getMTime()>f.getMTime()){var a,c,d,h,i,j,k=b.vertexAttributeKeys.Position,l=this.sourceData(k),m=l.data(),n=l.attributeNumberOfComponents(k),o=l.attributeStride(k),p=l.attributeOffset(k),q=l.sizeOfAttributeDataType(k),r=m.length,s=null;for(o/=q,p/=q,this.resetBounds(),a=0;n>a;a+=1){for(c=2*a,d=2*a+1,h=i=r?e[d]=m[p+a]:0,j=p+o+a;r>j;j+=o)s=m[j],s>h&&(h=s),i>s&&(i=s);e[c]=i,e[d]=h}f.modified()}},this.findClosestVertex=function(a){var c,d,e,f,g,h,i,j=b.vertexAttributeKeys.Position,k=this.sourceData(j),l=k.sizeOfAttributeDataType(j),m=k.attributeNumberOfComponents(j),n=k.data(),o=k.attributeStride(j)/l,p=k.attributeOffset(j)/l,q=Number.MAX_VALUE,r=null;for(3!==m&&console.log("[warning] Find closest vertex assumes threecomponent vertex "),a.z||(a={x:a.x,y:a.y,z:0}),c=p,i=0;ch&&(q=h,r=i);return r},this.getPosition=function(a){var c=b.vertexAttributeKeys.Position,d=this.sourceData(c),e=d.sizeOfAttributeDataType(c),f=d.attributeNumberOfComponents(c),g=d.data(),h=d.attributeStride(c)/e,i=d.attributeOffset(c)/e;return 3!==f&&console.log("[warning] getPosition assumes three component data"),[g[i+a*h],g[i+a*h+1],g[i+a*h+2]]},this.getScalar=function(a){var c,d,e,f,g=b.vertexAttributeKeys.Scalar,h=this.sourceData(g);return h?(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(b.geometryData,b.data),b.mapper=function(a){"use strict";function c(a){if(g){a&&(l=a.m_context);var c,d,e,f,m,n,o,p=g.numberOfSources(),q=null;for(c=0;p>c;c+=1){for(q=l.createBuffer(),l.bindBuffer(b.GL.ARRAY_BUFFER,q),o=g.source(c).data(),o instanceof Float32Array||(o=new Float32Array(o)),l.bufferData(b.GL.ARRAY_BUFFER,o,j?b.GL.DYNAMIC_DRAW:b.GL.STATIC_DRAW),f=g.source(c).keys(),m=[],d=0;de;e+=1)q=l.createBuffer(),l.bindBuffer(b.GL.ARRAY_BUFFER,q),l.bufferData(b.GL.ARRAY_BUFFER,g.primitive(e).indices(),b.GL.STATIC_DRAW),h[c]=q,c+=1;k.modified()}}function d(a){i={},h=[]}function e(a){m.deleteVertexBufferObjects(a),d(a),c(a)}if(!(this instanceof b.mapper))return new b.mapper(a);b.boundingObject.call(this),a=a||{};var f=[0,1,1],g=null,h=[],i={},j=void 0===a.dynamicDraw?!1:a.dynamicDraw,k=b.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,c,d){if(d&&(l=d.m_context),!l)return!1;for(var e=-1,f=0;fe||e>=h.length?!1:(c||(c=g.source(f).dataToFloat32Array()),l.bindBuffer(b.GL.ARRAY_BUFFER,h[e]),c instanceof Float32Array?l.bufferSubData(b.GL.ARRAY_BUFFER,0,c):l.bufferSubData(b.GL.ARRAY_BUFFER,0,new Float32Array(c)),!0)},this.getSourceBuffer=function(a){var b=g.sourceByName(a);return b?b.dataToFloat32Array():new Float32Array},this.render=function(a,c){ +!function(a,b){"function"==typeof define&&define.amd?define("vgl",[],function(){return a.vgl=b()}):"object"==typeof exports?module.exports=b():a.vgl=b()}(this,function(){if("undefined"==typeof a)var a={};a.namespace=function(b){"use strict";var c,d=b.split("."),e=a;for("ogs"===d[0]&&(d=d.slice(1)),c=0;c=0)return a.splice(c,1),b.setParent(null),this.boundsDirtyTimestamp().modified(),!0}},this.removeChildren=function(){for(;a.length;)this.removeChild(a[0]);this.modified()},this.children=function(){return a},this.hasChild=function(b){var c=0,d=!1;for(c=0;cthis.computeBoundsTimestamp().getMTime()&&this.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(b.groupNode,b.node),b.actor=function(){"use strict";if(!(this instanceof b.actor))return new b.actor;b.node.call(this);var a=this,c=mat4.create(),d=b.boundingObject.ReferenceFrame.Relative,e=null;return this.matrix=function(){return c},this.setMatrix=function(b){b!==c&&(c=b,a.modified())},this.referenceFrame=function(){return d},this.setReferenceFrame=function(b){return b!==d?(d=b,a.modified(),!0):!1},this.mapper=function(){return e},this.setMapper=function(b){b!==e&&(e=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===e||void 0===e)return void a.resetBounds();var b,d,f,g,h=a.computeBoundsTimestamp();(a.boundsDirtyTimestamp().getMTime()>h.getMTime()||e.boundsDirtyTimestamp().getMTime()>h.getMTime())&&(e.computeBounds(),b=e.bounds(),d=[b[0],b[2],b[4]],f=[b[1],b[3],b[5]],vec3.transformMat4(d,d,c),vec3.transformMat4(f,f,c),g=[d[0]>f[0]?f[0]:d[0],d[0]>f[0]?d[0]:f[0],d[1]>f[1]?f[1]:d[1],d[1]>f[1]?d[1]:f[1],d[2]>f[2]?f[2]:d[2],d[2]>f[2]?d[2]:f[2]],a.setBounds(g[0],g[1],g[2],g[3],g[4],g[5]),h.modified())},a},inherit(b.actor,b.node),b.freezeObject=function(a){"use strict";var b=Object.freeze?Object.freeze(a):void 0;return"undefined"==typeof b?a:b},b.defaultValue=function(a,b){"use strict";return"undefined"!=typeof a?a:b},b.defaultValue.EMPTY_OBJECT=b.freezeObject({}),b.graphicsObject=function(a){"use strict";if(a=a,!(this instanceof b.graphicsObject))return new b.graphicsObject;b.object.call(this);var c=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){c._cleanup(a)},c},inherit(b.graphicsObject,b.object),b.geojsonReader=function(){"use strict";return this instanceof b.geojsonReader?(this.readScalars=function(a,c,d,e){var f=null,g=null,h=null,i=null,j=null;"values"===this.m_scalarFormat&&4===a.length?(g=a[3],f=c.sourceData(b.vertexAttributeKeys.Scalar),f||(f=new b.sourceDataSf,this.m_scalarRange&&f.setScalarRange(this.m_scalarRange[0],this.m_scalarRange[1]),void 0!==d&&(f.data().length=d),c.addSource(f)),void 0===d?f.pushBack(g):f.insertAt(e,g)):"rgb"===this.m_scalarFormat&&6===a.length&&(f=c.sourceData(b.vertexAttributeKeys.Color),f||(f=new b.sourceDataC3fv,void 0!==d&&(f.length=3*d),c.addSource(f)),h=a[3],i=a[4],j=a[5],void 0===d?f.pushBack([h,i,j]):f.insertAt(e,[h,i,j]))},this.readPoint=function(a){var c=new b.geometryData,d=new b.points,e=new b.sourceDataP3fv,f=new Uint16Array(1),g=null,h=null,i=null,j=null;for(c.addSource(e),j=0;1>j;j+=1)f[j]=j,g=a[0],h=a[1],i=0,a.length>2&&(i=a[2]),e.pushBack([g,h,i]),this.readScalars(a,c);return d.setIndices(f),c.addPrimitive(d),c.setName("aPoint"),c},this.readMultiPoint=function(a){var c,d=new b.geometryData,e=new b.points,f=new b.sourceDataP3fv,g=new Uint16Array(a.length),h=0,i=a.length,j=null,k=null,l=null;for(f.data().length=3*i,c=0;c2&&(l=a[c][2]),f.insertAt(h,[j,k,l]),this.readScalars(a[c],d,i,h),h+=1;return e.setIndices(g),d.addPrimitive(e),d.addSource(f),d.setName("manyPoints"),d},this.readLineString=function(a){var c=new b.geometryData,d=new b.lineStrip,e=new b.sourceDataP3fv,f=[],g=null,h=null,i=null,j=null;for(d.setIndicesPerPrimitive(a.length),g=0;g2&&(j=a[g][2]),e.pushBack([h,i,j]),this.readScalars(a[g],c);return d.setIndices(f),c.addPrimitive(d),c.addSource(e),c.setName("aLineString"),c},this.readMultiLineString=function(a){var c=new b.geometryData,d=new b.sourceDataP3fv,e=0,f=2*a.length,g=null,h=null,i=null,j=null,k=null,l=null,m=null,n=null;for(d.data().length=3*f,h=0;hg;g+=1)l.push(e),i=a[h][g][0],j=a[h][g][1],k=0,a[h][g].length>2&&(k=a[h][g][2]),d.insertAt(e,[i,j,k]),this.readScalars(a[h][g],c,2*f,e),e+=1;m.setIndices(l),c.addPrimitive(m)}return c.setName("aMultiLineString"),c.addSource(d),c},this.readPolygon=function(a){var c=new b.geometryData,d=new b.sourceDataP3fv,e=null,f=null,g=null,h=a[0].length,i=1,j=null,k=null,l=null;for(j=0;h>j;j+=1)e=a[0][j][0],f=a[0][j][1],g=0,a[0][j].length>2&&(g=a[0][j][2]),d.pushBack([e,f,g]),this.readScalars(a[0][j],c),j>1&&(k=new Uint16Array([0,i,j]),l=new b.triangles,l.setIndices(k),c.addPrimitive(l),i=j);return c.setName("POLY"),c.addSource(d),c},this.readMultiPolygon=function(a){var c=new b.geometryData,d=new b.sourceDataP3fv,e=0,f=a.length,g=0,h=3*f,i=new b.triangles,j=[],k=null,l=null,m=null,n=null,o=null,p=null,q=null,r=null,s=null,t=!1,u=0;for(d.data().length=3*f,l=0;f>l;l+=1)for(p=a[l][0].length,q=e,r=e+1,s=[!1,!1,!1],k=0;p>k;k+=1)m=a[l][0][k][0],n=a[l][0][k][1],o=0,a[l][0][k].length>2&&(o=a[l][0][k][2]),t=!1,m>180&&(t=!0,m-=360),0===k?s[0]=t:s[1+(k-1)%2]=t,d.insertAt(g,[m,n,o]),this.readScalars(a[l][0][k],c,h,g),g+=1,k>1&&(s[0]===s[1]&&s[1]===s[2]&&(j[3*u+0]=q,j[3*u+1]=r,j[3*u+2]=e,u+=1),r=e),e+=1;return i.setIndices(j),c.addPrimitive(i),c.setName("aMultiPoly"),c.addSource(d),c},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;fd)&&(d=a),(null===c||c>a)&&(c=a),this.data()[this.data().length]=a},this.insertAt=function(a,b){(null===d||b>d)&&(d=b),(null===c||c>b)&&(c=b),this.data()[a]=b},this.scalarRange=function(){return null===e||null===f?[c,d]:[e,f]},this.setScalarRange=function(a,b){e=a,f=b},this},inherit(b.sourceDataSf,b.sourceData),b.sourceDataDf=function(a){"use strict";return this instanceof b.sourceDataDf?(b.sourceData.call(this,a),this.addAttribute(b.vertexAttributeKeys.Scalar,b.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 b.sourceDataDf(a)},inherit(b.sourceDataDf,b.sourceData),b.geometryData=function(){"use strict";if(!(this instanceof b.geometryData))return new b.geometryData;b.data.call(this);var a="",c=[],d=[],e=[0,0,0,0,0,0],f=b.timestamp(),g=b.timestamp();return this.type=function(){return b.data.geometry},this.name=function(){return a},this.setName=function(b){a=b},this.addSource=function(a,c){return void 0!==c&&a.setName(c),-1===d.indexOf(a)?(d.push(a),a.hasKey(b.vertexAttributeKeys.Position)&&g.modified(),!0):!1},this.source=function(a){return af.getMTime()&&this.computeBounds(),e},this.boundsDirty=function(a){return a&&g.modified(),g.getMTime()>f.getMTime()},this.resetBounds=function(){e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=0},this.setBounds=function(a,b,c,d,g,h){return e[0]=a,e[1]=b,e[2]=c,e[3]=d,e[4]=g,e[5]=h,f.modified(),!0},this.computeBounds=function(){if(g.getMTime()>f.getMTime()){var a,c,d,h,i,j,k=b.vertexAttributeKeys.Position,l=this.sourceData(k),m=l.data(),n=l.attributeNumberOfComponents(k),o=l.attributeStride(k),p=l.attributeOffset(k),q=l.sizeOfAttributeDataType(k),r=m.length,s=null;for(o/=q,p/=q,this.resetBounds(),a=0;n>a;a+=1){for(c=2*a,d=2*a+1,h=i=r?e[d]=m[p+a]:0,j=p+o+a;r>j;j+=o)s=m[j],s>h&&(h=s),i>s&&(i=s);e[c]=i,e[d]=h}f.modified()}},this.findClosestVertex=function(a){var c,d,e,f,g,h,i,j=b.vertexAttributeKeys.Position,k=this.sourceData(j),l=k.sizeOfAttributeDataType(j),m=k.attributeNumberOfComponents(j),n=k.data(),o=k.attributeStride(j)/l,p=k.attributeOffset(j)/l,q=Number.MAX_VALUE,r=null;for(3!==m&&console.log("[warning] Find closest vertex assumes threecomponent vertex "),a.z||(a={x:a.x,y:a.y,z:0}),c=p,i=0;ch&&(q=h,r=i);return r},this.getPosition=function(a){var c=b.vertexAttributeKeys.Position,d=this.sourceData(c),e=d.sizeOfAttributeDataType(c),f=d.attributeNumberOfComponents(c),g=d.data(),h=d.attributeStride(c)/e,i=d.attributeOffset(c)/e;return 3!==f&&console.log("[warning] getPosition assumes three component data"),[g[i+a*h],g[i+a*h+1],g[i+a*h+2]]},this.getScalar=function(a){var c,d,e,f,g=b.vertexAttributeKeys.Scalar,h=this.sourceData(g);return h?(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(b.geometryData,b.data),b.mapper=function(a){"use strict";function c(a){if(g){a&&(l=a.m_context);var c,d,e,f,m,n,o,p=g.numberOfSources(),q=null;for(c=0;p>c;c+=1){for(q=l.createBuffer(),l.bindBuffer(b.GL.ARRAY_BUFFER,q),o=g.source(c).data(),o instanceof Float32Array||(o=new Float32Array(o)),l.bufferData(b.GL.ARRAY_BUFFER,o,j?b.GL.DYNAMIC_DRAW:b.GL.STATIC_DRAW),f=g.source(c).keys(),m=[],d=0;de;e+=1)q=l.createBuffer(),l.bindBuffer(b.GL.ARRAY_BUFFER,q),l.bufferData(b.GL.ARRAY_BUFFER,g.primitive(e).indices(),b.GL.STATIC_DRAW),h[c]=q,c+=1;k.modified()}}function d(a){i={},h=[]}function e(a){m.deleteVertexBufferObjects(a),d(a),c(a)}if(!(this instanceof b.mapper))return new b.mapper(a);b.boundingObject.call(this),a=a||{};var f=[0,1,1],g=null,h=[],i={},j=void 0===a.dynamicDraw?!1:a.dynamicDraw,k=b.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,c,d){if(d&&(l=d.m_context),!l)return!1;for(var e=-1,f=0;fe||e>=h.length?!1:(c||(c=g.source(f).dataToFloat32Array()),l.bindBuffer(b.GL.ARRAY_BUFFER,h[e]),c instanceof Float32Array?l.bufferSubData(b.GL.ARRAY_BUFFER,0,c):l.bufferSubData(b.GL.ARRAY_BUFFER,0,new Float32Array(c)),!0)},this.getSourceBuffer=function(a){var b=g.sourceByName(a);return b?b.dataToFloat32Array():new Float32Array},this.render=function(a,c){ (this.getMTime()>k.getMTime()||a.m_contextChanged)&&e(a),l=a.m_context,l.vertexAttrib3fv(b.vertexAttributeKeys.Color,this.color());var d,f=0,j=0,m=null,n=null;for(d in i)if(i.hasOwnProperty(d)){for(l.bindBuffer(b.GL.ARRAY_BUFFER,h[f]),j=0;jj;j+=1){switch(l.bindBuffer(b.GL.ARRAY_BUFFER,h[f]),f+=1,n=g.primitive(j),n.primitiveType()){case b.GL.POINTS:l.drawArrays(b.GL.POINTS,0,n.numberOfIndices());break;case b.GL.LINES:l.drawArrays(b.GL.LINES,0,n.numberOfIndices());break;case b.GL.LINE_STRIP:l.drawArrays(b.GL.LINE_STRIP,0,n.numberOfIndices());break;case b.GL.TRIANGLES:l.drawArrays(b.GL.TRIANGLES,0,n.numberOfIndices());break;case b.GL.TRIANGLE_STRIP:l.drawArrays(b.GL.TRIANGLE_STRIP,0,n.numberOfIndices())}l.bindBuffer(b.GL.ARRAY_BUFFER,null)}c||this.undoBindVertexData(a)},this.undoBindVertexData=function(a){var b,c;for(b in i)if(i.hasOwnProperty(b))for(c=0;c0?d[0]:null},this.setGeometryData=function(a){(1!==d.length||d[0]!==a)&&(d=[],d.push(a),this.modified())},this.geometryDataArray=function(){return d},this.setGeometryDataArray=function(a){if(a instanceof Array){if(d!==a)return d=[],d=a,this.modified(),!0}else console.log("[error] Requies array of geometry data");return!1},this.computeBounds=function(){if(null===d||void 0===d)return void this.resetBounds();var a=this.computeBoundsTimestamp(),b=this.boundsDirtyTimestamp(),c=this.bounds(),e=null,f=null;if(b.getMTime()>a.getMTime()){for(f=0;fe[0]&&(c[0]=e[0]),c[1]e[2]&&(c[2]=e[2]),c[3]e[4]&&(c[4]=e[4]),c[5]a.getMTime()){for(f=0;f0&&c.m_resetScene&&(c.resetCamera(),c.m_resetScene=!1),a=0;a=0&&g.push([f.material().binNumber(),f]);for(g.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=c.m_camera.viewUpDirection(),Math.abs(vec3.dot(j,a))>.999&&c.m_camera.setViewUpDirection(-j[2],j[0],j[1]),c.m_camera.setFocalPoint(d[0],d[1],d[2]),c.m_camera.setPosition(d[0]+i*-a[0],d[1]+i*-a[1],d[2]+i*-a[2]),c.resetCameraClippingRange(b)},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&&(c.m_camera.computeBounds(),a=c.m_camera.bounds()),c.hasValidBounds(a)){var b=c.m_camera.viewPlaneNormal(),d=c.m_camera.position(),e=-b[0],f=-b[1],g=-b[2],h=-(e*d[0]+f*d[1]+g*d[2]),i=vec2.create(),j=null,k=null,l=null,m=null;if(c.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],c.m_nearClippingPlaneTolerance||(c.m_nearClippingPlaneTolerance=.01,c.m_depthBits&&c.m_depthBits>16&&(c.m_nearClippingPlaneTolerance=.001)),i[0]a||0>b||0>=d||0>=e)return void console.log("[error] Invalid position and resize values",a,b,d,e);if(c.m_resizable&&(c.m_width=d,c.m_height=e,c.m_camera.setViewAspect(d/e),c.m_camera.setParallelExtents({width:d,height:e}),c.modified()),c.m_renderPasses)for(f=0;ff||0===j[b].width()||j[b].height()>g||0===j[b].height())&&j[b].resize(d,e,f,g);return!0}catch(c){}return k||console("[ERROR] Unable to initialize WebGL. Your browser may not support it."),!1},this.context=function(){return k},this._cleanup=function(a){var c;for(c=0;ct?(g.x=0,a=!0):g.x=x.x,x.y<0||x.y>u?(g.y=0,a=!0):g.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(g.x,g.y,j[2],1),m=vec4.fromValues(h.x,h.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],f&&(w.pan(-p,-q,-r),c.viewer().render()),d&&(w.rotate(h.x-g.x,h.y-g.y),v.resetCameraClippingRange(),c.viewer().render()),e&&(s=2*(g.y-h.y)/u,s>0?w.zoom(1-Math.abs(s)):w.zoom(1+Math.abs(s)),v.resetCameraClippingRange(),c.viewer().render()),h.x=g.x,h.y=g.y,!1):void 0},this.handleMouseDown=function(a){var b;return 0===a.button&&(d=!0),1===a.button&&(f=!0),2===a.button&&(e=!0),b=c.viewer().relMouseCoords(a),b.x<0?h.x=0:h.x=b.x,b.y<0?h.y=0:h.y=b.y,!1},this.handleMouseUp=function(a){return 0===a.button&&(d=!1),1===a.button&&(f=!1),2===a.button&&(e=!1),!1},this.handleMouseWheel=function(a){var b=c.viewer().renderWindow().activeRenderer(),d=b.camera();return a.originalEvent.wheelDelta<0?d.zoom(.9):d.zoom(1.1),b.resetCameraClippingRange(),c.viewer().render(),!0},this},inherit(b.trackballInteractorStyle,b.interactorStyle),b.pvwInteractorStyle=function(){"use strict";function a(){e.resetCameraClippingRange(),u.viewer().render()}if(!(this instanceof b.pvwInteractorStyle))return new b.pvwInteractorStyle;b.trackballInteractorStyle.call(this);var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u=this,v=!1,w=!1,x=!1,y={x:0,y:0};return this.handleMouseMove=function(b){var z=[],A=null,B=[],C=null;for(c=u.viewer().renderWindow().windowSize()[0],d=u.viewer().renderWindow().windowSize()[1],e=u.viewer().renderWindow().activeRenderer(),f=e.camera(),g=!1,h=u.viewer().relMouseCoords(b),i={x:0,y:0},z=u.viewer().renderWindow().renderers(),A=0;Ac?(i.x=0,g=!0):i.x=h.x,h.y<0||h.y>d?(i.y=0,g=!0):i.y=h.y,g!==!0){if(j=f.focalPoint(),k=vec4.fromValues(j[0],j[1],j[2],1),l=e.worldToDisplay(k,f.viewMatrix(),f.projectionMatrix(),c,d),m=vec4.fromValues(i.x,i.y,l[2],1),n=vec4.fromValues(y.x,y.y,l[2],1),o=e.displayToWorld(m,f.viewMatrix(),f.projectionMatrix(),c,d),p=e.displayToWorld(n,f.viewMatrix(),f.projectionMatrix(),c,d),q=o[0]-p[0],r=o[1]-p[1],s=o[2]-p[2],x&&(f.pan(-q,-r,-s),a()),v){for(C=[y.x-i.x,y.y-i.y],f.rotate(C[0],C[1]),A=0;A0?f.zoom(1-Math.abs(t)):f.zoom(1+Math.abs(t)),a()),y.x=i.x,y.y=i.y,!1}},this.handleMouseDown=function(a){return 0===a.button&&(v=!0),1===a.button&&(x=!0),2===a.button&&(w=!0),h=u.viewer().relMouseCoords(a),h.x<0?y.x=0:y.x=h.x,h.y<0?y.y=0:y.y=h.y,!1},this.handleMouseUp=function(a){return 0===a.button&&(v=!1),1===a.button&&(x=!1),2===a.button&&(w=!1),!1},this},inherit(b.pvwInteractorStyle,b.trackballInteractorStyle),b.viewer=function(a,c){"use strict";if(!(this instanceof b.viewer))return new b.viewer(a,c);b.object.call(this);var d=this,e=a,f=!0,g=null,h=b.renderer(c),i=b.renderWindow(e);return this.canvas=function(){return e},this.renderWindow=function(){return i},this.init=function(){null!==i?i._setup():console.log("[ERROR] No render window attached")},this.exit=function(a){null!==i?i._cleanup(a):console.log("[ERROR] No render window attached")},this.interactorStyle=function(){return g},this.setInteractorStyle=function(a){a!==g&&(g=a,g.setViewer(this),this.modified())},this.handleMouseDown=function(a){if(f===!0){var c=$.event.fix(a||window.event);2===a.button&&c.preventDefault(),c.state="down",c.type=b.event.mousePress,$(d).trigger(c)}return!0},this.handleMouseUp=function(a){if(f===!0){var c=$.event.fix(a||window.event);c.preventDefault(),c.state="up",c.type=b.event.mouseRelease,$(d).trigger(c)}return!0},this.handleMouseMove=function(a){if(f===!0){var c=$.event.fix(a||window.event);c.preventDefault(),c.type=b.event.mouseMove,$(d).trigger(c)}return!0},this.handleMouseWheel=function(a){if(f===!0){var c=$.event.fix(a||window.event);c.preventDefault(),c.type=b.event.mouseWheel,$(d).trigger(c)}return!0},this.handleMouseOut=function(a){if(f===!0){var c=$.event.fix(a||window.event);c.preventDefault(),c.type=b.event.mouseOut,$(d).trigger(c)}return!0},this.handleKeyPress=function(a){if(f===!0){var c=$.event.fix(a||window.event);c.preventDefault(),c.type=b.event.keyPress,$(d).trigger(c)}return!0},this.handleContextMenu=function(a){if(f===!0){var c=$.event.fix(a||window.event);c.preventDefault(),c.type=b.event.contextMenu,$(d).trigger(c)}return!1},this.handleClick=function(a){if(f===!0){var c=$.event.fix(a||window.event);c.preventDefault(),c.type=b.event.click,$(d).trigger(c)}return!1},this.handleDoubleClick=function(a){if(f===!0){var c=$.event.fix(a||window.event);c.preventDefault(),c.type=b.event.dblClick,$(d).trigger(c)}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,d=0,f=0,g=e;do b+=g.offsetLeft-g.scrollLeft,c+=g.offsetTop-g.scrollTop,g=g.offsetParent;while(g);return d=a.pageX-b,f=a.pageY-c,{x:d,y:f}},this.render=function(){i.render()},this.bindEventHandlers=function(){$(e).on("mousedown",this.handleMouseDown),$(e).on("mouseup",this.handleMouseUp),$(e).on("mousemove",this.handleMouseMove),$(e).on("mousewheel",this.handleMouseWheel),$(e).on("contextmenu",this.handleContextMenu)},this.unbindEventHandlers=function(){$(e).off("mousedown",this.handleMouseDown),$(e).off("mouseup",this.handleMouseUp),$(e).off("mousemove",this.handleMouseMove),$(e).off("mousewheel",this.handleMouseWheel),$(e).off("contextmenu",this.handleContextMenu)},this._init=function(){this.bindEventHandlers(),i.addRenderer(h)},this._init(),this},inherit(b.viewer,b.object),b.shader=function(a){"use strict";if(!(this instanceof b.shader))return new b.shader(a);b.object.call(this);var c=[],d=a,e="";this._getContextEntry=function(a){var d,e,f=a.m_context;for(d=0;d=c&&a.splice(c,a.length-c),h},b.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 d=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}}();return b.shaderProgram=function(){"use strict";if(!(this instanceof b.shaderProgram))return new b.shaderProgram;b.materialAttribute.call(this,b.materialAttributeType.ShaderProgram);var a=this,c=0,e=b.timestamp(),f=b.timestamp(),g=[],h=[],i={},j={},k={};return this.loadFromFile=function(c,d){var e,f=!1;return $.ajax({url:d,type:"GET",dataType:"text",async:!1,success:function(d){e=b.shader(c),e.setShaderSource(d),a.addShader(e),f=!0}}),f},this.loadShader=function(a,b){return this.loadFromFile(a,d()+"/shaders/"+b)},this.queryUniformLocation=function(a,b){return a.m_context.getUniformLocation(c,b)},this.queryAttributeLocation=function(a,b){return a.m_context.getAttribLocation(c,b)},this.addShader=function(b){if(g.indexOf(b)>-1)return!1;var c;for(c=g.length-2;c>=0;c-=1)g[c].shaderType()===b.shaderType()&&g.splice(c,1);return g.push(b),a.modified(),!0},this.addUniform=function(b){return h.indexOf(b)>-1?!1:(h.push(b),a.modified(),!0)},this.addVertexAttribute=function(b,c){i[c]=b,a.modified()},this.uniformLocation=function(a){return j[a]},this.attributeLocation=function(a){return k[a]},this.uniform=function(a){var b;for(b=0;b=this.getMTime())){for(a._setup(b),d=0;dc.getMTime()&&this.setup(d),a(d),d.m_context.bindTexture(b.GL.TEXTURE_2D,this.m_textureHandle)},this.undoBind=function(a){a.m_context.bindTexture(b.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 d.m_width!==a?(d.m_width=a,d.modified(),!0):!1},this.height=function(){return d.m_height},this.setHeight=function(a){return d.m_height!==a?(d.m_height=a,d.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=b.GL.RGBA,this.m_pixelFormat=b.GL.RGBA,this.m_pixelDataType=b.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(b.texture,b.materialAttribute),b.lookupTable=function(){"use strict";if(!(this instanceof b.lookupTable))return new b.lookupTable;b.texture.call(this);var a=b.timestamp(),c=[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(c){0===this.textureUnit()?c.m_context.activeTexture(b.GL.TEXTURE0):1===this.textureUnit()&&c.m_context.activeTexture(b.GL.TEXTURE1),c.m_context.deleteTexture(this.m_textureHandle),this.m_textureHandle=c.m_context.createTexture(),c.m_context.bindTexture(b.GL.TEXTURE_2D,this.m_textureHandle),c.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_MIN_FILTER,b.GL.LINEAR),c.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_MAG_FILTER,b.GL.LINEAR),c.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_WRAP_S,b.GL.CLAMP_TO_EDGE),c.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_WRAP_T,b.GL.CLAMP_TO_EDGE),c.m_context.pixelStorei(b.GL.UNPACK_ALIGNMENT,1),this.m_width=this.m_colorTable.length/4,this.m_height=1,this.m_depth=0,c.m_context.texImage2D(b.GL.TEXTURE_2D,0,b.GL.RGBA,this.m_width,this.m_height,this.m_depth,b.GL.RGBA,b.GL.UNSIGNED_BYTE,new Uint8Array(this.m_colorTable)),c.m_context.bindTexture(b.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 c},this.setRange=function(a){return c===a?!1:(c=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]c[1]&&(c[1]=a[1],this.modified())},this},inherit(b.lookupTable,b.texture),b.uniform=function(a,c){"use strict";if(!(this instanceof b.uniform))return new b.uniform;this.getTypeNumberOfComponents=function(a){switch(a){case b.GL.FLOAT:case b.GL.INT:case b.GL.BOOL:return 1;case b.GL.FLOAT_VEC2:case b.GL.INT_VEC2:case b.GL.BOOL_VEC2:return 2;case b.GL.FLOAT_VEC3:case b.GL.INT_VEC3:case b.GL.BOOL_VEC3:return 3;case b.GL.FLOAT_VEC4:case b.GL.INT_VEC4:case b.GL.BOOL_VEC4:return 4;case b.GL.FLOAT_MAT3:return 9;case b.GL.FLOAT_MAT4:return 16;default:return 0}};var d=a,e=c,f=[];return f.length=this.getTypeNumberOfComponents(d),this.name=function(){return e},this.type=function(){return d},this.get=function(){return f},this.set=function(a){var b=0;if(16===f.length)for(b=0;16>b;b+=1)f[b]=a[b];else if(9===f.length)for(b=0;9>b;b+=1)f[b]=a[b];else if(4===f.length)for(b=0;4>b;b+=1)f[b]=a[b];else if(3===f.length)for(b=0;3>b;b+=1)f[b]=a[b];else if(2===f.length)for(b=0;2>b;b+=1)f[b]=a[b];else f[0]=a},this.callGL=function(a,c){if(!(this.m_numberElements<1))switch(d){case b.GL.BOOL:case b.GL.INT:a.m_context.uniform1iv(c,f);break;case b.GL.FLOAT:a.m_context.uniform1fv(c,f);break;case b.GL.FLOAT_VEC2:a.m_context.uniform2fv(c,f);break;case b.GL.FLOAT_VEC3:a.m_context.uniform3fv(c,f);break;case b.GL.FLOAT_VEC4:a.m_context.uniform4fv(c,f);break;case b.GL.FLOAT_MAT3:a.m_context.uniformMatrix3fv(c,b.GL.FALSE,f);break;case b.GL.FLOAT_MAT4:a.m_context.uniformMatrix4fv(c,b.GL.FALSE,f)}},this.update=function(a,b){a=a,b=b},this},b.modelViewUniform=function(a){"use strict";return this instanceof b.modelViewUniform?(0===a.length&&(a="modelViewMatrix"),b.uniform.call(this,b.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b,this.set(a.m_modelViewMatrix)},this):new b.modelViewUniform(a)},inherit(b.modelViewUniform,b.uniform),b.modelViewOriginUniform=function(a,c){"use strict";if(!(this instanceof b.modelViewOriginUniform))return new b.modelViewOriginUniform(a,c);0===a.length&&(a="modelViewMatrix"),c=c||[0,0,0];var d=[c[0],c[1],c[2]||0];return b.uniform.call(this,b.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.setOrigin=function(a){a=a||[0,0,0],d=[a[0],a[1],a[2]||0]},this.update=function(a,b){b=b;var c=mat4.create();if(mat4.translate(c,a.m_modelViewMatrix,d),a.m_modelViewAlignment){var e=a.m_modelViewAlignment;c[12]=Math.round(c[12]/e.roundx)*e.roundx+e.dx,c[13]=Math.round(c[13]/e.roundy)*e.roundy+e.dy}this.set(c)},this},inherit(b.modelViewOriginUniform,b.uniform),b.projectionUniform=function(a){"use strict";return this instanceof b.projectionUniform?(0===a.length&&(a="projectionMatrix"),b.uniform.call(this,b.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b,this.set(a.m_projectionMatrix)},this):new b.projectionUniform(a)},inherit(b.projectionUniform,b.uniform),b.floatUniform=function(a,c){"use strict";return this instanceof b.floatUniform?(0===a.length&&(a="floatUniform"),c=void 0===c?1:c,b.uniform.call(this,b.GL.FLOAT,a),void this.set(c)):new b.floatUniform(a,c)},inherit(b.floatUniform,b.uniform),b.normalMatrixUniform=function(a){"use strict";return this instanceof b.normalMatrixUniform?(0===a.length&&(a="normalMatrix"),b.uniform.call(this,b.GL.FLOAT_MAT4,a),this.set(mat4.create()),this.update=function(a,b){b=b,this.set(a.m_normalMatrix)},this):new b.normalMatrixUniform(a)},inherit(b.normalMatrixUniform,b.uniform),b.vertexAttributeKeys={Position:0,Normal:1,TextureCoordinate:2,Color:3,Scalar:4,CountAttributeIndex:5},b.vertexAttributeKeysIndexed={Zero:0,One:1,Two:2,Three:3,Four:4,Five:5,Six:6,Seven:7,Eight:8,Nine:9},b.vertexAttribute=function(a){"use strict";if(!(this instanceof b.vertexAttribute))return new b.vertexAttribute(a);var c=a;this.name=function(){return c},this.bindVertexData=function(a,b){var d=a.m_mapper.geometryData(),e=d.sourceData(b),f=a.m_material.shaderProgram();a.m_context.vertexAttribPointer(f.attributeLocation(c),e.attributeNumberOfComponents(b),e.attributeDataType(b),e.normalized(b),e.attributeStride(b),e.attributeOffset(b)),a.m_context.enableVertexAttribArray(f.attributeLocation(c))},this.undoBindVertexData=function(a,b){b=b;var d=a.m_material.shaderProgram();a.m_context.disableVertexAttribArray(d.attributeLocation(c))}},b.source=function(){"use strict";return this instanceof b.source?(b.object.call(this),this.create=function(){},this):new b.source},inherit(b.source,b.object),b.planeSource=function(){"use strict";if(!(this instanceof b.planeSource))return new b.planeSource;b.source.call(this);var a=[0,0,0],c=[1,0,0],d=[0,1,0],e=[0,0,1],f=1,g=1,h=null;this.setOrigin=function(b,c,d){a[0]=b,a[1]=c,a[2]=d},this.setPoint1=function(a,b,d){c[0]=a,c[1]=b,c[2]=d},this.setPoint2=function(a,b,c){d[0]=a,d[1]=b,d[2]=c},this.create=function(){h=new b.geometryData;var i,j,k,l,m,n=[],o=[],p=[],q=[],r=[],s=0,t=0,u=0,v=0,w=[],x=[],y=[],z=[],A=[],B=null,C=null,D=null;for(n.length=3,o.length=2,p.length=3,q.length=3,r.length=3,i=0;3>i;i+=1)p[i]=c[i]-a[i],q[i]=d[i]-a[i];for(l=(f+1)*(g+1),w.length=3*l,x.length=3*l,z.length=2*l,A.length=l,i=0;g+1>i;i+=1)for(o[1]=i/g,j=0;f+1>j;j+=1){for(o[0]=j/f,k=0;3>k;k+=1)n[k]=a[k]+o[0]*p[k]+o[1]*q[k];w[s++]=n[0],w[s++]=n[1],w[s++]=n[2],y[u++]=1,y[u++]=1,y[u++]=1,x[t++]=e[0],x[t++]=e[1],x[t++]=e[2],z[v++]=o[0],z[v++]=o[1]}for(i=0;g>i;i+=1)for(j=0;f>j;j+=1)r[0]=j+i*(f+1),r[1]=r[0]+1,r[2]=r[0]+f+2,r[3]=r[0]+f+1;for(i=0;l>i;i+=1)A[i]=i;return B=new b.triangleStrip,B.setIndices(A),C=b.sourceDataP3fv(),C.pushBack(w),D=b.sourceDataC3fv(),D.pushBack(y),m=b.sourceDataT2fv(),m.pushBack(z),h.addSource(C),h.addSource(D),h.addSource(m),h.addPrimitive(B),h}},inherit(b.planeSource,b.source),b.pointSource=function(){"use strict";if(!(this instanceof b.pointSource))return new b.pointSource;b.source.call(this);var a=this,c=[],d=[],e=[],f=[],g=null;this.getPositions=function(){return c},this.setPositions=function(b){b instanceof Array?c=b:console.log("[ERROR] Invalid data type for positions. Array is required."),a.modified()},this.getColors=function(){return d},this.setColors=function(b){b instanceof Array?d=b:console.log("[ERROR] Invalid data type for colors. Array is required."),a.modified()},this.getSize=function(){return f},this.setSize=function(a){f=a,this.modified()},this.setTextureCoordinates=function(b){b instanceof Array?e=b:console.log("[ERROR] Invalid data type for texture coordinates. Array is required."),a.modified()},this.create=function(){if(g=new b.geometryData,c.length%3!==0)return void console.log("[ERROR] Invalid length of the points array");var a,h,i,j,k,l=c.length/3,m=0,n=[];for(n.length=l,m=0;l>m;m+=1)n[m]=m;if(k=b.sourceDataDf(),l!==f.length)for(m=0;l>m;m+=1)k.pushBack(f);else k.setData(f);return g.addSource(k),a=new b.points,a.setIndices(n),h=b.sourceDataP3fv(),h.pushBack(c),g.addSource(h),d.length>0&&d.length===c.length?(i=b.sourceDataC3fv(),i.pushBack(d),g.addSource(i)):d.length>0&&d.length!==c.length&&console.log("[ERROR] Number of colors are different than number of points"),e.length>0&&e.length===c.length?(j=b.sourceDataT2fv(),j.pushBack(e),g.addSource(j)):e.length>0&&e.length/2!==c.length/3&&console.log("[ERROR] Number of texture coordinates are different than number of points"),g.addPrimitive(a),g}},inherit(b.pointSource,b.source),b.lineSource=function(a,c){"use strict";if(!(this instanceof b.lineSource))return new b.lineSource;b.source.call(this);var d=a,e=c;this.setPositions=function(a){return a instanceof Array?(d=a,this.modified(),!0):(console.log("[ERROR] Invalid data type for positions. Array is required."),!1)},this.setColors=function(a){return a instanceof Array?(e=a,this.modified(),!0):(console.log("[ERROR] Invalid data type for colors. Array is required."),!1)},this.create=function(){if(!d)return void console.log("[error] Invalid positions");if(d.length%3!==0)return void console.log("[error] Line source requires 3d points");if(d.length%3!==0)return void console.log("[ERROR] Invalid length of the points array");var a,c,f,g,h=new b.geometryData,i=d.length/3,j=[];for(j.length=i,a=0;i>a;a+=1)j[a]=a;return c=new b.lines,c.setIndices(j),f=b.sourceDataP3fv(),f.pushBack(d),h.addSource(f),e&&e.length>0&&e.length===d.length?(g=b.sourceDataC3fv(),g.pushBack(e),h.addSource(g)):e&&e.length>0&&e.length!==d.length&&console.log("[error] Number of colors are different than number of points"),h.addPrimitive(c),h}},inherit(b.lineSource,b.source),b.utils=function(){"use strict";return this instanceof b.utils?(b.object.call(this),this):new b.utils},inherit(b.utils,b.object),b.utils.computePowerOfTwo=function(a,b){"use strict";for(b=b||1;a>b;)b*=2;return b},b.utils.createTextureVertexShader=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.VERTEX_SHADER,a,c)},b.utils.createTextureFragmentShader=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.FRAGMENT_SHADER,a,c)},b.utils.createRgbaTextureFragmentShader=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.FRAGMENT_SHADER,a,c)},b.utils.createVertexShader=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.VERTEX_SHADER,a,c)},b.utils.createPointVertexShader=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.VERTEX_SHADER,a,c)},b.utils.createVertexShaderSolidColor=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.VERTEX_SHADER,a,c)},b.utils.createVertexShaderColorMap=function(a,c,d){"use strict";c=c,d=d;var e=["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 b.getCachedShader(b.GL.VERTEX_SHADER,a,e)},b.utils.createFragmentShader=function(a){"use strict";var c=["varying mediump vec3 iVertexColor;","uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4(iVertexColor, opacity);","}"].join("\n");return b.getCachedShader(b.GL.FRAGMENT_SHADER,a,c)},b.utils.createPhongVertexShader=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.VERTEX_SHADER,a,c)},b.utils.createPhongFragmentShader=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.FRAGMENT_SHADER,a,c)},b.utils.createFragmentShaderSolidColor=function(a,c){"use strict";var d=["uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4("+c[0]+","+c[1]+","+c[2]+", opacity);","}"].join("\n");return b.getCachedShader(b.GL.FRAGMENT_SHADER,a,d)},b.utils.createFragmentShaderColorMap=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.FRAGMENT_SHADER,a,c)},b.utils.createPointSpritesVertexShader=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.VERTEX_SHADER,a,c)},b.utils.createPointSpritesFragmentShader=function(a){"use strict";var c=["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 b.getCachedShader(b.GL.FRAGMENT_SHADER,a,c)},b.utils.createTextureMaterial=function(a,c){"use strict";var d,e=new b.material,f=new b.blend,g=new b.shaderProgram,h=b.utils.createTextureVertexShader(b.GL),i=null,j=new b.vertexAttribute("vertexPosition"),k=new b.vertexAttribute("textureCoord"),l=new b.floatUniform("pointSize",5),m=new b.projectionUniform("projectionMatrix"),n=new b.uniform(b.GL.INT,"sampler2d"),o=null;return d=void 0!==c?new b.modelViewOriginUniform("modelViewMatrix",c):new b.modelViewUniform("modelViewMatrix"),n.set(0),g.addVertexAttribute(j,b.vertexAttributeKeys.Position),g.addVertexAttribute(k,b.vertexAttributeKeys.TextureCoordinate),g.addUniform(l),g.addUniform(d),g.addUniform(m),i=a?b.utils.createRgbaTextureFragmentShader(b.GL):b.utils.createTextureFragmentShader(b.GL),o=new b.floatUniform("opacity",1),g.addUniform(o),g.addShader(i),g.addShader(h),e.addAttribute(g),e.addAttribute(f),e},b.utils.createGeometryMaterial=function(){"use strict";var a=new b.material,c=new b.shaderProgram,d=5,e=1,f=b.utils.createVertexShader(b.GL),g=b.utils.createFragmentShader(b.GL),h=new b.vertexAttribute("vertexPosition"),i=new b.vertexAttribute("vertexColor"),j=new b.floatUniform("pointSize",d),k=new b.floatUniform("opacity",e),l=new b.modelViewUniform("modelViewMatrix"),m=new b.projectionUniform("projectionMatrix");return c.addVertexAttribute(h,b.vertexAttributeKeys.Position),c.addVertexAttribute(i,b.vertexAttributeKeys.Color),c.addUniform(j),c.addUniform(k),c.addUniform(l),c.addUniform(m),c.addShader(g),c.addShader(f),a.addAttribute(c),a},b.utils.createPointGeometryMaterial=function(a){"use strict";a=void 0===a?1:a;var c=new b.material,d=new b.blend,e=new b.shaderProgram,f=b.utils.createPointVertexShader(b.GL),g=b.utils.createFragmentShader(b.GL),h=new b.vertexAttribute("vertexPosition"),i=new b.vertexAttribute("vertexColor"),j=new b.vertexAttribute("vertexSize"),k=new b.floatUniform("opacity",a),l=new b.modelViewUniform("modelViewMatrix"),m=new b.projectionUniform("projectionMatrix");return e.addVertexAttribute(h,b.vertexAttributeKeys.Position),e.addVertexAttribute(i,b.vertexAttributeKeys.Color),e.addVertexAttribute(j,b.vertexAttributeKeys.Scalar),e.addUniform(k),e.addUniform(l),e.addUniform(m),e.addShader(g),e.addShader(f),c.addAttribute(e),c.addAttribute(d),c},b.utils.createPhongMaterial=function(){"use strict";var a=new b.material,c=new b.shaderProgram,d=b.utils.createPhongVertexShader(b.GL),e=b.utils.createPhongFragmentShader(b.GL),f=new b.vertexAttribute("vertexPosition"),g=new b.vertexAttribute("vertexNormal"),h=new b.vertexAttribute("vertexColor"),i=new b.floatUniform("opacity",1),j=new b.modelViewUniform("modelViewMatrix"),k=new b.normalMatrixUniform("normalMatrix"),l=new b.projectionUniform("projectionMatrix");return c.addVertexAttribute(f,b.vertexAttributeKeys.Position),c.addVertexAttribute(g,b.vertexAttributeKeys.Normal),c.addVertexAttribute(h,b.vertexAttributeKeys.Color),c.addUniform(i),c.addUniform(j),c.addUniform(l),c.addUniform(k),c.addShader(e),c.addShader(d),a.addAttribute(c),a},b.utils.createColorMaterial=function(){"use strict";var a=new b.material,c=new b.blend,d=new b.shaderProgram,e=b.utils.createVertexShader(b.GL),f=b.utils.createFragmentShader(b.GL),g=new b.vertexAttribute("vertexPosition"),h=new b.vertexAttribute("textureCoord"),i=new b.vertexAttribute("vertexColor"),j=new b.floatUniform("pointSize",5),k=new b.floatUniform("opacity",1),l=new b.modelViewUniform("modelViewMatrix"),m=new b.projectionUniform("projectionMatrix");return d.addVertexAttribute(g,b.vertexAttributeKeys.Position),d.addVertexAttribute(i,b.vertexAttributeKeys.Color),d.addVertexAttribute(h,b.vertexAttributeKeys.TextureCoordinate),d.addUniform(j),d.addUniform(k),d.addUniform(l),d.addUniform(m),d.addShader(f),d.addShader(e),a.addAttribute(d),a.addAttribute(c),a},b.utils.createColorMappedMaterial=function(a){"use strict";a||(a=new b.lookupTable);var c=a.range(),d=new b.material,e=new b.blend,f=new b.shaderProgram,g=b.utils.createVertexShaderColorMap(b.GL,c[0],c[1]),h=b.utils.createFragmentShaderColorMap(b.GL),i=new b.vertexAttribute("vertexPosition"),j=new b.vertexAttribute("vertexScalar"),k=new b.floatUniform("pointSize",5),l=new b.floatUniform("opacity",1),m=new b.floatUniform("lutMin",c[0]),n=new b.floatUniform("lutMax",c[1]),o=new b.modelViewUniform("modelViewMatrix"),p=new b.projectionUniform("projectionMatrix"),q=new b.uniform(b.GL.FLOAT,"sampler2d"),r=a;return q.set(0),f.addVertexAttribute(i,b.vertexAttributeKeys.Position),f.addVertexAttribute(j,b.vertexAttributeKeys.Scalar),f.addUniform(k),f.addUniform(l),f.addUniform(m),f.addUniform(n),f.addUniform(o),f.addUniform(p),f.addShader(h),f.addShader(g),d.addAttribute(f),d.addAttribute(e),d.addAttribute(r),d},b.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)},b.utils.createSolidColorMaterial=function(a){"use strict";a||(a=[1,1,1]);var c=new b.material,d=new b.blend,e=new b.shaderProgram,f=b.utils.createVertexShaderSolidColor(b.GL),g=b.utils.createFragmentShaderSolidColor(b.GL,a),h=new b.vertexAttribute("vertexPosition"),i=new b.floatUniform("pointSize",5),j=new b.floatUniform("opacity",1),k=new b.modelViewUniform("modelViewMatrix"),l=new b.projectionUniform("projectionMatrix");return e.addVertexAttribute(h,b.vertexAttributeKeys.Position),e.addUniform(i),e.addUniform(j),e.addUniform(k),e.addUniform(l),e.addShader(g),e.addShader(f),c.addAttribute(e),c.addAttribute(d),c},b.utils.createPointSpritesMaterial=function(a,c){"use strict";var d=void 0===c?[0,1]:c.range(),e=new b.material,f=new b.blend,g=new b.shaderProgram,h=b.utils.createPointSpritesVertexShader(b.GL),i=b.utils.createPointSpritesFragmentShader(b.GL),j=new b.vertexAttribute("vertexPosition"),k=new b.vertexAttribute("vertexColor"),l=new b.floatUniform("height",0),m=new b.floatUniform("vertexColorWeight",0),n=new b.floatUniform("lutMin",d[0]),o=new b.floatUniform("lutMax",d[1]),p=new b.modelViewUniform("modelViewMatrix"),q=new b.projectionUniform("projectionMatrix"),r=new b.uniform(b.GL.INT,"opacityLookup"),s=new b.uniform(b.GL.INT,"scalarsToColors"),t=new b.uniform(b.GL.INT,"useScalarsToColors"),u=new b.uniform(b.GL.INT,"useVertexColors"),v=new b.uniform(b.GL.FLOAT_VEC2,"pointSize"),w=new b.texture;return r.set(0),s.set(1),t.set(0),u.set(0),v.set([1,1]),g.addVertexAttribute(j,b.vertexAttributeKeys.Position),g.addVertexAttribute(k,b.vertexAttributeKeys.Color),g.addUniform(l),g.addUniform(m),g.addUniform(p),g.addUniform(q),g.addUniform(r),g.addUniform(u),g.addUniform(t),g.addUniform(v),g.addShader(i),g.addShader(h),e.addAttribute(g),e.addAttribute(f),c&&(g.addUniform(s),t.set(1),g.addUniform(n),g.addUniform(o),c.setTextureUnit(1),e.addAttribute(c)),w.setImage(a),w.setTextureUnit(0),e.addAttribute(w),e},b.utils.createPlane=function(a,c,d,e,f,g,h,i,j){"use strict";var k=new b.mapper,l=new b.planeSource,m=b.utils.createGeometryMaterial(),n=new b.actor;return l.setOrigin(a,c,d),l.setPoint1(e,f,g),l.setPoint2(h,i,j),k.setGeometryData(l.create()),n.setMapper(k),n.setMaterial(m),n},b.utils.createTexturePlane=function(a,c,d,e,f,g,h,i,j,k){"use strict";var l=new b.mapper,m=new b.planeSource,n=b.utils.createTextureMaterial(k,[a,c,d]),o=new b.actor;return m.setPoint1(e-a,f-c,g-d),m.setPoint2(h-a,i-c,j-d),l.setGeometryData(m.create()),o.setMapper(l),o.setMaterial(n),o},b.utils.createPoints=function(a,c,d,e,f){"use strict";if(!a)return console.log("[ERROR] Cannot create points without positions"),null;f=void 0===f?1:f;var g=new b.mapper,h=new b.pointSource,i=b.utils.createPointGeometryMaterial(f),j=new b.actor;return h.setPositions(a),d&&h.setColors(d),e&&h.setTextureCoordinates(e),c?h.setSize(c):h.setSize(1),g.setGeometryData(h.create()),j.setMapper(g),j.setMaterial(i),j}, b.utils.createPointSprites=function(a,c,d,e){"use strict";if(!a)return console.log("[ERROR] Point sprites requires an image"),null;if(!c)return console.log("[ERROR] Cannot create points without positions"),null;var f=new b.mapper,g=new b.pointSource,h=b.utils.createPointSpritesMaterial(a),i=new b.actor;return g.setPositions(c),d&&g.setColors(d),e&&g.setTextureCoordinates(e),f.setGeometryData(g.create()),i.setMapper(f),i.setMaterial(h),i},b.utils.createLines=function(a,c){"use strict";if(!a)return console.log("[ERROR] Cannot create points without positions"),null;var d=new b.mapper,e=new b.lineSource,f=b.utils.createGeometryMaterial(),g=new b.actor;return e.setPositions(a),c&&e.setColors(c),d.setGeometryData(e.create()),g.setMapper(d),g.setMaterial(f),g},b.utils.createColorLegend=function(a,c,d,e,f,g,h){"use strict";function i(a,c,d){if(!c)return void console.log("[error] Create labels requires positions (x,y,z) array");if(c.length%3!==0)return void console.log("[error] Create labels require positions array contain 3d points");if(!d)return void console.log("[error] Create labels requires Valid range");var e,f=null,g=b.utils.computePowerOfTwo(48),h=0,i=[],j=[],k=[],l=[],m=c[6]-c[0],n=4;for(j.length=3,k.length=3,l.length=3,e=0;2>e;e+=1)h=e*(c.length-3),j[0]=c[h]-m,j[1]=c[h+1]-2*m,j[2]=c[h+2],k[0]=c[h]+m,k[1]=j[1],k[2]=j[2],l[0]=j[0],l[1]=c[1],l[2]=j[2],f=b.utils.createTexturePlane(j[0],j[1],j[2],k[0],k[1],k[2],l[0],l[1],l[2],!0),f.setReferenceFrame(b.boundingObject.ReferenceFrame.Absolute),f.material().setBinNumber(b.material.RenderBin.Overlay),f.material().addAttribute(b.utils.create2DTexture(d[e].toFixed(2).toString(),12,null)),i.push(f);return j[0]=.5*(c[0]+c[c.length-3]-g),j[1]=c[1]+n,j[2]=c[2],k[0]=j[0]+g,k[1]=j[1],k[2]=j[2],l[0]=j[0],l[1]=j[1]+g,l[2]=j[2],f=b.utils.createTexturePlane(j[0],j[1],j[2],k[0],k[1],k[2],l[0],l[1],l[2],!0),f.setReferenceFrame(b.boundingObject.ReferenceFrame.Absolute),f.material().setBinNumber(b.material.RenderBin.Overlay),f.material().addAttribute(b.utils.create2DTexture(a,24,null)),i.push(f),i}function j(a,b,c,d,e,f,g,h,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(h),t.push(f+s*r),t.push(g+o),t.push(h);return u=u.concat(i(a,t,b.range()))}if(!c)return console.log("[error] Invalid lookup table"),[];var k=d[0]+e,l=d[1],m=0,n=d[0],o=d[1]+f,p=0,q=[],r=null,s=null,t=b.groupNode();return r=b.utils.createTexturePlane(d[0],d[1],d[2],k,l,m,n,o,p,!0),s=r.material(),s.addAttribute(c),r.setMaterial(s),t.addChild(r),r.material().setBinNumber(b.material.RenderBin.Overlay),r.setReferenceFrame(b.boundingObject.ReferenceFrame.Absolute),q.push(r),q=q.concat(j(a,c,d[0],d[1],d[1],n,l,m,k,l,m,g,h,5,3))},b.utils.create2DTexture=function(a,c,d,e,f,g,h){"use strict";var i=document.getElementById("textRendering"),j=null,k=b.texture();return e=e||"sans-serif",f=f||"center",g=g||"bottom","undefined"==typeof h&&(h=!0),i||(i=document.createElement("canvas")),j=i.getContext("2d"),i.setAttribute("id","textRendering"),i.style.display="none",i.height=b.utils.computePowerOfTwo(8*c),i.width=i.height,j.fillStyle="rgba(0, 0, 0, 0)",j.fillRect(0,0,j.canvas.width,j.canvas.height),j.fillStyle="rgba(200, 85, 10, 1.0)",j.textAlign=f,j.textBaseline=g,j.font=4*c+"px "+e,h&&(j.font="bold "+j.font),j.fillText(a,i.width/2,i.height/2,i.width),k.setImage(i),k.updateDimensions(),k},b.picker=function(){"use strict";if(!(this instanceof b.picker))return new b.picker;b.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(b.picker,b.object),b.shapefileReader=function(){"use strict";if(!(this instanceof b.shapefileReader))return new b.shapefileReader;var a=this,c=0,d=1,e=5,f=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=d;g-=1){var h=a.ldbl64(b,c+16*g),i=a.ldbl64(b,c+16*g+8);f.push([h,i])}return f},m=function(g){var h,i,j,m,n,o,p,q,r,s=g+8,t=a.lint32(b,s);if(t===c)console.log("NULL Shape");else if(t===d){var u=a.ldbl64(b,s+4),v=a.ldbl64(b,s+12);k.push({type:"Point",attr:{},geom:[[u,v]]})}else if(t===e){for(h=a.lint32(b,s+36),i=a.lint32(b,s+40),j=g+52,m=g+52+4*h,r=[],n=0;h>n;n+=1)o=a.lint32(b,j+4*n),p=h>n+1?a.lint32(b,j+4*(n+1)):i,q=l(m,o,p),r.push(q);k.push({type:"Polygon",attr:{},geom:[r]})}else{if(t!==f)throw"Not Implemented: "+t;for(h=a.lint32(b,s+36),i=a.lint32(b,s+40),j=g+52,m=g+52+4*h,r=[],n=0;h>n;n+=1)o=a.lint32(b,j+4*n),p=h>n+1?a.lint32(b,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=i.length)return h;if(a=i.charAt(j),j+=1,c[a])return c[a];if("A"===a)return 0}return h},this.decode64=function(a){var b="",c=new Array(4),d=!1;for(i=a,j=0;!d&&(c[0]=this.readReverseBase64())!==h&&(c[1]=this.readReverseBase64())!==h;)c[2]=this.readReverseBase64(),c[3]=this.readReverseBase64(),b+=this.ntos(c[0]<<2&255|c[1]>>4),c[2]!==h?(b+=this.ntos(c[1]<<4&255|c[2]>>2),c[3]!==h?b+=this.ntos(c[2]<<6&255|c[3]):d=!0):d=!0;return b},this.readNumber=function(a){var b=a[k++]+(a[k++]<<8)+(a[k++]<<16)+(a[k++]<<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[k],k+=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[k++]/255,f[e++]=b[k++]/255,f[e++]=b[k++]/255,k++;c.insert(f)},this.parseObject=function(a){var c,d,e,f,g,h,i,j,n,o,p,q=new b.geometryData,r=b.mapper(),s=[],t=null,u=null,v=null,w=null;for(u=atob(a.data),m=0;ml;l+=1)q[r++]=f[3*l],q[r++]=f[3*l+1],q[r++]=f[3*l+2];for(m.insert(q),a.addSource(m),n=new b.sourceDataC3fv,this.readColorArray(e,c,n),a.addSource(n),o=new b.lines,a.addPrimitive(o),d=this.readNumber(c),g=new Int8Array(2*d),l=0;2*d>l;l+=1)g[l]=c[k],k+=1;for(h=new Uint16Array(g.buffer),o.setIndices(h),o.setPrimitiveType(b.GL.LINES),i=64,g=new Int8Array(i),l=0;i>l;l+=1)g[l]=c[k],k+=1;return j=new Float32Array(g.buffer),mat4.copy(p,j),p},this.parseMeshData=function(a,c){var d,e,f,g,h,i,j,l,m=null,n=null,o=null,p=mat4.create(),q=null,r=null,s=0;for(e=this.readNumber(c),r=new Array(6*e),m=new b.sourceDataP3N3f,f=this.readF3Array(e,c),o=this.readF3Array(e,c),l=0;e>l;l+=1)r[s++]=f[3*l],r[s++]=f[3*l+1],r[s++]=f[3*l+2],r[s++]=o[3*l],r[s++]=o[3*l+1],r[s++]=o[3*l+2];for(m.insert(r),a.addSource(m),n=new b.sourceDataC3fv,this.readColorArray(e,c,n),a.addSource(n),g=[],q=new b.triangles,d=this.readNumber(c),g=new Int8Array(2*d),l=0;2*d>l;l+=1)g[l]=c[k],k+=1;for(h=new Uint16Array(g.buffer),q.setIndices(h),a.addPrimitive(q),i=64,g=new Int8Array(i),l=0;i>l;l+=1)g[l]=c[k],k+=1;return j=new Float32Array(g.buffer),mat4.copy(p,j),p},this.parsePointData=function(a,c){var d,e,f,g,h,i,j=mat4.create(),l=null,n=null,o=null,p=null,q=0;for(d=this.readNumber(c),p=new Array(3*d),l=new b.sourceDataP3fv,e=this.readF3Array(d,c),f=new Uint16Array(d),m=0;d>m;m+=1)f[m]=m,p[q++]=e[3*m],p[q++]=e[3*m+1],p[q++]=e[3*m+2];for(l.insert(p),a.addSource(l),n=new b.sourceDataC3fv,this.readColorArray(d,c,n),a.addSource(n),o=new b.points,o.setIndices(f),a.addPrimitive(o),h=64,g=new Int8Array(h),m=0;h>m;m+=1)g[m]=c[k],k+=1;return i=new Float32Array(g.buffer),mat4.copy(j,i),j},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[k],k+=1;for(i.position=new Float32Array(d.buffer),e=8,d=new Int8Array(e),g=0;e>g;g+=1)d[g]=b[k],k+=1;for(i.size=new Float32Array(d.buffer),i.colors=[],h=0;hg;g+=1)d[g]=b[k],k+=1;f=[new Float32Array(d.buffer)[0],b[k++],b[k++],b[k++]],i.colors[h]=f}for(i.orientation=b[k++],i.numOfLabels=b[k++],i.title="";k=0;b-=1)a=this.getRenderer(b),this.parseSceneMetadata(a,b);return l},this.createViewer=function(a){var c;return null===l&&(g=a,l=b.viewer(a),l.init(),l.renderWindow().removeRenderer(l.renderWindow().activeRenderer()),l.renderWindow().addRenderer(new b.depthPeelRenderer),d[0]=l.renderWindow().activeRenderer(),l.renderWindow().resize(a.width,a.height),c=b.pvwInteractorStyle(),l.setInteractorStyle(c)),l},this.deleteViewer=function(){d={},l=null},this.updateCanvas=function(a){return g=a,l.renderWindow().resize(a.width,a.height),l},this.numObjects=function(){return e},this.getRenderer=function(a){var c;return c=d[a],(null===c||"undefined"==typeof c)&&(c=new b.renderer,c.setResetScene(!1),c.setResetClippingRange(!1),l.renderWindow().addRenderer(c),0!==a&&c.camera().setClearMask(b.GL.DepthBufferBit),d[a]=c),c},this.setVtkScene=function(a){f=a},this},b.DataBuffers=function(a){"use strict";if(!(this instanceof b.DataBuffers))return new b.DataBuffers(a);var c,d={};c=a||0===a?a:256;var e=0,f=function(a,b,c,d){if(!a)throw"No destination";c||(c=0),d||(d=b.length);for(var e=0;d>e;e+=1)a[c+e]=b[e]},g=function(a){var b=c;for(a>2*b&&(b=a);a>b;)b*=2;c=b;for(var e in d)if(d.hasOwnProperty(e)){var g=new Float32Array(b*d[e].len),h=d[e].array;f(g,h),d[e].array=g,d[e].dirty=!0}};this.create=function(a,b){if(!b||0>b)throw"Length of buffer must be a positive integer";var e=new Float32Array(c*b);return d[a]={array:e,len:b,dirty:!1},d[a].array},this.alloc=function(a){e+a>=c&&g(e+a);var b=e;return e+=a,b},this.get=function(a){return d[a].array},this.write=function(a,b,e,g){if(e+g>c)throw"Write would exceed buffer size";f(d[a].array,b,e*d[a].len,g*d[a].len),d[a].dirty=!0},this.repeat=function(a,b,e,g){if(e+g>c)throw"Repeat would exceed buffer size";for(var h=0;g>h;h+=1)f(d[a].array,b,(e+h)*d[a].len,d[a].len);d[a].dirty=!0},this.count=function(){return e},this.data=function(a){return d[a].array}},b.depthPeelRenderer=function(){"use strict";function a(a,b){E.setMaterial(b),a.m_mapper=E.mapper(),a.m_material=b,a.m_material.bind(a),a.m_mapper.render(a),a.m_material.undoBind(a),E.setMaterial(null)}function c(a,c,d){console.log(c),console.log(d),E=b.utils.createPlane(0,0,0,1,0,0,0,1,0)}function d(a){var c,d,e,f,g,h,i,j,t,u,v,w,x;e=new b.vertexAttribute("vertexPosition"),h=new b.vertexAttribute("vertexNormal"),f=new b.vertexAttribute("vertexColor"),c=new b.modelViewUniform("modelViewMatrix"),i=new b.modelViewUniform("normalMatrix"),d=new b.projectionUniform("projectionMatrix"),l=new b.floatUniform("width"),m=new b.floatUniform("height"),r=new b.floatUniform("opacity",1),g=new b.uniform(b.GL.INT,"depthTexture"),g.set(0),B=new b.shaderProgram,B.loadShader(b.GL.VERTEX_SHADER,"front_peel.vert"),B.loadShader(b.GL.FRAGMENT_SHADER,"front_peel.frag"),B.addUniform(c),B.addUniform(i),B.addUniform(d),B.addUniform(g),B.addUniform(l),B.addUniform(m),B.addUniform(r),B.addVertexAttribute(e,b.vertexAttributeKeys.Position),B.addVertexAttribute(h,b.vertexAttributeKeys.Normal),B.addVertexAttribute(f,b.vertexAttributeKeys.Color),B.compileAndLink(a),y.addAttribute(B),C=new b.shaderProgram,C.loadShader(b.GL.VERTEX_SHADER,"blend.vert"),C.loadShader(b.GL.FRAGMENT_SHADER,"blend.frag"),t=new b.uniform(b.GL.INT,"currColorTexture"),u=new b.uniform(b.GL.INT,"prevDepthTexture"),v=new b.uniform(b.GL.INT,"currDepthTexture"),n=new b.floatUniform("width"),o=new b.floatUniform("height"),t.set(0),u.set(1),v.set(2),j=new b.vertexAttribute("vertexPosition"),C.addUniform(t),C.addUniform(u),C.addUniform(u),C.addUniform(n),C.addUniform(o),C.addVertexAttribute(j,b.vertexAttributeKeys.Position),C.compileAndLink(a),z.addAttribute(C),k=new b.shaderProgram,k.loadShader(b.GL.VERTEX_SHADER,"blend.vert"),k.loadShader(b.GL.FRAGMENT_SHADER,"final.frag"),x=new b.uniform(b.GL.INT,"colorTexture"),p=new b.floatUniform("width"),q=new b.floatUniform("height"),s=new b.uniform(b.GL.FLOAT_VEC3,"backgroundColor"),x.set(0),w=new b.vertexAttribute("vertexPosition"),k.addUniform(x),k.addUniform(p),k.addUniform(q),k.addUniform(s),k.addVertexAttribute(w,b.vertexAttributeKeys.Position),k.compileAndLink(a),A.addAttribute(k)}function e(a,c,d){var e,f,g,h,k;h=a.m_context.getExtension("WEBKIT_WEBGL_depth_texture"),h||(h=a.m_context.getExtension("WEBGL_depth_texture"),h||console.log("Depth textures are not supported"));var l=a.m_context.getExtension("OES_texture_float");if(l||console.log("float textures are not supported"),f=a.m_context.getExtension("OES_texture_float"),!f)return console.log("Extension Texture Float is not working"),void window.alert(":( Sorry, Your browser doesn't support texture float extension.");if(g=a.m_context.getExtension("OES_texture_float_linear"),h=a.m_context.getExtension("WEBGL_depth_texture"),!h)return console.log("Extension Depth texture is not working"),void window.alert(":( Sorry, Your browser doesn't support depth texture extension.");for(k=g?b.GL.LINEAR:b.GL.NEAREST,u.push(a.m_context.createFramebuffer()),u.push(a.m_context.createFramebuffer()),v.push(a.m_context.createTexture()),v.push(a.m_context.createTexture()),w.push(a.m_context.createTexture()),w.push(a.m_context.createTexture()),e=0;2>e;e+=1)a.m_context.bindTexture(b.GL.TEXTURE_2D,w[e]),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_MAG_FILTER,b.GL.NEAREST),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_MIN_FILTER,b.GL.NEAREST),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_WRAP_S,b.GL.CLAMP_TO_EDGE),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_WRAP_T,b.GL.CLAMP_TO_EDGE),a.m_context.texImage2D(b.GL.TEXTURE_2D,0,b.GL.DEPTH_COMPONENT,c,d,0,b.GL.DEPTH_COMPONENT,b.GL.UNSIGNED_SHORT,null),a.m_context.bindTexture(b.GL.TEXTURE_2D,v[e]),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_MAG_FILTER,k),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_MIN_FILTER,k),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_WRAP_S,b.GL.CLAMP_TO_EDGE),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_WRAP_T,b.GL.CLAMP_TO_EDGE),a.m_context.texImage2D(b.GL.TEXTURE_2D,0,b.GL.RGBA,c,d,0,b.GL.RGBA,b.GL.FLOAT,null),a.m_context.bindFramebuffer(b.GL.FRAMEBUFFER,u[e]),a.m_context.framebufferTexture2D(b.GL.FRAMEBUFFER,b.GL.DEPTH_ATTACHMENT,b.GL.TEXTURE_2D,w[e],0),a.m_context.framebufferTexture2D(b.GL.FRAMEBUFFER,b.GL.COLOR_ATTACHMENT0,b.GL.TEXTURE_2D,v[e],0);i=a.m_context.createTexture(),a.m_context.bindTexture(b.GL.TEXTURE_2D,i),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_WRAP_S,b.GL.CLAMP_TO_EDGE),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_WRAP_T,b.GL.CLAMP_TO_EDGE),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_MIN_FILTER,b.GL.NEAREST),a.m_context.texParameteri(b.GL.TEXTURE_2D,b.GL.TEXTURE_MAG_FILTER,b.GL.NEAREST),a.m_context.texImage2D(b.GL.TEXTURE_2D,0,b.GL.RGBA,c,d,0,b.GL.RGBA,b.GL.FLOAT,null),j=a.m_context.createFramebuffer(),a.m_context.bindFramebuffer(b.GL.FRAMEBUFFER,j),a.m_context.framebufferTexture2D(b.GL.FRAMEBUFFER,b.GL.DEPTH_ATTACHMENT,b.GL.TEXTURE_2D,w[0],0),a.m_context.framebufferTexture2D(b.GL.FRAMEBUFFER,b.GL.COLOR_ATTACHMENT0,b.GL.TEXTURE_2D,i,0);var m=a.m_context.checkFramebufferStatus(b.GL.FRAMEBUFFER);m===b.GL.FRAMEBUFFER_COMPLETE?console.log("FBO setup successful !!! \n"):console.log("Problem with FBO setup"),a.m_context.bindFramebuffer(b.GL.FRAMEBUFFER,null)}function f(a){x.getMTime()e;e+=1){var k=e%2,r=1-k;c.m_context.bindFramebuffer(b.GL.FRAMEBUFFER,u[k]),c.m_context.disable(b.GL.BLEND),c.m_context.enable(b.GL.DEPTH_TEST),c.m_context.bindTexture(b.GL.TEXTURE_2D,w[r]),c.m_context.clearColor(0,0,0,0),c.m_context.clear(b.GL.COLOR_BUFFER_BIT|b.GL.DEPTH_BUFFER_BIT),g(c,d,y),c.m_context.bindFramebuffer(b.GL.FRAMEBUFFER,j),c.m_context.disable(b.GL.DEPTH_TEST),c.m_context.enable(b.GL.BLEND),c.m_context.blendEquation(b.GL.FUNC_ADD),c.m_context.blendFuncSeparate(b.GL.DST_ALPHA,b.GL.ONE,b.GL.ZERO,b.GL.ONE_MINUS_SRC_ALPHA),c.m_context.activeTexture(b.GL.TEXTURE0),c.m_context.bindTexture(b.GL.TEXTURE_2D,v[k]),c.m_context.activeTexture(b.GL.TEXTURE1),c.m_context.bindTexture(b.GL.TEXTURE_2D,w[r]),c.m_context.activeTexture(b.GL.TEXTURE2),c.m_context.bindTexture(b.GL.TEXTURE_2D,w[k]),a(c,z),c.m_context.activeTexture(b.GL.TEXTURE0),c.m_context.disable(b.GL.BLEND)}c.m_context.bindFramebuffer(b.GL.FRAMEBUFFER,null),c.m_context.disable(b.GL.DEPTH_TEST),c.m_context.disable(b.GL.BLEND),c.m_context.bindTexture(b.GL.TEXTURE_2D,i),s.set(t.m_camera.clearColor()),a(c,A),c.m_context.bindTexture(b.GL.TEXTURE_2D,null)}if(!(this instanceof b.depthPeelRenderer))return new b.depthPeelRenderer;b.renderer.call(this);var i,j,k,l,m,n,o,p,q,r,s,t=this,u=[],v=[],w=[],x=b.timestamp(),y=b.material(),z=b.material(),A=b.material(),B=null,C=null,D=6,E=null;this.render=function(){var a,c,d,e=null,g=[];for(c=new b.renderState,c.m_renderer=t,c.m_context=t.renderWindow().context(),c.m_contextChanged=t.m_contextChanged,c.m_context.viewport(t.m_x,t.m_y,t.m_width,t.m_height),f(c),d=t.m_sceneRoot.children(),d.length>0&&t.m_resetScene&&(this.resetCamera(),t.m_resetScene=!1),a=0;a