From 24dd32eb72b682667ac8bb4f0b4238a1abde5b25 Mon Sep 17 00:00:00 2001 From: Jonathan Beezley Date: Thu, 26 Mar 2015 14:05:18 -0400 Subject: [PATCH] Update to 0.4.1 with properly built libraries --- Gruntfile.js | 5 ++--- bower.json | 2 +- docs/conf.py | 4 ++-- geo.js | 2 +- geo.min.js | 2 +- package.json | 4 ++-- 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 5fd2e44b0d..1ea5d4288d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -192,12 +192,11 @@ module.exports = function (grunt) { uglify: { options: { - sourceMap: true, - sourceMapIncludeSources: true, + sourceMap: false, report: 'min', beautify: { ascii_only: true, - beautify: true + beautify: false }, mangle: false }, diff --git a/bower.json b/bower.json index 9636cdd128..b1cfc4f674 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "geojs", - "version": "0.4.0", + "version": "0.4.1", "description": "JavaScript Geo visualization and Analysis Library", "homepage": "https://github.com/OpenGeoscience/geojs", "main": "geo.js", diff --git a/docs/conf.py b/docs/conf.py index c619d833ca..8760448481 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -73,9 +73,9 @@ # built documents. # # The short X.Y version. -version = '0.2' +version = '0.4.1' # The full version, including alpha/beta/rc tags. -release = '0.2.0' +release = version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/geo.js b/geo.js index d169336f44..7a2ac0e325 100644 --- a/geo.js +++ b/geo.js @@ -226,7 +226,7 @@ if (!Math.log2) { /*global geo*/ -geo.version = "0.2.0"; +geo.version = "0.4.1"; ////////////////////////////////////////////////////////////////////////////// /** diff --git a/geo.min.js b/geo.min.js index 9ba5343143..7d5eeed6b0 100644 --- a/geo.min.js +++ b/geo.min.js @@ -1,4 +1,4 @@ -function inherit(C,P){"use strict";var F=function(){};F.prototype=P.prototype,C.prototype=new F,C.uber=P.prototype,C.prototype.constructor=C}var geo={};if(window.geo=geo,geo.renderers={},geo.features={},geo.fileReaders={},geo.inherit=function(C,P){"use strict";var F=inherit.func();F.prototype=P.prototype,C.prototype=new F,C.prototype.constructor=C},geo.inherit.func=function(){"use strict";return function(){}},window.inherit=geo.inherit,geo.registerFileReader=function(name,func){"use strict";void 0===geo.fileReaders&&(geo.fileReaders={}),geo.fileReaders[name]=func},geo.createFileReader=function(name,opts){"use strict";return geo.fileReaders.hasOwnProperty(name)?geo.fileReaders[name](opts):null},geo.registerRenderer=function(name,func){"use strict";void 0===geo.renderers&&(geo.renderers={}),geo.renderers[name]=func},geo.createRenderer=function(name,layer,canvas){"use strict";if(geo.renderers.hasOwnProperty(name)){var ren=geo.renderers[name]({layer:layer,canvas:canvas});return ren._init(),ren}return null},geo.registerFeature=function(category,name,func){"use strict";void 0===geo.features&&(geo.features={}),category in geo.features||(geo.features[category]={}),geo.features[category][name]=func},geo.createFeature=function(name,layer,renderer,arg){"use strict";var category=renderer.api(),options={layer:layer,renderer:renderer};return category in geo.features&&name in geo.features[category]?(void 0!==arg&&$.extend(!0,options,arg),geo.features[category][name](options)):null},geo.registerLayer=function(name,func){"use strict";void 0===geo.layers&&(geo.layers={}),geo.layers[name]=func},geo.createLayer=function(name,map,arg){"use strict";var options={map:map,renderer:"vgl"},layer=null;return name in geo.layers?(void 0!==arg&&$.extend(!0,options,arg),layer=geo.layers[name](options),layer._init(),layer):null},geo.registerWidget=function(category,name,func){"use strict";void 0===geo.widgets&&(geo.widgets={}),category in geo.widgets||(geo.widgets[category]={}),geo.widgets[category][name]=func},geo.createWidget=function(name,layer,renderer,arg){"use strict";var category=renderer.api(),options={layer:layer,renderer:renderer};return category in geo.widgets&&name in geo.widgets[category]?(void 0!==arg&&$.extend(!0,options,arg),geo.widgets[category][name](options)):null},window.requestAnimationFrame||(window.requestAnimationFrame=function(func){"use strict";window.setTimeout(func,15)}),Math.log2||(Math.log2=function(){"use strict";return Math.log.apply(Math,arguments)/Math.LN2}),geo.version="0.2.0","undefined"==typeof ogs)var ogs={};ogs.namespace=function(ns_string){"use strict";var i,parts=ns_string.split("."),parent=ogs;for("ogs"===parts[0]&&(parts=parts.slice(1)),i=0;ithis.computeBoundsTimestamp().getMTime()&&this.m_parent.boundsDirtyTimestamp.modified(),this.computeBounds(),visitor.mode()===visitor.TraverseAllChildren)for(i=0;ithis.boundsDirtyTimestamp().getMTime()))for(i=0;ii;++i)istep=2*i,jstep=2*i+1,childBounds[istep]bounds[jstep]&&(bounds[jstep]=childBounds[jstep]);this.setBounds(bounds[0],bounds[1],bounds[2],bounds[3],bounds[4],bounds[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 m_transformMatrix=mat4.create(),m_referenceFrame=vgl.boundingObject.ReferenceFrame.Relative,m_mapper=null;return this.matrix=function(){return m_transformMatrix},this.setMatrix=function(tmatrix){tmatrix!==m_transformMatrix&&(m_transformMatrix=tmatrix,this.modified())},this.referenceFrame=function(){return m_referenceFrame},this.setReferenceFrame=function(referenceFrame){return referenceFrame!==m_referenceFrame?(m_referenceFrame=referenceFrame,this.modified(),!0):!1},this.mapper=function(){return m_mapper},this.setMapper=function(mapper){mapper!==m_mapper&&(m_mapper=mapper,this.boundsModified())},this.accept=function(){},this.ascend=function(){},this.computeLocalToWorldMatrix=function(){},this.computeWorldToLocalMatrix=function(){},this.computeBounds=function(){if(null===m_mapper||void 0===m_mapper)return void this.resetBounds();var mapperBounds,minPt,maxPt,newBounds,computeBoundsTimestamp=this.computeBoundsTimestamp();(this.boundsDirtyTimestamp().getMTime()>computeBoundsTimestamp.getMTime()||m_mapper.boundsDirtyTimestamp().getMTime()>computeBoundsTimestamp.getMTime())&&(m_mapper.computeBounds(),mapperBounds=m_mapper.bounds(),minPt=[mapperBounds[0],mapperBounds[2],mapperBounds[4]],maxPt=[mapperBounds[1],mapperBounds[3],mapperBounds[5]],vec3.transformMat4(minPt,minPt,m_transformMatrix),vec3.transformMat4(maxPt,maxPt,m_transformMatrix),newBounds=[minPt[0]>maxPt[0]?maxPt[0]:minPt[0],minPt[0]>maxPt[0]?minPt[0]:maxPt[0],minPt[1]>maxPt[1]?maxPt[1]:minPt[1],minPt[1]>maxPt[1]?minPt[1]:maxPt[1],minPt[2]>maxPt[2]?maxPt[2]:minPt[2],minPt[2]>maxPt[2]?minPt[2]:maxPt[2]],this.setBounds(newBounds[0],newBounds[1],newBounds[2],newBounds[3],newBounds[4],newBounds[5]),computeBoundsTimestamp.modified())},this},inherit(vgl.actor,vgl.node),vgl.freezeObject=function(obj){"use strict";var freezedObject=Object.freeze(obj);return"undefined"==typeof freezedObject&&(freezedObject=function(o){return o}),freezedObject},vgl.defaultValue=function(a,b){"use strict";return"undefined"!=typeof a?a:b},vgl.defaultValue.EMPTY_OBJECT=vgl.freezeObject({}),vgl.geojsonReader=function(){"use strict";if(!(this instanceof vgl.geojsonReader))return new vgl.geojsonReader;return this.readScalars=function(coordinates,geom,size_estimate,idx){var array=null,s=null,r=null,g=null,b=null;"values"===this.m_scalarFormat&&4===coordinates.length?(s=coordinates[3],array=geom.sourceData(vgl.vertexAttributeKeys.Scalar),array||(array=new vgl.sourceDataSf,this.m_scalarRange&&array.setScalarRange(this.m_scalarRange[0],this.m_scalarRange[1]),void 0!==size_estimate&&(array.data().length=size_estimate),geom.addSource(array)),void 0===size_estimate?array.pushBack(s):array.insertAt(idx,s)):"rgb"===this.m_scalarFormat&&6===coordinates.length&&(array=geom.sourceData(vgl.vertexAttributeKeys.Color),array||(array=new vgl.sourceDataC3fv,void 0!==size_estimate&&(array.length=3*size_estimate),geom.addSource(array)),r=coordinates[3],g=coordinates[4],b=coordinates[5],void 0===size_estimate?array.pushBack([r,g,b]):array.insertAt(idx,[r,g,b]))},this.readPoint=function(coordinates){var geom=new vgl.geometryData,vglpoints=new vgl.points,vglcoords=new vgl.sourceDataP3fv,indices=new Uint16Array(1),x=null,y=null,z=null,i=null;for(geom.addSource(vglcoords),i=0;1>i;i++)indices[i]=i,x=coordinates[0],y=coordinates[1],z=0,coordinates.length>2&&(z=coordinates[2]),vglcoords.pushBack([x,y,z]),this.readScalars(coordinates,geom);return vglpoints.setIndices(indices),geom.addPrimitive(vglpoints),geom.setName("aPoint"),geom},this.readMultiPoint=function(coordinates){var i,geom=new vgl.geometryData,vglpoints=new vgl.points,vglcoords=new vgl.sourceDataP3fv,indices=new Uint16Array(coordinates.length),pntcnt=0,estpntcnt=coordinates.length,x=null,y=null,z=null;for(vglcoords.data().length=3*estpntcnt,i=0;i2&&(z=coordinates[i][2]),vglcoords.insertAt(pntcnt,[x,y,z]),this.readScalars(coordinates[i],geom,estpntcnt,pntcnt),pntcnt++;return vglpoints.setIndices(indices),geom.addPrimitive(vglpoints),geom.addSource(vglcoords),geom.setName("manyPoints"),geom},this.readLineString=function(coordinates){var geom=new vgl.geometryData,vglline=new vgl.lineStrip,vglcoords=new vgl.sourceDataP3fv,indices=[],i=null,x=null,y=null,z=null;for(vglline.setIndicesPerPrimitive(coordinates.length),i=0;i2&&(z=coordinates[i][2]),vglcoords.pushBack([x,y,z]),this.readScalars(coordinates[i],geom);return vglline.setIndices(indices),geom.addPrimitive(vglline),geom.addSource(vglcoords),geom.setName("aLineString"),geom},this.readMultiLineString=function(coordinates){var geom=new vgl.geometryData,vglcoords=new vgl.sourceDataP3fv,pntcnt=0,estpntcnt=2*coordinates.length,i=null,j=null,x=null,y=null,z=null,indices=null,vglline=null,thisLineLength=null;for(vglcoords.data().length=3*estpntcnt,j=0;ji;i++)indices.push(pntcnt),x=coordinates[j][i][0],y=coordinates[j][i][1],z=0,coordinates[j][i].length>2&&(z=coordinates[j][i][2]),vglcoords.insertAt(pntcnt,[x,y,z]),this.readScalars(coordinates[j][i],geom,2*estpntcnt,pntcnt),pntcnt++;vglline.setIndices(indices),geom.addPrimitive(vglline)}return geom.setName("aMultiLineString"),geom.addSource(vglcoords),geom},this.readPolygon=function(coordinates){var geom=new vgl.geometryData,vglcoords=new vgl.sourceDataP3fv,x=null,y=null,z=null,thisPolyLength=coordinates[0].length,vl=1,i=null,indices=null,vgltriangle=null;for(i=0;thisPolyLength>i;i++)x=coordinates[0][i][0],y=coordinates[0][i][1],z=0,coordinates[0][i].length>2&&(z=coordinates[0][i][2]),vglcoords.pushBack([x,y,z]),this.readScalars(coordinates[0][i],geom),i>1&&(indices=new Uint16Array([0,vl,i]),vgltriangle=new vgl.triangles,vgltriangle.setIndices(indices),geom.addPrimitive(vgltriangle),vl=i);return geom.setName("POLY"),geom.addSource(vglcoords),geom},this.readMultiPolygon=function(coordinates){var geom=new vgl.geometryData,vglcoords=new vgl.sourceDataP3fv,ccount=0,numPolys=coordinates.length,pntcnt=0,estpntcnt=3*numPolys,vgltriangle=new vgl.triangles,indexes=[],i=null,j=null,x=null,y=null,z=null,thisPolyLength=null,vf=null,vl=null,flip=null,flipped=!1,tcount=0;for(vglcoords.data().length=3*numPolys,j=0;numPolys>j;j++)for(thisPolyLength=coordinates[j][0].length,vf=ccount,vl=ccount+1,flip=[!1,!1,!1],i=0;thisPolyLength>i;i++)x=coordinates[j][0][i][0],y=coordinates[j][0][i][1],z=0,coordinates[j][0][i].length>2&&(z=coordinates[j][0][i][2]),flipped=!1,x>180&&(flipped=!0,x-=360),0===i?flip[0]=flipped:flip[1+(i-1)%2]=flipped,vglcoords.insertAt(pntcnt,[x,y,z]),this.readScalars(coordinates[j][0][i],geom,estpntcnt,pntcnt),pntcnt++,i>1&&(flip[0]===flip[1]&&flip[1]===flip[2]&&(indexes[3*tcount+0]=vf,indexes[3*tcount+1]=vl,indexes[3*tcount+2]=ccount,tcount++),vl=ccount),ccount++;return vgltriangle.setIndices(indexes),geom.addPrimitive(vgltriangle),geom.setName("aMultiPoly"),geom.addSource(vglcoords),geom},this.readGJObjectInt=function(object){if(!object.hasOwnProperty("type"))return null;object.properties&&object.properties.ScalarFormat&&"values"===object.properties.ScalarFormat&&(this.m_scalarFormat="values",object.properties.ScalarRange&&(this.m_scalarRange=object.properties.ScalarRange)),object.properties&&object.properties.ScalarFormat&&"rgb"===object.properties.ScalarFormat&&(this.m_scalarFormat="rgb");var ret,type=object.type,next=null,nextset=null,i=null;switch(type){case"Point":ret=this.readPoint(object.coordinates);break;case"MultiPoint":ret=this.readMultiPoint(object.coordinates);break;case"LineString":ret=this.readLineString(object.coordinates);break;case"MultiLineString":ret=this.readMultiLineString(object.coordinates);break;case"Polygon":ret=this.readPolygon(object.coordinates);break;case"MultiPolygon":ret=this.readMultiPolygon(object.coordinates);break;case"GeometryCollection":for(nextset=[],i=0;im_max)&&(m_max=value),(null===m_min||m_min>value)&&(m_min=value),this.data()[this.data().length]=value},this.insertAt=function(index,value){(null===m_max||value>m_max)&&(m_max=value),(null===m_min||m_min>value)&&(m_min=value),this.data()[index]=value},this.scalarRange=function(){return null===m_fixedmin||null===m_fixedmax?[m_min,m_max]:[m_fixedmin,m_fixedmax]},this.setScalarRange=function(min,max){m_fixedmin=min,m_fixedmax=max},this},inherit(vgl.sourceDataSf,vgl.sourceData),vgl.sourceDataDf=function(arg){"use strict";if(!(this instanceof vgl.sourceDataDf))return new vgl.sourceDataDf(arg);return vgl.sourceData.call(this,arg),this.addAttribute(vgl.vertexAttributeKeys.Scalar,gl.FLOAT,4,0,4,1,!1),this.pushBack=function(value){this.data()[this.data().length]=value},this.insertAt=function(index,value){this.data()[index]=value},this},inherit(vgl.sourceDataDf,vgl.sourceData),vgl.geometryData=function(){"use strict";if(!(this instanceof vgl.geometryData))return new vgl.geometryData;vgl.data.call(this);var m_name="",m_primitives=[],m_sources=[],m_bounds=[0,0,0,0,0,0],m_computeBoundsTimestamp=vgl.timestamp(),m_boundsDirtyTimestamp=vgl.timestamp();return this.type=function(){return vgl.data.geometry},this.name=function(){return m_name},this.setName=function(name){m_name=name},this.addSource=function(source,sourceName){return void 0!==sourceName&&source.setName(sourceName),-1===m_sources.indexOf(source)?(m_sources.push(source),source.hasKey(vgl.vertexAttributeKeys.Position)&&m_boundsDirtyTimestamp.modified(),!0):!1},this.source=function(index){return indexm_computeBoundsTimestamp.getMTime()&&this.computeBounds(),m_bounds},this.boundsDirty=function(dirty){return dirty&&m_boundsDirtyTimestamp.modified(),m_boundsDirtyTimestamp.getMTime()>m_computeBoundsTimestamp.getMTime()},this.resetBounds=function(){m_bounds[0]=0,m_bounds[1]=0,m_bounds[2]=0,m_bounds[3]=0,m_bounds[4]=0,m_bounds[5]=0},this.setBounds=function(minX,maxX,minY,maxY,minZ,maxZ){return m_bounds[0]=minX,m_bounds[1]=maxX,m_bounds[2]=minY,m_bounds[3]=maxY,m_bounds[4]=minZ,m_bounds[5]=maxZ,m_computeBoundsTimestamp.modified(),!0},this.computeBounds=function(){if(m_boundsDirtyTimestamp.getMTime()>m_computeBoundsTimestamp.getMTime()){var j,ib,jb,maxv,minv,vertexIndex,attr=vgl.vertexAttributeKeys.Position,sourceData=this.sourceData(attr),data=sourceData.data(),numberOfComponents=sourceData.attributeNumberOfComponents(attr),stride=sourceData.attributeStride(attr),offset=sourceData.attributeOffset(attr),sizeOfDataType=sourceData.sizeOfAttributeDataType(attr),count=data.length,value=null;for(stride/=sizeOfDataType,offset/=sizeOfDataType,this.resetBounds(),j=0;numberOfComponents>j;++j){for(ib=2*j,jb=2*j+1,maxv=minv=count?m_bounds[jb]=data[offset+j]:0,vertexIndex=offset+stride+j;count>vertexIndex;vertexIndex+=stride)value=data[vertexIndex],value>maxv&&(maxv=value),minv>value&&(minv=value);m_bounds[ib]=minv,m_bounds[jb]=maxv}m_computeBoundsTimestamp.modified()}},this.findClosestVertex=function(point){var vi,vPos,dx,dy,dz,dist,i,attr=vgl.vertexAttributeKeys.Position,sourceData=this.sourceData(attr),sizeOfDataType=sourceData.sizeOfAttributeDataType(attr),numberOfComponents=sourceData.attributeNumberOfComponents(attr),data=sourceData.data(),stride=sourceData.attributeStride(attr)/sizeOfDataType,offset=sourceData.attributeOffset(attr)/sizeOfDataType,minDist=Number.MAX_VALUE,minIndex=null;for(3!==numberOfComponents&&console.log("[warning] Find closest vertex assumes threecomponent vertex "),point.z||(point={x:point.x,y:point.y,z:0}),vi=offset,i=0;vidist&&(minDist=dist,minIndex=i);return minIndex},this.getPosition=function(index){var attr=vgl.vertexAttributeKeys.Position,sourceData=this.sourceData(attr),sizeOfDataType=sourceData.sizeOfAttributeDataType(attr),numberOfComponents=sourceData.attributeNumberOfComponents(attr),data=sourceData.data(),stride=sourceData.attributeStride(attr)/sizeOfDataType,offset=sourceData.attributeOffset(attr)/sizeOfDataType; +function inherit(C,P){"use strict";var F=function(){};F.prototype=P.prototype,C.prototype=new F,C.uber=P.prototype,C.prototype.constructor=C}var geo={};if(window.geo=geo,geo.renderers={},geo.features={},geo.fileReaders={},geo.inherit=function(C,P){"use strict";var F=inherit.func();F.prototype=P.prototype,C.prototype=new F,C.prototype.constructor=C},geo.inherit.func=function(){"use strict";return function(){}},window.inherit=geo.inherit,geo.registerFileReader=function(name,func){"use strict";void 0===geo.fileReaders&&(geo.fileReaders={}),geo.fileReaders[name]=func},geo.createFileReader=function(name,opts){"use strict";return geo.fileReaders.hasOwnProperty(name)?geo.fileReaders[name](opts):null},geo.registerRenderer=function(name,func){"use strict";void 0===geo.renderers&&(geo.renderers={}),geo.renderers[name]=func},geo.createRenderer=function(name,layer,canvas){"use strict";if(geo.renderers.hasOwnProperty(name)){var ren=geo.renderers[name]({layer:layer,canvas:canvas});return ren._init(),ren}return null},geo.registerFeature=function(category,name,func){"use strict";void 0===geo.features&&(geo.features={}),category in geo.features||(geo.features[category]={}),geo.features[category][name]=func},geo.createFeature=function(name,layer,renderer,arg){"use strict";var category=renderer.api(),options={layer:layer,renderer:renderer};return category in geo.features&&name in geo.features[category]?(void 0!==arg&&$.extend(!0,options,arg),geo.features[category][name](options)):null},geo.registerLayer=function(name,func){"use strict";void 0===geo.layers&&(geo.layers={}),geo.layers[name]=func},geo.createLayer=function(name,map,arg){"use strict";var options={map:map,renderer:"vgl"},layer=null;return name in geo.layers?(void 0!==arg&&$.extend(!0,options,arg),layer=geo.layers[name](options),layer._init(),layer):null},geo.registerWidget=function(category,name,func){"use strict";void 0===geo.widgets&&(geo.widgets={}),category in geo.widgets||(geo.widgets[category]={}),geo.widgets[category][name]=func},geo.createWidget=function(name,layer,renderer,arg){"use strict";var category=renderer.api(),options={layer:layer,renderer:renderer};return category in geo.widgets&&name in geo.widgets[category]?(void 0!==arg&&$.extend(!0,options,arg),geo.widgets[category][name](options)):null},window.requestAnimationFrame||(window.requestAnimationFrame=function(func){"use strict";window.setTimeout(func,15)}),Math.log2||(Math.log2=function(){"use strict";return Math.log.apply(Math,arguments)/Math.LN2}),geo.version="0.4.1","undefined"==typeof ogs)var ogs={};ogs.namespace=function(ns_string){"use strict";var i,parts=ns_string.split("."),parent=ogs;for("ogs"===parts[0]&&(parts=parts.slice(1)),i=0;ithis.computeBoundsTimestamp().getMTime()&&this.m_parent.boundsDirtyTimestamp.modified(),this.computeBounds(),visitor.mode()===visitor.TraverseAllChildren)for(i=0;ithis.boundsDirtyTimestamp().getMTime()))for(i=0;ii;++i)istep=2*i,jstep=2*i+1,childBounds[istep]bounds[jstep]&&(bounds[jstep]=childBounds[jstep]);this.setBounds(bounds[0],bounds[1],bounds[2],bounds[3],bounds[4],bounds[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 m_transformMatrix=mat4.create(),m_referenceFrame=vgl.boundingObject.ReferenceFrame.Relative,m_mapper=null;return this.matrix=function(){return m_transformMatrix},this.setMatrix=function(tmatrix){tmatrix!==m_transformMatrix&&(m_transformMatrix=tmatrix,this.modified())},this.referenceFrame=function(){return m_referenceFrame},this.setReferenceFrame=function(referenceFrame){return referenceFrame!==m_referenceFrame?(m_referenceFrame=referenceFrame,this.modified(),!0):!1},this.mapper=function(){return m_mapper},this.setMapper=function(mapper){mapper!==m_mapper&&(m_mapper=mapper,this.boundsModified())},this.accept=function(){},this.ascend=function(){},this.computeLocalToWorldMatrix=function(){},this.computeWorldToLocalMatrix=function(){},this.computeBounds=function(){if(null===m_mapper||void 0===m_mapper)return void this.resetBounds();var mapperBounds,minPt,maxPt,newBounds,computeBoundsTimestamp=this.computeBoundsTimestamp();(this.boundsDirtyTimestamp().getMTime()>computeBoundsTimestamp.getMTime()||m_mapper.boundsDirtyTimestamp().getMTime()>computeBoundsTimestamp.getMTime())&&(m_mapper.computeBounds(),mapperBounds=m_mapper.bounds(),minPt=[mapperBounds[0],mapperBounds[2],mapperBounds[4]],maxPt=[mapperBounds[1],mapperBounds[3],mapperBounds[5]],vec3.transformMat4(minPt,minPt,m_transformMatrix),vec3.transformMat4(maxPt,maxPt,m_transformMatrix),newBounds=[minPt[0]>maxPt[0]?maxPt[0]:minPt[0],minPt[0]>maxPt[0]?minPt[0]:maxPt[0],minPt[1]>maxPt[1]?maxPt[1]:minPt[1],minPt[1]>maxPt[1]?minPt[1]:maxPt[1],minPt[2]>maxPt[2]?maxPt[2]:minPt[2],minPt[2]>maxPt[2]?minPt[2]:maxPt[2]],this.setBounds(newBounds[0],newBounds[1],newBounds[2],newBounds[3],newBounds[4],newBounds[5]),computeBoundsTimestamp.modified())},this},inherit(vgl.actor,vgl.node),vgl.freezeObject=function(obj){"use strict";var freezedObject=Object.freeze(obj);return"undefined"==typeof freezedObject&&(freezedObject=function(o){return o}),freezedObject},vgl.defaultValue=function(a,b){"use strict";return"undefined"!=typeof a?a:b},vgl.defaultValue.EMPTY_OBJECT=vgl.freezeObject({}),vgl.geojsonReader=function(){"use strict";if(!(this instanceof vgl.geojsonReader))return new vgl.geojsonReader;return this.readScalars=function(coordinates,geom,size_estimate,idx){var array=null,s=null,r=null,g=null,b=null;"values"===this.m_scalarFormat&&4===coordinates.length?(s=coordinates[3],array=geom.sourceData(vgl.vertexAttributeKeys.Scalar),array||(array=new vgl.sourceDataSf,this.m_scalarRange&&array.setScalarRange(this.m_scalarRange[0],this.m_scalarRange[1]),void 0!==size_estimate&&(array.data().length=size_estimate),geom.addSource(array)),void 0===size_estimate?array.pushBack(s):array.insertAt(idx,s)):"rgb"===this.m_scalarFormat&&6===coordinates.length&&(array=geom.sourceData(vgl.vertexAttributeKeys.Color),array||(array=new vgl.sourceDataC3fv,void 0!==size_estimate&&(array.length=3*size_estimate),geom.addSource(array)),r=coordinates[3],g=coordinates[4],b=coordinates[5],void 0===size_estimate?array.pushBack([r,g,b]):array.insertAt(idx,[r,g,b]))},this.readPoint=function(coordinates){var geom=new vgl.geometryData,vglpoints=new vgl.points,vglcoords=new vgl.sourceDataP3fv,indices=new Uint16Array(1),x=null,y=null,z=null,i=null;for(geom.addSource(vglcoords),i=0;1>i;i++)indices[i]=i,x=coordinates[0],y=coordinates[1],z=0,coordinates.length>2&&(z=coordinates[2]),vglcoords.pushBack([x,y,z]),this.readScalars(coordinates,geom);return vglpoints.setIndices(indices),geom.addPrimitive(vglpoints),geom.setName("aPoint"),geom},this.readMultiPoint=function(coordinates){var i,geom=new vgl.geometryData,vglpoints=new vgl.points,vglcoords=new vgl.sourceDataP3fv,indices=new Uint16Array(coordinates.length),pntcnt=0,estpntcnt=coordinates.length,x=null,y=null,z=null;for(vglcoords.data().length=3*estpntcnt,i=0;i2&&(z=coordinates[i][2]),vglcoords.insertAt(pntcnt,[x,y,z]),this.readScalars(coordinates[i],geom,estpntcnt,pntcnt),pntcnt++;return vglpoints.setIndices(indices),geom.addPrimitive(vglpoints),geom.addSource(vglcoords),geom.setName("manyPoints"),geom},this.readLineString=function(coordinates){var geom=new vgl.geometryData,vglline=new vgl.lineStrip,vglcoords=new vgl.sourceDataP3fv,indices=[],i=null,x=null,y=null,z=null;for(vglline.setIndicesPerPrimitive(coordinates.length),i=0;i2&&(z=coordinates[i][2]),vglcoords.pushBack([x,y,z]),this.readScalars(coordinates[i],geom);return vglline.setIndices(indices),geom.addPrimitive(vglline),geom.addSource(vglcoords),geom.setName("aLineString"),geom},this.readMultiLineString=function(coordinates){var geom=new vgl.geometryData,vglcoords=new vgl.sourceDataP3fv,pntcnt=0,estpntcnt=2*coordinates.length,i=null,j=null,x=null,y=null,z=null,indices=null,vglline=null,thisLineLength=null;for(vglcoords.data().length=3*estpntcnt,j=0;ji;i++)indices.push(pntcnt),x=coordinates[j][i][0],y=coordinates[j][i][1],z=0,coordinates[j][i].length>2&&(z=coordinates[j][i][2]),vglcoords.insertAt(pntcnt,[x,y,z]),this.readScalars(coordinates[j][i],geom,2*estpntcnt,pntcnt),pntcnt++;vglline.setIndices(indices),geom.addPrimitive(vglline)}return geom.setName("aMultiLineString"),geom.addSource(vglcoords),geom},this.readPolygon=function(coordinates){var geom=new vgl.geometryData,vglcoords=new vgl.sourceDataP3fv,x=null,y=null,z=null,thisPolyLength=coordinates[0].length,vl=1,i=null,indices=null,vgltriangle=null;for(i=0;thisPolyLength>i;i++)x=coordinates[0][i][0],y=coordinates[0][i][1],z=0,coordinates[0][i].length>2&&(z=coordinates[0][i][2]),vglcoords.pushBack([x,y,z]),this.readScalars(coordinates[0][i],geom),i>1&&(indices=new Uint16Array([0,vl,i]),vgltriangle=new vgl.triangles,vgltriangle.setIndices(indices),geom.addPrimitive(vgltriangle),vl=i);return geom.setName("POLY"),geom.addSource(vglcoords),geom},this.readMultiPolygon=function(coordinates){var geom=new vgl.geometryData,vglcoords=new vgl.sourceDataP3fv,ccount=0,numPolys=coordinates.length,pntcnt=0,estpntcnt=3*numPolys,vgltriangle=new vgl.triangles,indexes=[],i=null,j=null,x=null,y=null,z=null,thisPolyLength=null,vf=null,vl=null,flip=null,flipped=!1,tcount=0;for(vglcoords.data().length=3*numPolys,j=0;numPolys>j;j++)for(thisPolyLength=coordinates[j][0].length,vf=ccount,vl=ccount+1,flip=[!1,!1,!1],i=0;thisPolyLength>i;i++)x=coordinates[j][0][i][0],y=coordinates[j][0][i][1],z=0,coordinates[j][0][i].length>2&&(z=coordinates[j][0][i][2]),flipped=!1,x>180&&(flipped=!0,x-=360),0===i?flip[0]=flipped:flip[1+(i-1)%2]=flipped,vglcoords.insertAt(pntcnt,[x,y,z]),this.readScalars(coordinates[j][0][i],geom,estpntcnt,pntcnt),pntcnt++,i>1&&(flip[0]===flip[1]&&flip[1]===flip[2]&&(indexes[3*tcount+0]=vf,indexes[3*tcount+1]=vl,indexes[3*tcount+2]=ccount,tcount++),vl=ccount),ccount++;return vgltriangle.setIndices(indexes),geom.addPrimitive(vgltriangle),geom.setName("aMultiPoly"),geom.addSource(vglcoords),geom},this.readGJObjectInt=function(object){if(!object.hasOwnProperty("type"))return null;object.properties&&object.properties.ScalarFormat&&"values"===object.properties.ScalarFormat&&(this.m_scalarFormat="values",object.properties.ScalarRange&&(this.m_scalarRange=object.properties.ScalarRange)),object.properties&&object.properties.ScalarFormat&&"rgb"===object.properties.ScalarFormat&&(this.m_scalarFormat="rgb");var ret,type=object.type,next=null,nextset=null,i=null;switch(type){case"Point":ret=this.readPoint(object.coordinates);break;case"MultiPoint":ret=this.readMultiPoint(object.coordinates);break;case"LineString":ret=this.readLineString(object.coordinates);break;case"MultiLineString":ret=this.readMultiLineString(object.coordinates);break;case"Polygon":ret=this.readPolygon(object.coordinates);break;case"MultiPolygon":ret=this.readMultiPolygon(object.coordinates);break;case"GeometryCollection":for(nextset=[],i=0;im_max)&&(m_max=value),(null===m_min||m_min>value)&&(m_min=value),this.data()[this.data().length]=value},this.insertAt=function(index,value){(null===m_max||value>m_max)&&(m_max=value),(null===m_min||m_min>value)&&(m_min=value),this.data()[index]=value},this.scalarRange=function(){return null===m_fixedmin||null===m_fixedmax?[m_min,m_max]:[m_fixedmin,m_fixedmax]},this.setScalarRange=function(min,max){m_fixedmin=min,m_fixedmax=max},this},inherit(vgl.sourceDataSf,vgl.sourceData),vgl.sourceDataDf=function(arg){"use strict";if(!(this instanceof vgl.sourceDataDf))return new vgl.sourceDataDf(arg);return vgl.sourceData.call(this,arg),this.addAttribute(vgl.vertexAttributeKeys.Scalar,gl.FLOAT,4,0,4,1,!1),this.pushBack=function(value){this.data()[this.data().length]=value},this.insertAt=function(index,value){this.data()[index]=value},this},inherit(vgl.sourceDataDf,vgl.sourceData),vgl.geometryData=function(){"use strict";if(!(this instanceof vgl.geometryData))return new vgl.geometryData;vgl.data.call(this);var m_name="",m_primitives=[],m_sources=[],m_bounds=[0,0,0,0,0,0],m_computeBoundsTimestamp=vgl.timestamp(),m_boundsDirtyTimestamp=vgl.timestamp();return this.type=function(){return vgl.data.geometry},this.name=function(){return m_name},this.setName=function(name){m_name=name},this.addSource=function(source,sourceName){return void 0!==sourceName&&source.setName(sourceName),-1===m_sources.indexOf(source)?(m_sources.push(source),source.hasKey(vgl.vertexAttributeKeys.Position)&&m_boundsDirtyTimestamp.modified(),!0):!1},this.source=function(index){return indexm_computeBoundsTimestamp.getMTime()&&this.computeBounds(),m_bounds},this.boundsDirty=function(dirty){return dirty&&m_boundsDirtyTimestamp.modified(),m_boundsDirtyTimestamp.getMTime()>m_computeBoundsTimestamp.getMTime()},this.resetBounds=function(){m_bounds[0]=0,m_bounds[1]=0,m_bounds[2]=0,m_bounds[3]=0,m_bounds[4]=0,m_bounds[5]=0},this.setBounds=function(minX,maxX,minY,maxY,minZ,maxZ){return m_bounds[0]=minX,m_bounds[1]=maxX,m_bounds[2]=minY,m_bounds[3]=maxY,m_bounds[4]=minZ,m_bounds[5]=maxZ,m_computeBoundsTimestamp.modified(),!0},this.computeBounds=function(){if(m_boundsDirtyTimestamp.getMTime()>m_computeBoundsTimestamp.getMTime()){var j,ib,jb,maxv,minv,vertexIndex,attr=vgl.vertexAttributeKeys.Position,sourceData=this.sourceData(attr),data=sourceData.data(),numberOfComponents=sourceData.attributeNumberOfComponents(attr),stride=sourceData.attributeStride(attr),offset=sourceData.attributeOffset(attr),sizeOfDataType=sourceData.sizeOfAttributeDataType(attr),count=data.length,value=null;for(stride/=sizeOfDataType,offset/=sizeOfDataType,this.resetBounds(),j=0;numberOfComponents>j;++j){for(ib=2*j,jb=2*j+1,maxv=minv=count?m_bounds[jb]=data[offset+j]:0,vertexIndex=offset+stride+j;count>vertexIndex;vertexIndex+=stride)value=data[vertexIndex],value>maxv&&(maxv=value),minv>value&&(minv=value);m_bounds[ib]=minv,m_bounds[jb]=maxv}m_computeBoundsTimestamp.modified()}},this.findClosestVertex=function(point){var vi,vPos,dx,dy,dz,dist,i,attr=vgl.vertexAttributeKeys.Position,sourceData=this.sourceData(attr),sizeOfDataType=sourceData.sizeOfAttributeDataType(attr),numberOfComponents=sourceData.attributeNumberOfComponents(attr),data=sourceData.data(),stride=sourceData.attributeStride(attr)/sizeOfDataType,offset=sourceData.attributeOffset(attr)/sizeOfDataType,minDist=Number.MAX_VALUE,minIndex=null;for(3!==numberOfComponents&&console.log("[warning] Find closest vertex assumes threecomponent vertex "),point.z||(point={x:point.x,y:point.y,z:0}),vi=offset,i=0;vidist&&(minDist=dist,minIndex=i);return minIndex},this.getPosition=function(index){var attr=vgl.vertexAttributeKeys.Position,sourceData=this.sourceData(attr),sizeOfDataType=sourceData.sizeOfAttributeDataType(attr),numberOfComponents=sourceData.attributeNumberOfComponents(attr),data=sourceData.data(),stride=sourceData.attributeStride(attr)/sizeOfDataType,offset=sourceData.attributeOffset(attr)/sizeOfDataType; return 3!==numberOfComponents&&console.log("[warning] getPosition assumes three component data"),[data[offset+index*stride],data[offset+index*stride+1],data[offset+index*stride+2]]},this.getScalar=function(index){var numberOfComponents,sizeOfDataType,data,stride,offset,attr=vgl.vertexAttributeKeys.Scalar,sourceData=this.sourceData(attr);return sourceData?(numberOfComponents=sourceData.attributeNumberOfComponents(attr),sizeOfDataType=sourceData.sizeOfAttributeDataType(attr),data=sourceData.data(),stride=sourceData.attributeStride(attr)/sizeOfDataType,offset=sourceData.attributeOffset(attr)/sizeOfDataType,index*stride+offset>=data.length&&console.log("access out of bounds in getScalar"),data[index*stride+offset]):null},this},inherit(vgl.geometryData,vgl.data),vgl.mapper=function(arg){"use strict";function deleteVertexBufferObjects(){var i;for(i=0;ii;++i){for(bufferId=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,bufferId),data=m_geomData.source(i).data(),data instanceof Float32Array||(data=new Float32Array(data)),gl.bufferData(gl.ARRAY_BUFFER,data,m_dynamicDraw?gl.DYNAMIC_DRAW:gl.STATIC_DRAW),keys=m_geomData.source(i).keys(),ks=[],j=0;jk;++k)bufferId=gl.createBuffer(),gl.bindBuffer(gl.ARRAY_BUFFER,bufferId),gl.bufferData(gl.ARRAY_BUFFER,m_geomData.primitive(k).indices(),gl.STATIC_DRAW),m_buffers[i++]=bufferId;m_glCompileTimestamp.modified()}}function cleanUpDrawObjects(){m_bufferVertexAttributeMap={},m_buffers=[]}function setupDrawObjects(){deleteVertexBufferObjects(),cleanUpDrawObjects(),createVertexBufferObjects(),m_dirty=!1}if(!(this instanceof vgl.mapper))return new vgl.mapper(arg);vgl.boundingObject.call(this),arg=arg||{};var m_dirty=!0,m_color=[0,1,1],m_geomData=null,m_buffers=[],m_bufferVertexAttributeMap={},m_dynamicDraw=void 0===arg.dynamicDraw?!1:arg.dynamicDraw,m_glCompileTimestamp=vgl.timestamp();return this.computeBounds=function(){if(null===m_geomData||"undefined"==typeof m_geomData)return void this.resetBounds();var computeBoundsTimestamp=this.computeBoundsTimestamp(),boundsDirtyTimestamp=this.boundsDirtyTimestamp(),geomBounds=null;boundsDirtyTimestamp.getMTime()>computeBoundsTimestamp.getMTime()&&(geomBounds=m_geomData.bounds(),this.setBounds(geomBounds[0],geomBounds[1],geomBounds[2],geomBounds[3],geomBounds[4],geomBounds[5]),computeBoundsTimestamp.modified())},this.color=function(){return m_color},this.setColor=function(r,g,b){m_color[0]=r,m_color[1]=g,m_color[2]=b,this.modified()},this.geometryData=function(){return m_geomData},this.setGeometryData=function(geom){m_geomData!==geom&&(m_geomData=geom,this.modified(),this.boundsDirtyTimestamp().modified())},this.updateSourceBuffer=function(sourceName,values){for(var bufferIndex=-1,i=0;ibufferIndex||bufferIndex>=m_buffers.length?!1:(values||(values=m_geomData.source(i).dataToFloat32Array()),gl.bindBuffer(gl.ARRAY_BUFFER,m_buffers[bufferIndex]),values instanceof Float32Array?gl.bufferSubData(gl.ARRAY_BUFFER,0,values):gl.bufferSubData(gl.ARRAY_BUFFER,0,new Float32Array(values)),!0)},this.getSourceBuffer=function(sourceName){var source=m_geomData.sourceByName(sourceName);return source?source.dataToFloat32Array():new Float32Array},this.render=function(renderState){this.getMTime()>m_glCompileTimestamp.getMTime()&&setupDrawObjects(renderState),gl.vertexAttrib3fv(vgl.vertexAttributeKeys.Color,this.color());var i,bufferIndex=0,j=0,noOfPrimitives=null,primitive=null;for(i in m_bufferVertexAttributeMap)if(m_bufferVertexAttributeMap.hasOwnProperty(i)){for(gl.bindBuffer(gl.ARRAY_BUFFER,m_buffers[bufferIndex]),j=0;jj;++j){switch(gl.bindBuffer(gl.ARRAY_BUFFER,m_buffers[bufferIndex++]),primitive=m_geomData.primitive(j),primitive.primitiveType()){case gl.POINTS:gl.drawArrays(gl.POINTS,0,primitive.numberOfIndices());break;case gl.LINES:gl.drawArrays(gl.LINES,0,primitive.numberOfIndices());break;case gl.LINE_STRIP:gl.drawArrays(gl.LINE_STRIP,0,primitive.numberOfIndices());break;case gl.TRIANGLES:gl.drawArrays(gl.TRIANGLES,0,primitive.numberOfIndices());break;case gl.TRIANGLE_STRIP:gl.drawArrays(gl.TRIANGLE_STRIP,0,primitive.numberOfIndices())}gl.bindBuffer(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 m_createMappersTimestamp=vgl.timestamp(),m_mappers=[],m_geomDataArray=[];return this.geometryData=function(index){return void 0!==index&&index0?m_geomDataArray[0]:null},this.setGeometryData=function(geom){(1!==m_geomDataArray.length||m_geomDataArray[0]!==geom)&&(m_geomDataArray=[],m_geomDataArray.push(geom),this.modified())},this.geometryDataArray=function(){return m_geomDataArray},this.setGeometryDataArray=function(geoms){if(geoms instanceof Array){if(m_geomDataArray!==geoms)return m_geomDataArray=[],m_geomDataArray=geoms,this.modified(),!0}else console.log("[error] Requies array of geometry data");return!1},this.computeBounds=function(){if(null===m_geomDataArray||void 0===m_geomDataArray)return void this.resetBounds();var computeBoundsTimestamp=this.computeBoundsTimestamp(),boundsDirtyTimestamp=this.boundsDirtyTimestamp(),m_bounds=this.bounds(),geomBounds=null,i=null;if(boundsDirtyTimestamp.getMTime()>computeBoundsTimestamp.getMTime()){for(i=0;igeomBounds[0]&&(m_bounds[0]=geomBounds[0]),m_bounds[1]geomBounds[2]&&(m_bounds[2]=geomBounds[2]),m_bounds[3]geomBounds[4]&&(m_bounds[4]=geomBounds[4]),m_bounds[5]m_createMappersTimestamp.getMTime()){for(i=0;i0&&m_resetScene&&(this.resetCamera(),m_resetScene=!1),i=0;idiagonals[1]?diagonals[0]>diagonals[2]?diagonals[0]/2:diagonals[2]/2:diagonals[1]>diagonals[2]?diagonals[1]/2:diagonals[2]/2,angle=aspect>=1?2*Math.atan(Math.tan(.5*angle)/aspect):2*Math.atan(Math.tan(.5*angle)*aspect),distance=radius/Math.sin(.5*angle),vup=m_camera.viewUpDirection(),Math.abs(vec3.dot(vup,vn))>.999&&m_camera.setViewUpDirection(-vup[2],vup[0],vup[1]),m_camera.setFocalPoint(center[0],center[1],center[2]),m_camera.setPosition(center[0]+distance*-vn[0],center[1]+distance*-vn[1],center[2]+distance*-vn[2]),this.resetCameraClippingRange(visibleBounds)},this.hasValidBounds=function(bounds){return bounds[0]==Number.MAX_VALUE||bounds[1]==-Number.MAX_VALUE||bounds[2]==Number.MAX_VALUE||bounds[3]==-Number.MAX_VALUE||bounds[4]==Number.MAX_VALUE||bounds[5]==-Number.MAX_VALUE?!1:!0},this.resetCameraClippingRange=function(bounds){if("undefined"==typeof bounds&&(m_camera.computeBounds(),bounds=m_camera.bounds()),this.hasValidBounds(bounds)){var vn=m_camera.viewPlaneNormal(),position=m_camera.position(),a=-vn[0],b=-vn[1],c=-vn[2],d=-(a*position[0]+b*position[1]+c*position[2]),range=vec2.create(),dist=null,i=null,j=null,k=null;if(m_resetClippingRange){for(range[0]=a*bounds[0]+b*bounds[2]+c*bounds[4]+d,range[1]=1e-18,k=0;2>k;k++)for(j=0;2>j;j++)for(i=0;2>i;i++)dist=a*bounds[i]+b*bounds[2+j]+c*bounds[4+k]+d,range[0]=distrange[1]?dist:range[1];range[0]<0&&(range[0]=0),range[0]=.99*range[0]-.5*(range[1]-range[0]),range[1]=1.01*range[1]+.5*(range[1]-range[0]),range[0]=range[0]>=range[1]?.01*range[1]:range[0],m_nearClippingPlaneTolerance||(m_nearClippingPlaneTolerance=.01,null!==gl&&gl.getParameter(gl.DEPTH_BITS)>16&&(m_nearClippingPlaneTolerance=.001)),range[0]x||0>y||0>width||0>height)&&console.log("[error] Invalid position and resize values",x,y,width,height),m_resizable&&(m_width=width,m_height=height,m_camera.setViewAspect(m_width/m_height),this.modified())},this.addActor=function(actor){return actor instanceof vgl.actor?(m_sceneRoot.addChild(actor),this.modified(),!0):!1},this.hasActor=function(actor){return m_sceneRoot.hasChild(actor)},this.addActors=function(actors){var i=null;if(actors instanceof Array){for(i=0;im_width||0===m_renderers[i].width()||m_renderers[i].height()>m_height||0===m_renderers[i].height())&&m_renderers[i].resize(m_x,m_y,m_width,m_height);return!0}catch(e){}return gl||console("[ERROR] Unable to initialize WebGL. Your browser may not support it."),!1},this.deleteWindow=function(){},this.render=function(){var i;for(m_renderers.sort(function(a,b){return a.layer()-b.layer()}),i=0;iwidth?(m_currPos.x=0,m_outsideCanvas=!0):m_currPos.x=coords.x,coords.y<0||coords.y>height?(m_currPos.y=0,m_outsideCanvas=!0):m_currPos.y=coords.y,m_outsideCanvas!==!0?(fp=cam.focalPoint(),fwp=vec4.fromValues(fp[0],fp[1],fp[2],1),fdp=ren.worldToDisplay(fwp,cam.viewMatrix(),cam.projectionMatrix(),width,height),dp1=vec4.fromValues(m_currPos.x,m_currPos.y,fdp[2],1),dp2=vec4.fromValues(m_lastPos.x,m_lastPos.y,fdp[2],1),wp1=ren.displayToWorld(dp1,cam.viewMatrix(),cam.projectionMatrix(),width,height),wp2=ren.displayToWorld(dp2,cam.viewMatrix(),cam.projectionMatrix(),width,height),dx=wp1[0]-wp2[0],dy=wp1[1]-wp2[1],dz=wp1[2]-wp2[2],m_midMouseBtnDown&&(cam.pan(-dx,-dy,-dz),m_that.viewer().render()),m_leftMouseBtnDown&&(cam.rotate(m_lastPos.x-m_currPos.x,m_lastPos.y-m_currPos.y),ren.resetCameraClippingRange(),m_that.viewer().render()),m_rightMouseBtnDown&&(m_zTrans=2*(m_currPos.y-m_lastPos.y)/height,cam.zoom(m_zTrans>0?1-Math.abs(m_zTrans):1+Math.abs(m_zTrans)),ren.resetCameraClippingRange(),m_that.viewer().render()),m_lastPos.x=m_currPos.x,m_lastPos.y=m_currPos.y,!1):void 0},this.handleMouseDown=function(event){var coords;return 0===event.button&&(m_leftMouseBtnDown=!0),1===event.button&&(m_midMouseBtnDown=!0),2===event.button&&(m_rightMouseBtnDown=!0),coords=m_that.view.relMouseCoords(event),m_lastPos.x=coords.x<0?0:coords.x,m_lastPos.y=coords.y<0?0:coords.y,!1},this.handleMouseUp=function(event){return 0===event.button&&(m_leftMouseBtnDown=!1),1===event.button&&(m_midMouseBtnDown=!1),2===event.button&&(m_rightMouseBtnDown=!1),!1},this.handleMouseWheel=function(event){var ren=m_that.viewer().renderWindow().activeRenderer(),cam=ren.camera();return cam.zoom(event.originalEvent.wheelDelta<0?.9:1.1),ren.resetCameraClippingRange(),m_that.viewer().render(),!0},this},inherit(vgl.trackballInteractorStyle,vgl.interactorStyle),vgl.pvwInteractorStyle=function(){"use strict";function render(){m_renderer.resetCameraClippingRange(),m_that.viewer().render()}if(!(this instanceof vgl.pvwInteractorStyle))return new vgl.pvwInteractorStyle;vgl.trackballInteractorStyle.call(this);var m_width,m_height,m_renderer,m_camera,m_outsideCanvas,m_coords,m_currentMousePos,m_focalPoint,m_focusWorldPt,m_focusDisplayPt,m_displayPt1,m_displayPt2,m_worldPt1,m_worldPt2,m_dx,m_dy,m_dz,m_zTrans,m_that=this,m_leftMouseButtonDown=!1,m_rightMouseButtonDown=!1,m_middleMouseButtonDown=!1,m_mouseLastPos={ x:0,y:0};return this.handleMouseMove=function(event){var rens=[],i=null,secCameras=[],deltaxy=null;for(m_width=m_that.viewer().renderWindow().windowSize()[0],m_height=m_that.viewer().renderWindow().windowSize()[1],m_renderer=m_that.viewer().renderWindow().activeRenderer(),m_camera=m_renderer.camera(),m_outsideCanvas=!1,m_coords=m_that.viewer().relMouseCoords(event),m_currentMousePos={x:0,y:0},rens=m_that.viewer().renderWindow().renderers(),i=0;im_width?(m_currentMousePos.x=0,m_outsideCanvas=!0):m_currentMousePos.x=m_coords.x,m_coords.y<0||m_coords.y>m_height?(m_currentMousePos.y=0,m_outsideCanvas=!0):m_currentMousePos.y=m_coords.y,m_outsideCanvas!==!0){if(m_focalPoint=m_camera.focalPoint(),m_focusWorldPt=vec4.fromValues(m_focalPoint[0],m_focalPoint[1],m_focalPoint[2],1),m_focusDisplayPt=m_renderer.worldToDisplay(m_focusWorldPt,m_camera.viewMatrix(),m_camera.projectionMatrix(),m_width,m_height),m_displayPt1=vec4.fromValues(m_currentMousePos.x,m_currentMousePos.y,m_focusDisplayPt[2],1),m_displayPt2=vec4.fromValues(m_mouseLastPos.x,m_mouseLastPos.y,m_focusDisplayPt[2],1),m_worldPt1=m_renderer.displayToWorld(m_displayPt1,m_camera.viewMatrix(),m_camera.projectionMatrix(),m_width,m_height),m_worldPt2=m_renderer.displayToWorld(m_displayPt2,m_camera.viewMatrix(),m_camera.projectionMatrix(),m_width,m_height),m_dx=m_worldPt1[0]-m_worldPt2[0],m_dy=m_worldPt1[1]-m_worldPt2[1],m_dz=m_worldPt1[2]-m_worldPt2[2],m_middleMouseButtonDown&&(m_camera.pan(-m_dx,-m_dy,-m_dz),render()),m_leftMouseButtonDown){for(deltaxy=[m_mouseLastPos.x-m_currentMousePos.x,m_mouseLastPos.y-m_currentMousePos.y],m_camera.rotate(deltaxy[0],deltaxy[1]),i=0;i0?1-Math.abs(m_zTrans):1+Math.abs(m_zTrans)),render()),m_mouseLastPos.x=m_currentMousePos.x,m_mouseLastPos.y=m_currentMousePos.y,!1}},this.handleMouseDown=function(event){return 0===event.button&&(m_leftMouseButtonDown=!0),1===event.button&&(m_middleMouseButtonDown=!0),2===event.button&&(m_rightMouseButtonDown=!0),m_coords=m_that.viewer().relMouseCoords(event),m_mouseLastPos.x=m_coords.x<0?0:m_coords.x,m_mouseLastPos.y=m_coords.y<0?0:m_coords.y,!1},this.handleMouseUp=function(event){m_that.viewer().canvas();return 0===event.button&&(m_leftMouseButtonDown=!1),1===event.button&&(m_middleMouseButtonDown=!1),2===event.button&&(m_rightMouseButtonDown=!1),!1},this},inherit(vgl.pvwInteractorStyle,vgl.trackballInteractorStyle),vgl.viewer=function(canvas){"use strict";if(!(this instanceof vgl.viewer))return new vgl.viewer(canvas);vgl.object.call(this);var m_that=this,m_canvas=canvas,m_ready=!0,m_interactorStyle=null,m_renderer=vgl.renderer(),m_renderWindow=vgl.renderWindow(m_canvas);return this.canvas=function(){return m_canvas},this.renderWindow=function(){return m_renderWindow},this.init=function(){null!==m_renderWindow?m_renderWindow.createWindow():console.log("[ERROR] No render window attached")},this.interactorStyle=function(){return m_interactorStyle},this.setInteractorStyle=function(style){style!==m_interactorStyle&&(m_interactorStyle=style,m_interactorStyle.setViewer(this),this.modified())},this.handleMouseDown=function(event){if(m_ready===!0){var fixedEvent=$.event.fix(event||window.event);2===event.button&&fixedEvent.preventDefault(),fixedEvent.state="down",fixedEvent.type=vgl.event.mousePress,$(m_that).trigger(fixedEvent)}return!0},this.handleMouseUp=function(event){if(m_ready===!0){var fixedEvent=$.event.fix(event||window.event);fixedEvent.preventDefault(),fixedEvent.state="up",fixedEvent.type=vgl.event.mouseRelease,$(m_that).trigger(fixedEvent)}return!0},this.handleMouseMove=function(event){if(m_ready===!0){var fixedEvent=$.event.fix(event||window.event);fixedEvent.preventDefault(),fixedEvent.type=vgl.event.mouseMove,$(m_that).trigger(fixedEvent)}return!0},this.handleMouseWheel=function(event){if(m_ready===!0){var fixedEvent=$.event.fix(event||window.event);fixedEvent.preventDefault(),fixedEvent.type=vgl.event.mouseWheel,$(m_that).trigger(fixedEvent)}return!0},this.handleMouseOut=function(event){if(m_ready===!0){var fixedEvent=$.event.fix(event||window.event);fixedEvent.preventDefault(),fixedEvent.type=vgl.event.mouseOut,$(m_that).trigger(fixedEvent)}return!0},this.handleKeyPress=function(event){if(m_ready===!0){var fixedEvent=$.event.fix(event||window.event);fixedEvent.preventDefault(),fixedEvent.type=vgl.event.keyPress,$(m_that).trigger(fixedEvent)}return!0},this.handleContextMenu=function(event){if(m_ready===!0){var fixedEvent=$.event.fix(event||window.event);fixedEvent.preventDefault(),fixedEvent.type=vgl.event.contextMenu,$(m_that).trigger(fixedEvent)}return!1},this.handleClick=function(event){if(m_ready===!0){var fixedEvent=$.event.fix(event||window.event);fixedEvent.preventDefault(),fixedEvent.type=vgl.event.click,$(m_that).trigger(fixedEvent)}return!1},this.handleDoubleClick=function(event){if(m_ready===!0){var fixedEvent=$.event.fix(event||window.event);fixedEvent.preventDefault(),fixedEvent.type=vgl.event.dblClick,$(m_that).trigger(fixedEvent)}return!1},this.relMouseCoords=function(event){if(void 0===event.pageX||void 0===event.pageY)throw"Missing attributes pageX and pageY on the event";var totalOffsetX=0,totalOffsetY=0,canvasX=0,canvasY=0,currentElement=m_canvas;do totalOffsetX+=currentElement.offsetLeft-currentElement.scrollLeft,totalOffsetY+=currentElement.offsetTop-currentElement.scrollTop;while(currentElement=currentElement.offsetParent);return canvasX=event.pageX-totalOffsetX,canvasY=event.pageY-totalOffsetY,{x:canvasX,y:canvasY}},this.render=function(){m_renderWindow.render()},this.bindEventHandlers=function(){$(m_canvas).on("mousedown",this.handleMouseDown),$(m_canvas).on("mouseup",this.handleMouseUp),$(m_canvas).on("mousemove",this.handleMouseMove),$(m_canvas).on("mousewheel",this.handleMouseWheel),$(m_canvas).on("contextmenu",this.handleContextMenu)},this.unbindEventHandlers=function(){$(m_canvas).off("mousedown",this.handleMouseDown),$(m_canvas).off("mouseup",this.handleMouseUp),$(m_canvas).off("mousemove",this.handleMouseMove),$(m_canvas).off("mousewheel",this.handleMouseWheel),$(m_canvas).off("contextmenu",this.handleContextMenu)},this._init=function(){this.bindEventHandlers(),m_renderWindow.addRenderer(m_renderer)},this._init(),this},inherit(vgl.viewer,vgl.object),vgl.shader=function(type){"use strict";if(!(this instanceof vgl.shader))return new vgl.shader(type);vgl.object.call(this);var m_shaderHandle=null,m_compileTimestamp=vgl.timestamp(),m_shaderType=type,m_shaderSource="";this.shaderHandle=function(){return m_shaderHandle},this.shaderType=function(){return m_shaderType},this.shaderSource=function(){return m_shaderSource},this.setShaderSource=function(source){m_shaderSource=source,this.modified()},this.compile=function(){return this.getMTime()-1)return!1;var i;for(i=0;i-1?!1:(m_uniforms.push(uniform),void this.modified())},this.addVertexAttribute=function(attr,key){m_vertexAttributes[key]=attr,this.modified()},this.uniformLocation=function(name){return m_uniformNameToLocation[name]},this.attributeLocation=function(name){return m_vertexAttributeNameToLocation[name]},this.uniform=function(name){var i;for(i=0;im_setupTimestamp.getMTime()&&this.setup(renderState),activateTextureUnit(),gl.bindTexture(gl.TEXTURE_2D,this.m_textureHandle)},this.undoBind=function(){gl.bindTexture(gl.TEXTURE_2D,null)},this.image=function(){return this.m_image},this.setImage=function(image){return null!==image?(this.m_image=image,this.updateDimensions(),this.modified(),!0):!1},this.textureUnit=function(){return this.m_textureUnit},this.setTextureUnit=function(unit){return this.m_textureUnit===unit?!1:(this.m_textureUnit=unit,this.modified(),!0)},this.width=function(){return this.m_width},this.setWidth=function(width){return null===this.m_image?!1:(this.m_width=width,this.modified(),!0)},this.depth=function(){return this.m_depth},this.setDepth=function(depth){return null===this.m_image?!1:(this.m_depth=depth,this.modified(),!0)},this.textureHandle=function(){return this.m_textureHandle},this.internalFormat=function(){return this.m_internalFormat},this.setInternalFormat=function(internalFormat){return this.m_internalFormat!==internalFormat?(this.m_internalFormat=internalFormat,this.modified(),!0):!1},this.pixelFormat=function(){return this.m_pixelFormat},this.setPixelFormat=function(pixelFormat){return null===this.m_image?!1:(this.m_pixelFormat=pixelFormat,this.modified(),!0)},this.pixelDataType=function(){return this.m_pixelDataType},this.setPixelDataType=function(pixelDataType){return null===this.m_image?!1:(this.m_pixelDataType=pixelDataType,this.modified(),!0)},this.computeInternalFormatUsingImage=function(){this.m_internalFormat=gl.RGBA,this.m_pixelFormat=gl.RGBA,this.m_pixelDataType=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 m_setupTimestamp=vgl.timestamp(),m_range=[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(x){return 255*x}),this.setup=function(){0===this.textureUnit()?gl.activeTexture(gl.TEXTURE0):1===this.textureUnit()&&gl.activeTexture(gl.TEXTURE1),gl.deleteTexture(this.m_textureHandle),this.m_textureHandle=gl.createTexture(),gl.bindTexture(gl.TEXTURE_2D,this.m_textureHandle),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.LINEAR),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.LINEAR),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE),gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE),gl.pixelStorei(gl.UNPACK_ALIGNMENT,1),this.m_width=this.m_colorTable.length/4,this.m_height=1,this.m_depth=0,gl.texImage2D(gl.TEXTURE_2D,0,gl.RGBA,this.m_width,this.m_height,this.m_depth,gl.RGBA,gl.UNSIGNED_BYTE,new Uint8Array(this.m_colorTable)),gl.bindTexture(gl.TEXTURE_2D,null),m_setupTimestamp.modified()},this.colorTable=function(){return this.m_colorTable},this.setColorTable=function(colors){return this.m_colorTable===colors?!1:(this.m_colorTable=colors,this.modified(),!0)},this.range=function(){return m_range},this.setRange=function(range){return m_range===range?!1:(m_range=range,this.modified(),!0)},this.updateRange=function(range){range instanceof Array||console.log("[error] Invalid data type for range. Requires array [min,max]"),range[0]m_range[1]&&(m_range[1]=range[1],this.modified())},this},inherit(vgl.lookupTable,vgl.texture),vgl.uniform=function(type,name){"use strict";if(!(this instanceof vgl.uniform))return new vgl.uniform;this.getTypeNumberOfComponents=function(type){switch(type){case gl.FLOAT:case gl.INT:case gl.BOOL:return 1;case gl.FLOAT_VEC2:case gl.INT_VEC2:case gl.BOOL_VEC2:return 2;case gl.FLOAT_VEC3:case gl.INT_VEC3:case gl.BOOLT_VEC3:return 3;case gl.FLOAT_VEC4:case gl.INT_VEC4:case gl.BOOL_VEC4:return 4;case gl.FLOAT_MAT3:return 9;case gl.FLOAT_MAT4:return 16;default:return 0}};var m_type=type,m_name=name,m_dataArray=[];return m_dataArray.length=this.getTypeNumberOfComponents(m_type),this.name=function(){return m_name},this.type=function(){return m_type},this.get=function(){return m_dataArray},this.set=function(value){var i=0;if(16===m_dataArray.length)for(i=0;16>i;++i)m_dataArray[i]=value[i];else if(9===m_dataArray.length)for(i=0;9>i;++i)m_dataArray[i]=value[i];else if(4===m_dataArray.length)for(i=0;4>i;++i)m_dataArray[i]=value[i];else if(3===m_dataArray.length)for(i=0;3>i;++i)m_dataArray[i]=value[i];else if(2===m_dataArray.length)for(i=0;2>i;++i)m_dataArray[i]=value[i];else m_dataArray[0]=value},this.callGL=function(location){if(!(this.m_numberElements<1))switch(m_type){case gl.BOOL:case gl.INT:gl.uniform1iv(location,m_dataArray);break;case gl.FLOAT:gl.uniform1fv(location,m_dataArray);break;case gl.FLOAT_VEC2:gl.uniform2fv(location,m_dataArray);break;case gl.FLOAT_VEC3:gl.uniform3fv(location,m_dataArray);break;case gl.FLOAT_VEC4:gl.uniform4fv(location,m_dataArray);break;case gl.FLOAT_MAT3:gl.uniformMatrix3fv(location,gl.FALSE,m_dataArray);break;case gl.FLOAT_MAT4:gl.uniformMatrix4fv(location,gl.FALSE,m_dataArray)}},this.update=function(){},this},vgl.modelViewUniform=function(name){"use strict";return this instanceof vgl.modelViewUniform?(0===name.length&&(name="modelViewMatrix"),vgl.uniform.call(this,gl.FLOAT_MAT4,name),this.set(mat4.create()),this.update=function(renderState){this.set(renderState.m_modelViewMatrix)},this):new vgl.modelViewUniform(name)},inherit(vgl.modelViewUniform,vgl.uniform),vgl.projectionUniform=function(name){"use strict";return this instanceof vgl.projectionUniform?(0===name.length&&(name="projectionMatrix"),vgl.uniform.call(this,gl.FLOAT_MAT4,name),this.set(mat4.create()),this.update=function(renderState){this.set(renderState.m_projectionMatrix)},this):new vgl.projectionUniform(name)},inherit(vgl.projectionUniform,vgl.uniform),vgl.floatUniform=function(name,value){"use strict";return this instanceof vgl.floatUniform?(0===name.length&&(name="floatUniform"),value=void 0===value?1:value,vgl.uniform.call(this,gl.FLOAT,name),void this.set(value)):new vgl.floatUniform(name,value)},inherit(vgl.floatUniform,vgl.uniform),vgl.normalMatrixUniform=function(name){"use strict";return this instanceof vgl.normalMatrixUniform?(0===name.length&&(name="normalMatrix"),vgl.uniform.call(this,gl.FLOAT_MAT4,name),this.set(mat4.create()),this.update=function(renderState){this.set(renderState.m_normalMatrix)},this):new vgl.normalMatrixUniform(name)},inherit(vgl.normalMatrixUniform,vgl.uniform),vgl.vertexAttributeKeys={Position:0,Normal:1,TextureCoordinate:2,Color:3,CountAttributeIndex:4},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(name){"use strict";if(!(this instanceof vgl.vertexAttribute))return new vgl.vertexAttribute(name);var m_name=name;this.name=function(){return m_name},this.bindVertexData=function(renderState,key){var geometryData=renderState.m_mapper.geometryData(),sourceData=geometryData.sourceData(key),program=renderState.m_material.shaderProgram();gl.vertexAttribPointer(program.attributeLocation(m_name),sourceData.attributeNumberOfComponents(key),sourceData.attributeDataType(key),sourceData.normalized(key),sourceData.attributeStride(key),sourceData.attributeOffset(key)),gl.enableVertexAttribArray(program.attributeLocation(m_name))},this.undoBindVertexData=function(renderState){var program=renderState.m_material.shaderProgram();gl.disableVertexAttribArray(program.attributeLocation(m_name))}},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 m_origin=[0,0,0],m_point1=[1,0,0],m_point2=[0,1,0],m_normal=[0,0,1],m_xresolution=1,m_yresolution=1,m_geom=null;this.setOrigin=function(x,y,z){m_origin[0]=x,m_origin[1]=y,m_origin[2]=z},this.setPoint1=function(x,y,z){m_point1[0]=x,m_point1[1]=y,m_point1[2]=z},this.setPoint2=function(x,y,z){m_point2[0]=x,m_point2[1]=y,m_point2[2]=z},this.create=function(){m_geom=new vgl.geometryData;var i,j,k,ii,numPts,numPolys,sourceTexCoords,x=[],tc=[],v1=[],v2=[],pts=[],posIndex=0,normIndex=0,colorIndex=0,texCoordIndex=0,positions=[],normals=[],colors=[],texCoords=[],indices=[],tristrip=null,sourcePositions=null,sourceColors=null;for(x.length=3,tc.length=2,v1.length=3,v2.length=3,pts.length=3,i=0;3>i;i++)v1[i]=m_point1[i]-m_origin[i],v2[i]=m_point2[i]-m_origin[i];for(numPts=(m_xresolution+1)*(m_yresolution+1),numPolys=m_xresolution*m_yresolution*2,positions.length=3*numPts,normals.length=3*numPts,texCoords.length=2*numPts,indices.length=numPts,k=0,i=0;m_yresolution+1>i;i++)for(tc[1]=i/m_yresolution,j=0;m_xresolution+1>j;j++){for(tc[0]=j/m_xresolution,ii=0;3>ii;ii++)x[ii]=m_origin[ii]+tc[0]*v1[ii]+tc[1]*v2[ii];positions[posIndex++]=x[0],positions[posIndex++]=x[1],positions[posIndex++]=x[2],colors[colorIndex++]=1,colors[colorIndex++]=1,colors[colorIndex++]=1,normals[normIndex++]=m_normal[0],normals[normIndex++]=m_normal[1],normals[normIndex++]=m_normal[2],texCoords[texCoordIndex++]=tc[0],texCoords[texCoordIndex++]=tc[1]}for(i=0;m_yresolution>i;i++)for(j=0;m_xresolution>j;j++)pts[0]=j+i*(m_xresolution+1),pts[1]=pts[0]+1,pts[2]=pts[0]+m_xresolution+2,pts[3]=pts[0]+m_xresolution+1;for(i=0;numPts>i;++i)indices[i]=i;return tristrip=new vgl.triangleStrip,tristrip.setIndices(indices),sourcePositions=vgl.sourceDataP3fv(),sourcePositions.pushBack(positions),sourceColors=vgl.sourceDataC3fv(),sourceColors.pushBack(colors),sourceTexCoords=vgl.sourceDataT2fv(),sourceTexCoords.pushBack(texCoords),m_geom.addSource(sourcePositions),m_geom.addSource(sourceColors),m_geom.addSource(sourceTexCoords),m_geom.addPrimitive(tristrip),m_geom}},inherit(vgl.planeSource,vgl.source),vgl.pointSource=function(){"use strict";if(!(this instanceof vgl.pointSource))return new vgl.pointSource;vgl.source.call(this);var m_this=this,m_positions=[],m_colors=[],m_textureCoords=[],m_size=[],m_geom=null;this.getPositions=function(){return m_positions},this.setPositions=function(positions){positions instanceof Array?m_positions=positions:console.log("[ERROR] Invalid data type for positions. Array is required."),m_this.modified()},this.getColors=function(){return m_colors},this.setColors=function(colors){colors instanceof Array?m_colors=colors:console.log("[ERROR] Invalid data type for colors. Array is required."),m_this.modified()},this.getSize=function(){return m_size},this.setSize=function(size){m_size=size,this.modified()},this.setTextureCoordinates=function(texcoords){texcoords instanceof Array?m_textureCoords=texcoords:console.log("[ERROR] Invalid data type for texture coordinates. Array is required."),m_this.modified()},this.create=function(){if(m_geom=new vgl.geometryData,m_positions.length%3!==0)return void console.log("[ERROR] Invalid length of the points array");var pointsPrimitive,sourcePositions,sourceColors,sourceTexCoords,sourceSize,numPts=m_positions.length/3,i=0,indices=[];for(indices.length=numPts,i=0;numPts>i;++i)indices[i]=i;if(sourceSize=vgl.sourceDataDf(),numPts!==m_size.length)for(i=0;numPts>i;++i)sourceSize.pushBack(m_size);else sourceSize.setData(m_size);return m_geom.addSource(sourceSize),pointsPrimitive=new vgl.points,pointsPrimitive.setIndices(indices),sourcePositions=vgl.sourceDataP3fv(),sourcePositions.pushBack(m_positions),m_geom.addSource(sourcePositions),m_colors.length>0&&m_colors.length===m_positions.length?(sourceColors=vgl.sourceDataC3fv(),sourceColors.pushBack(m_colors),m_geom.addSource(sourceColors)):m_colors.length>0&&m_colors.length!==m_positions.length&&console.log("[ERROR] Number of colors are different than number of points"),m_textureCoords.length>0&&m_textureCoords.length===m_positions.length?(sourceTexCoords=vgl.sourceDataT2fv(),sourceTexCoords.pushBack(m_textureCoords),m_geom.addSource(sourceTexCoords)):m_textureCoords.length>0&&m_textureCoords.length/2!==m_positions.length/3&&console.log("[ERROR] Number of texture coordinates are different than number of points"),m_geom.addPrimitive(pointsPrimitive),m_geom}},inherit(vgl.pointSource,vgl.source),vgl.lineSource=function(positions,colors){"use strict";if(!(this instanceof vgl.lineSource))return new vgl.lineSource;vgl.source.call(this);var m_positions=positions,m_colors=colors;this.setPositions=function(positions){return positions instanceof Array?(m_positions=positions,this.modified(),!0):(console.log("[ERROR] Invalid data type for positions. Array is required."),!1)},this.setColors=function(colors){return colors instanceof Array?(m_colors=colors,this.modified(),!0):(console.log("[ERROR] Invalid data type for colors. Array is required."),!1)},this.create=function(){if(!m_positions)return void console.log("[error] Invalid positions");if(m_positions.length%3!==0)return void console.log("[error] Line source requires 3d points");if(m_positions.length%3!==0)return void console.log("[ERROR] Invalid length of the points array");var i,linesPrimitive,sourcePositions,sourceColors,m_geom=new vgl.geometryData,numPts=m_positions.length/3,indices=[];for(indices.length=numPts,i=0;numPts>i;++i)indices[i]=i;return linesPrimitive=new vgl.lines,linesPrimitive.setIndices(indices),sourcePositions=vgl.sourceDataP3fv(),sourcePositions.pushBack(m_positions),m_geom.addSource(sourcePositions),m_colors&&m_colors.length>0&&m_colors.length===m_positions.length?(sourceColors=vgl.sourceDataC3fv(),sourceColors.pushBack(m_colors),m_geom.addSource(sourceColors)):m_colors&&m_colors.length>0&&m_colors.length!==m_positions.length&&console.log("[error] Number of colors are different than number of points"),m_geom.addPrimitive(linesPrimitive),m_geom}},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(value,pow){"use strict";for(pow=pow||1;value>pow;)pow*=2;return pow},vgl.utils.createTextureVertexShader=function(){"use strict";var vertexShaderSource=["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"),shader=new vgl.shader(gl.VERTEX_SHADER);return shader.setShaderSource(vertexShaderSource),shader},vgl.utils.createTextureFragmentShader=function(){"use strict";var fragmentShaderSource=["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"),shader=new vgl.shader(gl.FRAGMENT_SHADER);return shader.setShaderSource(fragmentShaderSource),shader},vgl.utils.createRgbaTextureFragmentShader=function(){"use strict";var fragmentShaderSource=["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"),shader=new vgl.shader(gl.FRAGMENT_SHADER);return shader.setShaderSource(fragmentShaderSource),shader},vgl.utils.createVertexShader=function(){"use strict";var vertexShaderSource=["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"),shader=new vgl.shader(gl.VERTEX_SHADER);return shader.setShaderSource(vertexShaderSource),shader},vgl.utils.createPointVertexShader=function(){"use strict";var vertexShaderSource=["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"),shader=new vgl.shader(gl.VERTEX_SHADER);return shader.setShaderSource(vertexShaderSource),shader},vgl.utils.createVertexShaderSolidColor=function(){"use strict";var vertexShaderSource=["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"),shader=new vgl.shader(gl.VERTEX_SHADER);return shader.setShaderSource(vertexShaderSource),shader},vgl.utils.createVertexShaderColorMap=function(){"use strict";var vertexShaderSource=["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"),shader=new vgl.shader(gl.VERTEX_SHADER);return shader.setShaderSource(vertexShaderSource),shader},vgl.utils.createFragmentShader=function(){"use strict";var fragmentShaderSource=["varying mediump vec3 iVertexColor;","uniform mediump float opacity;","void main(void) {","gl_FragColor = vec4(iVertexColor, opacity);","}"].join("\n"),shader=new vgl.shader(gl.FRAGMENT_SHADER); diff --git a/package.json b/package.json index 7d46153050..75a20a1d39 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "geojs", - "version": "0.4.0", + "version": "0.4.1", "description": "JavaScript Geo visualization and Analysis Library", "homepage": "https://github.com/OpenGeoscience/geojs", "license": "BSD-3-Clause", @@ -28,7 +28,7 @@ "grunt-contrib-watch": "~0.6", "grunt-docco": "^0.3.3", "grunt-express": "~1.4", - "jscs": "^1.11", + "jscs": "1.11.2", "jsdoc": "3.3.0-beta1", "jshint": "~2.5", "phantomjs": "~1.9"