vislite 0.6.0 → 0.7.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 (118) hide show
  1. package/CHANGELOG +15 -1
  2. package/README.md +24 -5
  3. package/lib/Buffer/index.umd.js +2 -2
  4. package/lib/Buffer/index.umd.min.js +2 -2
  5. package/lib/Canvas/index.umd.js +4 -4
  6. package/lib/Canvas/index.umd.min.js +3 -3
  7. package/lib/Cardinal/index.umd.js +2 -2
  8. package/lib/Cardinal/index.umd.min.js +2 -2
  9. package/lib/Eoap/index.umd.js +2 -2
  10. package/lib/Eoap/index.umd.min.js +2 -2
  11. package/lib/Geometry/index.umd.js +69 -8
  12. package/lib/Geometry/index.umd.min.js +3 -3
  13. package/lib/Hermite/index.umd.js +2 -2
  14. package/lib/Hermite/index.umd.min.js +2 -2
  15. package/lib/Matrix4/index.umd.js +2 -2
  16. package/lib/Matrix4/index.umd.min.js +2 -2
  17. package/lib/Mercator/index.umd.js +2 -2
  18. package/lib/Mercator/index.umd.min.js +2 -2
  19. package/lib/OralCanvas/index.es.js +3 -3
  20. package/lib/OralCanvas/index.es.min.js +3 -3
  21. package/lib/OralWebGL/index.es.js +21 -18
  22. package/lib/OralWebGL/index.es.min.js +3 -3
  23. package/lib/SVG/index.umd.js +2 -2
  24. package/lib/SVG/index.umd.min.js +2 -2
  25. package/lib/Shader/index.umd.js +3 -2
  26. package/lib/Shader/index.umd.min.js +3 -3
  27. package/lib/Texture/index.umd.js +2 -2
  28. package/lib/Texture/index.umd.min.js +2 -2
  29. package/lib/TreeLayout/index.umd.js +13 -11
  30. package/lib/TreeLayout/index.umd.min.js +3 -3
  31. package/lib/WebGL/index.umd.js +22 -19
  32. package/lib/WebGL/index.umd.min.js +3 -3
  33. package/lib/animation/index.umd.js +2 -2
  34. package/lib/animation/index.umd.min.js +2 -2
  35. package/lib/formatColor/index.umd.js +2 -2
  36. package/lib/formatColor/index.umd.min.js +2 -2
  37. package/lib/getLoopColors/index.umd.js +2 -2
  38. package/lib/getLoopColors/index.umd.min.js +2 -2
  39. package/lib/getWebGLContext/index.umd.js +4 -4
  40. package/lib/getWebGLContext/index.umd.min.js +3 -3
  41. package/lib/index.umd.js +104 -38
  42. package/lib/index.umd.min.js +3 -3
  43. package/lib/move/index.umd.js +2 -2
  44. package/lib/move/index.umd.min.js +2 -2
  45. package/lib/resizeObserver/index.umd.js +2 -2
  46. package/lib/resizeObserver/index.umd.min.js +2 -2
  47. package/lib/rotate/index.umd.js +2 -2
  48. package/lib/rotate/index.umd.min.js +2 -2
  49. package/lib/ruler/index.umd.js +4 -4
  50. package/lib/ruler/index.umd.min.js +3 -3
  51. package/lib/scale/index.umd.js +2 -2
  52. package/lib/scale/index.umd.min.js +2 -2
  53. package/lib/throttle/index.umd.js +2 -2
  54. package/lib/throttle/index.umd.min.js +2 -2
  55. package/lib/viewHandler/index.umd.js +2 -2
  56. package/lib/viewHandler/index.umd.min.js +2 -2
  57. package/package/TreeLayout/index.ts +2 -2
  58. package/package.json +1 -1
  59. package/src/Canvas.ts +1 -1
  60. package/src/Eoap.ts +66 -66
  61. package/src/Geometry.ts +57 -13
  62. package/src/Matrix4/index.ts +84 -84
  63. package/src/Matrix4/move.ts +12 -12
  64. package/src/Matrix4/rotate.ts +1 -1
  65. package/src/Matrix4/transform.ts +1 -1
  66. package/src/Mercator.ts +27 -27
  67. package/src/SVG.ts +24 -24
  68. package/src/WebGL.ts +1 -1
  69. package/src/animation.ts +98 -98
  70. package/src/common/assemble.ts +1 -1
  71. package/src/common/canvas/arc.ts +51 -51
  72. package/src/common/canvas/config.ts +158 -158
  73. package/src/common/canvas/gradient.ts +29 -29
  74. package/src/common/canvas/index.ts +2 -2
  75. package/src/common/canvas/painter.ts +2 -0
  76. package/src/common/geometry/prism-horizontal.ts +35 -35
  77. package/src/common/geometry/prism-vertical.ts +1 -1
  78. package/src/common/geometry/sphere-fragment.ts +40 -40
  79. package/src/common/geometry/tool/circle.ts +11 -11
  80. package/src/common/geometry/tool/rotateLine.ts +36 -0
  81. package/src/common/mergeOption.ts +6 -6
  82. package/src/common/setStyle.ts +1 -1
  83. package/src/common/svg/config.ts +10 -6
  84. package/src/common/svg/gradient.ts +63 -63
  85. package/src/common/svg/index.ts +5 -5
  86. package/src/common/svg/tool.ts +6 -6
  87. package/src/common/tree/toInnerTree.ts +8 -6
  88. package/src/common/tree/toPlainTree.ts +1 -1
  89. package/src/common/webgl/buffer.ts +1 -1
  90. package/src/common/webgl/doDraw.ts +16 -16
  91. package/src/common/webgl/getColorFactory.ts +26 -26
  92. package/src/common/webgl/getShader.ts +48 -48
  93. package/src/common/webgl/getTexture.ts +11 -11
  94. package/src/common/webgl/getWebGLContext.ts +3 -3
  95. package/src/common/webgl/index.ts +6 -4
  96. package/src/common/webgl/shader.ts +3 -3
  97. package/src/common/webgl/texture.ts +2 -2
  98. package/src/formatColor.ts +44 -44
  99. package/src/getLoopColors.ts +42 -42
  100. package/src/interpolation/Cardinal.ts +110 -110
  101. package/src/interpolation/Hermite.ts +65 -65
  102. package/src/layout/TreeLayout.ts +13 -11
  103. package/src/move.ts +7 -7
  104. package/src/resizeObserver.ts +2 -2
  105. package/src/rotate.ts +7 -7
  106. package/src/ruler.ts +10 -10
  107. package/src/throttle.ts +52 -52
  108. package/src/viewHandler.ts +4 -2
  109. package/types/Canvas.d.ts +1 -1
  110. package/types/CanvasOption.d.ts +8 -8
  111. package/types/CanvasOpts.d.ts +9 -9
  112. package/types/Geometry.d.ts +65 -40
  113. package/types/Matrix4.d.ts +47 -47
  114. package/types/SVGConfig.d.ts +79 -76
  115. package/types/TreeConfig.d.ts +36 -24
  116. package/uni-app/ui-canvas.vue +9 -31
  117. package/.editorconfig +0 -19
  118. package/.eslintrc.js +0 -26
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  var e,r;e=this,r=function(){"use strict";var e,r={},n=0;return function(o,t){try{return e||(e=new ResizeObserver((function(e){for(var n=0,o=e;n<o.length;n++){var t=o[n];r[t.target._resize_observer_]()}}))),n++,o._resize_observer_=n,r[n]=t,e.observe(o),function(){e&&(e.unobserve(o),delete r[o._resize_observer_])}}catch(e){t(),console.error("ResizeObserver undefined!")}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_resizeObserver=r();
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  var e,t;e=this,t=function(){"use strict";return function(e,t,n,o,i){var f=Math.cos(n),d=Math.sin(n);return[(o-e)*f-(i-t)*d+e,(o-e)*d+(i-t)*f+t]}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_rotate=t();
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -80,7 +80,7 @@
80
80
  var rulerArray = getResult(0);
81
81
  var balanceMax = function () {
82
82
  var rulerArray_temp = [];
83
- var changeDist = rulerArray[rulerArray.length - 1] - option.max;
83
+ var changeDist = rulerArray[rulerArray.length - 1] - (option === null || option === void 0 ? void 0 : option.max);
84
84
  for (var index = 0; index < rulerArray.length; index++) {
85
85
  if (index + 1 < rulerArray.length && rulerArray[index + 1] - changeDist < minValue) ;
86
86
  else {
@@ -91,7 +91,7 @@
91
91
  };
92
92
  var balanceMin = function () {
93
93
  var rulerArray_temp = [];
94
- var changeDist = rulerArray[0] - option.min;
94
+ var changeDist = rulerArray[0] - (option === null || option === void 0 ? void 0 : option.min);
95
95
  for (var index = 0; index < rulerArray.length; index++) {
96
96
  rulerArray_temp[index] = rulerArray[index] - changeDist;
97
97
  if (maxValue <= rulerArray_temp[index])
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
- var n,e;n=this,e=function(){"use strict";return function(n,e,r,t){if(n<e){var i=e;e=n,n=i}else if(n==e)return[n];var f=function(n){for(var e=n<100&&n>-100?10:.1,r=-1,t=n;10==e?t>=-100&&t<=100:t<=-100||t>=100;)r+=1,t*=e;if(10==e)return Math.pow(10,r);for(var i="0.",f=1;f<r;f++)i+="0";return+(i+"1")}(n-e),a=Math.ceil((n-e)*f/r),u=function(r){var t=({3:2,4:5,6:5,7:5,8:10,9:10,11:10,12:10,13:15,14:15,16:15,17:15,18:20,19:20,21:20,22:20,23:25,24:25,26:25,27:25}[a+r]||a+r)/f,i=Math.floor(e/t)*t,u=[];u.push(i);for(var o=1;u[u.length-1]<n;o++)u.push(i+t*o);return u},o=u(0),l=function(){for(var n=[],r=o[o.length-1]-t.max,i=0;i<o.length;i++)i+1<o.length&&o[i+1]-r<e||n.push(o[i]-r);return n},h=function(){for(var e=[],r=o[0]-t.min,i=0;i<o.length&&(e[i]=o[i]-r,!(n<=e[i]));i++);return e};if(t){if("max"in t&&"min"in t&&t.max>=n&&t.min<=e){var m=function(){if(o[0]>=t.min&&o[o.length-1]<=t.max)return!0;var n=l();if(n[0]>=t.min&&n[n.length-1]<=t.max)return o=n,!0;var e=h();return e[0]>=t.min&&e[n.length-1]<=t.max?(o=e,!0):void 0};if(m())return o;for(var s=1;s<100;s++){if(o=u(s),m())return o;if(o=u(-s),m())return o}}"max"in t&&t.max>=n?t.max<o[o.length-1]&&(o=l()):"min"in t&&t.min<=e&&t.min>o[0]&&(o=h())}for(var v=0;v<o.length;v++){var g=o[v]+"";/\./.test(g)&&(/9{7,}$/.test(g)?(g=g.replace(/9{7,}$/,""),o[v]=+(g.substring(0,g.length-1)+(+g[g.length-1]+1))):/0{7,}\d$/.test(g)&&(o[v]=+g.replace(/0{7,}\d$/,"")))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).VISLite_ruler=e();
11
+ var n,e;n=this,e=function(){"use strict";return function(n,e,r,t){if(n<e){var i=e;e=n,n=i}else if(n==e)return[n];var f=function(n){for(var e=n<100&&n>-100?10:.1,r=-1,t=n;10==e?t>=-100&&t<=100:t<=-100||t>=100;)r+=1,t*=e;if(10==e)return Math.pow(10,r);for(var i="0.",f=1;f<r;f++)i+="0";return+(i+"1")}(n-e),u=Math.ceil((n-e)*f/r),a=function(r){var t=({3:2,4:5,6:5,7:5,8:10,9:10,11:10,12:10,13:15,14:15,16:15,17:15,18:20,19:20,21:20,22:20,23:25,24:25,26:25,27:25}[u+r]||u+r)/f,i=Math.floor(e/t)*t,a=[];a.push(i);for(var o=1;a[a.length-1]<n;o++)a.push(i+t*o);return a},o=a(0),l=function(){for(var n=[],r=o[o.length-1]-(null==t?void 0:t.max),i=0;i<o.length;i++)i+1<o.length&&o[i+1]-r<e||n.push(o[i]-r);return n},h=function(){for(var e=[],r=o[0]-(null==t?void 0:t.min),i=0;i<o.length&&(e[i]=o[i]-r,!(n<=e[i]));i++);return e};if(t){if("max"in t&&"min"in t&&t.max>=n&&t.min<=e){var m=function(){if(o[0]>=t.min&&o[o.length-1]<=t.max)return!0;var n=l();if(n[0]>=t.min&&n[n.length-1]<=t.max)return o=n,!0;var e=h();return e[0]>=t.min&&e[n.length-1]<=t.max?(o=e,!0):void 0};if(m())return o;for(var v=1;v<100;v++){if(o=a(v),m())return o;if(o=a(-v),m())return o}}"max"in t&&t.max>=n?t.max<o[o.length-1]&&(o=l()):"min"in t&&t.min<=e&&t.min>o[0]&&(o=h())}for(var s=0;s<o.length;s++){var d=o[s]+"";/\./.test(d)&&(/9{7,}$/.test(d)?(d=d.replace(/9{7,}$/,""),o[s]=+(d.substring(0,d.length-1)+(+d[d.length-1]+1))):/0{7,}\d$/.test(d)&&(o[s]=+d.replace(/0{7,}\d$/,"")))}return o}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n="undefined"!=typeof globalThis?globalThis:n||self).VISLite_ruler=e();
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  var e,t;e=this,t=function(){"use strict";return function(e,t,n,o,f){return[n*(o-e)+e,n*(f-t)+t]}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_scale=t();
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  var e,t;e=this,t=function(){"use strict";return function(e,t){void 0===t&&(t={}),t=function(e,t){for(var n in e)t[n]=e[n];return t}(t,{time:200,keep:!1,opportunity:"end"});var n,o=!1,i=!1,r=!1;return function(){var p=this;if(n=arguments,o)i=!0,r=!0;else{"end"!=t.opportunity&&e.apply(p,n),o=!0;var f=setInterval((function(){i?t.keep||e.apply(p,n):("begin"!=t.opportunity&&(r||"end"==t.opportunity)&&e.apply(p,n),o=!1,r=!1,clearInterval(f)),i=!1}),t.time)}}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_throttle=t();
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.6.0
2
+ * VISLite JavaScript Library v0.7.0
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: Sun Dec 17 2023 17:10:48 GMT+0800 (中国标准时间)
9
+ * Publish Date: Sun Jan 14 2024 15:48:51 GMT+0800 (中国标准时间)
10
10
  */
11
11
  var e,n;e=this,n=function(){"use strict";var e=function(e,n){var t=e.getBoundingClientRect();return{x:n.clientX-t.left,y:n.clientY-t.top}};return function(n){var t=document.getElementsByTagName("body")[0];t.addEventListener("keydown",(function(e){var t=function(e){return{37:"left",38:"up",39:"right",40:"down"}[e.keyCode||e.which]}(e);"up"==t?n({type:"lookUp",normal:[],value:.1,event:e}):"down"==t?n({type:"lookDown",normal:[],value:.1,event:e}):"left"==t?n({type:"lookLeft",normal:[],value:.1,event:e}):"right"==t&&n({type:"lookRight",normal:[],value:.1,event:e})}));var o=null,i=function(i){if(null==o)n({type:"hover",normal:[],value:0,event:i});else{var u=e(t,i),l=[u.x-o.x,u.y-o.y],a=[l[1],l[0],0];if(0==a[0]&&0==a[1])return;n({type:"rotate",normal:a,value:.01*(Math.abs(u.x-o.x)+Math.abs(u.y-o.y)),event:i}),o=u}};t.addEventListener("mousedown",(function(n){o=e(t,n)})),t.addEventListener("mouseup",(function(){o=null})),t.addEventListener("mousemove",(function(e){i(e)})),t.addEventListener("touchend",(function(){o=null})),t.addEventListener("touchstart",(function(n){o=e(t,n)})),t.addEventListener("touchmove",(function(e){i(e.touches[0])}));var u=function(e,t){0!=e&&n({type:"scale",value:e<0?.899:1.101,normal:[],event:t})};t.addEventListener("mousewheel",(function(e){u(e.wheelDelta,e)})),window.addEventListener&&window.addEventListener("DOMMouseScroll",(function(e){u(-1*e.detail,e)}),!1)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_viewHandler=n();
@@ -1,3 +1,3 @@
1
- import TreeLayout from "../../src/layout/TreeLayout"
2
-
1
+ import TreeLayout from "../../src/layout/TreeLayout"
2
+
3
3
  export default TreeLayout
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vislite",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "灵活、快速、简单的数据可视化交互式跨端前端库",
5
5
  "main": "./lib/index.umd.min.js",
6
6
  "typings": "./types/index.d.ts",
package/src/Canvas.ts CHANGED
@@ -18,7 +18,7 @@ class Canvas extends OralCanvas implements CanvasType {
18
18
 
19
19
  const width = el.clientWidth, height = el.clientHeight
20
20
 
21
- let ViewCanvas: HTMLCanvasElement, RegionCanvas: HTMLCanvasElement
21
+ let ViewCanvas: HTMLCanvasElement, RegionCanvas: HTMLCanvasElement | null = null
22
22
 
23
23
  const _el = el as any
24
24
 
package/src/Eoap.ts CHANGED
@@ -1,66 +1,66 @@
1
- import type MapType from '../types/Map'
2
-
3
- // 围绕X轴旋转
4
- const rotateX = function (deg: number, x: number, y: number, z: number) {
5
- const cos = Math.cos(deg), sin = Math.sin(deg)
6
- return [x, y * cos - z * sin, y * sin + z * cos]
7
- }
8
-
9
- // 围绕Y轴旋转
10
- const rotateY = function (deg: number, x: number, y: number, z: number) {
11
- const cos = Math.cos(deg), sin = Math.sin(deg)
12
- return [z * sin + x * cos, y, z * cos - x * sin]
13
- }
14
-
15
- // 围绕Z轴旋转
16
- const rotateZ = function (deg: number, x: number, y: number, z: number) {
17
- const cos = Math.cos(deg), sin = Math.sin(deg)
18
- return [x * cos - y * sin, x * sin + y * cos, z]
19
- }
20
-
21
- /* 等角斜方位投影 */
22
- class Eoap implements MapType {
23
- readonly name: string = 'Eoap'
24
-
25
- private __scale: number // 缩放比例
26
- private __center: number[] // 投影中心经纬度
27
-
28
- constructor(scale: number = 7, center: number[] = [107, 36]) {
29
- this.__scale = scale
30
- this.__center = center
31
- }
32
-
33
- use(λ: number, φ: number): [number, number, number] {
34
- /**
35
- * 通过旋转的方法
36
- * 先旋转出点的位置
37
- * 然后根据把地心到旋转中心的这条射线变成OZ这条射线的变换应用到初始化点上
38
- * 这样求的的点的x,y就是最终结果
39
- *
40
- * 计算过程:
41
- * 1.初始化点的位置是p(x,0,0),其中x的值是地球半径除以缩放倍速
42
- * 2.根据点的纬度对p进行旋转,旋转后得到的p的坐标纬度就是目标纬度
43
- * 3.同样的对此刻的p进行经度的旋转,这样就获取了极点作为中心点的坐标
44
- * 4.接着想象一下为了让旋转中心移动到极点需要进行旋转的经纬度是多少,记为lo和la
45
- * 5.然后再对p进行经度度旋转lo获得新的p
46
- * 6.然后再对p进行纬度旋转la获得新的p
47
- * 7.旋转结束
48
- *
49
- * 特别注意:第5和第6步顺序一定不可以调换,原因来自经纬度定义上
50
- * 【除了经度为0的位置,不然纬度的旋转会改变原来的经度值,反过来不会】
51
- *
52
- */
53
- let p = rotateY((360 - φ) / 180 * Math.PI, 100 * this.__scale, 0, 0)
54
- p = rotateZ(λ / 180 * Math.PI, p[0], p[1], p[2])
55
- p = rotateZ((90 - this.__center[0]) / 180 * Math.PI, p[0], p[1], p[2])
56
- p = rotateX((90 - this.__center[1]) / 180 * Math.PI, p[0], p[1], p[2])
57
-
58
- return [
59
- -p[0], // 加-号是因为浏览器坐标和地图不一样
60
- p[1],
61
- p[2]
62
- ]
63
- }
64
- }
65
-
66
- export default Eoap
1
+ import type MapType from '../types/Map'
2
+
3
+ // 围绕X轴旋转
4
+ const rotateX = function (deg: number, x: number, y: number, z: number) {
5
+ const cos = Math.cos(deg), sin = Math.sin(deg)
6
+ return [x, y * cos - z * sin, y * sin + z * cos]
7
+ }
8
+
9
+ // 围绕Y轴旋转
10
+ const rotateY = function (deg: number, x: number, y: number, z: number) {
11
+ const cos = Math.cos(deg), sin = Math.sin(deg)
12
+ return [z * sin + x * cos, y, z * cos - x * sin]
13
+ }
14
+
15
+ // 围绕Z轴旋转
16
+ const rotateZ = function (deg: number, x: number, y: number, z: number) {
17
+ const cos = Math.cos(deg), sin = Math.sin(deg)
18
+ return [x * cos - y * sin, x * sin + y * cos, z]
19
+ }
20
+
21
+ /* 等角斜方位投影 */
22
+ class Eoap implements MapType {
23
+ readonly name: string = 'Eoap'
24
+
25
+ private __scale: number // 缩放比例
26
+ private __center: number[] // 投影中心经纬度
27
+
28
+ constructor(scale: number = 7, center: number[] = [107, 36]) {
29
+ this.__scale = scale
30
+ this.__center = center
31
+ }
32
+
33
+ use(λ: number, φ: number): [number, number, number] {
34
+ /**
35
+ * 通过旋转的方法
36
+ * 先旋转出点的位置
37
+ * 然后根据把地心到旋转中心的这条射线变成OZ这条射线的变换应用到初始化点上
38
+ * 这样求的的点的x,y就是最终结果
39
+ *
40
+ * 计算过程:
41
+ * 1.初始化点的位置是p(x,0,0),其中x的值是地球半径除以缩放倍速
42
+ * 2.根据点的纬度对p进行旋转,旋转后得到的p的坐标纬度就是目标纬度
43
+ * 3.同样的对此刻的p进行经度的旋转,这样就获取了极点作为中心点的坐标
44
+ * 4.接着想象一下为了让旋转中心移动到极点需要进行旋转的经纬度是多少,记为lo和la
45
+ * 5.然后再对p进行经度度旋转lo获得新的p
46
+ * 6.然后再对p进行纬度旋转la获得新的p
47
+ * 7.旋转结束
48
+ *
49
+ * 特别注意:第5和第6步顺序一定不可以调换,原因来自经纬度定义上
50
+ * 【除了经度为0的位置,不然纬度的旋转会改变原来的经度值,反过来不会】
51
+ *
52
+ */
53
+ let p = rotateY((360 - φ) / 180 * Math.PI, 100 * this.__scale, 0, 0)
54
+ p = rotateZ(λ / 180 * Math.PI, p[0], p[1], p[2])
55
+ p = rotateZ((90 - this.__center[0]) / 180 * Math.PI, p[0], p[1], p[2])
56
+ p = rotateX((90 - this.__center[1]) / 180 * Math.PI, p[0], p[1], p[2])
57
+
58
+ return [
59
+ -p[0], // 加-号是因为浏览器坐标和地图不一样
60
+ p[1],
61
+ p[2]
62
+ ]
63
+ }
64
+ }
65
+
66
+ export default Eoap
package/src/Geometry.ts CHANGED
@@ -2,11 +2,14 @@ import type GeometryType from "../types/Geometry"
2
2
  import type GeometryOptionType from "../types/GeometryOption"
3
3
  import type GeometryResultType from "../types/GeometryResult"
4
4
 
5
+ type rotateLineType = (x0: number, y0: number, z0: number, isNormal: boolean) => Array<number>
6
+
5
7
  import { splitNum } from './common/geometry/tool/circle'
6
8
  import prismHorizontal from './common/geometry/prism-horizontal'
7
9
  import prismVertical from './common/geometry/prism-vertical'
8
10
  import sphereFragment from './common/geometry/sphere-fragment'
9
11
  import mergeOption from './common/mergeOption'
12
+ import rotateLineFactory from "./common/geometry/tool/rotateLine"
10
13
 
11
14
  class Geometry implements GeometryType {
12
15
  readonly name: string = 'Geometry'
@@ -28,32 +31,72 @@ class Geometry implements GeometryType {
28
31
  }
29
32
 
30
33
  // 圆柱体
31
- cylinder(x: number, y: number, z: number, radius: number, height: number): Array<GeometryResultType> {
34
+ cylinder(x: number, y: number, z: number, radius: number, x2: number, y2?: number, z2?: number): Array<GeometryResultType> {
32
35
 
33
36
  // 求解出需要切割多少份比较合理
34
- const num = splitNum(this.__option.precision, radius)
35
- return this.prism(x, y, z, radius, height, num)
37
+ const num = splitNum(this.__option.precision as number, radius)
38
+
39
+ if (arguments.length == 5) {
40
+ return this.prism(x, y, z, radius, x2, num)
41
+ } else {
42
+ return this.prism(x, y, z, radius, x2, y2 as number, z2, num)
43
+ }
36
44
  }
37
45
 
38
46
  // 棱柱体
39
- prism(x: number, y: number, z: number, radius: number, height: number, num: number): Array<GeometryResultType> {
47
+ prism(x: number, y: number, z: number, radius: number, x2: number, y2: number, z2?: number, num?: number): Array<GeometryResultType> {
48
+
49
+
50
+ let height: number, rotateLine: rotateLineType | null = null
51
+
52
+ if (arguments.length == 6) {
53
+ height = x2
54
+ num = y2
55
+ } else {
56
+ height = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y) + (z2 as number - z) * (z2 as number - z))
57
+ rotateLine = rotateLineFactory(x, y, z, x2, y2, z2 as number)
58
+ }
40
59
 
41
60
  const result = [{
61
+ name: "bottom",
62
+ points: [],
63
+ length: 0,
64
+ method: "TRIANGLES" as const
65
+ }, {
66
+ name: "top",
67
+ points: [],
68
+ length: 0,
69
+ method: "TRIANGLES" as const
70
+ }, {
71
+ name: "side",
42
72
  points: [],
43
73
  length: 0,
44
74
  method: "TRIANGLES" as const
45
75
  }]
46
76
 
47
- // 绘制底部的盖子
48
- result[0].points.push(...prismHorizontal(this.__option.normal, x, y, z, radius, num, height > 0 ? -1 : 1))
77
+ // 绘制底部的盖子
78
+ ; (result[0].points as Array<number>).push(...prismHorizontal(this.__option.normal as boolean, x, y, z, radius, num as number, height > 0 ? -1 : 1))
79
+
80
+ // 绘制顶部的盖子
81
+ ; (result[1].points as Array<number>).push(...prismHorizontal(this.__option.normal as boolean, x, y + height, z, radius, num as number, height > 0 ? 1 : -1))
49
82
 
50
- // 绘制顶部的盖子
51
- result[0].points.push(...prismHorizontal(this.__option.normal, x, y + height, z, radius, num, height > 0 ? 1 : -1))
83
+ // 绘制侧边部分
84
+ ; (result[2].points as Array<number>).push(...prismVertical(this.__option.normal as boolean, x, y, z, radius, height, num as number))
52
85
 
53
- // 绘制侧边部分
54
- result[0].points.push(...prismVertical(this.__option.normal, x, y, z, radius, height, num))
86
+ for (let i = 0; i < result.length; i++) {
87
+ if (rotateLine) {
88
+
89
+ const points = []
90
+ let isNormal = false
91
+ for (let index = 0; index < result[i].points.length; index += 3) {
92
+ points.push(...rotateLine(result[i].points[index], result[i].points[index + 1], result[i].points[index + 2], (this.__option.normal as boolean) && isNormal))
93
+ isNormal = !isNormal
94
+ }
95
+ (result[i].points as Array<number>) = points
96
+ }
97
+ result[i].length = result[i].points.length / (this.__option.normal ? 6 : 3)
98
+ }
55
99
 
56
- result[0].length = 12 * num
57
100
  return result
58
101
  }
59
102
 
@@ -61,16 +104,17 @@ class Geometry implements GeometryType {
61
104
  sphere(cx: number, cy: number, cz: number, radius: number): Array<GeometryResultType> {
62
105
 
63
106
  // 求解出需要切割多少份比较合理
64
- const num = splitNum(this.__option.precision, radius)
107
+ const num = splitNum(this.__option.precision as number, radius)
65
108
 
66
109
  // 然后一瓣瓣的绘制
67
110
  const result = [{
111
+ name: "surface",
68
112
  points: [],
69
113
  length: 0,
70
114
  method: "TRIANGLES" as const
71
115
  }]
72
116
  for (let i = 0; i < num; i++) {
73
- result[0].points.push(...sphereFragment(this.__option.normal, cx, cy, cz, radius, num, i))
117
+ ; (result[0].points as Array<number>).push(...sphereFragment(this.__option.normal as boolean, cx, cy, cz, radius, num, i))
74
118
  }
75
119
 
76
120
  result[0].length = result[0].points.length / (this.__option.normal ? 6 : 3)