vislite 0.8.0 → 1.0.0-next.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.
- package/AUTHORS.txt +6 -6
- package/CHANGELOG +17 -2
- package/LICENSE +20 -20
- package/README.md +2 -36
- package/lib/Buffer/index.umd.js +2 -2
- package/lib/Buffer/index.umd.min.js +2 -2
- package/lib/Canvas/index.umd.js +9 -24
- package/lib/Canvas/index.umd.min.js +3 -3
- package/lib/Cardinal/index.umd.js +2 -2
- package/lib/Cardinal/index.umd.min.js +2 -2
- package/lib/Eoap/index.umd.js +2 -2
- package/lib/Eoap/index.umd.min.js +2 -2
- package/lib/Hermite/index.umd.js +2 -2
- package/lib/Hermite/index.umd.min.js +2 -2
- package/lib/Matrix4/index.umd.js +2 -2
- package/lib/Matrix4/index.umd.min.js +2 -2
- package/lib/Mercator/index.umd.js +2 -2
- package/lib/Mercator/index.umd.min.js +2 -2
- package/lib/SVG/index.umd.js +19 -35
- package/lib/SVG/index.umd.min.js +3 -3
- package/lib/Shader/index.umd.js +3 -82
- package/lib/Shader/index.umd.min.js +3 -3
- package/lib/Texture/index.umd.js +2 -2
- package/lib/Texture/index.umd.min.js +2 -2
- package/lib/TreeLayout/index.umd.js +2 -2
- package/lib/TreeLayout/index.umd.min.js +2 -2
- package/lib/animation/index.umd.js +2 -2
- package/lib/animation/index.umd.min.js +2 -2
- package/lib/getLoopColors/index.umd.js +2 -2
- package/lib/getLoopColors/index.umd.min.js +2 -2
- package/lib/getWebGLContext/index.umd.js +2 -2
- package/lib/getWebGLContext/index.umd.min.js +2 -2
- package/lib/index.umd.js +104 -944
- package/lib/index.umd.min.js +3 -3
- package/lib/move/index.umd.js +2 -2
- package/lib/move/index.umd.min.js +2 -2
- package/lib/resizeObserver/index.umd.js +2 -2
- package/lib/resizeObserver/index.umd.min.js +2 -2
- package/lib/rotate/index.umd.js +2 -2
- package/lib/rotate/index.umd.min.js +2 -2
- package/lib/ruler/index.umd.js +2 -2
- package/lib/ruler/index.umd.min.js +2 -2
- package/lib/scale/index.umd.js +2 -2
- package/lib/scale/index.umd.min.js +2 -2
- package/lib/throttle/index.umd.js +2 -2
- package/lib/throttle/index.umd.min.js +2 -2
- package/miniprogram/ui-canvas/index.js +100 -107
- package/miniprogram/ui-canvas/index.json +4 -4
- package/miniprogram/ui-canvas/index.wxml +4 -4
- package/miniprogram/ui-canvas/index.wxss +5 -5
- package/package/Buffer/index.ts +2 -2
- package/package/Canvas/index.ts +2 -2
- package/package/Cardinal/index.ts +2 -2
- package/package/Eoap/index.ts +2 -2
- package/package/Hermite/index.ts +2 -2
- package/package/Matrix4/index.ts +2 -2
- package/package/Mercator/index.ts +2 -2
- package/package/SVG/index.ts +2 -2
- package/package/Shader/index.ts +2 -39
- package/package/Texture/index.ts +2 -2
- package/package/TreeLayout/index.ts +2 -2
- package/package/animation/index.ts +2 -2
- package/package/getLoopColors/index.ts +2 -2
- package/package/index.ts +67 -76
- package/package/move/index.ts +2 -2
- package/package/resizeObserver/index.ts +2 -2
- package/package/rotate/index.ts +2 -2
- package/package/ruler/index.ts +2 -2
- package/package/scale/index.ts +2 -2
- package/package/throttle/index.ts +2 -2
- package/package.json +1 -1
- package/src/Eoap.ts +66 -66
- package/src/Matrix4/index.ts +84 -84
- package/src/Matrix4/move.ts +12 -12
- package/src/Matrix4/rotate.ts +15 -15
- package/src/Matrix4/scale.ts +11 -11
- package/src/Matrix4/transform.ts +64 -64
- package/src/Mercator.ts +27 -27
- package/src/SVG.ts +24 -24
- package/src/animation.ts +98 -98
- package/src/common/assemble.ts +22 -22
- package/src/common/canvas/arc.ts +51 -51
- package/src/common/canvas/config.ts +158 -158
- package/src/common/canvas/gradient.ts +24 -29
- package/src/common/canvas/index.ts +1 -12
- package/src/common/canvas/texts.ts +18 -18
- package/src/common/mergeOption.ts +6 -6
- package/src/common/setStyle.ts +5 -5
- package/src/common/svg/config.ts +190 -190
- package/src/common/svg/gradient.ts +53 -63
- package/src/common/svg/index.ts +347 -356
- package/src/common/svg/tool.ts +44 -44
- package/src/common/tree/index.ts +25 -25
- package/src/common/tree/toInnerTree.ts +59 -59
- package/src/common/tree/toPlainTree.ts +132 -132
- package/src/common/webgl/buffer.ts +79 -79
- package/src/common/webgl/getWebGLContext.ts +1 -1
- package/src/common/webgl/shader.ts +75 -75
- package/src/common/webgl/texture.ts +97 -97
- package/src/formatColor.ts +44 -44
- package/src/getLoopColors.ts +42 -42
- package/src/interpolation/Cardinal.ts +110 -110
- package/src/interpolation/Hermite.ts +65 -65
- package/src/layout/TreeLayout.ts +188 -188
- package/src/move.ts +7 -7
- package/src/resizeObserver.ts +37 -37
- package/src/rotate.ts +7 -7
- package/src/ruler.ts +209 -209
- package/src/scale.ts +6 -6
- package/src/throttle.ts +52 -52
- package/types/Buffer.d.ts +23 -23
- package/types/CanvasConfig.d.ts +106 -106
- package/types/CanvasOption.d.ts +8 -8
- package/types/CanvasOpts.d.ts +9 -9
- package/types/Cardinal.d.ts +13 -13
- package/types/Gradient.d.ts +14 -14
- package/types/Hermite.d.ts +18 -18
- package/types/Map.d.ts +9 -9
- package/types/Matrix4.d.ts +47 -47
- package/types/SVG.d.ts +238 -238
- package/types/SVGConfig.d.ts +79 -79
- package/types/Shader.d.ts +16 -23
- package/types/Texture.d.ts +16 -16
- package/types/Tree.d.ts +69 -69
- package/types/TreeConfig.d.ts +36 -36
- package/types/TreeLayout.d.ts +54 -54
- package/types/TreeOption.d.ts +48 -48
- package/types/animation.d.ts +9 -6
- package/types/getLoopColors.d.ts +5 -2
- package/types/getWebGLContext.d.ts +3 -0
- package/types/index.d.ts +149 -176
- package/types/move.d.ts +5 -2
- package/types/painterConfig.d.ts +2 -2
- package/types/resizeObserver.d.ts +5 -2
- package/types/rotate.d.ts +5 -2
- package/types/ruler.d.ts +10 -7
- package/types/scale.d.ts +5 -2
- package/types/throttle.d.ts +7 -4
- package/types/throttleOption.d.ts +21 -21
- package/uni-app/ui-canvas.vue +4 -11
- package/lib/Geometry/index.umd.d.ts +0 -3
- package/lib/Geometry/index.umd.js +0 -353
- package/lib/Geometry/index.umd.min.d.ts +0 -3
- package/lib/Geometry/index.umd.min.js +0 -11
- package/lib/OralCanvas/index.es.d.ts +0 -3
- package/lib/OralCanvas/index.es.js +0 -693
- package/lib/OralCanvas/index.es.min.d.ts +0 -3
- package/lib/OralCanvas/index.es.min.js +0 -11
- package/lib/OralWebGL/index.es.d.ts +0 -3
- package/lib/OralWebGL/index.es.js +0 -639
- package/lib/OralWebGL/index.es.min.d.ts +0 -3
- package/lib/OralWebGL/index.es.min.js +0 -11
- package/lib/WebGL/index.umd.d.ts +0 -3
- package/lib/WebGL/index.umd.js +0 -712
- package/lib/WebGL/index.umd.min.d.ts +0 -3
- package/lib/WebGL/index.umd.min.js +0 -11
- package/lib/formatColor/index.umd.d.ts +0 -3
- package/lib/formatColor/index.umd.js +0 -59
- package/lib/formatColor/index.umd.min.d.ts +0 -3
- package/lib/formatColor/index.umd.min.js +0 -11
- package/lib/viewHandler/index.umd.d.ts +0 -3
- package/lib/viewHandler/index.umd.js +0 -139
- package/lib/viewHandler/index.umd.min.d.ts +0 -3
- package/lib/viewHandler/index.umd.min.js +0 -11
- package/package/Geometry/index.ts +0 -3
- package/package/OralCanvas/index.ts +0 -3
- package/package/OralWebGL/index.ts +0 -3
- package/package/WebGL/index.ts +0 -3
- package/package/formatColor/index.ts +0 -3
- package/package/viewHandler/index.ts +0 -3
- package/src/Geometry.ts +0 -211
- package/src/WebGL.ts +0 -67
- package/src/common/geometry/prism-horizontal.ts +0 -50
- package/src/common/geometry/prism-vertical.ts +0 -55
- package/src/common/geometry/sphere-fragment.ts +0 -40
- package/src/common/geometry/tool/circle.ts +0 -18
- package/src/common/geometry/tool/rotateLine.ts +0 -49
- package/src/common/geometry/tool/triangles.ts +0 -24
- package/src/common/webgl/doDraw.ts +0 -109
- package/src/common/webgl/getColorFactory.ts +0 -27
- package/src/common/webgl/getShader.ts +0 -49
- package/src/common/webgl/getTexture.ts +0 -12
- package/src/common/webgl/index.ts +0 -228
- package/src/shader/fsColor.c +0 -8
- package/src/shader/fsColors.c +0 -8
- package/src/shader/fsCube.c +0 -9
- package/src/shader/fsImage.c +0 -9
- package/src/shader/vsColor.c +0 -18
- package/src/shader/vsColors.c +0 -14
- package/src/shader/vsCube.c +0 -14
- package/src/shader/vsImage.c +0 -14
- package/src/viewHandler.ts +0 -161
- package/types/Geometry.d.ts +0 -133
- package/types/GeometryOption.d.ts +0 -12
- package/types/GeometryResult.d.ts +0 -19
- package/types/Object3D.d.ts +0 -115
- package/types/Scene3D.d.ts +0 -7
- package/types/WebGL.d.ts +0 -39
- package/types/WebGLOption.d.ts +0 -15
- package/types/formatColor.d.ts +0 -3
- package/types/viewHandler.d.ts +0 -14
|
@@ -1,353 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.8.0
|
|
3
|
-
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
|
-
*
|
|
5
|
-
* Copyright zxl20070701
|
|
6
|
-
* Released under the MIT license
|
|
7
|
-
* https://zxl20070701.github.io/notebook/home.html
|
|
8
|
-
*
|
|
9
|
-
* Publish Date: Sat Mar 02 2024 12:41:38 GMT+0800 (中国标准时间)
|
|
10
|
-
*/
|
|
11
|
-
(function (global, factory) {
|
|
12
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
13
|
-
typeof define === 'function' && define.amd ? define(factory) :
|
|
14
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.VISLite_Geometry = factory());
|
|
15
|
-
})(this, (function () { 'use strict';
|
|
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;
|
|
22
|
-
};
|
|
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
|
-
];
|
|
30
|
-
}
|
|
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;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/******************************************************************************
|
|
67
|
-
Copyright (c) Microsoft Corporation.
|
|
68
|
-
|
|
69
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
70
|
-
purpose with or without fee is hereby granted.
|
|
71
|
-
|
|
72
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
73
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
74
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
75
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
76
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
77
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
78
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
79
|
-
***************************************************************************** */
|
|
80
|
-
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
function __spreadArray(to, from, pack) {
|
|
84
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
85
|
-
if (ar || !(i in from)) {
|
|
86
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
87
|
-
ar[i] = from[i];
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
94
|
-
var e = new Error(message);
|
|
95
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
96
|
-
};
|
|
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;
|
|
129
|
-
}
|
|
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;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
function mergeOption (option, defaultOption) {
|
|
162
|
-
for (var key in option) {
|
|
163
|
-
defaultOption[key] = option[key];
|
|
164
|
-
}
|
|
165
|
-
return defaultOption;
|
|
166
|
-
}
|
|
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
|
-
};
|
|
192
|
-
}
|
|
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
|
-
}
|
|
208
|
-
}
|
|
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;
|
|
349
|
-
}());
|
|
350
|
-
|
|
351
|
-
return Geometry;
|
|
352
|
-
|
|
353
|
-
}));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.8.0
|
|
3
|
-
* git+https://github.com/oi-contrib/VISLite.git
|
|
4
|
-
*
|
|
5
|
-
* Copyright zxl20070701
|
|
6
|
-
* Released under the MIT license
|
|
7
|
-
* https://zxl20070701.github.io/notebook/home.html
|
|
8
|
-
*
|
|
9
|
-
* Publish Date: Sat Mar 02 2024 12:41:38 GMT+0800 (中国标准时间)
|
|
10
|
-
*/
|
|
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();
|