vislite 0.8.0 → 0.8.1-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.
Files changed (79) hide show
  1. package/CHANGELOG +214 -209
  2. package/README.md +136 -144
  3. package/lib/Buffer/index.umd.js +36 -36
  4. package/lib/Buffer/index.umd.min.js +2 -2
  5. package/lib/Canvas/index.umd.js +691 -691
  6. package/lib/Canvas/index.umd.min.js +2 -2
  7. package/lib/Cardinal/index.umd.js +91 -91
  8. package/lib/Cardinal/index.umd.min.js +2 -2
  9. package/lib/Eoap/index.umd.js +34 -34
  10. package/lib/Eoap/index.umd.min.js +2 -2
  11. package/lib/Geometry/index.umd.js +286 -286
  12. package/lib/Geometry/index.umd.min.js +2 -2
  13. package/lib/Hermite/index.umd.js +36 -36
  14. package/lib/Hermite/index.umd.min.js +2 -2
  15. package/lib/Matrix4/index.umd.js +125 -125
  16. package/lib/Matrix4/index.umd.min.js +2 -2
  17. package/lib/Mercator/index.umd.js +20 -20
  18. package/lib/Mercator/index.umd.min.js +2 -2
  19. package/lib/OralCanvas/index.es.js +634 -634
  20. package/lib/OralCanvas/index.es.min.js +2 -2
  21. package/lib/OralWebGL/index.es.js +552 -552
  22. package/lib/OralWebGL/index.es.min.js +2 -2
  23. package/lib/SVG/index.umd.js +471 -471
  24. package/lib/SVG/index.umd.min.js +2 -2
  25. package/lib/Shader/index.umd.js +61 -61
  26. package/lib/Shader/index.umd.min.js +2 -2
  27. package/lib/Texture/index.umd.js +54 -54
  28. package/lib/Texture/index.umd.min.js +2 -2
  29. package/lib/TreeLayout/index.umd.js +368 -368
  30. package/lib/TreeLayout/index.umd.min.js +2 -2
  31. package/lib/WebGL/index.umd.js +599 -599
  32. package/lib/WebGL/index.umd.min.js +2 -2
  33. package/lib/animation/index.umd.js +73 -73
  34. package/lib/animation/index.umd.min.js +2 -2
  35. package/lib/formatColor/index.umd.js +40 -40
  36. package/lib/formatColor/index.umd.min.js +2 -2
  37. package/lib/getLoopColors/index.umd.js +36 -36
  38. package/lib/getLoopColors/index.umd.min.js +2 -2
  39. package/lib/getWebGLContext/index.umd.js +63 -63
  40. package/lib/getWebGLContext/index.umd.min.js +2 -2
  41. package/lib/index.umd.js +2955 -2955
  42. package/lib/index.umd.min.js +2 -2
  43. package/lib/move/index.umd.js +8 -8
  44. package/lib/move/index.umd.min.js +2 -2
  45. package/lib/resizeObserver/index.umd.js +30 -30
  46. package/lib/resizeObserver/index.umd.min.js +2 -2
  47. package/lib/rotate/index.umd.js +8 -8
  48. package/lib/rotate/index.umd.min.js +2 -2
  49. package/lib/ruler/index.umd.js +138 -138
  50. package/lib/ruler/index.umd.min.js +2 -2
  51. package/lib/scale/index.umd.js +7 -7
  52. package/lib/scale/index.umd.min.js +2 -2
  53. package/lib/throttle/index.umd.js +49 -49
  54. package/lib/throttle/index.umd.min.js +2 -2
  55. package/lib/viewHandler/index.umd.js +120 -120
  56. package/lib/viewHandler/index.umd.min.js +2 -2
  57. package/miniprogram/ui-canvas/drawImage.js +34 -0
  58. package/miniprogram/ui-canvas/index.js +24 -9
  59. package/package/getWebGLContext/index.ts +40 -40
  60. package/package.json +70 -70
  61. package/src/Canvas.ts +72 -72
  62. package/src/Geometry.ts +210 -210
  63. package/src/WebGL.ts +66 -66
  64. package/src/common/canvas/index.ts +183 -183
  65. package/src/common/canvas/painter.ts +446 -446
  66. package/src/common/geometry/prism-horizontal.ts +50 -50
  67. package/src/common/geometry/prism-vertical.ts +55 -55
  68. package/src/common/geometry/tool/circle.ts +17 -17
  69. package/src/common/geometry/tool/rotateLine.ts +48 -48
  70. package/src/common/geometry/tool/triangles.ts +23 -23
  71. package/src/common/webgl/getWebGLContext.ts +45 -45
  72. package/src/common/webgl/index.ts +227 -227
  73. package/types/Canvas.d.ts +318 -318
  74. package/types/Geometry.d.ts +132 -132
  75. package/types/WebGLOption.d.ts +14 -14
  76. package/types/getWebGLContext.d.ts +4 -4
  77. package/types/ui-canvas.d.ts +4 -4
  78. package/uni-app/drawImage.js +17 -17
  79. package/uni-app/ui-canvas.vue +290 -290
@@ -1,12 +1,12 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.8.0
2
+ * VISLite JavaScript Library v0.8.1-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: Sat Mar 02 2024 12:41:38 GMT+0800 (中国标准时间)
9
+ * Publish Date: Wed Apr 03 2024 10:29:52 GMT+0800 (China Standard Time)
10
10
  */
