@antv/g 5.5.2 → 5.6.0

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