vislite 1.4.0-alpha.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG +307 -307
  2. package/lib/BarLayout/index.es.js +437 -437
  3. package/lib/BarLayout/index.es.min.js +2 -2
  4. package/lib/Buffer/index.es.js +35 -35
  5. package/lib/Buffer/index.es.min.js +1 -1
  6. package/lib/Canvas/index.es.js +774 -774
  7. package/lib/Canvas/index.es.min.js +1 -1
  8. package/lib/Cardinal/index.es.js +90 -90
  9. package/lib/Cardinal/index.es.min.js +1 -1
  10. package/lib/Eoap/index.es.js +33 -33
  11. package/lib/Eoap/index.es.min.js +1 -1
  12. package/lib/Hermite/index.es.js +35 -35
  13. package/lib/Hermite/index.es.min.js +1 -1
  14. package/lib/MapCoordinate/index.es.js +199 -199
  15. package/lib/MapCoordinate/index.es.min.js +1 -1
  16. package/lib/Matrix4/index.es.js +124 -124
  17. package/lib/Matrix4/index.es.min.js +1 -1
  18. package/lib/Mercator/index.es.js +19 -19
  19. package/lib/Mercator/index.es.min.js +1 -1
  20. package/lib/PieLayout/index.es.js +213 -213
  21. package/lib/PieLayout/index.es.min.js +2 -2
  22. package/lib/RawCanvas/index.es.js +704 -704
  23. package/lib/RawCanvas/index.es.min.js +1 -1
  24. package/lib/SVG/index.es.js +514 -514
  25. package/lib/SVG/index.es.min.js +1 -1
  26. package/lib/Shader/index.es.js +35 -35
  27. package/lib/Shader/index.es.min.js +1 -1
  28. package/lib/Texture/index.es.js +53 -53
  29. package/lib/Texture/index.es.min.js +1 -1
  30. package/lib/TreeLayout/index.es.js +397 -397
  31. package/lib/TreeLayout/index.es.min.js +2 -2
  32. package/lib/animation/index.es.js +110 -106
  33. package/lib/animation/index.es.min.js +3 -3
  34. package/lib/assemble/index.es.js +17 -17
  35. package/lib/assemble/index.es.min.js +1 -1
  36. package/lib/getLoopColors/index.es.js +35 -35
  37. package/lib/getLoopColors/index.es.min.js +1 -1
  38. package/lib/getWebGLContext/index.es.js +62 -62
  39. package/lib/getWebGLContext/index.es.min.js +1 -1
  40. package/lib/index.umd.js +2795 -2791
  41. package/lib/index.umd.min.js +5 -5
  42. package/lib/initOption/index.es.js +6 -6
  43. package/lib/initOption/index.es.min.js +1 -1
  44. package/lib/mergeOption/index.es.js +34 -34
  45. package/lib/mergeOption/index.es.min.js +1 -1
  46. package/lib/move/index.es.js +7 -7
  47. package/lib/move/index.es.min.js +1 -1
  48. package/lib/rotate/index.es.js +7 -7
  49. package/lib/rotate/index.es.min.js +1 -1
  50. package/lib/ruler/index.es.js +137 -137
  51. package/lib/ruler/index.es.min.js +1 -1
  52. package/lib/scale/index.es.js +6 -6
  53. package/lib/scale/index.es.min.js +1 -1
  54. package/lib/throttle/index.es.js +51 -51
  55. package/lib/throttle/index.es.min.js +2 -2
  56. package/package/BarLayout/index.ts +2 -2
  57. package/package/PieLayout/index.ts +2 -2
  58. package/package/animation/index.ts +6 -3
  59. package/package/index.ts +84 -84
  60. package/package/throttle/index.ts +2 -2
  61. package/package.json +75 -75
  62. package/src/SVG.ts +55 -55
  63. package/src/common/canvas/gradient.ts +31 -31
  64. package/src/common/svg/default.ts +29 -29
  65. package/src/common/svg/gradient.ts +53 -53
  66. package/src/common/svg/index.ts +332 -332
  67. package/src/common/tree/toPlainTree.ts +135 -135
  68. package/src/common/webgl/texture.ts +98 -98
  69. package/src/layout/BarLayout.ts +248 -248
  70. package/src/layout/PieLayout.ts +141 -141
  71. package/src/layout/TreeLayout.ts +197 -197
  72. package/types/Bar.d.ts +91 -91
  73. package/types/BarConfig.d.ts +4 -4
  74. package/types/BarLayout.d.ts +48 -48
  75. package/types/BarOption.d.ts +31 -31
  76. package/types/Pie.d.ts +73 -73
  77. package/types/PieConfig.d.ts +26 -26
  78. package/types/PieLayout.d.ts +40 -40
  79. package/types/PieOption.d.ts +21 -21
  80. package/types/SVG.d.ts +247 -247
  81. package/types/animation.d.ts +11 -5
  82. package/types/index.d.ts +195 -195
  83. package/types/throttle.d.ts +5 -5
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * SVG of VISLite JavaScript Library v1.4.0-alpha.0
2
+ * SVG of VISLite JavaScript Library v1.4.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  var t=function(e,i){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},t(e,i)};"function"==typeof SuppressedError&&SuppressedError;var e=["href","title","show","type","role","actuate"],i=function(t,e){o(t,"stroke-dasharray",e.lineDash.join(",")),o(t,"stroke-width",e.lineWidth+""),o(t,"stroke-linecap",e.lineCap+""),o(t,"stroke-linejoin",e.lineJoin+"")};function n(t){return document.createElementNS("http://www.w3.org/2000/svg",t)}var r=function(t,i,n){e.indexOf(i)>-1?t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:"+i,n+""):t.setAttribute(i,n+"")},o=r;function s(t,e){i(t,e),r(t,"stroke",e.strokeStyle),r(t,"fill",e.fillStyle)}function u(t,e){r(t,"fill",e.fillStyle)}function h(t,e){i(t,e),r(t,"stroke",e.strokeStyle),r(t,"fill","none")}var a=function(t,e,i,n,r){var o=Math.cos(i),s=Math.sin(i);return[+((n-t)*o-(r-e)*s+t).toFixed(7),+((n-t)*s+(r-e)*o+e).toFixed(7)]};var _=function(t){var e=t.getElementsByTagName("defs");if(e.length<=0){var i=n("defs");return t.appendChild(i),i}return e[0]},l=function(t,e,i,n,r){if("text"!==t.nodeName.toLowerCase())throw new Error("Need a <text> !");o(t,"dy",{top:.5*e.fontSize,middle:0,bottom:.5*-e.fontSize}[e.textBaseline]),function(t,e){for(var i in e)t.style[i]=e[i]}(t,{"text-anchor":{left:"start",right:"end",center:"middle"}[e.textAlign],"dominant-baseline":"central","font-size":e.fontSize+"px","font-family":e.fontFamily}),o(t,"x",i),o(t,"y",n),"number"==typeof r&&o(t,"transform","rotate("+(r%=360)+","+i+","+n+")")},c=function(t,e,i,n){if("circle"!==t.nodeName.toLowerCase())throw new Error("Need a <circle> !");o(t,"cx",e),o(t,"cy",i),o(t,"r",n)},f=function(t,e){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");o(t,"d",e)},p=function(t,e,i,n,r,s){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");var u=[];if(Array.isArray(e.rectRadius)&&e.rectRadius.length>0)for(var h=0;h<4;h++)u.push.apply(u,e.rectRadius);s<0&&(n-=s*=-1),r<0&&(i-=r*=-1);var a="";u.length>=4?(a="M"+(i+u[0])+" "+n,a+="L"+(i+r-u[1])+" "+n,a+="A"+u[1]+" "+u[1]+" 0 0 1 "+(i+r)+" "+(n+u[1]),a+="L"+(i+r)+" "+(n+s-u[2]),a+="A"+u[2]+" "+u[2]+" 0 0 1 "+(i+r-u[2])+" "+(n+s),a+="L"+(i+u[3])+" "+(n+s),a+="A"+u[3]+" "+u[3]+" 0 0 1 "+i+" "+(n+s-u[3]),a+="L"+i+" "+(n+u[0]),a+="A"+u[0]+" "+u[0]+" 0 0 1 "+(i+u[0])+" "+n):(a="M"+i+" "+n,a+="L"+(i+r)+" "+n,a+="L"+(i+r)+" "+(n+s),a+="L"+i+" "+(n+s),a+="Z"),o(t,"d",a)},d=function(t,e,i,n,r,s,u,h){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");if(u=u/180*Math.PI,h=h/180*Math.PI,u%=2*Math.PI,r>s){var _=r;r=s,s=_}h>=1.999999*Math.PI||h<=1.999999*-Math.PI?h=1.999999*Math.PI:h%=2*Math.PI,function(t,e,i,n,r,o,s){e<0&&(t+=e,e*=-1);var u,h=[];u=a(0,0,t,r,0),h[0]=u[0],h[1]=u[1],u=a(0,0,e,u[0],u[1]),h[2]=u[0],h[3]=u[1],u=a(0,0,t,o,0),h[4]=u[0],h[5]=u[1],u=a(0,0,e,u[0],u[1]),h[6]=u[0],h[7]=u[1],s(t,t+e,h[0]+i,h[1]+n,h[4]+i,h[5]+n,h[2]+i,h[3]+n,h[6]+i,h[7]+n,.5*(o-r))}(u,h,i,n,r,s,(function(i,n,u,h,a,_,l,c,f,p,d){var g=n-i>Math.PI?1:0,y="M"+u+" "+h;d<0&&(d=-d),y+="A"+r+" "+r+" 0 "+g+" 1 "+l+" "+c,"round"==e.arcEndCap?y+="A"+d+" "+d+" 0 1 0 "+f+" "+p:"-round"==e.arcEndCap?y+="A"+d+" "+d+" 0 1 1 "+f+" "+p:y+="L"+f+" "+p,y+="A"+s+" "+s+" 0 "+g+" 0 "+a+" "+_,"round"==e.arcStartCap?y+="A"+d+" "+d+" 0 1 0 "+u+" "+h:"-round"==e.arcStartCap?y+="A"+d+" "+d+" 0 1 1 "+u+" "+h:y+="L"+u+" "+h,"butt"==e.arcStartCap&&(y+="Z"),o(t,"d",y)}))};function g(t,e,i,n,r){var o=Math.cos(i),s=Math.sin(i);return[(n-t)*o-(r-e)*s+t,(n-t)*s+(r-e)*o+e]}var y=function(t,e){var i={value:function(){return"url(#"+e+")"},setColor:function(e,r){var s=n("stop");return t.appendChild(s),o(s,"offset",100*e+"%"),o(s,"style","stop-color:"+r+";"),i}};return i};var E=function(){function t(t){this.name="SVG",this.__config={fillStyle:"rgb(0,0,0)",strokeStyle:"rgb(0,0,0)",textAlign:"left",textBaseline:"middle",fontSize:16,fontFamily:"sans-serif",arcStartCap:"butt",arcEndCap:"butt",lineDash:[],lineWidth:1,lineCap:"butt",lineJoin:"miter",rectRadius:[]},this.__path="",this.__currentPosition=[],this.__svg=t}return t.prototype.config=function(t){if("object"!=typeof t)return this.__config[t];for(var e in t)this.__config[e]=t[e];return this},t.prototype.reset=function(){return this.config({fillStyle:"rgb(0,0,0)",strokeStyle:"rgb(0,0,0)",textAlign:"left",textBaseline:"middle",fontSize:16,fontFamily:"sans-serif",arcStartCap:"butt",arcEndCap:"butt",lineDash:[],lineWidth:1,lineCap:"butt",lineJoin:"miter",rectRadius:[]}),this},t.prototype.useEl=function(t){return this.__useEl=t,this},t.prototype.getEl=function(){return this.__useEl},t.prototype.appendEl=function(t,e){return e=e||this.__svg,"string"==typeof t&&(t=n(t)),e.appendChild(t),this.__useEl=t,this},t.prototype.appendBoard=function(t,e){var i=t;if("string"==typeof t&&(i={text:"text",path:"path",arc:"path",circle:"circle",rect:"rect"}[t]||""),""==i)throw new Error("Unsupported drawing method:"+t);return this.appendEl(i,e)},t.prototype.remove=function(){if(!this.__useEl)throw new Error("Currently, no node can be deleted.");return this.__useEl.parentNode.removeChild(this.__useEl),this},t.prototype.attr=function(t){if(!this.__useEl)throw new Error("Currently, no node can be modified or viewed.");if("object"!=typeof t)return function(t,i){return e.indexOf(i)>-1&&(i="xlink:"+i),t.getAttribute(i)}(this.__useEl,t);for(var i in t)o(this.__useEl,i,t[i]);return this},t.prototype.fillText=function(t,e,i,n){return void 0===n&&(n=0),l(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,u(this.__useEl,this.__config),this},t.prototype.strokeText=function(t,e,i,n){return void 0===n&&(n=0),l(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,h(this.__useEl,this.__config),this},t.prototype.fullText=function(t,e,i,n){return void 0===n&&(n=0),l(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,s(this.__useEl,this.__config),this},t.prototype.fillArc=function(t,e,i,n,r,o){return d(this.__useEl,this.__config,t,e,i,n,r,o),u(this.__useEl,this.__config),this},t.prototype.strokeArc=function(t,e,i,n,r,o){return d(this.__useEl,this.__config,t,e,i,n,r,o),h(this.__useEl,this.__config),this},t.prototype.fullArc=function(t,e,i,n,r,o){return d(this.__useEl,this.__config,t,e,i,n,r,o),s(this.__useEl,this.__config),this},t.prototype.fillCircle=function(t,e,i){return c(this.__useEl,t,e,i),u(this.__useEl,this.__config),this},t.prototype.strokeCircle=function(t,e,i){return c(this.__useEl,t,e,i),h(this.__useEl,this.__config),this},t.prototype.fullCircle=function(t,e,i){return c(this.__useEl,t,e,i),s(this.__useEl,this.__config),this},t.prototype.fillRect=function(t,e,i,n){return p(this.__useEl,this.__config,t,e,i,n),u(this.__useEl,this.__config),this},t.prototype.strokeRect=function(t,e,i,n){return p(this.__useEl,this.__config,t,e,i,n),h(this.__useEl,this.__config),this},t.prototype.fullRect=function(t,e,i,n){return p(this.__useEl,this.__config,t,e,i,n),s(this.__useEl,this.__config),this},t.prototype.beginPath=function(){return this.__currentPosition=[],this.__path="",this},t.prototype.closePath=function(){return this.__path+="Z",this},t.prototype.moveTo=function(t,e){return this.__currentPosition=[t,e],this.__path+="M"+t+" "+e,this},t.prototype.lineTo=function(t,e){return this.__currentPosition=[t,e],this.__path+=(""==this.__path?"M":"L")+t+" "+e,this},t.prototype.fill=function(){return f(this.__useEl,this.__path),u(this.__useEl,this.__config),this},t.prototype.stroke=function(){return f(this.__useEl,this.__path),h(this.__useEl,this.__config),this},t.prototype.full=function(){return f(this.__useEl,this.__path),s(this.__useEl,this.__config),this},t.prototype.arc=function(t,e,i,n,r){var o=g(t,e,n/180*Math.PI,t+i,e),s=g(t,e,(n+r)/180*Math.PI,t+i,e);return""==this.__path?this.__path+="M"+o[0]+","+o[1]:o[0]==this.__currentPosition[0]&&o[1]==this.__currentPosition[1]||(this.__path+="L"+o[0]+","+o[1]),this.__path+="A"+i+","+i+" 0 "+(r>180||r<-180?1:0)+","+(r>0?1:0)+" "+s[0]+","+s[1],this},t.prototype.quadraticCurveTo=function(t,e,i,n){return this.__path+="Q"+t+" "+e+","+i+" "+n,this},t.prototype.bezierCurveTo=function(t,e,i,n,r,o){return this.__path+="C"+t+" "+e+","+i+" "+n+","+r+" "+o,this},t.prototype.bind=function(t,e){return this.__useEl.addEventListener(t,(function(t){e.call(this,t,this)}),!1),this},t.prototype.createLinearGradient=function(t,e,i,r){return function(t,e,i,r,s){var u=_(t),h="visliteLg"+(new Date).valueOf()+(1e6*Math.random()).toFixed(0),a=n("linearGradient");return u.appendChild(a),o(a,"id",h),o(a,"x1",e+"%"),o(a,"y1",i+"%"),o(a,"x2",r+"%"),o(a,"y2",s+"%"),y(a,h)}(this.__svg,t,e,i,r)},t.prototype.createRadialGradient=function(t,e,i){return function(t,e,i,r){var s=_(t),u="visliteRg"+(new Date).valueOf()+(1e6*Math.random()).toFixed(0),h=n("radialGradient");return s.appendChild(h),o(h,"id",u),o(h,"cx",e+"%"),o(h,"cy",i+"%"),o(h,"r",r+"%"),y(h,u)}(this.__svg,t,e,i)},t}(),v=function(e){function i(t){var i=this;if(!t)throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");var n=t.clientWidth,r=t.clientHeight,o=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.appendChild(o),o.setAttribute("width",n+""),o.setAttribute("height",r+""),o.setAttribute("viewBox","0 0 "+n+" "+r),(i=e.call(this,o)||this).__el=t,i}return function(e,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}(i,e),i.prototype.toDataURL=function(){var t=this;return new Promise((function(e){var i=t.__el.clientWidth,n=t.__el.clientHeight,r=document.createElement("img");r.setAttribute("width",i+""),r.setAttribute("height",n+"");var o="data:image/svg+xml;charset=utf-8,<svg xmlns='http://www.w3.org/2000/svg' width='"+i+"' height='"+n+"'>"+t.__svg.innerHTML.replace(/"/g,"'")+"</svg>";r.setAttribute("src",o),setTimeout((function(){var t=document.createElement("canvas");t.setAttribute("width",i+""),t.setAttribute("height",n+"");var o=t.getContext("2d");o&&o.drawImage(r,0,0,i,n),e(t.toDataURL())}),100)}))},i}(E);export{v as default};
@@ -1,41 +1,41 @@
1
1
  /*!
2
- * Shader of VISLite JavaScript Library v1.4.0-alpha.0
2
+ * Shader of VISLite JavaScript Library v1.4.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
- var loadShader = function (painter, type, source) {
6
- var shader = painter.createShader(type);
7
- if (shader == null)
8
- throw new Error('Unable to create shader!');
9
- painter.shaderSource(shader, source);
10
- painter.compileShader(shader);
11
- if (!painter.getShaderParameter(shader, painter.COMPILE_STATUS))
12
- throw new Error('Failed to compile shader:' + painter.getShaderInfoLog(shader));
13
- return shader;
14
- };
15
- var useShader = function (painter, vshaderSource, fshaderSource) {
16
- var vertexShader = loadShader(painter, painter.VERTEX_SHADER, vshaderSource);
17
- var fragmentShader = loadShader(painter, painter.FRAGMENT_SHADER, fshaderSource);
18
- var glProgram = painter.createProgram();
19
- painter.attachShader(glProgram, vertexShader);
20
- painter.attachShader(glProgram, fragmentShader);
21
- painter.linkProgram(glProgram);
22
- if (!painter.getProgramParameter(glProgram, painter.LINK_STATUS))
23
- throw new Error('Failed to link program: ' + painter.getProgramInfoLog(glProgram));
24
- return glProgram;
25
- };
26
- var ShaderObject = (function () {
27
- function ShaderObject(painter) {
28
- this.__painter = painter;
29
- }
30
- ShaderObject.prototype.use = function () {
31
- this.__painter.useProgram(this.program);
32
- return this;
33
- };
34
- ShaderObject.prototype.compile = function (vshaderSource, fshaderSource) {
35
- this.program = useShader(this.__painter, vshaderSource, fshaderSource);
36
- return this;
37
- };
38
- return ShaderObject;
5
+ var loadShader = function (painter, type, source) {
6
+ var shader = painter.createShader(type);
7
+ if (shader == null)
8
+ throw new Error('Unable to create shader!');
9
+ painter.shaderSource(shader, source);
10
+ painter.compileShader(shader);
11
+ if (!painter.getShaderParameter(shader, painter.COMPILE_STATUS))
12
+ throw new Error('Failed to compile shader:' + painter.getShaderInfoLog(shader));
13
+ return shader;
14
+ };
15
+ var useShader = function (painter, vshaderSource, fshaderSource) {
16
+ var vertexShader = loadShader(painter, painter.VERTEX_SHADER, vshaderSource);
17
+ var fragmentShader = loadShader(painter, painter.FRAGMENT_SHADER, fshaderSource);
18
+ var glProgram = painter.createProgram();
19
+ painter.attachShader(glProgram, vertexShader);
20
+ painter.attachShader(glProgram, fragmentShader);
21
+ painter.linkProgram(glProgram);
22
+ if (!painter.getProgramParameter(glProgram, painter.LINK_STATUS))
23
+ throw new Error('Failed to link program: ' + painter.getProgramInfoLog(glProgram));
24
+ return glProgram;
25
+ };
26
+ var ShaderObject = (function () {
27
+ function ShaderObject(painter) {
28
+ this.__painter = painter;
29
+ }
30
+ ShaderObject.prototype.use = function () {
31
+ this.__painter.useProgram(this.program);
32
+ return this;
33
+ };
34
+ ShaderObject.prototype.compile = function (vshaderSource, fshaderSource) {
35
+ this.program = useShader(this.__painter, vshaderSource, fshaderSource);
36
+ return this;
37
+ };
38
+ return ShaderObject;
39
39
  }());
40
40
 
41
41
  export { ShaderObject as default };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Shader of VISLite JavaScript Library v1.4.0-alpha.0
2
+ * Shader of VISLite JavaScript Library v1.4.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  var r=function(r,e,t){var a=r.createShader(e);if(null==a)throw new Error("Unable to create shader!");if(r.shaderSource(a,t),r.compileShader(a),!r.getShaderParameter(a,r.COMPILE_STATUS))throw new Error("Failed to compile shader:"+r.getShaderInfoLog(a));return a},e=function(){function e(r){this.__painter=r}return e.prototype.use=function(){return this.__painter.useProgram(this.program),this},e.prototype.compile=function(e,t){return this.program=function(e,t,a){var o=r(e,e.VERTEX_SHADER,t),n=r(e,e.FRAGMENT_SHADER,a),i=e.createProgram();if(e.attachShader(i,o),e.attachShader(i,n),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw new Error("Failed to link program: "+e.getProgramInfoLog(i));return i}(this.__painter,e,t),this},e}();export{e as default};
@@ -1,59 +1,59 @@
1
1
  /*!
2
- * Texture of VISLite JavaScript Library v1.4.0-alpha.0
2
+ * Texture of VISLite JavaScript Library v1.4.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
- var initTexture = function (painter, type, unit) {
6
- var texture = painter.createTexture();
7
- painter.activeTexture(painter['TEXTURE' + unit]);
8
- painter.bindTexture(type, texture);
9
- return texture;
10
- };
11
- var linkImage = function (painter, type, level, format, textureType, image) {
12
- painter.texImage2D(type, level, format, format, textureType, image);
13
- };
14
- var linkCube = function (painter, type, level, format, textureType, images, width, height, texture) {
15
- var types = [
16
- painter.TEXTURE_CUBE_MAP_POSITIVE_X,
17
- painter.TEXTURE_CUBE_MAP_NEGATIVE_X,
18
- painter.TEXTURE_CUBE_MAP_POSITIVE_Y,
19
- painter.TEXTURE_CUBE_MAP_NEGATIVE_Y,
20
- painter.TEXTURE_CUBE_MAP_POSITIVE_Z,
21
- painter.TEXTURE_CUBE_MAP_NEGATIVE_Z
22
- ];
23
- var target;
24
- for (var i = 0; i < types.length; i++) {
25
- if (images[i]) {
26
- target = types[i];
27
- painter.texImage2D(target, level, format, width, height, 0, format, textureType, null);
28
- painter.bindTexture(type, texture);
29
- painter.texImage2D(target, level, format, format, textureType, images[i]);
30
- }
31
- }
32
- painter.generateMipmap(type);
33
- };
34
- var TextureObject = (function () {
35
- function TextureObject(painter, type, unit) {
36
- if (unit === void 0) { unit = 0; }
37
- this.__painter = painter;
38
- this.__type = {
39
- "2d": painter.TEXTURE_2D,
40
- "cube": painter.TEXTURE_CUBE_MAP
41
- }[type];
42
- this.__texture = initTexture(painter, this.__type, unit);
43
- painter.texParameteri(this.__type, painter.TEXTURE_MIN_FILTER, painter.NEAREST);
44
- painter.texParameteri(this.__type, painter.TEXTURE_MAG_FILTER, painter.NEAREST);
45
- painter.texParameteri(this.__type, painter.TEXTURE_WRAP_S, painter.CLAMP_TO_EDGE);
46
- painter.texParameteri(this.__type, painter.TEXTURE_WRAP_T, painter.CLAMP_TO_EDGE);
47
- }
48
- TextureObject.prototype.useImage = function (image) {
49
- linkImage(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, image);
50
- return this;
51
- };
52
- TextureObject.prototype.useCube = function (images, width, height) {
53
- linkCube(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, images, width, height, this.__texture);
54
- return this;
55
- };
56
- return TextureObject;
5
+ var initTexture = function (painter, type, unit) {
6
+ var texture = painter.createTexture();
7
+ painter.activeTexture(painter['TEXTURE' + unit]);
8
+ painter.bindTexture(type, texture);
9
+ return texture;
10
+ };
11
+ var linkImage = function (painter, type, level, format, textureType, image) {
12
+ painter.texImage2D(type, level, format, format, textureType, image);
13
+ };
14
+ var linkCube = function (painter, type, level, format, textureType, images, width, height, texture) {
15
+ var types = [
16
+ painter.TEXTURE_CUBE_MAP_POSITIVE_X,
17
+ painter.TEXTURE_CUBE_MAP_NEGATIVE_X,
18
+ painter.TEXTURE_CUBE_MAP_POSITIVE_Y,
19
+ painter.TEXTURE_CUBE_MAP_NEGATIVE_Y,
20
+ painter.TEXTURE_CUBE_MAP_POSITIVE_Z,
21
+ painter.TEXTURE_CUBE_MAP_NEGATIVE_Z
22
+ ];
23
+ var target;
24
+ for (var i = 0; i < types.length; i++) {
25
+ if (images[i]) {
26
+ target = types[i];
27
+ painter.texImage2D(target, level, format, width, height, 0, format, textureType, null);
28
+ painter.bindTexture(type, texture);
29
+ painter.texImage2D(target, level, format, format, textureType, images[i]);
30
+ }
31
+ }
32
+ painter.generateMipmap(type);
33
+ };
34
+ var TextureObject = (function () {
35
+ function TextureObject(painter, type, unit) {
36
+ if (unit === void 0) { unit = 0; }
37
+ this.__painter = painter;
38
+ this.__type = {
39
+ "2d": painter.TEXTURE_2D,
40
+ "cube": painter.TEXTURE_CUBE_MAP
41
+ }[type];
42
+ this.__texture = initTexture(painter, this.__type, unit);
43
+ painter.texParameteri(this.__type, painter.TEXTURE_MIN_FILTER, painter.NEAREST);
44
+ painter.texParameteri(this.__type, painter.TEXTURE_MAG_FILTER, painter.NEAREST);
45
+ painter.texParameteri(this.__type, painter.TEXTURE_WRAP_S, painter.CLAMP_TO_EDGE);
46
+ painter.texParameteri(this.__type, painter.TEXTURE_WRAP_T, painter.CLAMP_TO_EDGE);
47
+ }
48
+ TextureObject.prototype.useImage = function (image) {
49
+ linkImage(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, image);
50
+ return this;
51
+ };
52
+ TextureObject.prototype.useCube = function (images, width, height) {
53
+ linkCube(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, images, width, height, this.__texture);
54
+ return this;
55
+ };
56
+ return TextureObject;
57
57
  }());
58
58
 
59
59
  export { TextureObject as default };
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * Texture of VISLite JavaScript Library v1.4.0-alpha.0
2
+ * Texture of VISLite JavaScript Library v1.4.0
3
3
  * git+https://github.com/oi-contrib/VISLite.git
4
4
  */
