@antv/g-canvas 1.3.0 → 1.5.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/dist/index.umd.js CHANGED
@@ -1090,151 +1090,6 @@
1090
1090
 
1091
1091
  return Math.sqrt(y);
1092
1092
  };
1093
- /**
1094
- * 3x3 Matrix
1095
- * @module mat3
1096
- */
1097
-
1098
- /**
1099
- * Creates a new identity mat3
1100
- *
1101
- * @returns {mat3} a new 3x3 matrix
1102
- */
1103
-
1104
- function create() {
1105
- var out = new ARRAY_TYPE(9);
1106
-
1107
- if (ARRAY_TYPE != Float32Array) {
1108
- out[1] = 0;
1109
- out[2] = 0;
1110
- out[3] = 0;
1111
- out[5] = 0;
1112
- out[6] = 0;
1113
- out[7] = 0;
1114
- }
1115
-
1116
- out[0] = 1;
1117
- out[4] = 1;
1118
- out[8] = 1;
1119
- return out;
1120
- }
1121
- /**
1122
- * Multiplies two mat3's
1123
- *
1124
- * @param {mat3} out the receiving matrix
1125
- * @param {ReadonlyMat3} a the first operand
1126
- * @param {ReadonlyMat3} b the second operand
1127
- * @returns {mat3} out
1128
- */
1129
-
1130
-
1131
- function multiply(out, a, b) {
1132
- var a00 = a[0],
1133
- a01 = a[1],
1134
- a02 = a[2];
1135
- var a10 = a[3],
1136
- a11 = a[4],
1137
- a12 = a[5];
1138
- var a20 = a[6],
1139
- a21 = a[7],
1140
- a22 = a[8];
1141
- var b00 = b[0],
1142
- b01 = b[1],
1143
- b02 = b[2];
1144
- var b10 = b[3],
1145
- b11 = b[4],
1146
- b12 = b[5];
1147
- var b20 = b[6],
1148
- b21 = b[7],
1149
- b22 = b[8];
1150
- out[0] = b00 * a00 + b01 * a10 + b02 * a20;
1151
- out[1] = b00 * a01 + b01 * a11 + b02 * a21;
1152
- out[2] = b00 * a02 + b01 * a12 + b02 * a22;
1153
- out[3] = b10 * a00 + b11 * a10 + b12 * a20;
1154
- out[4] = b10 * a01 + b11 * a11 + b12 * a21;
1155
- out[5] = b10 * a02 + b11 * a12 + b12 * a22;
1156
- out[6] = b20 * a00 + b21 * a10 + b22 * a20;
1157
- out[7] = b20 * a01 + b21 * a11 + b22 * a21;
1158
- out[8] = b20 * a02 + b21 * a12 + b22 * a22;
1159
- return out;
1160
- }
1161
- /**
1162
- * Creates a matrix from a vector translation
1163
- * This is equivalent to (but much faster than):
1164
- *
1165
- * mat3.identity(dest);
1166
- * mat3.translate(dest, dest, vec);
1167
- *
1168
- * @param {mat3} out mat3 receiving operation result
1169
- * @param {ReadonlyVec2} v Translation vector
1170
- * @returns {mat3} out
1171
- */
1172
-
1173
-
1174
- function fromTranslation(out, v) {
1175
- out[0] = 1;
1176
- out[1] = 0;
1177
- out[2] = 0;
1178
- out[3] = 0;
1179
- out[4] = 1;
1180
- out[5] = 0;
1181
- out[6] = v[0];
1182
- out[7] = v[1];
1183
- out[8] = 1;
1184
- return out;
1185
- }
1186
- /**
1187
- * Creates a matrix from a given angle
1188
- * This is equivalent to (but much faster than):
1189
- *
1190
- * mat3.identity(dest);
1191
- * mat3.rotate(dest, dest, rad);
1192
- *
1193
- * @param {mat3} out mat3 receiving operation result
1194
- * @param {Number} rad the angle to rotate the matrix by
1195
- * @returns {mat3} out
1196
- */
1197
-
1198
-
1199
- function fromRotation(out, rad) {
1200
- var s = Math.sin(rad),
1201
- c = Math.cos(rad);
1202
- out[0] = c;
1203
- out[1] = s;
1204
- out[2] = 0;
1205
- out[3] = -s;
1206
- out[4] = c;
1207
- out[5] = 0;
1208
- out[6] = 0;
1209
- out[7] = 0;
1210
- out[8] = 1;
1211
- return out;
1212
- }
1213
- /**
1214
- * Creates a matrix from a vector scaling
1215
- * This is equivalent to (but much faster than):
1216
- *
1217
- * mat3.identity(dest);
1218
- * mat3.scale(dest, dest, vec);
1219
- *
1220
- * @param {mat3} out mat3 receiving operation result
1221
- * @param {ReadonlyVec2} v Scaling vector
1222
- * @returns {mat3} out
1223
- */
1224
-
1225
-
1226
- function fromScaling(out, v) {
1227
- out[0] = v[0];
1228
- out[1] = 0;
1229
- out[2] = 0;
1230
- out[3] = 0;
1231
- out[4] = v[1];
1232
- out[5] = 0;
1233
- out[6] = 0;
1234
- out[7] = 0;
1235
- out[8] = 1;
1236
- return out;
1237
- }
1238
1093
  /**
1239
1094
  * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
1240
1095
  * @module mat4
@@ -1246,8 +1101,7 @@
1246
1101
  * @returns {mat4} a new 4x4 matrix
1247
1102
  */
1248
1103
 
