@antv/g-lite 1.0.45 → 1.0.47

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.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$style;
1660
- var clipPath = (_el$style = el.style) === null || _el$style === void 0 ? void 0 : _el$style.clipPath;
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
- // @ts-ignore
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,567 +4574,149 @@ 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
- * Axis-Aligned Bounding Box
4579
- * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
4580
- * @see https://github.com/antvis/GWebGPUEngine/issues/3
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 AABB = /*#__PURE__*/function () {
4583
- AABB.isEmpty = function isEmpty(aabb) {
4584
- return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
4585
- };
4586
- // center: vec3 = vec3.create();
4587
- // halfExtents: vec3 = vec3.create();
4588
- // min: vec3 = vec3.create();
4589
- // max: vec3 = vec3.create();
4590
- function AABB(center, halfExtents) {
4591
- if (center === void 0) {
4592
- center = [0, 0, 0];
4593
- }
4594
- if (halfExtents === void 0) {
4595
- halfExtents = [0, 0, 0];
4596
- }
4597
- this.center = [0, 0, 0];
4598
- this.halfExtents = [0, 0, 0];
4599
- this.min = [0, 0, 0];
4600
- this.max = [0, 0, 0];
4601
- this.update(center, halfExtents);
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
+ return getOrCreateUnitValue(Number(css), 'px');
4629
+ // return Number(css);
4602
4630
  }
4603
- var _proto = AABB.prototype;
4604
- _proto.update = function update(center, halfExtents) {
4605
- copyVec3(this.center, center);
4606
- copyVec3(this.halfExtents, halfExtents);
4607
- subVec3(this.min, this.center, this.halfExtents);
4608
- addVec3(this.max, this.center, this.halfExtents);
4609
- // vec3.copy(this.center, center);
4610
- // vec3.copy(this.halfExtents, halfExtents);
4611
- // vec3.sub(this.min, this.center, this.halfExtents);
4612
- // vec3.add(this.max, this.center, this.halfExtents);
4613
- };
4614
- _proto.setMinMax = function setMinMax(min, max) {
4615
- // vec3.add(this.center, max, min);
4616
- // vec3.scale(this.center, this.center, 0.5);
4617
- // vec3.sub(this.halfExtents, max, min);
4618
- // vec3.scale(this.halfExtents, this.halfExtents, 0.5);
4619
- // vec3.copy(this.min, min);
4620
- // vec3.copy(this.max, max);
4621
- addVec3(this.center, max, min);
4622
- scaleVec3(this.center, this.center, 0.5);
4623
- subVec3(this.halfExtents, max, min);
4624
- scaleVec3(this.halfExtents, this.halfExtents, 0.5);
4625
- copyVec3(this.min, min);
4626
- copyVec3(this.max, max);
4627
- };
4628
- _proto.getMin = function getMin() {
4629
- return this.min;
4630
- };
4631
- _proto.getMax = function getMax() {
4632
- return this.max;
4633
- };
4634
- _proto.add = function add(aabb) {
4635
- if (AABB.isEmpty(aabb)) {
4636
- return;
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;
4631
+
4632
+ return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
4633
+ };
4634
+ var parseAngle = memoize(function (css) {
4635
+ return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
4636
+ });
4637
+ /**
4638
+ * merge CSSUnitValue
4639
+ *
4640
+ * @example
4641
+ * 10px + 20px = 30px
4642
+ * 10deg + 10rad
4643
+ * 10% + 20% = 30%
4644
+ */
4645
+ function mergeDimensions(left, right, target, nonNegative, index) {
4646
+ if (index === void 0) {
4647
+ index = 0;
4648
+ }
4649
+ var unit = '';
4650
+ var leftValue = left.value || 0;
4651
+ var rightValue = right.value || 0;
4652
+ var canonicalUnit = toCanonicalUnit(left.unit);
4653
+ var leftCanonicalUnitValue = left.convertTo(canonicalUnit);
4654
+ var rightCanonicalUnitValue = right.convertTo(canonicalUnit);
4655
+ if (leftCanonicalUnitValue && rightCanonicalUnitValue) {
4656
+ leftValue = leftCanonicalUnitValue.value;
4657
+ rightValue = rightCanonicalUnitValue.value;
4658
+ unit = unitTypeToString(left.unit);
4659
+ } else {
4660
+ // format '%' to 'px'
4661
+ if (CSSUnitValue.isLength(left.unit) || CSSUnitValue.isLength(right.unit)) {
4662
+ leftValue = convertPercentUnit(left, index, target);
4663
+ rightValue = convertPercentUnit(right, index, target);
4664
+ unit = 'px';
4678
4665
  }
4679
- if (omaxy > tmaxy) {
4680
- tmaxy = omaxy;
4666
+ }
4667
+ // // format 'rad' 'turn' to 'deg'
4668
+ // if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
4669
+ // leftValue = convertAngleUnit(left);
4670
+ // rightValue = convertAngleUnit(right);
4671
+ // unit = 'deg';
4672
+ // }
4673
+ return [leftValue, rightValue, function (value) {
4674
+ if (nonNegative) {
4675
+ value = Math.max(value, 0);
4681
4676
  }
4682
- if (ominz < tminz) {
4683
- tminz = ominz;
4677
+ return value + unit;
4678
+ }];
4679
+ }
4680
+ function convertAngleUnit(value) {
4681
+ var deg = 0;
4682
+ if (value.unit === UnitType.kDegrees) {
4683
+ deg = value.value;
4684
+ } else if (value.unit === UnitType.kRadians) {
4685
+ deg = rad2deg(Number(value.value));
4686
+ } else if (value.unit === UnitType.kTurns) {
4687
+ deg = turn2deg(Number(value.value));
4688
+ }
4689
+ return deg;
4690
+ }
4691
+ function parseDimensionArrayFormat(string, size) {
4692
+ var parsed;
4693
+ if (Array.isArray(string)) {
4694
+ // [1, '2px', 3]
4695
+ parsed = string.map(function (segment) {
4696
+ return Number(segment);
4697
+ });
4698
+ } else if (isString(string)) {
4699
+ parsed = string.split(' ').map(function (segment) {
4700
+ return Number(segment);
4701
+ });
4702
+ } else if (isNumber(string)) {
4703
+ parsed = [string];
4704
+ }
4705
+ if (size === 2) {
4706
+ if (parsed.length === 1) {
4707
+ return [parsed[0], parsed[0]];
4708
+ } else {
4709
+ return [parsed[0], parsed[1]];
4684
4710
  }
4685
- if (omaxz > tmaxz) {
4686
- tmaxz = omaxz;
4687
- }
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
- }
4766
- // containsPoint(point: vec3) {
4767
- // const min = this.getMin();
4768
- // const max = this.getMax();
4769
- // return !(
4770
- // point[0] < min[0] ||
4771
- // point[0] > max[0] ||
4772
- // point[1] < min[1] ||
4773
- // point[1] > max[1] ||
4774
- // point[2] < min[2] ||
4775
- // point[2] > max[2]
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
- }
4808
- }
4809
- /**
4810
- * get p-vertex
4811
- * @param plane plane of CullingVolume
4812
- */;
4813
- _proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
4814
- if (plane.pnVertexFlag === 0x111) {
4815
- return copyVec3([0, 0, 0], this.max);
4816
- // return vec3.copy(vec3.create(), this.max);
4817
- } else if (plane.pnVertexFlag === 0x110) {
4818
- return [this.max[0], this.max[1], this.min[2]];
4819
- // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
4820
- } else if (plane.pnVertexFlag === 0x101) {
4821
- return [this.max[0], this.min[1], this.max[2]];
4822
- // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
4823
- } else if (plane.pnVertexFlag === 0x100) {
4824
- return [this.max[0], this.min[1], this.min[2]];
4825
- // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
4826
- } else if (plane.pnVertexFlag === 0x011) {
4827
- return [this.min[0], this.max[1], this.max[2]];
4828
- // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
4829
- } else if (plane.pnVertexFlag === 0x010) {
4830
- return [this.min[0], this.max[1], this.min[2]];
4831
- // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
4832
- } else if (plane.pnVertexFlag === 0x001) {
4833
- return [this.min[0], this.min[1], this.max[2]];
4834
- // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
4835
- } else {
4836
- return [this.min[0], this.min[1], this.min[2]];
4837
- // return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
4838
- }
4839
- };
4840
- return AABB;
4841
- }();
4842
-
4843
- var Plane = /*#__PURE__*/function () {
4844
- /**
4845
- * lookup table for p-vertex & n-vertex when doing frustum culling
4846
- */
4847
-
4848
- function Plane(distance, normal) {
4849
- this.distance = void 0;
4850
- this.normal = void 0;
4851
- this.pnVertexFlag = void 0;
4852
- this.distance = distance || 0;
4853
- this.normal = normal || vec3.fromValues(0, 1, 0);
4854
- this.updatePNVertexFlag();
4855
- }
4856
- var _proto = Plane.prototype;
4857
- _proto.updatePNVertexFlag = function updatePNVertexFlag() {
4858
- this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
4859
- };
4860
- _proto.distanceToPoint = function distanceToPoint(point) {
4861
- return vec3.dot(point, this.normal) - this.distance;
4862
- };
4863
- _proto.normalize = function normalize() {
4864
- var invLen = 1 / vec3.len(this.normal);
4865
- vec3.scale(this.normal, this.normal, invLen);
4866
- this.distance *= invLen;
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);
4875
- }
4876
- return intersects;
4877
- };
4878
- return Plane;
4879
- }();
4880
-
4881
- var Mask;
4882
- (function (Mask) {
4883
- Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
4884
- Mask[Mask["INSIDE"] = 0] = "INSIDE";
4885
- Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
4886
- })(Mask || (Mask = {}));
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
- }
4896
- }
4897
- }
4898
- /**
4899
- * extract 6 planes from projectionMatrix
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
- }();
4994
-
4995
- function parseDimension(unitRegExp, string) {
4996
- if (isNil(string)) {
4997
- return getOrCreateUnitValue(0, 'px');
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];
5016
- }
5017
- /**
5018
- * <length>
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);
5035
- *
5036
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
5037
- */
5038
- // export const parseLengthOrPercentage = memoize((css: string): CSSUnitValue => {
5039
- // if (isNumber(css) || isFinite(Number(css))) {
5040
- // return getOrCreateUnitValue(Number(css), 'px');
5041
- // }
5042
- // return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
5043
- // });
5044
- var parseLengthOrPercentage = function parseLengthOrPercentage(css) {
5045
- if (isNumber(css) || isFinite(Number(css))) {
5046
- return getOrCreateUnitValue(Number(css), 'px');
5047
- // return Number(css);
5048
- }
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
- });
5055
- /**
5056
- * merge CSSUnitValue
5057
- *
5058
- * @example
5059
- * 10px + 20px = 30px
5060
- * 10deg + 10rad
5061
- * 10% + 20% = 30%
5062
- */
5063
- function mergeDimensions(left, right, target, nonNegative, index) {
5064
- if (index === void 0) {
5065
- index = 0;
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);
5077
- } else {
5078
- // format '%' to 'px'
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
- }
5084
- }
5085
- // // format 'rad' 'turn' to 'deg'
5086
- // if (CSSUnitValue.isAngle(left.unit) || CSSUnitValue.isAngle(right.unit)) {
5087
- // leftValue = convertAngleUnit(left);
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
- }];
5097
- }
5098
- function convertAngleUnit(value) {
5099
- var deg = 0;
5100
- if (value.unit === UnitType.kDegrees) {
5101
- deg = value.value;
5102
- } else if (value.unit === UnitType.kRadians) {
5103
- deg = rad2deg(Number(value.value));
5104
- } else if (value.unit === UnitType.kTurns) {
5105
- deg = turn2deg(Number(value.value));
5106
- }
5107
- return deg;
5108
- }
5109
- function parseDimensionArrayFormat(string, size) {
5110
- var parsed;
5111
- if (Array.isArray(string)) {
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]];
4711
+ } else {
4712
+ if (parsed.length === 1) {
4713
+ return [parsed[0], parsed[0], parsed[0], parsed[0]];
4714
+ } else if (parsed.length === 2) {
4715
+ return [parsed[0], parsed[1], parsed[0], parsed[1]];
4716
+ } else if (parsed.length === 3) {
4717
+ return [parsed[0], parsed[1], parsed[2], parsed[1]];
4718
+ } else {
4719
+ return [parsed[0], parsed[1], parsed[2], parsed[3]];
5138
4720
  }
5139
4721
  }
