@antv/g-webgpu 1.1.8 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +8 -6
- package/dist/index.js +4 -2
- package/dist/index.umd.js +1835 -1074
- package/dist/index.umd.min.js +7 -5
- package/package.json +7 -6
package/dist/index.umd.js
CHANGED
|
@@ -393,11 +393,10 @@
|
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
function _setPrototypeOf(o, p) {
|
|
396
|
-
_setPrototypeOf = Object.setPrototypeOf
|
|
396
|
+
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
397
397
|
o.__proto__ = p;
|
|
398
398
|
return o;
|
|
399
399
|
};
|
|
400
|
-
|
|
401
400
|
return _setPrototypeOf(o, p);
|
|
402
401
|
}
|
|
403
402
|
|
|
@@ -1535,223 +1534,878 @@
|
|
|
1535
1534
|
}
|
|
1536
1535
|
});
|
|
1537
1536
|
|
|
1538
|
-
var
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1537
|
+
var ImagePool = /*#__PURE__*/function () {
|
|
1538
|
+
function ImagePool() {
|
|
1539
|
+
this.imageCache = {};
|
|
1540
|
+
this.gradientCache = {};
|
|
1541
|
+
this.patternCache = {};
|
|
1542
|
+
this.canvasConfig = void 0;
|
|
1543
|
+
}
|
|
1542
1544
|
|
|
1543
|
-
|
|
1545
|
+
var _proto = ImagePool.prototype;
|
|
1544
1546
|
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1547
|
+
_proto.getImageSync = function getImageSync(src, callback) {
|
|
1548
|
+
if (!this.imageCache[src]) {
|
|
1549
|
+
this.getOrCreateImage(src).then(function () {
|
|
1550
|
+
if (callback) {
|
|
1551
|
+
callback();
|
|
1552
|
+
}
|
|
1553
|
+
});
|
|
1554
|
+
}
|
|
1549
1555
|
|
|
1550
|
-
|
|
1556
|
+
return this.imageCache[src];
|
|
1557
|
+
};
|
|
1551
1558
|
|
|
1552
|
-
|
|
1559
|
+
_proto.getOrCreateImage = function getOrCreateImage(src) {
|
|
1560
|
+
var _this = this;
|
|
1553
1561
|
|
|
1554
|
-
if (
|
|
1562
|
+
if (this.imageCache[src]) {
|
|
1563
|
+
return Promise.resolve(this.imageCache[src]);
|
|
1564
|
+
} // @see https://github.com/antvis/g/issues/938
|
|
1555
1565
|
|
|
1556
|
-
// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
|
|
1557
|
-
if (data.length > 80 * dim) {
|
|
1558
|
-
minX = maxX = data[0];
|
|
1559
|
-
minY = maxY = data[1];
|
|
1560
1566
|
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
if (x < minX) minX = x;
|
|
1565
|
-
if (y < minY) minY = y;
|
|
1566
|
-
if (x > maxX) maxX = x;
|
|
1567
|
-
if (y > maxY) maxY = y;
|
|
1568
|
-
}
|
|
1567
|
+
var createImage = this.canvasConfig.createImage;
|
|
1568
|
+
return new Promise(function (resolve, reject) {
|
|
1569
|
+
var image;
|
|
1569
1570
|
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1571
|
+
if (createImage) {
|
|
1572
|
+
image = createImage(src);
|
|
1573
|
+
} else if (g.isBrowser) {
|
|
1574
|
+
image = new window.Image();
|
|
1575
|
+
}
|
|
1574
1576
|
|
|
1575
|
-
|
|
1577
|
+
if (image) {
|
|
1578
|
+
image.onload = function () {
|
|
1579
|
+
resolve(image);
|
|
1580
|
+
};
|
|
1576
1581
|
|
|
1577
|
-
|
|
1578
|
-
|
|
1582
|
+
image.onerror = function (ev) {
|
|
1583
|
+
reject(ev);
|
|
1584
|
+
};
|
|
1579
1585
|
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1586
|
+
image.crossOrigin = 'Anonymous';
|
|
1587
|
+
image.src = src;
|
|
1588
|
+
_this.imageCache[src] = image;
|
|
1589
|
+
}
|
|
1590
|
+
});
|
|
1591
|
+
};
|
|
1583
1592
|
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
} else {
|
|
1587
|
-
for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
|
|
1588
|
-
}
|
|
1593
|
+
_proto.getOrCreatePatternSync = function getOrCreatePatternSync(pattern, context, callback) {
|
|
1594
|
+
var patternKey = this.generatePatternKey(pattern);
|
|
1589
1595
|
|
|
1590
|
-
if (
|
|
1591
|
-
|
|
1592
|
-
last = last.next;
|
|
1596
|
+
if (patternKey && this.patternCache[patternKey]) {
|
|
1597
|
+
return this.patternCache[patternKey];
|
|
1593
1598
|
}
|
|
1594
1599
|
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
// eliminate colinear or duplicate points
|
|
1599
|
-
function filterPoints(start, end) {
|
|
1600
|
-
if (!start) return start;
|
|
1601
|
-
if (!end) end = start;
|
|
1602
|
-
|
|
1603
|
-
var p = start,
|
|
1604
|
-
again;
|
|
1605
|
-
do {
|
|
1606
|
-
again = false;
|
|
1600
|
+
var image = pattern.image,
|
|
1601
|
+
repetition = pattern.repetition;
|
|
1602
|
+
var src; // Image URL
|
|
1607
1603
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1604
|
+
if (g.isString(image)) {
|
|
1605
|
+
src = this.getImageSync(image, callback);
|
|
1606
|
+
} else {
|
|
1607
|
+
src = image;
|
|
1608
|
+
} // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createPattern
|
|
1613
1609
|
|
|
1614
|
-
} else {
|
|
1615
|
-
p = p.next;
|
|
1616
|
-
}
|
|
1617
|
-
} while (again || p !== end);
|
|
1618
1610
|
|
|
1619
|
-
|
|
1620
|
-
}
|
|
1611
|
+
var canvasPattern = src && context.createPattern(src, repetition);
|
|
1621
1612
|
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1613
|
+
if (patternKey && canvasPattern) {
|
|
1614
|
+
this.patternCache[patternKey] = canvasPattern;
|
|
1615
|
+
}
|
|
1625
1616
|
|
|
1626
|
-
|
|
1627
|
-
|
|
1617
|
+
return canvasPattern;
|
|
1618
|
+
};
|
|
1628
1619
|
|
|
1629
|
-
|
|
1630
|
-
|
|
1620
|
+
_proto.getOrCreateGradient = function getOrCreateGradient(params, context) {
|
|
1621
|
+
var key = this.generateGradientKey(params); // @ts-ignore
|
|
1631
1622
|
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1623
|
+
var type = params.type,
|
|
1624
|
+
steps = params.steps,
|
|
1625
|
+
width = params.width,
|
|
1626
|
+
height = params.height,
|
|
1627
|
+
angle = params.angle,
|
|
1628
|
+
cx = params.cx,
|
|
1629
|
+
cy = params.cy;
|
|
1636
1630
|
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
triangles.push(ear.i / dim);
|
|
1641
|
-
triangles.push(next.i / dim);
|
|
1631
|
+
if (this.gradientCache[key]) {
|
|
1632
|
+
return this.gradientCache[key];
|
|
1633
|
+
}
|
|
1642
1634
|
|
|
1643
|
-
|
|
1635
|
+
var gradient = null;
|
|
1644
1636
|
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1637
|
+
if (type === g.GradientType.LinearGradient) {
|
|
1638
|
+
var _computeLinearGradien = g.computeLinearGradient(width, height, angle),
|
|
1639
|
+
x1 = _computeLinearGradien.x1,
|
|
1640
|
+
y1 = _computeLinearGradien.y1,
|
|
1641
|
+
x2 = _computeLinearGradien.x2,
|
|
1642
|
+
y2 = _computeLinearGradien.y2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createLinearGradient
|
|
1648
1643
|
|
|
1649
|
-
continue;
|
|
1650
|
-
}
|
|
1651
1644
|
|
|
1652
|
-
|
|
1645
|
+
gradient = context.createLinearGradient(x1, y1, x2, y2);
|
|
1646
|
+
} else if (type === g.GradientType.RadialGradient) {
|
|
1647
|
+
var _computeRadialGradien = g.computeRadialGradient(width, height, cx, cy),
|
|
1648
|
+
x = _computeRadialGradien.x,
|
|
1649
|
+
y = _computeRadialGradien.y,
|
|
1650
|
+
r = _computeRadialGradien.r; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
1653
1651
|
|
|
1654
|
-
// if we looped through the whole remaining polygon and can't find any more ears
|
|
1655
|
-
if (ear === stop) {
|
|
1656
|
-
// try filtering points and slicing again
|
|
1657
|
-
if (!pass) {
|
|
1658
|
-
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
|
|
1659
1652
|
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
|
|
1663
|
-
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
|
|
1653
|
+
gradient = context.createRadialGradient(x, y, 0, x, y, r);
|
|
1654
|
+
}
|
|
1664
1655
|
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
}
|
|
1656
|
+
if (gradient) {
|
|
1657
|
+
steps.forEach(function (_ref) {
|
|
1658
|
+
var _gradient;
|
|
1669
1659
|
|
|
1670
|
-
|
|
1671
|
-
|
|
1660
|
+
var offset = _ref[0],
|
|
1661
|
+
color = _ref[1];
|
|
1662
|
+
(_gradient = gradient) === null || _gradient === void 0 ? void 0 : _gradient.addColorStop(offset, color);
|
|
1663
|
+
});
|
|
1664
|
+
this.gradientCache[key] = gradient;
|
|
1672
1665
|
}
|
|
1673
|
-
}
|
|
1674
1666
|
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
var a = ear.prev,
|
|
1678
|
-
b = ear,
|
|
1679
|
-
c = ear.next;
|
|
1667
|
+
return this.gradientCache[key];
|
|
1668
|
+
};
|
|
1680
1669
|
|
|
1681
|
-
|
|
1670
|
+
_proto.generateGradientKey = function generateGradientKey(params) {
|
|
1671
|
+
// @ts-ignore
|
|
1672
|
+
var type = params.type,
|
|
1673
|
+
width = params.width,
|
|
1674
|
+
height = params.height,
|
|
1675
|
+
steps = params.steps,
|
|
1676
|
+
angle = params.angle,
|
|
1677
|
+
cx = params.cx,
|
|
1678
|
+
cy = params.cy;
|
|
1679
|
+
return "gradient-" + type + "-" + (angle || 0) + "-" + (cx || 0) + "-" + (cy || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
|
|
1680
|
+
return step.join('');
|
|
1681
|
+
}).join('-');
|
|
1682
|
+
};
|
|
1682
1683
|
|
|
1683
|
-
|
|
1684
|
-
var
|
|
1684
|
+
_proto.generatePatternKey = function generatePatternKey(pattern) {
|
|
1685
|
+
var image = pattern.image,
|
|
1686
|
+
repetition = pattern.repetition; // only generate cache for Image
|
|
1685
1687
|
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
area(p.prev, p, p.next) >= 0) return false;
|
|
1689
|
-
p = p.next;
|
|
1688
|
+
if (g.isString(image)) {
|
|
1689
|
+
return "pattern-" + image + "-" + repetition;
|
|
1690
1690
|
}
|
|
1691
|
+
};
|
|
1691
1692
|
|
|
1692
|
-
|
|
1693
|
-
}
|
|
1693
|
+
return ImagePool;
|
|
1694
|
+
}();
|
|
1694
1695
|
|
|
1695
|
-
|
|
1696
|
-
var a = ear.prev,
|
|
1697
|
-
b = ear,
|
|
1698
|
-
c = ear.next;
|
|
1696
|
+
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], ImagePool.prototype, "canvasConfig", void 0);
|
|
1699
1697
|
|
|
1700
|
-
|
|
1698
|
+
ImagePool = __decorate([g.singleton()], ImagePool);
|
|
1701
1699
|
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1700
|
+
function _regeneratorRuntime$1() {
|
|
1701
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
1702
|
+
_regeneratorRuntime$1 = function _regeneratorRuntime() {
|
|
1703
|
+
return exports;
|
|
1704
|
+
};
|
|
1707
1705
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1706
|
+
var exports = {},
|
|
1707
|
+
Op = Object.prototype,
|
|
1708
|
+
hasOwn = Op.hasOwnProperty,
|
|
1709
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
|
1710
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
|
1711
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
|
1712
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
|
1711
1713
|
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
+
function define(obj, key, value) {
|
|
1715
|
+
return Object.defineProperty(obj, key, {
|
|
1716
|
+
value: value,
|
|
1717
|
+
enumerable: !0,
|
|
1718
|
+
configurable: !0,
|
|
1719
|
+
writable: !0
|
|
1720
|
+
}), obj[key];
|
|
1721
|
+
}
|
|
1714
1722
|
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1723
|
+
try {
|
|
1724
|
+
define({}, "");
|
|
1725
|
+
} catch (err) {
|
|
1726
|
+
define = function define(obj, key, value) {
|
|
1727
|
+
return obj[key] = value;
|
|
1728
|
+
};
|
|
1729
|
+
}
|
|
1721
1730
|
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1731
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
|
1732
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
|
1733
|
+
generator = Object.create(protoGenerator.prototype),
|
|
1734
|
+
context = new Context(tryLocsList || []);
|
|
1735
|
+
return generator._invoke = function (innerFn, self, context) {
|
|
1736
|
+
var state = "suspendedStart";
|
|
1737
|
+
return function (method, arg) {
|
|
1738
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
|
1727
1739
|
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
area(p.prev, p, p.next) >= 0) return false;
|
|
1733
|
-
p = p.prevZ;
|
|
1734
|
-
}
|
|
1740
|
+
if ("completed" === state) {
|
|
1741
|
+
if ("throw" === method) throw arg;
|
|
1742
|
+
return doneResult();
|
|
1743
|
+
}
|
|
1735
1744
|
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
if (n !== ear.prev && n !== ear.next &&
|
|
1739
|
-
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
|
|
1740
|
-
area(n.prev, n, n.next) >= 0) return false;
|
|
1741
|
-
n = n.nextZ;
|
|
1742
|
-
}
|
|
1745
|
+
for (context.method = method, context.arg = arg;;) {
|
|
1746
|
+
var delegate = context.delegate;
|
|
1743
1747
|
|
|
1744
|
-
|
|
1745
|
-
|
|
1748
|
+
if (delegate) {
|
|
1749
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
|
1746
1750
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
b = p.next.next;
|
|
1751
|
+
if (delegateResult) {
|
|
1752
|
+
if (delegateResult === ContinueSentinel) continue;
|
|
1753
|
+
return delegateResult;
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1753
1756
|
|
|
1754
|
-
|
|
1757
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
|
1758
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
|
1759
|
+
context.dispatchException(context.arg);
|
|
1760
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
|
1761
|
+
state = "executing";
|
|
1762
|
+
var record = tryCatch(innerFn, self, context);
|
|
1763
|
+
|
|
1764
|
+
if ("normal" === record.type) {
|
|
1765
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
|
1766
|
+
return {
|
|
1767
|
+
value: record.arg,
|
|
1768
|
+
done: context.done
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
|
|
1772
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
|
1773
|
+
}
|
|
1774
|
+
};
|
|
1775
|
+
}(innerFn, self, context), generator;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
1778
|
+
function tryCatch(fn, obj, arg) {
|
|
1779
|
+
try {
|
|
1780
|
+
return {
|
|
1781
|
+
type: "normal",
|
|
1782
|
+
arg: fn.call(obj, arg)
|
|
1783
|
+
};
|
|
1784
|
+
} catch (err) {
|
|
1785
|
+
return {
|
|
1786
|
+
type: "throw",
|
|
1787
|
+
arg: err
|
|
1788
|
+
};
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
exports.wrap = wrap;
|
|
1793
|
+
var ContinueSentinel = {};
|
|
1794
|
+
|
|
1795
|
+
function Generator() {}
|
|
1796
|
+
|
|
1797
|
+
function GeneratorFunction() {}
|
|
1798
|
+
|
|
1799
|
+
function GeneratorFunctionPrototype() {}
|
|
1800
|
+
|
|
1801
|
+
var IteratorPrototype = {};
|
|
1802
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
1803
|
+
return this;
|
|
1804
|
+
});
|
|
1805
|
+
var getProto = Object.getPrototypeOf,
|
|
1806
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
1807
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
|
1808
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
1809
|
+
|
|
1810
|
+
function defineIteratorMethods(prototype) {
|
|
1811
|
+
["next", "throw", "return"].forEach(function (method) {
|
|
1812
|
+
define(prototype, method, function (arg) {
|
|
1813
|
+
return this._invoke(method, arg);
|
|
1814
|
+
});
|
|
1815
|
+
});
|
|
1816
|
+
}
|
|
1817
|
+
|
|
1818
|
+
function AsyncIterator(generator, PromiseImpl) {
|
|
1819
|
+
function invoke(method, arg, resolve, reject) {
|
|
1820
|
+
var record = tryCatch(generator[method], generator, arg);
|
|
1821
|
+
|
|
1822
|
+
if ("throw" !== record.type) {
|
|
1823
|
+
var result = record.arg,
|
|
1824
|
+
value = result.value;
|
|
1825
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
|
1826
|
+
invoke("next", value, resolve, reject);
|
|
1827
|
+
}, function (err) {
|
|
1828
|
+
invoke("throw", err, resolve, reject);
|
|
1829
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
|
1830
|
+
result.value = unwrapped, resolve(result);
|
|
1831
|
+
}, function (error) {
|
|
1832
|
+
return invoke("throw", error, resolve, reject);
|
|
1833
|
+
});
|
|
1834
|
+
}
|
|
1835
|
+
|
|
1836
|
+
reject(record.arg);
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
var previousPromise;
|
|
1840
|
+
|
|
1841
|
+
this._invoke = function (method, arg) {
|
|
1842
|
+
function callInvokeWithMethodAndArg() {
|
|
1843
|
+
return new PromiseImpl(function (resolve, reject) {
|
|
1844
|
+
invoke(method, arg, resolve, reject);
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
1849
|
+
};
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
function maybeInvokeDelegate(delegate, context) {
|
|
1853
|
+
var method = delegate.iterator[context.method];
|
|
1854
|
+
|
|
1855
|
+
if (undefined === method) {
|
|
1856
|
+
if (context.delegate = null, "throw" === context.method) {
|
|
1857
|
+
if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
|
|
1858
|
+
context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
|
|
1859
|
+
}
|
|
1860
|
+
|
|
1861
|
+
return ContinueSentinel;
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
|
1865
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
|
1866
|
+
var info = record.arg;
|
|
1867
|
+
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);
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
function pushTryEntry(locs) {
|
|
1871
|
+
var entry = {
|
|
1872
|
+
tryLoc: locs[0]
|
|
1873
|
+
};
|
|
1874
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
|
1875
|
+
}
|
|
1876
|
+
|
|
1877
|
+
function resetTryEntry(entry) {
|
|
1878
|
+
var record = entry.completion || {};
|
|
1879
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
function Context(tryLocsList) {
|
|
1883
|
+
this.tryEntries = [{
|
|
1884
|
+
tryLoc: "root"
|
|
1885
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
function values(iterable) {
|
|
1889
|
+
if (iterable) {
|
|
1890
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
|
1891
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
|
1892
|
+
if ("function" == typeof iterable.next) return iterable;
|
|
1893
|
+
|
|
1894
|
+
if (!isNaN(iterable.length)) {
|
|
1895
|
+
var i = -1,
|
|
1896
|
+
next = function next() {
|
|
1897
|
+
for (; ++i < iterable.length;) {
|
|
1898
|
+
if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1901
|
+
return next.value = undefined, next.done = !0, next;
|
|
1902
|
+
};
|
|
1903
|
+
|
|
1904
|
+
return next.next = next;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
return {
|
|
1909
|
+
next: doneResult
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
function doneResult() {
|
|
1914
|
+
return {
|
|
1915
|
+
value: undefined,
|
|
1916
|
+
done: !0
|
|
1917
|
+
};
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
|
1921
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
|
1922
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
|
1923
|
+
}, exports.mark = function (genFun) {
|
|
1924
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
|
1925
|
+
}, exports.awrap = function (arg) {
|
|
1926
|
+
return {
|
|
1927
|
+
__await: arg
|
|
1928
|
+
};
|
|
1929
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
1930
|
+
return this;
|
|
1931
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
|
1932
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
|
1933
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
|
1934
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
|
1935
|
+
return result.done ? result.value : iter.next();
|
|
1936
|
+
});
|
|
1937
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
|
1938
|
+
return this;
|
|
1939
|
+
}), define(Gp, "toString", function () {
|
|
1940
|
+
return "[object Generator]";
|
|
1941
|
+
}), exports.keys = function (object) {
|
|
1942
|
+
var keys = [];
|
|
1943
|
+
|
|
1944
|
+
for (var key in object) {
|
|
1945
|
+
keys.push(key);
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
return keys.reverse(), function next() {
|
|
1949
|
+
for (; keys.length;) {
|
|
1950
|
+
var key = keys.pop();
|
|
1951
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
|
1952
|
+
}
|
|
1953
|
+
|
|
1954
|
+
return next.done = !0, next;
|
|
1955
|
+
};
|
|
1956
|
+
}, exports.values = values, Context.prototype = {
|
|
1957
|
+
constructor: Context,
|
|
1958
|
+
reset: function reset(skipTempReset) {
|
|
1959
|
+
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) {
|
|
1960
|
+
"t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
|
1961
|
+
}
|
|
1962
|
+
},
|
|
1963
|
+
stop: function stop() {
|
|
1964
|
+
this.done = !0;
|
|
1965
|
+
var rootRecord = this.tryEntries[0].completion;
|
|
1966
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
|
1967
|
+
return this.rval;
|
|
1968
|
+
},
|
|
1969
|
+
dispatchException: function dispatchException(exception) {
|
|
1970
|
+
if (this.done) throw exception;
|
|
1971
|
+
var context = this;
|
|
1972
|
+
|
|
1973
|
+
function handle(loc, caught) {
|
|
1974
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
|
1975
|
+
}
|
|
1976
|
+
|
|
1977
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
1978
|
+
var entry = this.tryEntries[i],
|
|
1979
|
+
record = entry.completion;
|
|
1980
|
+
if ("root" === entry.tryLoc) return handle("end");
|
|
1981
|
+
|
|
1982
|
+
if (entry.tryLoc <= this.prev) {
|
|
1983
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
|
1984
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
1985
|
+
|
|
1986
|
+
if (hasCatch && hasFinally) {
|
|
1987
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1988
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1989
|
+
} else if (hasCatch) {
|
|
1990
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
|
1991
|
+
} else {
|
|
1992
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
|
1993
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
}
|
|
1997
|
+
},
|
|
1998
|
+
abrupt: function abrupt(type, arg) {
|
|
1999
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2000
|
+
var entry = this.tryEntries[i];
|
|
2001
|
+
|
|
2002
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
2003
|
+
var finallyEntry = entry;
|
|
2004
|
+
break;
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
|
|
2008
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
|
2009
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
|
2010
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
|
2011
|
+
},
|
|
2012
|
+
complete: function complete(record, afterLoc) {
|
|
2013
|
+
if ("throw" === record.type) throw record.arg;
|
|
2014
|
+
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;
|
|
2015
|
+
},
|
|
2016
|
+
finish: function finish(finallyLoc) {
|
|
2017
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2018
|
+
var entry = this.tryEntries[i];
|
|
2019
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
|
2020
|
+
}
|
|
2021
|
+
},
|
|
2022
|
+
catch: function _catch(tryLoc) {
|
|
2023
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
|
2024
|
+
var entry = this.tryEntries[i];
|
|
2025
|
+
|
|
2026
|
+
if (entry.tryLoc === tryLoc) {
|
|
2027
|
+
var record = entry.completion;
|
|
2028
|
+
|
|
2029
|
+
if ("throw" === record.type) {
|
|
2030
|
+
var thrown = record.arg;
|
|
2031
|
+
resetTryEntry(entry);
|
|
2032
|
+
}
|
|
2033
|
+
|
|
2034
|
+
return thrown;
|
|
2035
|
+
}
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
throw new Error("illegal catch attempt");
|
|
2039
|
+
},
|
|
2040
|
+
delegateYield: function delegateYield(iterable, resultName, nextLoc) {
|
|
2041
|
+
return this.delegate = {
|
|
2042
|
+
iterator: values(iterable),
|
|
2043
|
+
resultName: resultName,
|
|
2044
|
+
nextLoc: nextLoc
|
|
2045
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
|
2046
|
+
}
|
|
2047
|
+
}, exports;
|
|
2048
|
+
}
|
|
2049
|
+
|
|
2050
|
+
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2051
|
+
try {
|
|
2052
|
+
var info = gen[key](arg);
|
|
2053
|
+
var value = info.value;
|
|
2054
|
+
} catch (error) {
|
|
2055
|
+
reject(error);
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
2058
|
+
|
|
2059
|
+
if (info.done) {
|
|
2060
|
+
resolve(value);
|
|
2061
|
+
} else {
|
|
2062
|
+
Promise.resolve(value).then(_next, _throw);
|
|
2063
|
+
}
|
|
2064
|
+
}
|
|
2065
|
+
|
|
2066
|
+
function _asyncToGenerator$1(fn) {
|
|
2067
|
+
return function () {
|
|
2068
|
+
var self = this,
|
|
2069
|
+
args = arguments;
|
|
2070
|
+
return new Promise(function (resolve, reject) {
|
|
2071
|
+
var gen = fn.apply(self, args);
|
|
2072
|
+
|
|
2073
|
+
function _next(value) {
|
|
2074
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
function _throw(err) {
|
|
2078
|
+
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
_next(undefined);
|
|
2082
|
+
});
|
|
2083
|
+
};
|
|
2084
|
+
}
|
|
2085
|
+
|
|
2086
|
+
var _class;
|
|
2087
|
+
|
|
2088
|
+
var LoadImagePlugin_1;
|
|
2089
|
+
var LoadImagePlugin = LoadImagePlugin_1 = (_class = /*#__PURE__*/function () {
|
|
2090
|
+
function LoadImagePlugin() {
|
|
2091
|
+
this.imagePool = void 0;
|
|
2092
|
+
this.renderingContext = void 0;
|
|
2093
|
+
}
|
|
2094
|
+
|
|
2095
|
+
var _proto = LoadImagePlugin.prototype;
|
|
2096
|
+
|
|
2097
|
+
_proto.apply = function apply(renderingService) {
|
|
2098
|
+
var _this = this;
|
|
2099
|
+
|
|
2100
|
+
var handleMounted = function handleMounted(e) {
|
|
2101
|
+
var object = e.target;
|
|
2102
|
+
var nodeName = object.nodeName,
|
|
2103
|
+
attributes = object.attributes;
|
|
2104
|
+
|
|
2105
|
+
if (nodeName === g.Shape.IMAGE) {
|
|
2106
|
+
var img = attributes.img;
|
|
2107
|
+
|
|
2108
|
+
if (g.isString(img)) {
|
|
2109
|
+
_this.imagePool.getImageSync(img, function () {
|
|
2110
|
+
// set dirty rectangle flag
|
|
2111
|
+
object.renderable.dirty = true;
|
|
2112
|
+
renderingService.dirtify();
|
|
2113
|
+
});
|
|
2114
|
+
}
|
|
2115
|
+
}
|
|
2116
|
+
};
|
|
2117
|
+
|
|
2118
|
+
var handleAttributeChanged = function handleAttributeChanged(e) {
|
|
2119
|
+
var object = e.target;
|
|
2120
|
+
var attrName = e.attrName,
|
|
2121
|
+
newValue = e.newValue;
|
|
2122
|
+
|
|
2123
|
+
if (object.nodeName === g.Shape.IMAGE) {
|
|
2124
|
+
if (attrName === 'img') {
|
|
2125
|
+
if (g.isString(newValue)) {
|
|
2126
|
+
_this.imagePool.getOrCreateImage(newValue).then(function () {
|
|
2127
|
+
// set dirty rectangle flag
|
|
2128
|
+
object.renderable.dirty = true;
|
|
2129
|
+
renderingService.dirtify();
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
};
|
|
2135
|
+
|
|
2136
|
+
renderingService.hooks.init.tapPromise(LoadImagePlugin_1.tag, /*#__PURE__*/_asyncToGenerator$1( /*#__PURE__*/_regeneratorRuntime$1().mark(function _callee() {
|
|
2137
|
+
return _regeneratorRuntime$1().wrap(function _callee$(_context) {
|
|
2138
|
+
while (1) {
|
|
2139
|
+
switch (_context.prev = _context.next) {
|
|
2140
|
+
case 0:
|
|
2141
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
2142
|
+
|
|
2143
|
+
_this.renderingContext.root.addEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2144
|
+
|
|
2145
|
+
case 2:
|
|
2146
|
+
case "end":
|
|
2147
|
+
return _context.stop();
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
}, _callee);
|
|
2151
|
+
})));
|
|
2152
|
+
renderingService.hooks.destroy.tap(LoadImagePlugin_1.tag, function () {
|
|
2153
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
2154
|
+
|
|
2155
|
+
_this.renderingContext.root.removeEventListener(g.ElementEvent.ATTR_MODIFIED, handleAttributeChanged);
|
|
2156
|
+
});
|
|
2157
|
+
};
|
|
2158
|
+
|
|
2159
|
+
return LoadImagePlugin;
|
|
2160
|
+
}(), _class.tag = 'LoadImage', _class);
|
|
2161
|
+
|
|
2162
|
+
__decorate([g.inject(ImagePool), __metadata("design:type", ImagePool)], LoadImagePlugin.prototype, "imagePool", void 0);
|
|
2163
|
+
|
|
2164
|
+
__decorate([g.inject(g.RenderingContext), __metadata("design:type", Object)], LoadImagePlugin.prototype, "renderingContext", void 0);
|
|
2165
|
+
|
|
2166
|
+
LoadImagePlugin = LoadImagePlugin_1 = __decorate([g.singleton({
|
|
2167
|
+
contrib: g.RenderingPluginContribution
|
|
2168
|
+
})], LoadImagePlugin);
|
|
2169
|
+
var containerModule = g.Module(function (register) {
|
|
2170
|
+
register(ImagePool);
|
|
2171
|
+
register(LoadImagePlugin);
|
|
2172
|
+
});
|
|
2173
|
+
|
|
2174
|
+
var Plugin = /*#__PURE__*/function () {
|
|
2175
|
+
function Plugin() {
|
|
2176
|
+
this.name = 'image-loader';
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
var _proto = Plugin.prototype;
|
|
2180
|
+
|
|
2181
|
+
_proto.init = function init(container) {
|
|
2182
|
+
container.load(containerModule, true);
|
|
2183
|
+
};
|
|
2184
|
+
|
|
2185
|
+
_proto.destroy = function destroy(container) {
|
|
2186
|
+
container.unload(containerModule);
|
|
2187
|
+
};
|
|
2188
|
+
|
|
2189
|
+
return Plugin;
|
|
2190
|
+
}();
|
|
2191
|
+
|
|
2192
|
+
var earcut_1 = earcut;
|
|
2193
|
+
var _default = earcut;
|
|
2194
|
+
|
|
2195
|
+
function earcut(data, holeIndices, dim) {
|
|
2196
|
+
|
|
2197
|
+
dim = dim || 2;
|
|
2198
|
+
|
|
2199
|
+
var hasHoles = holeIndices && holeIndices.length,
|
|
2200
|
+
outerLen = hasHoles ? holeIndices[0] * dim : data.length,
|
|
2201
|
+
outerNode = linkedList(data, 0, outerLen, dim, true),
|
|
2202
|
+
triangles = [];
|
|
2203
|
+
|
|
2204
|
+
if (!outerNode || outerNode.next === outerNode.prev) return triangles;
|
|
2205
|
+
|
|
2206
|
+
var minX, minY, maxX, maxY, x, y, invSize;
|
|
2207
|
+
|
|
2208
|
+
if (hasHoles) outerNode = eliminateHoles(data, holeIndices, outerNode, dim);
|
|
2209
|
+
|
|
2210
|
+
// if the shape is not too simple, we'll use z-order curve hash later; calculate polygon bbox
|
|
2211
|
+
if (data.length > 80 * dim) {
|
|
2212
|
+
minX = maxX = data[0];
|
|
2213
|
+
minY = maxY = data[1];
|
|
2214
|
+
|
|
2215
|
+
for (var i = dim; i < outerLen; i += dim) {
|
|
2216
|
+
x = data[i];
|
|
2217
|
+
y = data[i + 1];
|
|
2218
|
+
if (x < minX) minX = x;
|
|
2219
|
+
if (y < minY) minY = y;
|
|
2220
|
+
if (x > maxX) maxX = x;
|
|
2221
|
+
if (y > maxY) maxY = y;
|
|
2222
|
+
}
|
|
2223
|
+
|
|
2224
|
+
// minX, minY and invSize are later used to transform coords into integers for z-order calculation
|
|
2225
|
+
invSize = Math.max(maxX - minX, maxY - minY);
|
|
2226
|
+
invSize = invSize !== 0 ? 1 / invSize : 0;
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2229
|
+
earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
|
|
2230
|
+
|
|
2231
|
+
return triangles;
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
// create a circular doubly linked list from polygon points in the specified winding order
|
|
2235
|
+
function linkedList(data, start, end, dim, clockwise) {
|
|
2236
|
+
var i, last;
|
|
2237
|
+
|
|
2238
|
+
if (clockwise === (signedArea(data, start, end, dim) > 0)) {
|
|
2239
|
+
for (i = start; i < end; i += dim) last = insertNode(i, data[i], data[i + 1], last);
|
|
2240
|
+
} else {
|
|
2241
|
+
for (i = end - dim; i >= start; i -= dim) last = insertNode(i, data[i], data[i + 1], last);
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
if (last && equals(last, last.next)) {
|
|
2245
|
+
removeNode(last);
|
|
2246
|
+
last = last.next;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
return last;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
// eliminate colinear or duplicate points
|
|
2253
|
+
function filterPoints(start, end) {
|
|
2254
|
+
if (!start) return start;
|
|
2255
|
+
if (!end) end = start;
|
|
2256
|
+
|
|
2257
|
+
var p = start,
|
|
2258
|
+
again;
|
|
2259
|
+
do {
|
|
2260
|
+
again = false;
|
|
2261
|
+
|
|
2262
|
+
if (!p.steiner && (equals(p, p.next) || area(p.prev, p, p.next) === 0)) {
|
|
2263
|
+
removeNode(p);
|
|
2264
|
+
p = end = p.prev;
|
|
2265
|
+
if (p === p.next) break;
|
|
2266
|
+
again = true;
|
|
2267
|
+
|
|
2268
|
+
} else {
|
|
2269
|
+
p = p.next;
|
|
2270
|
+
}
|
|
2271
|
+
} while (again || p !== end);
|
|
2272
|
+
|
|
2273
|
+
return end;
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
// main ear slicing loop which triangulates a polygon (given as a linked list)
|
|
2277
|
+
function earcutLinked(ear, triangles, dim, minX, minY, invSize, pass) {
|
|
2278
|
+
if (!ear) return;
|
|
2279
|
+
|
|
2280
|
+
// interlink polygon nodes in z-order
|
|
2281
|
+
if (!pass && invSize) indexCurve(ear, minX, minY, invSize);
|
|
2282
|
+
|
|
2283
|
+
var stop = ear,
|
|
2284
|
+
prev, next;
|
|
2285
|
+
|
|
2286
|
+
// iterate through ears, slicing them one by one
|
|
2287
|
+
while (ear.prev !== ear.next) {
|
|
2288
|
+
prev = ear.prev;
|
|
2289
|
+
next = ear.next;
|
|
2290
|
+
|
|
2291
|
+
if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
|
|
2292
|
+
// cut off the triangle
|
|
2293
|
+
triangles.push(prev.i / dim);
|
|
2294
|
+
triangles.push(ear.i / dim);
|
|
2295
|
+
triangles.push(next.i / dim);
|
|
2296
|
+
|
|
2297
|
+
removeNode(ear);
|
|
2298
|
+
|
|
2299
|
+
// skipping the next vertex leads to less sliver triangles
|
|
2300
|
+
ear = next.next;
|
|
2301
|
+
stop = next.next;
|
|
2302
|
+
|
|
2303
|
+
continue;
|
|
2304
|
+
}
|
|
2305
|
+
|
|
2306
|
+
ear = next;
|
|
2307
|
+
|
|
2308
|
+
// if we looped through the whole remaining polygon and can't find any more ears
|
|
2309
|
+
if (ear === stop) {
|
|
2310
|
+
// try filtering points and slicing again
|
|
2311
|
+
if (!pass) {
|
|
2312
|
+
earcutLinked(filterPoints(ear), triangles, dim, minX, minY, invSize, 1);
|
|
2313
|
+
|
|
2314
|
+
// if this didn't work, try curing all small self-intersections locally
|
|
2315
|
+
} else if (pass === 1) {
|
|
2316
|
+
ear = cureLocalIntersections(filterPoints(ear), triangles, dim);
|
|
2317
|
+
earcutLinked(ear, triangles, dim, minX, minY, invSize, 2);
|
|
2318
|
+
|
|
2319
|
+
// as a last resort, try splitting the remaining polygon into two
|
|
2320
|
+
} else if (pass === 2) {
|
|
2321
|
+
splitEarcut(ear, triangles, dim, minX, minY, invSize);
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
break;
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
// check whether a polygon node forms a valid ear with adjacent nodes
|
|
2330
|
+
function isEar(ear) {
|
|
2331
|
+
var a = ear.prev,
|
|
2332
|
+
b = ear,
|
|
2333
|
+
c = ear.next;
|
|
2334
|
+
|
|
2335
|
+
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
2336
|
+
|
|
2337
|
+
// now make sure we don't have other points inside the potential ear
|
|
2338
|
+
var p = ear.next.next;
|
|
2339
|
+
|
|
2340
|
+
while (p !== ear.prev) {
|
|
2341
|
+
if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
|
|
2342
|
+
area(p.prev, p, p.next) >= 0) return false;
|
|
2343
|
+
p = p.next;
|
|
2344
|
+
}
|
|
2345
|
+
|
|
2346
|
+
return true;
|
|
2347
|
+
}
|
|
2348
|
+
|
|
2349
|
+
function isEarHashed(ear, minX, minY, invSize) {
|
|
2350
|
+
var a = ear.prev,
|
|
2351
|
+
b = ear,
|
|
2352
|
+
c = ear.next;
|
|
2353
|
+
|
|
2354
|
+
if (area(a, b, c) >= 0) return false; // reflex, can't be an ear
|
|
2355
|
+
|
|
2356
|
+
// triangle bbox; min & max are calculated like this for speed
|
|
2357
|
+
var minTX = a.x < b.x ? (a.x < c.x ? a.x : c.x) : (b.x < c.x ? b.x : c.x),
|
|
2358
|
+
minTY = a.y < b.y ? (a.y < c.y ? a.y : c.y) : (b.y < c.y ? b.y : c.y),
|
|
2359
|
+
maxTX = a.x > b.x ? (a.x > c.x ? a.x : c.x) : (b.x > c.x ? b.x : c.x),
|
|
2360
|
+
maxTY = a.y > b.y ? (a.y > c.y ? a.y : c.y) : (b.y > c.y ? b.y : c.y);
|
|
2361
|
+
|
|
2362
|
+
// z-order range for the current triangle bbox;
|
|
2363
|
+
var minZ = zOrder(minTX, minTY, minX, minY, invSize),
|
|
2364
|
+
maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
|
|
2365
|
+
|
|
2366
|
+
var p = ear.prevZ,
|
|
2367
|
+
n = ear.nextZ;
|
|
2368
|
+
|
|
2369
|
+
// look for points inside the triangle in both directions
|
|
2370
|
+
while (p && p.z >= minZ && n && n.z <= maxZ) {
|
|
2371
|
+
if (p !== ear.prev && p !== ear.next &&
|
|
2372
|
+
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
|
|
2373
|
+
area(p.prev, p, p.next) >= 0) return false;
|
|
2374
|
+
p = p.prevZ;
|
|
2375
|
+
|
|
2376
|
+
if (n !== ear.prev && n !== ear.next &&
|
|
2377
|
+
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
|
|
2378
|
+
area(n.prev, n, n.next) >= 0) return false;
|
|
2379
|
+
n = n.nextZ;
|
|
2380
|
+
}
|
|
2381
|
+
|
|
2382
|
+
// look for remaining points in decreasing z-order
|
|
2383
|
+
while (p && p.z >= minZ) {
|
|
2384
|
+
if (p !== ear.prev && p !== ear.next &&
|
|
2385
|
+
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) &&
|
|
2386
|
+
area(p.prev, p, p.next) >= 0) return false;
|
|
2387
|
+
p = p.prevZ;
|
|
2388
|
+
}
|
|
2389
|
+
|
|
2390
|
+
// look for remaining points in increasing z-order
|
|
2391
|
+
while (n && n.z <= maxZ) {
|
|
2392
|
+
if (n !== ear.prev && n !== ear.next &&
|
|
2393
|
+
pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) &&
|
|
2394
|
+
area(n.prev, n, n.next) >= 0) return false;
|
|
2395
|
+
n = n.nextZ;
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
return true;
|
|
2399
|
+
}
|
|
2400
|
+
|
|
2401
|
+
// go through all polygon nodes and cure small local self-intersections
|
|
2402
|
+
function cureLocalIntersections(start, triangles, dim) {
|
|
2403
|
+
var p = start;
|
|
2404
|
+
do {
|
|
2405
|
+
var a = p.prev,
|
|
2406
|
+
b = p.next.next;
|
|
2407
|
+
|
|
2408
|
+
if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
|
|
1755
2409
|
|
|
1756
2410
|
triangles.push(a.i / dim);
|
|
1757
2411
|
triangles.push(p.i / dim);
|
|
@@ -2436,9 +3090,9 @@
|
|
|
2436
3090
|
|
|
2437
3091
|
LightPool = __decorate([g.singleton()], LightPool);
|
|
2438
3092
|
|
|
2439
|
-
function _regeneratorRuntime$
|
|
3093
|
+
function _regeneratorRuntime$2() {
|
|
2440
3094
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
2441
|
-
_regeneratorRuntime$
|
|
3095
|
+
_regeneratorRuntime$2 = function _regeneratorRuntime() {
|
|
2442
3096
|
return exports;
|
|
2443
3097
|
};
|
|
2444
3098
|
|
|
@@ -2786,7 +3440,7 @@
|
|
|
2786
3440
|
}, exports;
|
|
2787
3441
|
}
|
|
2788
3442
|
|
|
2789
|
-
function asyncGeneratorStep$
|
|
3443
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2790
3444
|
try {
|
|
2791
3445
|
var info = gen[key](arg);
|
|
2792
3446
|
var value = info.value;
|
|
@@ -2802,7 +3456,7 @@
|
|
|
2802
3456
|
}
|
|
2803
3457
|
}
|
|
2804
3458
|
|
|
2805
|
-
function _asyncToGenerator$
|
|
3459
|
+
function _asyncToGenerator$2(fn) {
|
|
2806
3460
|
return function () {
|
|
2807
3461
|
var self = this,
|
|
2808
3462
|
args = arguments;
|
|
@@ -2810,11 +3464,11 @@
|
|
|
2810
3464
|
var gen = fn.apply(self, args);
|
|
2811
3465
|
|
|
2812
3466
|
function _next(value) {
|
|
2813
|
-
asyncGeneratorStep$
|
|
3467
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
2814
3468
|
}
|
|
2815
3469
|
|
|
2816
3470
|
function _throw(err) {
|
|
2817
|
-
asyncGeneratorStep$
|
|
3471
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2818
3472
|
}
|
|
2819
3473
|
|
|
2820
3474
|
_next(undefined);
|
|
@@ -2842,7 +3496,7 @@
|
|
|
2842
3496
|
}
|
|
2843
3497
|
|
|
2844
3498
|
function _extends() {
|
|
2845
|
-
_extends = Object.assign
|
|
3499
|
+
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
2846
3500
|
for (var i = 1; i < arguments.length; i++) {
|
|
2847
3501
|
var source = arguments[i];
|
|
2848
3502
|
|
|
@@ -2855,7 +3509,6 @@
|
|
|
2855
3509
|
|
|
2856
3510
|
return target;
|
|
2857
3511
|
};
|
|
2858
|
-
|
|
2859
3512
|
return _extends.apply(this, arguments);
|
|
2860
3513
|
}
|
|
2861
3514
|
|
|
@@ -2867,11 +3520,10 @@
|
|
|
2867
3520
|
}
|
|
2868
3521
|
|
|
2869
3522
|
function _setPrototypeOf$1(o, p) {
|
|
2870
|
-
_setPrototypeOf$1 = Object.setPrototypeOf
|
|
3523
|
+
_setPrototypeOf$1 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
2871
3524
|
o.__proto__ = p;
|
|
2872
3525
|
return o;
|
|
2873
3526
|
};
|
|
2874
|
-
|
|
2875
3527
|
return _setPrototypeOf$1(o, p);
|
|
2876
3528
|
}
|
|
2877
3529
|
|
|
@@ -6492,10 +7144,10 @@
|
|
|
6492
7144
|
return acc;
|
|
6493
7145
|
};
|
|
6494
7146
|
|
|
6495
|
-
_proto.values = /*#__PURE__*/_regeneratorRuntime$
|
|
7147
|
+
_proto.values = /*#__PURE__*/_regeneratorRuntime$2().mark(function values() {
|
|
6496
7148
|
var _iterator2, _step2, bucket, j;
|
|
6497
7149
|
|
|
6498
|
-
return _regeneratorRuntime$
|
|
7150
|
+
return _regeneratorRuntime$2().wrap(function values$(_context) {
|
|
6499
7151
|
while (1) {
|
|
6500
7152
|
switch (_context.prev = _context.next) {
|
|
6501
7153
|
case 0:
|
|
@@ -8760,23 +9412,25 @@
|
|
|
8760
9412
|
|
|
8761
9413
|
var TexturePool = /*#__PURE__*/function () {
|
|
8762
9414
|
function TexturePool() {
|
|
9415
|
+
this.imagePool = void 0;
|
|
8763
9416
|
this.offscreenCanvas = void 0;
|
|
8764
9417
|
this.renderingService = void 0;
|
|
8765
9418
|
this.canvasConfig = void 0;
|
|
8766
9419
|
this.textureCache = {};
|
|
8767
|
-
this.gradientCache = {};
|
|
8768
9420
|
}
|
|
8769
9421
|
|
|
8770
9422
|
var _proto = TexturePool.prototype;
|
|
8771
9423
|
|
|
8772
9424
|
_proto.getOrCreateTexture = function getOrCreateTexture(device, src, descriptor, successCallback) {
|
|
8773
|
-
var _this = this; //
|
|
9425
|
+
var _this = this; // use Image URL or src as cache key
|
|
9426
|
+
// @ts-ignore
|
|
8774
9427
|
|
|
8775
9428
|
|
|
8776
9429
|
var id = typeof src === 'string' ? src : src.src || '';
|
|
9430
|
+
var texture;
|
|
8777
9431
|
|
|
8778
|
-
if (!this.textureCache[id]) {
|
|
8779
|
-
|
|
9432
|
+
if (!id || !this.textureCache[id]) {
|
|
9433
|
+
texture = device.createTexture(_extends({
|
|
8780
9434
|
pixelFormat: Format.U8_RGBA_NORM,
|
|
8781
9435
|
width: 1,
|
|
8782
9436
|
height: 1,
|
|
@@ -8790,9 +9444,13 @@
|
|
|
8790
9444
|
immutable: false
|
|
8791
9445
|
}, descriptor));
|
|
8792
9446
|
|
|
8793
|
-
if (
|
|
8794
|
-
this.textureCache[id]
|
|
8795
|
-
|
|
9447
|
+
if (id) {
|
|
9448
|
+
this.textureCache[id] = texture;
|
|
9449
|
+
}
|
|
9450
|
+
|
|
9451
|
+
if (!g.isString(src)) {
|
|
9452
|
+
texture.setImageData(src);
|
|
9453
|
+
texture.emit(TextureEvent.LOADED);
|
|
8796
9454
|
this.renderingService.dirtify();
|
|
8797
9455
|
} else {
|
|
8798
9456
|
// @see https://github.com/antvis/g/issues/938
|
|
@@ -8825,10 +9483,11 @@
|
|
|
8825
9483
|
}
|
|
8826
9484
|
}
|
|
8827
9485
|
} else {
|
|
8828
|
-
this.textureCache[id]
|
|
9486
|
+
texture = this.textureCache[id];
|
|
9487
|
+
texture.emit(TextureEvent.LOADED);
|
|
8829
9488
|
}
|
|
8830
9489
|
|
|
8831
|
-
return
|
|
9490
|
+
return texture;
|
|
8832
9491
|
};
|
|
8833
9492
|
|
|
8834
9493
|
_proto.getOrCreateCanvas = function getOrCreateCanvas() {
|
|
@@ -8836,66 +9495,60 @@
|
|
|
8836
9495
|
};
|
|
8837
9496
|
|
|
8838
9497
|
_proto.getOrCreateGradient = function getOrCreateGradient(params) {
|
|
8839
|
-
var
|
|
8840
|
-
var type = params.type,
|
|
8841
|
-
x0 = params.x0,
|
|
8842
|
-
y0 = params.y0,
|
|
8843
|
-
x1 = params.x1,
|
|
8844
|
-
y1 = params.y1,
|
|
8845
|
-
steps = params.steps,
|
|
8846
|
-
width = params.width,
|
|
8847
|
-
height = params.height;
|
|
8848
|
-
var gradient = this.gradientCache[key];
|
|
8849
|
-
var canvas = this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas);
|
|
8850
|
-
var context = this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);
|
|
9498
|
+
var _this2 = this;
|
|
8851
9499
|
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
canvas.height = height; // needs only 1px height
|
|
9500
|
+
var instance = params.instance,
|
|
9501
|
+
gradients = params.gradients;
|
|
8855
9502
|
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
gradient = context.createLinearGradient(x0 * width, y0 * height, x1 * width, y1 * height);
|
|
8859
|
-
} else if (type === g.GradientPatternType.RadialGradient) {
|
|
8860
|
-
var r = Math.sqrt(width * width + height * height) / 2; // @see https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D/createRadialGradient
|
|
9503
|
+
var _instance$getGeometry = instance.getGeometryBounds(),
|
|
9504
|
+
halfExtents = _instance$getGeometry.halfExtents;
|
|
8861
9505
|
|
|
8862
|
-
|
|
8863
|
-
|
|
9506
|
+
var width = halfExtents[0] * 2 || 1;
|
|
9507
|
+
var height = halfExtents[1] * 2 || 1;
|
|
9508
|
+
var canvas = this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas);
|
|
9509
|
+
var context = this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);
|
|
9510
|
+
canvas.width = width;
|
|
9511
|
+
canvas.height = height;
|
|
9512
|
+
gradients.forEach(function (g) {
|
|
9513
|
+
var gradient = _this2.imagePool.getOrCreateGradient(_extends({
|
|
9514
|
+
type: g.type
|
|
9515
|
+
}, g.value, {
|
|
9516
|
+
width: width,
|
|
9517
|
+
height: height
|
|
9518
|
+
}), context); // used as canvas' ID
|
|
9519
|
+
// @ts-ignore
|
|
9520
|
+
// canvas.src = key;
|
|
8864
9521
|
|
|
8865
|
-
steps.forEach(function (_ref) {
|
|
8866
|
-
var _gradient;
|
|
8867
9522
|
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
this.gradientCache[key] = gradient;
|
|
8873
|
-
} // used as canvas' ID
|
|
8874
|
-
// @ts-ignore
|
|
9523
|
+
context.fillStyle = gradient;
|
|
9524
|
+
context.fillRect(0, 0, width, height);
|
|
9525
|
+
});
|
|
9526
|
+
};
|
|
8875
9527
|
|
|
9528
|
+
_proto.getOrCreatePattern = function getOrCreatePattern(pattern, instance, callback) {
|
|
9529
|
+
var image = pattern.image,
|
|
9530
|
+
repetition = pattern.repetition;
|
|
8876
9531
|
|
|
8877
|
-
|
|
9532
|
+
var _instance$getGeometry2 = instance.getGeometryBounds(),
|
|
9533
|
+
halfExtents = _instance$getGeometry2.halfExtents;
|
|
8878
9534
|
|
|
8879
|
-
|
|
8880
|
-
|
|
8881
|
-
|
|
9535
|
+
var width = halfExtents[0] * 2 || 1;
|
|
9536
|
+
var height = halfExtents[1] * 2 || 1;
|
|
9537
|
+
var canvas = this.offscreenCanvas.getOrCreateCanvas(this.canvasConfig.offscreenCanvas);
|
|
9538
|
+
var context = this.offscreenCanvas.getOrCreateContext(this.canvasConfig.offscreenCanvas);
|
|
9539
|
+
canvas.width = width;
|
|
9540
|
+
canvas.height = height;
|
|
9541
|
+
var src; // Image URL
|
|
9542
|
+
|
|
9543
|
+
if (g.isString(image)) {
|
|
9544
|
+
src = this.imagePool.getImageSync(image, callback);
|
|
9545
|
+
} else {
|
|
9546
|
+
src = image;
|
|
8882
9547
|
}
|
|
8883
|
-
};
|
|
8884
9548
|
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
x0 = params.x0,
|
|
8889
|
-
y0 = params.y0,
|
|
8890
|
-
x1 = params.x1,
|
|
8891
|
-
y1 = params.y1,
|
|
8892
|
-
r1 = params.r1,
|
|
8893
|
-
steps = params.steps,
|
|
8894
|
-
width = params.width,
|
|
8895
|
-
height = params.height;
|
|
8896
|
-
return "gradient-" + type + "-" + x0 + "-" + y0 + "-" + x1 + "-" + y1 + "-" + (r1 || 0) + "-" + width + "-" + height + "-" + steps.map(function (step) {
|
|
8897
|
-
return step.join('');
|
|
8898
|
-
}).join('-');
|
|
9549
|
+
var canvasPattern = src && context.createPattern(src, repetition);
|
|
9550
|
+
context.fillStyle = canvasPattern;
|
|
9551
|
+
context.fillRect(0, 0, width, height);
|
|
8899
9552
|
};
|
|
8900
9553
|
|
|
8901
9554
|
_proto.destroy = function destroy() {
|
|
@@ -8904,12 +9557,13 @@
|
|
|
8904
9557
|
}
|
|
8905
9558
|
|
|
8906
9559
|
this.textureCache = {};
|
|
8907
|
-
this.gradientCache = {};
|
|
8908
9560
|
};
|
|
8909
9561
|
|
|
8910
9562
|
return TexturePool;
|
|
8911
9563
|
}();
|
|
8912
9564
|
|
|
9565
|
+
__decorate([g.inject(ImagePool), __metadata("design:type", ImagePool)], TexturePool.prototype, "imagePool", void 0);
|
|
9566
|
+
|
|
8913
9567
|
__decorate([g.inject(g.OffscreenCanvasCreator), __metadata("design:type", g.OffscreenCanvasCreator)], TexturePool.prototype, "offscreenCanvas", void 0);
|
|
8914
9568
|
|
|
8915
9569
|
__decorate([g.inject(g.RenderingService), __metadata("design:type", g.RenderingService)], TexturePool.prototype, "renderingService", void 0);
|
|
@@ -9396,6 +10050,29 @@
|
|
|
9396
10050
|
|
|
9397
10051
|
_this2.renderingService.dirtify();
|
|
9398
10052
|
});
|
|
10053
|
+
};
|
|
10054
|
+
|
|
10055
|
+
_proto.shouldMergeColor = function shouldMergeColor(o1, o2, name) {
|
|
10056
|
+
// c1: CSSRGB | CSSGradientValue[] | Pattern, c2: CSSRGB | CSSGradientValue[] | Pattern
|
|
10057
|
+
// can't be merged if gradients & pattern used
|
|
10058
|
+
var source = o1.parsedStyle[name];
|
|
10059
|
+
var target = o2.parsedStyle[name]; // constant color value
|
|
10060
|
+
|
|
10061
|
+
if (source instanceof g.CSSRGB && target instanceof g.CSSRGB) {
|
|
10062
|
+
return true;
|
|
10063
|
+
} // pattern
|
|
10064
|
+
|
|
10065
|
+
|
|
10066
|
+
if (g.isPattern(source) && g.isPattern(target) && source.image === target.image) {
|
|
10067
|
+
return true;
|
|
10068
|
+
} // gradients
|
|
10069
|
+
|
|
10070
|
+
|
|
10071
|
+
if (Array.isArray(source) && Array.isArray(target) && o1.style[name] === o2.style[name]) {
|
|
10072
|
+
return true;
|
|
10073
|
+
}
|
|
10074
|
+
|
|
10075
|
+
return false;
|
|
9399
10076
|
}
|
|
9400
10077
|
/**
|
|
9401
10078
|
* should be merged into current InstancedMesh
|
|
@@ -9416,6 +10093,10 @@
|
|
|
9416
10093
|
return false;
|
|
9417
10094
|
}
|
|
9418
10095
|
|
|
10096
|
+
if (!this.shouldMergeColor(this.instance, object, 'fill') || !this.shouldMergeColor(this.instance, object, 'stroke')) {
|
|
10097
|
+
return false;
|
|
10098
|
+
}
|
|
10099
|
+
|
|
9419
10100
|
return true;
|
|
9420
10101
|
};
|
|
9421
10102
|
|
|
@@ -10094,47 +10775,58 @@
|
|
|
10094
10775
|
};
|
|
10095
10776
|
|
|
10096
10777
|
_proto.createFillGradientTextureMapping = function createFillGradientTextureMapping(objects) {
|
|
10097
|
-
var
|
|
10098
|
-
var fill = instance.nodeName === g.Shape.LINE ? instance.parsedStyle.stroke : instance.parsedStyle.fill; // use pattern & gradient
|
|
10778
|
+
var _this6 = this;
|
|
10099
10779
|
|
|
10100
|
-
|
|
10101
|
-
|
|
10780
|
+
var instance = objects[0];
|
|
10781
|
+
var fill = instance.nodeName === g.Shape.LINE ? instance.parsedStyle.stroke : instance.parsedStyle.fill;
|
|
10782
|
+
var texImageSource; // use pattern & gradient
|
|
10102
10783
|
|
|
10103
|
-
|
|
10784
|
+
if (fill && (g.isPattern(fill) || Array.isArray(fill))) {
|
|
10785
|
+
if (Array.isArray(fill)) {
|
|
10104
10786
|
this.program.setDefineBool('USE_PATTERN', false);
|
|
10105
|
-
this.texturePool.getOrCreateGradient(
|
|
10106
|
-
|
|
10107
|
-
}, fill.value, {
|
|
10787
|
+
this.texturePool.getOrCreateGradient({
|
|
10788
|
+
gradients: fill,
|
|
10108
10789
|
width: 128,
|
|
10109
|
-
height: 128
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
} else {
|
|
10113
|
-
this.program.setDefineBool('USE_PATTERN', true);
|
|
10114
|
-
|
|
10115
|
-
|
|
10790
|
+
height: 128,
|
|
10791
|
+
instance: instance
|
|
10792
|
+
});
|
|
10793
|
+
} else if (g.isPattern(fill)) {
|
|
10794
|
+
this.program.setDefineBool('USE_PATTERN', true);
|
|
10795
|
+
this.texturePool.getOrCreatePattern(fill, instance, function () {
|
|
10796
|
+
// need re-render
|
|
10797
|
+
objects.forEach(function (object) {
|
|
10798
|
+
object.renderable.dirty = true;
|
|
10799
|
+
});
|
|
10800
|
+
_this6.material.textureDirty = true;
|
|
10801
|
+
});
|
|
10116
10802
|
}
|
|
10117
10803
|
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10804
|
+
texImageSource = this.texturePool.getOrCreateCanvas();
|
|
10805
|
+
var texture = this.texturePool.getOrCreateTexture(this.device, texImageSource, makeTextureDescriptor2D(Format.U8_RGBA_NORM, 1, 1, 1));
|
|
10806
|
+
|
|
10807
|
+
if (texture) {
|
|
10808
|
+
var fillMapping = new TextureMapping();
|
|
10809
|
+
fillMapping.name = FILL_TEXTURE_MAPPING;
|
|
10810
|
+
fillMapping.texture = texture;
|
|
10811
|
+
fillMapping.texture.on('loaded', function () {
|
|
10812
|
+
// need re-render
|
|
10813
|
+
objects.forEach(function (object) {
|
|
10814
|
+
object.renderable.dirty = true;
|
|
10815
|
+
});
|
|
10816
|
+
_this6.material.textureDirty = true;
|
|
10125
10817
|
});
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10818
|
+
this.device.setResourceName(fillMapping.texture, 'Fill Texture' + this.id);
|
|
10819
|
+
fillMapping.sampler = this.renderHelper.getCache().createSampler({
|
|
10820
|
+
wrapS: WrapMode.Repeat,
|
|
10821
|
+
wrapT: WrapMode.Repeat,
|
|
10822
|
+
minFilter: TexFilterMode.Point,
|
|
10823
|
+
magFilter: TexFilterMode.Bilinear,
|
|
10824
|
+
mipFilter: MipFilterMode.Linear,
|
|
10825
|
+
minLOD: 0,
|
|
10826
|
+
maxLOD: 0
|
|
10827
|
+
});
|
|
10828
|
+
return fillMapping;
|
|
10829
|
+
}
|
|
10138
10830
|
}
|
|
10139
10831
|
|
|
10140
10832
|
return null;
|
|
@@ -10390,18 +11082,6 @@
|
|
|
10390
11082
|
|
|
10391
11083
|
if (!shouldMerge) {
|
|
10392
11084
|
return false;
|
|
10393
|
-
} // should split when using gradient & pattern
|
|
10394
|
-
|
|
10395
|
-
|
|
10396
|
-
var instance = this.instance;
|
|
10397
|
-
|
|
10398
|
-
if (instance.nodeName === g.Shape.LINE) {
|
|
10399
|
-
var source = instance.parsedStyle.stroke;
|
|
10400
|
-
var target = object.parsedStyle.stroke; // can't be merged if stroke's types are different
|
|
10401
|
-
|
|
10402
|
-
if (source.toString() !== target.toString()) {
|
|
10403
|
-
return false;
|
|
10404
|
-
}
|
|
10405
11085
|
}
|
|
10406
11086
|
|
|
10407
11087
|
return true;
|
|
@@ -10951,9 +11631,9 @@
|
|
|
10951
11631
|
return piMod(Math.atan2(dy, dx));
|
|
10952
11632
|
}
|
|
10953
11633
|
};
|
|
10954
|
-
var frag$2 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4
|
|
11634
|
+
var frag$2 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nin vec4 v_Distance;\nin vec4 v_Arc;\nin float v_Type;\nin float v_Travel;\n\nout vec4 outputColor;\n\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\n\n float alpha = 1.0;\n float lineWidth = v_Distance.w;\n if (v_Type < 0.5) {\n float left = max(v_Distance.x - 0.5, -v_Distance.w);\n float right = min(v_Distance.x + 0.5, v_Distance.w);\n float near = v_Distance.y - 0.5;\n float far = min(v_Distance.y + 0.5, 0.0);\n float top = v_Distance.z - 0.5;\n float bottom = min(v_Distance.z + 0.5, 0.0);\n alpha = max(right - left, 0.0) * max(bottom - top, 0.0) * max(far - near, 0.0);\n } else if (v_Type < 1.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n } else if (v_Type < 2.5) {\n alpha *= max(min(v_Distance.x + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.y + 0.5, 1.0), 0.0);\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n } else if (v_Type < 3.5) {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n float alpha_miter = a2 * b2 - a1 * b1;\n float alpha_plane = max(min(v_Distance.z + 0.5, 1.0), 0.0);\n float d = length(v_Arc.xy);\n float circle_hor = max(min(v_Arc.w, d + 0.5) - max(-v_Arc.w, d - 0.5), 0.0);\n float circle_vert = min(v_Arc.w * 2.0, 1.0);\n float alpha_circle = circle_hor * circle_vert;\n alpha = min(alpha_miter, max(alpha_circle, alpha_plane));\n } else {\n float a1 = clamp(v_Distance.x + 0.5 - lineWidth, 0.0, 1.0);\n float a2 = clamp(v_Distance.x + 0.5 + lineWidth, 0.0, 1.0);\n float b1 = clamp(v_Distance.y + 0.5 - lineWidth, 0.0, 1.0);\n float b2 = clamp(v_Distance.y + 0.5 + lineWidth, 0.0, 1.0);\n alpha = a2 * b2 - a1 * b1;\n alpha *= max(min(v_Distance.z + 0.5, 1.0), 0.0);\n }\n\n if (u_Dash + u_Gap > 1.0) {\n float scalingFactor = sqrt(u_ModelMatrix[0][0] * u_ModelMatrix[0][0] + u_ModelMatrix[0][1] * u_ModelMatrix[0][1] + u_ModelMatrix[0][2] * u_ModelMatrix[0][2]);\n float travel = mod(v_Travel + u_Gap * scalingFactor * 0.5 + u_DashOffset, u_Dash * scalingFactor + u_Gap * scalingFactor) - (u_Gap * scalingFactor * 0.5);\n float left = max(travel - 0.5, -0.5);\n float right = min(travel + 0.5, u_Gap * scalingFactor + 0.5);\n alpha *= max(0.0, right - left);\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n outputColor = u_StrokeColor;\n outputColor.a *= alpha * u_Opacity * u_StrokeOpacity;\n }\n}"; // eslint-disable-line
|
|
10955
11635
|
|
|
10956
|
-
var vert$2 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_Color;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nlayout(location = PREV) in vec2 a_Prev;\nlayout(location = POINT1) in vec2 a_Point1;\nlayout(location = POINT2) in vec2 a_Point2;\nlayout(location = NEXT) in vec2 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvoid main() {\n vec2 pointA = (u_ModelMatrix * vec4(a_Point1, 0., 1.0)).xy;\n vec2 pointB = (u_ModelMatrix * vec4(a_Point2, 0., 1.0)).xy;\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n next = (u_ModelMatrix * vec4(a_Prev, 0.0, 1.0)).xy;\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 0.0, 1.0)).xy;\n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n //TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n}"; // eslint-disable-line
|
|
11636
|
+
var vert$2 = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec4 u_StrokeColor;\n float u_StrokeWidth;\n float u_Opacity;\n float u_FillOpacity;\n float u_StrokeOpacity;\n float u_Expand;\n float u_MiterLimit;\n float u_ScaleMode;\n float u_Alignment;\n vec3 u_PickingColor;\n float u_Dash;\n float u_Gap;\n float u_DashOffset;\n float u_Visible;\n float u_ZIndex;\n float u_IncreasedLineWidthForHitTesting;\n};\n\nlayout(location = PREV) in vec2 a_Prev;\nlayout(location = POINT1) in vec2 a_Point1;\nlayout(location = POINT2) in vec2 a_Point2;\nlayout(location = NEXT) in vec2 a_Next;\nlayout(location = VERTEX_JOINT) in float a_VertexJoint;\nlayout(location = VERTEX_NUM) in float a_VertexNum;\nlayout(location = TRAVEL) in float a_Travel;\n\nconst float FILL = 1.0;\nconst float BEVEL = 4.0;\nconst float MITER = 8.0;\nconst float ROUND = 12.0;\nconst float JOINT_CAP_BUTT = 16.0;\nconst float JOINT_CAP_SQUARE = 18.0;\nconst float JOINT_CAP_ROUND = 20.0;\nconst float FILL_EXPAND = 24.0;\nconst float CAP_BUTT = 1.0;\nconst float CAP_SQUARE = 2.0;\nconst float CAP_ROUND = 3.0;\nconst float CAP_BUTT2 = 4.0;\n\nout vec4 v_Distance;\nout vec4 v_Arc;\nout float v_Type;\nout float v_Travel;\n\nvec2 doBisect(\n vec2 norm, float len, vec2 norm2, float len2, float dy, float inner\n) {\n vec2 bisect = (norm + norm2) / 2.0;\n bisect /= dot(norm, bisect);\n vec2 shift = dy * bisect;\n if (inner > 0.5) {\n if (len < len2) {\n if (abs(dy * (bisect.x * norm.y - bisect.y * norm.x)) > len) {\n return dy * norm;\n }\n } else {\n if (abs(dy * (bisect.x * norm2.y - bisect.y * norm2.x)) > len2) {\n return dy * norm;\n }\n }\n }\n return dy * bisect;\n}\n\nvoid main() {\n vec2 pointA = (u_ModelMatrix * vec4(a_Point1, 0., 1.0)).xy;\n vec2 pointB = (u_ModelMatrix * vec4(a_Point2, 0., 1.0)).xy;\n\n vec2 xBasis = pointB - pointA;\n float len = length(xBasis);\n vec2 forward = xBasis / len;\n vec2 norm = vec2(forward.y, -forward.x);\n\n float type = a_VertexJoint;\n\n float lineWidth;\n if (u_IsPicking > 0.5) {\n lineWidth = u_IncreasedLineWidthForHitTesting + u_StrokeWidth;\n } else {\n lineWidth = u_StrokeWidth;\n }\n\n if (u_ScaleMode > 2.5) {\n lineWidth *= length(u_ModelMatrix * vec4(1.0, 0.0, 0.0, 0.0));\n } else if (u_ScaleMode > 1.5) {\n lineWidth *= length(u_ModelMatrix * vec4(0.0, 1.0, 0.0, 0.0));\n } else if (u_ScaleMode > 0.5) {\n vec2 avgDiag = (u_ModelMatrix * vec4(1.0, 1.0, 0.0, 0.0)).xy;\n lineWidth *= sqrt(dot(avgDiag, avgDiag) * 0.5);\n }\n float capType = floor(type / 32.0);\n type -= capType * 32.0;\n v_Arc = vec4(0.0);\n lineWidth *= 0.5;\n float lineAlignment = 2.0 * u_Alignment - 1.0;\n\n vec2 pos;\n\n if (capType == CAP_ROUND) {\n if (a_VertexNum < 3.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n type = JOINT_CAP_ROUND;\n capType = 0.0;\n }\n\n if (type >= BEVEL) {\n float dy = lineWidth + u_Expand;\n float inner = 0.0;\n if (a_VertexNum >= 1.5) {\n dy = -dy;\n inner = 1.0;\n }\n\n vec2 base, next, xBasis2, bisect;\n float flag = 0.0;\n float sign2 = 1.0;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5 && a_VertexNum < 3.5) {\n next = (u_ModelMatrix * vec4(a_Prev, 0.0, 1.0)).xy;\n base = pointA;\n flag = type - floor(type / 2.0) * 2.0;\n sign2 = -1.0;\n\n } else {\n next = (u_ModelMatrix * vec4(a_Next, 0.0, 1.0)).xy;\n base = pointB;\n if (type >= MITER && type < MITER + 3.5) {\n flag = step(MITER + 1.5, type);\n // check miter limit here?\n }\n }\n xBasis2 = next - base;\n float len2 = length(xBasis2);\n vec2 norm2 = vec2(xBasis2.y, -xBasis2.x) / len2;\n float D = norm.x * norm2.y - norm.y * norm2.x;\n if (D < 0.0) {\n inner = 1.0 - inner;\n }\n norm2 *= sign2;\n\n if (abs(lineAlignment) > 0.01) {\n float shift = lineWidth * lineAlignment;\n pointA += norm * shift;\n pointB += norm * shift;\n if (abs(D) < 0.01) {\n base += norm * shift;\n } else {\n base += doBisect(norm, len, norm2, len2, shift, 0.0);\n }\n }\n\n float collinear = step(0.0, dot(norm, norm2));\n v_Type = 0.0;\n float dy2 = -1000.0;\n float dy3 = -1000.0;\n if (abs(D) < 0.01 && collinear < 0.5) {\n if (type >= ROUND && type < ROUND + 1.5) {\n type = JOINT_CAP_ROUND;\n }\n //TODO: BUTT here too\n }\n\n if (a_VertexNum < 3.5) {\n if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (flag < 0.5 && inner < 0.5) {\n pos = dy * norm;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, inner);\n }\n }\n if (capType >= CAP_BUTT && capType < CAP_ROUND) {\n float extra = step(CAP_SQUARE, capType) * lineWidth;\n vec2 back = -forward;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n pos += back * (u_Expand + extra);\n dy2 = u_Expand;\n } else {\n dy2 = dot(pos + base - pointA, back) - extra;\n }\n }\n if (type >= JOINT_CAP_BUTT && type < JOINT_CAP_SQUARE + 0.5) {\n float extra = step(JOINT_CAP_SQUARE, type) * lineWidth;\n if (a_VertexNum < 0.5 || a_VertexNum > 2.5) {\n dy3 = dot(pos + base - pointB, forward) - extra;\n } else {\n pos += forward * (u_Expand + extra);\n dy3 = u_Expand;\n if (capType >= CAP_BUTT) {\n dy2 -= u_Expand + extra;\n }\n }\n }\n } else if (type >= JOINT_CAP_ROUND && type < JOINT_CAP_ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n vec2 d2 = abs(dy) * forward;\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = dy * norm;\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum < 6.5) {\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n } else {\n dy = -dy;\n pos = dy * norm + d2;\n v_Arc.x = abs(dy);\n }\n dy2 = 0.0;\n v_Arc.y = dy;\n v_Arc.z = 0.0;\n v_Arc.w = lineWidth;\n v_Type = 3.0;\n } else if (abs(D) < 0.01) {\n pos = dy * norm;\n } else {\n if (type >= ROUND && type < ROUND + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n float d2 = abs(dy);\n if (length(pos) > abs(dy) * 1.5) {\n if (a_VertexNum < 6.5) {\n pos.x = dy * norm.x - d2 * norm.y;\n pos.y = dy * norm.y + d2 * norm.x;\n } else {\n pos.x = dy * norm2.x + d2 * norm2.y;\n pos.y = dy * norm2.y - d2 * norm2.x;\n }\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n v_Arc.x = sign * dot(pos, norm3);\n v_Arc.y = pos.x * norm3.y - pos.y * norm3.x;\n v_Arc.z = dot(norm, norm3) * lineWidth;\n v_Arc.w = lineWidth;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = v_Arc.z - v_Arc.x;\n v_Type = 3.0;\n } else {\n float hit = 0.0;\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (dot(norm, norm2) > 0.0) {\n type = MITER;\n }\n }\n if (type >= MITER && type < MITER + 3.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float sign = step(0.0, dy) * 2.0 - 1.0;\n pos = doBisect(norm, len, norm2, len2, dy, 0.0);\n if (length(pos) > abs(dy) * u_MiterLimit) {\n type = BEVEL;\n } else {\n if (a_VertexNum < 4.5) {\n dy = -dy;\n pos = doBisect(norm, len, norm2, len2, dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 6.5) {\n pos = dy * norm2;\n }\n v_Type = 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n hit = 1.0;\n }\n }\n if (type >= BEVEL && type < BEVEL + 1.5) {\n if (inner > 0.5) {\n dy = -dy;\n inner = 0.0;\n }\n float d2 = abs(dy);\n vec2 pos3 = vec2(dy * norm.x - d2 * norm.y, dy * norm.y + d2 * norm.x);\n vec2 pos4 = vec2(dy * norm2.x + d2 * norm2.y, dy * norm2.y - d2 * norm2.x);\n if (a_VertexNum < 4.5) {\n pos = doBisect(norm, len, norm2, len2, -dy, 1.0);\n } else if (a_VertexNum < 5.5) {\n pos = dy * norm;\n } else if (a_VertexNum > 7.5) {\n pos = dy * norm2;\n } else {\n if (a_VertexNum < 6.5) {\n pos = pos3;\n } else {\n pos = pos4;\n }\n }\n vec2 norm3 = normalize(norm + norm2);\n float sign = step(0.0, dy) * 2.0 - 1.0;\n dy = -sign * dot(pos, norm);\n dy2 = -sign * dot(pos, norm2);\n dy3 = (-sign * dot(pos, norm3)) + lineWidth;\n v_Type = 4.0;\n hit = 1.0;\n }\n if (hit < 0.5) {\n gl_Position = vec4(0.0, 0.0, 0.0, 1.0);\n return;\n }\n }\n }\n pos += base;\n v_Distance = vec4(dy, dy2, dy3, lineWidth) * u_DevicePixelRatio;\n v_Arc = v_Arc * u_DevicePixelRatio;\n v_Travel = a_Travel + dot(pos - pointA, vec2(-norm.y, norm.x));\n }\n\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * vec4(pos, u_ZIndex, 1.0);\n}"; // eslint-disable-line
|
|
10957
11637
|
|
|
10958
11638
|
var JOINT_TYPE;
|
|
10959
11639
|
|
|
@@ -11000,7 +11680,7 @@
|
|
|
11000
11680
|
|
|
11001
11681
|
(function (Uniform) {
|
|
11002
11682
|
Uniform["MODEL_MATRIX"] = "u_ModelMatrix";
|
|
11003
|
-
Uniform["
|
|
11683
|
+
Uniform["FILL_COLOR"] = "u_FillColor";
|
|
11004
11684
|
Uniform["STROKE_COLOR"] = "u_StrokeColor";
|
|
11005
11685
|
Uniform["STROKE_WIDTH"] = "u_StrokeWidth";
|
|
11006
11686
|
Uniform["INCREASED_LINE_WIDTH_FOR_HIT_TESTING"] = "u_IncreasedLineWidthForHitTesting";
|
|
@@ -11179,7 +11859,7 @@
|
|
|
11179
11859
|
var m = create();
|
|
11180
11860
|
mul(m, instance.getWorldTransform(), // apply anchor
|
|
11181
11861
|
fromTranslation(m, fromValues$1(translateX, translateY, 0)));
|
|
11182
|
-
this.material.setUniforms((_this$material$setUni13 = {}, _this$material$setUni13[Uniform.MODEL_MATRIX] = m, _this$material$setUni13[Uniform.
|
|
11862
|
+
this.material.setUniforms((_this$material$setUni13 = {}, _this$material$setUni13[Uniform.MODEL_MATRIX] = m, _this$material$setUni13[Uniform.FILL_COLOR] = fillColor, _this$material$setUni13[Uniform.STROKE_COLOR] = strokeColor, _this$material$setUni13[Uniform.STROKE_WIDTH] = lineWidth.value, _this$material$setUni13[Uniform.INCREASED_LINE_WIDTH_FOR_HIT_TESTING] = increasedLineWidthForHitTesting.value, _this$material$setUni13[Uniform.OPACITY] = opacity.value, _this$material$setUni13[Uniform.FILL_OPACITY] = fillOpacity.value, _this$material$setUni13[Uniform.STROKE_OPACITY] = strokeOpacity.value, _this$material$setUni13[Uniform.EXPAND] = 1, _this$material$setUni13[Uniform.MITER_LIMIT] = 5, _this$material$setUni13[Uniform.SCALE_MODE] = 1, _this$material$setUni13[Uniform.ALIGNMENT] = 0.5, _this$material$setUni13[Uniform.PICKING_COLOR] = encodedPickingColor, _this$material$setUni13[Uniform.DASH] = lineDash && ((_lineDash$ = lineDash[0]) === null || _lineDash$ === void 0 ? void 0 : _lineDash$.value) || 0, _this$material$setUni13[Uniform.GAP] = lineDash && ((_lineDash$2 = lineDash[1]) === null || _lineDash$2 === void 0 ? void 0 : _lineDash$2.value) || 0, _this$material$setUni13[Uniform.DASH_OFFSET] = lineDashOffset && lineDashOffset.value || 0, _this$material$setUni13[Uniform.VISIBLE] = visibility.value === 'visible' ? 1 : 0, _this$material$setUni13[Uniform.Z_INDEX] = instance.sortable.renderOrder * RENDER_ORDER_SCALE, _this$material$setUni13));
|
|
11183
11863
|
this.material.cullMode = CullMode.None;
|
|
11184
11864
|
};
|
|
11185
11865
|
|
|
@@ -11323,7 +12003,7 @@
|
|
|
11323
12003
|
var triangles = [];
|
|
11324
12004
|
|
|
11325
12005
|
if (object.nodeName === g.Shape.POLYLINE || object.nodeName === g.Shape.POLYGON) {
|
|
11326
|
-
points = object.parsedStyle.points.points.reduce(function (prev, cur) {
|
|
12006
|
+
points[0] = object.parsedStyle.points.points.reduce(function (prev, cur) {
|
|
11327
12007
|
prev.push(cur[0] - defX, cur[1] - defY);
|
|
11328
12008
|
return prev;
|
|
11329
12009
|
}, []); // close polygon, dealing with extra joint
|
|
@@ -11331,19 +12011,19 @@
|
|
|
11331
12011
|
if (object.nodeName === g.Shape.POLYGON) {
|
|
11332
12012
|
if (needEarcut) {
|
|
11333
12013
|
// use earcut for triangulation
|
|
11334
|
-
triangles = earcut_1(points, [], 2);
|
|
12014
|
+
triangles = earcut_1(points[0], [], 2);
|
|
11335
12015
|
return {
|
|
11336
|
-
pointsBuffer: points,
|
|
12016
|
+
pointsBuffer: points[0],
|
|
11337
12017
|
travelBuffer: [],
|
|
11338
12018
|
triangles: triangles,
|
|
11339
|
-
instancedCount: Math.round(points.length / stridePoints)
|
|
12019
|
+
instancedCount: Math.round(points[0].length / stridePoints)
|
|
11340
12020
|
};
|
|
11341
12021
|
} else {
|
|
11342
|
-
var _points
|
|
12022
|
+
var _points$;
|
|
11343
12023
|
|
|
11344
|
-
points.push(points[0], points[1]);
|
|
12024
|
+
points[0].push(points[0][0], points[0][1]);
|
|
11345
12025
|
|
|
11346
|
-
(_points = points).push.apply(_points
|
|
12026
|
+
(_points$ = points[0]).push.apply(_points$, addTailSegment(points[0][0], points[0][1], points[0][2], points[0][3]));
|
|
11347
12027
|
}
|
|
11348
12028
|
}
|
|
11349
12029
|
} else if (object.nodeName === g.Shape.PATH || object.nodeName === g.Shape.CIRCLE || object.nodeName === g.Shape.ELLIPSE || object.nodeName === g.Shape.RECT) {
|
|
@@ -11352,7 +12032,21 @@
|
|
|
11352
12032
|
if (object.nodeName !== g.Shape.PATH) {
|
|
11353
12033
|
path = g.parsePath(g.convertToPath(object, false), object);
|
|
11354
12034
|
defX = path.rect.x;
|
|
11355
|
-
defY = path.rect.y;
|
|
12035
|
+
defY = path.rect.y; // support negative width/height of Rect
|
|
12036
|
+
|
|
12037
|
+
if (object.nodeName === g.Shape.RECT) {
|
|
12038
|
+
var _object$parsedStyle4 = object.parsedStyle,
|
|
12039
|
+
width = _object$parsedStyle4.width,
|
|
12040
|
+
height = _object$parsedStyle4.height;
|
|
12041
|
+
|
|
12042
|
+
if (width.value < 0) {
|
|
12043
|
+
defX += path.rect.width;
|
|
12044
|
+
}
|
|
12045
|
+
|
|
12046
|
+
if (height.value < 0) {
|
|
12047
|
+
defY += path.rect.height;
|
|
12048
|
+
}
|
|
12049
|
+
}
|
|
11356
12050
|
} else {
|
|
11357
12051
|
path = object.parsedStyle.path;
|
|
11358
12052
|
}
|
|
@@ -11363,36 +12057,43 @@
|
|
|
11363
12057
|
return zCommandIndexes.includes(i) ? ['Z'] : c;
|
|
11364
12058
|
});
|
|
11365
12059
|
var startPointIndex = -1;
|
|
12060
|
+
var mCommandsNum = -1;
|
|
11366
12061
|
curve.forEach(function (_ref) {
|
|
11367
12062
|
var command = _ref[0],
|
|
11368
12063
|
params = _ref.slice(1);
|
|
11369
12064
|
|
|
11370
12065
|
if (command === 'M') {
|
|
11371
|
-
|
|
11372
|
-
points
|
|
12066
|
+
mCommandsNum++;
|
|
12067
|
+
points[mCommandsNum] = [];
|
|
12068
|
+
startPointIndex = points[mCommandsNum].length;
|
|
12069
|
+
points[mCommandsNum].push(params[0] - defX, params[1] - defY);
|
|
11373
12070
|
} else if (command === 'C') {
|
|
11374
|
-
curveTo(params[0] - defX, params[1] - defY, params[2] - defX, params[3] - defY, params[4] - defX, params[5] - defY, points);
|
|
12071
|
+
curveTo(params[0] - defX, params[1] - defY, params[2] - defX, params[3] - defY, params[4] - defX, params[5] - defY, points[mCommandsNum]);
|
|
11375
12072
|
} else if (command === 'Z' && (object.nodeName === g.Shape.PATH || object.nodeName === g.Shape.RECT)) {
|
|
11376
|
-
var
|
|
12073
|
+
var _points$mCommandsNum;
|
|
11377
12074
|
|
|
11378
12075
|
var epsilon = 0.0001; // skip if already closed
|
|
11379
12076
|
|
|
11380
|
-
if (Math.abs(points[points.length - 2] - points[startPointIndex]) > epsilon || Math.abs(points[points.length - 1] - points[startPointIndex + 1]) > epsilon) {
|
|
11381
|
-
points.push(points[startPointIndex], points[startPointIndex + 1]);
|
|
12077
|
+
if (Math.abs(points[mCommandsNum][points[mCommandsNum].length - 2] - points[mCommandsNum][startPointIndex]) > epsilon || Math.abs(points[mCommandsNum][points[mCommandsNum].length - 1] - points[mCommandsNum][startPointIndex + 1]) > epsilon) {
|
|
12078
|
+
points[mCommandsNum].push(points[mCommandsNum][startPointIndex], points[mCommandsNum][startPointIndex + 1]);
|
|
11382
12079
|
}
|
|
11383
12080
|
|
|
11384
|
-
(
|
|
12081
|
+
(_points$mCommandsNum = points[mCommandsNum]).push.apply(_points$mCommandsNum, addTailSegment(points[mCommandsNum][startPointIndex], points[mCommandsNum][startPointIndex + 1], points[mCommandsNum][startPointIndex + 2], points[mCommandsNum][startPointIndex + 3]));
|
|
11385
12082
|
}
|
|
11386
12083
|
});
|
|
11387
12084
|
|
|
11388
12085
|
if (needEarcut) {
|
|
11389
|
-
|
|
11390
|
-
|
|
12086
|
+
var pointsBuffer = points.reduce(function (prev, cur) {
|
|
12087
|
+
prev.push.apply(prev, cur);
|
|
12088
|
+
return prev;
|
|
12089
|
+
}, []); // use earcut for triangulation
|
|
12090
|
+
|
|
12091
|
+
triangles = earcut_1(pointsBuffer, [], 2);
|
|
11391
12092
|
return {
|
|
11392
|
-
pointsBuffer:
|
|
12093
|
+
pointsBuffer: pointsBuffer,
|
|
11393
12094
|
travelBuffer: [],
|
|
11394
12095
|
triangles: triangles,
|
|
11395
|
-
instancedCount: Math.round(
|
|
12096
|
+
instancedCount: Math.round(pointsBuffer.length / stridePoints)
|
|
11396
12097
|
};
|
|
11397
12098
|
}
|
|
11398
12099
|
}
|
|
@@ -11413,56 +12114,72 @@
|
|
|
11413
12114
|
endJoint = JOINT_TYPE.JOINT_CAP_SQUARE;
|
|
11414
12115
|
}
|
|
11415
12116
|
|
|
11416
|
-
|
|
12117
|
+
return points.map(function (points) {
|
|
12118
|
+
var j = (Math.round(0 / stridePoints) + 2) * strideFloats; // const needDash = !isNil(lineDash);
|
|
11417
12119
|
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
12120
|
+
var dist = 0;
|
|
12121
|
+
var pointsBuffer = [];
|
|
12122
|
+
var travelBuffer = [];
|
|
11421
12123
|
|
|
11422
|
-
|
|
11423
|
-
|
|
11424
|
-
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
12124
|
+
for (var i = 0; i < points.length; i += stridePoints) {
|
|
12125
|
+
// calc travel
|
|
12126
|
+
// if (needDash) {
|
|
12127
|
+
if (i > 1) {
|
|
12128
|
+
dist += Math.sqrt(Math.pow(points[i] - points[i - 2], 2) + Math.pow(points[i + 1] - points[i + 1 - 2], 2));
|
|
12129
|
+
}
|
|
11428
12130
|
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
12131
|
+
travelBuffer.push(dist); // } else {
|
|
12132
|
+
// travelBuffer.push(0);
|
|
12133
|
+
// }
|
|
11432
12134
|
|
|
11433
|
-
|
|
11434
|
-
|
|
11435
|
-
|
|
12135
|
+
pointsBuffer[j++] = points[i];
|
|
12136
|
+
pointsBuffer[j++] = points[i + 1];
|
|
12137
|
+
pointsBuffer[j] = jointType;
|
|
11436
12138
|
|
|
11437
|
-
|
|
11438
|
-
|
|
11439
|
-
|
|
12139
|
+
if (i == 0 && capType !== JOINT_TYPE.CAP_ROUND) {
|
|
12140
|
+
pointsBuffer[j] += capType;
|
|
12141
|
+
}
|
|
12142
|
+
|
|
12143
|
+
if (i + stridePoints * 2 >= points.length) {
|
|
12144
|
+
pointsBuffer[j] += endJoint - jointType;
|
|
12145
|
+
} else if (i + stridePoints >= points.length) {
|
|
12146
|
+
pointsBuffer[j] = 0;
|
|
12147
|
+
}
|
|
11440
12148
|
|
|
11441
|
-
|
|
11442
|
-
pointsBuffer[j] += endJoint - jointType;
|
|
11443
|
-
} else if (i + stridePoints >= points.length) {
|
|
11444
|
-
pointsBuffer[j] = 0;
|
|
12149
|
+
j++;
|
|
11445
12150
|
}
|
|
11446
12151
|
|
|
11447
|
-
j
|
|
11448
|
-
|
|
12152
|
+
pointsBuffer[j++] = points[points.length - 4];
|
|
12153
|
+
pointsBuffer[j++] = points[points.length - 3];
|
|
12154
|
+
pointsBuffer[j++] = 0;
|
|
12155
|
+
pointsBuffer[0] = points[0];
|
|
12156
|
+
pointsBuffer[1] = points[1];
|
|
12157
|
+
pointsBuffer[2] = 0;
|
|
12158
|
+
pointsBuffer[3] = points[2];
|
|
12159
|
+
pointsBuffer[4] = points[3];
|
|
12160
|
+
pointsBuffer[5] = capType === JOINT_TYPE.CAP_ROUND ? capType : 0;
|
|
12161
|
+
var instancedCount = Math.round(points.length / stridePoints);
|
|
12162
|
+
return {
|
|
12163
|
+
pointsBuffer: pointsBuffer,
|
|
12164
|
+
travelBuffer: travelBuffer,
|
|
12165
|
+
triangles: triangles,
|
|
12166
|
+
instancedCount: instancedCount
|
|
12167
|
+
};
|
|
12168
|
+
}).reduce(function (prev, cur) {
|
|
12169
|
+
var _prev$pointsBuffer, _prev$travelBuffer;
|
|
11449
12170
|
|
|
11450
|
-
|
|
11451
|
-
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
|
|
11457
|
-
|
|
11458
|
-
|
|
11459
|
-
var instancedCount = Math.round(points.length / stridePoints);
|
|
11460
|
-
return {
|
|
11461
|
-
pointsBuffer: pointsBuffer,
|
|
11462
|
-
travelBuffer: travelBuffer,
|
|
12171
|
+
(_prev$pointsBuffer = prev.pointsBuffer).push.apply(_prev$pointsBuffer, cur.pointsBuffer);
|
|
12172
|
+
|
|
12173
|
+
(_prev$travelBuffer = prev.travelBuffer).push.apply(_prev$travelBuffer, cur.travelBuffer);
|
|
12174
|
+
|
|
12175
|
+
prev.instancedCount += cur.instancedCount;
|
|
12176
|
+
return prev;
|
|
12177
|
+
}, {
|
|
12178
|
+
pointsBuffer: [],
|
|
12179
|
+
travelBuffer: [],
|
|
11463
12180
|
triangles: triangles,
|
|
11464
|
-
instancedCount:
|
|
11465
|
-
};
|
|
12181
|
+
instancedCount: 0
|
|
12182
|
+
});
|
|
11466
12183
|
}
|
|
11467
12184
|
|
|
11468
12185
|
function getJointType(lineJoin) {
|
|
@@ -11519,9 +12236,9 @@
|
|
|
11519
12236
|
return [x1 + vec[0] * length, y1 + vec[1] * length];
|
|
11520
12237
|
}
|
|
11521
12238
|
|
|
11522
|
-
var meshFrag = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4
|
|
12239
|
+
var meshFrag = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\n#ifdef USE_UV\n in vec2 v_Uv;\n#endif\n#ifdef USE_MAP\n uniform sampler2D u_Map;\n#endif\n\nout vec4 outputColor;\n\n#define COLOR_SCALE 1. / 255.\n\nvoid main(){\n if (u_Visible < 0.5) {\n discard;\n }\n\n if (u_IsPicking > 0.5) {\n vec3 pickingColor = COLOR_SCALE * u_PickingColor;\n if (pickingColor.x == 0.0 && pickingColor.y == 0.0 && pickingColor.z == 0.0) {\n discard;\n }\n outputColor = vec4(pickingColor, 1.0);\n } else {\n\n vec4 u_Color = u_FillColor;\n\n #ifdef USE_MAP\n #ifdef USE_PATTERN\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #else\n vec4 texelColor = texture(SAMPLER_2D(u_Map), v_Uv);\n u_Color = texelColor;\n #endif\n#endif\n\n outputColor = u_Color;\n outputColor.a = outputColor.a * u_Opacity * u_FillOpacity;\n }\n}"; // eslint-disable-line
|
|
11523
12240
|
|
|
11524
|
-
var meshVert = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4
|
|
12241
|
+
var meshVert = "#define GLSLIFY 1\nlayout(std140) uniform ub_SceneParams {\n mat4 u_ProjectionMatrix;\n mat4 u_ViewMatrix;\n vec3 u_CameraPosition;\n float u_DevicePixelRatio;\n vec2 u_Viewport;\n float u_IsOrtho;\n float u_IsPicking;\n};\nlayout(std140) uniform ub_ObjectParams {\n mat4 u_ModelMatrix;\n vec4 u_FillColor;\n vec3 u_PickingColor;\n float u_Opacity;\n float u_FillOpacity;\n float u_Visible;\n float u_ZIndex;\n};\n\nlayout(location = POSITION) in vec2 a_Position;\n#ifdef USE_UV\n layout(location = UV) in vec2 a_Uv;\n out vec2 v_Uv;\n#endif\n\nvoid main() {\n #ifdef USE_UV\n v_Uv = a_Uv;\n #ifdef VIEWPORT_ORIGIN_TL\n v_Uv.y = 1.0 - v_Uv.y;\n #endif\n#endif\n\n gl_Position = u_ProjectionMatrix * u_ViewMatrix * u_ModelMatrix * vec4(a_Position, u_ZIndex, 1.0);\n}"; // eslint-disable-line
|
|
11525
12242
|
|
|
11526
12243
|
var FillMesh = /*#__PURE__*/function (_Instanced) {
|
|
11527
12244
|
_inheritsLoose$1(FillMesh, _Instanced);
|
|
@@ -11550,11 +12267,28 @@
|
|
|
11550
12267
|
attributes: [{
|
|
11551
12268
|
format: Format.F32_RG,
|
|
11552
12269
|
bufferByteOffset: 4 * 0,
|
|
11553
|
-
byteStride: 4 * 2,
|
|
11554
12270
|
location: VertexAttributeLocation.POSITION
|
|
11555
12271
|
}],
|
|
11556
12272
|
data: new Float32Array(pointsBuffer)
|
|
11557
12273
|
});
|
|
12274
|
+
|
|
12275
|
+
var _instance$getGeometry = instance.getGeometryBounds(),
|
|
12276
|
+
halfExtents = _instance$getGeometry.halfExtents;
|
|
12277
|
+
|
|
12278
|
+
var uvsBuffer = pointsBuffer.map(function (x, i) {
|
|
12279
|
+
return x / halfExtents[i % 2] / 2;
|
|
12280
|
+
});
|
|
12281
|
+
this.geometry.setVertexBuffer({
|
|
12282
|
+
bufferIndex: VertexAttributeBufferIndex.UV,
|
|
12283
|
+
byteStride: 4 * 2,
|
|
12284
|
+
frequency: VertexBufferFrequency.PerVertex,
|
|
12285
|
+
attributes: [{
|
|
12286
|
+
format: Format.F32_RG,
|
|
12287
|
+
bufferByteOffset: 4 * 0,
|
|
12288
|
+
location: VertexAttributeLocation.UV
|
|
12289
|
+
}],
|
|
12290
|
+
data: new Float32Array(uvsBuffer)
|
|
12291
|
+
});
|
|
11558
12292
|
this.geometry.vertexCount = triangles.length;
|
|
11559
12293
|
this.geometry.setIndexBuffer(new Uint32Array(triangles));
|
|
11560
12294
|
};
|
|
@@ -11592,7 +12326,7 @@
|
|
|
11592
12326
|
var m = create();
|
|
11593
12327
|
mul(m, instance.getWorldTransform(), // apply anchor
|
|
11594
12328
|
fromTranslation(m, fromValues$1(translateX, translateY, 0)));
|
|
11595
|
-
this.material.setUniforms((_this$material$setUni = {}, _this$material$setUni[Uniform.MODEL_MATRIX] = m, _this$material$setUni[Uniform.
|
|
12329
|
+
this.material.setUniforms((_this$material$setUni = {}, _this$material$setUni[Uniform.MODEL_MATRIX] = m, _this$material$setUni[Uniform.FILL_COLOR] = fillColor, _this$material$setUni[Uniform.PICKING_COLOR] = encodedPickingColor, _this$material$setUni[Uniform.OPACITY] = opacity.value, _this$material$setUni[Uniform.FILL_OPACITY] = fillOpacity.value, _this$material$setUni[Uniform.VISIBLE] = visibility.value === 'visible' ? 1 : 0, _this$material$setUni[Uniform.Z_INDEX] = instance.sortable.renderOrder * RENDER_ORDER_SCALE, _this$material$setUni));
|
|
11596
12330
|
};
|
|
11597
12331
|
|
|
11598
12332
|
_proto.updateAttribute = function updateAttribute(objects, startIndex, name, value) {
|
|
@@ -11613,15 +12347,25 @@
|
|
|
11613
12347
|
_this.material.geometryDirty = true;
|
|
11614
12348
|
_this.material.programDirty = true;
|
|
11615
12349
|
} else if (name === 'fill') {
|
|
11616
|
-
|
|
12350
|
+
if (fill instanceof g.CSSRGB) {
|
|
12351
|
+
var _this$material$setUni2;
|
|
11617
12352
|
|
|
11618
|
-
|
|
12353
|
+
var fillColor = [Number(fill.r) / 255, Number(fill.g) / 255, Number(fill.b) / 255, Number(fill.alpha)];
|
|
11619
12354
|
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
12355
|
+
_this.material.setUniforms((_this$material$setUni2 = {}, _this$material$setUni2[Uniform.FILL_COLOR] = fillColor, _this$material$setUni2));
|
|
12356
|
+
} else {
|
|
12357
|
+
var i = _this.textureMappings.findIndex(function (m) {
|
|
12358
|
+
return m.name === FILL_TEXTURE_MAPPING;
|
|
12359
|
+
});
|
|
12360
|
+
|
|
12361
|
+
var fillTextureMapping = _this.createFillGradientTextureMapping([_this.instance]);
|
|
12362
|
+
|
|
12363
|
+
if (i >= 0) {
|
|
12364
|
+
_this.textureMappings.splice(i, 1, fillTextureMapping);
|
|
12365
|
+
}
|
|
11623
12366
|
|
|
11624
|
-
|
|
12367
|
+
_this.material.textureDirty = true;
|
|
12368
|
+
}
|
|
11625
12369
|
} else if (name === 'opacity') {
|
|
11626
12370
|
var _this$material$setUni3;
|
|
11627
12371
|
|
|
@@ -12871,10 +13615,16 @@
|
|
|
12871
13615
|
_proto.shouldSubmitRenderInst = function shouldSubmitRenderInst(object, index) {
|
|
12872
13616
|
var _object$parsedStyle = object.parsedStyle,
|
|
12873
13617
|
fill = _object$parsedStyle.fill,
|
|
13618
|
+
stroke = _object$parsedStyle.stroke,
|
|
13619
|
+
opacity = _object$parsedStyle.opacity,
|
|
12874
13620
|
strokeOpacity = _object$parsedStyle.strokeOpacity,
|
|
12875
13621
|
lineDash = _object$parsedStyle.lineDash,
|
|
12876
13622
|
lineWidth = _object$parsedStyle.lineWidth;
|
|
12877
|
-
var nodeName = object.nodeName;
|
|
13623
|
+
var nodeName = object.nodeName;
|
|
13624
|
+
var hasStroke = stroke && !stroke.isNone;
|
|
13625
|
+
var hasDash = lineDash && lineDash.length && lineDash.every(function (item) {
|
|
13626
|
+
return item.value !== 0;
|
|
13627
|
+
}); // Polyline don't need fill
|
|
12878
13628
|
|
|
12879
13629
|
if (index === 0 && (object.nodeName === g.Shape.POLYLINE || fill.isNone)) {
|
|
12880
13630
|
return false;
|
|
@@ -12882,14 +13632,10 @@
|
|
|
12882
13632
|
|
|
12883
13633
|
|
|
12884
13634
|
if (index === 1) {
|
|
12885
|
-
if (strokeOpacity.value === 0 || lineWidth.value === 0) {
|
|
13635
|
+
if (strokeOpacity.value === 0 || opacity.value === 0 || lineWidth.value === 0 || !hasStroke) {
|
|
12886
13636
|
return false;
|
|
12887
13637
|
}
|
|
12888
13638
|
|
|
12889
|
-
var hasDash = lineDash && lineDash.length && lineDash.every(function (item) {
|
|
12890
|
-
return item.value !== 0;
|
|
12891
|
-
});
|
|
12892
|
-
|
|
12893
13639
|
if (nodeName === g.Shape.CIRCLE || nodeName === g.Shape.ELLIPSE) {
|
|
12894
13640
|
// @see https://github.com/antvis/g/issues/824
|
|
12895
13641
|
return hasDash;
|
|
@@ -13154,7 +13900,7 @@
|
|
|
13154
13900
|
|
|
13155
13901
|
Fog.tag = 'fog';
|
|
13156
13902
|
|
|
13157
|
-
var _class;
|
|
13903
|
+
var _class$1;
|
|
13158
13904
|
|
|
13159
13905
|
var RenderGraphPlugin_1;
|
|
13160
13906
|
var SceneUniformBufferIndex = 0; // uniforms in scene level
|
|
@@ -13171,7 +13917,7 @@
|
|
|
13171
13917
|
SceneUniform["IS_PICKING"] = "u_IsPicking";
|
|
13172
13918
|
})(SceneUniform || (SceneUniform = {}));
|
|
13173
13919
|
|
|
13174
|
-
var RenderGraphPlugin = RenderGraphPlugin_1 = (_class = /*#__PURE__*/function () {
|
|
13920
|
+
var RenderGraphPlugin = RenderGraphPlugin_1 = (_class$1 = /*#__PURE__*/function () {
|
|
13175
13921
|
function RenderGraphPlugin() {
|
|
13176
13922
|
this.canvasConfig = void 0;
|
|
13177
13923
|
this.contextService = void 0;
|
|
@@ -13274,10 +14020,10 @@
|
|
|
13274
14020
|
_this.batchManager.changeRenderOrder(object, renderOrder);
|
|
13275
14021
|
};
|
|
13276
14022
|
|
|
13277
|
-
renderingService.hooks.init.tapPromise(RenderGraphPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$
|
|
14023
|
+
renderingService.hooks.init.tapPromise(RenderGraphPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
13278
14024
|
var $canvas, _this$canvasConfig, width, height;
|
|
13279
14025
|
|
|
13280
|
-
return _regeneratorRuntime$
|
|
14026
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
13281
14027
|
while (1) {
|
|
13282
14028
|
switch (_context.prev = _context.next) {
|
|
13283
14029
|
case 0:
|
|
@@ -13455,7 +14201,7 @@
|
|
|
13455
14201
|
};
|
|
13456
14202
|
|
|
13457
14203
|
return RenderGraphPlugin;
|
|
13458
|
-
}(), _class.tag = 'RenderGraph', _class);
|
|
14204
|
+
}(), _class$1.tag = 'RenderGraph', _class$1);
|
|
13459
14205
|
|
|
13460
14206
|
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], RenderGraphPlugin.prototype, "canvasConfig", void 0);
|
|
13461
14207
|
|
|
@@ -13479,7 +14225,7 @@
|
|
|
13479
14225
|
contrib: g.RenderingPluginContribution
|
|
13480
14226
|
})], RenderGraphPlugin);
|
|
13481
14227
|
|
|
13482
|
-
var _class$1;
|
|
14228
|
+
var _class$1$1;
|
|
13483
14229
|
|
|
13484
14230
|
var PickingPlugin_1;
|
|
13485
14231
|
/**
|
|
@@ -13491,7 +14237,7 @@
|
|
|
13491
14237
|
* Use color-based picking in GPU
|
|
13492
14238
|
*/
|
|
13493
14239
|
|
|
13494
|
-
var PickingPlugin = PickingPlugin_1 = (_class$1 = /*#__PURE__*/function () {
|
|
14240
|
+
var PickingPlugin = PickingPlugin_1 = (_class$1$1 = /*#__PURE__*/function () {
|
|
13495
14241
|
function PickingPlugin() {
|
|
13496
14242
|
this.canvasConfig = void 0;
|
|
13497
14243
|
this.sceneGraphService = void 0;
|
|
@@ -13523,8 +14269,8 @@
|
|
|
13523
14269
|
}
|
|
13524
14270
|
};
|
|
13525
14271
|
|
|
13526
|
-
renderingService.hooks.init.tapPromise(PickingPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$
|
|
13527
|
-
return _regeneratorRuntime$
|
|
14272
|
+
renderingService.hooks.init.tapPromise(PickingPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee() {
|
|
14273
|
+
return _regeneratorRuntime$2().wrap(function _callee$(_context) {
|
|
13528
14274
|
while (1) {
|
|
13529
14275
|
switch (_context.prev = _context.next) {
|
|
13530
14276
|
case 0:
|
|
@@ -13541,9 +14287,9 @@
|
|
|
13541
14287
|
_this.renderingContext.root.removeEventListener(g.ElementEvent.MOUNTED, handleMounted);
|
|
13542
14288
|
});
|
|
13543
14289
|
renderingService.hooks.pick.tapPromise(PickingPlugin_1.tag, /*#__PURE__*/function () {
|
|
13544
|
-
var _ref2 = _asyncToGenerator$
|
|
14290
|
+
var _ref2 = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee2(result) {
|
|
13545
14291
|
var topmost, position, x, y, dpr, width, height, xInDevicePixel, yInDevicePixel, pickedDisplayObjects;
|
|
13546
|
-
return _regeneratorRuntime$
|
|
14292
|
+
return _regeneratorRuntime$2().wrap(function _callee2$(_context2) {
|
|
13547
14293
|
while (1) {
|
|
13548
14294
|
switch (_context2.prev = _context2.next) {
|
|
13549
14295
|
case 0:
|
|
@@ -13588,9 +14334,9 @@
|
|
|
13588
14334
|
};
|
|
13589
14335
|
|
|
13590
14336
|
_proto.pickByRectangleInDepth = /*#__PURE__*/function () {
|
|
13591
|
-
var _pickByRectangleInDepth = _asyncToGenerator$
|
|
14337
|
+
var _pickByRectangleInDepth = _asyncToGenerator$2( /*#__PURE__*/_regeneratorRuntime$2().mark(function _callee3(rect, depth) {
|
|
13592
14338
|
var picked, counter, targets;
|
|
13593
|
-
return _regeneratorRuntime$
|
|
14339
|
+
return _regeneratorRuntime$2().wrap(function _callee3$(_context3) {
|
|
13594
14340
|
while (1) {
|
|
13595
14341
|
switch (_context3.prev = _context3.next) {
|
|
13596
14342
|
case 0:
|
|
@@ -13806,7 +14552,7 @@
|
|
|
13806
14552
|
};
|
|
13807
14553
|
|
|
13808
14554
|
return PickingPlugin;
|
|
13809
|
-
}(), _class$1.tag = 'WebGLPicker', _class$1);
|
|
14555
|
+
}(), _class$1$1.tag = 'WebGLPicker', _class$1$1);
|
|
13810
14556
|
|
|
13811
14557
|
__decorate([g.inject(g.CanvasConfig), __metadata("design:type", Object)], PickingPlugin.prototype, "canvasConfig", void 0);
|
|
13812
14558
|
|
|
@@ -14000,7 +14746,7 @@
|
|
|
14000
14746
|
});
|
|
14001
14747
|
}
|
|
14002
14748
|
|
|
14003
|
-
var containerModule = g.Module(function (register) {
|
|
14749
|
+
var containerModule$1 = g.Module(function (register) {
|
|
14004
14750
|
register(RenderHelper);
|
|
14005
14751
|
register(TexturePool);
|
|
14006
14752
|
register(LightPool);
|
|
@@ -14056,7 +14802,7 @@
|
|
|
14056
14802
|
});
|
|
14057
14803
|
});
|
|
14058
14804
|
|
|
14059
|
-
var Plugin = /*#__PURE__*/function () {
|
|
14805
|
+
var Plugin$1 = /*#__PURE__*/function () {
|
|
14060
14806
|
function Plugin() {
|
|
14061
14807
|
this.name = 'device-renderer';
|
|
14062
14808
|
this.container = void 0;
|
|
@@ -14070,7 +14816,7 @@
|
|
|
14070
14816
|
}
|
|
14071
14817
|
|
|
14072
14818
|
this.container = container;
|
|
14073
|
-
container.load(containerModule, true);
|
|
14819
|
+
container.load(containerModule$1, true);
|
|
14074
14820
|
};
|
|
14075
14821
|
|
|
14076
14822
|
_proto.destroy = function destroy(container) {
|
|
@@ -14078,7 +14824,7 @@
|
|
|
14078
14824
|
g.GlobalContainer.remove(MeshUpdater);
|
|
14079
14825
|
}
|
|
14080
14826
|
|
|
14081
|
-
container.unload(containerModule);
|
|
14827
|
+
container.unload(containerModule$1);
|
|
14082
14828
|
};
|
|
14083
14829
|
|
|
14084
14830
|
_proto.getDevice = function getDevice() {
|
|
@@ -14110,6 +14856,7 @@
|
|
|
14110
14856
|
DeviceProgram: DeviceProgram,
|
|
14111
14857
|
DynamicUniformBuffer: DynamicUniformBuffer,
|
|
14112
14858
|
get Endianness () { return Endianness; },
|
|
14859
|
+
FILL_TEXTURE_MAPPING: FILL_TEXTURE_MAPPING,
|
|
14113
14860
|
get FillMesh () { return FillMesh; },
|
|
14114
14861
|
Fog: Fog,
|
|
14115
14862
|
get FogType () { return FogType; },
|
|
@@ -14136,7 +14883,7 @@
|
|
|
14136
14883
|
get MipFilterMode () { return MipFilterMode; },
|
|
14137
14884
|
OpaqueBlack: OpaqueBlack,
|
|
14138
14885
|
OpaqueWhite: OpaqueWhite,
|
|
14139
|
-
Plugin: Plugin,
|
|
14886
|
+
Plugin: Plugin$1,
|
|
14140
14887
|
get PrimitiveTopology () { return PrimitiveTopology; },
|
|
14141
14888
|
get QueryPoolType () { return QueryPoolType; },
|
|
14142
14889
|
get RGAttachmentSlot () { return RGAttachmentSlot; },
|
|
@@ -14193,7 +14940,7 @@
|
|
|
14193
14940
|
colorNewFromRGBA: colorNewFromRGBA,
|
|
14194
14941
|
compareDefines: compareDefines,
|
|
14195
14942
|
compareDepthValues: compareDepthValues,
|
|
14196
|
-
containerModule: containerModule,
|
|
14943
|
+
containerModule: containerModule$1,
|
|
14197
14944
|
copyAttachmentState: copyAttachmentState,
|
|
14198
14945
|
copyAttachmentStateFromSimple: copyAttachmentStateFromSimple,
|
|
14199
14946
|
copyMegaState: copyMegaState,
|
|
@@ -14289,9 +15036,9 @@
|
|
|
14289
15036
|
vertexAttributeDescriptorEquals: vertexAttributeDescriptorEquals
|
|
14290
15037
|
});
|
|
14291
15038
|
|
|
14292
|
-
function _regeneratorRuntime$
|
|
15039
|
+
function _regeneratorRuntime$3() {
|
|
14293
15040
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
14294
|
-
_regeneratorRuntime$
|
|
15041
|
+
_regeneratorRuntime$3 = function _regeneratorRuntime() {
|
|
14295
15042
|
return exports;
|
|
14296
15043
|
};
|
|
14297
15044
|
|
|
@@ -14639,7 +15386,7 @@
|
|
|
14639
15386
|
}, exports;
|
|
14640
15387
|
}
|
|
14641
15388
|
|
|
14642
|
-
function asyncGeneratorStep$
|
|
15389
|
+
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
14643
15390
|
try {
|
|
14644
15391
|
var info = gen[key](arg);
|
|
14645
15392
|
var value = info.value;
|
|
@@ -14655,7 +15402,7 @@
|
|
|
14655
15402
|
}
|
|
14656
15403
|
}
|
|
14657
15404
|
|
|
14658
|
-
function _asyncToGenerator$
|
|
15405
|
+
function _asyncToGenerator$3(fn) {
|
|
14659
15406
|
return function () {
|
|
14660
15407
|
var self = this,
|
|
14661
15408
|
args = arguments;
|
|
@@ -14663,11 +15410,11 @@
|
|
|
14663
15410
|
var gen = fn.apply(self, args);
|
|
14664
15411
|
|
|
14665
15412
|
function _next(value) {
|
|
14666
|
-
asyncGeneratorStep$
|
|
15413
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
14667
15414
|
}
|
|
14668
15415
|
|
|
14669
15416
|
function _throw(err) {
|
|
14670
|
-
asyncGeneratorStep$
|
|
15417
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
14671
15418
|
}
|
|
14672
15419
|
|
|
14673
15420
|
_next(undefined);
|
|
@@ -14768,9 +15515,9 @@
|
|
|
14768
15515
|
globalThis.removeEventListener('mouseup', onPointerUp, true);
|
|
14769
15516
|
};
|
|
14770
15517
|
|
|
14771
|
-
renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$
|
|
15518
|
+
renderingService.hooks.init.tapPromise(DOMInteractionPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$3( /*#__PURE__*/_regeneratorRuntime$3().mark(function _callee() {
|
|
14772
15519
|
var $el;
|
|
14773
|
-
return _regeneratorRuntime$
|
|
15520
|
+
return _regeneratorRuntime$3().wrap(function _callee$(_context) {
|
|
14774
15521
|
while (1) {
|
|
14775
15522
|
switch (_context.prev = _context.next) {
|
|
14776
15523
|
case 0:
|
|
@@ -14836,11 +15583,11 @@
|
|
|
14836
15583
|
DOMInteractionPlugin = DOMInteractionPlugin_1 = __decorate([g.singleton({
|
|
14837
15584
|
contrib: g.RenderingPluginContribution
|
|
14838
15585
|
})], DOMInteractionPlugin);
|
|
14839
|
-
var containerModule$
|
|
15586
|
+
var containerModule$2 = g.Module(function (register) {
|
|
14840
15587
|
register(DOMInteractionPlugin);
|
|
14841
15588
|
});
|
|
14842
15589
|
|
|
14843
|
-
var Plugin$
|
|
15590
|
+
var Plugin$2 = /*#__PURE__*/function () {
|
|
14844
15591
|
function Plugin() {
|
|
14845
15592
|
this.name = 'dom-interaction';
|
|
14846
15593
|
}
|
|
@@ -14848,11 +15595,11 @@
|
|
|
14848
15595
|
var _proto = Plugin.prototype;
|
|
14849
15596
|
|
|
14850
15597
|
_proto.init = function init(container) {
|
|
14851
|
-
container.load(containerModule$
|
|
15598
|
+
container.load(containerModule$2, true);
|
|
14852
15599
|
};
|
|
14853
15600
|
|
|
14854
15601
|
_proto.destroy = function destroy(container) {
|
|
14855
|
-
container.unload(containerModule$
|
|
15602
|
+
container.unload(containerModule$2);
|
|
14856
15603
|
};
|
|
14857
15604
|
|
|
14858
15605
|
return Plugin;
|
|
@@ -14860,12 +15607,12 @@
|
|
|
14860
15607
|
|
|
14861
15608
|
var index_esm$1 = /*#__PURE__*/Object.freeze({
|
|
14862
15609
|
__proto__: null,
|
|
14863
|
-
Plugin: Plugin$
|
|
15610
|
+
Plugin: Plugin$2
|
|
14864
15611
|
});
|
|
14865
15612
|
|
|
14866
|
-
function _regeneratorRuntime$
|
|
15613
|
+
function _regeneratorRuntime$4() {
|
|
14867
15614
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
14868
|
-
_regeneratorRuntime$
|
|
15615
|
+
_regeneratorRuntime$4 = function _regeneratorRuntime() {
|
|
14869
15616
|
return exports;
|
|
14870
15617
|
};
|
|
14871
15618
|
|
|
@@ -15213,7 +15960,7 @@
|
|
|
15213
15960
|
}, exports;
|
|
15214
15961
|
}
|
|
15215
15962
|
|
|
15216
|
-
function asyncGeneratorStep$
|
|
15963
|
+
function asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, key, arg) {
|
|
15217
15964
|
try {
|
|
15218
15965
|
var info = gen[key](arg);
|
|
15219
15966
|
var value = info.value;
|
|
@@ -15229,7 +15976,7 @@
|
|
|
15229
15976
|
}
|
|
15230
15977
|
}
|
|
15231
15978
|
|
|
15232
|
-
function _asyncToGenerator$
|
|
15979
|
+
function _asyncToGenerator$4(fn) {
|
|
15233
15980
|
return function () {
|
|
15234
15981
|
var self = this,
|
|
15235
15982
|
args = arguments;
|
|
@@ -15237,11 +15984,11 @@
|
|
|
15237
15984
|
var gen = fn.apply(self, args);
|
|
15238
15985
|
|
|
15239
15986
|
function _next(value) {
|
|
15240
|
-
asyncGeneratorStep$
|
|
15987
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "next", value);
|
|
15241
15988
|
}
|
|
15242
15989
|
|
|
15243
15990
|
function _throw(err) {
|
|
15244
|
-
asyncGeneratorStep$
|
|
15991
|
+
asyncGeneratorStep$4(gen, resolve, reject, _next, _throw, "throw", err);
|
|
15245
15992
|
}
|
|
15246
15993
|
|
|
15247
15994
|
_next(undefined);
|
|
@@ -15311,8 +16058,8 @@
|
|
|
15311
16058
|
}
|
|
15312
16059
|
};
|
|
15313
16060
|
|
|
15314
|
-
renderingService.hooks.init.tapPromise(HTMLRenderingPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$
|
|
15315
|
-
return _regeneratorRuntime$
|
|
16061
|
+
renderingService.hooks.init.tapPromise(HTMLRenderingPlugin_1.tag, /*#__PURE__*/_asyncToGenerator$4( /*#__PURE__*/_regeneratorRuntime$4().mark(function _callee() {
|
|
16062
|
+
return _regeneratorRuntime$4().wrap(function _callee$(_context) {
|
|
15316
16063
|
while (1) {
|
|
15317
16064
|
switch (_context.prev = _context.next) {
|
|
15318
16065
|
case 0:
|
|
@@ -15438,24 +16185,33 @@
|
|
|
15438
16185
|
var color = '';
|
|
15439
16186
|
|
|
15440
16187
|
if (fill instanceof g.CSSRGB) {
|
|
15441
|
-
|
|
15442
|
-
|
|
15443
|
-
|
|
15444
|
-
|
|
15445
|
-
// ['0', '#ffffff'],
|
|
15446
|
-
return cur[1] + " " + Number(cur[0]) * 100 + "%";
|
|
15447
|
-
}).join(','); // @see https://developer.mozilla.org/en-US/docs/Web/CSS/gradient/linear-gradient()
|
|
15448
|
-
|
|
15449
|
-
color = "linear-gradient(to right, " + steps + ");";
|
|
16188
|
+
if (fill.isNone) {
|
|
16189
|
+
color = 'transparent';
|
|
16190
|
+
} else {
|
|
16191
|
+
color = object.getAttribute('fill');
|
|
15450
16192
|
}
|
|
15451
|
-
}
|
|
16193
|
+
} else if (Array.isArray(fill)) {
|
|
16194
|
+
color = object.getAttribute('fill');
|
|
16195
|
+
} else if (g.isPattern(fill)) ;
|
|
15452
16196
|
|
|
15453
16197
|
$el.style.background = color;
|
|
15454
16198
|
break;
|
|
15455
16199
|
|
|
15456
16200
|
case 'stroke':
|
|
15457
16201
|
var stroke = object.parsedStyle.stroke;
|
|
15458
|
-
|
|
16202
|
+
var borderColor = '';
|
|
16203
|
+
|
|
16204
|
+
if (stroke instanceof g.CSSRGB) {
|
|
16205
|
+
if (stroke.isNone) {
|
|
16206
|
+
borderColor = 'transparent';
|
|
16207
|
+
} else {
|
|
16208
|
+
borderColor = object.getAttribute('stroke');
|
|
16209
|
+
}
|
|
16210
|
+
} else if (Array.isArray(stroke)) {
|
|
16211
|
+
borderColor = object.getAttribute('stroke');
|
|
16212
|
+
} else if (g.isPattern(stroke)) ;
|
|
16213
|
+
|
|
16214
|
+
$el.style['border-color'] = borderColor;
|
|
15459
16215
|
$el.style['border-style'] = 'solid';
|
|
15460
16216
|
break;
|
|
15461
16217
|
|
|
@@ -15487,11 +16243,11 @@
|
|
|
15487
16243
|
HTMLRenderingPlugin = HTMLRenderingPlugin_1 = __decorate([g.singleton({
|
|
15488
16244
|
contrib: g.RenderingPluginContribution
|
|
15489
16245
|
})], HTMLRenderingPlugin);
|
|
15490
|
-
var containerModule$
|
|
16246
|
+
var containerModule$3 = g.Module(function (register) {
|
|
15491
16247
|
register(HTMLRenderingPlugin);
|
|
15492
16248
|
});
|
|
15493
16249
|
|
|
15494
|
-
var Plugin$
|
|
16250
|
+
var Plugin$3 = /*#__PURE__*/function () {
|
|
15495
16251
|
function Plugin() {
|
|
15496
16252
|
this.name = 'html-renderer';
|
|
15497
16253
|
}
|
|
@@ -15499,11 +16255,11 @@
|
|
|
15499
16255
|
var _proto = Plugin.prototype;
|
|
15500
16256
|
|
|
15501
16257
|
_proto.init = function init(container) {
|
|
15502
|
-
container.load(containerModule$
|
|
16258
|
+
container.load(containerModule$3, true);
|
|
15503
16259
|
};
|
|
15504
16260
|
|
|
15505
16261
|
_proto.destroy = function destroy(container) {
|
|
15506
|
-
container.unload(containerModule$
|
|
16262
|
+
container.unload(containerModule$3);
|
|
15507
16263
|
};
|
|
15508
16264
|
|
|
15509
16265
|
return Plugin;
|
|
@@ -15511,12 +16267,12 @@
|
|
|
15511
16267
|
|
|
15512
16268
|
var index_esm$2 = /*#__PURE__*/Object.freeze({
|
|
15513
16269
|
__proto__: null,
|
|
15514
|
-
Plugin: Plugin$
|
|
16270
|
+
Plugin: Plugin$3
|
|
15515
16271
|
});
|
|
15516
16272
|
|
|
15517
|
-
function _regeneratorRuntime$
|
|
16273
|
+
function _regeneratorRuntime$5() {
|
|
15518
16274
|
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
15519
|
-
_regeneratorRuntime$
|
|
16275
|
+
_regeneratorRuntime$5 = function _regeneratorRuntime() {
|
|
15520
16276
|
return exports;
|
|
15521
16277
|
};
|
|
15522
16278
|
|
|
@@ -15864,7 +16620,7 @@
|
|
|
15864
16620
|
}, exports;
|
|
15865
16621
|
}
|
|
15866
16622
|
|
|
15867
|
-
function asyncGeneratorStep$
|
|
16623
|
+
function asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, key, arg) {
|
|
15868
16624
|
try {
|
|
15869
16625
|
var info = gen[key](arg);
|
|
15870
16626
|
var value = info.value;
|
|
@@ -15880,7 +16636,7 @@
|
|
|
15880
16636
|
}
|
|
15881
16637
|
}
|
|
15882
16638
|
|
|
15883
|
-
function _asyncToGenerator$
|
|
16639
|
+
function _asyncToGenerator$5(fn) {
|
|
15884
16640
|
return function () {
|
|
15885
16641
|
var self = this,
|
|
15886
16642
|
args = arguments;
|
|
@@ -15888,11 +16644,11 @@
|
|
|
15888
16644
|
var gen = fn.apply(self, args);
|
|
15889
16645
|
|
|
15890
16646
|
function _next(value) {
|
|
15891
|
-
asyncGeneratorStep$
|
|
16647
|
+
asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "next", value);
|
|
15892
16648
|
}
|
|
15893
16649
|
|
|
15894
16650
|
function _throw(err) {
|
|
15895
|
-
asyncGeneratorStep$
|
|
16651
|
+
asyncGeneratorStep$5(gen, resolve, reject, _next, _throw, "throw", err);
|
|
15896
16652
|
}
|
|
15897
16653
|
|
|
15898
16654
|
_next(undefined);
|
|
@@ -15901,7 +16657,7 @@
|
|
|
15901
16657
|
}
|
|
15902
16658
|
|
|
15903
16659
|
function _extends$1() {
|
|
15904
|
-
_extends$1 = Object.assign
|
|
16660
|
+
_extends$1 = Object.assign ? Object.assign.bind() : function (target) {
|
|
15905
16661
|
for (var i = 1; i < arguments.length; i++) {
|
|
15906
16662
|
var source = arguments[i];
|
|
15907
16663
|
|
|
@@ -15914,7 +16670,6 @@
|
|
|
15914
16670
|
|
|
15915
16671
|
return target;
|
|
15916
16672
|
};
|
|
15917
|
-
|
|
15918
16673
|
return _extends$1.apply(this, arguments);
|
|
15919
16674
|
}
|
|
15920
16675
|
|
|
@@ -15926,11 +16681,10 @@
|
|
|
15926
16681
|
}
|
|
15927
16682
|
|
|
15928
16683
|
function _setPrototypeOf$2(o, p) {
|
|
15929
|
-
_setPrototypeOf$2 = Object.setPrototypeOf
|
|
16684
|
+
_setPrototypeOf$2 = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
|
|
15930
16685
|
o.__proto__ = p;
|
|
15931
16686
|
return o;
|
|
15932
16687
|
};
|
|
15933
|
-
|
|
15934
16688
|
return _setPrototypeOf$2(o, p);
|
|
15935
16689
|
}
|
|
15936
16690
|
|
|
@@ -16082,9 +16836,9 @@
|
|
|
16082
16836
|
}
|
|
16083
16837
|
|
|
16084
16838
|
function _load() {
|
|
16085
|
-
_load = _asyncToGenerator$
|
|
16839
|
+
_load = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee(module, imports) {
|
|
16086
16840
|
var bytes, instance;
|
|
16087
|
-
return _regeneratorRuntime$
|
|
16841
|
+
return _regeneratorRuntime$5().wrap(function _callee$(_context) {
|
|
16088
16842
|
while (1) {
|
|
16089
16843
|
switch (_context.prev = _context.next) {
|
|
16090
16844
|
case 0:
|
|
@@ -16168,10 +16922,10 @@
|
|
|
16168
16922
|
}
|
|
16169
16923
|
|
|
16170
16924
|
function _init() {
|
|
16171
|
-
_init = _asyncToGenerator$
|
|
16925
|
+
_init = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee2(input) {
|
|
16172
16926
|
var imports, _yield$load, instance, module;
|
|
16173
16927
|
|
|
16174
|
-
return _regeneratorRuntime$
|
|
16928
|
+
return _regeneratorRuntime$5().wrap(function _callee2$(_context2) {
|
|
16175
16929
|
while (1) {
|
|
16176
16930
|
switch (_context2.prev = _context2.next) {
|
|
16177
16931
|
case 0:
|
|
@@ -16692,629 +17446,392 @@
|
|
|
16692
17446
|
binding: numBindings++,
|
|
16693
17447
|
resource: gpuSampler
|
|
16694
17448
|
});
|
|
16695
|
-
}
|
|
16696
|
-
|
|
16697
|
-
_this.gpuBindGroup = gpuBindGroupEntries.map(function (gpuBindGroupEntry, i) {
|
|
16698
|
-
return _this.device.device.createBindGroup({
|
|
16699
|
-
layout: pipeline.getBindGroupLayout(i),
|
|
16700
|
-
// layout: bindGroupLayout.gpuBindGroupLayout[i],
|
|
16701
|
-
entries: gpuBindGroupEntry
|
|
16702
|
-
});
|
|
16703
|
-
});
|
|
16704
|
-
_this.bindingLayout = descriptor.bindingLayout;
|
|
16705
|
-
_this.bindGroupLayout = bindGroupLayout;
|
|
16706
|
-
return _this;
|
|
16707
|
-
}
|
|
16708
|
-
|
|
16709
|
-
return Bindings_WebGPU;
|
|
16710
|
-
}(ResourceBase_WebGPU);
|
|
16711
|
-
|
|
16712
|
-
function isView(viewOrSize) {
|
|
16713
|
-
return viewOrSize.byteLength !== undefined;
|
|
16714
|
-
}
|
|
16715
|
-
|
|
16716
|
-
var Buffer_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
16717
|
-
_inheritsLoose$2(Buffer_WebGPU, _ResourceBase_WebGPU);
|
|
16718
|
-
/**
|
|
16719
|
-
* @see https://www.w3.org/TR/webgpu/#gpubuffer
|
|
16720
|
-
*/
|
|
16721
|
-
|
|
16722
|
-
|
|
16723
|
-
function Buffer_WebGPU(_ref) {
|
|
16724
|
-
var _this;
|
|
16725
|
-
|
|
16726
|
-
var id = _ref.id,
|
|
16727
|
-
device = _ref.device,
|
|
16728
|
-
descriptor = _ref.descriptor;
|
|
16729
|
-
_this = _ResourceBase_WebGPU.call(this, {
|
|
16730
|
-
id: id,
|
|
16731
|
-
device: device
|
|
16732
|
-
}) || this;
|
|
16733
|
-
_this.type = ResourceType.Buffer;
|
|
16734
|
-
_this.gpuBuffer = void 0;
|
|
16735
|
-
_this.size = void 0;
|
|
16736
|
-
_this.view = void 0;
|
|
16737
|
-
_this.usage = void 0;
|
|
16738
|
-
var usage = descriptor.usage,
|
|
16739
|
-
viewOrSize = descriptor.viewOrSize;
|
|
16740
|
-
var alignedLength = isView(viewOrSize) ? viewOrSize.byteLength + 3 & ~3 : viewOrSize + 3 & ~3; // 4 bytes alignments (because of the upload which requires this)
|
|
16741
|
-
|
|
16742
|
-
_this.usage = usage; // Buffer usages (BufferUsage::(MapRead|CopyDst|Storage)) is invalid. If a buffer usage contains BufferUsage::MapRead the only other allowed usage is BufferUsage::CopyDst.
|
|
16743
|
-
// @see https://www.w3.org/TR/webgpu/#dom-gpubufferusage-copy_dst
|
|
16744
|
-
|
|
16745
|
-
if (_this.usage & BufferUsage.MAP_READ) {
|
|
16746
|
-
_this.usage = BufferUsage.MAP_READ | BufferUsage.COPY_DST;
|
|
16747
|
-
}
|
|
16748
|
-
|
|
16749
|
-
var mapBuffer = isView(viewOrSize);
|
|
16750
|
-
_this.size = isView(viewOrSize) ? viewOrSize.byteLength : viewOrSize;
|
|
16751
|
-
_this.view = isView(viewOrSize) ? viewOrSize : null;
|
|
16752
|
-
_this.gpuBuffer = _this.device.device.createBuffer({
|
|
16753
|
-
usage: _this.usage,
|
|
16754
|
-
size: alignedLength,
|
|
16755
|
-
mappedAtCreation: mapBuffer
|
|
16756
|
-
});
|
|
16757
|
-
|
|
16758
|
-
if (mapBuffer) {
|
|
16759
|
-
var arrayBuffer = _this.gpuBuffer.getMappedRange(); // @ts-expect-error
|
|
16760
|
-
|
|
16761
|
-
|
|
16762
|
-
new viewOrSize.constructor(arrayBuffer).set(viewOrSize);
|
|
16763
|
-
|
|
16764
|
-
_this.gpuBuffer.unmap();
|
|
16765
|
-
}
|
|
16766
|
-
|
|
16767
|
-
return _this;
|
|
16768
|
-
}
|
|
16769
|
-
|
|
16770
|
-
var _proto = Buffer_WebGPU.prototype;
|
|
16771
|
-
|
|
16772
|
-
_proto.setSubData = function setSubData(dstByteOffset, src, srcByteOffset, byteLength) {
|
|
16773
|
-
if (srcByteOffset === void 0) {
|
|
16774
|
-
srcByteOffset = 0;
|
|
16775
|
-
}
|
|
16776
|
-
|
|
16777
|
-
if (byteLength === void 0) {
|
|
16778
|
-
byteLength = 0;
|
|
16779
|
-
}
|
|
16780
|
-
|
|
16781
|
-
var buffer = this.gpuBuffer;
|
|
16782
|
-
byteLength = byteLength || src.byteLength;
|
|
16783
|
-
byteLength = Math.min(byteLength, this.size - dstByteOffset); // After Migration to Canary
|
|
16784
|
-
|
|
16785
|
-
var chunkStart = src.byteOffset + srcByteOffset;
|
|
16786
|
-
var chunkEnd = chunkStart + byteLength; // 4 bytes alignments for upload
|
|
16787
|
-
|
|
16788
|
-
var alignedLength = byteLength + 3 & ~3;
|
|
16789
|
-
|
|
16790
|
-
if (alignedLength !== byteLength) {
|
|
16791
|
-
var tempView = new Uint8Array(src.buffer.slice(chunkStart, chunkEnd));
|
|
16792
|
-
src = new Uint8Array(alignedLength);
|
|
16793
|
-
src.set(tempView);
|
|
16794
|
-
srcByteOffset = 0;
|
|
16795
|
-
chunkStart = 0;
|
|
16796
|
-
chunkEnd = alignedLength;
|
|
16797
|
-
byteLength = alignedLength;
|
|
16798
|
-
} // Chunk
|
|
16799
|
-
|
|
16800
|
-
|
|
16801
|
-
var maxChunk = 1024 * 1024 * 15;
|
|
16802
|
-
var offset = 0;
|
|
16803
|
-
|
|
16804
|
-
while (chunkEnd - (chunkStart + offset) > maxChunk) {
|
|
16805
|
-
this.device.device.queue.writeBuffer(buffer, dstByteOffset + offset, src.buffer, chunkStart + offset, maxChunk);
|
|
16806
|
-
offset += maxChunk;
|
|
16807
|
-
}
|
|
16808
|
-
|
|
16809
|
-
this.device.device.queue.writeBuffer(buffer, dstByteOffset + offset, src.buffer, chunkStart + offset, byteLength - offset);
|
|
16810
|
-
};
|
|
16811
|
-
|
|
16812
|
-
_proto.destroy = function destroy() {
|
|
16813
|
-
_ResourceBase_WebGPU.prototype.destroy.call(this); // @see https://www.w3.org/TR/webgpu/#dom-gpubuffer-destroy
|
|
16814
|
-
|
|
16815
|
-
|
|
16816
|
-
this.gpuBuffer.destroy();
|
|
16817
|
-
};
|
|
16818
|
-
|
|
16819
|
-
return Buffer_WebGPU;
|
|
16820
|
-
}(ResourceBase_WebGPU);
|
|
16821
|
-
|
|
16822
|
-
var InputLayout_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
16823
|
-
_inheritsLoose$2(InputLayout_WebGPU, _ResourceBase_WebGPU);
|
|
16824
|
-
|
|
16825
|
-
function InputLayout_WebGPU(_ref) {
|
|
16826
|
-
var _this;
|
|
16827
|
-
|
|
16828
|
-
var id = _ref.id,
|
|
16829
|
-
device = _ref.device,
|
|
16830
|
-
descriptor = _ref.descriptor;
|
|
16831
|
-
_this = _ResourceBase_WebGPU.call(this, {
|
|
16832
|
-
id: id,
|
|
16833
|
-
device: device
|
|
16834
|
-
}) || this;
|
|
16835
|
-
_this.type = ResourceType.InputLayout;
|
|
16836
|
-
_this.buffers = void 0;
|
|
16837
|
-
_this.indexFormat = void 0;
|
|
16838
|
-
var buffers = [];
|
|
16839
|
-
|
|
16840
|
-
for (var i = 0; i < descriptor.vertexBufferDescriptors.length; i++) {
|
|
16841
|
-
var b = descriptor.vertexBufferDescriptors[i];
|
|
16842
|
-
if (g.isNil(b)) continue;
|
|
16843
|
-
var arrayStride = b.byteStride;
|
|
16844
|
-
var stepMode = translateVertexBufferFrequency(b.frequency);
|
|
16845
|
-
var attributes = [];
|
|
16846
|
-
buffers[i] = {
|
|
16847
|
-
arrayStride: arrayStride,
|
|
16848
|
-
stepMode: stepMode,
|
|
16849
|
-
attributes: attributes
|
|
16850
|
-
};
|
|
16851
|
-
}
|
|
16852
|
-
|
|
16853
|
-
for (var _i = 0; _i < descriptor.vertexAttributeDescriptors.length; _i++) {
|
|
16854
|
-
var attr = descriptor.vertexAttributeDescriptors[_i];
|
|
16855
|
-
|
|
16856
|
-
var _b = assertExists(buffers[attr.bufferIndex]);
|
|
16857
|
-
|
|
16858
|
-
var attribute = {
|
|
16859
|
-
shaderLocation: attr.location,
|
|
16860
|
-
format: translateVertexFormat(attr.format),
|
|
16861
|
-
offset: attr.bufferByteOffset
|
|
16862
|
-
};
|
|
16863
|
-
|
|
16864
|
-
_b.attributes.push(attribute);
|
|
16865
|
-
}
|
|
16866
|
-
|
|
16867
|
-
_this.indexFormat = translateIndexFormat(descriptor.indexBufferFormat);
|
|
16868
|
-
_this.buffers = buffers;
|
|
16869
|
-
return _this;
|
|
16870
|
-
}
|
|
16871
|
-
|
|
16872
|
-
return InputLayout_WebGPU;
|
|
16873
|
-
}(ResourceBase_WebGPU);
|
|
16874
|
-
|
|
16875
|
-
var Program_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
16876
|
-
_inheritsLoose$2(Program_WebGPU, _ResourceBase_WebGPU);
|
|
16877
|
-
|
|
16878
|
-
function Program_WebGPU(_ref) {
|
|
16879
|
-
var _this;
|
|
16880
|
-
|
|
16881
|
-
var id = _ref.id,
|
|
16882
|
-
device = _ref.device,
|
|
16883
|
-
descriptor = _ref.descriptor;
|
|
16884
|
-
_this = _ResourceBase_WebGPU.call(this, {
|
|
16885
|
-
id: id,
|
|
16886
|
-
device: device
|
|
16887
|
-
}) || this;
|
|
16888
|
-
_this.type = ResourceType.Program;
|
|
16889
|
-
_this.descriptor = void 0;
|
|
16890
|
-
_this.vertexStage = null;
|
|
16891
|
-
_this.fragmentStage = null;
|
|
16892
|
-
_this.computeStage = null;
|
|
16893
|
-
_this.descriptor = descriptor;
|
|
16894
|
-
|
|
16895
|
-
if (descriptor.preprocessedVert) {
|
|
16896
|
-
_this.vertexStage = _this.createShaderStage(descriptor.preprocessedVert, 'vertex');
|
|
16897
|
-
}
|
|
16898
|
-
|
|
16899
|
-
if (descriptor.preprocessedFrag) {
|
|
16900
|
-
_this.fragmentStage = _this.createShaderStage(descriptor.preprocessedFrag, 'fragment');
|
|
16901
|
-
}
|
|
16902
|
-
|
|
16903
|
-
if (descriptor.preprocessedCompute) {
|
|
16904
|
-
// FIXME: Only support WGSL now
|
|
16905
|
-
_this.computeStage = _this.createShaderStage(descriptor.preprocessedCompute, 'compute');
|
|
16906
|
-
}
|
|
16907
|
-
|
|
16908
|
-
return _this;
|
|
16909
|
-
}
|
|
16910
|
-
|
|
16911
|
-
var _proto = Program_WebGPU.prototype;
|
|
16912
|
-
|
|
16913
|
-
_proto.createShaderStage = function createShaderStage(sourceText, shaderStage) {
|
|
16914
|
-
var validationEnabled = false;
|
|
16915
|
-
var code = sourceText;
|
|
16916
|
-
|
|
16917
|
-
if (shaderStage !== 'compute') {
|
|
16918
|
-
try {
|
|
16919
|
-
code = this.device.glsl_compile(sourceText, shaderStage, validationEnabled);
|
|
16920
|
-
} catch (e) {
|
|
16921
|
-
console.error(e, sourceText);
|
|
16922
|
-
throw new Error('whoops');
|
|
16923
|
-
}
|
|
16924
|
-
} // Workaround for https://github.com/gfx-rs/naga/issues/1355
|
|
16925
|
-
|
|
16926
|
-
|
|
16927
|
-
var _loop = function _loop() {
|
|
16928
|
-
var depthTextureName = _arr[_i];
|
|
16929
|
-
if (!code.includes(depthTextureName)) return "continue";
|
|
16930
|
-
code = code.replace("var T_" + depthTextureName + ": texture_2d<f32>;", "var T_" + depthTextureName + ": texture_depth_2d;");
|
|
16931
|
-
code = code.replace(new RegExp("textureSample\\(T_" + depthTextureName + "(.*)\\);$", 'gm'), function (sub, cap) {
|
|
16932
|
-
return "vec4<f32>(textureSample(T_" + depthTextureName + cap + "), 0.0, 0.0, 0.0);";
|
|
16933
|
-
});
|
|
16934
|
-
};
|
|
17449
|
+
}
|
|
16935
17450
|
|
|
16936
|
-
|
|
16937
|
-
|
|
17451
|
+
_this.gpuBindGroup = gpuBindGroupEntries.map(function (gpuBindGroupEntry, i) {
|
|
17452
|
+
return _this.device.device.createBindGroup({
|
|
17453
|
+
layout: pipeline.getBindGroupLayout(i),
|
|
17454
|
+
// layout: bindGroupLayout.gpuBindGroupLayout[i],
|
|
17455
|
+
entries: gpuBindGroupEntry
|
|
17456
|
+
});
|
|
17457
|
+
});
|
|
17458
|
+
_this.bindingLayout = descriptor.bindingLayout;
|
|
17459
|
+
_this.bindGroupLayout = bindGroupLayout;
|
|
17460
|
+
return _this;
|
|
17461
|
+
}
|
|
16938
17462
|
|
|
16939
|
-
|
|
16940
|
-
|
|
17463
|
+
return Bindings_WebGPU;
|
|
17464
|
+
}(ResourceBase_WebGPU);
|
|
16941
17465
|
|
|
17466
|
+
function isView(viewOrSize) {
|
|
17467
|
+
return viewOrSize.byteLength !== undefined;
|
|
17468
|
+
}
|
|
16942
17469
|
|
|
16943
|
-
|
|
16944
|
-
|
|
16945
|
-
|
|
16946
|
-
|
|
16947
|
-
|
|
16948
|
-
entryPoint: 'main'
|
|
16949
|
-
};
|
|
16950
|
-
};
|
|
17470
|
+
var Buffer_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
17471
|
+
_inheritsLoose$2(Buffer_WebGPU, _ResourceBase_WebGPU);
|
|
17472
|
+
/**
|
|
17473
|
+
* @see https://www.w3.org/TR/webgpu/#gpubuffer
|
|
17474
|
+
*/
|
|
16951
17475
|
|
|
16952
|
-
return Program_WebGPU;
|
|
16953
|
-
}(ResourceBase_WebGPU);
|
|
16954
17476
|
|
|
16955
|
-
|
|
16956
|
-
|
|
16957
|
-
this.commandEncoder = null;
|
|
16958
|
-
this.descriptor = void 0;
|
|
16959
|
-
this.gpuRenderPassEncoder = null;
|
|
16960
|
-
this.gpuRenderPassDescriptor = void 0;
|
|
16961
|
-
this.gpuColorAttachments = void 0;
|
|
16962
|
-
this.gpuDepthStencilAttachment = void 0;
|
|
16963
|
-
this.gfxColorAttachment = [];
|
|
16964
|
-
this.gfxColorResolveTo = [];
|
|
16965
|
-
this.gfxDepthStencilAttachment = null;
|
|
16966
|
-
this.gfxDepthStencilResolveTo = null;
|
|
16967
|
-
this.gpuColorAttachments = [];
|
|
16968
|
-
this.gpuDepthStencilAttachment = {
|
|
16969
|
-
view: null,
|
|
16970
|
-
depthLoadOp: 'load',
|
|
16971
|
-
depthStoreOp: 'store',
|
|
16972
|
-
stencilLoadOp: 'load',
|
|
16973
|
-
stencilStoreOp: 'store'
|
|
16974
|
-
};
|
|
16975
|
-
this.gpuRenderPassDescriptor = {
|
|
16976
|
-
colorAttachments: this.gpuColorAttachments,
|
|
16977
|
-
depthStencilAttachment: this.gpuDepthStencilAttachment
|
|
16978
|
-
};
|
|
16979
|
-
}
|
|
17477
|
+
function Buffer_WebGPU(_ref) {
|
|
17478
|
+
var _this;
|
|
16980
17479
|
|
|
16981
|
-
|
|
17480
|
+
var id = _ref.id,
|
|
17481
|
+
device = _ref.device,
|
|
17482
|
+
descriptor = _ref.descriptor;
|
|
17483
|
+
_this = _ResourceBase_WebGPU.call(this, {
|
|
17484
|
+
id: id,
|
|
17485
|
+
device: device
|
|
17486
|
+
}) || this;
|
|
17487
|
+
_this.type = ResourceType.Buffer;
|
|
17488
|
+
_this.gpuBuffer = void 0;
|
|
17489
|
+
_this.size = void 0;
|
|
17490
|
+
_this.view = void 0;
|
|
17491
|
+
_this.usage = void 0;
|
|
17492
|
+
var usage = descriptor.usage,
|
|
17493
|
+
viewOrSize = descriptor.viewOrSize;
|
|
17494
|
+
var alignedLength = isView(viewOrSize) ? viewOrSize.byteLength + 3 & ~3 : viewOrSize + 3 & ~3; // 4 bytes alignments (because of the upload which requires this)
|
|
16982
17495
|
|
|
16983
|
-
|
|
16984
|
-
|
|
16985
|
-
this.gpuRenderPassDescriptor.colorAttachments = this.gpuColorAttachments;
|
|
16986
|
-
var numColorAttachments = descriptor.colorAttachment.length;
|
|
16987
|
-
this.gfxColorAttachment.length = numColorAttachments;
|
|
16988
|
-
this.gfxColorResolveTo.length = numColorAttachments;
|
|
17496
|
+
_this.usage = usage; // Buffer usages (BufferUsage::(MapRead|CopyDst|Storage)) is invalid. If a buffer usage contains BufferUsage::MapRead the only other allowed usage is BufferUsage::CopyDst.
|
|
17497
|
+
// @see https://www.w3.org/TR/webgpu/#dom-gpubufferusage-copy_dst
|
|
16989
17498
|
|
|
16990
|
-
|
|
16991
|
-
|
|
16992
|
-
|
|
17499
|
+
if (_this.usage & BufferUsage.MAP_READ) {
|
|
17500
|
+
_this.usage = BufferUsage.MAP_READ | BufferUsage.COPY_DST;
|
|
17501
|
+
}
|
|
16993
17502
|
|
|
16994
|
-
|
|
16995
|
-
|
|
16996
|
-
|
|
16997
|
-
|
|
17503
|
+
var mapBuffer = isView(viewOrSize);
|
|
17504
|
+
_this.size = isView(viewOrSize) ? viewOrSize.byteLength : viewOrSize;
|
|
17505
|
+
_this.view = isView(viewOrSize) ? viewOrSize : null;
|
|
17506
|
+
_this.gpuBuffer = _this.device.device.createBuffer({
|
|
17507
|
+
usage: _this.usage,
|
|
17508
|
+
size: alignedLength,
|
|
17509
|
+
mappedAtCreation: mapBuffer
|
|
17510
|
+
});
|
|
16998
17511
|
|
|
16999
|
-
|
|
17000
|
-
|
|
17512
|
+
if (mapBuffer) {
|
|
17513
|
+
var arrayBuffer = _this.gpuBuffer.getMappedRange(); // @ts-expect-error
|
|
17001
17514
|
|
|
17002
|
-
if (colorAttachment !== null) {
|
|
17003
|
-
if (this.gpuColorAttachments[i] === undefined) {
|
|
17004
|
-
this.gpuColorAttachments[i] = {};
|
|
17005
|
-
}
|
|
17006
17515
|
|
|
17007
|
-
|
|
17008
|
-
dstAttachment.view = colorAttachment.gpuTextureView;
|
|
17009
|
-
var clearColor = descriptor.colorClearColor[i];
|
|
17516
|
+
new viewOrSize.constructor(arrayBuffer).set(viewOrSize);
|
|
17010
17517
|
|
|
17011
|
-
|
|
17012
|
-
|
|
17013
|
-
} else {
|
|
17014
|
-
dstAttachment.loadOp = 'clear';
|
|
17015
|
-
dstAttachment.clearValue = clearColor;
|
|
17016
|
-
}
|
|
17518
|
+
_this.gpuBuffer.unmap();
|
|
17519
|
+
}
|
|
17017
17520
|
|
|
17018
|
-
|
|
17019
|
-
|
|
17521
|
+
return _this;
|
|
17522
|
+
}
|
|
17020
17523
|
|
|
17021
|
-
|
|
17022
|
-
|
|
17023
|
-
|
|
17024
|
-
|
|
17025
|
-
|
|
17026
|
-
}
|
|
17027
|
-
}
|
|
17028
|
-
} else {
|
|
17029
|
-
// https://github.com/gpuweb/gpuweb/issues/1250
|
|
17030
|
-
this.gpuColorAttachments.length = i;
|
|
17031
|
-
this.gfxColorAttachment.length = i;
|
|
17032
|
-
this.gfxColorResolveTo.length = i;
|
|
17033
|
-
break;
|
|
17034
|
-
}
|
|
17524
|
+
var _proto = Buffer_WebGPU.prototype;
|
|
17525
|
+
|
|
17526
|
+
_proto.setSubData = function setSubData(dstByteOffset, src, srcByteOffset, byteLength) {
|
|
17527
|
+
if (srcByteOffset === void 0) {
|
|
17528
|
+
srcByteOffset = 0;
|
|
17035
17529
|
}
|
|
17036
17530
|
|
|
17037
|
-
|
|
17038
|
-
|
|
17531
|
+
if (byteLength === void 0) {
|
|
17532
|
+
byteLength = 0;
|
|
17533
|
+
}
|
|
17039
17534
|
|
|
17040
|
-
|
|
17041
|
-
|
|
17042
|
-
|
|
17043
|
-
_dstAttachment.view = dsAttachment.gpuTextureView;
|
|
17535
|
+
var buffer = this.gpuBuffer;
|
|
17536
|
+
byteLength = byteLength || src.byteLength;
|
|
17537
|
+
byteLength = Math.min(byteLength, this.size - dstByteOffset); // After Migration to Canary
|
|
17044
17538
|
|
|
17045
|
-
|
|
17046
|
-
|
|
17047
|
-
} else {
|
|
17048
|
-
_dstAttachment.depthLoadOp = 'clear';
|
|
17049
|
-
_dstAttachment.depthClearValue = descriptor.depthClearValue;
|
|
17050
|
-
}
|
|
17539
|
+
var chunkStart = src.byteOffset + srcByteOffset;
|
|
17540
|
+
var chunkEnd = chunkStart + byteLength; // 4 bytes alignments for upload
|
|
17051
17541
|
|
|
17052
|
-
|
|
17053
|
-
_dstAttachment.stencilLoadOp = 'load';
|
|
17054
|
-
} else {
|
|
17055
|
-
_dstAttachment.stencilLoadOp = 'clear';
|
|
17056
|
-
_dstAttachment.stencilClearValue = descriptor.stencilClearValue;
|
|
17057
|
-
}
|
|
17542
|
+
var alignedLength = byteLength + 3 & ~3;
|
|
17058
17543
|
|
|
17059
|
-
|
|
17060
|
-
|
|
17061
|
-
|
|
17544
|
+
if (alignedLength !== byteLength) {
|
|
17545
|
+
var tempView = new Uint8Array(src.buffer.slice(chunkStart, chunkEnd));
|
|
17546
|
+
src = new Uint8Array(alignedLength);
|
|
17547
|
+
src.set(tempView);
|
|
17548
|
+
srcByteOffset = 0;
|
|
17549
|
+
chunkStart = 0;
|
|
17550
|
+
chunkEnd = alignedLength;
|
|
17551
|
+
byteLength = alignedLength;
|
|
17552
|
+
} // Chunk
|
|
17062
17553
|
|
|
17063
|
-
|
|
17064
|
-
|
|
17065
|
-
|
|
17066
|
-
|
|
17067
|
-
|
|
17068
|
-
this.
|
|
17554
|
+
|
|
17555
|
+
var maxChunk = 1024 * 1024 * 15;
|
|
17556
|
+
var offset = 0;
|
|
17557
|
+
|
|
17558
|
+
while (chunkEnd - (chunkStart + offset) > maxChunk) {
|
|
17559
|
+
this.device.device.queue.writeBuffer(buffer, dstByteOffset + offset, src.buffer, chunkStart + offset, maxChunk);
|
|
17560
|
+
offset += maxChunk;
|
|
17069
17561
|
}
|
|
17070
17562
|
|
|
17071
|
-
this.
|
|
17563
|
+
this.device.device.queue.writeBuffer(buffer, dstByteOffset + offset, src.buffer, chunkStart + offset, byteLength - offset);
|
|
17072
17564
|
};
|
|
17073
17565
|
|
|
17074
|
-
_proto.
|
|
17075
|
-
|
|
17076
|
-
this.setRenderPassDescriptor(renderPassDescriptor);
|
|
17077
|
-
this.gpuRenderPassEncoder = this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor);
|
|
17078
|
-
};
|
|
17566
|
+
_proto.destroy = function destroy() {
|
|
17567
|
+
_ResourceBase_WebGPU.prototype.destroy.call(this); // @see https://www.w3.org/TR/webgpu/#dom-gpubuffer-destroy
|
|
17079
17568
|
|
|
17080
|
-
_proto.setViewport = function setViewport(x, y, w, h) {
|
|
17081
|
-
this.gpuRenderPassEncoder.setViewport(x, y, w, h, 0, 1);
|
|
17082
|
-
};
|
|
17083
17569
|
|
|
17084
|
-
|
|
17085
|
-
this.gpuRenderPassEncoder.setScissorRect(x, y, w, h);
|
|
17570
|
+
this.gpuBuffer.destroy();
|
|
17086
17571
|
};
|
|
17087
17572
|
|
|
17088
|
-
|
|
17089
|
-
|
|
17090
|
-
var gpuRenderPipeline = assertExists(pipeline.gpuRenderPipeline);
|
|
17091
|
-
this.gpuRenderPassEncoder.setPipeline(gpuRenderPipeline);
|
|
17092
|
-
};
|
|
17573
|
+
return Buffer_WebGPU;
|
|
17574
|
+
}(ResourceBase_WebGPU);
|
|
17093
17575
|
|
|
17094
|
-
|
|
17095
|
-
|
|
17096
|
-
|
|
17576
|
+
var ComputePass_WebGPU = /*#__PURE__*/function () {
|
|
17577
|
+
function ComputePass_WebGPU() {
|
|
17578
|
+
this.commandEncoder = null;
|
|
17579
|
+
this.descriptor = void 0;
|
|
17580
|
+
this.gpuComputePassDescriptor = void 0;
|
|
17581
|
+
this.gpuComputePassEncoder = null;
|
|
17582
|
+
}
|
|
17097
17583
|
|
|
17098
|
-
|
|
17099
|
-
|
|
17100
|
-
|
|
17101
|
-
|
|
17102
|
-
|
|
17584
|
+
var _proto = ComputePass_WebGPU.prototype;
|
|
17585
|
+
/**
|
|
17586
|
+
* @see https://www.w3.org/TR/webgpu/#dom-gpucomputepassencoder-dispatch
|
|
17587
|
+
*/
|
|
17588
|
+
|
|
17589
|
+
_proto.dispatch = function dispatch(x, y, z) {
|
|
17590
|
+
this.gpuComputePassEncoder.dispatch(x, y, z); // TODO: dispatchIndirect read from GPUBuffer
|
|
17591
|
+
};
|
|
17592
|
+
|
|
17593
|
+
_proto.finish = function finish() {
|
|
17594
|
+
this.gpuComputePassEncoder.end();
|
|
17595
|
+
this.gpuComputePassEncoder = null;
|
|
17596
|
+
return this.commandEncoder.finish();
|
|
17597
|
+
}
|
|
17598
|
+
/**
|
|
17599
|
+
* @see https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-begincomputepass
|
|
17600
|
+
*/
|
|
17601
|
+
;
|
|
17103
17602
|
|
|
17104
|
-
|
|
17105
|
-
|
|
17106
|
-
|
|
17107
|
-
|
|
17108
|
-
}
|
|
17603
|
+
_proto.beginComputePass = function beginComputePass(computePassDescriptor) {
|
|
17604
|
+
assert(this.gpuComputePassEncoder === null);
|
|
17605
|
+
this.setComputePassDescriptor(computePassDescriptor);
|
|
17606
|
+
this.gpuComputePassEncoder = this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor);
|
|
17109
17607
|
};
|
|
17110
17608
|
|
|
17111
|
-
_proto.
|
|
17112
|
-
var
|
|
17113
|
-
|
|
17114
|
-
this.
|
|
17609
|
+
_proto.setPipeline = function setPipeline(pipeline_) {
|
|
17610
|
+
var pipeline = pipeline_;
|
|
17611
|
+
var gpuComputePipeline = assertExists(pipeline.gpuComputePipeline);
|
|
17612
|
+
this.gpuComputePassEncoder.setPipeline(gpuComputePipeline);
|
|
17115
17613
|
};
|
|
17116
17614
|
|
|
17117
|
-
_proto.
|
|
17118
|
-
|
|
17615
|
+
_proto.setBindings = function setBindings(bindingLayoutIndex, bindings_) {
|
|
17616
|
+
var bindings = bindings_;
|
|
17617
|
+
this.gpuComputePassEncoder.setBindGroup(bindingLayoutIndex, bindings.gpuBindGroup[0]);
|
|
17119
17618
|
};
|
|
17120
17619
|
|
|
17121
|
-
_proto.
|
|
17122
|
-
this.
|
|
17620
|
+
_proto.setComputePassDescriptor = function setComputePassDescriptor(descriptor) {
|
|
17621
|
+
this.descriptor = descriptor;
|
|
17123
17622
|
};
|
|
17124
17623
|
|
|
17125
|
-
|
|
17126
|
-
|
|
17127
|
-
};
|
|
17624
|
+
return ComputePass_WebGPU;
|
|
17625
|
+
}();
|
|
17128
17626
|
|
|
17129
|
-
|
|
17130
|
-
|
|
17131
|
-
};
|
|
17627
|
+
var ComputePipeline_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
17628
|
+
_inheritsLoose$2(ComputePipeline_WebGPU, _ResourceBase_WebGPU);
|
|
17132
17629
|
|
|
17133
|
-
|
|
17134
|
-
|
|
17135
|
-
};
|
|
17630
|
+
function ComputePipeline_WebGPU(_ref) {
|
|
17631
|
+
var _this;
|
|
17136
17632
|
|
|
17137
|
-
|
|
17138
|
-
|
|
17139
|
-
|
|
17633
|
+
var id = _ref.id,
|
|
17634
|
+
device = _ref.device,
|
|
17635
|
+
descriptor = _ref.descriptor;
|
|
17636
|
+
_this = _ResourceBase_WebGPU.call(this, {
|
|
17637
|
+
id: id,
|
|
17638
|
+
device: device
|
|
17639
|
+
}) || this;
|
|
17640
|
+
_this.type = ResourceType.ComputePipeline;
|
|
17641
|
+
_this.descriptor = void 0;
|
|
17642
|
+
_this.gpuComputePipeline = null;
|
|
17643
|
+
_this.descriptor = descriptor;
|
|
17644
|
+
var program = descriptor.program;
|
|
17645
|
+
var computeStage = program.computeStage;
|
|
17646
|
+
if (computeStage === null) return _assertThisInitialized$1(_this);
|
|
17647
|
+
var gpuComputePipeline = {
|
|
17648
|
+
compute: _extends$1({}, computeStage),
|
|
17649
|
+
layout: undefined
|
|
17650
|
+
}; // @see https://www.w3.org/TR/webgpu/#dom-gpudevice-createrenderpipeline
|
|
17140
17651
|
|
|
17141
|
-
|
|
17142
|
-
// FIREFOX MISSING
|
|
17143
|
-
if (this.gpuRenderPassEncoder.pushDebugGroup === undefined) return;
|
|
17144
|
-
this.gpuRenderPassEncoder.pushDebugGroup(name);
|
|
17145
|
-
};
|
|
17652
|
+
_this.gpuComputePipeline = _this.device.device.createComputePipeline(gpuComputePipeline);
|
|
17146
17653
|
|
|
17147
|
-
|
|
17148
|
-
|
|
17149
|
-
|
|
17150
|
-
|
|
17654
|
+
if (_this.name !== undefined) {
|
|
17655
|
+
_this.gpuComputePipeline.label = _this.name;
|
|
17656
|
+
}
|
|
17657
|
+
|
|
17658
|
+
return _this;
|
|
17659
|
+
}
|
|
17660
|
+
|
|
17661
|
+
var _proto = ComputePipeline_WebGPU.prototype;
|
|
17662
|
+
|
|
17663
|
+
_proto.getBindGroupLayout = function getBindGroupLayout(index) {
|
|
17664
|
+
return this.gpuComputePipeline.getBindGroupLayout(index);
|
|
17151
17665
|
};
|
|
17152
17666
|
|
|
17153
|
-
|
|
17154
|
-
|
|
17155
|
-
this.gpuRenderPassEncoder = null; // Fake a resolve with a copy for non-MSAA.
|
|
17667
|
+
return ComputePipeline_WebGPU;
|
|
17668
|
+
}(ResourceBase_WebGPU);
|
|
17156
17669
|
|
|
17157
|
-
|
|
17158
|
-
|
|
17159
|
-
var colorResolveTo = this.gfxColorResolveTo[i];
|
|
17670
|
+
var InputLayout_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
17671
|
+
_inheritsLoose$2(InputLayout_WebGPU, _ResourceBase_WebGPU);
|
|
17160
17672
|
|
|
17161
|
-
|
|
17162
|
-
|
|
17163
|
-
}
|
|
17164
|
-
}
|
|
17673
|
+
function InputLayout_WebGPU(_ref) {
|
|
17674
|
+
var _this;
|
|
17165
17675
|
|
|
17166
|
-
|
|
17167
|
-
|
|
17168
|
-
|
|
17169
|
-
|
|
17676
|
+
var id = _ref.id,
|
|
17677
|
+
device = _ref.device,
|
|
17678
|
+
descriptor = _ref.descriptor;
|
|
17679
|
+
_this = _ResourceBase_WebGPU.call(this, {
|
|
17680
|
+
id: id,
|
|
17681
|
+
device: device
|
|
17682
|
+
}) || this;
|
|
17683
|
+
_this.type = ResourceType.InputLayout;
|
|
17684
|
+
_this.buffers = void 0;
|
|
17685
|
+
_this.indexFormat = void 0;
|
|
17686
|
+
var buffers = [];
|
|
17687
|
+
|
|
17688
|
+
for (var i = 0; i < descriptor.vertexBufferDescriptors.length; i++) {
|
|
17689
|
+
var b = descriptor.vertexBufferDescriptors[i];
|
|
17690
|
+
if (g.isNil(b)) continue;
|
|
17691
|
+
var arrayStride = b.byteStride;
|
|
17692
|
+
var stepMode = translateVertexBufferFrequency(b.frequency);
|
|
17693
|
+
var attributes = [];
|
|
17694
|
+
buffers[i] = {
|
|
17695
|
+
arrayStride: arrayStride,
|
|
17696
|
+
stepMode: stepMode,
|
|
17697
|
+
attributes: attributes
|
|
17698
|
+
};
|
|
17170
17699
|
}
|
|
17171
17700
|
|
|
17172
|
-
|
|
17173
|
-
|
|
17701
|
+
for (var _i = 0; _i < descriptor.vertexAttributeDescriptors.length; _i++) {
|
|
17702
|
+
var attr = descriptor.vertexAttributeDescriptors[_i];
|
|
17174
17703
|
|
|
17175
|
-
|
|
17176
|
-
assert(src.sampleCount === 1);
|
|
17177
|
-
var srcCopy = {
|
|
17178
|
-
texture: src.gpuTexture
|
|
17179
|
-
};
|
|
17180
|
-
var dstCopy = {
|
|
17181
|
-
texture: dst.gpuTexture
|
|
17182
|
-
};
|
|
17183
|
-
assert(src.width === dst.width);
|
|
17184
|
-
assert(src.height === dst.height);
|
|
17185
|
-
assert(!!(src.usage & GPUTextureUsage.COPY_SRC));
|
|
17186
|
-
assert(!!(dst.usage & GPUTextureUsage.COPY_DST));
|
|
17187
|
-
this.commandEncoder.copyTextureToTexture(srcCopy, dstCopy, [dst.width, dst.height, 1]);
|
|
17188
|
-
};
|
|
17704
|
+
var _b = assertExists(buffers[attr.bufferIndex]);
|
|
17189
17705
|
|
|
17190
|
-
|
|
17191
|
-
|
|
17706
|
+
var attribute = {
|
|
17707
|
+
shaderLocation: attr.location,
|
|
17708
|
+
format: translateVertexFormat(attr.format),
|
|
17709
|
+
offset: attr.bufferByteOffset
|
|
17710
|
+
};
|
|
17192
17711
|
|
|
17193
|
-
|
|
17194
|
-
|
|
17712
|
+
_b.attributes.push(attribute);
|
|
17713
|
+
}
|
|
17714
|
+
|
|
17715
|
+
_this.indexFormat = translateIndexFormat(descriptor.indexBufferFormat);
|
|
17716
|
+
_this.buffers = buffers;
|
|
17717
|
+
return _this;
|
|
17718
|
+
}
|
|
17195
17719
|
|
|
17720
|
+
return InputLayout_WebGPU;
|
|
17721
|
+
}(ResourceBase_WebGPU);
|
|
17196
17722
|
|
|
17197
|
-
|
|
17198
|
-
|
|
17723
|
+
var InputState_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
17724
|
+
_inheritsLoose$2(InputState_WebGPU, _ResourceBase_WebGPU);
|
|
17199
17725
|
|
|
17726
|
+
function InputState_WebGPU(_ref) {
|
|
17200
17727
|
var _this;
|
|
17201
17728
|
|
|
17202
17729
|
var id = _ref.id,
|
|
17203
17730
|
device = _ref.device,
|
|
17204
|
-
|
|
17731
|
+
inputLayout = _ref.inputLayout,
|
|
17732
|
+
vertexBuffers = _ref.vertexBuffers,
|
|
17733
|
+
indexBuffer = _ref.indexBuffer;
|
|
17205
17734
|
_this = _ResourceBase_WebGPU.call(this, {
|
|
17206
17735
|
id: id,
|
|
17207
17736
|
device: device
|
|
17208
17737
|
}) || this;
|
|
17209
|
-
_this.type = ResourceType.
|
|
17210
|
-
_this.
|
|
17211
|
-
|
|
17212
|
-
|
|
17213
|
-
|
|
17214
|
-
|
|
17215
|
-
_this.
|
|
17216
|
-
addressModeU: translateWrapMode(descriptor.wrapS),
|
|
17217
|
-
addressModeV: translateWrapMode(descriptor.wrapT),
|
|
17218
|
-
addressModeW: translateWrapMode((_descriptor$wrapQ = descriptor.wrapQ) !== null && _descriptor$wrapQ !== void 0 ? _descriptor$wrapQ : descriptor.wrapS),
|
|
17219
|
-
lodMinClamp: lodMinClamp,
|
|
17220
|
-
lodMaxClamp: lodMaxClamp,
|
|
17221
|
-
minFilter: translateMinMagFilter(descriptor.minFilter),
|
|
17222
|
-
magFilter: translateMinMagFilter(descriptor.magFilter),
|
|
17223
|
-
mipmapFilter: translateMipFilter(descriptor.mipFilter),
|
|
17224
|
-
maxAnisotropy: maxAnisotropy
|
|
17225
|
-
});
|
|
17738
|
+
_this.type = ResourceType.InputState;
|
|
17739
|
+
_this.inputLayout = void 0;
|
|
17740
|
+
_this.vertexBuffers = void 0;
|
|
17741
|
+
_this.indexBuffer = void 0;
|
|
17742
|
+
_this.inputLayout = inputLayout;
|
|
17743
|
+
_this.vertexBuffers = vertexBuffers;
|
|
17744
|
+
_this.indexBuffer = indexBuffer;
|
|
17226
17745
|
return _this;
|
|
17227
17746
|
}
|
|
17228
17747
|
|
|
17229
|
-
return
|
|
17748
|
+
return InputState_WebGPU;
|
|
17230
17749
|
}(ResourceBase_WebGPU);
|
|
17231
17750
|
|
|
17232
|
-
var
|
|
17233
|
-
_inheritsLoose$2(
|
|
17751
|
+
var Program_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
17752
|
+
_inheritsLoose$2(Program_WebGPU, _ResourceBase_WebGPU);
|
|
17234
17753
|
|
|
17235
|
-
function
|
|
17754
|
+
function Program_WebGPU(_ref) {
|
|
17236
17755
|
var _this;
|
|
17237
17756
|
|
|
17238
17757
|
var id = _ref.id,
|
|
17239
17758
|
device = _ref.device,
|
|
17240
|
-
descriptor = _ref.descriptor
|
|
17241
|
-
skipCreate = _ref.skipCreate;
|
|
17759
|
+
descriptor = _ref.descriptor;
|
|
17242
17760
|
_this = _ResourceBase_WebGPU.call(this, {
|
|
17243
17761
|
id: id,
|
|
17244
17762
|
device: device
|
|
17245
17763
|
}) || this;
|
|
17246
|
-
_this.type = ResourceType.
|
|
17247
|
-
_this.
|
|
17248
|
-
_this.
|
|
17249
|
-
_this.
|
|
17250
|
-
_this.
|
|
17251
|
-
_this.
|
|
17252
|
-
_this.depthOrArrayLayers = void 0;
|
|
17253
|
-
_this.numLevels = void 0;
|
|
17254
|
-
_this.sampleCount = void 0;
|
|
17255
|
-
_this.usage = void 0;
|
|
17256
|
-
_this.gpuTexture = void 0;
|
|
17257
|
-
_this.gpuTextureView = void 0;
|
|
17764
|
+
_this.type = ResourceType.Program;
|
|
17765
|
+
_this.descriptor = void 0;
|
|
17766
|
+
_this.vertexStage = null;
|
|
17767
|
+
_this.fragmentStage = null;
|
|
17768
|
+
_this.computeStage = null;
|
|
17769
|
+
_this.descriptor = descriptor;
|
|
17258
17770
|
|
|
17259
|
-
|
|
17260
|
-
|
|
17261
|
-
|
|
17262
|
-
|
|
17263
|
-
|
|
17264
|
-
|
|
17265
|
-
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17771
|
+
if (descriptor.preprocessedVert) {
|
|
17772
|
+
_this.vertexStage = _this.createShaderStage(descriptor.preprocessedVert, 'vertex');
|
|
17773
|
+
}
|
|
17774
|
+
|
|
17775
|
+
if (descriptor.preprocessedFrag) {
|
|
17776
|
+
_this.fragmentStage = _this.createShaderStage(descriptor.preprocessedFrag, 'fragment');
|
|
17777
|
+
}
|
|
17778
|
+
|
|
17779
|
+
if (descriptor.preprocessedCompute) {
|
|
17780
|
+
// FIXME: Only support WGSL now
|
|
17781
|
+
_this.computeStage = _this.createShaderStage(descriptor.preprocessedCompute, 'compute');
|
|
17782
|
+
}
|
|
17269
17783
|
|
|
17270
17784
|
return _this;
|
|
17271
17785
|
}
|
|
17272
17786
|
|
|
17273
|
-
var _proto =
|
|
17787
|
+
var _proto = Program_WebGPU.prototype;
|
|
17788
|
+
|
|
17789
|
+
_proto.createShaderStage = function createShaderStage(sourceText, shaderStage) {
|
|
17790
|
+
var validationEnabled = false;
|
|
17791
|
+
var code = sourceText;
|
|
17792
|
+
|
|
17793
|
+
if (shaderStage !== 'compute') {
|
|
17794
|
+
try {
|
|
17795
|
+
code = this.device.glsl_compile(sourceText, shaderStage, validationEnabled);
|
|
17796
|
+
} catch (e) {
|
|
17797
|
+
console.error(e, sourceText);
|
|
17798
|
+
throw new Error('whoops');
|
|
17799
|
+
}
|
|
17800
|
+
} // Workaround for https://github.com/gfx-rs/naga/issues/1355
|
|
17274
17801
|
|
|
17275
|
-
_proto.setImageData = function setImageData(data, level) {// TODO: https://www.w3.org/TR/webgpu/#image-copies
|
|
17276
|
-
};
|
|
17277
17802
|
|
|
17278
|
-
|
|
17279
|
-
|
|
17280
|
-
|
|
17281
|
-
|
|
17803
|
+
var _loop = function _loop() {
|
|
17804
|
+
var depthTextureName = _arr[_i];
|
|
17805
|
+
if (!code.includes(depthTextureName)) return "continue";
|
|
17806
|
+
code = code.replace("var T_" + depthTextureName + ": texture_2d<f32>;", "var T_" + depthTextureName + ": texture_depth_2d;");
|
|
17807
|
+
code = code.replace(new RegExp("textureSample\\(T_" + depthTextureName + "(.*)\\);$", 'gm'), function (sub, cap) {
|
|
17808
|
+
return "vec4<f32>(textureSample(T_" + depthTextureName + cap + "), 0.0, 0.0, 0.0);";
|
|
17809
|
+
});
|
|
17810
|
+
};
|
|
17282
17811
|
|
|
17283
|
-
|
|
17284
|
-
|
|
17812
|
+
for (var _i = 0, _arr = ['u_TextureFramebufferDepth']; _i < _arr.length; _i++) {
|
|
17813
|
+
var _ret = _loop();
|
|
17285
17814
|
|
|
17286
|
-
|
|
17287
|
-
|
|
17815
|
+
if (_ret === "continue") continue;
|
|
17816
|
+
} // @see https://www.w3.org/TR/webgpu/#dom-gpudevice-createshadermodule
|
|
17288
17817
|
|
|
17289
|
-
function InputState_WebGPU(_ref) {
|
|
17290
|
-
var _this;
|
|
17291
17818
|
|
|
17292
|
-
var
|
|
17293
|
-
|
|
17294
|
-
|
|
17295
|
-
|
|
17296
|
-
|
|
17297
|
-
|
|
17298
|
-
|
|
17299
|
-
|
|
17300
|
-
}) || this;
|
|
17301
|
-
_this.type = ResourceType.InputState;
|
|
17302
|
-
_this.inputLayout = void 0;
|
|
17303
|
-
_this.vertexBuffers = void 0;
|
|
17304
|
-
_this.indexBuffer = void 0;
|
|
17305
|
-
_this.inputLayout = inputLayout;
|
|
17306
|
-
_this.vertexBuffers = vertexBuffers;
|
|
17307
|
-
_this.indexBuffer = indexBuffer;
|
|
17308
|
-
return _this;
|
|
17309
|
-
}
|
|
17819
|
+
var shaderModule = this.device.device.createShaderModule({
|
|
17820
|
+
code: code
|
|
17821
|
+
});
|
|
17822
|
+
return {
|
|
17823
|
+
module: shaderModule,
|
|
17824
|
+
entryPoint: 'main'
|
|
17825
|
+
};
|
|
17826
|
+
};
|
|
17310
17827
|
|
|
17311
|
-
return
|
|
17828
|
+
return Program_WebGPU;
|
|
17312
17829
|
}(ResourceBase_WebGPU);
|
|
17313
17830
|
|
|
17314
|
-
var
|
|
17315
|
-
_inheritsLoose$2(
|
|
17831
|
+
var QueryPool_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
17832
|
+
_inheritsLoose$2(QueryPool_WebGPU, _ResourceBase_WebGPU);
|
|
17316
17833
|
|
|
17317
|
-
function
|
|
17834
|
+
function QueryPool_WebGPU(_ref) {
|
|
17318
17835
|
var _this;
|
|
17319
17836
|
|
|
17320
17837
|
var id = _ref.id,
|
|
@@ -17324,25 +17841,24 @@
|
|
|
17324
17841
|
id: id,
|
|
17325
17842
|
device: device
|
|
17326
17843
|
}) || this;
|
|
17327
|
-
_this.type = ResourceType.
|
|
17328
|
-
_this.
|
|
17329
|
-
|
|
17330
|
-
|
|
17331
|
-
_this.
|
|
17332
|
-
|
|
17333
|
-
|
|
17334
|
-
|
|
17335
|
-
|
|
17844
|
+
_this.type = ResourceType.QueryPool;
|
|
17845
|
+
_this.querySet = void 0;
|
|
17846
|
+
var elemCount = descriptor.elemCount,
|
|
17847
|
+
type = descriptor.type;
|
|
17848
|
+
_this.querySet = _this.device.device.createQuerySet({
|
|
17849
|
+
type: translateQueryPoolType(type),
|
|
17850
|
+
count: elemCount
|
|
17851
|
+
});
|
|
17336
17852
|
return _this;
|
|
17337
17853
|
}
|
|
17338
17854
|
|
|
17339
|
-
var _proto =
|
|
17855
|
+
var _proto = QueryPool_WebGPU.prototype;
|
|
17340
17856
|
|
|
17341
|
-
_proto.
|
|
17342
|
-
return
|
|
17857
|
+
_proto.queryResultOcclusion = function queryResultOcclusion(dstOffs) {
|
|
17858
|
+
return true;
|
|
17343
17859
|
};
|
|
17344
17860
|
|
|
17345
|
-
return
|
|
17861
|
+
return QueryPool_WebGPU;
|
|
17346
17862
|
}(ResourceBase_WebGPU);
|
|
17347
17863
|
|
|
17348
17864
|
var Readback_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
@@ -17658,13 +18174,8 @@
|
|
|
17658
18174
|
height: 1,
|
|
17659
18175
|
length: 4
|
|
17660
18176
|
};
|
|
17661
|
-
|
|
17662
|
-
|
|
17663
|
-
return {
|
|
17664
|
-
width: 1,
|
|
17665
|
-
height: 1,
|
|
17666
|
-
length: 4
|
|
17667
|
-
};
|
|
18177
|
+
// case 'depth24unorm-stencil8':
|
|
18178
|
+
// return { width: 1, height: 1, length: 4 };
|
|
17668
18179
|
|
|
17669
18180
|
case 'depth32float-stencil8':
|
|
17670
18181
|
return {
|
|
@@ -17701,73 +18212,260 @@
|
|
|
17701
18212
|
length: 8
|
|
17702
18213
|
};
|
|
17703
18214
|
|
|
17704
|
-
default:
|
|
17705
|
-
return {
|
|
17706
|
-
width: 1,
|
|
17707
|
-
height: 1,
|
|
17708
|
-
length: 4
|
|
17709
|
-
};
|
|
18215
|
+
default:
|
|
18216
|
+
return {
|
|
18217
|
+
width: 1,
|
|
18218
|
+
height: 1,
|
|
18219
|
+
length: 4
|
|
18220
|
+
};
|
|
18221
|
+
}
|
|
18222
|
+
};
|
|
18223
|
+
|
|
18224
|
+
return Readback_WebGPU;
|
|
18225
|
+
}(ResourceBase_WebGPU);
|
|
18226
|
+
|
|
18227
|
+
var RenderPass_WebGPU = /*#__PURE__*/function () {
|
|
18228
|
+
function RenderPass_WebGPU() {
|
|
18229
|
+
this.commandEncoder = null;
|
|
18230
|
+
this.descriptor = void 0;
|
|
18231
|
+
this.gpuRenderPassEncoder = null;
|
|
18232
|
+
this.gpuRenderPassDescriptor = void 0;
|
|
18233
|
+
this.gpuColorAttachments = void 0;
|
|
18234
|
+
this.gpuDepthStencilAttachment = void 0;
|
|
18235
|
+
this.gfxColorAttachment = [];
|
|
18236
|
+
this.gfxColorResolveTo = [];
|
|
18237
|
+
this.gfxDepthStencilAttachment = null;
|
|
18238
|
+
this.gfxDepthStencilResolveTo = null;
|
|
18239
|
+
this.gpuColorAttachments = [];
|
|
18240
|
+
this.gpuDepthStencilAttachment = {
|
|
18241
|
+
view: null,
|
|
18242
|
+
depthLoadOp: 'load',
|
|
18243
|
+
depthStoreOp: 'store',
|
|
18244
|
+
stencilLoadOp: 'load',
|
|
18245
|
+
stencilStoreOp: 'store'
|
|
18246
|
+
};
|
|
18247
|
+
this.gpuRenderPassDescriptor = {
|
|
18248
|
+
colorAttachments: this.gpuColorAttachments,
|
|
18249
|
+
depthStencilAttachment: this.gpuDepthStencilAttachment
|
|
18250
|
+
};
|
|
18251
|
+
}
|
|
18252
|
+
|
|
18253
|
+
var _proto = RenderPass_WebGPU.prototype;
|
|
18254
|
+
|
|
18255
|
+
_proto.setRenderPassDescriptor = function setRenderPassDescriptor(descriptor) {
|
|
18256
|
+
this.descriptor = descriptor;
|
|
18257
|
+
this.gpuRenderPassDescriptor.colorAttachments = this.gpuColorAttachments;
|
|
18258
|
+
var numColorAttachments = descriptor.colorAttachment.length;
|
|
18259
|
+
this.gfxColorAttachment.length = numColorAttachments;
|
|
18260
|
+
this.gfxColorResolveTo.length = numColorAttachments;
|
|
18261
|
+
|
|
18262
|
+
for (var i = 0; i < descriptor.colorAttachment.length; i++) {
|
|
18263
|
+
var colorAttachment = descriptor.colorAttachment[i];
|
|
18264
|
+
var colorResolveTo = descriptor.colorResolveTo[i]; // Do some dumb juggling...
|
|
18265
|
+
|
|
18266
|
+
if (colorAttachment === null && colorResolveTo !== null) {
|
|
18267
|
+
colorAttachment = colorResolveTo;
|
|
18268
|
+
colorResolveTo = null;
|
|
18269
|
+
}
|
|
18270
|
+
|
|
18271
|
+
this.gfxColorAttachment[i] = colorAttachment;
|
|
18272
|
+
this.gfxColorResolveTo[i] = colorResolveTo;
|
|
18273
|
+
|
|
18274
|
+
if (colorAttachment !== null) {
|
|
18275
|
+
if (this.gpuColorAttachments[i] === undefined) {
|
|
18276
|
+
this.gpuColorAttachments[i] = {};
|
|
18277
|
+
}
|
|
18278
|
+
|
|
18279
|
+
var dstAttachment = this.gpuColorAttachments[i];
|
|
18280
|
+
dstAttachment.view = colorAttachment.gpuTextureView;
|
|
18281
|
+
var clearColor = descriptor.colorClearColor[i];
|
|
18282
|
+
|
|
18283
|
+
if (clearColor === 'load') {
|
|
18284
|
+
dstAttachment.loadOp = 'load';
|
|
18285
|
+
} else {
|
|
18286
|
+
dstAttachment.loadOp = 'clear';
|
|
18287
|
+
dstAttachment.clearValue = clearColor;
|
|
18288
|
+
}
|
|
18289
|
+
|
|
18290
|
+
dstAttachment.storeOp = descriptor.colorStore[i] ? 'store' : 'discard';
|
|
18291
|
+
dstAttachment.resolveTarget = undefined;
|
|
18292
|
+
|
|
18293
|
+
if (colorResolveTo !== null) {
|
|
18294
|
+
if (colorAttachment.sampleCount > 1) {
|
|
18295
|
+
dstAttachment.resolveTarget = colorResolveTo.gpuTextureView;
|
|
18296
|
+
} else {
|
|
18297
|
+
dstAttachment.storeOp = 'store';
|
|
18298
|
+
}
|
|
18299
|
+
}
|
|
18300
|
+
} else {
|
|
18301
|
+
// https://github.com/gpuweb/gpuweb/issues/1250
|
|
18302
|
+
this.gpuColorAttachments.length = i;
|
|
18303
|
+
this.gfxColorAttachment.length = i;
|
|
18304
|
+
this.gfxColorResolveTo.length = i;
|
|
18305
|
+
break;
|
|
18306
|
+
}
|
|
18307
|
+
}
|
|
18308
|
+
|
|
18309
|
+
this.gfxDepthStencilAttachment = descriptor.depthStencilAttachment;
|
|
18310
|
+
this.gfxDepthStencilResolveTo = descriptor.depthStencilResolveTo;
|
|
18311
|
+
|
|
18312
|
+
if (descriptor.depthStencilAttachment !== null) {
|
|
18313
|
+
var dsAttachment = descriptor.depthStencilAttachment;
|
|
18314
|
+
var _dstAttachment = this.gpuDepthStencilAttachment;
|
|
18315
|
+
_dstAttachment.view = dsAttachment.gpuTextureView;
|
|
18316
|
+
|
|
18317
|
+
if (descriptor.depthClearValue === 'load') {
|
|
18318
|
+
_dstAttachment.depthLoadOp = 'load';
|
|
18319
|
+
} else {
|
|
18320
|
+
_dstAttachment.depthLoadOp = 'clear';
|
|
18321
|
+
_dstAttachment.depthClearValue = descriptor.depthClearValue;
|
|
18322
|
+
}
|
|
18323
|
+
|
|
18324
|
+
if (descriptor.stencilClearValue === 'load') {
|
|
18325
|
+
_dstAttachment.stencilLoadOp = 'load';
|
|
18326
|
+
} else {
|
|
18327
|
+
_dstAttachment.stencilLoadOp = 'clear';
|
|
18328
|
+
_dstAttachment.stencilClearValue = descriptor.stencilClearValue;
|
|
18329
|
+
}
|
|
18330
|
+
|
|
18331
|
+
_dstAttachment.depthStoreOp = descriptor.depthStencilStore ? 'store' : 'discard';
|
|
18332
|
+
_dstAttachment.stencilStoreOp = descriptor.depthStencilStore ? 'store' : 'discard';
|
|
18333
|
+
this.gpuRenderPassDescriptor.depthStencilAttachment = this.gpuDepthStencilAttachment;
|
|
18334
|
+
|
|
18335
|
+
if (this.gfxDepthStencilResolveTo !== null) {
|
|
18336
|
+
_dstAttachment.depthStoreOp = 'store';
|
|
18337
|
+
_dstAttachment.stencilStoreOp = 'store';
|
|
18338
|
+
}
|
|
18339
|
+
} else {
|
|
18340
|
+
this.gpuRenderPassDescriptor.depthStencilAttachment = undefined;
|
|
18341
|
+
}
|
|
18342
|
+
|
|
18343
|
+
this.gpuRenderPassDescriptor.occlusionQuerySet = descriptor.occlusionQueryPool !== null ? getPlatformQuerySet(descriptor.occlusionQueryPool) : undefined;
|
|
18344
|
+
};
|
|
18345
|
+
|
|
18346
|
+
_proto.beginRenderPass = function beginRenderPass(renderPassDescriptor) {
|
|
18347
|
+
assert(this.gpuRenderPassEncoder === null);
|
|
18348
|
+
this.setRenderPassDescriptor(renderPassDescriptor);
|
|
18349
|
+
this.gpuRenderPassEncoder = this.commandEncoder.beginRenderPass(this.gpuRenderPassDescriptor);
|
|
18350
|
+
};
|
|
18351
|
+
|
|
18352
|
+
_proto.setViewport = function setViewport(x, y, w, h) {
|
|
18353
|
+
this.gpuRenderPassEncoder.setViewport(x, y, w, h, 0, 1);
|
|
18354
|
+
};
|
|
18355
|
+
|
|
18356
|
+
_proto.setScissor = function setScissor(x, y, w, h) {
|
|
18357
|
+
this.gpuRenderPassEncoder.setScissorRect(x, y, w, h);
|
|
18358
|
+
};
|
|
18359
|
+
|
|
18360
|
+
_proto.setPipeline = function setPipeline(pipeline_) {
|
|
18361
|
+
var pipeline = pipeline_;
|
|
18362
|
+
var gpuRenderPipeline = assertExists(pipeline.gpuRenderPipeline);
|
|
18363
|
+
this.gpuRenderPassEncoder.setPipeline(gpuRenderPipeline);
|
|
18364
|
+
};
|
|
18365
|
+
|
|
18366
|
+
_proto.setInputState = function setInputState(inputState_) {
|
|
18367
|
+
if (inputState_ === null) return;
|
|
18368
|
+
var inputState = inputState_;
|
|
18369
|
+
|
|
18370
|
+
if (inputState.indexBuffer !== null) {
|
|
18371
|
+
var inputLayout = inputState.inputLayout;
|
|
18372
|
+
var indexBuffer = inputState.indexBuffer;
|
|
18373
|
+
this.gpuRenderPassEncoder.setIndexBuffer(getPlatformBuffer(indexBuffer.buffer), assertExists(inputLayout.indexFormat), indexBuffer.byteOffset);
|
|
18374
|
+
}
|
|
18375
|
+
|
|
18376
|
+
for (var i = 0; i < inputState.vertexBuffers.length; i++) {
|
|
18377
|
+
var b = inputState.vertexBuffers[i];
|
|
18378
|
+
if (g.isNil(b)) continue;
|
|
18379
|
+
this.gpuRenderPassEncoder.setVertexBuffer(i, getPlatformBuffer(b.buffer), b.byteOffset);
|
|
17710
18380
|
}
|
|
17711
18381
|
};
|
|
17712
18382
|
|
|
17713
|
-
|
|
17714
|
-
|
|
18383
|
+
_proto.setBindings = function setBindings(bindingLayoutIndex, bindings_, dynamicByteOffsets) {
|
|
18384
|
+
var bindings = bindings_;
|
|
18385
|
+
this.gpuRenderPassEncoder.setBindGroup(bindingLayoutIndex + 0, bindings.gpuBindGroup[0], dynamicByteOffsets.slice(0, bindings.bindingLayout.numUniformBuffers));
|
|
18386
|
+
this.gpuRenderPassEncoder.setBindGroup(bindingLayoutIndex + 1, bindings.gpuBindGroup[1]);
|
|
18387
|
+
};
|
|
17715
18388
|
|
|
17716
|
-
|
|
17717
|
-
|
|
17718
|
-
|
|
17719
|
-
this.descriptor = void 0;
|
|
17720
|
-
this.gpuComputePassDescriptor = void 0;
|
|
17721
|
-
this.gpuComputePassEncoder = null;
|
|
17722
|
-
}
|
|
18389
|
+
_proto.setStencilRef = function setStencilRef(ref) {
|
|
18390
|
+
this.gpuRenderPassEncoder.setStencilReference(ref);
|
|
18391
|
+
};
|
|
17723
18392
|
|
|
17724
|
-
|
|
17725
|
-
|
|
17726
|
-
|
|
17727
|
-
*/
|
|
18393
|
+
_proto.draw = function draw(vertexCount, firstVertex) {
|
|
18394
|
+
this.gpuRenderPassEncoder.draw(vertexCount, 1, firstVertex, 0);
|
|
18395
|
+
};
|
|
17728
18396
|
|
|
17729
|
-
_proto.
|
|
17730
|
-
this.
|
|
18397
|
+
_proto.drawIndexed = function drawIndexed(indexCount, firstIndex) {
|
|
18398
|
+
this.gpuRenderPassEncoder.drawIndexed(indexCount, 1, firstIndex, 0, 0);
|
|
17731
18399
|
};
|
|
17732
18400
|
|
|
17733
|
-
_proto.
|
|
17734
|
-
this.
|
|
17735
|
-
|
|
17736
|
-
return this.commandEncoder.finish();
|
|
17737
|
-
}
|
|
17738
|
-
/**
|
|
17739
|
-
* @see https://www.w3.org/TR/webgpu/#dom-gpucommandencoder-begincomputepass
|
|
17740
|
-
*/
|
|
17741
|
-
;
|
|
18401
|
+
_proto.drawIndexedInstanced = function drawIndexedInstanced(indexCount, firstIndex, instanceCount) {
|
|
18402
|
+
this.gpuRenderPassEncoder.drawIndexed(indexCount, instanceCount, firstIndex, 0, 0);
|
|
18403
|
+
};
|
|
17742
18404
|
|
|
17743
|
-
_proto.
|
|
17744
|
-
|
|
17745
|
-
this.setComputePassDescriptor(computePassDescriptor);
|
|
17746
|
-
this.gpuComputePassEncoder = this.commandEncoder.beginComputePass(this.gpuComputePassDescriptor);
|
|
18405
|
+
_proto.beginOcclusionQuery = function beginOcclusionQuery(dstOffs) {
|
|
18406
|
+
this.gpuRenderPassEncoder.beginOcclusionQuery(dstOffs);
|
|
17747
18407
|
};
|
|
17748
18408
|
|
|
17749
|
-
_proto.
|
|
17750
|
-
|
|
17751
|
-
var gpuComputePipeline = assertExists(pipeline.gpuComputePipeline);
|
|
17752
|
-
this.gpuComputePassEncoder.setPipeline(gpuComputePipeline);
|
|
18409
|
+
_proto.endOcclusionQuery = function endOcclusionQuery(dstOffs) {
|
|
18410
|
+
this.gpuRenderPassEncoder.endOcclusionQuery();
|
|
17753
18411
|
};
|
|
17754
18412
|
|
|
17755
|
-
_proto.
|
|
17756
|
-
|
|
17757
|
-
this.
|
|
18413
|
+
_proto.beginDebugGroup = function beginDebugGroup(name) {
|
|
18414
|
+
// FIREFOX MISSING
|
|
18415
|
+
if (this.gpuRenderPassEncoder.pushDebugGroup === undefined) return;
|
|
18416
|
+
this.gpuRenderPassEncoder.pushDebugGroup(name);
|
|
17758
18417
|
};
|
|
17759
18418
|
|
|
17760
|
-
_proto.
|
|
17761
|
-
|
|
18419
|
+
_proto.endDebugGroup = function endDebugGroup() {
|
|
18420
|
+
// FIREFOX MISSING
|
|
18421
|
+
if (this.gpuRenderPassEncoder.popDebugGroup === undefined) return;
|
|
18422
|
+
this.gpuRenderPassEncoder.popDebugGroup();
|
|
17762
18423
|
};
|
|
17763
18424
|
|
|
17764
|
-
|
|
18425
|
+
_proto.finish = function finish() {
|
|
18426
|
+
this.gpuRenderPassEncoder.end();
|
|
18427
|
+
this.gpuRenderPassEncoder = null; // Fake a resolve with a copy for non-MSAA.
|
|
18428
|
+
|
|
18429
|
+
for (var i = 0; i < this.gfxColorAttachment.length; i++) {
|
|
18430
|
+
var colorAttachment = this.gfxColorAttachment[i];
|
|
18431
|
+
var colorResolveTo = this.gfxColorResolveTo[i];
|
|
18432
|
+
|
|
18433
|
+
if (colorAttachment !== null && colorResolveTo !== null && colorAttachment.sampleCount === 1) {
|
|
18434
|
+
this.copyAttachment(colorResolveTo, colorAttachment);
|
|
18435
|
+
}
|
|
18436
|
+
}
|
|
18437
|
+
|
|
18438
|
+
if (this.gfxDepthStencilAttachment !== null && this.gfxDepthStencilResolveTo !== null) {
|
|
18439
|
+
if (this.gfxDepthStencilAttachment.sampleCount > 1) ;else {
|
|
18440
|
+
this.copyAttachment(this.gfxDepthStencilResolveTo, this.gfxDepthStencilAttachment);
|
|
18441
|
+
}
|
|
18442
|
+
}
|
|
18443
|
+
|
|
18444
|
+
return this.commandEncoder.finish();
|
|
18445
|
+
};
|
|
18446
|
+
|
|
18447
|
+
_proto.copyAttachment = function copyAttachment(dst, src) {
|
|
18448
|
+
assert(src.sampleCount === 1);
|
|
18449
|
+
var srcCopy = {
|
|
18450
|
+
texture: src.gpuTexture
|
|
18451
|
+
};
|
|
18452
|
+
var dstCopy = {
|
|
18453
|
+
texture: dst.gpuTexture
|
|
18454
|
+
};
|
|
18455
|
+
assert(src.width === dst.width);
|
|
18456
|
+
assert(src.height === dst.height);
|
|
18457
|
+
assert(!!(src.usage & GPUTextureUsage.COPY_SRC));
|
|
18458
|
+
assert(!!(dst.usage & GPUTextureUsage.COPY_DST));
|
|
18459
|
+
this.commandEncoder.copyTextureToTexture(srcCopy, dstCopy, [dst.width, dst.height, 1]);
|
|
18460
|
+
};
|
|
18461
|
+
|
|
18462
|
+
return RenderPass_WebGPU;
|
|
17765
18463
|
}();
|
|
17766
18464
|
|
|
17767
|
-
var
|
|
17768
|
-
_inheritsLoose$2(
|
|
18465
|
+
var RenderPipeline_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
18466
|
+
_inheritsLoose$2(RenderPipeline_WebGPU, _ResourceBase_WebGPU);
|
|
17769
18467
|
|
|
17770
|
-
function
|
|
18468
|
+
function RenderPipeline_WebGPU(_ref) {
|
|
17771
18469
|
var _this;
|
|
17772
18470
|
|
|
17773
18471
|
var id = _ref.id,
|
|
@@ -17777,40 +18475,34 @@
|
|
|
17777
18475
|
id: id,
|
|
17778
18476
|
device: device
|
|
17779
18477
|
}) || this;
|
|
17780
|
-
_this.type = ResourceType.
|
|
18478
|
+
_this.type = ResourceType.RenderPipeline;
|
|
17781
18479
|
_this.descriptor = void 0;
|
|
17782
|
-
_this.
|
|
18480
|
+
_this.isCreating = false;
|
|
18481
|
+
_this.isCreatingAsync = false;
|
|
18482
|
+
_this.gpuRenderPipeline = null;
|
|
17783
18483
|
_this.descriptor = descriptor;
|
|
17784
|
-
var program = descriptor.program;
|
|
17785
|
-
var computeStage = program.computeStage;
|
|
17786
|
-
if (computeStage === null) return _assertThisInitialized$1(_this);
|
|
17787
|
-
var gpuComputePipeline = {
|
|
17788
|
-
compute: _extends$1({}, computeStage),
|
|
17789
|
-
layout: undefined
|
|
17790
|
-
}; // @see https://www.w3.org/TR/webgpu/#dom-gpudevice-createrenderpipeline
|
|
17791
|
-
|
|
17792
|
-
_this.gpuComputePipeline = _this.device.device.createComputePipeline(gpuComputePipeline);
|
|
17793
18484
|
|
|
17794
|
-
|
|
17795
|
-
_this.gpuComputePipeline.label = _this.name;
|
|
17796
|
-
}
|
|
18485
|
+
_this.device._createRenderPipeline(_assertThisInitialized$1(_this), false);
|
|
17797
18486
|
|
|
17798
18487
|
return _this;
|
|
17799
18488
|
}
|
|
17800
18489
|
|
|
17801
|
-
var _proto =
|
|
18490
|
+
var _proto = RenderPipeline_WebGPU.prototype;
|
|
17802
18491
|
|
|
17803
18492
|
_proto.getBindGroupLayout = function getBindGroupLayout(index) {
|
|
17804
|
-
return this.
|
|
18493
|
+
return this.gpuRenderPipeline.getBindGroupLayout(index);
|
|
17805
18494
|
};
|
|
17806
18495
|
|
|
17807
|
-
return
|
|
18496
|
+
return RenderPipeline_WebGPU;
|
|
17808
18497
|
}(ResourceBase_WebGPU);
|
|
17809
18498
|
|
|
17810
|
-
var
|
|
17811
|
-
_inheritsLoose$2(
|
|
18499
|
+
var Sampler_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
18500
|
+
_inheritsLoose$2(Sampler_WebGPU, _ResourceBase_WebGPU); // @see https://www.w3.org/TR/webgpu/#gpusampler
|
|
18501
|
+
|
|
18502
|
+
|
|
18503
|
+
function Sampler_WebGPU(_ref) {
|
|
18504
|
+
var _descriptor$maxAnisot, _descriptor$wrapQ;
|
|
17812
18505
|
|
|
17813
|
-
function QueryPool_WebGPU(_ref) {
|
|
17814
18506
|
var _this;
|
|
17815
18507
|
|
|
17816
18508
|
var id = _ref.id,
|
|
@@ -17820,24 +18512,81 @@
|
|
|
17820
18512
|
id: id,
|
|
17821
18513
|
device: device
|
|
17822
18514
|
}) || this;
|
|
17823
|
-
_this.type = ResourceType.
|
|
17824
|
-
_this.
|
|
17825
|
-
var
|
|
17826
|
-
|
|
17827
|
-
|
|
17828
|
-
|
|
17829
|
-
|
|
18515
|
+
_this.type = ResourceType.Sampler;
|
|
18516
|
+
_this.gpuSampler = void 0;
|
|
18517
|
+
var lodMinClamp = descriptor.minLOD;
|
|
18518
|
+
var lodMaxClamp = descriptor.mipFilter === MipFilterMode.NoMip ? descriptor.minLOD : descriptor.maxLOD;
|
|
18519
|
+
var maxAnisotropy = (_descriptor$maxAnisot = descriptor.maxAnisotropy) !== null && _descriptor$maxAnisot !== void 0 ? _descriptor$maxAnisot : 1;
|
|
18520
|
+
if (maxAnisotropy > 1) assert(descriptor.minFilter === TexFilterMode.Bilinear && descriptor.magFilter === TexFilterMode.Bilinear && descriptor.mipFilter === MipFilterMode.Linear);
|
|
18521
|
+
_this.gpuSampler = _this.device.device.createSampler({
|
|
18522
|
+
addressModeU: translateWrapMode(descriptor.wrapS),
|
|
18523
|
+
addressModeV: translateWrapMode(descriptor.wrapT),
|
|
18524
|
+
addressModeW: translateWrapMode((_descriptor$wrapQ = descriptor.wrapQ) !== null && _descriptor$wrapQ !== void 0 ? _descriptor$wrapQ : descriptor.wrapS),
|
|
18525
|
+
lodMinClamp: lodMinClamp,
|
|
18526
|
+
lodMaxClamp: lodMaxClamp,
|
|
18527
|
+
minFilter: translateMinMagFilter(descriptor.minFilter),
|
|
18528
|
+
magFilter: translateMinMagFilter(descriptor.magFilter),
|
|
18529
|
+
mipmapFilter: translateMipFilter(descriptor.mipFilter),
|
|
18530
|
+
maxAnisotropy: maxAnisotropy
|
|
17830
18531
|
});
|
|
17831
18532
|
return _this;
|
|
17832
18533
|
}
|
|
17833
18534
|
|
|
17834
|
-
|
|
18535
|
+
return Sampler_WebGPU;
|
|
18536
|
+
}(ResourceBase_WebGPU);
|
|
17835
18537
|
|
|
17836
|
-
|
|
17837
|
-
|
|
18538
|
+
var Texture_WebGPU = /*#__PURE__*/function (_ResourceBase_WebGPU) {
|
|
18539
|
+
_inheritsLoose$2(Texture_WebGPU, _ResourceBase_WebGPU);
|
|
18540
|
+
|
|
18541
|
+
function Texture_WebGPU(_ref) {
|
|
18542
|
+
var _this;
|
|
18543
|
+
|
|
18544
|
+
var id = _ref.id,
|
|
18545
|
+
device = _ref.device,
|
|
18546
|
+
descriptor = _ref.descriptor,
|
|
18547
|
+
skipCreate = _ref.skipCreate;
|
|
18548
|
+
_this = _ResourceBase_WebGPU.call(this, {
|
|
18549
|
+
id: id,
|
|
18550
|
+
device: device
|
|
18551
|
+
}) || this;
|
|
18552
|
+
_this.type = ResourceType.Texture;
|
|
18553
|
+
_this.pixelFormat = void 0;
|
|
18554
|
+
_this.dimension = void 0;
|
|
18555
|
+
_this.format = void 0;
|
|
18556
|
+
_this.width = void 0;
|
|
18557
|
+
_this.height = void 0;
|
|
18558
|
+
_this.depthOrArrayLayers = void 0;
|
|
18559
|
+
_this.numLevels = void 0;
|
|
18560
|
+
_this.sampleCount = void 0;
|
|
18561
|
+
_this.usage = void 0;
|
|
18562
|
+
_this.gpuTexture = void 0;
|
|
18563
|
+
_this.gpuTextureView = void 0;
|
|
18564
|
+
|
|
18565
|
+
_this.device.createTextureShared({
|
|
18566
|
+
pixelFormat: descriptor.pixelFormat,
|
|
18567
|
+
dimension: descriptor.dimension,
|
|
18568
|
+
width: descriptor.width,
|
|
18569
|
+
height: descriptor.height,
|
|
18570
|
+
depthOrArrayLayers: descriptor.depth,
|
|
18571
|
+
numLevels: descriptor.numLevels,
|
|
18572
|
+
usage: descriptor.usage,
|
|
18573
|
+
sampleCount: 1
|
|
18574
|
+
}, _assertThisInitialized$1(_this), skipCreate);
|
|
18575
|
+
|
|
18576
|
+
return _this;
|
|
18577
|
+
}
|
|
18578
|
+
|
|
18579
|
+
var _proto = Texture_WebGPU.prototype;
|
|
18580
|
+
|
|
18581
|
+
_proto.setImageData = function setImageData(data, level) {// TODO: https://www.w3.org/TR/webgpu/#image-copies
|
|
17838
18582
|
};
|
|
17839
18583
|
|
|
17840
|
-
|
|
18584
|
+
_proto.destroy = function destroy() {
|
|
18585
|
+
// @see https://www.w3.org/TR/webgpu/#dom-gputexture-destroy
|
|
18586
|
+
this.gpuTexture.destroy();
|
|
18587
|
+
};
|
|
18588
|
+
|
|
18589
|
+
return Texture_WebGPU;
|
|
17841
18590
|
}(ResourceBase_WebGPU);
|
|
17842
18591
|
|
|
17843
18592
|
var Device_WebGPU = /*#__PURE__*/function () {
|
|
@@ -18355,6 +19104,15 @@
|
|
|
18355
19104
|
return this.featureTextureCompressionBC;
|
|
18356
19105
|
}
|
|
18357
19106
|
|
|
19107
|
+
switch (format) {
|
|
19108
|
+
case Format.U16_RGBA_NORM:
|
|
19109
|
+
return false;
|
|
19110
|
+
|
|
19111
|
+
case Format.F32_RGBA:
|
|
19112
|
+
return false;
|
|
19113
|
+
// unfilterable
|
|
19114
|
+
}
|
|
19115
|
+
|
|
18358
19116
|
return true;
|
|
18359
19117
|
};
|
|
18360
19118
|
|
|
@@ -18431,9 +19189,9 @@
|
|
|
18431
19189
|
var _proto = WebGPUDeviceContribution.prototype;
|
|
18432
19190
|
|
|
18433
19191
|
_proto.createSwapChain = /*#__PURE__*/function () {
|
|
18434
|
-
var _createSwapChain = _asyncToGenerator$
|
|
19192
|
+
var _createSwapChain = _asyncToGenerator$5( /*#__PURE__*/_regeneratorRuntime$5().mark(function _callee($canvas) {
|
|
18435
19193
|
var adapter, optionalFeatures, requiredFeatures, device, context;
|
|
18436
|
-
return _regeneratorRuntime$
|
|
19194
|
+
return _regeneratorRuntime$5().wrap(function _callee$(_context) {
|
|
18437
19195
|
while (1) {
|
|
18438
19196
|
switch (_context.prev = _context.next) {
|
|
18439
19197
|
case 0:
|
|
@@ -18470,7 +19228,8 @@
|
|
|
18470
19228
|
|
|
18471
19229
|
case 14:
|
|
18472
19230
|
// @see https://www.w3.org/TR/webgpu/#dom-gpudevicedescriptor-requiredfeatures
|
|
18473
|
-
optionalFeatures = ['depth24unorm-stencil8',
|
|
19231
|
+
optionalFeatures = [// 'depth24unorm-stencil8',
|
|
19232
|
+
'depth32float-stencil8', 'texture-compression-bc'];
|
|
18474
19233
|
requiredFeatures = optionalFeatures.filter(function (feature) {
|
|
18475
19234
|
return adapter.features.has(feature);
|
|
18476
19235
|
});
|
|
@@ -18538,11 +19297,11 @@
|
|
|
18538
19297
|
WebGPUDeviceContribution = __decorate([g.singleton({
|
|
18539
19298
|
token: DeviceContribution
|
|
18540
19299
|
})], WebGPUDeviceContribution);
|
|
18541
|
-
var containerModule$
|
|
19300
|
+
var containerModule$4 = g.Module(function (register) {
|
|
18542
19301
|
register(WebGPUDeviceContribution);
|
|
18543
19302
|
});
|
|
18544
19303
|
|
|
18545
|
-
var Plugin$
|
|
19304
|
+
var Plugin$4 = /*#__PURE__*/function () {
|
|
18546
19305
|
function Plugin(options) {
|
|
18547
19306
|
if (options === void 0) {
|
|
18548
19307
|
options = {};
|
|
@@ -18559,12 +19318,12 @@
|
|
|
18559
19318
|
container.register(WebGPUDeviceOptions, {
|
|
18560
19319
|
useValue: _extends$1({}, this.options)
|
|
18561
19320
|
});
|
|
18562
|
-
container.load(containerModule$
|
|
19321
|
+
container.load(containerModule$4, true);
|
|
18563
19322
|
};
|
|
18564
19323
|
|
|
18565
19324
|
_proto.destroy = function destroy(container) {
|
|
18566
19325
|
container.remove(WebGPUDeviceOptions);
|
|
18567
|
-
container.unload(containerModule$
|
|
19326
|
+
container.unload(containerModule$4);
|
|
18568
19327
|
};
|
|
18569
19328
|
|
|
18570
19329
|
return Plugin;
|
|
@@ -18572,7 +19331,7 @@
|
|
|
18572
19331
|
|
|
18573
19332
|
var index_esm$3 = /*#__PURE__*/Object.freeze({
|
|
18574
19333
|
__proto__: null,
|
|
18575
|
-
Plugin: Plugin$
|
|
19334
|
+
Plugin: Plugin$4
|
|
18576
19335
|
});
|
|
18577
19336
|
|
|
18578
19337
|
var WebGLContextService = /*#__PURE__*/function () {
|
|
@@ -18694,7 +19453,7 @@
|
|
|
18694
19453
|
token: g.ContextService
|
|
18695
19454
|
})], WebGLContextService);
|
|
18696
19455
|
|
|
18697
|
-
var containerModule$
|
|
19456
|
+
var containerModule$5 = g.Module(function (register) {
|
|
18698
19457
|
/**
|
|
18699
19458
|
* implements ContextService
|
|
18700
19459
|
*/
|
|
@@ -18708,11 +19467,11 @@
|
|
|
18708
19467
|
var _proto = ContextRegisterPlugin.prototype;
|
|
18709
19468
|
|
|
18710
19469
|
_proto.init = function init(container) {
|
|
18711
|
-
container.load(containerModule$
|
|
19470
|
+
container.load(containerModule$5, true);
|
|
18712
19471
|
};
|
|
18713
19472
|
|
|
18714
19473
|
_proto.destroy = function destroy(container) {
|
|
18715
|
-
container.unload(containerModule$
|
|
19474
|
+
container.unload(containerModule$5);
|
|
18716
19475
|
};
|
|
18717
19476
|
|
|
18718
19477
|
return ContextRegisterPlugin;
|
|
@@ -18728,14 +19487,16 @@
|
|
|
18728
19487
|
|
|
18729
19488
|
_this.registerPlugin(new ContextRegisterPlugin());
|
|
18730
19489
|
|
|
18731
|
-
_this.registerPlugin(new Plugin$3());
|
|
18732
|
-
|
|
18733
19490
|
_this.registerPlugin(new Plugin());
|
|
18734
19491
|
|
|
19492
|
+
_this.registerPlugin(new Plugin$4());
|
|
19493
|
+
|
|
18735
19494
|
_this.registerPlugin(new Plugin$1());
|
|
18736
19495
|
|
|
18737
19496
|
_this.registerPlugin(new Plugin$2());
|
|
18738
19497
|
|
|
19498
|
+
_this.registerPlugin(new Plugin$3());
|
|
19499
|
+
|
|
18739
19500
|
return _this;
|
|
18740
19501
|
}
|
|
18741
19502
|
|