vislite 0.4.1-alpha.2 → 0.4.1-beta.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/.editorconfig +19 -0
- package/CHANGELOG +17 -8
- package/README.md +16 -1
- package/lib/Buffer/index.umd.js +2 -2
- package/lib/Buffer/index.umd.min.js +2 -2
- package/lib/Canvas/index.umd.js +89 -10
- 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/OralCanvas/index.es.js +79 -8
- package/lib/OralCanvas/index.es.min.js +3 -3
- package/lib/OralWebGL/index.es.js +35 -10
- package/lib/OralWebGL/index.es.min.js +3 -3
- package/lib/SVG/index.umd.js +2 -2
- package/lib/SVG/index.umd.min.js +2 -2
- package/lib/Shader/index.umd.js +82 -3
- package/lib/Shader/index.umd.min.js +3 -3
- package/lib/Texture/index.umd.js +3 -5
- package/lib/Texture/index.umd.min.js +3 -3
- package/lib/TreeLayout/index.umd.js +427 -0
- package/lib/TreeLayout/index.umd.min.js +11 -0
- package/lib/WebGL/index.umd.js +45 -12
- package/lib/WebGL/index.umd.min.js +3 -3
- package/lib/animation/index.umd.js +3 -3
- package/lib/animation/index.umd.min.js +2 -2
- package/lib/formatColor/index.umd.js +59 -0
- package/lib/formatColor/index.umd.min.js +11 -0
- 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 +555 -23
- package/lib/index.umd.min.js +3 -3
- package/lib/resizeObserver/index.umd.js +48 -0
- package/lib/resizeObserver/index.umd.min.js +11 -0
- 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/throttle/index.umd.js +68 -0
- package/lib/throttle/index.umd.min.js +11 -0
- package/lib/viewHandler/index.umd.js +2 -2
- package/lib/viewHandler/index.umd.min.js +2 -2
- package/package/Buffer/index.ts +1 -0
- package/package/Canvas/index.ts +1 -0
- package/package/OralCanvas/index.ts +1 -0
- package/package/OralWebGL/index.ts +1 -0
- package/package/Shader/index.ts +39 -1
- package/package/Texture/index.ts +1 -0
- package/package/TreeLayout/index.ts +3 -0
- package/package/WebGL/index.ts +1 -0
- package/package/formatColor/index.ts +3 -0
- package/package/index.ts +12 -1
- package/package/resizeObserver/index.ts +3 -0
- package/package/throttle/index.ts +3 -0
- package/package.json +1 -1
- package/src/Canvas.ts +7 -3
- package/src/Eoap.ts +1 -1
- package/src/Matrix4/index.ts +1 -1
- package/src/Mercator.ts +1 -1
- package/src/SVG.ts +2 -1
- package/src/TreeLayout/index.ts +186 -0
- package/src/WebGL.ts +7 -3
- package/src/animation.ts +2 -3
- package/src/common/canvas/config.ts +2 -1
- package/src/common/canvas/index.ts +10 -3
- package/src/common/canvas/painter.ts +74 -5
- package/src/common/mergeOption.ts +7 -0
- package/src/common/svg/config.ts +2 -1
- package/src/common/svg/index.ts +2 -1
- package/src/common/svg/tool.ts +2 -1
- package/src/common/tree/index.ts +26 -0
- package/src/common/tree/toInnerTree.ts +57 -0
- package/src/common/tree/toPlainTree.ts +132 -0
- package/src/common/webgl/doDraw.ts +2 -0
- package/src/common/webgl/getShader.ts +25 -52
- package/src/common/webgl/index.ts +4 -3
- package/src/common/webgl/texture.ts +2 -5
- package/src/formatColor.ts +45 -0
- package/src/interpolation/Cardinal.ts +2 -1
- package/src/interpolation/Hermite.ts +1 -1
- package/src/resizeObserver.ts +37 -0
- package/src/ruler.ts +1 -1
- package/src/shader/fsColor.c +8 -0
- package/src/shader/fsColors.c +8 -0
- package/src/shader/fsCube.c +9 -0
- package/src/shader/fsImage.c +9 -0
- package/src/shader/vsColor.c +18 -0
- package/src/shader/vsColors.c +14 -0
- package/src/shader/vsCube.c +14 -0
- package/src/shader/vsImage.c +14 -0
- package/src/throttle.ts +50 -0
- package/src/viewHandler.ts +1 -1
- package/types/Canvas.d.ts +12 -0
- package/types/CanvasOption.d.ts +2 -2
- package/types/Shader.d.ts +6 -0
- package/types/Tree.d.ts +38 -0
- package/types/TreeConfig.d.ts +25 -0
- package/types/TreeLayout.d.ts +49 -0
- package/types/TreeOption.d.ts +46 -0
- package/types/formatColor.d.ts +3 -0
- package/types/index.d.ts +24 -1
- package/types/resizeObserver.d.ts +3 -0
- package/types/throttle.d.ts +5 -0
- package/types/throttleOption.d.ts +20 -0
package/lib/index.umd.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* VISLite JavaScript Library v0.4.1-
|
|
2
|
+
* VISLite JavaScript Library v0.4.1-beta.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:
|
|
9
|
+
* Publish Date: Wed Aug 23 2023 22:06:27 GMT+0800 (中国标准时间)
|
|
10
10
|
*/
|
|
11
11
|
(function (global, factory) {
|
|
12
12
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
@@ -278,6 +278,46 @@
|
|
|
278
278
|
return colors;
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
+
var toHex = function (value) {
|
|
282
|
+
var hex = value.toString(16);
|
|
283
|
+
return hex.length == 1 ? ("0" + hex) : hex;
|
|
284
|
+
};
|
|
285
|
+
function formatColor (color, format) {
|
|
286
|
+
var colorNode = document.getElementsByTagName('head')[0];
|
|
287
|
+
colorNode.style['color'] = color;
|
|
288
|
+
var allStyle = document.defaultView && document.defaultView.getComputedStyle ?
|
|
289
|
+
document.defaultView.getComputedStyle(colorNode, null) :
|
|
290
|
+
colorNode.currentStyle;
|
|
291
|
+
var oralFormat = allStyle.getPropertyValue('color').replace(/rgba?\(/, '').replace(")", "").split(',');
|
|
292
|
+
for (var index = 0; index < oralFormat.length; index++) {
|
|
293
|
+
oralFormat[index] = +oralFormat[index];
|
|
294
|
+
}
|
|
295
|
+
oralFormat.push(1);
|
|
296
|
+
switch (format) {
|
|
297
|
+
case "3d": {
|
|
298
|
+
return [
|
|
299
|
+
oralFormat[0] / 255,
|
|
300
|
+
oralFormat[1] / 255,
|
|
301
|
+
oralFormat[2] / 255,
|
|
302
|
+
oralFormat[3]
|
|
303
|
+
];
|
|
304
|
+
}
|
|
305
|
+
case "rgba": {
|
|
306
|
+
return "rgba(".concat(oralFormat[0], ", ").concat(oralFormat[1], ", ").concat(oralFormat[2], ", ").concat(oralFormat[3], ")");
|
|
307
|
+
}
|
|
308
|
+
case "rgb": {
|
|
309
|
+
return "rgb(".concat(oralFormat[0], ", ").concat(oralFormat[1], ", ").concat(oralFormat[2], ")");
|
|
310
|
+
}
|
|
311
|
+
case "hexAlpha": {
|
|
312
|
+
return "#".concat(toHex(oralFormat[0])).concat(toHex(oralFormat[1])).concat(toHex(oralFormat[2])).concat(toHex(+(oralFormat[3] * 255).toFixed(0)));
|
|
313
|
+
}
|
|
314
|
+
case "hex": {
|
|
315
|
+
return "#".concat(toHex(oralFormat[0])).concat(toHex(oralFormat[1])).concat(toHex(oralFormat[2]));
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
throw new Error("Unsupported color format: " + format);
|
|
319
|
+
}
|
|
320
|
+
|
|
281
321
|
var $timers = [];
|
|
282
322
|
var $interval = 13;
|
|
283
323
|
var $timerId;
|
|
@@ -343,7 +383,7 @@
|
|
|
343
383
|
var i;
|
|
344
384
|
for (i in $timers) {
|
|
345
385
|
if ($timers[i].id == id) {
|
|
346
|
-
$timers[i].id =
|
|
386
|
+
$timers[i].id = void 0;
|
|
347
387
|
return;
|
|
348
388
|
}
|
|
349
389
|
}
|
|
@@ -1011,9 +1051,11 @@
|
|
|
1011
1051
|
}
|
|
1012
1052
|
|
|
1013
1053
|
var Painter = (function () {
|
|
1014
|
-
function Painter(canvas, opts, region) {
|
|
1054
|
+
function Painter(canvas, opts, region, isPainter) {
|
|
1015
1055
|
if (opts === void 0) { opts = {}; }
|
|
1056
|
+
if (isPainter === void 0) { isPainter = false; }
|
|
1016
1057
|
this.__region = null;
|
|
1058
|
+
this.__onlyRegion = false;
|
|
1017
1059
|
this.__specialConfig = {
|
|
1018
1060
|
"fontSize": 16,
|
|
1019
1061
|
"fontFamily": "sans-serif",
|
|
@@ -1034,6 +1076,7 @@
|
|
|
1034
1076
|
};
|
|
1035
1077
|
this.painter = canvas.getContext("2d", opts);
|
|
1036
1078
|
this.__region = region;
|
|
1079
|
+
this.__isPainter = isPainter;
|
|
1037
1080
|
this.painter.textBaseline = 'middle';
|
|
1038
1081
|
this.painter.textAlign = 'left';
|
|
1039
1082
|
}
|
|
@@ -1043,6 +1086,8 @@
|
|
|
1043
1086
|
this.__region.useConfig(key, value);
|
|
1044
1087
|
}
|
|
1045
1088
|
}
|
|
1089
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1090
|
+
return this;
|
|
1046
1091
|
if (key == 'lineDash') {
|
|
1047
1092
|
if (this.painter.setLineDash)
|
|
1048
1093
|
this.painter.setLineDash(value);
|
|
@@ -1065,6 +1110,8 @@
|
|
|
1065
1110
|
if (deg === void 0) { deg = 0; }
|
|
1066
1111
|
if (this.__region)
|
|
1067
1112
|
this.__region.fillText(text, x, y, deg);
|
|
1113
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1114
|
+
return this;
|
|
1068
1115
|
this.painter.save();
|
|
1069
1116
|
initText(this.painter, this.__specialConfig, x, y, deg).fillText(text, 0, 0);
|
|
1070
1117
|
this.painter.restore();
|
|
@@ -1074,6 +1121,8 @@
|
|
|
1074
1121
|
if (deg === void 0) { deg = 0; }
|
|
1075
1122
|
if (this.__region)
|
|
1076
1123
|
this.__region.strokeText(text, x, y, deg);
|
|
1124
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1125
|
+
return this;
|
|
1077
1126
|
this.painter.save();
|
|
1078
1127
|
initText(this.painter, this.__specialConfig, x, y, deg).strokeText(text, 0, 0);
|
|
1079
1128
|
this.painter.restore();
|
|
@@ -1083,6 +1132,8 @@
|
|
|
1083
1132
|
if (deg === void 0) { deg = 0; }
|
|
1084
1133
|
if (this.__region)
|
|
1085
1134
|
this.__region.fullText(text, x, y, deg);
|
|
1135
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1136
|
+
return this;
|
|
1086
1137
|
this.painter.save();
|
|
1087
1138
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
1088
1139
|
this.painter.fillText(text, 0, 0);
|
|
@@ -1094,8 +1145,11 @@
|
|
|
1094
1145
|
var _this = this;
|
|
1095
1146
|
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
1096
1147
|
if (deg === void 0) { deg = 0; }
|
|
1148
|
+
var h = 0;
|
|
1097
1149
|
if (this.__region)
|
|
1098
|
-
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
1150
|
+
h = this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
1151
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1152
|
+
return h;
|
|
1099
1153
|
this.painter.save();
|
|
1100
1154
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
1101
1155
|
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
@@ -1108,8 +1162,11 @@
|
|
|
1108
1162
|
var _this = this;
|
|
1109
1163
|
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
1110
1164
|
if (deg === void 0) { deg = 0; }
|
|
1165
|
+
var h = 0;
|
|
1111
1166
|
if (this.__region)
|
|
1112
|
-
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
1167
|
+
h = this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
1168
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1169
|
+
return h;
|
|
1113
1170
|
this.painter.save();
|
|
1114
1171
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
1115
1172
|
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
@@ -1122,8 +1179,11 @@
|
|
|
1122
1179
|
var _this = this;
|
|
1123
1180
|
if (lineHeight === void 0) { lineHeight = 1.2; }
|
|
1124
1181
|
if (deg === void 0) { deg = 0; }
|
|
1182
|
+
var h = 0;
|
|
1125
1183
|
if (this.__region)
|
|
1126
|
-
this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
1184
|
+
h = this.__region.fillTexts(contents, x, y, width, lineHeight);
|
|
1185
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1186
|
+
return h;
|
|
1127
1187
|
this.painter.save();
|
|
1128
1188
|
initText(this.painter, this.__specialConfig, x, y, deg);
|
|
1129
1189
|
var height = texts(this.painter, contents, width, this.__specialConfig.fontSize * lineHeight, function (content, top) {
|
|
@@ -1136,48 +1196,64 @@
|
|
|
1136
1196
|
Painter.prototype.beginPath = function () {
|
|
1137
1197
|
if (this.__region)
|
|
1138
1198
|
this.__region.beginPath();
|
|
1199
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1200
|
+
return this;
|
|
1139
1201
|
this.painter.beginPath();
|
|
1140
1202
|
return this;
|
|
1141
1203
|
};
|
|
1142
1204
|
Painter.prototype.closePath = function () {
|
|
1143
1205
|
if (this.__region)
|
|
1144
1206
|
this.__region.closePath();
|
|
1207
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1208
|
+
return this;
|
|
1145
1209
|
this.painter.closePath();
|
|
1146
1210
|
return this;
|
|
1147
1211
|
};
|
|
1148
1212
|
Painter.prototype.moveTo = function (x, y) {
|
|
1149
1213
|
if (this.__region)
|
|
1150
1214
|
this.__region.moveTo(x, y);
|
|
1215
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1216
|
+
return this;
|
|
1151
1217
|
this.painter.moveTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
1152
1218
|
return this;
|
|
1153
1219
|
};
|
|
1154
1220
|
Painter.prototype.lineTo = function (x, y) {
|
|
1155
1221
|
if (this.__region)
|
|
1156
1222
|
this.__region.lineTo(x, y);
|
|
1223
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1224
|
+
return this;
|
|
1157
1225
|
this.painter.lineTo(Math.round(x) + 0.5, Math.round(y) + 0.5);
|
|
1158
1226
|
return this;
|
|
1159
1227
|
};
|
|
1160
1228
|
Painter.prototype.arc = function (x, y, r, beginDeg, deg) {
|
|
1161
1229
|
if (this.__region)
|
|
1162
1230
|
this.__region.arc(x, y, r, beginDeg, deg);
|
|
1231
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1232
|
+
return this;
|
|
1163
1233
|
this.painter.arc(x, y, r, beginDeg, beginDeg + deg, deg < 0);
|
|
1164
1234
|
return this;
|
|
1165
1235
|
};
|
|
1166
1236
|
Painter.prototype.fill = function () {
|
|
1167
1237
|
if (this.__region)
|
|
1168
1238
|
this.__region.fill();
|
|
1239
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1240
|
+
return this;
|
|
1169
1241
|
this.painter.fill();
|
|
1170
1242
|
return this;
|
|
1171
1243
|
};
|
|
1172
1244
|
Painter.prototype.stroke = function () {
|
|
1173
1245
|
if (this.__region)
|
|
1174
1246
|
this.__region.stroke();
|
|
1247
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1248
|
+
return this;
|
|
1175
1249
|
this.painter.stroke();
|
|
1176
1250
|
return this;
|
|
1177
1251
|
};
|
|
1178
1252
|
Painter.prototype.full = function () {
|
|
1179
1253
|
if (this.__region)
|
|
1180
1254
|
this.__region.full();
|
|
1255
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1256
|
+
return this;
|
|
1181
1257
|
this.painter.fill();
|
|
1182
1258
|
this.painter.stroke();
|
|
1183
1259
|
return this;
|
|
@@ -1185,54 +1261,72 @@
|
|
|
1185
1261
|
Painter.prototype.save = function () {
|
|
1186
1262
|
if (this.__region)
|
|
1187
1263
|
this.__region.save();
|
|
1264
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1265
|
+
return this;
|
|
1188
1266
|
this.painter.save();
|
|
1189
1267
|
return this;
|
|
1190
1268
|
};
|
|
1191
1269
|
Painter.prototype.restore = function () {
|
|
1192
1270
|
if (this.__region)
|
|
1193
1271
|
this.__region.restore();
|
|
1272
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1273
|
+
return this;
|
|
1194
1274
|
this.painter.restore();
|
|
1195
1275
|
return this;
|
|
1196
1276
|
};
|
|
1197
1277
|
Painter.prototype.clip = function () {
|
|
1198
1278
|
if (this.__region)
|
|
1199
1279
|
this.__region.clip();
|
|
1280
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1281
|
+
return this;
|
|
1200
1282
|
this.painter.clip();
|
|
1201
1283
|
return this;
|
|
1202
1284
|
};
|
|
1203
1285
|
Painter.prototype.quadraticCurveTo = function (cpx, cpy, x, y) {
|
|
1204
1286
|
if (this.__region)
|
|
1205
1287
|
this.__region.quadraticCurveTo(cpx, cpy, x, y);
|
|
1288
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1289
|
+
return this;
|
|
1206
1290
|
this.painter.quadraticCurveTo(cpx, cpy, x, y);
|
|
1207
1291
|
return this;
|
|
1208
1292
|
};
|
|
1209
1293
|
Painter.prototype.bezierCurveTo = function (cp1x, cp1y, cp2x, cp2y, x, y) {
|
|
1210
1294
|
if (this.__region)
|
|
1211
1295
|
this.__region.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
1296
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1297
|
+
return this;
|
|
1212
1298
|
this.painter.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
|
|
1213
1299
|
return this;
|
|
1214
1300
|
};
|
|
1215
1301
|
Painter.prototype.clearRect = function (x, y, w, h) {
|
|
1216
1302
|
if (this.__region)
|
|
1217
1303
|
this.__region.clearRect(x, y, w, h);
|
|
1304
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1305
|
+
return this;
|
|
1218
1306
|
this.painter.clearRect(x, y, w, h);
|
|
1219
1307
|
return this;
|
|
1220
1308
|
};
|
|
1221
1309
|
Painter.prototype.fillArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
1222
1310
|
if (this.__region)
|
|
1223
1311
|
this.__region.fillArc(cx, cy, r1, r2, beginDeg, deg);
|
|
1312
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1313
|
+
return this;
|
|
1224
1314
|
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).fill();
|
|
1225
1315
|
return this;
|
|
1226
1316
|
};
|
|
1227
1317
|
Painter.prototype.strokeArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
1228
1318
|
if (this.__region)
|
|
1229
1319
|
this.__region.strokeArc(cx, cy, r1, r2, beginDeg, deg);
|
|
1320
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1321
|
+
return this;
|
|
1230
1322
|
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg).stroke();
|
|
1231
1323
|
return this;
|
|
1232
1324
|
};
|
|
1233
1325
|
Painter.prototype.fullArc = function (cx, cy, r1, r2, beginDeg, deg) {
|
|
1234
1326
|
if (this.__region)
|
|
1235
1327
|
this.__region.fullArc(cx, cy, r1, r2, beginDeg, deg);
|
|
1328
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1329
|
+
return this;
|
|
1236
1330
|
initArc(this.painter, this.__specialConfig, cx, cy, r1, r2, beginDeg, deg);
|
|
1237
1331
|
this.painter.fill();
|
|
1238
1332
|
this.painter.stroke();
|
|
@@ -1241,18 +1335,24 @@
|
|
|
1241
1335
|
Painter.prototype.fillCircle = function (cx, cy, r) {
|
|
1242
1336
|
if (this.__region)
|
|
1243
1337
|
this.__region.fillCircle(cx, cy, r);
|
|
1338
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1339
|
+
return this;
|
|
1244
1340
|
initCircle(this.painter, cx, cy, r).fill();
|
|
1245
1341
|
return this;
|
|
1246
1342
|
};
|
|
1247
1343
|
Painter.prototype.strokeCircle = function (cx, cy, r) {
|
|
1248
1344
|
if (this.__region)
|
|
1249
1345
|
this.__region.strokeCircle(cx, cy, r);
|
|
1346
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1347
|
+
return this;
|
|
1250
1348
|
initCircle(this.painter, cx, cy, r).stroke();
|
|
1251
1349
|
return this;
|
|
1252
1350
|
};
|
|
1253
1351
|
Painter.prototype.fullCircle = function (cx, cy, r) {
|
|
1254
1352
|
if (this.__region)
|
|
1255
1353
|
this.__region.fullCircle(cx, cy, r);
|
|
1354
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1355
|
+
return this;
|
|
1256
1356
|
initCircle(this.painter, cx, cy, r);
|
|
1257
1357
|
this.painter.fill();
|
|
1258
1358
|
this.painter.stroke();
|
|
@@ -1261,23 +1361,30 @@
|
|
|
1261
1361
|
Painter.prototype.fillRect = function (x, y, width, height) {
|
|
1262
1362
|
if (this.__region)
|
|
1263
1363
|
this.__region.fillRect(x, y, width, height);
|
|
1364
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1365
|
+
return this;
|
|
1264
1366
|
initRect(this.painter, x, y, width, height).fill();
|
|
1265
1367
|
return this;
|
|
1266
1368
|
};
|
|
1267
1369
|
Painter.prototype.strokeRect = function (x, y, width, height) {
|
|
1268
1370
|
if (this.__region)
|
|
1269
1371
|
this.__region.strokeRect(x, y, width, height);
|
|
1372
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1373
|
+
return this;
|
|
1270
1374
|
initRect(this.painter, x, y, width, height).stroke();
|
|
1271
1375
|
return this;
|
|
1272
1376
|
};
|
|
1273
1377
|
Painter.prototype.fullRect = function (x, y, width, height) {
|
|
1274
1378
|
if (this.__region)
|
|
1275
1379
|
this.__region.fullRect(x, y, width, height);
|
|
1380
|
+
if (this.__isPainter && this.__onlyRegion)
|
|
1381
|
+
return this;
|
|
1276
1382
|
initRect(this.painter, x, y, width, height);
|
|
1277
1383
|
this.painter.fill();
|
|
1278
1384
|
this.painter.stroke();
|
|
1279
1385
|
return this;
|
|
1280
1386
|
};
|
|
1387
|
+
Painter.prototype.draw = function () { };
|
|
1281
1388
|
return Painter;
|
|
1282
1389
|
}());
|
|
1283
1390
|
|
|
@@ -1339,7 +1446,7 @@
|
|
|
1339
1446
|
function Canvas(ViewCanvas, RegionCanvas) {
|
|
1340
1447
|
var _this = _super.call(this, ViewCanvas, {}, RegionCanvas ? new Painter(RegionCanvas, {
|
|
1341
1448
|
willReadFrequently: true,
|
|
1342
|
-
}) : null) || this;
|
|
1449
|
+
}) : null, true) || this;
|
|
1343
1450
|
_this.name = "Canvas";
|
|
1344
1451
|
_this.__regionList = {};
|
|
1345
1452
|
_this.__regionAssemble = assemble(0, 255, 10, 3);
|
|
@@ -1353,10 +1460,14 @@
|
|
|
1353
1460
|
}
|
|
1354
1461
|
return this;
|
|
1355
1462
|
};
|
|
1463
|
+
Canvas.prototype.onlyRegion = function (flag) {
|
|
1464
|
+
this.__onlyRegion = flag;
|
|
1465
|
+
return this;
|
|
1466
|
+
};
|
|
1356
1467
|
Canvas.prototype.setRegion = function (regionName) {
|
|
1357
1468
|
if (this.__region) {
|
|
1358
1469
|
if (regionName) {
|
|
1359
|
-
if (this.__regionList[regionName] ==
|
|
1470
|
+
if (this.__regionList[regionName] == void 0) {
|
|
1360
1471
|
var tempColor = this.__regionAssemble();
|
|
1361
1472
|
this.__regionList[regionName] =
|
|
1362
1473
|
"rgb(" + tempColor[0] + "," + tempColor[1] + "," + tempColor[2] + ")";
|
|
@@ -1439,6 +1550,13 @@
|
|
|
1439
1550
|
return Canvas;
|
|
1440
1551
|
}(Painter));
|
|
1441
1552
|
|
|
1553
|
+
function mergeOption (option, defaultOption) {
|
|
1554
|
+
for (var key in option) {
|
|
1555
|
+
defaultOption[key] = option[key];
|
|
1556
|
+
}
|
|
1557
|
+
return defaultOption;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1442
1560
|
var Canvas = (function (_super) {
|
|
1443
1561
|
__extends(Canvas, _super);
|
|
1444
1562
|
function Canvas(el, option) {
|
|
@@ -1447,8 +1565,9 @@
|
|
|
1447
1565
|
if (!el) {
|
|
1448
1566
|
throw new Error("VISLite Canvas:The mount point requires an HTMLElement type but encountered null.");
|
|
1449
1567
|
}
|
|
1450
|
-
|
|
1451
|
-
|
|
1568
|
+
option = mergeOption(option, {
|
|
1569
|
+
region: true
|
|
1570
|
+
});
|
|
1452
1571
|
var width = el.clientWidth, height = el.clientHeight;
|
|
1453
1572
|
var ViewCanvas, RegionCanvas;
|
|
1454
1573
|
var _el = el;
|
|
@@ -1561,9 +1680,7 @@
|
|
|
1561
1680
|
|
|
1562
1681
|
var initTexture = function (painter, type, unit) {
|
|
1563
1682
|
var texture = painter.createTexture();
|
|
1564
|
-
|
|
1565
|
-
painter.activeTexture(painter['TEXTURE' + unit]);
|
|
1566
|
-
}
|
|
1683
|
+
painter.activeTexture(painter['TEXTURE' + unit]);
|
|
1567
1684
|
painter.bindTexture(type, texture);
|
|
1568
1685
|
return texture;
|
|
1569
1686
|
};
|
|
@@ -1659,18 +1776,44 @@
|
|
|
1659
1776
|
return ShaderObject;
|
|
1660
1777
|
}());
|
|
1661
1778
|
|
|
1779
|
+
var vsColor = "attribute vec4 a_position;\r\nuniform mat4 u_matrix;\r\n\r\nvoid main()\r\n{\r\n vec4 temp = u_matrix * a_position;\r\n\r\n // 把原生的WebGL使用的左手坐标系变成了右手坐标系\r\n temp.z = -1.0 * temp.z;\r\n\r\n // 表示眼睛距离vec4(0.0,0.0,1.0)的距离\r\n float dist = 4.0;\r\n\r\n // 使用投影直接计算\r\n // 为保证纹理和相对位置正确\r\n // x、y、z的改变满足线性变换\r\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\r\n}";
|
|
1780
|
+
|
|
1781
|
+
var vsColors = "attribute vec4 a_position;\r\nuniform mat4 u_matrix;\r\nattribute vec4 a_color;\r\nvarying vec4 v_color;\r\n\r\nvoid main()\r\n{\r\n vec4 temp = u_matrix * a_position;\r\n temp.z = -1.0 * temp.z;\r\n float dist = 4.0;\r\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\r\n\r\n v_color = a_color;\r\n}";
|
|
1782
|
+
|
|
1783
|
+
var vsImage = "attribute vec4 a_position;\r\nuniform mat4 u_matrix;\r\nattribute vec2 a_textcoord;\r\nvarying vec2 v_textcoord;\r\n\r\nvoid main()\r\n{\r\n vec4 temp = u_matrix * a_position;\r\n temp.z = -1.0 * temp.z;\r\n float dist = 4.0;\r\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\r\n\r\n v_textcoord = a_textcoord;\r\n}";
|
|
1784
|
+
|
|
1785
|
+
var vsCube = "attribute vec4 a_position;\r\nuniform mat4 u_matrix;\r\nattribute vec4 a_normal;\r\nvarying vec3 v_normal;\r\n\r\nvoid main()\r\n{\r\n vec4 temp = u_matrix * a_position;\r\n temp.z = -1.0 * temp.z;\r\n float dist = 4.0;\r\n gl_Position = vec4((dist + 1.0) * temp.x, (dist + 1.0) * temp.y, dist * (dist + temp.z) + 1.0 - dist * dist, temp.w * 2.0 * (dist + temp.z));\r\n\r\n v_normal = normalize(vec3(a_normal));\r\n}";
|
|
1786
|
+
|
|
1787
|
+
var fsColor = "precision mediump float;\r\n\r\nuniform vec4 u_color;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = u_color;\r\n}";
|
|
1788
|
+
|
|
1789
|
+
var fsColors = "precision mediump float;\r\n\r\nvarying vec4 v_color;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = v_color;\r\n}";
|
|
1790
|
+
|
|
1791
|
+
var fsImage = "precision mediump float;\r\n\r\nuniform sampler2D u_sampler;\r\nvarying vec2 v_textcoord;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = texture2D(u_sampler, v_textcoord);\r\n}";
|
|
1792
|
+
|
|
1793
|
+
var fsCube = "precision mediump float;\r\n\r\nvarying vec3 v_normal;\r\nuniform samplerCube u_texture;\r\n\r\nvoid main()\r\n{\r\n gl_FragColor = textureCube(u_texture, normalize(v_normal));\r\n}";
|
|
1794
|
+
|
|
1662
1795
|
var shaders = {};
|
|
1663
1796
|
function getShader (type, painter, mesh) {
|
|
1797
|
+
var _a, _b;
|
|
1664
1798
|
var uniqueName = type +
|
|
1665
|
-
(mesh.geometry.attributes.normal ? "1" : "0") +
|
|
1666
|
-
(mesh.material.image ? "1" : "0") +
|
|
1667
1799
|
(mesh.material.color ? "1" : "0") +
|
|
1668
1800
|
(mesh.material.colors ? "1" : "0") +
|
|
1801
|
+
(mesh.material.image ? "1" : "0") +
|
|
1669
1802
|
(mesh.material.cube ? "1" : "0");
|
|
1670
1803
|
if (shaders[uniqueName])
|
|
1671
1804
|
return shaders[uniqueName].use();
|
|
1672
|
-
var vertexShader =
|
|
1673
|
-
|
|
1805
|
+
var vertexShader = (_a = {},
|
|
1806
|
+
_a[type + "1000"] = vsColor,
|
|
1807
|
+
_a[type + "0100"] = vsColors,
|
|
1808
|
+
_a[type + "0010"] = vsImage,
|
|
1809
|
+
_a[type + "0001"] = vsCube,
|
|
1810
|
+
_a)[uniqueName].replace(/uniform +mat4 +u_matrix;/, "\n uniform mat4 u_matrix_world;\n uniform mat4 u_matrix_mesh;\n uniform mat4 u_matrix_proporion;").replace(/u_matrix +\* +a_position/, "u_matrix_proporion * u_matrix_world * u_matrix_mesh * a_position");
|
|
1811
|
+
var fragmentShader = (_b = {},
|
|
1812
|
+
_b[type + "1000"] = fsColor,
|
|
1813
|
+
_b[type + "0100"] = fsColors,
|
|
1814
|
+
_b[type + "0010"] = fsImage,
|
|
1815
|
+
_b[type + "0001"] = fsCube,
|
|
1816
|
+
_b)[uniqueName];
|
|
1674
1817
|
var shader = new ShaderObject(painter).compile(vertexShader, fragmentShader).use();
|
|
1675
1818
|
shaders[uniqueName] = shader;
|
|
1676
1819
|
return shader;
|
|
@@ -1699,6 +1842,7 @@
|
|
|
1699
1842
|
}
|
|
1700
1843
|
else if ("cube" in mesh.material) {
|
|
1701
1844
|
var size = mesh.material.cube.right.image.value.width;
|
|
1845
|
+
painter.uniform1i(painter.getUniformLocation(shader.program, "u_texture"), 0);
|
|
1702
1846
|
getTexture(type, painter, 'cube').useCube([
|
|
1703
1847
|
mesh.material.cube.right.image.value,
|
|
1704
1848
|
mesh.material.cube.left.image.value,
|
|
@@ -1855,7 +1999,7 @@
|
|
|
1855
1999
|
WebGL.prototype.setRegion = function (regionName) {
|
|
1856
2000
|
this.__regionName = regionName + "";
|
|
1857
2001
|
if (regionName) {
|
|
1858
|
-
if (this.__regionList[regionName] ==
|
|
2002
|
+
if (this.__regionList[regionName] == void 0) {
|
|
1859
2003
|
this.__regionList[regionName] = __spreadArray(__spreadArray([], this.__regionAssemble(), true), [1], false);
|
|
1860
2004
|
}
|
|
1861
2005
|
this.__regionColor = this.__regionList[regionName];
|
|
@@ -1892,8 +2036,9 @@
|
|
|
1892
2036
|
if (!el) {
|
|
1893
2037
|
throw new Error("VISLite WebGL:The mount point requires an HTMLElement type but encountered null.");
|
|
1894
2038
|
}
|
|
1895
|
-
|
|
1896
|
-
|
|
2039
|
+
option = mergeOption(option, {
|
|
2040
|
+
region: true
|
|
2041
|
+
});
|
|
1897
2042
|
var width = el.clientWidth, height = el.clientHeight;
|
|
1898
2043
|
var ViewCanvas, RegionCanvas;
|
|
1899
2044
|
var _el = el;
|
|
@@ -1952,6 +2097,33 @@
|
|
|
1952
2097
|
return getWebGLContext$1(ViewCanvas, scale);
|
|
1953
2098
|
});
|
|
1954
2099
|
|
|
2100
|
+
var Shader = (function (_super) {
|
|
2101
|
+
__extends(Shader, _super);
|
|
2102
|
+
function Shader() {
|
|
2103
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
2104
|
+
}
|
|
2105
|
+
Shader.prototype.compile = function (arg1, arg2) {
|
|
2106
|
+
if (arg2) {
|
|
2107
|
+
_super.prototype.compile.call(this, arg1, arg2);
|
|
2108
|
+
}
|
|
2109
|
+
else {
|
|
2110
|
+
_super.prototype.compile.call(this, {
|
|
2111
|
+
"color": vsColor,
|
|
2112
|
+
"colors": vsColors,
|
|
2113
|
+
"image": vsImage,
|
|
2114
|
+
"cube": vsCube
|
|
2115
|
+
}[arg1], {
|
|
2116
|
+
"color": fsColor,
|
|
2117
|
+
"colors": fsColors,
|
|
2118
|
+
"image": fsImage,
|
|
2119
|
+
"cube": fsCube
|
|
2120
|
+
}[arg1]);
|
|
2121
|
+
}
|
|
2122
|
+
return this;
|
|
2123
|
+
};
|
|
2124
|
+
return Shader;
|
|
2125
|
+
}(ShaderObject));
|
|
2126
|
+
|
|
1955
2127
|
var rotateX = function (deg, x, y, z) {
|
|
1956
2128
|
var cos = Math.cos(deg), sin = Math.sin(deg);
|
|
1957
2129
|
return [x, y * cos - z * sin, y * sin + z * cos];
|
|
@@ -2125,24 +2297,384 @@
|
|
|
2125
2297
|
}
|
|
2126
2298
|
}
|
|
2127
2299
|
|
|
2300
|
+
var observer;
|
|
2301
|
+
var attrValueToCallback = {}, uniqueid = 0;
|
|
2302
|
+
function resizeObserver (el, callback) {
|
|
2303
|
+
try {
|
|
2304
|
+
if (!observer) {
|
|
2305
|
+
observer = new ResizeObserver(function (entries) {
|
|
2306
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
2307
|
+
var entry = entries_1[_i];
|
|
2308
|
+
attrValueToCallback[entry.target._resize_observer_]();
|
|
2309
|
+
}
|
|
2310
|
+
});
|
|
2311
|
+
}
|
|
2312
|
+
uniqueid++;
|
|
2313
|
+
el._resize_observer_ = uniqueid;
|
|
2314
|
+
attrValueToCallback[uniqueid] = callback;
|
|
2315
|
+
observer.observe(el);
|
|
2316
|
+
return function () {
|
|
2317
|
+
if (observer) {
|
|
2318
|
+
observer.unobserve(el);
|
|
2319
|
+
delete attrValueToCallback[el._resize_observer_];
|
|
2320
|
+
}
|
|
2321
|
+
};
|
|
2322
|
+
}
|
|
2323
|
+
catch (e) {
|
|
2324
|
+
callback();
|
|
2325
|
+
console.error('ResizeObserver undefined!');
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
function throttle (callback, option) {
|
|
2330
|
+
if (option === void 0) { option = {}; }
|
|
2331
|
+
option = mergeOption(option, {
|
|
2332
|
+
time: 200,
|
|
2333
|
+
keep: false,
|
|
2334
|
+
opportunity: "end"
|
|
2335
|
+
});
|
|
2336
|
+
var hadInterval = false;
|
|
2337
|
+
var hadClick = false;
|
|
2338
|
+
var oneClick = false;
|
|
2339
|
+
return function () {
|
|
2340
|
+
var _this = this, arg = arguments;
|
|
2341
|
+
if (!hadInterval) {
|
|
2342
|
+
if (option.opportunity != 'end') {
|
|
2343
|
+
callback.apply(_this, arg);
|
|
2344
|
+
}
|
|
2345
|
+
hadInterval = true;
|
|
2346
|
+
var interval_1 = setInterval(function () {
|
|
2347
|
+
if (hadClick) {
|
|
2348
|
+
if (!option.keep) {
|
|
2349
|
+
callback.apply(_this, arg);
|
|
2350
|
+
}
|
|
2351
|
+
}
|
|
2352
|
+
else {
|
|
2353
|
+
if (option.opportunity != 'begin') {
|
|
2354
|
+
if (oneClick || option.opportunity == 'end')
|
|
2355
|
+
callback.apply(_this, arg);
|
|
2356
|
+
}
|
|
2357
|
+
hadInterval = false;
|
|
2358
|
+
oneClick = false;
|
|
2359
|
+
clearInterval(interval_1);
|
|
2360
|
+
}
|
|
2361
|
+
hadClick = false;
|
|
2362
|
+
}, option.time);
|
|
2363
|
+
}
|
|
2364
|
+
else {
|
|
2365
|
+
hadClick = true;
|
|
2366
|
+
oneClick = true;
|
|
2367
|
+
}
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
var toInnerTree = (function (initTree, config) {
|
|
2372
|
+
var tempTree = {};
|
|
2373
|
+
var temp = config.root(initTree), id, rid;
|
|
2374
|
+
id = rid = config.id(temp);
|
|
2375
|
+
tempTree[id] = {
|
|
2376
|
+
"data": temp,
|
|
2377
|
+
"pid": null,
|
|
2378
|
+
"id": id,
|
|
2379
|
+
"isOpen": true,
|
|
2380
|
+
"show": true,
|
|
2381
|
+
"children": []
|
|
2382
|
+
};
|
|
2383
|
+
var num = 1;
|
|
2384
|
+
(function createTree(pdata, pid) {
|
|
2385
|
+
var children = config.children(pdata, initTree);
|
|
2386
|
+
num += children ? children.length : 0;
|
|
2387
|
+
for (var flag = 0; children && flag < children.length; flag++) {
|
|
2388
|
+
id = config.id(children[flag]);
|
|
2389
|
+
tempTree[pid].children.push(id);
|
|
2390
|
+
tempTree[id] = {
|
|
2391
|
+
"data": children[flag],
|
|
2392
|
+
"pid": pid,
|
|
2393
|
+
"id": id,
|
|
2394
|
+
"isOpen": true,
|
|
2395
|
+
"show": true,
|
|
2396
|
+
"children": []
|
|
2397
|
+
};
|
|
2398
|
+
createTree(children[flag], id);
|
|
2399
|
+
}
|
|
2400
|
+
})(temp, id);
|
|
2401
|
+
return {
|
|
2402
|
+
rid: rid,
|
|
2403
|
+
value: tempTree,
|
|
2404
|
+
num: num
|
|
2405
|
+
};
|
|
2406
|
+
});
|
|
2407
|
+
|
|
2408
|
+
function toPlainTree (initTree, config, noOpens) {
|
|
2409
|
+
var treeData = toInnerTree(initTree, config);
|
|
2410
|
+
var alltreedata = treeData.value;
|
|
2411
|
+
var rootid = treeData.rid;
|
|
2412
|
+
if (treeData.num == 1) {
|
|
2413
|
+
alltreedata[rootid].left = 0.5;
|
|
2414
|
+
alltreedata[rootid].top = 0.5;
|
|
2415
|
+
alltreedata[rootid].show = true;
|
|
2416
|
+
return {
|
|
2417
|
+
deep: 1,
|
|
2418
|
+
node: alltreedata,
|
|
2419
|
+
root: rootid,
|
|
2420
|
+
size: 1
|
|
2421
|
+
};
|
|
2422
|
+
}
|
|
2423
|
+
else {
|
|
2424
|
+
var beforeDis_1 = [], size_1 = 0, maxDeep_1 = 0;
|
|
2425
|
+
if (noOpens[rootid]) {
|
|
2426
|
+
alltreedata[rootid].left = 0.5;
|
|
2427
|
+
alltreedata[rootid].top = 0.5;
|
|
2428
|
+
alltreedata[rootid].show = true;
|
|
2429
|
+
size_1 = 1;
|
|
2430
|
+
}
|
|
2431
|
+
else {
|
|
2432
|
+
(function positionCalc(pNode, deep) {
|
|
2433
|
+
if (deep > maxDeep_1)
|
|
2434
|
+
maxDeep_1 = deep;
|
|
2435
|
+
var flag = 0;
|
|
2436
|
+
if (!noOpens[pNode.id]) {
|
|
2437
|
+
for (flag = 0; flag < pNode.children.length; flag++)
|
|
2438
|
+
positionCalc(alltreedata[pNode.children[flag]], deep + 1);
|
|
2439
|
+
}
|
|
2440
|
+
alltreedata[pNode.id].left = deep + 0.5;
|
|
2441
|
+
if (flag == 0) {
|
|
2442
|
+
if (beforeDis_1[deep] == void 0)
|
|
2443
|
+
beforeDis_1[deep] = -0.5;
|
|
2444
|
+
if (beforeDis_1[deep - 1] == void 0)
|
|
2445
|
+
beforeDis_1[deep - 1] = -0.5;
|
|
2446
|
+
alltreedata[pNode.id].top = beforeDis_1[deep] + 1;
|
|
2447
|
+
var pTop = beforeDis_1[deep] + 1 + (alltreedata[pNode.pid].children.length - 1) * 0.5;
|
|
2448
|
+
if (pTop - 1 < beforeDis_1[deep - 1])
|
|
2449
|
+
alltreedata[pNode.id].top = beforeDis_1[deep - 1] + 1 - (alltreedata[pNode.pid].children.length - 1) * 0.5;
|
|
2450
|
+
}
|
|
2451
|
+
else {
|
|
2452
|
+
alltreedata[pNode.id].top = (alltreedata[pNode.children[0]].top + alltreedata[pNode.children[flag - 1]].top) * 0.5;
|
|
2453
|
+
}
|
|
2454
|
+
if (alltreedata[pNode.id].top <= beforeDis_1[deep]) {
|
|
2455
|
+
var needUp_1 = beforeDis_1[deep] + 1 - alltreedata[pNode.id].top(function doUp(_pid, _deep) {
|
|
2456
|
+
alltreedata[_pid].top += needUp_1;
|
|
2457
|
+
if (beforeDis_1[_deep] < alltreedata[_pid].top)
|
|
2458
|
+
beforeDis_1[_deep] = alltreedata[_pid].top;
|
|
2459
|
+
for (var _flag = 0; _flag < alltreedata[_pid].children.length; _flag++) {
|
|
2460
|
+
doUp(alltreedata[_pid].children[_flag], _deep + 1);
|
|
2461
|
+
}
|
|
2462
|
+
})(pNode.id, deep);
|
|
2463
|
+
}
|
|
2464
|
+
beforeDis_1[deep] = alltreedata[pNode.id].top;
|
|
2465
|
+
if (alltreedata[pNode.id].top + 0.5 > size_1)
|
|
2466
|
+
size_1 = alltreedata[pNode.id].top + 0.5;
|
|
2467
|
+
})(alltreedata[rootid], 0);
|
|
2468
|
+
}
|
|
2469
|
+
for (var key in noOpens) {
|
|
2470
|
+
if (noOpens[key]) {
|
|
2471
|
+
alltreedata[key].isOpen = false;
|
|
2472
|
+
(function updateHidden(pid, left, top) {
|
|
2473
|
+
for (var index = 0; index < alltreedata[pid].children.length; index++) {
|
|
2474
|
+
alltreedata[alltreedata[pid].children[index]].left = left;
|
|
2475
|
+
alltreedata[alltreedata[pid].children[index]].top = top;
|
|
2476
|
+
alltreedata[alltreedata[pid].children[index]].show = false;
|
|
2477
|
+
updateHidden(alltreedata[pid].children[index], left, top);
|
|
2478
|
+
}
|
|
2479
|
+
})(key, alltreedata[key].left, alltreedata[key].top);
|
|
2480
|
+
}
|
|
2481
|
+
}
|
|
2482
|
+
return {
|
|
2483
|
+
"node": alltreedata,
|
|
2484
|
+
"root": rootid,
|
|
2485
|
+
"size": size_1,
|
|
2486
|
+
"deep": maxDeep_1 + 1
|
|
2487
|
+
};
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
|
|
2491
|
+
var Tree = (function () {
|
|
2492
|
+
function Tree(config) {
|
|
2493
|
+
if (config === void 0) { config = {}; }
|
|
2494
|
+
this.name = 'Tree';
|
|
2495
|
+
this.__config = mergeOption(config, {
|
|
2496
|
+
root: function (initTree) { return initTree; },
|
|
2497
|
+
children: function (parentTree) { return parentTree.children; },
|
|
2498
|
+
id: function (treedata) { return treedata.name; }
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
Tree.prototype.use = function (initTree, noOpens) {
|
|
2502
|
+
if (noOpens === void 0) { noOpens = {}; }
|
|
2503
|
+
return toPlainTree(initTree, this.__config, noOpens);
|
|
2504
|
+
};
|
|
2505
|
+
return Tree;
|
|
2506
|
+
}());
|
|
2507
|
+
|
|
2508
|
+
var TreeLayout = (function (_super) {
|
|
2509
|
+
__extends(TreeLayout, _super);
|
|
2510
|
+
function TreeLayout() {
|
|
2511
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
2512
|
+
_this.name = 'TreeLayout';
|
|
2513
|
+
_this.__option = {
|
|
2514
|
+
offsetX: 0,
|
|
2515
|
+
offsetY: 0,
|
|
2516
|
+
duration: 500,
|
|
2517
|
+
type: "plain",
|
|
2518
|
+
direction: "LR",
|
|
2519
|
+
x: 100,
|
|
2520
|
+
y: 100,
|
|
2521
|
+
width: 100,
|
|
2522
|
+
height: 100,
|
|
2523
|
+
radius: 100
|
|
2524
|
+
};
|
|
2525
|
+
_this.__noOpens = {};
|
|
2526
|
+
return _this;
|
|
2527
|
+
}
|
|
2528
|
+
TreeLayout.prototype.setOption = function (option) {
|
|
2529
|
+
mergeOption(option, this.__option);
|
|
2530
|
+
return this;
|
|
2531
|
+
};
|
|
2532
|
+
TreeLayout.prototype.use = function (initTree, noOpens) {
|
|
2533
|
+
var tree = _super.prototype.use.call(this, initTree, noOpens);
|
|
2534
|
+
if (this.__option.offsetX != 0 || this.__option.offsetY != 0) {
|
|
2535
|
+
for (var key in tree.node) {
|
|
2536
|
+
if (!tree.node[key].show) {
|
|
2537
|
+
var deep = 0, pid = key;
|
|
2538
|
+
do {
|
|
2539
|
+
pid = tree.node[pid].pid;
|
|
2540
|
+
deep++;
|
|
2541
|
+
} while (!tree.node[pid].show);
|
|
2542
|
+
tree.node[key].left += this.__option.offsetX * deep;
|
|
2543
|
+
tree.node[key].top += this.__option.offsetY * deep;
|
|
2544
|
+
}
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
if (this.__option.type == 'rect') {
|
|
2548
|
+
if (this.__option.direction == 'LR' || this.__option.direction == "RL") {
|
|
2549
|
+
var perW = this.__option.height / tree.size;
|
|
2550
|
+
var perD = this.__option.width / (tree.deep - 1);
|
|
2551
|
+
var balanceW = this.__option.y - this.__option.height * 0.5;
|
|
2552
|
+
var flag = this.__option.direction == 'LR' ? 1 : -1;
|
|
2553
|
+
for (var key in tree.node) {
|
|
2554
|
+
if (tree.deep == 1) {
|
|
2555
|
+
tree.node[key].left = this.__option.x + this.__option.width * 0.5 * flag;
|
|
2556
|
+
tree.node[key].top = this.__option.y;
|
|
2557
|
+
}
|
|
2558
|
+
else {
|
|
2559
|
+
tree.node[key].left = this.__option.x + (tree.node[key].left - 0.5) * perD * flag;
|
|
2560
|
+
tree.node[key].top = tree.node[key].top * perW + balanceW;
|
|
2561
|
+
}
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
else if (this.__option.direction == 'TB' || this.__option.direction == "BT") {
|
|
2565
|
+
var perW = this.__option.width / tree.size;
|
|
2566
|
+
var perD = this.__option.height / (tree.deep - 1);
|
|
2567
|
+
var balanceW = this.__option.x - this.__option.width * 0.5;
|
|
2568
|
+
var flag = this.__option.direction == 'TB' ? 1 : -1;
|
|
2569
|
+
for (var key in tree.node) {
|
|
2570
|
+
if (tree.deep == 1) {
|
|
2571
|
+
tree.node[key].left = this.__option.x;
|
|
2572
|
+
tree.node[key].top = this.__option.y + this.__option.height * 0.5 * flag;
|
|
2573
|
+
}
|
|
2574
|
+
else {
|
|
2575
|
+
var left = tree.node[key].left;
|
|
2576
|
+
tree.node[key].left = tree.node[key].top * perW + balanceW;
|
|
2577
|
+
tree.node[key].top = this.__option.y + (left - 0.5) * perD * flag;
|
|
2578
|
+
}
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
}
|
|
2582
|
+
else if (this.__option.type == 'circle') {
|
|
2583
|
+
var cx = this.__option.x, cy = this.__option.y;
|
|
2584
|
+
var deg = Math.PI * 2 / tree.size;
|
|
2585
|
+
var per = this.__option.radius / (tree.deep - 1);
|
|
2586
|
+
for (var key in tree.node) {
|
|
2587
|
+
if (tree.node[key].left == 0.5) {
|
|
2588
|
+
tree.node[key].left = cx;
|
|
2589
|
+
tree.node[key].top = cy;
|
|
2590
|
+
}
|
|
2591
|
+
else {
|
|
2592
|
+
var position = rotate$1(cx, cy, deg * tree.node[key].top, cx + (tree.node[key].left - 0.5) * per, cy);
|
|
2593
|
+
tree.node[key].left = position[0];
|
|
2594
|
+
tree.node[key].top = position[1];
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
return tree;
|
|
2599
|
+
};
|
|
2600
|
+
TreeLayout.prototype.bind = function (initTree, renderBack) {
|
|
2601
|
+
this.__rback = renderBack;
|
|
2602
|
+
this.__oralTree = initTree;
|
|
2603
|
+
this.__preTree = this.use(this.__oralTree);
|
|
2604
|
+
this.__rback(this.__preTree);
|
|
2605
|
+
return this;
|
|
2606
|
+
};
|
|
2607
|
+
TreeLayout.prototype.unbind = function () {
|
|
2608
|
+
this.__rback = null;
|
|
2609
|
+
this.__oralTree = null;
|
|
2610
|
+
this.__preTree = null;
|
|
2611
|
+
this.__noOpens = {};
|
|
2612
|
+
return this;
|
|
2613
|
+
};
|
|
2614
|
+
TreeLayout.prototype.doUpdate = function () {
|
|
2615
|
+
var _this = this;
|
|
2616
|
+
var newTree = this.use(this.__oralTree, this.__noOpens);
|
|
2617
|
+
var cacheTree = JSON.parse(JSON.stringify(newTree));
|
|
2618
|
+
animation(function (deep) {
|
|
2619
|
+
for (var key in cacheTree.node) {
|
|
2620
|
+
if (newTree.node[key].show || _this.__preTree.node[key].show) {
|
|
2621
|
+
cacheTree.node[key].show = true;
|
|
2622
|
+
cacheTree.node[key].left = _this.__preTree.node[key].left + (newTree.node[key].left - _this.__preTree.node[key].left) * deep;
|
|
2623
|
+
cacheTree.node[key].top = _this.__preTree.node[key].top + (newTree.node[key].top - _this.__preTree.node[key].top) * deep;
|
|
2624
|
+
}
|
|
2625
|
+
}
|
|
2626
|
+
_this.__rback(cacheTree);
|
|
2627
|
+
}, this.__option.duration, function () {
|
|
2628
|
+
_this.__preTree = newTree;
|
|
2629
|
+
_this.__rback(_this.__preTree);
|
|
2630
|
+
});
|
|
2631
|
+
};
|
|
2632
|
+
TreeLayout.prototype.closeNode = function (id) {
|
|
2633
|
+
if (!this.__preTree)
|
|
2634
|
+
return;
|
|
2635
|
+
this.__noOpens[id] = true;
|
|
2636
|
+
this.doUpdate();
|
|
2637
|
+
return this;
|
|
2638
|
+
};
|
|
2639
|
+
TreeLayout.prototype.openNode = function (id) {
|
|
2640
|
+
if (!this.__preTree)
|
|
2641
|
+
return;
|
|
2642
|
+
this.__noOpens[id] = false;
|
|
2643
|
+
this.doUpdate();
|
|
2644
|
+
return this;
|
|
2645
|
+
};
|
|
2646
|
+
TreeLayout.prototype.toggleNode = function (id) {
|
|
2647
|
+
if (!this.__preTree)
|
|
2648
|
+
return;
|
|
2649
|
+
this.__noOpens[id] = !this.__noOpens[id];
|
|
2650
|
+
this.doUpdate();
|
|
2651
|
+
return this;
|
|
2652
|
+
};
|
|
2653
|
+
return TreeLayout;
|
|
2654
|
+
}(Tree));
|
|
2655
|
+
|
|
2128
2656
|
var index = {
|
|
2129
2657
|
Cardinal: Cardinal,
|
|
2130
2658
|
Hermite: Hermite,
|
|
2131
2659
|
Matrix4: Matrix4,
|
|
2132
2660
|
rotate: rotate$1,
|
|
2133
2661
|
getLoopColors: getLoopColors,
|
|
2662
|
+
formatColor: formatColor,
|
|
2134
2663
|
animation: animation,
|
|
2135
2664
|
ruler: ruler,
|
|
2136
2665
|
SVG: SVG,
|
|
2137
2666
|
Canvas: Canvas,
|
|
2138
2667
|
WebGL: WebGL,
|
|
2139
2668
|
getWebGLContext: getWebGLContext,
|
|
2140
|
-
Shader:
|
|
2669
|
+
Shader: Shader,
|
|
2141
2670
|
Texture: TextureObject,
|
|
2142
2671
|
Buffer: BufferObject,
|
|
2143
2672
|
Eoap: Eoap,
|
|
2144
2673
|
Mercator: Mercator,
|
|
2145
|
-
viewHandler: viewHandler
|
|
2674
|
+
viewHandler: viewHandler,
|
|
2675
|
+
resizeObserver: resizeObserver,
|
|
2676
|
+
throttle: throttle,
|
|
2677
|
+
TreeLayout: TreeLayout
|
|
2146
2678
|
};
|
|
2147
2679
|
|
|
2148
2680
|
return index;
|