1249
-
1250
- function create$1() {
1104
+ function create() {
1251
1105
  var out = new ARRAY_TYPE(16);
1252
1106
 
1253
1107
  if (ARRAY_TYPE != Float32Array) {
@@ -1345,7 +1199,7 @@
1345
1199
  */
1346
1200
 
1347
1201
 
1348
- function multiply$1(out, a, b) {
1202
+ function multiply(out, a, b) {
1349
1203
  var a00 = a[0],
1350
1204
  a01 = a[1],
1351
1205
  a02 = a[2],
@@ -1409,7 +1263,7 @@
1409
1263
  */
1410
1264
 
1411
1265
 
1412
- function create$2() {
1266
+ function create$1() {
1413
1267
  var out = new ARRAY_TYPE(3);
1414
1268
 
1415
1269
  if (ARRAY_TYPE != Float32Array) {
@@ -1474,7 +1328,7 @@
1474
1328
 
1475
1329
 
1476
1330
  var forEach = function () {
1477
- var vec = create$2();
1331
+ var vec = create$1();
1478
1332
  return function (a, stride, offset, count, fn, arg) {
1479
1333
  var i, l;
1480
1334
 
@@ -1517,7 +1371,7 @@
1517
1371
  */
1518
1372
 
1519
1373
 
1520
- function create$3() {
1374
+ function create$2() {
1521
1375
  var out = new ARRAY_TYPE(2);
1522
1376
 
1523
1377
  if (ARRAY_TYPE != Float32Array) {
@@ -1527,21 +1381,6 @@
1527
1381
 
1528
1382
  return out;
1529
1383
  }
1530
- /**
1531
- * Creates a new vec2 initialized with the given values
1532
- *
1533
- * @param {Number} x X component
1534
- * @param {Number} y Y component
1535
- * @returns {vec2} a new 2D vector
1536
- */
1537
-
1538
-
1539
- function fromValues$1(x, y) {
1540
- var out = new ARRAY_TYPE(2);
1541
- out[0] = x;
1542
- out[1] = y;
1543
- return out;
1544
- }
1545
1384
  /**
1546
1385
  * Normalize a vec2
1547
1386
  *
@@ -1577,24 +1416,6 @@
1577
1416
  function dot(a, b) {
1578
1417
  return a[0] * b[0] + a[1] * b[1];
1579
1418
  }
1580
- /**
1581
- * Transforms the vec2 with a mat3
1582
- * 3rd vector component is implicitly '1'
1583
- *
1584
- * @param {vec2} out the receiving vector
1585
- * @param {ReadonlyVec2} a the vector to transform
1586
- * @param {ReadonlyMat3} m matrix to transform with
1587
- * @returns {vec2} out
1588
- */
1589
-
1590
-
1591
- function transformMat3(out, a, m) {
1592
- var x = a[0],
1593
- y = a[1];
1594
- out[0] = m[0] * x + m[3] * y + m[6];
1595
- out[1] = m[1] * x + m[4] * y + m[7];
1596
- return out;
1597
- }
1598
1419
  /**
1599
1420
  * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
1600
1421
  *
@@ -1622,7 +1443,7 @@
1622
1443
 
1623
1444
 
1624
1445
  var forEach$1 = function () {
1625
- var vec = create$3();
1446
+ var vec = create$2();
1626
1447
  return function (a, stride, offset, count, fn, arg) {
1627
1448
  var i, l;
1628
1449
 
@@ -1681,9 +1502,9 @@
1681
1502
 
1682
1503
  if (pick) {
1683
1504
  // invert with world matrix
1684
- var invertWorldMat = invert(create$1(), worldTransform); // transform client position to local space, do picking in local space
1505
+ var invertWorldMat = invert(create(), worldTransform); // transform client position to local space, do picking in local space
1685
1506
 
1686
- var localPosition = transformMat4(create$2(), fromValues(position[0], position[1], 0), invertWorldMat); // account for anchor
1507
+ var localPosition = transformMat4(create$1(), fromValues(position[0], position[1], 0), invertWorldMat); // account for anchor
1687
1508
 
1688
1509
  var _displayObject$getGeo = displayObject.getGeometryBounds(),
1689
1510
  halfExtents = _displayObject$getGeo.halfExtents;
@@ -1710,7 +1531,9 @@
1710
1531
  var generatePath = _this.pathGeneratorFactoryCache[displayObject.nodeName];
1711
1532
 
1712
1533
  if (generatePath) {
1534
+ context.beginPath();
1713
1535
  generatePath(context, displayObject.parsedStyle);
1536
+ context.closePath();
1714
1537
  }
1715
1538
 
1716
1539
  return context.isPointInPath(position.x, position.y);
@@ -1778,7 +1601,7 @@
1778
1601
  worldTransform = displayObject.getWorldTransform(); // clipped's world matrix * clipPath's local matrix
1779
1602
 
1780
1603
  if (clipPath) {
1781
- worldTransform = multiply$1(create$1(), worldTransform, clipPath.getLocalTransform());
1604
+ worldTransform = multiply(create(), worldTransform, clipPath.getLocalTransform());
1782
1605
  }
1783
1606
 
1784
1607
  if (!_this2.isHit(objectToTest, position, worldTransform)) {
@@ -2080,104 +1903,6 @@
2080
1903
  return totalLength / 2;
2081
1904
  }
2082
1905
 
2083
- function quadraticAt(p0, p1, p2, t) {
2084
- var onet = 1 - t;
2085
- return onet * onet * p0 + 2 * t * onet * p1 + t * t * p2;
2086
- } // 求极值
2087
-
2088
-
2089
- function extrema(p0, p1, p2) {
2090
- var a = p0 + p2 - 2 * p1;
2091
-
2092
- if (isNumberEqual(a, 0)) {
2093
- return [0.5];
2094
- }
2095
-
2096
- var rst = (p0 - p1) / a;
2097
-
2098
- if (rst <= 1 && rst >= 0) {
2099
- return [rst];
2100
- }
2101
-
2102
- return [];
2103
- }
2104
-
2105
- function derivativeAt(p0, p1, p2, t) {
2106
- return 2 * (1 - t) * (p1 - p0) + 2 * t * (p2 - p1);
2107
- } // 分割贝塞尔曲线
2108
-
2109
-
2110
- function divideQuadratic(x1, y1, x2, y2, x3, y3, t) {
2111
- // 划分点
2112
- var xt = quadraticAt(x1, x2, x3, t);
2113
- var yt = quadraticAt(y1, y2, y3, t); // 分割的第一条曲线的控制点
2114
-
2115
- var controlPoint1 = line.pointAt(x1, y1, x2, y2, t); // 分割的第二条曲线的控制点
2116
-
2117
- var controlPoint2 = line.pointAt(x2, y2, x3, y3, t);
2118
- return [[x1, y1, controlPoint1.x, controlPoint1.y, xt, yt], [xt, yt, controlPoint2.x, controlPoint2.y, x3, y3]];
2119
- } // 使用迭代法取贝塞尔曲线的长度
2120
-
2121
-
2122
- function quadraticLength(x1, y1, x2, y2, x3, y3, iterationCount) {
2123
- if (iterationCount === 0) {
2124
- return (distance(x1, y1, x2, y2) + distance(x2, y2, x3, y3) + distance(x1, y1, x3, y3)) / 2;
2125
- }
2126
-
2127
- var quadratics = divideQuadratic(x1, y1, x2, y2, x3, y3, 0.5);
2128
- var left = quadratics[0];
2129
- var right = quadratics[1];
2130
- left.push(iterationCount - 1);
2131
- right.push(iterationCount - 1);
2132
- return quadraticLength.apply(void 0, left) + quadraticLength.apply(void 0, right);
2133
- }
2134
-
2135
- var quadratic = {
2136
- box: function box(x1, y1, x2, y2, x3, y3) {
2137
- var xExtrema = extrema(x1, x2, x3)[0];
2138
- var yExtrema = extrema(y1, y2, y3)[0]; // 控制点不加入 box 的计算
2139
-
2140
- var xArr = [x1, x3];
2141
- var yArr = [y1, y3];
2142
-
2143
- if (xExtrema !== undefined) {
2144
- xArr.push(quadraticAt(x1, x2, x3, xExtrema));
2145
- }
2146
-
2147
- if (yExtrema !== undefined) {
2148
- yArr.push(quadraticAt(y1, y2, y3, yExtrema));
2149
- }
2150
-
2151
- return getBBoxByArray(xArr, yArr);
2152
- },
2153
- length: function length(x1, y1, x2, y2, x3, y3) {
2154
- return quadraticLength(x1, y1, x2, y2, x3, y3, 3);
2155
- },
2156
- nearestPoint: function nearestPoint$1(x1, y1, x2, y2, x3, y3, x0, y0) {
2157
- return nearestPoint([x1, x2, x3], [y1, y2, y3], x0, y0, quadraticAt);
2158
- },
2159
- pointDistance: function pointDistance(x1, y1, x2, y2, x3, y3, x0, y0) {
2160
- var point = this.nearestPoint(x1, y1, x2, y2, x3, y3, x0, y0);
2161
- return distance(point.x, point.y, x0, y0);
2162
- },
2163
- interpolationAt: quadraticAt,
2164
- pointAt: function pointAt(x1, y1, x2, y2, x3, y3, t) {
2165
- return {
2166
- x: quadraticAt(x1, x2, x3, t),
2167
- y: quadraticAt(y1, y2, y3, t)
2168
- };
2169
- },
2170
- divide: function divide(x1, y1, x2, y2, x3, y3, t) {
2171
- return divideQuadratic(x1, y1, x2, y2, x3, y3, t);
2172
- },
2173
- tangentAngle: function tangentAngle(x1, y1, x2, y2, x3, y3, t) {
2174
- var dx = derivativeAt(x1, x2, x3, t);
2175
- var dy = derivativeAt(y1, y2, y3, t);
2176
- var angle = Math.atan2(dy, dx);
2177
- return piMod(angle);
2178
- }
2179
- };
2180
-
2181
1906
  function cubicAt(p0, p1, p2, p3, t) {
2182
1907
  var onet = 1 - t; // t * t * t 的性能大概是 Math.pow(t, 3) 的三倍
2183
1908
 
@@ -2531,18 +2256,12 @@
2531
2256
 
2532
2257
  function isPointInStroke(segments, lineWidth, px, py, length, x, y) {
2533
2258
  var isHit = false;
2534
- var halfWidth = lineWidth / 2;
2535
2259
 
2536
2260
  for (var i = 0; i < segments.length; i++) {
2537
2261
  var segment = segments[i];
2538
2262
  var currentPoint = segment.currentPoint,
2539
2263
  params = segment.params,
2540
- prePoint = segment.prePoint,
2541
- box = segment.box; // 如果在前面已经生成过包围盒,直接按照包围盒计算
2542
-
2543
- if (box && !inBox(box.x - halfWidth, box.y - halfWidth, box.width + lineWidth, box.height + lineWidth, px, py)) {
2544
- continue;
2545
- }
2264
+ prePoint = segment.prePoint;
2546
2265
 
2547
2266
  switch (segment.command) {
2548
2267
  // L 和 Z 都是直线, M 不进行拾取
@@ -2550,11 +2269,19 @@
2550
2269
  case 'Z':
2551
2270
  isHit = inLine(prePoint[0], prePoint[1], currentPoint[0], currentPoint[1], lineWidth, px, py);
2552
2271
  break;
2553
-
2554
- case 'Q':
2555
- var qDistance = quadratic.pointDistance(prePoint[0], prePoint[1], params[1], params[2], params[3], params[4], px, py);
2556
- isHit = qDistance <= lineWidth / 2;
2557
- break;
2272
+ // case 'Q':
2273
+ // const qDistance = QuadUtil.pointDistance(
2274
+ // prePoint[0],
2275
+ // prePoint[1],
2276
+ // params[1],
2277
+ // params[2],
2278
+ // params[3],
2279
+ // params[4],
2280
+ // px,
2281
+ // py,
2282
+ // );
2283
+ // isHit = qDistance <= lineWidth / 2;
2284
+ // break;
2558
2285
 
2559
2286
  case 'C':
2560
2287
  var cDistance = cubic.pointDistance(prePoint[0], // 上一段结束位置, 即 C 的起始点
@@ -2562,36 +2289,6 @@
2562
2289
  params[2], params[3], params[4], params[5], params[6], px, py, length);
2563
2290
  isHit = cDistance <= lineWidth / 2;
2564
2291
  break;
2565
-
2566
- case 'A':
2567
- // 计算点到椭圆圆弧的距离,暂时使用近似算法,后面可以改成切割法求最近距离
2568
- var arcParams = segment.arcParams;
2569
- var cx = arcParams.cx,
2570
- cy = arcParams.cy,
2571
- rx = arcParams.rx,
2572
- ry = arcParams.ry,
2573
- startAngle = arcParams.startAngle,
2574
- endAngle = arcParams.endAngle,
2575
- xRotation = arcParams.xRotation;
2576
- var r = rx > ry ? rx : ry;
2577
- var scaleX = rx > ry ? 1 : rx / ry;
2578
- var scaleY = rx > ry ? ry / rx : 1; // const m = transform(null, [
2579
- // ['t', -cx, -cy],
2580
- // ['r', -xRotation],
2581
- // ['s', 1 / scaleX, 1 / scaleY],
2582
- // ]);
2583
- // FIXME
2584
-
2585
- var m = fromTranslation(create(), [-cx, -cy]);
2586
- multiply(m, fromRotation(create(), -xRotation), m);
2587
- multiply(m, fromScaling(create(), [1 / scaleX, 1 / scaleY]), m);
2588
- var p = fromValues$1(px, py);
2589
- p = transformMat3(p, p, m); // isHit = inArc(cx, cy, r, startAngle, endAngle, lineWidth, px, py);
2590
- // console.log(m, p[0], px - cx);
2591
- // isHit = inArc(cx, cy, r, startAngle, endAngle, lineWidth, px, py);
2592
-
2593
- isHit = inArc(0, 0, r, startAngle, endAngle, lineWidth, p[0], p[1]);
2594
- break;
2595
2292
  }
2596
2293
 
2597
2294
  if (isHit) {
@@ -3905,10 +3602,8 @@
3905
3602
  * Common utilities
3906
3603
  * @module glMatrix
3907
3604
  */
3908
- // Configuration Constants
3909
3605
 
3910
3606
 
3911
- var EPSILON$1 = 0.000001;
3912
3607
  var ARRAY_TYPE$1 = typeof Float32Array !== 'undefined' ? Float32Array : Array;
3913
3608
  if (!Math.hypot) Math.hypot = function () {
3914
3609
  var y = 0,
@@ -3920,34 +3615,6 @@
3920
3615
 
3921
3616
  return Math.sqrt(y);
3922
3617
  };
3923
- /**
3924
- * 3x3 Matrix
3925
- * @module mat3
3926
- */
3927
-
3928
- /**
3929
- * Creates a new identity mat3
3930
- *
3931
- * @returns {mat3} a new 3x3 matrix
3932
- */
3933
-
3934
- function create$4() {
3935
- var out = new ARRAY_TYPE$1(9);
3936
-
3937
- if (ARRAY_TYPE$1 != Float32Array) {
3938
- out[1] = 0;
3939
- out[2] = 0;
3940
- out[3] = 0;
3941
- out[5] = 0;
3942
- out[6] = 0;
3943
- out[7] = 0;
3944
- }
3945
-
3946
- out[0] = 1;
3947
- out[4] = 1;
3948
- out[8] = 1;
3949
- return out;
3950
- }
3951
3618
  /**
3952
3619
  * 4x4 Matrix<br>Format: column-major, when typed out it looks like row-major<br>The matrices are being post multiplied.
3953
3620
  * @module mat4
@@ -3959,8 +3626,7 @@
3959
3626
  * @returns {mat4} a new 4x4 matrix
3960
3627
  */
3961
3628
 
3962
-
3963
- function create$1$1() {
3629
+ function create$3() {
3964
3630
  var out = new ARRAY_TYPE$1(16);
3965
3631
 
3966
3632
  if (ARRAY_TYPE$1 != Float32Array) {
@@ -3984,107 +3650,6 @@
3984
3650
  out[15] = 1;
3985
3651
  return out;
3986
3652
  }
3987
- /**
3988
- * Returns the translation vector component of a transformation
3989
- * matrix. If a matrix is built with fromRotationTranslation,
3990
- * the returned vector will be the same as the translation vector
3991
- * originally supplied.
3992
- * @param {vec3} out Vector to receive translation component
3993
- * @param {ReadonlyMat4} mat Matrix to be decomposed (input)
3994
- * @return {vec3} out
3995
- */
3996
-
3997
-
3998
- function getTranslation(out, mat) {
3999
- out[0] = mat[12];
4000
- out[1] = mat[13];
4001
- out[2] = mat[14];
4002
- return out;
4003
- }
4004
- /**
4005
- * Returns the scaling factor component of a transformation
4006
- * matrix. If a matrix is built with fromRotationTranslationScale
4007
- * with a normalized Quaternion paramter, the returned vector will be
4008
- * the same as the scaling vector
4009
- * originally supplied.
4010
- * @param {vec3} out Vector to receive scaling factor component
4011
- * @param {ReadonlyMat4} mat Matrix to be decomposed (input)
4012
- * @return {vec3} out
4013
- */
4014
-
4015
-
4016
- function getScaling(out, mat) {
4017
- var m11 = mat[0];
4018
- var m12 = mat[1];
4019
- var m13 = mat[2];
4020
- var m21 = mat[4];
4021
- var m22 = mat[5];
4022
- var m23 = mat[6];
4023
- var m31 = mat[8];
4024
- var m32 = mat[9];
4025
- var m33 = mat[10];
4026
- out[0] = Math.hypot(m11, m12, m13);
4027
- out[1] = Math.hypot(m21, m22, m23);
4028
- out[2] = Math.hypot(m31, m32, m33);
4029
- return out;
4030
- }
4031
- /**
4032
- * Returns a quaternion representing the rotational component
4033
- * of a transformation matrix. If a matrix is built with
4034
- * fromRotationTranslation, the returned quaternion will be the
4035
- * same as the quaternion originally supplied.
4036
- * @param {quat} out Quaternion to receive the rotation component
4037
- * @param {ReadonlyMat4} mat Matrix to be decomposed (input)
4038
- * @return {quat} out
4039
- */
4040
-
4041
-
4042
- function getRotation(out, mat) {
4043
- var scaling = new ARRAY_TYPE$1(3);
4044
- getScaling(scaling, mat);
4045
- var is1 = 1 / scaling[0];
4046
- var is2 = 1 / scaling[1];
4047
- var is3 = 1 / scaling[2];
4048
- var sm11 = mat[0] * is1;
4049
- var sm12 = mat[1] * is2;
4050
- var sm13 = mat[2] * is3;
4051
- var sm21 = mat[4] * is1;
4052
- var sm22 = mat[5] * is2;
4053
- var sm23 = mat[6] * is3;
4054
- var sm31 = mat[8] * is1;
4055
- var sm32 = mat[9] * is2;
4056
- var sm33 = mat[10] * is3;
4057
- var trace = sm11 + sm22 + sm33;
4058
- var S = 0;
4059
-
4060
- if (trace > 0) {
4061
- S = Math.sqrt(trace + 1.0) * 2;
4062
- out[3] = 0.25 * S;
4063
- out[0] = (sm23 - sm32) / S;
4064
- out[1] = (sm31 - sm13) / S;
4065
- out[2] = (sm12 - sm21) / S;
4066
- } else if (sm11 > sm22 && sm11 > sm33) {
4067
- S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;
4068
- out[3] = (sm23 - sm32) / S;
4069
- out[0] = 0.25 * S;
4070
- out[1] = (sm12 + sm21) / S;
4071
- out[2] = (sm31 + sm13) / S;
4072
- } else if (sm22 > sm33) {
4073
- S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;
4074
- out[3] = (sm31 - sm13) / S;
4075
- out[0] = (sm12 + sm21) / S;
4076
- out[1] = 0.25 * S;
4077
- out[2] = (sm23 + sm32) / S;
4078
- } else {
4079
- S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;
4080
- out[3] = (sm12 - sm21) / S;
4081
- out[0] = (sm31 + sm13) / S;
4082
- out[1] = (sm23 + sm32) / S;
4083
- out[2] = 0.25 * S;
4084
- }
4085
-
4086
- return out;
4087
- }
4088
3653
  /**
4089
3654
  * 3 Dimensional Vector
4090
3655
  * @module vec3
@@ -4097,7 +3662,7 @@
4097
3662
  */
4098
3663
 
4099
3664
 
4100
- function create$2$1() {
3665
+ function create$1$1() {
4101
3666
  var out = new ARRAY_TYPE$1(3);
4102
3667
 
4103
3668
  if (ARRAY_TYPE$1 != Float32Array) {
@@ -4108,20 +3673,6 @@
4108
3673
 
4109
3674
  return out;
4110
3675
  }
4111
- /**
4112
- * Calculates the length of a vec3
4113
- *
4114
- * @param {ReadonlyVec3} a vector to calculate length of
4115
- * @returns {Number} length of a
4116
- */
4117
-
4118
-
4119
- function length(a) {
4120
- var x = a[0];
4121
- var y = a[1];
4122
- var z = a[2];
4123
- return Math.hypot(x, y, z);
4124
- }
4125
3676
  /**
4126
3677
  * Creates a new vec3 initialized with the given values
4127
3678
  *
@@ -4132,79 +3683,13 @@
4132
3683
  */
4133
3684
 
4134
3685
 
4135
- function fromValues$2(x, y, z) {
3686
+ function fromValues$1(x, y, z) {
4136
3687
  var out = new ARRAY_TYPE$1(3);
4137
3688
  out[0] = x;
4138
3689
  out[1] = y;
4139
3690
  out[2] = z;
4140
3691
  return out;
4141
3692
  }
4142
- /**
4143
- * Normalize a vec3
4144
- *
4145
- * @param {vec3} out the receiving vector
4146
- * @param {ReadonlyVec3} a vector to normalize
4147
- * @returns {vec3} out
4148
- */
4149
-
4150
-
4151
- function normalize$1(out, a) {
4152
- var x = a[0];
4153
- var y = a[1];
4154
- var z = a[2];
4155
- var len = x * x + y * y + z * z;
4156
-
4157
- if (len > 0) {
4158
- //TODO: evaluate use of glm_invsqrt here?
4159
- len = 1 / Math.sqrt(len);
4160
- }
4161
-
4162
- out[0] = a[0] * len;
4163
- out[1] = a[1] * len;
4164
- out[2] = a[2] * len;
4165
- return out;
4166
- }
4167
- /**
4168
- * Calculates the dot product of two vec3's
4169
- *
4170
- * @param {ReadonlyVec3} a the first operand
4171
- * @param {ReadonlyVec3} b the second operand
4172
- * @returns {Number} dot product of a and b
4173
- */
4174
-
4175
-
4176
- function dot$1(a, b) {
4177
- return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
4178
- }
4179
- /**
4180
- * Computes the cross product of two vec3's
4181
- *
4182
- * @param {vec3} out the receiving vector
4183
- * @param {ReadonlyVec3} a the first operand
4184
- * @param {ReadonlyVec3} b the second operand
4185
- * @returns {vec3} out
4186
- */
4187
-
4188
-
4189
- function cross(out, a, b) {
4190
- var ax = a[0],
4191
- ay = a[1],
4192
- az = a[2];
4193
- var bx = b[0],
4194
- by = b[1],
4195
- bz = b[2];
4196
- out[0] = ay * bz - az * by;
4197
- out[1] = az * bx - ax * bz;
4198
- out[2] = ax * by - ay * bx;
4199
- return out;
4200
- }
4201
- /**
4202
- * Alias for {@link vec3.length}
4203
- * @function
4204
- */
4205
-
4206
-
4207
- var len = length;
4208
3693
  /**
4209
3694
  * Perform some operation over an array of vec3s.
4210
3695
  *
@@ -4218,8 +3703,9 @@
4218
3703
  * @function
4219
3704
  */
4220
3705
 
3706
+
4221
3707
  var forEach$2 = function () {
4222
- var vec = create$2$1();
3708
+ var vec = create$1$1();
4223
3709
  return function (a, stride, offset, count, fn, arg) {
4224
3710
  var i, l;
4225
3711
 
@@ -4250,351 +3736,6 @@
4250
3736
  return a;
4251
3737
  };
4252
3738
  }();
4253
- /**
4254
- * 4 Dimensional Vector
4255
- * @module vec4
4256
- */
4257
-
4258
- /**
4259
- * Creates a new, empty vec4
4260
- *
4261
- * @returns {vec4} a new 4D vector
4262
- */
4263
-
4264
-
4265
- function create$3$1() {
4266
- var out = new ARRAY_TYPE$1(4);
4267
-
4268
- if (ARRAY_TYPE$1 != Float32Array) {
4269
- out[0] = 0;
4270
- out[1] = 0;
4271
- out[2] = 0;
4272
- out[3] = 0;
4273
- }
4274
-
4275
- return out;
4276
- }
4277
- /**
4278
- * Normalize a vec4
4279
- *
4280
- * @param {vec4} out the receiving vector
4281
- * @param {ReadonlyVec4} a vector to normalize
4282
- * @returns {vec4} out
4283
- */
4284
-
4285
-
4286
- function normalize$1$1(out, a) {
4287
- var x = a[0];
4288
- var y = a[1];
4289
- var z = a[2];
4290
- var w = a[3];
4291
- var len = x * x + y * y + z * z + w * w;
4292
-
4293
- if (len > 0) {
4294
- len = 1 / Math.sqrt(len);
4295
- }
4296
-
4297
- out[0] = x * len;
4298
- out[1] = y * len;
4299
- out[2] = z * len;
4300
- out[3] = w * len;
4301
- return out;
4302
- }
4303
- /**
4304
- * Perform some operation over an array of vec4s.
4305
- *
4306
- * @param {Array} a the array of vectors to iterate over
4307
- * @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
4308
- * @param {Number} offset Number of elements to skip at the beginning of the array
4309
- * @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
4310
- * @param {Function} fn Function to call for each vector in the array
4311
- * @param {Object} [arg] additional argument to pass to fn
4312
- * @returns {Array} a
4313
- * @function
4314
- */
4315
-
4316
-
4317
- var forEach$1$1 = function () {
4318
- var vec = create$3$1();
4319
- return function (a, stride, offset, count, fn, arg) {
4320
- var i, l;
4321
-
4322
- if (!stride) {
4323
- stride = 4;
4324
- }
4325
-
4326
- if (!offset) {
4327
- offset = 0;
4328
- }
4329
-
4330
- if (count) {
4331
- l = Math.min(count * stride + offset, a.length);
4332
- } else {
4333
- l = a.length;
4334
- }
4335
-
4336
- for (i = offset; i < l; i += stride) {
4337
- vec[0] = a[i];
4338
- vec[1] = a[i + 1];
4339
- vec[2] = a[i + 2];
4340
- vec[3] = a[i + 3];
4341
- fn(vec, vec, arg);
4342
- a[i] = vec[0];
4343
- a[i + 1] = vec[1];
4344
- a[i + 2] = vec[2];
4345
- a[i + 3] = vec[3];
4346
- }
4347
-
4348
- return a;
4349
- };
4350
- }();
4351
- /**
4352
- * Quaternion
4353
- * @module quat
4354
- */
4355
-
4356
- /**
4357
- * Creates a new identity quat
4358
- *
4359
- * @returns {quat} a new quaternion
4360
- */
4361
-
4362
-
4363
- function create$4$1() {
4364
- var out = new ARRAY_TYPE$1(4);
4365
-
4366
- if (ARRAY_TYPE$1 != Float32Array) {
4367
- out[0] = 0;
4368
- out[1] = 0;
4369
- out[2] = 0;
4370
- }
4371
-
4372
- out[3] = 1;
4373
- return out;
4374
- }
4375
- /**
4376
- * Sets a quat from the given angle and rotation axis,
4377
- * then returns it.
4378
- *
4379
- * @param {quat} out the receiving quaternion
4380
- * @param {ReadonlyVec3} axis the axis around which to rotate
4381
- * @param {Number} rad the angle in radians
4382
- * @returns {quat} out
4383
- **/
4384
-
4385
-
4386
- function setAxisAngle(out, axis, rad) {
4387
- rad = rad * 0.5;
4388
- var s = Math.sin(rad);
4389
- out[0] = s * axis[0];
4390
- out[1] = s * axis[1];
4391
- out[2] = s * axis[2];
4392
- out[3] = Math.cos(rad);
4393
- return out;
4394
- }
4395
- /**
4396
- * Performs a spherical linear interpolation between two quat
4397
- *
4398
- * @param {quat} out the receiving quaternion
4399
- * @param {ReadonlyQuat} a the first operand
4400
- * @param {ReadonlyQuat} b the second operand
4401
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
4402
- * @returns {quat} out
4403
- */
4404
-
4405
-
4406
- function slerp(out, a, b, t) {
4407
- // benchmarks:
4408
- // http://jsperf.com/quaternion-slerp-implementations
4409
- var ax = a[0],
4410
- ay = a[1],
4411
- az = a[2],
4412
- aw = a[3];
4413
- var bx = b[0],
4414
- by = b[1],
4415
- bz = b[2],
4416
- bw = b[3];
4417
- var omega, cosom, sinom, scale0, scale1; // calc cosine
4418
-
4419
- cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)
4420
-
4421
- if (cosom < 0.0) {
4422
- cosom = -cosom;
4423
- bx = -bx;
4424
- by = -by;
4425
- bz = -bz;
4426
- bw = -bw;
4427
- } // calculate coefficients
4428
-
4429
-
4430
- if (1.0 - cosom > EPSILON$1) {
4431
- // standard case (slerp)
4432
- omega = Math.acos(cosom);
4433
- sinom = Math.sin(omega);
4434
- scale0 = Math.sin((1.0 - t) * omega) / sinom;
4435
- scale1 = Math.sin(t * omega) / sinom;
4436
- } else {
4437
- // "from" and "to" quaternions are very close
4438
- // ... so we can do a linear interpolation
4439
- scale0 = 1.0 - t;
4440
- scale1 = t;
4441
- } // calculate final values
4442
-
4443
-
4444
- out[0] = scale0 * ax + scale1 * bx;
4445
- out[1] = scale0 * ay + scale1 * by;
4446
- out[2] = scale0 * az + scale1 * bz;
4447
- out[3] = scale0 * aw + scale1 * bw;
4448
- return out;
4449
- }
4450
- /**
4451
- * Creates a quaternion from the given 3x3 rotation matrix.
4452
- *
4453
- * NOTE: The resultant quaternion is not normalized, so you should be sure
4454
- * to renormalize the quaternion yourself where necessary.
4455
- *
4456
- * @param {quat} out the receiving quaternion
4457
- * @param {ReadonlyMat3} m rotation matrix
4458
- * @returns {quat} out
4459
- * @function
4460
- */
4461
-
4462
-
4463
- function fromMat3(out, m) {
4464
- // Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
4465
- // article "Quaternion Calculus and Fast Animation".
4466
- var fTrace = m[0] + m[4] + m[8];
4467
- var fRoot;
4468
-
4469
- if (fTrace > 0.0) {
4470
- // |w| > 1/2, may as well choose w > 1/2
4471
- fRoot = Math.sqrt(fTrace + 1.0); // 2w
4472
-
4473
- out[3] = 0.5 * fRoot;
4474
- fRoot = 0.5 / fRoot; // 1/(4w)
4475
-
4476
- out[0] = (m[5] - m[7]) * fRoot;
4477
- out[1] = (m[6] - m[2]) * fRoot;
4478
- out[2] = (m[1] - m[3]) * fRoot;
4479
- } else {
4480
- // |w| <= 1/2
4481
- var i = 0;
4482
- if (m[4] > m[0]) i = 1;
4483
- if (m[8] > m[i * 3 + i]) i = 2;
4484
- var j = (i + 1) % 3;
4485
- var k = (i + 2) % 3;
4486
- fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);
4487
- out[i] = 0.5 * fRoot;
4488
- fRoot = 0.5 / fRoot;
4489
- out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;
4490
- out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;
4491
- out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;
4492
- }
4493
-
4494
- return out;
4495
- }
4496
- /**
4497
- * Normalize a quat
4498
- *
4499
- * @param {quat} out the receiving quaternion
4500
- * @param {ReadonlyQuat} a quaternion to normalize
4501
- * @returns {quat} out
4502
- * @function
4503
- */
4504
-
4505
-
4506
- var normalize$2 = normalize$1$1;
4507
- /**
4508
- * Sets a quaternion to represent the shortest rotation from one
4509
- * vector to another.
4510
- *
4511
- * Both vectors are assumed to be unit length.
4512
- *
4513
- * @param {quat} out the receiving quaternion.
4514
- * @param {ReadonlyVec3} a the initial vector
4515
- * @param {ReadonlyVec3} b the destination vector
4516
- * @returns {quat} out
4517
- */
4518
-
4519
- var rotationTo = function () {
4520
- var tmpvec3 = create$2$1();
4521
- var xUnitVec3 = fromValues$2(1, 0, 0);
4522
- var yUnitVec3 = fromValues$2(0, 1, 0);
4523
- return function (out, a, b) {
4524
- var dot$1$1 = dot$1(a, b);
4525
-
4526
- if (dot$1$1 < -0.999999) {
4527
- cross(tmpvec3, xUnitVec3, a);
4528
- if (len(tmpvec3) < 0.000001) cross(tmpvec3, yUnitVec3, a);
4529
- normalize$1(tmpvec3, tmpvec3);
4530
- setAxisAngle(out, tmpvec3, Math.PI);
4531
- return out;
4532
- } else if (dot$1$1 > 0.999999) {
4533
- out[0] = 0;
4534
- out[1] = 0;
4535
- out[2] = 0;
4536
- out[3] = 1;
4537
- return out;
4538
- } else {
4539
- cross(tmpvec3, a, b);
4540
- out[0] = tmpvec3[0];
4541
- out[1] = tmpvec3[1];
4542
- out[2] = tmpvec3[2];
4543
- out[3] = 1 + dot$1$1;
4544
- return normalize$2(out, out);
4545
- }
4546
- };
4547
- }();
4548
- /**
4549
- * Performs a spherical linear interpolation with two control points
4550
- *
4551
- * @param {quat} out the receiving quaternion
4552
- * @param {ReadonlyQuat} a the first operand
4553
- * @param {ReadonlyQuat} b the second operand
4554
- * @param {ReadonlyQuat} c the third operand
4555
- * @param {ReadonlyQuat} d the fourth operand
4556
- * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
4557
- * @returns {quat} out
4558
- */
4559
-
4560
-
4561
- var sqlerp = function () {
4562
- var temp1 = create$4$1();
4563
- var temp2 = create$4$1();
4564
- return function (out, a, b, c, d, t) {
4565
- slerp(temp1, a, d, t);
4566
- slerp(temp2, b, c, t);
4567
- slerp(out, temp1, temp2, 2 * t * (1 - t));
4568
- return out;
4569
- };
4570
- }();
4571
- /**
4572
- * Sets the specified quaternion with values corresponding to the given
4573
- * axes. Each axis is a vec3 and is expected to be unit length and
4574
- * perpendicular to all other specified axes.
4575
- *
4576
- * @param {ReadonlyVec3} view the vector representing the viewing direction
4577
- * @param {ReadonlyVec3} right the vector representing the local "right" direction
4578
- * @param {ReadonlyVec3} up the vector representing the local "up" direction
4579
- * @returns {quat} out
4580
- */
4581
-
4582
-
4583
- var setAxes = function () {
4584
- var matr = create$4();
4585
- return function (out, view, right, up) {
4586
- matr[0] = right[0];
4587
- matr[3] = right[1];
4588
- matr[6] = right[2];
4589
- matr[1] = up[0];
4590
- matr[4] = up[1];
4591
- matr[7] = up[2];
4592
- matr[2] = -view[0];
4593
- matr[5] = -view[1];
4594
- matr[8] = -view[2];
4595
- return normalize$2(out, fromMat3(out, matr));
4596
- };
4597
- }();
4598
3739
 
4599
3740
  var StyleRendererFactory = g.Syringe.defineToken('StyleRendererFactory');
4600
3741
  var CircleRendererContribution = g.Syringe.defineToken('CircleRenderer', {
@@ -5121,8 +4262,8 @@
5121
4262
  this.renderQueue = [];
5122
4263
  this.restoreStack = [];
5123
4264
  this.clearFullScreen = false;
5124
- this.tmpVec3 = create$2$1();
5125
- this.tmpMat4 = create$1$1();
4265
+ this.tmpVec3 = create$1$1();
4266
+ this.tmpMat4 = create$3();
5126
4267
  }
5127
4268
 
5128
4269
  var _proto = CanvasRendererPlugin.prototype;
@@ -5218,7 +4359,7 @@
5218
4359
  maxX = _ref2.maxX,
5219
4360
  maxY = _ref2.maxY;
5220
4361
  var aabb = new g.AABB();
5221
- aabb.setMinMax(fromValues$2(minX, minY, 0), fromValues$2(maxX, maxY, 0));
4362
+ aabb.setMinMax(fromValues$1(minX, minY, 0), fromValues$1(maxX, maxY, 0));
5222
4363
  return aabb;
5223
4364
  })));
5224
4365
 
@@ -5478,25 +4619,8 @@
5478
4619
  };
5479
4620
 
5480
4621
  _proto.applyTransform = function applyTransform(context, transform) {
5481
- var _mat4$getTranslation = getTranslation(create$2$1(), transform),
5482
- tx = _mat4$getTranslation[0],
5483
- ty = _mat4$getTranslation[1];
5484
-
5485
- var _mat4$getScaling = getScaling(create$2$1(), transform),
5486
- sx = _mat4$getScaling[0],
5487
- sy = _mat4$getScaling[1];
5488
-
5489
- var rotation = getRotation(create$4$1(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
5490
-
5491
- var _getEuler = g.getEuler(create$2$1(), rotation),
5492
- eux = _getEuler[0],
5493
- euy = _getEuler[1],
5494
- euz = _getEuler[2]; // gimbal lock at 90 degrees
5495
-
5496
-
5497
- var rts = g.fromRotationTranslationScale(eux || euz, tx, ty, sx, sy); // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
5498
-
5499
- context.transform(rts[0], rts[1], rts[3], rts[4], rts[6], rts[7]);
4622
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Transformations
4623
+ context.transform(transform[0], transform[1], transform[4], transform[5], transform[12], transform[13]);
5500
4624
  };
5501
4625
 
5502
4626
  _proto.applyAttributesToContext = function applyAttributesToContext(context, object) {
@@ -5540,7 +4664,9 @@
5540
4664
  context.filter = object.style.filter;
5541
4665
  }
5542
4666
 
5543
- if (!g.isNil(shadowColor)) {
4667
+ var hasShadow = !g.isNil(shadowColor) && shadowBlur.value > 0;
4668
+
4669
+ if (hasShadow) {
5544
4670
  context.shadowColor = shadowColor.toString();
5545
4671
  context.shadowBlur = shadowBlur && shadowBlur.value || 0;
5546
4672
  context.shadowOffsetX = shadowOffsetX && shadowOffsetX.value || 0;
@@ -6117,7 +5243,7 @@
6117
5243
  var addTouchEventListener = function addTouchEventListener($el) {
6118
5244
  $el.addEventListener('touchstart', onPointerDown, true);
6119
5245
  $el.addEventListener('touchend', onPointerUp, true);
6120
- $el.addEventListener('touchmove', onPointerMove, true);
5246
+ globalThis.document.addEventListener('touchmove', onPointerMove, true);
6121
5247
  $el.addEventListener('touchcancel', onPointerCancel, true);
6122
5248
  };
6123
5249
 
@@ -6140,7 +5266,8 @@
6140
5266
  var removeTouchEventListener = function removeTouchEventListener($el) {
6141
5267
  $el.removeEventListener('touchstart', onPointerDown, true);
6142
5268
  $el.removeEventListener('touchend', onPointerUp, true);
6143
- $el.removeEventListener('touchmove', onPointerMove, true);
5269
+ $el.removeEventListener('touchcancel', onPointerCancel, true);
5270
+ globalThis.document.removeEventListener('touchmove', onPointerMove, true);
6144
5271
  };
6145
5272
 
6146
5273
  var removeMouseEventListener = function removeMouseEventListener($el) {