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