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