vislite 0.5.0 → 0.5.2-alpha.1
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.
- package/CHANGELOG +137 -132
- package/lib/Buffer/index.umd.js +36 -36
- package/lib/Buffer/index.umd.min.js +2 -2
- package/lib/Canvas/index.umd.js +650 -650
- package/lib/Canvas/index.umd.min.js +2 -2
- package/lib/Cardinal/index.umd.js +91 -91
- package/lib/Cardinal/index.umd.min.js +2 -2
- package/lib/Eoap/index.umd.js +34 -34
- package/lib/Eoap/index.umd.min.js +2 -2
- package/lib/Geometry/index.umd.js +142 -142
- package/lib/Geometry/index.umd.min.js +2 -2
- package/lib/Hermite/index.umd.js +36 -36
- package/lib/Hermite/index.umd.min.js +2 -2
- package/lib/Matrix4/index.umd.js +119 -119
- package/lib/Matrix4/index.umd.min.js +2 -2
- package/lib/Mercator/index.umd.js +20 -20
- package/lib/Mercator/index.umd.min.js +2 -2
- package/lib/OralCanvas/index.es.js +598 -598
- package/lib/OralCanvas/index.es.min.js +2 -2
- package/lib/OralWebGL/index.es.js +524 -524
- package/lib/OralWebGL/index.es.min.js +2 -2
- package/lib/SVG/index.umd.js +406 -406
- package/lib/SVG/index.umd.min.js +2 -2
- package/lib/Shader/index.umd.js +61 -61
- package/lib/Shader/index.umd.min.js +2 -2
- package/lib/Texture/index.umd.js +53 -53
- package/lib/Texture/index.umd.min.js +2 -2
- package/lib/TreeLayout/index.umd.js +363 -363
- package/lib/TreeLayout/index.umd.min.js +2 -2
- package/lib/WebGL/index.umd.js +571 -571
- package/lib/WebGL/index.umd.min.js +2 -2
- package/lib/animation/index.umd.js +72 -72
- package/lib/animation/index.umd.min.js +2 -2
- package/lib/formatColor/index.umd.js +40 -40
- package/lib/formatColor/index.umd.min.js +2 -2
- package/lib/getLoopColors/index.umd.js +36 -36
- package/lib/getLoopColors/index.umd.min.js +2 -2
- package/lib/getWebGLContext/index.umd.js +44 -44
- package/lib/getWebGLContext/index.umd.min.js +2 -2
- package/lib/index.umd.js +2647 -2647
- package/lib/index.umd.min.js +2 -2
- package/lib/resizeObserver/index.umd.js +29 -29
- package/lib/resizeObserver/index.umd.min.js +2 -2
- package/lib/rotate/index.umd.js +8 -8
- package/lib/rotate/index.umd.min.js +2 -2
- package/lib/ruler/index.umd.js +126 -126
- package/lib/ruler/index.umd.min.js +2 -2
- package/lib/throttle/index.umd.js +49 -49
- package/lib/throttle/index.umd.min.js +2 -2
- package/lib/viewHandler/index.umd.js +120 -120
- package/lib/viewHandler/index.umd.min.js +2 -2
- package/package/Geometry/index.ts +2 -2
- package/package/index.ts +72 -72
- package/package.json +66 -66
- package/src/Eoap.ts +66 -66
- package/src/Geometry.ts +82 -82
- package/src/Matrix4/index.ts +76 -76
- package/src/Mercator.ts +27 -27
- package/src/TreeLayout/index.ts +186 -186
- package/src/common/geometry/prism-horizontal.ts +33 -33
- package/src/common/geometry/prism-vertical.ts +40 -40
- package/src/common/geometry/sphere-fragment.ts +39 -39
- package/src/common/geometry/tool/circle.ts +11 -11
- package/src/common/svg/index.ts +344 -344
- package/src/rotate.ts +7 -7
- package/types/CanvasConfig.d.ts +106 -106
- package/types/Geometry.d.ts +40 -40
- package/types/GeometryOption.d.ts +11 -11
- package/types/GeometryResult.d.ts +18 -18
- package/types/Map.d.ts +9 -9
- package/types/Matrix4.d.ts +42 -42
- package/types/SVG.d.ts +215 -215
- package/types/TreeLayout.d.ts +54 -54
- package/types/index.d.ts +169 -169
- package/types/rotate.d.ts +2 -2
- package/uni-app/ui-canvas.vue +206 -202
package/lib/SVG/index.umd.min.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.5.
|
|
2
|
+
* VISLite JavaScript Library v0.5.2-alpha.1
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Thu Oct 12 2023 15:44:35 GMT+0800 (China Standard Time)
|
|
10
10
|
*/
|
|
11
11
|
var t,e;t=this,e=function(){"use strict";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,i,n){e.indexOf(i)>-1?t.setAttributeNS("http://www.w3.org/1999/xlink","xlink:"+i,n+""):t.setAttribute(i,n+"")},n=i;function r(t,e){i(t,"stroke",e.strokeStyle),i(t,"fill",e.fillStyle),i(t,"stroke-dasharray",e.lineDash.join(","))}function o(t,e){i(t,"fill",e.fillStyle)}function s(t,e){i(t,"stroke",e.strokeStyle),i(t,"fill","none"),i(t,"stroke-dasharray",e.lineDash.join(","))}var h=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)]},u=function(t,e,i,r,o){if("text"!==t.nodeName.toLowerCase())throw new Error("Need a <text> !");n(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}),n(t,"x",i),n(t,"y",r),"number"==typeof o&&n(t,"transform","rotate("+(o%=360)+","+i+","+r+")")},_=function(t,e,i,r){if("circle"!==t.nodeName.toLowerCase())throw new Error("Need a <circle> !");n(t,"cx",e),n(t,"cy",i),n(t,"r",r)},c=function(t,e){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");n(t,"d",e)},a=function(t,e,i,r,o){if("rect"!==t.nodeName.toLowerCase())throw new Error("Need a <rect> !");o<0&&(i-=o*=-1),r<0&&(e-=r*=-1),n(t,"x",e),n(t,"y",i),n(t,"width",r),n(t,"height",o)},f=function(t,e,i,r,o,s,u,_){if("path"!==t.nodeName.toLowerCase())throw new Error("Need a <path> !");if(u=u/180*Math.PI,_=_/180*Math.PI,u%=2*Math.PI,o>s){var c=o;o=s,s=c}_>=1.999999*Math.PI||_<=1.999999*-Math.PI?_=1.999999*Math.PI:_%=2*Math.PI,function(t,e,i,n,r,o,s){e<0&&(t+=e,e*=-1);var u,_=[];u=h(0,0,t,r,0),_[0]=u[0],_[1]=u[1],u=h(0,0,e,u[0],u[1]),_[2]=u[0],_[3]=u[1],u=h(0,0,t,o,0),_[4]=u[0],_[5]=u[1],u=h(0,0,e,u[0],u[1]),_[6]=u[0],_[7]=u[1],s(t,t+e,_[0]+i,_[1]+n,_[4]+i,_[5]+n,_[2]+i,_[3]+n,_[6]+i,_[7]+n,.5*(o-r))}(u,_,i,r,o,s,(function(i,r,h,u,_,c,a,f,l,p,d){var y=r-i>Math.PI?1:0,E="M"+h+" "+u;d<0&&(d=-d),E+="A"+o+" "+o+" 0 "+y+" 1 "+a+" "+f,"round"==e.arcEndCap?E+="A"+d+" "+d+" 0 1 0 "+l+" "+p:"-round"==e.arcEndCap?E+="A"+d+" "+d+" 0 1 1 "+l+" "+p:E+="L"+l+" "+p,E+="A"+s+" "+s+" 0 "+y+" 0 "+_+" "+c,"round"==e.arcStartCap?E+="A"+d+" "+d+" 0 1 0 "+h+" "+u:"-round"==e.arcStartCap?E+="A"+d+" "+d+" 0 1 1 "+h+" "+u:E+="L"+h+" "+u,"butt"==e.arcStartCap&&(E+="Z"),n(t,"d",E)}))};function l(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 p={"font-size":"fontSize","font-family":"fontFamily","arc-start-cap":"arcStartCap","arc-end-cap":"arcEndCap"},d=function(){function t(t){this.name="SVG",this.__config={fillStyle:"#000",strokeStyle:"#000",lineWidth:1,textAlign:"left",textBaseline:"middle",fontSize:16,fontFamily:"sans-serif",arcStartCap:"butt",arcEndCap:"butt",lineDash:[]},this.__path="",this.__currentPosition=[],this.__svg=t}return t.prototype.config=function(t){if("object"!=typeof t)return this.__config[p[t]||t];for(var e in t){var i=p[e]||e;this.__config[i]=t[e]}return this},t.prototype.useEl=function(t){return this.__useEl=t,this},t.prototype.getEl=function(){return this.__useEl},t.prototype.appendEl=function(t,e){var i;return e=e||this.__svg,"string"==typeof t&&(i=t,t=document.createElementNS("http://www.w3.org/2000/svg",i)),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)n(this.__useEl,i,t[i]);return this},t.prototype.fillText=function(t,e,i,n){return void 0===n&&(n=0),u(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,o(this.__useEl,this.__config),this},t.prototype.strokeText=function(t,e,i,n){return void 0===n&&(n=0),u(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,s(this.__useEl,this.__config),this},t.prototype.fullText=function(t,e,i,n){return void 0===n&&(n=0),u(this.__useEl,this.__config,e,i,n),this.__useEl.textContent=t,r(this.__useEl,this.__config),this},t.prototype.fillArc=function(t,e,i,n,r,s){return f(this.__useEl,this.__config,t,e,i,n,r,s),o(this.__useEl,this.__config),this},t.prototype.strokeArc=function(t,e,i,n,r,o){return f(this.__useEl,this.__config,t,e,i,n,r,o),s(this.__useEl,this.__config),this},t.prototype.fullArc=function(t,e,i,n,o,s){return f(this.__useEl,this.__config,t,e,i,n,o,s),r(this.__useEl,this.__config),this},t.prototype.fillCircle=function(t,e,i){return _(this.__useEl,t,e,i),o(this.__useEl,this.__config),this},t.prototype.strokeCircle=function(t,e,i){return _(this.__useEl,t,e,i),s(this.__useEl,this.__config),this},t.prototype.fullCircle=function(t,e,i){return _(this.__useEl,t,e,i),r(this.__useEl,this.__config),this},t.prototype.fillRect=function(t,e,i,n){return a(this.__useEl,t,e,i,n),o(this.__useEl,this.__config),this},t.prototype.strokeRect=function(t,e,i,n){return a(this.__useEl,t,e,i,n),s(this.__useEl,this.__config),this},t.prototype.fullRect=function(t,e,i,n){return a(this.__useEl,t,e,i,n),r(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 c(this.__useEl,this.__path),o(this.__useEl,this.__config),this},t.prototype.stroke=function(){return c(this.__useEl,this.__path),s(this.__useEl,this.__config),this},t.prototype.full=function(){return c(this.__useEl,this.__path),r(this.__useEl,this.__config),this},t.prototype.arc=function(t,e,i,n,r){var o=l(t,e,n/180*Math.PI,t+i,e),s=l(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}();return function(e){function i(t){if(!t)throw new Error("VISLite SVG:The mount point requires an HTMLElement type but encountered null.");var i=t.clientWidth,n=t.clientHeight,r=document.createElementNS("http://www.w3.org/2000/svg","svg");return t.appendChild(r),r.setAttribute("width",i+""),r.setAttribute("height",n+""),r.setAttribute("viewBox","0 0 "+i+" "+n),e.call(this,r)||this}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}(d)},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_SVG=e();
|
package/lib/Shader/index.umd.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.5.
|
|
2
|
+
* VISLite JavaScript Library v0.5.2-alpha.1
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Thu Oct 12 2023 15:44:35 GMT+0800 (China Standard Time)
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
12
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -50,40 +50,40 @@
|
|
|
50
50
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
var loadShader = function (painter, type, source) {
|
|
54
|
-
var shader = painter.createShader(type);
|
|
55
|
-
if (shader == null)
|
|
56
|
-
throw new Error('Unable to create shader!');
|
|
57
|
-
painter.shaderSource(shader, source);
|
|
58
|
-
painter.compileShader(shader);
|
|
59
|
-
if (!painter.getShaderParameter(shader, painter.COMPILE_STATUS))
|
|
60
|
-
throw new Error('Failed to compile shader:' + painter.getShaderInfoLog(shader));
|
|
61
|
-
return shader;
|
|
62
|
-
};
|
|
63
|
-
var useShader = function (painter, vshaderSource, fshaderSource) {
|
|
64
|
-
var vertexShader = loadShader(painter, painter.VERTEX_SHADER, vshaderSource);
|
|
65
|
-
var fragmentShader = loadShader(painter, painter.FRAGMENT_SHADER, fshaderSource);
|
|
66
|
-
var glProgram = painter.createProgram();
|
|
67
|
-
painter.attachShader(glProgram, vertexShader);
|
|
68
|
-
painter.attachShader(glProgram, fragmentShader);
|
|
69
|
-
painter.linkProgram(glProgram);
|
|
70
|
-
if (!painter.getProgramParameter(glProgram, painter.LINK_STATUS))
|
|
71
|
-
throw new Error('Failed to link program: ' + painter.getProgramInfoLog(glProgram));
|
|
72
|
-
return glProgram;
|
|
73
|
-
};
|
|
74
|
-
var ShaderObject = (function () {
|
|
75
|
-
function ShaderObject(painter) {
|
|
76
|
-
this.__painter = painter;
|
|
77
|
-
}
|
|
78
|
-
ShaderObject.prototype.use = function () {
|
|
79
|
-
this.__painter.useProgram(this.program);
|
|
80
|
-
return this;
|
|
81
|
-
};
|
|
82
|
-
ShaderObject.prototype.compile = function (vshaderSource, fshaderSource) {
|
|
83
|
-
this.program = useShader(this.__painter, vshaderSource, fshaderSource);
|
|
84
|
-
return this;
|
|
85
|
-
};
|
|
86
|
-
return ShaderObject;
|
|
53
|
+
var loadShader = function (painter, type, source) {
|
|
54
|
+
var shader = painter.createShader(type);
|
|
55
|
+
if (shader == null)
|
|
56
|
+
throw new Error('Unable to create shader!');
|
|
57
|
+
painter.shaderSource(shader, source);
|
|
58
|
+
painter.compileShader(shader);
|
|
59
|
+
if (!painter.getShaderParameter(shader, painter.COMPILE_STATUS))
|
|
60
|
+
throw new Error('Failed to compile shader:' + painter.getShaderInfoLog(shader));
|
|
61
|
+
return shader;
|
|
62
|
+
};
|
|
63
|
+
var useShader = function (painter, vshaderSource, fshaderSource) {
|
|
64
|
+
var vertexShader = loadShader(painter, painter.VERTEX_SHADER, vshaderSource);
|
|
65
|
+
var fragmentShader = loadShader(painter, painter.FRAGMENT_SHADER, fshaderSource);
|
|
66
|
+
var glProgram = painter.createProgram();
|
|
67
|
+
painter.attachShader(glProgram, vertexShader);
|
|
68
|
+
painter.attachShader(glProgram, fragmentShader);
|
|
69
|
+
painter.linkProgram(glProgram);
|
|
70
|
+
if (!painter.getProgramParameter(glProgram, painter.LINK_STATUS))
|
|
71
|
+
throw new Error('Failed to link program: ' + painter.getProgramInfoLog(glProgram));
|
|
72
|
+
return glProgram;
|
|
73
|
+
};
|
|
74
|
+
var ShaderObject = (function () {
|
|
75
|
+
function ShaderObject(painter) {
|
|
76
|
+
this.__painter = painter;
|
|
77
|
+
}
|
|
78
|
+
ShaderObject.prototype.use = function () {
|
|
79
|
+
this.__painter.useProgram(this.program);
|
|
80
|
+
return this;
|
|
81
|
+
};
|
|
82
|
+
ShaderObject.prototype.compile = function (vshaderSource, fshaderSource) {
|
|
83
|
+
this.program = useShader(this.__painter, vshaderSource, fshaderSource);
|
|
84
|
+
return this;
|
|
85
|
+
};
|
|
86
|
+
return ShaderObject;
|
|
87
87
|
}());
|
|
88
88
|
|
|
89
89
|
var vsColor = "attribute vec4 a_position;\nuniform mat4 u_matrix;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n\n // 把原生的WebGL使用的左手坐标系变成了右手坐标系\n temp.z = -1.0 * temp.z;\n\n // 表示眼睛距离vec4(0.0,0.0,1.0)的距离\n float dist = 4.0;\n\n // 使用投影直接计算\n // 为保证纹理和相对位置正确\n // x、y、z的改变满足线性变换\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n}";
|
|
@@ -102,31 +102,31 @@
|
|
|
102
102
|
|
|
103
103
|
var fsCube = "precision mediump float;\n\nvarying vec3 v_normal;\nuniform samplerCube u_texture;\n\nvoid main()\n{\n gl_FragColor = textureCube(u_texture, normalize(v_normal));\n}";
|
|
104
104
|
|
|
105
|
-
var Shader = (function (_super) {
|
|
106
|
-
__extends(Shader, _super);
|
|
107
|
-
function Shader() {
|
|
108
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
109
|
-
}
|
|
110
|
-
Shader.prototype.compile = function (arg1, arg2) {
|
|
111
|
-
if (arg2) {
|
|
112
|
-
_super.prototype.compile.call(this, arg1, arg2);
|
|
113
|
-
}
|
|
114
|
-
else {
|
|
115
|
-
_super.prototype.compile.call(this, {
|
|
116
|
-
"color": vsColor,
|
|
117
|
-
"colors": vsColors,
|
|
118
|
-
"image": vsImage,
|
|
119
|
-
"cube": vsCube
|
|
120
|
-
}[arg1], {
|
|
121
|
-
"color": fsColor,
|
|
122
|
-
"colors": fsColors,
|
|
123
|
-
"image": fsImage,
|
|
124
|
-
"cube": fsCube
|
|
125
|
-
}[arg1]);
|
|
126
|
-
}
|
|
127
|
-
return this;
|
|
128
|
-
};
|
|
129
|
-
return Shader;
|
|
105
|
+
var Shader = (function (_super) {
|
|
106
|
+
__extends(Shader, _super);
|
|
107
|
+
function Shader() {
|
|
108
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
109
|
+
}
|
|
110
|
+
Shader.prototype.compile = function (arg1, arg2) {
|
|
111
|
+
if (arg2) {
|
|
112
|
+
_super.prototype.compile.call(this, arg1, arg2);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
_super.prototype.compile.call(this, {
|
|
116
|
+
"color": vsColor,
|
|
117
|
+
"colors": vsColors,
|
|
118
|
+
"image": vsImage,
|
|
119
|
+
"cube": vsCube
|
|
120
|
+
}[arg1], {
|
|
121
|
+
"color": fsColor,
|
|
122
|
+
"colors": fsColors,
|
|
123
|
+
"image": fsImage,
|
|
124
|
+
"cube": fsCube
|
|
125
|
+
}[arg1]);
|
|
126
|
+
}
|
|
127
|
+
return this;
|
|
128
|
+
};
|
|
129
|
+
return Shader;
|
|
130
130
|
}(ShaderObject));
|
|
131
131
|
|
|
132
132
|
return Shader;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.5.
|
|
2
|
+
* VISLite JavaScript Library v0.5.2-alpha.1
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Thu Oct 12 2023 15:44:35 GMT+0800 (China Standard Time)
|
|
10
10
|
*/
|
|
11
11
|
var t,n;t=this,n=function(){"use strict";var t=function(n,e){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)Object.prototype.hasOwnProperty.call(n,e)&&(t[e]=n[e])},t(n,e)};"function"==typeof SuppressedError&&SuppressedError;var n=function(t,n,e){var o=t.createShader(n);if(null==o)throw new Error("Unable to create shader!");if(t.shaderSource(o,e),t.compileShader(o),!t.getShaderParameter(o,t.COMPILE_STATUS))throw new Error("Failed to compile shader:"+t.getShaderInfoLog(o));return o},e=function(){function t(t){this.__painter=t}return t.prototype.use=function(){return this.__painter.useProgram(this.program),this},t.prototype.compile=function(t,e){return this.program=function(t,e,o){var r=n(t,t.VERTEX_SHADER,e),i=n(t,t.FRAGMENT_SHADER,o),a=t.createProgram();if(t.attachShader(a,r),t.attachShader(a,i),t.linkProgram(a),!t.getProgramParameter(a,t.LINK_STATUS))throw new Error("Failed to link program: "+t.getProgramInfoLog(a));return a}(this.__painter,t,e),this},t}(),o=function(n){function e(){return null!==n&&n.apply(this,arguments)||this}return function(n,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}(e,n),e.prototype.compile=function(t,e){return e?n.prototype.compile.call(this,t,e):n.prototype.compile.call(this,{color:"attribute vec4 a_position;\nuniform mat4 u_matrix;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n\n // 把原生的WebGL使用的左手坐标系变成了右手坐标系\n temp.z = -1.0 * temp.z;\n\n // 表示眼睛距离vec4(0.0,0.0,1.0)的距离\n float dist = 4.0;\n\n // 使用投影直接计算\n // 为保证纹理和相对位置正确\n // x、y、z的改变满足线性变换\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n}",colors:"attribute vec4 a_position;\nuniform mat4 u_matrix;\nattribute vec4 a_color;\nvarying vec4 v_color;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n temp.z = -1.0 * temp.z;\n float dist = 4.0;\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n v_color = a_color;\n}",image:"attribute vec4 a_position;\nuniform mat4 u_matrix;\nattribute vec2 a_textcoord;\nvarying vec2 v_textcoord;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n temp.z = -1.0 * temp.z;\n float dist = 4.0;\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n v_textcoord = a_textcoord;\n}",cube:"attribute vec4 a_position;\nuniform mat4 u_matrix;\nattribute vec4 a_normal;\nvarying vec3 v_normal;\n\nvoid main()\n{\n vec4 temp = u_matrix * a_position;\n temp.z = -1.0 * temp.z;\n float dist = 4.0;\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\n\n v_normal = normalize(vec3(a_normal));\n}"}[t],{color:"precision mediump float;\n\nuniform vec4 u_color;\n\nvoid main()\n{\n gl_FragColor = u_color;\n}",colors:"precision mediump float;\n\nvarying vec4 v_color;\n\nvoid main()\n{\n gl_FragColor = v_color;\n}",image:"precision mediump float;\n\nuniform sampler2D u_sampler;\nvarying vec2 v_textcoord;\n\nvoid main()\n{\n gl_FragColor = texture2D(u_sampler, v_textcoord);\n}",cube:"precision mediump float;\n\nvarying vec3 v_normal;\nuniform samplerCube u_texture;\n\nvoid main()\n{\n gl_FragColor = textureCube(u_texture, normalize(v_normal));\n}"}[t]),this},e}(e);return o},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_Shader=n();
|
package/lib/Texture/index.umd.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.5.
|
|
2
|
+
* VISLite JavaScript Library v0.5.2-alpha.1
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Thu Oct 12 2023 15:44:35 GMT+0800 (China Standard Time)
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
12
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -14,57 +14,57 @@
|
|
|
14
14
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VISLite_Texture = factory());
|
|
15
15
|
})(this, (function () { 'use strict';
|
|
16
16
|
|
|
17
|
-
var initTexture = function (painter, type, unit) {
|
|
18
|
-
var texture = painter.createTexture();
|
|
19
|
-
painter.activeTexture(painter['TEXTURE' + unit]);
|
|
20
|
-
painter.bindTexture(type, texture);
|
|
21
|
-
return texture;
|
|
22
|
-
};
|
|
23
|
-
var linkImage = function (painter, type, level, format, textureType, image) {
|
|
24
|
-
painter.texImage2D(type, level, format, format, textureType, image);
|
|
25
|
-
};
|
|
26
|
-
var linkCube = function (painter, type, level, format, textureType, images, width, height, texture) {
|
|
27
|
-
var types = [
|
|
28
|
-
painter.TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
29
|
-
painter.TEXTURE_CUBE_MAP_NEGATIVE_X,
|
|
30
|
-
painter.TEXTURE_CUBE_MAP_POSITIVE_Y,
|
|
31
|
-
painter.TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
|
32
|
-
painter.TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
33
|
-
painter.TEXTURE_CUBE_MAP_NEGATIVE_Z
|
|
34
|
-
], target;
|
|
35
|
-
for (var i = 0; i < types.length; i++) {
|
|
36
|
-
if (images[i]) {
|
|
37
|
-
target = types[i];
|
|
38
|
-
painter.texImage2D(target, level, format, width, height, 0, format, textureType, null);
|
|
39
|
-
painter.bindTexture(type, texture);
|
|
40
|
-
painter.texImage2D(target, level, format, format, textureType, images[i]);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
painter.generateMipmap(type);
|
|
44
|
-
};
|
|
45
|
-
var TextureObject = (function () {
|
|
46
|
-
function TextureObject(painter, type, unit) {
|
|
47
|
-
if (unit === void 0) { unit = 0; }
|
|
48
|
-
this.__painter = painter;
|
|
49
|
-
this.__type = {
|
|
50
|
-
"2d": painter.TEXTURE_2D,
|
|
51
|
-
"cube": painter.TEXTURE_CUBE_MAP
|
|
52
|
-
}[type];
|
|
53
|
-
this.__texture = initTexture(painter, this.__type, unit);
|
|
54
|
-
painter.texParameteri(this.__type, painter.TEXTURE_MIN_FILTER, painter.NEAREST);
|
|
55
|
-
painter.texParameteri(this.__type, painter.TEXTURE_MAG_FILTER, painter.NEAREST);
|
|
56
|
-
painter.texParameteri(this.__type, painter.TEXTURE_WRAP_S, painter.CLAMP_TO_EDGE);
|
|
57
|
-
painter.texParameteri(this.__type, painter.TEXTURE_WRAP_T, painter.CLAMP_TO_EDGE);
|
|
58
|
-
}
|
|
59
|
-
TextureObject.prototype.useImage = function (image) {
|
|
60
|
-
linkImage(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, image);
|
|
61
|
-
return this;
|
|
62
|
-
};
|
|
63
|
-
TextureObject.prototype.useCube = function (images, width, height) {
|
|
64
|
-
linkCube(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, images, width, height, this.__texture);
|
|
65
|
-
return this;
|
|
66
|
-
};
|
|
67
|
-
return TextureObject;
|
|
17
|
+
var initTexture = function (painter, type, unit) {
|
|
18
|
+
var texture = painter.createTexture();
|
|
19
|
+
painter.activeTexture(painter['TEXTURE' + unit]);
|
|
20
|
+
painter.bindTexture(type, texture);
|
|
21
|
+
return texture;
|
|
22
|
+
};
|
|
23
|
+
var linkImage = function (painter, type, level, format, textureType, image) {
|
|
24
|
+
painter.texImage2D(type, level, format, format, textureType, image);
|
|
25
|
+
};
|
|
26
|
+
var linkCube = function (painter, type, level, format, textureType, images, width, height, texture) {
|
|
27
|
+
var types = [
|
|
28
|
+
painter.TEXTURE_CUBE_MAP_POSITIVE_X,
|
|
29
|
+
painter.TEXTURE_CUBE_MAP_NEGATIVE_X,
|
|
30
|
+
painter.TEXTURE_CUBE_MAP_POSITIVE_Y,
|
|
31
|
+
painter.TEXTURE_CUBE_MAP_NEGATIVE_Y,
|
|
32
|
+
painter.TEXTURE_CUBE_MAP_POSITIVE_Z,
|
|
33
|
+
painter.TEXTURE_CUBE_MAP_NEGATIVE_Z
|
|
34
|
+
], target;
|
|
35
|
+
for (var i = 0; i < types.length; i++) {
|
|
36
|
+
if (images[i]) {
|
|
37
|
+
target = types[i];
|
|
38
|
+
painter.texImage2D(target, level, format, width, height, 0, format, textureType, null);
|
|
39
|
+
painter.bindTexture(type, texture);
|
|
40
|
+
painter.texImage2D(target, level, format, format, textureType, images[i]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
painter.generateMipmap(type);
|
|
44
|
+
};
|
|
45
|
+
var TextureObject = (function () {
|
|
46
|
+
function TextureObject(painter, type, unit) {
|
|
47
|
+
if (unit === void 0) { unit = 0; }
|
|
48
|
+
this.__painter = painter;
|
|
49
|
+
this.__type = {
|
|
50
|
+
"2d": painter.TEXTURE_2D,
|
|
51
|
+
"cube": painter.TEXTURE_CUBE_MAP
|
|
52
|
+
}[type];
|
|
53
|
+
this.__texture = initTexture(painter, this.__type, unit);
|
|
54
|
+
painter.texParameteri(this.__type, painter.TEXTURE_MIN_FILTER, painter.NEAREST);
|
|
55
|
+
painter.texParameteri(this.__type, painter.TEXTURE_MAG_FILTER, painter.NEAREST);
|
|
56
|
+
painter.texParameteri(this.__type, painter.TEXTURE_WRAP_S, painter.CLAMP_TO_EDGE);
|
|
57
|
+
painter.texParameteri(this.__type, painter.TEXTURE_WRAP_T, painter.CLAMP_TO_EDGE);
|
|
58
|
+
}
|
|
59
|
+
TextureObject.prototype.useImage = function (image) {
|
|
60
|
+
linkImage(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, image);
|
|
61
|
+
return this;
|
|
62
|
+
};
|
|
63
|
+
TextureObject.prototype.useCube = function (images, width, height) {
|
|
64
|
+
linkCube(this.__painter, this.__type, 0, this.__painter.RGBA, this.__painter.UNSIGNED_BYTE, images, width, height, this.__texture);
|
|
65
|
+
return this;
|
|
66
|
+
};
|
|
67
|
+
return TextureObject;
|
|
68
68
|
}());
|
|
69
69
|
|
|
70
70
|
return TextureObject;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.5.
|
|
2
|
+
* VISLite JavaScript Library v0.5.2-alpha.1
|
|
3
3
|
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
4
|
*
|
|
5
5
|
* Copyright zxl20070701
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
* https://zxl20070701.github.io/notebook/home.html
|
|
8
8
|
*
|
|
9
|
-
* Publish Date:
|
|
9
|
+
* Publish Date: Thu Oct 12 2023 15:44:35 GMT+0800 (China Standard Time)
|
|
10
10
|
*/
|
|
11
11
|
var e,t;e=this,t=function(){"use strict";return function(){function e(e,t,_){void 0===_&&(_=0),this.__painter=e,this.__type={"2d":e.TEXTURE_2D,cube:e.TEXTURE_CUBE_MAP}[t],this.__texture=function(e,t,_){var E=e.createTexture();return e.activeTexture(e["TEXTURE"+_]),e.bindTexture(t,E),E}(e,this.__type,_),e.texParameteri(this.__type,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(this.__type,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(this.__type,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(this.__type,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE)}return e.prototype.useImage=function(e){return function(e,t,_,E,i,T){e.texImage2D(t,_,E,E,i,T)}(this.__painter,this.__type,0,this.__painter.RGBA,this.__painter.UNSIGNED_BYTE,e),this},e.prototype.useCube=function(e,t,_){return function(e,t,_,E,i,T,r,n,u){for(var a,s=[e.TEXTURE_CUBE_MAP_POSITIVE_X,e.TEXTURE_CUBE_MAP_NEGATIVE_X,e.TEXTURE_CUBE_MAP_POSITIVE_Y,e.TEXTURE_CUBE_MAP_NEGATIVE_Y,e.TEXTURE_CUBE_MAP_POSITIVE_Z,e.TEXTURE_CUBE_MAP_NEGATIVE_Z],p=0;p<s.length;p++)T[p]&&(a=s[p],e.texImage2D(a,_,E,r,n,0,E,i,null),e.bindTexture(t,u),e.texImage2D(a,_,E,E,i,T[p]));e.generateMipmap(t)}(this.__painter,this.__type,0,this.__painter.RGBA,this.__painter.UNSIGNED_BYTE,e,t,_,this.__texture),this},e}()},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_Texture=t();
|