5140
4722
  }
@@ -5169,17 +4751,16 @@ function parseDimensionArray(string) {
5169
4751
  // ];
5170
4752
  // }
5171
4753
  function convertPercentUnit(valueWithUnit, vec3Index, target) {
4754
+ if (valueWithUnit.value === 0) {
4755
+ return 0;
4756
+ }
5172
4757
  if (valueWithUnit.unit === UnitType.kPixels) {
5173
4758
  return Number(valueWithUnit.value);
5174
4759
  } else if (valueWithUnit.unit === UnitType.kPercentage && target) {
5175
4760
  var bounds = target.nodeName === Shape.GROUP ? target.getLocalBounds() :
5176
4761
  // : target.getGeometryBounds();
5177
4762
  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;
4763
+ return valueWithUnit.value / 100 * bounds.halfExtents[vec3Index] * 2;
5183
4764
  }
5184
4765
  return 0;
5185
4766
  }
@@ -5869,420 +5450,831 @@ function mergeTransforms(left, right, target) {
5869
5450
  leftResult = rightResult;
5870
5451
  rightResult = tmp;
5871
5452
  }
5872
- return [leftResult, rightResult, function (list) {
5873
- return list.map(function (args, i) {
5874
- var stringifiedArgs = args.map(function (arg, j) {
5875
- return types[i][1][j](arg);
5876
- }).join(',');
5877
- if (types[i][0] === 'matrix' && stringifiedArgs.split(',').length === 16) {
5878
- types[i][0] = 'matrix3d';
5879
- }
5880
- if (types[i][0] === 'matrix3d' && stringifiedArgs.split(',').length === 6) {
5881
- types[i][0] = 'matrix';
5882
- }
5883
- return types[i][0] + '(' + stringifiedArgs + ')';
5884
- }).join(' ');
5885
- }];
5886
- }
5453
+ return [leftResult, rightResult, function (list) {
5454
+ return list.map(function (args, i) {
5455
+ var stringifiedArgs = args.map(function (arg, j) {
5456
+ return types[i][1][j](arg);
5457
+ }).join(',');
5458
+ if (types[i][0] === 'matrix' && stringifiedArgs.split(',').length === 16) {
5459
+ types[i][0] = 'matrix3d';
5460
+ }
5461
+ if (types[i][0] === 'matrix3d' && stringifiedArgs.split(',').length === 6) {
5462
+ types[i][0] = 'matrix';
5463
+ }
5464
+ return types[i][0] + '(' + stringifiedArgs + ')';
5465
+ }).join(' ');
5466
+ }];
5467
+ }
5468
+
5469
+ /**
5470
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/transform-origin
5471
+ * eg. 'center' 'top left' '50px 50px'
5472
+ */
5473
+ var parseTransformOrigin = memoize(function (value) {
5474
+ if (isString(value)) {
5475
+ if (value === 'text-anchor') {
5476
+ return [getOrCreateUnitValue(0, 'px'), getOrCreateUnitValue(0, 'px')];
5477
+ }
5478
+ var values = value.split(' ');
5479
+ if (values.length === 1) {
5480
+ if (values[0] === 'top' || values[0] === 'bottom') {
5481
+ // 'top' -> 'center top'
5482
+ values[1] = values[0];
5483
+ values[0] = 'center';
5484
+ } else {
5485
+ // '50px' -> '50px center'
5486
+ values[1] = 'center';
5487
+ }
5488
+ }
5489
+ if (values.length !== 2) {
5490
+ return null;
5491
+ }
5492
+ // eg. center bottom
5493
+ return [parseLengthOrPercentage(convertKeyword2Percent(values[0])), parseLengthOrPercentage(convertKeyword2Percent(values[1]))];
5494
+ } else {
5495
+ return [getOrCreateUnitValue(value[0] || 0, 'px'), getOrCreateUnitValue(value[1] || 0, 'px')];
5496
+ }
5497
+ });
5498
+ function convertKeyword2Percent(keyword) {
5499
+ if (keyword === 'center') {
5500
+ return '50%';
5501
+ } else if (keyword === 'left' || keyword === 'top') {
5502
+ return '0';
5503
+ } else if (keyword === 'right' || keyword === 'bottom') {
5504
+ return '100%';
5505
+ }
5506
+ return keyword;
5507
+ }
5508
+
5509
+ var CSSPropertyAngle = /*#__PURE__*/function () {
5510
+ function CSSPropertyAngle() {
5511
+ this.parser = parseAngle;
5512
+ this.parserWithCSSDisabled = null;
5513
+ this.mixer = mergeNumbers;
5514
+ }
5515
+ var _proto = CSSPropertyAngle.prototype;
5516
+ _proto.calculator = function calculator(name, oldParsed, parsed, object) {
5517
+ return convertAngleUnit(parsed);
5518
+ };
5519
+ return CSSPropertyAngle;
5520
+ }();
5521
+
5522
+ /**
5523
+ * clipPath / textPath / offsetPath
5524
+ */
5525
+ var CSSPropertyClipPath = /*#__PURE__*/function () {
5526
+ function CSSPropertyClipPath() {}
5527
+ var _proto = CSSPropertyClipPath.prototype;
5528
+ _proto.calculator = function calculator(name, oldPath, newPath, object) {
5529
+ // unset
5530
+ if (newPath instanceof CSSKeywordValue) {
5531
+ newPath = null;
5532
+ }
5533
+ runtime.sceneGraphService.updateDisplayObjectDependency(name, oldPath, newPath, object);
5534
+ if (name === 'clipPath') {
5535
+ // should affect children
5536
+ object.forEach(function (leaf) {
5537
+ if (leaf.childNodes.length === 0) {
5538
+ runtime.sceneGraphService.dirtifyToRoot(leaf);
5539
+ }
5540
+ });
5541
+ }
5542
+ return newPath;
5543
+ };
5544
+ return CSSPropertyClipPath;
5545
+ }();
5546
+
5547
+ var CSSPropertyColor = /*#__PURE__*/function () {
5548
+ function CSSPropertyColor() {
5549
+ this.parser = parseColor;
5550
+ this.parserWithCSSDisabled = parseColor;
5551
+ this.mixer = mergeColors;
5552
+ }
5553
+ var _proto = CSSPropertyColor.prototype;
5554
+ _proto.calculator = function calculator(name, oldParsed, parsed, object) {
5555
+ if (parsed instanceof CSSKeywordValue) {
5556
+ // 'unset' 'none'
5557
+ return parsed.value === 'none' ? noneColor : transparentColor;
5558
+ }
5559
+ return parsed;
5560
+ };
5561
+ return CSSPropertyColor;
5562
+ }();
5563
+
5564
+ var CSSPropertyFilter = /*#__PURE__*/function () {
5565
+ function CSSPropertyFilter() {
5566
+ this.parser = parseFilter;
5567
+ }
5568
+ var _proto = CSSPropertyFilter.prototype;
5569
+ _proto.calculator = function calculator(name, oldParsed, parsed) {
5570
+ // unset or none
5571
+ if (parsed instanceof CSSKeywordValue) {
5572
+ return [];
5573
+ }
5574
+ return parsed;
5575
+ };
5576
+ return CSSPropertyFilter;
5577
+ }();
5887
5578
 
5579
+ function getFontSize(object) {
5580
+ var fontSize = object.parsedStyle.fontSize;
5581
+ return isNil(fontSize) ? null : fontSize;
5582
+ }
5888
5583
  /**
5889
- * @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/transform-origin
5890
- * eg. 'center' 'top left' '50px 50px'
5584
+ * <length> & <percentage>
5891
5585
  */
