@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/index.js CHANGED
@@ -1627,6 +1627,7 @@ var getOrCreateUnitValue = function getOrCreateUnitValue(value, unitOrName) {
1627
1627
  }
1628
1628
  return new CSSUnitValue(value, unitOrName);
1629
1629
  };
1630
+ var PECENTAGE_50 = new CSSUnitValue(50, '%');
1630
1631
 
1631
1632
  var canvasMap = {};
1632
1633
  var defaultCanvasIdCounter = 0;
@@ -1660,8 +1661,8 @@ function sortByZIndex(o1, o2) {
1660
1661
  function findClosestClipPathTarget(object) {
1661
1662
  var el = object;
1662
1663
  do {
1663
- var _el$style;
1664
- var clipPath = (_el$style = el.style) === null || _el$style === void 0 ? void 0 : _el$style.clipPath;
1664
+ var _el$parsedStyle;
1665
+ var clipPath = (_el$parsedStyle = el.parsedStyle) === null || _el$parsedStyle === void 0 ? void 0 : _el$parsedStyle.clipPath;
1665
1666
  if (clipPath) return el;
1666
1667
  el = el.parentElement;
1667
1668
  } while (el !== null);
@@ -4167,8 +4168,7 @@ function toFontString(attributes) {
4167
4168
  var fontSizeString = util.isNumber(fontSize) && fontSize + "px" || '16px';
4168
4169
  // Clean-up fontFamily property by quoting each font name
4169
4170
  // this will support font names with spaces
4170
- // @ts-ignore
4171
- var fontFamilies = util.isString(fontFamily) ? fontFamily.split(',') : [fontFamily];
4171
+ var fontFamilies = fontFamily.split(',');
4172
4172
  for (var i = fontFamilies.length - 1; i >= 0; i--) {
4173
4173
  // Trim any extra white-space
4174
4174
  var _fontFamily = fontFamilies[i].trim();
@@ -4577,698 +4577,281 @@ function mergeColors(left, right) {
4577
4577
  }];
4578
4578
  }
4579
4579
 
4580
+ function parseDimension(unitRegExp, string) {
4581
+ if (util.isNil(string)) {
4582
+ return getOrCreateUnitValue(0, 'px');
4583
+ }
4584
+ string = ("" + string).trim().toLowerCase();
4585
+ if (isFinite(Number(string))) {
4586
+ if ('px'.search(unitRegExp) >= 0) {
4587
+ return getOrCreateUnitValue(Number(string), 'px');
4588
+ } else if ('deg'.search(unitRegExp) >= 0) {
4589
+ return getOrCreateUnitValue(Number(string), 'deg');
4590
+ }
4591
+ }
4592
+ var matchedUnits = [];
4593
+ string = string.replace(unitRegExp, function (match) {
4594
+ matchedUnits.push(match);
4595
+ return 'U' + match;
4596
+ });
4597
+ var taggedUnitRegExp = 'U(' + unitRegExp.source + ')';
4598
+ return matchedUnits.map(function (unit) {
4599
+ return getOrCreateUnitValue(Number(string.replace(new RegExp('U' + unit, 'g'), '').replace(new RegExp(taggedUnitRegExp, 'g'), '*0')), unit);
4600
+ })[0];
4601
+ }
4580
4602
  /**
4581
- * Axis-Aligned Bounding Box
4582
- * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
4583
- * @see https://github.com/antvis/GWebGPUEngine/issues/3
4603
+ * <length>
4604
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
4605
+ * length with only absolute unit, eg. 1px
4584
4606
  */
4585
- var AABB = /*#__PURE__*/function () {
4586
- AABB.isEmpty = function isEmpty(aabb) {
4587
- return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
4588
- };
4589
- // center: vec3 = vec3.create();
4590
- // halfExtents: vec3 = vec3.create();
4591
- // min: vec3 = vec3.create();
4592
- // max: vec3 = vec3.create();
4593
- function AABB(center, halfExtents) {
4594
- if (center === void 0) {
4595
- center = [0, 0, 0];
4596
- }
4597
- if (halfExtents === void 0) {
4598
- halfExtents = [0, 0, 0];
4599
- }
4600
- this.center = [0, 0, 0];
4601
- this.halfExtents = [0, 0, 0];
4602
- this.min = [0, 0, 0];
4603
- this.max = [0, 0, 0];
4604
- this.update(center, halfExtents);
4607
+ var parseLength = memoize(function (css) {
4608
+ return parseDimension(new RegExp('px', 'g'), css);
4609
+ });
4610
+ /**
4611
+ * <percentage>
4612
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
4613
+ */
4614
+ var parserPercentage = memoize(function (css) {
4615
+ return parseDimension(new RegExp('%', 'g'), css);
4616
+ });
4617
+ /**
4618
+ * length with absolute or relative unit,
4619
+ * eg. 1px, 0.7em, 50%, calc(100% - 200px);
4620
+ *
4621
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
4622
+ */
4623
+ // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
4624
+ // if (isNumber(css) || isFinite(Number(css))) {
4625
+ // return getOrCreateUnitValue(Number(css), 'px');
4626
+ // }
4627
+ // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
4628
+ // });
4629
+ var parseLengthOrPercentage = function parseLengthOrPercentage(css) {
4630
+ if (util.isNumber(css) || isFinite(Number(css))) {
4631
+ // Number(css) is NaN
4632
+ return getOrCreateUnitValue(Number(css) || 0, 'px');
4633
+ // return Number(css);
4605
4634
  }
4606
- var _proto = AABB.prototype;
4607
- _proto.update = function update(center, halfExtents) {
4608
- copyVec3(this.center, center);
4609
- copyVec3(this.halfExtents, halfExtents);
4610
- subVec3(this.min, this.center, this.halfExtents);
4611
- addVec3(this.max, this.center, this.halfExtents);
4612
- // vec3.copy(this.center, center);
4613
- // vec3.copy(this.halfExtents, halfExtents);
4614
- // vec3.sub(this.min, this.center, this.halfExtents);
4615
- // vec3.add(this.max, this.center, this.halfExtents);
4616
- };
4617
- _proto.setMinMax = function setMinMax(min, max) {
4618
- // vec3.add(this.center, max, min);
4619
- // vec3.scale(this.center, this.center, 0.5);
4620
- // vec3.sub(this.halfExtents, max, min);
4621
- // vec3.scale(this.halfExtents, this.halfExtents, 0.5);
4622
- // vec3.copy(this.min, min);
4623
- // vec3.copy(this.max, max);
4624
- addVec3(this.center, max, min);
4625
- scaleVec3(this.center, this.center, 0.5);
4626
- subVec3(this.halfExtents, max, min);
4627
- scaleVec3(this.halfExtents, this.halfExtents, 0.5);
4628
- copyVec3(this.min, min);
4629
- copyVec3(this.max, max);
4630
- };
4631
- _proto.getMin = function getMin() {
4632
- return this.min;
4633
- };
4634
- _proto.getMax = function getMax() {
4635
- return this.max;
4636
- };
4637
- _proto.add = function add(aabb) {
4638
- if (AABB.isEmpty(aabb)) {
4639
- return;
4640
- }
4641
- if (AABB.isEmpty(this)) {
4642
- this.setMinMax(aabb.getMin(), aabb.getMax());
4643
- return;
4644
- }
4645
- var tc = this.center;
4646
- var tcx = tc[0];
4647
- var tcy = tc[1];
4648
- var tcz = tc[2];
4649
- var th = this.halfExtents;
4650
- var thx = th[0];
4651
- var thy = th[1];
4652
- var thz = th[2];
4653
- var tminx = tcx - thx;
4654
- var tmaxx = tcx + thx;
4655
- var tminy = tcy - thy;
4656
- var tmaxy = tcy + thy;
4657
- var tminz = tcz - thz;
4658
- var tmaxz = tcz + thz;
4659
- var oc = aabb.center;
4660
- var ocx = oc[0];
4661
- var ocy = oc[1];
4662
- var ocz = oc[2];
4663
- var oh = aabb.halfExtents;
4664
- var ohx = oh[0];
4665
- var ohy = oh[1];
4666
- var ohz = oh[2];
4667
- var ominx = ocx - ohx;
4668
- var omaxx = ocx + ohx;
4669
- var ominy = ocy - ohy;
4670
- var omaxy = ocy + ohy;
4671
- var ominz = ocz - ohz;
4672
- var omaxz = ocz + ohz;
4673
- if (ominx < tminx) {
4674
- tminx = ominx;
4675
- }
4676
- if (omaxx > tmaxx) {
4677
- tmaxx = omaxx;
4678
- }
4679
- if (ominy < tminy) {
4680
- tminy = ominy;
4635
+
4636
+ return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
4637
+ };
4638
+ var parseAngle = memoize(function (css) {
4639
+ return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
4640
+ });
4641
+ /**
4642
+ * merge CSSUnitValue
4643
+ *
4644
+ * @example
4645
+ * 10px + 20px = 30px
4646
+ * 10deg + 10rad
4647
+ * 10% + 20% = 30%
4648
+ */
4649
+ function mergeDimensions(left, right, target, nonNegative, index) {
4650
+ if (index === void 0) {
4651
+ index = 0;
4652
+ }
4653
+ var unit = '';
4654
+ var leftValue = left.value || 0;
4655
+ var rightValue = right.value || 0;
4656
+ var canonicalUnit = toCanonicalUnit(left.unit);
4657
+ var leftCanonicalUnitValue = left.convertTo(canonicalUnit);
4658
+ var rightCanonicalUnitValue = right.convertTo(canonicalUnit);
4659
+ if (leftCanonicalUnitValue && rightCanonicalUnitValue) {
4660
+ leftValue = leftCanonicalUnitValue.value;
4661
+ rightValue = rightCanonicalUnitValue.value;
4662
+ unit = unitTypeToString(left.unit);
4663
+ } else {
4664
+ // format '%' to 'px'
4665
+ if (CSSUnitValue.isLength(left.unit) || CSSUnitValue.isLength(right.unit)) {
4666
+ leftValue = convertPercentUnit(left, index, target);
4667
+ rightValue = convertPercentUnit(right, index, target);
4668
+ unit = 'px';
4681
4669
  }
4682
- if (omaxy > tmaxy) {
4683
- tmaxy = omaxy;
4670
+ }
4671
+ // // format 'rad' 'turn' to 'deg'
4672
+ // if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
4673
+ // leftValue = convertAngleUnit(left);
4674
+ // rightValue = convertAngleUnit(right);
4675
+ // unit = 'deg';
4676
+ // }
4677
+ return [leftValue, rightValue, function (value) {
4678
+ if (nonNegative) {
4679
+ value = Math.max(value, 0);
4684
4680
  }
4685
- if (ominz < tminz) {
4686
- tminz = ominz;
4681
+ return value + unit;
4682
+ }];
4683
+ }
4684
+ function convertAngleUnit(value) {
4685
+ var deg = 0;
4686
+ if (value.unit === exports.UnitType.kDegrees) {
4687
+ deg = value.value;
4688
+ } else if (value.unit === exports.UnitType.kRadians) {
4689
+ deg = rad2deg(Number(value.value));
4690
+ } else if (value.unit === exports.UnitType.kTurns) {
4691
+ deg = turn2deg(Number(value.value));
4692
+ }
4693
+ return deg;
4694
+ }
4695
+ function parseDimensionArrayFormat(string, size) {
4696
+ var parsed;
4697
+ if (Array.isArray(string)) {
4698
+ // [1, '2px', 3]
4699
+ parsed = string.map(function (segment) {
4700
+ return Number(segment);
4701
+ });
4702
+ } else if (util.isString(string)) {
4703
+ parsed = string.split(' ').map(function (segment) {
4704
+ return Number(segment);
4705
+ });
4706
+ } else if (util.isNumber(string)) {
4707
+ parsed = [string];
4708
+ }
4709
+ if (size === 2) {
4710
+ if (parsed.length === 1) {
4711
+ return [parsed[0], parsed[0]];
4712
+ } else {
4713
+ return [parsed[0], parsed[1]];
4687
4714
  }
4688
- if (omaxz > tmaxz) {
4689
- tmaxz = omaxz;
4715
+ } else {
4716
+ if (parsed.length === 1) {
4717
+ return [parsed[0], parsed[0], parsed[0], parsed[0]];
4718
+ } else if (parsed.length === 2) {
4719
+ return [parsed[0], parsed[1], parsed[0], parsed[1]];
4720
+ } else if (parsed.length === 3) {
4721
+ return [parsed[0], parsed[1], parsed[2], parsed[1]];
4722
+ } else {
4723
+ return [parsed[0], parsed[1], parsed[2], parsed[3]];
4690
4724
  }
4691
- tc[0] = (tminx + tmaxx) * 0.5;
4692
- tc[1] = (tminy + tmaxy) * 0.5;
4693
- tc[2] = (tminz + tmaxz) * 0.5;
4694
- th[0] = (tmaxx - tminx) * 0.5;
4695
- th[1] = (tmaxy - tminy) * 0.5;
4696
- th[2] = (tmaxz - tminz) * 0.5;
4697
- this.min[0] = tminx;
4698
- this.min[1] = tminy;
4699
- this.min[2] = tminz;
4700
- this.max[0] = tmaxx;
4701
- this.max[1] = tmaxy;
4702
- this.max[2] = tmaxz;
4703
- };
4704
- _proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
4705
- var bc = this.center;
4706
- var br = this.halfExtents;
4707
- var ac = aabb.center;
4708
- var ar = aabb.halfExtents;
4709
- var mx0 = m[0];
4710
- var mx1 = m[4];
4711
- var mx2 = m[8];
4712
- var my0 = m[1];
4713
- var my1 = m[5];
4714
- var my2 = m[9];
4715
- var mz0 = m[2];
4716
- var mz1 = m[6];
4717
- var mz2 = m[10];
4718
- var mx0a = Math.abs(mx0);
4719
- var mx1a = Math.abs(mx1);
4720
- var mx2a = Math.abs(mx2);
4721
- var my0a = Math.abs(my0);
4722
- var my1a = Math.abs(my1);
4723
- var my2a = Math.abs(my2);
4724
- var mz0a = Math.abs(mz0);
4725
- var mz1a = Math.abs(mz1);
4726
- var mz2a = Math.abs(mz2);
4727
- bc[0] = m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2];
4728
- bc[1] = m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2];
4729
- bc[2] = m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2];
4730
- // vec3.set(
4731
- // bc,
4732
- // m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
4733
- // m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
4734
- // m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
4735
- // );
4736
- br[0] = mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2];
4737
- br[1] = my0a * ar[0] + my1a * ar[1] + my2a * ar[2];
4738
- br[2] = mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2];
4739
- // vec3.set(
4740
- // br,
4741
- // mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
4742
- // my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
4743
- // mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
4744
- // );
4745
- // this.min = vec3.sub(this.min, bc, br);
4746
- // this.max = vec3.add(this.max, bc, br);
4747
- subVec3(this.min, bc, br);
4748
- addVec3(this.max, bc, br);
4749
- };
4750
- _proto.intersects = function intersects(aabb) {
4751
- var aMax = this.getMax();
4752
- var aMin = this.getMin();
4753
- var bMax = aabb.getMax();
4754
- var bMin = aabb.getMin();
4755
- 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];
4756
- };
4757
- _proto.intersection = function intersection(aabb) {
4758
- if (!this.intersects(aabb)) {
4759
- return null;
4760
- }
4761
- var intersection = new AABB();
4762
- // const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
4763
- // const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
4764
- var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
4765
- var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
4766
- intersection.setMinMax(min, max);
4767
- return intersection;
4768
4725
  }
4769
- // containsPoint(point: vec3) {
4770
- // const min = this.getMin();
4771
- // const max = this.getMax();
4772
- // return !(
4773
- // point[0] < min[0] ||
4774
- // point[0] > max[0] ||
4775
- // point[1] < min[1] ||
4776
- // point[1] > max[1] ||
4777
- // point[2] < min[2] ||
4778
- // point[2] > max[2]
4779
- // );
4780
- // }
4781
- /**
4782
- * get n-vertex
4783
- * @param plane plane of CullingVolume
4784
- */;
4785
- _proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
4786
- if (plane.pnVertexFlag === 0x111) {
4787
- return copyVec3([0, 0, 0], this.min);
4788
- // return vec3.copy(vec3.create(), this.min);
4789
- } else if (plane.pnVertexFlag === 0x110) {
4790
- return [this.min[0], this.min[1], this.max[2]];
4791
- // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
4792
- } else if (plane.pnVertexFlag === 0x101) {
4793
- return [this.min[0], this.max[1], this.min[2]];
4794
- // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
4795
- } else if (plane.pnVertexFlag === 0x100) {
4796
- return [this.min[0], this.max[1], this.max[2]];
4797
- // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
4798
- } else if (plane.pnVertexFlag === 0x011) {
4799
- return [this.max[0], this.min[1], this.min[2]];
4800
- // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
4801
- } else if (plane.pnVertexFlag === 0x010) {
4802
- return [this.max[0], this.min[1], this.max[2]];
4803
- // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
4804
- } else if (plane.pnVertexFlag === 0x001) {
4805
- return [this.max[0], this.max[1], this.min[2]];
4806
- // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
4807
- } else {
4808
- return [this.max[0], this.max[1], this.max[2]];
4809
- // return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
4810
- }
4726
+ }
4727
+ function parseDimensionArray(string) {
4728
+ if (util.isString(string)) {
4729
+ // "1px 2px 3px"
4730
+ return string.split(' ').map(function (segment) {
4731
+ return parseLengthOrPercentage(segment);
4732
+ });
4733
+ } else {
4734
+ // [1, '2px', 3]
4735
+ return string.map(function (segment) {
4736
+ return parseLengthOrPercentage(segment.toString());
4737
+ });
4811
4738
  }
4812
- /**
4813
- * get p-vertex
4814
- * @param plane plane of CullingVolume
4815
- */;
4816
- _proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
4817
- if (plane.pnVertexFlag === 0x111) {
4818
- return copyVec3([0, 0, 0], this.max);
4819
- // return vec3.copy(vec3.create(), this.max);
4820
- } else if (plane.pnVertexFlag === 0x110) {
4821
- return [this.max[0], this.max[1], this.min[2]];
4822
- // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
4823
- } else if (plane.pnVertexFlag === 0x101) {
4824
- return [this.max[0], this.min[1], this.max[2]];
4825
- // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
4826
- } else if (plane.pnVertexFlag === 0x100) {
4827
- return [this.max[0], this.min[1], this.min[2]];
4828
- // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
4829
- } else if (plane.pnVertexFlag === 0x011) {
4830
- return [this.min[0], this.max[1], this.max[2]];
4831
- // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
4832
- } else if (plane.pnVertexFlag === 0x010) {
4833
- return [this.min[0], this.max[1], this.min[2]];
4834
- // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
4835
- } else if (plane.pnVertexFlag === 0x001) {
4836
- return [this.min[0], this.min[1], this.max[2]];
4837
- // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
4838
- } else {
4839
- return [this.min[0], this.min[1], this.min[2]];
4840
- // return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
4841
- }
4842
- };
4843
- return AABB;
4844
- }();
4845
-
4846
- var Plane = /*#__PURE__*/function () {
4847
- /**
4848
- * lookup table for p-vertex & n-vertex when doing frustum culling
4849
- */
4739
+ }
4740
+ // export function mergeDimensionList(
4741
+ // left: CSSUnitValue[],
4742
+ // right: CSSUnitValue[],
4743
+ // target: IElement | null,
4744
+ // ): [number[], number[], (list: number[]) => string] | undefined {
4745
+ // if (left.length !== right.length) {
4746
+ // return;
4747
+ // }
4748
+ // const unit = left[0].unit;
4749
+ // return [
4750
+ // left.map((l) => l.value),
4751
+ // right.map((l) => l.value),
4752
+ // (values: number[]) => {
4753
+ // return values.map((n) => new CSSUnitValue(n, unit)).join(' ');
4754
+ // },
4755
+ // ];
4756
+ // }
4757
+ function convertPercentUnit(valueWithUnit, vec3Index, target) {
4758
+ if (valueWithUnit.value === 0) {
4759
+ return 0;
4760
+ }
4761
+ if (valueWithUnit.unit === exports.UnitType.kPixels) {
4762
+ return Number(valueWithUnit.value);
4763
+ } else if (valueWithUnit.unit === exports.UnitType.kPercentage && target) {
4764
+ var bounds = target.nodeName === exports.Shape.GROUP ? target.getLocalBounds() :
4765
+ // : target.getGeometryBounds();
4766
+ target.geometry.contentBounds;
4767
+ return valueWithUnit.value / 100 * bounds.halfExtents[vec3Index] * 2;
4768
+ }
4769
+ return 0;
4770
+ }
4850
4771
 
4851
- function Plane(distance, normal) {
4852
- this.distance = void 0;
4853
- this.normal = void 0;
4854
- this.pnVertexFlag = void 0;
4855
- this.distance = distance || 0;
4856
- this.normal = normal || glMatrix.vec3.fromValues(0, 1, 0);
4857
- this.updatePNVertexFlag();
4772
+ var parseParam = function parseParam(css) {
4773
+ return parseDimension(/deg|rad|grad|turn|px|%/g, css);
4774
+ };
4775
+ var supportedFilters = ['blur', 'brightness', 'drop-shadow', 'contrast', 'grayscale', 'sepia', 'saturate', 'hue-rotate', 'invert'];
4776
+ function parseFilter(filterStr) {
4777
+ if (filterStr === void 0) {
4778
+ filterStr = '';
4858
4779
  }
4859
- var _proto = Plane.prototype;
4860
- _proto.updatePNVertexFlag = function updatePNVertexFlag() {
4861
- this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
4862
- };
4863
- _proto.distanceToPoint = function distanceToPoint(point) {
4864
- return glMatrix.vec3.dot(point, this.normal) - this.distance;
4865
- };
4866
- _proto.normalize = function normalize() {
4867
- var invLen = 1 / glMatrix.vec3.len(this.normal);
4868
- glMatrix.vec3.scale(this.normal, this.normal, invLen);
4869
- this.distance *= invLen;
4870
- };
4871
- _proto.intersectsLine = function intersectsLine(start, end, point) {
4872
- var d0 = this.distanceToPoint(start);
4873
- var d1 = this.distanceToPoint(end);
4874
- var t = d0 / (d0 - d1);
4875
- var intersects = t >= 0 && t <= 1;
4876
- if (intersects && point) {
4877
- glMatrix.vec3.lerp(point, start, end, t);
4780
+ filterStr = filterStr.toLowerCase().trim();
4781
+ if (filterStr === 'none') {
4782
+ return [];
4783
+ }
4784
+ var filterRegExp = /\s*([\w-]+)\(([^)]*)\)/g;
4785
+ var result = [];
4786
+ var match;
4787
+ var prevLastIndex = 0;
4788
+ while (match = filterRegExp.exec(filterStr)) {
4789
+ if (match.index !== prevLastIndex) {
4790
+ return [];
4878
4791
  }
4879
- return intersects;
4880
- };
4881
- return Plane;
4882
- }();
4883
-
4884
- (function (Mask) {
4885
- Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
4886
- Mask[Mask["INSIDE"] = 0] = "INSIDE";
4887
- Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
4888
- })(exports.Mask || (exports.Mask = {}));
4889
- var Frustum = /*#__PURE__*/function () {
4890
- function Frustum(planes) {
4891
- this.planes = [];
4892
- if (planes) {
4893
- this.planes = planes;
4894
- } else {
4895
- for (var i = 0; i < 6; i++) {
4896
- this.planes.push(new Plane());
4897
- }
4792
+ prevLastIndex = match.index + match[0].length;
4793
+ if (supportedFilters.indexOf(match[1]) > -1) {
4794
+ result.push({
4795
+ name: match[1],
4796
+ params: match[2].split(' ').map(function (p) {
4797
+ return parseParam(p) || parseColor(p);
4798
+ })
4799
+ });
4800
+ }
4801
+ if (filterRegExp.lastIndex === filterStr.length) {
4802
+ return result;
4898
4803
  }
4899
4804
  }
4900
- /**
4901
- * extract 6 planes from projectionMatrix
4902
- * @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
4903
- */
4904
- var _proto = Frustum.prototype;
4905
- _proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
4906
- // @ts-ignore
4907
- var m0 = projectionMatrix[0],
4908
- m1 = projectionMatrix[1],
4909
- m2 = projectionMatrix[2],
4910
- m3 = projectionMatrix[3],
4911
- m4 = projectionMatrix[4],
4912
- m5 = projectionMatrix[5],
4913
- m6 = projectionMatrix[6],
4914
- m7 = projectionMatrix[7],
4915
- m8 = projectionMatrix[8],
4916
- m9 = projectionMatrix[9],
4917
- m10 = projectionMatrix[10],
4918
- m11 = projectionMatrix[11],
4919
- m12 = projectionMatrix[12],
4920
- m13 = projectionMatrix[13],
4921
- m14 = projectionMatrix[14],
4922
- m15 = projectionMatrix[15];
4923
- // right
4924
- glMatrix.vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
4925
- this.planes[0].distance = m15 - m12;
4926
- // left
4927
- glMatrix.vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
4928
- this.planes[1].distance = m15 + m12;
4929
- // bottom
4930
- glMatrix.vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
4931
- this.planes[2].distance = m15 + m13;
4932
- // top
4933
- glMatrix.vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
4934
- this.planes[3].distance = m15 - m13;
4935
- // far
4936
- glMatrix.vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
4937
- this.planes[4].distance = m15 - m14;
4938
- // near
4939
- glMatrix.vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
4940
- this.planes[5].distance = m15 + m14;
4941
- this.planes.forEach(function (plane) {
4942
- plane.normalize();
4943
- plane.updatePNVertexFlag();
4944
- });
4945
- };
4946
- return Frustum;
4947
- }();
4948
-
4949
- var Point = /*#__PURE__*/function () {
4950
- function Point(x, y) {
4951
- if (x === void 0) {
4952
- x = 0;
4953
- }
4954
- if (y === void 0) {
4955
- y = 0;
4956
- }
4957
- this.x = 0;
4958
- this.y = 0;
4959
- this.x = x;
4960
- this.y = y;
4961
- }
4962
- var _proto = Point.prototype;
4963
- _proto.clone = function clone() {
4964
- return new Point(this.x, this.y);
4965
- };
4966
- _proto.copyFrom = function copyFrom(p) {
4967
- this.x = p.x;
4968
- this.y = p.y;
4969
- };
4970
- return Point;
4971
- }();
4972
-
4973
- var Rectangle = /*#__PURE__*/function () {
4974
- function Rectangle(x, y, width, height) {
4975
- this.x = void 0;
4976
- this.y = void 0;
4977
- this.width = void 0;
4978
- this.height = void 0;
4979
- this.left = void 0;
4980
- this.right = void 0;
4981
- this.top = void 0;
4982
- this.bottom = void 0;
4983
- this.x = x;
4984
- this.y = y;
4985
- this.width = width;
4986
- this.height = height;
4987
- this.left = x;
4988
- this.right = x + width;
4989
- this.top = y;
4990
- this.bottom = y + height;
4991
- }
4992
- var _proto = Rectangle.prototype;
4993
- _proto.toJSON = function toJSON() {};
4994
- return Rectangle;
4995
- }();
4805
+ return [];
4806
+ }
4996
4807
 
4997
- function parseDimension(unitRegExp, string) {
4998
- if (util.isNil(string)) {
4999
- return getOrCreateUnitValue(0, 'px');
5000
- }
5001
- string = ("" + string).trim().toLowerCase();
5002
- if (isFinite(Number(string))) {
5003
- if ('px'.search(unitRegExp) >= 0) {
5004
- return getOrCreateUnitValue(Number(string), 'px');
5005
- } else if ('deg'.search(unitRegExp) >= 0) {
5006
- return getOrCreateUnitValue(Number(string), 'deg');
5007
- }
5008
- }
5009
- var matchedUnits = [];
5010
- string = string.replace(unitRegExp, function (match) {
5011
- matchedUnits.push(match);
5012
- return 'U' + match;
5013
- });
5014
- var taggedUnitRegExp = 'U(' + unitRegExp.source + ')';
5015
- return matchedUnits.map(function (unit) {
5016
- return getOrCreateUnitValue(Number(string.replace(new RegExp('U' + unit, 'g'), '').replace(new RegExp(taggedUnitRegExp, 'g'), '*0')), unit);
5017
- })[0];
4808
+ function numberToString(x) {
4809
+ // scale(0.00000001) -> scale(0)
4810
+ // return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
4811
+ return x.toString();
5018
4812
  }
5019
4813
  /**
5020
- * <length>
5021
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
5022
- * length with only absolute unit, eg. 1px
5023
- */
5024
- var parseLength = memoize(function (css) {
5025
- return parseDimension(new RegExp('px', 'g'), css);
5026
- });
5027
- /**
5028
- * <percentage>
5029
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
5030
- */
5031
- var parserPercentage = memoize(function (css) {
5032
- return parseDimension(new RegExp('%', 'g'), css);
5033
- });
5034
- /**
5035
- * length with absolute or relative unit,
5036
- * eg. 1px, 0.7em, 50%, calc(100% - 200px);
4814
+ * parse string or number to CSSUnitValue(numeric)
5037
4815
  *
5038
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
4816
+ * eg.
4817
+ * * 0 -> CSSUnitValue(0)
4818
+ * * '2' -> CSSUnitValue(2)
5039
4819
  */
5040
- // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
5041
- // if (isNumber(css) || isFinite(Number(css))) {
5042
- // return getOrCreateUnitValue(Number(css), 'px');
5043
- // }
5044
- // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
5045
- // });
5046
- var parseLengthOrPercentage = function parseLengthOrPercentage(css) {
5047
- if (util.isNumber(css) || isFinite(Number(css))) {
5048
- return getOrCreateUnitValue(Number(css), 'px');
5049
- // return Number(css);
4820
+ var parseNumber = memoize(function (string) {
4821
+ if (typeof string === 'number') {
4822
+ return getOrCreateUnitValue(string);
4823
+ }
4824
+ if (/^\s*[-+]?(\d*\.)?\d+\s*$/.test(string)) {
4825
+ return getOrCreateUnitValue(Number(string));
4826
+ } else {
4827
+ return getOrCreateUnitValue(0);
5050
4828
  }
5051
-
5052
- return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
5053
- };
5054
- var parseAngle = memoize(function (css) {
5055
- return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
5056
4829
  });
5057
4830
  /**
5058
- * merge CSSUnitValue
5059
- *
5060
- * @example
5061
- * 10px + 20px = 30px
5062
- * 10deg + 10rad
5063
- * 10% + 20% = 30%
4831
+ * separate string to array
4832
+ * eg.
4833
+ * * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
5064
4834
  */
5065
- function mergeDimensions(left, right, target, nonNegative, index) {
5066
- if (index === void 0) {
5067
- index = 0;
5068
- }
5069
- var unit = '';
5070
- var leftValue = left.value || 0;
5071
- var rightValue = right.value || 0;
5072
- var canonicalUnit = toCanonicalUnit(left.unit);
5073
- var leftCanonicalUnitValue = left.convertTo(canonicalUnit);
5074
- var rightCanonicalUnitValue = right.convertTo(canonicalUnit);
5075
- if (leftCanonicalUnitValue && rightCanonicalUnitValue) {
5076
- leftValue = leftCanonicalUnitValue.value;
5077
- rightValue = rightCanonicalUnitValue.value;
5078
- unit = unitTypeToString(left.unit);
4835
+ var parseNumberList = memoize(function (string) {
4836
+ if (util.isString(string)) {
4837
+ return string.split(' ').map(parseNumber);
5079
4838
  } else {
5080
- // format '%' to 'px'
5081
- if (CSSUnitValue.isLength(left.unit) || CSSUnitValue.isLength(right.unit)) {
5082
- leftValue = convertPercentUnit(left, index, target);
5083
- rightValue = convertPercentUnit(right, index, target);
5084
- unit = 'px';
5085
- }
4839
+ return string.map(parseNumber);
5086
4840
  }
5087
- // // format 'rad' 'turn' to 'deg'
5088
- // if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
5089
- // leftValue = convertAngleUnit(left);
5090
- // rightValue = convertAngleUnit(right);
5091
- // unit = 'deg';
5092
- // }
5093
- return [leftValue, rightValue, function (value) {
5094
- if (nonNegative) {
5095
- value = Math.max(value, 0);
5096
- }
5097
- return value + unit;
5098
- }];
4841
+ });
4842
+ function mergeNumbers(left, right) {
4843
+ return [left, right, numberToString];
5099
4844
  }
5100
- function convertAngleUnit(value) {
5101
- var deg = 0;
5102
- if (value.unit === exports.UnitType.kDegrees) {
5103
- deg = value.value;
5104
- } else if (value.unit === exports.UnitType.kRadians) {
5105
- deg = rad2deg(Number(value.value));
5106
- } else if (value.unit === exports.UnitType.kTurns) {
5107
- deg = turn2deg(Number(value.value));
5108
- }
5109
- return deg;
4845
+ function clampedMergeNumbers(min, max) {
4846
+ return function (left, right) {
4847
+ return [left, right, function (x) {
4848
+ return numberToString(util.clamp(x, min, max));
4849
+ }];
4850
+ };
5110
4851
  }
5111
- function parseDimensionArrayFormat(string, size) {
5112
- var parsed;
5113
- if (Array.isArray(string)) {
5114
- // [1, '2px', 3]
5115
- parsed = string.map(function (segment) {
5116
- return Number(segment);
5117
- });
5118
- } else if (util.isString(string)) {
5119
- parsed = string.split(' ').map(function (segment) {
5120
- return Number(segment);
5121
- });
5122
- } else if (util.isNumber(string)) {
5123
- parsed = [string];
5124
- }
5125
- if (size === 2) {
5126
- if (parsed.length === 1) {
5127
- return [parsed[0], parsed[0]];
5128
- } else {
5129
- return [parsed[0], parsed[1]];
5130
- }
5131
- } else {
5132
- if (parsed.length === 1) {
5133
- return [parsed[0], parsed[0], parsed[0], parsed[0]];
5134
- } else if (parsed.length === 2) {
5135
- return [parsed[0], parsed[1], parsed[0], parsed[1]];
5136
- } else if (parsed.length === 3) {
5137
- return [parsed[0], parsed[1], parsed[2], parsed[1]];
5138
- } else {
5139
- return [parsed[0], parsed[1], parsed[2], parsed[3]];
5140
- }
5141
- }
5142
- }
5143
- function parseDimensionArray(string) {
5144
- if (util.isString(string)) {
5145
- // "1px 2px 3px"
5146
- return string.split(' ').map(function (segment) {
5147
- return parseLengthOrPercentage(segment);
5148
- });
5149
- } else {
5150
- // [1, '2px', 3]
5151
- return string.map(function (segment) {
5152
- return parseLengthOrPercentage(segment.toString());
5153
- });
5154
- }
5155
- }
5156
- // export function mergeDimensionList(
5157
- // left: CSSUnitValue[],
5158
- // right: CSSUnitValue[],
5159
- // target: IElement | null,
5160
- // ): [number[], number[], (list: number[]) => string] | undefined {
5161
- // if (left.length !== right.length) {
5162
- // return;
5163
- // }
5164
- // const unit = left[0].unit;
5165
- // return [
5166
- // left.map((l) => l.value),
5167
- // right.map((l) => l.value),
5168
- // (values: number[]) => {
5169
- // return values.map((n) => new CSSUnitValue(n, unit)).join(' ');
5170
- // },
5171
- // ];
5172
- // }
5173
- function convertPercentUnit(valueWithUnit, vec3Index, target) {
5174
- if (valueWithUnit.unit === exports.UnitType.kPixels) {
5175
- return Number(valueWithUnit.value);
5176
- } else if (valueWithUnit.unit === exports.UnitType.kPercentage && target) {
5177
- var bounds = target.nodeName === exports.Shape.GROUP ? target.getLocalBounds() :
5178
- // : target.getGeometryBounds();
5179
- target.geometry.contentBounds;
5180
- var size = 0;
5181
- if (!AABB.isEmpty(bounds)) {
5182
- size = bounds.halfExtents[vec3Index] * 2;
5183
- }
5184
- return Number(valueWithUnit.value) / 100 * size;
5185
- }
5186
- return 0;
5187
- }
5188
-
5189
- var parseParam = function parseParam(css) {
5190
- return parseDimension(/deg|rad|grad|turn|px|%/g, css);
5191
- };
5192
- var supportedFilters = ['blur', 'brightness', 'drop-shadow', 'contrast', 'grayscale', 'sepia', 'saturate', 'hue-rotate', 'invert'];
5193
- function parseFilter(filterStr) {
5194
- if (filterStr === void 0) {
5195
- filterStr = '';
5196
- }
5197
- filterStr = filterStr.toLowerCase().trim();
5198
- if (filterStr === 'none') {
5199
- return [];
5200
- }
5201
- var filterRegExp = /\s*([\w-]+)\(([^)]*)\)/g;
5202
- var result = [];
5203
- var match;
5204
- var prevLastIndex = 0;
5205
- while (match = filterRegExp.exec(filterStr)) {
5206
- if (match.index !== prevLastIndex) {
5207
- return [];
5208
- }
5209
- prevLastIndex = match.index + match[0].length;
5210
- if (supportedFilters.indexOf(match[1]) > -1) {
5211
- result.push({
5212
- name: match[1],
5213
- params: match[2].split(' ').map(function (p) {
5214
- return parseParam(p) || parseColor(p);
5215
- })
5216
- });
5217
- }
5218
- if (filterRegExp.lastIndex === filterStr.length) {
5219
- return result;
5220
- }
5221
- }
5222
- return [];
5223
- }
5224
-
5225
- function numberToString(x) {
5226
- // scale(0.00000001) -> scale(0)
5227
- // return x.toFixed(6).replace(/0+$/, '').replace(/\.$/, '');
5228
- return x.toString();
5229
- }
5230
- /**
5231
- * parse string or number to CSSUnitValue(numeric)
5232
- *
5233
- * eg.
5234
- * * 0 -> CSSUnitValue(0)
5235
- * * '2' -> CSSUnitValue(2)
5236
- */
5237
- var parseNumber = memoize(function (string) {
5238
- if (typeof string === 'number') {
5239
- return getOrCreateUnitValue(string);
5240
- }
5241
- if (/^\s*[-+]?(\d*\.)?\d+\s*$/.test(string)) {
5242
- return getOrCreateUnitValue(Number(string));
5243
- } else {
5244
- return getOrCreateUnitValue(0);
5245
- }
5246
- });
5247
- /**
5248
- * separate string to array
5249
- * eg.
5250
- * * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
5251
- */
5252
- var parseNumberList = memoize(function (string) {
5253
- if (util.isString(string)) {
5254
- return string.split(' ').map(parseNumber);
5255
- } else {
5256
- return string.map(parseNumber);
5257
- }
5258
- });
5259
- function mergeNumbers(left, right) {
5260
- return [left, right, numberToString];
5261
- }
5262
- function clampedMergeNumbers(min, max) {
5263
- return function (left, right) {
5264
- return [left, right, function (x) {
5265
- return numberToString(util.clamp(x, min, max));
5266
- }];
5267
- };
5268
- }
5269
- function mergeNumberLists(left, right) {
5270
- if (left.length !== right.length) {
5271
- return;
4852
+ function mergeNumberLists(left, right) {
4853
+ if (left.length !== right.length) {
4854
+ return;
5272
4855
  }
5273
4856
  return [left, right, function (numberList) {
5274
4857
  return numberList;
@@ -5412,6 +4995,11 @@ function parsePoints(pointsOrStr, object) {
5412
4995
  segments: segments
5413
4996
  };
5414
4997
  }
4998
+ function mergePoints(left, right) {
4999
+ return [left.points, right.points, function (points) {
5000
+ return points;
5001
+ }];
5002
+ }
5415
5003
 
5416
5004
  var _ = null;
5417
5005
  function cast(pattern) {
@@ -6217,74 +5805,484 @@ var CSSPropertyMarker = /*#__PURE__*/function () {
6217
5805
  if (newMarker instanceof CSSKeywordValue) {
6218
5806
  newMarker = null;
6219
5807
  }
6220
- var cloned = (_newMarker = newMarker) === null || _newMarker === void 0 ? void 0 : _newMarker.cloneNode(true);
6221
- if (cloned) {
6222
- // FIXME: SVG should not inherit parent's style, add a flag here
6223
- cloned.style.isMarker = true;
5808
+ var cloned = (_newMarker = newMarker) === null || _newMarker === void 0 ? void 0 : _newMarker.cloneNode(true);
5809
+ if (cloned) {
5810
+ // FIXME: SVG should not inherit parent's style, add a flag here
5811
+ cloned.style.isMarker = true;
5812
+ }
5813
+ return cloned;
5814
+ };
5815
+ return CSSPropertyMarker;
5816
+ }();
5817
+
5818
+ var CSSPropertyNumber = /*#__PURE__*/function () {
5819
+ function CSSPropertyNumber() {
5820
+ this.mixer = mergeNumbers;
5821
+ this.parser = parseNumber;
5822
+ this.parserWithCSSDisabled = null;
5823
+ }
5824
+ var _proto = CSSPropertyNumber.prototype;
5825
+ _proto.calculator = function calculator(name, oldParsed, computed) {
5826
+ return computed.value;
5827
+ };
5828
+ return CSSPropertyNumber;
5829
+ }();
5830
+
5831
+ var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
5832
+ function CSSPropertyOffsetDistance() {
5833
+ this.parser = parseNumber;
5834
+ this.parserWithCSSDisabled = null;
5835
+ this.mixer = clampedMergeNumbers(0, 1);
5836
+ }
5837
+ var _proto = CSSPropertyOffsetDistance.prototype;
5838
+ _proto.calculator = function calculator(name, oldParsed, computed) {
5839
+ return computed.value;
5840
+ };
5841
+ _proto.postProcessor = function postProcessor(object) {
5842
+ var _object$parsedStyle = object.parsedStyle,
5843
+ offsetPath = _object$parsedStyle.offsetPath,
5844
+ offsetDistance = _object$parsedStyle.offsetDistance;
5845
+ if (!offsetPath) {
5846
+ return;
5847
+ }
5848
+ var nodeName = offsetPath.nodeName;
5849
+ if (nodeName === exports.Shape.LINE || nodeName === exports.Shape.PATH || nodeName === exports.Shape.POLYLINE) {
5850
+ // set position in world space
5851
+ var point = offsetPath.getPoint(offsetDistance);
5852
+ if (point) {
5853
+ object.parsedStyle.defX = point.x;
5854
+ object.parsedStyle.defY = point.y;
5855
+ object.setLocalPosition(point.x, point.y);
5856
+ }
5857
+ }
5858
+ };
5859
+ return CSSPropertyOffsetDistance;
5860
+ }();
5861
+
5862
+ /**
5863
+ * opacity
5864
+ */
5865
+ var CSSPropertyOpacity = /*#__PURE__*/function () {
5866
+ function CSSPropertyOpacity() {
5867
+ this.parser = parseNumber;
5868
+ this.parserWithCSSDisabled = null;
5869
+ this.mixer = clampedMergeNumbers(0, 1);
5870
+ }
5871
+ var _proto = CSSPropertyOpacity.prototype;
5872
+ _proto.calculator = function calculator(name, oldParsed, computed) {
5873
+ return computed.value;
5874
+ };
5875
+ return CSSPropertyOpacity;
5876
+ }();
5877
+
5878
+ /**
5879
+ * Axis-Aligned Bounding Box
5880
+ * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
5881
+ * @see https://github.com/antvis/GWebGPUEngine/issues/3
5882
+ */
5883
+ var AABB = /*#__PURE__*/function () {
5884
+ function AABB() {
5885
+ this.center = [0, 0, 0];
5886
+ this.halfExtents = [0, 0, 0];
5887
+ this.min = [0, 0, 0];
5888
+ this.max = [0, 0, 0];
5889
+ }
5890
+ AABB.isEmpty = function isEmpty(aabb) {
5891
+ return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
5892
+ };
5893
+ var _proto = AABB.prototype;
5894
+ // center: vec3 = vec3.create();
5895
+ // halfExtents: vec3 = vec3.create();
5896
+ // min: vec3 = vec3.create();
5897
+ // max: vec3 = vec3.create();
5898
+ _proto.update = function update(center, halfExtents) {
5899
+ copyVec3(this.center, center);
5900
+ copyVec3(this.halfExtents, halfExtents);
5901
+ subVec3(this.min, this.center, this.halfExtents);
5902
+ addVec3(this.max, this.center, this.halfExtents);
5903
+ // vec3.copy(this.center, center);
5904
+ // vec3.copy(this.halfExtents, halfExtents);
5905
+ // vec3.sub(this.min, this.center, this.halfExtents);
5906
+ // vec3.add(this.max, this.center, this.halfExtents);
5907
+ };
5908
+ _proto.setMinMax = function setMinMax(min, max) {
5909
+ // vec3.add(this.center, max, min);
5910
+ // vec3.scale(this.center, this.center, 0.5);
5911
+ // vec3.sub(this.halfExtents, max, min);
5912
+ // vec3.scale(this.halfExtents, this.halfExtents, 0.5);
5913
+ // vec3.copy(this.min, min);
5914
+ // vec3.copy(this.max, max);
5915
+ addVec3(this.center, max, min);
5916
+ scaleVec3(this.center, this.center, 0.5);
5917
+ subVec3(this.halfExtents, max, min);
5918
+ scaleVec3(this.halfExtents, this.halfExtents, 0.5);
5919
+ copyVec3(this.min, min);
5920
+ copyVec3(this.max, max);
5921
+ };
5922
+ _proto.getMin = function getMin() {
5923
+ return this.min;
5924
+ };
5925
+ _proto.getMax = function getMax() {
5926
+ return this.max;
5927
+ };
5928
+ _proto.add = function add(aabb) {
5929
+ if (AABB.isEmpty(aabb)) {
5930
+ return;
5931
+ }
5932
+ if (AABB.isEmpty(this)) {
5933
+ this.setMinMax(aabb.getMin(), aabb.getMax());
5934
+ return;
5935
+ }
5936
+ var tc = this.center;
5937
+ var tcx = tc[0];
5938
+ var tcy = tc[1];
5939
+ var tcz = tc[2];
5940
+ var th = this.halfExtents;
5941
+ var thx = th[0];
5942
+ var thy = th[1];
5943
+ var thz = th[2];
5944
+ var tminx = tcx - thx;
5945
+ var tmaxx = tcx + thx;
5946
+ var tminy = tcy - thy;
5947
+ var tmaxy = tcy + thy;
5948
+ var tminz = tcz - thz;
5949
+ var tmaxz = tcz + thz;
5950
+ var oc = aabb.center;
5951
+ var ocx = oc[0];
5952
+ var ocy = oc[1];
5953
+ var ocz = oc[2];
5954
+ var oh = aabb.halfExtents;
5955
+ var ohx = oh[0];
5956
+ var ohy = oh[1];
5957
+ var ohz = oh[2];
5958
+ var ominx = ocx - ohx;
5959
+ var omaxx = ocx + ohx;
5960
+ var ominy = ocy - ohy;
5961
+ var omaxy = ocy + ohy;
5962
+ var ominz = ocz - ohz;
5963
+ var omaxz = ocz + ohz;
5964
+ if (ominx < tminx) {
5965
+ tminx = ominx;
5966
+ }
5967
+ if (omaxx > tmaxx) {
5968
+ tmaxx = omaxx;
5969
+ }
5970
+ if (ominy < tminy) {
5971
+ tminy = ominy;
5972
+ }
5973
+ if (omaxy > tmaxy) {
5974
+ tmaxy = omaxy;
5975
+ }
5976
+ if (ominz < tminz) {
5977
+ tminz = ominz;
5978
+ }
5979
+ if (omaxz > tmaxz) {
5980
+ tmaxz = omaxz;
5981
+ }
5982
+ tc[0] = (tminx + tmaxx) * 0.5;
5983
+ tc[1] = (tminy + tmaxy) * 0.5;
5984
+ tc[2] = (tminz + tmaxz) * 0.5;
5985
+ th[0] = (tmaxx - tminx) * 0.5;
5986
+ th[1] = (tmaxy - tminy) * 0.5;
5987
+ th[2] = (tmaxz - tminz) * 0.5;
5988
+ this.min[0] = tminx;
5989
+ this.min[1] = tminy;
5990
+ this.min[2] = tminz;
5991
+ this.max[0] = tmaxx;
5992
+ this.max[1] = tmaxy;
5993
+ this.max[2] = tmaxz;
5994
+ };
5995
+ _proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
5996
+ var bc = this.center;
5997
+ var br = this.halfExtents;
5998
+ var ac = aabb.center;
5999
+ var ar = aabb.halfExtents;
6000
+ var mx0 = m[0];
6001
+ var mx1 = m[4];
6002
+ var mx2 = m[8];
6003
+ var my0 = m[1];
6004
+ var my1 = m[5];
6005
+ var my2 = m[9];
6006
+ var mz0 = m[2];
6007
+ var mz1 = m[6];
6008
+ var mz2 = m[10];
6009
+ var mx0a = Math.abs(mx0);
6010
+ var mx1a = Math.abs(mx1);
6011
+ var mx2a = Math.abs(mx2);
6012
+ var my0a = Math.abs(my0);
6013
+ var my1a = Math.abs(my1);
6014
+ var my2a = Math.abs(my2);
6015
+ var mz0a = Math.abs(mz0);
6016
+ var mz1a = Math.abs(mz1);
6017
+ var mz2a = Math.abs(mz2);
6018
+ bc[0] = m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2];
6019
+ bc[1] = m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2];
6020
+ bc[2] = m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2];
6021
+ // vec3.set(
6022
+ // bc,
6023
+ // m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
6024
+ // m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
6025
+ // m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
6026
+ // );
6027
+ br[0] = mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2];
6028
+ br[1] = my0a * ar[0] + my1a * ar[1] + my2a * ar[2];
6029
+ br[2] = mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2];
6030
+ // vec3.set(
6031
+ // br,
6032
+ // mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
6033
+ // my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
6034
+ // mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
6035
+ // );
6036
+ // this.min = vec3.sub(this.min, bc, br);
6037
+ // this.max = vec3.add(this.max, bc, br);
6038
+ subVec3(this.min, bc, br);
6039
+ addVec3(this.max, bc, br);
6040
+ };
6041
+ _proto.intersects = function intersects(aabb) {
6042
+ var aMax = this.getMax();
6043
+ var aMin = this.getMin();
6044
+ var bMax = aabb.getMax();
6045
+ var bMin = aabb.getMin();
6046
+ 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];
6047
+ };
6048
+ _proto.intersection = function intersection(aabb) {
6049
+ if (!this.intersects(aabb)) {
6050
+ return null;
6051
+ }
6052
+ var intersection = new AABB();
6053
+ // const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
6054
+ // const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
6055
+ var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
6056
+ var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
6057
+ intersection.setMinMax(min, max);
6058
+ return intersection;
6059
+ }
6060
+ // containsPoint(point: vec3) {
6061
+ // const min = this.getMin();
6062
+ // const max = this.getMax();
6063
+ // return !(
6064
+ // point[0] < min[0] ||
6065
+ // point[0] > max[0] ||
6066
+ // point[1] < min[1] ||
6067
+ // point[1] > max[1] ||
6068
+ // point[2] < min[2] ||
6069
+ // point[2] > max[2]
6070
+ // );
6071
+ // }
6072
+ /**
6073
+ * get n-vertex
6074
+ * @param plane plane of CullingVolume
6075
+ */;
6076
+ _proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
6077
+ if (plane.pnVertexFlag === 0x111) {
6078
+ return copyVec3([0, 0, 0], this.min);
6079
+ // return vec3.copy(vec3.create(), this.min);
6080
+ } else if (plane.pnVertexFlag === 0x110) {
6081
+ return [this.min[0], this.min[1], this.max[2]];
6082
+ // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
6083
+ } else if (plane.pnVertexFlag === 0x101) {
6084
+ return [this.min[0], this.max[1], this.min[2]];
6085
+ // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
6086
+ } else if (plane.pnVertexFlag === 0x100) {
6087
+ return [this.min[0], this.max[1], this.max[2]];
6088
+ // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
6089
+ } else if (plane.pnVertexFlag === 0x011) {
6090
+ return [this.max[0], this.min[1], this.min[2]];
6091
+ // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
6092
+ } else if (plane.pnVertexFlag === 0x010) {
6093
+ return [this.max[0], this.min[1], this.max[2]];
6094
+ // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
6095
+ } else if (plane.pnVertexFlag === 0x001) {
6096
+ return [this.max[0], this.max[1], this.min[2]];
6097
+ // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
6098
+ } else {
6099
+ return [this.max[0], this.max[1], this.max[2]];
6100
+ // return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
6101
+ }
6102
+ }
6103
+ /**
6104
+ * get p-vertex
6105
+ * @param plane plane of CullingVolume
6106
+ */;
6107
+ _proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
6108
+ if (plane.pnVertexFlag === 0x111) {
6109
+ return copyVec3([0, 0, 0], this.max);
6110
+ // return vec3.copy(vec3.create(), this.max);
6111
+ } else if (plane.pnVertexFlag === 0x110) {
6112
+ return [this.max[0], this.max[1], this.min[2]];
6113
+ // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
6114
+ } else if (plane.pnVertexFlag === 0x101) {
6115
+ return [this.max[0], this.min[1], this.max[2]];
6116
+ // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
6117
+ } else if (plane.pnVertexFlag === 0x100) {
6118
+ return [this.max[0], this.min[1], this.min[2]];
6119
+ // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
6120
+ } else if (plane.pnVertexFlag === 0x011) {
6121
+ return [this.min[0], this.max[1], this.max[2]];
6122
+ // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
6123
+ } else if (plane.pnVertexFlag === 0x010) {
6124
+ return [this.min[0], this.max[1], this.min[2]];
6125
+ // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
6126
+ } else if (plane.pnVertexFlag === 0x001) {
6127
+ return [this.min[0], this.min[1], this.max[2]];
6128
+ // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
6129
+ } else {
6130
+ return [this.min[0], this.min[1], this.min[2]];
6131
+ // return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
6224
6132
  }
6225
- return cloned;
6226
6133
  };
6227
- return CSSPropertyMarker;
6134
+ return AABB;
6228
6135
  }();
6229
6136
 
6230
- var CSSPropertyNumber = /*#__PURE__*/function () {
6231
- function CSSPropertyNumber() {
6232
- this.mixer = mergeNumbers;
6233
- this.parser = parseNumber;
6234
- this.parserWithCSSDisabled = null;
6137
+ var Plane = /*#__PURE__*/function () {
6138
+ /**
6139
+ * lookup table for p-vertex & n-vertex when doing frustum culling
6140
+ */
6141
+
6142
+ function Plane(distance, normal) {
6143
+ this.distance = void 0;
6144
+ this.normal = void 0;
6145
+ this.pnVertexFlag = void 0;
6146
+ this.distance = distance || 0;
6147
+ this.normal = normal || glMatrix.vec3.fromValues(0, 1, 0);
6148
+ this.updatePNVertexFlag();
6235
6149
  }
6236
- var _proto = CSSPropertyNumber.prototype;
6237
- _proto.calculator = function calculator(name, oldParsed, computed) {
6238
- return computed.value;
6150
+ var _proto = Plane.prototype;
6151
+ _proto.updatePNVertexFlag = function updatePNVertexFlag() {
6152
+ this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
6239
6153
  };
6240
- return CSSPropertyNumber;
6154
+ _proto.distanceToPoint = function distanceToPoint(point) {
6155
+ return glMatrix.vec3.dot(point, this.normal) - this.distance;
6156
+ };
6157
+ _proto.normalize = function normalize() {
6158
+ var invLen = 1 / glMatrix.vec3.len(this.normal);
6159
+ glMatrix.vec3.scale(this.normal, this.normal, invLen);
6160
+ this.distance *= invLen;
6161
+ };
6162
+ _proto.intersectsLine = function intersectsLine(start, end, point) {
6163
+ var d0 = this.distanceToPoint(start);
6164
+ var d1 = this.distanceToPoint(end);
6165
+ var t = d0 / (d0 - d1);
6166
+ var intersects = t >= 0 && t <= 1;
6167
+ if (intersects && point) {
6168
+ glMatrix.vec3.lerp(point, start, end, t);
6169
+ }
6170
+ return intersects;
6171
+ };
6172
+ return Plane;
6241
6173
  }();
6242
6174
 
6243
- var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
6244
- function CSSPropertyOffsetDistance() {
6245
- this.parser = parseNumber;
6246
- this.parserWithCSSDisabled = null;
6247
- this.mixer = clampedMergeNumbers(0, 1);
6175
+ (function (Mask) {
6176
+ Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
6177
+ Mask[Mask["INSIDE"] = 0] = "INSIDE";
6178
+ Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
6179
+ })(exports.Mask || (exports.Mask = {}));
6180
+ var Frustum = /*#__PURE__*/function () {
6181
+ function Frustum(planes) {
6182
+ this.planes = [];
6183
+ if (planes) {
6184
+ this.planes = planes;
6185
+ } else {
6186
+ for (var i = 0; i < 6; i++) {
6187
+ this.planes.push(new Plane());
6188
+ }
6189
+ }
6248
6190
  }
6249
- var _proto = CSSPropertyOffsetDistance.prototype;
6250
- _proto.calculator = function calculator(name, oldParsed, computed) {
6251
- return computed.value;
6191
+ /**
6192
+ * extract 6 planes from projectionMatrix
6193
+ * @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
6194
+ */
6195
+ var _proto = Frustum.prototype;
6196
+ _proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
6197
+ // @ts-ignore
6198
+ var m0 = projectionMatrix[0],
6199
+ m1 = projectionMatrix[1],
6200
+ m2 = projectionMatrix[2],
6201
+ m3 = projectionMatrix[3],
6202
+ m4 = projectionMatrix[4],
6203
+ m5 = projectionMatrix[5],
6204
+ m6 = projectionMatrix[6],
6205
+ m7 = projectionMatrix[7],
6206
+ m8 = projectionMatrix[8],
6207
+ m9 = projectionMatrix[9],
6208
+ m10 = projectionMatrix[10],
6209
+ m11 = projectionMatrix[11],
6210
+ m12 = projectionMatrix[12],
6211
+ m13 = projectionMatrix[13],
6212
+ m14 = projectionMatrix[14],
6213
+ m15 = projectionMatrix[15];
6214
+ // right
6215
+ glMatrix.vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
6216
+ this.planes[0].distance = m15 - m12;
6217
+ // left
6218
+ glMatrix.vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
6219
+ this.planes[1].distance = m15 + m12;
6220
+ // bottom
6221
+ glMatrix.vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
6222
+ this.planes[2].distance = m15 + m13;
6223
+ // top
6224
+ glMatrix.vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
6225
+ this.planes[3].distance = m15 - m13;
6226
+ // far
6227
+ glMatrix.vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
6228
+ this.planes[4].distance = m15 - m14;
6229
+ // near
6230
+ glMatrix.vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
6231
+ this.planes[5].distance = m15 + m14;
6232
+ this.planes.forEach(function (plane) {
6233
+ plane.normalize();
6234
+ plane.updatePNVertexFlag();
6235
+ });
6252
6236
  };
6253
- _proto.postProcessor = function postProcessor(object) {
6254
- var _object$parsedStyle = object.parsedStyle,
6255
- offsetPath = _object$parsedStyle.offsetPath,
6256
- offsetDistance = _object$parsedStyle.offsetDistance;
6257
- if (!offsetPath) {
6258
- return;
6237
+ return Frustum;
6238
+ }();
6239
+
6240
+ var Point = /*#__PURE__*/function () {
6241
+ function Point(x, y) {
6242
+ if (x === void 0) {
6243
+ x = 0;
6259
6244
  }
6260
- var nodeName = offsetPath.nodeName;
6261
- if (nodeName === exports.Shape.LINE || nodeName === exports.Shape.PATH || nodeName === exports.Shape.POLYLINE) {
6262
- // set position in world space
6263
- var point = offsetPath.getPoint(offsetDistance);
6264
- if (point) {
6265
- object.parsedStyle.defX = point.x;
6266
- object.parsedStyle.defY = point.y;
6267
- object.setLocalPosition(point.x, point.y);
6268
- }
6245
+ if (y === void 0) {
6246
+ y = 0;
6269
6247
  }
6248
+ this.x = 0;
6249
+ this.y = 0;
6250
+ this.x = x;
6251
+ this.y = y;
6252
+ }
6253
+ var _proto = Point.prototype;
6254
+ _proto.clone = function clone() {
6255
+ return new Point(this.x, this.y);
6270
6256
  };
6271
- return CSSPropertyOffsetDistance;
6257
+ _proto.copyFrom = function copyFrom(p) {
6258
+ this.x = p.x;
6259
+ this.y = p.y;
6260
+ };
6261
+ return Point;
6272
6262
  }();
6273
6263
 
6274
- /**
6275
- * opacity
6276
- */
6277
- var CSSPropertyOpacity = /*#__PURE__*/function () {
6278
- function CSSPropertyOpacity() {
6279
- this.parser = parseNumber;
6280
- this.parserWithCSSDisabled = null;
6281
- this.mixer = clampedMergeNumbers(0, 1);
6264
+ var Rectangle = /*#__PURE__*/function () {
6265
+ function Rectangle(x, y, width, height) {
6266
+ this.x = void 0;
6267
+ this.y = void 0;
6268
+ this.width = void 0;
6269
+ this.height = void 0;
6270
+ this.left = void 0;
6271
+ this.right = void 0;
6272
+ this.top = void 0;
6273
+ this.bottom = void 0;
6274
+ this.x = x;
6275
+ this.y = y;
6276
+ this.width = width;
6277
+ this.height = height;
6278
+ this.left = x;
6279
+ this.right = x + width;
6280
+ this.top = y;
6281
+ this.bottom = y + height;
6282
6282
  }
6283
- var _proto = CSSPropertyOpacity.prototype;
6284
- _proto.calculator = function calculator(name, oldParsed, computed) {
6285
- return computed.value;
6286
- };
6287
- return CSSPropertyOpacity;
6283
+ var _proto = Rectangle.prototype;
6284
+ _proto.toJSON = function toJSON() {};
6285
+ return Rectangle;
6288
6286
  }();
6289
6287
 
6290
6288
  var CSSPropertyPath = /*#__PURE__*/function () {
@@ -6329,6 +6327,7 @@ var CSSPropertyPath = /*#__PURE__*/function () {
6329
6327
  var CSSPropertyPoints = /*#__PURE__*/function () {
6330
6328
  function CSSPropertyPoints() {
6331
6329
  this.parser = parsePoints;
6330
+ this.mixer = mergePoints;
6332
6331
  }
6333
6332
  var _proto = CSSPropertyPoints.prototype;
6334
6333
  /**
@@ -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: glMatrix.mat4.create(),
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: glMatrix.mat4.create(),
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 : [getOrCreateUnitValue(50, '%'), getOrCreateUnitValue(50, '%')]
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 : [getOrCreateUnitValue(50, '%'), getOrCreateUnitValue(50, '%')]
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: exports.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.geometry.dirty = true;
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 geometryUpdater = runtime.geometryUpdaterFactory[object.nodeName];
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 (object.nodeName === exports.Shape.TEXT) {
11140
+ if (nodeName === exports.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 = object.nodeName === exports.Shape.POLYLINE || object.nodeName === exports.Shape.POLYGON || object.nodeName === exports.Shape.PATH ? Math.SQRT2 : 0.5;
11153
+ var expansion = nodeName === exports.Shape.POLYLINE || nodeName === exports.Shape.POLYGON || nodeName === exports.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
- geometry.dirty = false;
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
- // runtime.sceneGraphService.dirtifyToRoot(object);
11237
+ runtime.sceneGraphService.dirtifyToRoot(object);
11241
11238
  }
11242
11239
  };
11243
11240
  _proto.isPropertyInheritable = function isPropertyInheritable(name) {
@@ -13793,10 +13790,10 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13793
13790
  z = 0;
13794
13791
  }
13795
13792
  if (typeof origin === 'number') {
13796
- origin = glMatrix.vec3.fromValues(origin, y, z);
13793
+ origin = [origin, y, z];
13797
13794
  }
13798
13795
  var transform = element.transformable;
13799
- if (glMatrix.vec3.equals(origin, transform.origin)) {
13796
+ if (origin[0] === transform.origin[0] && origin[1] === transform.origin[1] && origin[2] === transform.origin[2]) {
13800
13797
  return;
13801
13798
  }
13802
13799
  var originVec = transform.origin;
@@ -14072,9 +14069,6 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
14072
14069
  render = false;
14073
14070
  }
14074
14071
  var geometry = element.geometry;
14075
- if (geometry.dirty) {
14076
- runtime.styleValueRegistry.updateGeometry(element);
14077
- }
14078
14072
  var bounds = render ? geometry.renderBounds : geometry.contentBounds || null;
14079
14073
  // return (bounds && new AABB(bounds.center, bounds.halfExtents)) || new AABB();
14080
14074
  return bounds || new AABB();
@@ -14116,7 +14110,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
14116
14110
  var clipped = findClosestClipPathTarget(element);
14117
14111
  if (clipped) {
14118
14112
  // use bounds under world space
14119
- var clipPathBounds = clipped.style.clipPath.getBounds(render);
14113
+ var clipPathBounds = clipped.parsedStyle.clipPath.getBounds(render);
14120
14114
  if (!aabb) {
14121
14115
  aabb = clipPathBounds;
14122
14116
  } else if (clipPathBounds) {
@@ -14393,19 +14387,19 @@ var TextService = /*#__PURE__*/function () {
14393
14387
  leading = _parsedStyle$leading === void 0 ? 0 : _parsedStyle$leading;
14394
14388
  var font = toFontString(parsedStyle);
14395
14389
  var fontProperties;
14396
- if (runtime.enableCSSParsing) {
14397
- fontProperties = this.measureFont(font, offscreenCanvas);
14398
- // fallback in case UA disallow canvas data extraction
14399
- // (toDataURI, getImageData functions)
14400
- if (fontProperties.fontSize === 0) {
14401
- fontProperties.fontSize = fontSize;
14402
- fontProperties.ascent = fontSize;
14403
- }
14404
- } else {
14405
- fontProperties = {
14406
- fontSize: fontSize
14407
- };
14408
- }
14390
+ // if (runtime.enableCSSParsing) {
14391
+ fontProperties = this.measureFont(font, offscreenCanvas);
14392
+ // fallback in case UA disallow canvas data extraction
14393
+ // (toDataURI, getImageData functions)
14394
+ if (fontProperties.fontSize === 0) {
14395
+ fontProperties.fontSize = fontSize;
14396
+ fontProperties.ascent = fontSize;
14397
+ }
14398
+ // } else {
14399
+ // fontProperties = {
14400
+ // fontSize,
14401
+ // };
14402
+ // }
14409
14403
  var context = this.runtime.offscreenCanvas.getOrCreateContext(offscreenCanvas);
14410
14404
  context.font = font;
14411
14405
  // no overflowing by default
@@ -14854,7 +14848,7 @@ var EventPlugin = /*#__PURE__*/function () {
14854
14848
  var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
14855
14849
  for (var _iterator = _createForOfIteratorHelperLoose(normalizedEvents), _step; !(_step = _iterator()).done;) {
14856
14850
  var normalizedEvent = _step.value;
14857
- var event = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas);
14851
+ var event = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas, nativeEvent);
14858
14852
  _this.context.eventService.mapEvent(event);
14859
14853
  }
14860
14854
  _this.setCursor(_this.context.eventService.cursor);
@@ -14909,7 +14903,7 @@ var EventPlugin = /*#__PURE__*/function () {
14909
14903
  }
14910
14904
  for (var _iterator2 = _createForOfIteratorHelperLoose(events), _step2; !(_step2 = _iterator2()).done;) {
14911
14905
  var event = _step2.value;
14912
- var federatedEvent = _this2.bootstrapEvent(_this2.rootPointerEvent, event, canvas);
14906
+ var federatedEvent = _this2.bootstrapEvent(_this2.rootPointerEvent, event, canvas, nativeEvent);
14913
14907
  _this2.context.eventService.mapEvent(federatedEvent);
14914
14908
  }
14915
14909
  _this2.setCursor(_this2.context.eventService.cursor);
@@ -14928,7 +14922,7 @@ var EventPlugin = /*#__PURE__*/function () {
14928
14922
  var normalizedEvents = _this2.normalizeToPointerEvent(nativeEvent, canvas);
14929
14923
  for (var _iterator3 = _createForOfIteratorHelperLoose(normalizedEvents), _step3; !(_step3 = _iterator3()).done;) {
14930
14924
  var normalizedEvent = _step3.value;
14931
- var event = _this2.bootstrapEvent(_this2.rootPointerEvent, normalizedEvent, canvas);
14925
+ var event = _this2.bootstrapEvent(_this2.rootPointerEvent, normalizedEvent, canvas, nativeEvent);
14932
14926
  event.type += outside;
14933
14927
  _this2.context.eventService.mapEvent(event);
14934
14928
  }
@@ -14963,22 +14957,22 @@ var EventPlugin = /*#__PURE__*/function () {
14963
14957
  y: y
14964
14958
  };
14965
14959
  };
14966
- _proto.bootstrapEvent = function bootstrapEvent(event, nativeEvent, view) {
14960
+ _proto.bootstrapEvent = function bootstrapEvent(event, normalizedEvent, view, nativeEvent) {
14967
14961
  event.view = view;
14968
14962
  event.originalEvent = null;
14969
14963
  event.nativeEvent = nativeEvent;
14970
- event.pointerId = nativeEvent.pointerId;
14971
- event.width = nativeEvent.width;
14972
- event.height = nativeEvent.height;
14973
- event.isPrimary = nativeEvent.isPrimary;
14974
- event.pointerType = nativeEvent.pointerType;
14975
- event.pressure = nativeEvent.pressure;
14976
- event.tangentialPressure = nativeEvent.tangentialPressure;
14977
- event.tiltX = nativeEvent.tiltX;
14978
- event.tiltY = nativeEvent.tiltY;
14979
- event.twist = nativeEvent.twist;
14980
- this.transferMouseData(event, nativeEvent);
14981
- var _this$getViewportXY = this.getViewportXY(nativeEvent),
14964
+ event.pointerId = normalizedEvent.pointerId;
14965
+ event.width = normalizedEvent.width;
14966
+ event.height = normalizedEvent.height;
14967
+ event.isPrimary = normalizedEvent.isPrimary;
14968
+ event.pointerType = normalizedEvent.pointerType;
14969
+ event.pressure = normalizedEvent.pressure;
14970
+ event.tangentialPressure = normalizedEvent.tangentialPressure;
14971
+ event.tiltX = normalizedEvent.tiltX;
14972
+ event.tiltY = normalizedEvent.tiltY;
14973
+ event.twist = normalizedEvent.twist;
14974
+ this.transferMouseData(event, normalizedEvent);
14975
+ var _this$getViewportXY = this.getViewportXY(normalizedEvent),
14982
14976
  x = _this$getViewportXY.x,
14983
14977
  y = _this$getViewportXY.y;
14984
14978
  event.viewport.x = x;