@antv/g-lite 1.0.46 → 1.0.48
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 +0 -1
- package/dist/components/Geometry.d.ts.map +1 -1
- package/dist/css/CSSStyleValuePool.d.ts +1 -0
- package/dist/css/CSSStyleValuePool.d.ts.map +1 -1
- package/dist/css/StyleValueRegistry.d.ts +1 -1
- package/dist/css/StyleValueRegistry.d.ts.map +1 -1
- package/dist/css/interfaces.d.ts +0 -1
- package/dist/css/interfaces.d.ts.map +1 -1
- package/dist/css/parser/dimension.d.ts.map +1 -1
- package/dist/css/parser/points.d.ts +11 -0
- package/dist/css/parser/points.d.ts.map +1 -1
- package/dist/css/properties/CSSPropertyPoints.d.ts +2 -1
- package/dist/css/properties/CSSPropertyPoints.d.ts.map +1 -1
- package/dist/display-objects/DisplayObject.d.ts.map +1 -1
- package/dist/display-objects/Text.d.ts +0 -1
- package/dist/display-objects/Text.d.ts.map +1 -1
- package/dist/dom/Element.d.ts.map +1 -1
- package/dist/index.esm.js +778 -784
- package/dist/index.js +777 -783
- package/dist/index.umd.js +777 -783
- package/dist/index.umd.min.js +1 -1
- package/dist/plugins/EventPlugin.d.ts.map +1 -1
- package/dist/services/SceneGraphService.d.ts.map +1 -1
- package/dist/shapes/AABB.d.ts +0 -1
- package/dist/shapes/AABB.d.ts.map +1 -1
- package/dist/utils/text.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1623,6 +1623,7 @@ var getOrCreateUnitValue = function getOrCreateUnitValue(value, unitOrName) {
|
|
|
1623
1623
|
}
|
|
1624
1624
|
return new CSSUnitValue(value, unitOrName);
|
|
1625
1625
|
};
|
|
1626
|
+
var PECENTAGE_50 = new CSSUnitValue(50, '%');
|
|
1626
1627
|
|
|
1627
1628
|
var canvasMap = {};
|
|
1628
1629
|
var defaultCanvasIdCounter = 0;
|
|
@@ -1656,8 +1657,8 @@ function sortByZIndex(o1, o2) {
|
|
|
1656
1657
|
function findClosestClipPathTarget(object) {
|
|
1657
1658
|
var el = object;
|
|
1658
1659
|
do {
|
|
1659
|
-
var _el$
|
|
1660
|
-
var clipPath = (_el$
|
|
1660
|
+
var _el$parsedStyle;
|
|
1661
|
+
var clipPath = (_el$parsedStyle = el.parsedStyle) === null || _el$parsedStyle === void 0 ? void 0 : _el$parsedStyle.clipPath;
|
|
1661
1662
|
if (clipPath) return el;
|
|
1662
1663
|
el = el.parentElement;
|
|
1663
1664
|
} while (el !== null);
|
|
@@ -4164,8 +4165,7 @@ function toFontString(attributes) {
|
|
|
4164
4165
|
var fontSizeString = isNumber(fontSize) && fontSize + "px" || '16px';
|
|
4165
4166
|
// Clean-up fontFamily property by quoting each font name
|
|
4166
4167
|
// this will support font names with spaces
|
|
4167
|
-
|
|
4168
|
-
var fontFamilies = isString(fontFamily) ? fontFamily.split(',') : [fontFamily];
|
|
4168
|
+
var fontFamilies = fontFamily.split(',');
|
|
4169
4169
|
for (var i = fontFamilies.length - 1; i >= 0; i--) {
|
|
4170
4170
|
// Trim any extra white-space
|
|
4171
4171
|
var _fontFamily = fontFamilies[i].trim();
|
|
@@ -4574,699 +4574,281 @@ function mergeColors(left, right) {
|
|
|
4574
4574
|
}];
|
|
4575
4575
|
}
|
|
4576
4576
|
|
|
4577
|
+
function parseDimension(unitRegExp, string) {
|
|
4578
|
+
if (isNil(string)) {
|
|
4579
|
+
return getOrCreateUnitValue(0, 'px');
|
|
4580
|
+
}
|
|
4581
|
+
string = ("" + string).trim().toLowerCase();
|
|
4582
|
+
if (isFinite(Number(string))) {
|
|
4583
|
+
if ('px'.search(unitRegExp) >= 0) {
|
|
4584
|
+
return getOrCreateUnitValue(Number(string), 'px');
|
|
4585
|
+
} else if ('deg'.search(unitRegExp) >= 0) {
|
|
4586
|
+
return getOrCreateUnitValue(Number(string), 'deg');
|
|
4587
|
+
}
|
|
4588
|
+
}
|
|
4589
|
+
var matchedUnits = [];
|
|
4590
|
+
string = string.replace(unitRegExp, function (match) {
|
|
4591
|
+
matchedUnits.push(match);
|
|
4592
|
+
return 'U' + match;
|
|
4593
|
+
});
|
|
4594
|
+
var taggedUnitRegExp = 'U(' + unitRegExp.source + ')';
|
|
4595
|
+
return matchedUnits.map(function (unit) {
|
|
4596
|
+
return getOrCreateUnitValue(Number(string.replace(new RegExp('U' + unit, 'g'), '').replace(new RegExp(taggedUnitRegExp, 'g'), '*0')), unit);
|
|
4597
|
+
})[0];
|
|
4598
|
+
}
|
|
4577
4599
|
/**
|
|
4578
|
-
*
|
|
4579
|
-
*
|
|
4580
|
-
*
|
|
4600
|
+
* <length>
|
|
4601
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
|
|
4602
|
+
* length with only absolute unit, eg. 1px
|
|
4581
4603
|
*/
|
|
4582
|
-
var
|
|
4583
|
-
|
|
4584
|
-
|
|
4585
|
-
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
|
|
4604
|
+
var parseLength = memoize(function (css) {
|
|
4605
|
+
return parseDimension(new RegExp('px', 'g'), css);
|
|
4606
|
+
});
|
|
4607
|
+
/**
|
|
4608
|
+
* <percentage>
|
|
4609
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
|
|
4610
|
+
*/
|
|
4611
|
+
var parserPercentage = memoize(function (css) {
|
|
4612
|
+
return parseDimension(new RegExp('%', 'g'), css);
|
|
4613
|
+
});
|
|
4614
|
+
/**
|
|
4615
|
+
* length with absolute or relative unit,
|
|
4616
|
+
* eg. 1px, 0.7em, 50%, calc(100% - 200px);
|
|
4617
|
+
*
|
|
4618
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
|
|
4619
|
+
*/
|
|
4620
|
+
// export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
|
|
4621
|
+
// if (isNumber(css) || isFinite(Number(css))) {
|
|
4622
|
+
// return getOrCreateUnitValue(Number(css), 'px');
|
|
4623
|
+
// }
|
|
4624
|
+
// return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
|
|
4625
|
+
// });
|
|
4626
|
+
var parseLengthOrPercentage = function parseLengthOrPercentage(css) {
|
|
4627
|
+
if (isNumber(css) || isFinite(Number(css))) {
|
|
4628
|
+
// Number(css) is NaN
|
|
4629
|
+
return getOrCreateUnitValue(Number(css) || 0, 'px');
|
|
4630
|
+
// return Number(css);
|
|
4602
4631
|
}
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
}
|
|
4638
|
-
if (AABB.isEmpty(this)) {
|
|
4639
|
-
this.setMinMax(aabb.getMin(), aabb.getMax());
|
|
4640
|
-
return;
|
|
4641
|
-
}
|
|
4642
|
-
var tc = this.center;
|
|
4643
|
-
var tcx = tc[0];
|
|
4644
|
-
var tcy = tc[1];
|
|
4645
|
-
var tcz = tc[2];
|
|
4646
|
-
var th = this.halfExtents;
|
|
4647
|
-
var thx = th[0];
|
|
4648
|
-
var thy = th[1];
|
|
4649
|
-
var thz = th[2];
|
|
4650
|
-
var tminx = tcx - thx;
|
|
4651
|
-
var tmaxx = tcx + thx;
|
|
4652
|
-
var tminy = tcy - thy;
|
|
4653
|
-
var tmaxy = tcy + thy;
|
|
4654
|
-
var tminz = tcz - thz;
|
|
4655
|
-
var tmaxz = tcz + thz;
|
|
4656
|
-
var oc = aabb.center;
|
|
4657
|
-
var ocx = oc[0];
|
|
4658
|
-
var ocy = oc[1];
|
|
4659
|
-
var ocz = oc[2];
|
|
4660
|
-
var oh = aabb.halfExtents;
|
|
4661
|
-
var ohx = oh[0];
|
|
4662
|
-
var ohy = oh[1];
|
|
4663
|
-
var ohz = oh[2];
|
|
4664
|
-
var ominx = ocx - ohx;
|
|
4665
|
-
var omaxx = ocx + ohx;
|
|
4666
|
-
var ominy = ocy - ohy;
|
|
4667
|
-
var omaxy = ocy + ohy;
|
|
4668
|
-
var ominz = ocz - ohz;
|
|
4669
|
-
var omaxz = ocz + ohz;
|
|
4670
|
-
if (ominx < tminx) {
|
|
4671
|
-
tminx = ominx;
|
|
4672
|
-
}
|
|
4673
|
-
if (omaxx > tmaxx) {
|
|
4674
|
-
tmaxx = omaxx;
|
|
4675
|
-
}
|
|
4676
|
-
if (ominy < tminy) {
|
|
4677
|
-
tminy = ominy;
|
|
4632
|
+
|
|
4633
|
+
return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
|
|
4634
|
+
};
|
|
4635
|
+
var parseAngle = memoize(function (css) {
|
|
4636
|
+
return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
|
|
4637
|
+
});
|
|
4638
|
+
/**
|
|
4639
|
+
* merge CSSUnitValue
|
|
4640
|
+
*
|
|
4641
|
+
* @example
|
|
4642
|
+
* 10px + 20px = 30px
|
|
4643
|
+
* 10deg + 10rad
|
|
4644
|
+
* 10% + 20% = 30%
|
|
4645
|
+
*/
|
|
4646
|
+
function mergeDimensions(left, right, target, nonNegative, index) {
|
|
4647
|
+
if (index === void 0) {
|
|
4648
|
+
index = 0;
|
|
4649
|
+
}
|
|
4650
|
+
var unit = '';
|
|
4651
|
+
var leftValue = left.value || 0;
|
|
4652
|
+
var rightValue = right.value || 0;
|
|
4653
|
+
var canonicalUnit = toCanonicalUnit(left.unit);
|
|
4654
|
+
var leftCanonicalUnitValue = left.convertTo(canonicalUnit);
|
|
4655
|
+
var rightCanonicalUnitValue = right.convertTo(canonicalUnit);
|
|
4656
|
+
if (leftCanonicalUnitValue && rightCanonicalUnitValue) {
|
|
4657
|
+
leftValue = leftCanonicalUnitValue.value;
|
|
4658
|
+
rightValue = rightCanonicalUnitValue.value;
|
|
4659
|
+
unit = unitTypeToString(left.unit);
|
|
4660
|
+
} else {
|
|
4661
|
+
// format '%' to 'px'
|
|
4662
|
+
if (CSSUnitValue.isLength(left.unit) || CSSUnitValue.isLength(right.unit)) {
|
|
4663
|
+
leftValue = convertPercentUnit(left, index, target);
|
|
4664
|
+
rightValue = convertPercentUnit(right, index, target);
|
|
4665
|
+
unit = 'px';
|
|
4678
4666
|
}
|
|
4679
|
-
|
|
4680
|
-
|
|
4667
|
+
}
|
|
4668
|
+
// // format 'rad' 'turn' to 'deg'
|
|
4669
|
+
// if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
|
|
4670
|
+
// leftValue = convertAngleUnit(left);
|
|
4671
|
+
// rightValue = convertAngleUnit(right);
|
|
4672
|
+
// unit = 'deg';
|
|
4673
|
+
// }
|
|
4674
|
+
return [leftValue, rightValue, function (value) {
|
|
4675
|
+
if (nonNegative) {
|
|
4676
|
+
value = Math.max(value, 0);
|
|
4681
4677
|
}
|
|
4682
|
-
|
|
4683
|
-
|
|
4678
|
+
return value + unit;
|
|
4679
|
+
}];
|
|
4680
|
+
}
|
|
4681
|
+
function convertAngleUnit(value) {
|
|
4682
|
+
var deg = 0;
|
|
4683
|
+
if (value.unit === UnitType.kDegrees) {
|
|
4684
|
+
deg = value.value;
|
|
4685
|
+
} else if (value.unit === UnitType.kRadians) {
|
|
4686
|
+
deg = rad2deg(Number(value.value));
|
|
4687
|
+
} else if (value.unit === UnitType.kTurns) {
|
|
4688
|
+
deg = turn2deg(Number(value.value));
|
|
4689
|
+
}
|
|
4690
|
+
return deg;
|
|
4691
|
+
}
|
|
4692
|
+
function parseDimensionArrayFormat(string, size) {
|
|
4693
|
+
var parsed;
|
|
4694
|
+
if (Array.isArray(string)) {
|
|
4695
|
+
// [1, '2px', 3]
|
|
4696
|
+
parsed = string.map(function (segment) {
|
|
4697
|
+
return Number(segment);
|
|
4698
|
+
});
|
|
4699
|
+
} else if (isString(string)) {
|
|
4700
|
+
parsed = string.split(' ').map(function (segment) {
|
|
4701
|
+
return Number(segment);
|
|
4702
|
+
});
|
|
4703
|
+
} else if (isNumber(string)) {
|
|
4704
|
+
parsed = [string];
|
|
4705
|
+
}
|
|
4706
|
+
if (size === 2) {
|
|
4707
|
+
if (parsed.length === 1) {
|
|
4708
|
+
return [parsed[0], parsed[0]];
|
|
4709
|
+
} else {
|
|
4710
|
+
return [parsed[0], parsed[1]];
|
|
4684
4711
|
}
|
|
4685
|
-
|
|
4686
|
-
|
|
4712
|
+
} else {
|
|
4713
|
+
if (parsed.length === 1) {
|
|
4714
|
+
return [parsed[0], parsed[0], parsed[0], parsed[0]];
|
|
4715
|
+
} else if (parsed.length === 2) {
|
|
4716
|
+
return [parsed[0], parsed[1], parsed[0], parsed[1]];
|
|
4717
|
+
} else if (parsed.length === 3) {
|
|
4718
|
+
return [parsed[0], parsed[1], parsed[2], parsed[1]];
|
|
4719
|
+
} else {
|
|
4720
|
+
return [parsed[0], parsed[1], parsed[2], parsed[3]];
|
|
4687
4721
|
}
|
|
4688
|
-
tc[0] = (tminx + tmaxx) * 0.5;
|
|
4689
|
-
tc[1] = (tminy + tmaxy) * 0.5;
|
|
4690
|
-
tc[2] = (tminz + tmaxz) * 0.5;
|
|
4691
|
-
th[0] = (tmaxx - tminx) * 0.5;
|
|
4692
|
-
th[1] = (tmaxy - tminy) * 0.5;
|
|
4693
|
-
th[2] = (tmaxz - tminz) * 0.5;
|
|
4694
|
-
this.min[0] = tminx;
|
|
4695
|
-
this.min[1] = tminy;
|
|
4696
|
-
this.min[2] = tminz;
|
|
4697
|
-
this.max[0] = tmaxx;
|
|
4698
|
-
this.max[1] = tmaxy;
|
|
4699
|
-
this.max[2] = tmaxz;
|
|
4700
|
-
};
|
|
4701
|
-
_proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
|
|
4702
|
-
var bc = this.center;
|
|
4703
|
-
var br = this.halfExtents;
|
|
4704
|
-
var ac = aabb.center;
|
|
4705
|
-
var ar = aabb.halfExtents;
|
|
4706
|
-
var mx0 = m[0];
|
|
4707
|
-
var mx1 = m[4];
|
|
4708
|
-
var mx2 = m[8];
|
|
4709
|
-
var my0 = m[1];
|
|
4710
|
-
var my1 = m[5];
|
|
4711
|
-
var my2 = m[9];
|
|
4712
|
-
var mz0 = m[2];
|
|
4713
|
-
var mz1 = m[6];
|
|
4714
|
-
var mz2 = m[10];
|
|
4715
|
-
var mx0a = Math.abs(mx0);
|
|
4716
|
-
var mx1a = Math.abs(mx1);
|
|
4717
|
-
var mx2a = Math.abs(mx2);
|
|
4718
|
-
var my0a = Math.abs(my0);
|
|
4719
|
-
var my1a = Math.abs(my1);
|
|
4720
|
-
var my2a = Math.abs(my2);
|
|
4721
|
-
var mz0a = Math.abs(mz0);
|
|
4722
|
-
var mz1a = Math.abs(mz1);
|
|
4723
|
-
var mz2a = Math.abs(mz2);
|
|
4724
|
-
bc[0] = m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2];
|
|
4725
|
-
bc[1] = m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2];
|
|
4726
|
-
bc[2] = m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2];
|
|
4727
|
-
// vec3.set(
|
|
4728
|
-
// bc,
|
|
4729
|
-
// m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
|
|
4730
|
-
// m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
|
|
4731
|
-
// m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
|
|
4732
|
-
// );
|
|
4733
|
-
br[0] = mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2];
|
|
4734
|
-
br[1] = my0a * ar[0] + my1a * ar[1] + my2a * ar[2];
|
|
4735
|
-
br[2] = mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2];
|
|
4736
|
-
// vec3.set(
|
|
4737
|
-
// br,
|
|
4738
|
-
// mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
|
|
4739
|
-
// my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
|
|
4740
|
-
// mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
|
|
4741
|
-
// );
|
|
4742
|
-
// this.min = vec3.sub(this.min, bc, br);
|
|
4743
|
-
// this.max = vec3.add(this.max, bc, br);
|
|
4744
|
-
subVec3(this.min, bc, br);
|
|
4745
|
-
addVec3(this.max, bc, br);
|
|
4746
|
-
};
|
|
4747
|
-
_proto.intersects = function intersects(aabb) {
|
|
4748
|
-
var aMax = this.getMax();
|
|
4749
|
-
var aMin = this.getMin();
|
|
4750
|
-
var bMax = aabb.getMax();
|
|
4751
|
-
var bMin = aabb.getMin();
|
|
4752
|
-
return aMin[0] <= bMax[0] && aMax[0] >= bMin[0] && aMin[1] <= bMax[1] && aMax[1] >= bMin[1] && aMin[2] <= bMax[2] && aMax[2] >= bMin[2];
|
|
4753
|
-
};
|
|
4754
|
-
_proto.intersection = function intersection(aabb) {
|
|
4755
|
-
if (!this.intersects(aabb)) {
|
|
4756
|
-
return null;
|
|
4757
|
-
}
|
|
4758
|
-
var intersection = new AABB();
|
|
4759
|
-
// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
|
|
4760
|
-
// const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
|
|
4761
|
-
var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
|
|
4762
|
-
var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
|
|
4763
|
-
intersection.setMinMax(min, max);
|
|
4764
|
-
return intersection;
|
|
4765
4722
|
}
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
/**
|
|
4779
|
-
* get n-vertex
|
|
4780
|
-
* @param plane plane of CullingVolume
|
|
4781
|
-
*/;
|
|
4782
|
-
_proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
|
|
4783
|
-
if (plane.pnVertexFlag === 0x111) {
|
|
4784
|
-
return copyVec3([0, 0, 0], this.min);
|
|
4785
|
-
// return vec3.copy(vec3.create(), this.min);
|
|
4786
|
-
} else if (plane.pnVertexFlag === 0x110) {
|
|
4787
|
-
return [this.min[0], this.min[1], this.max[2]];
|
|
4788
|
-
// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
4789
|
-
} else if (plane.pnVertexFlag === 0x101) {
|
|
4790
|
-
return [this.min[0], this.max[1], this.min[2]];
|
|
4791
|
-
// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
4792
|
-
} else if (plane.pnVertexFlag === 0x100) {
|
|
4793
|
-
return [this.min[0], this.max[1], this.max[2]];
|
|
4794
|
-
// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
4795
|
-
} else if (plane.pnVertexFlag === 0x011) {
|
|
4796
|
-
return [this.max[0], this.min[1], this.min[2]];
|
|
4797
|
-
// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
4798
|
-
} else if (plane.pnVertexFlag === 0x010) {
|
|
4799
|
-
return [this.max[0], this.min[1], this.max[2]];
|
|
4800
|
-
// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
4801
|
-
} else if (plane.pnVertexFlag === 0x001) {
|
|
4802
|
-
return [this.max[0], this.max[1], this.min[2]];
|
|
4803
|
-
// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
4804
|
-
} else {
|
|
4805
|
-
return [this.max[0], this.max[1], this.max[2]];
|
|
4806
|
-
// return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
|
|
4807
|
-
}
|
|
4723
|
+
}
|
|
4724
|
+
function parseDimensionArray(string) {
|
|
4725
|
+
if (isString(string)) {
|
|
4726
|
+
// "1px 2px 3px"
|
|
4727
|
+
return string.split(' ').map(function (segment) {
|
|
4728
|
+
return parseLengthOrPercentage(segment);
|
|
4729
|
+
});
|
|
4730
|
+
} else {
|
|
4731
|
+
// [1, '2px', 3]
|
|
4732
|
+
return string.map(function (segment) {
|
|
4733
|
+
return parseLengthOrPercentage(segment.toString());
|
|
4734
|
+
});
|
|
4808
4735
|
}
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
|
|
4830
|
-
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
4834
|
-
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
}();
|
|
4842
|
-
|
|
4843
|
-
var Plane = /*#__PURE__*/function () {
|
|
4844
|
-
/**
|
|
4845
|
-
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
4846
|
-
*/
|
|
4736
|
+
}
|
|
4737
|
+
// export function mergeDimensionList(
|
|
4738
|
+
// left: CSSUnitValue[],
|
|
4739
|
+
// right: CSSUnitValue[],
|
|
4740
|
+
// target: IElement | null,
|
|
4741
|
+
// ): [number[], number[], (list: number[]) => string] | undefined {
|
|
4742
|
+
// if (left.length !== right.length) {
|
|
4743
|
+
// return;
|
|
4744
|
+
// }
|
|
4745
|
+
// const unit = left[0].unit;
|
|
4746
|
+
// return [
|
|
4747
|
+
// left.map((l) => l.value),
|
|
4748
|
+
// right.map((l) => l.value),
|
|
4749
|
+
// (values: number[]) => {
|
|
4750
|
+
// return values.map((n) => new CSSUnitValue(n, unit)).join(' ');
|
|
4751
|
+
// },
|
|
4752
|
+
// ];
|
|
4753
|
+
// }
|
|
4754
|
+
function convertPercentUnit(valueWithUnit, vec3Index, target) {
|
|
4755
|
+
if (valueWithUnit.value === 0) {
|
|
4756
|
+
return 0;
|
|
4757
|
+
}
|
|
4758
|
+
if (valueWithUnit.unit === UnitType.kPixels) {
|
|
4759
|
+
return Number(valueWithUnit.value);
|
|
4760
|
+
} else if (valueWithUnit.unit === UnitType.kPercentage && target) {
|
|
4761
|
+
var bounds = target.nodeName === Shape.GROUP ? target.getLocalBounds() :
|
|
4762
|
+
// : target.getGeometryBounds();
|
|
4763
|
+
target.geometry.contentBounds;
|
|
4764
|
+
return valueWithUnit.value / 100 * bounds.halfExtents[vec3Index] * 2;
|
|
4765
|
+
}
|
|
4766
|
+
return 0;
|
|
4767
|
+
}
|
|
4847
4768
|
|
|
4848
|
-
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4769
|
+
var parseParam = function parseParam(css) {
|
|
4770
|
+
return parseDimension(/deg|rad|grad|turn|px|%/g, css);
|
|
4771
|
+
};
|
|
4772
|
+
var supportedFilters = ['blur', 'brightness', 'drop-shadow', 'contrast', 'grayscale', 'sepia', 'saturate', 'hue-rotate', 'invert'];
|
|
4773
|
+
function parseFilter(filterStr) {
|
|
4774
|
+
if (filterStr === void 0) {
|
|
4775
|
+
filterStr = '';
|
|
4855
4776
|
}
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
}
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4864
|
-
|
|
4865
|
-
|
|
4866
|
-
|
|
4867
|
-
};
|
|
4868
|
-
_proto.intersectsLine = function intersectsLine(start, end, point) {
|
|
4869
|
-
var d0 = this.distanceToPoint(start);
|
|
4870
|
-
var d1 = this.distanceToPoint(end);
|
|
4871
|
-
var t = d0 / (d0 - d1);
|
|
4872
|
-
var intersects = t >= 0 && t <= 1;
|
|
4873
|
-
if (intersects && point) {
|
|
4874
|
-
vec3.lerp(point, start, end, t);
|
|
4777
|
+
filterStr = filterStr.toLowerCase().trim();
|
|
4778
|
+
if (filterStr === 'none') {
|
|
4779
|
+
return [];
|
|
4780
|
+
}
|
|
4781
|
+
var filterRegExp = /\s*([\w-]+)\(([^)]*)\)/g;
|
|
4782
|
+
var result = [];
|
|
4783
|
+
var match;
|
|
4784
|
+
var prevLastIndex = 0;
|
|
4785
|
+
while (match = filterRegExp.exec(filterStr)) {
|
|
4786
|
+
if (match.index !== prevLastIndex) {
|
|
4787
|
+
return [];
|
|
4875
4788
|
}
|
|
4876
|
-
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
|
|
4880
|
-
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
var Frustum = /*#__PURE__*/function () {
|
|
4888
|
-
function Frustum(planes) {
|
|
4889
|
-
this.planes = [];
|
|
4890
|
-
if (planes) {
|
|
4891
|
-
this.planes = planes;
|
|
4892
|
-
} else {
|
|
4893
|
-
for (var i = 0; i < 6; i++) {
|
|
4894
|
-
this.planes.push(new Plane());
|
|
4895
|
-
}
|
|
4789
|
+
prevLastIndex = match.index + match[0].length;
|
|
4790
|
+
if (supportedFilters.indexOf(match[1]) > -1) {
|
|
4791
|
+
result.push({
|
|
4792
|
+
name: match[1],
|
|
4793
|
+
params: match[2].split(' ').map(function (p) {
|
|
4794
|
+
return parseParam(p) || parseColor(p);
|
|
4795
|
+
})
|
|
4796
|
+
});
|
|
4797
|
+
}
|
|
4798
|
+
if (filterRegExp.lastIndex === filterStr.length) {
|
|
4799
|
+
return result;
|
|
4896
4800
|
}
|
|
4897
4801
|
}
|
|
4898
|
-
|
|
4899
|
-
|
|
4900
|
-
* @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
|
|
4901
|
-
*/
|
|
4902
|
-
var _proto = Frustum.prototype;
|
|
4903
|
-
_proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
|
|
4904
|
-
// @ts-ignore
|
|
4905
|
-
var m0 = projectionMatrix[0],
|
|
4906
|
-
m1 = projectionMatrix[1],
|
|
4907
|
-
m2 = projectionMatrix[2],
|
|
4908
|
-
m3 = projectionMatrix[3],
|
|
4909
|
-
m4 = projectionMatrix[4],
|
|
4910
|
-
m5 = projectionMatrix[5],
|
|
4911
|
-
m6 = projectionMatrix[6],
|
|
4912
|
-
m7 = projectionMatrix[7],
|
|
4913
|
-
m8 = projectionMatrix[8],
|
|
4914
|
-
m9 = projectionMatrix[9],
|
|
4915
|
-
m10 = projectionMatrix[10],
|
|
4916
|
-
m11 = projectionMatrix[11],
|
|
4917
|
-
m12 = projectionMatrix[12],
|
|
4918
|
-
m13 = projectionMatrix[13],
|
|
4919
|
-
m14 = projectionMatrix[14],
|
|
4920
|
-
m15 = projectionMatrix[15];
|
|
4921
|
-
// right
|
|
4922
|
-
vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
|
|
4923
|
-
this.planes[0].distance = m15 - m12;
|
|
4924
|
-
// left
|
|
4925
|
-
vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
|
|
4926
|
-
this.planes[1].distance = m15 + m12;
|
|
4927
|
-
// bottom
|
|
4928
|
-
vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
|
|
4929
|
-
this.planes[2].distance = m15 + m13;
|
|
4930
|
-
// top
|
|
4931
|
-
vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
|
|
4932
|
-
this.planes[3].distance = m15 - m13;
|
|
4933
|
-
// far
|
|
4934
|
-
vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
|
|
4935
|
-
this.planes[4].distance = m15 - m14;
|
|
4936
|
-
// near
|
|
4937
|
-
vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
|
|
4938
|
-
this.planes[5].distance = m15 + m14;
|
|
4939
|
-
this.planes.forEach(function (plane) {
|
|
4940
|
-
plane.normalize();
|
|
4941
|
-
plane.updatePNVertexFlag();
|
|
4942
|
-
});
|
|
4943
|
-
};
|
|
4944
|
-
return Frustum;
|
|
4945
|
-
}();
|
|
4946
|
-
|
|
4947
|
-
var Point = /*#__PURE__*/function () {
|
|
4948
|
-
function Point(x, y) {
|
|
4949
|
-
if (x === void 0) {
|
|
4950
|
-
x = 0;
|
|
4951
|
-
}
|
|
4952
|
-
if (y === void 0) {
|
|
4953
|
-
y = 0;
|
|
4954
|
-
}
|
|
4955
|
-
this.x = 0;
|
|
4956
|
-
this.y = 0;
|
|
4957
|
-
this.x = x;
|
|
4958
|
-
this.y = y;
|
|
4959
|
-
}
|
|
4960
|
-
var _proto = Point.prototype;
|
|
4961
|
-
_proto.clone = function clone() {
|
|
4962
|
-
return new Point(this.x, this.y);
|
|
4963
|
-
};
|
|
4964
|
-
_proto.copyFrom = function copyFrom(p) {
|
|
4965
|
-
this.x = p.x;
|
|
4966
|
-
this.y = p.y;
|
|
4967
|
-
};
|
|
4968
|
-
return Point;
|
|
4969
|
-
}();
|
|
4970
|
-
|
|
4971
|
-
var Rectangle = /*#__PURE__*/function () {
|
|
4972
|
-
function Rectangle(x, y, width, height) {
|
|
4973
|
-
this.x = void 0;
|
|
4974
|
-
this.y = void 0;
|
|
4975
|
-
this.width = void 0;
|
|
4976
|
-
this.height = void 0;
|
|
4977
|
-
this.left = void 0;
|
|
4978
|
-
this.right = void 0;
|
|
4979
|
-
this.top = void 0;
|
|
4980
|
-
this.bottom = void 0;
|
|
4981
|
-
this.x = x;
|
|
4982
|
-
this.y = y;
|
|
4983
|
-
this.width = width;
|
|
4984
|
-
this.height = height;
|
|
4985
|
-
this.left = x;
|
|
4986
|
-
this.right = x + width;
|
|
4987
|
-
this.top = y;
|
|
4988
|
-
this.bottom = y + height;
|
|
4989
|
-
}
|
|
4990
|
-
var _proto = Rectangle.prototype;
|
|
4991
|
-
_proto.toJSON = function toJSON() {};
|
|
4992
|
-
return Rectangle;
|
|
4993
|
-
}();
|
|
4802
|
+
return [];
|
|
4803
|
+
}
|
|
4994
4804
|
|
|
4995
|
-
function
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
string = ("" + string).trim().toLowerCase();
|
|
5000
|
-
if (isFinite(Number(string))) {
|
|
5001
|
-
if ('px'.search(unitRegExp) >= 0) {
|
|
5002
|
-
return getOrCreateUnitValue(Number(string), 'px');
|
|
5003
|
-
} else if ('deg'.search(unitRegExp) >= 0) {
|
|
5004
|
-
return getOrCreateUnitValue(Number(string), 'deg');
|
|
5005
|
-
}
|
|
5006
|
-
}
|
|
5007
|
-
var matchedUnits = [];
|
|
5008
|
-
string = string.replace(unitRegExp, function (match) {
|
|
5009
|
-
matchedUnits.push(match);
|
|
5010
|
-
return 'U' + match;
|
|
5011
|
-
});
|
|
5012
|
-
var taggedUnitRegExp = 'U(' + unitRegExp.source + ')';
|
|
5013
|
-
return matchedUnits.map(function (unit) {
|
|
5014
|
-
return getOrCreateUnitValue(Number(string.replace(new RegExp('U' + unit, 'g'), '').replace(new RegExp(taggedUnitRegExp, 'g'), '*0')), unit);
|
|
5015
|
-
})[0];
|
|
4805
|
+
function numberToString(x) {
|
|
4806
|
+
// scale(0.00000001) -> scale(0)
|
|
4807
|
+
// return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
|
|
4808
|
+
return x.toString();
|
|
5016
4809
|
}
|
|
5017
4810
|
/**
|
|
5018
|
-
*
|
|
5019
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
|
|
5020
|
-
* length with only absolute unit, eg. 1px
|
|
5021
|
-
*/
|
|
5022
|
-
var parseLength = memoize(function (css) {
|
|
5023
|
-
return parseDimension(new RegExp('px', 'g'), css);
|
|
5024
|
-
});
|
|
5025
|
-
/**
|
|
5026
|
-
* <percentage>
|
|
5027
|
-
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
|
|
5028
|
-
*/
|
|
5029
|
-
var parserPercentage = memoize(function (css) {
|
|
5030
|
-
return parseDimension(new RegExp('%', 'g'), css);
|
|
5031
|
-
});
|
|
5032
|
-
/**
|
|
5033
|
-
* length with absolute or relative unit,
|
|
5034
|
-
* eg. 1px, 0.7em, 50%, calc(100% - 200px);
|
|
4811
|
+
* parse string or number to CSSUnitValue(numeric)
|
|
5035
4812
|
*
|
|
5036
|
-
*
|
|
4813
|
+
* eg.
|
|
4814
|
+
* * 0 -> CSSUnitValue(0)
|
|
4815
|
+
* * '2' -> CSSUnitValue(2)
|
|
5037
4816
|
*/
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
return getOrCreateUnitValue(Number(css), 'px');
|
|
5047
|
-
// return Number(css);
|
|
4817
|
+
var parseNumber = memoize(function (string) {
|
|
4818
|
+
if (typeof string === 'number') {
|
|
4819
|
+
return getOrCreateUnitValue(string);
|
|
4820
|
+
}
|
|
4821
|
+
if (/^\s*[-+]?(\d*\.)?\d+\s*$/.test(string)) {
|
|
4822
|
+
return getOrCreateUnitValue(Number(string));
|
|
4823
|
+
} else {
|
|
4824
|
+
return getOrCreateUnitValue(0);
|
|
5048
4825
|
}
|
|
5049
|
-
|
|
5050
|
-
return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
|
|
5051
|
-
};
|
|
5052
|
-
var parseAngle = memoize(function (css) {
|
|
5053
|
-
return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
|
|
5054
4826
|
});
|
|
5055
4827
|
/**
|
|
5056
|
-
*
|
|
5057
|
-
*
|
|
5058
|
-
*
|
|
5059
|
-
* 10px + 20px = 30px
|
|
5060
|
-
* 10deg + 10rad
|
|
5061
|
-
* 10% + 20% = 30%
|
|
4828
|
+
* separate string to array
|
|
4829
|
+
* eg.
|
|
4830
|
+
* * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
|
|
5062
4831
|
*/
|
|
5063
|
-
|
|
5064
|
-
if (
|
|
5065
|
-
|
|
5066
|
-
}
|
|
5067
|
-
var unit = '';
|
|
5068
|
-
var leftValue = left.value || 0;
|
|
5069
|
-
var rightValue = right.value || 0;
|
|
5070
|
-
var canonicalUnit = toCanonicalUnit(left.unit);
|
|
5071
|
-
var leftCanonicalUnitValue = left.convertTo(canonicalUnit);
|
|
5072
|
-
var rightCanonicalUnitValue = right.convertTo(canonicalUnit);
|
|
5073
|
-
if (leftCanonicalUnitValue && rightCanonicalUnitValue) {
|
|
5074
|
-
leftValue = leftCanonicalUnitValue.value;
|
|
5075
|
-
rightValue = rightCanonicalUnitValue.value;
|
|
5076
|
-
unit = unitTypeToString(left.unit);
|
|
4832
|
+
var parseNumberList = memoize(function (string) {
|
|
4833
|
+
if (isString(string)) {
|
|
4834
|
+
return string.split(' ').map(parseNumber);
|
|
5077
4835
|
} else {
|
|
5078
|
-
|
|
5079
|
-
if (CSSUnitValue.isLength(left.unit) || CSSUnitValue.isLength(right.unit)) {
|
|
5080
|
-
leftValue = convertPercentUnit(left, index, target);
|
|
5081
|
-
rightValue = convertPercentUnit(right, index, target);
|
|
5082
|
-
unit = 'px';
|
|
5083
|
-
}
|
|
4836
|
+
return string.map(parseNumber);
|
|
5084
4837
|
}
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
// rightValue = convertAngleUnit(right);
|
|
5089
|
-
// unit = 'deg';
|
|
5090
|
-
// }
|
|
5091
|
-
return [leftValue, rightValue, function (value) {
|
|
5092
|
-
if (nonNegative) {
|
|
5093
|
-
value = Math.max(value, 0);
|
|
5094
|
-
}
|
|
5095
|
-
return value + unit;
|
|
5096
|
-
}];
|
|
4838
|
+
});
|
|
4839
|
+
function mergeNumbers(left, right) {
|
|
4840
|
+
return [left, right, numberToString];
|
|
5097
4841
|
}
|
|
5098
|
-
function
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
} else if (value.unit === UnitType.kTurns) {
|
|
5105
|
-
deg = turn2deg(Number(value.value));
|
|
5106
|
-
}
|
|
5107
|
-
return deg;
|
|
4842
|
+
function clampedMergeNumbers(min, max) {
|
|
4843
|
+
return function (left, right) {
|
|
4844
|
+
return [left, right, function (x) {
|
|
4845
|
+
return numberToString(clamp(x, min, max));
|
|
4846
|
+
}];
|
|
4847
|
+
};
|
|
5108
4848
|
}
|
|
5109
|
-
function
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
// [1, '2px', 3]
|
|
5113
|
-
parsed = string.map(function (segment) {
|
|
5114
|
-
return Number(segment);
|
|
5115
|
-
});
|
|
5116
|
-
} else if (isString(string)) {
|
|
5117
|
-
parsed = string.split(' ').map(function (segment) {
|
|
5118
|
-
return Number(segment);
|
|
5119
|
-
});
|
|
5120
|
-
} else if (isNumber(string)) {
|
|
5121
|
-
parsed = [string];
|
|
5122
|
-
}
|
|
5123
|
-
if (size === 2) {
|
|
5124
|
-
if (parsed.length === 1) {
|
|
5125
|
-
return [parsed[0], parsed[0]];
|
|
5126
|
-
} else {
|
|
5127
|
-
return [parsed[0], parsed[1]];
|
|
5128
|
-
}
|
|
5129
|
-
} else {
|
|
5130
|
-
if (parsed.length === 1) {
|
|
5131
|
-
return [parsed[0], parsed[0], parsed[0], parsed[0]];
|
|
5132
|
-
} else if (parsed.length === 2) {
|
|
5133
|
-
return [parsed[0], parsed[1], parsed[0], parsed[1]];
|
|
5134
|
-
} else if (parsed.length === 3) {
|
|
5135
|
-
return [parsed[0], parsed[1], parsed[2], parsed[1]];
|
|
5136
|
-
} else {
|
|
5137
|
-
return [parsed[0], parsed[1], parsed[2], parsed[3]];
|
|
5138
|
-
}
|
|
5139
|
-
}
|
|
5140
|
-
}
|
|
5141
|
-
function parseDimensionArray(string) {
|
|
5142
|
-
if (isString(string)) {
|
|
5143
|
-
// "1px 2px 3px"
|
|
5144
|
-
return string.split(' ').map(function (segment) {
|
|
5145
|
-
return parseLengthOrPercentage(segment);
|
|
5146
|
-
});
|
|
5147
|
-
} else {
|
|
5148
|
-
// [1, '2px', 3]
|
|
5149
|
-
return string.map(function (segment) {
|
|
5150
|
-
return parseLengthOrPercentage(segment.toString());
|
|
5151
|
-
});
|
|
5152
|
-
}
|
|
5153
|
-
}
|
|
5154
|
-
// export function mergeDimensionList(
|
|
5155
|
-
// left: CSSUnitValue[],
|
|
5156
|
-
// right: CSSUnitValue[],
|
|
5157
|
-
// target: IElement | null,
|
|
5158
|
-
// ): [number[], number[], (list: number[]) => string] | undefined {
|
|
5159
|
-
// if (left.length !== right.length) {
|
|
5160
|
-
// return;
|
|
5161
|
-
// }
|
|
5162
|
-
// const unit = left[0].unit;
|
|
5163
|
-
// return [
|
|
5164
|
-
// left.map((l) => l.value),
|
|
5165
|
-
// right.map((l) => l.value),
|
|
5166
|
-
// (values: number[]) => {
|
|
5167
|
-
// return values.map((n) => new CSSUnitValue(n, unit)).join(' ');
|
|
5168
|
-
// },
|
|
5169
|
-
// ];
|
|
5170
|
-
// }
|
|
5171
|
-
function convertPercentUnit(valueWithUnit, vec3Index, target) {
|
|
5172
|
-
if (valueWithUnit.unit === UnitType.kPixels) {
|
|
5173
|
-
return Number(valueWithUnit.value);
|
|
5174
|
-
} else if (valueWithUnit.unit === UnitType.kPercentage && target) {
|
|
5175
|
-
var bounds = target.nodeName === Shape.GROUP ? target.getLocalBounds() :
|
|
5176
|
-
// : target.getGeometryBounds();
|
|
5177
|
-
target.geometry.contentBounds;
|
|
5178
|
-
var size = 0;
|
|
5179
|
-
if (!AABB.isEmpty(bounds)) {
|
|
5180
|
-
size = bounds.halfExtents[vec3Index] * 2;
|
|
5181
|
-
}
|
|
5182
|
-
return Number(valueWithUnit.value) / 100 * size;
|
|
5183
|
-
}
|
|
5184
|
-
return 0;
|
|
5185
|
-
}
|
|
5186
|
-
|
|
5187
|
-
var parseParam = function parseParam(css) {
|
|
5188
|
-
return parseDimension(/deg|rad|grad|turn|px|%/g, css);
|
|
5189
|
-
};
|
|
5190
|
-
var supportedFilters = ['blur', 'brightness', 'drop-shadow', 'contrast', 'grayscale', 'sepia', 'saturate', 'hue-rotate', 'invert'];
|
|
5191
|
-
function parseFilter(filterStr) {
|
|
5192
|
-
if (filterStr === void 0) {
|
|
5193
|
-
filterStr = '';
|
|
5194
|
-
}
|
|
5195
|
-
filterStr = filterStr.toLowerCase().trim();
|
|
5196
|
-
if (filterStr === 'none') {
|
|
5197
|
-
return [];
|
|
5198
|
-
}
|
|
5199
|
-
var filterRegExp = /\s*([\w-]+)\(([^)]*)\)/g;
|
|
5200
|
-
var result = [];
|
|
5201
|
-
var match;
|
|
5202
|
-
var prevLastIndex = 0;
|
|
5203
|
-
while (match = filterRegExp.exec(filterStr)) {
|
|
5204
|
-
if (match.index !== prevLastIndex) {
|
|
5205
|
-
return [];
|
|
5206
|
-
}
|
|
5207
|
-
prevLastIndex = match.index + match[0].length;
|
|
5208
|
-
if (supportedFilters.indexOf(match[1]) > -1) {
|
|
5209
|
-
result.push({
|
|
5210
|
-
name: match[1],
|
|
5211
|
-
params: match[2].split(' ').map(function (p) {
|
|
5212
|
-
return parseParam(p) || parseColor(p);
|
|
5213
|
-
})
|
|
5214
|
-
});
|
|
5215
|
-
}
|
|
5216
|
-
if (filterRegExp.lastIndex === filterStr.length) {
|
|
5217
|
-
return result;
|
|
5218
|
-
}
|
|
5219
|
-
}
|
|
5220
|
-
return [];
|
|
5221
|
-
}
|
|
5222
|
-
|
|
5223
|
-
function numberToString(x) {
|
|
5224
|
-
// scale(0.00000001) -> scale(0)
|
|
5225
|
-
// return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
|
|
5226
|
-
return x.toString();
|
|
5227
|
-
}
|
|
5228
|
-
/**
|
|
5229
|
-
* parse string or number to CSSUnitValue(numeric)
|
|
5230
|
-
*
|
|
5231
|
-
* eg.
|
|
5232
|
-
* * 0 -> CSSUnitValue(0)
|
|
5233
|
-
* * '2' -> CSSUnitValue(2)
|
|
5234
|
-
*/
|
|
5235
|
-
var parseNumber = memoize(function (string) {
|
|
5236
|
-
if (typeof string === 'number') {
|
|
5237
|
-
return getOrCreateUnitValue(string);
|
|
5238
|
-
}
|
|
5239
|
-
if (/^\s*[-+]?(\d*\.)?\d+\s*$/.test(string)) {
|
|
5240
|
-
return getOrCreateUnitValue(Number(string));
|
|
5241
|
-
} else {
|
|
5242
|
-
return getOrCreateUnitValue(0);
|
|
5243
|
-
}
|
|
5244
|
-
});
|
|
5245
|
-
/**
|
|
5246
|
-
* separate string to array
|
|
5247
|
-
* eg.
|
|
5248
|
-
* * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
|
|
5249
|
-
*/
|
|
5250
|
-
var parseNumberList = memoize(function (string) {
|
|
5251
|
-
if (isString(string)) {
|
|
5252
|
-
return string.split(' ').map(parseNumber);
|
|
5253
|
-
} else {
|
|
5254
|
-
return string.map(parseNumber);
|
|
5255
|
-
}
|
|
5256
|
-
});
|
|
5257
|
-
function mergeNumbers(left, right) {
|
|
5258
|
-
return [left, right, numberToString];
|
|
5259
|
-
}
|
|
5260
|
-
function clampedMergeNumbers(min, max) {
|
|
5261
|
-
return function (left, right) {
|
|
5262
|
-
return [left, right, function (x) {
|
|
5263
|
-
return numberToString(clamp(x, min, max));
|
|
5264
|
-
}];
|
|
5265
|
-
};
|
|
5266
|
-
}
|
|
5267
|
-
function mergeNumberLists(left, right) {
|
|
5268
|
-
if (left.length !== right.length) {
|
|
5269
|
-
return;
|
|
4849
|
+
function mergeNumberLists(left, right) {
|
|
4850
|
+
if (left.length !== right.length) {
|
|
4851
|
+
return;
|
|
5270
4852
|
}
|
|
5271
4853
|
return [left, right, function (numberList) {
|
|
5272
4854
|
return numberList;
|
|
@@ -5410,6 +4992,11 @@ function parsePoints(pointsOrStr, object) {
|
|
|
5410
4992
|
segments: segments
|
|
5411
4993
|
};
|
|
5412
4994
|
}
|
|
4995
|
+
function mergePoints(left, right) {
|
|
4996
|
+
return [left.points, right.points, function (points) {
|
|
4997
|
+
return points;
|
|
4998
|
+
}];
|
|
4999
|
+
}
|
|
5413
5000
|
|
|
5414
5001
|
var _ = null;
|
|
5415
5002
|
function cast(pattern) {
|
|
@@ -6215,74 +5802,485 @@ var CSSPropertyMarker = /*#__PURE__*/function () {
|
|
|
6215
5802
|
if (newMarker instanceof CSSKeywordValue) {
|
|
6216
5803
|
newMarker = null;
|
|
6217
5804
|
}
|
|
6218
|
-
var cloned = (_newMarker = newMarker) === null || _newMarker === void 0 ? void 0 : _newMarker.cloneNode(true);
|
|
6219
|
-
if (cloned) {
|
|
6220
|
-
// FIXME: SVG should not inherit parent's style, add a flag here
|
|
6221
|
-
cloned.style.isMarker = true;
|
|
5805
|
+
var cloned = (_newMarker = newMarker) === null || _newMarker === void 0 ? void 0 : _newMarker.cloneNode(true);
|
|
5806
|
+
if (cloned) {
|
|
5807
|
+
// FIXME: SVG should not inherit parent's style, add a flag here
|
|
5808
|
+
cloned.style.isMarker = true;
|
|
5809
|
+
}
|
|
5810
|
+
return cloned;
|
|
5811
|
+
};
|
|
5812
|
+
return CSSPropertyMarker;
|
|
5813
|
+
}();
|
|
5814
|
+
|
|
5815
|
+
var CSSPropertyNumber = /*#__PURE__*/function () {
|
|
5816
|
+
function CSSPropertyNumber() {
|
|
5817
|
+
this.mixer = mergeNumbers;
|
|
5818
|
+
this.parser = parseNumber;
|
|
5819
|
+
this.parserWithCSSDisabled = null;
|
|
5820
|
+
}
|
|
5821
|
+
var _proto = CSSPropertyNumber.prototype;
|
|
5822
|
+
_proto.calculator = function calculator(name, oldParsed, computed) {
|
|
5823
|
+
return computed.value;
|
|
5824
|
+
};
|
|
5825
|
+
return CSSPropertyNumber;
|
|
5826
|
+
}();
|
|
5827
|
+
|
|
5828
|
+
var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
|
|
5829
|
+
function CSSPropertyOffsetDistance() {
|
|
5830
|
+
this.parser = parseNumber;
|
|
5831
|
+
this.parserWithCSSDisabled = null;
|
|
5832
|
+
this.mixer = clampedMergeNumbers(0, 1);
|
|
5833
|
+
}
|
|
5834
|
+
var _proto = CSSPropertyOffsetDistance.prototype;
|
|
5835
|
+
_proto.calculator = function calculator(name, oldParsed, computed) {
|
|
5836
|
+
return computed.value;
|
|
5837
|
+
};
|
|
5838
|
+
_proto.postProcessor = function postProcessor(object) {
|
|
5839
|
+
var _object$parsedStyle = object.parsedStyle,
|
|
5840
|
+
offsetPath = _object$parsedStyle.offsetPath,
|
|
5841
|
+
offsetDistance = _object$parsedStyle.offsetDistance;
|
|
5842
|
+
if (!offsetPath) {
|
|
5843
|
+
return;
|
|
5844
|
+
}
|
|
5845
|
+
var nodeName = offsetPath.nodeName;
|
|
5846
|
+
if (nodeName === Shape.LINE || nodeName === Shape.PATH || nodeName === Shape.POLYLINE) {
|
|
5847
|
+
// set position in world space
|
|
5848
|
+
var point = offsetPath.getPoint(offsetDistance);
|
|
5849
|
+
if (point) {
|
|
5850
|
+
object.parsedStyle.defX = point.x;
|
|
5851
|
+
object.parsedStyle.defY = point.y;
|
|
5852
|
+
object.setLocalPosition(point.x, point.y);
|
|
5853
|
+
}
|
|
5854
|
+
}
|
|
5855
|
+
};
|
|
5856
|
+
return CSSPropertyOffsetDistance;
|
|
5857
|
+
}();
|
|
5858
|
+
|
|
5859
|
+
/**
|
|
5860
|
+
* opacity
|
|
5861
|
+
*/
|
|
5862
|
+
var CSSPropertyOpacity = /*#__PURE__*/function () {
|
|
5863
|
+
function CSSPropertyOpacity() {
|
|
5864
|
+
this.parser = parseNumber;
|
|
5865
|
+
this.parserWithCSSDisabled = null;
|
|
5866
|
+
this.mixer = clampedMergeNumbers(0, 1);
|
|
5867
|
+
}
|
|
5868
|
+
var _proto = CSSPropertyOpacity.prototype;
|
|
5869
|
+
_proto.calculator = function calculator(name, oldParsed, computed) {
|
|
5870
|
+
return computed.value;
|
|
5871
|
+
};
|
|
5872
|
+
return CSSPropertyOpacity;
|
|
5873
|
+
}();
|
|
5874
|
+
|
|
5875
|
+
/**
|
|
5876
|
+
* Axis-Aligned Bounding Box
|
|
5877
|
+
* 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
|
|
5878
|
+
* @see https://github.com/antvis/GWebGPUEngine/issues/3
|
|
5879
|
+
*/
|
|
5880
|
+
var AABB = /*#__PURE__*/function () {
|
|
5881
|
+
function AABB() {
|
|
5882
|
+
this.center = [0, 0, 0];
|
|
5883
|
+
this.halfExtents = [0, 0, 0];
|
|
5884
|
+
this.min = [0, 0, 0];
|
|
5885
|
+
this.max = [0, 0, 0];
|
|
5886
|
+
}
|
|
5887
|
+
AABB.isEmpty = function isEmpty(aabb) {
|
|
5888
|
+
return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
|
|
5889
|
+
};
|
|
5890
|
+
var _proto = AABB.prototype;
|
|
5891
|
+
// center: vec3 = vec3.create();
|
|
5892
|
+
// halfExtents: vec3 = vec3.create();
|
|
5893
|
+
// min: vec3 = vec3.create();
|
|
5894
|
+
// max: vec3 = vec3.create();
|
|
5895
|
+
_proto.update = function update(center, halfExtents) {
|
|
5896
|
+
copyVec3(this.center, center);
|
|
5897
|
+
copyVec3(this.halfExtents, halfExtents);
|
|
5898
|
+
subVec3(this.min, this.center, this.halfExtents);
|
|
5899
|
+
addVec3(this.max, this.center, this.halfExtents);
|
|
5900
|
+
// vec3.copy(this.center, center);
|
|
5901
|
+
// vec3.copy(this.halfExtents, halfExtents);
|
|
5902
|
+
// vec3.sub(this.min, this.center, this.halfExtents);
|
|
5903
|
+
// vec3.add(this.max, this.center, this.halfExtents);
|
|
5904
|
+
};
|
|
5905
|
+
_proto.setMinMax = function setMinMax(min, max) {
|
|
5906
|
+
// vec3.add(this.center, max, min);
|
|
5907
|
+
// vec3.scale(this.center, this.center, 0.5);
|
|
5908
|
+
// vec3.sub(this.halfExtents, max, min);
|
|
5909
|
+
// vec3.scale(this.halfExtents, this.halfExtents, 0.5);
|
|
5910
|
+
// vec3.copy(this.min, min);
|
|
5911
|
+
// vec3.copy(this.max, max);
|
|
5912
|
+
addVec3(this.center, max, min);
|
|
5913
|
+
scaleVec3(this.center, this.center, 0.5);
|
|
5914
|
+
subVec3(this.halfExtents, max, min);
|
|
5915
|
+
scaleVec3(this.halfExtents, this.halfExtents, 0.5);
|
|
5916
|
+
copyVec3(this.min, min);
|
|
5917
|
+
copyVec3(this.max, max);
|
|
5918
|
+
};
|
|
5919
|
+
_proto.getMin = function getMin() {
|
|
5920
|
+
return this.min;
|
|
5921
|
+
};
|
|
5922
|
+
_proto.getMax = function getMax() {
|
|
5923
|
+
return this.max;
|
|
5924
|
+
};
|
|
5925
|
+
_proto.add = function add(aabb) {
|
|
5926
|
+
if (AABB.isEmpty(aabb)) {
|
|
5927
|
+
return;
|
|
5928
|
+
}
|
|
5929
|
+
if (AABB.isEmpty(this)) {
|
|
5930
|
+
this.setMinMax(aabb.getMin(), aabb.getMax());
|
|
5931
|
+
return;
|
|
5932
|
+
}
|
|
5933
|
+
var tc = this.center;
|
|
5934
|
+
var tcx = tc[0];
|
|
5935
|
+
var tcy = tc[1];
|
|
5936
|
+
var tcz = tc[2];
|
|
5937
|
+
var th = this.halfExtents;
|
|
5938
|
+
var thx = th[0];
|
|
5939
|
+
var thy = th[1];
|
|
5940
|
+
var thz = th[2];
|
|
5941
|
+
var tminx = tcx - thx;
|
|
5942
|
+
var tmaxx = tcx + thx;
|
|
5943
|
+
var tminy = tcy - thy;
|
|
5944
|
+
var tmaxy = tcy + thy;
|
|
5945
|
+
var tminz = tcz - thz;
|
|
5946
|
+
var tmaxz = tcz + thz;
|
|
5947
|
+
var oc = aabb.center;
|
|
5948
|
+
var ocx = oc[0];
|
|
5949
|
+
var ocy = oc[1];
|
|
5950
|
+
var ocz = oc[2];
|
|
5951
|
+
var oh = aabb.halfExtents;
|
|
5952
|
+
var ohx = oh[0];
|
|
5953
|
+
var ohy = oh[1];
|
|
5954
|
+
var ohz = oh[2];
|
|
5955
|
+
var ominx = ocx - ohx;
|
|
5956
|
+
var omaxx = ocx + ohx;
|
|
5957
|
+
var ominy = ocy - ohy;
|
|
5958
|
+
var omaxy = ocy + ohy;
|
|
5959
|
+
var ominz = ocz - ohz;
|
|
5960
|
+
var omaxz = ocz + ohz;
|
|
5961
|
+
if (ominx < tminx) {
|
|
5962
|
+
tminx = ominx;
|
|
5963
|
+
}
|
|
5964
|
+
if (omaxx > tmaxx) {
|
|
5965
|
+
tmaxx = omaxx;
|
|
5966
|
+
}
|
|
5967
|
+
if (ominy < tminy) {
|
|
5968
|
+
tminy = ominy;
|
|
5969
|
+
}
|
|
5970
|
+
if (omaxy > tmaxy) {
|
|
5971
|
+
tmaxy = omaxy;
|
|
5972
|
+
}
|
|
5973
|
+
if (ominz < tminz) {
|
|
5974
|
+
tminz = ominz;
|
|
5975
|
+
}
|
|
5976
|
+
if (omaxz > tmaxz) {
|
|
5977
|
+
tmaxz = omaxz;
|
|
5978
|
+
}
|
|
5979
|
+
tc[0] = (tminx + tmaxx) * 0.5;
|
|
5980
|
+
tc[1] = (tminy + tmaxy) * 0.5;
|
|
5981
|
+
tc[2] = (tminz + tmaxz) * 0.5;
|
|
5982
|
+
th[0] = (tmaxx - tminx) * 0.5;
|
|
5983
|
+
th[1] = (tmaxy - tminy) * 0.5;
|
|
5984
|
+
th[2] = (tmaxz - tminz) * 0.5;
|
|
5985
|
+
this.min[0] = tminx;
|
|
5986
|
+
this.min[1] = tminy;
|
|
5987
|
+
this.min[2] = tminz;
|
|
5988
|
+
this.max[0] = tmaxx;
|
|
5989
|
+
this.max[1] = tmaxy;
|
|
5990
|
+
this.max[2] = tmaxz;
|
|
5991
|
+
};
|
|
5992
|
+
_proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
|
|
5993
|
+
var bc = this.center;
|
|
5994
|
+
var br = this.halfExtents;
|
|
5995
|
+
var ac = aabb.center;
|
|
5996
|
+
var ar = aabb.halfExtents;
|
|
5997
|
+
var mx0 = m[0];
|
|
5998
|
+
var mx1 = m[4];
|
|
5999
|
+
var mx2 = m[8];
|
|
6000
|
+
var my0 = m[1];
|
|
6001
|
+
var my1 = m[5];
|
|
6002
|
+
var my2 = m[9];
|
|
6003
|
+
var mz0 = m[2];
|
|
6004
|
+
var mz1 = m[6];
|
|
6005
|
+
var mz2 = m[10];
|
|
6006
|
+
var mx0a = Math.abs(mx0);
|
|
6007
|
+
var mx1a = Math.abs(mx1);
|
|
6008
|
+
var mx2a = Math.abs(mx2);
|
|
6009
|
+
var my0a = Math.abs(my0);
|
|
6010
|
+
var my1a = Math.abs(my1);
|
|
6011
|
+
var my2a = Math.abs(my2);
|
|
6012
|
+
var mz0a = Math.abs(mz0);
|
|
6013
|
+
var mz1a = Math.abs(mz1);
|
|
6014
|
+
var mz2a = Math.abs(mz2);
|
|
6015
|
+
bc[0] = m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2];
|
|
6016
|
+
bc[1] = m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2];
|
|
6017
|
+
bc[2] = m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2];
|
|
6018
|
+
// vec3.set(
|
|
6019
|
+
// bc,
|
|
6020
|
+
// m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
|
|
6021
|
+
// m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
|
|
6022
|
+
// m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
|
|
6023
|
+
// );
|
|
6024
|
+
br[0] = mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2];
|
|
6025
|
+
br[1] = my0a * ar[0] + my1a * ar[1] + my2a * ar[2];
|
|
6026
|
+
br[2] = mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2];
|
|
6027
|
+
// vec3.set(
|
|
6028
|
+
// br,
|
|
6029
|
+
// mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
|
|
6030
|
+
// my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
|
|
6031
|
+
// mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
|
|
6032
|
+
// );
|
|
6033
|
+
// this.min = vec3.sub(this.min, bc, br);
|
|
6034
|
+
// this.max = vec3.add(this.max, bc, br);
|
|
6035
|
+
subVec3(this.min, bc, br);
|
|
6036
|
+
addVec3(this.max, bc, br);
|
|
6037
|
+
};
|
|
6038
|
+
_proto.intersects = function intersects(aabb) {
|
|
6039
|
+
var aMax = this.getMax();
|
|
6040
|
+
var aMin = this.getMin();
|
|
6041
|
+
var bMax = aabb.getMax();
|
|
6042
|
+
var bMin = aabb.getMin();
|
|
6043
|
+
return aMin[0] <= bMax[0] && aMax[0] >= bMin[0] && aMin[1] <= bMax[1] && aMax[1] >= bMin[1] && aMin[2] <= bMax[2] && aMax[2] >= bMin[2];
|
|
6044
|
+
};
|
|
6045
|
+
_proto.intersection = function intersection(aabb) {
|
|
6046
|
+
if (!this.intersects(aabb)) {
|
|
6047
|
+
return null;
|
|
6048
|
+
}
|
|
6049
|
+
var intersection = new AABB();
|
|
6050
|
+
// const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
|
|
6051
|
+
// const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
|
|
6052
|
+
var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
|
|
6053
|
+
var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
|
|
6054
|
+
intersection.setMinMax(min, max);
|
|
6055
|
+
return intersection;
|
|
6056
|
+
}
|
|
6057
|
+
// containsPoint(point: vec3) {
|
|
6058
|
+
// const min = this.getMin();
|
|
6059
|
+
// const max = this.getMax();
|
|
6060
|
+
// return !(
|
|
6061
|
+
// point[0] < min[0] ||
|
|
6062
|
+
// point[0] > max[0] ||
|
|
6063
|
+
// point[1] < min[1] ||
|
|
6064
|
+
// point[1] > max[1] ||
|
|
6065
|
+
// point[2] < min[2] ||
|
|
6066
|
+
// point[2] > max[2]
|
|
6067
|
+
// );
|
|
6068
|
+
// }
|
|
6069
|
+
/**
|
|
6070
|
+
* get n-vertex
|
|
6071
|
+
* @param plane plane of CullingVolume
|
|
6072
|
+
*/;
|
|
6073
|
+
_proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
|
|
6074
|
+
if (plane.pnVertexFlag === 0x111) {
|
|
6075
|
+
return copyVec3([0, 0, 0], this.min);
|
|
6076
|
+
// return vec3.copy(vec3.create(), this.min);
|
|
6077
|
+
} else if (plane.pnVertexFlag === 0x110) {
|
|
6078
|
+
return [this.min[0], this.min[1], this.max[2]];
|
|
6079
|
+
// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
6080
|
+
} else if (plane.pnVertexFlag === 0x101) {
|
|
6081
|
+
return [this.min[0], this.max[1], this.min[2]];
|
|
6082
|
+
// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
6083
|
+
} else if (plane.pnVertexFlag === 0x100) {
|
|
6084
|
+
return [this.min[0], this.max[1], this.max[2]];
|
|
6085
|
+
// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
6086
|
+
} else if (plane.pnVertexFlag === 0x011) {
|
|
6087
|
+
return [this.max[0], this.min[1], this.min[2]];
|
|
6088
|
+
// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
6089
|
+
} else if (plane.pnVertexFlag === 0x010) {
|
|
6090
|
+
return [this.max[0], this.min[1], this.max[2]];
|
|
6091
|
+
// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
6092
|
+
} else if (plane.pnVertexFlag === 0x001) {
|
|
6093
|
+
return [this.max[0], this.max[1], this.min[2]];
|
|
6094
|
+
// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
6095
|
+
} else {
|
|
6096
|
+
return [this.max[0], this.max[1], this.max[2]];
|
|
6097
|
+
// return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
|
|
6098
|
+
}
|
|
6099
|
+
}
|
|
6100
|
+
/**
|
|
6101
|
+
* get p-vertex
|
|
6102
|
+
* @param plane plane of CullingVolume
|
|
6103
|
+
*/;
|
|
6104
|
+
_proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
|
|
6105
|
+
if (plane.pnVertexFlag === 0x111) {
|
|
6106
|
+
return copyVec3([0, 0, 0], this.max);
|
|
6107
|
+
// return vec3.copy(vec3.create(), this.max);
|
|
6108
|
+
} else if (plane.pnVertexFlag === 0x110) {
|
|
6109
|
+
return [this.max[0], this.max[1], this.min[2]];
|
|
6110
|
+
// return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
|
|
6111
|
+
} else if (plane.pnVertexFlag === 0x101) {
|
|
6112
|
+
return [this.max[0], this.min[1], this.max[2]];
|
|
6113
|
+
// return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
|
|
6114
|
+
} else if (plane.pnVertexFlag === 0x100) {
|
|
6115
|
+
return [this.max[0], this.min[1], this.min[2]];
|
|
6116
|
+
// return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
|
|
6117
|
+
} else if (plane.pnVertexFlag === 0x011) {
|
|
6118
|
+
return [this.min[0], this.max[1], this.max[2]];
|
|
6119
|
+
// return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
|
|
6120
|
+
} else if (plane.pnVertexFlag === 0x010) {
|
|
6121
|
+
return [this.min[0], this.max[1], this.min[2]];
|
|
6122
|
+
// return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
|
|
6123
|
+
} else if (plane.pnVertexFlag === 0x001) {
|
|
6124
|
+
return [this.min[0], this.min[1], this.max[2]];
|
|
6125
|
+
// return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
|
|
6126
|
+
} else {
|
|
6127
|
+
return [this.min[0], this.min[1], this.min[2]];
|
|
6128
|
+
// return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
|
|
6222
6129
|
}
|
|
6223
|
-
return cloned;
|
|
6224
6130
|
};
|
|
6225
|
-
return
|
|
6131
|
+
return AABB;
|
|
6226
6132
|
}();
|
|
6227
6133
|
|
|
6228
|
-
var
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6134
|
+
var Plane = /*#__PURE__*/function () {
|
|
6135
|
+
/**
|
|
6136
|
+
* lookup table for p-vertex & n-vertex when doing frustum culling
|
|
6137
|
+
*/
|
|
6138
|
+
|
|
6139
|
+
function Plane(distance, normal) {
|
|
6140
|
+
this.distance = void 0;
|
|
6141
|
+
this.normal = void 0;
|
|
6142
|
+
this.pnVertexFlag = void 0;
|
|
6143
|
+
this.distance = distance || 0;
|
|
6144
|
+
this.normal = normal || vec3.fromValues(0, 1, 0);
|
|
6145
|
+
this.updatePNVertexFlag();
|
|
6233
6146
|
}
|
|
6234
|
-
var _proto =
|
|
6235
|
-
_proto.
|
|
6236
|
-
|
|
6147
|
+
var _proto = Plane.prototype;
|
|
6148
|
+
_proto.updatePNVertexFlag = function updatePNVertexFlag() {
|
|
6149
|
+
this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
|
|
6237
6150
|
};
|
|
6238
|
-
|
|
6151
|
+
_proto.distanceToPoint = function distanceToPoint(point) {
|
|
6152
|
+
return vec3.dot(point, this.normal) - this.distance;
|
|
6153
|
+
};
|
|
6154
|
+
_proto.normalize = function normalize() {
|
|
6155
|
+
var invLen = 1 / vec3.len(this.normal);
|
|
6156
|
+
vec3.scale(this.normal, this.normal, invLen);
|
|
6157
|
+
this.distance *= invLen;
|
|
6158
|
+
};
|
|
6159
|
+
_proto.intersectsLine = function intersectsLine(start, end, point) {
|
|
6160
|
+
var d0 = this.distanceToPoint(start);
|
|
6161
|
+
var d1 = this.distanceToPoint(end);
|
|
6162
|
+
var t = d0 / (d0 - d1);
|
|
6163
|
+
var intersects = t >= 0 && t <= 1;
|
|
6164
|
+
if (intersects && point) {
|
|
6165
|
+
vec3.lerp(point, start, end, t);
|
|
6166
|
+
}
|
|
6167
|
+
return intersects;
|
|
6168
|
+
};
|
|
6169
|
+
return Plane;
|
|
6239
6170
|
}();
|
|
6240
6171
|
|
|
6241
|
-
var
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6172
|
+
var Mask;
|
|
6173
|
+
(function (Mask) {
|
|
6174
|
+
Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
|
|
6175
|
+
Mask[Mask["INSIDE"] = 0] = "INSIDE";
|
|
6176
|
+
Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
|
|
6177
|
+
})(Mask || (Mask = {}));
|
|
6178
|
+
var Frustum = /*#__PURE__*/function () {
|
|
6179
|
+
function Frustum(planes) {
|
|
6180
|
+
this.planes = [];
|
|
6181
|
+
if (planes) {
|
|
6182
|
+
this.planes = planes;
|
|
6183
|
+
} else {
|
|
6184
|
+
for (var i = 0; i < 6; i++) {
|
|
6185
|
+
this.planes.push(new Plane());
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6246
6188
|
}
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6189
|
+
/**
|
|
6190
|
+
* extract 6 planes from projectionMatrix
|
|
6191
|
+
* @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
|
|
6192
|
+
*/
|
|
6193
|
+
var _proto = Frustum.prototype;
|
|
6194
|
+
_proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
|
|
6195
|
+
// @ts-ignore
|
|
6196
|
+
var m0 = projectionMatrix[0],
|
|
6197
|
+
m1 = projectionMatrix[1],
|
|
6198
|
+
m2 = projectionMatrix[2],
|
|
6199
|
+
m3 = projectionMatrix[3],
|
|
6200
|
+
m4 = projectionMatrix[4],
|
|
6201
|
+
m5 = projectionMatrix[5],
|
|
6202
|
+
m6 = projectionMatrix[6],
|
|
6203
|
+
m7 = projectionMatrix[7],
|
|
6204
|
+
m8 = projectionMatrix[8],
|
|
6205
|
+
m9 = projectionMatrix[9],
|
|
6206
|
+
m10 = projectionMatrix[10],
|
|
6207
|
+
m11 = projectionMatrix[11],
|
|
6208
|
+
m12 = projectionMatrix[12],
|
|
6209
|
+
m13 = projectionMatrix[13],
|
|
6210
|
+
m14 = projectionMatrix[14],
|
|
6211
|
+
m15 = projectionMatrix[15];
|
|
6212
|
+
// right
|
|
6213
|
+
vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
|
|
6214
|
+
this.planes[0].distance = m15 - m12;
|
|
6215
|
+
// left
|
|
6216
|
+
vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
|
|
6217
|
+
this.planes[1].distance = m15 + m12;
|
|
6218
|
+
// bottom
|
|
6219
|
+
vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
|
|
6220
|
+
this.planes[2].distance = m15 + m13;
|
|
6221
|
+
// top
|
|
6222
|
+
vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
|
|
6223
|
+
this.planes[3].distance = m15 - m13;
|
|
6224
|
+
// far
|
|
6225
|
+
vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
|
|
6226
|
+
this.planes[4].distance = m15 - m14;
|
|
6227
|
+
// near
|
|
6228
|
+
vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
|
|
6229
|
+
this.planes[5].distance = m15 + m14;
|
|
6230
|
+
this.planes.forEach(function (plane) {
|
|
6231
|
+
plane.normalize();
|
|
6232
|
+
plane.updatePNVertexFlag();
|
|
6233
|
+
});
|
|
6250
6234
|
};
|
|
6251
|
-
|
|
6252
|
-
|
|
6253
|
-
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6235
|
+
return Frustum;
|
|
6236
|
+
}();
|
|
6237
|
+
|
|
6238
|
+
var Point = /*#__PURE__*/function () {
|
|
6239
|
+
function Point(x, y) {
|
|
6240
|
+
if (x === void 0) {
|
|
6241
|
+
x = 0;
|
|
6257
6242
|
}
|
|
6258
|
-
|
|
6259
|
-
|
|
6260
|
-
// set position in world space
|
|
6261
|
-
var point = offsetPath.getPoint(offsetDistance);
|
|
6262
|
-
if (point) {
|
|
6263
|
-
object.parsedStyle.defX = point.x;
|
|
6264
|
-
object.parsedStyle.defY = point.y;
|
|
6265
|
-
object.setLocalPosition(point.x, point.y);
|
|
6266
|
-
}
|
|
6243
|
+
if (y === void 0) {
|
|
6244
|
+
y = 0;
|
|
6267
6245
|
}
|
|
6246
|
+
this.x = 0;
|
|
6247
|
+
this.y = 0;
|
|
6248
|
+
this.x = x;
|
|
6249
|
+
this.y = y;
|
|
6250
|
+
}
|
|
6251
|
+
var _proto = Point.prototype;
|
|
6252
|
+
_proto.clone = function clone() {
|
|
6253
|
+
return new Point(this.x, this.y);
|
|
6268
6254
|
};
|
|
6269
|
-
|
|
6255
|
+
_proto.copyFrom = function copyFrom(p) {
|
|
6256
|
+
this.x = p.x;
|
|
6257
|
+
this.y = p.y;
|
|
6258
|
+
};
|
|
6259
|
+
return Point;
|
|
6270
6260
|
}();
|
|
6271
6261
|
|
|
6272
|
-
|
|
6273
|
-
|
|
6274
|
-
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
this.
|
|
6278
|
-
this.
|
|
6279
|
-
this.
|
|
6262
|
+
var Rectangle = /*#__PURE__*/function () {
|
|
6263
|
+
function Rectangle(x, y, width, height) {
|
|
6264
|
+
this.x = void 0;
|
|
6265
|
+
this.y = void 0;
|
|
6266
|
+
this.width = void 0;
|
|
6267
|
+
this.height = void 0;
|
|
6268
|
+
this.left = void 0;
|
|
6269
|
+
this.right = void 0;
|
|
6270
|
+
this.top = void 0;
|
|
6271
|
+
this.bottom = void 0;
|
|
6272
|
+
this.x = x;
|
|
6273
|
+
this.y = y;
|
|
6274
|
+
this.width = width;
|
|
6275
|
+
this.height = height;
|
|
6276
|
+
this.left = x;
|
|
6277
|
+
this.right = x + width;
|
|
6278
|
+
this.top = y;
|
|
6279
|
+
this.bottom = y + height;
|
|
6280
6280
|
}
|
|
6281
|
-
var _proto =
|
|
6282
|
-
_proto.
|
|
6283
|
-
|
|
6284
|
-
};
|
|
6285
|
-
return CSSPropertyOpacity;
|
|
6281
|
+
var _proto = Rectangle.prototype;
|
|
6282
|
+
_proto.toJSON = function toJSON() {};
|
|
6283
|
+
return Rectangle;
|
|
6286
6284
|
}();
|
|
6287
6285
|
|
|
6288
6286
|
var CSSPropertyPath = /*#__PURE__*/function () {
|
|
@@ -6327,6 +6325,7 @@ var CSSPropertyPath = /*#__PURE__*/function () {
|
|
|
6327
6325
|
var CSSPropertyPoints = /*#__PURE__*/function () {
|
|
6328
6326
|
function CSSPropertyPoints() {
|
|
6329
6327
|
this.parser = parsePoints;
|
|
6328
|
+
this.mixer = mergePoints;
|
|
6330
6329
|
}
|
|
6331
6330
|
var _proto = CSSPropertyPoints.prototype;
|
|
6332
6331
|
/**
|
|
@@ -7627,12 +7626,12 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
7627
7626
|
localPosition: [0, 0, 0],
|
|
7628
7627
|
localRotation: [0, 0, 0, 1],
|
|
7629
7628
|
localScale: [1, 1, 1],
|
|
7630
|
-
localTransform:
|
|
7629
|
+
localTransform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
|
7631
7630
|
localSkew: [0, 0],
|
|
7632
7631
|
position: [0, 0, 0],
|
|
7633
7632
|
rotation: [0, 0, 0, 1],
|
|
7634
7633
|
scaling: [1, 1, 1],
|
|
7635
|
-
worldTransform:
|
|
7634
|
+
worldTransform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
|
|
7636
7635
|
origin: [0, 0, 0]
|
|
7637
7636
|
};
|
|
7638
7637
|
_this.sortable = {
|
|
@@ -7642,7 +7641,6 @@ var Element = /*#__PURE__*/function (_Node) {
|
|
|
7642
7641
|
renderOrder: 0
|
|
7643
7642
|
};
|
|
7644
7643
|
_this.geometry = {
|
|
7645
|
-
dirty: false,
|
|
7646
7644
|
contentBounds: undefined,
|
|
7647
7645
|
renderBounds: undefined
|
|
7648
7646
|
};
|
|
@@ -8453,6 +8451,7 @@ var DisplayObject = /*#__PURE__*/function (_Element) {
|
|
|
8453
8451
|
}
|
|
8454
8452
|
// start to process attributes
|
|
8455
8453
|
_this.initAttributes(_this.config.style);
|
|
8454
|
+
var Proxy = runtime.globalThis.Proxy ? runtime.globalThis.Proxy : function () {};
|
|
8456
8455
|
_this.dataset = new Proxy({}, {
|
|
8457
8456
|
get: function get(target, name) {
|
|
8458
8457
|
var formattedName = "" + DATASET_PREFIX + kebabize(name);
|
|
@@ -9142,7 +9141,7 @@ var Circle = /*#__PURE__*/function (_DisplayObject) {
|
|
|
9142
9141
|
}, style) : _extends({}, style),
|
|
9143
9142
|
initialParsedStyle: {
|
|
9144
9143
|
anchor: [0.5, 0.5],
|
|
9145
|
-
transformOrigin: runtime.enableCSSParsing ? null : [
|
|
9144
|
+
transformOrigin: runtime.enableCSSParsing ? null : [PECENTAGE_50, PECENTAGE_50]
|
|
9146
9145
|
}
|
|
9147
9146
|
}, rest)) || this;
|
|
9148
9147
|
}
|
|
@@ -9230,7 +9229,7 @@ var Ellipse = /*#__PURE__*/function (_DisplayObject) {
|
|
|
9230
9229
|
}, style) : _extends({}, style),
|
|
9231
9230
|
initialParsedStyle: {
|
|
9232
9231
|
anchor: [0.5, 0.5],
|
|
9233
|
-
transformOrigin: runtime.enableCSSParsing ? null : [
|
|
9232
|
+
transformOrigin: runtime.enableCSSParsing ? null : [PECENTAGE_50, PECENTAGE_50]
|
|
9234
9233
|
}
|
|
9235
9234
|
}, rest)) || this;
|
|
9236
9235
|
}
|
|
@@ -10088,7 +10087,6 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
|
|
|
10088
10087
|
var _proto = Text.prototype;
|
|
10089
10088
|
_proto.getComputedTextLength = function getComputedTextLength() {
|
|
10090
10089
|
var _this$parsedStyle$met;
|
|
10091
|
-
this.forceUpdateGeometry();
|
|
10092
10090
|
return ((_this$parsedStyle$met = this.parsedStyle.metrics) === null || _this$parsedStyle$met === void 0 ? void 0 : _this$parsedStyle$met.maxLineWidth) || 0;
|
|
10093
10091
|
}
|
|
10094
10092
|
// getEndPositionOfChar(charnum: number): DOMPoint {
|
|
@@ -10115,18 +10113,11 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
|
|
|
10115
10113
|
;
|
|
10116
10114
|
_proto.getLineBoundingRects = function getLineBoundingRects() {
|
|
10117
10115
|
var _this$parsedStyle$met2;
|
|
10118
|
-
this.forceUpdateGeometry();
|
|
10119
10116
|
return ((_this$parsedStyle$met2 = this.parsedStyle.metrics) === null || _this$parsedStyle$met2 === void 0 ? void 0 : _this$parsedStyle$met2.lineMetrics) || [];
|
|
10120
10117
|
};
|
|
10121
10118
|
_proto.isOverflowing = function isOverflowing() {
|
|
10122
|
-
this.forceUpdateGeometry();
|
|
10123
10119
|
return !!this.parsedStyle.isOverflowing;
|
|
10124
10120
|
};
|
|
10125
|
-
_proto.forceUpdateGeometry = function forceUpdateGeometry() {
|
|
10126
|
-
if (!this.parsedStyle.metrics) {
|
|
10127
|
-
runtime.styleValueRegistry.updateGeometry(this);
|
|
10128
|
-
}
|
|
10129
|
-
};
|
|
10130
10121
|
return Text;
|
|
10131
10122
|
}(DisplayObject);
|
|
10132
10123
|
|
|
@@ -10490,6 +10481,10 @@ var BUILT_IN_PROPERTIES = [{
|
|
|
10490
10481
|
// Polyline & Polygon
|
|
10491
10482
|
{
|
|
10492
10483
|
n: 'points',
|
|
10484
|
+
/**
|
|
10485
|
+
* support interpolation
|
|
10486
|
+
*/
|
|
10487
|
+
int: true,
|
|
10493
10488
|
l: true,
|
|
10494
10489
|
syntax: PropertySyntax.LIST_OF_POINTS,
|
|
10495
10490
|
p: 50
|
|
@@ -10858,8 +10853,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
10858
10853
|
runtime.CSSPropertySyntaxFactory['<transform>'].postProcessor(object, _attributeNames);
|
|
10859
10854
|
}
|
|
10860
10855
|
if (_needUpdateGeometry) {
|
|
10861
|
-
object
|
|
10862
|
-
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
10856
|
+
this.updateGeometry(object);
|
|
10863
10857
|
}
|
|
10864
10858
|
return;
|
|
10865
10859
|
}
|
|
@@ -10925,8 +10919,9 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
10925
10919
|
// }
|
|
10926
10920
|
// update geometry
|
|
10927
10921
|
if (needUpdateGeometry) {
|
|
10928
|
-
object.geometry.dirty = true;
|
|
10929
|
-
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
10922
|
+
// object.geometry.dirty = true;
|
|
10923
|
+
// runtime.sceneGraphService.dirtifyToRoot(object);
|
|
10924
|
+
this.updateGeometry(object);
|
|
10930
10925
|
}
|
|
10931
10926
|
attributeNames.forEach(function (name) {
|
|
10932
10927
|
if (name in object.parsedStyle) {
|
|
@@ -11101,7 +11096,8 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11101
11096
|
* eg. r of Circle, width/height of Rect
|
|
11102
11097
|
*/;
|
|
11103
11098
|
_proto.updateGeometry = function updateGeometry(object) {
|
|
11104
|
-
var
|
|
11099
|
+
var nodeName = object.nodeName;
|
|
11100
|
+
var geometryUpdater = runtime.geometryUpdaterFactory[nodeName];
|
|
11105
11101
|
if (geometryUpdater) {
|
|
11106
11102
|
var geometry = object.geometry;
|
|
11107
11103
|
if (!geometry.contentBounds) {
|
|
@@ -11122,10 +11118,6 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11122
11118
|
offsetY = _geometryUpdater$upda4 === void 0 ? 0 : _geometryUpdater$upda4,
|
|
11123
11119
|
_geometryUpdater$upda5 = _geometryUpdater$upda.offsetZ,
|
|
11124
11120
|
offsetZ = _geometryUpdater$upda5 === void 0 ? 0 : _geometryUpdater$upda5;
|
|
11125
|
-
// account for negative width / height of Rect
|
|
11126
|
-
// @see https://github.com/antvis/g/issues/957
|
|
11127
|
-
var flipY = width < 0;
|
|
11128
|
-
var flipX = height < 0;
|
|
11129
11121
|
// init with content box
|
|
11130
11122
|
var halfExtents = [Math.abs(width) / 2, Math.abs(height) / 2, depth / 2];
|
|
11131
11123
|
// const halfExtents = vec3.set(
|
|
@@ -11145,7 +11137,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11145
11137
|
transformOrigin = parsedStyle.transformOrigin;
|
|
11146
11138
|
var anchor = parsedStyle.anchor;
|
|
11147
11139
|
// <Text> use textAlign & textBaseline instead of anchor
|
|
11148
|
-
if (
|
|
11140
|
+
if (nodeName === Shape.TEXT) {
|
|
11149
11141
|
delete parsedStyle.anchor;
|
|
11150
11142
|
}
|
|
11151
11143
|
var center = [(1 - (anchor && anchor[0] || 0) * 2) * width / 2 + offsetX, (1 - (anchor && anchor[1] || 0) * 2) * height / 2 + offsetY, (1 - (anchor && anchor[2] || 0) * 2) * halfExtents[2] + offsetZ];
|
|
@@ -11158,7 +11150,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11158
11150
|
// update geometry's AABB
|
|
11159
11151
|
geometry.contentBounds.update(center, halfExtents);
|
|
11160
11152
|
// @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
|
|
11161
|
-
var expansion =
|
|
11153
|
+
var expansion = nodeName === Shape.POLYLINE || nodeName === Shape.POLYGON || nodeName === Shape.PATH ? Math.SQRT2 : 0.5;
|
|
11162
11154
|
// if (lineCap?.value === 'square') {
|
|
11163
11155
|
// expansion = Math.SQRT1_2;
|
|
11164
11156
|
// }
|
|
@@ -11228,16 +11220,21 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
|
|
|
11228
11220
|
}
|
|
11229
11221
|
});
|
|
11230
11222
|
anchor = parsedStyle.anchor;
|
|
11231
|
-
|
|
11223
|
+
// if (nodeName === Shape.RECT) {
|
|
11224
|
+
// account for negative width / height of Rect
|
|
11225
|
+
// @see https://github.com/antvis/g/issues/957
|
|
11226
|
+
var flipY = width < 0;
|
|
11227
|
+
var flipX = height < 0;
|
|
11228
|
+
// } else {
|
|
11229
|
+
// }
|
|
11232
11230
|
// set transform origin
|
|
11233
11231
|
var usedOriginXValue = (flipY ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[0], 0, object) : 0);
|
|
11234
11232
|
var usedOriginYValue = (flipX ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[1], 1, object) : 0);
|
|
11235
11233
|
usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0] || 0) * geometry.contentBounds.halfExtents[0] * 2;
|
|
11236
11234
|
usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1] || 0) * geometry.contentBounds.halfExtents[1] * 2;
|
|
11237
11235
|
object.setOrigin(usedOriginXValue, usedOriginYValue);
|
|
11238
|
-
// console.log('calc geometry', object);
|
|
11239
11236
|
// FIXME setOrigin may have already dirtified to root.
|
|
11240
|
-
|
|
11237
|
+
runtime.sceneGraphService.dirtifyToRoot(object);
|
|
11241
11238
|
}
|
|
11242
11239
|
};
|
|
11243
11240
|
_proto.isPropertyInheritable = function isPropertyInheritable(name) {
|
|
@@ -13800,10 +13797,10 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
13800
13797
|
z = 0;
|
|
13801
13798
|
}
|
|
13802
13799
|
if (typeof origin === 'number') {
|
|
13803
|
-
origin =
|
|
13800
|
+
origin = [origin, y, z];
|
|
13804
13801
|
}
|
|
13805
13802
|
var transform = element.transformable;
|
|
13806
|
-
if (
|
|
13803
|
+
if (origin[0] === transform.origin[0] && origin[1] === transform.origin[1] && origin[2] === transform.origin[2]) {
|
|
13807
13804
|
return;
|
|
13808
13805
|
}
|
|
13809
13806
|
var originVec = transform.origin;
|
|
@@ -14079,9 +14076,6 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
14079
14076
|
render = false;
|
|
14080
14077
|
}
|
|
14081
14078
|
var geometry = element.geometry;
|
|
14082
|
-
if (geometry.dirty) {
|
|
14083
|
-
runtime.styleValueRegistry.updateGeometry(element);
|
|
14084
|
-
}
|
|
14085
14079
|
var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
|
|
14086
14080
|
// return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
|
|
14087
14081
|
return bounds || new AABB();
|
|
@@ -14123,7 +14117,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
|
|
|
14123
14117
|
var clipped = findClosestClipPathTarget(element);
|
|
14124
14118
|
if (clipped) {
|
|
14125
14119
|
// use bounds under world space
|
|
14126
|
-
var clipPathBounds = clipped.
|
|
14120
|
+
var clipPathBounds = clipped.parsedStyle.clipPath.getBounds(render);
|
|
14127
14121
|
if (!aabb) {
|
|
14128
14122
|
aabb = clipPathBounds;
|
|
14129
14123
|
} else if (clipPathBounds) {
|
|
@@ -14400,19 +14394,19 @@ var TextService = /*#__PURE__*/function () {
|
|
|
14400
14394
|
leading = _parsedStyle$leading === void 0 ? 0 : _parsedStyle$leading;
|
|
14401
14395
|
var font = toFontString(parsedStyle);
|
|
14402
14396
|
var fontProperties;
|
|
14403
|
-
if (runtime.enableCSSParsing) {
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
} else {
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
}
|
|
14397
|
+
// if (runtime.enableCSSParsing) {
|
|
14398
|
+
fontProperties = this.measureFont(font, offscreenCanvas);
|
|
14399
|
+
// fallback in case UA disallow canvas data extraction
|
|
14400
|
+
// (toDataURI, getImageData functions)
|
|
14401
|
+
if (fontProperties.fontSize === 0) {
|
|
14402
|
+
fontProperties.fontSize = fontSize;
|
|
14403
|
+
fontProperties.ascent = fontSize;
|
|
14404
|
+
}
|
|
14405
|
+
// } else {
|
|
14406
|
+
// fontProperties = {
|
|
14407
|
+
// fontSize,
|
|
14408
|
+
// };
|
|
14409
|
+
// }
|
|
14416
14410
|
var context = this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);
|
|
14417
14411
|
context.font = font;
|
|
14418
14412
|
// no overflowing by default
|
|
@@ -14861,7 +14855,7 @@ var EventPlugin = /*#__PURE__*/function () {
|
|
|
14861
14855
|
var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
|
|
14862
14856
|
for (var _iterator = _createForOfIteratorHelperLoose(normalizedEvents), _step; !(_step = _iterator()).done;) {
|
|
14863
14857
|
var normalizedEvent = _step.value;
|
|
14864
|
-
var event = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas);
|
|
14858
|
+
var event = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas, nativeEvent);
|
|
14865
14859
|
_this.context.eventService.mapEvent(event);
|
|
14866
14860
|
}
|
|
14867
14861
|
_this.setCursor(_this.context.eventService.cursor);
|
|
@@ -14916,7 +14910,7 @@ var EventPlugin = /*#__PURE__*/function () {
|
|
|
14916
14910
|
}
|
|
14917
14911
|
for (var _iterator2 = _createForOfIteratorHelperLoose(events), _step2; !(_step2 = _iterator2()).done;) {
|
|
14918
14912
|
var event = _step2.value;
|
|
14919
|
-
var federatedEvent = _this2.bootstrapEvent(_this2.rootPointerEvent, event, canvas);
|
|
14913
|
+
var federatedEvent = _this2.bootstrapEvent(_this2.rootPointerEvent, event, canvas, nativeEvent);
|
|
14920
14914
|
_this2.context.eventService.mapEvent(federatedEvent);
|
|
14921
14915
|
}
|
|
14922
14916
|
_this2.setCursor(_this2.context.eventService.cursor);
|
|
@@ -14935,7 +14929,7 @@ var EventPlugin = /*#__PURE__*/function () {
|
|
|
14935
14929
|
var normalizedEvents = _this2.normalizeToPointerEvent(nativeEvent, canvas);
|
|
14936
14930
|
for (var _iterator3 = _createForOfIteratorHelperLoose(normalizedEvents), _step3; !(_step3 = _iterator3()).done;) {
|
|
14937
14931
|
var normalizedEvent = _step3.value;
|
|
14938
|
-
var event = _this2.bootstrapEvent(_this2.rootPointerEvent, normalizedEvent, canvas);
|
|
14932
|
+
var event = _this2.bootstrapEvent(_this2.rootPointerEvent, normalizedEvent, canvas, nativeEvent);
|
|
14939
14933
|
event.type += outside;
|
|
14940
14934
|
_this2.context.eventService.mapEvent(event);
|
|
14941
14935
|
}
|
|
@@ -14970,22 +14964,22 @@ var EventPlugin = /*#__PURE__*/function () {
|
|
|
14970
14964
|
y: y
|
|
14971
14965
|
};
|
|
14972
14966
|
};
|
|
14973
|
-
_proto.bootstrapEvent = function bootstrapEvent(event,
|
|
14967
|
+
_proto.bootstrapEvent = function bootstrapEvent(event, normalizedEvent, view, nativeEvent) {
|
|
14974
14968
|
event.view = view;
|
|
14975
14969
|
event.originalEvent = null;
|
|
14976
14970
|
event.nativeEvent = nativeEvent;
|
|
14977
|
-
event.pointerId =
|
|
14978
|
-
event.width =
|
|
14979
|
-
event.height =
|
|
14980
|
-
event.isPrimary =
|
|
14981
|
-
event.pointerType =
|
|
14982
|
-
event.pressure =
|
|
14983
|
-
event.tangentialPressure =
|
|
14984
|
-
event.tiltX =
|
|
14985
|
-
event.tiltY =
|
|
14986
|
-
event.twist =
|
|
14987
|
-
this.transferMouseData(event,
|
|
14988
|
-
var _this$getViewportXY = this.getViewportXY(
|
|
14971
|
+
event.pointerId = normalizedEvent.pointerId;
|
|
14972
|
+
event.width = normalizedEvent.width;
|
|
14973
|
+
event.height = normalizedEvent.height;
|
|
14974
|
+
event.isPrimary = normalizedEvent.isPrimary;
|
|
14975
|
+
event.pointerType = normalizedEvent.pointerType;
|
|
14976
|
+
event.pressure = normalizedEvent.pressure;
|
|
14977
|
+
event.tangentialPressure = normalizedEvent.tangentialPressure;
|
|
14978
|
+
event.tiltX = normalizedEvent.tiltX;
|
|
14979
|
+
event.tiltY = normalizedEvent.tiltY;
|
|
14980
|
+
event.twist = normalizedEvent.twist;
|
|
14981
|
+
this.transferMouseData(event, normalizedEvent);
|
|
14982
|
+
var _this$getViewportXY = this.getViewportXY(normalizedEvent),
|
|
14989
14983
|
x = _this$getViewportXY.x,
|
|
14990
14984
|
y = _this$getViewportXY.y;
|
|
14991
14985
|
event.viewport.x = x;
|