5892
- var parseTransformOrigin = memoize(function (value) {
5893
- if (isString(value)) {
5894
- if (value === 'text-anchor') {
5895
- return [getOrCreateUnitValue(0, 'px'), getOrCreateUnitValue(0, 'px')];
5586
+ var CSSPropertyLengthOrPercentage = /*#__PURE__*/function () {
5587
+ function CSSPropertyLengthOrPercentage() {
5588
+ this.parser = parseLengthOrPercentage;
5589
+ this.parserWithCSSDisabled = null;
5590
+ this.mixer = mergeNumbers;
5591
+ }
5592
+ var _proto = CSSPropertyLengthOrPercentage.prototype;
5593
+ /**
5594
+ * according to parent's bounds
5595
+ *
5596
+ * @example
5597
+ * CSS.percent(50) -> CSS.px(0.5 * parent.width)
5598
+ */
5599
+ _proto.calculator = function calculator(name, oldParsed, computed, object, registry) {
5600
+ if (isNumber(computed)) {
5601
+ return computed;
5896
5602
  }
5897
- var values = value.split(' ');
5898
- if (values.length === 1) {
5899
- if (values[0] === 'top' || values[0] === 'bottom') {
5900
- // 'top' -> 'center top'
5901
- values[1] = values[0];
5902
- values[0] = 'center';
5903
- } else {
5904
- // '50px' -> '50px center'
5905
- values[1] = 'center';
5603
+ if (CSSUnitValue.isRelativeUnit(computed.unit)) {
5604
+ if (computed.unit === UnitType.kPercentage) {
5605
+ // TODO: merge dimensions
5606
+ return 0;
5607
+ } else if (computed.unit === UnitType.kEms) {
5608
+ if (object.parentNode) {
5609
+ var fontSize = getFontSize(object.parentNode);
5610
+ if (fontSize) {
5611
+ fontSize *= computed.value;
5612
+ return fontSize;
5613
+ } else {
5614
+ registry.addUnresolveProperty(object, name);
5615
+ }
5616
+ } else {
5617
+ registry.addUnresolveProperty(object, name);
5618
+ }
5619
+ return 0;
5620
+ } else if (computed.unit === UnitType.kRems) {
5621
+ var _object$ownerDocument;
5622
+ if (object === null || object === void 0 ? void 0 : (_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.documentElement) {
5623
+ var _fontSize = getFontSize(object.ownerDocument.documentElement);
5624
+ if (_fontSize) {
5625
+ _fontSize *= computed.value;
5626
+ return _fontSize;
5627
+ } else {
5628
+ registry.addUnresolveProperty(object, name);
5629
+ }
5630
+ } else {
5631
+ registry.addUnresolveProperty(object, name);
5632
+ }
5633
+ return 0;
5906
5634
  }
5635
+ } else {
5636
+ // remove listener if exists
5637
+ // registry.unregisterParentGeometryBoundsChangedHandler(object, name);
5638
+ // return absolute value
5639
+ return computed.value;
5907
5640
  }
5908
- if (values.length !== 2) {
5909
- return null;
5910
- }
5911
- // eg. center bottom
5912
- return [parseLengthOrPercentage(convertKeyword2Percent(values[0])), parseLengthOrPercentage(convertKeyword2Percent(values[1]))];
5913
- } else {
5914
- return [getOrCreateUnitValue(value[0] || 0, 'px'), getOrCreateUnitValue(value[1] || 0, 'px')];
5641
+ };
5642
+ return CSSPropertyLengthOrPercentage;
5643
+ }();
5644
+
5645
+ /**
5646
+ * format to Tuple2<CSSUnitValue>
5647
+ *
5648
+ * @example
5649
+ * rect.style.lineDash = 10;
5650
+ * rect.style.lineDash = [10, 10];
5651
+ * rect.style.lineDash = '10 10';
5652
+ */
5653
+ var CSSPropertyLengthOrPercentage12 = /*#__PURE__*/function () {
5654
+ function CSSPropertyLengthOrPercentage12() {
5655
+ this.mixer = mergeNumberLists;
5915
5656
  }
5916
- });
5917
- function convertKeyword2Percent(keyword) {
5918
- if (keyword === 'center') {
5919
- return '50%';
5920
- } else if (keyword === 'left' || keyword === 'top') {
5921
- return '0';
5922
- } else if (keyword === 'right' || keyword === 'bottom') {
5923
- return '100%';
5657
+ var _proto = CSSPropertyLengthOrPercentage12.prototype;
5658
+ _proto.parser = function parser(radius) {
5659
+ var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
5660
+ var formatted;
5661
+ if (parsed.length === 1) {
5662
+ formatted = [parsed[0], parsed[0]];
5663
+ } else {
5664
+ formatted = [parsed[0], parsed[1]];
5665
+ }
5666
+ return formatted;
5667
+ };
5668
+ _proto.calculator = function calculator(name, oldParsed, computed) {
5669
+ return computed.map(function (c) {
5670
+ return c.value;
5671
+ });
5672
+ };
5673
+ return CSSPropertyLengthOrPercentage12;
5674
+ }();
5675
+
5676
+ /**
5677
+ * used in rounded rect
5678
+ *
5679
+ * @example
5680
+ * rect.style.radius = 10;
5681
+ * rect.style.radius = '10 10';
5682
+ * rect.style.radius = '10 10 10 10';
5683
+ */
5684
+ var CSSPropertyLengthOrPercentage14 = /*#__PURE__*/function () {
5685
+ function CSSPropertyLengthOrPercentage14() {
5686
+ this.mixer = mergeNumberLists;
5924
5687
  }
5925
- return keyword;
5926
- }
5688
+ var _proto = CSSPropertyLengthOrPercentage14.prototype;
5689
+ _proto.parser = function parser(radius) {
5690
+ var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
5691
+ var formatted;
5692
+ // format to Tuple<CSSUnitValue>
5693
+ if (parsed.length === 1) {
5694
+ formatted = [parsed[0], parsed[0], parsed[0], parsed[0]];
5695
+ } else if (parsed.length === 2) {
5696
+ formatted = [parsed[0], parsed[1], parsed[0], parsed[1]];
5697
+ } else if (parsed.length === 3) {
5698
+ formatted = [parsed[0], parsed[1], parsed[2], parsed[1]];
5699
+ } else {
5700
+ formatted = [parsed[0], parsed[1], parsed[2], parsed[3]];
5701
+ }
5702
+ return formatted;
5703
+ };
5704
+ _proto.calculator = function calculator(name, oldParsed, computed) {
5705
+ return computed.map(function (c) {
5706
+ return c.value;
5707
+ });
5708
+ };
5709
+ return CSSPropertyLengthOrPercentage14;
5710
+ }();
5927
5711
 
5928
- var CSSPropertyAngle = /*#__PURE__*/function () {
5929
- function CSSPropertyAngle() {
5930
- this.parser = parseAngle;
5931
- this.parserWithCSSDisabled = null;
5932
- this.mixer = mergeNumbers;
5712
+ /**
5713
+ * local position
5714
+ */
5715
+ var CSSPropertyLocalPosition = /*#__PURE__*/function (_CSSPropertyLengthOrP) {
5716
+ _inheritsLoose(CSSPropertyLocalPosition, _CSSPropertyLengthOrP);
5717
+ function CSSPropertyLocalPosition() {
5718
+ return _CSSPropertyLengthOrP.apply(this, arguments) || this;
5933
5719
  }
5934
- var _proto = CSSPropertyAngle.prototype;
5935
- _proto.calculator = function calculator(name, oldParsed, parsed, object) {
5936
- return convertAngleUnit(parsed);
5720
+ var _proto = CSSPropertyLocalPosition.prototype;
5721
+ /**
5722
+ * update local position
5723
+ */
5724
+ _proto.postProcessor = function postProcessor(object, attributes) {
5725
+ var x;
5726
+ var y;
5727
+ var z;
5728
+ switch (object.nodeName) {
5729
+ case Shape.CIRCLE:
5730
+ case Shape.ELLIPSE:
5731
+ var _object$parsedStyle = object.parsedStyle,
5732
+ cx = _object$parsedStyle.cx,
5733
+ cy = _object$parsedStyle.cy;
5734
+ if (!isNil(cx)) {
5735
+ x = cx;
5736
+ }
5737
+ if (!isNil(cy)) {
5738
+ y = cy;
5739
+ }
5740
+ break;
5741
+ case Shape.LINE:
5742
+ var _object$parsedStyle2 = object.parsedStyle,
5743
+ x1 = _object$parsedStyle2.x1,
5744
+ x2 = _object$parsedStyle2.x2,
5745
+ y1 = _object$parsedStyle2.y1,
5746
+ y2 = _object$parsedStyle2.y2;
5747
+ var minX = Math.min(x1, x2);
5748
+ var minY = Math.min(y1, y2);
5749
+ x = minX;
5750
+ y = minY;
5751
+ z = 0;
5752
+ break;
5753
+ case Shape.RECT:
5754
+ case Shape.IMAGE:
5755
+ case Shape.GROUP:
5756
+ case Shape.HTML:
5757
+ case Shape.TEXT:
5758
+ case Shape.MESH:
5759
+ if (!isNil(object.parsedStyle.x)) {
5760
+ x = object.parsedStyle.x;
5761
+ }
5762
+ if (!isNil(object.parsedStyle.y)) {
5763
+ y = object.parsedStyle.y;
5764
+ }
5765
+ break;
5766
+ }
5767
+ if (object.nodeName !== Shape.PATH && object.nodeName !== Shape.POLYLINE && object.nodeName !== Shape.POLYGON) {
5768
+ object.parsedStyle.defX = x || 0;
5769
+ object.parsedStyle.defY = y || 0;
5770
+ }
5771
+ var needResetLocalPosition = !isNil(x) || !isNil(y) || !isNil(z);
5772
+ // only if `transform` won't be processed later
5773
+ if (needResetLocalPosition && attributes.indexOf('transform') === -1) {
5774
+ // account for current transform if needed
5775
+ var transform = object.parsedStyle.transform;
5776
+ if (transform && transform.length) {
5777
+ parsedTransformToMat4(transform, object);
5778
+ } else {
5779
+ var _object$getLocalPosit = object.getLocalPosition(),
5780
+ ox = _object$getLocalPosit[0],
5781
+ oy = _object$getLocalPosit[1],
5782
+ oz = _object$getLocalPosit[2];
5783
+ object.setLocalPosition(isNil(x) ? ox : x, isNil(y) ? oy : y, isNil(z) ? oz : z);
5784
+ }
5785
+ }
5937
5786
  };
5938
- return CSSPropertyAngle;
5939
- }();
5787
+ return CSSPropertyLocalPosition;
5788
+ }(CSSPropertyLengthOrPercentage);
5940
5789
 
5941
- /**
5942
- * clipPath / textPath / offsetPath
5943
- */
5944
- var CSSPropertyClipPath = /*#__PURE__*/function () {
5945
- function CSSPropertyClipPath() {}
5946
- var _proto = CSSPropertyClipPath.prototype;
5947
- _proto.calculator = function calculator(name, oldPath, newPath, object) {
5790
+ var CSSPropertyMarker = /*#__PURE__*/function () {
5791
+ function CSSPropertyMarker() {}
5792
+ var _proto = CSSPropertyMarker.prototype;
5793
+ _proto.calculator = function calculator(name, oldMarker, newMarker, object) {
5794
+ var _newMarker;
5948
5795
  // unset
5949
- if (newPath instanceof CSSKeywordValue) {
5950
- newPath = null;
5796
+ if (newMarker instanceof CSSKeywordValue) {
5797
+ newMarker = null;
5951
5798
  }
5952
- runtime.sceneGraphService.updateDisplayObjectDependency(name, oldPath, newPath, object);
5953
- if (name === 'clipPath') {
5954
- // should affect children
5955
- object.forEach(function (leaf) {
5956
- if (leaf.childNodes.length === 0) {
5957
- runtime.sceneGraphService.dirtifyToRoot(leaf);
5958
- }
5959
- });
5799
+ var cloned = (_newMarker = newMarker) === null || _newMarker === void 0 ? void 0 : _newMarker.cloneNode(true);
5800
+ if (cloned) {
5801
+ // FIXME: SVG should not inherit parent's style, add a flag here
5802
+ cloned.style.isMarker = true;
5960
5803
  }
5961
- return newPath;
5804
+ return cloned;
5962
5805
  };
5963
- return CSSPropertyClipPath;
5806
+ return CSSPropertyMarker;
5964
5807
  }();
5965
5808
 
5966
- var CSSPropertyColor = /*#__PURE__*/function () {
5967
- function CSSPropertyColor() {
5968
- this.parser = parseColor;
5969
- this.parserWithCSSDisabled = parseColor;
5970
- this.mixer = mergeColors;
5809
+ var CSSPropertyNumber = /*#__PURE__*/function () {
5810
+ function CSSPropertyNumber() {
5811
+ this.mixer = mergeNumbers;
5812
+ this.parser = parseNumber;
5813
+ this.parserWithCSSDisabled = null;
5971
5814
  }
5972
- var _proto = CSSPropertyColor.prototype;
5973
- _proto.calculator = function calculator(name, oldParsed, parsed, object) {
5974
- if (parsed instanceof CSSKeywordValue) {
5975
- // 'unset' 'none'
5976
- return parsed.value === 'none' ? noneColor : transparentColor;
5977
- }
5978
- return parsed;
5815
+ var _proto = CSSPropertyNumber.prototype;
5816
+ _proto.calculator = function calculator(name, oldParsed, computed) {
5817
+ return computed.value;
5979
5818
  };
5980
- return CSSPropertyColor;
5819
+ return CSSPropertyNumber;
5981
5820
  }();
5982
5821
 
5983
- var CSSPropertyFilter = /*#__PURE__*/function () {
5984
- function CSSPropertyFilter() {
5985
- this.parser = parseFilter;
5822
+ var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
5823
+ function CSSPropertyOffsetDistance() {
5824
+ this.parser = parseNumber;
5825
+ this.parserWithCSSDisabled = null;
5826
+ this.mixer = clampedMergeNumbers(0, 1);
5986
5827
  }
5987
- var _proto = CSSPropertyFilter.prototype;
5988
- _proto.calculator = function calculator(name, oldParsed, parsed) {
5989
- // unset or none
5990
- if (parsed instanceof CSSKeywordValue) {
5991
- return [];
5828
+ var _proto = CSSPropertyOffsetDistance.prototype;
5829
+ _proto.calculator = function calculator(name, oldParsed, computed) {
5830
+ return computed.value;
5831
+ };
5832
+ _proto.postProcessor = function postProcessor(object) {
5833
+ var _object$parsedStyle = object.parsedStyle,
5834
+ offsetPath = _object$parsedStyle.offsetPath,
5835
+ offsetDistance = _object$parsedStyle.offsetDistance;
5836
+ if (!offsetPath) {
5837
+ return;
5838
+ }
5839
+ var nodeName = offsetPath.nodeName;
5840
+ if (nodeName === Shape.LINE || nodeName === Shape.PATH || nodeName === Shape.POLYLINE) {
5841
+ // set position in world space
5842
+ var point = offsetPath.getPoint(offsetDistance);
5843
+ if (point) {
5844
+ object.parsedStyle.defX = point.x;
5845
+ object.parsedStyle.defY = point.y;
5846
+ object.setLocalPosition(point.x, point.y);
5847
+ }
5992
5848
  }
5993
- return parsed;
5994
5849
  };
5995
- return CSSPropertyFilter;
5850
+ return CSSPropertyOffsetDistance;
5996
5851
  }();
5997
5852
 
5998
- function getFontSize(object) {
5999
- var fontSize = object.parsedStyle.fontSize;
6000
- return isNil(fontSize) ? null : fontSize;
6001
- }
6002
5853
  /**
6003
- * <length> & <percentage>
5854
+ * opacity
6004
5855
  */
6005
- var CSSPropertyLengthOrPercentage = /*#__PURE__*/function () {
6006
- function CSSPropertyLengthOrPercentage() {
6007
- this.parser = parseLengthOrPercentage;
5856
+ var CSSPropertyOpacity = /*#__PURE__*/function () {
5857
+ function CSSPropertyOpacity() {
5858
+ this.parser = parseNumber;
6008
5859
  this.parserWithCSSDisabled = null;
6009
- this.mixer = mergeNumbers;
5860
+ this.mixer = clampedMergeNumbers(0, 1);
6010
5861
  }
6011
- var _proto = CSSPropertyLengthOrPercentage.prototype;
6012
- /**
6013
- * according to parent's bounds
6014
- *
6015
- * @example
6016
- * CSS.percent(50) -> CSS.px(0.5 * parent.width)
6017
- */
6018
- _proto.calculator = function calculator(name, oldParsed, computed, object, registry) {
6019
- if (isNumber(computed)) {
6020
- return computed;
5862
+ var _proto = CSSPropertyOpacity.prototype;
5863
+ _proto.calculator = function calculator(name, oldParsed, computed) {
5864
+ return computed.value;
5865
+ };
5866
+ return CSSPropertyOpacity;
5867
+ }();
5868
+
5869
+ /**
5870
+ * Axis-Aligned Bounding Box
5871
+ * 为了便于后续 Frustum Culling,通过查找表定义 p-vertex 和 n-vertex
5872
+ * @see https://github.com/antvis/GWebGPUEngine/issues/3
5873
+ */
5874
+ var AABB = /*#__PURE__*/function () {
5875
+ function AABB() {
5876
+ this.center = [0, 0, 0];
5877
+ this.halfExtents = [0, 0, 0];
5878
+ this.min = [0, 0, 0];
5879
+ this.max = [0, 0, 0];
5880
+ }
5881
+ AABB.isEmpty = function isEmpty(aabb) {
5882
+ return !aabb || aabb.halfExtents[0] === 0 && aabb.halfExtents[1] === 0 && aabb.halfExtents[2] === 0;
5883
+ };
5884
+ var _proto = AABB.prototype;
5885
+ // center: vec3 = vec3.create();
5886
+ // halfExtents: vec3 = vec3.create();
5887
+ // min: vec3 = vec3.create();
5888
+ // max: vec3 = vec3.create();
5889
+ _proto.update = function update(center, halfExtents) {
5890
+ copyVec3(this.center, center);
5891
+ copyVec3(this.halfExtents, halfExtents);
5892
+ subVec3(this.min, this.center, this.halfExtents);
5893
+ addVec3(this.max, this.center, this.halfExtents);
5894
+ // vec3.copy(this.center, center);
5895
+ // vec3.copy(this.halfExtents, halfExtents);
5896
+ // vec3.sub(this.min, this.center, this.halfExtents);
5897
+ // vec3.add(this.max, this.center, this.halfExtents);
5898
+ };
5899
+ _proto.setMinMax = function setMinMax(min, max) {
5900
+ // vec3.add(this.center, max, min);
5901
+ // vec3.scale(this.center, this.center, 0.5);
5902
+ // vec3.sub(this.halfExtents, max, min);
5903
+ // vec3.scale(this.halfExtents, this.halfExtents, 0.5);
5904
+ // vec3.copy(this.min, min);
5905
+ // vec3.copy(this.max, max);
5906
+ addVec3(this.center, max, min);
5907
+ scaleVec3(this.center, this.center, 0.5);
5908
+ subVec3(this.halfExtents, max, min);
5909
+ scaleVec3(this.halfExtents, this.halfExtents, 0.5);
5910
+ copyVec3(this.min, min);
5911
+ copyVec3(this.max, max);
5912
+ };
5913
+ _proto.getMin = function getMin() {
5914
+ return this.min;
5915
+ };
5916
+ _proto.getMax = function getMax() {
5917
+ return this.max;
5918
+ };
5919
+ _proto.add = function add(aabb) {
5920
+ if (AABB.isEmpty(aabb)) {
5921
+ return;
6021
5922
  }
6022
- if (CSSUnitValue.isRelativeUnit(computed.unit)) {
6023
- if (computed.unit === UnitType.kPercentage) {
6024
- // TODO: merge dimensions
6025
- return 0;
6026
- } else if (computed.unit === UnitType.kEms) {
6027
- if (object.parentNode) {
6028
- var fontSize = getFontSize(object.parentNode);
6029
- if (fontSize) {
6030
- fontSize *= computed.value;
6031
- return fontSize;
6032
- } else {
6033
- registry.addUnresolveProperty(object, name);
6034
- }
6035
- } else {
6036
- registry.addUnresolveProperty(object, name);
6037
- }
6038
- return 0;
6039
- } else if (computed.unit === UnitType.kRems) {
6040
- var _object$ownerDocument;
6041
- if (object === null || object === void 0 ? void 0 : (_object$ownerDocument = object.ownerDocument) === null || _object$ownerDocument === void 0 ? void 0 : _object$ownerDocument.documentElement) {
6042
- var _fontSize = getFontSize(object.ownerDocument.documentElement);
6043
- if (_fontSize) {
6044
- _fontSize *= computed.value;
6045
- return _fontSize;
6046
- } else {
6047
- registry.addUnresolveProperty(object, name);
6048
- }
6049
- } else {
6050
- registry.addUnresolveProperty(object, name);
6051
- }
6052
- return 0;
6053
- }
6054
- } else {
6055
- // remove listener if exists
6056
- // registry.unregisterParentGeometryBoundsChangedHandler(object, name);
6057
- // return absolute value
6058
- return computed.value;
5923
+ if (AABB.isEmpty(this)) {
5924
+ this.setMinMax(aabb.getMin(), aabb.getMax());
5925
+ return;
5926
+ }
5927
+ var tc = this.center;
5928
+ var tcx = tc[0];
5929
+ var tcy = tc[1];
5930
+ var tcz = tc[2];
5931
+ var th = this.halfExtents;
5932
+ var thx = th[0];
5933
+ var thy = th[1];
5934
+ var thz = th[2];
5935
+ var tminx = tcx - thx;
5936
+ var tmaxx = tcx + thx;
5937
+ var tminy = tcy - thy;
5938
+ var tmaxy = tcy + thy;
5939
+ var tminz = tcz - thz;
5940
+ var tmaxz = tcz + thz;
5941
+ var oc = aabb.center;
5942
+ var ocx = oc[0];
5943
+ var ocy = oc[1];
5944
+ var ocz = oc[2];
5945
+ var oh = aabb.halfExtents;
5946
+ var ohx = oh[0];
5947
+ var ohy = oh[1];
5948
+ var ohz = oh[2];
5949
+ var ominx = ocx - ohx;
5950
+ var omaxx = ocx + ohx;
5951
+ var ominy = ocy - ohy;
5952
+ var omaxy = ocy + ohy;
5953
+ var ominz = ocz - ohz;
5954
+ var omaxz = ocz + ohz;
5955
+ if (ominx < tminx) {
5956
+ tminx = ominx;
5957
+ }
5958
+ if (omaxx > tmaxx) {
5959
+ tmaxx = omaxx;
6059
5960
  }
6060
- };
6061
- return CSSPropertyLengthOrPercentage;
6062
- }();
6063
-
6064
- /**
6065
- * format to Tuple2<CSSUnitValue>
6066
- *
6067
- * @example
6068
- * rect.style.lineDash = 10;
6069
- * rect.style.lineDash = [10, 10];
6070
- * rect.style.lineDash = '10 10';
6071
- */
6072
- var CSSPropertyLengthOrPercentage12 = /*#__PURE__*/function () {
6073
- function CSSPropertyLengthOrPercentage12() {
6074
- this.mixer = mergeNumberLists;
6075
- }
6076
- var _proto = CSSPropertyLengthOrPercentage12.prototype;
6077
- _proto.parser = function parser(radius) {
6078
- var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
6079
- var formatted;
6080
- if (parsed.length === 1) {
6081
- formatted = [parsed[0], parsed[0]];
6082
- } else {
6083
- formatted = [parsed[0], parsed[1]];
5961
+ if (ominy < tminy) {
5962
+ tminy = ominy;
6084
5963
  }
6085
- return formatted;
6086
- };
6087
- _proto.calculator = function calculator(name, oldParsed, computed) {
6088
- return computed.map(function (c) {
6089
- return c.value;
6090
- });
6091
- };
6092
- return CSSPropertyLengthOrPercentage12;
6093
- }();
6094
-
6095
- /**
6096
- * used in rounded rect
6097
- *
6098
- * @example
6099
- * rect.style.radius = 10;
6100
- * rect.style.radius = '10 10';
6101
- * rect.style.radius = '10 10 10 10';
6102
- */
6103
- var CSSPropertyLengthOrPercentage14 = /*#__PURE__*/function () {
6104
- function CSSPropertyLengthOrPercentage14() {
6105
- this.mixer = mergeNumberLists;
6106
- }
6107
- var _proto = CSSPropertyLengthOrPercentage14.prototype;
6108
- _proto.parser = function parser(radius) {
6109
- var parsed = parseDimensionArray(isNumber(radius) ? [radius] : radius);
6110
- var formatted;
6111
- // format to Tuple<CSSUnitValue>
6112
- if (parsed.length === 1) {
6113
- formatted = [parsed[0], parsed[0], parsed[0], parsed[0]];
6114
- } else if (parsed.length === 2) {
6115
- formatted = [parsed[0], parsed[1], parsed[0], parsed[1]];
6116
- } else if (parsed.length === 3) {
6117
- formatted = [parsed[0], parsed[1], parsed[2], parsed[1]];
6118
- } else {
6119
- formatted = [parsed[0], parsed[1], parsed[2], parsed[3]];
5964
+ if (omaxy > tmaxy) {
5965
+ tmaxy = omaxy;
6120
5966
  }
6121
- return formatted;
5967
+ if (ominz < tminz) {
5968
+ tminz = ominz;
5969
+ }
5970
+ if (omaxz > tmaxz) {
5971
+ tmaxz = omaxz;
5972
+ }
5973
+ tc[0] = (tminx + tmaxx) * 0.5;
5974
+ tc[1] = (tminy + tmaxy) * 0.5;
5975
+ tc[2] = (tminz + tmaxz) * 0.5;
5976
+ th[0] = (tmaxx - tminx) * 0.5;
5977
+ th[1] = (tmaxy - tminy) * 0.5;
5978
+ th[2] = (tmaxz - tminz) * 0.5;
5979
+ this.min[0] = tminx;
5980
+ this.min[1] = tminy;
5981
+ this.min[2] = tminz;
5982
+ this.max[0] = tmaxx;
5983
+ this.max[1] = tmaxy;
5984
+ this.max[2] = tmaxz;
6122
5985
  };
6123
- _proto.calculator = function calculator(name, oldParsed, computed) {
6124
- return computed.map(function (c) {
6125
- return c.value;
6126
- });
5986
+ _proto.setFromTransformedAABB = function setFromTransformedAABB(aabb, m) {
5987
+ var bc = this.center;
5988
+ var br = this.halfExtents;
5989
+ var ac = aabb.center;
5990
+ var ar = aabb.halfExtents;
5991
+ var mx0 = m[0];
5992
+ var mx1 = m[4];
5993
+ var mx2 = m[8];
5994
+ var my0 = m[1];
5995
+ var my1 = m[5];
5996
+ var my2 = m[9];
5997
+ var mz0 = m[2];
5998
+ var mz1 = m[6];
5999
+ var mz2 = m[10];
6000
+ var mx0a = Math.abs(mx0);
6001
+ var mx1a = Math.abs(mx1);
6002
+ var mx2a = Math.abs(mx2);
6003
+ var my0a = Math.abs(my0);
6004
+ var my1a = Math.abs(my1);
6005
+ var my2a = Math.abs(my2);
6006
+ var mz0a = Math.abs(mz0);
6007
+ var mz1a = Math.abs(mz1);
6008
+ var mz2a = Math.abs(mz2);
6009
+ bc[0] = m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2];
6010
+ bc[1] = m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2];
6011
+ bc[2] = m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2];
6012
+ // vec3.set(
6013
+ // bc,
6014
+ // m[12] + mx0 * ac[0] + mx1 * ac[1] + mx2 * ac[2],
6015
+ // m[13] + my0 * ac[0] + my1 * ac[1] + my2 * ac[2],
6016
+ // m[14] + mz0 * ac[0] + mz1 * ac[1] + mz2 * ac[2],
6017
+ // );
6018
+ br[0] = mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2];
6019
+ br[1] = my0a * ar[0] + my1a * ar[1] + my2a * ar[2];
6020
+ br[2] = mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2];
6021
+ // vec3.set(
6022
+ // br,
6023
+ // mx0a * ar[0] + mx1a * ar[1] + mx2a * ar[2],
6024
+ // my0a * ar[0] + my1a * ar[1] + my2a * ar[2],
6025
+ // mz0a * ar[0] + mz1a * ar[1] + mz2a * ar[2],
6026
+ // );
6027
+ // this.min = vec3.sub(this.min, bc, br);
6028
+ // this.max = vec3.add(this.max, bc, br);
6029
+ subVec3(this.min, bc, br);
6030
+ addVec3(this.max, bc, br);
6127
6031
  };
6128
- return CSSPropertyLengthOrPercentage14;
6129
- }();
6130
-
6131
- /**
6132
- * local position
6133
- */
6134
- var CSSPropertyLocalPosition = /*#__PURE__*/function (_CSSPropertyLengthOrP) {
6135
- _inheritsLoose(CSSPropertyLocalPosition, _CSSPropertyLengthOrP);
6136
- function CSSPropertyLocalPosition() {
6137
- return _CSSPropertyLengthOrP.apply(this, arguments) || this;
6032
+ _proto.intersects = function intersects(aabb) {
6033
+ var aMax = this.getMax();
6034
+ var aMin = this.getMin();
6035
+ var bMax = aabb.getMax();
6036
+ var bMin = aabb.getMin();
6037
+ 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];
6038
+ };
6039
+ _proto.intersection = function intersection(aabb) {
6040
+ if (!this.intersects(aabb)) {
6041
+ return null;
6042
+ }
6043
+ var intersection = new AABB();
6044
+ // const min = vec3.max(vec3.create(), this.getMin(), aabb.getMin());
6045
+ // const max = vec3.min(vec3.create(), this.getMax(), aabb.getMax());
6046
+ var min = maxVec3([0, 0, 0], this.getMin(), aabb.getMin());
6047
+ var max = minVec3([0, 0, 0], this.getMax(), aabb.getMax());
6048
+ intersection.setMinMax(min, max);
6049
+ return intersection;
6138
6050
  }
6139
- var _proto = CSSPropertyLocalPosition.prototype;
6051
+ // containsPoint(point: vec3) {
6052
+ // const min = this.getMin();
6053
+ // const max = this.getMax();
6054
+ // return !(
6055
+ // point[0] < min[0] ||
6056
+ // point[0] > max[0] ||
6057
+ // point[1] < min[1] ||
6058
+ // point[1] > max[1] ||
6059
+ // point[2] < min[2] ||
6060
+ // point[2] > max[2]
6061
+ // );
6062
+ // }
6140
6063
  /**
6141
- * update local position
6142
- */
6143
- _proto.postProcessor = function postProcessor(object, attributes) {
6144
- var x;
6145
- var y;
6146
- var z;
6147
- switch (object.nodeName) {
6148
- case Shape.CIRCLE:
6149
- case Shape.ELLIPSE:
6150
- var _object$parsedStyle = object.parsedStyle,
6151
- cx = _object$parsedStyle.cx,
6152
- cy = _object$parsedStyle.cy;
6153
- if (!isNil(cx)) {
6154
- x = cx;
6155
- }
6156
- if (!isNil(cy)) {
6157
- y = cy;
6158
- }
6159
- break;
6160
- case Shape.LINE:
6161
- var _object$parsedStyle2 = object.parsedStyle,
6162
- x1 = _object$parsedStyle2.x1,
6163
- x2 = _object$parsedStyle2.x2,
6164
- y1 = _object$parsedStyle2.y1,
6165
- y2 = _object$parsedStyle2.y2;
6166
- var minX = Math.min(x1, x2);
6167
- var minY = Math.min(y1, y2);
6168
- x = minX;
6169
- y = minY;
6170
- z = 0;
6171
- break;
6172
- case Shape.RECT:
6173
- case Shape.IMAGE:
6174
- case Shape.GROUP:
6175
- case Shape.HTML:
6176
- case Shape.TEXT:
6177
- case Shape.MESH:
6178
- if (!isNil(object.parsedStyle.x)) {
6179
- x = object.parsedStyle.x;
6180
- }
6181
- if (!isNil(object.parsedStyle.y)) {
6182
- y = object.parsedStyle.y;
6183
- }
6184
- break;
6185
- }
6186
- if (object.nodeName !== Shape.PATH && object.nodeName !== Shape.POLYLINE && object.nodeName !== Shape.POLYGON) {
6187
- object.parsedStyle.defX = x || 0;
6188
- object.parsedStyle.defY = y || 0;
6189
- }
6190
- var needResetLocalPosition = !isNil(x) || !isNil(y) || !isNil(z);
6191
- // only if `transform` won't be processed later
6192
- if (needResetLocalPosition && attributes.indexOf('transform') === -1) {
6193
- // account for current transform if needed
6194
- var transform = object.parsedStyle.transform;
6195
- if (transform && transform.length) {
6196
- parsedTransformToMat4(transform, object);
6197
- } else {
6198
- var _object$getLocalPosit = object.getLocalPosition(),
6199
- ox = _object$getLocalPosit[0],
6200
- oy = _object$getLocalPosit[1],
6201
- oz = _object$getLocalPosit[2];
6202
- object.setLocalPosition(isNil(x) ? ox : x, isNil(y) ? oy : y, isNil(z) ? oz : z);
6203
- }
6204
- }
6205
- };
6206
- return CSSPropertyLocalPosition;
6207
- }(CSSPropertyLengthOrPercentage);
6208
-
6209
- var CSSPropertyMarker = /*#__PURE__*/function () {
6210
- function CSSPropertyMarker() {}
6211
- var _proto = CSSPropertyMarker.prototype;
6212
- _proto.calculator = function calculator(name, oldMarker, newMarker, object) {
6213
- var _newMarker;
6214
- // unset
6215
- if (newMarker instanceof CSSKeywordValue) {
6216
- newMarker = null;
6064
+ * get n-vertex
6065
+ * @param plane plane of CullingVolume
6066
+ */;
6067
+ _proto.getNegativeFarPoint = function getNegativeFarPoint(plane) {
6068
+ if (plane.pnVertexFlag === 0x111) {
6069
+ return copyVec3([0, 0, 0], this.min);
6070
+ // return vec3.copy(vec3.create(), this.min);
6071
+ } else if (plane.pnVertexFlag === 0x110) {
6072
+ return [this.min[0], this.min[1], this.max[2]];
6073
+ // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
6074
+ } else if (plane.pnVertexFlag === 0x101) {
6075
+ return [this.min[0], this.max[1], this.min[2]];
6076
+ // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
6077
+ } else if (plane.pnVertexFlag === 0x100) {
6078
+ return [this.min[0], this.max[1], this.max[2]];
6079
+ // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
6080
+ } else if (plane.pnVertexFlag === 0x011) {
6081
+ return [this.max[0], this.min[1], this.min[2]];
6082
+ // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
6083
+ } else if (plane.pnVertexFlag === 0x010) {
6084
+ return [this.max[0], this.min[1], this.max[2]];
6085
+ // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
6086
+ } else if (plane.pnVertexFlag === 0x001) {
6087
+ return [this.max[0], this.max[1], this.min[2]];
6088
+ // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
6089
+ } else {
6090
+ return [this.max[0], this.max[1], this.max[2]];
6091
+ // return vec3.fromValues(this.max[0], this.max[1], this.max[2]);
6217
6092
  }
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;
6093
+ }
6094
+ /**
6095
+ * get p-vertex
6096
+ * @param plane plane of CullingVolume
6097
+ */;
6098
+ _proto.getPositiveFarPoint = function getPositiveFarPoint(plane) {
6099
+ if (plane.pnVertexFlag === 0x111) {
6100
+ return copyVec3([0, 0, 0], this.max);
6101
+ // return vec3.copy(vec3.create(), this.max);
6102
+ } else if (plane.pnVertexFlag === 0x110) {
6103
+ return [this.max[0], this.max[1], this.min[2]];
6104
+ // return vec3.fromValues(this.max[0], this.max[1], this.min[2]);
6105
+ } else if (plane.pnVertexFlag === 0x101) {
6106
+ return [this.max[0], this.min[1], this.max[2]];
6107
+ // return vec3.fromValues(this.max[0], this.min[1], this.max[2]);
6108
+ } else if (plane.pnVertexFlag === 0x100) {
6109
+ return [this.max[0], this.min[1], this.min[2]];
6110
+ // return vec3.fromValues(this.max[0], this.min[1], this.min[2]);
6111
+ } else if (plane.pnVertexFlag === 0x011) {
6112
+ return [this.min[0], this.max[1], this.max[2]];
6113
+ // return vec3.fromValues(this.min[0], this.max[1], this.max[2]);
6114
+ } else if (plane.pnVertexFlag === 0x010) {
6115
+ return [this.min[0], this.max[1], this.min[2]];
6116
+ // return vec3.fromValues(this.min[0], this.max[1], this.min[2]);
6117
+ } else if (plane.pnVertexFlag === 0x001) {
6118
+ return [this.min[0], this.min[1], this.max[2]];
6119
+ // return vec3.fromValues(this.min[0], this.min[1], this.max[2]);
6120
+ } else {
6121
+ return [this.min[0], this.min[1], this.min[2]];
6122
+ // return vec3.fromValues(this.min[0], this.min[1], this.min[2]);
6222
6123
  }
6223
- return cloned;
6224
6124
  };
6225
- return CSSPropertyMarker;
6125
+ return AABB;
6226
6126
  }();
6227
6127
 
6228
- var CSSPropertyNumber = /*#__PURE__*/function () {
6229
- function CSSPropertyNumber() {
6230
- this.mixer = mergeNumbers;
6231
- this.parser = parseNumber;
6232
- this.parserWithCSSDisabled = null;
6128
+ var Plane = /*#__PURE__*/function () {
6129
+ /**
6130
+ * lookup table for p-vertex & n-vertex when doing frustum culling
6131
+ */
6132
+
6133
+ function Plane(distance, normal) {
6134
+ this.distance = void 0;
6135
+ this.normal = void 0;
6136
+ this.pnVertexFlag = void 0;
6137
+ this.distance = distance || 0;
6138
+ this.normal = normal || vec3.fromValues(0, 1, 0);
6139
+ this.updatePNVertexFlag();
6233
6140
  }
6234
- var _proto = CSSPropertyNumber.prototype;
6235
- _proto.calculator = function calculator(name, oldParsed, computed) {
6236
- return computed.value;
6141
+ var _proto = Plane.prototype;
6142
+ _proto.updatePNVertexFlag = function updatePNVertexFlag() {
6143
+ this.pnVertexFlag = (Number(this.normal[0] >= 0) << 8) + (Number(this.normal[1] >= 0) << 4) + Number(this.normal[2] >= 0);
6237
6144
  };
6238
- return CSSPropertyNumber;
6145
+ _proto.distanceToPoint = function distanceToPoint(point) {
6146
+ return vec3.dot(point, this.normal) - this.distance;
6147
+ };
6148
+ _proto.normalize = function normalize() {
6149
+ var invLen = 1 / vec3.len(this.normal);
6150
+ vec3.scale(this.normal, this.normal, invLen);
6151
+ this.distance *= invLen;
6152
+ };
6153
+ _proto.intersectsLine = function intersectsLine(start, end, point) {
6154
+ var d0 = this.distanceToPoint(start);
6155
+ var d1 = this.distanceToPoint(end);
6156
+ var t = d0 / (d0 - d1);
6157
+ var intersects = t >= 0 && t <= 1;
6158
+ if (intersects && point) {
6159
+ vec3.lerp(point, start, end, t);
6160
+ }
6161
+ return intersects;
6162
+ };
6163
+ return Plane;
6239
6164
  }();
6240
6165
 
6241
- var CSSPropertyOffsetDistance = /*#__PURE__*/function () {
6242
- function CSSPropertyOffsetDistance() {
6243
- this.parser = parseNumber;
6244
- this.parserWithCSSDisabled = null;
6245
- this.mixer = clampedMergeNumbers(0, 1);
6166
+ var Mask;
6167
+ (function (Mask) {
6168
+ Mask[Mask["OUTSIDE"] = 4294967295] = "OUTSIDE";
6169
+ Mask[Mask["INSIDE"] = 0] = "INSIDE";
6170
+ Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
6171
+ })(Mask || (Mask = {}));
6172
+ var Frustum = /*#__PURE__*/function () {
6173
+ function Frustum(planes) {
6174
+ this.planes = [];
6175
+ if (planes) {
6176
+ this.planes = planes;
6177
+ } else {
6178
+ for (var i = 0; i < 6; i++) {
6179
+ this.planes.push(new Plane());
6180
+ }
6181
+ }
6246
6182
  }
6247
- var _proto = CSSPropertyOffsetDistance.prototype;
6248
- _proto.calculator = function calculator(name, oldParsed, computed) {
6249
- return computed.value;
6183
+ /**
6184
+ * extract 6 planes from projectionMatrix
6185
+ * @see http://www8.cs.umu.se/kurser/5DV051/HT12/lab/plane_extraction.pdf
6186
+ */
6187
+ var _proto = Frustum.prototype;
6188
+ _proto.extractFromVPMatrix = function extractFromVPMatrix(projectionMatrix) {
6189
+ // @ts-ignore
6190
+ var m0 = projectionMatrix[0],
6191
+ m1 = projectionMatrix[1],
6192
+ m2 = projectionMatrix[2],
6193
+ m3 = projectionMatrix[3],
6194
+ m4 = projectionMatrix[4],
6195
+ m5 = projectionMatrix[5],
6196
+ m6 = projectionMatrix[6],
6197
+ m7 = projectionMatrix[7],
6198
+ m8 = projectionMatrix[8],
6199
+ m9 = projectionMatrix[9],
6200
+ m10 = projectionMatrix[10],
6201
+ m11 = projectionMatrix[11],
6202
+ m12 = projectionMatrix[12],
6203
+ m13 = projectionMatrix[13],
6204
+ m14 = projectionMatrix[14],
6205
+ m15 = projectionMatrix[15];
6206
+ // right
6207
+ vec3.set(this.planes[0].normal, m3 - m0, m7 - m4, m11 - m8);
6208
+ this.planes[0].distance = m15 - m12;
6209
+ // left
6210
+ vec3.set(this.planes[1].normal, m3 + m0, m7 + m4, m11 + m8);
6211
+ this.planes[1].distance = m15 + m12;
6212
+ // bottom
6213
+ vec3.set(this.planes[2].normal, m3 + m1, m7 + m5, m11 + m9);
6214
+ this.planes[2].distance = m15 + m13;
6215
+ // top
6216
+ vec3.set(this.planes[3].normal, m3 - m1, m7 - m5, m11 - m9);
6217
+ this.planes[3].distance = m15 - m13;
6218
+ // far
6219
+ vec3.set(this.planes[4].normal, m3 - m2, m7 - m6, m11 - m10);
6220
+ this.planes[4].distance = m15 - m14;
6221
+ // near
6222
+ vec3.set(this.planes[5].normal, m3 + m2, m7 + m6, m11 + m10);
6223
+ this.planes[5].distance = m15 + m14;
6224
+ this.planes.forEach(function (plane) {
6225
+ plane.normalize();
6226
+ plane.updatePNVertexFlag();
6227
+ });
6250
6228
  };
6251
- _proto.postProcessor = function postProcessor(object) {
6252
- var _object$parsedStyle = object.parsedStyle,
6253
- offsetPath = _object$parsedStyle.offsetPath,
6254
- offsetDistance = _object$parsedStyle.offsetDistance;
6255
- if (!offsetPath) {
6256
- return;
6229
+ return Frustum;
6230
+ }();
6231
+
6232
+ var Point = /*#__PURE__*/function () {
6233
+ function Point(x, y) {
6234
+ if (x === void 0) {
6235
+ x = 0;
6257
6236
  }
6258
- var nodeName = offsetPath.nodeName;
6259
- if (nodeName === Shape.LINE || nodeName === Shape.PATH || nodeName === Shape.POLYLINE) {
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
- }
6237
+ if (y === void 0) {
6238
+ y = 0;
6267
6239
  }
6240
+ this.x = 0;
6241
+ this.y = 0;
6242
+ this.x = x;
6243
+ this.y = y;
6244
+ }
6245
+ var _proto = Point.prototype;
6246
+ _proto.clone = function clone() {
6247
+ return new Point(this.x, this.y);
6268
6248
  };
6269
- return CSSPropertyOffsetDistance;
6249
+ _proto.copyFrom = function copyFrom(p) {
6250
+ this.x = p.x;
6251
+ this.y = p.y;
6252
+ };
6253
+ return Point;
6270
6254
  }();
6271
6255
 
6272
- /**
6273
- * opacity
6274
- */
6275
- var CSSPropertyOpacity = /*#__PURE__*/function () {
6276
- function CSSPropertyOpacity() {
6277
- this.parser = parseNumber;
6278
- this.parserWithCSSDisabled = null;
6279
- this.mixer = clampedMergeNumbers(0, 1);
6256
+ var Rectangle = /*#__PURE__*/function () {
6257
+ function Rectangle(x, y, width, height) {
6258
+ this.x = void 0;
6259
+ this.y = void 0;
6260
+ this.width = void 0;
6261
+ this.height = void 0;
6262
+ this.left = void 0;
6263
+ this.right = void 0;
6264
+ this.top = void 0;
6265
+ this.bottom = void 0;
6266
+ this.x = x;
6267
+ this.y = y;
6268
+ this.width = width;
6269
+ this.height = height;
6270
+ this.left = x;
6271
+ this.right = x + width;
6272
+ this.top = y;
6273
+ this.bottom = y + height;
6280
6274
  }
6281
- var _proto = CSSPropertyOpacity.prototype;
6282
- _proto.calculator = function calculator(name, oldParsed, computed) {
6283
- return computed.value;
6284
- };
6285
- return CSSPropertyOpacity;
6275
+ var _proto = Rectangle.prototype;
6276
+ _proto.toJSON = function toJSON() {};
6277
+ return Rectangle;
6286
6278
  }();
6287
6279
 
6288
6280
  var CSSPropertyPath = /*#__PURE__*/function () {
@@ -7627,12 +7619,12 @@ var Element = /*#__PURE__*/function (_Node) {
7627
7619
  localPosition: [0, 0, 0],
7628
7620
  localRotation: [0, 0, 0, 1],
7629
7621
  localScale: [1, 1, 1],
7630
- localTransform: mat4.create(),
7622
+ localTransform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
7631
7623
  localSkew: [0, 0],
7632
7624
  position: [0, 0, 0],
7633
7625
  rotation: [0, 0, 0, 1],
7634
7626
  scaling: [1, 1, 1],
7635
- worldTransform: mat4.create(),
7627
+ worldTransform: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1],
7636
7628
  origin: [0, 0, 0]
7637
7629
  };
7638
7630
  _this.sortable = {
@@ -9142,7 +9134,7 @@ var Circle = /*#__PURE__*/function (_DisplayObject) {
9142
9134
  }, style) : _extends({}, style),
9143
9135
  initialParsedStyle: {
9144
9136
  anchor: [0.5, 0.5],
9145
- transformOrigin: runtime.enableCSSParsing ? null : [getOrCreateUnitValue(50, '%'), getOrCreateUnitValue(50, '%')]
9137
+ transformOrigin: runtime.enableCSSParsing ? null : [PECENTAGE_50, PECENTAGE_50]
9146
9138
  }
9147
9139
  }, rest)) || this;
9148
9140
  }
@@ -9230,7 +9222,7 @@ var Ellipse = /*#__PURE__*/function (_DisplayObject) {
9230
9222
  }, style) : _extends({}, style),
9231
9223
  initialParsedStyle: {
9232
9224
  anchor: [0.5, 0.5],
9233
- transformOrigin: runtime.enableCSSParsing ? null : [getOrCreateUnitValue(50, '%'), getOrCreateUnitValue(50, '%')]
9225
+ transformOrigin: runtime.enableCSSParsing ? null : [PECENTAGE_50, PECENTAGE_50]
9234
9226
  }
9235
9227
  }, rest)) || this;
9236
9228
  }
@@ -10088,6 +10080,7 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
10088
10080
  var _proto = Text.prototype;
10089
10081
  _proto.getComputedTextLength = function getComputedTextLength() {
10090
10082
  var _this$parsedStyle$met;
10083
+ this.forceUpdateGeometry();
10091
10084
  return ((_this$parsedStyle$met = this.parsedStyle.metrics) === null || _this$parsedStyle$met === void 0 ? void 0 : _this$parsedStyle$met.maxLineWidth) || 0;
10092
10085
  }
10093
10086
  // getEndPositionOfChar(charnum: number): DOMPoint {
@@ -10114,11 +10107,18 @@ var Text = /*#__PURE__*/function (_DisplayObject) {
10114
10107
  ;
10115
10108
  _proto.getLineBoundingRects = function getLineBoundingRects() {
10116
10109
  var _this$parsedStyle$met2;
10110
+ this.forceUpdateGeometry();
10117
10111
  return ((_this$parsedStyle$met2 = this.parsedStyle.metrics) === null || _this$parsedStyle$met2 === void 0 ? void 0 : _this$parsedStyle$met2.lineMetrics) || [];
10118
10112
  };
10119
10113
  _proto.isOverflowing = function isOverflowing() {
10114
+ this.forceUpdateGeometry();
10120
10115
  return !!this.parsedStyle.isOverflowing;
10121
10116
  };
10117
+ _proto.forceUpdateGeometry = function forceUpdateGeometry() {
10118
+ if (!this.parsedStyle.metrics) {
10119
+ runtime.styleValueRegistry.updateGeometry(this);
10120
+ }
10121
+ };
10122
10122
  return Text;
10123
10123
  }(DisplayObject);
10124
10124
 
@@ -11093,7 +11093,8 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11093
11093
  * eg. r of Circle, width/height of Rect
11094
11094
  */;
11095
11095
  _proto.updateGeometry = function updateGeometry(object) {
11096
- var geometryUpdater = runtime.geometryUpdaterFactory[object.nodeName];
11096
+ var nodeName = object.nodeName;
11097
+ var geometryUpdater = runtime.geometryUpdaterFactory[nodeName];
11097
11098
  if (geometryUpdater) {
11098
11099
  var geometry = object.geometry;
11099
11100
  if (!geometry.contentBounds) {
@@ -11114,10 +11115,6 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11114
11115
  offsetY = _geometryUpdater$upda4 === void 0 ? 0 : _geometryUpdater$upda4,
11115
11116
  _geometryUpdater$upda5 = _geometryUpdater$upda.offsetZ,
11116
11117
  offsetZ = _geometryUpdater$upda5 === void 0 ? 0 : _geometryUpdater$upda5;
11117
- // account for negative width / height of Rect
11118
- // @see https://github.com/antvis/g/issues/957
11119
- var flipY = width < 0;
11120
- var flipX = height < 0;
11121
11118
  // init with content box
11122
11119
  var halfExtents = [Math.abs(width) / 2, Math.abs(height) / 2, depth / 2];
11123
11120
  // const halfExtents = vec3.set(
@@ -11137,7 +11134,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11137
11134
  transformOrigin = parsedStyle.transformOrigin;
11138
11135
  var anchor = parsedStyle.anchor;
11139
11136
  // <Text> use textAlign & textBaseline instead of anchor
11140
- if (object.nodeName === Shape.TEXT) {
11137
+ if (nodeName === Shape.TEXT) {
11141
11138
  delete parsedStyle.anchor;
11142
11139
  }
11143
11140
  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];
@@ -11150,7 +11147,7 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11150
11147
  // update geometry's AABB
11151
11148
  geometry.contentBounds.update(center, halfExtents);
11152
11149
  // @see https://github.molgen.mpg.de/git-mirror/cairo/blob/master/src/cairo-stroke-style.c#L97..L128
11153
- var expansion = object.nodeName === Shape.POLYLINE || object.nodeName === Shape.POLYGON || object.nodeName === Shape.PATH ? Math.SQRT2 : 0.5;
11150
+ var expansion = nodeName === Shape.POLYLINE || nodeName === Shape.POLYGON || nodeName === Shape.PATH ? Math.SQRT2 : 0.5;
11154
11151
  // if (lineCap?.value === 'square') {
11155
11152
  // expansion = Math.SQRT1_2;
11156
11153
  // }
@@ -11221,13 +11218,19 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
11221
11218
  });
11222
11219
  anchor = parsedStyle.anchor;
11223
11220
  geometry.dirty = false;
11221
+ // if (nodeName === Shape.RECT) {
11222
+ // account for negative width / height of Rect
11223
+ // @see https://github.com/antvis/g/issues/957
11224
+ var flipY = width < 0;
11225
+ var flipX = height < 0;
11226
+ // } else {
11227
+ // }
11224
11228
  // set transform origin
11225
11229
  var usedOriginXValue = (flipY ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[0], 0, object) : 0);
11226
11230
  var usedOriginYValue = (flipX ? -1 : 1) * (transformOrigin ? convertPercentUnit(transformOrigin[1], 1, object) : 0);
11227
11231
  usedOriginXValue = usedOriginXValue - (flipY ? -1 : 1) * (anchor && anchor[0] || 0) * geometry.contentBounds.halfExtents[0] * 2;
11228
11232
  usedOriginYValue = usedOriginYValue - (flipX ? -1 : 1) * (anchor && anchor[1] || 0) * geometry.contentBounds.halfExtents[1] * 2;
11229
11233
  object.setOrigin(usedOriginXValue, usedOriginYValue);
11230
- // console.log('calc geometry', object);
11231
11234
  // FIXME setOrigin may have already dirtified to root.
11232
11235
  // runtime.sceneGraphService.dirtifyToRoot(object);
11233
11236
  }
@@ -13792,10 +13795,10 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
13792
13795
  z = 0;
13793
13796
  }
13794
13797
  if (typeof origin === 'number') {
13795
- origin = vec3.fromValues(origin, y, z);
13798
+ origin = [origin, y, z];
13796
13799
  }
13797
13800
  var transform = element.transformable;
13798
- if (vec3.equals(origin, transform.origin)) {
13801
+ if (origin[0] === transform.origin[0] && origin[1] === transform.origin[1] && origin[2] === transform.origin[2]) {
13799
13802
  return;
13800
13803
  }
13801
13804
  var originVec = transform.origin;
@@ -14115,7 +14118,7 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
14115
14118
  var clipped = findClosestClipPathTarget(element);
14116
14119
  if (clipped) {
14117
14120
  // use bounds under world space
14118
- var clipPathBounds = clipped.style.clipPath.getBounds(render);
14121
+ var clipPathBounds = clipped.parsedStyle.clipPath.getBounds(render);
14119
14122
  if (!aabb) {
14120
14123
  aabb = clipPathBounds;
14121
14124
  } else if (clipPathBounds) {
@@ -14853,7 +14856,7 @@ var EventPlugin = /*#__PURE__*/function () {
14853
14856
  var normalizedEvents = _this.normalizeToPointerEvent(nativeEvent, canvas);
14854
14857
  for (var _iterator = _createForOfIteratorHelperLoose(normalizedEvents), _step; !(_step = _iterator()).done;) {
14855
14858
  var normalizedEvent = _step.value;
14856
- var event = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas);
14859
+ var event = _this.bootstrapEvent(_this.rootPointerEvent, normalizedEvent, canvas, nativeEvent);
14857
14860
  _this.context.eventService.mapEvent(event);
14858
14861
  }
14859
14862
  _this.setCursor(_this.context.eventService.cursor);
@@ -14908,7 +14911,7 @@ var EventPlugin = /*#__PURE__*/function () {
14908
14911
  }
14909
14912
  for (var _iterator2 = _createForOfIteratorHelperLoose(events), _step2; !(_step2 = _iterator2()).done;) {
14910
14913
  var event = _step2.value;
14911
- var federatedEvent = _this2.bootstrapEvent(_this2.rootPointerEvent, event, canvas);
14914
+ var federatedEvent = _this2.bootstrapEvent(_this2.rootPointerEvent, event, canvas, nativeEvent);
14912
14915
  _this2.context.eventService.mapEvent(federatedEvent);
14913
14916
  }
14914
14917
  _this2.setCursor(_this2.context.eventService.cursor);
@@ -14927,7 +14930,7 @@ var EventPlugin = /*#__PURE__*/function () {
14927
14930
  var normalizedEvents = _this2.normalizeToPointerEvent(nativeEvent, canvas);
14928
14931
  for (var _iterator3 = _createForOfIteratorHelperLoose(normalizedEvents), _step3; !(_step3 = _iterator3()).done;) {
14929
14932
  var normalizedEvent = _step3.value;
14930
- var event = _this2.bootstrapEvent(_this2.rootPointerEvent, normalizedEvent, canvas);
14933
+ var event = _this2.bootstrapEvent(_this2.rootPointerEvent, normalizedEvent, canvas, nativeEvent);
14931
14934
  event.type += outside;
14932
14935
  _this2.context.eventService.mapEvent(event);
14933
14936
  }
@@ -14962,22 +14965,22 @@ var EventPlugin = /*#__PURE__*/function () {
14962
14965
  y: y
14963
14966
  };
14964
14967
  };
14965
- _proto.bootstrapEvent = function bootstrapEvent(event, nativeEvent, view) {
14968
+ _proto.bootstrapEvent = function bootstrapEvent(event, normalizedEvent, view, nativeEvent) {
14966
14969
  event.view = view;
14967
14970
  event.originalEvent = null;
14968
14971
  event.nativeEvent = nativeEvent;
14969
- event.pointerId = nativeEvent.pointerId;
14970
- event.width = nativeEvent.width;
14971
- event.height = nativeEvent.height;
14972
- event.isPrimary = nativeEvent.isPrimary;
14973
- event.pointerType = nativeEvent.pointerType;
14974
- event.pressure = nativeEvent.pressure;
14975
- event.tangentialPressure = nativeEvent.tangentialPressure;
14976
- event.tiltX = nativeEvent.tiltX;
14977
- event.tiltY = nativeEvent.tiltY;
14978
- event.twist = nativeEvent.twist;
14979
- this.transferMouseData(event, nativeEvent);
14980
- var _this$getViewportXY = this.getViewportXY(nativeEvent),
14972
+ event.pointerId = normalizedEvent.pointerId;
14973
+ event.width = normalizedEvent.width;
14974
+ event.height = normalizedEvent.height;
14975
+ event.isPrimary = normalizedEvent.isPrimary;
14976
+ event.pointerType = normalizedEvent.pointerType;
14977
+ event.pressure = normalizedEvent.pressure;
14978
+ event.tangentialPressure = normalizedEvent.tangentialPressure;
14979
+ event.tiltX = normalizedEvent.tiltX;
14980
+ event.tiltY = normalizedEvent.tiltY;
14981
+ event.twist = normalizedEvent.twist;
14982
+ this.transferMouseData(event, normalizedEvent);
14983
+ var _this$getViewportXY = this.getViewportXY(normalizedEvent),
14981
14984
  x = _this$getViewportXY.x,
14982
14985
  y = _this$getViewportXY.y;
14983
14986
  event.viewport.x = x;