vislite 0.7.1 → 0.8.0-alpha.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 (129) hide show
  1. package/CHANGELOG +28 -2
  2. package/README.md +144 -135
  3. package/lib/Buffer/index.umd.d.ts +3 -0
  4. package/lib/Buffer/index.umd.js +2 -2
  5. package/lib/Buffer/index.umd.min.d.ts +3 -0
  6. package/lib/Buffer/index.umd.min.js +2 -2
  7. package/lib/Canvas/index.umd.d.ts +3 -0
  8. package/lib/Canvas/index.umd.js +26 -2
  9. package/lib/Canvas/index.umd.min.d.ts +3 -0
  10. package/lib/Canvas/index.umd.min.js +3 -3
  11. package/lib/Cardinal/index.umd.d.ts +3 -0
  12. package/lib/Cardinal/index.umd.js +2 -2
  13. package/lib/Cardinal/index.umd.min.d.ts +3 -0
  14. package/lib/Cardinal/index.umd.min.js +2 -2
  15. package/lib/Eoap/index.umd.d.ts +3 -0
  16. package/lib/Eoap/index.umd.js +2 -2
  17. package/lib/Eoap/index.umd.min.d.ts +3 -0
  18. package/lib/Eoap/index.umd.min.js +2 -2
  19. package/lib/Geometry/index.umd.d.ts +3 -0
  20. package/lib/Geometry/index.umd.js +61 -11
  21. package/lib/Geometry/index.umd.min.d.ts +3 -0
  22. package/lib/Geometry/index.umd.min.js +3 -3
  23. package/lib/Hermite/index.umd.d.ts +3 -0
  24. package/lib/Hermite/index.umd.js +2 -2
  25. package/lib/Hermite/index.umd.min.d.ts +3 -0
  26. package/lib/Hermite/index.umd.min.js +2 -2
  27. package/lib/Matrix4/index.umd.d.ts +3 -0
  28. package/lib/Matrix4/index.umd.js +2 -2
  29. package/lib/Matrix4/index.umd.min.d.ts +3 -0
  30. package/lib/Matrix4/index.umd.min.js +2 -2
  31. package/lib/Mercator/index.umd.d.ts +3 -0
  32. package/lib/Mercator/index.umd.js +2 -2
  33. package/lib/Mercator/index.umd.min.d.ts +3 -0
  34. package/lib/Mercator/index.umd.min.js +2 -2
  35. package/lib/OralCanvas/index.es.d.ts +3 -0
  36. package/lib/OralCanvas/index.es.js +26 -2
  37. package/lib/OralCanvas/index.es.min.d.ts +3 -0
  38. package/lib/OralCanvas/index.es.min.js +3 -3
  39. package/lib/OralWebGL/index.es.d.ts +3 -0
  40. package/lib/OralWebGL/index.es.js +26 -8
  41. package/lib/OralWebGL/index.es.min.d.ts +3 -0
  42. package/lib/OralWebGL/index.es.min.js +3 -3
  43. package/lib/SVG/index.umd.d.ts +3 -0
  44. package/lib/SVG/index.umd.js +2 -2
  45. package/lib/SVG/index.umd.min.d.ts +3 -0
  46. package/lib/SVG/index.umd.min.js +2 -2
  47. package/lib/Shader/index.umd.d.ts +3 -0
  48. package/lib/Shader/index.umd.js +2 -2
  49. package/lib/Shader/index.umd.min.d.ts +3 -0
  50. package/lib/Shader/index.umd.min.js +2 -2
  51. package/lib/Texture/index.umd.d.ts +3 -0
  52. package/lib/Texture/index.umd.js +2 -2
  53. package/lib/Texture/index.umd.min.d.ts +3 -0
  54. package/lib/Texture/index.umd.min.js +2 -2
  55. package/lib/TreeLayout/index.umd.d.ts +3 -0
  56. package/lib/TreeLayout/index.umd.js +2 -2
  57. package/lib/TreeLayout/index.umd.min.d.ts +3 -0
  58. package/lib/TreeLayout/index.umd.min.js +2 -2
  59. package/lib/WebGL/index.umd.d.ts +3 -0
  60. package/lib/WebGL/index.umd.js +27 -9
  61. package/lib/WebGL/index.umd.min.d.ts +3 -0
  62. package/lib/WebGL/index.umd.min.js +3 -3
  63. package/lib/animation/index.umd.d.ts +3 -0
  64. package/lib/animation/index.umd.js +2 -2
  65. package/lib/animation/index.umd.min.d.ts +3 -0
  66. package/lib/animation/index.umd.min.js +2 -2
  67. package/lib/formatColor/index.umd.d.ts +3 -0
  68. package/lib/formatColor/index.umd.js +2 -2
  69. package/lib/formatColor/index.umd.min.d.ts +3 -0
  70. package/lib/formatColor/index.umd.min.js +2 -2
  71. package/lib/getLoopColors/index.umd.d.ts +3 -0
  72. package/lib/getLoopColors/index.umd.js +2 -2
  73. package/lib/getLoopColors/index.umd.min.d.ts +3 -0
  74. package/lib/getLoopColors/index.umd.min.js +2 -2
  75. package/lib/getWebGLContext/index.umd.d.ts +3 -0
  76. package/lib/getWebGLContext/index.umd.js +25 -7
  77. package/lib/getWebGLContext/index.umd.min.d.ts +3 -0
  78. package/lib/getWebGLContext/index.umd.min.js +3 -3
  79. package/lib/index.umd.js +112 -20
  80. package/lib/index.umd.min.js +3 -3
  81. package/lib/move/index.umd.d.ts +3 -0
  82. package/lib/move/index.umd.js +2 -2
  83. package/lib/move/index.umd.min.d.ts +3 -0
  84. package/lib/move/index.umd.min.js +2 -2
  85. package/lib/resizeObserver/index.umd.d.ts +3 -0
  86. package/lib/resizeObserver/index.umd.js +2 -2
  87. package/lib/resizeObserver/index.umd.min.d.ts +3 -0
  88. package/lib/resizeObserver/index.umd.min.js +2 -2
  89. package/lib/rotate/index.umd.d.ts +3 -0
  90. package/lib/rotate/index.umd.js +2 -2
  91. package/lib/rotate/index.umd.min.d.ts +3 -0
  92. package/lib/rotate/index.umd.min.js +2 -2
  93. package/lib/ruler/index.umd.d.ts +3 -0
  94. package/lib/ruler/index.umd.js +2 -2
  95. package/lib/ruler/index.umd.min.d.ts +3 -0
  96. package/lib/ruler/index.umd.min.js +2 -2
  97. package/lib/scale/index.umd.d.ts +3 -0
  98. package/lib/scale/index.umd.js +2 -2
  99. package/lib/scale/index.umd.min.d.ts +3 -0
  100. package/lib/scale/index.umd.min.js +2 -2
  101. package/lib/throttle/index.umd.d.ts +3 -0
  102. package/lib/throttle/index.umd.js +2 -2
  103. package/lib/throttle/index.umd.min.d.ts +3 -0
  104. package/lib/throttle/index.umd.min.js +2 -2
  105. package/lib/viewHandler/index.umd.d.ts +3 -0
  106. package/lib/viewHandler/index.umd.js +2 -2
  107. package/lib/viewHandler/index.umd.min.d.ts +3 -0
  108. package/lib/viewHandler/index.umd.min.js +2 -2
  109. package/package/getWebGLContext/index.ts +40 -39
  110. package/package.json +1 -1
  111. package/src/Canvas.ts +2 -2
  112. package/src/Geometry.ts +65 -1
  113. package/src/WebGL.ts +66 -66
  114. package/src/common/canvas/painter.ts +26 -0
  115. package/src/common/geometry/prism-horizontal.ts +50 -35
  116. package/src/common/geometry/prism-vertical.ts +55 -40
  117. package/src/common/geometry/tool/circle.ts +17 -11
  118. package/src/common/geometry/tool/rotateLine.ts +48 -35
  119. package/src/common/webgl/getWebGLContext.ts +45 -28
  120. package/src/common/webgl/index.ts +227 -226
  121. package/src/common/webgl/shader.ts +75 -75
  122. package/types/Canvas.d.ts +318 -308
  123. package/types/Geometry.d.ts +132 -65
  124. package/types/Object3D.d.ts +114 -114
  125. package/types/Shader.d.ts +23 -23
  126. package/types/WebGLOption.d.ts +14 -7
  127. package/types/getWebGLContext.d.ts +4 -2
  128. package/uni-app/drawImage.js +18 -0
  129. package/uni-app/ui-canvas.vue +10 -1
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.7.1
2
+ * VISLite JavaScript Library v0.8.0-alpha.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: Sat Jan 20 2024 00:04:36 GMT+0800 (中国标准时间)
9
+ * Publish Date: Tue Feb 13 2024 21:00:43 GMT+0800 (中国标准时间)
10
10
  */