11
11
  (function (global, factory) {
12
12
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -14,53 +14,53 @@
14
14
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VISLite_Geometry = factory());
15
15
  })(this, (function () { 'use strict';
16
16
 
17
- var splitNum = function (precision, radius, deg) {
18
- if (deg === void 0) { deg = Math.PI * 2; }
19
- var num = Math.ceil(deg /
20
- Math.asin(precision / radius) * 2);
21
- return (isNaN(num) || num < 12) ? 12 : num;
17
+ var splitNum = function (precision, radius, deg) {
18
+ if (deg === void 0) { deg = Math.PI * 2; }
19
+ var num = Math.ceil(deg /
20
+ Math.asin(precision / radius) * 2);
21
+ return (isNaN(num) || num < 12) ? 12 : num;
22
22
  };
23
23
 
24
- function rotate (cx, cy, deg, x, y) {
25
- var cos = Math.cos(deg), sin = Math.sin(deg);
26
- return [
27
- (x - cx) * cos - (y - cy) * sin + cx,
28
- (x - cx) * sin + (y - cy) * cos + cy
29
- ];
24
+ function rotate (cx, cy, deg, x, y) {
25
+ var cos = Math.cos(deg), sin = Math.sin(deg);
26
+ return [
27
+ (x - cx) * cos - (y - cy) * sin + cx,
28
+ (x - cx) * sin + (y - cy) * cos + cy
29
+ ];
30
30
  }
31
31
 
32
- function prismHorizontal (normal, x, y, z, radius, num, d, beginDeg, deg) {
33
- if (beginDeg === void 0) { beginDeg = 0; }
34
- if (deg === void 0) { deg = Math.PI * 2; }
35
- var beginX, beginZ;
36
- if (num == 4) {
37
- var temp = radius / 1.414;
38
- beginX = x + temp;
39
- beginZ = z + temp;
40
- }
41
- else {
42
- beginX = x + radius;
43
- beginZ = z;
44
- }
45
- var point = [beginX, beginZ];
46
- if (beginDeg != 0) {
47
- point = rotate(x, z, beginDeg, beginX, beginZ);
48
- }
49
- var points = [];
50
- var perDeg = deg / num;
51
- for (var i = 0; i < num; i++) {
52
- points.push(x, y, z);
53
- if (normal)
54
- points.push(0, d, 0);
55
- points.push(point[0], y, point[1]);
56
- if (normal)
57
- points.push(0, d, 0);
58
- point = rotate(x, z, perDeg * (i + 1), beginX, beginZ);
59
- points.push(point[0], y, point[1]);
60
- if (normal)
61
- points.push(0, d, 0);
62
- }
63
- return points;
32
+ function prismHorizontal (normal, x, y, z, radius, num, d, beginDeg, deg) {
33
+ if (beginDeg === void 0) { beginDeg = 0; }
34
+ if (deg === void 0) { deg = Math.PI * 2; }
35
+ var beginX, beginZ;
36
+ if (num == 4) {
37
+ var temp = radius / 1.414;
38
+ beginX = x + temp;
39
+ beginZ = z + temp;
40
+ }
41
+ else {
42
+ beginX = x + radius;
43
+ beginZ = z;
44
+ }
45
+ var point = [beginX, beginZ];
46
+ if (beginDeg != 0) {
47
+ point = rotate(x, z, beginDeg, beginX, beginZ);
48
+ }
49
+ var points = [];
50
+ var perDeg = deg / num;
51
+ for (var i = 0; i < num; i++) {
52
+ points.push(x, y, z);
53
+ if (normal)
54
+ points.push(0, d, 0);
55
+ points.push(point[0], y, point[1]);
56
+ if (normal)
57
+ points.push(0, d, 0);
58
+ point = rotate(x, z, perDeg * (i + 1), beginX, beginZ);
59
+ points.push(point[0], y, point[1]);
60
+ if (normal)
61
+ points.push(0, d, 0);
62
+ }
63
+ return points;
64
64
  }
65
65
 
66
66
  /******************************************************************************
@@ -95,257 +95,257 @@
95
95
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
96
96
  };
97
97
 
98
- function prismVertical (normal, x, y, z, radius, height, num, beginDeg, deg) {
99
- if (beginDeg === void 0) { beginDeg = 0; }
100
- if (deg === void 0) { deg = Math.PI * 2; }
101
- var points = [];
102
- var beginPosition;
103
- if (num == 4) {
104
- beginPosition = rotate(x, z, Math.PI * 0.25, x - radius, z);
105
- }
106
- else {
107
- beginPosition = [x + radius, z];
108
- }
109
- if (beginDeg != 0) {
110
- beginPosition = rotate.apply(void 0, __spreadArray([x, z, beginDeg], beginPosition, false));
111
- }
112
- var perDeg = deg / num, degHalf = deg / (num * 2);
113
- var endPosition, normalPosition = [];
114
- for (var i = 0; i < num; i++) {
115
- endPosition = rotate.apply(void 0, __spreadArray([x, z, perDeg], beginPosition, false));
116
- if (normal) {
117
- var halfPosition = rotate.apply(void 0, __spreadArray([x, z, degHalf], beginPosition, false));
118
- normalPosition = [halfPosition[0], 0, halfPosition[1]];
119
- }
120
- points.push.apply(points, __spreadArray([beginPosition[0], y, beginPosition[1]], normalPosition, false));
121
- points.push.apply(points, __spreadArray([beginPosition[0], y + height, beginPosition[1]], normalPosition, false));
122
- points.push.apply(points, __spreadArray([endPosition[0], y + height, endPosition[1]], normalPosition, false));
123
- points.push.apply(points, __spreadArray([beginPosition[0], y, beginPosition[1]], normalPosition, false));
124
- points.push.apply(points, __spreadArray([endPosition[0], y, endPosition[1]], normalPosition, false));
125
- points.push.apply(points, __spreadArray([endPosition[0], y + height, endPosition[1]], normalPosition, false));
126
- beginPosition = endPosition;
127
- }
128
- return points;
98
+ function prismVertical (normal, x, y, z, radius, height, num, beginDeg, deg) {
99
+ if (beginDeg === void 0) { beginDeg = 0; }
100
+ if (deg === void 0) { deg = Math.PI * 2; }
101
+ var points = [];
102
+ var beginPosition;
103
+ if (num == 4) {
104
+ beginPosition = rotate(x, z, Math.PI * 0.25, x - radius, z);
105
+ }
106
+ else {
107
+ beginPosition = [x + radius, z];
108
+ }
109
+ if (beginDeg != 0) {
110
+ beginPosition = rotate.apply(void 0, __spreadArray([x, z, beginDeg], beginPosition, false));
111
+ }
112
+ var perDeg = deg / num, degHalf = deg / (num * 2);
113
+ var endPosition, normalPosition = [];
114
+ for (var i = 0; i < num; i++) {
115
+ endPosition = rotate.apply(void 0, __spreadArray([x, z, perDeg], beginPosition, false));
116
+ if (normal) {
117
+ var halfPosition = rotate.apply(void 0, __spreadArray([x, z, degHalf], beginPosition, false));
118
+ normalPosition = [halfPosition[0], 0, halfPosition[1]];
119
+ }
120
+ points.push.apply(points, __spreadArray([beginPosition[0], y, beginPosition[1]], normalPosition, false));
121
+ points.push.apply(points, __spreadArray([beginPosition[0], y + height, beginPosition[1]], normalPosition, false));
122
+ points.push.apply(points, __spreadArray([endPosition[0], y + height, endPosition[1]], normalPosition, false));
123
+ points.push.apply(points, __spreadArray([beginPosition[0], y, beginPosition[1]], normalPosition, false));
124
+ points.push.apply(points, __spreadArray([endPosition[0], y, endPosition[1]], normalPosition, false));
125
+ points.push.apply(points, __spreadArray([endPosition[0], y + height, endPosition[1]], normalPosition, false));
126
+ beginPosition = endPosition;
127
+ }
128
+ return points;
129
129
  }
130
130
 
131
- function sphereFragment (normal, cx, cy, cz, radius, num, index) {
132
- var points = [cx, cy + radius, cz], deg = Math.PI * 2 / num;
133
- var point;
134
- if (normal)
135
- points.push(0, radius, 0);
136
- var copy2 = function () {
137
- points.push.apply(points, points.slice(points.length - (normal ? 12 : 6)));
138
- };
139
- for (var i = 1; i < num * 0.5; i++) {
140
- point = rotate(cx, cy, deg * i, cx, cy + radius);
141
- if (i > 1)
142
- copy2();
143
- var point1 = rotate(cx, cz, deg * index, point[0], cz);
144
- points.push(point1[0], point[1], point1[1]);
145
- if (normal)
146
- points.push(point1[0] - cx, point[1] - cy, point1[1] - cz);
147
- if (i > 1)
148
- copy2();
149
- var point2 = rotate(cx, cz, deg * (index + 1), point[0], cz);
150
- points.push(point2[0], point[1], point2[1]);
151
- if (normal)
152
- points.push(point2[0] - cx, point2[1] - cy, point2[1] - cz);
153
- }
154
- copy2();
155
- points.push(cx, cy - radius, cz);
156
- if (normal)
157
- points.push(0, -radius, 0);
158
- return points;
131
+ function sphereFragment (normal, cx, cy, cz, radius, num, index) {
132
+ var points = [cx, cy + radius, cz], deg = Math.PI * 2 / num;
133
+ var point;
134
+ if (normal)
135
+ points.push(0, radius, 0);
136
+ var copy2 = function () {
137
+ points.push.apply(points, points.slice(points.length - (normal ? 12 : 6)));
138
+ };
139
+ for (var i = 1; i < num * 0.5; i++) {
140
+ point = rotate(cx, cy, deg * i, cx, cy + radius);
141
+ if (i > 1)
142
+ copy2();
143
+ var point1 = rotate(cx, cz, deg * index, point[0], cz);
144
+ points.push(point1[0], point[1], point1[1]);
145
+ if (normal)
146
+ points.push(point1[0] - cx, point[1] - cy, point1[1] - cz);
147
+ if (i > 1)
148
+ copy2();
149
+ var point2 = rotate(cx, cz, deg * (index + 1), point[0], cz);
150
+ points.push(point2[0], point[1], point2[1]);
151
+ if (normal)
152
+ points.push(point2[0] - cx, point2[1] - cy, point2[1] - cz);
153
+ }
154
+ copy2();
155
+ points.push(cx, cy - radius, cz);
156
+ if (normal)
157
+ points.push(0, -radius, 0);
158
+ return points;
159
159
  }
160
160
 
161
- function mergeOption (option, defaultOption) {
162
- for (var key in option) {
163
- defaultOption[key] = option[key];
164
- }
165
- return defaultOption;
161
+ function mergeOption (option, defaultOption) {
162
+ for (var key in option) {
163
+ defaultOption[key] = option[key];
164
+ }
165
+ return defaultOption;
166
166
  }
167
167
 
168
- function rotateLineFactory (x, y, z, x2, y2, z2) {
169
- return function (x0, y0, z0, isNormal) {
170
- if (x == x2 && z == z2)
171
- return [x0, y0, z0];
172
- var sin, cos, temp;
173
- var _x0 = x0 - (isNormal ? 0 : x), _y0 = y0 - (isNormal ? 0 : y), _z0 = z0 - (isNormal ? 0 : z);
174
- var _x2 = x2 - x, _y2 = y2 - y, _z2 = z2 - z;
175
- var __d = Math.sqrt(_x2 * _x2 + _z2 * _z2);
176
- cos = _x2 / __d;
177
- sin = _z2 / __d;
178
- var _x2N = _z2 * sin + _x2 * cos;
179
- var d = Math.sqrt(_y2 * _y2 + _x2N * _x2N);
180
- cos = _y2 / d;
181
- sin = _x2N / d;
182
- temp = [_y0, _x0];
183
- _y0 = temp[0] * cos - temp[1] * sin;
184
- _x0 = temp[0] * sin + temp[1] * cos;
185
- cos = _x2 / __d;
186
- sin = _z2 / __d;
187
- temp = [_x0, _z0];
188
- _x0 = temp[0] * cos - temp[1] * sin;
189
- _z0 = temp[0] * sin + temp[1] * cos;
190
- return [_x0 + (isNormal ? 0 : x), _y0 + (isNormal ? 0 : y), _z0 + (isNormal ? 0 : z)];
191
- };
168
+ function rotateLineFactory (x, y, z, x2, y2, z2) {
169
+ return function (x0, y0, z0, isNormal) {
170
+ if (x == x2 && z == z2)
171
+ return [x0, y0, z0];
172
+ var sin, cos, temp;
173
+ var _x0 = x0 - (isNormal ? 0 : x), _y0 = y0 - (isNormal ? 0 : y), _z0 = z0 - (isNormal ? 0 : z);
174
+ var _x2 = x2 - x, _y2 = y2 - y, _z2 = z2 - z;
175
+ var __d = Math.sqrt(_x2 * _x2 + _z2 * _z2);
176
+ cos = _x2 / __d;
177
+ sin = _z2 / __d;
178
+ var _x2N = _z2 * sin + _x2 * cos;
179
+ var d = Math.sqrt(_y2 * _y2 + _x2N * _x2N);
180
+ cos = _y2 / d;
181
+ sin = _x2N / d;
182
+ temp = [_y0, _x0];
183
+ _y0 = temp[0] * cos - temp[1] * sin;
184
+ _x0 = temp[0] * sin + temp[1] * cos;
185
+ cos = _x2 / __d;
186
+ sin = _z2 / __d;
187
+ temp = [_x0, _z0];
188
+ _x0 = temp[0] * cos - temp[1] * sin;
189
+ _z0 = temp[0] * sin + temp[1] * cos;
190
+ return [_x0 + (isNormal ? 0 : x), _y0 + (isNormal ? 0 : y), _z0 + (isNormal ? 0 : z)];
191
+ };
192
192
  }
193
193
 
194
- function triangles (normal, points) {
195
- if (normal) {
196
- var _points = [];
197
- for (var i = 0; i < points.length; i += 9) {
198
- var ab = [points[i + 3] - points[i], points[i + 4] - points[i + 1], points[i + 5] - points[i + 2]];
199
- var ac = [points[i + 6] - points[i], points[i + 7] - points[i + 1], points[i + 8] - points[i + 2]];
200
- var normalVector = [ab[1] * ac[2] - ac[1] * ab[2], ab[2] * ac[0] - ab[0] * ac[2], ab[0] * ac[1] - ab[1] * ac[2]];
201
- _points.push.apply(_points, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([points[i], points[i + 1], points[i + 2]], normalVector, false), [points[i + 3], points[i + 4], points[i + 5]], false), normalVector, false), [points[i + 6], points[i + 7], points[i + 8]], false), normalVector, false));
202
- }
203
- return _points;
204
- }
205
- else {
206
- return points;
207
- }
194
+ function triangles (normal, points) {
195
+ if (normal) {
196
+ var _points = [];
197
+ for (var i = 0; i < points.length; i += 9) {
198
+ var ab = [points[i + 3] - points[i], points[i + 4] - points[i + 1], points[i + 5] - points[i + 2]];
199
+ var ac = [points[i + 6] - points[i], points[i + 7] - points[i + 1], points[i + 8] - points[i + 2]];
200
+ var normalVector = [ab[1] * ac[2] - ac[1] * ab[2], ab[2] * ac[0] - ab[0] * ac[2], ab[0] * ac[1] - ab[1] * ac[2]];
201
+ _points.push.apply(_points, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([points[i], points[i + 1], points[i + 2]], normalVector, false), [points[i + 3], points[i + 4], points[i + 5]], false), normalVector, false), [points[i + 6], points[i + 7], points[i + 8]], false), normalVector, false));
202
+ }
203
+ return _points;
204
+ }
205
+ else {
206
+ return points;
207
+ }
208
208
  }
209
209
 
210
- var Geometry = (function () {
211
- function Geometry(option) {
212
- if (option === void 0) { option = {}; }
213
- this.name = 'Geometry';
214
- this.__option = mergeOption(option, {
215
- precision: 0.1,
216
- normal: false,
217
- });
218
- }
219
- Geometry.prototype.config = function (option) {
220
- for (var key in option) {
221
- this.__option[key] = option[key];
222
- }
223
- return this;
224
- };
225
- Geometry.prototype.splitNum = function (radius, deg) {
226
- return splitNum(this.__option.precision, radius, deg);
227
- };
228
- Geometry.prototype.rotateLine = function (x1, y1, z1, x2, y2, z2) {
229
- var _this = this;
230
- var rotateLine = rotateLineFactory(x1, y1, z1, x2, y2, z2);
231
- return function (x, y, z) { return rotateLine(x, y, z, _this.__option.normal); };
232
- };
233
- Geometry.prototype.prismHorizontal = function (x, y, z, radius, num, d, beginDeg, deg) {
234
- return prismHorizontal(this.__option.normal, x, y, z, radius, num, d, beginDeg, deg);
235
- };
236
- Geometry.prototype.prismVertical = function (x, y, z, radius, height, num, beginDeg, deg) {
237
- return prismVertical(this.__option.normal, x, y, z, radius, height, num, beginDeg, deg);
238
- };
239
- Geometry.prototype.sphereFragment = function (cx, cy, cz, radius, num, index) {
240
- return sphereFragment(this.__option.normal, cx, cy, cz, radius, num, index);
241
- };
242
- Geometry.prototype.pie = function (x, y, z, radius, height, beginDeg, deg) {
243
- var num = splitNum(this.__option.precision, radius, deg);
244
- var beginXZ = rotate(x, z, beginDeg, x + radius, z);
245
- var endXZ = rotate(x, z, beginDeg + deg, x + radius, z);
246
- var result = [{
247
- name: "bottom",
248
- points: prismHorizontal(this.__option.normal, x, y, z, radius, num, height > 0 ? -1 : 1, beginDeg, deg),
249
- length: 3 * num,
250
- method: "TRIANGLES"
251
- }, {
252
- name: "top",
253
- points: prismHorizontal(this.__option.normal, x, y + height, z, radius, num, height > 0 ? 1 : -1, beginDeg, deg),
254
- length: 3 * num,
255
- method: "TRIANGLES"
256
- }, {
257
- name: "side",
258
- points: prismVertical(this.__option.normal, x, y, z, radius, height, num, beginDeg, deg),
259
- length: 6 * num,
260
- method: "TRIANGLES"
261
- }, {
262
- name: "begin",
263
- points: triangles(this.__option.normal, [
264
- x, y, z, x, y + height, z, beginXZ[0], y, beginXZ[1],
265
- beginXZ[0], y + height, beginXZ[1], beginXZ[0], y, beginXZ[1], x, y + height, z
266
- ]),
267
- length: 6,
268
- method: "TRIANGLES"
269
- }, {
270
- name: "end",
271
- points: triangles(this.__option.normal, [
272
- x, y, z, endXZ[0], y, endXZ[1], x, y + height, z,
273
- endXZ[0], y + height, endXZ[1], x, y + height, z, endXZ[0], y, endXZ[1]
274
- ]),
275
- length: 6,
276
- method: "TRIANGLES"
277
- }];
278
- return result;
279
- };
280
- Geometry.prototype.cylinder = function (x, y, z, radius, x2, y2, z2) {
281
- var num = splitNum(this.__option.precision, radius);
282
- if (arguments.length == 5) {
283
- return this.prism(x, y, z, radius, x2, num);
284
- }
285
- else {
286
- return this.prism(x, y, z, radius, x2, y2, z2, num);
287
- }
288
- };
289
- Geometry.prototype.prism = function (x, y, z, radius, x2, y2, z2, num) {
290
- var _a, _b, _c;
291
- var height, rotateLine = null;
292
- if (arguments.length == 6) {
293
- height = x2;
294
- num = y2;
295
- }
296
- else {
297
- height = (y > y2 ? -1 : 1) * Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y) + (z2 - z) * (z2 - z));
298
- rotateLine = rotateLineFactory(x, y, z, x2, y2, z2);
299
- }
300
- var result = [{
301
- name: "bottom",
302
- points: [],
303
- length: 0,
304
- method: "TRIANGLES"
305
- }, {
306
- name: "top",
307
- points: [],
308
- length: 0,
309
- method: "TRIANGLES"
310
- }, {
311
- name: "side",
312
- points: [],
313
- length: 0,
314
- method: "TRIANGLES"
315
- }];
316
- (_a = result[0].points).push.apply(_a, prismHorizontal(this.__option.normal, x, y, z, radius, num, height > 0 ? -1 : 1));
317
- (_b = result[1].points).push.apply(_b, prismHorizontal(this.__option.normal, x, y + height, z, radius, num, height > 0 ? 1 : -1));
318
- (_c = result[2].points).push.apply(_c, prismVertical(this.__option.normal, x, y, z, radius, height, num));
319
- for (var i = 0; i < result.length; i++) {
320
- if (rotateLine) {
321
- var points = [];
322
- var isNormal = false;
323
- for (var index = 0; index < result[i].points.length; index += 3) {
324
- points.push.apply(points, rotateLine(result[i].points[index], result[i].points[index + 1], result[i].points[index + 2], this.__option.normal && isNormal));
325
- isNormal = !isNormal;
326
- }
327
- result[i].points = points;
328
- }
329
- result[i].length = result[i].points.length / (this.__option.normal ? 6 : 3);
330
- }
331
- return result;
332
- };
333
- Geometry.prototype.sphere = function (cx, cy, cz, radius) {
334
- var _a;
335
- var num = splitNum(this.__option.precision, radius);
336
- var result = [{
337
- name: "surface",
338
- points: [],
339
- length: 0,
340
- method: "TRIANGLES"
341
- }];
342
- for (var i = 0; i < num; i++) {
343
- (_a = result[0].points).push.apply(_a, sphereFragment(this.__option.normal, cx, cy, cz, radius, num, i));
344
- }
345
- result[0].length = result[0].points.length / (this.__option.normal ? 6 : 3);
346
- return result;
347
- };
348
- return Geometry;
210
+ var Geometry = (function () {
211
+ function Geometry(option) {
212
+ if (option === void 0) { option = {}; }
213
+ this.name = 'Geometry';
214
+ this.__option = mergeOption(option, {
215
+ precision: 0.1,
216
+ normal: false,
217
+ });
218
+ }
219
+ Geometry.prototype.config = function (option) {
220
+ for (var key in option) {
221
+ this.__option[key] = option[key];
222
+ }
223
+ return this;
224
+ };
225
+ Geometry.prototype.splitNum = function (radius, deg) {
226
+ return splitNum(this.__option.precision, radius, deg);
227
+ };
228
+ Geometry.prototype.rotateLine = function (x1, y1, z1, x2, y2, z2) {
229
+ var _this = this;
230
+ var rotateLine = rotateLineFactory(x1, y1, z1, x2, y2, z2);
231
+ return function (x, y, z) { return rotateLine(x, y, z, _this.__option.normal); };
232
+ };
233
+ Geometry.prototype.prismHorizontal = function (x, y, z, radius, num, d, beginDeg, deg) {
234
+ return prismHorizontal(this.__option.normal, x, y, z, radius, num, d, beginDeg, deg);
235
+ };
236
+ Geometry.prototype.prismVertical = function (x, y, z, radius, height, num, beginDeg, deg) {
237
+ return prismVertical(this.__option.normal, x, y, z, radius, height, num, beginDeg, deg);
238
+ };
239
+ Geometry.prototype.sphereFragment = function (cx, cy, cz, radius, num, index) {
240
+ return sphereFragment(this.__option.normal, cx, cy, cz, radius, num, index);
241
+ };
242
+ Geometry.prototype.pie = function (x, y, z, radius, height, beginDeg, deg) {
243
+ var num = splitNum(this.__option.precision, radius, deg);
244
+ var beginXZ = rotate(x, z, beginDeg, x + radius, z);
245
+ var endXZ = rotate(x, z, beginDeg + deg, x + radius, z);
246
+ var result = [{
247
+ name: "bottom",
248
+ points: prismHorizontal(this.__option.normal, x, y, z, radius, num, height > 0 ? -1 : 1, beginDeg, deg),
249
+ length: 3 * num,
250
+ method: "TRIANGLES"
251
+ }, {
252
+ name: "top",
253
+ points: prismHorizontal(this.__option.normal, x, y + height, z, radius, num, height > 0 ? 1 : -1, beginDeg, deg),
254
+ length: 3 * num,
255
+ method: "TRIANGLES"
256
+ }, {
257
+ name: "side",
258
+ points: prismVertical(this.__option.normal, x, y, z, radius, height, num, beginDeg, deg),
259
+ length: 6 * num,
260
+ method: "TRIANGLES"
261
+ }, {
262
+ name: "begin",
263
+ points: triangles(this.__option.normal, [
264
+ x, y, z, x, y + height, z, beginXZ[0], y, beginXZ[1],
265
+ beginXZ[0], y + height, beginXZ[1], beginXZ[0], y, beginXZ[1], x, y + height, z
266
+ ]),
267
+ length: 6,
268
+ method: "TRIANGLES"
269
+ }, {
270
+ name: "end",
271
+ points: triangles(this.__option.normal, [
272
+ x, y, z, endXZ[0], y, endXZ[1], x, y + height, z,
273
+ endXZ[0], y + height, endXZ[1], x, y + height, z, endXZ[0], y, endXZ[1]
274
+ ]),
275
+ length: 6,
276
+ method: "TRIANGLES"
277
+ }];
278
+ return result;
279
+ };
280
+ Geometry.prototype.cylinder = function (x, y, z, radius, x2, y2, z2) {
281
+ var num = splitNum(this.__option.precision, radius);
282
+ if (arguments.length == 5) {
283
+ return this.prism(x, y, z, radius, x2, num);
284
+ }
285
+ else {
286
+ return this.prism(x, y, z, radius, x2, y2, z2, num);
287
+ }
288
+ };
289
+ Geometry.prototype.prism = function (x, y, z, radius, x2, y2, z2, num) {
290
+ var _a, _b, _c;
291
+ var height, rotateLine = null;
292
+ if (arguments.length == 6) {
293
+ height = x2;
294
+ num = y2;
295
+ }
296
+ else {
297
+ height = (y > y2 ? -1 : 1) * Math.sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y) + (z2 - z) * (z2 - z));
298
+ rotateLine = rotateLineFactory(x, y, z, x2, y2, z2);
299
+ }
300
+ var result = [{
301
+ name: "bottom",
302
+ points: [],
303
+ length: 0,
304
+ method: "TRIANGLES"
305
+ }, {
306
+ name: "top",
307
+ points: [],
308
+ length: 0,
309
+ method: "TRIANGLES"
310
+ }, {
311
+ name: "side",
312
+ points: [],
313
+ length: 0,
314
+ method: "TRIANGLES"
315
+ }];
316
+ (_a = result[0].points).push.apply(_a, prismHorizontal(this.__option.normal, x, y, z, radius, num, height > 0 ? -1 : 1));
317
+ (_b = result[1].points).push.apply(_b, prismHorizontal(this.__option.normal, x, y + height, z, radius, num, height > 0 ? 1 : -1));
318
+ (_c = result[2].points).push.apply(_c, prismVertical(this.__option.normal, x, y, z, radius, height, num));
319
+ for (var i = 0; i < result.length; i++) {
320
+ if (rotateLine) {
321
+ var points = [];
322
+ var isNormal = false;
323
+ for (var index = 0; index < result[i].points.length; index += 3) {
324
+ points.push.apply(points, rotateLine(result[i].points[index], result[i].points[index + 1], result[i].points[index + 2], this.__option.normal && isNormal));
325
+ isNormal = !isNormal;
326
+ }
327
+ result[i].points = points;
328
+ }
329
+ result[i].length = result[i].points.length / (this.__option.normal ? 6 : 3);
330
+ }
331
+ return result;
332
+ };
333
+ Geometry.prototype.sphere = function (cx, cy, cz, radius) {
334
+ var _a;
335
+ var num = splitNum(this.__option.precision, radius);
336
+ var result = [{
337
+ name: "surface",
338
+ points: [],
339
+ length: 0,
340
+ method: "TRIANGLES"
341
+ }];
342
+ for (var i = 0; i < num; i++) {
343
+ (_a = result[0].points).push.apply(_a, sphereFragment(this.__option.normal, cx, cy, cz, radius, num, i));
344
+ }
345
+ result[0].length = result[0].points.length / (this.__option.normal ? 6 : 3);
346
+ return result;
347
+ };
348
+ return Geometry;
349
349
  }());
350
350
 
351
351
  return Geometry;
@@ -1,11 +1,11 @@
1
1
  /*!
2
- * VISLite JavaScript Library v0.8.0
2
+ * VISLite JavaScript Library v0.8.1-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: Sat Mar 02 2024 12:41:38 GMT+0800 (中国标准时间)
9
+ * Publish Date: Wed Apr 03 2024 10:29:52 GMT+0800 (China Standard Time)
10
10
  */
11
11
  var t,n;t=this,n=function(){"use strict";var t=function(t,n,o){void 0===o&&(o=2*Math.PI);var r=Math.ceil(o/Math.asin(t/n)*2);return isNaN(r)||r<12?12:r};function n(t,n,o,r,i){var p=Math.cos(o),e=Math.sin(o);return[(r-t)*p-(i-n)*e+t,(r-t)*e+(i-n)*p+n]}function o(t,o,r,i,p,e,s,a,h){var u,l;if(void 0===a&&(a=0),void 0===h&&(h=2*Math.PI),4==e){var f=p/1.414;u=o+f,l=i+f}else u=o+p,l=i;var m=[u,l];0!=a&&(m=n(o,i,a,u,l));for(var c=[],_=h/e,v=0;v<e;v++)c.push(o,r,i),t&&c.push(0,s,0),c.push(m[0],r,m[1]),t&&c.push(0,s,0),m=n(o,i,_*(v+1),u,l),c.push(m[0],r,m[1]),t&&c.push(0,s,0);return c}function r(t,n,o){if(o||2===arguments.length)for(var r,i=0,p=n.length;i<p;i++)!r&&i in n||(r||(r=Array.prototype.slice.call(n,0,i)),r[i]=n[i]);return t.concat(r||Array.prototype.slice.call(n))}function i(t,o,i,p,e,s,a,h,u){void 0===h&&(h=0),void 0===u&&(u=2*Math.PI);var l,f=[];l=4==a?n(o,p,.25*Math.PI,o-e,p):[o+e,p],0!=h&&(l=n.apply(void 0,r([o,p,h],l,!1)));for(var m,c=u/a,_=u/(2*a),v=[],y=0;y<a;y++){if(m=n.apply(void 0,r([o,p,c],l,!1)),t){var d=n.apply(void 0,r([o,p,_],l,!1));v=[d[0],0,d[1]]}f.push.apply(f,r([l[0],i,l[1]],v,!1)),f.push.apply(f,r([l[0],i+s,l[1]],v,!1)),f.push.apply(f,r([m[0],i+s,m[1]],v,!1)),f.push.apply(f,r([l[0],i,l[1]],v,!1)),f.push.apply(f,r([m[0],i,m[1]],v,!1)),f.push.apply(f,r([m[0],i+s,m[1]],v,!1)),l=m}return f}function p(t,o,r,i,p,e,s){var a,h=[o,r+p,i],u=2*Math.PI/e;t&&h.push(0,p,0);for(var l=function(){h.push.apply(h,h.slice(h.length-(t?12:6)))},f=1;f<.5*e;f++){a=n(o,r,u*f,o,r+p),f>1&&l();var m=n(o,i,u*s,a[0],i);h.push(m[0],a[1],m[1]),t&&h.push(m[0]-o,a[1]-r,m[1]-i),f>1&&l();var c=n(o,i,u*(s+1),a[0],i);h.push(c[0],a[1],c[1]),t&&h.push(c[0]-o,c[1]-r,c[1]-i)}return l(),h.push(o,r-p,i),t&&h.push(0,-p,0),h}function e(t,n,o,r,i,p){return function(e,s,a,h){if(t==r&&o==p)return[e,s,a];var u,l,f,m=e-(h?0:t),c=s-(h?0:n),_=a-(h?0:o),v=r-t,y=i-n,d=p-o,g=Math.sqrt(v*v+d*d),I=d*(u=d/g)+v*(l=v/g),M=Math.sqrt(y*y+I*I);return u=I/M,c=(f=[c,m])[0]*(l=y/M)-f[1]*u,m=f[0]*u+f[1]*l,u=d/g,m=(f=[m,_])[0]*(l=v/g)-f[1]*u,_=f[0]*u+f[1]*l,[m+(h?0:t),c+(h?0:n),_+(h?0:o)]}}function s(t,n){if(t){for(var o=[],i=0;i<n.length;i+=9){var p=[n[i+3]-n[i],n[i+4]-n[i+1],n[i+5]-n[i+2]],e=[n[i+6]-n[i],n[i+7]-n[i+1],n[i+8]-n[i+2]],s=[p[1]*e[2]-e[1]*p[2],p[2]*e[0]-p[0]*e[2],p[0]*e[1]-p[1]*e[2]];o.push.apply(o,r(r(r(r(r([n[i],n[i+1],n[i+2]],s,!1),[n[i+3],n[i+4],n[i+5]],!1),s,!1),[n[i+6],n[i+7],n[i+8]],!1),s,!1))}return o}return n}"function"==typeof SuppressedError&&SuppressedError;var a=function(){function r(t){void 0===t&&(t={}),this.name="Geometry",this.__option=function(t,n){for(var o in t)n[o]=t[o];return n}(t,{precision:.1,normal:!1})}return r.prototype.config=function(t){for(var n in t)this.__option[n]=t[n];return this},r.prototype.splitNum=function(n,o){return t(this.__option.precision,n,o)},r.prototype.rotateLine=function(t,n,o,r,i,p){var s=this,a=e(t,n,o,r,i,p);return function(t,n,o){return a(t,n,o,s.__option.normal)}},r.prototype.prismHorizontal=function(t,n,r,i,p,e,s,a){return o(this.__option.normal,t,n,r,i,p,e,s,a)},r.prototype.prismVertical=function(t,n,o,r,p,e,s,a){return i(this.__option.normal,t,n,o,r,p,e,s,a)},r.prototype.sphereFragment=function(t,n,o,r,i,e){return p(this.__option.normal,t,n,o,r,i,e)},r.prototype.pie=function(r,p,e,a,h,u,l){var f=t(this.__option.precision,a,l),m=n(r,e,u,r+a,e),c=n(r,e,u+l,r+a,e);return[{name:"bottom",points:o(this.__option.normal,r,p,e,a,f,h>0?-1:1,u,l),length:3*f,method:"TRIANGLES"},{name:"top",points:o(this.__option.normal,r,p+h,e,a,f,h>0?1:-1,u,l),length:3*f,method:"TRIANGLES"},{name:"side",points:i(this.__option.normal,r,p,e,a,h,f,u,l),length:6*f,method:"TRIANGLES"},{name:"begin",points:s(this.__option.normal,[r,p,e,r,p+h,e,m[0],p,m[1],m[0],p+h,m[1],m[0],p,m[1],r,p+h,e]),length:6,method:"TRIANGLES"},{name:"end",points:s(this.__option.normal,[r,p,e,c[0],p,c[1],r,p+h,e,c[0],p+h,c[1],r,p+h,e,c[0],p,c[1]]),length:6,method:"TRIANGLES"}]},r.prototype.cylinder=function(n,o,r,i,p,e,s){var a=t(this.__option.precision,i);return 5==arguments.length?this.prism(n,o,r,i,p,a):this.prism(n,o,r,i,p,e,s,a)},r.prototype.prism=function(t,n,r,p,s,a,h,u){var l,f,m,c,_=null;6==arguments.length?(c=s,u=a):(c=(n>a?-1:1)*Math.sqrt((s-t)*(s-t)+(a-n)*(a-n)+(h-r)*(h-r)),_=e(t,n,r,s,a,h));var v=[{name:"bottom",points:[],length:0,method:"TRIANGLES"},{name:"top",points:[],length:0,method:"TRIANGLES"},{name:"side",points:[],length:0,method:"TRIANGLES"}];(l=v[0].points).push.apply(l,o(this.__option.normal,t,n,r,p,u,c>0?-1:1)),(f=v[1].points).push.apply(f,o(this.__option.normal,t,n+c,r,p,u,c>0?1:-1)),(m=v[2].points).push.apply(m,i(this.__option.normal,t,n,r,p,c,u));for(var y=0;y<v.length;y++){if(_){for(var d=[],g=!1,I=0;I<v[y].points.length;I+=3)d.push.apply(d,_(v[y].points[I],v[y].points[I+1],v[y].points[I+2],this.__option.normal&&g)),g=!g;v[y].points=d}v[y].length=v[y].points.length/(this.__option.normal?6:3)}return v},r.prototype.sphere=function(n,o,r,i){for(var e,s=t(this.__option.precision,i),a=[{name:"surface",points:[],length:0,method:"TRIANGLES"}],h=0;h<s;h++)(e=a[0].points).push.apply(e,p(this.__option.normal,n,o,r,i,s,h));return a[0].length=a[0].points.length/(this.__option.normal?6:3),a},r}();return a},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(t="undefined"!=typeof globalThis?globalThis:t||self).VISLite_Geometry=n();