5
5
  var _=function(){function _(_,t,e){void 0===e&&(e=0),this.__painter=_,this.__type={"2d":_.TEXTURE_2D,cube:_.TEXTURE_CUBE_MAP}[t],this.__texture=function(_,t,e){var E=_.createTexture();return _.activeTexture(_["TEXTURE"+e]),_.bindTexture(t,E),E}(_,this.__type,e),_.texParameteri(this.__type,_.TEXTURE_MIN_FILTER,_.NEAREST),_.texParameteri(this.__type,_.TEXTURE_MAG_FILTER,_.NEAREST),_.texParameteri(this.__type,_.TEXTURE_WRAP_S,_.CLAMP_TO_EDGE),_.texParameteri(this.__type,_.TEXTURE_WRAP_T,_.CLAMP_TO_EDGE)}return _.prototype.useImage=function(_){return function(_,t,e,E,T,i){_.texImage2D(t,e,E,E,T,i)}(this.__painter,this.__type,0,this.__painter.RGBA,this.__painter.UNSIGNED_BYTE,_),this},_.prototype.useCube=function(_,t,e){return function(_,t,e,E,T,i,r,n,a){for(var u,p=[_.TEXTURE_CUBE_MAP_POSITIVE_X,_.TEXTURE_CUBE_MAP_NEGATIVE_X,_.TEXTURE_CUBE_MAP_POSITIVE_Y,_.TEXTURE_CUBE_MAP_NEGATIVE_Y,_.TEXTURE_CUBE_MAP_POSITIVE_Z,_.TEXTURE_CUBE_MAP_NEGATIVE_Z],s=0;s<p.length;s++)i[s]&&(u=p[s],_.texImage2D(u,e,E,r,n,0,E,T,null),_.bindTexture(t,a),_.texImage2D(u,e,E,E,T,i[s]));_.generateMipmap(t)}(this.__painter,this.__type,0,this.__painter.RGBA,this.__painter.UNSIGNED_BYTE,_,t,e,this.__texture),this},_}();export{_ as default};