@antv/g-canvas 1.1.4 → 1.1.7
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/Canvas2DContextService.d.ts +2 -2
- package/dist/Canvas2DContextService.d.ts.map +1 -1
- package/dist/index.umd.js +1466 -1462
- package/dist/index.umd.min.js +5 -5
- package/package.json +6 -6
package/dist/index.umd.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@antv/g'), require('mana-syringe')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports', '@antv/g', 'mana-syringe'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.G = global.G || {}, global.G.CanvasKit = {}), global.window.G, global.window.G.ManaSyringe));
|
|
5
5
|
}(this, (function (exports, g, manaSyringe) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _inheritsLoose(subClass, superClass) {
|
|
@@ -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,1028 +1185,1242 @@
|
|
|
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
|
-
|
|
1648
|
-
|
|
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;
|
|
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
|
+
*/
|
|
1649
1707
|
|
|
1650
|
-
var previousPromise;
|
|
1651
1708
|
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
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;
|
|
1658
1726
|
|
|
1659
|
-
|
|
1660
|
-
|
|
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;
|
|
1745
|
+
} else {
|
|
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;
|
|
1661
1751
|
}
|
|
1662
1752
|
|
|
1663
|
-
|
|
1664
|
-
|
|
1753
|
+
return out;
|
|
1754
|
+
}
|
|
1755
|
+
/**
|
|
1756
|
+
* 3 Dimensional Vector
|
|
1757
|
+
* @module vec3
|
|
1758
|
+
*/
|
|
1665
1759
|
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1760
|
+
/**
|
|
1761
|
+
* Creates a new, empty vec3
|
|
1762
|
+
*
|
|
1763
|
+
* @returns {vec3} a new 3D vector
|
|
1764
|
+
*/
|
|
1671
1765
|
|
|
1672
|
-
return ContinueSentinel;
|
|
1673
|
-
}
|
|
1674
1766
|
|
|
1675
|
-
|
|
1676
|
-
|
|
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
|
-
}
|
|
1767
|
+
function create$1() {
|
|
1768
|
+
var out = new ARRAY_TYPE(3);
|
|
1680
1769
|
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
1770
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
1771
|
+
out[0] = 0;
|
|
1772
|
+
out[1] = 0;
|
|
1773
|
+
out[2] = 0;
|
|
1686
1774
|
}
|
|
1687
1775
|
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1776
|
+
return out;
|
|
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
|
+
*/
|
|
1692
1784
|
|
|
1693
|
-
function Context(tryLocsList) {
|
|
1694
|
-
this.tryEntries = [{
|
|
1695
|
-
tryLoc: "root"
|
|
1696
|
-
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
1697
|
-
}
|
|
1698
1785
|
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
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
|
+
*/
|
|
1704
1800
|
|
|
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
1801
|
|
|
1712
|
-
|
|
1713
|
-
|
|
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
|
+
*/
|
|
1714
1816
|
|
|
1715
|
-
return next.next = next;
|
|
1716
|
-
}
|
|
1717
|
-
}
|
|
1718
1817
|
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
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;
|
|
1723
1823
|
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
done: !0
|
|
1728
|
-
};
|
|
1824
|
+
if (len > 0) {
|
|
1825
|
+
//TODO: evaluate use of glm_invsqrt here?
|
|
1826
|
+
len = 1 / Math.sqrt(len);
|
|
1729
1827
|
}
|
|
1730
1828
|
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
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 = [];
|
|
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
|
+
*/
|
|
1754
1841
|
|
|
1755
|
-
for (var key in object) {
|
|
1756
|
-
keys.push(key);
|
|
1757
|
-
}
|
|
1758
1842
|
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
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
|
+
*/
|
|
1764
1854
|
|
|
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
1855
|
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
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
|
+
*/
|
|
1787
1872
|
|
|
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
1873
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
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
|
+
*/
|
|
1796
1887
|
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
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];
|
|
1888
|
+
var forEach = function () {
|
|
1889
|
+
var vec = create$1();
|
|
1890
|
+
return function (a, stride, offset, count, fn, arg) {
|
|
1891
|
+
var i, l;
|
|
1812
1892
|
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
}
|
|
1817
|
-
}
|
|
1893
|
+
if (!stride) {
|
|
1894
|
+
stride = 3;
|
|
1895
|
+
}
|
|
1818
1896
|
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
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];
|
|
1897
|
+
if (!offset) {
|
|
1898
|
+
offset = 0;
|
|
1899
|
+
}
|
|
1836
1900
|
|
|
1837
|
-
|
|
1838
|
-
|
|
1901
|
+
if (count) {
|
|
1902
|
+
l = Math.min(count * stride + offset, a.length);
|
|
1903
|
+
} else {
|
|
1904
|
+
l = a.length;
|
|
1905
|
+
}
|
|
1839
1906
|
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
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
|
+
}
|
|
1844
1916
|
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1917
|
+
return a;
|
|
1918
|
+
};
|
|
1919
|
+
}();
|
|
1920
|
+
/**
|
|
1921
|
+
* 4 Dimensional Vector
|
|
1922
|
+
* @module vec4
|
|
1923
|
+
*/
|
|
1848
1924
|
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
resultName: resultName,
|
|
1855
|
-
nextLoc: nextLoc
|
|
1856
|
-
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
1857
|
-
}
|
|
1858
|
-
}, exports;
|
|
1859
|
-
}
|
|
1925
|
+
/**
|
|
1926
|
+
* Creates a new, empty vec4
|
|
1927
|
+
*
|
|
1928
|
+
* @returns {vec4} a new 4D vector
|
|
1929
|
+
*/
|
|
1860
1930
|
|
|
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
1931
|
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
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;
|
|
1874
1940
|
}
|
|
1941
|
+
|
|
1942
|
+
return out;
|
|
1875
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
|
+
*/
|
|
1876
1951
|
|
|
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
1952
|
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
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;
|
|
1887
1959
|
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1960
|
+
if (len > 0) {
|
|
1961
|
+
len = 1 / Math.sqrt(len);
|
|
1962
|
+
}
|
|
1891
1963
|
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1964
|
+
out[0] = x * len;
|
|
1965
|
+
out[1] = y * len;
|
|
1966
|
+
out[2] = z * len;
|
|
1967
|
+
out[3] = w * len;
|
|
1968
|
+
return out;
|
|
1895
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
|
+
*/
|
|
1896
1982
|
|
|
1897
|
-
function _extends() {
|
|
1898
|
-
_extends = Object.assign || function (target) {
|
|
1899
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
1900
|
-
var source = arguments[i];
|
|
1901
1983
|
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
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];
|
|
1907
2013
|
}
|
|
1908
2014
|
|
|
1909
|
-
return
|
|
2015
|
+
return a;
|
|
1910
2016
|
};
|
|
2017
|
+
}();
|
|
2018
|
+
/**
|
|
2019
|
+
* Quaternion
|
|
2020
|
+
* @module quat
|
|
2021
|
+
*/
|
|
1911
2022
|
|
|
1912
|
-
|
|
1913
|
-
|
|
2023
|
+
/**
|
|
2024
|
+
* Creates a new identity quat
|
|
2025
|
+
*
|
|
2026
|
+
* @returns {quat} a new quaternion
|
|
2027
|
+
*/
|
|
1914
2028
|
|
|
1915
|
-
function _inheritsLoose$1(subClass, superClass) {
|
|
1916
|
-
subClass.prototype = Object.create(superClass.prototype);
|
|
1917
|
-
subClass.prototype.constructor = subClass;
|
|
1918
2029
|
|
|
1919
|
-
|
|
1920
|
-
|
|
2030
|
+
function create$3() {
|
|
2031
|
+
var out = new ARRAY_TYPE(4);
|
|
1921
2032
|
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
}
|
|
2033
|
+
if (ARRAY_TYPE != Float32Array) {
|
|
2034
|
+
out[0] = 0;
|
|
2035
|
+
out[1] = 0;
|
|
2036
|
+
out[2] = 0;
|
|
2037
|
+
}
|
|
1927
2038
|
|
|
1928
|
-
|
|
2039
|
+
out[3] = 1;
|
|
2040
|
+
return out;
|
|
1929
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
|
+
**/
|
|
1930
2051
|
|
|
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
2052
|
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
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
|
+
*/
|
|
1968
2071
|
|
|
1969
|
-
if (hasStroke) {
|
|
1970
|
-
if (lineWidth && lineWidth.value > 0) {
|
|
1971
|
-
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
|
|
1972
2072
|
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
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
|
|
1976
2085
|
|
|
1977
|
-
|
|
2086
|
+
cosom = ax * bx + ay * by + az * bz + aw * bw; // adjust signs (if necessary)
|
|
1978
2087
|
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
2088
|
+
if (cosom < 0.0) {
|
|
2089
|
+
cosom = -cosom;
|
|
2090
|
+
bx = -bx;
|
|
2091
|
+
by = -by;
|
|
2092
|
+
bz = -bz;
|
|
2093
|
+
bw = -bw;
|
|
2094
|
+
} // calculate coefficients
|
|
1982
2095
|
|
|
1983
|
-
if (!g.isNil(lineCap)) {
|
|
1984
|
-
context.lineCap = lineCap.value;
|
|
1985
|
-
}
|
|
1986
2096
|
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
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
|
|
1990
2109
|
|
|
1991
|
-
var oldShadowBlur;
|
|
1992
|
-
var oldShadowColor;
|
|
1993
|
-
var oldFilter;
|
|
1994
|
-
var hasShadowColor = !g.isNil(shadowColor);
|
|
1995
|
-
var hasFilter = !g.isNil(filter);
|
|
1996
2110
|
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
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
|
+
*/
|
|
2002
2128
|
|
|
2003
|
-
if (!g.isNil(oldShadowBlur)) {
|
|
2004
|
-
context.shadowColor = 'transparent';
|
|
2005
|
-
context.shadowBlur = 0;
|
|
2006
|
-
}
|
|
2007
|
-
}
|
|
2008
2129
|
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
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;
|
|
2012
2135
|
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
}
|
|
2136
|
+
if (fTrace > 0.0) {
|
|
2137
|
+
// |w| > 1/2, may as well choose w > 1/2
|
|
2138
|
+
fRoot = Math.sqrt(fTrace + 1.0); // 2w
|
|
2017
2139
|
|
|
2018
|
-
|
|
2140
|
+
out[3] = 0.5 * fRoot;
|
|
2141
|
+
fRoot = 0.5 / fRoot; // 1/(4w)
|
|
2019
2142
|
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
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
|
+
}
|
|
2023
2160
|
|
|
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
|
+
*/
|
|
2024
2171
|
|
|
2025
|
-
if (hasShadowColor) {
|
|
2026
|
-
context.shadowColor = oldShadowColor;
|
|
2027
|
-
context.shadowBlur = oldShadowBlur;
|
|
2028
|
-
} // restore filters
|
|
2029
2172
|
|
|
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
|
+
*/
|
|
2030
2185
|
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
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);
|
|
2034
2192
|
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
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);
|
|
2039
2212
|
}
|
|
2040
2213
|
};
|
|
2041
|
-
|
|
2042
|
-
return DefaultRenderer;
|
|
2043
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
|
+
*/
|
|
2044
2226
|
|
|
2045
|
-
DefaultRenderer = __decorate([manaSyringe.singleton()], DefaultRenderer);
|
|
2046
2227
|
|
|
2047
|
-
var
|
|
2048
|
-
|
|
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;
|
|
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
|
+
*/
|
|
2049
2248
|
|
|
2050
|
-
function RectRenderer() {
|
|
2051
|
-
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2052
|
-
}
|
|
2053
2249
|
|
|
2054
|
-
|
|
2055
|
-
|
|
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
|
+
};
|
|
2264
|
+
}();
|
|
2056
2265
|
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
}
|
|
2266
|
+
var RBushNode = function RBushNode() {
|
|
2267
|
+
this.aabb = void 0;
|
|
2268
|
+
};
|
|
2060
2269
|
|
|
2061
|
-
|
|
2062
|
-
_inheritsLoose$1(CircleRenderer, _DefaultRenderer);
|
|
2270
|
+
RBushNode.tag = 'c-canvas-rbush-node';
|
|
2063
2271
|
|
|
2064
|
-
|
|
2065
|
-
|
|
2272
|
+
var GradientPool = /*#__PURE__*/function () {
|
|
2273
|
+
function GradientPool() {
|
|
2274
|
+
this.gradientCache = {};
|
|
2066
2275
|
}
|
|
2067
2276
|
|
|
2068
|
-
|
|
2069
|
-
}(DefaultRenderer);
|
|
2070
|
-
|
|
2071
|
-
CircleRenderer = __decorate([manaSyringe.singleton({
|
|
2072
|
-
token: CircleRendererContribution
|
|
2073
|
-
})], CircleRenderer);
|
|
2277
|
+
var _proto = GradientPool.prototype;
|
|
2074
2278
|
|
|
2075
|
-
|
|
2076
|
-
|
|
2279
|
+
_proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
|
|
2280
|
+
var key = this.generateCacheKey(params);
|
|
2281
|
+
var type = params.type,
|
|
2282
|
+
x0 = params.x0,
|
|
2283
|
+
y0 = params.y0,
|
|
2284
|
+
x1 = params.x1,
|
|
2285
|
+
y1 = params.y1,
|
|
2286
|
+
steps = params.steps,
|
|
2287
|
+
width = params.width,
|
|
2288
|
+
height = params.height;
|
|
2077
2289
|
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2290
|
+
if (this.gradientCache[key]) {
|
|
2291
|
+
return this.gradientCache[key];
|
|
2292
|
+
}
|
|
2081
2293
|
|
|
2082
|
-
|
|
2083
|
-
}(DefaultRenderer);
|
|
2294
|
+
var gradient = null;
|
|
2084
2295
|
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2296
|
+
if (type === g.GradientPatternType.LinearGradient) {
|
|
2297
|
+
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
2298
|
+
gradient = context.createLinearGradient(x0 * width, y0 * height, x1 * width, y1 * height);
|
|
2299
|
+
} else if (type === g.GradientPatternType.RadialGradient) {
|
|
2300
|
+
var r = Math.sqrt(width * width + height * height) / 2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
2088
2301
|
|
|
2089
|
-
|
|
2090
|
-
|
|
2302
|
+
gradient = context.createRadialGradient(x0 * width, y0 * height, 0, x1 * width, y1 * height, params.r1 * r);
|
|
2303
|
+
}
|
|
2091
2304
|
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2305
|
+
if (gradient) {
|
|
2306
|
+
steps.forEach(function (_ref) {
|
|
2307
|
+
var _gradient;
|
|
2095
2308
|
|
|
2096
|
-
|
|
2097
|
-
|
|
2309
|
+
var offset = _ref[0],
|
|
2310
|
+
color = _ref[1];
|
|
2311
|
+
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(Number(offset), color);
|
|
2312
|
+
});
|
|
2313
|
+
this.gradientCache[key] = gradient;
|
|
2314
|
+
}
|
|
2098
2315
|
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
})], LineRenderer);
|
|
2316
|
+
return this.gradientCache[key];
|
|
2317
|
+
};
|
|
2102
2318
|
|
|
2103
|
-
|
|
2104
|
-
|
|
2319
|
+
_proto.generateCacheKey = function generateCacheKey(params) {
|
|
2320
|
+
// @ts-ignore
|
|
2321
|
+
var type = params.type,
|
|
2322
|
+
x0 = params.x0,
|
|
2323
|
+
y0 = params.y0,
|
|
2324
|
+
x1 = params.x1,
|
|
2325
|
+
y1 = params.y1,
|
|
2326
|
+
r1 = params.r1,
|
|
2327
|
+
steps = params.steps,
|
|
2328
|
+
width = params.width,
|
|
2329
|
+
height = params.height;
|
|
2330
|
+
return "gradient-" + type + "-" + x0 + "-" + y0 + "-" + x1 + "-" + y1 + "-" + (r1 || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
|
|
2331
|
+
return step.join('');
|
|
2332
|
+
}).join('-');
|
|
2333
|
+
};
|
|
2105
2334
|
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
}
|
|
2335
|
+
return GradientPool;
|
|
2336
|
+
}();
|
|
2109
2337
|
|
|
2110
|
-
|
|
2111
|
-
}(DefaultRenderer);
|
|
2338
|
+
GradientPool = __decorate([manaSyringe.singleton()], GradientPool);
|
|
2112
2339
|
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2340
|
+
var ImagePool = /*#__PURE__*/function () {
|
|
2341
|
+
function ImagePool() {
|
|
2342
|
+
this.imageCache = {};
|
|
2343
|
+
this.patternCache = {};
|
|
2344
|
+
this.canvasConfig = void 0;
|
|
2345
|
+
}
|
|
2116
2346
|
|
|
2117
|
-
|
|
2118
|
-
_inheritsLoose$1(PolygonRenderer, _DefaultRenderer);
|
|
2347
|
+
var _proto = ImagePool.prototype;
|
|
2119
2348
|
|
|
2120
|
-
function
|
|
2121
|
-
return
|
|
2122
|
-
}
|
|
2349
|
+
_proto.getImageSync = function getImageSync(src) {
|
|
2350
|
+
return this.imageCache[src];
|
|
2351
|
+
};
|
|
2123
2352
|
|
|
2124
|
-
|
|
2125
|
-
|
|
2353
|
+
_proto.getOrCreateImage = function getOrCreateImage(src) {
|
|
2354
|
+
var _this = this;
|
|
2126
2355
|
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2356
|
+
if (this.imageCache[src]) {
|
|
2357
|
+
return Promise.resolve(this.imageCache[src]);
|
|
2358
|
+
} // @see https://github.com/antvis/g/issues/938
|
|
2130
2359
|
|
|
2131
|
-
var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2132
|
-
_inheritsLoose$1(PathRenderer, _DefaultRenderer);
|
|
2133
2360
|
|
|
2134
|
-
|
|
2135
|
-
return
|
|
2136
|
-
|
|
2361
|
+
var createImage = this.canvasConfig.createImage;
|
|
2362
|
+
return new Promise(function (resolve, reject) {
|
|
2363
|
+
var image;
|
|
2137
2364
|
|
|
2138
|
-
|
|
2139
|
-
|
|
2365
|
+
if (createImage) {
|
|
2366
|
+
image = createImage(src);
|
|
2367
|
+
} else if (g.isBrowser) {
|
|
2368
|
+
image = new window.Image();
|
|
2369
|
+
}
|
|
2140
2370
|
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2371
|
+
if (image) {
|
|
2372
|
+
image.onload = function () {
|
|
2373
|
+
resolve(image);
|
|
2374
|
+
};
|
|
2144
2375
|
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
}
|
|
2376
|
+
image.onerror = function (ev) {
|
|
2377
|
+
reject(ev);
|
|
2378
|
+
};
|
|
2149
2379
|
|
|
2150
|
-
|
|
2380
|
+
image.crossOrigin = 'Anonymous';
|
|
2381
|
+
image.src = src;
|
|
2382
|
+
_this.imageCache[src] = image;
|
|
2383
|
+
}
|
|
2384
|
+
});
|
|
2385
|
+
};
|
|
2151
2386
|
|
|
2152
|
-
_proto.
|
|
2153
|
-
var
|
|
2154
|
-
var type = params.type,
|
|
2155
|
-
x0 = params.x0,
|
|
2156
|
-
y0 = params.y0,
|
|
2157
|
-
x1 = params.x1,
|
|
2158
|
-
y1 = params.y1,
|
|
2159
|
-
steps = params.steps,
|
|
2160
|
-
width = params.width,
|
|
2161
|
-
height = params.height;
|
|
2387
|
+
_proto.getPatternSync = function getPatternSync(pattern) {
|
|
2388
|
+
var patternKey = this.generatePatternKey(pattern);
|
|
2162
2389
|
|
|
2163
|
-
if (this.
|
|
2164
|
-
return this.
|
|
2390
|
+
if (this.patternCache[patternKey]) {
|
|
2391
|
+
return this.patternCache[patternKey];
|
|
2165
2392
|
}
|
|
2393
|
+
};
|
|
2166
2394
|
|
|
2167
|
-
|
|
2395
|
+
_proto.createPattern = function createPattern(patternParams, context) {
|
|
2396
|
+
var _this2 = this;
|
|
2168
2397
|
|
|
2169
|
-
|
|
2170
|
-
// @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/
|
|
2171
|
-
gradient = context.createLinearGradient(x0 * width, y0 * height, x1 * width, y1 * height);
|
|
2172
|
-
} else if (type === g.GradientPatternType.RadialGradient) {
|
|
2173
|
-
var r = Math.sqrt(width * width + height * height) / 2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
2398
|
+
return this.getOrCreateImage(patternParams.src).then(function (image) {
|
|
2399
|
+
var patternKey = _this2.generatePatternKey(patternParams); // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
2174
2400
|
|
|
2175
|
-
gradient = context.createRadialGradient(x0 * width, y0 * height, 0, x1 * width, y1 * height, params.r1 * r);
|
|
2176
|
-
}
|
|
2177
2401
|
|
|
2178
|
-
|
|
2179
|
-
steps.forEach(function (_ref) {
|
|
2180
|
-
var _gradient;
|
|
2402
|
+
var pattern = context.createPattern(image, patternParams.repetition);
|
|
2181
2403
|
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
});
|
|
2186
|
-
this.gradientCache[key] = gradient;
|
|
2187
|
-
}
|
|
2404
|
+
if (pattern) {
|
|
2405
|
+
_this2.patternCache[patternKey] = pattern;
|
|
2406
|
+
}
|
|
2188
2407
|
|
|
2189
|
-
|
|
2408
|
+
return _this2.patternCache[patternKey];
|
|
2409
|
+
});
|
|
2190
2410
|
};
|
|
2191
2411
|
|
|
2192
|
-
_proto.
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
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('-');
|
|
2412
|
+
_proto.generatePatternKey = function generatePatternKey(pattern) {
|
|
2413
|
+
var src = pattern.src,
|
|
2414
|
+
repetition = pattern.repetition;
|
|
2415
|
+
return "pattern-" + src + "-" + repetition;
|
|
2206
2416
|
};
|
|
2207
2417
|
|
|
2208
|
-
return
|
|
2418
|
+
return ImagePool;
|
|
2209
2419
|
}();
|
|
2210
2420
|
|
|
2211
|
-
|
|
2421
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
|
|
2422
|
+
|
|
2423
|
+
ImagePool = __decorate([manaSyringe.singleton()], ImagePool);
|
|
2212
2424
|
|
|
2213
2425
|
function generatePath(context, parsedStyle) {
|
|
2214
2426
|
var r = parsedStyle.r;
|
|
@@ -2373,669 +2585,455 @@
|
|
|
2373
2585
|
|
|
2374
2586
|
var PathGeneratorFactory = manaSyringe.Syringe.defineToken('PathGeneratorFactory');
|
|
2375
2587
|
var PathGenerator = manaSyringe.Syringe.defineToken('PathGenerator');
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
var
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2588
|
+
var StyleRendererFactory = manaSyringe.Syringe.defineToken('StyleRendererFactory');
|
|
2589
|
+
var CircleRendererContribution = manaSyringe.Syringe.defineToken('CircleRenderer', {
|
|
2590
|
+
multiple: false
|
|
2591
|
+
});
|
|
2592
|
+
var EllipseRendererContribution = manaSyringe.Syringe.defineToken('EllipseRenderer', {
|
|
2593
|
+
multiple: false
|
|
2594
|
+
});
|
|
2595
|
+
var RectRendererContribution = manaSyringe.Syringe.defineToken('RectRenderer', {
|
|
2596
|
+
multiple: false
|
|
2597
|
+
});
|
|
2598
|
+
var LineRendererContribution = manaSyringe.Syringe.defineToken('LineRenderer', {
|
|
2599
|
+
multiple: false
|
|
2600
|
+
});
|
|
2601
|
+
var PolylineRendererContribution = manaSyringe.Syringe.defineToken('PolylineRenderer', {
|
|
2602
|
+
multiple: false
|
|
2603
|
+
});
|
|
2604
|
+
var PolygonRendererContribution = manaSyringe.Syringe.defineToken('PolygonRenderer', {
|
|
2605
|
+
multiple: false
|
|
2606
|
+
});
|
|
2607
|
+
var PathRendererContribution = manaSyringe.Syringe.defineToken('PathRenderer', {
|
|
2608
|
+
multiple: false
|
|
2609
|
+
});
|
|
2610
|
+
var TextRendererContribution = manaSyringe.Syringe.defineToken('TextRenderer', {
|
|
2611
|
+
multiple: false
|
|
2612
|
+
});
|
|
2613
|
+
var ImageRendererContribution = manaSyringe.Syringe.defineToken('ImageRenderer', {
|
|
2614
|
+
multiple: false
|
|
2615
|
+
});
|
|
2387
2616
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2617
|
+
var ImageRenderer = /*#__PURE__*/function () {
|
|
2618
|
+
function ImageRenderer() {
|
|
2619
|
+
this.imagePool = void 0;
|
|
2390
2620
|
}
|
|
2391
2621
|
|
|
2392
|
-
|
|
2393
|
-
};
|
|
2394
|
-
/**
|
|
2395
|
-
* 3x3 Matrix
|
|
2396
|
-
* @module mat3
|
|
2397
|
-
*/
|
|
2622
|
+
var _proto = ImageRenderer.prototype;
|
|
2398
2623
|
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
* @returns {mat3} a new 3x3 matrix
|
|
2403
|
-
*/
|
|
2624
|
+
_proto.hash = function hash(parsedStyle) {
|
|
2625
|
+
return '';
|
|
2626
|
+
};
|
|
2404
2627
|
|
|
2405
|
-
|
|
2406
|
-
|
|
2628
|
+
_proto.render = function render(context, parsedStyle) {
|
|
2629
|
+
var width = parsedStyle.width,
|
|
2630
|
+
height = parsedStyle.height,
|
|
2631
|
+
img = parsedStyle.img;
|
|
2632
|
+
var image;
|
|
2633
|
+
var iw = width.value;
|
|
2634
|
+
var ih = height.value;
|
|
2407
2635
|
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2636
|
+
if (g.isString(img)) {
|
|
2637
|
+
// image has been loaded in `mounted` hook
|
|
2638
|
+
image = this.imagePool.getImageSync(img);
|
|
2639
|
+
} else {
|
|
2640
|
+
iw || (iw = img.width);
|
|
2641
|
+
ih || (ih = img.height);
|
|
2642
|
+
image = img;
|
|
2643
|
+
}
|
|
2416
2644
|
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
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
|
-
*/
|
|
2645
|
+
if (image) {
|
|
2646
|
+
// node-canvas will throw the following err:
|
|
2647
|
+
// Error: Image given has not completed loading
|
|
2648
|
+
try {
|
|
2649
|
+
context.drawImage(image, 0, 0, iw, ih);
|
|
2650
|
+
} catch (e) {}
|
|
2651
|
+
}
|
|
2652
|
+
};
|
|
2431
2653
|
|
|
2654
|
+
return ImageRenderer;
|
|
2655
|
+
}();
|
|
2432
2656
|
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2657
|
+
__decorate([manaSyringe.inject(ImagePool), __metadata("design:type", ImagePool)], ImageRenderer.prototype, "imagePool", void 0);
|
|
2658
|
+
|
|
2659
|
+
ImageRenderer = __decorate([manaSyringe.singleton({
|
|
2660
|
+
token: ImageRendererContribution
|
|
2661
|
+
})], ImageRenderer);
|
|
2662
|
+
|
|
2663
|
+
var TextRenderer = /*#__PURE__*/function () {
|
|
2664
|
+
function TextRenderer() {}
|
|
2665
|
+
|
|
2666
|
+
var _proto = TextRenderer.prototype;
|
|
2667
|
+
|
|
2668
|
+
_proto.hash = function hash(parsedStyle) {
|
|
2669
|
+
return '';
|
|
2670
|
+
};
|
|
2671
|
+
|
|
2672
|
+
_proto.render = function render(context, parsedStyle, object) {
|
|
2673
|
+
var lineWidth = parsedStyle.lineWidth,
|
|
2674
|
+
textAlign = parsedStyle.textAlign,
|
|
2675
|
+
textBaseline = parsedStyle.textBaseline,
|
|
2676
|
+
lineJoin = parsedStyle.lineJoin,
|
|
2677
|
+
_parsedStyle$miterLim = parsedStyle.miterLimit,
|
|
2678
|
+
miterLimit = _parsedStyle$miterLim === void 0 ? 0 : _parsedStyle$miterLim,
|
|
2679
|
+
_parsedStyle$letterSp = parsedStyle.letterSpacing,
|
|
2680
|
+
letterSpacing = _parsedStyle$letterSp === void 0 ? 0 : _parsedStyle$letterSp,
|
|
2681
|
+
stroke = parsedStyle.stroke,
|
|
2682
|
+
fill = parsedStyle.fill,
|
|
2683
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
2684
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
2685
|
+
opacity = parsedStyle.opacity,
|
|
2686
|
+
metrics = parsedStyle.metrics,
|
|
2687
|
+
dx = parsedStyle.dx,
|
|
2688
|
+
dy = parsedStyle.dy;
|
|
2689
|
+
var font = metrics.font,
|
|
2690
|
+
lines = metrics.lines,
|
|
2691
|
+
height = metrics.height,
|
|
2692
|
+
lineHeight = metrics.lineHeight,
|
|
2693
|
+
lineMetrics = metrics.lineMetrics;
|
|
2694
|
+
context.font = font;
|
|
2695
|
+
context.lineWidth = lineWidth.value;
|
|
2696
|
+
context.textAlign = textAlign.value;
|
|
2697
|
+
context.textBaseline = textBaseline.value;
|
|
2698
|
+
context.lineJoin = lineJoin.value;
|
|
2699
|
+
context.miterLimit = miterLimit;
|
|
2700
|
+
var linePositionY = 0; // handle vertical text baseline
|
|
2701
|
+
|
|
2702
|
+
if (textBaseline.value === 'middle') {
|
|
2703
|
+
linePositionY = -height / 2 - lineHeight / 2;
|
|
2704
|
+
} else if (textBaseline.value === 'bottom' || textBaseline.value === 'alphabetic' || textBaseline.value === 'ideographic') {
|
|
2705
|
+
linePositionY = -height;
|
|
2706
|
+
} else if (textBaseline.value === 'top' || textBaseline.value === 'hanging') {
|
|
2707
|
+
linePositionY = -lineHeight;
|
|
2708
|
+
} // account for dx & dy
|
|
2709
|
+
|
|
2710
|
+
|
|
2711
|
+
var offsetX = 0;
|
|
2712
|
+
|
|
2713
|
+
if (dx && dx.unit === g.UnitType.kPixels) {
|
|
2714
|
+
offsetX += dx.value;
|
|
2715
|
+
}
|
|
2716
|
+
|
|
2717
|
+
if (dy && dy.unit === g.UnitType.kPixels) {
|
|
2718
|
+
linePositionY += dy.value;
|
|
2719
|
+
} // draw lines line by line
|
|
2720
|
+
|
|
2721
|
+
|
|
2722
|
+
for (var i = 0; i < lines.length; i++) {
|
|
2723
|
+
var linePositionX = lineWidth.value / 2 + offsetX;
|
|
2724
|
+
linePositionY += lineHeight; // no need to re-position X, cause we already set text align
|
|
2725
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/textAlign
|
|
2449
2726
|
|
|
2727
|
+
if (!g.isNil(stroke) && !stroke.isNone && lineWidth && lineWidth.value) {
|
|
2728
|
+
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value, true);
|
|
2729
|
+
}
|
|
2730
|
+
|
|
2731
|
+
if (!g.isNil(fill)) {
|
|
2732
|
+
this.drawLetterSpacing(context, lines[i], lineMetrics[i], textAlign.value, linePositionX, linePositionY, letterSpacing, fillOpacity.value, strokeOpacity.value, opacity.value);
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
};
|
|
2450
2736
|
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
var m21 = mat[4];
|
|
2456
|
-
var m22 = mat[5];
|
|
2457
|
-
var m23 = mat[6];
|
|
2458
|
-
var m31 = mat[8];
|
|
2459
|
-
var m32 = mat[9];
|
|
2460
|
-
var m33 = mat[10];
|
|
2461
|
-
out[0] = Math.hypot(m11, m12, m13);
|
|
2462
|
-
out[1] = Math.hypot(m21, m22, m23);
|
|
2463
|
-
out[2] = Math.hypot(m31, m32, m33);
|
|
2464
|
-
return out;
|
|
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
|
-
*/
|
|
2737
|
+
_proto.drawLetterSpacing = function drawLetterSpacing(context, text, lineMetrics, textAlign, x, y, letterSpacing, fillOpacity, strokeOpacity, opacity, isStroke) {
|
|
2738
|
+
if (isStroke === void 0) {
|
|
2739
|
+
isStroke = false;
|
|
2740
|
+
} // letterSpacing of 0 means normal, render all texts directly
|
|
2475
2741
|
|
|
2476
2742
|
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
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;
|
|
2743
|
+
if (letterSpacing === 0) {
|
|
2744
|
+
if (isStroke) {
|
|
2745
|
+
this.strokeText(context, text, x, y, strokeOpacity);
|
|
2746
|
+
} else {
|
|
2747
|
+
this.fillText(context, text, x, y, fillOpacity, opacity);
|
|
2748
|
+
}
|
|
2494
2749
|
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
out[3] = 0.25 * S;
|
|
2498
|
-
out[0] = (sm23 - sm32) / S;
|
|
2499
|
-
out[1] = (sm31 - sm13) / S;
|
|
2500
|
-
out[2] = (sm12 - sm21) / S;
|
|
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
|
-
}
|
|
2750
|
+
return;
|
|
2751
|
+
} // draw text using left align
|
|
2520
2752
|
|
|
2521
|
-
return out;
|
|
2522
|
-
}
|
|
2523
|
-
/**
|
|
2524
|
-
* 3 Dimensional Vector
|
|
2525
|
-
* @module vec3
|
|
2526
|
-
*/
|
|
2527
2753
|
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
* @returns {vec3} a new 3D vector
|
|
2532
|
-
*/
|
|
2754
|
+
var currentTextAlign = context.textAlign;
|
|
2755
|
+
context.textAlign = 'left';
|
|
2756
|
+
var currentPosition = x;
|
|
2533
2757
|
|
|
2758
|
+
if (textAlign === 'center') {
|
|
2759
|
+
currentPosition = x - lineMetrics.width / 2;
|
|
2760
|
+
} else if (textAlign === 'right' || textAlign === 'end') {
|
|
2761
|
+
currentPosition = x - lineMetrics.width;
|
|
2762
|
+
}
|
|
2534
2763
|
|
|
2535
|
-
|
|
2536
|
-
|
|
2764
|
+
var stringArray = Array.from(text);
|
|
2765
|
+
var previousWidth = context.measureText(text).width;
|
|
2766
|
+
var currentWidth = 0;
|
|
2537
2767
|
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
out[1] = 0;
|
|
2541
|
-
out[2] = 0;
|
|
2542
|
-
}
|
|
2768
|
+
for (var i = 0; i < stringArray.length; ++i) {
|
|
2769
|
+
var currentChar = stringArray[i];
|
|
2543
2770
|
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
* @param {ReadonlyVec3} a vector to calculate length of
|
|
2550
|
-
* @returns {Number} length of a
|
|
2551
|
-
*/
|
|
2771
|
+
if (isStroke) {
|
|
2772
|
+
this.strokeText(context, currentChar, currentPosition, y, strokeOpacity);
|
|
2773
|
+
} else {
|
|
2774
|
+
this.fillText(context, currentChar, currentPosition, y, fillOpacity, opacity);
|
|
2775
|
+
}
|
|
2552
2776
|
|
|
2777
|
+
currentWidth = context.measureText(text.substring(i + 1)).width;
|
|
2778
|
+
currentPosition += previousWidth - currentWidth + letterSpacing;
|
|
2779
|
+
previousWidth = currentWidth;
|
|
2780
|
+
}
|
|
2553
2781
|
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
var y = a[1];
|
|
2557
|
-
var z = a[2];
|
|
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
|
-
*/
|
|
2782
|
+
context.textAlign = currentTextAlign;
|
|
2783
|
+
};
|
|
2568
2784
|
|
|
2785
|
+
_proto.fillText = function fillText(context, text, x, y, fillOpacity, opacity) {
|
|
2786
|
+
var currentGlobalAlpha;
|
|
2787
|
+
var applyOpacity = !g.isNil(fillOpacity) && fillOpacity !== 1;
|
|
2569
2788
|
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
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
|
-
*/
|
|
2789
|
+
if (applyOpacity) {
|
|
2790
|
+
currentGlobalAlpha = context.globalAlpha;
|
|
2791
|
+
context.globalAlpha = fillOpacity * opacity;
|
|
2792
|
+
}
|
|
2584
2793
|
|
|
2794
|
+
context.fillText(text, x, y);
|
|
2585
2795
|
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
var len = x * x + y * y + z * z;
|
|
2796
|
+
if (applyOpacity) {
|
|
2797
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
2798
|
+
}
|
|
2799
|
+
};
|
|
2591
2800
|
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
}
|
|
2801
|
+
_proto.strokeText = function strokeText(context, text, x, y, strokeOpacity) {
|
|
2802
|
+
var currentGlobalAlpha;
|
|
2803
|
+
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity !== 1;
|
|
2596
2804
|
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
}
|
|
2602
|
-
/**
|
|
2603
|
-
* Calculates the dot product of two vec3's
|
|
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
|
-
*/
|
|
2805
|
+
if (applyOpacity) {
|
|
2806
|
+
currentGlobalAlpha = context.globalAlpha;
|
|
2807
|
+
context.globalAlpha = strokeOpacity;
|
|
2808
|
+
}
|
|
2609
2809
|
|
|
2810
|
+
context.strokeText(text, x, y);
|
|
2610
2811
|
|
|
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
|
-
*/
|
|
2812
|
+
if (applyOpacity) {
|
|
2813
|
+
context.globalAlpha = currentGlobalAlpha;
|
|
2814
|
+
}
|
|
2815
|
+
};
|
|
2622
2816
|
|
|
2817
|
+
return TextRenderer;
|
|
2818
|
+
}();
|
|
2623
2819
|
|
|
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
|
-
*/
|
|
2820
|
+
TextRenderer = __decorate([manaSyringe.singleton({
|
|
2821
|
+
token: TextRendererContribution
|
|
2822
|
+
})], TextRenderer);
|
|
2640
2823
|
|
|
2824
|
+
var DefaultRenderer = /*#__PURE__*/function () {
|
|
2825
|
+
function DefaultRenderer() {}
|
|
2641
2826
|
|
|
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
|
-
*/
|
|
2827
|
+
var _proto = DefaultRenderer.prototype;
|
|
2655
2828
|
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2829
|
+
_proto.hash = function hash(parsedStyle) {
|
|
2830
|
+
// const { fill, opacity, fillOpacity, stroke, strokeOpacity, lineWidth, lineCap, lineJoin } =
|
|
2831
|
+
// parsedStyle;
|
|
2832
|
+
// return fill + opacity + fillOpacity + stroke + strokeOpacity + lineWidth + lineCap + lineJoin;
|
|
2833
|
+
return '';
|
|
2834
|
+
};
|
|
2660
2835
|
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2836
|
+
_proto.render = function render(context, parsedStyle) {
|
|
2837
|
+
var fill = parsedStyle.fill,
|
|
2838
|
+
opacity = parsedStyle.opacity,
|
|
2839
|
+
fillOpacity = parsedStyle.fillOpacity,
|
|
2840
|
+
stroke = parsedStyle.stroke,
|
|
2841
|
+
strokeOpacity = parsedStyle.strokeOpacity,
|
|
2842
|
+
lineWidth = parsedStyle.lineWidth,
|
|
2843
|
+
lineCap = parsedStyle.lineCap,
|
|
2844
|
+
lineJoin = parsedStyle.lineJoin,
|
|
2845
|
+
shadowColor = parsedStyle.shadowColor,
|
|
2846
|
+
filter = parsedStyle.filter,
|
|
2847
|
+
miterLimit = parsedStyle.miterLimit;
|
|
2848
|
+
var hasFill = !g.isNil(fill) && !fill.isNone;
|
|
2849
|
+
var hasStroke = !g.isNil(stroke) && !stroke.isNone;
|
|
2850
|
+
var isFillTransparent = fill.alpha === 0;
|
|
2664
2851
|
|
|
2665
|
-
if (
|
|
2666
|
-
|
|
2852
|
+
if (hasFill) {
|
|
2853
|
+
if (!g.isNil(fillOpacity) && fillOpacity.value !== 1) {
|
|
2854
|
+
context.globalAlpha = fillOpacity.value;
|
|
2855
|
+
context.fill();
|
|
2856
|
+
context.globalAlpha = opacity.value;
|
|
2857
|
+
} else {
|
|
2858
|
+
context.fill();
|
|
2859
|
+
}
|
|
2667
2860
|
}
|
|
2668
2861
|
|
|
2669
|
-
if (
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
l = a.length;
|
|
2673
|
-
}
|
|
2862
|
+
if (hasStroke) {
|
|
2863
|
+
if (lineWidth && lineWidth.value > 0) {
|
|
2864
|
+
var applyOpacity = !g.isNil(strokeOpacity) && strokeOpacity.value !== 1;
|
|
2674
2865
|
|
|
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
|
-
}
|
|
2866
|
+
if (applyOpacity) {
|
|
2867
|
+
context.globalAlpha = strokeOpacity.value;
|
|
2868
|
+
}
|
|
2684
2869
|
|
|
2685
|
-
|
|
2686
|
-
};
|
|
2687
|
-
}();
|
|
2688
|
-
/**
|
|
2689
|
-
* 4 Dimensional Vector
|
|
2690
|
-
* @module vec4
|
|
2691
|
-
*/
|
|
2870
|
+
context.lineWidth = lineWidth.value;
|
|
2692
2871
|
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
* @returns {vec4} a new 4D vector
|
|
2697
|
-
*/
|
|
2872
|
+
if (!g.isNil(miterLimit)) {
|
|
2873
|
+
context.miterLimit = miterLimit;
|
|
2874
|
+
}
|
|
2698
2875
|
|
|
2876
|
+
if (!g.isNil(lineCap)) {
|
|
2877
|
+
context.lineCap = lineCap.value;
|
|
2878
|
+
}
|
|
2699
2879
|
|
|
2700
|
-
|
|
2701
|
-
|
|
2880
|
+
if (!g.isNil(lineJoin)) {
|
|
2881
|
+
context.lineJoin = lineJoin.value;
|
|
2882
|
+
}
|
|
2702
2883
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
}
|
|
2884
|
+
var oldShadowBlur;
|
|
2885
|
+
var oldShadowColor;
|
|
2886
|
+
var oldFilter;
|
|
2887
|
+
var hasShadowColor = !g.isNil(shadowColor);
|
|
2888
|
+
var hasFilter = !g.isNil(filter);
|
|
2709
2889
|
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
* @param {vec4} out the receiving vector
|
|
2716
|
-
* @param {ReadonlyVec4} a vector to normalize
|
|
2717
|
-
* @returns {vec4} out
|
|
2718
|
-
*/
|
|
2890
|
+
if (hasShadowColor) {
|
|
2891
|
+
// prevent inner shadow when drawing stroke, toggle shadowBlur & filter(drop-shadow)
|
|
2892
|
+
// save shadow blur
|
|
2893
|
+
oldShadowBlur = context.shadowBlur;
|
|
2894
|
+
oldShadowColor = context.shadowColor;
|
|
2719
2895
|
|
|
2896
|
+
if (!g.isNil(oldShadowBlur)) {
|
|
2897
|
+
context.shadowColor = 'transparent';
|
|
2898
|
+
context.shadowBlur = 0;
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2720
2901
|
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
var z = a[2];
|
|
2725
|
-
var w = a[3];
|
|
2726
|
-
var len = x * x + y * y + z * z + w * w;
|
|
2902
|
+
if (hasFilter) {
|
|
2903
|
+
// save drop-shadow filter
|
|
2904
|
+
oldFilter = context.filter;
|
|
2727
2905
|
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2906
|
+
if (!g.isNil(oldFilter) && oldFilter.indexOf('drop-shadow') > -1) {
|
|
2907
|
+
context.filter = oldFilter.replace(/drop-shadow\([^)]*\)/, '').trim() || 'none';
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2731
2910
|
|
|
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
|
-
*/
|
|
2911
|
+
var drawStroke = hasFill && !isFillTransparent;
|
|
2750
2912
|
|
|
2913
|
+
if (drawStroke) {
|
|
2914
|
+
context.stroke();
|
|
2915
|
+
} // restore shadow blur
|
|
2751
2916
|
|
|
2752
|
-
var forEach$1 = function () {
|
|
2753
|
-
var vec = create$2();
|
|
2754
|
-
return function (a, stride, offset, count, fn, arg) {
|
|
2755
|
-
var i, l;
|
|
2756
2917
|
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2918
|
+
if (hasShadowColor) {
|
|
2919
|
+
context.shadowColor = oldShadowColor;
|
|
2920
|
+
context.shadowBlur = oldShadowBlur;
|
|
2921
|
+
} // restore filters
|
|
2760
2922
|
|
|
2761
|
-
if (!offset) {
|
|
2762
|
-
offset = 0;
|
|
2763
|
-
}
|
|
2764
2923
|
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
l = a.length;
|
|
2769
|
-
}
|
|
2924
|
+
if (hasFilter) {
|
|
2925
|
+
context.filter = oldFilter;
|
|
2926
|
+
}
|
|
2770
2927
|
|
|
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];
|
|
2928
|
+
if (!drawStroke) {
|
|
2929
|
+
context.stroke();
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2781
2932
|
}
|
|
2782
|
-
|
|
2783
|
-
return a;
|
|
2784
2933
|
};
|
|
2785
|
-
}();
|
|
2786
|
-
/**
|
|
2787
|
-
* Quaternion
|
|
2788
|
-
* @module quat
|
|
2789
|
-
*/
|
|
2790
2934
|
|
|
2791
|
-
|
|
2792
|
-
|
|
2793
|
-
*
|
|
2794
|
-
* @returns {quat} a new quaternion
|
|
2795
|
-
*/
|
|
2935
|
+
return DefaultRenderer;
|
|
2936
|
+
}();
|
|
2796
2937
|
|
|
2938
|
+
DefaultRenderer = __decorate([manaSyringe.singleton()], DefaultRenderer);
|
|
2797
2939
|
|
|
2798
|
-
function
|
|
2799
|
-
|
|
2940
|
+
var RectRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2941
|
+
_inheritsLoose$1(RectRenderer, _DefaultRenderer);
|
|
2800
2942
|
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
out[1] = 0;
|
|
2804
|
-
out[2] = 0;
|
|
2943
|
+
function RectRenderer() {
|
|
2944
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2805
2945
|
}
|
|
2806
2946
|
|
|
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
|
-
**/
|
|
2947
|
+
return RectRenderer;
|
|
2948
|
+
}(DefaultRenderer);
|
|
2819
2949
|
|
|
2950
|
+
RectRenderer = __decorate([manaSyringe.singleton({
|
|
2951
|
+
token: RectRendererContribution
|
|
2952
|
+
})], RectRenderer);
|
|
2820
2953
|
|
|
2821
|
-
function
|
|
2822
|
-
|
|
2823
|
-
var s = Math.sin(rad);
|
|
2824
|
-
out[0] = s * axis[0];
|
|
2825
|
-
out[1] = s * axis[1];
|
|
2826
|
-
out[2] = s * axis[2];
|
|
2827
|
-
out[3] = Math.cos(rad);
|
|
2828
|
-
return out;
|
|
2829
|
-
}
|
|
2830
|
-
/**
|
|
2831
|
-
* Performs a spherical linear interpolation between two quat
|
|
2832
|
-
*
|
|
2833
|
-
* @param {quat} out the receiving quaternion
|
|
2834
|
-
* @param {ReadonlyQuat} a the first operand
|
|
2835
|
-
* @param {ReadonlyQuat} b the second operand
|
|
2836
|
-
* @param {Number} t interpolation amount, in the range [0-1], between the two inputs
|
|
2837
|
-
* @returns {quat} out
|
|
2838
|
-
*/
|
|
2954
|
+
var CircleRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2955
|
+
_inheritsLoose$1(CircleRenderer, _DefaultRenderer);
|
|
2839
2956
|
|
|
2957
|
+
function CircleRenderer() {
|
|
2958
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2959
|
+
}
|
|
2840
2960
|
|
|
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
|
|
2961
|
+
return CircleRenderer;
|
|
2962
|
+
}(DefaultRenderer);
|
|
2853
2963
|
|
|
2854
|
-
|
|
2964
|
+
CircleRenderer = __decorate([manaSyringe.singleton({
|
|
2965
|
+
token: CircleRendererContribution
|
|
2966
|
+
})], CircleRenderer);
|
|
2855
2967
|
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
bx = -bx;
|
|
2859
|
-
by = -by;
|
|
2860
|
-
bz = -bz;
|
|
2861
|
-
bw = -bw;
|
|
2862
|
-
} // calculate coefficients
|
|
2968
|
+
var EllipseRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2969
|
+
_inheritsLoose$1(EllipseRenderer, _DefaultRenderer);
|
|
2863
2970
|
|
|
2971
|
+
function EllipseRenderer() {
|
|
2972
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2973
|
+
}
|
|
2864
2974
|
|
|
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
|
|
2975
|
+
return EllipseRenderer;
|
|
2976
|
+
}(DefaultRenderer);
|
|
2877
2977
|
|
|
2978
|
+
EllipseRenderer = __decorate([manaSyringe.singleton({
|
|
2979
|
+
token: EllipseRendererContribution
|
|
2980
|
+
})], EllipseRenderer);
|
|
2878
2981
|
|
|
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
|
-
*/
|
|
2982
|
+
var LineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2983
|
+
_inheritsLoose$1(LineRenderer, _DefaultRenderer);
|
|
2896
2984
|
|
|
2985
|
+
function LineRenderer() {
|
|
2986
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2987
|
+
}
|
|
2897
2988
|
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
// article "Quaternion Calculus and Fast Animation".
|
|
2901
|
-
var fTrace = m[0] + m[4] + m[8];
|
|
2902
|
-
var fRoot;
|
|
2989
|
+
return LineRenderer;
|
|
2990
|
+
}(DefaultRenderer);
|
|
2903
2991
|
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2992
|
+
LineRenderer = __decorate([manaSyringe.singleton({
|
|
2993
|
+
token: LineRendererContribution
|
|
2994
|
+
})], LineRenderer);
|
|
2907
2995
|
|
|
2908
|
-
|
|
2909
|
-
|
|
2996
|
+
var PolylineRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
2997
|
+
_inheritsLoose$1(PolylineRenderer, _DefaultRenderer);
|
|
2910
2998
|
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
out[2] = (m[1] - m[3]) * fRoot;
|
|
2914
|
-
} else {
|
|
2915
|
-
// |w| <= 1/2
|
|
2916
|
-
var i = 0;
|
|
2917
|
-
if (m[4] > m[0]) i = 1;
|
|
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;
|
|
2999
|
+
function PolylineRenderer() {
|
|
3000
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
2927
3001
|
}
|
|
2928
3002
|
|
|
2929
|
-
return
|
|
2930
|
-
}
|
|
2931
|
-
/**
|
|
2932
|
-
* Normalize a quat
|
|
2933
|
-
*
|
|
2934
|
-
* @param {quat} out the receiving quaternion
|
|
2935
|
-
* @param {ReadonlyQuat} a quaternion to normalize
|
|
2936
|
-
* @returns {quat} out
|
|
2937
|
-
* @function
|
|
2938
|
-
*/
|
|
2939
|
-
|
|
3003
|
+
return PolylineRenderer;
|
|
3004
|
+
}(DefaultRenderer);
|
|
2940
3005
|
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
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
|
-
*/
|
|
3006
|
+
PolylineRenderer = __decorate([manaSyringe.singleton({
|
|
3007
|
+
token: PolylineRendererContribution
|
|
3008
|
+
})], PolylineRenderer);
|
|
2953
3009
|
|
|
2954
|
-
var
|
|
2955
|
-
|
|
2956
|
-
var xUnitVec3 = fromValues(1, 0, 0);
|
|
2957
|
-
var yUnitVec3 = fromValues(0, 1, 0);
|
|
2958
|
-
return function (out, a, b) {
|
|
2959
|
-
var dot$1 = dot(a, b);
|
|
3010
|
+
var PolygonRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
3011
|
+
_inheritsLoose$1(PolygonRenderer, _DefaultRenderer);
|
|
2960
3012
|
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
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);
|
|
2980
|
-
}
|
|
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
|
-
*/
|
|
3013
|
+
function PolygonRenderer() {
|
|
3014
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
3015
|
+
}
|
|
2994
3016
|
|
|
3017
|
+
return PolygonRenderer;
|
|
3018
|
+
}(DefaultRenderer);
|
|
2995
3019
|
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
return function (out, a, b, c, d, t) {
|
|
3000
|
-
slerp(temp1, a, d, t);
|
|
3001
|
-
slerp(temp2, b, c, t);
|
|
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
|
-
*/
|
|
3020
|
+
PolygonRenderer = __decorate([manaSyringe.singleton({
|
|
3021
|
+
token: PolygonRendererContribution
|
|
3022
|
+
})], PolygonRenderer);
|
|
3016
3023
|
|
|
3024
|
+
var PathRenderer = /*#__PURE__*/function (_DefaultRenderer) {
|
|
3025
|
+
_inheritsLoose$1(PathRenderer, _DefaultRenderer);
|
|
3017
3026
|
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
matr[0] = right[0];
|
|
3022
|
-
matr[3] = right[1];
|
|
3023
|
-
matr[6] = right[2];
|
|
3024
|
-
matr[1] = up[0];
|
|
3025
|
-
matr[4] = up[1];
|
|
3026
|
-
matr[7] = up[2];
|
|
3027
|
-
matr[2] = -view[0];
|
|
3028
|
-
matr[5] = -view[1];
|
|
3029
|
-
matr[8] = -view[2];
|
|
3030
|
-
return normalize$2(out, fromMat3(out, matr));
|
|
3031
|
-
};
|
|
3032
|
-
}();
|
|
3027
|
+
function PathRenderer() {
|
|
3028
|
+
return _DefaultRenderer.apply(this, arguments) || this;
|
|
3029
|
+
}
|
|
3033
3030
|
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
};
|
|
3031
|
+
return PathRenderer;
|
|
3032
|
+
}(DefaultRenderer);
|
|
3037
3033
|
|
|
3038
|
-
|
|
3034
|
+
PathRenderer = __decorate([manaSyringe.singleton({
|
|
3035
|
+
token: PathRendererContribution
|
|
3036
|
+
})], PathRenderer);
|
|
3039
3037
|
|
|
3040
3038
|
var _class$1;
|
|
3041
3039
|
|
|
@@ -3632,11 +3630,11 @@
|
|
|
3632
3630
|
context.globalAlpha *= opacity.value;
|
|
3633
3631
|
}
|
|
3634
3632
|
|
|
3635
|
-
if (!g.isNil(stroke)) {
|
|
3633
|
+
if (!g.isNil(stroke) && !stroke.isNone) {
|
|
3636
3634
|
context.strokeStyle = this.getColor(stroke, object, context, renderingService);
|
|
3637
3635
|
}
|
|
3638
3636
|
|
|
3639
|
-
if (!g.isNil(fill)) {
|
|
3637
|
+
if (!g.isNil(fill) && !fill.isNone) {
|
|
3640
3638
|
context.fillStyle = this.getColor(fill, object, context, renderingService);
|
|
3641
3639
|
}
|
|
3642
3640
|
|
|
@@ -3793,74 +3791,6 @@
|
|
|
3793
3791
|
LoadImagePlugin = LoadImagePlugin_1 = __decorate([manaSyringe.singleton({
|
|
3794
3792
|
contrib: g.RenderingPluginContribution
|
|
3795
3793
|
})], LoadImagePlugin);
|
|
3796
|
-
/**
|
|
3797
|
-
* register shape renderers
|
|
3798
|
-
*/
|
|
3799
|
-
|
|
3800
|
-
manaSyringe.GlobalContainer.register({
|
|
3801
|
-
token: {
|
|
3802
|
-
token: PathGenerator,
|
|
3803
|
-
named: g.Shape.CIRCLE
|
|
3804
|
-
},
|
|
3805
|
-
useValue: generatePath
|
|
3806
|
-
});
|
|
3807
|
-
manaSyringe.GlobalContainer.register({
|
|
3808
|
-
token: {
|
|
3809
|
-
token: PathGenerator,
|
|
3810
|
-
named: g.Shape.ELLIPSE
|
|
3811
|
-
},
|
|
3812
|
-
useValue: generatePath$1
|
|
3813
|
-
});
|
|
3814
|
-
manaSyringe.GlobalContainer.register({
|
|
3815
|
-
token: {
|
|
3816
|
-
token: PathGenerator,
|
|
3817
|
-
named: g.Shape.RECT
|
|
3818
|
-
},
|
|
3819
|
-
useValue: generatePath$2
|
|
3820
|
-
});
|
|
3821
|
-
manaSyringe.GlobalContainer.register({
|
|
3822
|
-
token: {
|
|
3823
|
-
token: PathGenerator,
|
|
3824
|
-
named: g.Shape.LINE
|
|
3825
|
-
},
|
|
3826
|
-
useValue: generatePath$3
|
|
3827
|
-
});
|
|
3828
|
-
manaSyringe.GlobalContainer.register({
|
|
3829
|
-
token: {
|
|
3830
|
-
token: PathGenerator,
|
|
3831
|
-
named: g.Shape.POLYLINE
|
|
3832
|
-
},
|
|
3833
|
-
useValue: generatePath$4
|
|
3834
|
-
});
|
|
3835
|
-
manaSyringe.GlobalContainer.register({
|
|
3836
|
-
token: {
|
|
3837
|
-
token: PathGenerator,
|
|
3838
|
-
named: g.Shape.POLYGON
|
|
3839
|
-
},
|
|
3840
|
-
useValue: generatePath$5
|
|
3841
|
-
});
|
|
3842
|
-
manaSyringe.GlobalContainer.register({
|
|
3843
|
-
token: {
|
|
3844
|
-
token: PathGenerator,
|
|
3845
|
-
named: g.Shape.PATH
|
|
3846
|
-
},
|
|
3847
|
-
useValue: generatePath$6
|
|
3848
|
-
});
|
|
3849
|
-
manaSyringe.GlobalContainer.register({
|
|
3850
|
-
token: PathGeneratorFactory,
|
|
3851
|
-
useFactory: function useFactory(ctx) {
|
|
3852
|
-
var cache = {};
|
|
3853
|
-
return function (tagName) {
|
|
3854
|
-
if (!cache[tagName]) {
|
|
3855
|
-
if (ctx.container.isBoundNamed(PathGenerator, tagName)) {
|
|
3856
|
-
cache[tagName] = ctx.container.getNamed(PathGenerator, tagName);
|
|
3857
|
-
}
|
|
3858
|
-
}
|
|
3859
|
-
|
|
3860
|
-
return cache[tagName];
|
|
3861
|
-
};
|
|
3862
|
-
}
|
|
3863
|
-
});
|
|
3864
3794
|
var containerModule$1 = manaSyringe.Module(function (register) {
|
|
3865
3795
|
var _shape2Token;
|
|
3866
3796
|
|
|
@@ -3909,6 +3839,76 @@
|
|
|
3909
3839
|
var _proto = Plugin.prototype;
|
|
3910
3840
|
|
|
3911
3841
|
_proto.init = function init(container) {
|
|
3842
|
+
if (!manaSyringe.GlobalContainer.isBound(PathGeneratorFactory)) {
|
|
3843
|
+
/**
|
|
3844
|
+
* register shape renderers
|
|
3845
|
+
*/
|
|
3846
|
+
manaSyringe.GlobalContainer.register({
|
|
3847
|
+
token: {
|
|
3848
|
+
token: PathGenerator,
|
|
3849
|
+
named: g.Shape.CIRCLE
|
|
3850
|
+
},
|
|
3851
|
+
useValue: generatePath
|
|
3852
|
+
});
|
|
3853
|
+
manaSyringe.GlobalContainer.register({
|
|
3854
|
+
token: {
|
|
3855
|
+
token: PathGenerator,
|
|
3856
|
+
named: g.Shape.ELLIPSE
|
|
3857
|
+
},
|
|
3858
|
+
useValue: generatePath$1
|
|
3859
|
+
});
|
|
3860
|
+
manaSyringe.GlobalContainer.register({
|
|
3861
|
+
token: {
|
|
3862
|
+
token: PathGenerator,
|
|
3863
|
+
named: g.Shape.RECT
|
|
3864
|
+
},
|
|
3865
|
+
useValue: generatePath$2
|
|
3866
|
+
});
|
|
3867
|
+
manaSyringe.GlobalContainer.register({
|
|
3868
|
+
token: {
|
|
3869
|
+
token: PathGenerator,
|
|
3870
|
+
named: g.Shape.LINE
|
|
3871
|
+
},
|
|
3872
|
+
useValue: generatePath$3
|
|
3873
|
+
});
|
|
3874
|
+
manaSyringe.GlobalContainer.register({
|
|
3875
|
+
token: {
|
|
3876
|
+
token: PathGenerator,
|
|
3877
|
+
named: g.Shape.POLYLINE
|
|
3878
|
+
},
|
|
3879
|
+
useValue: generatePath$4
|
|
3880
|
+
});
|
|
3881
|
+
manaSyringe.GlobalContainer.register({
|
|
3882
|
+
token: {
|
|
3883
|
+
token: PathGenerator,
|
|
3884
|
+
named: g.Shape.POLYGON
|
|
3885
|
+
},
|
|
3886
|
+
useValue: generatePath$5
|
|
3887
|
+
});
|
|
3888
|
+
manaSyringe.GlobalContainer.register({
|
|
3889
|
+
token: {
|
|
3890
|
+
token: PathGenerator,
|
|
3891
|
+
named: g.Shape.PATH
|
|
3892
|
+
},
|
|
3893
|
+
useValue: generatePath$6
|
|
3894
|
+
});
|
|
3895
|
+
manaSyringe.GlobalContainer.register({
|
|
3896
|
+
token: PathGeneratorFactory,
|
|
3897
|
+
useFactory: function useFactory(ctx) {
|
|
3898
|
+
var cache = {};
|
|
3899
|
+
return function (tagName) {
|
|
3900
|
+
if (!cache[tagName]) {
|
|
3901
|
+
if (ctx.container.isBoundNamed(PathGenerator, tagName)) {
|
|
3902
|
+
cache[tagName] = ctx.container.getNamed(PathGenerator, tagName);
|
|
3903
|
+
}
|
|
3904
|
+
}
|
|
3905
|
+
|
|
3906
|
+
return cache[tagName];
|
|
3907
|
+
};
|
|
3908
|
+
}
|
|
3909
|
+
});
|
|
3910
|
+
}
|
|
3911
|
+
|
|
3912
3912
|
container.load(containerModule$1, true);
|
|
3913
3913
|
};
|
|
3914
3914
|
|
|
@@ -5709,7 +5709,7 @@
|
|
|
5709
5709
|
increasedLineWidthForHitTesting = _displayObject$parsed.increasedLineWidthForHitTesting,
|
|
5710
5710
|
clipPathTargets = _displayObject$parsed.clipPathTargets;
|
|
5711
5711
|
var r = rInPixels.value;
|
|
5712
|
-
var halfLineWidth = (lineWidth.value + increasedLineWidthForHitTesting.value) / 2;
|
|
5712
|
+
var halfLineWidth = ((lineWidth && lineWidth.value || 0) + (increasedLineWidthForHitTesting && increasedLineWidthForHitTesting.value || 0)) / 2;
|
|
5713
5713
|
var absDistance = distance$1(r, r, position.x, position.y);
|
|
5714
5714
|
var isClipPath = !!(clipPathTargets === null || clipPathTargets === void 0 ? void 0 : clipPathTargets.length);
|
|
5715
5715
|
var hasFill = fill && !fill.isNone;
|
|
@@ -5750,7 +5750,7 @@
|
|
|
5750
5750
|
var hasStroke = stroke && !stroke.isNone;
|
|
5751
5751
|
var rx = rxInPixels.value;
|
|
5752
5752
|
var ry = ryInPixels.value;
|
|
5753
|
-
var halfLineWith = (lineWidth.value + increasedLineWidthForHitTesting.value) / 2;
|
|
5753
|
+
var halfLineWith = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + increasedLineWidthForHitTesting.value) / 2;
|
|
5754
5754
|
var squareX = (x - rx) * (x - rx);
|
|
5755
5755
|
var squareY = (y - ry) * (y - ry); // 使用椭圆的公式: x*x/rx*rx + y*y/ry*ry = 1;
|
|
5756
5756
|
|
|
@@ -6472,6 +6472,7 @@
|
|
|
6472
6472
|
function HTMLRenderingPlugin() {
|
|
6473
6473
|
this.contextService = void 0;
|
|
6474
6474
|
this.renderingContext = void 0;
|
|
6475
|
+
this.canvasConfig = void 0;
|
|
6475
6476
|
this.$camera = void 0;
|
|
6476
6477
|
}
|
|
6477
6478
|
|
|
@@ -6557,6 +6558,7 @@
|
|
|
6557
6558
|
};
|
|
6558
6559
|
|
|
6559
6560
|
_proto.getOrCreateEl = function getOrCreateEl(object) {
|
|
6561
|
+
var doc = this.canvasConfig.document;
|
|
6560
6562
|
var existedId = this.getId(object);
|
|
6561
6563
|
var $container = this.contextService.getDomElement().parentNode;
|
|
6562
6564
|
|
|
@@ -6564,7 +6566,7 @@
|
|
|
6564
6566
|
var $existedElement = $container.querySelector('#' + existedId);
|
|
6565
6567
|
|
|
6566
6568
|
if (!$existedElement) {
|
|
6567
|
-
$existedElement = document.createElement('div');
|
|
6569
|
+
$existedElement = (doc || document).createElement('div');
|
|
6568
6570
|
object.parsedStyle.$el = $existedElement;
|
|
6569
6571
|
$existedElement.id = existedId;
|
|
6570
6572
|
|
|
@@ -6695,6 +6697,8 @@
|
|
|
6695
6697
|
|
|
6696
6698
|
__decorate([manaSyringe.inject(g.RenderingContext), __metadata("design:type", Object)], HTMLRenderingPlugin.prototype, "renderingContext", void 0);
|
|
6697
6699
|
|
|
6700
|
+
__decorate([manaSyringe.inject(g.CanvasConfig), __metadata("design:type", Object)], HTMLRenderingPlugin.prototype, "canvasConfig", void 0);
|
|
6701
|
+
|
|
6698
6702
|
HTMLRenderingPlugin = HTMLRenderingPlugin_1 = __decorate([manaSyringe.singleton({
|
|
6699
6703
|
contrib: g.RenderingPluginContribution
|
|
6700
6704
|
})], HTMLRenderingPlugin);
|