@antv/g-lite 1.3.0-next.2 → 1.3.0-next.20
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/components/Geometry.d.ts +4 -0
- package/dist/css/StyleValueRegistry.d.ts +1 -1
- package/dist/css/cssom/CSSStyleValue.d.ts +1 -1
- package/dist/css/parser/dimension.d.ts +1 -1
- package/dist/css/parser/path.d.ts +2 -2
- package/dist/css/parser/points.d.ts +1 -1
- package/dist/css/properties/CSSPropertyPath.d.ts +2 -2
- package/dist/css/properties/CSSPropertyTransformOrigin.d.ts +3 -1
- package/dist/display-objects/Circle.d.ts +1 -1
- package/dist/display-objects/DisplayObject.d.ts +0 -10
- package/dist/display-objects/Ellipse.d.ts +1 -1
- package/dist/display-objects/Group.d.ts +1 -1
- package/dist/display-objects/Image.d.ts +1 -3
- package/dist/display-objects/Path.d.ts +1 -12
- package/dist/display-objects/Rect.d.ts +1 -1
- package/dist/dom/Element.d.ts +1 -0
- package/dist/dom/Node.d.ts +1 -0
- package/dist/dom/interfaces.d.ts +1 -1
- package/dist/global-runtime.d.ts +6 -0
- package/dist/index.esm.js +613 -539
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +612 -537
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/plugins/PrepareRendererPlugin.d.ts +3 -0
- package/dist/services/SceneGraphService.d.ts +12 -12
- package/dist/services/aabb/GroupUpdater.d.ts +10 -0
- package/dist/services/aabb/index.d.ts +1 -0
- package/dist/types.d.ts +1 -1
- package/dist/utils/path.d.ts +2 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -3,7 +3,7 @@ import EventEmitter from 'eventemitter3';
|
|
|
3
3
|
import { mat4, vec4, vec3, mat3, quat as quat$1, vec2 } from 'gl-matrix';
|
|
4
4
|
import { isNumber, distanceSquareRoot, isString, isNil, clamp, getTotalLength, min, max, isNumberEqual, mod, normalizePath, path2Curve, equalizeSegments, getDrawDirection, reverseCurve, clonePath, getRotatedCurve, isArray, isBoolean, isObject, isUndefined, getPointAtLength } from '@antv/util';
|
|
5
5
|
import * as d3 from 'd3-color';
|
|
6
|
-
import { arcBox, cubicBox, quadBox,
|
|
6
|
+
import { polylineLength, arcBox, cubicBox, quadBox, linePointAt, lineLength } from '@antv/g-math';
|
|
7
7
|
|
|
8
8
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
9
9
|
|
|
@@ -3165,7 +3165,7 @@ var getOrCreateUnitValue = function (value, unitOrName) {
|
|
|
3165
3165
|
if (unitOrName === void 0) { unitOrName = UnitType.kNumber; }
|
|
3166
3166
|
return new CSSUnitValue(value, unitOrName);
|
|
3167
3167
|
};
|
|
3168
|
-
|
|
3168
|
+
new CSSUnitValue(50, '%');
|
|
3169
3169
|
|
|
3170
3170
|
/**
|
|
3171
3171
|
* @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
|
|
@@ -4107,19 +4107,17 @@ function parseDimensionArray(string) {
|
|
|
4107
4107
|
// },
|
|
4108
4108
|
// ];
|
|
4109
4109
|
// }
|
|
4110
|
-
function convertPercentUnit(valueWithUnit, vec3Index, target) {
|
|
4111
|
-
if (
|
|
4112
|
-
return 0;
|
|
4113
|
-
}
|
|
4110
|
+
function convertPercentUnit(valueWithUnit, vec3Index, target, useMin) {
|
|
4111
|
+
if (useMin === void 0) { useMin = false; }
|
|
4114
4112
|
if (valueWithUnit.unit === UnitType.kPixels) {
|
|
4115
4113
|
return Number(valueWithUnit.value);
|
|
4116
4114
|
}
|
|
4117
4115
|
else if (valueWithUnit.unit === UnitType.kPercentage && target) {
|
|
4118
4116
|
var bounds = target.nodeName === Shape.GROUP
|
|
4119
4117
|
? target.getLocalBounds()
|
|
4120
|
-
:
|
|
4121
|
-
|
|
4122
|
-
|
|
4118
|
+
: target.getGeometryBounds();
|
|
4119
|
+
return ((useMin ? bounds.min[vec3Index] : 0) +
|
|
4120
|
+
(valueWithUnit.value / 100) * bounds.halfExtents[vec3Index] * 2);
|
|
4123
4121
|
}
|
|
4124
4122
|
return 0;
|
|
4125
4123
|
}
|
|
@@ -4222,10 +4220,16 @@ function mergeNumberLists(left, right) {
|
|
|
4222
4220
|
}
|
|
4223
4221
|
|
|
4224
4222
|
function getOrCalculatePathTotalLength(path) {
|
|
4225
|
-
if (path.parsedStyle.
|
|
4226
|
-
path.parsedStyle.
|
|
4223
|
+
if (path.parsedStyle.d.totalLength === 0) {
|
|
4224
|
+
path.parsedStyle.d.totalLength = getTotalLength(path.parsedStyle.d.absolutePath);
|
|
4225
|
+
}
|
|
4226
|
+
return path.parsedStyle.d.totalLength;
|
|
4227
|
+
}
|
|
4228
|
+
function getOrCalculatePolylineTotalLength(polyline) {
|
|
4229
|
+
if (polyline.parsedStyle.points.totalLength === 0) {
|
|
4230
|
+
polyline.parsedStyle.points.totalLength = polylineLength(polyline.parsedStyle.points.points);
|
|
4227
4231
|
}
|
|
4228
|
-
return
|
|
4232
|
+
return polyline.parsedStyle.points.totalLength;
|
|
4229
4233
|
}
|
|
4230
4234
|
function removeRedundantMCommand(path) {
|
|
4231
4235
|
for (var i = 0; i < path.length; i++) {
|
|
@@ -4935,7 +4939,7 @@ function convertToPath(object, transform) {
|
|
|
4935
4939
|
}));
|
|
4936
4940
|
break;
|
|
4937
4941
|
case Shape.PATH:
|
|
4938
|
-
var absolutePath = object.parsedStyle.
|
|
4942
|
+
var absolutePath = object.parsedStyle.d.absolutePath;
|
|
4939
4943
|
commands = __spreadArray([], __read(absolutePath), false);
|
|
4940
4944
|
break;
|
|
4941
4945
|
}
|
|
@@ -5097,27 +5101,10 @@ function parsePoints(pointsOrStr, object) {
|
|
|
5097
5101
|
else {
|
|
5098
5102
|
points = pointsOrStr;
|
|
5099
5103
|
}
|
|
5100
|
-
var segments = [];
|
|
5101
|
-
var tempLength = 0;
|
|
5102
|
-
var segmentT;
|
|
5103
|
-
var segmentL;
|
|
5104
|
-
var totalLength = polylineLength(points);
|
|
5105
|
-
points.forEach(function (p, i) {
|
|
5106
|
-
if (points[i + 1]) {
|
|
5107
|
-
segmentT = [0, 0];
|
|
5108
|
-
segmentT[0] = tempLength / totalLength;
|
|
5109
|
-
segmentL = lineLength(p[0], p[1], points[i + 1][0], points[i + 1][1]);
|
|
5110
|
-
tempLength += segmentL;
|
|
5111
|
-
segmentT[1] = tempLength / totalLength;
|
|
5112
|
-
segments.push(segmentT);
|
|
5113
|
-
}
|
|
5114
|
-
});
|
|
5115
|
-
// const minX = Math.min(...points.map((point) => point[0]));
|
|
5116
|
-
// const minY = Math.min(...points.map((point) => point[1]));
|
|
5117
5104
|
return {
|
|
5118
5105
|
points: points,
|
|
5119
|
-
totalLength:
|
|
5120
|
-
segments:
|
|
5106
|
+
totalLength: 0,
|
|
5107
|
+
segments: [],
|
|
5121
5108
|
};
|
|
5122
5109
|
}
|
|
5123
5110
|
function mergePoints(left, right) {
|
|
@@ -5958,7 +5945,7 @@ function convertKeyword2Percent(keyword) {
|
|
|
5958
5945
|
return '50%';
|
|
5959
5946
|
}
|
|
5960
5947
|
else if (keyword === 'left' || keyword === 'top') {
|
|
5961
|
-
return '0';
|
|
5948
|
+
return '0%';
|
|
5962
5949
|
}
|
|
5963
5950
|
else if (keyword === 'right' || keyword === 'bottom') {
|
|
5964
5951
|
return '100%';
|
|
@@ -6226,16 +6213,17 @@ var BUILT_IN_PROPERTIES = [
|
|
|
6226
6213
|
{
|
|
6227
6214
|
n: 'transformOrigin',
|
|
6228
6215
|
p: 100,
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6216
|
+
d: '0 0',
|
|
6217
|
+
// // int: true,
|
|
6218
|
+
// d: (nodeName: string) => {
|
|
6219
|
+
// if (nodeName === Shape.CIRCLE || nodeName === Shape.ELLIPSE) {
|
|
6220
|
+
// return 'center';
|
|
6221
|
+
// }
|
|
6222
|
+
// if (nodeName === Shape.TEXT) {
|
|
6223
|
+
// return 'text-anchor';
|
|
6224
|
+
// }
|
|
6225
|
+
// return 'left top';
|
|
6226
|
+
// },
|
|
6239
6227
|
l: true,
|
|
6240
6228
|
syntax: PropertySyntax.TRANSFORM_ORIGIN,
|
|
6241
6229
|
},
|
|
@@ -6374,11 +6362,10 @@ var BUILT_IN_PROPERTIES = [
|
|
|
6374
6362
|
},
|
|
6375
6363
|
// Path
|
|
6376
6364
|
{
|
|
6377
|
-
n: '
|
|
6365
|
+
n: 'd',
|
|
6378
6366
|
int: true,
|
|
6379
6367
|
l: true,
|
|
6380
6368
|
d: '',
|
|
6381
|
-
a: ['d'],
|
|
6382
6369
|
syntax: PropertySyntax.PATH,
|
|
6383
6370
|
p: 50,
|
|
6384
6371
|
},
|
|
@@ -6602,16 +6589,16 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6602
6589
|
}; }
|
|
6603
6590
|
if (!this.runtime.enableCSSParsing) {
|
|
6604
6591
|
Object.assign(object.attributes, attributes);
|
|
6605
|
-
var
|
|
6592
|
+
var attributeNames = Object.keys(attributes);
|
|
6606
6593
|
// clipPath
|
|
6607
6594
|
var oldClipPath = object.parsedStyle.clipPath;
|
|
6608
6595
|
var oldOffsetPath = object.parsedStyle.offsetPath;
|
|
6609
6596
|
object.parsedStyle = Object.assign(object.parsedStyle, attributes);
|
|
6610
|
-
var
|
|
6611
|
-
if (!
|
|
6597
|
+
var needUpdateGeometry = !!options.forceUpdateGeometry;
|
|
6598
|
+
if (!needUpdateGeometry) {
|
|
6612
6599
|
for (var i = 0; i < GEOMETRY_ATTRIBUTE_NAMES.length; i++) {
|
|
6613
6600
|
if (GEOMETRY_ATTRIBUTE_NAMES[i] in attributes) {
|
|
6614
|
-
|
|
6601
|
+
needUpdateGeometry = true;
|
|
6615
6602
|
break;
|
|
6616
6603
|
}
|
|
6617
6604
|
}
|
|
@@ -6647,14 +6634,14 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6647
6634
|
}
|
|
6648
6635
|
// Path
|
|
6649
6636
|
// @ts-ignore
|
|
6650
|
-
if (attributes.
|
|
6651
|
-
object.parsedStyle.
|
|
6637
|
+
if (attributes.d === '') {
|
|
6638
|
+
object.parsedStyle.d = __assign({}, EMPTY_PARSED_PATH);
|
|
6652
6639
|
}
|
|
6653
6640
|
// @ts-ignore
|
|
6654
|
-
if (attributes.
|
|
6655
|
-
object.parsedStyle.
|
|
6641
|
+
if (attributes.d) {
|
|
6642
|
+
object.parsedStyle.d = parsePath(
|
|
6656
6643
|
// @ts-ignore
|
|
6657
|
-
attributes.
|
|
6644
|
+
attributes.d);
|
|
6658
6645
|
}
|
|
6659
6646
|
// Text
|
|
6660
6647
|
if (attributes.textTransform) {
|
|
@@ -6698,95 +6685,107 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6698
6685
|
attributes.markerMid, null, null);
|
|
6699
6686
|
}
|
|
6700
6687
|
if (!isNil(attributes.zIndex)) {
|
|
6701
|
-
this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object,
|
|
6688
|
+
this.runtime.CSSPropertySyntaxFactory['<z-index>'].postProcessor(object, attributeNames);
|
|
6702
6689
|
}
|
|
6703
6690
|
if (!isNil(attributes.offsetDistance)) {
|
|
6704
|
-
this.runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object,
|
|
6691
|
+
this.runtime.CSSPropertySyntaxFactory['<offset-distance>'].postProcessor(object, attributeNames);
|
|
6705
6692
|
}
|
|
6706
6693
|
if (attributes.transform) {
|
|
6707
|
-
this.runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object,
|
|
6694
|
+
this.runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, attributeNames);
|
|
6708
6695
|
}
|
|
6709
|
-
if (
|
|
6710
|
-
this.
|
|
6696
|
+
if (attributes.transformOrigin) {
|
|
6697
|
+
this.runtime.CSSPropertySyntaxFactory['<transform-origin>'].postProcessor(object, attributeNames);
|
|
6698
|
+
}
|
|
6699
|
+
if (needUpdateGeometry) {
|
|
6700
|
+
object.geometry.dirty = true;
|
|
6701
|
+
object.renderable.boundsDirty = true;
|
|
6702
|
+
object.renderable.renderBoundsDirty = true;
|
|
6703
|
+
if (!options.forceUpdateGeometry) {
|
|
6704
|
+
this.runtime.sceneGraphService.dirtifyToRoot(object);
|
|
6705
|
+
}
|
|
6711
6706
|
}
|
|
6712
|
-
return;
|
|
6713
6707
|
}
|
|
6714
|
-
|
|
6715
|
-
|
|
6716
|
-
|
|
6717
|
-
|
|
6718
|
-
|
|
6719
|
-
|
|
6720
|
-
|
|
6721
|
-
|
|
6722
|
-
|
|
6723
|
-
|
|
6724
|
-
|
|
6725
|
-
|
|
6726
|
-
if (!skipParse) {
|
|
6727
|
-
attributeNames.forEach(function (name) {
|
|
6728
|
-
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize);
|
|
6708
|
+
else {
|
|
6709
|
+
var skipUpdateAttribute_1 = options.skipUpdateAttribute, skipParse = options.skipParse, forceUpdateGeometry = options.forceUpdateGeometry, usedAttributes = options.usedAttributes, memoize_1 = options.memoize;
|
|
6710
|
+
var needUpdateGeometry_1 = forceUpdateGeometry;
|
|
6711
|
+
var attributeNames_1 = Object.keys(attributes);
|
|
6712
|
+
attributeNames_1.forEach(function (attributeName) {
|
|
6713
|
+
var _a;
|
|
6714
|
+
if (!skipUpdateAttribute_1) {
|
|
6715
|
+
object.attributes[attributeName] = attributes[attributeName];
|
|
6716
|
+
}
|
|
6717
|
+
if (!needUpdateGeometry_1 && ((_a = propertyMetadataCache[attributeName]) === null || _a === void 0 ? void 0 : _a.l)) {
|
|
6718
|
+
needUpdateGeometry_1 = true;
|
|
6719
|
+
}
|
|
6729
6720
|
});
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
|
|
6734
|
-
// points 50
|
|
6735
|
-
// text 50
|
|
6736
|
-
// textTransform 51
|
|
6737
|
-
// transform 100
|
|
6738
|
-
// transformOrigin 100
|
|
6739
|
-
if (usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) {
|
|
6740
|
-
// uniqueAttributeSet.clear();
|
|
6741
|
-
attributeNames = Array.from(new Set(attributeNames.concat(usedAttributes)));
|
|
6742
|
-
}
|
|
6743
|
-
// [
|
|
6744
|
-
// 'path',
|
|
6745
|
-
// 'points',
|
|
6746
|
-
// 'text',
|
|
6747
|
-
// 'textTransform',
|
|
6748
|
-
// 'transform',
|
|
6749
|
-
// 'transformOrigin',
|
|
6750
|
-
// ].forEach((name) => {
|
|
6751
|
-
// const index = attributeNames.indexOf(name);
|
|
6752
|
-
// if (index > -1) {
|
|
6753
|
-
// attributeNames.splice(index, 1);
|
|
6754
|
-
// attributeNames.push(name);
|
|
6755
|
-
// }
|
|
6756
|
-
// });
|
|
6757
|
-
attributeNames.forEach(function (name) {
|
|
6758
|
-
// some style props maybe deleted after parsing such as `anchor` in Text
|
|
6759
|
-
if (name in object.computedStyle) {
|
|
6760
|
-
object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize);
|
|
6721
|
+
if (!skipParse) {
|
|
6722
|
+
attributeNames_1.forEach(function (name) {
|
|
6723
|
+
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize_1);
|
|
6724
|
+
});
|
|
6761
6725
|
}
|
|
6762
|
-
|
|
6763
|
-
|
|
6764
|
-
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
//
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6773
|
-
|
|
6774
|
-
|
|
6775
|
-
|
|
6726
|
+
// let hasUnresolvedProperties = false;
|
|
6727
|
+
// parse according to priority
|
|
6728
|
+
// path 50
|
|
6729
|
+
// points 50
|
|
6730
|
+
// text 50
|
|
6731
|
+
// textTransform 51
|
|
6732
|
+
// transform 100
|
|
6733
|
+
// transformOrigin 100
|
|
6734
|
+
if (usedAttributes === null || usedAttributes === void 0 ? void 0 : usedAttributes.length) {
|
|
6735
|
+
// uniqueAttributeSet.clear();
|
|
6736
|
+
attributeNames_1 = Array.from(new Set(attributeNames_1.concat(usedAttributes)));
|
|
6737
|
+
}
|
|
6738
|
+
// [
|
|
6739
|
+
// 'path',
|
|
6740
|
+
// 'points',
|
|
6741
|
+
// 'text',
|
|
6742
|
+
// 'textTransform',
|
|
6743
|
+
// 'transform',
|
|
6744
|
+
// 'transformOrigin',
|
|
6745
|
+
// ].forEach((name) => {
|
|
6746
|
+
// const index = attributeNames.indexOf(name);
|
|
6747
|
+
// if (index > -1) {
|
|
6748
|
+
// attributeNames.splice(index, 1);
|
|
6749
|
+
// attributeNames.push(name);
|
|
6750
|
+
// }
|
|
6751
|
+
// });
|
|
6752
|
+
attributeNames_1.forEach(function (name) {
|
|
6753
|
+
// some style props maybe deleted after parsing such as `anchor` in Text
|
|
6754
|
+
if (name in object.computedStyle) {
|
|
6755
|
+
object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize_1);
|
|
6756
|
+
}
|
|
6757
|
+
});
|
|
6758
|
+
// if (hasUnresolvedProperties) {
|
|
6759
|
+
// this.dirty = true;
|
|
6760
|
+
// return;
|
|
6761
|
+
// }
|
|
6762
|
+
// update geometry
|
|
6763
|
+
if (needUpdateGeometry_1) {
|
|
6764
|
+
object.geometry.dirty = true;
|
|
6765
|
+
object.renderable.boundsDirty = true;
|
|
6766
|
+
object.renderable.renderBoundsDirty = true;
|
|
6767
|
+
if (!options.forceUpdateGeometry) {
|
|
6768
|
+
this.runtime.sceneGraphService.dirtifyToRoot(object);
|
|
6769
|
+
}
|
|
6776
6770
|
}
|
|
6777
|
-
|
|
6778
|
-
|
|
6779
|
-
|
|
6780
|
-
if (name in object.parsedStyle && _this.isPropertyInheritable(name)) {
|
|
6781
|
-
// update children's inheritable
|
|
6782
|
-
object.children.forEach(function (child) {
|
|
6783
|
-
child.internalSetAttribute(name, null, {
|
|
6784
|
-
skipUpdateAttribute: true,
|
|
6785
|
-
skipParse: true,
|
|
6786
|
-
});
|
|
6787
|
-
});
|
|
6771
|
+
attributeNames_1.forEach(function (name) {
|
|
6772
|
+
if (name in object.parsedStyle) {
|
|
6773
|
+
_this.postProcessProperty(name, object, attributeNames_1);
|
|
6788
6774
|
}
|
|
6789
6775
|
});
|
|
6776
|
+
if (this.runtime.enableCSSParsing && object.children.length) {
|
|
6777
|
+
attributeNames_1.forEach(function (name) {
|
|
6778
|
+
if (name in object.parsedStyle && _this.isPropertyInheritable(name)) {
|
|
6779
|
+
// update children's inheritable
|
|
6780
|
+
object.children.forEach(function (child) {
|
|
6781
|
+
child.internalSetAttribute(name, null, {
|
|
6782
|
+
skipUpdateAttribute: true,
|
|
6783
|
+
skipParse: true,
|
|
6784
|
+
});
|
|
6785
|
+
});
|
|
6786
|
+
}
|
|
6787
|
+
});
|
|
6788
|
+
}
|
|
6790
6789
|
}
|
|
6791
6790
|
};
|
|
6792
6791
|
/**
|
|
@@ -6979,11 +6978,15 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6979
6978
|
// depth / 2,
|
|
6980
6979
|
// );
|
|
6981
6980
|
// anchor is center by default, don't account for lineWidth here
|
|
6982
|
-
var _h = parsedStyle, stroke = _h.stroke,
|
|
6981
|
+
var _h = parsedStyle, stroke = _h.stroke, _j = _h.lineWidth, lineWidth = _j === void 0 ? 1 : _j,
|
|
6982
|
+
// lineCap,
|
|
6983
|
+
// lineJoin,
|
|
6984
|
+
// miterLimit,
|
|
6985
|
+
_k = _h.increasedLineWidthForHitTesting,
|
|
6983
6986
|
// lineCap,
|
|
6984
6987
|
// lineJoin,
|
|
6985
6988
|
// miterLimit,
|
|
6986
|
-
increasedLineWidthForHitTesting =
|
|
6989
|
+
increasedLineWidthForHitTesting = _k === void 0 ? 0 : _k, shadowType = _h.shadowType, shadowColor = _h.shadowColor, _l = _h.filter, filter = _l === void 0 ? [] : _l, transformOrigin = _h.transformOrigin;
|
|
6987
6990
|
var center = [cx, cy, cz];
|
|
6988
6991
|
// update geometry's AABB
|
|
6989
6992
|
geometry_1.contentBounds.update(center, halfExtents);
|
|
@@ -7017,8 +7020,8 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7017
7020
|
geometry_1.renderBounds.update(center, halfExtents);
|
|
7018
7021
|
// account for shadow, only support constant value now
|
|
7019
7022
|
if (shadowColor && shadowType && shadowType !== 'inner') {
|
|
7020
|
-
var
|
|
7021
|
-
var
|
|
7023
|
+
var _m = geometry_1.renderBounds, min = _m.min, max = _m.max;
|
|
7024
|
+
var _o = parsedStyle, shadowBlur = _o.shadowBlur, shadowOffsetX = _o.shadowOffsetX, shadowOffsetY = _o.shadowOffsetY;
|
|
7022
7025
|
var shadowBlurInPixels = shadowBlur || 0;
|
|
7023
7026
|
var shadowOffsetXInPixels = shadowOffsetX || 0;
|
|
7024
7027
|
var shadowOffsetYInPixels = shadowOffsetY || 0;
|
|
@@ -7055,25 +7058,22 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7055
7058
|
geometry_1.renderBounds.setMinMax(min, max);
|
|
7056
7059
|
}
|
|
7057
7060
|
});
|
|
7058
|
-
|
|
7059
|
-
// account for negative width / height of Rect
|
|
7061
|
+
object.geometry.dirty = false;
|
|
7060
7062
|
// @see https://github.com/antvis/g/issues/957
|
|
7061
7063
|
var flipY = hwidth < 0;
|
|
7062
7064
|
var flipX = hheight < 0;
|
|
7063
|
-
// } else {
|
|
7064
|
-
// }
|
|
7065
7065
|
// set transform origin
|
|
7066
7066
|
var usedOriginXValue = (flipY ? -1 : 1) *
|
|
7067
7067
|
(transformOrigin
|
|
7068
|
-
? convertPercentUnit(transformOrigin[0], 0, object)
|
|
7068
|
+
? convertPercentUnit(transformOrigin[0], 0, object, true)
|
|
7069
7069
|
: 0);
|
|
7070
7070
|
var usedOriginYValue = (flipX ? -1 : 1) *
|
|
7071
7071
|
(transformOrigin
|
|
7072
|
-
? convertPercentUnit(transformOrigin[1], 1, object)
|
|
7072
|
+
? convertPercentUnit(transformOrigin[1], 1, object, true)
|
|
7073
7073
|
: 0);
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7074
|
+
if (usedOriginXValue || usedOriginYValue) {
|
|
7075
|
+
object.setOrigin(usedOriginXValue, usedOriginYValue);
|
|
7076
|
+
}
|
|
7077
7077
|
}
|
|
7078
7078
|
};
|
|
7079
7079
|
DefaultStyleValueRegistry.prototype.isPropertyInheritable = function (name) {
|
|
@@ -7499,8 +7499,8 @@ function sortedIndex(array, value) {
|
|
|
7499
7499
|
return low;
|
|
7500
7500
|
}
|
|
7501
7501
|
function sortByZIndex(o1, o2) {
|
|
7502
|
-
var zIndex1 = Number(o1.parsedStyle.zIndex);
|
|
7503
|
-
var zIndex2 = Number(o2.parsedStyle.zIndex);
|
|
7502
|
+
var zIndex1 = Number(o1.parsedStyle.zIndex || 0);
|
|
7503
|
+
var zIndex2 = Number(o2.parsedStyle.zIndex || 0);
|
|
7504
7504
|
if (zIndex1 === zIndex2) {
|
|
7505
7505
|
var parent_1 = o1.parentNode;
|
|
7506
7506
|
if (parent_1) {
|
|
@@ -7564,6 +7564,7 @@ var clock = typeof performance === 'object' && performance.now ? performance : D
|
|
|
7564
7564
|
function isFillOrStrokeAffected(pointerEvents, fill, stroke) {
|
|
7565
7565
|
// account for pointerEvents
|
|
7566
7566
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
7567
|
+
if (pointerEvents === void 0) { pointerEvents = 'auto'; }
|
|
7567
7568
|
var hasFill = false;
|
|
7568
7569
|
var hasStroke = false;
|
|
7569
7570
|
var isFillOtherThanNone = !!fill && !fill.isNone;
|
|
@@ -7790,7 +7791,7 @@ var genericFontFamilies = [
|
|
|
7790
7791
|
];
|
|
7791
7792
|
var stringRegExp = /([\"\'])[^\'\"]+\1/;
|
|
7792
7793
|
function toFontString(attributes) {
|
|
7793
|
-
var
|
|
7794
|
+
var _a = attributes.fontSize, fontSize = _a === void 0 ? 16 : _a, _b = attributes.fontFamily, fontFamily = _b === void 0 ? 'sans-serif' : _b, _c = attributes.fontStyle, fontStyle = _c === void 0 ? 'normal' : _c, _d = attributes.fontVariant, fontVariant = _d === void 0 ? 'normal' : _d, _e = attributes.fontWeight, fontWeight = _e === void 0 ? 'normal' : _e;
|
|
7794
7795
|
// build canvas api font setting from individual components. Convert a numeric this.fontSize to px
|
|
7795
7796
|
// const fontSizeString: string = isNumber(fontSize) ? `${fontSize}px` : fontSize.toString();
|
|
7796
7797
|
var fontSizeString = (isNumber(fontSize) && "".concat(fontSize, "px")) || '16px';
|
|
@@ -7810,92 +7811,126 @@ function toFontString(attributes) {
|
|
|
7810
7811
|
return "".concat(fontStyle, " ").concat(fontVariant, " ").concat(fontWeight, " ").concat(fontSizeString, " ").concat(fontFamilies.join(','));
|
|
7811
7812
|
}
|
|
7812
7813
|
|
|
7813
|
-
|
|
7814
|
+
function createSkewMatrix(skewMatrix, skewX, skewY) {
|
|
7815
|
+
// Create an identity matrix
|
|
7816
|
+
mat4.identity(skewMatrix);
|
|
7817
|
+
// Apply skew to the matrix
|
|
7818
|
+
skewMatrix[4] = Math.tan(skewX); // Skew Y axis in X direction
|
|
7819
|
+
skewMatrix[1] = Math.tan(skewY); // Skew X axis in Y direction
|
|
7820
|
+
return skewMatrix;
|
|
7821
|
+
}
|
|
7822
|
+
var SCALE_EPSILON = 0.00001;
|
|
7823
|
+
var tmpMat1 = mat4.create();
|
|
7824
|
+
var tmpMat2 = mat4.create();
|
|
7814
7825
|
function parsedTransformToMat4(transform, object) {
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7826
|
+
if (transform.length) {
|
|
7827
|
+
var m_1 = mat4.identity(tmpMat1);
|
|
7828
|
+
transform.forEach(function (parsed) {
|
|
7829
|
+
var t = parsed.t, d = parsed.d;
|
|
7830
|
+
if (t === 'scale') {
|
|
7831
|
+
// scale(1) scale(1, 1)
|
|
7832
|
+
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [
|
|
7833
|
+
1, 1,
|
|
7834
|
+
];
|
|
7835
|
+
mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], 1]);
|
|
7836
|
+
}
|
|
7837
|
+
else if (t === 'scalex') {
|
|
7838
|
+
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7839
|
+
mat4.fromScaling(tmpMat2, [newScale[0], 1, 1]);
|
|
7840
|
+
}
|
|
7841
|
+
else if (t === 'scaley') {
|
|
7842
|
+
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7843
|
+
mat4.fromScaling(tmpMat2, [1, newScale[0], 1]);
|
|
7844
|
+
}
|
|
7845
|
+
else if (t === 'scalez') {
|
|
7846
|
+
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [1];
|
|
7847
|
+
mat4.fromScaling(tmpMat2, [1, 1, newScale[0]]);
|
|
7848
|
+
}
|
|
7849
|
+
else if (t === 'scale3d') {
|
|
7850
|
+
var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) { return Math.max(s.value, SCALE_EPSILON); })) || [
|
|
7851
|
+
1, 1, 1,
|
|
7852
|
+
];
|
|
7853
|
+
mat4.fromScaling(tmpMat2, [newScale[0], newScale[1], newScale[2]]);
|
|
7854
|
+
}
|
|
7855
|
+
else if (t === 'translate') {
|
|
7856
|
+
var newTranslation = d || [Opx, Opx];
|
|
7857
|
+
mat4.fromTranslation(tmpMat2, [
|
|
7858
|
+
newTranslation[0].value,
|
|
7859
|
+
newTranslation[1].value,
|
|
7860
|
+
0,
|
|
7861
|
+
]);
|
|
7862
|
+
}
|
|
7863
|
+
else if (t === 'translatex') {
|
|
7864
|
+
var newTranslation = d || [Opx];
|
|
7865
|
+
mat4.fromTranslation(tmpMat2, [newTranslation[0].value, 0, 0]);
|
|
7866
|
+
}
|
|
7867
|
+
else if (t === 'translatey') {
|
|
7868
|
+
var newTranslation = d || [Opx];
|
|
7869
|
+
mat4.fromTranslation(tmpMat2, [0, newTranslation[0].value, 0]);
|
|
7870
|
+
}
|
|
7871
|
+
else if (t === 'translatez') {
|
|
7872
|
+
var newTranslation = d || [Opx];
|
|
7873
|
+
mat4.fromTranslation(tmpMat2, [0, 0, newTranslation[0].value]);
|
|
7874
|
+
}
|
|
7875
|
+
else if (t === 'translate3d') {
|
|
7876
|
+
var newTranslation = d || [Opx, Opx, Opx];
|
|
7877
|
+
mat4.fromTranslation(tmpMat2, [
|
|
7878
|
+
newTranslation[0].value,
|
|
7879
|
+
newTranslation[1].value,
|
|
7880
|
+
newTranslation[2].value,
|
|
7881
|
+
]);
|
|
7882
|
+
}
|
|
7883
|
+
else if (t === 'rotate') {
|
|
7884
|
+
var newAngles = d || [Odeg];
|
|
7885
|
+
mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7886
|
+
}
|
|
7887
|
+
else if (t === 'rotatex') {
|
|
7888
|
+
var newAngles = d || [Odeg];
|
|
7889
|
+
mat4.fromXRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7890
|
+
}
|
|
7891
|
+
else if (t === 'rotatey') {
|
|
7892
|
+
var newAngles = d || [Odeg];
|
|
7893
|
+
mat4.fromYRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7894
|
+
}
|
|
7895
|
+
else if (t === 'rotatez') {
|
|
7896
|
+
var newAngles = d || [Odeg];
|
|
7897
|
+
mat4.fromZRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[0])));
|
|
7898
|
+
}
|
|
7899
|
+
else if (t === 'rotate3d') {
|
|
7900
|
+
var newAngles = d || [Opx, Opx, Opx, Odeg];
|
|
7901
|
+
mat4.fromRotation(tmpMat2, deg2rad(convertAngleUnit(newAngles[3])), [
|
|
7902
|
+
newAngles[0].value,
|
|
7903
|
+
newAngles[1].value,
|
|
7904
|
+
newAngles[2].value,
|
|
7905
|
+
]);
|
|
7906
|
+
}
|
|
7907
|
+
else if (t === 'skew') {
|
|
7908
|
+
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0, 0];
|
|
7909
|
+
createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), deg2rad(newSkew[1]));
|
|
7910
|
+
}
|
|
7911
|
+
else if (t === 'skewx') {
|
|
7912
|
+
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
|
|
7913
|
+
createSkewMatrix(tmpMat2, deg2rad(newSkew[0]), 0);
|
|
7914
|
+
}
|
|
7915
|
+
else if (t === 'skewy') {
|
|
7916
|
+
var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) { return s.value; })) || [0];
|
|
7917
|
+
createSkewMatrix(tmpMat2, 0, deg2rad(newSkew[0]));
|
|
7918
|
+
}
|
|
7919
|
+
else if (t === 'matrix') {
|
|
7920
|
+
var _a = __read(d.map(function (s) { return s.value; }), 6), a = _a[0], b = _a[1], c = _a[2], dd = _a[3], tx = _a[4], ty = _a[5];
|
|
7921
|
+
mat4.set(tmpMat2, a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx, ty, 0, 1);
|
|
7922
|
+
}
|
|
7923
|
+
else if (t === 'matrix3d') {
|
|
7924
|
+
// @ts-ignore
|
|
7925
|
+
mat4.set.apply(mat4, __spreadArray([tmpMat2], __read(d.map(function (s) { return s.value; })), false));
|
|
7926
|
+
}
|
|
7927
|
+
mat4.mul(m_1, m_1, tmpMat2);
|
|
7928
|
+
});
|
|
7929
|
+
object.setLocalTransform(m_1);
|
|
7930
|
+
}
|
|
7931
|
+
else {
|
|
7932
|
+
object.resetLocalTransform();
|
|
7933
|
+
}
|
|
7899
7934
|
return object.getLocalTransform();
|
|
7900
7935
|
}
|
|
7901
7936
|
|
|
@@ -7959,17 +7994,18 @@ var CSSPropertyTransformOrigin = /** @class */ (function () {
|
|
|
7959
7994
|
function CSSPropertyTransformOrigin() {
|
|
7960
7995
|
this.parser = parseTransformOrigin;
|
|
7961
7996
|
this.parserUnmemoize = parseTransformOriginUnmemoize;
|
|
7962
|
-
// calculator(
|
|
7963
|
-
// name: string,
|
|
7964
|
-
// oldParsed: [CSSUnitValue, CSSUnitValue],
|
|
7965
|
-
// parsed: [CSSUnitValue, CSSUnitValue],
|
|
7966
|
-
// object: DisplayObject,
|
|
7967
|
-
// ): [number, number] {
|
|
7968
|
-
// console.log(object, parsed);
|
|
7969
|
-
// return [parsed[0].value, parsed[1].value];
|
|
7970
|
-
// // return [convertPercentUnit(parsed[0], 0, object), convertPercentUnit(parsed[1], 1, object)];
|
|
7971
|
-
// }
|
|
7972
7997
|
}
|
|
7998
|
+
CSSPropertyTransformOrigin.prototype.postProcessor = function (object) {
|
|
7999
|
+
var transformOrigin = object.parsedStyle.transformOrigin;
|
|
8000
|
+
if (transformOrigin[0].unit === UnitType.kPixels &&
|
|
8001
|
+
transformOrigin[1].unit === UnitType.kPixels) {
|
|
8002
|
+
object.setOrigin(transformOrigin[0].value, transformOrigin[1].value);
|
|
8003
|
+
}
|
|
8004
|
+
else {
|
|
8005
|
+
// Relative to geometry bounds, calculate later.
|
|
8006
|
+
object.getGeometryBounds();
|
|
8007
|
+
}
|
|
8008
|
+
};
|
|
7973
8009
|
return CSSPropertyTransformOrigin;
|
|
7974
8010
|
}());
|
|
7975
8011
|
|
|
@@ -8056,8 +8092,8 @@ var PathUpdater = /** @class */ (function () {
|
|
|
8056
8092
|
function PathUpdater() {
|
|
8057
8093
|
}
|
|
8058
8094
|
PathUpdater.prototype.update = function (parsedStyle) {
|
|
8059
|
-
var
|
|
8060
|
-
var _a =
|
|
8095
|
+
var d = parsedStyle.d;
|
|
8096
|
+
var _a = d.rect, x = _a.x, y = _a.y, width = _a.width, height = _a.height;
|
|
8061
8097
|
var hwidth = width / 2;
|
|
8062
8098
|
var hheight = height / 2;
|
|
8063
8099
|
return {
|
|
@@ -8106,17 +8142,17 @@ var RectUpdater = /** @class */ (function () {
|
|
|
8106
8142
|
function RectUpdater() {
|
|
8107
8143
|
}
|
|
8108
8144
|
RectUpdater.prototype.update = function (parsedStyle, object) {
|
|
8109
|
-
var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b,
|
|
8145
|
+
var _a = parsedStyle.x, x = _a === void 0 ? 0 : _a, _b = parsedStyle.y, y = _b === void 0 ? 0 : _b, src = parsedStyle.src, _c = parsedStyle.width, width = _c === void 0 ? 0 : _c, _d = parsedStyle.height, height = _d === void 0 ? 0 : _d;
|
|
8110
8146
|
var contentWidth = width;
|
|
8111
8147
|
var contentHeight = height;
|
|
8112
8148
|
// resize with HTMLImageElement's size
|
|
8113
|
-
if (
|
|
8149
|
+
if (src && !isString(src)) {
|
|
8114
8150
|
if (!contentWidth) {
|
|
8115
|
-
contentWidth =
|
|
8151
|
+
contentWidth = src.width;
|
|
8116
8152
|
parsedStyle.width = contentWidth;
|
|
8117
8153
|
}
|
|
8118
8154
|
if (!contentHeight) {
|
|
8119
|
-
contentHeight =
|
|
8155
|
+
contentHeight = src.height;
|
|
8120
8156
|
parsedStyle.height = contentHeight;
|
|
8121
8157
|
}
|
|
8122
8158
|
}
|
|
@@ -8136,18 +8172,20 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8136
8172
|
}
|
|
8137
8173
|
TextUpdater.prototype.isReadyToMeasure = function (parsedStyle, object) {
|
|
8138
8174
|
var text = parsedStyle.text, textAlign = parsedStyle.textAlign, textBaseline = parsedStyle.textBaseline, fontSize = parsedStyle.fontSize, fontStyle = parsedStyle.fontStyle, fontWeight = parsedStyle.fontWeight, fontVariant = parsedStyle.fontVariant, lineWidth = parsedStyle.lineWidth;
|
|
8139
|
-
return
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8175
|
+
return runtime.enableCSSParsing
|
|
8176
|
+
? text &&
|
|
8177
|
+
fontSize &&
|
|
8178
|
+
fontStyle &&
|
|
8179
|
+
fontWeight &&
|
|
8180
|
+
fontVariant &&
|
|
8181
|
+
textAlign &&
|
|
8182
|
+
textBaseline &&
|
|
8183
|
+
!isNil(lineWidth)
|
|
8184
|
+
: text;
|
|
8147
8185
|
};
|
|
8148
8186
|
TextUpdater.prototype.update = function (parsedStyle, object) {
|
|
8149
8187
|
var _a, _b;
|
|
8150
|
-
var text = parsedStyle.text,
|
|
8188
|
+
var text = parsedStyle.text, _c = parsedStyle.textAlign, textAlign = _c === void 0 ? 'start' : _c, _d = parsedStyle.lineWidth, lineWidth = _d === void 0 ? 1 : _d, _e = parsedStyle.textBaseline, textBaseline = _e === void 0 ? 'alphabetic' : _e, _f = parsedStyle.dx, dx = _f === void 0 ? 0 : _f, _g = parsedStyle.dy, dy = _g === void 0 ? 0 : _g, _h = parsedStyle.x, x = _h === void 0 ? 0 : _h, _j = parsedStyle.y, y = _j === void 0 ? 0 : _j;
|
|
8151
8189
|
if (!this.isReadyToMeasure(parsedStyle, object)) {
|
|
8152
8190
|
parsedStyle.metrics = {
|
|
8153
8191
|
font: '',
|
|
@@ -8219,6 +8257,20 @@ var TextUpdater = /** @class */ (function () {
|
|
|
8219
8257
|
return TextUpdater;
|
|
8220
8258
|
}());
|
|
8221
8259
|
|
|
8260
|
+
var GroupUpdater = /** @class */ (function () {
|
|
8261
|
+
function GroupUpdater() {
|
|
8262
|
+
}
|
|
8263
|
+
GroupUpdater.prototype.update = function (parsedStyle, object) {
|
|
8264
|
+
return {
|
|
8265
|
+
cx: 0,
|
|
8266
|
+
cy: 0,
|
|
8267
|
+
hwidth: 0,
|
|
8268
|
+
hheight: 0,
|
|
8269
|
+
};
|
|
8270
|
+
};
|
|
8271
|
+
return GroupUpdater;
|
|
8272
|
+
}());
|
|
8273
|
+
|
|
8222
8274
|
function isFederatedEvent(value) {
|
|
8223
8275
|
return !!value.type;
|
|
8224
8276
|
}
|
|
@@ -8769,7 +8821,7 @@ var EventTarget = /** @class */ (function () {
|
|
|
8769
8821
|
var Node = /** @class */ (function (_super) {
|
|
8770
8822
|
__extends(Node, _super);
|
|
8771
8823
|
function Node() {
|
|
8772
|
-
var _this = _super.
|
|
8824
|
+
var _this = _super.call(this) || this;
|
|
8773
8825
|
_this.shadow = false;
|
|
8774
8826
|
/**
|
|
8775
8827
|
* points to canvas.document
|
|
@@ -10318,9 +10370,10 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10318
10370
|
*/
|
|
10319
10371
|
this.rotate = (function () {
|
|
10320
10372
|
var parentInvertRotation = quat$1.create();
|
|
10321
|
-
return function (element, degrees, y, z) {
|
|
10373
|
+
return function (element, degrees, y, z, dirtify) {
|
|
10322
10374
|
if (y === void 0) { y = 0; }
|
|
10323
10375
|
if (z === void 0) { z = 0; }
|
|
10376
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10324
10377
|
if (typeof degrees === 'number') {
|
|
10325
10378
|
degrees = vec3.fromValues(degrees, y, z);
|
|
10326
10379
|
}
|
|
@@ -10339,7 +10392,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10339
10392
|
quat$1.multiply(rotation, parentInvertRotation, rotation);
|
|
10340
10393
|
quat$1.multiply(transform.localRotation, rotation, rot);
|
|
10341
10394
|
quat$1.normalize(transform.localRotation, transform.localRotation);
|
|
10342
|
-
|
|
10395
|
+
if (dirtify) {
|
|
10396
|
+
_this.dirtifyLocal(element, transform);
|
|
10397
|
+
}
|
|
10343
10398
|
}
|
|
10344
10399
|
};
|
|
10345
10400
|
})();
|
|
@@ -10349,16 +10404,19 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10349
10404
|
*/
|
|
10350
10405
|
this.rotateLocal = (function () {
|
|
10351
10406
|
var rotation = quat$1.create();
|
|
10352
|
-
return function (element, degrees, y, z) {
|
|
10407
|
+
return function (element, degrees, y, z, dirtify) {
|
|
10353
10408
|
if (y === void 0) { y = 0; }
|
|
10354
10409
|
if (z === void 0) { z = 0; }
|
|
10410
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10355
10411
|
if (typeof degrees === 'number') {
|
|
10356
10412
|
degrees = vec3.fromValues(degrees, y, z);
|
|
10357
10413
|
}
|
|
10358
10414
|
var transform = element.transformable;
|
|
10359
10415
|
quat$1.fromEuler(rotation, degrees[0], degrees[1], degrees[2]);
|
|
10360
10416
|
quat$1.mul(transform.localRotation, transform.localRotation, rotation);
|
|
10361
|
-
|
|
10417
|
+
if (dirtify) {
|
|
10418
|
+
_this.dirtifyLocal(element, transform);
|
|
10419
|
+
}
|
|
10362
10420
|
};
|
|
10363
10421
|
})();
|
|
10364
10422
|
/**
|
|
@@ -10366,9 +10424,10 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10366
10424
|
*/
|
|
10367
10425
|
this.setEulerAngles = (function () {
|
|
10368
10426
|
var invParentRot = quat$1.create();
|
|
10369
|
-
return function (element, degrees, y, z) {
|
|
10427
|
+
return function (element, degrees, y, z, dirtify) {
|
|
10370
10428
|
if (y === void 0) { y = 0; }
|
|
10371
10429
|
if (z === void 0) { z = 0; }
|
|
10430
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10372
10431
|
if (typeof degrees === 'number') {
|
|
10373
10432
|
degrees = vec3.fromValues(degrees, y, z);
|
|
10374
10433
|
}
|
|
@@ -10382,7 +10441,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10382
10441
|
var parentRotation = _this.getRotation(element.parentNode);
|
|
10383
10442
|
quat$1.copy(invParentRot, quat$1.invert(quat$1.create(), parentRotation));
|
|
10384
10443
|
quat$1.mul(transform.localRotation, transform.localRotation, invParentRot);
|
|
10385
|
-
|
|
10444
|
+
if (dirtify) {
|
|
10445
|
+
_this.dirtifyLocal(element, transform);
|
|
10446
|
+
}
|
|
10386
10447
|
}
|
|
10387
10448
|
};
|
|
10388
10449
|
})();
|
|
@@ -10396,9 +10457,10 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10396
10457
|
* ```
|
|
10397
10458
|
*/
|
|
10398
10459
|
this.translateLocal = (function () {
|
|
10399
|
-
return function (element, translation, y, z) {
|
|
10460
|
+
return function (element, translation, y, z, dirtify) {
|
|
10400
10461
|
if (y === void 0) { y = 0; }
|
|
10401
10462
|
if (z === void 0) { z = 0; }
|
|
10463
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10402
10464
|
if (typeof translation === 'number') {
|
|
10403
10465
|
translation = vec3.fromValues(translation, y, z);
|
|
10404
10466
|
}
|
|
@@ -10408,7 +10470,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10408
10470
|
}
|
|
10409
10471
|
vec3.transformQuat(translation, translation, transform.localRotation);
|
|
10410
10472
|
vec3.add(transform.localPosition, transform.localPosition, translation);
|
|
10411
|
-
|
|
10473
|
+
if (dirtify) {
|
|
10474
|
+
_this.dirtifyLocal(element, transform);
|
|
10475
|
+
}
|
|
10412
10476
|
};
|
|
10413
10477
|
})();
|
|
10414
10478
|
/**
|
|
@@ -10420,7 +10484,8 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10420
10484
|
this.setPosition = (function () {
|
|
10421
10485
|
var parentInvertMatrix = mat4.create();
|
|
10422
10486
|
var tmpPosition = vec3.create();
|
|
10423
|
-
return function (element, position) {
|
|
10487
|
+
return function (element, position, dirtify) {
|
|
10488
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10424
10489
|
var transform = element.transformable;
|
|
10425
10490
|
tmpPosition[0] = position[0];
|
|
10426
10491
|
tmpPosition[1] = position[1];
|
|
@@ -10439,7 +10504,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10439
10504
|
mat4.invert(parentInvertMatrix, parentInvertMatrix);
|
|
10440
10505
|
vec3.transformMat4(transform.localPosition, tmpPosition, parentInvertMatrix);
|
|
10441
10506
|
}
|
|
10442
|
-
|
|
10507
|
+
if (dirtify) {
|
|
10508
|
+
_this.dirtifyLocal(element, transform);
|
|
10509
|
+
}
|
|
10443
10510
|
};
|
|
10444
10511
|
})();
|
|
10445
10512
|
/**
|
|
@@ -10447,7 +10514,8 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10447
10514
|
*/
|
|
10448
10515
|
this.setLocalPosition = (function () {
|
|
10449
10516
|
var tmpPosition = vec3.create();
|
|
10450
|
-
return function (element, position) {
|
|
10517
|
+
return function (element, position, dirtify) {
|
|
10518
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10451
10519
|
var transform = element.transformable;
|
|
10452
10520
|
tmpPosition[0] = position[0];
|
|
10453
10521
|
tmpPosition[1] = position[1];
|
|
@@ -10456,7 +10524,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10456
10524
|
return;
|
|
10457
10525
|
}
|
|
10458
10526
|
vec3.copy(transform.localPosition, tmpPosition);
|
|
10459
|
-
|
|
10527
|
+
if (dirtify) {
|
|
10528
|
+
_this.dirtifyLocal(element, transform);
|
|
10529
|
+
}
|
|
10460
10530
|
};
|
|
10461
10531
|
})();
|
|
10462
10532
|
/**
|
|
@@ -10475,9 +10545,10 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10475
10545
|
var zeroVec3 = vec3.create();
|
|
10476
10546
|
var tmpVec3 = vec3.create();
|
|
10477
10547
|
var tr = vec3.create();
|
|
10478
|
-
return function (element, translation, y, z) {
|
|
10548
|
+
return function (element, translation, y, z, dirtify) {
|
|
10479
10549
|
if (y === void 0) { y = 0; }
|
|
10480
10550
|
if (z === void 0) { z = 0; }
|
|
10551
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10481
10552
|
if (typeof translation === 'number') {
|
|
10482
10553
|
translation = vec3.set(tmpVec3, translation, y, z);
|
|
10483
10554
|
}
|
|
@@ -10485,12 +10556,13 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10485
10556
|
return;
|
|
10486
10557
|
}
|
|
10487
10558
|
vec3.add(tr, _this.getPosition(element), translation);
|
|
10488
|
-
_this.setPosition(element, tr);
|
|
10559
|
+
_this.setPosition(element, tr, dirtify);
|
|
10489
10560
|
};
|
|
10490
10561
|
})();
|
|
10491
10562
|
this.setRotation = function () {
|
|
10492
10563
|
var parentInvertRotation = quat$1.create();
|
|
10493
|
-
return function (element, rotation, y, z, w) {
|
|
10564
|
+
return function (element, rotation, y, z, w, dirtify) {
|
|
10565
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10494
10566
|
var transform = element.transformable;
|
|
10495
10567
|
if (typeof rotation === 'number') {
|
|
10496
10568
|
rotation = quat$1.fromValues(rotation, y, z, w);
|
|
@@ -10505,7 +10577,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10505
10577
|
quat$1.invert(parentInvertRotation, parentInvertRotation);
|
|
10506
10578
|
quat$1.multiply(transform.localRotation, parentInvertRotation, rotation);
|
|
10507
10579
|
quat$1.normalize(transform.localRotation, transform.localRotation);
|
|
10508
|
-
|
|
10580
|
+
if (dirtify) {
|
|
10581
|
+
_this.dirtifyLocal(element, transform);
|
|
10582
|
+
}
|
|
10509
10583
|
}
|
|
10510
10584
|
};
|
|
10511
10585
|
};
|
|
@@ -10546,7 +10620,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10546
10620
|
// .filter((node) => !node.shadow);
|
|
10547
10621
|
};
|
|
10548
10622
|
DefaultSceneGraphService.prototype.attach = function (child, parent, index) {
|
|
10549
|
-
var _a
|
|
10623
|
+
var _a;
|
|
10550
10624
|
var detached = false;
|
|
10551
10625
|
if (child.parentNode) {
|
|
10552
10626
|
detached = child.parentNode !== parent;
|
|
@@ -10562,7 +10636,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10562
10636
|
// parent needs re-sort
|
|
10563
10637
|
var sortable = parent.sortable;
|
|
10564
10638
|
if (((_a = sortable === null || sortable === void 0 ? void 0 : sortable.sorted) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
10565
|
-
|
|
10639
|
+
child.parsedStyle.zIndex) {
|
|
10566
10640
|
if (sortable.dirtyChildren.indexOf(child) === -1) {
|
|
10567
10641
|
sortable.dirtyChildren.push(child);
|
|
10568
10642
|
}
|
|
@@ -10616,6 +10690,7 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10616
10690
|
}
|
|
10617
10691
|
};
|
|
10618
10692
|
DefaultSceneGraphService.prototype.getOrigin = function (element) {
|
|
10693
|
+
element.getGeometryBounds();
|
|
10619
10694
|
return element.transformable.origin;
|
|
10620
10695
|
};
|
|
10621
10696
|
/**
|
|
@@ -10647,40 +10722,52 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10647
10722
|
/**
|
|
10648
10723
|
* set euler angles(degrees) in local space
|
|
10649
10724
|
*/
|
|
10650
|
-
DefaultSceneGraphService.prototype.setLocalEulerAngles = function (element, degrees, y, z) {
|
|
10725
|
+
DefaultSceneGraphService.prototype.setLocalEulerAngles = function (element, degrees, y, z, dirtify) {
|
|
10651
10726
|
if (y === void 0) { y = 0; }
|
|
10652
10727
|
if (z === void 0) { z = 0; }
|
|
10728
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10653
10729
|
if (typeof degrees === 'number') {
|
|
10654
10730
|
degrees = vec3.fromValues(degrees, y, z);
|
|
10655
10731
|
}
|
|
10656
10732
|
var transform = element.transformable;
|
|
10657
10733
|
quat$1.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
|
|
10658
|
-
|
|
10734
|
+
if (dirtify) {
|
|
10735
|
+
this.dirtifyLocal(element, transform);
|
|
10736
|
+
}
|
|
10659
10737
|
};
|
|
10660
10738
|
/**
|
|
10661
10739
|
* scale in local space
|
|
10662
10740
|
*/
|
|
10663
|
-
DefaultSceneGraphService.prototype.scaleLocal = function (element, scaling) {
|
|
10741
|
+
DefaultSceneGraphService.prototype.scaleLocal = function (element, scaling, dirtify) {
|
|
10742
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10664
10743
|
var transform = element.transformable;
|
|
10665
10744
|
vec3.multiply(transform.localScale, transform.localScale, vec3.fromValues(scaling[0], scaling[1], scaling[2] || 1));
|
|
10666
|
-
|
|
10745
|
+
if (dirtify) {
|
|
10746
|
+
this.dirtifyLocal(element, transform);
|
|
10747
|
+
}
|
|
10667
10748
|
};
|
|
10668
|
-
DefaultSceneGraphService.prototype.setLocalScale = function (element, scaling) {
|
|
10749
|
+
DefaultSceneGraphService.prototype.setLocalScale = function (element, scaling, dirtify) {
|
|
10750
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10669
10751
|
var transform = element.transformable;
|
|
10670
10752
|
var updatedScaling = vec3.fromValues(scaling[0], scaling[1], scaling[2] || transform.localScale[2]);
|
|
10671
10753
|
if (vec3.equals(updatedScaling, transform.localScale)) {
|
|
10672
10754
|
return;
|
|
10673
10755
|
}
|
|
10674
10756
|
vec3.copy(transform.localScale, updatedScaling);
|
|
10675
|
-
|
|
10757
|
+
if (dirtify) {
|
|
10758
|
+
this.dirtifyLocal(element, transform);
|
|
10759
|
+
}
|
|
10676
10760
|
};
|
|
10677
|
-
DefaultSceneGraphService.prototype.setLocalRotation = function (element, rotation, y, z, w) {
|
|
10761
|
+
DefaultSceneGraphService.prototype.setLocalRotation = function (element, rotation, y, z, w, dirtify) {
|
|
10762
|
+
if (dirtify === void 0) { dirtify = true; }
|
|
10678
10763
|
if (typeof rotation === 'number') {
|
|
10679
10764
|
rotation = quat$1.fromValues(rotation, y, z, w);
|
|
10680
10765
|
}
|
|
10681
10766
|
var transform = element.transformable;
|
|
10682
10767
|
quat$1.copy(transform.localRotation, rotation);
|
|
10683
|
-
|
|
10768
|
+
if (dirtify) {
|
|
10769
|
+
this.dirtifyLocal(element, transform);
|
|
10770
|
+
}
|
|
10684
10771
|
};
|
|
10685
10772
|
DefaultSceneGraphService.prototype.setLocalSkew = function (element, skew, y) {
|
|
10686
10773
|
if (typeof skew === 'number') {
|
|
@@ -10844,9 +10931,10 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10844
10931
|
var t = mat4.getTranslation(vec3.create(), transform);
|
|
10845
10932
|
var r = mat4.getRotation(quat$1.create(), transform);
|
|
10846
10933
|
var s = mat4.getScaling(vec3.create(), transform);
|
|
10847
|
-
this.setLocalScale(element, s);
|
|
10848
|
-
this.setLocalPosition(element, t);
|
|
10849
|
-
this.setLocalRotation(element, r);
|
|
10934
|
+
this.setLocalScale(element, s, false);
|
|
10935
|
+
this.setLocalPosition(element, t, false);
|
|
10936
|
+
this.setLocalRotation(element, r, undefined, undefined, undefined, false);
|
|
10937
|
+
this.dirtifyLocal(element, element.transformable);
|
|
10850
10938
|
};
|
|
10851
10939
|
DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
|
|
10852
10940
|
this.setLocalScale(element, [1, 1, 1]);
|
|
@@ -10872,6 +10960,9 @@ var DefaultSceneGraphService = /** @class */ (function () {
|
|
|
10872
10960
|
DefaultSceneGraphService.prototype.getGeometryBounds = function (element, render) {
|
|
10873
10961
|
if (render === void 0) { render = false; }
|
|
10874
10962
|
var geometry = element.geometry;
|
|
10963
|
+
if (geometry.dirty) {
|
|
10964
|
+
runtime.styleValueRegistry.updateGeometry(element);
|
|
10965
|
+
}
|
|
10875
10966
|
var bounds = render
|
|
10876
10967
|
? geometry.renderBounds
|
|
10877
10968
|
: geometry.contentBounds || null;
|
|
@@ -11194,13 +11285,13 @@ var TextService = /** @class */ (function () {
|
|
|
11194
11285
|
return properties;
|
|
11195
11286
|
};
|
|
11196
11287
|
TextService.prototype.measureText = function (text, parsedStyle, offscreenCanvas) {
|
|
11197
|
-
var
|
|
11288
|
+
var _a = parsedStyle.fontSize, fontSize = _a === void 0 ? 16 : _a, _b = parsedStyle.wordWrap, wordWrap = _b === void 0 ? false : _b, strokeHeight = parsedStyle.lineHeight, _c = parsedStyle.lineWidth, lineWidth = _c === void 0 ? 1 : _c, _d = parsedStyle.textBaseline, textBaseline = _d === void 0 ? 'alphabetic' : _d, _e = parsedStyle.textAlign, textAlign = _e === void 0 ? 'start' : _e, _f = parsedStyle.letterSpacing, letterSpacing = _f === void 0 ? 0 : _f, textPath = parsedStyle.textPath; parsedStyle.textPathSide; parsedStyle.textPathStartOffset;
|
|
11198
11289
|
var // dropShadow = 0,
|
|
11199
11290
|
// dropShadowDistance = 0,
|
|
11200
|
-
|
|
11291
|
+
_g = parsedStyle.leading,
|
|
11201
11292
|
// dropShadow = 0,
|
|
11202
11293
|
// dropShadowDistance = 0,
|
|
11203
|
-
leading =
|
|
11294
|
+
leading = _g === void 0 ? 0 : _g;
|
|
11204
11295
|
var font = toFontString(parsedStyle);
|
|
11205
11296
|
// if (runtime.enableCSSParsing) {
|
|
11206
11297
|
var fontProperties = this.measureFont(font, offscreenCanvas);
|
|
@@ -11312,7 +11403,7 @@ var TextService = /** @class */ (function () {
|
|
|
11312
11403
|
TextService.prototype.setGraphemeOnPath = function () { };
|
|
11313
11404
|
TextService.prototype.wordWrap = function (text, parsedStyle, offscreenCanvas) {
|
|
11314
11405
|
var _this = this;
|
|
11315
|
-
var _a = parsedStyle.wordWrapWidth, wordWrapWidth = _a === void 0 ? 0 : _a,
|
|
11406
|
+
var _a = parsedStyle.wordWrapWidth, wordWrapWidth = _a === void 0 ? 0 : _a, _b = parsedStyle.letterSpacing, letterSpacing = _b === void 0 ? 0 : _b, _c = parsedStyle.maxLines, maxLines = _c === void 0 ? Infinity : _c, textOverflow = parsedStyle.textOverflow;
|
|
11316
11407
|
var context = this.runtime.offscreenCanvasCreator.getOrCreateContext(offscreenCanvas);
|
|
11317
11408
|
var maxWidth = wordWrapWidth + letterSpacing;
|
|
11318
11409
|
var ellipsis = '';
|
|
@@ -11462,7 +11553,7 @@ var geometryUpdaterFactory = (function () {
|
|
|
11462
11553
|
_a[Shape.ELLIPSE] = new EllipseUpdater(),
|
|
11463
11554
|
_a[Shape.RECT] = rectUpdater,
|
|
11464
11555
|
_a[Shape.IMAGE] = rectUpdater,
|
|
11465
|
-
_a[Shape.GROUP] =
|
|
11556
|
+
_a[Shape.GROUP] = new GroupUpdater(),
|
|
11466
11557
|
_a[Shape.LINE] = new LineUpdater(),
|
|
11467
11558
|
_a[Shape.TEXT] = new TextUpdater(runtime),
|
|
11468
11559
|
_a[Shape.POLYLINE] = polylineUpdater,
|
|
@@ -11539,6 +11630,7 @@ runtime.globalThis = getGlobalThis();
|
|
|
11539
11630
|
runtime.enableCSSParsing = true;
|
|
11540
11631
|
runtime.enableDataset = false;
|
|
11541
11632
|
runtime.enableStyleSyntax = true;
|
|
11633
|
+
runtime.enableAttributeDashCased = false;
|
|
11542
11634
|
|
|
11543
11635
|
var entityCounter = 0;
|
|
11544
11636
|
function resetEntityCounter() {
|
|
@@ -11556,7 +11648,7 @@ var destroyEvent = new CustomEvent(ElementEvent.DESTROY);
|
|
|
11556
11648
|
var Element = /** @class */ (function (_super) {
|
|
11557
11649
|
__extends(Element, _super);
|
|
11558
11650
|
function Element() {
|
|
11559
|
-
var _this = _super.
|
|
11651
|
+
var _this = _super.call(this) || this;
|
|
11560
11652
|
/**
|
|
11561
11653
|
* Unique id.
|
|
11562
11654
|
*/
|
|
@@ -11600,6 +11692,7 @@ var Element = /** @class */ (function (_super) {
|
|
|
11600
11692
|
_this.geometry = {
|
|
11601
11693
|
contentBounds: undefined,
|
|
11602
11694
|
renderBounds: undefined,
|
|
11695
|
+
dirty: true,
|
|
11603
11696
|
};
|
|
11604
11697
|
_this.rBushNode = {
|
|
11605
11698
|
aabb: undefined,
|
|
@@ -11784,7 +11877,7 @@ var Element = /** @class */ (function (_super) {
|
|
|
11784
11877
|
this.ownerDocument.defaultView.mountChildren(child);
|
|
11785
11878
|
}
|
|
11786
11879
|
// @ts-ignore
|
|
11787
|
-
if (
|
|
11880
|
+
if (this.isMutationObserved) {
|
|
11788
11881
|
insertedEvent.relatedNode = this;
|
|
11789
11882
|
child.dispatchEvent(insertedEvent);
|
|
11790
11883
|
}
|
|
@@ -12060,8 +12153,10 @@ var Element = /** @class */ (function (_super) {
|
|
|
12060
12153
|
}
|
|
12061
12154
|
var value = this.attributes[name];
|
|
12062
12155
|
if (value === undefined) {
|
|
12063
|
-
|
|
12064
|
-
|
|
12156
|
+
if (runtime.enableAttributeDashCased) {
|
|
12157
|
+
var attributeName = formatAttributeName(name);
|
|
12158
|
+
value = this.attributes[attributeName];
|
|
12159
|
+
}
|
|
12065
12160
|
// if the given attribute does not exist, the value returned will either be null or ""
|
|
12066
12161
|
return runtime.enableCSSParsing ? (isNil(value) ? null : value) : value;
|
|
12067
12162
|
}
|
|
@@ -12131,6 +12226,9 @@ var Element = /** @class */ (function (_super) {
|
|
|
12131
12226
|
function isDisplayObject(value) {
|
|
12132
12227
|
return !!(value === null || value === void 0 ? void 0 : value.nodeName);
|
|
12133
12228
|
}
|
|
12229
|
+
var Proxy = runtime.globalThis.Proxy
|
|
12230
|
+
? runtime.globalThis.Proxy
|
|
12231
|
+
: function () { };
|
|
12134
12232
|
var mutationEvent = new MutationEvent(ElementEvent.ATTR_MODIFIED, null, null, null, null, MutationEvent.MODIFICATION, null, null);
|
|
12135
12233
|
var DEFAULT_STYLE_PROPS = {
|
|
12136
12234
|
opacity: '',
|
|
@@ -12167,7 +12265,20 @@ var DEFAULT_PARSED_STYLE_PROPS = {
|
|
|
12167
12265
|
shadowType: 'outer',
|
|
12168
12266
|
miterLimit: 10,
|
|
12169
12267
|
};
|
|
12170
|
-
|
|
12268
|
+
// const DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED = {
|
|
12269
|
+
// ...DEFAULT_PARSED_STYLE_PROPS,
|
|
12270
|
+
// opacity: 1,
|
|
12271
|
+
// fillOpacity: 1,
|
|
12272
|
+
// strokeOpacity: 1,
|
|
12273
|
+
// visibility: 'visible',
|
|
12274
|
+
// pointerEvents: 'auto',
|
|
12275
|
+
// lineWidth: 1,
|
|
12276
|
+
// lineCap: 'butt',
|
|
12277
|
+
// lineJoin: 'miter',
|
|
12278
|
+
// increasedLineWidthForHitTesting: 0,
|
|
12279
|
+
// fillRule: 'nonzero',
|
|
12280
|
+
// // TODO: transformOrigin
|
|
12281
|
+
// };
|
|
12171
12282
|
var INHERITABLE_BASE_STYLE_PROPS = [
|
|
12172
12283
|
'opacity',
|
|
12173
12284
|
'fillOpacity',
|
|
@@ -12219,18 +12330,9 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12219
12330
|
* push to active animations after calling `animate()`
|
|
12220
12331
|
*/
|
|
12221
12332
|
_this.activeAnimations = [];
|
|
12222
|
-
/**
|
|
12223
|
-
* Use `this.style.clipPath` instead.
|
|
12224
|
-
* @deprecated
|
|
12225
|
-
*/
|
|
12226
|
-
_this.getClip = function () {
|
|
12227
|
-
return this.style.clipPath || null;
|
|
12228
|
-
};
|
|
12229
12333
|
// assign name, id to config
|
|
12230
12334
|
// eg. group.get('name')
|
|
12231
12335
|
_this.config = config;
|
|
12232
|
-
// compatible with G 3.0
|
|
12233
|
-
// this.config.interactive = this.config.capture ?? this.config.interactive;
|
|
12234
12336
|
// init scene graph node
|
|
12235
12337
|
_this.id = _this.config.id || '';
|
|
12236
12338
|
_this.name = _this.config.name || '';
|
|
@@ -12238,35 +12340,17 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12238
12340
|
_this.className = _this.config.className || _this.config.class;
|
|
12239
12341
|
}
|
|
12240
12342
|
_this.nodeName = _this.config.type || Shape.GROUP;
|
|
12241
|
-
// // compatible with G 3.0
|
|
12242
|
-
// this.config.style =
|
|
12243
|
-
// this.config.style || this.config.attrs || ({} as StyleProps);
|
|
12244
|
-
// // Object.assign(this.config.style, this.config.attrs);
|
|
12245
|
-
// // this.config.style = {
|
|
12246
|
-
// // // ...DEFAULT_STYLE_PROPS,
|
|
12247
|
-
// // ...this.config.style,
|
|
12248
|
-
// // ...this.config.attrs,
|
|
12249
|
-
// // };
|
|
12250
|
-
// if (this.config.visible != null) {
|
|
12251
|
-
// this.config.style.visibility =
|
|
12252
|
-
// this.config.visible === false ? 'hidden' : 'visible';
|
|
12253
|
-
// }
|
|
12254
|
-
// if (this.config.interactive != null) {
|
|
12255
|
-
// this.config.style.pointerEvents =
|
|
12256
|
-
// this.config.interactive === false ? 'none' : 'auto';
|
|
12257
|
-
// }
|
|
12258
|
-
// merge parsed value
|
|
12259
|
-
Object.assign(_this.parsedStyle, runtime.enableCSSParsing
|
|
12260
|
-
? DEFAULT_PARSED_STYLE_PROPS
|
|
12261
|
-
: DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED, _this.config.initialParsedStyle);
|
|
12262
12343
|
if (runtime.enableCSSParsing) {
|
|
12263
12344
|
Object.assign(_this.attributes, DEFAULT_STYLE_PROPS);
|
|
12345
|
+
Object.assign(_this.parsedStyle, DEFAULT_PARSED_STYLE_PROPS, _this.config.initialParsedStyle);
|
|
12346
|
+
}
|
|
12347
|
+
else if (_this.config.initialParsedStyle) {
|
|
12348
|
+
Object.assign(_this.parsedStyle,
|
|
12349
|
+
// DEFAULT_PARSED_STYLE_PROPS_CSS_DISABLED,
|
|
12350
|
+
_this.config.initialParsedStyle);
|
|
12264
12351
|
}
|
|
12265
12352
|
// start to process attributes
|
|
12266
12353
|
_this.initAttributes(_this.config.style);
|
|
12267
|
-
var Proxy = runtime.globalThis.Proxy
|
|
12268
|
-
? runtime.globalThis.Proxy
|
|
12269
|
-
: function () { };
|
|
12270
12354
|
if (runtime.enableDataset) {
|
|
12271
12355
|
_this.dataset = new Proxy({}, {
|
|
12272
12356
|
get: function (target, name) {
|
|
@@ -12384,10 +12468,14 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12384
12468
|
options.usedAttributes = INHERITABLE_STYLE_PROPS;
|
|
12385
12469
|
}
|
|
12386
12470
|
// account for FCP, process properties as less as possible
|
|
12387
|
-
var formattedAttributes =
|
|
12388
|
-
|
|
12389
|
-
|
|
12390
|
-
formattedAttributes
|
|
12471
|
+
var formattedAttributes = attributes;
|
|
12472
|
+
if (runtime.enableAttributeDashCased) {
|
|
12473
|
+
// @ts-ignore
|
|
12474
|
+
formattedAttributes = {};
|
|
12475
|
+
for (var name_1 in attributes) {
|
|
12476
|
+
var attributeName = formatAttributeName(name_1);
|
|
12477
|
+
formattedAttributes[attributeName] = attributes[name_1];
|
|
12478
|
+
}
|
|
12391
12479
|
}
|
|
12392
12480
|
runtime.styleValueRegistry.processProperties(this, formattedAttributes, options);
|
|
12393
12481
|
// redraw at next frame
|
|
@@ -12396,14 +12484,16 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12396
12484
|
DisplayObject.prototype.setAttribute = function (name, value, force, memoize) {
|
|
12397
12485
|
if (force === void 0) { force = false; }
|
|
12398
12486
|
if (memoize === void 0) { memoize = true; }
|
|
12399
|
-
|
|
12487
|
+
if (runtime.enableAttributeDashCased) {
|
|
12488
|
+
name = formatAttributeName(name);
|
|
12489
|
+
}
|
|
12400
12490
|
// ignore undefined value
|
|
12401
12491
|
if (isUndefined(value)) {
|
|
12402
12492
|
return;
|
|
12403
12493
|
}
|
|
12404
|
-
if (force || value !== this.attributes[
|
|
12405
|
-
this.internalSetAttribute(
|
|
12406
|
-
_super.prototype.setAttribute.call(this,
|
|
12494
|
+
if (force || value !== this.attributes[name]) {
|
|
12495
|
+
this.internalSetAttribute(name, value, { memoize: memoize });
|
|
12496
|
+
_super.prototype.setAttribute.call(this, name, value);
|
|
12407
12497
|
}
|
|
12408
12498
|
};
|
|
12409
12499
|
/**
|
|
@@ -12657,8 +12747,10 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12657
12747
|
* shortcut for Used value of `visibility`
|
|
12658
12748
|
*/
|
|
12659
12749
|
DisplayObject.prototype.isVisible = function () {
|
|
12660
|
-
var _a;
|
|
12661
|
-
return
|
|
12750
|
+
var _a, _b;
|
|
12751
|
+
return runtime.enableCSSParsing
|
|
12752
|
+
? ((_a = this.parsedStyle) === null || _a === void 0 ? void 0 : _a.visibility) === 'visible'
|
|
12753
|
+
: ((_b = this.parsedStyle) === null || _b === void 0 ? void 0 : _b.visibility) !== 'hidden';
|
|
12662
12754
|
};
|
|
12663
12755
|
Object.defineProperty(DisplayObject.prototype, "interactive", {
|
|
12664
12756
|
get: function () {
|
|
@@ -12850,13 +12942,6 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12850
12942
|
DisplayObject.prototype.add = function (child, index) {
|
|
12851
12943
|
return this.appendChild(child, index);
|
|
12852
12944
|
};
|
|
12853
|
-
/**
|
|
12854
|
-
* Use `this.style.clipPath` instead.
|
|
12855
|
-
* @deprecated
|
|
12856
|
-
*/
|
|
12857
|
-
DisplayObject.prototype.setClip = function (clipPath) {
|
|
12858
|
-
this.style.clipPath = clipPath;
|
|
12859
|
-
};
|
|
12860
12945
|
/**
|
|
12861
12946
|
* @deprecated
|
|
12862
12947
|
*/
|
|
@@ -12901,124 +12986,11 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12901
12986
|
return DisplayObject;
|
|
12902
12987
|
}(Element));
|
|
12903
12988
|
|
|
12904
|
-
/**
|
|
12905
|
-
* holds useful CSS-related methods.
|
|
12906
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS
|
|
12907
|
-
*
|
|
12908
|
-
* * CSS Typed OM @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/factory_functions
|
|
12909
|
-
* * register property @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty
|
|
12910
|
-
* * CSS Layout API
|
|
12911
|
-
*/
|
|
12912
|
-
var CSS = {
|
|
12913
|
-
/**
|
|
12914
|
-
* <number>
|
|
12915
|
-
* @see https://drafts.csswg.org/css-values-4/#number-value
|
|
12916
|
-
*/
|
|
12917
|
-
number: function (n) {
|
|
12918
|
-
return new CSSUnitValue(n);
|
|
12919
|
-
},
|
|
12920
|
-
/**
|
|
12921
|
-
* <percentage>
|
|
12922
|
-
* @see https://drafts.csswg.org/css-values-4/#percentage-value
|
|
12923
|
-
*/
|
|
12924
|
-
percent: function (n) {
|
|
12925
|
-
return new CSSUnitValue(n, '%');
|
|
12926
|
-
},
|
|
12927
|
-
/**
|
|
12928
|
-
* <length>
|
|
12929
|
-
*/
|
|
12930
|
-
px: function (n) {
|
|
12931
|
-
return new CSSUnitValue(n, 'px');
|
|
12932
|
-
},
|
|
12933
|
-
/**
|
|
12934
|
-
* <length>
|
|
12935
|
-
*/
|
|
12936
|
-
em: function (n) {
|
|
12937
|
-
return new CSSUnitValue(n, 'em');
|
|
12938
|
-
},
|
|
12939
|
-
rem: function (n) {
|
|
12940
|
-
return new CSSUnitValue(n, 'rem');
|
|
12941
|
-
},
|
|
12942
|
-
/**
|
|
12943
|
-
* <angle>
|
|
12944
|
-
*/
|
|
12945
|
-
deg: function (n) {
|
|
12946
|
-
return new CSSUnitValue(n, 'deg');
|
|
12947
|
-
},
|
|
12948
|
-
/**
|
|
12949
|
-
* <angle>
|
|
12950
|
-
*/
|
|
12951
|
-
grad: function (n) {
|
|
12952
|
-
return new CSSUnitValue(n, 'grad');
|
|
12953
|
-
},
|
|
12954
|
-
/**
|
|
12955
|
-
* <angle>
|
|
12956
|
-
*/
|
|
12957
|
-
rad: function (n) {
|
|
12958
|
-
return new CSSUnitValue(n, 'rad');
|
|
12959
|
-
},
|
|
12960
|
-
/**
|
|
12961
|
-
* <angle>
|
|
12962
|
-
*/
|
|
12963
|
-
turn: function (n) {
|
|
12964
|
-
return new CSSUnitValue(n, 'turn');
|
|
12965
|
-
},
|
|
12966
|
-
/**
|
|
12967
|
-
* <time>
|
|
12968
|
-
*/
|
|
12969
|
-
s: function (n) {
|
|
12970
|
-
return new CSSUnitValue(n, 's');
|
|
12971
|
-
},
|
|
12972
|
-
/**
|
|
12973
|
-
* <time>
|
|
12974
|
-
*/
|
|
12975
|
-
ms: function (n) {
|
|
12976
|
-
return new CSSUnitValue(n, 'ms');
|
|
12977
|
-
},
|
|
12978
|
-
/**
|
|
12979
|
-
* CSS Properties & Values API
|
|
12980
|
-
*
|
|
12981
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS_Properties_and_Values_API
|
|
12982
|
-
* @see https://drafts.css-houdini.org/css-properties-values-api/#registering-custom-properties
|
|
12983
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty
|
|
12984
|
-
*/
|
|
12985
|
-
registerProperty: function (definition) {
|
|
12986
|
-
var name = definition.name, inherits = definition.inherits, interpolable = definition.interpolable, initialValue = definition.initialValue, syntax = definition.syntax;
|
|
12987
|
-
runtime.styleValueRegistry.registerMetadata({
|
|
12988
|
-
n: name,
|
|
12989
|
-
inh: inherits,
|
|
12990
|
-
int: interpolable,
|
|
12991
|
-
d: initialValue,
|
|
12992
|
-
syntax: syntax,
|
|
12993
|
-
});
|
|
12994
|
-
},
|
|
12995
|
-
/**
|
|
12996
|
-
* CSS Layout API
|
|
12997
|
-
* register layout
|
|
12998
|
-
*
|
|
12999
|
-
* @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
|
|
13000
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
|
|
13001
|
-
*/
|
|
13002
|
-
registerLayout: function (name, clazz) {
|
|
13003
|
-
runtime.layoutRegistry.registerLayout(name, clazz);
|
|
13004
|
-
},
|
|
13005
|
-
};
|
|
13006
|
-
|
|
13007
12989
|
var Circle = /** @class */ (function (_super) {
|
|
13008
12990
|
__extends(Circle, _super);
|
|
13009
|
-
|
|
13010
|
-
|
|
13011
|
-
|
|
13012
|
-
// }
|
|
13013
|
-
function Circle(_a) {
|
|
13014
|
-
if (_a === void 0) { _a = {}; }
|
|
13015
|
-
var style = _a.style, rest = __rest(_a, ["style"]);
|
|
13016
|
-
return _super.call(this, __assign({ type: Shape.CIRCLE, style: runtime.enableCSSParsing
|
|
13017
|
-
? __assign({ cx: '', cy: '', r: '' }, style) : __assign({}, style), initialParsedStyle: {
|
|
13018
|
-
transformOrigin: runtime.enableCSSParsing
|
|
13019
|
-
? null
|
|
13020
|
-
: [PECENTAGE_50, PECENTAGE_50],
|
|
13021
|
-
} }, rest)) || this;
|
|
12991
|
+
function Circle(options) {
|
|
12992
|
+
if (options === void 0) { options = {}; }
|
|
12993
|
+
return _super.call(this, __assign({ type: Shape.CIRCLE }, options)) || this;
|
|
13022
12994
|
}
|
|
13023
12995
|
return Circle;
|
|
13024
12996
|
}(DisplayObject));
|
|
@@ -13047,15 +13019,9 @@ var CustomElement = /** @class */ (function (_super) {
|
|
|
13047
13019
|
|
|
13048
13020
|
var Ellipse = /** @class */ (function (_super) {
|
|
13049
13021
|
__extends(Ellipse, _super);
|
|
13050
|
-
function Ellipse(
|
|
13051
|
-
if (
|
|
13052
|
-
|
|
13053
|
-
return _super.call(this, __assign({ type: Shape.ELLIPSE, style: runtime.enableCSSParsing
|
|
13054
|
-
? __assign({ cx: '', cy: '', rx: '', ry: '' }, style) : __assign({}, style), initialParsedStyle: {
|
|
13055
|
-
transformOrigin: runtime.enableCSSParsing
|
|
13056
|
-
? null
|
|
13057
|
-
: [PECENTAGE_50, PECENTAGE_50],
|
|
13058
|
-
} }, rest)) || this;
|
|
13022
|
+
function Ellipse(options) {
|
|
13023
|
+
if (options === void 0) { options = {}; }
|
|
13024
|
+
return _super.call(this, __assign({ type: Shape.ELLIPSE }, options)) || this;
|
|
13059
13025
|
}
|
|
13060
13026
|
return Ellipse;
|
|
13061
13027
|
}(DisplayObject));
|
|
@@ -13072,11 +13038,9 @@ var Ellipse = /** @class */ (function (_super) {
|
|
|
13072
13038
|
*/
|
|
13073
13039
|
var Group = /** @class */ (function (_super) {
|
|
13074
13040
|
__extends(Group, _super);
|
|
13075
|
-
function Group(
|
|
13076
|
-
if (
|
|
13077
|
-
|
|
13078
|
-
return _super.call(this, __assign({ type: Shape.GROUP, style: runtime.enableCSSParsing
|
|
13079
|
-
? __assign({ width: '', height: '' }, style) : __assign({}, style) }, rest)) || this;
|
|
13041
|
+
function Group(options) {
|
|
13042
|
+
if (options === void 0) { options = {}; }
|
|
13043
|
+
return _super.call(this, __assign({ type: Shape.GROUP }, options)) || this;
|
|
13080
13044
|
}
|
|
13081
13045
|
return Group;
|
|
13082
13046
|
}(DisplayObject));
|
|
@@ -13149,11 +13113,9 @@ var HTML = /** @class */ (function (_super) {
|
|
|
13149
13113
|
|
|
13150
13114
|
var Image = /** @class */ (function (_super) {
|
|
13151
13115
|
__extends(Image, _super);
|
|
13152
|
-
function Image(
|
|
13153
|
-
if (
|
|
13154
|
-
|
|
13155
|
-
return _super.call(this, __assign({ type: Shape.IMAGE, style: runtime.enableCSSParsing
|
|
13156
|
-
? __assign({ x: '', y: '', img: '', width: '', height: '' }, style) : __assign({}, style) }, rest)) || this;
|
|
13116
|
+
function Image(options) {
|
|
13117
|
+
if (options === void 0) { options = {}; }
|
|
13118
|
+
return _super.call(this, __assign({ type: Shape.IMAGE }, options)) || this;
|
|
13157
13119
|
}
|
|
13158
13120
|
return Image;
|
|
13159
13121
|
}(DisplayObject));
|
|
@@ -13282,11 +13244,11 @@ var Path = /** @class */ (function (_super) {
|
|
|
13282
13244
|
var _this = this;
|
|
13283
13245
|
var style = _a.style, rest = __rest(_a, ["style"]);
|
|
13284
13246
|
_this = _super.call(this, __assign({ type: Shape.PATH, style: runtime.enableCSSParsing
|
|
13285
|
-
? __assign({
|
|
13247
|
+
? __assign({ d: '', miterLimit: '' }, style) : __assign({}, style), initialParsedStyle: runtime.enableCSSParsing
|
|
13286
13248
|
? null
|
|
13287
13249
|
: {
|
|
13288
13250
|
miterLimit: 4,
|
|
13289
|
-
|
|
13251
|
+
d: __assign({}, EMPTY_PARSED_PATH),
|
|
13290
13252
|
} }, rest)) || this;
|
|
13291
13253
|
_this.markerStartAngle = 0;
|
|
13292
13254
|
_this.markerEndAngle = 0;
|
|
@@ -13311,7 +13273,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
13311
13273
|
return _this;
|
|
13312
13274
|
}
|
|
13313
13275
|
Path.prototype.attributeChangedCallback = function (attrName, oldValue, newValue, prevParsedValue, newParsedValue) {
|
|
13314
|
-
if (attrName === '
|
|
13276
|
+
if (attrName === 'd') {
|
|
13315
13277
|
// recalc markers
|
|
13316
13278
|
this.transformMarker(true);
|
|
13317
13279
|
this.transformMarker(false);
|
|
@@ -13386,7 +13348,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
13386
13348
|
marker.setLocalPosition(ox + Math.cos(rad) * offset, oy + Math.sin(rad) * offset);
|
|
13387
13349
|
};
|
|
13388
13350
|
Path.prototype.placeMarkerMid = function (marker) {
|
|
13389
|
-
var segments = this.parsedStyle.
|
|
13351
|
+
var segments = this.parsedStyle.d.segments;
|
|
13390
13352
|
// clear all existed markers
|
|
13391
13353
|
this.markerMidList.forEach(function (marker) {
|
|
13392
13354
|
marker.remove();
|
|
@@ -13415,7 +13377,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
13415
13377
|
*/
|
|
13416
13378
|
Path.prototype.getPointAtLength = function (distance, inWorldSpace) {
|
|
13417
13379
|
if (inWorldSpace === void 0) { inWorldSpace = false; }
|
|
13418
|
-
var absolutePath = this.parsedStyle.
|
|
13380
|
+
var absolutePath = this.parsedStyle.d.absolutePath;
|
|
13419
13381
|
var _a = getPointAtLength(absolutePath, distance), x = _a.x, y = _a.y;
|
|
13420
13382
|
var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
|
|
13421
13383
|
// apply local transformation
|
|
@@ -13432,7 +13394,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
13432
13394
|
* Get start tangent vector
|
|
13433
13395
|
*/
|
|
13434
13396
|
Path.prototype.getStartTangent = function () {
|
|
13435
|
-
var segments = this.parsedStyle.
|
|
13397
|
+
var segments = this.parsedStyle.d.segments;
|
|
13436
13398
|
var result = [];
|
|
13437
13399
|
if (segments.length > 1) {
|
|
13438
13400
|
var startPoint = segments[0].currentPoint;
|
|
@@ -13454,7 +13416,7 @@ var Path = /** @class */ (function (_super) {
|
|
|
13454
13416
|
* Get end tangent vector
|
|
13455
13417
|
*/
|
|
13456
13418
|
Path.prototype.getEndTangent = function () {
|
|
13457
|
-
var segments = this.parsedStyle.
|
|
13419
|
+
var segments = this.parsedStyle.d.segments;
|
|
13458
13420
|
var length = segments.length;
|
|
13459
13421
|
var result = [];
|
|
13460
13422
|
if (length > 1) {
|
|
@@ -13642,7 +13604,7 @@ var Polyline = /** @class */ (function (_super) {
|
|
|
13642
13604
|
} }, rest)) || this;
|
|
13643
13605
|
}
|
|
13644
13606
|
Polyline.prototype.getTotalLength = function () {
|
|
13645
|
-
return this
|
|
13607
|
+
return getOrCalculatePolylineTotalLength(this);
|
|
13646
13608
|
};
|
|
13647
13609
|
Polyline.prototype.getPointAtLength = function (distance, inWorldSpace) {
|
|
13648
13610
|
if (inWorldSpace === void 0) { inWorldSpace = false; }
|
|
@@ -13650,16 +13612,34 @@ var Polyline = /** @class */ (function (_super) {
|
|
|
13650
13612
|
};
|
|
13651
13613
|
Polyline.prototype.getPoint = function (ratio, inWorldSpace) {
|
|
13652
13614
|
if (inWorldSpace === void 0) { inWorldSpace = false; }
|
|
13653
|
-
var
|
|
13615
|
+
var points = this.parsedStyle.points.points;
|
|
13616
|
+
if (this.parsedStyle.points.segments.length === 0) {
|
|
13617
|
+
var segments_1 = [];
|
|
13618
|
+
var tempLength_1 = 0;
|
|
13619
|
+
var segmentT_1;
|
|
13620
|
+
var segmentL_1;
|
|
13621
|
+
var totalLength_1 = this.getTotalLength();
|
|
13622
|
+
points.forEach(function (p, i) {
|
|
13623
|
+
if (points[i + 1]) {
|
|
13624
|
+
segmentT_1 = [0, 0];
|
|
13625
|
+
segmentT_1[0] = tempLength_1 / totalLength_1;
|
|
13626
|
+
segmentL_1 = lineLength(p[0], p[1], points[i + 1][0], points[i + 1][1]);
|
|
13627
|
+
tempLength_1 += segmentL_1;
|
|
13628
|
+
segmentT_1[1] = tempLength_1 / totalLength_1;
|
|
13629
|
+
segments_1.push(segmentT_1);
|
|
13630
|
+
}
|
|
13631
|
+
});
|
|
13632
|
+
this.parsedStyle.points.segments = segments_1;
|
|
13633
|
+
}
|
|
13654
13634
|
var subt = 0;
|
|
13655
13635
|
var index = 0;
|
|
13656
|
-
segments.forEach(function (v, i) {
|
|
13636
|
+
this.parsedStyle.points.segments.forEach(function (v, i) {
|
|
13657
13637
|
if (ratio >= v[0] && ratio <= v[1]) {
|
|
13658
13638
|
subt = (ratio - v[0]) / (v[1] - v[0]);
|
|
13659
13639
|
index = i;
|
|
13660
13640
|
}
|
|
13661
13641
|
});
|
|
13662
|
-
var
|
|
13642
|
+
var _a = linePointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt), x = _a.x, y = _a.y;
|
|
13663
13643
|
var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x, y, 0), inWorldSpace ? this.getWorldTransform() : this.getLocalTransform());
|
|
13664
13644
|
// apply local transformation
|
|
13665
13645
|
return new Point(transformed[0], transformed[1]);
|
|
@@ -13684,11 +13664,9 @@ var Polyline = /** @class */ (function (_super) {
|
|
|
13684
13664
|
|
|
13685
13665
|
var Rect = /** @class */ (function (_super) {
|
|
13686
13666
|
__extends(Rect, _super);
|
|
13687
|
-
function Rect(
|
|
13688
|
-
if (
|
|
13689
|
-
|
|
13690
|
-
return _super.call(this, __assign({ type: Shape.RECT, style: runtime.enableCSSParsing
|
|
13691
|
-
? __assign({ x: '', y: '', width: '', height: '', radius: '' }, style) : __assign({}, style) }, rest)) || this;
|
|
13667
|
+
function Rect(options) {
|
|
13668
|
+
if (options === void 0) { options = {}; }
|
|
13669
|
+
return _super.call(this, __assign({ type: Shape.RECT }, options)) || this;
|
|
13692
13670
|
}
|
|
13693
13671
|
return Rect;
|
|
13694
13672
|
}(DisplayObject));
|
|
@@ -13710,26 +13688,7 @@ var Text = /** @class */ (function (_super) {
|
|
|
13710
13688
|
return _super.call(this, __assign({ type: Shape.TEXT, style: runtime.enableCSSParsing
|
|
13711
13689
|
? __assign({ x: '', y: '', text: '', fontSize: '', fontFamily: '', fontStyle: '', fontWeight: '', fontVariant: '', textAlign: '', textBaseline: '', textTransform: '', fill: 'black', letterSpacing: '', lineHeight: '', miterLimit: '',
|
|
13712
13690
|
// whiteSpace: 'pre',
|
|
13713
|
-
wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : __assign({ fill: 'black' }, style),
|
|
13714
|
-
? {}
|
|
13715
|
-
: {
|
|
13716
|
-
x: 0,
|
|
13717
|
-
y: 0,
|
|
13718
|
-
fontSize: 16,
|
|
13719
|
-
fontFamily: 'sans-serif',
|
|
13720
|
-
fontStyle: 'normal',
|
|
13721
|
-
fontWeight: 'normal',
|
|
13722
|
-
fontVariant: 'normal',
|
|
13723
|
-
lineHeight: 0,
|
|
13724
|
-
letterSpacing: 0,
|
|
13725
|
-
textBaseline: 'alphabetic',
|
|
13726
|
-
textAlign: 'start',
|
|
13727
|
-
wordWrap: false,
|
|
13728
|
-
wordWrapWidth: 0,
|
|
13729
|
-
leading: 0,
|
|
13730
|
-
dx: 0,
|
|
13731
|
-
dy: 0,
|
|
13732
|
-
} }, rest)) || this;
|
|
13691
|
+
wordWrap: false, wordWrapWidth: 0, leading: 0, dx: '', dy: '' }, style) : __assign({ fill: 'black' }, style) }, rest)) || this;
|
|
13733
13692
|
}
|
|
13734
13693
|
// lengthAdjust: SVGAnimatedEnumeration;
|
|
13735
13694
|
// textLength: SVGAnimatedLength;
|
|
@@ -13806,6 +13765,109 @@ var CustomElementRegistry = /** @class */ (function () {
|
|
|
13806
13765
|
return CustomElementRegistry;
|
|
13807
13766
|
}());
|
|
13808
13767
|
|
|
13768
|
+
/**
|
|
13769
|
+
* holds useful CSS-related methods.
|
|
13770
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS
|
|
13771
|
+
*
|
|
13772
|
+
* * CSS Typed OM @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/factory_functions
|
|
13773
|
+
* * register property @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty
|
|
13774
|
+
* * CSS Layout API
|
|
13775
|
+
*/
|
|
13776
|
+
var CSS = {
|
|
13777
|
+
/**
|
|
13778
|
+
* <number>
|
|
13779
|
+
* @see https://drafts.csswg.org/css-values-4/#number-value
|
|
13780
|
+
*/
|
|
13781
|
+
number: function (n) {
|
|
13782
|
+
return new CSSUnitValue(n);
|
|
13783
|
+
},
|
|
13784
|
+
/**
|
|
13785
|
+
* <percentage>
|
|
13786
|
+
* @see https://drafts.csswg.org/css-values-4/#percentage-value
|
|
13787
|
+
*/
|
|
13788
|
+
percent: function (n) {
|
|
13789
|
+
return new CSSUnitValue(n, '%');
|
|
13790
|
+
},
|
|
13791
|
+
/**
|
|
13792
|
+
* <length>
|
|
13793
|
+
*/
|
|
13794
|
+
px: function (n) {
|
|
13795
|
+
return new CSSUnitValue(n, 'px');
|
|
13796
|
+
},
|
|
13797
|
+
/**
|
|
13798
|
+
* <length>
|
|
13799
|
+
*/
|
|
13800
|
+
em: function (n) {
|
|
13801
|
+
return new CSSUnitValue(n, 'em');
|
|
13802
|
+
},
|
|
13803
|
+
rem: function (n) {
|
|
13804
|
+
return new CSSUnitValue(n, 'rem');
|
|
13805
|
+
},
|
|
13806
|
+
/**
|
|
13807
|
+
* <angle>
|
|
13808
|
+
*/
|
|
13809
|
+
deg: function (n) {
|
|
13810
|
+
return new CSSUnitValue(n, 'deg');
|
|
13811
|
+
},
|
|
13812
|
+
/**
|
|
13813
|
+
* <angle>
|
|
13814
|
+
*/
|
|
13815
|
+
grad: function (n) {
|
|
13816
|
+
return new CSSUnitValue(n, 'grad');
|
|
13817
|
+
},
|
|
13818
|
+
/**
|
|
13819
|
+
* <angle>
|
|
13820
|
+
*/
|
|
13821
|
+
rad: function (n) {
|
|
13822
|
+
return new CSSUnitValue(n, 'rad');
|
|
13823
|
+
},
|
|
13824
|
+
/**
|
|
13825
|
+
* <angle>
|
|
13826
|
+
*/
|
|
13827
|
+
turn: function (n) {
|
|
13828
|
+
return new CSSUnitValue(n, 'turn');
|
|
13829
|
+
},
|
|
13830
|
+
/**
|
|
13831
|
+
* <time>
|
|
13832
|
+
*/
|
|
13833
|
+
s: function (n) {
|
|
13834
|
+
return new CSSUnitValue(n, 's');
|
|
13835
|
+
},
|
|
13836
|
+
/**
|
|
13837
|
+
* <time>
|
|
13838
|
+
*/
|
|
13839
|
+
ms: function (n) {
|
|
13840
|
+
return new CSSUnitValue(n, 'ms');
|
|
13841
|
+
},
|
|
13842
|
+
/**
|
|
13843
|
+
* CSS Properties & Values API
|
|
13844
|
+
*
|
|
13845
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS_Properties_and_Values_API
|
|
13846
|
+
* @see https://drafts.css-houdini.org/css-properties-values-api/#registering-custom-properties
|
|
13847
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty
|
|
13848
|
+
*/
|
|
13849
|
+
registerProperty: function (definition) {
|
|
13850
|
+
var name = definition.name, inherits = definition.inherits, interpolable = definition.interpolable, initialValue = definition.initialValue, syntax = definition.syntax;
|
|
13851
|
+
runtime.styleValueRegistry.registerMetadata({
|
|
13852
|
+
n: name,
|
|
13853
|
+
inh: inherits,
|
|
13854
|
+
int: interpolable,
|
|
13855
|
+
d: initialValue,
|
|
13856
|
+
syntax: syntax,
|
|
13857
|
+
});
|
|
13858
|
+
},
|
|
13859
|
+
/**
|
|
13860
|
+
* CSS Layout API
|
|
13861
|
+
* register layout
|
|
13862
|
+
*
|
|
13863
|
+
* @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
|
|
13864
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
|
|
13865
|
+
*/
|
|
13866
|
+
registerLayout: function (name, clazz) {
|
|
13867
|
+
runtime.layoutRegistry.registerLayout(name, clazz);
|
|
13868
|
+
},
|
|
13869
|
+
};
|
|
13870
|
+
|
|
13809
13871
|
/**
|
|
13810
13872
|
* the entry of DOM tree
|
|
13811
13873
|
* Document -> Node -> EventTarget
|
|
@@ -13917,7 +13979,7 @@ var Document = /** @class */ (function (_super) {
|
|
|
13917
13979
|
var hitTestList = [];
|
|
13918
13980
|
rBushNodes.forEach(function (_a) {
|
|
13919
13981
|
var displayObject = _a.displayObject;
|
|
13920
|
-
var
|
|
13982
|
+
var _b = displayObject.parsedStyle.pointerEvents, pointerEvents = _b === void 0 ? 'auto' : _b;
|
|
13921
13983
|
// account for `visibility`
|
|
13922
13984
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events
|
|
13923
13985
|
var isVisibilityAffected = [
|
|
@@ -14646,11 +14708,13 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14646
14708
|
* sync to RBush later
|
|
14647
14709
|
*/
|
|
14648
14710
|
this.toSync = new Set();
|
|
14711
|
+
this.isFirstTimeRendering = true;
|
|
14712
|
+
this.syncing = false;
|
|
14713
|
+
this.isFirstTimeRenderingFinished = false;
|
|
14649
14714
|
}
|
|
14650
|
-
// private isFirstTimeRendering = true;
|
|
14651
|
-
// private syncing = false;
|
|
14652
14715
|
PrepareRendererPlugin.prototype.apply = function (context) {
|
|
14653
14716
|
var _this = this;
|
|
14717
|
+
var _a;
|
|
14654
14718
|
var renderingService = context.renderingService, renderingContext = context.renderingContext, rBushRoot = context.rBushRoot;
|
|
14655
14719
|
var canvas = renderingContext.root.ownerDocument.defaultView;
|
|
14656
14720
|
this.rBush = rBushRoot;
|
|
@@ -14709,26 +14773,28 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14709
14773
|
canvas.removeEventListener(ElementEvent.BOUNDS_CHANGED, handleBoundsChanged);
|
|
14710
14774
|
_this.toSync.clear();
|
|
14711
14775
|
});
|
|
14776
|
+
var ric = (_a = runtime.globalThis.requestIdleCallback) !== null && _a !== void 0 ? _a : raf.bind(runtime.globalThis);
|
|
14712
14777
|
renderingService.hooks.endFrame.tap(PrepareRendererPlugin.tag, function () {
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
|
|
14717
|
-
|
|
14718
|
-
|
|
14719
|
-
|
|
14720
|
-
|
|
14721
|
-
|
|
14722
|
-
|
|
14723
|
-
|
|
14724
|
-
// }
|
|
14778
|
+
if (_this.isFirstTimeRendering) {
|
|
14779
|
+
_this.isFirstTimeRendering = false;
|
|
14780
|
+
_this.syncing = true;
|
|
14781
|
+
ric(function () {
|
|
14782
|
+
_this.syncRTree(true);
|
|
14783
|
+
_this.isFirstTimeRenderingFinished = true;
|
|
14784
|
+
});
|
|
14785
|
+
}
|
|
14786
|
+
else {
|
|
14787
|
+
_this.syncRTree();
|
|
14788
|
+
}
|
|
14725
14789
|
});
|
|
14726
14790
|
};
|
|
14727
|
-
PrepareRendererPlugin.prototype.syncRTree = function () {
|
|
14728
|
-
// if (this.syncing) {
|
|
14729
|
-
// return;
|
|
14730
|
-
// }
|
|
14791
|
+
PrepareRendererPlugin.prototype.syncRTree = function (force) {
|
|
14731
14792
|
var _this = this;
|
|
14793
|
+
if (force === void 0) { force = false; }
|
|
14794
|
+
if (!force && (this.syncing || this.toSync.size === 0)) {
|
|
14795
|
+
return;
|
|
14796
|
+
}
|
|
14797
|
+
this.syncing = true;
|
|
14732
14798
|
// bounds changed, need re-inserting its children
|
|
14733
14799
|
var bulk = [];
|
|
14734
14800
|
Array.from(this.toSync)
|
|
@@ -14742,6 +14808,14 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14742
14808
|
}
|
|
14743
14809
|
var renderBounds = node.getRenderBounds();
|
|
14744
14810
|
if (renderBounds) {
|
|
14811
|
+
var renderable = node.renderable;
|
|
14812
|
+
if (force) {
|
|
14813
|
+
if (!renderable.dirtyRenderBounds) {
|
|
14814
|
+
renderable.dirtyRenderBounds = new AABB();
|
|
14815
|
+
}
|
|
14816
|
+
// save last dirty aabb
|
|
14817
|
+
renderable.dirtyRenderBounds.update(renderBounds.center, renderBounds.halfExtents);
|
|
14818
|
+
}
|
|
14745
14819
|
var _a = __read(renderBounds.getMin(), 2), minX = _a[0], minY = _a[1];
|
|
14746
14820
|
var _b = __read(renderBounds.getMax(), 2), maxX = _b[0], maxY = _b[1];
|
|
14747
14821
|
if (!rBushNode.aabb) {
|
|
@@ -14768,7 +14842,7 @@ var PrepareRendererPlugin = /** @class */ (function () {
|
|
|
14768
14842
|
this.rBush.load(bulk);
|
|
14769
14843
|
bulk.length = 0;
|
|
14770
14844
|
this.toSync.clear();
|
|
14771
|
-
|
|
14845
|
+
this.syncing = false;
|
|
14772
14846
|
};
|
|
14773
14847
|
PrepareRendererPlugin.tag = 'Prepare';
|
|
14774
14848
|
return PrepareRendererPlugin;
|
|
@@ -15275,5 +15349,5 @@ var Canvas = /** @class */ (function (_super) {
|
|
|
15275
15349
|
return Canvas;
|
|
15276
15350
|
}(EventTarget));
|
|
15277
15351
|
|
|
15278
|
-
export { AABB, AbstractRenderer, AbstractRendererPlugin, BUILT_IN_PROPERTIES, CSS, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSStyleValue, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasEvent, Circle, CircleUpdater, ClipSpaceNearZ, CustomElement, CustomElementRegistry, CustomEvent, DefaultSceneGraphSelector, DefaultSceneGraphService, DisplayObject, Document, ERROR_MSG_METHOD_NOT_IMPLEMENTED, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, Frustum, GradientType, Group, HTML, Image, Line, LineUpdater, Mask, MutationEvent, Node, OffscreenCanvasCreator, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertySyntax, RBush, Rect, RectUpdater, Rectangle, RenderReason, RenderingService, Shape, SortReason, Strategy, Text, TextService, TextUpdater, UnitType, computeLinearGradient, computeRadialGradient, convertToPath, createVec3, decompose, definedProps, deg2rad, deg2turn, findClosestClipPathTarget, fromRotationTranslationScale, getAngle, getEuler, getOrCalculatePathTotalLength, grad2deg, isBrowser, isCSSGradientValue, isCSSRGB, isCanvas, isDisplayObject, isFederatedEvent, isFillOrStrokeAffected, isPattern, mergeColors, parseColor, parseLength, parsePath, parseTransform, parsedTransformToMat4, propertyMetadataCache, rad2deg, resetEntityCounter, runtime, setDOMSize, translatePathToString, turn2deg };
|
|
15352
|
+
export { AABB, AbstractRenderer, AbstractRendererPlugin, BUILT_IN_PROPERTIES, CSS, CSSGradientValue, CSSKeywordValue, CSSRGB, CSSStyleValue, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasEvent, Circle, CircleUpdater, ClipSpaceNearZ, CustomElement, CustomElementRegistry, CustomEvent, DefaultSceneGraphSelector, DefaultSceneGraphService, DisplayObject, Document, ERROR_MSG_METHOD_NOT_IMPLEMENTED, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, Frustum, GradientType, Group, GroupUpdater, HTML, Image, Line, LineUpdater, Mask, MutationEvent, Node, OffscreenCanvasCreator, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertySyntax, RBush, Rect, RectUpdater, Rectangle, RenderReason, RenderingService, Shape, SortReason, Strategy, Text, TextService, TextUpdater, UnitType, computeLinearGradient, computeRadialGradient, convertToPath, createVec3, decompose, definedProps, deg2rad, deg2turn, findClosestClipPathTarget, fromRotationTranslationScale, getAngle, getEuler, getOrCalculatePathTotalLength, grad2deg, isBrowser, isCSSGradientValue, isCSSRGB, isCanvas, isDisplayObject, isFederatedEvent, isFillOrStrokeAffected, isPattern, mergeColors, parseColor, parseLength, parsePath, parseTransform, parsedTransformToMat4, propertyMetadataCache, rad2deg, resetEntityCounter, runtime, setDOMSize, translatePathToString, turn2deg };
|
|
15279
15353
|
//# sourceMappingURL=index.esm.js.map
|