11
11
  var e,t;e=this,t=function(){"use strict";return function(e,t){void 0===t&&(t=1);var r=["rgba(84,112,198,"+t+")","rgba(145,204,117,"+t+")","rgba(250,200,88,"+t+")","rgba(238,102,102,"+t+")","rgba(115,192,222,"+t+")","rgba(59,162,114,"+t+")","rgba(252,132,82,"+t+")","rgba(154,96,180,"+t+")","rgba(234,124,204,"+t+")"],n=[];if(e<=r.length)return r;if(e%r.length==0)for(var o=0;o<e/r.length;o++)n=n.concat(r);else{for(var a=1;a<e/r.length;a++)n=n.concat(r);if(e%r.length==1)n=n.concat(r[4]);else for(var f=0;f<e%r.length;f++)n=n.concat(r[f])}return n}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_getLoopColors=t();
@@ -0,0 +1,3 @@
1
+ import { getWebGLContext } from "../../types/index"
2
+
3
+ export default getWebGLContext
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.7.1
2
+ * VISLite JavaScript Library v0.8.0-alpha.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: Sat Jan 20 2024 00:04:36 GMT+0800 (中国标准时间)
9
+ * Publish Date: Tue Feb 13 2024 21:00:43 GMT+0800 (中国标准时间)
10
10
  */
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -14,8 +14,9 @@
14
14
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VISLite_getWebGLContext = factory());
15
15
  })(this, (function () { 'use strict';
16
16
 
17
- function getWebGLContext (canvas, scale, opts) {
17
+ function getWebGLContext (canvas, scale, opts, mode) {
18
18
  if (opts === void 0) { opts = {}; }
19
+ if (mode === void 0) { mode = "scaleToFill"; }
19
20
  var names = ["experimental-webgl", "webkit-3d", "moz-webgl"];
20
21
  var painter = canvas.getContext("webgl", opts);
21
22
  for (var i = 0; i < names.length; i++) {
@@ -29,15 +30,32 @@
29
30
  if (!painter)
30
31
  throw new Error('Non canvas or browser does not support webgl.');
31
32
  var width = painter.canvas.width, height = painter.canvas.height;
32
- var viewWidth = width * scale;
33
- var viewHeight = height * scale;
33
+ var scaleX = scale, scaleY = scale;
34
+ if (mode == "aspectFit") {
35
+ if (width > height) {
36
+ scaleX *= height / width;
37
+ }
38
+ else if (height > width) {
39
+ scaleY *= width / height;
40
+ }
41
+ }
42
+ else if (mode == "aspectFill") {
43
+ if (width > height) {
44
+ scaleY *= width / height;
45
+ }
46
+ else if (height > width) {
47
+ scaleX *= height / width;
48
+ }
49
+ }
50
+ var viewWidth = width * scaleX;
51
+ var viewHeight = height * scaleY;
34
52
  painter.viewport((width - viewWidth) * 0.5, (height - viewHeight) * 0.5, viewWidth, viewHeight);
35
53
  painter.depthFunc(painter.LEQUAL);
36
54
  painter.enable(painter.DEPTH_TEST);
37
55
  return painter;
38
56
  }
39
57
 
40
- var index = (function (el, scale) {
58
+ var index = (function (el, scale, mode) {
41
59
  if (scale === void 0) { scale = 1; }
42
60
  if (!el) {
43
61
  throw new Error("VISLite getWebGLContext:The mount point requires an HTMLElement type but encountered null.");
@@ -58,7 +76,7 @@
58
76
  ViewCanvas.setAttribute('width', width + "");
59
77
  ViewCanvas.style.height = height + "px";
60
78
  ViewCanvas.setAttribute('height', height + "");
61
- return getWebGLContext(ViewCanvas, scale);
79
+ return getWebGLContext(ViewCanvas, scale, {}, mode);
62
80
  });
63
81
 
64
82
  return index;
@@ -0,0 +1,3 @@
1
+ import { getWebGLContext } from "../../types/index"
2
+
3
+ export default getWebGLContext
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.7.1
2
+ * VISLite JavaScript Library v0.8.0-alpha.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: Sat Jan 20 2024 00:04:36 GMT+0800 (中国标准时间)
9
+ * Publish Date: Tue Feb 13 2024 21:00:43 GMT+0800 (中国标准时间)
10
10
  */
11
- var e,t;e=this,t=function(){"use strict";return function(e,t){if(void 0===t&&(t=1),!e)throw new Error("VISLite getWebGLContext:The mount point requires an HTMLElement type but encountered null.");var n,i=e.clientWidth,o=e.clientHeight,r=e;return r._vislite_canvas_?n=r._vislite_canvas_:(n=document.createElement("canvas"),e.appendChild(n),r._vislite_canvas_=n,e.setAttribute("vislite","WebGL")),n.style.width=i+"px",n.setAttribute("width",i+""),n.style.height=o+"px",n.setAttribute("height",o+""),function(e,t,n){void 0===n&&(n={});for(var i=["experimental-webgl","webkit-3d","moz-webgl"],o=e.getContext("webgl",n),r=0;r<i.length;r++){try{o=e.getContext(i[r],n)}catch(e){}if(o)break}if(!o)throw new Error("Non canvas or browser does not support webgl.");var a=o.canvas.width,s=o.canvas.height,l=a*t,d=s*t;return o.viewport(.5*(a-l),.5*(s-d),l,d),o.depthFunc(o.LEQUAL),o.enable(o.DEPTH_TEST),o}(n,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_getWebGLContext=t();
11
+ var e,t;e=this,t=function(){"use strict";return function(e,t,i){if(void 0===t&&(t=1),!e)throw new Error("VISLite getWebGLContext:The mount point requires an HTMLElement type but encountered null.");var n,o=e.clientWidth,r=e.clientHeight,a=e;return a._vislite_canvas_?n=a._vislite_canvas_:(n=document.createElement("canvas"),e.appendChild(n),a._vislite_canvas_=n,e.setAttribute("vislite","WebGL")),n.style.width=o+"px",n.setAttribute("width",o+""),n.style.height=r+"px",n.setAttribute("height",r+""),function(e,t,i,n){void 0===i&&(i={}),void 0===n&&(n="scaleToFill");for(var o=["experimental-webgl","webkit-3d","moz-webgl"],r=e.getContext("webgl",i),a=0;a<o.length;a++){try{r=e.getContext(o[a],i)}catch(e){}if(r)break}if(!r)throw new Error("Non canvas or browser does not support webgl.");var l=r.canvas.width,s=r.canvas.height,c=t,d=t;"aspectFit"==n?l>s?c*=s/l:s>l&&(d*=l/s):"aspectFill"==n&&(l>s?d*=l/s:s>l&&(c*=s/l));var u=l*c,h=s*d;return r.viewport(.5*(l-u),.5*(s-h),u,h),r.depthFunc(r.LEQUAL),r.enable(r.DEPTH_TEST),r}(n,t,{},i)}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).VISLite_getWebGLContext=t();
package/lib/index.umd.js CHANGED
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.7.1
2
+ * VISLite JavaScript Library v0.8.0-alpha.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: Sat Jan 20 2024 00:04:36 GMT+0800 (中国标准时间)
9
+ * Publish Date: Tue Feb 13 2024 21:00:43 GMT+0800 (中国标准时间)
10
10
  */
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -1492,6 +1492,30 @@
1492
1492
  return this;
1493
1493
  };
1494
1494
  Painter.prototype.draw = function () { };
1495
+ Painter.prototype.drawImage = function (img, x, y, w, h, isUniapp) {
1496
+ var _this = this;
1497
+ if (isUniapp === void 0) { isUniapp = false; }
1498
+ return new Promise(function (resolve) {
1499
+ if (_this.__region) {
1500
+ _this.__region.fillRect(x, y, w, h);
1501
+ resolve({});
1502
+ }
1503
+ if (_this.__isPainter && _this.__onlyRegion)
1504
+ return _this;
1505
+ if (typeof img == 'string' && !isUniapp) {
1506
+ var imgInstance_1 = new Image();
1507
+ imgInstance_1.onload = function () {
1508
+ _this.painter.drawImage(imgInstance_1, x, y, w, h);
1509
+ resolve({});
1510
+ };
1511
+ imgInstance_1.src = img;
1512
+ }
1513
+ else {
1514
+ _this.painter.drawImage(img, x, y, w, h);
1515
+ resolve({});
1516
+ }
1517
+ });
1518
+ };
1495
1519
  return Painter;
1496
1520
  }());
1497
1521
 
@@ -1729,8 +1753,9 @@
1729
1753
  return Canvas;
1730
1754
  }(Canvas$1));
1731
1755
 
1732
- function getWebGLContext$1 (canvas, scale, opts) {
1756
+ function getWebGLContext$1 (canvas, scale, opts, mode) {
1733
1757
  if (opts === void 0) { opts = {}; }
1758
+ if (mode === void 0) { mode = "scaleToFill"; }
1734
1759
  var names = ["experimental-webgl", "webkit-3d", "moz-webgl"];
1735
1760
  var painter = canvas.getContext("webgl", opts);
1736
1761
  for (var i = 0; i < names.length; i++) {
@@ -1744,8 +1769,25 @@
1744
1769
  if (!painter)
1745
1770
  throw new Error('Non canvas or browser does not support webgl.');
1746
1771
  var width = painter.canvas.width, height = painter.canvas.height;
1747
- var viewWidth = width * scale;
1748
- var viewHeight = height * scale;
1772
+ var scaleX = scale, scaleY = scale;
1773
+ if (mode == "aspectFit") {
1774
+ if (width > height) {
1775
+ scaleX *= height / width;
1776
+ }
1777
+ else if (height > width) {
1778
+ scaleY *= width / height;
1779
+ }
1780
+ }
1781
+ else if (mode == "aspectFill") {
1782
+ if (width > height) {
1783
+ scaleY *= width / height;
1784
+ }
1785
+ else if (height > width) {
1786
+ scaleX *= height / width;
1787
+ }
1788
+ }
1789
+ var viewWidth = width * scaleX;
1790
+ var viewHeight = height * scaleY;
1749
1791
  painter.viewport((width - viewWidth) * 0.5, (height - viewHeight) * 0.5, viewWidth, viewHeight);
1750
1792
  painter.depthFunc(painter.LEQUAL);
1751
1793
  painter.enable(painter.DEPTH_TEST);
@@ -1998,7 +2040,7 @@
1998
2040
  var needUpdate = false;
1999
2041
  var scale = 10;
2000
2042
  var WebGL$1 = (function () {
2001
- function WebGL(ViewCanvas, RegionCanvas) {
2043
+ function WebGL(ViewCanvas, RegionCanvas, mode) {
2002
2044
  this.name = "WebGL";
2003
2045
  this.__getColor = function (x, y) { return "rgba(0,0,0,1)"; };
2004
2046
  this.__regionList = {};
@@ -2015,9 +2057,9 @@
2015
2057
  ])
2016
2058
  };
2017
2059
  this.__unique = new Date().valueOf();
2018
- this.painter = getWebGLContext$1(ViewCanvas, scale);
2060
+ this.painter = getWebGLContext$1(ViewCanvas, scale, {}, mode);
2019
2061
  if (RegionCanvas) {
2020
- this.__regionPainter = getWebGLContext$1(RegionCanvas, scale, {});
2062
+ this.__regionPainter = getWebGLContext$1(RegionCanvas, scale, {}, mode);
2021
2063
  }
2022
2064
  var proportion = this.painter.canvas.width / this.painter.canvas.height;
2023
2065
  var xProportion = 1;
@@ -2195,12 +2237,12 @@
2195
2237
  canvas.setAttribute('height', height + "");
2196
2238
  }
2197
2239
  }
2198
- return _super.call(this, ViewCanvas, RegionCanvas) || this;
2240
+ return _super.call(this, ViewCanvas, RegionCanvas, option.mode) || this;
2199
2241
  }
2200
2242
  return WebGL;
2201
2243
  }(WebGL$1));
2202
2244
 
2203
- var getWebGLContext = (function (el, scale) {
2245
+ var getWebGLContext = (function (el, scale, mode) {
2204
2246
  if (scale === void 0) { scale = 1; }
2205
2247
  if (!el) {
2206
2248
  throw new Error("VISLite getWebGLContext:The mount point requires an HTMLElement type but encountered null.");
@@ -2221,7 +2263,7 @@
2221
2263
  ViewCanvas.setAttribute('width', width + "");
2222
2264
  ViewCanvas.style.height = height + "px";
2223
2265
  ViewCanvas.setAttribute('height', height + "");
2224
- return getWebGLContext$1(ViewCanvas, scale);
2266
+ return getWebGLContext$1(ViewCanvas, scale, {}, mode);
2225
2267
  });
2226
2268
 
2227
2269
  var Shader = (function (_super) {
@@ -2791,13 +2833,16 @@
2791
2833
  return TreeLayout;
2792
2834
  }(Tree));
2793
2835
 
2794
- var splitNum = function (precision, radius) {
2795
- var num = Math.ceil(Math.PI * 2 /
2836
+ var splitNum = function (precision, radius, deg) {
2837
+ if (deg === void 0) { deg = Math.PI * 2; }
2838
+ var num = Math.ceil(deg /
2796
2839
  Math.asin(precision / radius) * 2);
2797
2840
  return (isNaN(num) || num < 12) ? 12 : num;
2798
2841
  };
2799
2842
 
2800
- function prismHorizontal (normal, x, y, z, radius, num, d) {
2843
+ function prismHorizontal (normal, x, y, z, radius, num, d, beginDeg, deg) {
2844
+ if (beginDeg === void 0) { beginDeg = 0; }
2845
+ if (deg === void 0) { deg = Math.PI * 2; }
2801
2846
  var beginX, beginZ;
2802
2847
  if (num == 4) {
2803
2848
  var temp = radius / 1.414;
@@ -2809,8 +2854,11 @@
2809
2854
  beginZ = z;
2810
2855
  }
2811
2856
  var point = [beginX, beginZ];
2857
+ if (beginDeg != 0) {
2858
+ point = rotate$1(x, z, beginDeg, beginX, beginZ);
2859
+ }
2812
2860
  var points = [];
2813
- var deg = Math.PI * 2 / num;
2861
+ var perDeg = deg / num;
2814
2862
  for (var i = 0; i < num; i++) {
2815
2863
  points.push(x, y, z);
2816
2864
  if (normal)
@@ -2818,7 +2866,7 @@
2818
2866
  points.push(point[0], y, point[1]);
2819
2867
  if (normal)
2820
2868
  points.push(0, d, 0);
2821
- point = rotate$1(x, z, deg * (i + 1), beginX, beginZ);
2869
+ point = rotate$1(x, z, perDeg * (i + 1), beginX, beginZ);
2822
2870
  points.push(point[0], y, point[1]);
2823
2871
  if (normal)
2824
2872
  points.push(0, d, 0);
@@ -2826,7 +2874,9 @@
2826
2874
  return points;
2827
2875
  }
2828
2876
 
2829
- function prismVertical (normal, x, y, z, radius, height, num) {
2877
+ function prismVertical (normal, x, y, z, radius, height, num, beginDeg, deg) {
2878
+ if (beginDeg === void 0) { beginDeg = 0; }
2879
+ if (deg === void 0) { deg = Math.PI * 2; }
2830
2880
  var points = [];
2831
2881
  var beginPosition;
2832
2882
  if (num == 4) {
@@ -2835,10 +2885,13 @@
2835
2885
  else {
2836
2886
  beginPosition = [x + radius, z];
2837
2887
  }
2838
- var deg = Math.PI * 2 / num, degHalf = Math.PI * 2 / (num * 2);
2888
+ if (beginDeg != 0) {
2889
+ beginPosition = rotate$1.apply(void 0, __spreadArray([x, z, beginDeg], beginPosition, false));
2890
+ }
2891
+ var perDeg = deg / num, degHalf = deg / (num * 2);
2839
2892
  var endPosition, normalPosition = [];
2840
2893
  for (var i = 0; i < num; i++) {
2841
- endPosition = rotate$1.apply(void 0, __spreadArray([x, z, deg], beginPosition, false));
2894
+ endPosition = rotate$1.apply(void 0, __spreadArray([x, z, perDeg], beginPosition, false));
2842
2895
  if (normal) {
2843
2896
  var halfPosition = rotate$1.apply(void 0, __spreadArray([x, z, degHalf], beginPosition, false));
2844
2897
  normalPosition = [halfPosition[0], 0, halfPosition[1]];
@@ -2886,6 +2939,8 @@
2886
2939
 
2887
2940
  function rotateLineFactory (x, y, z, x2, y2, z2) {
2888
2941
  return function (x0, y0, z0, isNormal) {
2942
+ if (x == x2 && z == z2)
2943
+ return [x0, y0, z0];
2889
2944
  var sin, cos, temp;
2890
2945
  var _x0 = x0 - (isNormal ? 0 : x), _y0 = y0 - (isNormal ? 0 : y), _z0 = z0 - (isNormal ? 0 : z);
2891
2946
  var _x2 = x2 - x, _y2 = y2 - y, _z2 = z2 - z;
@@ -2923,6 +2978,43 @@
2923
2978
  }
2924
2979
  return this;
2925
2980
  };
2981
+ Geometry.prototype.splitNum = function (radius, deg) {
2982
+ return splitNum(this.__option.precision, radius, deg);
2983
+ };
2984
+ Geometry.prototype.rotateLine = function (x1, y1, z1, x2, y2, z2) {
2985
+ var _this = this;
2986
+ var rotateLine = rotateLineFactory(x1, y1, z1, x2, y2, z2);
2987
+ return function (x, y, z) { return rotateLine(x, y, z, _this.__option.normal); };
2988
+ };
2989
+ Geometry.prototype.prismHorizontal = function (x, y, z, radius, num, d, beginDeg, deg) {
2990
+ return prismHorizontal(this.__option.normal, x, y, z, radius, num, d, beginDeg, deg);
2991
+ };
2992
+ Geometry.prototype.prismVertical = function (x, y, z, radius, height, num, beginDeg, deg) {
2993
+ return prismVertical(this.__option.normal, x, y, z, radius, height, num, beginDeg, deg);
2994
+ };
2995
+ Geometry.prototype.sphereFragment = function (cx, cy, cz, radius, num, index) {
2996
+ return sphereFragment(this.__option.normal, cx, cy, cz, radius, num, index);
2997
+ };
2998
+ Geometry.prototype.pie = function (x, y, z, radius, height, beginDeg, deg) {
2999
+ var num = splitNum(this.__option.precision, radius, deg);
3000
+ var result = [{
3001
+ name: "bottom",
3002
+ points: prismHorizontal(this.__option.normal, x, y, z, radius, num, height > 0 ? -1 : 1, beginDeg, deg),
3003
+ length: 3 * num,
3004
+ method: "TRIANGLES"
3005
+ }, {
3006
+ name: "top",
3007
+ points: prismHorizontal(this.__option.normal, x, y + height, z, radius, num, height > 0 ? 1 : -1, beginDeg, deg),
3008
+ length: 3 * num,
3009
+ method: "TRIANGLES"
3010
+ }, {
3011
+ name: "side",
3012
+ points: prismVertical(this.__option.normal, x, y, z, radius, height, num, beginDeg, deg),
3013
+ length: 6 * num,
3014
+ method: "TRIANGLES"
3015
+ }];
3016
+ return result;
3017
+ };
2926
3018
  Geometry.prototype.cylinder = function (x, y, z, radius, x2, y2, z2) {
2927
3019
  var num = splitNum(this.__option.precision, radius);
2928
3020
  if (arguments.length == 5) {
@@ -2940,7 +3032,7 @@
2940
3032
  num = y2;
2941
3033
  }
2942
3034
  else {
2943
- height = Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y) + (z2 - z) * (z2 - z));
3035
+ height = (y > y2 ? -1 : 1) * Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y) + (z2 - z) * (z2 - z));
2944
3036
  rotateLine = rotateLineFactory(x, y, z, x2, y2, z2);
2945
3037
  }
2946
3038
  var result = [{