@antv/g 5.5.2 → 5.6.0

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
@@ -8215,6 +8215,10 @@ var memoizedParsePath = memoize(function (path) {
8215
8215
  var absolutePath;
8216
8216
 
8217
8217
  try {
8218
+ if (Array.isArray(path) && path.length === 0) {
8219
+ throw new Error();
8220
+ }
8221
+
8218
8222
  absolutePath = normalizePath(path);
8219
8223
  } catch (e) {
8220
8224
  absolutePath = normalizePath('');
@@ -8252,7 +8256,7 @@ var memoizedParsePath = memoize(function (path) {
8252
8256
  curve: curve,
8253
8257
  totalLength: length,
8254
8258
  zCommandIndexes: zCommandIndexes,
8255
- rect: new Rectangle(x, y, width, height)
8259
+ rect: new Rectangle(Number.isFinite(x) ? x : 0, Number.isFinite(y) ? y : 0, Number.isFinite(width) ? width : 0, Number.isFinite(height) ? height : 0)
8256
8260
  };
8257
8261
  }, function (path) {
8258
8262
  return isString(path) ? path : path2String(path);
@@ -8756,12 +8760,12 @@ function convertToMatrix(transformList) {
8756
8760
 
8757
8761
  function makeMatrixDecomposition(transformList) {
8758
8762
  var translate = [0, 0, 0];
8759
- var scale = [0, 0, 0];
8763
+ var scale = [1, 1, 1];
8760
8764
  var skew = [0, 0, 0];
8761
8765
  var perspective = [0, 0, 0, 1];
8762
8766
  var quaternion = [0, 0, 0, 1];
8763
8767
  decomposeMatrix(convertToMatrix(transformList), translate, scale, skew, perspective, quaternion);
8764
- return [translate, scale, skew, quaternion, perspective];
8768
+ return [[translate, scale, skew, quaternion, perspective]];
8765
8769
  }
8766
8770
 
8767
8771
  var composeMatrix = function () {
@@ -8856,14 +8860,16 @@ function mergeMatrices(left, right) {
8856
8860
 
8857
8861
  if (left.decompositionPair !== right) {
8858
8862
  // @ts-ignore
8859
- left.decompositionPair = right;
8863
+ left.decompositionPair = right; // @ts-ignore
8864
+
8860
8865
  leftArgs = makeMatrixDecomposition(left);
8861
8866
  } // @ts-ignore
8862
8867
 
8863
8868
 
8864
8869
  if (right.decompositionPair !== left) {
8865
8870
  // @ts-ignore
8866
- right.decompositionPair = left;
8871
+ right.decompositionPair = left; // @ts-ignore
8872
+
8867
8873
  rightArgs = makeMatrixDecomposition(right);
8868
8874
  }
8869
8875
 
@@ -9050,7 +9056,15 @@ function mergeTransforms(left, right, target) {
9050
9056
  var stringifiedArgs = args.map(function (arg, j) {
9051
9057
  return types[i][1][j](arg);
9052
9058
  }).join(',');
9053
- if (types[i][0] === 'matrix' && stringifiedArgs.split(',').length === 16) types[i][0] = 'matrix3d';
9059
+
9060
+ if (types[i][0] === 'matrix' && stringifiedArgs.split(',').length === 16) {
9061
+ types[i][0] = 'matrix3d';
9062
+ }
9063
+
9064
+ if (types[i][0] === 'matrix3d' && stringifiedArgs.split(',').length === 6) {
9065
+ types[i][0] = 'matrix';
9066
+ }
9067
+
9054
9068
  return types[i][0] + '(' + stringifiedArgs + ')';
9055
9069
  }).join(' ');
9056
9070
  }];
@@ -10555,2336 +10569,2337 @@ var Element = /*#__PURE__*/function (_Node) {
10555
10569
  return Element;
10556
10570
  }(Node);
10557
10571
 
10558
- /**
10559
- * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationPlaybackEvent
10560
- */
10572
+ var DisplayObjectPool = /*#__PURE__*/function () {
10573
+ function DisplayObjectPool() {
10574
+ this.pool = {};
10575
+ this.htmlPool = [];
10576
+ }
10561
10577
 
10562
- var AnimationEvent = /*#__PURE__*/function (_FederatedEvent) {
10563
- _inheritsLoose(AnimationEvent, _FederatedEvent);
10578
+ var _proto = DisplayObjectPool.prototype;
10564
10579
 
10565
- function AnimationEvent(manager, target, currentTime, timelineTime) {
10566
- var _this;
10580
+ _proto.getByEntity = function getByEntity(entity) {
10581
+ return this.pool[entity];
10582
+ };
10567
10583
 
10568
- _this = _FederatedEvent.call(this, manager) || this;
10569
- _this.currentTime = void 0;
10570
- _this.timelineTime = void 0;
10571
- _this.currentTime = currentTime;
10572
- _this.timelineTime = timelineTime; // @ts-ignore
10584
+ _proto.add = function add(entity, groupOrShape) {
10585
+ this.pool[entity] = groupOrShape;
10573
10586
 
10574
- _this.target = target;
10575
- _this.type = 'finish';
10576
- _this.bubbles = false; // @ts-ignore
10587
+ if (groupOrShape.nodeName === Shape.HTML) {
10588
+ this.htmlPool.push(groupOrShape);
10589
+ }
10590
+ };
10577
10591
 
10578
- _this.currentTarget = target;
10579
- _this.defaultPrevented = false;
10580
- _this.eventPhase = _this.AT_TARGET;
10581
- _this.timeStamp = Date.now();
10582
- _this.currentTime = currentTime;
10583
- _this.timelineTime = timelineTime;
10584
- return _this;
10585
- }
10592
+ _proto.remove = function remove(entity) {
10593
+ var existed = this.pool[entity];
10594
+ delete this.pool[entity];
10586
10595
 
10587
- return AnimationEvent;
10588
- }(FederatedEvent);
10596
+ if (existed.nodeName === Shape.HTML) {
10597
+ var index = this.htmlPool.indexOf(existed);
10598
+ this.htmlPool.splice(index, 1);
10599
+ }
10600
+ };
10589
10601
 
10590
- var sequenceNumber = 0;
10602
+ _proto.getHTMLs = function getHTMLs() {
10603
+ return this.htmlPool;
10604
+ };
10605
+
10606
+ return DisplayObjectPool;
10607
+ }();
10608
+
10609
+ DisplayObjectPool = __decorate([singleton()], DisplayObjectPool);
10610
+
10611
+ var DEFAULT_STYLE_PROPS = {
10612
+ anchor: '',
10613
+ opacity: '',
10614
+ fillOpacity: '',
10615
+ strokeOpacity: '',
10616
+ fill: '',
10617
+ stroke: '',
10618
+ transform: '',
10619
+ transformOrigin: '',
10620
+ visibility: '',
10621
+ pointerEvents: '',
10622
+ lineWidth: '',
10623
+ lineCap: '',
10624
+ lineJoin: '',
10625
+ increasedLineWidthForHitTesting: '',
10626
+ fontSize: '',
10627
+ fontFamily: '',
10628
+ fontStyle: '',
10629
+ fontWeight: '',
10630
+ fontVariant: '',
10631
+ textAlign: '',
10632
+ textBaseline: '',
10633
+ textTransform: '',
10634
+ zIndex: '',
10635
+ filter: ''
10636
+ };
10591
10637
  /**
10592
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/Animation
10638
+ * prototype chains: DisplayObject -> Element -> Node -> EventTarget
10639
+ *
10640
+ * mixins: Animatable, Transformable, Visible
10641
+ * @see https://github.com/tannerntannern/ts-mixer/blob/master/README.md#mixing-generic-classes
10642
+ *
10643
+ * Provide abilities in scene graph, such as:
10644
+ * * transform `translate/rotate/scale`
10645
+ * * add/remove child
10646
+ * * visibility and z-index
10647
+ *
10648
+ * Those abilities are implemented with those components: `Transform/Sortable/Visible`.
10649
+ *
10650
+ * Emit following events:
10651
+ * * init
10652
+ * * destroy
10653
+ * * attributeChanged
10593
10654
  */
10594
10655
 
10595
- var Animation = /*#__PURE__*/function () {
10596
- function Animation(effect, timeline) {
10597
- this.effect = void 0;
10598
- this.timeline = void 0;
10599
- this.id = void 0;
10600
- this.currentTimePending = false;
10601
- this._idle = true;
10602
- this._paused = false;
10603
- this._finishedFlag = true;
10604
- this.oldPlayState = void 0;
10605
- this._holdTime = void 0;
10606
- this.readyPromise = void 0;
10607
- this.finishedPromise = void 0;
10608
- this.resolveReadyPromise = void 0;
10609
- this.rejectReadyPromise = void 0;
10610
- this.resolveFinishedPromise = void 0;
10611
- this.rejectFinishedPromise = void 0;
10612
- this.onfinish = void 0;
10613
- this.oncancel = void 0;
10614
- this.onframe = void 0;
10615
- this._currentTime = 0;
10616
- this._startTime = void 0;
10617
- this._playbackRate = 1;
10618
- this._inEffect = void 0;
10619
- this._inTimeline = true;
10620
- this.onremove = void 0;
10621
- this.effect = effect;
10622
- effect.animation = this;
10623
- this.timeline = timeline;
10624
- this.id = "" + sequenceNumber++;
10625
- this._inEffect = !!this.effect.update(0);
10626
- this._holdTime = 0;
10627
- this._paused = false;
10628
- this.oldPlayState = 'idle';
10629
- this.updatePromises();
10630
- }
10656
+ var DisplayObject = /*#__PURE__*/function (_Element) {
10657
+ _inheritsLoose(DisplayObject, _Element);
10658
+
10631
10659
  /**
10632
- * state machine,
10633
- * resolve/reject ready/finished Promise according to current state
10660
+ * contains style props in constructor's params, eg. fill, stroke...
10634
10661
  */
10635
10662
 
10663
+ /**
10664
+ * push to active animations after calling `animate()`
10665
+ */
10666
+ function DisplayObject(config) {
10667
+ var _this$config$capture;
10636
10668
 
10637
- var _proto = Animation.prototype;
10669
+ var _this;
10638
10670
 
10639
- _proto.updatePromises = function updatePromises() {
10640
- var oldPlayState = this.oldPlayState;
10641
- var newPlayState = this.pending ? 'pending' : this.playState;
10671
+ _this = _Element.call(this) || this; // assign name, id to config
10672
+ // eg. group.get('name')
10642
10673
 
10643
- if (this.readyPromise && newPlayState !== oldPlayState) {
10644
- if (newPlayState === 'idle') {
10645
- this.rejectReadyPromise();
10646
- this.readyPromise = undefined;
10647
- } else if (oldPlayState === 'pending') {
10648
- this.resolveReadyPromise();
10649
- } else if (newPlayState === 'pending') {
10650
- this.readyPromise = undefined;
10651
- }
10652
- }
10674
+ _this.config = void 0;
10675
+ _this.styleValueRegistry = GlobalContainer.get(StyleValueRegistry);
10676
+ _this.isCustomElement = false;
10677
+ _this.activeAnimations = [];
10678
+ _this.mutationEvent = new MutationEvent(ElementEvent.ATTR_MODIFIED, _assertThisInitialized(_this), null, null, null, MutationEvent.MODIFICATION, null, null);
10679
+ _this.config = config; // compatible with G 3.0
10653
10680
 
10654
- if (this.finishedPromise && newPlayState !== oldPlayState) {
10655
- if (newPlayState === 'idle') {
10656
- this.rejectFinishedPromise();
10657
- this.finishedPromise = undefined;
10658
- } else if (newPlayState === 'finished') {
10659
- this.resolveFinishedPromise();
10660
- } else if (oldPlayState === 'finished') {
10661
- this.finishedPromise = undefined;
10662
- }
10681
+ _this.config.interactive = (_this$config$capture = _this.config.capture) !== null && _this$config$capture !== void 0 ? _this$config$capture : _this.config.interactive; // init scene graph node
10682
+
10683
+ _this.id = _this.config.id || '';
10684
+ _this.name = _this.config.name || '';
10685
+
10686
+ if (_this.config.className || _this.config.class) {
10687
+ _this.className = _this.config.className || _this.config.class;
10663
10688
  }
10664
10689
 
10665
- this.oldPlayState = newPlayState;
10666
- return this.readyPromise || this.finishedPromise;
10667
- };
10690
+ _this.nodeName = _this.config.type || Shape.GROUP; // compatible with G 3.0
10668
10691
 
10669
- _proto.play = function play() {
10670
- this.updatePromises();
10671
- this._paused = false;
10692
+ _this.config.style = _extends({}, DEFAULT_STYLE_PROPS, _this.config.style, _this.config.attrs);
10672
10693
 
10673
- if (this._isFinished || this._idle) {
10674
- this.rewind();
10675
- this._startTime = null;
10694
+ if (_this.config.visible != null) {
10695
+ _this.config.style.visibility = _this.config.visible === false ? 'hidden' : 'visible';
10676
10696
  }
10677
10697
 
10678
- this._finishedFlag = false;
10679
- this._idle = false;
10680
- this.ensureAlive();
10681
- this.timeline.applyDirtiedAnimation(this);
10682
-
10683
- if (this.timeline.animations.indexOf(this) === -1) {
10684
- this.timeline.animations.push(this);
10698
+ if (_this.config.interactive != null) {
10699
+ _this.config.style.pointerEvents = _this.config.interactive === false ? 'none' : 'auto';
10685
10700
  }
10686
10701
 
10687
- this.updatePromises();
10688
- };
10702
+ _this.style = new Proxy(_extends({}, _this.attributes, {
10703
+ setProperty: function setProperty(propertyName, value) {
10704
+ _this.setAttribute(propertyName, value);
10705
+ },
10706
+ getPropertyValue: function getPropertyValue(propertyName) {
10707
+ return _this.getAttribute(propertyName);
10708
+ },
10709
+ removeProperty: function removeProperty(propertyName) {
10710
+ _this.removeAttribute(propertyName);
10711
+ },
10712
+ item: function item() {
10713
+ return '';
10714
+ }
10715
+ }), {
10716
+ get: function get(target, name) {
10717
+ if (target[name] !== undefined) {
10718
+ // if (name in target) {
10719
+ return target[name];
10720
+ }
10689
10721
 
10690
- _proto.pause = function pause() {
10691
- this.updatePromises();
10722
+ return _this.getAttribute(name);
10723
+ },
10724
+ set: function set(_, prop, value) {
10725
+ _this.setAttribute(prop, value);
10692
10726
 
10693
- if (this.currentTime) {
10694
- this._holdTime = this.currentTime;
10695
- }
10727
+ return true;
10728
+ }
10729
+ });
10696
10730
 
10697
- if (!this._isFinished && !this._paused && !this._idle) {
10698
- this.currentTimePending = true;
10699
- } else if (this._idle) {
10700
- this.rewind();
10701
- this._idle = false;
10702
- }
10731
+ _this.initAttributes(_this.config.style); // insert this group into pool
10703
10732
 
10704
- this._startTime = null;
10705
- this._paused = true;
10706
- this.updatePromises();
10733
+
10734
+ GlobalContainer.get(DisplayObjectPool).add(_this.entity, _assertThisInitialized(_this));
10735
+ return _this;
10736
+ }
10737
+
10738
+ var _proto = DisplayObject.prototype;
10739
+
10740
+ _proto.destroy = function destroy() {
10741
+ _Element.prototype.destroy.call(this); // remove from into pool
10742
+
10743
+
10744
+ GlobalContainer.get(DisplayObjectPool).remove(this.entity); // stop all active animations
10745
+
10746
+ this.getAnimations().forEach(function (animation) {
10747
+ animation.cancel();
10748
+ });
10707
10749
  };
10708
10750
 
10709
- _proto.finish = function finish() {
10710
- this.updatePromises();
10711
- if (this._idle) return;
10712
- this.currentTime = this._playbackRate > 0 ? this.totalDuration : 0;
10713
- this._startTime = this.totalDuration - this.currentTime;
10714
- this.currentTimePending = false;
10715
- this.timeline.applyDirtiedAnimation(this);
10716
- this.updatePromises();
10751
+ _proto.cloneNode = function cloneNode(deep) {
10752
+ var cloned = new this.constructor({
10753
+ // copy id & name
10754
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
10755
+ id: this.id,
10756
+ name: this.name,
10757
+ className: this.name,
10758
+ interactive: this.interactive,
10759
+ style: _extends({}, this.attributes)
10760
+ }); // apply transform
10761
+
10762
+ cloned.setLocalTransform(this.getLocalTransform());
10763
+
10764
+ if (deep) {
10765
+ this.children.forEach(function (child) {
10766
+ var clonedChild = child.cloneNode(deep);
10767
+ cloned.appendChild(clonedChild);
10768
+ });
10769
+ }
10770
+
10771
+ return cloned;
10717
10772
  };
10718
10773
 
10719
- _proto.cancel = function cancel() {
10720
- this.updatePromises();
10721
- if (!this._inEffect) return;
10722
- this._inEffect = false;
10723
- this._idle = true;
10724
- this._paused = false;
10725
- this._finishedFlag = true;
10726
- this._currentTime = 0;
10727
- this._startTime = null;
10728
- this.effect.update(null); // effects are invalid after cancellation as the animation state
10729
- // needs to un-apply.
10774
+ _proto.initAttributes = function initAttributes(attributes) {
10775
+ if (attributes === void 0) {
10776
+ attributes = {};
10777
+ }
10730
10778
 
10731
- this.timeline.applyDirtiedAnimation(this);
10732
- this.updatePromises();
10779
+ var renderable = this.renderable;
10780
+ this.styleValueRegistry.processProperties(this, attributes); // redraw at next frame
10781
+
10782
+ renderable.dirty = true;
10733
10783
  };
10734
10784
 
10735
- _proto.reverse = function reverse() {
10736
- this.updatePromises();
10737
- var oldCurrentTime = this.currentTime;
10738
- this.playbackRate *= -1;
10739
- this.play();
10785
+ _proto.setAttribute = function setAttribute(name, value, force) {
10786
+ if (force === void 0) {
10787
+ force = false;
10788
+ }
10740
10789
 
10741
- if (oldCurrentTime !== null) {
10742
- this.currentTime = oldCurrentTime;
10790
+ var _formatAttribute = formatAttribute(name, value),
10791
+ attributeName = _formatAttribute[0],
10792
+ attributeValue = _formatAttribute[1]; // ignore undefined value
10793
+
10794
+
10795
+ if (isUndefined(value)) {
10796
+ return;
10743
10797
  }
10744
10798
 
10745
- this.updatePromises();
10799
+ if (force || attributeValue !== this.attributes[attributeName]) {
10800
+ this.internalSetAttribute(attributeName, attributeValue);
10801
+
10802
+ _Element.prototype.setAttribute.call(this, attributeName, attributeValue);
10803
+ }
10746
10804
  }
10747
10805
  /**
10748
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/updatePlaybackRate
10806
+ * called when attributes get changed or initialized
10749
10807
  */
10750
10808
  ;
10751
10809
 
10752
- _proto.updatePlaybackRate = function updatePlaybackRate(playbackRate) {
10753
- this.playbackRate = playbackRate;
10754
- };
10810
+ _proto.internalSetAttribute = function internalSetAttribute(name, value, parseOptions) {
10811
+ var _this$styleValueRegis,
10812
+ _this2 = this;
10755
10813
 
10756
- _proto.targetAnimations = function targetAnimations() {
10757
- var _this$effect;
10814
+ if (parseOptions === void 0) {
10815
+ parseOptions = {};
10816
+ }
10758
10817
 
10759
- var target = (_this$effect = this.effect) === null || _this$effect === void 0 ? void 0 : _this$effect.target;
10760
- return target.getAnimations();
10761
- };
10818
+ var renderable = this.renderable;
10819
+ var oldValue = this.attributes[name];
10820
+ var oldParsedValue = this.parsedStyle[name];
10821
+ this.styleValueRegistry.processProperties(this, (_this$styleValueRegis = {}, _this$styleValueRegis[name] = value, _this$styleValueRegis), parseOptions); // inform clip path targets
10762
10822
 
10763
- _proto.markTarget = function markTarget() {
10764
- var animations = this.targetAnimations();
10823
+ if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
10824
+ this.parsedStyle.clipPathTargets.forEach(function (target) {
10825
+ _this2.sceneGraphService.dirtifyToRoot(target);
10765
10826
 
10766
- if (animations.indexOf(this) === -1) {
10767
- animations.push(this);
10768
- }
10769
- };
10827
+ target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target, _this2, _this2, 'clipPath', MutationEvent.MODIFICATION, _this2, _this2));
10770
10828
 
10771
- _proto.unmarkTarget = function unmarkTarget() {
10772
- var animations = this.targetAnimations();
10773
- var index = animations.indexOf(this);
10829
+ if (target.isCustomElement && target.isConnected) {
10830
+ if (target.attributeChangedCallback) {
10831
+ target.attributeChangedCallback('clipPath', _this2, _this2);
10832
+ }
10833
+ }
10834
+ });
10835
+ } // redraw at next frame
10774
10836
 
10775
- if (index !== -1) {
10776
- animations.splice(index, 1);
10777
- }
10778
- };
10779
10837
 
10780
- _proto.tick = function tick(timelineTime, isAnimationFrame) {
10781
- if (!this._idle && !this._paused) {
10782
- if (this._startTime === null) {
10783
- if (isAnimationFrame) {
10784
- this.startTime = timelineTime - this._currentTime / this.playbackRate;
10785
- }
10786
- } else if (!this._isFinished) {
10787
- this.tickCurrentTime((timelineTime - this._startTime) * this.playbackRate);
10788
- }
10789
- }
10838
+ renderable.dirty = true; // trigger later
10839
+ // this.sceneGraphService.pendingEvents.push([ElementEvent.ATTR_MODIFIED, { affectChildren }]);
10790
10840
 
10791
- if (isAnimationFrame) {
10792
- this.currentTimePending = false;
10793
- this.fireEvents(timelineTime);
10794
- }
10795
- };
10841
+ this.mutationEvent.prevValue = oldValue;
10842
+ this.mutationEvent.newValue = value;
10843
+ this.mutationEvent.attrName = name;
10844
+ this.mutationEvent.prevParsedValue = oldParsedValue;
10845
+ this.mutationEvent.newParsedValue = this.parsedStyle[name];
10846
+ this.dispatchEvent(this.mutationEvent);
10796
10847
 
10797
- _proto.rewind = function rewind() {
10798
- if (this.playbackRate >= 0) {
10799
- this.currentTime = 0;
10800
- } else if (this.totalDuration < Infinity) {
10801
- this.currentTime = this.totalDuration;
10802
- } else {
10803
- throw new Error('Unable to rewind negative playback rate animation with infinite duration');
10848
+ if (this.isCustomElement && this.isConnected) {
10849
+ if (this.attributeChangedCallback) {
10850
+ this.attributeChangedCallback(name, oldValue, value);
10851
+ }
10804
10852
  }
10805
- };
10853
+ } // #region transformable
10806
10854
 
10807
- _proto.persist = function persist() {
10808
- throw new Error('Method not implemented.');
10809
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
10855
+ /**
10856
+ * returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
10857
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
10858
+ *
10859
+ * FIXME: It is worth noting that getBBox responds to original untransformed values of a drawn object.
10860
+ * @see https://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#getBBox
10861
+ */
10810
10862
  ;
10811
10863
 
10812
- _proto.addEventListener = function addEventListener(type, listener, options) {
10813
- throw new Error('Method not implemented.');
10814
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
10815
- ;
10864
+ _proto.getBBox = function getBBox() {
10865
+ var aabb = this.getBounds();
10816
10866
 
10817
- _proto.removeEventListener = function removeEventListener(type, listener, options) {
10818
- throw new Error('Method not implemented.');
10819
- } // eslint-disable-next-line @typescript-eslint/no-unused-vars
10820
- ;
10867
+ var _aabb$getMin = aabb.getMin(),
10868
+ left = _aabb$getMin[0],
10869
+ top = _aabb$getMin[1];
10821
10870
 
10822
- _proto.dispatchEvent = function dispatchEvent(event) {
10823
- throw new Error('Method not implemented.');
10824
- };
10871
+ var _aabb$getMax = aabb.getMax(),
10872
+ right = _aabb$getMax[0],
10873
+ bottom = _aabb$getMax[1];
10825
10874
 
10826
- // replaceState: AnimationReplaceState;
10827
- _proto.commitStyles = function commitStyles() {
10828
- throw new Error('Method not implemented.');
10875
+ return new Rectangle(left, top, right - left, bottom - top);
10829
10876
  };
10830
10877
 
10831
- _proto.ensureAlive = function ensureAlive() {
10832
- // If an animation is playing backwards and is not fill backwards/both
10833
- // then it should go out of effect when it reaches the start of its
10834
- // active interval (currentTime === 0).
10835
- if (this.playbackRate < 0 && this.currentTime === 0) {
10836
- var _this$effect2;
10837
-
10838
- this._inEffect = !!((_this$effect2 = this.effect) === null || _this$effect2 === void 0 ? void 0 : _this$effect2.update(-1));
10839
- } else {
10840
- var _this$effect3;
10841
-
10842
- this._inEffect = !!((_this$effect3 = this.effect) === null || _this$effect3 === void 0 ? void 0 : _this$effect3.update(this.currentTime));
10878
+ _proto.setOrigin = function setOrigin(position, y, z) {
10879
+ if (y === void 0) {
10880
+ y = 0;
10843
10881
  }
10844
10882
 
10845
- if (!this._inTimeline && (this._inEffect || !this._finishedFlag)) {
10846
- this._inTimeline = true;
10847
- this.timeline.animations.push(this);
10883
+ if (z === void 0) {
10884
+ z = 0;
10848
10885
  }
10849
- };
10850
10886
 
10851
- _proto.tickCurrentTime = function tickCurrentTime(newTime, ignoreLimit) {
10852
- if (newTime !== this._currentTime) {
10853
- this._currentTime = newTime;
10887
+ this.sceneGraphService.setOrigin(this, createVec3(position, y, z));
10888
+ return this;
10889
+ };
10854
10890
 
10855
- if (this._isFinished && !ignoreLimit) {
10856
- this._currentTime = this._playbackRate > 0 ? this.totalDuration : 0;
10857
- }
10891
+ _proto.getOrigin = function getOrigin() {
10892
+ return this.sceneGraphService.getOrigin(this);
10893
+ }
10894
+ /**
10895
+ * set position in world space
10896
+ */
10897
+ ;
10858
10898
 
10859
- this.ensureAlive();
10899
+ _proto.setPosition = function setPosition(position, y, z) {
10900
+ if (y === void 0) {
10901
+ y = 0;
10860
10902
  }
10861
- };
10862
10903
 
10863
- _proto.fireEvents = function fireEvents(baseTime) {
10864
- var _this = this;
10904
+ if (z === void 0) {
10905
+ z = 0;
10906
+ }
10865
10907
 
10866
- if (this._isFinished) {
10867
- if (!this._finishedFlag) {
10868
- if (this.onfinish) {
10869
- var event = new AnimationEvent(null, this, this.currentTime, baseTime);
10870
- setTimeout(function () {
10871
- if (_this.onfinish) {
10872
- _this.onfinish(event);
10873
- }
10874
- });
10875
- }
10876
-
10877
- this._finishedFlag = true;
10878
- }
10879
- } else {
10880
- if (this.onframe && this.playState === 'running') {
10881
- var _event = new AnimationEvent(null, this, this.currentTime, baseTime);
10882
-
10883
- this.onframe(_event);
10884
- }
10908
+ this.sceneGraphService.setPosition(this, createVec3(position, y, z));
10909
+ return this;
10910
+ }
10911
+ /**
10912
+ * set position in local space
10913
+ */
10914
+ ;
10885
10915
 
10886
- this._finishedFlag = false;
10916
+ _proto.setLocalPosition = function setLocalPosition(position, y, z) {
10917
+ if (y === void 0) {
10918
+ y = 0;
10887
10919
  }
10888
- };
10889
-
10890
- _createClass(Animation, [{
10891
- key: "pending",
10892
- get:
10893
- /**
10894
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/effect
10895
- */
10896
10920
 
10897
- /**
10898
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/timeline
10899
- */
10900
-
10901
- /**
10902
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/id
10903
- */
10904
- // animation: InternalAnimation | null;
10905
-
10906
- /**
10907
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/pending
10908
- */
10909
- function get() {
10910
- return this._startTime === null && !this._paused && this.playbackRate !== 0 || this.currentTimePending;
10911
- }
10912
- }, {
10913
- key: "playState",
10914
- get: function get() {
10915
- if (this._idle) return 'idle';
10916
- if (this._isFinished) return 'finished';
10917
- if (this._paused) return 'paused';
10918
- return 'running';
10921
+ if (z === void 0) {
10922
+ z = 0;
10919
10923
  }
10920
- /**
10921
- * record previos state
10922
- */
10923
-
10924
- }, {
10925
- key: "ready",
10926
- get:
10927
- /**
10928
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/ready
10929
- * @example
10930
- animation.pause();
10931
- animation.ready.then(function() {
10932
- // Displays 'running'
10933
- alert(animation.playState);
10934
- });
10935
- animation.play();
10936
- */
10937
- function get() {
10938
- var _this2 = this;
10939
-
10940
- if (!this.readyPromise) {
10941
- if (this.timeline.animationsWithPromises.indexOf(this) === -1) {
10942
- this.timeline.animationsWithPromises.push(this);
10943
- }
10944
-
10945
- this.readyPromise = new Promise(function (resolve, reject) {
10946
- _this2.resolveReadyPromise = function () {
10947
- resolve(_this2);
10948
- };
10949
10924
 
10950
- _this2.rejectReadyPromise = function () {
10951
- reject(new Error());
10952
- };
10953
- });
10954
-
10955
- if (!this.pending) {
10956
- this.resolveReadyPromise();
10957
- }
10958
- }
10925
+ this.sceneGraphService.setLocalPosition(this, createVec3(position, y, z));
10926
+ return this;
10927
+ }
10928
+ /**
10929
+ * translate in world space
10930
+ */
10931
+ ;
10959
10932
 
10960
- return this.readyPromise;
10933
+ _proto.translate = function translate(position, y, z) {
10934
+ if (y === void 0) {
10935
+ y = 0;
10961
10936
  }
10962
- /**
10963
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/finished
10964
- * @example
10965
- Promise.all(
10966
- elem.getAnimations().map(
10967
- function(animation) {
10968
- return animation.finished
10969
- }
10970
- )
10971
- ).then(
10972
- function() {
10973
- return elem.remove();
10974
- }
10975
- );
10976
- */
10977
-
10978
- }, {
10979
- key: "finished",
10980
- get: function get() {
10981
- var _this3 = this;
10982
-
10983
- if (!this.finishedPromise) {
10984
- if (this.timeline.animationsWithPromises.indexOf(this) === -1) {
10985
- this.timeline.animationsWithPromises.push(this);
10986
- }
10987
-
10988
- this.finishedPromise = new Promise(function (resolve, reject) {
10989
- _this3.resolveFinishedPromise = function () {
10990
- resolve(_this3);
10991
- };
10992
-
10993
- _this3.rejectFinishedPromise = function () {
10994
- reject(new Error());
10995
- };
10996
- });
10997
10937
 
10998
- if (this.playState === 'finished') {
10999
- this.resolveFinishedPromise();
11000
- }
11001
- }
11002
-
11003
- return this.finishedPromise;
10938
+ if (z === void 0) {
10939
+ z = 0;
11004
10940
  }
11005
- /**
11006
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/onfinish
11007
- */
11008
-
11009
- }, {
11010
- key: "currentTime",
11011
- get:
11012
- /**
11013
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/currentTime
11014
- */
11015
- function get() {
11016
- this.updatePromises();
11017
- return this._idle || this.currentTimePending ? null : this._currentTime;
11018
- },
11019
- set: function set(newTime) {
11020
- newTime = Number(newTime);
11021
- if (isNaN(newTime)) return;
11022
- this.timeline.restart();
11023
10941
 
11024
- if (!this._paused && this._startTime !== null) {
11025
- var _this$timeline;
11026
-
11027
- this._startTime = Number((_this$timeline = this.timeline) === null || _this$timeline === void 0 ? void 0 : _this$timeline.currentTime) - newTime / this.playbackRate;
11028
- }
11029
-
11030
- this.currentTimePending = false;
11031
-
11032
- if (this._currentTime === newTime) {
11033
- return;
11034
- }
11035
-
11036
- if (this._idle) {
11037
- this._idle = false;
11038
- this._paused = true;
11039
- }
10942
+ this.sceneGraphService.translate(this, createVec3(position, y, z));
10943
+ return this;
10944
+ }
10945
+ /**
10946
+ * translate in local space
10947
+ */
10948
+ ;
11040
10949
 
11041
- this.tickCurrentTime(newTime, true);
11042
- this.timeline.applyDirtiedAnimation(this);
10950
+ _proto.translateLocal = function translateLocal(position, y, z) {
10951
+ if (y === void 0) {
10952
+ y = 0;
11043
10953
  }
11044
- /**
11045
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/startTime
11046
- */
11047
10954
 
11048
- }, {
11049
- key: "startTime",
11050
- get: function get() {
11051
- return this._startTime;
11052
- },
11053
- set: function set(newTime) {
11054
- if (newTime !== null) {
11055
- this.updatePromises();
11056
- newTime = Number(newTime);
11057
- if (isNaN(newTime)) return;
11058
- if (this._paused || this._idle) return;
11059
- this._startTime = newTime;
11060
- this.tickCurrentTime((Number(this.timeline.currentTime) - this._startTime) * this.playbackRate);
11061
- this.timeline.applyDirtiedAnimation(this);
11062
- this.updatePromises();
11063
- }
10955
+ if (z === void 0) {
10956
+ z = 0;
11064
10957
  }
11065
- }, {
11066
- key: "playbackRate",
11067
- get: function get() {
11068
- return this._playbackRate;
11069
- },
11070
- set: function set(value) {
11071
- if (value === this._playbackRate) {
11072
- return;
11073
- }
11074
10958
 
11075
- this.updatePromises();
11076
- var oldCurrentTime = this.currentTime;
11077
- this._playbackRate = value;
11078
- this.startTime = null;
10959
+ this.sceneGraphService.translateLocal(this, createVec3(position, y, z));
10960
+ return this;
10961
+ };
11079
10962
 
11080
- if (this.playState !== 'paused' && this.playState !== 'idle') {
11081
- this._finishedFlag = false;
11082
- this._idle = false;
11083
- this.ensureAlive();
11084
- this.timeline.applyDirtiedAnimation(this);
11085
- }
10963
+ _proto.getPosition = function getPosition() {
10964
+ return this.sceneGraphService.getPosition(this);
10965
+ };
11086
10966
 
11087
- if (oldCurrentTime !== null) {
11088
- this.currentTime = oldCurrentTime;
11089
- }
10967
+ _proto.getLocalPosition = function getLocalPosition() {
10968
+ return this.sceneGraphService.getLocalPosition(this);
10969
+ }
10970
+ /**
10971
+ * compatible with G 3.0
10972
+ *
10973
+ * scaling in local space
10974
+ * scale(10) = scale(10, 10, 10)
10975
+ *
10976
+ * we can't set scale in world space
10977
+ */
10978
+ ;
11090
10979
 
11091
- this.updatePromises();
11092
- }
11093
- }, {
11094
- key: "_isFinished",
11095
- get: function get() {
11096
- return !this._idle && (this._playbackRate > 0 && Number(this._currentTime) >= this.totalDuration || this._playbackRate < 0 && Number(this._currentTime) <= 0);
11097
- }
11098
- }, {
11099
- key: "totalDuration",
11100
- get: function get() {
11101
- var _this$effect4;
10980
+ _proto.scale = function scale(scaling, y, z) {
10981
+ return this.scaleLocal(scaling, y, z);
10982
+ };
11102
10983
 
11103
- return Number((_this$effect4 = this.effect) === null || _this$effect4 === void 0 ? void 0 : _this$effect4.getComputedTiming().endTime);
11104
- }
11105
- }, {
11106
- key: "_needsTick",
11107
- get: function get() {
11108
- return this.pending || this.playState === 'running' || !this._finishedFlag;
10984
+ _proto.scaleLocal = function scaleLocal(scaling, y, z) {
10985
+ if (typeof scaling === 'number') {
10986
+ y = y || scaling;
10987
+ z = z || scaling;
10988
+ scaling = createVec3(scaling, y, z);
11109
10989
  }
11110
- }]);
11111
10990
 
11112
- return Animation;
11113
- }();
11114
-
11115
- function compareAnimations(leftAnimation, rightAnimation) {
11116
- return Number(leftAnimation.id) - Number(rightAnimation.id);
11117
- }
11118
- /**
11119
- * @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/web-animations-js/index.d.ts
11120
- */
11121
-
11122
- var AnimationTimeline = /*#__PURE__*/function () {
10991
+ this.sceneGraphService.scaleLocal(this, scaling);
10992
+ return this;
10993
+ }
11123
10994
  /**
11124
- * all active animations
10995
+ * set scaling in local space
11125
10996
  */
11126
- function AnimationTimeline(document) {
11127
- var _this = this;
11128
-
11129
- this.document = void 0;
11130
- this.animations = [];
11131
- this.ticking = false;
11132
- this.timelineTicking = false;
11133
- this.hasRestartedThisFrame = false;
11134
- this.animationsWithPromises = [];
11135
- this.inTick = false;
11136
- this.pendingEffects = [];
11137
- this.currentTime = null;
11138
- this.rafId = 0;
11139
- this.rafCallbacks = [];
11140
- this.frameId = void 0;
11141
-
11142
- this.webAnimationsNextTick = function (t) {
11143
- _this.currentTime = t;
11144
-
11145
- _this.discardAnimations();
11146
-
11147
- if (_this.animations.length === 0) {
11148
- _this.timelineTicking = false;
11149
- } else {
11150
- _this.requestAnimationFrame(_this.webAnimationsNextTick);
11151
- }
11152
- };
11153
-
11154
- this.processRafCallbacks = function (t) {
11155
- var processing = _this.rafCallbacks;
11156
- _this.rafCallbacks = [];
11157
- if (t < Number(_this.currentTime)) t = Number(_this.currentTime);
11158
-
11159
- _this.animations.sort(compareAnimations);
11160
-
11161
- _this.animations = _this.tick(t, true, _this.animations)[0];
11162
- processing.forEach(function (entry) {
11163
- entry[1](t);
11164
- });
10997
+ ;
11165
10998
 
11166
- _this.applyPendingEffects();
11167
- };
10999
+ _proto.setLocalScale = function setLocalScale(scaling, y, z) {
11000
+ if (typeof scaling === 'number') {
11001
+ y = y || scaling;
11002
+ z = z || scaling;
11003
+ scaling = createVec3(scaling, y, z);
11004
+ }
11168
11005
 
11169
- this.document = document;
11006
+ this.sceneGraphService.setLocalScale(this, scaling);
11007
+ return this;
11170
11008
  }
11009
+ /**
11010
+ * get scaling in local space
11011
+ */
11012
+ ;
11171
11013
 
11172
- var _proto = AnimationTimeline.prototype;
11173
-
11174
- _proto.getAnimations = function getAnimations() {
11175
- this.discardAnimations();
11176
- return this.animations.slice();
11177
- };
11178
-
11179
- _proto.isTicking = function isTicking() {
11180
- return this.inTick;
11181
- };
11014
+ _proto.getLocalScale = function getLocalScale() {
11015
+ return this.sceneGraphService.getLocalScale(this);
11016
+ }
11017
+ /**
11018
+ * get scaling in world space
11019
+ */
11020
+ ;
11182
11021
 
11183
- _proto.play = function play(effect) {
11184
- var animation = new Animation(effect, this);
11185
- this.animations.push(animation);
11186
- this.restartWebAnimationsNextTick();
11187
- animation.updatePromises();
11188
- animation.play();
11189
- animation.updatePromises();
11190
- return animation;
11191
- } // RAF is supposed to be the last script to occur before frame rendering but not
11192
- // all browsers behave like this. This function is for synchonously updating an
11193
- // animation's effects whenever its state is mutated by script to work around
11194
- // incorrect script execution ordering by the browser.
11022
+ _proto.getScale = function getScale() {
11023
+ return this.sceneGraphService.getScale(this);
11024
+ }
11025
+ /**
11026
+ * only return degrees of Z axis in world space
11027
+ */
11195
11028
  ;
11196
11029
 
11197
- _proto.applyDirtiedAnimation = function applyDirtiedAnimation(animation) {
11198
- var _this2 = this;
11030
+ _proto.getEulerAngles = function getEulerAngles() {
11031
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11032
+ var _getEuler = getEuler(vec3.create(), this.sceneGraphService.getWorldTransform(this)),
11033
+ ex = _getEuler[0],
11034
+ ey = _getEuler[1],
11035
+ ez = _getEuler[2];
11199
11036
 
11200
- if (this.inTick) {
11201
- return;
11202
- } // update active animations in displayobject
11037
+ return rad2deg(ez);
11038
+ }
11039
+ /**
11040
+ * only return degrees of Z axis in local space
11041
+ */
11042
+ ;
11203
11043
 
11044
+ _proto.getLocalEulerAngles = function getLocalEulerAngles() {
11045
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
11046
+ var _getEuler2 = getEuler(vec3.create(), this.sceneGraphService.getLocalRotation(this)),
11047
+ ex = _getEuler2[0],
11048
+ ey = _getEuler2[1],
11049
+ ez = _getEuler2[2];
11204
11050
 
11205
- animation.markTarget();
11206
- var animations = animation.targetAnimations();
11207
- animations.sort(compareAnimations); // clear inactive animations
11051
+ return rad2deg(ez);
11052
+ }
11053
+ /**
11054
+ * set euler angles(degrees) in world space
11055
+ */
11056
+ ;
11208
11057
 
11209
- var inactiveAnimations = this.tick(Number(this.currentTime), false, animations.slice())[1];
11210
- inactiveAnimations.forEach(function (animation) {
11211
- var index = _this2.animations.indexOf(animation);
11058
+ _proto.setEulerAngles = function setEulerAngles(z) {
11059
+ this.sceneGraphService.setEulerAngles(this, 0, 0, z);
11060
+ return this;
11061
+ }
11062
+ /**
11063
+ * set euler angles(degrees) in local space
11064
+ */
11065
+ ;
11212
11066
 
11213
- if (index !== -1) {
11214
- _this2.animations.splice(index, 1);
11215
- }
11216
- });
11217
- this.applyPendingEffects();
11067
+ _proto.setLocalEulerAngles = function setLocalEulerAngles(z) {
11068
+ this.sceneGraphService.setLocalEulerAngles(this, 0, 0, z);
11069
+ return this;
11218
11070
  };
11219
11071
 
11220
- _proto.restart = function restart() {
11221
- if (!this.ticking) {
11222
- this.ticking = true;
11223
- this.requestAnimationFrame(function () {});
11224
- this.hasRestartedThisFrame = true;
11072
+ _proto.rotateLocal = function rotateLocal(x, y, z) {
11073
+ if (isNil(y) && isNil(z)) {
11074
+ this.sceneGraphService.rotateLocal(this, 0, 0, x);
11075
+ } else {
11076
+ this.sceneGraphService.rotateLocal(this, x, y, z);
11225
11077
  }
11226
11078
 
11227
- return this.hasRestartedThisFrame;
11079
+ return this;
11228
11080
  };
11229
11081
 
11230
- _proto.destroy = function destroy() {
11231
- this.document.defaultView.cancelAnimationFrame(this.frameId);
11232
- };
11082
+ _proto.rotate = function rotate(x, y, z) {
11083
+ if (isNil(y) && isNil(z)) {
11084
+ this.sceneGraphService.rotate(this, 0, 0, x);
11085
+ } else {
11086
+ this.sceneGraphService.rotate(this, x, y, z);
11087
+ }
11233
11088
 
11234
- _proto.applyPendingEffects = function applyPendingEffects() {
11235
- this.pendingEffects.forEach(function (effect) {
11236
- effect === null || effect === void 0 ? void 0 : effect.applyInterpolations();
11237
- });
11238
- this.pendingEffects = [];
11089
+ return this;
11239
11090
  };
11240
11091
 
11241
- _proto.updateAnimationsPromises = function updateAnimationsPromises() {
11242
- this.animationsWithPromises = this.animationsWithPromises.filter(function (animation) {
11243
- return animation.updatePromises();
11244
- });
11092
+ _proto.setRotation = function setRotation(rotation, y, z, w) {
11093
+ this.sceneGraphService.setRotation(this, rotation, y, z, w);
11094
+ return this;
11245
11095
  };
11246
11096
 
11247
- _proto.discardAnimations = function discardAnimations() {
11248
- this.updateAnimationsPromises();
11249
- this.animations = this.animations.filter(function (animation) {
11250
- return animation.playState !== 'finished' && animation.playState !== 'idle';
11251
- });
11097
+ _proto.setLocalRotation = function setLocalRotation(rotation, y, z, w) {
11098
+ this.sceneGraphService.setLocalRotation(this, rotation, y, z, w);
11099
+ return this;
11252
11100
  };
11253
11101
 
11254
- _proto.restartWebAnimationsNextTick = function restartWebAnimationsNextTick() {
11255
- if (!this.timelineTicking) {
11256
- this.timelineTicking = true;
11257
- this.requestAnimationFrame(this.webAnimationsNextTick);
11258
- }
11102
+ _proto.setLocalSkew = function setLocalSkew(skew, y) {
11103
+ this.sceneGraphService.setLocalSkew(this, skew, y);
11104
+ return this;
11259
11105
  };
11260
11106
 
11261
- _proto.rAF = function rAF(f) {
11262
- var id = this.rafId++;
11263
-
11264
- if (this.rafCallbacks.length === 0) {
11265
- this.frameId = this.document.defaultView.requestAnimationFrame(this.processRafCallbacks);
11266
- }
11267
-
11268
- this.rafCallbacks.push([id, f]);
11269
- return id;
11107
+ _proto.getRotation = function getRotation() {
11108
+ return this.sceneGraphService.getRotation(this);
11270
11109
  };
11271
11110
 
11272
- _proto.requestAnimationFrame = function requestAnimationFrame(f) {
11273
- var _this3 = this;
11274
-
11275
- return this.rAF(function (x) {
11276
- _this3.updateAnimationsPromises();
11277
-
11278
- f(x);
11279
-
11280
- _this3.updateAnimationsPromises();
11281
- });
11111
+ _proto.getLocalRotation = function getLocalRotation() {
11112
+ return this.sceneGraphService.getLocalRotation(this);
11282
11113
  };
11283
11114
 
11284
- _proto.tick = function tick(t, isAnimationFrame, updatingAnimations) {
11285
- var _this4 = this,
11286
- _this$pendingEffects,
11287
- _this$pendingEffects2;
11288
-
11289
- this.inTick = true;
11290
- this.hasRestartedThisFrame = false;
11291
- this.currentTime = t;
11292
- this.ticking = false;
11293
- var newPendingClears = [];
11294
- var newPendingEffects = [];
11295
- var activeAnimations = [];
11296
- var inactiveAnimations = [];
11297
- updatingAnimations.forEach(function (animation) {
11298
- animation.tick(t, isAnimationFrame);
11299
-
11300
- if (!animation._inEffect) {
11301
- newPendingClears.push(animation.effect);
11302
- animation.unmarkTarget();
11303
- } else {
11304
- newPendingEffects.push(animation.effect);
11305
- animation.markTarget();
11306
- }
11307
-
11308
- if (animation._needsTick) _this4.ticking = true;
11309
- var alive = animation._inEffect || animation._needsTick;
11310
- animation._inTimeline = alive;
11311
-
11312
- if (alive) {
11313
- activeAnimations.push(animation);
11314
- } else {
11315
- inactiveAnimations.push(animation);
11316
- }
11317
- });
11115
+ _proto.getLocalSkew = function getLocalSkew() {
11116
+ return this.sceneGraphService.getLocalSkew(this);
11117
+ };
11318
11118
 
11319
- (_this$pendingEffects = this.pendingEffects).push.apply(_this$pendingEffects, newPendingClears);
11119
+ _proto.getLocalTransform = function getLocalTransform() {
11120
+ return this.sceneGraphService.getLocalTransform(this);
11121
+ };
11320
11122
 
11321
- (_this$pendingEffects2 = this.pendingEffects).push.apply(_this$pendingEffects2, newPendingEffects);
11123
+ _proto.getWorldTransform = function getWorldTransform() {
11124
+ return this.sceneGraphService.getWorldTransform(this);
11125
+ };
11322
11126
 
11323
- if (this.ticking) this.requestAnimationFrame(function () {});
11324
- this.inTick = false;
11325
- return [activeAnimations, inactiveAnimations];
11127
+ _proto.setLocalTransform = function setLocalTransform(transform) {
11128
+ this.sceneGraphService.setLocalTransform(this, transform);
11129
+ return this;
11326
11130
  };
11327
11131
 
11328
- return AnimationTimeline;
11329
- }();
11132
+ _proto.resetLocalTransform = function resetLocalTransform() {
11133
+ this.sceneGraphService.resetLocalTransform(this);
11134
+ } // #endregion transformable
11135
+ // #region animatable
11330
11136
 
11331
- var DisplayObjectPool = /*#__PURE__*/function () {
11332
- function DisplayObjectPool() {
11333
- this.pool = {};
11334
- this.htmlPool = [];
11137
+ /**
11138
+ * returns an array of all Animation objects affecting this element
11139
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
11140
+ */
11141
+ ;
11142
+
11143
+ _proto.getAnimations = function getAnimations() {
11144
+ return this.activeAnimations;
11335
11145
  }
11146
+ /**
11147
+ * create an animation with WAAPI
11148
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/animate
11149
+ */
11150
+ ;
11336
11151
 
11337
- var _proto = DisplayObjectPool.prototype;
11152
+ _proto.animate = function animate(keyframes, options) {
11153
+ var _this$ownerDocument;
11338
11154
 
11339
- _proto.getByEntity = function getByEntity(entity) {
11340
- return this.pool[entity];
11341
- };
11155
+ var timeline = (_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.timeline; // account for clip path, use target's timeline
11342
11156
 
11343
- _proto.add = function add(entity, groupOrShape) {
11344
- this.pool[entity] = groupOrShape;
11157
+ if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
11158
+ var _target$ownerDocument;
11345
11159
 
11346
- if (groupOrShape.nodeName === Shape.HTML) {
11347
- this.htmlPool.push(groupOrShape);
11348
- }
11349
- };
11160
+ var target = this.parsedStyle.clipPathTargets[0];
11161
+ timeline = (_target$ownerDocument = target.ownerDocument) === null || _target$ownerDocument === void 0 ? void 0 : _target$ownerDocument.timeline;
11162
+ } // clear old parsed transform
11350
11163
 
11351
- _proto.remove = function remove(entity) {
11352
- var existed = this.pool[entity];
11353
- delete this.pool[entity];
11354
11164
 
11355
- if (existed.nodeName === Shape.HTML) {
11356
- var index = this.htmlPool.indexOf(existed);
11357
- this.htmlPool.splice(index, 1);
11165
+ delete this.parsedStyle.transform;
11166
+
11167
+ if (timeline) {
11168
+ return timeline.play(new KeyframeEffect(this, keyframes, options));
11358
11169
  }
11359
- };
11360
11170
 
11361
- _proto.getHTMLs = function getHTMLs() {
11362
- return this.htmlPool;
11363
- };
11171
+ return null;
11172
+ } // #endregion animatable
11173
+ // #region visible
11364
11174
 
11365
- return DisplayObjectPool;
11366
- }();
11175
+ /**
11176
+ * show group, which will also change visibility of its children in sceneGraphNode
11177
+ *
11178
+ * @deprecated
11179
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility
11180
+ */
11181
+ ;
11367
11182
 
11368
- DisplayObjectPool = __decorate([singleton()], DisplayObjectPool);
11183
+ _proto.show = function show() {
11184
+ this.style.visibility = 'visible';
11185
+ }
11186
+ /**
11187
+ * @deprecated
11188
+ * hide group, which will also change visibility of its children in sceneGraphNode
11189
+ */
11190
+ ;
11369
11191
 
11370
- var DEFAULT_STYLE_PROPS = {
11371
- anchor: '',
11372
- opacity: '',
11373
- fillOpacity: '',
11374
- strokeOpacity: '',
11375
- fill: '',
11376
- stroke: '',
11377
- transform: '',
11378
- transformOrigin: '',
11379
- visibility: '',
11380
- pointerEvents: '',
11381
- lineWidth: '',
11382
- lineCap: '',
11383
- lineJoin: '',
11384
- increasedLineWidthForHitTesting: '',
11385
- fontSize: '',
11386
- fontFamily: '',
11387
- fontStyle: '',
11388
- fontWeight: '',
11389
- fontVariant: '',
11390
- textAlign: '',
11391
- textBaseline: '',
11392
- textTransform: '',
11393
- zIndex: ''
11394
- };
11395
- /**
11396
- * prototype chains: DisplayObject -> Element -> Node -> EventTarget
11397
- *
11398
- * mixins: Animatable, Transformable, Visible
11399
- * @see https://github.com/tannerntannern/ts-mixer/blob/master/README.md#mixing-generic-classes
11400
- *
11401
- * Provide abilities in scene graph, such as:
11402
- * * transform `translate/rotate/scale`
11403
- * * add/remove child
11404
- * * visibility and z-index
11405
- *
11406
- * Those abilities are implemented with those components: `Transform/Sortable/Visible`.
11407
- *
11408
- * Emit following events:
11409
- * * init
11410
- * * destroy
11411
- * * attributeChanged
11412
- */
11192
+ _proto.hide = function hide() {
11193
+ this.style.visibility = 'hidden';
11194
+ }
11195
+ /**
11196
+ * shortcut for Used value of `visibility`
11197
+ */
11198
+ ;
11413
11199
 
11414
- var DisplayObject = /*#__PURE__*/function (_Element) {
11415
- _inheritsLoose(DisplayObject, _Element);
11200
+ _proto.isVisible = function isVisible() {
11201
+ var _this$parsedStyle, _this$parsedStyle$vis;
11202
+
11203
+ return ((_this$parsedStyle = this.parsedStyle) === null || _this$parsedStyle === void 0 ? void 0 : (_this$parsedStyle$vis = _this$parsedStyle.visibility) === null || _this$parsedStyle$vis === void 0 ? void 0 : _this$parsedStyle$vis.value) === 'visible';
11204
+ };
11205
+
11206
+ _proto.isInteractive = function isInteractive() {
11207
+ var _this$parsedStyle2, _this$parsedStyle2$po;
11416
11208
 
11209
+ return ((_this$parsedStyle2 = this.parsedStyle) === null || _this$parsedStyle2 === void 0 ? void 0 : (_this$parsedStyle2$po = _this$parsedStyle2.pointerEvents) === null || _this$parsedStyle2$po === void 0 ? void 0 : _this$parsedStyle2$po.value) !== 'none';
11210
+ };
11211
+
11212
+ _proto.isCulled = function isCulled() {
11213
+ return !!(this.cullable && this.cullable.isCulled());
11214
+ }
11417
11215
  /**
11418
- * contains style props in constructor's params, eg. fill, stroke...
11216
+ * bring to front in current group
11419
11217
  */
11218
+ ;
11219
+
11220
+ _proto.toFront = function toFront() {
11221
+ if (this.parentNode) {
11222
+ this.style.zIndex = Math.max.apply(Math, this.parentNode.children.map(function (child) {
11223
+ return Number(child.style.zIndex);
11224
+ })) + 1;
11225
+ }
11420
11226
 
11227
+ return this;
11228
+ }
11421
11229
  /**
11422
- * push to active animations after calling `animate()`
11230
+ * send to back in current group
11423
11231
  */
11424
- function DisplayObject(config) {
11425
- var _this$config$capture;
11232
+ ;
11426
11233
 
11427
- var _this;
11234
+ _proto.toBack = function toBack() {
11235
+ if (this.parentNode) {
11236
+ this.style.zIndex = Math.min.apply(Math, this.parentNode.children.map(function (child) {
11237
+ return Number(child.style.zIndex);
11238
+ })) - 1;
11239
+ }
11428
11240
 
11429
- _this = _Element.call(this) || this; // assign name, id to config
11430
- // eg. group.get('name')
11241
+ return this;
11242
+ } // #endregion visible
11243
+ // #region deprecated
11431
11244
 
11432
- _this.config = void 0;
11433
- _this.styleValueRegistry = GlobalContainer.get(StyleValueRegistry);
11434
- _this.isCustomElement = false;
11435
- _this.activeAnimations = [];
11436
- _this.mutationEvent = new MutationEvent(ElementEvent.ATTR_MODIFIED, _assertThisInitialized(_this), null, null, null, MutationEvent.MODIFICATION, null, null);
11437
- _this.config = config; // compatible with G 3.0
11245
+ /**
11246
+ * @deprecated
11247
+ * compatible with G 3.0
11248
+ * @deprecated
11249
+ */
11250
+ ;
11438
11251
 
11439
- _this.config.interactive = (_this$config$capture = _this.config.capture) !== null && _this$config$capture !== void 0 ? _this$config$capture : _this.config.interactive; // init scene graph node
11252
+ _proto.getCount = function getCount() {
11253
+ return this.childElementCount;
11254
+ }
11255
+ /**
11256
+ * @deprecated
11257
+ * compatible with G 3.0
11258
+ * @deprecated
11259
+ */
11260
+ ;
11440
11261
 
11441
- _this.id = _this.config.id || '';
11442
- _this.name = _this.config.name || '';
11262
+ _proto.getParent = function getParent() {
11263
+ return this.parentElement;
11264
+ }
11265
+ /**
11266
+ * @deprecated
11267
+ * compatible with G 3.0
11268
+ * @deprecated
11269
+ */
11270
+ ;
11443
11271
 
11444
- if (_this.config.className || _this.config.class) {
11445
- _this.className = _this.config.className || _this.config.class;
11446
- }
11272
+ _proto.getChildren = function getChildren() {
11273
+ return this.children;
11274
+ }
11275
+ /**
11276
+ * @deprecated
11277
+ * compatible with G 3.0
11278
+ * @deprecated
11279
+ */
11280
+ ;
11447
11281
 
11448
- _this.nodeName = _this.config.type || Shape.GROUP; // compatible with G 3.0
11282
+ _proto.getFirst = function getFirst() {
11283
+ return this.firstElementChild;
11284
+ }
11285
+ /**
11286
+ * @deprecated
11287
+ * compatible with G 3.0
11288
+ * @deprecated
11289
+ * get last child group/shape
11290
+ */
11291
+ ;
11449
11292
 
11450
- _this.config.style = _extends({}, DEFAULT_STYLE_PROPS, _this.config.style, _this.config.attrs);
11293
+ _proto.getLast = function getLast() {
11294
+ return this.lastElementChild;
11295
+ }
11296
+ /**
11297
+ * @deprecated
11298
+ * compatible with G 3.0
11299
+ * @deprecated
11300
+ * get child group/shape by index
11301
+ */
11302
+ ;
11451
11303
 
11452
- if (_this.config.visible != null) {
11453
- _this.config.style.visibility = _this.config.visible === false ? 'hidden' : 'visible';
11454
- }
11304
+ _proto.getChildByIndex = function getChildByIndex(index) {
11305
+ return this.children[index] || null;
11306
+ }
11307
+ /**
11308
+ * compatible with G 3.0
11309
+ * @deprecated
11310
+ */
11311
+ ;
11455
11312
 
11456
- if (_this.config.interactive != null) {
11457
- _this.config.style.pointerEvents = _this.config.interactive === false ? 'none' : 'auto';
11458
- }
11313
+ _proto.add = function add(child, index) {
11314
+ return this.appendChild(child, index);
11315
+ }
11316
+ /**
11317
+ * @alias style.clipPath
11318
+ * @deprecated
11319
+ */
11320
+ ;
11459
11321
 
11460
- _this.style = new Proxy(_extends({}, _this.attributes, {
11461
- setProperty: function setProperty(propertyName, value) {
11462
- _this.setAttribute(propertyName, value);
11463
- },
11464
- getPropertyValue: function getPropertyValue(propertyName) {
11465
- return _this.getAttribute(propertyName);
11466
- },
11467
- removeProperty: function removeProperty(propertyName) {
11468
- _this.removeAttribute(propertyName);
11469
- },
11470
- item: function item() {
11471
- return '';
11472
- }
11473
- }), {
11474
- get: function get(target, name) {
11475
- if (target[name] !== undefined) {
11476
- // if (name in target) {
11477
- return target[name];
11478
- }
11322
+ _proto.setClip = function setClip(clipPath) {
11323
+ this.style.clipPath = clipPath;
11324
+ }
11325
+ /**
11326
+ * @alias style.clipPath
11327
+ * @deprecated
11328
+ */
11329
+ ;
11479
11330
 
11480
- return _this.getAttribute(name);
11481
- },
11482
- set: function set(_, prop, value) {
11483
- _this.setAttribute(prop, value);
11331
+ _proto.getClip = function getClip() {
11332
+ return this.style.clipPath || null;
11333
+ }
11334
+ /**
11335
+ * compatible with G 3.0
11336
+ * @deprecated
11337
+ */
11338
+ ;
11484
11339
 
11485
- return true;
11486
- }
11487
- });
11340
+ _proto.set = function set(name, value) {
11341
+ this.config[name] = value;
11342
+ }
11343
+ /**
11344
+ * compatible with G 3.0
11345
+ * @deprecated
11346
+ */
11347
+ ;
11488
11348
 
11489
- _this.initAttributes(_this.config.style); // insert this group into pool
11349
+ _proto.get = function get(name) {
11350
+ return this.config[name];
11351
+ }
11352
+ /**
11353
+ * compatible with G 3.0
11354
+ * @alias object.config
11355
+ * @deprecated
11356
+ */
11357
+ ;
11490
11358
 
11359
+ _proto.getConfig = function getConfig() {
11360
+ return this.config;
11361
+ };
11491
11362
 
11492
- GlobalContainer.get(DisplayObjectPool).add(_this.entity, _assertThisInitialized(_this));
11493
- return _this;
11494
- }
11363
+ _proto.attr = function attr() {
11364
+ var _this3 = this;
11495
11365
 
11496
- var _proto = DisplayObject.prototype;
11366
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
11367
+ args[_key] = arguments[_key];
11368
+ }
11497
11369
 
11498
- _proto.destroy = function destroy() {
11499
- _Element.prototype.destroy.call(this); // remove from into pool
11370
+ var name = args[0],
11371
+ value = args[1];
11500
11372
 
11373
+ if (!name) {
11374
+ return this.attributes;
11375
+ }
11501
11376
 
11502
- GlobalContainer.get(DisplayObjectPool).remove(this.entity); // stop all active animations
11377
+ if (isObject(name)) {
11378
+ Object.keys(name).forEach(function (key) {
11379
+ _this3.setAttribute(key, name[key]);
11380
+ });
11381
+ return this;
11382
+ }
11503
11383
 
11504
- this.getAnimations().forEach(function (animation) {
11505
- animation.cancel();
11506
- });
11507
- };
11384
+ if (args.length === 2) {
11385
+ this.setAttribute(name, value);
11386
+ return this;
11387
+ }
11508
11388
 
11509
- _proto.cloneNode = function cloneNode(deep) {
11510
- var cloned = new this.constructor({
11511
- // copy id & name
11512
- // @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
11513
- id: this.id,
11514
- name: this.name,
11515
- className: this.name,
11516
- interactive: this.interactive,
11517
- style: _extends({}, this.attributes)
11518
- }); // apply transform
11389
+ return this.attributes[name];
11390
+ }
11391
+ /**
11392
+ * @alias setPosition
11393
+ * @deprecated
11394
+ */
11395
+ ;
11396
+
11397
+ _proto.moveTo = function moveTo(position, y, z) {
11398
+ if (y === void 0) {
11399
+ y = 0;
11400
+ }
11401
+
11402
+ if (z === void 0) {
11403
+ z = 0;
11404
+ }
11519
11405
 
11520
- cloned.setLocalTransform(this.getLocalTransform());
11406
+ this.setPosition(position, y, z);
11407
+ return this;
11408
+ }
11409
+ /**
11410
+ * @alias setPosition
11411
+ * @deprecated
11412
+ */
11413
+ ;
11521
11414
 
11522
- if (deep) {
11523
- this.children.forEach(function (child) {
11524
- var clonedChild = child.cloneNode(deep);
11525
- cloned.appendChild(clonedChild);
11526
- });
11415
+ _proto.move = function move(position, y, z) {
11416
+ if (y === void 0) {
11417
+ y = 0;
11527
11418
  }
11528
11419
 
11529
- return cloned;
11530
- };
11531
-
11532
- _proto.initAttributes = function initAttributes(attributes) {
11533
- if (attributes === void 0) {
11534
- attributes = {};
11420
+ if (z === void 0) {
11421
+ z = 0;
11535
11422
  }
11536
11423
 
11537
- var renderable = this.renderable;
11538
- this.styleValueRegistry.processProperties(this, attributes); // redraw at next frame
11424
+ this.setPosition(position, y, z);
11425
+ return this;
11426
+ }
11427
+ /**
11428
+ * @alias style.zIndex
11429
+ * @deprecated
11430
+ */
11431
+ ;
11539
11432
 
11540
- renderable.dirty = true;
11541
- };
11433
+ _proto.setZIndex = function setZIndex(zIndex) {
11434
+ this.style.zIndex = zIndex;
11435
+ return this;
11436
+ }
11437
+ /**
11438
+ * return 3x3 matrix in world space
11439
+ * @deprecated
11440
+ */
11441
+ ;
11542
11442
 
11543
- _proto.setAttribute = function setAttribute(name, value, force) {
11544
- if (force === void 0) {
11545
- force = false;
11546
- }
11443
+ _proto.getMatrix = function getMatrix(transformMat4) {
11444
+ var transform = transformMat4 || this.getWorldTransform();
11547
11445
 
11548
- var _formatAttribute = formatAttribute(name, value),
11549
- attributeName = _formatAttribute[0],
11550
- attributeValue = _formatAttribute[1]; // ignore undefined value
11446
+ var _mat4$getTranslation = mat4.getTranslation(vec3.create(), transform),
11447
+ tx = _mat4$getTranslation[0],
11448
+ ty = _mat4$getTranslation[1];
11551
11449
 
11450
+ var _mat4$getScaling = mat4.getScaling(vec3.create(), transform),
11451
+ sx = _mat4$getScaling[0],
11452
+ sy = _mat4$getScaling[1];
11552
11453
 
11553
- if (isUndefined(value)) {
11554
- return;
11555
- }
11454
+ var rotation = mat4.getRotation(quat$1.create(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
11556
11455
 
11557
- if (force || attributeValue !== this.attributes[attributeName]) {
11558
- this.internalSetAttribute(attributeName, attributeValue);
11456
+ var _getEuler3 = getEuler(vec3.create(), rotation),
11457
+ eux = _getEuler3[0],
11458
+ euy = _getEuler3[1],
11459
+ euz = _getEuler3[2]; // gimbal lock at 90 degrees
11559
11460
 
11560
- _Element.prototype.setAttribute.call(this, attributeName, attributeValue);
11561
- }
11461
+
11462
+ return fromRotationTranslationScale(eux || euz, tx, ty, sx, sy);
11562
11463
  }
11563
11464
  /**
11564
- * called when attributes get changed or initialized
11465
+ * return 3x3 matrix in local space
11466
+ * @deprecated
11565
11467
  */
11566
11468
  ;
11567
11469
 
11568
- _proto.internalSetAttribute = function internalSetAttribute(name, value, parseOptions) {
11569
- var _this$styleValueRegis,
11570
- _this2 = this;
11470
+ _proto.getLocalMatrix = function getLocalMatrix() {
11471
+ return this.getMatrix(this.getLocalTransform());
11472
+ }
11473
+ /**
11474
+ * set 3x3 matrix in world space
11475
+ * @deprecated
11476
+ */
11477
+ ;
11571
11478
 
11572
- if (parseOptions === void 0) {
11573
- parseOptions = {};
11479
+ _proto.setMatrix = function setMatrix(mat) {
11480
+ var _decompose = decompose(mat),
11481
+ tx = _decompose[0],
11482
+ ty = _decompose[1],
11483
+ scalingX = _decompose[2],
11484
+ scalingY = _decompose[3],
11485
+ angle = _decompose[4];
11486
+
11487
+ this.setEulerAngles(angle).setPosition(tx, ty).setLocalScale(scalingX, scalingY);
11488
+ }
11489
+ /**
11490
+ * set 3x3 matrix in local space
11491
+ * @deprecated
11492
+ */
11493
+ ;
11494
+
11495
+ _proto.setLocalMatrix = function setLocalMatrix(mat) {
11496
+ var _decompose2 = decompose(mat),
11497
+ tx = _decompose2[0],
11498
+ ty = _decompose2[1],
11499
+ scalingX = _decompose2[2],
11500
+ scalingY = _decompose2[3],
11501
+ angle = _decompose2[4];
11502
+
11503
+ this.setLocalEulerAngles(angle).setLocalPosition(tx, ty).setLocalScale(scalingX, scalingY);
11504
+ };
11505
+
11506
+ _createClass(DisplayObject, [{
11507
+ key: "interactive",
11508
+ get: function get() {
11509
+ return this.isInteractive();
11510
+ },
11511
+ set: function set(b) {
11512
+ this.style.pointerEvents = b ? 'auto' : 'none';
11574
11513
  }
11514
+ }]);
11575
11515
 
11576
- var renderable = this.renderable;
11577
- var oldValue = this.attributes[name];
11578
- var oldParsedValue = this.parsedStyle[name];
11579
- this.styleValueRegistry.processProperties(this, (_this$styleValueRegis = {}, _this$styleValueRegis[name] = value, _this$styleValueRegis), parseOptions); // inform clip path targets
11516
+ return DisplayObject;
11517
+ }(Element);
11580
11518
 
11581
- if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
11582
- this.parsedStyle.clipPathTargets.forEach(function (target) {
11583
- _this2.sceneGraphService.dirtifyToRoot(target);
11519
+ var _excluded = ["style"];
11520
+ /**
11521
+ * shadow root
11522
+ * @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
11523
+ */
11584
11524
 
11585
- target.dispatchEvent(new MutationEvent(ElementEvent.ATTR_MODIFIED, target, _this2, _this2, 'clipPath', MutationEvent.MODIFICATION, _this2, _this2));
11525
+ var CustomElement = /*#__PURE__*/function (_DisplayObject) {
11526
+ _inheritsLoose(CustomElement, _DisplayObject);
11586
11527
 
11587
- if (target.isCustomElement && target.isConnected) {
11588
- if (target.attributeChangedCallback) {
11589
- target.attributeChangedCallback('clipPath', _this2, _this2);
11590
- }
11591
- }
11592
- });
11593
- } // redraw at next frame
11528
+ // static get observedAttributes(): string[] {
11529
+ // return [];
11530
+ // }
11531
+ // private shadowNodes: DisplayObject[] = [];
11532
+ function CustomElement(_temp) {
11533
+ var _this;
11594
11534
 
11535
+ var _ref = _temp === void 0 ? {} : _temp,
11536
+ style = _ref.style,
11537
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
11595
11538
 
11596
- renderable.dirty = true; // trigger later
11597
- // this.sceneGraphService.pendingEvents.push([ElementEvent.ATTR_MODIFIED, { affectChildren }]);
11539
+ _this = _DisplayObject.call(this, _extends({
11540
+ style: _extends({
11541
+ x: '',
11542
+ y: ''
11543
+ }, style)
11544
+ }, rest)) || this;
11545
+ _this.isCustomElement = true;
11546
+ return _this;
11547
+ }
11598
11548
 
11599
- this.mutationEvent.prevValue = oldValue;
11600
- this.mutationEvent.newValue = value;
11601
- this.mutationEvent.attrName = name;
11602
- this.mutationEvent.prevParsedValue = oldParsedValue;
11603
- this.mutationEvent.newParsedValue = this.parsedStyle[name];
11604
- this.dispatchEvent(this.mutationEvent);
11549
+ return CustomElement;
11550
+ }(DisplayObject);
11605
11551
 
11606
- if (this.isCustomElement && this.isConnected) {
11607
- if (this.attributeChangedCallback) {
11608
- this.attributeChangedCallback(name, oldValue, value);
11609
- }
11610
- }
11611
- } // #region transformable
11552
+ var _excluded$1 = ["style"];
11553
+ var Circle = /*#__PURE__*/function (_DisplayObject) {
11554
+ _inheritsLoose(Circle, _DisplayObject);
11612
11555
 
11613
- /**
11614
- * returns different values than getBoundingClientRect(), as the latter returns value relative to the viewport
11615
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGGraphicsElement/getBBox
11616
- *
11617
- * FIXME: It is worth noting that getBBox responds to original untransformed values of a drawn object.
11618
- * @see https://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#getBBox
11619
- */
11620
- ;
11556
+ function Circle(_temp) {
11557
+ var _ref = _temp === void 0 ? {} : _temp,
11558
+ style = _ref.style,
11559
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
11621
11560
 
11622
- _proto.getBBox = function getBBox() {
11623
- var aabb = this.getBounds();
11561
+ return _DisplayObject.call(this, _extends({
11562
+ type: Shape.CIRCLE,
11563
+ style: _extends({
11564
+ cx: '',
11565
+ cy: '',
11566
+ r: ''
11567
+ }, style)
11568
+ }, rest)) || this;
11569
+ }
11624
11570
 
11625
- var _aabb$getMin = aabb.getMin(),
11626
- left = _aabb$getMin[0],
11627
- top = _aabb$getMin[1];
11571
+ return Circle;
11572
+ }(DisplayObject);
11628
11573
 
11629
- var _aabb$getMax = aabb.getMax(),
11630
- right = _aabb$getMax[0],
11631
- bottom = _aabb$getMax[1];
11574
+ var _excluded$2 = ["style"];
11575
+ var Ellipse = /*#__PURE__*/function (_DisplayObject) {
11576
+ _inheritsLoose(Ellipse, _DisplayObject);
11632
11577
 
11633
- return new Rectangle(left, top, right - left, bottom - top);
11634
- };
11578
+ function Ellipse(_temp) {
11579
+ var _ref = _temp === void 0 ? {} : _temp,
11580
+ style = _ref.style,
11581
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
11635
11582
 
11636
- _proto.setOrigin = function setOrigin(position, y, z) {
11637
- if (y === void 0) {
11638
- y = 0;
11639
- }
11583
+ return _DisplayObject.call(this, _extends({
11584
+ type: Shape.ELLIPSE,
11585
+ style: _extends({
11586
+ cx: '',
11587
+ cy: '',
11588
+ rx: '',
11589
+ ry: ''
11590
+ }, style)
11591
+ }, rest)) || this;
11592
+ }
11593
+
11594
+ return Ellipse;
11595
+ }(DisplayObject);
11596
+
11597
+ var _excluded$3 = ["style"];
11598
+ /**
11599
+ * its attributes are inherited by its children.
11600
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
11601
+ *
11602
+ * @example
11603
+ * <g fill="white" stroke="green" stroke-width="5">
11604
+ <circle cx="40" cy="40" r="25" />
11605
+ <circle cx="60" cy="60" r="25" />
11606
+ </g>
11607
+ */
11640
11608
 
11641
- if (z === void 0) {
11642
- z = 0;
11643
- }
11609
+ var Group = /*#__PURE__*/function (_DisplayObject) {
11610
+ _inheritsLoose(Group, _DisplayObject);
11644
11611
 
11645
- this.sceneGraphService.setOrigin(this, createVec3(position, y, z));
11646
- return this;
11647
- };
11612
+ function Group(_temp) {
11613
+ var _ref = _temp === void 0 ? {} : _temp,
11614
+ style = _ref.style,
11615
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
11648
11616
 
11649
- _proto.getOrigin = function getOrigin() {
11650
- return this.sceneGraphService.getOrigin(this);
11617
+ return _DisplayObject.call(this, _extends({
11618
+ type: Shape.GROUP,
11619
+ style: _extends({
11620
+ x: '',
11621
+ y: '',
11622
+ width: '',
11623
+ height: ''
11624
+ }, style)
11625
+ }, rest)) || this;
11651
11626
  }
11652
- /**
11653
- * set position in world space
11654
- */
11655
- ;
11656
11627
 
11657
- _proto.setPosition = function setPosition(position, y, z) {
11658
- if (y === void 0) {
11659
- y = 0;
11660
- }
11628
+ return Group;
11629
+ }(DisplayObject);
11661
11630
 
11662
- if (z === void 0) {
11663
- z = 0;
11664
- }
11631
+ var _excluded$4 = ["style"];
11632
+ var Image = /*#__PURE__*/function (_DisplayObject) {
11633
+ _inheritsLoose(Image, _DisplayObject);
11665
11634
 
11666
- this.sceneGraphService.setPosition(this, createVec3(position, y, z));
11667
- return this;
11635
+ function Image(_temp) {
11636
+ var _ref = _temp === void 0 ? {} : _temp,
11637
+ style = _ref.style,
11638
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
11639
+
11640
+ return _DisplayObject.call(this, _extends({
11641
+ type: Shape.IMAGE,
11642
+ style: _extends({
11643
+ x: '',
11644
+ y: '',
11645
+ img: '',
11646
+ width: '',
11647
+ height: ''
11648
+ }, style)
11649
+ }, rest)) || this;
11668
11650
  }
11669
- /**
11670
- * set position in local space
11671
- */
11672
- ;
11673
11651
 
11674
- _proto.setLocalPosition = function setLocalPosition(position, y, z) {
11675
- if (y === void 0) {
11676
- y = 0;
11677
- }
11652
+ return Image;
11653
+ }(DisplayObject);
11678
11654
 
11679
- if (z === void 0) {
11680
- z = 0;
11681
- }
11655
+ var _excluded$5 = ["style"];
11656
+ var Line = /*#__PURE__*/function (_DisplayObject) {
11657
+ _inheritsLoose(Line, _DisplayObject);
11682
11658
 
11683
- this.sceneGraphService.setLocalPosition(this, createVec3(position, y, z));
11684
- return this;
11685
- }
11686
- /**
11687
- * translate in world space
11688
- */
11689
- ;
11659
+ function Line(_temp) {
11660
+ var _ref = _temp === void 0 ? {} : _temp,
11661
+ style = _ref.style,
11662
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
11690
11663
 
11691
- _proto.translate = function translate(position, y, z) {
11692
- if (y === void 0) {
11693
- y = 0;
11694
- }
11664
+ return _DisplayObject.call(this, _extends({
11665
+ type: Shape.LINE,
11666
+ style: _extends({
11667
+ x1: 0,
11668
+ y1: 0,
11669
+ x2: 0,
11670
+ y2: 0,
11671
+ z1: 0,
11672
+ z2: 0,
11673
+ isBillboard: false
11674
+ }, style)
11675
+ }, rest)) || this;
11676
+ }
11695
11677
 
11696
- if (z === void 0) {
11697
- z = 0;
11698
- }
11678
+ var _proto = Line.prototype;
11699
11679
 
11700
- this.sceneGraphService.translate(this, createVec3(position, y, z));
11701
- return this;
11702
- }
11703
- /**
11704
- * translate in local space
11705
- */
11706
- ;
11680
+ _proto.getPoint = function getPoint(ratio) {
11681
+ // TODO: account for z1/z2 in 3D line
11682
+ var _this$parsedStyle = this.parsedStyle,
11683
+ x1 = _this$parsedStyle.x1,
11684
+ y1 = _this$parsedStyle.y1,
11685
+ x2 = _this$parsedStyle.x2,
11686
+ y2 = _this$parsedStyle.y2,
11687
+ defX = _this$parsedStyle.defX,
11688
+ defY = _this$parsedStyle.defY;
11707
11689
 
11708
- _proto.translateLocal = function translateLocal(position, y, z) {
11709
- if (y === void 0) {
11710
- y = 0;
11711
- }
11690
+ var _LineUtil$pointAt = Line$1.pointAt(x1.value, y1.value, x2.value, y2.value, ratio),
11691
+ x = _LineUtil$pointAt.x,
11692
+ y = _LineUtil$pointAt.y;
11712
11693
 
11713
- if (z === void 0) {
11714
- z = 0;
11715
- }
11694
+ var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
11716
11695
 
11717
- this.sceneGraphService.translateLocal(this, createVec3(position, y, z));
11718
- return this;
11696
+ return new Point(transformed[0], transformed[1]);
11719
11697
  };
11720
11698
 
11721
- _proto.getPosition = function getPosition() {
11722
- return this.sceneGraphService.getPosition(this);
11699
+ _proto.getTotalLength = function getTotalLength() {
11700
+ // TODO: account for z1/z2 in 3D line
11701
+ var _this$parsedStyle2 = this.parsedStyle,
11702
+ x1 = _this$parsedStyle2.x1,
11703
+ y1 = _this$parsedStyle2.y1,
11704
+ x2 = _this$parsedStyle2.x2,
11705
+ y2 = _this$parsedStyle2.y2;
11706
+ return Line$1.length(x1.value, y1.value, x2.value, y2.value);
11723
11707
  };
11724
11708
 
11725
- _proto.getLocalPosition = function getLocalPosition() {
11726
- return this.sceneGraphService.getLocalPosition(this);
11727
- }
11728
- /**
11729
- * compatible with G 3.0
11730
- *
11731
- * scaling in local space
11732
- * scale(10) = scale(10, 10, 10)
11733
- *
11734
- * we can't set scale in world space
11735
- */
11736
- ;
11709
+ return Line;
11710
+ }(DisplayObject);
11737
11711
 
11738
- _proto.scale = function scale(scaling, y, z) {
11739
- return this.scaleLocal(scaling, y, z);
11740
- };
11712
+ var _excluded$6 = ["style"];
11713
+ var Path = /*#__PURE__*/function (_DisplayObject) {
11714
+ _inheritsLoose(Path, _DisplayObject);
11741
11715
 
11742
- _proto.scaleLocal = function scaleLocal(scaling, y, z) {
11743
- if (typeof scaling === 'number') {
11744
- y = y || scaling;
11745
- z = z || scaling;
11746
- scaling = createVec3(scaling, y, z);
11747
- }
11716
+ function Path(_temp) {
11717
+ var _ref = _temp === void 0 ? {} : _temp,
11718
+ style = _ref.style,
11719
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
11748
11720
 
11749
- this.sceneGraphService.scaleLocal(this, scaling);
11750
- return this;
11721
+ return _DisplayObject.call(this, _extends({
11722
+ type: Shape.PATH,
11723
+ style: _extends({
11724
+ path: '',
11725
+ miterLimit: 4
11726
+ }, style)
11727
+ }, rest)) || this;
11751
11728
  }
11752
- /**
11753
- * set scaling in local space
11754
- */
11755
- ;
11756
11729
 
11757
- _proto.setLocalScale = function setLocalScale(scaling, y, z) {
11758
- if (typeof scaling === 'number') {
11759
- y = y || scaling;
11760
- z = z || scaling;
11761
- scaling = createVec3(scaling, y, z);
11762
- }
11730
+ var _proto = Path.prototype;
11763
11731
 
11764
- this.sceneGraphService.setLocalScale(this, scaling);
11765
- return this;
11732
+ _proto.getTotalLength = function getTotalLength() {
11733
+ return this.parsedStyle.path.totalLength;
11766
11734
  }
11767
11735
  /**
11768
- * get scaling in local space
11736
+ * Get point according to ratio
11769
11737
  */
11770
11738
  ;
11771
11739
 
11772
- _proto.getLocalScale = function getLocalScale() {
11773
- return this.sceneGraphService.getLocalScale(this);
11774
- }
11775
- /**
11776
- * get scaling in world space
11777
- */
11778
- ;
11740
+ _proto.getPoint = function getPoint(ratio) {
11741
+ var _this$parsedStyle = this.parsedStyle,
11742
+ defX = _this$parsedStyle.defX,
11743
+ defY = _this$parsedStyle.defY,
11744
+ _this$parsedStyle$pat = _this$parsedStyle.path,
11745
+ totalLength = _this$parsedStyle$pat.totalLength,
11746
+ absolutePath = _this$parsedStyle$pat.absolutePath;
11779
11747
 
11780
- _proto.getScale = function getScale() {
11781
- return this.sceneGraphService.getScale(this);
11782
- }
11783
- /**
11784
- * only return degrees of Z axis in world space
11785
- */
11786
- ;
11748
+ var _getPointAtLength = getPointAtLength(absolutePath, ratio * totalLength),
11749
+ x = _getPointAtLength.x,
11750
+ y = _getPointAtLength.y;
11787
11751
 
11788
- _proto.getEulerAngles = function getEulerAngles() {
11789
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
11790
- var _getEuler = getEuler(vec3.create(), this.sceneGraphService.getWorldTransform(this)),
11791
- ex = _getEuler[0],
11792
- ey = _getEuler[1],
11793
- ez = _getEuler[2];
11752
+ var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
11794
11753
 
11795
- return rad2deg(ez);
11754
+ return new Point(transformed[0], transformed[1]);
11796
11755
  }
11797
11756
  /**
11798
- * only return degrees of Z axis in local space
11757
+ * Get start tangent vector
11799
11758
  */
11800
11759
  ;
11801
11760
 
11802
- _proto.getLocalEulerAngles = function getLocalEulerAngles() {
11803
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
11804
- var _getEuler2 = getEuler(vec3.create(), this.sceneGraphService.getLocalRotation(this)),
11805
- ex = _getEuler2[0],
11806
- ey = _getEuler2[1],
11807
- ez = _getEuler2[2];
11761
+ _proto.getStartTangent = function getStartTangent() {
11762
+ var segments = this.parsedStyle.path.segments;
11763
+ var result = [];
11764
+
11765
+ if (segments.length > 1) {
11766
+ var startPoint = segments[0].currentPoint;
11767
+ var endPoint = segments[1].currentPoint;
11768
+ var tangent = segments[1].startTangent;
11769
+ result = [];
11770
+
11771
+ if (tangent) {
11772
+ result.push([startPoint[0] - tangent[0], startPoint[1] - tangent[1]]);
11773
+ result.push([startPoint[0], startPoint[1]]);
11774
+ } else {
11775
+ result.push([endPoint[0], endPoint[1]]);
11776
+ result.push([startPoint[0], startPoint[1]]);
11777
+ }
11778
+ }
11808
11779
 
11809
- return rad2deg(ez);
11780
+ return result;
11810
11781
  }
11811
11782
  /**
11812
- * set euler angles(degrees) in world space
11783
+ * Get end tangent vector
11813
11784
  */
11814
11785
  ;
11815
11786
 
11816
- _proto.setEulerAngles = function setEulerAngles(z) {
11817
- this.sceneGraphService.setEulerAngles(this, 0, 0, z);
11818
- return this;
11819
- }
11820
- /**
11821
- * set euler angles(degrees) in local space
11822
- */
11823
- ;
11787
+ _proto.getEndTangent = function getEndTangent() {
11788
+ var segments = this.parsedStyle.path.segments;
11789
+ var length = segments.length;
11790
+ var result = [];
11824
11791
 
11825
- _proto.setLocalEulerAngles = function setLocalEulerAngles(z) {
11826
- this.sceneGraphService.setLocalEulerAngles(this, 0, 0, z);
11827
- return this;
11828
- };
11792
+ if (length > 1) {
11793
+ var startPoint = segments[length - 2].currentPoint;
11794
+ var endPoint = segments[length - 1].currentPoint;
11795
+ var tangent = segments[length - 1].endTangent;
11796
+ result = [];
11829
11797
 
11830
- _proto.rotateLocal = function rotateLocal(x, y, z) {
11831
- if (isNil(y) && isNil(z)) {
11832
- this.sceneGraphService.rotateLocal(this, 0, 0, x);
11833
- } else {
11834
- this.sceneGraphService.rotateLocal(this, x, y, z);
11798
+ if (tangent) {
11799
+ result.push([endPoint[0] - tangent[0], endPoint[1] - tangent[1]]);
11800
+ result.push([endPoint[0], endPoint[1]]);
11801
+ } else {
11802
+ result.push([startPoint[0], startPoint[1]]);
11803
+ result.push([endPoint[0], endPoint[1]]);
11804
+ }
11835
11805
  }
11836
11806
 
11837
- return this;
11807
+ return result;
11838
11808
  };
11839
11809
 
11840
- _proto.rotate = function rotate(x, y, z) {
11841
- if (isNil(y) && isNil(z)) {
11842
- this.sceneGraphService.rotate(this, 0, 0, x);
11843
- } else {
11844
- this.sceneGraphService.rotate(this, x, y, z);
11845
- }
11810
+ return Path;
11811
+ }(DisplayObject);
11846
11812
 
11847
- return this;
11848
- };
11813
+ var _excluded$7 = ["style"];
11814
+ var Polygon = /*#__PURE__*/function (_DisplayObject) {
11815
+ _inheritsLoose(Polygon, _DisplayObject);
11849
11816
 
11850
- _proto.setRotation = function setRotation(rotation, y, z, w) {
11851
- this.sceneGraphService.setRotation(this, rotation, y, z, w);
11852
- return this;
11853
- };
11817
+ function Polygon(_temp) {
11818
+ var _ref = _temp === void 0 ? {} : _temp,
11819
+ style = _ref.style,
11820
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
11854
11821
 
11855
- _proto.setLocalRotation = function setLocalRotation(rotation, y, z, w) {
11856
- this.sceneGraphService.setLocalRotation(this, rotation, y, z, w);
11857
- return this;
11858
- };
11822
+ return _DisplayObject.call(this, _extends({
11823
+ type: Shape.POLYGON,
11824
+ style: _extends({
11825
+ points: '',
11826
+ miterLimit: 4
11827
+ }, style)
11828
+ }, rest)) || this;
11829
+ }
11859
11830
 
11860
- _proto.setLocalSkew = function setLocalSkew(skew, y) {
11861
- this.sceneGraphService.setLocalSkew(this, skew, y);
11862
- return this;
11863
- };
11831
+ return Polygon;
11832
+ }(DisplayObject);
11864
11833
 
11865
- _proto.getRotation = function getRotation() {
11866
- return this.sceneGraphService.getRotation(this);
11867
- };
11834
+ var _excluded$8 = ["style"];
11835
+ var Polyline = /*#__PURE__*/function (_DisplayObject) {
11836
+ _inheritsLoose(Polyline, _DisplayObject);
11868
11837
 
11869
- _proto.getLocalRotation = function getLocalRotation() {
11870
- return this.sceneGraphService.getLocalRotation(this);
11871
- };
11838
+ function Polyline(_temp) {
11839
+ var _ref = _temp === void 0 ? {} : _temp,
11840
+ style = _ref.style,
11841
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
11872
11842
 
11873
- _proto.getLocalSkew = function getLocalSkew() {
11874
- return this.sceneGraphService.getLocalSkew(this);
11875
- };
11843
+ return _DisplayObject.call(this, _extends({
11844
+ type: Shape.POLYLINE,
11845
+ style: _extends({
11846
+ points: '',
11847
+ miterLimit: 4
11848
+ }, style)
11849
+ }, rest)) || this;
11850
+ }
11876
11851
 
11877
- _proto.getLocalTransform = function getLocalTransform() {
11878
- return this.sceneGraphService.getLocalTransform(this);
11879
- };
11852
+ var _proto = Polyline.prototype;
11880
11853
 
11881
- _proto.getWorldTransform = function getWorldTransform() {
11882
- return this.sceneGraphService.getWorldTransform(this);
11854
+ _proto.getTotalLength = function getTotalLength() {
11855
+ return this.parsedStyle.points.totalLength;
11883
11856
  };
11884
11857
 
11885
- _proto.setLocalTransform = function setLocalTransform(transform) {
11886
- this.sceneGraphService.setLocalTransform(this, transform);
11887
- return this;
11888
- };
11858
+ _proto.getPoint = function getPoint(ratio) {
11859
+ var _this$parsedStyle = this.parsedStyle,
11860
+ defX = _this$parsedStyle.defX,
11861
+ defY = _this$parsedStyle.defY,
11862
+ _this$parsedStyle$poi = _this$parsedStyle.points,
11863
+ points = _this$parsedStyle$poi.points,
11864
+ segments = _this$parsedStyle$poi.segments;
11865
+ var subt = 0;
11866
+ var index = 0;
11867
+ segments.forEach(function (v, i) {
11868
+ if (ratio >= v[0] && ratio <= v[1]) {
11869
+ subt = (ratio - v[0]) / (v[1] - v[0]);
11870
+ index = i;
11871
+ }
11872
+ });
11889
11873
 
11890
- _proto.resetLocalTransform = function resetLocalTransform() {
11891
- this.sceneGraphService.resetLocalTransform(this);
11892
- } // #endregion transformable
11893
- // #region animatable
11874
+ var _LineUtil$pointAt = Line$1.pointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt),
11875
+ x = _LineUtil$pointAt.x,
11876
+ y = _LineUtil$pointAt.y;
11894
11877
 
11895
- /**
11896
- * returns an array of all Animation objects affecting this element
11897
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
11898
- */
11899
- ;
11878
+ var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
11900
11879
 
11901
- _proto.getAnimations = function getAnimations() {
11902
- return this.activeAnimations;
11903
- }
11904
- /**
11905
- * create an animation with WAAPI
11906
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/animate
11907
- */
11908
- ;
11880
+ return new Point(transformed[0], transformed[1]);
11881
+ };
11909
11882
 
11910
- _proto.animate = function animate(keyframes, options) {
11911
- var _this$ownerDocument;
11883
+ _proto.getStartTangent = function getStartTangent() {
11884
+ var points = this.parsedStyle.points.points;
11885
+ var result = [];
11886
+ result.push([points[1][0], points[1][1]]);
11887
+ result.push([points[0][0], points[0][1]]);
11888
+ return result;
11889
+ };
11912
11890
 
11913
- var timeline = (_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : _this$ownerDocument.timeline; // account for clip path, use target's timeline
11891
+ _proto.getEndTangent = function getEndTangent() {
11892
+ var points = this.parsedStyle.points.points;
11893
+ var l = points.length - 1;
11894
+ var result = [];
11895
+ result.push([points[l - 1][0], points[l - 1][1]]);
11896
+ result.push([points[l][0], points[l][1]]);
11897
+ return result;
11898
+ };
11914
11899
 
11915
- if (this.parsedStyle.clipPathTargets && this.parsedStyle.clipPathTargets.length) {
11916
- var _target$ownerDocument;
11900
+ return Polyline;
11901
+ }(DisplayObject);
11917
11902
 
11918
- var target = this.parsedStyle.clipPathTargets[0];
11919
- timeline = (_target$ownerDocument = target.ownerDocument) === null || _target$ownerDocument === void 0 ? void 0 : _target$ownerDocument.timeline;
11920
- } // clear old parsed transform
11903
+ var _excluded$9 = ["style"];
11904
+ var Rect = /*#__PURE__*/function (_DisplayObject) {
11905
+ _inheritsLoose(Rect, _DisplayObject);
11921
11906
 
11907
+ function Rect(_temp) {
11908
+ var _ref = _temp === void 0 ? {} : _temp,
11909
+ style = _ref.style,
11910
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
11922
11911
 
11923
- delete this.parsedStyle.transform;
11912
+ return _DisplayObject.call(this, _extends({
11913
+ type: Shape.RECT,
11914
+ style: _extends({
11915
+ x: '',
11916
+ y: '',
11917
+ width: '',
11918
+ height: '',
11919
+ radius: ''
11920
+ }, style)
11921
+ }, rest)) || this;
11922
+ }
11924
11923
 
11925
- if (timeline) {
11926
- return timeline.play(new KeyframeEffect(this, keyframes, options));
11927
- }
11924
+ return Rect;
11925
+ }(DisplayObject);
11928
11926
 
11929
- return null;
11930
- } // #endregion animatable
11931
- // #region visible
11927
+ var _excluded$a = ["style"];
11928
+ /**
11929
+ * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
11930
+ */
11931
+
11932
+ var Text = /*#__PURE__*/function (_DisplayObject) {
11933
+ _inheritsLoose(Text, _DisplayObject);
11932
11934
 
11933
11935
  /**
11934
- * show group, which will also change visibility of its children in sceneGraphNode
11935
- *
11936
- * @deprecated
11937
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility
11936
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
11938
11937
  */
11939
- ;
11938
+ function Text(_temp) {
11939
+ var _this;
11940
11940
 
11941
- _proto.show = function show() {
11942
- this.style.visibility = 'visible';
11941
+ var _ref = _temp === void 0 ? {} : _temp,
11942
+ style = _ref.style,
11943
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
11944
+
11945
+ _this = _DisplayObject.call(this, _extends({
11946
+ type: Shape.TEXT,
11947
+ style: _extends({
11948
+ x: '',
11949
+ y: '',
11950
+ text: '',
11951
+ fontSize: '',
11952
+ fontFamily: '',
11953
+ fontStyle: '',
11954
+ fontWeight: '',
11955
+ fontVariant: '',
11956
+ textAlign: '',
11957
+ textBaseline: '',
11958
+ textTransform: '',
11959
+ // dropShadow: false,
11960
+ // dropShadowAlpha: 1,
11961
+ // dropShadowAngle: Math.PI / 6,
11962
+ // dropShadowBlur: 0,
11963
+ // dropShadowColor: '#000',
11964
+ // dropShadowDistance: 5,
11965
+ fill: 'black',
11966
+ // stroke: 'black',
11967
+ letterSpacing: 0,
11968
+ lineHeight: 0,
11969
+ miterLimit: 10,
11970
+ whiteSpace: 'pre',
11971
+ wordWrap: false,
11972
+ wordWrapWidth: 0,
11973
+ leading: 0,
11974
+ dx: '',
11975
+ dy: ''
11976
+ }, style)
11977
+ }, rest)) || this;
11978
+ _this.LENGTHADJUST_SPACING = 1;
11979
+ _this.LENGTHADJUST_SPACINGANDGLYPHS = 2;
11980
+ _this.LENGTHADJUST_UNKNOWN = 0;
11981
+ _this.lengthAdjust = void 0;
11982
+ _this.textLength = void 0;
11983
+ return _this;
11943
11984
  }
11944
- /**
11945
- * @deprecated
11946
- * hide group, which will also change visibility of its children in sceneGraphNode
11947
- */
11948
- ;
11949
11985
 
11950
- _proto.hide = function hide() {
11951
- this.style.visibility = 'hidden';
11986
+ var _proto = Text.prototype;
11987
+
11988
+ _proto.getCharNumAtPosition = function getCharNumAtPosition(point) {
11989
+ throw new Error('Method not implemented.');
11952
11990
  }
11953
11991
  /**
11954
- * shortcut for Used value of `visibility`
11992
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
11955
11993
  */
11956
11994
  ;
11957
11995
 
11958
- _proto.isVisible = function isVisible() {
11959
- var _this$parsedStyle, _this$parsedStyle$vis;
11996
+ _proto.getComputedTextLength = function getComputedTextLength() {
11997
+ var _this$parsedStyle$met;
11960
11998
 
11961
- return ((_this$parsedStyle = this.parsedStyle) === null || _this$parsedStyle === void 0 ? void 0 : (_this$parsedStyle$vis = _this$parsedStyle.visibility) === null || _this$parsedStyle$vis === void 0 ? void 0 : _this$parsedStyle$vis.value) === 'visible';
11999
+ return ((_this$parsedStyle$met = this.parsedStyle.metrics) === null || _this$parsedStyle$met === void 0 ? void 0 : _this$parsedStyle$met.maxLineWidth) || 0;
11962
12000
  };
11963
12001
 
11964
- _proto.isInteractive = function isInteractive() {
11965
- var _this$parsedStyle2, _this$parsedStyle2$po;
11966
-
11967
- return ((_this$parsedStyle2 = this.parsedStyle) === null || _this$parsedStyle2 === void 0 ? void 0 : (_this$parsedStyle2$po = _this$parsedStyle2.pointerEvents) === null || _this$parsedStyle2$po === void 0 ? void 0 : _this$parsedStyle2$po.value) !== 'none';
12002
+ _proto.getEndPositionOfChar = function getEndPositionOfChar(charnum) {
12003
+ throw new Error('Method not implemented.');
11968
12004
  };
11969
12005
 
11970
- _proto.isCulled = function isCulled() {
11971
- return !!(this.cullable && this.cullable.isCulled());
11972
- }
11973
- /**
11974
- * bring to front in current group
11975
- */
11976
- ;
12006
+ _proto.getExtentOfChar = function getExtentOfChar(charnum) {
12007
+ throw new Error('Method not implemented.');
12008
+ };
11977
12009
 
11978
- _proto.toFront = function toFront() {
11979
- if (this.parentNode) {
11980
- this.style.zIndex = Math.max.apply(Math, this.parentNode.children.map(function (child) {
11981
- return Number(child.style.zIndex);
11982
- })) + 1;
11983
- }
12010
+ _proto.getNumberOfChars = function getNumberOfChars() {
12011
+ throw new Error('Method not implemented.');
12012
+ };
11984
12013
 
11985
- return this;
11986
- }
11987
- /**
11988
- * send to back in current group
11989
- */
11990
- ;
12014
+ _proto.getRotationOfChar = function getRotationOfChar(charnum) {
12015
+ throw new Error('Method not implemented.');
12016
+ };
11991
12017
 
11992
- _proto.toBack = function toBack() {
11993
- if (this.parentNode) {
11994
- this.style.zIndex = Math.min.apply(Math, this.parentNode.children.map(function (child) {
11995
- return Number(child.style.zIndex);
11996
- })) - 1;
11997
- }
12018
+ _proto.getStartPositionOfChar = function getStartPositionOfChar(charnum) {
12019
+ throw new Error('Method not implemented.');
12020
+ };
11998
12021
 
11999
- return this;
12000
- } // #endregion visible
12001
- // #region deprecated
12022
+ _proto.getSubStringLength = function getSubStringLength(charnum, nchars) {
12023
+ throw new Error('Method not implemented.');
12024
+ };
12002
12025
 
12003
- /**
12004
- * @deprecated
12005
- * compatible with G 3.0
12006
- * @deprecated
12007
- */
12008
- ;
12026
+ _proto.selectSubString = function selectSubString(charnum, nchars) {
12027
+ throw new Error('Method not implemented.');
12028
+ };
12009
12029
 
12010
- _proto.getCount = function getCount() {
12011
- return this.childElementCount;
12012
- }
12013
- /**
12014
- * @deprecated
12015
- * compatible with G 3.0
12016
- * @deprecated
12017
- */
12018
- ;
12030
+ _proto.getLineBoundingRects = function getLineBoundingRects() {
12031
+ var _this$parsedStyle$met2;
12019
12032
 
12020
- _proto.getParent = function getParent() {
12021
- return this.parentElement;
12022
- }
12023
- /**
12024
- * @deprecated
12025
- * compatible with G 3.0
12026
- * @deprecated
12027
- */
12028
- ;
12033
+ return ((_this$parsedStyle$met2 = this.parsedStyle.metrics) === null || _this$parsedStyle$met2 === void 0 ? void 0 : _this$parsedStyle$met2.lineMetrics) || [];
12034
+ };
12029
12035
 
12030
- _proto.getChildren = function getChildren() {
12031
- return this.children;
12032
- }
12033
- /**
12034
- * @deprecated
12035
- * compatible with G 3.0
12036
- * @deprecated
12037
- */
12038
- ;
12036
+ return Text;
12037
+ }(DisplayObject);
12039
12038
 
12040
- _proto.getFirst = function getFirst() {
12041
- return this.firstElementChild;
12042
- }
12043
- /**
12044
- * @deprecated
12045
- * compatible with G 3.0
12046
- * @deprecated
12047
- * get last child group/shape
12048
- */
12049
- ;
12039
+ var _excluded$b = ["style"];
12040
+ /**
12041
+ * HTML container
12042
+ * @see https://github.com/pmndrs/drei#html
12043
+ */
12050
12044
 
12051
- _proto.getLast = function getLast() {
12052
- return this.lastElementChild;
12053
- }
12054
- /**
12055
- * @deprecated
12056
- * compatible with G 3.0
12057
- * @deprecated
12058
- * get child group/shape by index
12059
- */
12060
- ;
12045
+ var HTML = /*#__PURE__*/function (_DisplayObject) {
12046
+ _inheritsLoose(HTML, _DisplayObject);
12061
12047
 
12062
- _proto.getChildByIndex = function getChildByIndex(index) {
12063
- return this.children[index] || null;
12064
- }
12065
- /**
12066
- * compatible with G 3.0
12067
- * @deprecated
12068
- */
12069
- ;
12048
+ function HTML(_temp) {
12049
+ var _this;
12070
12050
 
12071
- _proto.add = function add(child, index) {
12072
- return this.appendChild(child, index);
12073
- }
12074
- /**
12075
- * @alias style.clipPath
12076
- * @deprecated
12077
- */
12078
- ;
12051
+ var _ref = _temp === void 0 ? {} : _temp,
12052
+ style = _ref.style,
12053
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$b);
12079
12054
 
12080
- _proto.setClip = function setClip(clipPath) {
12081
- this.style.clipPath = clipPath;
12055
+ _this = _DisplayObject.call(this, _extends({
12056
+ type: Shape.HTML,
12057
+ style: _extends({
12058
+ x: '',
12059
+ y: '',
12060
+ width: 'auto',
12061
+ height: 'auto',
12062
+ innerHTML: ''
12063
+ }, style)
12064
+ }, rest)) || this;
12065
+ _this.cullable.enable = false;
12066
+ return _this;
12082
12067
  }
12083
12068
  /**
12084
- * @alias style.clipPath
12085
- * @deprecated
12069
+ * return wrapper HTMLElement
12070
+ * * <div> in g-webgl/canvas
12071
+ * * <foreignObject> in g-svg
12086
12072
  */
12087
- ;
12088
12073
 
12089
- _proto.getClip = function getClip() {
12090
- return this.style.clipPath || null;
12091
- }
12092
- /**
12093
- * compatible with G 3.0
12094
- * @deprecated
12095
- */
12096
- ;
12097
12074
 
12098
- _proto.set = function set(name, value) {
12099
- this.config[name] = value;
12100
- }
12101
- /**
12102
- * compatible with G 3.0
12103
- * @deprecated
12104
- */
12105
- ;
12075
+ var _proto = HTML.prototype;
12106
12076
 
12107
- _proto.get = function get(name) {
12108
- return this.config[name];
12077
+ _proto.getDomElement = function getDomElement() {
12078
+ return this.parsedStyle.$el;
12109
12079
  }
12110
12080
  /**
12111
- * compatible with G 3.0
12112
- * @alias object.config
12113
- * @deprecated
12081
+ * override with $el.getBoundingClientRect
12082
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
12114
12083
  */
12115
12084
  ;
12116
12085
 
12117
- _proto.getConfig = function getConfig() {
12118
- return this.config;
12086
+ _proto.getBoundingClientRect = function getBoundingClientRect() {
12087
+ return this.parsedStyle.$el.getBoundingClientRect();
12119
12088
  };
12120
12089
 
12121
- _proto.attr = function attr() {
12122
- var _this3 = this;
12123
-
12124
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12125
- args[_key] = arguments[_key];
12126
- }
12127
-
12128
- var name = args[0],
12129
- value = args[1];
12130
-
12131
- if (!name) {
12132
- return this.attributes;
12133
- }
12134
-
12135
- if (isObject(name)) {
12136
- Object.keys(name).forEach(function (key) {
12137
- _this3.setAttribute(key, name[key]);
12138
- });
12139
- return this;
12140
- }
12090
+ _proto.getClientRects = function getClientRects() {
12091
+ return [this.getBoundingClientRect()];
12092
+ };
12141
12093
 
12142
- if (args.length === 2) {
12143
- this.setAttribute(name, value);
12144
- return this;
12145
- }
12094
+ _proto.getBounds = function getBounds() {
12095
+ var _this$ownerDocument, _this$ownerDocument$d;
12146
12096
 
12147
- return this.attributes[name];
12148
- }
12149
- /**
12150
- * @alias setPosition
12151
- * @deprecated
12152
- */
12153
- ;
12097
+ var clientRect = this.getBoundingClientRect(); // calc context's offset
12098
+ // @ts-ignore
12154
12099
 
12155
- _proto.moveTo = function moveTo(position, y, z) {
12156
- if (y === void 0) {
12157
- y = 0;
12158
- }
12100
+ var canvasRect = (_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : (_this$ownerDocument$d = _this$ownerDocument.defaultView) === null || _this$ownerDocument$d === void 0 ? void 0 : _this$ownerDocument$d.getContextService().getBoundingClientRect();
12159
12101
 
12160
- if (z === void 0) {
12161
- z = 0;
12102
+ if (canvasRect) {
12103
+ var minX = clientRect.left - canvasRect.left;
12104
+ var minY = clientRect.top - canvasRect.top;
12105
+ var aabb = new AABB();
12106
+ aabb.setMinMax(vec3.fromValues(minX, minY, 0), vec3.fromValues(minX + clientRect.width, minY + clientRect.height, 0));
12107
+ return aabb;
12162
12108
  }
12163
12109
 
12164
- this.setPosition(position, y, z);
12165
- return this;
12166
- }
12167
- /**
12168
- * @alias setPosition
12169
- * @deprecated
12170
- */
12171
- ;
12110
+ return null;
12111
+ };
12172
12112
 
12173
- _proto.move = function move(position, y, z) {
12174
- if (y === void 0) {
12175
- y = 0;
12176
- }
12113
+ _proto.getLocalBounds = function getLocalBounds() {
12114
+ if (this.parentNode) {
12115
+ var parentInvert = mat4.invert(mat4.create(), this.parentNode.getWorldTransform());
12116
+ var bounds = this.getBounds();
12177
12117
 
12178
- if (z === void 0) {
12179
- z = 0;
12118
+ if (!AABB.isEmpty(bounds)) {
12119
+ var localBounds = new AABB();
12120
+ localBounds.setFromTransformedAABB(bounds, parentInvert);
12121
+ return localBounds;
12122
+ }
12180
12123
  }
12181
12124
 
12182
- this.setPosition(position, y, z);
12183
- return this;
12184
- }
12185
- /**
12186
- * @alias style.zIndex
12187
- * @deprecated
12188
- */
12189
- ;
12190
-
12191
- _proto.setZIndex = function setZIndex(zIndex) {
12192
- this.style.zIndex = zIndex;
12193
- return this;
12194
- }
12195
- /**
12196
- * return 3x3 matrix in world space
12197
- * @deprecated
12198
- */
12199
- ;
12125
+ return this.getBounds();
12126
+ };
12200
12127
 
12201
- _proto.getMatrix = function getMatrix(transformMat4) {
12202
- var transform = transformMat4 || this.getWorldTransform();
12128
+ return HTML;
12129
+ }(DisplayObject);
12203
12130
 
12204
- var _mat4$getTranslation = mat4.getTranslation(vec3.create(), transform),
12205
- tx = _mat4$getTranslation[0],
12206
- ty = _mat4$getTranslation[1];
12131
+ /**
12132
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/AnimationPlaybackEvent
12133
+ */
12207
12134
 
12208
- var _mat4$getScaling = mat4.getScaling(vec3.create(), transform),
12209
- sx = _mat4$getScaling[0],
12210
- sy = _mat4$getScaling[1];
12135
+ var AnimationEvent = /*#__PURE__*/function (_FederatedEvent) {
12136
+ _inheritsLoose(AnimationEvent, _FederatedEvent);
12211
12137
 
12212
- var rotation = mat4.getRotation(quat$1.create(), transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
12138
+ function AnimationEvent(manager, target, currentTime, timelineTime) {
12139
+ var _this;
12213
12140
 
12214
- var _getEuler3 = getEuler(vec3.create(), rotation),
12215
- eux = _getEuler3[0],
12216
- euy = _getEuler3[1],
12217
- euz = _getEuler3[2]; // gimbal lock at 90 degrees
12141
+ _this = _FederatedEvent.call(this, manager) || this;
12142
+ _this.currentTime = void 0;
12143
+ _this.timelineTime = void 0;
12144
+ _this.currentTime = currentTime;
12145
+ _this.timelineTime = timelineTime; // @ts-ignore
12218
12146
 
12147
+ _this.target = target;
12148
+ _this.type = 'finish';
12149
+ _this.bubbles = false; // @ts-ignore
12219
12150
 
12220
- return fromRotationTranslationScale(eux || euz, tx, ty, sx, sy);
12151
+ _this.currentTarget = target;
12152
+ _this.defaultPrevented = false;
12153
+ _this.eventPhase = _this.AT_TARGET;
12154
+ _this.timeStamp = Date.now();
12155
+ _this.currentTime = currentTime;
12156
+ _this.timelineTime = timelineTime;
12157
+ return _this;
12221
12158
  }
12222
- /**
12223
- * return 3x3 matrix in local space
12224
- * @deprecated
12225
- */
12226
- ;
12227
12159
 
12228
- _proto.getLocalMatrix = function getLocalMatrix() {
12229
- return this.getMatrix(this.getLocalTransform());
12230
- }
12231
- /**
12232
- * set 3x3 matrix in world space
12233
- * @deprecated
12234
- */
12235
- ;
12160
+ return AnimationEvent;
12161
+ }(FederatedEvent);
12236
12162
 
12237
- _proto.setMatrix = function setMatrix(mat) {
12238
- var _decompose = decompose(mat),
12239
- tx = _decompose[0],
12240
- ty = _decompose[1],
12241
- scalingX = _decompose[2],
12242
- scalingY = _decompose[3],
12243
- angle = _decompose[4];
12163
+ var sequenceNumber = 0;
12164
+ /**
12165
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/Animation
12166
+ */
12244
12167
 
12245
- this.setEulerAngles(angle).setPosition(tx, ty).setLocalScale(scalingX, scalingY);
12168
+ var Animation = /*#__PURE__*/function () {
12169
+ function Animation(effect, timeline) {
12170
+ this.effect = void 0;
12171
+ this.timeline = void 0;
12172
+ this.id = void 0;
12173
+ this.currentTimePending = false;
12174
+ this._idle = true;
12175
+ this._paused = false;
12176
+ this._finishedFlag = true;
12177
+ this.oldPlayState = void 0;
12178
+ this._holdTime = void 0;
12179
+ this.readyPromise = void 0;
12180
+ this.finishedPromise = void 0;
12181
+ this.resolveReadyPromise = void 0;
12182
+ this.rejectReadyPromise = void 0;
12183
+ this.resolveFinishedPromise = void 0;
12184
+ this.rejectFinishedPromise = void 0;
12185
+ this.onfinish = void 0;
12186
+ this.oncancel = void 0;
12187
+ this.onframe = void 0;
12188
+ this._currentTime = 0;
12189
+ this._startTime = void 0;
12190
+ this._playbackRate = 1;
12191
+ this._inEffect = void 0;
12192
+ this._inTimeline = true;
12193
+ this.onremove = void 0;
12194
+ this.effect = effect;
12195
+ effect.animation = this;
12196
+ this.timeline = timeline;
12197
+ this.id = "" + sequenceNumber++;
12198
+ this._inEffect = !!this.effect.update(0);
12199
+ this._holdTime = 0;
12200
+ this._paused = false;
12201
+ this.oldPlayState = 'idle';
12202
+ this.updatePromises();
12246
12203
  }
12247
12204
  /**
12248
- * set 3x3 matrix in local space
12249
- * @deprecated
12205
+ * state machine,
12206
+ * resolve/reject ready/finished Promise according to current state
12250
12207
  */
12251
- ;
12252
12208
 
12253
- _proto.setLocalMatrix = function setLocalMatrix(mat) {
12254
- var _decompose2 = decompose(mat),
12255
- tx = _decompose2[0],
12256
- ty = _decompose2[1],
12257
- scalingX = _decompose2[2],
12258
- scalingY = _decompose2[3],
12259
- angle = _decompose2[4];
12260
12209
 
12261
- this.setLocalEulerAngles(angle).setLocalPosition(tx, ty).setLocalScale(scalingX, scalingY);
12262
- };
12210
+ var _proto = Animation.prototype;
12263
12211
 
12264
- _createClass(DisplayObject, [{
12265
- key: "interactive",
12266
- get: function get() {
12267
- return this.isInteractive();
12268
- },
12269
- set: function set(b) {
12270
- this.style.pointerEvents = b ? 'auto' : 'none';
12212
+ _proto.updatePromises = function updatePromises() {
12213
+ var oldPlayState = this.oldPlayState;
12214
+ var newPlayState = this.pending ? 'pending' : this.playState;
12215
+
12216
+ if (this.readyPromise && newPlayState !== oldPlayState) {
12217
+ if (newPlayState === 'idle') {
12218
+ this.rejectReadyPromise();
12219
+ this.readyPromise = undefined;
12220
+ } else if (oldPlayState === 'pending') {
12221
+ this.resolveReadyPromise();
12222
+ } else if (newPlayState === 'pending') {
12223
+ this.readyPromise = undefined;
12224
+ }
12271
12225
  }
12272
- }]);
12273
12226
 
12274
- return DisplayObject;
12275
- }(Element);
12227
+ if (this.finishedPromise && newPlayState !== oldPlayState) {
12228
+ if (newPlayState === 'idle') {
12229
+ this.rejectFinishedPromise();
12230
+ this.finishedPromise = undefined;
12231
+ } else if (newPlayState === 'finished') {
12232
+ this.resolveFinishedPromise();
12233
+ } else if (oldPlayState === 'finished') {
12234
+ this.finishedPromise = undefined;
12235
+ }
12236
+ }
12276
12237
 
12277
- var _excluded = ["style"];
12278
- /**
12279
- * shadow root
12280
- * @see https://yuque.antfin-inc.com/antv/czqvg5/pgqipg
12281
- */
12238
+ this.oldPlayState = newPlayState;
12239
+ return this.readyPromise || this.finishedPromise;
12240
+ };
12282
12241
 
12283
- var CustomElement = /*#__PURE__*/function (_DisplayObject) {
12284
- _inheritsLoose(CustomElement, _DisplayObject);
12242
+ _proto.play = function play() {
12243
+ this.updatePromises();
12244
+ this._paused = false;
12285
12245
 
12286
- // static get observedAttributes(): string[] {
12287
- // return [];
12288
- // }
12289
- // private shadowNodes: DisplayObject[] = [];
12290
- function CustomElement(_temp) {
12291
- var _this;
12246
+ if (this._isFinished || this._idle) {
12247
+ this.rewind();
12248
+ this._startTime = null;
12249
+ }
12292
12250
 
12293
- var _ref = _temp === void 0 ? {} : _temp,
12294
- style = _ref.style,
12295
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
12251
+ this._finishedFlag = false;
12252
+ this._idle = false;
12253
+ this.ensureAlive();
12254
+ this.timeline.applyDirtiedAnimation(this);
12296
12255
 
12297
- _this = _DisplayObject.call(this, _extends({
12298
- style: _extends({
12299
- x: '',
12300
- y: ''
12301
- }, style)
12302
- }, rest)) || this;
12303
- _this.isCustomElement = true;
12304
- return _this;
12305
- }
12256
+ if (this.timeline.animations.indexOf(this) === -1) {
12257
+ this.timeline.animations.push(this);
12258
+ }
12259
+
12260
+ this.updatePromises();
12261
+ };
12262
+
12263
+ _proto.pause = function pause() {
12264
+ this.updatePromises();
12265
+
12266
+ if (this.currentTime) {
12267
+ this._holdTime = this.currentTime;
12268
+ }
12306
12269
 
12307
- return CustomElement;
12308
- }(DisplayObject);
12270
+ if (!this._isFinished && !this._paused && !this._idle) {
12271
+ this.currentTimePending = true;
12272
+ } else if (this._idle) {
12273
+ this.rewind();
12274
+ this._idle = false;
12275
+ }
12309
12276
 
12310
- var _excluded$1 = ["style"];
12311
- var Circle = /*#__PURE__*/function (_DisplayObject) {
12312
- _inheritsLoose(Circle, _DisplayObject);
12277
+ this._startTime = null;
12278
+ this._paused = true;
12279
+ this.updatePromises();
12280
+ };
12313
12281
 
12314
- function Circle(_temp) {
12315
- var _ref = _temp === void 0 ? {} : _temp,
12316
- style = _ref.style,
12317
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
12282
+ _proto.finish = function finish() {
12283
+ this.updatePromises();
12284
+ if (this._idle) return;
12285
+ this.currentTime = this._playbackRate > 0 ? this.totalDuration : 0;
12286
+ this._startTime = this.totalDuration - this.currentTime;
12287
+ this.currentTimePending = false;
12288
+ this.timeline.applyDirtiedAnimation(this);
12289
+ this.updatePromises();
12290
+ };
12318
12291
 
12319
- return _DisplayObject.call(this, _extends({
12320
- type: Shape.CIRCLE,
12321
- style: _extends({
12322
- cx: '',
12323
- cy: '',
12324
- r: ''
12325
- }, style)
12326
- }, rest)) || this;
12327
- }
12292
+ _proto.cancel = function cancel() {
12293
+ this.updatePromises();
12294
+ if (!this._inEffect) return;
12295
+ this._inEffect = false;
12296
+ this._idle = true;
12297
+ this._paused = false;
12298
+ this._finishedFlag = true;
12299
+ this._currentTime = 0;
12300
+ this._startTime = null;
12301
+ this.effect.update(null); // effects are invalid after cancellation as the animation state
12302
+ // needs to un-apply.
12328
12303
 
12329
- return Circle;
12330
- }(DisplayObject);
12304
+ this.timeline.applyDirtiedAnimation(this);
12305
+ this.updatePromises();
12306
+ };
12331
12307
 
12332
- var _excluded$2 = ["style"];
12333
- var Ellipse = /*#__PURE__*/function (_DisplayObject) {
12334
- _inheritsLoose(Ellipse, _DisplayObject);
12308
+ _proto.reverse = function reverse() {
12309
+ this.updatePromises();
12310
+ var oldCurrentTime = this.currentTime;
12311
+ this.playbackRate *= -1;
12312
+ this.play();
12335
12313
 
12336
- function Ellipse(_temp) {
12337
- var _ref = _temp === void 0 ? {} : _temp,
12338
- style = _ref.style,
12339
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$2);
12314
+ if (oldCurrentTime !== null) {
12315
+ this.currentTime = oldCurrentTime;
12316
+ }
12340
12317
 
12341
- return _DisplayObject.call(this, _extends({
12342
- type: Shape.ELLIPSE,
12343
- style: _extends({
12344
- cx: '',
12345
- cy: '',
12346
- rx: '',
12347
- ry: ''
12348
- }, style)
12349
- }, rest)) || this;
12318
+ this.updatePromises();
12350
12319
  }
12320
+ /**
12321
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/updatePlaybackRate
12322
+ */
12323
+ ;
12351
12324
 
12352
- return Ellipse;
12353
- }(DisplayObject);
12325
+ _proto.updatePlaybackRate = function updatePlaybackRate(playbackRate) {
12326
+ this.playbackRate = playbackRate;
12327
+ };
12354
12328
 
12355
- var _excluded$3 = ["style"];
12356
- /**
12357
- * its attributes are inherited by its children.
12358
- * @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Element/g
12359
- *
12360
- * @example
12361
- * <g fill="white" stroke="green" stroke-width="5">
12362
- <circle cx="40" cy="40" r="25" />
12363
- <circle cx="60" cy="60" r="25" />
12364
- </g>
12365
- */
12329
+ _proto.targetAnimations = function targetAnimations() {
12330
+ var _this$effect;
12366
12331
 
12367
- var Group = /*#__PURE__*/function (_DisplayObject) {
12368
- _inheritsLoose(Group, _DisplayObject);
12332
+ var target = (_this$effect = this.effect) === null || _this$effect === void 0 ? void 0 : _this$effect.target;
12333
+ return target.getAnimations();
12334
+ };
12369
12335
 
12370
- function Group(_temp) {
12371
- var _ref = _temp === void 0 ? {} : _temp,
12372
- style = _ref.style,
12373
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
12336
+ _proto.markTarget = function markTarget() {
12337
+ var animations = this.targetAnimations();
12374
12338
 
12375
- return _DisplayObject.call(this, _extends({
12376
- type: Shape.GROUP,
12377
- style: _extends({
12378
- x: '',
12379
- y: '',
12380
- width: '',
12381
- height: ''
12382
- }, style)
12383
- }, rest)) || this;
12384
- }
12339
+ if (animations.indexOf(this) === -1) {
12340
+ animations.push(this);
12341
+ }
12342
+ };
12385
12343
 
12386
- return Group;
12387
- }(DisplayObject);
12344
+ _proto.unmarkTarget = function unmarkTarget() {
12345
+ var animations = this.targetAnimations();
12346
+ var index = animations.indexOf(this);
12388
12347
 
12389
- var _excluded$4 = ["style"];
12390
- var Image = /*#__PURE__*/function (_DisplayObject) {
12391
- _inheritsLoose(Image, _DisplayObject);
12348
+ if (index !== -1) {
12349
+ animations.splice(index, 1);
12350
+ }
12351
+ };
12392
12352
 
12393
- function Image(_temp) {
12394
- var _ref = _temp === void 0 ? {} : _temp,
12395
- style = _ref.style,
12396
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
12353
+ _proto.tick = function tick(timelineTime, isAnimationFrame) {
12354
+ if (!this._idle && !this._paused) {
12355
+ if (this._startTime === null) {
12356
+ if (isAnimationFrame) {
12357
+ this.startTime = timelineTime - this._currentTime / this.playbackRate;
12358
+ }
12359
+ } else if (!this._isFinished) {
12360
+ this.tickCurrentTime((timelineTime - this._startTime) * this.playbackRate);
12361
+ }
12362
+ }
12397
12363
 
12398
- return _DisplayObject.call(this, _extends({
12399
- type: Shape.IMAGE,
12400
- style: _extends({
12401
- x: '',
12402
- y: '',
12403
- img: '',
12404
- width: '',
12405
- height: ''
12406
- }, style)
12407
- }, rest)) || this;
12408
- }
12364
+ if (isAnimationFrame) {
12365
+ this.currentTimePending = false;
12366
+ this.fireEvents(timelineTime);
12367
+ }
12368
+ };
12409
12369
 
12410
- return Image;
12411
- }(DisplayObject);
12370
+ _proto.rewind = function rewind() {
12371
+ if (this.playbackRate >= 0) {
12372
+ this.currentTime = 0;
12373
+ } else if (this.totalDuration < Infinity) {
12374
+ this.currentTime = this.totalDuration;
12375
+ } else {
12376
+ throw new Error('Unable to rewind negative playback rate animation with infinite duration');
12377
+ }
12378
+ };
12412
12379
 
12413
- var _excluded$5 = ["style"];
12414
- var Line = /*#__PURE__*/function (_DisplayObject) {
12415
- _inheritsLoose(Line, _DisplayObject);
12380
+ _proto.persist = function persist() {
12381
+ throw new Error('Method not implemented.');
12382
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
12383
+ ;
12416
12384
 
12417
- function Line(_temp) {
12418
- var _ref = _temp === void 0 ? {} : _temp,
12419
- style = _ref.style,
12420
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
12385
+ _proto.addEventListener = function addEventListener(type, listener, options) {
12386
+ throw new Error('Method not implemented.');
12387
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
12388
+ ;
12421
12389
 
12422
- return _DisplayObject.call(this, _extends({
12423
- type: Shape.LINE,
12424
- style: _extends({
12425
- x1: 0,
12426
- y1: 0,
12427
- x2: 0,
12428
- y2: 0,
12429
- z1: 0,
12430
- z2: 0,
12431
- isBillboard: false
12432
- }, style)
12433
- }, rest)) || this;
12434
- }
12390
+ _proto.removeEventListener = function removeEventListener(type, listener, options) {
12391
+ throw new Error('Method not implemented.');
12392
+ } // eslint-disable-next-line @typescript-eslint/no-unused-vars
12393
+ ;
12435
12394
 
12436
- var _proto = Line.prototype;
12395
+ _proto.dispatchEvent = function dispatchEvent(event) {
12396
+ throw new Error('Method not implemented.');
12397
+ };
12437
12398
 
12438
- _proto.getPoint = function getPoint(ratio) {
12439
- // TODO: account for z1/z2 in 3D line
12440
- var _this$parsedStyle = this.parsedStyle,
12441
- x1 = _this$parsedStyle.x1,
12442
- y1 = _this$parsedStyle.y1,
12443
- x2 = _this$parsedStyle.x2,
12444
- y2 = _this$parsedStyle.y2,
12445
- defX = _this$parsedStyle.defX,
12446
- defY = _this$parsedStyle.defY;
12399
+ // replaceState: AnimationReplaceState;
12400
+ _proto.commitStyles = function commitStyles() {
12401
+ throw new Error('Method not implemented.');
12402
+ };
12447
12403
 
12448
- var _LineUtil$pointAt = Line$1.pointAt(x1.value, y1.value, x2.value, y2.value, ratio),
12449
- x = _LineUtil$pointAt.x,
12450
- y = _LineUtil$pointAt.y;
12404
+ _proto.ensureAlive = function ensureAlive() {
12405
+ // If an animation is playing backwards and is not fill backwards/both
12406
+ // then it should go out of effect when it reaches the start of its
12407
+ // active interval (currentTime === 0).
12408
+ if (this.playbackRate < 0 && this.currentTime === 0) {
12409
+ var _this$effect2;
12451
12410
 
12452
- var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
12411
+ this._inEffect = !!((_this$effect2 = this.effect) === null || _this$effect2 === void 0 ? void 0 : _this$effect2.update(-1));
12412
+ } else {
12413
+ var _this$effect3;
12453
12414
 
12454
- return new Point(transformed[0], transformed[1]);
12455
- };
12415
+ this._inEffect = !!((_this$effect3 = this.effect) === null || _this$effect3 === void 0 ? void 0 : _this$effect3.update(this.currentTime));
12416
+ }
12456
12417
 
12457
- _proto.getTotalLength = function getTotalLength() {
12458
- // TODO: account for z1/z2 in 3D line
12459
- var _this$parsedStyle2 = this.parsedStyle,
12460
- x1 = _this$parsedStyle2.x1,
12461
- y1 = _this$parsedStyle2.y1,
12462
- x2 = _this$parsedStyle2.x2,
12463
- y2 = _this$parsedStyle2.y2;
12464
- return Line$1.length(x1.value, y1.value, x2.value, y2.value);
12418
+ if (!this._inTimeline && (this._inEffect || !this._finishedFlag)) {
12419
+ this._inTimeline = true;
12420
+ this.timeline.animations.push(this);
12421
+ }
12465
12422
  };
12466
12423
 
12467
- return Line;
12468
- }(DisplayObject);
12469
-
12470
- var _excluded$6 = ["style"];
12471
- var Path = /*#__PURE__*/function (_DisplayObject) {
12472
- _inheritsLoose(Path, _DisplayObject);
12424
+ _proto.tickCurrentTime = function tickCurrentTime(newTime, ignoreLimit) {
12425
+ if (newTime !== this._currentTime) {
12426
+ this._currentTime = newTime;
12473
12427
 
12474
- function Path(_temp) {
12475
- var _ref = _temp === void 0 ? {} : _temp,
12476
- style = _ref.style,
12477
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
12428
+ if (this._isFinished && !ignoreLimit) {
12429
+ this._currentTime = this._playbackRate > 0 ? this.totalDuration : 0;
12430
+ }
12478
12431
 
12479
- return _DisplayObject.call(this, _extends({
12480
- type: Shape.PATH,
12481
- style: _extends({
12482
- path: '',
12483
- miterLimit: 4
12484
- }, style)
12485
- }, rest)) || this;
12486
- }
12432
+ this.ensureAlive();
12433
+ }
12434
+ };
12487
12435
 
12488
- var _proto = Path.prototype;
12436
+ _proto.fireEvents = function fireEvents(baseTime) {
12437
+ var _this = this;
12489
12438
 
12490
- _proto.getTotalLength = function getTotalLength() {
12491
- return this.parsedStyle.path.totalLength;
12492
- }
12493
- /**
12494
- * Get point according to ratio
12495
- */
12496
- ;
12439
+ if (this._isFinished) {
12440
+ if (!this._finishedFlag) {
12441
+ if (this.onfinish) {
12442
+ var event = new AnimationEvent(null, this, this.currentTime, baseTime);
12443
+ setTimeout(function () {
12444
+ if (_this.onfinish) {
12445
+ _this.onfinish(event);
12446
+ }
12447
+ });
12448
+ }
12497
12449
 
12498
- _proto.getPoint = function getPoint(ratio) {
12499
- var _this$parsedStyle = this.parsedStyle,
12500
- defX = _this$parsedStyle.defX,
12501
- defY = _this$parsedStyle.defY,
12502
- _this$parsedStyle$pat = _this$parsedStyle.path,
12503
- totalLength = _this$parsedStyle$pat.totalLength,
12504
- absolutePath = _this$parsedStyle$pat.absolutePath;
12450
+ this._finishedFlag = true;
12451
+ }
12452
+ } else {
12453
+ if (this.onframe && this.playState === 'running') {
12454
+ var _event = new AnimationEvent(null, this, this.currentTime, baseTime);
12505
12455
 
12506
- var _getPointAtLength = getPointAtLength(absolutePath, ratio * totalLength),
12507
- x = _getPointAtLength.x,
12508
- y = _getPointAtLength.y;
12456
+ this.onframe(_event);
12457
+ }
12509
12458
 
12510
- var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
12459
+ this._finishedFlag = false;
12460
+ }
12461
+ };
12511
12462
 
12512
- return new Point(transformed[0], transformed[1]);
12513
- }
12514
- /**
12515
- * Get start tangent vector
12516
- */
12517
- ;
12463
+ _createClass(Animation, [{
12464
+ key: "pending",
12465
+ get:
12466
+ /**
12467
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/effect
12468
+ */
12518
12469
 
12519
- _proto.getStartTangent = function getStartTangent() {
12520
- var segments = this.parsedStyle.path.segments;
12521
- var result = [];
12470
+ /**
12471
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/timeline
12472
+ */
12522
12473
 
12523
- if (segments.length > 1) {
12524
- var startPoint = segments[0].currentPoint;
12525
- var endPoint = segments[1].currentPoint;
12526
- var tangent = segments[1].startTangent;
12527
- result = [];
12474
+ /**
12475
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/id
12476
+ */
12477
+ // animation: InternalAnimation | null;
12528
12478
 
12529
- if (tangent) {
12530
- result.push([startPoint[0] - tangent[0], startPoint[1] - tangent[1]]);
12531
- result.push([startPoint[0], startPoint[1]]);
12532
- } else {
12533
- result.push([endPoint[0], endPoint[1]]);
12534
- result.push([startPoint[0], startPoint[1]]);
12535
- }
12479
+ /**
12480
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/pending
12481
+ */
12482
+ function get() {
12483
+ return this._startTime === null && !this._paused && this.playbackRate !== 0 || this.currentTimePending;
12484
+ }
12485
+ }, {
12486
+ key: "playState",
12487
+ get: function get() {
12488
+ if (this._idle) return 'idle';
12489
+ if (this._isFinished) return 'finished';
12490
+ if (this._paused) return 'paused';
12491
+ return 'running';
12536
12492
  }
12493
+ /**
12494
+ * record previos state
12495
+ */
12537
12496
 
12538
- return result;
12539
- }
12540
- /**
12541
- * Get end tangent vector
12542
- */
12543
- ;
12497
+ }, {
12498
+ key: "ready",
12499
+ get:
12500
+ /**
12501
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/ready
12502
+ * @example
12503
+ animation.pause();
12504
+ animation.ready.then(function() {
12505
+ // Displays 'running'
12506
+ alert(animation.playState);
12507
+ });
12508
+ animation.play();
12509
+ */
12510
+ function get() {
12511
+ var _this2 = this;
12544
12512
 
12545
- _proto.getEndTangent = function getEndTangent() {
12546
- var segments = this.parsedStyle.path.segments;
12547
- var length = segments.length;
12548
- var result = [];
12513
+ if (!this.readyPromise) {
12514
+ if (this.timeline.animationsWithPromises.indexOf(this) === -1) {
12515
+ this.timeline.animationsWithPromises.push(this);
12516
+ }
12549
12517
 
12550
- if (length > 1) {
12551
- var startPoint = segments[length - 2].currentPoint;
12552
- var endPoint = segments[length - 1].currentPoint;
12553
- var tangent = segments[length - 1].endTangent;
12554
- result = [];
12518
+ this.readyPromise = new Promise(function (resolve, reject) {
12519
+ _this2.resolveReadyPromise = function () {
12520
+ resolve(_this2);
12521
+ };
12555
12522
 
12556
- if (tangent) {
12557
- result.push([endPoint[0] - tangent[0], endPoint[1] - tangent[1]]);
12558
- result.push([endPoint[0], endPoint[1]]);
12559
- } else {
12560
- result.push([startPoint[0], startPoint[1]]);
12561
- result.push([endPoint[0], endPoint[1]]);
12523
+ _this2.rejectReadyPromise = function () {
12524
+ reject(new Error());
12525
+ };
12526
+ });
12527
+
12528
+ if (!this.pending) {
12529
+ this.resolveReadyPromise();
12530
+ }
12562
12531
  }
12563
- }
12564
12532
 
12565
- return result;
12566
- };
12533
+ return this.readyPromise;
12534
+ }
12535
+ /**
12536
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/finished
12537
+ * @example
12538
+ Promise.all(
12539
+ elem.getAnimations().map(
12540
+ function(animation) {
12541
+ return animation.finished
12542
+ }
12543
+ )
12544
+ ).then(
12545
+ function() {
12546
+ return elem.remove();
12547
+ }
12548
+ );
12549
+ */
12567
12550
 
12568
- return Path;
12569
- }(DisplayObject);
12551
+ }, {
12552
+ key: "finished",
12553
+ get: function get() {
12554
+ var _this3 = this;
12570
12555
 
12571
- var _excluded$7 = ["style"];
12572
- var Polygon = /*#__PURE__*/function (_DisplayObject) {
12573
- _inheritsLoose(Polygon, _DisplayObject);
12556
+ if (!this.finishedPromise) {
12557
+ if (this.timeline.animationsWithPromises.indexOf(this) === -1) {
12558
+ this.timeline.animationsWithPromises.push(this);
12559
+ }
12574
12560
 
12575
- function Polygon(_temp) {
12576
- var _ref = _temp === void 0 ? {} : _temp,
12577
- style = _ref.style,
12578
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
12561
+ this.finishedPromise = new Promise(function (resolve, reject) {
12562
+ _this3.resolveFinishedPromise = function () {
12563
+ resolve(_this3);
12564
+ };
12579
12565
 
12580
- return _DisplayObject.call(this, _extends({
12581
- type: Shape.POLYGON,
12582
- style: _extends({
12583
- points: '',
12584
- miterLimit: 4
12585
- }, style)
12586
- }, rest)) || this;
12587
- }
12566
+ _this3.rejectFinishedPromise = function () {
12567
+ reject(new Error());
12568
+ };
12569
+ });
12588
12570
 
12589
- return Polygon;
12590
- }(DisplayObject);
12571
+ if (this.playState === 'finished') {
12572
+ this.resolveFinishedPromise();
12573
+ }
12574
+ }
12591
12575
 
12592
- var _excluded$8 = ["style"];
12593
- var Polyline = /*#__PURE__*/function (_DisplayObject) {
12594
- _inheritsLoose(Polyline, _DisplayObject);
12576
+ return this.finishedPromise;
12577
+ }
12578
+ /**
12579
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/onfinish
12580
+ */
12595
12581
 
12596
- function Polyline(_temp) {
12597
- var _ref = _temp === void 0 ? {} : _temp,
12598
- style = _ref.style,
12599
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$8);
12582
+ }, {
12583
+ key: "currentTime",
12584
+ get:
12585
+ /**
12586
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/currentTime
12587
+ */
12588
+ function get() {
12589
+ this.updatePromises();
12590
+ return this._idle || this.currentTimePending ? null : this._currentTime;
12591
+ },
12592
+ set: function set(newTime) {
12593
+ newTime = Number(newTime);
12594
+ if (isNaN(newTime)) return;
12595
+ this.timeline.restart();
12600
12596
 
12601
- return _DisplayObject.call(this, _extends({
12602
- type: Shape.POLYLINE,
12603
- style: _extends({
12604
- points: '',
12605
- miterLimit: 4
12606
- }, style)
12607
- }, rest)) || this;
12608
- }
12597
+ if (!this._paused && this._startTime !== null) {
12598
+ var _this$timeline;
12609
12599
 
12610
- var _proto = Polyline.prototype;
12600
+ this._startTime = Number((_this$timeline = this.timeline) === null || _this$timeline === void 0 ? void 0 : _this$timeline.currentTime) - newTime / this.playbackRate;
12601
+ }
12611
12602
 
12612
- _proto.getTotalLength = function getTotalLength() {
12613
- return this.parsedStyle.points.totalLength;
12614
- };
12603
+ this.currentTimePending = false;
12615
12604
 
12616
- _proto.getPoint = function getPoint(ratio) {
12617
- var _this$parsedStyle = this.parsedStyle,
12618
- defX = _this$parsedStyle.defX,
12619
- defY = _this$parsedStyle.defY,
12620
- _this$parsedStyle$poi = _this$parsedStyle.points,
12621
- points = _this$parsedStyle$poi.points,
12622
- segments = _this$parsedStyle$poi.segments;
12623
- var subt = 0;
12624
- var index = 0;
12625
- segments.forEach(function (v, i) {
12626
- if (ratio >= v[0] && ratio <= v[1]) {
12627
- subt = (ratio - v[0]) / (v[1] - v[0]);
12628
- index = i;
12605
+ if (this._currentTime === newTime) {
12606
+ return;
12629
12607
  }
12630
- });
12631
-
12632
- var _LineUtil$pointAt = Line$1.pointAt(points[index][0], points[index][1], points[index + 1][0], points[index + 1][1], subt),
12633
- x = _LineUtil$pointAt.x,
12634
- y = _LineUtil$pointAt.y;
12635
12608
 
12636
- var transformed = vec3.transformMat4(vec3.create(), vec3.fromValues(x - defX, y - defY, 0), this.getLocalTransform()); // apply local transformation
12609
+ if (this._idle) {
12610
+ this._idle = false;
12611
+ this._paused = true;
12612
+ }
12637
12613
 
12638
- return new Point(transformed[0], transformed[1]);
12639
- };
12614
+ this.tickCurrentTime(newTime, true);
12615
+ this.timeline.applyDirtiedAnimation(this);
12616
+ }
12617
+ /**
12618
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Animation/startTime
12619
+ */
12640
12620
 
12641
- _proto.getStartTangent = function getStartTangent() {
12642
- var points = this.parsedStyle.points.points;
12643
- var result = [];
12644
- result.push([points[1][0], points[1][1]]);
12645
- result.push([points[0][0], points[0][1]]);
12646
- return result;
12647
- };
12621
+ }, {
12622
+ key: "startTime",
12623
+ get: function get() {
12624
+ return this._startTime;
12625
+ },
12626
+ set: function set(newTime) {
12627
+ if (newTime !== null) {
12628
+ this.updatePromises();
12629
+ newTime = Number(newTime);
12630
+ if (isNaN(newTime)) return;
12631
+ if (this._paused || this._idle) return;
12632
+ this._startTime = newTime;
12633
+ this.tickCurrentTime((Number(this.timeline.currentTime) - this._startTime) * this.playbackRate);
12634
+ this.timeline.applyDirtiedAnimation(this);
12635
+ this.updatePromises();
12636
+ }
12637
+ }
12638
+ }, {
12639
+ key: "playbackRate",
12640
+ get: function get() {
12641
+ return this._playbackRate;
12642
+ },
12643
+ set: function set(value) {
12644
+ if (value === this._playbackRate) {
12645
+ return;
12646
+ }
12648
12647
 
12649
- _proto.getEndTangent = function getEndTangent() {
12650
- var points = this.parsedStyle.points.points;
12651
- var l = points.length - 1;
12652
- var result = [];
12653
- result.push([points[l - 1][0], points[l - 1][1]]);
12654
- result.push([points[l][0], points[l][1]]);
12655
- return result;
12656
- };
12648
+ this.updatePromises();
12649
+ var oldCurrentTime = this.currentTime;
12650
+ this._playbackRate = value;
12651
+ this.startTime = null;
12657
12652
 
12658
- return Polyline;
12659
- }(DisplayObject);
12653
+ if (this.playState !== 'paused' && this.playState !== 'idle') {
12654
+ this._finishedFlag = false;
12655
+ this._idle = false;
12656
+ this.ensureAlive();
12657
+ this.timeline.applyDirtiedAnimation(this);
12658
+ }
12660
12659
 
12661
- var _excluded$9 = ["style"];
12662
- var Rect = /*#__PURE__*/function (_DisplayObject) {
12663
- _inheritsLoose(Rect, _DisplayObject);
12660
+ if (oldCurrentTime !== null) {
12661
+ this.currentTime = oldCurrentTime;
12662
+ }
12664
12663
 
12665
- function Rect(_temp) {
12666
- var _ref = _temp === void 0 ? {} : _temp,
12667
- style = _ref.style,
12668
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$9);
12664
+ this.updatePromises();
12665
+ }
12666
+ }, {
12667
+ key: "_isFinished",
12668
+ get: function get() {
12669
+ return !this._idle && (this._playbackRate > 0 && Number(this._currentTime) >= this.totalDuration || this._playbackRate < 0 && Number(this._currentTime) <= 0);
12670
+ }
12671
+ }, {
12672
+ key: "totalDuration",
12673
+ get: function get() {
12674
+ var _this$effect4;
12669
12675
 
12670
- return _DisplayObject.call(this, _extends({
12671
- type: Shape.RECT,
12672
- style: _extends({
12673
- x: '',
12674
- y: '',
12675
- width: '',
12676
- height: '',
12677
- radius: ''
12678
- }, style)
12679
- }, rest)) || this;
12680
- }
12676
+ return Number((_this$effect4 = this.effect) === null || _this$effect4 === void 0 ? void 0 : _this$effect4.getComputedTiming().endTime);
12677
+ }
12678
+ }, {
12679
+ key: "_needsTick",
12680
+ get: function get() {
12681
+ return this.pending || this.playState === 'running' || !this._finishedFlag;
12682
+ }
12683
+ }]);
12681
12684
 
12682
- return Rect;
12683
- }(DisplayObject);
12685
+ return Animation;
12686
+ }();
12684
12687
 
12685
- var _excluded$a = ["style"];
12688
+ function compareAnimations(leftAnimation, rightAnimation) {
12689
+ return Number(leftAnimation.id) - Number(rightAnimation.id);
12690
+ }
12686
12691
  /**
12687
- * <text> @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextElement
12692
+ * @see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/web-animations-js/index.d.ts
12688
12693
  */
12689
12694
 
12690
- var Text = /*#__PURE__*/function (_DisplayObject) {
12691
- _inheritsLoose(Text, _DisplayObject);
12692
-
12695
+ var AnimationTimeline = /*#__PURE__*/function () {
12693
12696
  /**
12694
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement#constants
12697
+ * all active animations
12695
12698
  */
12696
- function Text(_temp) {
12697
- var _this;
12699
+ function AnimationTimeline(document) {
12700
+ var _this = this;
12698
12701
 
12699
- var _ref = _temp === void 0 ? {} : _temp,
12700
- style = _ref.style,
12701
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$a);
12702
+ this.document = void 0;
12703
+ this.animations = [];
12704
+ this.ticking = false;
12705
+ this.timelineTicking = false;
12706
+ this.hasRestartedThisFrame = false;
12707
+ this.animationsWithPromises = [];
12708
+ this.inTick = false;
12709
+ this.pendingEffects = [];
12710
+ this.currentTime = null;
12711
+ this.rafId = 0;
12712
+ this.rafCallbacks = [];
12713
+ this.frameId = void 0;
12702
12714
 
12703
- _this = _DisplayObject.call(this, _extends({
12704
- type: Shape.TEXT,
12705
- style: _extends({
12706
- x: '',
12707
- y: '',
12708
- text: '',
12709
- fontSize: '',
12710
- fontFamily: '',
12711
- fontStyle: '',
12712
- fontWeight: '',
12713
- fontVariant: '',
12714
- textAlign: '',
12715
- textBaseline: '',
12716
- textTransform: '',
12717
- // dropShadow: false,
12718
- // dropShadowAlpha: 1,
12719
- // dropShadowAngle: Math.PI / 6,
12720
- // dropShadowBlur: 0,
12721
- // dropShadowColor: '#000',
12722
- // dropShadowDistance: 5,
12723
- fill: 'black',
12724
- // stroke: 'black',
12725
- letterSpacing: 0,
12726
- lineHeight: 0,
12727
- miterLimit: 10,
12728
- whiteSpace: 'pre',
12729
- wordWrap: false,
12730
- wordWrapWidth: 0,
12731
- leading: 0,
12732
- dx: '',
12733
- dy: ''
12734
- }, style)
12735
- }, rest)) || this;
12736
- _this.LENGTHADJUST_SPACING = 1;
12737
- _this.LENGTHADJUST_SPACINGANDGLYPHS = 2;
12738
- _this.LENGTHADJUST_UNKNOWN = 0;
12739
- _this.lengthAdjust = void 0;
12740
- _this.textLength = void 0;
12741
- return _this;
12715
+ this.webAnimationsNextTick = function (t) {
12716
+ _this.currentTime = t;
12717
+
12718
+ _this.discardAnimations();
12719
+
12720
+ if (_this.animations.length === 0) {
12721
+ _this.timelineTicking = false;
12722
+ } else {
12723
+ _this.requestAnimationFrame(_this.webAnimationsNextTick);
12724
+ }
12725
+ };
12726
+
12727
+ this.processRafCallbacks = function (t) {
12728
+ var processing = _this.rafCallbacks;
12729
+ _this.rafCallbacks = [];
12730
+ if (t < Number(_this.currentTime)) t = Number(_this.currentTime);
12731
+
12732
+ _this.animations.sort(compareAnimations);
12733
+
12734
+ _this.animations = _this.tick(t, true, _this.animations)[0];
12735
+ processing.forEach(function (entry) {
12736
+ entry[1](t);
12737
+ });
12738
+
12739
+ _this.applyPendingEffects();
12740
+ };
12741
+
12742
+ this.document = document;
12742
12743
  }
12743
12744
 
12744
- var _proto = Text.prototype;
12745
+ var _proto = AnimationTimeline.prototype;
12746
+
12747
+ _proto.getAnimations = function getAnimations() {
12748
+ this.discardAnimations();
12749
+ return this.animations.slice();
12750
+ };
12751
+
12752
+ _proto.isTicking = function isTicking() {
12753
+ return this.inTick;
12754
+ };
12745
12755
 
12746
- _proto.getCharNumAtPosition = function getCharNumAtPosition(point) {
12747
- throw new Error('Method not implemented.');
12748
- }
12749
- /**
12750
- * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGTextContentElement
12751
- */
12756
+ _proto.play = function play(effect) {
12757
+ var animation = new Animation(effect, this);
12758
+ this.animations.push(animation);
12759
+ this.restartWebAnimationsNextTick();
12760
+ animation.updatePromises();
12761
+ animation.play();
12762
+ animation.updatePromises();
12763
+ return animation;
12764
+ } // RAF is supposed to be the last script to occur before frame rendering but not
12765
+ // all browsers behave like this. This function is for synchonously updating an
12766
+ // animation's effects whenever its state is mutated by script to work around
12767
+ // incorrect script execution ordering by the browser.
12752
12768
  ;
12753
12769
 
12754
- _proto.getComputedTextLength = function getComputedTextLength() {
12755
- var _this$parsedStyle$met;
12770
+ _proto.applyDirtiedAnimation = function applyDirtiedAnimation(animation) {
12771
+ var _this2 = this;
12756
12772
 
12757
- return ((_this$parsedStyle$met = this.parsedStyle.metrics) === null || _this$parsedStyle$met === void 0 ? void 0 : _this$parsedStyle$met.maxLineWidth) || 0;
12758
- };
12773
+ if (this.inTick) {
12774
+ return;
12775
+ } // update active animations in displayobject
12759
12776
 
12760
- _proto.getEndPositionOfChar = function getEndPositionOfChar(charnum) {
12761
- throw new Error('Method not implemented.');
12762
- };
12763
12777
 
12764
- _proto.getExtentOfChar = function getExtentOfChar(charnum) {
12765
- throw new Error('Method not implemented.');
12766
- };
12778
+ animation.markTarget();
12779
+ var animations = animation.targetAnimations();
12780
+ animations.sort(compareAnimations); // clear inactive animations
12767
12781
 
12768
- _proto.getNumberOfChars = function getNumberOfChars() {
12769
- throw new Error('Method not implemented.');
12770
- };
12782
+ var inactiveAnimations = this.tick(Number(this.currentTime), false, animations.slice())[1];
12783
+ inactiveAnimations.forEach(function (animation) {
12784
+ var index = _this2.animations.indexOf(animation);
12771
12785
 
12772
- _proto.getRotationOfChar = function getRotationOfChar(charnum) {
12773
- throw new Error('Method not implemented.');
12786
+ if (index !== -1) {
12787
+ _this2.animations.splice(index, 1);
12788
+ }
12789
+ });
12790
+ this.applyPendingEffects();
12774
12791
  };
12775
12792
 
12776
- _proto.getStartPositionOfChar = function getStartPositionOfChar(charnum) {
12777
- throw new Error('Method not implemented.');
12778
- };
12793
+ _proto.restart = function restart() {
12794
+ if (!this.ticking) {
12795
+ this.ticking = true;
12796
+ this.requestAnimationFrame(function () {});
12797
+ this.hasRestartedThisFrame = true;
12798
+ }
12779
12799
 
12780
- _proto.getSubStringLength = function getSubStringLength(charnum, nchars) {
12781
- throw new Error('Method not implemented.');
12800
+ return this.hasRestartedThisFrame;
12782
12801
  };
12783
12802
 
12784
- _proto.selectSubString = function selectSubString(charnum, nchars) {
12785
- throw new Error('Method not implemented.');
12803
+ _proto.destroy = function destroy() {
12804
+ this.document.defaultView.cancelAnimationFrame(this.frameId);
12786
12805
  };
12787
12806
 
12788
- _proto.getLineBoundingRects = function getLineBoundingRects() {
12789
- var _this$parsedStyle$met2;
12790
-
12791
- return ((_this$parsedStyle$met2 = this.parsedStyle.metrics) === null || _this$parsedStyle$met2 === void 0 ? void 0 : _this$parsedStyle$met2.lineMetrics) || [];
12807
+ _proto.applyPendingEffects = function applyPendingEffects() {
12808
+ this.pendingEffects.forEach(function (effect) {
12809
+ effect === null || effect === void 0 ? void 0 : effect.applyInterpolations();
12810
+ });
12811
+ this.pendingEffects = [];
12792
12812
  };
12793
12813
 
12794
- return Text;
12795
- }(DisplayObject);
12796
-
12797
- var _excluded$b = ["style"];
12798
- /**
12799
- * HTML container
12800
- * @see https://github.com/pmndrs/drei#html
12801
- */
12814
+ _proto.updateAnimationsPromises = function updateAnimationsPromises() {
12815
+ this.animationsWithPromises = this.animationsWithPromises.filter(function (animation) {
12816
+ return animation.updatePromises();
12817
+ });
12818
+ };
12802
12819
 
12803
- var HTML = /*#__PURE__*/function (_DisplayObject) {
12804
- _inheritsLoose(HTML, _DisplayObject);
12820
+ _proto.discardAnimations = function discardAnimations() {
12821
+ this.updateAnimationsPromises();
12822
+ this.animations = this.animations.filter(function (animation) {
12823
+ return animation.playState !== 'finished' && animation.playState !== 'idle';
12824
+ });
12825
+ };
12805
12826
 
12806
- function HTML(_temp) {
12807
- var _this;
12827
+ _proto.restartWebAnimationsNextTick = function restartWebAnimationsNextTick() {
12828
+ if (!this.timelineTicking) {
12829
+ this.timelineTicking = true;
12830
+ this.requestAnimationFrame(this.webAnimationsNextTick);
12831
+ }
12832
+ };
12808
12833
 
12809
- var _ref = _temp === void 0 ? {} : _temp,
12810
- style = _ref.style,
12811
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$b);
12834
+ _proto.rAF = function rAF(f) {
12835
+ var id = this.rafId++;
12812
12836
 
12813
- _this = _DisplayObject.call(this, _extends({
12814
- type: Shape.HTML,
12815
- style: _extends({
12816
- x: '',
12817
- y: '',
12818
- width: 'auto',
12819
- height: 'auto',
12820
- innerHTML: ''
12821
- }, style)
12822
- }, rest)) || this;
12823
- _this.cullable.enable = false;
12824
- return _this;
12825
- }
12826
- /**
12827
- * return wrapper HTMLElement
12828
- * * <div> in g-webgl/canvas
12829
- * * <foreignObject> in g-svg
12830
- */
12837
+ if (this.rafCallbacks.length === 0) {
12838
+ this.frameId = this.document.defaultView.requestAnimationFrame(this.processRafCallbacks);
12839
+ }
12831
12840
 
12841
+ this.rafCallbacks.push([id, f]);
12842
+ return id;
12843
+ };
12832
12844
 
12833
- var _proto = HTML.prototype;
12845
+ _proto.requestAnimationFrame = function requestAnimationFrame(f) {
12846
+ var _this3 = this;
12834
12847
 
12835
- _proto.getDomElement = function getDomElement() {
12836
- return this.parsedStyle.$el;
12837
- }
12838
- /**
12839
- * override with $el.getBoundingClientRect
12840
- * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/getBoundingClientRect
12841
- */
12842
- ;
12848
+ return this.rAF(function (x) {
12849
+ _this3.updateAnimationsPromises();
12843
12850
 
12844
- _proto.getBoundingClientRect = function getBoundingClientRect() {
12845
- return this.parsedStyle.$el.getBoundingClientRect();
12846
- };
12851
+ f(x);
12847
12852
 
12848
- _proto.getClientRects = function getClientRects() {
12849
- return [this.getBoundingClientRect()];
12853
+ _this3.updateAnimationsPromises();
12854
+ });
12850
12855
  };
12851
12856
 
12852
- _proto.getBounds = function getBounds() {
12853
- var _this$ownerDocument, _this$ownerDocument$d;
12857
+ _proto.tick = function tick(t, isAnimationFrame, updatingAnimations) {
12858
+ var _this4 = this,
12859
+ _this$pendingEffects,
12860
+ _this$pendingEffects2;
12854
12861
 
12855
- var clientRect = this.getBoundingClientRect(); // calc context's offset
12856
- // @ts-ignore
12862
+ this.inTick = true;
12863
+ this.hasRestartedThisFrame = false;
12864
+ this.currentTime = t;
12865
+ this.ticking = false;
12866
+ var newPendingClears = [];
12867
+ var newPendingEffects = [];
12868
+ var activeAnimations = [];
12869
+ var inactiveAnimations = [];
12870
+ updatingAnimations.forEach(function (animation) {
12871
+ animation.tick(t, isAnimationFrame);
12857
12872
 
12858
- var canvasRect = (_this$ownerDocument = this.ownerDocument) === null || _this$ownerDocument === void 0 ? void 0 : (_this$ownerDocument$d = _this$ownerDocument.defaultView) === null || _this$ownerDocument$d === void 0 ? void 0 : _this$ownerDocument$d.getContextService().getBoundingClientRect();
12873
+ if (!animation._inEffect) {
12874
+ newPendingClears.push(animation.effect);
12875
+ animation.unmarkTarget();
12876
+ } else {
12877
+ newPendingEffects.push(animation.effect);
12878
+ animation.markTarget();
12879
+ }
12859
12880
 
12860
- if (canvasRect) {
12861
- var minX = clientRect.left - canvasRect.left;
12862
- var minY = clientRect.top - canvasRect.top;
12863
- var aabb = new AABB();
12864
- aabb.setMinMax(vec3.fromValues(minX, minY, 0), vec3.fromValues(minX + clientRect.width, minY + clientRect.height, 0));
12865
- return aabb;
12866
- }
12881
+ if (animation._needsTick) _this4.ticking = true;
12882
+ var alive = animation._inEffect || animation._needsTick;
12883
+ animation._inTimeline = alive;
12867
12884
 
12868
- return null;
12869
- };
12885
+ if (alive) {
12886
+ activeAnimations.push(animation);
12887
+ } else {
12888
+ inactiveAnimations.push(animation);
12889
+ }
12890
+ });
12870
12891
 
12871
- _proto.getLocalBounds = function getLocalBounds() {
12872
- if (this.parentNode) {
12873
- var parentInvert = mat4.invert(mat4.create(), this.parentNode.getWorldTransform());
12874
- var bounds = this.getBounds();
12892
+ (_this$pendingEffects = this.pendingEffects).push.apply(_this$pendingEffects, newPendingClears);
12875
12893
 
12876
- if (!AABB.isEmpty(bounds)) {
12877
- var localBounds = new AABB();
12878
- localBounds.setFromTransformedAABB(bounds, parentInvert);
12879
- return localBounds;
12880
- }
12881
- }
12894
+ (_this$pendingEffects2 = this.pendingEffects).push.apply(_this$pendingEffects2, newPendingEffects);
12882
12895
 
12883
- return this.getBounds();
12896
+ if (this.ticking) this.requestAnimationFrame(function () {});
12897
+ this.inTick = false;
12898
+ return [activeAnimations, inactiveAnimations];
12884
12899
  };
12885
12900
 
12886
- return HTML;
12887
- }(DisplayObject);
12901
+ return AnimationTimeline;
12902
+ }();
12888
12903
 
12889
12904
  /**
12890
12905
  * the entry of DOM tree
@@ -12919,7 +12934,7 @@ var Document = /*#__PURE__*/function (_Node) {
12919
12934
  defaultValue = _ref.defaultValue;
12920
12935
 
12921
12936
  if (inherited && defaultValue) {
12922
- initialStyle[name] = defaultValue;
12937
+ initialStyle[name] = isFunction(defaultValue) ? defaultValue(Shape.GROUP) : defaultValue;
12923
12938
  }
12924
12939
  }); // like <html> in DOM tree
12925
12940
 
@@ -12939,7 +12954,12 @@ var Document = /*#__PURE__*/function (_Node) {
12939
12954
  * @example const circle = document.createElement('circle', { style: { r: 10 } });
12940
12955
  */
12941
12956
  _proto.createElement = function createElement(tagName, options) {
12942
- // d3 will use <tspan>
12957
+ // @observablehq/plot will create <svg>
12958
+ if (tagName === 'svg') {
12959
+ return this.documentElement;
12960
+ } // d3 will use <tspan>
12961
+
12962
+
12943
12963
  var clazz = this.defaultView.customElements.get(tagName);
12944
12964
 
12945
12965
  if (!clazz) {
@@ -14918,7 +14938,11 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
14918
14938
  affectChildren = false;
14919
14939
  }
14920
14940
 
14921
- var p = element;
14941
+ var p = element; // only need to re-render itself
14942
+
14943
+ if (p.renderable) {
14944
+ p.renderable.dirty = true;
14945
+ }
14922
14946
 
14923
14947
  while (p) {
14924
14948
  var renderable = p.renderable;
@@ -14926,7 +14950,6 @@ var DefaultSceneGraphService = /*#__PURE__*/function () {
14926
14950
  if (renderable) {
14927
14951
  renderable.renderBoundsDirty = true;
14928
14952
  renderable.boundsDirty = true;
14929
- renderable.dirty = true;
14930
14953
  }
14931
14954
 
14932
14955
  p = p.parentNode;
@@ -16484,6 +16507,7 @@ var RenderingService = /*#__PURE__*/function () {
16484
16507
  rendered: 0
16485
16508
  };
16486
16509
  this.zIndexCounter = 0;
16510
+ this.renderOrderChangedEvent = new CustomEvent(ElementEvent.RENDER_ORDER_CHANGED);
16487
16511
  this.hooks = {
16488
16512
  /**
16489
16513
  * called before any frame rendered
@@ -16670,9 +16694,10 @@ var RenderingService = /*#__PURE__*/function () {
16670
16694
 
16671
16695
  if (renderOrderChanged) {
16672
16696
  displayObject.forEach(function (child) {
16673
- child.dispatchEvent(new CustomEvent(ElementEvent.RENDER_ORDER_CHANGED, {
16697
+ _this3.renderOrderChangedEvent.detail = {
16674
16698
  renderOrder: child.sortable.renderOrder
16675
- }));
16699
+ };
16700
+ child.dispatchEvent(_this3.renderOrderChangedEvent);
16676
16701
  });
16677
16702
  }
16678
16703
  };
@@ -18759,9 +18784,24 @@ CSSPropertyColor = __decorate([singleton({
18759
18784
  }]
18760
18785
  })], CSSPropertyColor);
18761
18786
 
18762
- var CSSPropertyFilter = function CSSPropertyFilter() {
18763
- this.parser = parseFilter;
18764
- };
18787
+ var CSSPropertyFilter = /*#__PURE__*/function () {
18788
+ function CSSPropertyFilter() {
18789
+ this.parser = parseFilter;
18790
+ }
18791
+
18792
+ var _proto = CSSPropertyFilter.prototype;
18793
+
18794
+ _proto.calculator = function calculator(name, oldParsed, parsed) {
18795
+ // unset or none
18796
+ if (parsed instanceof CSSKeywordValue) {
18797
+ return [];
18798
+ }
18799
+
18800
+ return parsed;
18801
+ };
18802
+
18803
+ return CSSPropertyFilter;
18804
+ }();
18765
18805
 
18766
18806
  CSSPropertyFilter = __decorate([singleton({
18767
18807
  token: {
@@ -19335,32 +19375,32 @@ var CSSPropertyTransform = /*#__PURE__*/function () {
19335
19375
 
19336
19376
  if (t === 'scale') {
19337
19377
  // scale(1) scale(1, 1)
19338
- var newScale = d.map(function (s) {
19378
+ var newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
19339
19379
  return s.value;
19340
- }) || [1, 1];
19380
+ })) || [1, 1];
19341
19381
  object.scaleLocal(newScale[0], newScale[1], 1);
19342
19382
  } else if (t === 'scalex') {
19343
- var _newScale = d.map(function (s) {
19383
+ var _newScale = (d === null || d === void 0 ? void 0 : d.map(function (s) {
19344
19384
  return s.value;
19345
- }) || [1];
19385
+ })) || [1];
19346
19386
 
19347
19387
  object.scaleLocal(_newScale[0], 1, 1);
19348
19388
  } else if (t === 'scaley') {
19349
- var _newScale2 = d.map(function (s) {
19389
+ var _newScale2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
19350
19390
  return s.value;
19351
- }) || [1];
19391
+ })) || [1];
19352
19392
 
19353
19393
  object.scaleLocal(1, _newScale2[0], 1);
19354
19394
  } else if (t === 'scalez') {
19355
- var _newScale3 = d.map(function (s) {
19395
+ var _newScale3 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
19356
19396
  return s.value;
19357
- }) || [1];
19397
+ })) || [1];
19358
19398
 
19359
19399
  object.scaleLocal(1, 1, _newScale3[0]);
19360
19400
  } else if (t === 'scale3d') {
19361
- var _newScale4 = d.map(function (s) {
19401
+ var _newScale4 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
19362
19402
  return s.value;
19363
- }) || [1, 1, 1];
19403
+ })) || [1, 1, 1];
19364
19404
 
19365
19405
  object.scaleLocal(_newScale4[0], _newScale4[1], _newScale4[2]);
19366
19406
  } else if (t === 'translate') {
@@ -19398,22 +19438,42 @@ var CSSPropertyTransform = /*#__PURE__*/function () {
19398
19438
 
19399
19439
  object.rotateLocal(0, 0, _newAngles3[0].value);
19400
19440
  } else if (t === 'rotate3d') ; else if (t === 'skew') {
19401
- var newSkew = d.map(function (s) {
19441
+ var newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
19402
19442
  return s.value;
19403
- }) || [0, 0];
19443
+ })) || [0, 0];
19404
19444
  object.setLocalSkew(deg2rad(newSkew[0]), deg2rad(newSkew[1]));
19405
19445
  } else if (t === 'skewx') {
19406
- var _newSkew = d.map(function (s) {
19446
+ var _newSkew = (d === null || d === void 0 ? void 0 : d.map(function (s) {
19407
19447
  return s.value;
19408
- }) || [0];
19448
+ })) || [0];
19409
19449
 
19410
19450
  object.setLocalSkew(deg2rad(_newSkew[0]), object.getLocalSkew()[1]);
19411
19451
  } else if (t === 'skewy') {
19412
- var _newSkew2 = d.map(function (s) {
19452
+ var _newSkew2 = (d === null || d === void 0 ? void 0 : d.map(function (s) {
19413
19453
  return s.value;
19414
- }) || [0];
19454
+ })) || [0];
19415
19455
 
19416
19456
  object.setLocalSkew(object.getLocalSkew()[0], deg2rad(_newSkew2[0]));
19457
+ } else if (t === 'matrix') {
19458
+ var _d$map = d.map(function (s) {
19459
+ return s.value;
19460
+ }),
19461
+ a = _d$map[0],
19462
+ b = _d$map[1],
19463
+ c = _d$map[2],
19464
+ dd = _d$map[3],
19465
+ tx = _d$map[4],
19466
+ ty = _d$map[5];
19467
+
19468
+ object.setLocalTransform(mat4.fromValues(a, b, 0, 0, c, dd, 0, 0, 0, 0, 1, 0, tx + defX, ty + defY, 0, 1));
19469
+ } else if (t === 'matrix3d') {
19470
+ // @ts-ignore
19471
+ var mat = mat4.fromValues.apply(mat4, d.map(function (s) {
19472
+ return s.value;
19473
+ }));
19474
+ mat[12] += defX;
19475
+ mat[13] += defY;
19476
+ object.setLocalTransform(mat);
19417
19477
  }
19418
19478
  });
19419
19479
  }
@@ -19551,16 +19611,19 @@ var BUILT_IN_PROPERTIES = [{
19551
19611
  name: 'shadowOffsetX',
19552
19612
  interpolable: true,
19553
19613
  layoutDependent: true,
19614
+ defaultValue: '0',
19554
19615
  syntax: PropertySyntax.LENGTH_PERCENTAGE
19555
19616
  }, {
19556
19617
  name: 'shadowOffsetY',
19557
19618
  interpolable: true,
19558
19619
  layoutDependent: true,
19620
+ defaultValue: '0',
19559
19621
  syntax: PropertySyntax.LENGTH_PERCENTAGE
19560
19622
  }, {
19561
19623
  name: 'shadowBlur',
19562
19624
  interpolable: true,
19563
19625
  layoutDependent: true,
19626
+ defaultValue: '0',
19564
19627
  syntax: PropertySyntax.SHADOW_BLUR
19565
19628
  }, {
19566
19629
  /**
@@ -19654,6 +19717,8 @@ var BUILT_IN_PROPERTIES = [{
19654
19717
  name: 'filter',
19655
19718
  independent: true,
19656
19719
  layoutDependent: true,
19720
+ keywords: ['none'],
19721
+ defaultValue: 'none',
19657
19722
  syntax: PropertySyntax.FILTER
19658
19723
  }, {
19659
19724
  name: 'clipPath',
@@ -20267,7 +20332,8 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
20267
20332
 
20268
20333
  var halfExtents = vec3.fromValues(Math.abs(width) / 2, Math.abs(height) / 2, depth / 2); // anchor is center by default, don't account for lineWidth here
20269
20334
 
20270
- var lineWidth = parsedStyle.lineWidth,
20335
+ var stroke = parsedStyle.stroke,
20336
+ lineWidth = parsedStyle.lineWidth,
20271
20337
  increasedLineWidthForHitTesting = parsedStyle.increasedLineWidthForHitTesting,
20272
20338
  shadowColor = parsedStyle.shadowColor,
20273
20339
  _parsedStyle$filter = parsedStyle.filter,
@@ -20289,10 +20355,15 @@ var DefaultStyleValueRegistry = /*#__PURE__*/function () {
20289
20355
  // if (lineJoin?.value === 'miter' && expansion < Math.SQRT2 * miterLimit) {
20290
20356
  // expansion = Math.SQRT1_2 * miterLimit;
20291
20357
  // }
20358
+ // append border only if stroke existed
20292
20359
 
20293
- var halfLineWidth = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) * expansion; // append border
20360
+ var hasStroke = stroke && !stroke.isNone;
20361
+
20362
+ if (hasStroke) {
20363
+ var halfLineWidth = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) * expansion;
20364
+ vec3.add(halfExtents, halfExtents, vec3.fromValues(halfLineWidth, halfLineWidth, 0));
20365
+ }
20294
20366
 
20295
- vec3.add(halfExtents, halfExtents, vec3.fromValues(halfLineWidth, halfLineWidth, 0));
20296
20367
  geometry.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
20297
20368
 
20298
20369
  if (shadowColor) {
@@ -20547,6 +20618,9 @@ var containerModule = Module(function (register) {
20547
20618
  });
20548
20619
  });
20549
20620
 
20621
+ var AbstractRendererPlugin = function AbstractRendererPlugin() {
20622
+ this.container = void 0;
20623
+ };
20550
20624
  var AbstractRenderer = /*#__PURE__*/function () {
20551
20625
  function AbstractRenderer(config) {
20552
20626
  this.plugins = [];
@@ -20566,7 +20640,8 @@ var AbstractRenderer = /*#__PURE__*/function () {
20566
20640
  /**
20567
20641
  * enable dirty rectangle rendering by default
20568
20642
  */
20569
- enableDirtyRectangleRendering: true
20643
+ enableDirtyRectangleRendering: true,
20644
+ enableDirtyRectangleRenderingDebug: false
20570
20645
  }, config);
20571
20646
  }
20572
20647
 
@@ -21327,6 +21402,7 @@ var CanvasEvent;
21327
21402
  CanvasEvent["BEFORE_DESTROY"] = "beforedestroy";
21328
21403
  CanvasEvent["AFTER_DESTROY"] = "afterdestroy";
21329
21404
  CanvasEvent["RESIZE"] = "resize";
21405
+ CanvasEvent["DIRTY_RECTANGLE"] = "dirtyrectangle";
21330
21406
  })(CanvasEvent || (CanvasEvent = {}));
21331
21407
  /**
21332
21408
  * can be treated like Window in DOM
@@ -21811,14 +21887,13 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
21811
21887
  // load other container modules provided by g-canvas/g-svg/g-webgl
21812
21888
  var plugins = renderer.getPlugins();
21813
21889
  plugins.forEach(function (plugin) {
21814
- plugin.init(_this4.container);
21890
+ plugin.container = _this4.container;
21891
+ plugin.init();
21815
21892
  });
21816
21893
  };
21817
21894
 
21818
21895
  _proto.setRenderer = /*#__PURE__*/function () {
21819
21896
  var _setRenderer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(renderer) {
21820
- var _this5 = this;
21821
-
21822
21897
  var canvasConfig, oldRenderer;
21823
21898
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
21824
21899
  while (1) {
@@ -21841,7 +21916,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
21841
21916
  this.destroy(false, true); // destroy all plugins, reverse will mutate origin array
21842
21917
 
21843
21918
  [].concat(oldRenderer === null || oldRenderer === void 0 ? void 0 : oldRenderer.getPlugins()).reverse().forEach(function (plugin) {
21844
- plugin.destroy(_this5.container);
21919
+ plugin.destroy();
21845
21920
  });
21846
21921
  _context3.next = 9;
21847
21922
  return this.initRenderer(renderer);
@@ -21866,7 +21941,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
21866
21941
  };
21867
21942
 
21868
21943
  _proto.unmountChildren = function unmountChildren(parent) {
21869
- var _this6 = this;
21944
+ var _this5 = this;
21870
21945
 
21871
21946
  if (this.inited) {
21872
21947
  var path = [];
@@ -21886,7 +21961,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
21886
21961
 
21887
21962
  child.dispatchEvent(new CustomEvent(ElementEvent.UNMOUNTED)); // skip document.documentElement
21888
21963
 
21889
- if (child !== _this6.document.documentElement) {
21964
+ if (child !== _this5.document.documentElement) {
21890
21965
  child.ownerDocument = null;
21891
21966
  }
21892
21967
 
@@ -21896,12 +21971,12 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
21896
21971
  };
21897
21972
 
21898
21973
  _proto.mountChildren = function mountChildren(parent) {
21899
- var _this7 = this;
21974
+ var _this6 = this;
21900
21975
 
21901
21976
  if (this.inited) {
21902
21977
  parent.forEach(function (child) {
21903
21978
  if (!child.isConnected) {
21904
- child.ownerDocument = _this7.document;
21979
+ child.ownerDocument = _this6.document;
21905
21980
  child.isConnected = true;
21906
21981
  child.dispatchEvent(new CustomEvent(ElementEvent.MOUNTED)); // trigger after mounted
21907
21982
 
@@ -21913,7 +21988,7 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
21913
21988
  }
21914
21989
  });
21915
21990
  } else {
21916
- console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.", 'appended child: ', parent);
21991
+ console.warn("[g]: You are trying to call `canvas.appendChild` before canvas' initialization finished. You can either await `canvas.ready` or listen to `CanvasEvent.READY` manually.", 'appended child: ', parent.nodeName);
21917
21992
  }
21918
21993
  };
21919
21994
 
@@ -21960,12 +22035,12 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
21960
22035
  _createClass(Canvas, [{
21961
22036
  key: "ready",
21962
22037
  get: function get() {
21963
- var _this8 = this;
22038
+ var _this7 = this;
21964
22039
 
21965
22040
  if (!this.readyPromise) {
21966
22041
  this.readyPromise = new Promise(function (resolve) {
21967
- _this8.resolveReadyPromise = function () {
21968
- resolve(_this8);
22042
+ _this7.resolveReadyPromise = function () {
22043
+ resolve(_this7);
21969
22044
  };
21970
22045
  });
21971
22046
 
@@ -21985,4 +22060,4 @@ var Canvas = /*#__PURE__*/function (_EventTarget) {
21985
22060
  GlobalContainer.load(containerModule);
21986
22061
  var layoutEngine = GlobalContainer.get(LayoutEngine);
21987
22062
 
21988
- export { AABB, AbstractLayoutDefinition, AbstractRenderer, Animation, AnimationEffectTiming, AnimationEvent, AnimationTimeline, AsyncParallelHook, AsyncSeriesWaterfallHook, BUILT_IN_PROPERTIES, BaseType, BoundingSphere, CSS, CSSColorValue, CSSGradientValue, CSSKeywordValue, CSSMathInvert, CSSMathMax, CSSMathMin, CSSMathNegate, CSSMathOperator, CSSMathProduct, CSSMathSum, CSSMathValue, CSSMathVariadic, CSSNumericValue, CSSNumericValueType, CSSProperty, CSSPropertyAngle, CSSPropertyClipPath, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage, CSSPropertyLengthOrPercentage12, CSSPropertyLengthOrPercentage14, CSSPropertyLocalPosition, CSSPropertyNumber, CSSPropertyOffsetDistance, CSSPropertyOffsetPath, CSSPropertyOpacity, CSSPropertyPath, CSSPropertyPoints, CSSPropertyShadowBlur, CSSPropertySyntaxFactory, CSSPropertyText, CSSPropertyTextTransform, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyZIndex, CSSRGB, CSSStyleValue, CSSStyleValueType, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasConfig, CanvasEvent, Circle, CircleUpdater, ContextNode, ContextService, Cullable, CustomElement, CustomElementRegistry, CustomEvent, DCHECK, DCHECK_EQ, DCHECK_NE, DELEGATION_SPLITTER, DefaultCamera, DefaultSceneGraphSelector, DefaultSceneGraphService, DefaultStyleValueRegistry, Deferred, DisplayObject, DisplayObjectPool, Document, EasingFunctions, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FragmentResult, FragmentResultFactory, FragmentResultOptions, Frustum, Geometry, GeometryAABBUpdater, GeometryUpdaterFactory, GradientType, Group, HTML, Image, KeyframeEffect, LayoutChildren, LayoutChildrenFactory, LayoutChildrenOptions, LayoutContext, LayoutContextFactory, LayoutContextOptions, LayoutEdges, LayoutEdgesFactory, LayoutEdgesOptions, LayoutEngine, LayoutFragment, LayoutFragmentFactory, LayoutFragmentOptions, LayoutObject, LayoutRegistry, LayoutTaskType, Line, LineUpdater, MOUSE_POINTER_ID, Mask, MutationEvent, MutationObserver, MutationRecord, Nested, Node, ObjectTyped, Odeg, OffscreenCanvasCreator, Opx, ParenLess, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertyName, PropertySyntax, RBushNode, RBushRoot, Ray, Rect, RectUpdater, Rectangle, Registration, RenderReason, Renderable, RenderingContext, RenderingPluginContribution, RenderingService, SceneGraphSelector, SceneGraphSelectorFactory, SceneGraphService, Shape, Sortable, Strategy, StyleValueRegistry, SyncHook, SyncWaterfallHook, TOUCH_TO_POINTER, Text, TextService, TextUpdater, Transform, UnitCategory, UnitType, ValueRange, baseTypeToString, camelCase, clamp, clampedMergeNumbers, cleanExistedCanvas, colorStopToString, compareAnimations, computeLinearGradient, computeRadialGradient, convertAngleUnit, convertEffectInput, convertItemToMatrix, convertPercentUnit, convertToDash, convertToPath, createVec3, decompose, deg2rad, deg2turn, equalSet, extractPolygons, formatAttribute, fromRotationTranslationScale, getAngle, getEasingFunction, getEuler, getHeight, getRotationInRadians, getScaling, getStyle, getTranslation, getWidth, grad2deg, hasArcOrBezier, isBoolean, isBrowser, isComparison, isFunction, isNil, isNumber, isObject, isPattern, isString, isUndefined, layoutEngine, makePerspective, makeQuerablePromise, makeTiming, memoize, mergeColors, mergeDimensionList, mergeDimensions, mergeNumberLists, mergeNumbers, mergePaths, mergeTransforms, normalizeKeyframes, normalizeTimingInput, numberToString, numericTimingToObject, parseAngle, parseColor, parseDimension, parseDimensionArray, parseFilter, parseGradient, parseLength, parseLengthOrPercentage, parseNumber, parseNumberList, parseParam, parsePath, parsePoints, parseTransform, parseTransformOrigin, parserPercentage, path2Segments, rad2deg, setDOMSize, sortByZIndex, toFontString, translatePathToString, turn2deg, typeCheck, unitTypeToBaseType };
22063
+ export { AABB, AbstractLayoutDefinition, AbstractRenderer, AbstractRendererPlugin, Animation, AnimationEffectTiming, AnimationEvent, AnimationTimeline, AsyncParallelHook, AsyncSeriesWaterfallHook, BUILT_IN_PROPERTIES, BaseType, BoundingSphere, CSS, CSSColorValue, CSSGradientValue, CSSKeywordValue, CSSMathInvert, CSSMathMax, CSSMathMin, CSSMathNegate, CSSMathOperator, CSSMathProduct, CSSMathSum, CSSMathValue, CSSMathVariadic, CSSNumericValue, CSSNumericValueType, CSSProperty, CSSPropertyAngle, CSSPropertyClipPath, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage, CSSPropertyLengthOrPercentage12, CSSPropertyLengthOrPercentage14, CSSPropertyLocalPosition, CSSPropertyNumber, CSSPropertyOffsetDistance, CSSPropertyOffsetPath, CSSPropertyOpacity, CSSPropertyPath, CSSPropertyPoints, CSSPropertyShadowBlur, CSSPropertySyntaxFactory, CSSPropertyText, CSSPropertyTextTransform, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyZIndex, CSSRGB, CSSStyleValue, CSSStyleValueType, CSSUnitValue, Camera, CameraEvent, CameraProjectionMode, CameraTrackingMode, CameraType, Canvas, CanvasConfig, CanvasEvent, Circle, CircleUpdater, ContextNode, ContextService, Cullable, CustomElement, CustomElementRegistry, CustomEvent, DCHECK, DCHECK_EQ, DCHECK_NE, DELEGATION_SPLITTER, DefaultCamera, DefaultSceneGraphSelector, DefaultSceneGraphService, DefaultStyleValueRegistry, Deferred, DisplayObject, DisplayObjectPool, Document, EasingFunctions, Element, ElementEvent, Ellipse, EllipseUpdater, EventService, EventTarget, FederatedEvent, FederatedMouseEvent, FederatedPointerEvent, FederatedWheelEvent, FragmentResult, FragmentResultFactory, FragmentResultOptions, Frustum, Geometry, GeometryAABBUpdater, GeometryUpdaterFactory, GradientType, Group, HTML, Image, KeyframeEffect, LayoutChildren, LayoutChildrenFactory, LayoutChildrenOptions, LayoutContext, LayoutContextFactory, LayoutContextOptions, LayoutEdges, LayoutEdgesFactory, LayoutEdgesOptions, LayoutEngine, LayoutFragment, LayoutFragmentFactory, LayoutFragmentOptions, LayoutObject, LayoutRegistry, LayoutTaskType, Line, LineUpdater, MOUSE_POINTER_ID, Mask, MutationEvent, MutationObserver, MutationRecord, Nested, Node, ObjectTyped, Odeg, OffscreenCanvasCreator, Opx, ParenLess, Path, PathUpdater, Plane, Point, Polygon, Polyline, PolylineUpdater, PropertyName, PropertySyntax, RBushNode, RBushRoot, Ray, Rect, RectUpdater, Rectangle, Registration, RenderReason, Renderable, RenderingContext, RenderingPluginContribution, RenderingService, SceneGraphSelector, SceneGraphSelectorFactory, SceneGraphService, Shape, Sortable, Strategy, StyleValueRegistry, SyncHook, SyncWaterfallHook, TOUCH_TO_POINTER, Text, TextService, TextUpdater, Transform, UnitCategory, UnitType, ValueRange, baseTypeToString, camelCase, clamp, clampedMergeNumbers, cleanExistedCanvas, colorStopToString, compareAnimations, composeMatrix, computeLinearGradient, computeRadialGradient, convertAngleUnit, convertEffectInput, convertItemToMatrix, convertPercentUnit, convertToDash, convertToPath, createVec3, decompose, deg2rad, deg2turn, equalSet, extractPolygons, formatAttribute, fromRotationTranslationScale, getAngle, getEasingFunction, getEuler, getHeight, getRotationInRadians, getScaling, getStyle, getTranslation, getWidth, grad2deg, hasArcOrBezier, isBoolean, isBrowser, isComparison, isFunction, isNil, isNumber, isObject, isPattern, isString, isUndefined, layoutEngine, makePerspective, makeQuerablePromise, makeTiming, memoize, mergeColors, mergeDimensionList, mergeDimensions, mergeNumberLists, mergeNumbers, mergePaths, mergeTransforms, normalizeKeyframes, normalizeTimingInput, numberToString, numericTimingToObject, parseAngle, parseColor, parseDimension, parseDimensionArray, parseFilter, parseGradient, parseLength, parseLengthOrPercentage, parseNumber, parseNumberList, parseParam, parsePath, parsePoints, parseTransform, parseTransformOrigin, parserPercentage, path2Segments, rad2deg, setDOMSize, sortByZIndex, toFontString, translatePathToString, turn2deg, typeCheck, unitTypeToBaseType };