@antv/g-canvas 1.1.4 → 1.1.5
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 +1485 -1487
- package/dist/index.umd.min.js +4 -4
- package/package.json +6 -6
package/dist/index.umd.js
CHANGED
|
@@ -435,7 +435,6 @@
|
|
|
435
435
|
var _class;
|
|
436
436
|
|
|
437
437
|
var DOMInteractionPlugin_1;
|
|
438
|
-
var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
439
438
|
/**
|
|
440
439
|
* listen to mouse/touch/pointer events on DOM wrapper, trigger pointer events
|
|
441
440
|
*/
|
|
@@ -451,8 +450,7 @@
|
|
|
451
450
|
_proto.apply = function apply(renderingService) {
|
|
452
451
|
var _this = this;
|
|
453
452
|
|
|
454
|
-
var canvas = this.renderingContext.root.ownerDocument.defaultView;
|
|
455
|
-
var SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
453
|
+
var canvas = this.renderingContext.root.ownerDocument.defaultView; // const SUPPORT_ONLY_TOUCH = canvas.supportsTouchEvents && MOBILE_REGEX.test(navigator.userAgent);
|
|
456
454
|
|
|
457
455
|
var onPointerMove = function onPointerMove(ev) {
|
|
458
456
|
renderingService.hooks.pointerMove.call(ev);
|
|
@@ -1187,1029 +1185,1084 @@
|
|
|
1187
1185
|
}
|
|
1188
1186
|
}
|
|
1189
1187
|
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
multiple: false
|
|
1196
|
-
});
|
|
1197
|
-
var RectRendererContribution = manaSyringe.Syringe.defineToken('RectRenderer', {
|
|
1198
|
-
multiple: false
|
|
1199
|
-
});
|
|
1200
|
-
var LineRendererContribution = manaSyringe.Syringe.defineToken('LineRenderer', {
|
|
1201
|
-
multiple: false
|
|
1202
|
-
});
|
|
1203
|
-
var PolylineRendererContribution = manaSyringe.Syringe.defineToken('PolylineRenderer', {
|
|
1204
|
-
multiple: false
|
|
1205
|
-
});
|
|
1206
|
-
var PolygonRendererContribution = manaSyringe.Syringe.defineToken('PolygonRenderer', {
|
|
1207
|
-
multiple: false
|
|
1208
|
-
});
|
|
1209
|
-
var PathRendererContribution = manaSyringe.Syringe.defineToken('PathRenderer', {
|
|
1210
|
-
multiple: false
|
|
1211
|
-
});
|
|
1212
|
-
var TextRendererContribution = manaSyringe.Syringe.defineToken('TextRenderer', {
|
|
1213
|
-
multiple: false
|
|
1214
|
-
});
|
|
1215
|
-
var ImageRendererContribution = manaSyringe.Syringe.defineToken('ImageRenderer', {
|
|
1216
|
-
multiple: false
|
|
1217
|
-
});
|
|
1218
|
-
|
|
1219
|
-
var ImagePool = /*#__PURE__*/function () {
|
|
1220
|
-
function ImagePool() {
|
|
1221
|
-
this.imageCache = {};
|
|
1222
|
-
this.patternCache = {};
|
|
1223
|
-
this.canvasConfig = void 0;
|
|
1224
|
-
}
|
|
1188
|
+
function _regeneratorRuntime$1() {
|
|
1189
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
1190
|
+
_regeneratorRuntime$1 = function _regeneratorRuntime() {
|
|
1191
|
+
return exports;
|
|
1192
|
+
};
|
|
1225
1193
|
|
|
1226
|
-
var
|
|
1194
|
+
var exports = {},
|
|
1195
|
+
Op = Object.prototype,
|
|
1196
|
+
hasOwn = Op.hasOwnProperty,
|
|
1197
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
1198
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
1199
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
1200
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1227
1201
|
|
|
1228
|
-
|
|
1229
|
-
return
|
|
1230
|
-
|
|
1202
|
+
function define(obj, key, value) {
|
|
1203
|
+
return Object.defineProperty(obj, key, {
|
|
1204
|
+
value: value,
|
|
1205
|
+
enumerable: !0,
|
|
1206
|
+
configurable: !0,
|
|
1207
|
+
writable: !0
|
|
1208
|
+
}), obj[key];
|
|
1209
|
+
}
|
|
1231
1210
|
|
|
1232
|
-
|
|
1233
|
-
|
|
1211
|
+
try {
|
|
1212
|
+
define({}, "");
|
|
1213
|
+
} catch (err) {
|
|
1214
|
+
define = function define(obj, key, value) {
|
|
1215
|
+
return obj[key] = value;
|
|
1216
|
+
};
|
|
1217
|
+
}
|
|
1234
1218
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1219
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
1220
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
1221
|
+
generator = Object.create(protoGenerator.prototype),
|
|
1222
|
+
context = new Context(tryLocsList || []);
|
|
1223
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
1224
|
+
var state = "suspendedStart";
|
|
1225
|
+
return function (method, arg) {
|
|
1226
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
1238
1227
|
|
|
1228
|
+
if ("completed" === state) {
|
|
1229
|
+
if ("throw" === method) throw arg;
|
|
1230
|
+
return doneResult();
|
|
1231
|
+
}
|
|
1239
1232
|
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
var image;
|
|
1233
|
+
for (context.method = method, context.arg = arg;;) {
|
|
1234
|
+
var delegate = context.delegate;
|
|
1243
1235
|
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
} else if (g.isBrowser) {
|
|
1247
|
-
image = new window.Image();
|
|
1248
|
-
}
|
|
1236
|
+
if (delegate) {
|
|
1237
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
1249
1238
|
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1239
|
+
if (delegateResult) {
|
|
1240
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
1241
|
+
return delegateResult;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1254
1244
|
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1245
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
1246
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
1247
|
+
context.dispatchException(context.arg);
|
|
1248
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
1249
|
+
state = "executing";
|
|
1250
|
+
var record = tryCatch(innerFn, self, context);
|
|
1258
1251
|
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1252
|
+
if ("normal" === record.type) {
|
|
1253
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
1254
|
+
return {
|
|
1255
|
+
value: record.arg,
|
|
1256
|
+
done: context.done
|
|
1257
|
+
};
|
|
1258
|
+
}
|
|
1265
1259
|
|
|
1266
|
-
|
|
1267
|
-
|
|
1260
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
}(innerFn, self, context), generator;
|
|
1264
|
+
}
|
|
1268
1265
|
|
|
1269
|
-
|
|
1270
|
-
|
|
1266
|
+
function tryCatch(fn, obj, arg) {
|
|
1267
|
+
try {
|
|
1268
|
+
return {
|
|
1269
|
+
type: "normal",
|
|
1270
|
+
arg: fn.call(obj, arg)
|
|
1271
|
+
};
|
|
1272
|
+
} catch (err) {
|
|
1273
|
+
return {
|
|
1274
|
+
type: "throw",
|
|
1275
|
+
arg: err
|
|
1276
|
+
};
|
|
1271
1277
|
}
|
|
1272
|
-
}
|
|
1278
|
+
}
|
|
1273
1279
|
|
|
1274
|
-
|
|
1275
|
-
|
|
1280
|
+
exports.wrap = wrap;
|
|
1281
|
+
var ContinueSentinel = {};
|
|
1276
1282
|
|
|
1277
|
-
|
|
1278
|
-
var patternKey = _this2.generatePatternKey(patternParams); // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
1283
|
+
function Generator() {}
|
|
1279
1284
|
|
|
1285
|
+
function GeneratorFunction() {}
|
|
1280
1286
|
|
|
1281
|
-
|
|
1287
|
+
function GeneratorFunctionPrototype() {}
|
|
1282
1288
|
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1289
|
+
var IteratorPrototype = {};
|
|
1290
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
1291
|
+
return this;
|
|
1292
|
+
});
|
|
1293
|
+
var getProto = Object.getPrototypeOf,
|
|
1294
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1295
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
1296
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
1286
1297
|
|
|
1287
|
-
|
|
1298
|
+
function defineIteratorMethods(prototype) {
|
|
1299
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
1300
|
+
define(prototype, method, function (arg) {
|
|
1301
|
+
return this._invoke(method, arg);
|
|
1302
|
+
});
|
|
1288
1303
|
});
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
_proto.generatePatternKey = function generatePatternKey(pattern) {
|
|
1292
|
-
var src = pattern.src,
|
|
1293
|
-
repetition = pattern.repetition;
|
|
1294
|
-
return "pattern-" + src + "-" + repetition;
|
|
1295
|
-
};
|
|
1304
|
+
}
|
|
1296
1305
|
|
|
1297
|
-
|
|
1298
|
-
|
|
1306
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
1307
|
+
function invoke(method, arg, resolve, reject) {
|
|
1308
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
1299
1309
|
|
|
1300
|
-
|
|
1310
|
+
if ("throw" !== record.type) {
|
|
1311
|
+
var result = record.arg,
|
|
1312
|
+
value = result.value;
|
|
1313
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1314
|
+
invoke("next", value, resolve, reject);
|
|
1315
|
+
}, function (err) {
|
|
1316
|
+
invoke("throw", err, resolve, reject);
|
|
1317
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
1318
|
+
result.value = unwrapped, resolve(result);
|
|
1319
|
+
}, function (error) {
|
|
1320
|
+
return invoke("throw", error, resolve, reject);
|
|
1321
|
+
});
|
|
1322
|
+
}
|
|
1301
1323
|
|
|
1302
|
-
|
|
1324
|
+
reject(record.arg);
|
|
1325
|
+
}
|
|
1303
1326
|
|
|
1304
|
-
|
|
1305
|
-
function ImageRenderer() {
|
|
1306
|
-
this.imagePool = void 0;
|
|
1307
|
-
}
|
|
1327
|
+
var previousPromise;
|
|
1308
1328
|
|
|
1309
|
-
|
|
1329
|
+
this._invoke = function (method, arg) {
|
|
1330
|
+
function callInvokeWithMethodAndArg() {
|
|
1331
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
1332
|
+
invoke(method, arg, resolve, reject);
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1310
1335
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
}
|
|
1336
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1314
1339
|
|
|
1315
|
-
|
|
1316
|
-
var
|
|
1317
|
-
height = parsedStyle.height,
|
|
1318
|
-
img = parsedStyle.img;
|
|
1319
|
-
var image;
|
|
1320
|
-
var iw = width.value;
|
|
1321
|
-
var ih = height.value;
|
|
1340
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
1341
|
+
var method = delegate.iterator[context.method];
|
|
1322
1342
|
|
|
1323
|
-
if (
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
ih || (ih = img.height);
|
|
1329
|
-
image = img;
|
|
1330
|
-
}
|
|
1343
|
+
if (undefined === method) {
|
|
1344
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
1345
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
1346
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
1347
|
+
}
|
|
1331
1348
|
|
|
1332
|
-
|
|
1333
|
-
// node-canvas will throw the following err:
|
|
1334
|
-
// Error: Image given has not completed loading
|
|
1335
|
-
try {
|
|
1336
|
-
context.drawImage(image, 0, 0, iw, ih);
|
|
1337
|
-
} catch (e) {}
|
|
1349
|
+
return ContinueSentinel;
|
|
1338
1350
|
}
|
|
1339
|
-
};
|
|
1340
|
-
|
|
1341
|
-
return ImageRenderer;
|
|
1342
|
-
}();
|
|
1343
1351
|
|
|
1344
|
-
|
|
1352
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1353
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
1354
|
+
var info = record.arg;
|
|
1355
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
1356
|
+
}
|
|
1345
1357
|
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1358
|
+
function pushTryEntry(locs) {
|
|
1359
|
+
var entry = {
|
|
1360
|
+
tryLoc: locs[0]
|
|
1361
|
+
};
|
|
1362
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
1363
|
+
}
|
|
1349
1364
|
|
|
1350
|
-
|
|
1351
|
-
|
|
1365
|
+
function resetTryEntry(entry) {
|
|
1366
|
+
var record = entry.completion || {};
|
|
1367
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
1368
|
+
}
|
|
1352
1369
|
|
|
1353
|
-
|
|
1370
|
+
function Context(tryLocsList) {
|
|
1371
|
+
this.tryEntries = [{
|
|
1372
|
+
tryLoc: "root"
|
|
1373
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
1374
|
+
}
|
|
1354
1375
|
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1376
|
+
function values(iterable) {
|
|
1377
|
+
if (iterable) {
|
|
1378
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
1379
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
1380
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
1358
1381
|
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
miterLimit = _parsedStyle$miterLim === void 0 ? 0 : _parsedStyle$miterLim,
|
|
1366
|
-
_parsedStyle$letterSp = parsedStyle.letterSpacing,
|
|
1367
|
-
letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
|
|
1368
|
-
stroke = parsedStyle.stroke,
|
|
1369
|
-
fill = parsedStyle.fill,
|
|
1370
|
-
fillOpacity = parsedStyle.fillOpacity,
|
|
1371
|
-
strokeOpacity = parsedStyle.strokeOpacity,
|
|
1372
|
-
opacity = parsedStyle.opacity,
|
|
1373
|
-
metrics = parsedStyle.metrics,
|
|
1374
|
-
dx = parsedStyle.dx,
|
|
1375
|
-
dy = parsedStyle.dy;
|
|
1376
|
-
var font = metrics.font,
|
|
1377
|
-
lines = metrics.lines,
|
|
1378
|
-
height = metrics.height,
|
|
1379
|
-
lineHeight = metrics.lineHeight,
|
|
1380
|
-
lineMetrics = metrics.lineMetrics;
|
|
1381
|
-
context.font = font;
|
|
1382
|
-
context.lineWidth = lineWidth.value;
|
|
1383
|
-
context.textAlign = textAlign.value;
|
|
1384
|
-
context.textBaseline = textBaseline.value;
|
|
1385
|
-
context.lineJoin = lineJoin.value;
|
|
1386
|
-
context.miterLimit = miterLimit;
|
|
1387
|
-
var linePositionY = 0; // handle vertical text baseline
|
|
1382
|
+
if (!isNaN(iterable.length)) {
|
|
1383
|
+
var i = -1,
|
|
1384
|
+
next = function next() {
|
|
1385
|
+
for (; ++i < iterable.length;) {
|
|
1386
|
+
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
1387
|
+
}
|
|
1388
1388
|
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
1392
|
-
linePositionY = -height;
|
|
1393
|
-
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
1394
|
-
linePositionY = -lineHeight;
|
|
1395
|
-
} // account for dx & dy
|
|
1389
|
+
return next.value = undefined, next.done = !0, next;
|
|
1390
|
+
};
|
|
1396
1391
|
|
|
1392
|
+
return next.next = next;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1397
1395
|
|
|
1398
|
-
|
|
1396
|
+
return {
|
|
1397
|
+
next: doneResult
|
|
1398
|
+
};
|
|
1399
|
+
}
|
|
1399
1400
|
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1401
|
+
function doneResult() {
|
|
1402
|
+
return {
|
|
1403
|
+
value: undefined,
|
|
1404
|
+
done: !0
|
|
1405
|
+
};
|
|
1406
|
+
}
|
|
1403
1407
|
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1408
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
1409
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
1410
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
1411
|
+
}, exports.mark = function (genFun) {
|
|
1412
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
1413
|
+
}, exports.awrap = function (arg) {
|
|
1414
|
+
return {
|
|
1415
|
+
__await: arg
|
|
1416
|
+
};
|
|
1417
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
1418
|
+
return this;
|
|
1419
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1420
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
1421
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1422
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
1423
|
+
return result.done ? result.value : iter.next();
|
|
1424
|
+
});
|
|
1425
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
1426
|
+
return this;
|
|
1427
|
+
}), define(Gp, "toString", function () {
|
|
1428
|
+
return "[object Generator]";
|
|
1429
|
+
}), exports.keys = function (object) {
|
|
1430
|
+
var keys = [];
|
|
1407
1431
|
|
|
1432
|
+
for (var key in object) {
|
|
1433
|
+
keys.push(key);
|
|
1434
|
+
}
|
|
1408
1435
|
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1436
|
+
return keys.reverse(), function next() {
|
|
1437
|
+
for (; keys.length;) {
|
|
1438
|
+
var key = keys.pop();
|
|
1439
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
1440
|
+
}
|
|
1413
1441
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1442
|
+
return next.done = !0, next;
|
|
1443
|
+
};
|
|
1444
|
+
}, exports.values = values, Context.prototype = {
|
|
1445
|
+
constructor: Context,
|
|
1446
|
+
reset: function reset(skipTempReset) {
|
|
1447
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
|
|
1448
|
+
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
1416
1449
|
}
|
|
1450
|
+
},
|
|
1451
|
+
stop: function stop() {
|
|
1452
|
+
this.done = !0;
|
|
1453
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
1454
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
1455
|
+
return this.rval;
|
|
1456
|
+
},
|
|
1457
|
+
dispatchException: function dispatchException(exception) {
|
|
1458
|
+
if (this.done) throw exception;
|
|
1459
|
+
var context = this;
|
|
1417
1460
|
|
|
1418
|
-
|
|
1419
|
-
|
|
1461
|
+
function handle(loc, caught) {
|
|
1462
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
1420
1463
|
}
|
|
1421
|
-
}
|
|
1422
|
-
};
|
|
1423
1464
|
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1465
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1466
|
+
var entry = this.tryEntries[i],
|
|
1467
|
+
record = entry.completion;
|
|
1468
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
1428
1469
|
|
|
1470
|
+
if (entry.tryLoc <= this.prev) {
|
|
1471
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
1472
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1429
1473
|
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1474
|
+
if (hasCatch && hasFinally) {
|
|
1475
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1476
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1477
|
+
} else if (hasCatch) {
|
|
1478
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1479
|
+
} else {
|
|
1480
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
1481
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1435
1484
|
}
|
|
1485
|
+
},
|
|
1486
|
+
abrupt: function abrupt(type, arg) {
|
|
1487
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1488
|
+
var entry = this.tryEntries[i];
|
|
1436
1489
|
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
context.textAlign = 'left';
|
|
1443
|
-
var currentPosition = x;
|
|
1490
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1491
|
+
var finallyEntry = entry;
|
|
1492
|
+
break;
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1444
1495
|
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1496
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
1497
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1498
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
1499
|
+
},
|
|
1500
|
+
complete: function complete(record, afterLoc) {
|
|
1501
|
+
if ("throw" === record.type) throw record.arg;
|
|
1502
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
1503
|
+
},
|
|
1504
|
+
finish: function finish(finallyLoc) {
|
|
1505
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1506
|
+
var entry = this.tryEntries[i];
|
|
1507
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
1508
|
+
}
|
|
1509
|
+
},
|
|
1510
|
+
catch: function _catch(tryLoc) {
|
|
1511
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1512
|
+
var entry = this.tryEntries[i];
|
|
1450
1513
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
var currentWidth = 0;
|
|
1514
|
+
if (entry.tryLoc === tryLoc) {
|
|
1515
|
+
var record = entry.completion;
|
|
1454
1516
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1517
|
+
if ("throw" === record.type) {
|
|
1518
|
+
var thrown = record.arg;
|
|
1519
|
+
resetTryEntry(entry);
|
|
1520
|
+
}
|
|
1457
1521
|
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
} else {
|
|
1461
|
-
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
1522
|
+
return thrown;
|
|
1523
|
+
}
|
|
1462
1524
|
}
|
|
1463
1525
|
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1526
|
+
throw new Error("illegal catch attempt");
|
|
1527
|
+
},
|
|
1528
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1529
|
+
return this.delegate = {
|
|
1530
|
+
iterator: values(iterable),
|
|
1531
|
+
resultName: resultName,
|
|
1532
|
+
nextLoc: nextLoc
|
|
1533
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
1467
1534
|
}
|
|
1535
|
+
}, exports;
|
|
1536
|
+
}
|
|
1468
1537
|
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
currentGlobalAlpha = context.globalAlpha;
|
|
1478
|
-
context.globalAlpha = fillOpacity * opacity;
|
|
1479
|
-
}
|
|
1480
|
-
|
|
1481
|
-
context.fillText(text, x, y);
|
|
1538
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1539
|
+
try {
|
|
1540
|
+
var info = gen[key](arg);
|
|
1541
|
+
var value = info.value;
|
|
1542
|
+
} catch (error) {
|
|
1543
|
+
reject(error);
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1482
1546
|
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1547
|
+
if (info.done) {
|
|
1548
|
+
resolve(value);
|
|
1549
|
+
} else {
|
|
1550
|
+
Promise.resolve(value).then(_next, _throw);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1487
1553
|
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
var
|
|
1554
|
+
function _asyncToGenerator$1(fn) {
|
|
1555
|
+
return function () {
|
|
1556
|
+
var self = this,
|
|
1557
|
+
args = arguments;
|
|
1558
|
+
return new Promise(function (resolve, reject) {
|
|
1559
|
+
var gen = fn.apply(self, args);
|
|
1491
1560
|
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
}
|
|
1561
|
+
function _next(value) {
|
|
1562
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1563
|
+
}
|
|
1496
1564
|
|
|
1497
|
-
|
|
1565
|
+
function _throw(err) {
|
|
1566
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1567
|
+
}
|
|
1498
1568
|
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
}
|
|
1569
|
+
_next(undefined);
|
|
1570
|
+
});
|
|
1502
1571
|
};
|
|
1572
|
+
}
|
|
1503
1573
|
|
|
1504
|
-
|
|
1505
|
-
|
|
1574
|
+
function _extends() {
|
|
1575
|
+
_extends = Object.assign || function (target) {
|
|
1576
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1577
|
+
var source = arguments[i];
|
|
1506
1578
|
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1579
|
+
for (var key in source) {
|
|
1580
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1581
|
+
target[key] = source[key];
|
|
1582
|
+
}
|
|
1583
|
+
}
|
|
1584
|
+
}
|
|
1510
1585
|
|
|
1511
|
-
|
|
1512
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
1513
|
-
_regeneratorRuntime$1 = function _regeneratorRuntime() {
|
|
1514
|
-
return exports;
|
|
1586
|
+
return target;
|
|
1515
1587
|
};
|
|
1516
1588
|
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
hasOwn = Op.hasOwnProperty,
|
|
1520
|
-
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
1521
|
-
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
1522
|
-
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
1523
|
-
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1524
|
-
|
|
1525
|
-
function define(obj, key, value) {
|
|
1526
|
-
return Object.defineProperty(obj, key, {
|
|
1527
|
-
value: value,
|
|
1528
|
-
enumerable: !0,
|
|
1529
|
-
configurable: !0,
|
|
1530
|
-
writable: !0
|
|
1531
|
-
}), obj[key];
|
|
1532
|
-
}
|
|
1533
|
-
|
|
1534
|
-
try {
|
|
1535
|
-
define({}, "");
|
|
1536
|
-
} catch (err) {
|
|
1537
|
-
define = function define(obj, key, value) {
|
|
1538
|
-
return obj[key] = value;
|
|
1539
|
-
};
|
|
1540
|
-
}
|
|
1541
|
-
|
|
1542
|
-
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
1543
|
-
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
1544
|
-
generator = Object.create(protoGenerator.prototype),
|
|
1545
|
-
context = new Context(tryLocsList || []);
|
|
1546
|
-
return generator._invoke = function (innerFn, self, context) {
|
|
1547
|
-
var state = "suspendedStart";
|
|
1548
|
-
return function (method, arg) {
|
|
1549
|
-
if ("executing" === state) throw new Error("Generator is already running");
|
|
1589
|
+
return _extends.apply(this, arguments);
|
|
1590
|
+
}
|
|
1550
1591
|
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
}
|
|
1592
|
+
function _inheritsLoose$1(subClass, superClass) {
|
|
1593
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
1594
|
+
subClass.prototype.constructor = subClass;
|
|
1555
1595
|
|
|
1556
|
-
|
|
1557
|
-
|
|
1596
|
+
_setPrototypeOf$1(subClass, superClass);
|
|
1597
|
+
}
|
|
1558
1598
|
|
|
1559
|
-
|
|
1560
|
-
|
|
1599
|
+
function _setPrototypeOf$1(o, p) {
|
|
1600
|
+
_setPrototypeOf$1 = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
1601
|
+
o.__proto__ = p;
|
|
1602
|
+
return o;
|
|
1603
|
+
};
|
|
1561
1604
|
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1605
|
+
return _setPrototypeOf$1(o, p);
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* Common utilities
|
|
1609
|
+
* @module glMatrix
|
|
1610
|
+
*/
|
|
1611
|
+
// Configuration Constants
|
|
1567
1612
|
|
|
1568
|
-
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
1569
|
-
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
1570
|
-
context.dispatchException(context.arg);
|
|
1571
|
-
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
1572
|
-
state = "executing";
|
|
1573
|
-
var record = tryCatch(innerFn, self, context);
|
|
1574
1613
|
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
};
|
|
1581
|
-
}
|
|
1614
|
+
var EPSILON = 0.000001;
|
|
1615
|
+
var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
|
|
1616
|
+
if (!Math.hypot) Math.hypot = function () {
|
|
1617
|
+
var y = 0,
|
|
1618
|
+
i = arguments.length;
|
|
1582
1619
|
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
};
|
|
1586
|
-
}(innerFn, self, context), generator;
|
|
1620
|
+
while (i--) {
|
|
1621
|
+
y += arguments[i] * arguments[i];
|
|
1587
1622
|
}
|
|
1588
1623
|
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
} catch (err) {
|
|
1596
|
-
return {
|
|
1597
|
-
type: "throw",
|
|
1598
|
-
arg: err
|
|
1599
|
-
};
|
|
1600
|
-
}
|
|
1601
|
-
}
|
|
1624
|
+
return Math.sqrt(y);
|
|
1625
|
+
};
|
|
1626
|
+
/**
|
|
1627
|
+
* 3x3 Matrix
|
|
1628
|
+
* @module mat3
|
|
1629
|
+
*/
|
|
1602
1630
|
|
|
1603
|
-
|
|
1604
|
-
|
|
1631
|
+
/**
|
|
1632
|
+
* Creates a new identity mat3
|
|
1633
|
+
*
|
|
1634
|
+
* @returns {mat3} a new 3x3 matrix
|
|
1635
|
+
*/
|
|
1605
1636
|
|
|
1606
|
-
|
|
1637
|
+
function create() {
|
|
1638
|
+
var out = new ARRAY_TYPE(9);
|
|
1607
1639
|
|
|
1608
|
-
|
|
1640
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
1641
|
+
out[1] = 0;
|
|
1642
|
+
out[2] = 0;
|
|
1643
|
+
out[3] = 0;
|
|
1644
|
+
out[5] = 0;
|
|
1645
|
+
out[6] = 0;
|
|
1646
|
+
out[7] = 0;
|
|
1647
|
+
}
|
|
1609
1648
|
|
|
1610
|
-
|
|
1649
|
+
out[0] = 1;
|
|
1650
|
+
out[4] = 1;
|
|
1651
|
+
out[8] = 1;
|
|
1652
|
+
return out;
|
|
1653
|
+
}
|
|
1654
|
+
/**
|
|
1655
|
+
* Returns the translation vector component of a transformation
|
|
1656
|
+
* matrix. If a matrix is built with fromRotationTranslation,
|
|
1657
|
+
* the returned vector will be the same as the translation vector
|
|
1658
|
+
* originally supplied.
|
|
1659
|
+
* @param {vec3} out Vector to receive translation component
|
|
1660
|
+
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
1661
|
+
* @return {vec3} out
|
|
1662
|
+
*/
|
|
1611
1663
|
|
|
1612
|
-
var IteratorPrototype = {};
|
|
1613
|
-
define(IteratorPrototype, iteratorSymbol, function () {
|
|
1614
|
-
return this;
|
|
1615
|
-
});
|
|
1616
|
-
var getProto = Object.getPrototypeOf,
|
|
1617
|
-
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1618
|
-
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
1619
|
-
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
1620
1664
|
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1665
|
+
function getTranslation(out, mat) {
|
|
1666
|
+
out[0] = mat[12];
|
|
1667
|
+
out[1] = mat[13];
|
|
1668
|
+
out[2] = mat[14];
|
|
1669
|
+
return out;
|
|
1670
|
+
}
|
|
1671
|
+
/**
|
|
1672
|
+
* Returns the scaling factor component of a transformation
|
|
1673
|
+
* matrix. If a matrix is built with fromRotationTranslationScale
|
|
1674
|
+
* with a normalized Quaternion paramter, the returned vector will be
|
|
1675
|
+
* the same as the scaling vector
|
|
1676
|
+
* originally supplied.
|
|
1677
|
+
* @param {vec3} out Vector to receive scaling factor component
|
|
1678
|
+
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
1679
|
+
* @return {vec3} out
|
|
1680
|
+
*/
|
|
1628
1681
|
|
|
1629
|
-
function AsyncIterator(generator, PromiseImpl) {
|
|
1630
|
-
function invoke(method, arg, resolve, reject) {
|
|
1631
|
-
var record = tryCatch(generator[method], generator, arg);
|
|
1632
1682
|
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
reject(record.arg);
|
|
1648
|
-
}
|
|
1649
|
-
|
|
1650
|
-
var previousPromise;
|
|
1651
|
-
|
|
1652
|
-
this._invoke = function (method, arg) {
|
|
1653
|
-
function callInvokeWithMethodAndArg() {
|
|
1654
|
-
return new PromiseImpl(function (resolve, reject) {
|
|
1655
|
-
invoke(method, arg, resolve, reject);
|
|
1656
|
-
});
|
|
1657
|
-
}
|
|
1658
|
-
|
|
1659
|
-
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
1660
|
-
};
|
|
1661
|
-
}
|
|
1662
|
-
|
|
1663
|
-
function maybeInvokeDelegate(delegate, context) {
|
|
1664
|
-
var method = delegate.iterator[context.method];
|
|
1665
|
-
|
|
1666
|
-
if (undefined === method) {
|
|
1667
|
-
if (context.delegate = null, "throw" === context.method) {
|
|
1668
|
-
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
1669
|
-
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
1670
|
-
}
|
|
1671
|
-
|
|
1672
|
-
return ContinueSentinel;
|
|
1673
|
-
}
|
|
1674
|
-
|
|
1675
|
-
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1676
|
-
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
1677
|
-
var info = record.arg;
|
|
1678
|
-
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
function pushTryEntry(locs) {
|
|
1682
|
-
var entry = {
|
|
1683
|
-
tryLoc: locs[0]
|
|
1684
|
-
};
|
|
1685
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
1686
|
-
}
|
|
1687
|
-
|
|
1688
|
-
function resetTryEntry(entry) {
|
|
1689
|
-
var record = entry.completion || {};
|
|
1690
|
-
record.type = "normal", delete record.arg, entry.completion = record;
|
|
1691
|
-
}
|
|
1692
|
-
|
|
1693
|
-
function Context(tryLocsList) {
|
|
1694
|
-
this.tryEntries = [{
|
|
1695
|
-
tryLoc: "root"
|
|
1696
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
function values(iterable) {
|
|
1700
|
-
if (iterable) {
|
|
1701
|
-
var iteratorMethod = iterable[iteratorSymbol];
|
|
1702
|
-
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
1703
|
-
if ("function" == typeof iterable.next) return iterable;
|
|
1704
|
-
|
|
1705
|
-
if (!isNaN(iterable.length)) {
|
|
1706
|
-
var i = -1,
|
|
1707
|
-
next = function next() {
|
|
1708
|
-
for (; ++i < iterable.length;) {
|
|
1709
|
-
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
|
-
return next.value = undefined, next.done = !0, next;
|
|
1713
|
-
};
|
|
1714
|
-
|
|
1715
|
-
return next.next = next;
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
return {
|
|
1720
|
-
next: doneResult
|
|
1721
|
-
};
|
|
1722
|
-
}
|
|
1723
|
-
|
|
1724
|
-
function doneResult() {
|
|
1725
|
-
return {
|
|
1726
|
-
value: undefined,
|
|
1727
|
-
done: !0
|
|
1728
|
-
};
|
|
1729
|
-
}
|
|
1730
|
-
|
|
1731
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
1732
|
-
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
1733
|
-
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
1734
|
-
}, exports.mark = function (genFun) {
|
|
1735
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
1736
|
-
}, exports.awrap = function (arg) {
|
|
1737
|
-
return {
|
|
1738
|
-
__await: arg
|
|
1739
|
-
};
|
|
1740
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
1741
|
-
return this;
|
|
1742
|
-
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1743
|
-
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
1744
|
-
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1745
|
-
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
1746
|
-
return result.done ? result.value : iter.next();
|
|
1747
|
-
});
|
|
1748
|
-
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
1749
|
-
return this;
|
|
1750
|
-
}), define(Gp, "toString", function () {
|
|
1751
|
-
return "[object Generator]";
|
|
1752
|
-
}), exports.keys = function (object) {
|
|
1753
|
-
var keys = [];
|
|
1754
|
-
|
|
1755
|
-
for (var key in object) {
|
|
1756
|
-
keys.push(key);
|
|
1757
|
-
}
|
|
1758
|
-
|
|
1759
|
-
return keys.reverse(), function next() {
|
|
1760
|
-
for (; keys.length;) {
|
|
1761
|
-
var key = keys.pop();
|
|
1762
|
-
if (key in object) return next.value = key, next.done = !1, next;
|
|
1763
|
-
}
|
|
1764
|
-
|
|
1765
|
-
return next.done = !0, next;
|
|
1766
|
-
};
|
|
1767
|
-
}, exports.values = values, Context.prototype = {
|
|
1768
|
-
constructor: Context,
|
|
1769
|
-
reset: function reset(skipTempReset) {
|
|
1770
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
|
|
1771
|
-
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
1772
|
-
}
|
|
1773
|
-
},
|
|
1774
|
-
stop: function stop() {
|
|
1775
|
-
this.done = !0;
|
|
1776
|
-
var rootRecord = this.tryEntries[0].completion;
|
|
1777
|
-
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
1778
|
-
return this.rval;
|
|
1779
|
-
},
|
|
1780
|
-
dispatchException: function dispatchException(exception) {
|
|
1781
|
-
if (this.done) throw exception;
|
|
1782
|
-
var context = this;
|
|
1783
|
-
|
|
1784
|
-
function handle(loc, caught) {
|
|
1785
|
-
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
1786
|
-
}
|
|
1787
|
-
|
|
1788
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1789
|
-
var entry = this.tryEntries[i],
|
|
1790
|
-
record = entry.completion;
|
|
1791
|
-
if ("root" === entry.tryLoc) return handle("end");
|
|
1792
|
-
|
|
1793
|
-
if (entry.tryLoc <= this.prev) {
|
|
1794
|
-
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
1795
|
-
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1796
|
-
|
|
1797
|
-
if (hasCatch && hasFinally) {
|
|
1798
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1799
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1800
|
-
} else if (hasCatch) {
|
|
1801
|
-
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1802
|
-
} else {
|
|
1803
|
-
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
1804
|
-
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1805
|
-
}
|
|
1806
|
-
}
|
|
1807
|
-
}
|
|
1808
|
-
},
|
|
1809
|
-
abrupt: function abrupt(type, arg) {
|
|
1810
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1811
|
-
var entry = this.tryEntries[i];
|
|
1812
|
-
|
|
1813
|
-
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
1814
|
-
var finallyEntry = entry;
|
|
1815
|
-
break;
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1818
|
-
|
|
1819
|
-
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
1820
|
-
var record = finallyEntry ? finallyEntry.completion : {};
|
|
1821
|
-
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
1822
|
-
},
|
|
1823
|
-
complete: function complete(record, afterLoc) {
|
|
1824
|
-
if ("throw" === record.type) throw record.arg;
|
|
1825
|
-
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
|
1826
|
-
},
|
|
1827
|
-
finish: function finish(finallyLoc) {
|
|
1828
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1829
|
-
var entry = this.tryEntries[i];
|
|
1830
|
-
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
1831
|
-
}
|
|
1832
|
-
},
|
|
1833
|
-
catch: function _catch(tryLoc) {
|
|
1834
|
-
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1835
|
-
var entry = this.tryEntries[i];
|
|
1836
|
-
|
|
1837
|
-
if (entry.tryLoc === tryLoc) {
|
|
1838
|
-
var record = entry.completion;
|
|
1839
|
-
|
|
1840
|
-
if ("throw" === record.type) {
|
|
1841
|
-
var thrown = record.arg;
|
|
1842
|
-
resetTryEntry(entry);
|
|
1843
|
-
}
|
|
1844
|
-
|
|
1845
|
-
return thrown;
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
|
|
1849
|
-
throw new Error("illegal catch attempt");
|
|
1850
|
-
},
|
|
1851
|
-
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
1852
|
-
return this.delegate = {
|
|
1853
|
-
iterator: values(iterable),
|
|
1854
|
-
resultName: resultName,
|
|
1855
|
-
nextLoc: nextLoc
|
|
1856
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
1857
|
-
}
|
|
1858
|
-
}, exports;
|
|
1683
|
+
function getScaling(out, mat) {
|
|
1684
|
+
var m11 = mat[0];
|
|
1685
|
+
var m12 = mat[1];
|
|
1686
|
+
var m13 = mat[2];
|
|
1687
|
+
var m21 = mat[4];
|
|
1688
|
+
var m22 = mat[5];
|
|
1689
|
+
var m23 = mat[6];
|
|
1690
|
+
var m31 = mat[8];
|
|
1691
|
+
var m32 = mat[9];
|
|
1692
|
+
var m33 = mat[10];
|
|
1693
|
+
out[0] = Math.hypot(m11, m12, m13);
|
|
1694
|
+
out[1] = Math.hypot(m21, m22, m23);
|
|
1695
|
+
out[2] = Math.hypot(m31, m32, m33);
|
|
1696
|
+
return out;
|
|
1859
1697
|
}
|
|
1698
|
+
/**
|
|
1699
|
+
* Returns a quaternion representing the rotational component
|
|
1700
|
+
* of a transformation matrix. If a matrix is built with
|
|
1701
|
+
* fromRotationTranslation, the returned quaternion will be the
|
|
1702
|
+
* same as the quaternion originally supplied.
|
|
1703
|
+
* @param {quat} out Quaternion to receive the rotation component
|
|
1704
|
+
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
1705
|
+
* @return {quat} out
|
|
1706
|
+
*/
|
|
1860
1707
|
|
|
1861
|
-
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1862
|
-
try {
|
|
1863
|
-
var info = gen[key](arg);
|
|
1864
|
-
var value = info.value;
|
|
1865
|
-
} catch (error) {
|
|
1866
|
-
reject(error);
|
|
1867
|
-
return;
|
|
1868
|
-
}
|
|
1869
1708
|
|
|
1870
|
-
|
|
1871
|
-
|
|
1709
|
+
function getRotation(out, mat) {
|
|
1710
|
+
var scaling = new ARRAY_TYPE(3);
|
|
1711
|
+
getScaling(scaling, mat);
|
|
1712
|
+
var is1 = 1 / scaling[0];
|
|
1713
|
+
var is2 = 1 / scaling[1];
|
|
1714
|
+
var is3 = 1 / scaling[2];
|
|
1715
|
+
var sm11 = mat[0] * is1;
|
|
1716
|
+
var sm12 = mat[1] * is2;
|
|
1717
|
+
var sm13 = mat[2] * is3;
|
|
1718
|
+
var sm21 = mat[4] * is1;
|
|
1719
|
+
var sm22 = mat[5] * is2;
|
|
1720
|
+
var sm23 = mat[6] * is3;
|
|
1721
|
+
var sm31 = mat[8] * is1;
|
|
1722
|
+
var sm32 = mat[9] * is2;
|
|
1723
|
+
var sm33 = mat[10] * is3;
|
|
1724
|
+
var trace = sm11 + sm22 + sm33;
|
|
1725
|
+
var S = 0;
|
|
1726
|
+
|
|
1727
|
+
if (trace > 0) {
|
|
1728
|
+
S = Math.sqrt(trace + 1.0) * 2;
|
|
1729
|
+
out[3] = 0.25 * S;
|
|
1730
|
+
out[0] = (sm23 - sm32) / S;
|
|
1731
|
+
out[1] = (sm31 - sm13) / S;
|
|
1732
|
+
out[2] = (sm12 - sm21) / S;
|
|
1733
|
+
} else if (sm11 > sm22 && sm11 > sm33) {
|
|
1734
|
+
S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;
|
|
1735
|
+
out[3] = (sm23 - sm32) / S;
|
|
1736
|
+
out[0] = 0.25 * S;
|
|
1737
|
+
out[1] = (sm12 + sm21) / S;
|
|
1738
|
+
out[2] = (sm31 + sm13) / S;
|
|
1739
|
+
} else if (sm22 > sm33) {
|
|
1740
|
+
S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;
|
|
1741
|
+
out[3] = (sm31 - sm13) / S;
|
|
1742
|
+
out[0] = (sm12 + sm21) / S;
|
|
1743
|
+
out[1] = 0.25 * S;
|
|
1744
|
+
out[2] = (sm23 + sm32) / S;
|
|
1872
1745
|
} else {
|
|
1873
|
-
|
|
1746
|
+
S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;
|
|
1747
|
+
out[3] = (sm12 - sm21) / S;
|
|
1748
|
+
out[0] = (sm31 + sm13) / S;
|
|
1749
|
+
out[1] = (sm23 + sm32) / S;
|
|
1750
|
+
out[2] = 0.25 * S;
|
|
1874
1751
|
}
|
|
1875
|
-
}
|
|
1876
|
-
|
|
1877
|
-
function _asyncToGenerator$1(fn) {
|
|
1878
|
-
return function () {
|
|
1879
|
-
var self = this,
|
|
1880
|
-
args = arguments;
|
|
1881
|
-
return new Promise(function (resolve, reject) {
|
|
1882
|
-
var gen = fn.apply(self, args);
|
|
1883
|
-
|
|
1884
|
-
function _next(value) {
|
|
1885
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
1886
|
-
}
|
|
1887
1752
|
|
|
1888
|
-
|
|
1889
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1890
|
-
}
|
|
1891
|
-
|
|
1892
|
-
_next(undefined);
|
|
1893
|
-
});
|
|
1894
|
-
};
|
|
1753
|
+
return out;
|
|
1895
1754
|
}
|
|
1755
|
+
/**
|
|
1756
|
+
* 3 Dimensional Vector
|
|
1757
|
+
* @module vec3
|
|
1758
|
+
*/
|
|
1896
1759
|
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
for (var key in source) {
|
|
1903
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1904
|
-
target[key] = source[key];
|
|
1905
|
-
}
|
|
1906
|
-
}
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
return target;
|
|
1910
|
-
};
|
|
1911
|
-
|
|
1912
|
-
return _extends.apply(this, arguments);
|
|
1913
|
-
}
|
|
1760
|
+
/**
|
|
1761
|
+
* Creates a new, empty vec3
|
|
1762
|
+
*
|
|
1763
|
+
* @returns {vec3} a new 3D vector
|
|
1764
|
+
*/
|
|
1914
1765
|
|
|
1915
|
-
function _inheritsLoose$1(subClass, superClass) {
|
|
1916
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
1917
|
-
subClass.prototype.constructor = subClass;
|
|
1918
1766
|
|
|
1919
|
-
|
|
1920
|
-
|
|
1767
|
+
function create$1() {
|
|
1768
|
+
var out = new ARRAY_TYPE(3);
|
|
1921
1769
|
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
}
|
|
1770
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
1771
|
+
out[0] = 0;
|
|
1772
|
+
out[1] = 0;
|
|
1773
|
+
out[2] = 0;
|
|
1774
|
+
}
|
|
1927
1775
|
|
|
1928
|
-
return
|
|
1776
|
+
return out;
|
|
1929
1777
|
}
|
|
1778
|
+
/**
|
|
1779
|
+
* Calculates the length of a vec3
|
|
1780
|
+
*
|
|
1781
|
+
* @param {ReadonlyVec3} a vector to calculate length of
|
|
1782
|
+
* @returns {Number} length of a
|
|
1783
|
+
*/
|
|
1930
1784
|
|
|
1931
|
-
var DefaultRenderer = /*#__PURE__*/function () {
|
|
1932
|
-
function DefaultRenderer() {}
|
|
1933
|
-
|
|
1934
|
-
var _proto = DefaultRenderer.prototype;
|
|
1935
|
-
|
|
1936
|
-
_proto.hash = function hash(parsedStyle) {
|
|
1937
|
-
// const { fill, opacity, fillOpacity, stroke, strokeOpacity, lineWidth, lineCap, lineJoin } =
|
|
1938
|
-
// parsedStyle;
|
|
1939
|
-
// return fill + opacity + fillOpacity + stroke + strokeOpacity + lineWidth + lineCap + lineJoin;
|
|
1940
|
-
return '';
|
|
1941
|
-
};
|
|
1942
|
-
|
|
1943
|
-
_proto.render = function render(context, parsedStyle) {
|
|
1944
|
-
var fill = parsedStyle.fill,
|
|
1945
|
-
opacity = parsedStyle.opacity,
|
|
1946
|
-
fillOpacity = parsedStyle.fillOpacity,
|
|
1947
|
-
stroke = parsedStyle.stroke,
|
|
1948
|
-
strokeOpacity = parsedStyle.strokeOpacity,
|
|
1949
|
-
lineWidth = parsedStyle.lineWidth,
|
|
1950
|
-
lineCap = parsedStyle.lineCap,
|
|
1951
|
-
lineJoin = parsedStyle.lineJoin,
|
|
1952
|
-
shadowColor = parsedStyle.shadowColor,
|
|
1953
|
-
filter = parsedStyle.filter,
|
|
1954
|
-
miterLimit = parsedStyle.miterLimit;
|
|
1955
|
-
var hasFill = !g.isNil(fill);
|
|
1956
|
-
var hasStroke = !g.isNil(stroke);
|
|
1957
|
-
var isFillTransparent = fill.alpha === 0;
|
|
1958
|
-
|
|
1959
|
-
if (hasFill) {
|
|
1960
|
-
if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
|
|
1961
|
-
context.globalAlpha = fillOpacity.value;
|
|
1962
|
-
context.fill();
|
|
1963
|
-
context.globalAlpha = opacity.value;
|
|
1964
|
-
} else {
|
|
1965
|
-
context.fill();
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
|
|
1969
|
-
if (hasStroke) {
|
|
1970
|
-
if (lineWidth && lineWidth.value > 0) {
|
|
1971
|
-
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
|
|
1972
|
-
|
|
1973
|
-
if (applyOpacity) {
|
|
1974
|
-
context.globalAlpha = strokeOpacity.value;
|
|
1975
|
-
}
|
|
1976
1785
|
|
|
1977
|
-
|
|
1786
|
+
function length(a) {
|
|
1787
|
+
var x = a[0];
|
|
1788
|
+
var y = a[1];
|
|
1789
|
+
var z = a[2];
|
|
1790
|
+
return Math.hypot(x, y, z);
|
|
1791
|
+
}
|
|
1792
|
+
/**
|
|
1793
|
+
* Creates a new vec3 initialized with the given values
|
|
1794
|
+
*
|
|
1795
|
+
* @param {Number} x X component
|
|
1796
|
+
* @param {Number} y Y component
|
|
1797
|
+
* @param {Number} z Z component
|
|
1798
|
+
* @returns {vec3} a new 3D vector
|
|
1799
|
+
*/
|
|
1978
1800
|
|
|
1979
|
-
if (!g.isNil(miterLimit)) {
|
|
1980
|
-
context.miterLimit = miterLimit;
|
|
1981
|
-
}
|
|
1982
1801
|
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1802
|
+
function fromValues(x, y, z) {
|
|
1803
|
+
var out = new ARRAY_TYPE(3);
|
|
1804
|
+
out[0] = x;
|
|
1805
|
+
out[1] = y;
|
|
1806
|
+
out[2] = z;
|
|
1807
|
+
return out;
|
|
1808
|
+
}
|
|
1809
|
+
/**
|
|
1810
|
+
* Normalize a vec3
|
|
1811
|
+
*
|
|
1812
|
+
* @param {vec3} out the receiving vector
|
|
1813
|
+
* @param {ReadonlyVec3} a vector to normalize
|
|
1814
|
+
* @returns {vec3} out
|
|
1815
|
+
*/
|
|
1986
1816
|
|
|
1987
|
-
if (!g.isNil(lineJoin)) {
|
|
1988
|
-
context.lineJoin = lineJoin.value;
|
|
1989
|
-
}
|
|
1990
1817
|
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1818
|
+
function normalize(out, a) {
|
|
1819
|
+
var x = a[0];
|
|
1820
|
+
var y = a[1];
|
|
1821
|
+
var z = a[2];
|
|
1822
|
+
var len = x * x + y * y + z * z;
|
|
1996
1823
|
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
oldShadowColor = context.shadowColor;
|
|
1824
|
+
if (len > 0) {
|
|
1825
|
+
//TODO: evaluate use of glm_invsqrt here?
|
|
1826
|
+
len = 1 / Math.sqrt(len);
|
|
1827
|
+
}
|
|
2002
1828
|
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
1829
|
+
out[0] = a[0] * len;
|
|
1830
|
+
out[1] = a[1] * len;
|
|
1831
|
+
out[2] = a[2] * len;
|
|
1832
|
+
return out;
|
|
1833
|
+
}
|
|
1834
|
+
/**
|
|
1835
|
+
* Calculates the dot product of two vec3's
|
|
1836
|
+
*
|
|
1837
|
+
* @param {ReadonlyVec3} a the first operand
|
|
1838
|
+
* @param {ReadonlyVec3} b the second operand
|
|
1839
|
+
* @returns {Number} dot product of a and b
|
|
1840
|
+
*/
|
|
2008
1841
|
|
|
2009
|
-
if (hasFilter) {
|
|
2010
|
-
// save drop-shadow filter
|
|
2011
|
-
oldFilter = context.filter;
|
|
2012
1842
|
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
1843
|
+
function dot(a, b) {
|
|
1844
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
1845
|
+
}
|
|
1846
|
+
/**
|
|
1847
|
+
* Computes the cross product of two vec3's
|
|
1848
|
+
*
|
|
1849
|
+
* @param {vec3} out the receiving vector
|
|
1850
|
+
* @param {ReadonlyVec3} a the first operand
|
|
1851
|
+
* @param {ReadonlyVec3} b the second operand
|
|
1852
|
+
* @returns {vec3} out
|
|
1853
|
+
*/
|
|
2017
1854
|
|
|
2018
|
-
var drawStroke = hasFill && !isFillTransparent;
|
|
2019
1855
|
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
1856
|
+
function cross(out, a, b) {
|
|
1857
|
+
var ax = a[0],
|
|
1858
|
+
ay = a[1],
|
|
1859
|
+
az = a[2];
|
|
1860
|
+
var bx = b[0],
|
|
1861
|
+
by = b[1],
|
|
1862
|
+
bz = b[2];
|
|
1863
|
+
out[0] = ay * bz - az * by;
|
|
1864
|
+
out[1] = az * bx - ax * bz;
|
|
1865
|
+
out[2] = ax * by - ay * bx;
|
|
1866
|
+
return out;
|
|
1867
|
+
}
|
|
1868
|
+
/**
|
|
1869
|
+
* Alias for {@link vec3.length}
|
|
1870
|
+
* @function
|
|
1871
|
+
*/
|
|
2023
1872
|
|
|
2024
1873
|
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
1874
|
+
var len = length;
|
|
1875
|
+
/**
|
|
1876
|
+
* Perform some operation over an array of vec3s.
|
|
1877
|
+
*
|
|
1878
|
+
* @param {Array} a the array of vectors to iterate over
|
|
1879
|
+
* @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
|
|
1880
|
+
* @param {Number} offset Number of elements to skip at the beginning of the array
|
|
1881
|
+
* @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
|
|
1882
|
+
* @param {Function} fn Function to call for each vector in the array
|
|
1883
|
+
* @param {Object} [arg] additional argument to pass to fn
|
|
1884
|
+
* @returns {Array} a
|
|
1885
|
+
* @function
|
|
1886
|
+
*/
|
|
2029
1887
|
|
|
1888
|
+
var forEach = function () {
|
|
1889
|
+
var vec = create$1();
|
|
1890
|
+
return function (a, stride, offset, count, fn, arg) {
|
|
1891
|
+
var i, l;
|
|
2030
1892
|
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
1893
|
+
if (!stride) {
|
|
1894
|
+
stride = 3;
|
|
1895
|
+
}
|
|
2034
1896
|
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
}
|
|
2038
|
-
}
|
|
1897
|
+
if (!offset) {
|
|
1898
|
+
offset = 0;
|
|
2039
1899
|
}
|
|
2040
|
-
};
|
|
2041
1900
|
|
|
2042
|
-
|
|
1901
|
+
if (count) {
|
|
1902
|
+
l = Math.min(count * stride + offset, a.length);
|
|
1903
|
+
} else {
|
|
1904
|
+
l = a.length;
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
for (i = offset; i < l; i += stride) {
|
|
1908
|
+
vec[0] = a[i];
|
|
1909
|
+
vec[1] = a[i + 1];
|
|
1910
|
+
vec[2] = a[i + 2];
|
|
1911
|
+
fn(vec, vec, arg);
|
|
1912
|
+
a[i] = vec[0];
|
|
1913
|
+
a[i + 1] = vec[1];
|
|
1914
|
+
a[i + 2] = vec[2];
|
|
1915
|
+
}
|
|
1916
|
+
|
|
1917
|
+
return a;
|
|
1918
|
+
};
|
|
2043
1919
|
}();
|
|
1920
|
+
/**
|
|
1921
|
+
* 4 Dimensional Vector
|
|
1922
|
+
* @module vec4
|
|
1923
|
+
*/
|
|
2044
1924
|
|
|
2045
|
-
|
|
1925
|
+
/**
|
|
1926
|
+
* Creates a new, empty vec4
|
|
1927
|
+
*
|
|
1928
|
+
* @returns {vec4} a new 4D vector
|
|
1929
|
+
*/
|
|
2046
1930
|
|
|
2047
|
-
var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2048
|
-
_inheritsLoose$1(RectRenderer, _DefaultRenderer);
|
|
2049
1931
|
|
|
2050
|
-
|
|
2051
|
-
|
|
1932
|
+
function create$2() {
|
|
1933
|
+
var out = new ARRAY_TYPE(4);
|
|
1934
|
+
|
|
1935
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
1936
|
+
out[0] = 0;
|
|
1937
|
+
out[1] = 0;
|
|
1938
|
+
out[2] = 0;
|
|
1939
|
+
out[3] = 0;
|
|
2052
1940
|
}
|
|
2053
1941
|
|
|
2054
|
-
return
|
|
2055
|
-
}
|
|
1942
|
+
return out;
|
|
1943
|
+
}
|
|
1944
|
+
/**
|
|
1945
|
+
* Normalize a vec4
|
|
1946
|
+
*
|
|
1947
|
+
* @param {vec4} out the receiving vector
|
|
1948
|
+
* @param {ReadonlyVec4} a vector to normalize
|
|
1949
|
+
* @returns {vec4} out
|
|
1950
|
+
*/
|
|
2056
1951
|
|
|
2057
|
-
RectRenderer = __decorate([manaSyringe.singleton({
|
|
2058
|
-
token: RectRendererContribution
|
|
2059
|
-
})], RectRenderer);
|
|
2060
1952
|
|
|
2061
|
-
|
|
2062
|
-
|
|
1953
|
+
function normalize$1(out, a) {
|
|
1954
|
+
var x = a[0];
|
|
1955
|
+
var y = a[1];
|
|
1956
|
+
var z = a[2];
|
|
1957
|
+
var w = a[3];
|
|
1958
|
+
var len = x * x + y * y + z * z + w * w;
|
|
2063
1959
|
|
|
2064
|
-
|
|
2065
|
-
|
|
1960
|
+
if (len > 0) {
|
|
1961
|
+
len = 1 / Math.sqrt(len);
|
|
2066
1962
|
}
|
|
2067
1963
|
|
|
2068
|
-
|
|
2069
|
-
|
|
1964
|
+
out[0] = x * len;
|
|
1965
|
+
out[1] = y * len;
|
|
1966
|
+
out[2] = z * len;
|
|
1967
|
+
out[3] = w * len;
|
|
1968
|
+
return out;
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* Perform some operation over an array of vec4s.
|
|
1972
|
+
*
|
|
1973
|
+
* @param {Array} a the array of vectors to iterate over
|
|
1974
|
+
* @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
|
|
1975
|
+
* @param {Number} offset Number of elements to skip at the beginning of the array
|
|
1976
|
+
* @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
|
|
1977
|
+
* @param {Function} fn Function to call for each vector in the array
|
|
1978
|
+
* @param {Object} [arg] additional argument to pass to fn
|
|
1979
|
+
* @returns {Array} a
|
|
1980
|
+
* @function
|
|
1981
|
+
*/
|
|
2070
1982
|
|
|
2071
|
-
CircleRenderer = __decorate([manaSyringe.singleton({
|
|
2072
|
-
token: CircleRendererContribution
|
|
2073
|
-
})], CircleRenderer);
|
|
2074
1983
|
|
|
2075
|
-
var
|
|
2076
|
-
|
|
1984
|
+
var forEach$1 = function () {
|
|
1985
|
+
var vec = create$2();
|
|
1986
|
+
return function (a, stride, offset, count, fn, arg) {
|
|
1987
|
+
var i, l;
|
|
1988
|
+
|
|
1989
|
+
if (!stride) {
|
|
1990
|
+
stride = 4;
|
|
1991
|
+
}
|
|
1992
|
+
|
|
1993
|
+
if (!offset) {
|
|
1994
|
+
offset = 0;
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
if (count) {
|
|
1998
|
+
l = Math.min(count * stride + offset, a.length);
|
|
1999
|
+
} else {
|
|
2000
|
+
l = a.length;
|
|
2001
|
+
}
|
|
2002
|
+
|
|
2003
|
+
for (i = offset; i < l; i += stride) {
|
|
2004
|
+
vec[0] = a[i];
|
|
2005
|
+
vec[1] = a[i + 1];
|
|
2006
|
+
vec[2] = a[i + 2];
|
|
2007
|
+
vec[3] = a[i + 3];
|
|
2008
|
+
fn(vec, vec, arg);
|
|
2009
|
+
a[i] = vec[0];
|
|
2010
|
+
a[i + 1] = vec[1];
|
|
2011
|
+
a[i + 2] = vec[2];
|
|
2012
|
+
a[i + 3] = vec[3];
|
|
2013
|
+
}
|
|
2077
2014
|
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2015
|
+
return a;
|
|
2016
|
+
};
|
|
2017
|
+
}();
|
|
2018
|
+
/**
|
|
2019
|
+
* Quaternion
|
|
2020
|
+
* @module quat
|
|
2021
|
+
*/
|
|
2081
2022
|
|
|
2082
|
-
|
|
2083
|
-
|
|
2023
|
+
/**
|
|
2024
|
+
* Creates a new identity quat
|
|
2025
|
+
*
|
|
2026
|
+
* @returns {quat} a new quaternion
|
|
2027
|
+
*/
|
|
2084
2028
|
|
|
2085
|
-
EllipseRenderer = __decorate([manaSyringe.singleton({
|
|
2086
|
-
token: EllipseRendererContribution
|
|
2087
|
-
})], EllipseRenderer);
|
|
2088
2029
|
|
|
2089
|
-
|
|
2090
|
-
|
|
2030
|
+
function create$3() {
|
|
2031
|
+
var out = new ARRAY_TYPE(4);
|
|
2091
2032
|
|
|
2092
|
-
|
|
2093
|
-
|
|
2033
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
2034
|
+
out[0] = 0;
|
|
2035
|
+
out[1] = 0;
|
|
2036
|
+
out[2] = 0;
|
|
2094
2037
|
}
|
|
2095
2038
|
|
|
2096
|
-
|
|
2097
|
-
|
|
2039
|
+
out[3] = 1;
|
|
2040
|
+
return out;
|
|
2041
|
+
}
|
|
2042
|
+
/**
|
|
2043
|
+
* Sets a quat from the given angle and rotation axis,
|
|
2044
|
+
* then returns it.
|
|
2045
|
+
*
|
|
2046
|
+
* @param {quat} out the receiving quaternion
|
|
2047
|
+
* @param {ReadonlyVec3} axis the axis around which to rotate
|
|
2048
|
+
* @param {Number} rad the angle in radians
|
|
2049
|
+
* @returns {quat} out
|
|
2050
|
+
**/
|
|
2098
2051
|
|
|
2099
|
-
LineRenderer = __decorate([manaSyringe.singleton({
|
|
2100
|
-
token: LineRendererContribution
|
|
2101
|
-
})], LineRenderer);
|
|
2102
2052
|
|
|
2103
|
-
|
|
2104
|
-
|
|
2053
|
+
function setAxisAngle(out, axis, rad) {
|
|
2054
|
+
rad = rad * 0.5;
|
|
2055
|
+
var s = Math.sin(rad);
|
|
2056
|
+
out[0] = s * axis[0];
|
|
2057
|
+
out[1] = s * axis[1];
|
|
2058
|
+
out[2] = s * axis[2];
|
|
2059
|
+
out[3] = Math.cos(rad);
|
|
2060
|
+
return out;
|
|
2061
|
+
}
|
|
2062
|
+
/**
|
|
2063
|
+
* Performs a spherical linear interpolation between two quat
|
|
2064
|
+
*
|
|
2065
|
+
* @param {quat} out the receiving quaternion
|
|
2066
|
+
* @param {ReadonlyQuat} a the first operand
|
|
2067
|
+
* @param {ReadonlyQuat} b the second operand
|
|
2068
|
+
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
2069
|
+
* @returns {quat} out
|
|
2070
|
+
*/
|
|
2105
2071
|
|
|
2106
|
-
function PolylineRenderer() {
|
|
2107
|
-
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2108
|
-
}
|
|
2109
2072
|
|
|
2110
|
-
|
|
2111
|
-
|
|
2073
|
+
function slerp(out, a, b, t) {
|
|
2074
|
+
// benchmarks:
|
|
2075
|
+
// http://jsperf.com/quaternion-slerp-implementations
|
|
2076
|
+
var ax = a[0],
|
|
2077
|
+
ay = a[1],
|
|
2078
|
+
az = a[2],
|
|
2079
|
+
aw = a[3];
|
|
2080
|
+
var bx = b[0],
|
|
2081
|
+
by = b[1],
|
|
2082
|
+
bz = b[2],
|
|
2083
|
+
bw = b[3];
|
|
2084
|
+
var omega, cosom, sinom, scale0, scale1; // calc cosine
|
|
2112
2085
|
|
|
2113
|
-
|
|
2114
|
-
token: PolylineRendererContribution
|
|
2115
|
-
})], PolylineRenderer);
|
|
2086
|
+
cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)
|
|
2116
2087
|
|
|
2117
|
-
|
|
2118
|
-
|
|
2088
|
+
if (cosom < 0.0) {
|
|
2089
|
+
cosom = -cosom;
|
|
2090
|
+
bx = -bx;
|
|
2091
|
+
by = -by;
|
|
2092
|
+
bz = -bz;
|
|
2093
|
+
bw = -bw;
|
|
2094
|
+
} // calculate coefficients
|
|
2119
2095
|
|
|
2120
|
-
function PolygonRenderer() {
|
|
2121
|
-
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2122
|
-
}
|
|
2123
2096
|
|
|
2124
|
-
|
|
2125
|
-
|
|
2097
|
+
if (1.0 - cosom > EPSILON) {
|
|
2098
|
+
// standard case (slerp)
|
|
2099
|
+
omega = Math.acos(cosom);
|
|
2100
|
+
sinom = Math.sin(omega);
|
|
2101
|
+
scale0 = Math.sin((1.0 - t) * omega) / sinom;
|
|
2102
|
+
scale1 = Math.sin(t * omega) / sinom;
|
|
2103
|
+
} else {
|
|
2104
|
+
// "from" and "to" quaternions are very close
|
|
2105
|
+
// ... so we can do a linear interpolation
|
|
2106
|
+
scale0 = 1.0 - t;
|
|
2107
|
+
scale1 = t;
|
|
2108
|
+
} // calculate final values
|
|
2126
2109
|
|
|
2127
|
-
PolygonRenderer = __decorate([manaSyringe.singleton({
|
|
2128
|
-
token: PolygonRendererContribution
|
|
2129
|
-
})], PolygonRenderer);
|
|
2130
2110
|
|
|
2131
|
-
|
|
2132
|
-
|
|
2111
|
+
out[0] = scale0 * ax + scale1 * bx;
|
|
2112
|
+
out[1] = scale0 * ay + scale1 * by;
|
|
2113
|
+
out[2] = scale0 * az + scale1 * bz;
|
|
2114
|
+
out[3] = scale0 * aw + scale1 * bw;
|
|
2115
|
+
return out;
|
|
2116
|
+
}
|
|
2117
|
+
/**
|
|
2118
|
+
* Creates a quaternion from the given 3x3 rotation matrix.
|
|
2119
|
+
*
|
|
2120
|
+
* NOTE: The resultant quaternion is not normalized, so you should be sure
|
|
2121
|
+
* to renormalize the quaternion yourself where necessary.
|
|
2122
|
+
*
|
|
2123
|
+
* @param {quat} out the receiving quaternion
|
|
2124
|
+
* @param {ReadonlyMat3} m rotation matrix
|
|
2125
|
+
* @returns {quat} out
|
|
2126
|
+
* @function
|
|
2127
|
+
*/
|
|
2133
2128
|
|
|
2134
|
-
function PathRenderer() {
|
|
2135
|
-
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2136
|
-
}
|
|
2137
2129
|
|
|
2138
|
-
|
|
2139
|
-
|
|
2130
|
+
function fromMat3(out, m) {
|
|
2131
|
+
// Algorithm in Ken Shoemake's article in 1987 SIGGRAPH course notes
|
|
2132
|
+
// article "Quaternion Calculus and Fast Animation".
|
|
2133
|
+
var fTrace = m[0] + m[4] + m[8];
|
|
2134
|
+
var fRoot;
|
|
2140
2135
|
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2136
|
+
if (fTrace > 0.0) {
|
|
2137
|
+
// |w| > 1/2, may as well choose w > 1/2
|
|
2138
|
+
fRoot = Math.sqrt(fTrace + 1.0); // 2w
|
|
2144
2139
|
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
this.gradientCache = {};
|
|
2148
|
-
}
|
|
2140
|
+
out[3] = 0.5 * fRoot;
|
|
2141
|
+
fRoot = 0.5 / fRoot; // 1/(4w)
|
|
2149
2142
|
|
|
2150
|
-
|
|
2143
|
+
out[0] = (m[5] - m[7]) * fRoot;
|
|
2144
|
+
out[1] = (m[6] - m[2]) * fRoot;
|
|
2145
|
+
out[2] = (m[1] - m[3]) * fRoot;
|
|
2146
|
+
} else {
|
|
2147
|
+
// |w| <= 1/2
|
|
2148
|
+
var i = 0;
|
|
2149
|
+
if (m[4] > m[0]) i = 1;
|
|
2150
|
+
if (m[8] > m[i * 3 + i]) i = 2;
|
|
2151
|
+
var j = (i + 1) % 3;
|
|
2152
|
+
var k = (i + 2) % 3;
|
|
2153
|
+
fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);
|
|
2154
|
+
out[i] = 0.5 * fRoot;
|
|
2155
|
+
fRoot = 0.5 / fRoot;
|
|
2156
|
+
out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;
|
|
2157
|
+
out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;
|
|
2158
|
+
out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;
|
|
2159
|
+
}
|
|
2151
2160
|
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2161
|
+
return out;
|
|
2162
|
+
}
|
|
2163
|
+
/**
|
|
2164
|
+
* Normalize a quat
|
|
2165
|
+
*
|
|
2166
|
+
* @param {quat} out the receiving quaternion
|
|
2167
|
+
* @param {ReadonlyQuat} a quaternion to normalize
|
|
2168
|
+
* @returns {quat} out
|
|
2169
|
+
* @function
|
|
2170
|
+
*/
|
|
2162
2171
|
|
|
2163
|
-
if (this.gradientCache[key]) {
|
|
2164
|
-
return this.gradientCache[key];
|
|
2165
|
-
}
|
|
2166
2172
|
|
|
2167
|
-
|
|
2173
|
+
var normalize$2 = normalize$1;
|
|
2174
|
+
/**
|
|
2175
|
+
* Sets a quaternion to represent the shortest rotation from one
|
|
2176
|
+
* vector to another.
|
|
2177
|
+
*
|
|
2178
|
+
* Both vectors are assumed to be unit length.
|
|
2179
|
+
*
|
|
2180
|
+
* @param {quat} out the receiving quaternion.
|
|
2181
|
+
* @param {ReadonlyVec3} a the initial vector
|
|
2182
|
+
* @param {ReadonlyVec3} b the destination vector
|
|
2183
|
+
* @returns {quat} out
|
|
2184
|
+
*/
|
|
2168
2185
|
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2186
|
+
var rotationTo = function () {
|
|
2187
|
+
var tmpvec3 = create$1();
|
|
2188
|
+
var xUnitVec3 = fromValues(1, 0, 0);
|
|
2189
|
+
var yUnitVec3 = fromValues(0, 1, 0);
|
|
2190
|
+
return function (out, a, b) {
|
|
2191
|
+
var dot$1 = dot(a, b);
|
|
2174
2192
|
|
|
2175
|
-
|
|
2193
|
+
if (dot$1 < -0.999999) {
|
|
2194
|
+
cross(tmpvec3, xUnitVec3, a);
|
|
2195
|
+
if (len(tmpvec3) < 0.000001) cross(tmpvec3, yUnitVec3, a);
|
|
2196
|
+
normalize(tmpvec3, tmpvec3);
|
|
2197
|
+
setAxisAngle(out, tmpvec3, Math.PI);
|
|
2198
|
+
return out;
|
|
2199
|
+
} else if (dot$1 > 0.999999) {
|
|
2200
|
+
out[0] = 0;
|
|
2201
|
+
out[1] = 0;
|
|
2202
|
+
out[2] = 0;
|
|
2203
|
+
out[3] = 1;
|
|
2204
|
+
return out;
|
|
2205
|
+
} else {
|
|
2206
|
+
cross(tmpvec3, a, b);
|
|
2207
|
+
out[0] = tmpvec3[0];
|
|
2208
|
+
out[1] = tmpvec3[1];
|
|
2209
|
+
out[2] = tmpvec3[2];
|
|
2210
|
+
out[3] = 1 + dot$1;
|
|
2211
|
+
return normalize$2(out, out);
|
|
2176
2212
|
}
|
|
2213
|
+
};
|
|
2214
|
+
}();
|
|
2215
|
+
/**
|
|
2216
|
+
* Performs a spherical linear interpolation with two control points
|
|
2217
|
+
*
|
|
2218
|
+
* @param {quat} out the receiving quaternion
|
|
2219
|
+
* @param {ReadonlyQuat} a the first operand
|
|
2220
|
+
* @param {ReadonlyQuat} b the second operand
|
|
2221
|
+
* @param {ReadonlyQuat} c the third operand
|
|
2222
|
+
* @param {ReadonlyQuat} d the fourth operand
|
|
2223
|
+
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
2224
|
+
* @returns {quat} out
|
|
2225
|
+
*/
|
|
2177
2226
|
|
|
2178
|
-
if (gradient) {
|
|
2179
|
-
steps.forEach(function (_ref) {
|
|
2180
|
-
var _gradient;
|
|
2181
|
-
|
|
2182
|
-
var offset = _ref[0],
|
|
2183
|
-
color = _ref[1];
|
|
2184
|
-
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(Number(offset), color);
|
|
2185
|
-
});
|
|
2186
|
-
this.gradientCache[key] = gradient;
|
|
2187
|
-
}
|
|
2188
2227
|
|
|
2189
|
-
|
|
2228
|
+
var sqlerp = function () {
|
|
2229
|
+
var temp1 = create$3();
|
|
2230
|
+
var temp2 = create$3();
|
|
2231
|
+
return function (out, a, b, c, d, t) {
|
|
2232
|
+
slerp(temp1, a, d, t);
|
|
2233
|
+
slerp(temp2, b, c, t);
|
|
2234
|
+
slerp(out, temp1, temp2, 2 * t * (1 - t));
|
|
2235
|
+
return out;
|
|
2190
2236
|
};
|
|
2237
|
+
}();
|
|
2238
|
+
/**
|
|
2239
|
+
* Sets the specified quaternion with values corresponding to the given
|
|
2240
|
+
* axes. Each axis is a vec3 and is expected to be unit length and
|
|
2241
|
+
* perpendicular to all other specified axes.
|
|
2242
|
+
*
|
|
2243
|
+
* @param {ReadonlyVec3} view the vector representing the viewing direction
|
|
2244
|
+
* @param {ReadonlyVec3} right the vector representing the local "right" direction
|
|
2245
|
+
* @param {ReadonlyVec3} up the vector representing the local "up" direction
|
|
2246
|
+
* @returns {quat} out
|
|
2247
|
+
*/
|
|
2191
2248
|
|
|
2192
|
-
_proto.generateCacheKey = function generateCacheKey(params) {
|
|
2193
|
-
// @ts-ignore
|
|
2194
|
-
var type = params.type,
|
|
2195
|
-
x0 = params.x0,
|
|
2196
|
-
y0 = params.y0,
|
|
2197
|
-
x1 = params.x1,
|
|
2198
|
-
y1 = params.y1,
|
|
2199
|
-
r1 = params.r1,
|
|
2200
|
-
steps = params.steps,
|
|
2201
|
-
width = params.width,
|
|
2202
|
-
height = params.height;
|
|
2203
|
-
return "gradient-" + type + "-" + x0 + "-" + y0 + "-" + x1 + "-" + y1 + "-" + (r1 || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
|
|
2204
|
-
return step.join('');
|
|
2205
|
-
}).join('-');
|
|
2206
|
-
};
|
|
2207
2249
|
|
|
2208
|
-
|
|
2250
|
+
var setAxes = function () {
|
|
2251
|
+
var matr = create();
|
|
2252
|
+
return function (out, view, right, up) {
|
|
2253
|
+
matr[0] = right[0];
|
|
2254
|
+
matr[3] = right[1];
|
|
2255
|
+
matr[6] = right[2];
|
|
2256
|
+
matr[1] = up[0];
|
|
2257
|
+
matr[4] = up[1];
|
|
2258
|
+
matr[7] = up[2];
|
|
2259
|
+
matr[2] = -view[0];
|
|
2260
|
+
matr[5] = -view[1];
|
|
2261
|
+
matr[8] = -view[2];
|
|
2262
|
+
return normalize$2(out, fromMat3(out, matr));
|
|
2263
|
+
};
|
|
2209
2264
|
}();
|
|
2210
2265
|
|
|
2211
|
-
GradientPool = __decorate([manaSyringe.singleton()], GradientPool);
|
|
2212
|
-
|
|
2213
2266
|
function generatePath(context, parsedStyle) {
|
|
2214
2267
|
var r = parsedStyle.r;
|
|
2215
2268
|
context.arc(r.value, r.value, r.value, 0, Math.PI * 2, false);
|
|
@@ -2295,742 +2348,687 @@
|
|
|
2295
2348
|
context.lineTo(x2.value - defX, y2.value - defY);
|
|
2296
2349
|
}
|
|
2297
2350
|
|
|
2298
|
-
function generatePath$4(context, parsedStyle) {
|
|
2299
|
-
var _parsedStyle$defX = parsedStyle.defX,
|
|
2300
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
2301
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
2302
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
2303
|
-
var points = parsedStyle.points.points;
|
|
2304
|
-
var length = points.length;
|
|
2305
|
-
var x1 = points[0][0] - x;
|
|
2306
|
-
var y1 = points[0][1] - y;
|
|
2307
|
-
var x2 = points[length - 1][0] - x;
|
|
2308
|
-
var y2 = points[length - 1][1] - y;
|
|
2309
|
-
context.moveTo(x1, y1);
|
|
2351
|
+
function generatePath$4(context, parsedStyle) {
|
|
2352
|
+
var _parsedStyle$defX = parsedStyle.defX,
|
|
2353
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
2354
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
2355
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
2356
|
+
var points = parsedStyle.points.points;
|
|
2357
|
+
var length = points.length;
|
|
2358
|
+
var x1 = points[0][0] - x;
|
|
2359
|
+
var y1 = points[0][1] - y;
|
|
2360
|
+
var x2 = points[length - 1][0] - x;
|
|
2361
|
+
var y2 = points[length - 1][1] - y;
|
|
2362
|
+
context.moveTo(x1, y1);
|
|
2363
|
+
|
|
2364
|
+
for (var i = 0; i < length - 1; i++) {
|
|
2365
|
+
var point = points[i];
|
|
2366
|
+
context.lineTo(point[0] - x, point[1] - y);
|
|
2367
|
+
}
|
|
2368
|
+
|
|
2369
|
+
context.lineTo(x2, y2);
|
|
2370
|
+
}
|
|
2371
|
+
|
|
2372
|
+
function generatePath$5(context, parsedStyle) {
|
|
2373
|
+
var _parsedStyle$defX = parsedStyle.defX,
|
|
2374
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
2375
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
2376
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
2377
|
+
var points = parsedStyle.points.points;
|
|
2378
|
+
var length = points.length;
|
|
2379
|
+
var x1 = points[0][0] - x;
|
|
2380
|
+
var y1 = points[0][1] - y;
|
|
2381
|
+
var x2 = points[length - 1][0] - x;
|
|
2382
|
+
var y2 = points[length - 1][1] - y;
|
|
2383
|
+
context.moveTo(x1, y1);
|
|
2384
|
+
|
|
2385
|
+
for (var i = 0; i < length - 1; i++) {
|
|
2386
|
+
var point = points[i];
|
|
2387
|
+
context.lineTo(point[0] - x, point[1] - y);
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
context.lineTo(x2, y2);
|
|
2391
|
+
}
|
|
2392
|
+
|
|
2393
|
+
function generatePath$6(context, parsedStyle) {
|
|
2394
|
+
var _parsedStyle$defX = parsedStyle.defX,
|
|
2395
|
+
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
2396
|
+
_parsedStyle$defY = parsedStyle.defY,
|
|
2397
|
+
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
2398
|
+
var _parsedStyle$path = parsedStyle.path,
|
|
2399
|
+
curve = _parsedStyle$path.curve,
|
|
2400
|
+
zCommandIndexes = _parsedStyle$path.zCommandIndexes;
|
|
2401
|
+
var path = [].concat(curve);
|
|
2402
|
+
zCommandIndexes.forEach(function (zIndex, index) {
|
|
2403
|
+
path.splice(zIndex + index, 1, ['Z']);
|
|
2404
|
+
});
|
|
2405
|
+
|
|
2406
|
+
for (var i = 0; i < path.length; i++) {
|
|
2407
|
+
var params = path[i]; // eg. M 100 200
|
|
2408
|
+
|
|
2409
|
+
var command = params[0]; // V,H,S,T 都在前面被转换成标准形式
|
|
2410
|
+
|
|
2411
|
+
switch (command) {
|
|
2412
|
+
case 'M':
|
|
2413
|
+
context.moveTo(params[1] - x, params[2] - y);
|
|
2414
|
+
break;
|
|
2415
|
+
|
|
2416
|
+
case 'C':
|
|
2417
|
+
context.bezierCurveTo(params[1] - x, params[2] - y, params[3] - x, params[4] - y, params[5] - x, params[6] - y);
|
|
2418
|
+
break;
|
|
2419
|
+
|
|
2420
|
+
case 'Z':
|
|
2421
|
+
context.closePath();
|
|
2422
|
+
break;
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
}
|
|
2426
|
+
|
|
2427
|
+
var PathGeneratorFactory = manaSyringe.Syringe.defineToken('PathGeneratorFactory');
|
|
2428
|
+
var PathGenerator = manaSyringe.Syringe.defineToken('PathGenerator');
|
|
2429
|
+
var StyleRendererFactory = manaSyringe.Syringe.defineToken('StyleRendererFactory');
|
|
2430
|
+
var CircleRendererContribution = manaSyringe.Syringe.defineToken('CircleRenderer', {
|
|
2431
|
+
multiple: false
|
|
2432
|
+
});
|
|
2433
|
+
var EllipseRendererContribution = manaSyringe.Syringe.defineToken('EllipseRenderer', {
|
|
2434
|
+
multiple: false
|
|
2435
|
+
});
|
|
2436
|
+
var RectRendererContribution = manaSyringe.Syringe.defineToken('RectRenderer', {
|
|
2437
|
+
multiple: false
|
|
2438
|
+
});
|
|
2439
|
+
var LineRendererContribution = manaSyringe.Syringe.defineToken('LineRenderer', {
|
|
2440
|
+
multiple: false
|
|
2441
|
+
});
|
|
2442
|
+
var PolylineRendererContribution = manaSyringe.Syringe.defineToken('PolylineRenderer', {
|
|
2443
|
+
multiple: false
|
|
2444
|
+
});
|
|
2445
|
+
var PolygonRendererContribution = manaSyringe.Syringe.defineToken('PolygonRenderer', {
|
|
2446
|
+
multiple: false
|
|
2447
|
+
});
|
|
2448
|
+
var PathRendererContribution = manaSyringe.Syringe.defineToken('PathRenderer', {
|
|
2449
|
+
multiple: false
|
|
2450
|
+
});
|
|
2451
|
+
var TextRendererContribution = manaSyringe.Syringe.defineToken('TextRenderer', {
|
|
2452
|
+
multiple: false
|
|
2453
|
+
});
|
|
2454
|
+
var ImageRendererContribution = manaSyringe.Syringe.defineToken('ImageRenderer', {
|
|
2455
|
+
multiple: false
|
|
2456
|
+
});
|
|
2457
|
+
|
|
2458
|
+
var ImagePool = /*#__PURE__*/function () {
|
|
2459
|
+
function ImagePool() {
|
|
2460
|
+
this.imageCache = {};
|
|
2461
|
+
this.patternCache = {};
|
|
2462
|
+
this.canvasConfig = void 0;
|
|
2463
|
+
}
|
|
2464
|
+
|
|
2465
|
+
var _proto = ImagePool.prototype;
|
|
2466
|
+
|
|
2467
|
+
_proto.getImageSync = function getImageSync(src) {
|
|
2468
|
+
return this.imageCache[src];
|
|
2469
|
+
};
|
|
2470
|
+
|
|
2471
|
+
_proto.getOrCreateImage = function getOrCreateImage(src) {
|
|
2472
|
+
var _this = this;
|
|
2473
|
+
|
|
2474
|
+
if (this.imageCache[src]) {
|
|
2475
|
+
return Promise.resolve(this.imageCache[src]);
|
|
2476
|
+
} // @see https://github.com/antvis/g/issues/938
|
|
2477
|
+
|
|
2478
|
+
|
|
2479
|
+
var createImage = this.canvasConfig.createImage;
|
|
2480
|
+
return new Promise(function (resolve, reject) {
|
|
2481
|
+
var image;
|
|
2482
|
+
|
|
2483
|
+
if (createImage) {
|
|
2484
|
+
image = createImage(src);
|
|
2485
|
+
} else if (g.isBrowser) {
|
|
2486
|
+
image = new window.Image();
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
if (image) {
|
|
2490
|
+
image.onload = function () {
|
|
2491
|
+
resolve(image);
|
|
2492
|
+
};
|
|
2493
|
+
|
|
2494
|
+
image.onerror = function (ev) {
|
|
2495
|
+
reject(ev);
|
|
2496
|
+
};
|
|
2497
|
+
|
|
2498
|
+
image.crossOrigin = 'Anonymous';
|
|
2499
|
+
image.src = src;
|
|
2500
|
+
_this.imageCache[src] = image;
|
|
2501
|
+
}
|
|
2502
|
+
});
|
|
2503
|
+
};
|
|
2504
|
+
|
|
2505
|
+
_proto.getPatternSync = function getPatternSync(pattern) {
|
|
2506
|
+
var patternKey = this.generatePatternKey(pattern);
|
|
2507
|
+
|
|
2508
|
+
if (this.patternCache[patternKey]) {
|
|
2509
|
+
return this.patternCache[patternKey];
|
|
2510
|
+
}
|
|
2511
|
+
};
|
|
2512
|
+
|
|
2513
|
+
_proto.createPattern = function createPattern(patternParams, context) {
|
|
2514
|
+
var _this2 = this;
|
|
2515
|
+
|
|
2516
|
+
return this.getOrCreateImage(patternParams.src).then(function (image) {
|
|
2517
|
+
var patternKey = _this2.generatePatternKey(patternParams); // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
2518
|
+
|
|
2519
|
+
|
|
2520
|
+
var pattern = context.createPattern(image, patternParams.repetition);
|
|
2521
|
+
|
|
2522
|
+
if (pattern) {
|
|
2523
|
+
_this2.patternCache[patternKey] = pattern;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
return _this2.patternCache[patternKey];
|
|
2527
|
+
});
|
|
2528
|
+
};
|
|
2529
|
+
|
|
2530
|
+
_proto.generatePatternKey = function generatePatternKey(pattern) {
|
|
2531
|
+
var src = pattern.src,
|
|
2532
|
+
repetition = pattern.repetition;
|
|
2533
|
+
return "pattern-" + src + "-" + repetition;
|
|
2534
|
+
};
|
|
2310
2535
|
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
context.lineTo(point[0] - x, point[1] - y);
|
|
2314
|
-
}
|
|
2536
|
+
return ImagePool;
|
|
2537
|
+
}();
|
|
2315
2538
|
|
|
2316
|
-
|
|
2317
|
-
}
|
|
2539
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
|
|
2318
2540
|
|
|
2319
|
-
|
|
2320
|
-
var _parsedStyle$defX = parsedStyle.defX,
|
|
2321
|
-
x = _parsedStyle$defX === void 0 ? 0 : _parsedStyle$defX,
|
|
2322
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
2323
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
2324
|
-
var points = parsedStyle.points.points;
|
|
2325
|
-
var length = points.length;
|
|
2326
|
-
var x1 = points[0][0] - x;
|
|
2327
|
-
var y1 = points[0][1] - y;
|
|
2328
|
-
var x2 = points[length - 1][0] - x;
|
|
2329
|
-
var y2 = points[length - 1][1] - y;
|
|
2330
|
-
context.moveTo(x1, y1);
|
|
2541
|
+
ImagePool = __decorate([manaSyringe.singleton()], ImagePool);
|
|
2331
2542
|
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2543
|
+
var ImageRenderer = /*#__PURE__*/function () {
|
|
2544
|
+
function ImageRenderer() {
|
|
2545
|
+
this.imagePool = void 0;
|
|
2335
2546
|
}
|
|
2336
2547
|
|
|
2337
|
-
|
|
2338
|
-
}
|
|
2548
|
+
var _proto = ImageRenderer.prototype;
|
|
2339
2549
|
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
_parsedStyle$defY = parsedStyle.defY,
|
|
2344
|
-
y = _parsedStyle$defY === void 0 ? 0 : _parsedStyle$defY;
|
|
2345
|
-
var _parsedStyle$path = parsedStyle.path,
|
|
2346
|
-
curve = _parsedStyle$path.curve,
|
|
2347
|
-
zCommandIndexes = _parsedStyle$path.zCommandIndexes;
|
|
2348
|
-
var path = [].concat(curve);
|
|
2349
|
-
zCommandIndexes.forEach(function (zIndex, index) {
|
|
2350
|
-
path.splice(zIndex + index, 1, ['Z']);
|
|
2351
|
-
});
|
|
2550
|
+
_proto.hash = function hash(parsedStyle) {
|
|
2551
|
+
return '';
|
|
2552
|
+
};
|
|
2352
2553
|
|
|
2353
|
-
|
|
2354
|
-
var
|
|
2554
|
+
_proto.render = function render(context, parsedStyle) {
|
|
2555
|
+
var width = parsedStyle.width,
|
|
2556
|
+
height = parsedStyle.height,
|
|
2557
|
+
img = parsedStyle.img;
|
|
2558
|
+
var image;
|
|
2559
|
+
var iw = width.value;
|
|
2560
|
+
var ih = height.value;
|
|
2355
2561
|
|
|
2356
|
-
|
|
2562
|
+
if (g.isString(img)) {
|
|
2563
|
+
// image has been loaded in `mounted` hook
|
|
2564
|
+
image = this.imagePool.getImageSync(img);
|
|
2565
|
+
} else {
|
|
2566
|
+
iw || (iw = img.width);
|
|
2567
|
+
ih || (ih = img.height);
|
|
2568
|
+
image = img;
|
|
2569
|
+
}
|
|
2357
2570
|
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2571
|
+
if (image) {
|
|
2572
|
+
// node-canvas will throw the following err:
|
|
2573
|
+
// Error: Image given has not completed loading
|
|
2574
|
+
try {
|
|
2575
|
+
context.drawImage(image, 0, 0, iw, ih);
|
|
2576
|
+
} catch (e) {}
|
|
2577
|
+
}
|
|
2578
|
+
};
|
|
2362
2579
|
|
|
2363
|
-
|
|
2364
|
-
|
|
2365
|
-
break;
|
|
2580
|
+
return ImageRenderer;
|
|
2581
|
+
}();
|
|
2366
2582
|
|
|
2367
|
-
|
|
2368
|
-
context.closePath();
|
|
2369
|
-
break;
|
|
2370
|
-
}
|
|
2371
|
-
}
|
|
2372
|
-
}
|
|
2583
|
+
__decorate([manaSyringe.inject(ImagePool), __metadata("design:type", ImagePool)], ImageRenderer.prototype, "imagePool", void 0);
|
|
2373
2584
|
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
* Common utilities
|
|
2378
|
-
* @module glMatrix
|
|
2379
|
-
*/
|
|
2380
|
-
// Configuration Constants
|
|
2585
|
+
ImageRenderer = __decorate([manaSyringe.singleton({
|
|
2586
|
+
token: ImageRendererContribution
|
|
2587
|
+
})], ImageRenderer);
|
|
2381
2588
|
|
|
2382
|
-
var
|
|
2383
|
-
|
|
2384
|
-
if (!Math.hypot) Math.hypot = function () {
|
|
2385
|
-
var y = 0,
|
|
2386
|
-
i = arguments.length;
|
|
2589
|
+
var TextRenderer = /*#__PURE__*/function () {
|
|
2590
|
+
function TextRenderer() {}
|
|
2387
2591
|
|
|
2388
|
-
|
|
2389
|
-
y += arguments[i] * arguments[i];
|
|
2390
|
-
}
|
|
2592
|
+
var _proto = TextRenderer.prototype;
|
|
2391
2593
|
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
* 3x3 Matrix
|
|
2396
|
-
* @module mat3
|
|
2397
|
-
*/
|
|
2594
|
+
_proto.hash = function hash(parsedStyle) {
|
|
2595
|
+
return '';
|
|
2596
|
+
};
|
|
2398
2597
|
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2598
|
+
_proto.render = function render(context, parsedStyle, object) {
|
|
2599
|
+
var lineWidth = parsedStyle.lineWidth,
|
|
2600
|
+
textAlign = parsedStyle.textAlign,
|
|
2601
|
+
textBaseline = parsedStyle.textBaseline,
|
|
2602
|
+
lineJoin = parsedStyle.lineJoin,
|
|
2603
|
+
_parsedStyle$miterLim = parsedStyle.miterLimit,
|
|
2604
|
+
miterLimit = _parsedStyle$miterLim === void 0 ? 0 : _parsedStyle$miterLim,
|
|
2605
|
+
_parsedStyle$letterSp = parsedStyle.letterSpacing,
|
|
2606
|
+
letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
|
|
2607
|
+
stroke = parsedStyle.stroke,
|
|
2608
|
+
fill = parsedStyle.fill,
|
|
2609
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
2610
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
2611
|
+
opacity = parsedStyle.opacity,
|
|
2612
|
+
metrics = parsedStyle.metrics,
|
|
2613
|
+
dx = parsedStyle.dx,
|
|
2614
|
+
dy = parsedStyle.dy;
|
|
2615
|
+
var font = metrics.font,
|
|
2616
|
+
lines = metrics.lines,
|
|
2617
|
+
height = metrics.height,
|
|
2618
|
+
lineHeight = metrics.lineHeight,
|
|
2619
|
+
lineMetrics = metrics.lineMetrics;
|
|
2620
|
+
context.font = font;
|
|
2621
|
+
context.lineWidth = lineWidth.value;
|
|
2622
|
+
context.textAlign = textAlign.value;
|
|
2623
|
+
context.textBaseline = textBaseline.value;
|
|
2624
|
+
context.lineJoin = lineJoin.value;
|
|
2625
|
+
context.miterLimit = miterLimit;
|
|
2626
|
+
var linePositionY = 0; // handle vertical text baseline
|
|
2404
2627
|
|
|
2405
|
-
|
|
2406
|
-
|
|
2628
|
+
if (textBaseline.value === 'middle') {
|
|
2629
|
+
linePositionY = -height / 2 - lineHeight / 2;
|
|
2630
|
+
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
2631
|
+
linePositionY = -height;
|
|
2632
|
+
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
2633
|
+
linePositionY = -lineHeight;
|
|
2634
|
+
} // account for dx & dy
|
|
2407
2635
|
|
|
2408
|
-
if (ARRAY_TYPE != Float32Array) {
|
|
2409
|
-
out[1] = 0;
|
|
2410
|
-
out[2] = 0;
|
|
2411
|
-
out[3] = 0;
|
|
2412
|
-
out[5] = 0;
|
|
2413
|
-
out[6] = 0;
|
|
2414
|
-
out[7] = 0;
|
|
2415
|
-
}
|
|
2416
2636
|
|
|
2417
|
-
|
|
2418
|
-
out[4] = 1;
|
|
2419
|
-
out[8] = 1;
|
|
2420
|
-
return out;
|
|
2421
|
-
}
|
|
2422
|
-
/**
|
|
2423
|
-
* Returns the translation vector component of a transformation
|
|
2424
|
-
* matrix. If a matrix is built with fromRotationTranslation,
|
|
2425
|
-
* the returned vector will be the same as the translation vector
|
|
2426
|
-
* originally supplied.
|
|
2427
|
-
* @param {vec3} out Vector to receive translation component
|
|
2428
|
-
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
2429
|
-
* @return {vec3} out
|
|
2430
|
-
*/
|
|
2637
|
+
var offsetX = 0;
|
|
2431
2638
|
|
|
2639
|
+
if (dx && dx.unit === g.UnitType.kPixels) {
|
|
2640
|
+
offsetX += dx.value;
|
|
2641
|
+
}
|
|
2432
2642
|
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
out[2] = mat[14];
|
|
2437
|
-
return out;
|
|
2438
|
-
}
|
|
2439
|
-
/**
|
|
2440
|
-
* Returns the scaling factor component of a transformation
|
|
2441
|
-
* matrix. If a matrix is built with fromRotationTranslationScale
|
|
2442
|
-
* with a normalized Quaternion paramter, the returned vector will be
|
|
2443
|
-
* the same as the scaling vector
|
|
2444
|
-
* originally supplied.
|
|
2445
|
-
* @param {vec3} out Vector to receive scaling factor component
|
|
2446
|
-
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
2447
|
-
* @return {vec3} out
|
|
2448
|
-
*/
|
|
2643
|
+
if (dy && dy.unit === g.UnitType.kPixels) {
|
|
2644
|
+
linePositionY += dy.value;
|
|
2645
|
+
} // draw lines line by line
|
|
2449
2646
|
|
|
2450
2647
|
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
}
|
|
2466
|
-
/**
|
|
2467
|
-
* Returns a quaternion representing the rotational component
|
|
2468
|
-
* of a transformation matrix. If a matrix is built with
|
|
2469
|
-
* fromRotationTranslation, the returned quaternion will be the
|
|
2470
|
-
* same as the quaternion originally supplied.
|
|
2471
|
-
* @param {quat} out Quaternion to receive the rotation component
|
|
2472
|
-
* @param {ReadonlyMat4} mat Matrix to be decomposed (input)
|
|
2473
|
-
* @return {quat} out
|
|
2474
|
-
*/
|
|
2648
|
+
for (var i = 0; i < lines.length; i++) {
|
|
2649
|
+
var linePositionX = lineWidth.value / 2 + offsetX;
|
|
2650
|
+
linePositionY += lineHeight; // no need to re-position X, cause we already set text align
|
|
2651
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
|
|
2652
|
+
|
|
2653
|
+
if (!g.isNil(stroke) && lineWidth && lineWidth.value) {
|
|
2654
|
+
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
|
|
2655
|
+
}
|
|
2656
|
+
|
|
2657
|
+
if (!g.isNil(fill)) {
|
|
2658
|
+
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value);
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
};
|
|
2475
2662
|
|
|
2663
|
+
_proto.drawLetterSpacing = function drawLetterSpacing(context, text, lineMetrics, textAlign, x, y, letterSpacing, fillOpacity, strokeOpacity, opacity, isStroke) {
|
|
2664
|
+
if (isStroke === void 0) {
|
|
2665
|
+
isStroke = false;
|
|
2666
|
+
} // letterSpacing of 0 means normal, render all texts directly
|
|
2476
2667
|
|
|
2477
|
-
function getRotation(out, mat) {
|
|
2478
|
-
var scaling = new ARRAY_TYPE(3);
|
|
2479
|
-
getScaling(scaling, mat);
|
|
2480
|
-
var is1 = 1 / scaling[0];
|
|
2481
|
-
var is2 = 1 / scaling[1];
|
|
2482
|
-
var is3 = 1 / scaling[2];
|
|
2483
|
-
var sm11 = mat[0] * is1;
|
|
2484
|
-
var sm12 = mat[1] * is2;
|
|
2485
|
-
var sm13 = mat[2] * is3;
|
|
2486
|
-
var sm21 = mat[4] * is1;
|
|
2487
|
-
var sm22 = mat[5] * is2;
|
|
2488
|
-
var sm23 = mat[6] * is3;
|
|
2489
|
-
var sm31 = mat[8] * is1;
|
|
2490
|
-
var sm32 = mat[9] * is2;
|
|
2491
|
-
var sm33 = mat[10] * is3;
|
|
2492
|
-
var trace = sm11 + sm22 + sm33;
|
|
2493
|
-
var S = 0;
|
|
2494
2668
|
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
} else if (sm11 > sm22 && sm11 > sm33) {
|
|
2502
|
-
S = Math.sqrt(1.0 + sm11 - sm22 - sm33) * 2;
|
|
2503
|
-
out[3] = (sm23 - sm32) / S;
|
|
2504
|
-
out[0] = 0.25 * S;
|
|
2505
|
-
out[1] = (sm12 + sm21) / S;
|
|
2506
|
-
out[2] = (sm31 + sm13) / S;
|
|
2507
|
-
} else if (sm22 > sm33) {
|
|
2508
|
-
S = Math.sqrt(1.0 + sm22 - sm11 - sm33) * 2;
|
|
2509
|
-
out[3] = (sm31 - sm13) / S;
|
|
2510
|
-
out[0] = (sm12 + sm21) / S;
|
|
2511
|
-
out[1] = 0.25 * S;
|
|
2512
|
-
out[2] = (sm23 + sm32) / S;
|
|
2513
|
-
} else {
|
|
2514
|
-
S = Math.sqrt(1.0 + sm33 - sm11 - sm22) * 2;
|
|
2515
|
-
out[3] = (sm12 - sm21) / S;
|
|
2516
|
-
out[0] = (sm31 + sm13) / S;
|
|
2517
|
-
out[1] = (sm23 + sm32) / S;
|
|
2518
|
-
out[2] = 0.25 * S;
|
|
2519
|
-
}
|
|
2669
|
+
if (letterSpacing === 0) {
|
|
2670
|
+
if (isStroke) {
|
|
2671
|
+
this.strokeText(context, text, x, y, strokeOpacity);
|
|
2672
|
+
} else {
|
|
2673
|
+
this.fillText(context, text, x, y, fillOpacity, opacity);
|
|
2674
|
+
}
|
|
2520
2675
|
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
/**
|
|
2524
|
-
* 3 Dimensional Vector
|
|
2525
|
-
* @module vec3
|
|
2526
|
-
*/
|
|
2676
|
+
return;
|
|
2677
|
+
} // draw text using left align
|
|
2527
2678
|
|
|
2528
|
-
/**
|
|
2529
|
-
* Creates a new, empty vec3
|
|
2530
|
-
*
|
|
2531
|
-
* @returns {vec3} a new 3D vector
|
|
2532
|
-
*/
|
|
2533
2679
|
|
|
2680
|
+
var currentTextAlign = context.textAlign;
|
|
2681
|
+
context.textAlign = 'left';
|
|
2682
|
+
var currentPosition = x;
|
|
2534
2683
|
|
|
2535
|
-
|
|
2536
|
-
|
|
2684
|
+
if (textAlign === 'center') {
|
|
2685
|
+
currentPosition = x - lineMetrics.width / 2;
|
|
2686
|
+
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
2687
|
+
currentPosition = x - lineMetrics.width;
|
|
2688
|
+
}
|
|
2537
2689
|
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
out[2] = 0;
|
|
2542
|
-
}
|
|
2690
|
+
var stringArray = Array.from(text);
|
|
2691
|
+
var previousWidth = context.measureText(text).width;
|
|
2692
|
+
var currentWidth = 0;
|
|
2543
2693
|
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
/**
|
|
2547
|
-
* Calculates the length of a vec3
|
|
2548
|
-
*
|
|
2549
|
-
* @param {ReadonlyVec3} a vector to calculate length of
|
|
2550
|
-
* @returns {Number} length of a
|
|
2551
|
-
*/
|
|
2694
|
+
for (var i = 0; i < stringArray.length; ++i) {
|
|
2695
|
+
var currentChar = stringArray[i];
|
|
2552
2696
|
|
|
2697
|
+
if (isStroke) {
|
|
2698
|
+
this.strokeText(context, currentChar, currentPosition, y, strokeOpacity);
|
|
2699
|
+
} else {
|
|
2700
|
+
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
2701
|
+
}
|
|
2553
2702
|
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
return Math.hypot(x, y, z);
|
|
2559
|
-
}
|
|
2560
|
-
/**
|
|
2561
|
-
* Creates a new vec3 initialized with the given values
|
|
2562
|
-
*
|
|
2563
|
-
* @param {Number} x X component
|
|
2564
|
-
* @param {Number} y Y component
|
|
2565
|
-
* @param {Number} z Z component
|
|
2566
|
-
* @returns {vec3} a new 3D vector
|
|
2567
|
-
*/
|
|
2703
|
+
currentWidth = context.measureText(text.substring(i + 1)).width;
|
|
2704
|
+
currentPosition += previousWidth - currentWidth + letterSpacing;
|
|
2705
|
+
previousWidth = currentWidth;
|
|
2706
|
+
}
|
|
2568
2707
|
|
|
2708
|
+
context.textAlign = currentTextAlign;
|
|
2709
|
+
};
|
|
2569
2710
|
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
out[1] = y;
|
|
2574
|
-
out[2] = z;
|
|
2575
|
-
return out;
|
|
2576
|
-
}
|
|
2577
|
-
/**
|
|
2578
|
-
* Normalize a vec3
|
|
2579
|
-
*
|
|
2580
|
-
* @param {vec3} out the receiving vector
|
|
2581
|
-
* @param {ReadonlyVec3} a vector to normalize
|
|
2582
|
-
* @returns {vec3} out
|
|
2583
|
-
*/
|
|
2711
|
+
_proto.fillText = function fillText(context, text, x, y, fillOpacity, opacity) {
|
|
2712
|
+
var currentGlobalAlpha;
|
|
2713
|
+
var applyOpacity = !g.isNil(fillOpacity) && fillOpacity !== 1;
|
|
2584
2714
|
|
|
2715
|
+
if (applyOpacity) {
|
|
2716
|
+
currentGlobalAlpha = context.globalAlpha;
|
|
2717
|
+
context.globalAlpha = fillOpacity * opacity;
|
|
2718
|
+
}
|
|
2585
2719
|
|
|
2586
|
-
|
|
2587
|
-
var x = a[0];
|
|
2588
|
-
var y = a[1];
|
|
2589
|
-
var z = a[2];
|
|
2590
|
-
var len = x * x + y * y + z * z;
|
|
2720
|
+
context.fillText(text, x, y);
|
|
2591
2721
|
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
}
|
|
2722
|
+
if (applyOpacity) {
|
|
2723
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
2724
|
+
}
|
|
2725
|
+
};
|
|
2596
2726
|
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
* @param {ReadonlyVec3} a the first operand
|
|
2606
|
-
* @param {ReadonlyVec3} b the second operand
|
|
2607
|
-
* @returns {Number} dot product of a and b
|
|
2608
|
-
*/
|
|
2727
|
+
_proto.strokeText = function strokeText(context, text, x, y, strokeOpacity) {
|
|
2728
|
+
var currentGlobalAlpha;
|
|
2729
|
+
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity !== 1;
|
|
2730
|
+
|
|
2731
|
+
if (applyOpacity) {
|
|
2732
|
+
currentGlobalAlpha = context.globalAlpha;
|
|
2733
|
+
context.globalAlpha = strokeOpacity;
|
|
2734
|
+
}
|
|
2609
2735
|
|
|
2736
|
+
context.strokeText(text, x, y);
|
|
2610
2737
|
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
* Computes the cross product of two vec3's
|
|
2616
|
-
*
|
|
2617
|
-
* @param {vec3} out the receiving vector
|
|
2618
|
-
* @param {ReadonlyVec3} a the first operand
|
|
2619
|
-
* @param {ReadonlyVec3} b the second operand
|
|
2620
|
-
* @returns {vec3} out
|
|
2621
|
-
*/
|
|
2738
|
+
if (applyOpacity) {
|
|
2739
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
2740
|
+
}
|
|
2741
|
+
};
|
|
2622
2742
|
|
|
2743
|
+
return TextRenderer;
|
|
2744
|
+
}();
|
|
2623
2745
|
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
az = a[2];
|
|
2628
|
-
var bx = b[0],
|
|
2629
|
-
by = b[1],
|
|
2630
|
-
bz = b[2];
|
|
2631
|
-
out[0] = ay * bz - az * by;
|
|
2632
|
-
out[1] = az * bx - ax * bz;
|
|
2633
|
-
out[2] = ax * by - ay * bx;
|
|
2634
|
-
return out;
|
|
2635
|
-
}
|
|
2636
|
-
/**
|
|
2637
|
-
* Alias for {@link vec3.length}
|
|
2638
|
-
* @function
|
|
2639
|
-
*/
|
|
2746
|
+
TextRenderer = __decorate([manaSyringe.singleton({
|
|
2747
|
+
token: TextRendererContribution
|
|
2748
|
+
})], TextRenderer);
|
|
2640
2749
|
|
|
2750
|
+
var DefaultRenderer = /*#__PURE__*/function () {
|
|
2751
|
+
function DefaultRenderer() {}
|
|
2641
2752
|
|
|
2642
|
-
|
|
2643
|
-
/**
|
|
2644
|
-
* Perform some operation over an array of vec3s.
|
|
2645
|
-
*
|
|
2646
|
-
* @param {Array} a the array of vectors to iterate over
|
|
2647
|
-
* @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
|
|
2648
|
-
* @param {Number} offset Number of elements to skip at the beginning of the array
|
|
2649
|
-
* @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
|
|
2650
|
-
* @param {Function} fn Function to call for each vector in the array
|
|
2651
|
-
* @param {Object} [arg] additional argument to pass to fn
|
|
2652
|
-
* @returns {Array} a
|
|
2653
|
-
* @function
|
|
2654
|
-
*/
|
|
2753
|
+
var _proto = DefaultRenderer.prototype;
|
|
2655
2754
|
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2755
|
+
_proto.hash = function hash(parsedStyle) {
|
|
2756
|
+
// const { fill, opacity, fillOpacity, stroke, strokeOpacity, lineWidth, lineCap, lineJoin } =
|
|
2757
|
+
// parsedStyle;
|
|
2758
|
+
// return fill + opacity + fillOpacity + stroke + strokeOpacity + lineWidth + lineCap + lineJoin;
|
|
2759
|
+
return '';
|
|
2760
|
+
};
|
|
2660
2761
|
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2762
|
+
_proto.render = function render(context, parsedStyle) {
|
|
2763
|
+
var fill = parsedStyle.fill,
|
|
2764
|
+
opacity = parsedStyle.opacity,
|
|
2765
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
2766
|
+
stroke = parsedStyle.stroke,
|
|
2767
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
2768
|
+
lineWidth = parsedStyle.lineWidth,
|
|
2769
|
+
lineCap = parsedStyle.lineCap,
|
|
2770
|
+
lineJoin = parsedStyle.lineJoin,
|
|
2771
|
+
shadowColor = parsedStyle.shadowColor,
|
|
2772
|
+
filter = parsedStyle.filter,
|
|
2773
|
+
miterLimit = parsedStyle.miterLimit;
|
|
2774
|
+
var hasFill = !g.isNil(fill);
|
|
2775
|
+
var hasStroke = !g.isNil(stroke);
|
|
2776
|
+
var isFillTransparent = fill.alpha === 0;
|
|
2664
2777
|
|
|
2665
|
-
if (
|
|
2666
|
-
|
|
2778
|
+
if (hasFill) {
|
|
2779
|
+
if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
|
|
2780
|
+
context.globalAlpha = fillOpacity.value;
|
|
2781
|
+
context.fill();
|
|
2782
|
+
context.globalAlpha = opacity.value;
|
|
2783
|
+
} else {
|
|
2784
|
+
context.fill();
|
|
2785
|
+
}
|
|
2667
2786
|
}
|
|
2668
2787
|
|
|
2669
|
-
if (
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
l = a.length;
|
|
2673
|
-
}
|
|
2788
|
+
if (hasStroke) {
|
|
2789
|
+
if (lineWidth && lineWidth.value > 0) {
|
|
2790
|
+
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
|
|
2674
2791
|
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
vec[2] = a[i + 2];
|
|
2679
|
-
fn(vec, vec, arg);
|
|
2680
|
-
a[i] = vec[0];
|
|
2681
|
-
a[i + 1] = vec[1];
|
|
2682
|
-
a[i + 2] = vec[2];
|
|
2683
|
-
}
|
|
2792
|
+
if (applyOpacity) {
|
|
2793
|
+
context.globalAlpha = strokeOpacity.value;
|
|
2794
|
+
}
|
|
2684
2795
|
|
|
2685
|
-
|
|
2686
|
-
};
|
|
2687
|
-
}();
|
|
2688
|
-
/**
|
|
2689
|
-
* 4 Dimensional Vector
|
|
2690
|
-
* @module vec4
|
|
2691
|
-
*/
|
|
2796
|
+
context.lineWidth = lineWidth.value;
|
|
2692
2797
|
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
* @returns {vec4} a new 4D vector
|
|
2697
|
-
*/
|
|
2798
|
+
if (!g.isNil(miterLimit)) {
|
|
2799
|
+
context.miterLimit = miterLimit;
|
|
2800
|
+
}
|
|
2698
2801
|
|
|
2802
|
+
if (!g.isNil(lineCap)) {
|
|
2803
|
+
context.lineCap = lineCap.value;
|
|
2804
|
+
}
|
|
2699
2805
|
|
|
2700
|
-
|
|
2701
|
-
|
|
2806
|
+
if (!g.isNil(lineJoin)) {
|
|
2807
|
+
context.lineJoin = lineJoin.value;
|
|
2808
|
+
}
|
|
2702
2809
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
}
|
|
2810
|
+
var oldShadowBlur;
|
|
2811
|
+
var oldShadowColor;
|
|
2812
|
+
var oldFilter;
|
|
2813
|
+
var hasShadowColor = !g.isNil(shadowColor);
|
|
2814
|
+
var hasFilter = !g.isNil(filter);
|
|
2709
2815
|
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
* @param {vec4} out the receiving vector
|
|
2716
|
-
* @param {ReadonlyVec4} a vector to normalize
|
|
2717
|
-
* @returns {vec4} out
|
|
2718
|
-
*/
|
|
2816
|
+
if (hasShadowColor) {
|
|
2817
|
+
// prevent inner shadow when drawing stroke, toggle shadowBlur & filter(drop-shadow)
|
|
2818
|
+
// save shadow blur
|
|
2819
|
+
oldShadowBlur = context.shadowBlur;
|
|
2820
|
+
oldShadowColor = context.shadowColor;
|
|
2719
2821
|
|
|
2822
|
+
if (!g.isNil(oldShadowBlur)) {
|
|
2823
|
+
context.shadowColor = 'transparent';
|
|
2824
|
+
context.shadowBlur = 0;
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2720
2827
|
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
var z = a[2];
|
|
2725
|
-
var w = a[3];
|
|
2726
|
-
var len = x * x + y * y + z * z + w * w;
|
|
2828
|
+
if (hasFilter) {
|
|
2829
|
+
// save drop-shadow filter
|
|
2830
|
+
oldFilter = context.filter;
|
|
2727
2831
|
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2832
|
+
if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
|
|
2833
|
+
context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2731
2836
|
|
|
2732
|
-
|
|
2733
|
-
out[1] = y * len;
|
|
2734
|
-
out[2] = z * len;
|
|
2735
|
-
out[3] = w * len;
|
|
2736
|
-
return out;
|
|
2737
|
-
}
|
|
2738
|
-
/**
|
|
2739
|
-
* Perform some operation over an array of vec4s.
|
|
2740
|
-
*
|
|
2741
|
-
* @param {Array} a the array of vectors to iterate over
|
|
2742
|
-
* @param {Number} stride Number of elements between the start of each vec4. If 0 assumes tightly packed
|
|
2743
|
-
* @param {Number} offset Number of elements to skip at the beginning of the array
|
|
2744
|
-
* @param {Number} count Number of vec4s to iterate over. If 0 iterates over entire array
|
|
2745
|
-
* @param {Function} fn Function to call for each vector in the array
|
|
2746
|
-
* @param {Object} [arg] additional argument to pass to fn
|
|
2747
|
-
* @returns {Array} a
|
|
2748
|
-
* @function
|
|
2749
|
-
*/
|
|
2837
|
+
var drawStroke = hasFill && !isFillTransparent;
|
|
2750
2838
|
|
|
2839
|
+
if (drawStroke) {
|
|
2840
|
+
context.stroke();
|
|
2841
|
+
} // restore shadow blur
|
|
2751
2842
|
|
|
2752
|
-
var forEach$1 = function () {
|
|
2753
|
-
var vec = create$2();
|
|
2754
|
-
return function (a, stride, offset, count, fn, arg) {
|
|
2755
|
-
var i, l;
|
|
2756
2843
|
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2844
|
+
if (hasShadowColor) {
|
|
2845
|
+
context.shadowColor = oldShadowColor;
|
|
2846
|
+
context.shadowBlur = oldShadowBlur;
|
|
2847
|
+
} // restore filters
|
|
2760
2848
|
|
|
2761
|
-
if (!offset) {
|
|
2762
|
-
offset = 0;
|
|
2763
|
-
}
|
|
2764
2849
|
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
l = a.length;
|
|
2769
|
-
}
|
|
2850
|
+
if (hasFilter) {
|
|
2851
|
+
context.filter = oldFilter;
|
|
2852
|
+
}
|
|
2770
2853
|
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
vec[3] = a[i + 3];
|
|
2776
|
-
fn(vec, vec, arg);
|
|
2777
|
-
a[i] = vec[0];
|
|
2778
|
-
a[i + 1] = vec[1];
|
|
2779
|
-
a[i + 2] = vec[2];
|
|
2780
|
-
a[i + 3] = vec[3];
|
|
2854
|
+
if (!drawStroke) {
|
|
2855
|
+
context.stroke();
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2781
2858
|
}
|
|
2782
|
-
|
|
2783
|
-
return a;
|
|
2784
2859
|
};
|
|
2860
|
+
|
|
2861
|
+
return DefaultRenderer;
|
|
2785
2862
|
}();
|
|
2786
|
-
/**
|
|
2787
|
-
* Quaternion
|
|
2788
|
-
* @module quat
|
|
2789
|
-
*/
|
|
2790
2863
|
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
*/
|
|
2864
|
+
DefaultRenderer = __decorate([manaSyringe.singleton()], DefaultRenderer);
|
|
2865
|
+
|
|
2866
|
+
var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2867
|
+
_inheritsLoose$1(RectRenderer, _DefaultRenderer);
|
|
2796
2868
|
|
|
2869
|
+
function RectRenderer() {
|
|
2870
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2871
|
+
}
|
|
2797
2872
|
|
|
2798
|
-
|
|
2799
|
-
|
|
2873
|
+
return RectRenderer;
|
|
2874
|
+
}(DefaultRenderer);
|
|
2800
2875
|
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2804
|
-
|
|
2876
|
+
RectRenderer = __decorate([manaSyringe.singleton({
|
|
2877
|
+
token: RectRendererContribution
|
|
2878
|
+
})], RectRenderer);
|
|
2879
|
+
|
|
2880
|
+
var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2881
|
+
_inheritsLoose$1(CircleRenderer, _DefaultRenderer);
|
|
2882
|
+
|
|
2883
|
+
function CircleRenderer() {
|
|
2884
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2805
2885
|
}
|
|
2806
2886
|
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
}
|
|
2810
|
-
/**
|
|
2811
|
-
* Sets a quat from the given angle and rotation axis,
|
|
2812
|
-
* then returns it.
|
|
2813
|
-
*
|
|
2814
|
-
* @param {quat} out the receiving quaternion
|
|
2815
|
-
* @param {ReadonlyVec3} axis the axis around which to rotate
|
|
2816
|
-
* @param {Number} rad the angle in radians
|
|
2817
|
-
* @returns {quat} out
|
|
2818
|
-
**/
|
|
2887
|
+
return CircleRenderer;
|
|
2888
|
+
}(DefaultRenderer);
|
|
2819
2889
|
|
|
2890
|
+
CircleRenderer = __decorate([manaSyringe.singleton({
|
|
2891
|
+
token: CircleRendererContribution
|
|
2892
|
+
})], CircleRenderer);
|
|
2820
2893
|
|
|
2821
|
-
function
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
return
|
|
2829
|
-
}
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2894
|
+
var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2895
|
+
_inheritsLoose$1(EllipseRenderer, _DefaultRenderer);
|
|
2896
|
+
|
|
2897
|
+
function EllipseRenderer() {
|
|
2898
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2899
|
+
}
|
|
2900
|
+
|
|
2901
|
+
return EllipseRenderer;
|
|
2902
|
+
}(DefaultRenderer);
|
|
2903
|
+
|
|
2904
|
+
EllipseRenderer = __decorate([manaSyringe.singleton({
|
|
2905
|
+
token: EllipseRendererContribution
|
|
2906
|
+
})], EllipseRenderer);
|
|
2907
|
+
|
|
2908
|
+
var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2909
|
+
_inheritsLoose$1(LineRenderer, _DefaultRenderer);
|
|
2910
|
+
|
|
2911
|
+
function LineRenderer() {
|
|
2912
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
return LineRenderer;
|
|
2916
|
+
}(DefaultRenderer);
|
|
2839
2917
|
|
|
2918
|
+
LineRenderer = __decorate([manaSyringe.singleton({
|
|
2919
|
+
token: LineRendererContribution
|
|
2920
|
+
})], LineRenderer);
|
|
2840
2921
|
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
// http://jsperf.com/quaternion-slerp-implementations
|
|
2844
|
-
var ax = a[0],
|
|
2845
|
-
ay = a[1],
|
|
2846
|
-
az = a[2],
|
|
2847
|
-
aw = a[3];
|
|
2848
|
-
var bx = b[0],
|
|
2849
|
-
by = b[1],
|
|
2850
|
-
bz = b[2],
|
|
2851
|
-
bw = b[3];
|
|
2852
|
-
var omega, cosom, sinom, scale0, scale1; // calc cosine
|
|
2922
|
+
var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2923
|
+
_inheritsLoose$1(PolylineRenderer, _DefaultRenderer);
|
|
2853
2924
|
|
|
2854
|
-
|
|
2925
|
+
function PolylineRenderer() {
|
|
2926
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2927
|
+
}
|
|
2855
2928
|
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
bx = -bx;
|
|
2859
|
-
by = -by;
|
|
2860
|
-
bz = -bz;
|
|
2861
|
-
bw = -bw;
|
|
2862
|
-
} // calculate coefficients
|
|
2929
|
+
return PolylineRenderer;
|
|
2930
|
+
}(DefaultRenderer);
|
|
2863
2931
|
|
|
2932
|
+
PolylineRenderer = __decorate([manaSyringe.singleton({
|
|
2933
|
+
token: PolylineRendererContribution
|
|
2934
|
+
})], PolylineRenderer);
|
|
2864
2935
|
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
omega = Math.acos(cosom);
|
|
2868
|
-
sinom = Math.sin(omega);
|
|
2869
|
-
scale0 = Math.sin((1.0 - t) * omega) / sinom;
|
|
2870
|
-
scale1 = Math.sin(t * omega) / sinom;
|
|
2871
|
-
} else {
|
|
2872
|
-
// "from" and "to" quaternions are very close
|
|
2873
|
-
// ... so we can do a linear interpolation
|
|
2874
|
-
scale0 = 1.0 - t;
|
|
2875
|
-
scale1 = t;
|
|
2876
|
-
} // calculate final values
|
|
2936
|
+
var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2937
|
+
_inheritsLoose$1(PolygonRenderer, _DefaultRenderer);
|
|
2877
2938
|
|
|
2939
|
+
function PolygonRenderer() {
|
|
2940
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2941
|
+
}
|
|
2878
2942
|
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
out[2] = scale0 * az + scale1 * bz;
|
|
2882
|
-
out[3] = scale0 * aw + scale1 * bw;
|
|
2883
|
-
return out;
|
|
2884
|
-
}
|
|
2885
|
-
/**
|
|
2886
|
-
* Creates a quaternion from the given 3x3 rotation matrix.
|
|
2887
|
-
*
|
|
2888
|
-
* NOTE: The resultant quaternion is not normalized, so you should be sure
|
|
2889
|
-
* to renormalize the quaternion yourself where necessary.
|
|
2890
|
-
*
|
|
2891
|
-
* @param {quat} out the receiving quaternion
|
|
2892
|
-
* @param {ReadonlyMat3} m rotation matrix
|
|
2893
|
-
* @returns {quat} out
|
|
2894
|
-
* @function
|
|
2895
|
-
*/
|
|
2943
|
+
return PolygonRenderer;
|
|
2944
|
+
}(DefaultRenderer);
|
|
2896
2945
|
|
|
2946
|
+
PolygonRenderer = __decorate([manaSyringe.singleton({
|
|
2947
|
+
token: PolygonRendererContribution
|
|
2948
|
+
})], PolygonRenderer);
|
|
2897
2949
|
|
|
2898
|
-
function
|
|
2899
|
-
|
|
2900
|
-
// article "Quaternion Calculus and Fast Animation".
|
|
2901
|
-
var fTrace = m[0] + m[4] + m[8];
|
|
2902
|
-
var fRoot;
|
|
2950
|
+
var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2951
|
+
_inheritsLoose$1(PathRenderer, _DefaultRenderer);
|
|
2903
2952
|
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2953
|
+
function PathRenderer() {
|
|
2954
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2955
|
+
}
|
|
2907
2956
|
|
|
2908
|
-
|
|
2909
|
-
|
|
2957
|
+
return PathRenderer;
|
|
2958
|
+
}(DefaultRenderer);
|
|
2910
2959
|
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
if (m[8] > m[i * 3 + i]) i = 2;
|
|
2919
|
-
var j = (i + 1) % 3;
|
|
2920
|
-
var k = (i + 2) % 3;
|
|
2921
|
-
fRoot = Math.sqrt(m[i * 3 + i] - m[j * 3 + j] - m[k * 3 + k] + 1.0);
|
|
2922
|
-
out[i] = 0.5 * fRoot;
|
|
2923
|
-
fRoot = 0.5 / fRoot;
|
|
2924
|
-
out[3] = (m[j * 3 + k] - m[k * 3 + j]) * fRoot;
|
|
2925
|
-
out[j] = (m[j * 3 + i] + m[i * 3 + j]) * fRoot;
|
|
2926
|
-
out[k] = (m[k * 3 + i] + m[i * 3 + k]) * fRoot;
|
|
2960
|
+
PathRenderer = __decorate([manaSyringe.singleton({
|
|
2961
|
+
token: PathRendererContribution
|
|
2962
|
+
})], PathRenderer);
|
|
2963
|
+
|
|
2964
|
+
var GradientPool = /*#__PURE__*/function () {
|
|
2965
|
+
function GradientPool() {
|
|
2966
|
+
this.gradientCache = {};
|
|
2927
2967
|
}
|
|
2928
2968
|
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2969
|
+
var _proto = GradientPool.prototype;
|
|
2970
|
+
|
|
2971
|
+
_proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
|
|
2972
|
+
var key = this.generateCacheKey(params);
|
|
2973
|
+
var type = params.type,
|
|
2974
|
+
x0 = params.x0,
|
|
2975
|
+
y0 = params.y0,
|
|
2976
|
+
x1 = params.x1,
|
|
2977
|
+
y1 = params.y1,
|
|
2978
|
+
steps = params.steps,
|
|
2979
|
+
width = params.width,
|
|
2980
|
+
height = params.height;
|
|
2939
2981
|
|
|
2982
|
+
if (this.gradientCache[key]) {
|
|
2983
|
+
return this.gradientCache[key];
|
|
2984
|
+
}
|
|
2940
2985
|
|
|
2941
|
-
|
|
2942
|
-
/**
|
|
2943
|
-
* Sets a quaternion to represent the shortest rotation from one
|
|
2944
|
-
* vector to another.
|
|
2945
|
-
*
|
|
2946
|
-
* Both vectors are assumed to be unit length.
|
|
2947
|
-
*
|
|
2948
|
-
* @param {quat} out the receiving quaternion.
|
|
2949
|
-
* @param {ReadonlyVec3} a the initial vector
|
|
2950
|
-
* @param {ReadonlyVec3} b the destination vector
|
|
2951
|
-
* @returns {quat} out
|
|
2952
|
-
*/
|
|
2986
|
+
var gradient = null;
|
|
2953
2987
|
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
var dot$1 = dot(a, b);
|
|
2988
|
+
if (type === g.GradientPatternType.LinearGradient) {
|
|
2989
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
2990
|
+
gradient = context.createLinearGradient(x0 * width, y0 * height, x1 * width, y1 * height);
|
|
2991
|
+
} else if (type === g.GradientPatternType.RadialGradient) {
|
|
2992
|
+
var r = Math.sqrt(width * width + height * height) / 2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
2960
2993
|
|
|
2961
|
-
|
|
2962
|
-
cross(tmpvec3, xUnitVec3, a);
|
|
2963
|
-
if (len(tmpvec3) < 0.000001) cross(tmpvec3, yUnitVec3, a);
|
|
2964
|
-
normalize(tmpvec3, tmpvec3);
|
|
2965
|
-
setAxisAngle(out, tmpvec3, Math.PI);
|
|
2966
|
-
return out;
|
|
2967
|
-
} else if (dot$1 > 0.999999) {
|
|
2968
|
-
out[0] = 0;
|
|
2969
|
-
out[1] = 0;
|
|
2970
|
-
out[2] = 0;
|
|
2971
|
-
out[3] = 1;
|
|
2972
|
-
return out;
|
|
2973
|
-
} else {
|
|
2974
|
-
cross(tmpvec3, a, b);
|
|
2975
|
-
out[0] = tmpvec3[0];
|
|
2976
|
-
out[1] = tmpvec3[1];
|
|
2977
|
-
out[2] = tmpvec3[2];
|
|
2978
|
-
out[3] = 1 + dot$1;
|
|
2979
|
-
return normalize$2(out, out);
|
|
2994
|
+
gradient = context.createRadialGradient(x0 * width, y0 * height, 0, x1 * width, y1 * height, params.r1 * r);
|
|
2980
2995
|
}
|
|
2981
|
-
};
|
|
2982
|
-
}();
|
|
2983
|
-
/**
|
|
2984
|
-
* Performs a spherical linear interpolation with two control points
|
|
2985
|
-
*
|
|
2986
|
-
* @param {quat} out the receiving quaternion
|
|
2987
|
-
* @param {ReadonlyQuat} a the first operand
|
|
2988
|
-
* @param {ReadonlyQuat} b the second operand
|
|
2989
|
-
* @param {ReadonlyQuat} c the third operand
|
|
2990
|
-
* @param {ReadonlyQuat} d the fourth operand
|
|
2991
|
-
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
2992
|
-
* @returns {quat} out
|
|
2993
|
-
*/
|
|
2994
2996
|
|
|
2997
|
+
if (gradient) {
|
|
2998
|
+
steps.forEach(function (_ref) {
|
|
2999
|
+
var _gradient;
|
|
2995
3000
|
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
slerp(out, temp1, temp2, 2 * t * (1 - t));
|
|
3003
|
-
return out;
|
|
3004
|
-
};
|
|
3005
|
-
}();
|
|
3006
|
-
/**
|
|
3007
|
-
* Sets the specified quaternion with values corresponding to the given
|
|
3008
|
-
* axes. Each axis is a vec3 and is expected to be unit length and
|
|
3009
|
-
* perpendicular to all other specified axes.
|
|
3010
|
-
*
|
|
3011
|
-
* @param {ReadonlyVec3} view the vector representing the viewing direction
|
|
3012
|
-
* @param {ReadonlyVec3} right the vector representing the local "right" direction
|
|
3013
|
-
* @param {ReadonlyVec3} up the vector representing the local "up" direction
|
|
3014
|
-
* @returns {quat} out
|
|
3015
|
-
*/
|
|
3001
|
+
var offset = _ref[0],
|
|
3002
|
+
color = _ref[1];
|
|
3003
|
+
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(Number(offset), color);
|
|
3004
|
+
});
|
|
3005
|
+
this.gradientCache[key] = gradient;
|
|
3006
|
+
}
|
|
3016
3007
|
|
|
3008
|
+
return this.gradientCache[key];
|
|
3009
|
+
};
|
|
3017
3010
|
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3011
|
+
_proto.generateCacheKey = function generateCacheKey(params) {
|
|
3012
|
+
// @ts-ignore
|
|
3013
|
+
var type = params.type,
|
|
3014
|
+
x0 = params.x0,
|
|
3015
|
+
y0 = params.y0,
|
|
3016
|
+
x1 = params.x1,
|
|
3017
|
+
y1 = params.y1,
|
|
3018
|
+
r1 = params.r1,
|
|
3019
|
+
steps = params.steps,
|
|
3020
|
+
width = params.width,
|
|
3021
|
+
height = params.height;
|
|
3022
|
+
return "gradient-" + type + "-" + x0 + "-" + y0 + "-" + x1 + "-" + y1 + "-" + (r1 || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
|
|
3023
|
+
return step.join('');
|
|
3024
|
+
}).join('-');
|
|
3031
3025
|
};
|
|
3026
|
+
|
|
3027
|
+
return GradientPool;
|
|
3032
3028
|
}();
|
|
3033
3029
|
|
|
3030
|
+
GradientPool = __decorate([manaSyringe.singleton()], GradientPool);
|
|
3031
|
+
|
|
3034
3032
|
var RBushNode = function RBushNode() {
|
|
3035
3033
|
this.aabb = void 0;
|
|
3036
3034
|
};
|