@antv/g 5.0.17 → 5.0.18

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.
Files changed (192) hide show
  1. package/dist/index.umd.min.js +31 -0
  2. package/es/AbstractRenderer.js +3 -1
  3. package/es/Canvas.d.ts +4 -1
  4. package/es/Canvas.js +4 -2
  5. package/es/DisplayObjectPool.js +3 -1
  6. package/es/camera/Camera.js +3 -1
  7. package/es/camera/Landmark.js +3 -1
  8. package/es/components/Cullable.js +3 -1
  9. package/es/components/Geometry.js +3 -1
  10. package/es/components/Renderable.js +3 -1
  11. package/es/components/Sortable.js +3 -1
  12. package/es/components/Transform.js +3 -1
  13. package/es/display-objects/Circle.js +3 -1
  14. package/es/display-objects/CustomElement.js +3 -1
  15. package/es/display-objects/DisplayObject.js +6 -3
  16. package/es/display-objects/Ellipse.js +3 -1
  17. package/es/display-objects/Group.js +3 -1
  18. package/es/display-objects/HTML.js +6 -3
  19. package/es/display-objects/Image.js +3 -1
  20. package/es/display-objects/Line.js +3 -1
  21. package/es/display-objects/Path.js +3 -1
  22. package/es/display-objects/Polygon.js +3 -1
  23. package/es/display-objects/Polyline.js +3 -1
  24. package/es/display-objects/Rect.js +3 -1
  25. package/es/display-objects/Text.js +6 -3
  26. package/es/dom/Animation.js +4 -2
  27. package/es/dom/AnimationEffectTiming.js +3 -1
  28. package/es/dom/AnimationEvent.js +3 -1
  29. package/es/dom/AnimationTimeline.js +3 -1
  30. package/es/dom/CustomElementRegistry.js +3 -1
  31. package/es/dom/CustomEvent.js +3 -1
  32. package/es/dom/Document.js +3 -1
  33. package/es/dom/Element.d.ts +6 -0
  34. package/es/dom/Element.js +16 -5
  35. package/es/dom/EventTarget.js +5 -3
  36. package/es/dom/FederatedEvent.d.ts +2 -2
  37. package/es/dom/FederatedEvent.js +3 -1
  38. package/es/dom/FederatedMouseEvent.js +3 -1
  39. package/es/dom/FederatedPointerEvent.js +3 -1
  40. package/es/dom/FederatedWheelEvent.js +3 -1
  41. package/es/dom/KeyframeEffect.js +3 -1
  42. package/es/dom/KeyframeList.js +1 -1
  43. package/es/dom/MutationEvent.js +3 -1
  44. package/es/dom/MutationObserver.js +10 -3
  45. package/es/dom/MutationRecord.js +3 -1
  46. package/es/dom/Node.js +4 -2
  47. package/es/dom/interfaces.d.ts +3 -0
  48. package/es/plugins/CullingPlugin.js +3 -1
  49. package/es/plugins/DirtyCheckPlugin.js +3 -1
  50. package/es/plugins/EventPlugin.d.ts +1 -1
  51. package/es/plugins/EventPlugin.js +3 -1
  52. package/es/plugins/FrustumCullingStrategy.js +6 -3
  53. package/es/plugins/PrepareRendererPlugin.js +3 -1
  54. package/es/property-handlers/color.js +2 -2
  55. package/es/property-handlers/dimension.js +1 -1
  56. package/es/property-handlers/path.d.ts +1 -1
  57. package/es/property-handlers/text.js +1 -1
  58. package/es/services/EventService.js +13 -5
  59. package/es/services/RenderingService.d.ts +12 -2
  60. package/es/services/RenderingService.js +24 -5
  61. package/es/services/SceneGraphSelector.js +3 -1
  62. package/es/services/SceneGraphService.js +11 -11
  63. package/es/services/aabb/CircleUpdater.js +3 -1
  64. package/es/services/aabb/EllipseUpdater.js +3 -1
  65. package/es/services/aabb/LineUpdater.js +3 -1
  66. package/es/services/aabb/PathUpdater.js +3 -1
  67. package/es/services/aabb/PolylineUpdater.js +3 -1
  68. package/es/services/aabb/RectUpdater.js +3 -1
  69. package/es/services/aabb/TextUpdater.js +15 -1
  70. package/es/services/text/OffscreenCanvasCreator.js +3 -1
  71. package/es/services/text/index.js +5 -3
  72. package/es/shapes/AABB.js +8 -1
  73. package/es/shapes/BoundingSphere.js +3 -1
  74. package/es/shapes/Frustum.js +3 -1
  75. package/es/shapes/Plane.js +3 -1
  76. package/es/shapes/Point.js +3 -1
  77. package/es/shapes/Polygon.js +3 -1
  78. package/es/shapes/Ray.js +3 -1
  79. package/es/shapes/Rect.js +3 -1
  80. package/es/shapes/Rectangle.js +3 -1
  81. package/es/utils/custom-easing.js +1 -1
  82. package/es/utils/event.js +6 -5
  83. package/es/utils/index.d.ts +1 -0
  84. package/es/utils/index.js +2 -1
  85. package/es/utils/path.d.ts +1 -1
  86. package/es/utils/path.js +3 -3
  87. package/es/utils/text.js +3 -3
  88. package/lib/AbstractRenderer.js +3 -1
  89. package/lib/Canvas.d.ts +4 -1
  90. package/lib/Canvas.js +5 -3
  91. package/lib/DisplayObjectPool.js +3 -1
  92. package/lib/camera/Camera.js +4 -2
  93. package/lib/camera/Landmark.js +3 -1
  94. package/lib/components/Cullable.js +4 -2
  95. package/lib/components/Geometry.js +3 -1
  96. package/lib/components/Renderable.js +3 -1
  97. package/lib/components/Sortable.js +3 -1
  98. package/lib/components/Transform.js +3 -1
  99. package/lib/display-objects/Circle.js +3 -1
  100. package/lib/display-objects/CustomElement.js +3 -1
  101. package/lib/display-objects/DisplayObject.js +6 -3
  102. package/lib/display-objects/Ellipse.js +3 -1
  103. package/lib/display-objects/Group.js +3 -1
  104. package/lib/display-objects/HTML.js +6 -4
  105. package/lib/display-objects/Image.js +3 -1
  106. package/lib/display-objects/Line.js +3 -1
  107. package/lib/display-objects/Path.js +3 -1
  108. package/lib/display-objects/Polygon.js +3 -1
  109. package/lib/display-objects/Polyline.js +3 -1
  110. package/lib/display-objects/Rect.js +3 -1
  111. package/lib/display-objects/Text.js +6 -4
  112. package/lib/dom/Animation.js +4 -2
  113. package/lib/dom/AnimationEffectTiming.js +3 -1
  114. package/lib/dom/AnimationEvent.js +3 -1
  115. package/lib/dom/AnimationTimeline.js +4 -2
  116. package/lib/dom/CustomElementRegistry.js +3 -1
  117. package/lib/dom/CustomEvent.js +3 -1
  118. package/lib/dom/Document.js +3 -1
  119. package/lib/dom/Element.d.ts +6 -0
  120. package/lib/dom/Element.js +16 -5
  121. package/lib/dom/EventTarget.js +5 -3
  122. package/lib/dom/FederatedEvent.d.ts +2 -2
  123. package/lib/dom/FederatedEvent.js +3 -1
  124. package/lib/dom/FederatedMouseEvent.js +3 -1
  125. package/lib/dom/FederatedPointerEvent.js +3 -1
  126. package/lib/dom/FederatedWheelEvent.js +3 -1
  127. package/lib/dom/KeyframeEffect.js +4 -2
  128. package/lib/dom/KeyframeList.js +1 -1
  129. package/lib/dom/MutationEvent.js +3 -1
  130. package/lib/dom/MutationObserver.js +11 -4
  131. package/lib/dom/MutationRecord.js +3 -1
  132. package/lib/dom/Node.js +4 -2
  133. package/lib/dom/interfaces.d.ts +3 -0
  134. package/lib/global-module.js +3 -2
  135. package/lib/index.js +1 -1
  136. package/lib/plugins/CullingPlugin.js +4 -2
  137. package/lib/plugins/DirtyCheckPlugin.js +3 -1
  138. package/lib/plugins/EventPlugin.d.ts +1 -1
  139. package/lib/plugins/EventPlugin.js +3 -1
  140. package/lib/plugins/FrustumCullingStrategy.js +5 -2
  141. package/lib/plugins/PrepareRendererPlugin.js +3 -1
  142. package/lib/property-handlers/color.js +5 -5
  143. package/lib/property-handlers/dimension.js +6 -5
  144. package/lib/property-handlers/inherit.js +1 -1
  145. package/lib/property-handlers/interfaces.js +1 -1
  146. package/lib/property-handlers/numeric.js +3 -3
  147. package/lib/property-handlers/path.d.ts +1 -1
  148. package/lib/property-handlers/path.js +1 -1
  149. package/lib/property-handlers/text.js +1 -1
  150. package/lib/property-handlers/transform.js +1 -1
  151. package/lib/services/EventService.js +13 -5
  152. package/lib/services/RenderingService.d.ts +12 -2
  153. package/lib/services/RenderingService.js +25 -5
  154. package/lib/services/SceneGraphSelector.js +4 -2
  155. package/lib/services/SceneGraphService.js +13 -17
  156. package/lib/services/aabb/CircleUpdater.js +3 -1
  157. package/lib/services/aabb/EllipseUpdater.js +3 -1
  158. package/lib/services/aabb/LineUpdater.js +3 -1
  159. package/lib/services/aabb/PathUpdater.js +3 -1
  160. package/lib/services/aabb/PolylineUpdater.js +3 -1
  161. package/lib/services/aabb/RectUpdater.js +3 -1
  162. package/lib/services/aabb/TextUpdater.js +15 -1
  163. package/lib/services/aabb/index.js +10 -10
  164. package/lib/services/aabb/interfaces.js +1 -1
  165. package/lib/services/text/OffscreenCanvasCreator.js +3 -1
  166. package/lib/services/text/index.js +5 -3
  167. package/lib/shapes/AABB.js +8 -1
  168. package/lib/shapes/BoundingSphere.js +3 -1
  169. package/lib/shapes/Frustum.js +4 -2
  170. package/lib/shapes/Plane.js +3 -1
  171. package/lib/shapes/Point.js +3 -1
  172. package/lib/shapes/Polygon.js +3 -1
  173. package/lib/shapes/Ray.js +3 -1
  174. package/lib/shapes/Rect.js +3 -1
  175. package/lib/shapes/Rectangle.js +3 -1
  176. package/lib/types.js +1 -1
  177. package/lib/utils/animation.js +3 -2
  178. package/lib/utils/bezier-easing.js +1 -1
  179. package/lib/utils/custom-easing.js +2 -2
  180. package/lib/utils/event.js +9 -7
  181. package/lib/utils/index.d.ts +1 -0
  182. package/lib/utils/index.js +13 -0
  183. package/lib/utils/math.js +5 -5
  184. package/lib/utils/path.d.ts +1 -1
  185. package/lib/utils/path.js +6 -6
  186. package/lib/utils/raf.js +2 -1
  187. package/lib/utils/text.js +3 -3
  188. package/package.json +3 -3
  189. package/es/display-objects/TSpan.d.ts +0 -1
  190. package/es/display-objects/TSpan.js +0 -0
  191. package/lib/display-objects/TSpan.d.ts +0 -1
  192. package/lib/display-objects/TSpan.js +0 -1
@@ -5,7 +5,9 @@ import { MutationRecord } from './MutationRecord';
5
5
  var uidCounter = 0;
6
6
  var registrationsTable = new WeakMap();
7
7
 
8
- var Registration = function () {
8
+ var Registration =
9
+ /** @class */
10
+ function () {
9
11
  function Registration(observer, target, options) {
10
12
  this.observer = observer;
11
13
  this.target = target;
@@ -195,7 +197,9 @@ export { Registration };
195
197
  * @see https://github.com/googlearchive/MutationObservers/blob/master/MutationObserver.js
196
198
  */
197
199
 
198
- var MutationObserver = function () {
200
+ var MutationObserver =
201
+ /** @class */
202
+ function () {
199
203
  function MutationObserver(callback) {
200
204
  this.callback = callback;
201
205
  this.nodes = [];
@@ -205,7 +209,10 @@ var MutationObserver = function () {
205
209
 
206
210
  MutationObserver.prototype.observe = function (target, options) {
207
211
  // 1.1
208
- if (!options.childList && !options.attributes && !options.characterData || options.attributeOldValue && !options.attributes || options.attributeFilter && options.attributeFilter.length && !options.attributes || options.characterDataOldValue && !options.characterData) {
212
+ if (!options.childList && !options.attributes && !options.characterData || // 1.2
213
+ options.attributeOldValue && !options.attributes || // 1.3
214
+ options.attributeFilter && options.attributeFilter.length && !options.attributes || // 1.4
215
+ options.characterDataOldValue && !options.characterData) {
209
216
  throw new SyntaxError();
210
217
  }
211
218
 
@@ -1,4 +1,6 @@
1
- var MutationRecord = function () {
1
+ var MutationRecord =
2
+ /** @class */
3
+ function () {
2
4
  function MutationRecord(type, target) {
3
5
  this.type = type;
4
6
  this.target = target;
package/es/dom/Node.js CHANGED
@@ -6,7 +6,9 @@ import { EventTarget } from './EventTarget';
6
6
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Node
7
7
  */
8
8
 
9
- var Node = function (_super) {
9
+ var Node =
10
+ /** @class */
11
+ function (_super) {
10
12
  __extends(Node, _super);
11
13
 
12
14
  function Node() {
@@ -115,7 +117,7 @@ var Node = function (_super) {
115
117
 
116
118
  if (this.nodeName === Shape.TEXT) {
117
119
  // @ts-ignore
118
- this.style.text = "" + content;
120
+ this.style.text = "".concat(content);
119
121
  } else {// this.appendChild(
120
122
  // new Text({
121
123
  // style: {
@@ -303,6 +303,8 @@ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INod
303
303
  getElementsByTagName: <E extends IElement = IElement>(tagName: string) => E[];
304
304
  scrollLeft: number;
305
305
  scrollTop: number;
306
+ clientLeft: number;
307
+ clientTop: number;
306
308
  /**
307
309
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/setAttribute
308
310
  */
@@ -315,6 +317,7 @@ export interface IElement<StyleProps = any, ParsedStyleProps = any> extends INod
315
317
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/removeAttribute
316
318
  */
317
319
  removeAttribute: (attributeName: keyof StyleProps) => void;
320
+ hasAttribute: (qualifiedName: string) => boolean;
318
321
  }
319
322
  export interface IDocument extends INode, IParentNode {
320
323
  /**
@@ -8,7 +8,9 @@ export var CullingStrategyContribution = Syringe.defineToken('CullingStrategyCon
8
8
  * 2. other custom culling strategies, eg. frustum culling
9
9
  */
10
10
 
11
- var CullingPlugin = function () {
11
+ var CullingPlugin =
12
+ /** @class */
13
+ function () {
12
14
  function CullingPlugin() {}
13
15
 
14
16
  CullingPlugin_1 = CullingPlugin;
@@ -7,7 +7,9 @@ import { RenderingContext, RenderReason } from '../services/RenderingContext';
7
7
  * Filter dirty renderables and calculate the "dirty rectangle" which will be clear when frame began
8
8
  */
9
9
 
10
- var DirtyCheckPlugin = function () {
10
+ var DirtyCheckPlugin =
11
+ /** @class */
12
+ function () {
11
13
  function DirtyCheckPlugin() {}
12
14
 
13
15
  DirtyCheckPlugin_1 = DirtyCheckPlugin;
@@ -1,4 +1,4 @@
1
- import { RenderingPlugin } from '../services';
1
+ import type { RenderingPlugin } from '../services';
2
2
  import { RenderingService } from '../services';
3
3
  /**
4
4
  * support mouse & touch events
@@ -14,7 +14,9 @@ import { normalizeToPointerEvent, supportsTouchEvents, TOUCH_TO_POINTER } from '
14
14
  * also provide some extra events such as `drag`
15
15
  */
16
16
 
17
- var EventPlugin = function () {
17
+ var EventPlugin =
18
+ /** @class */
19
+ function () {
18
20
  function EventPlugin() {
19
21
  var _this = this;
20
22
 
@@ -2,16 +2,19 @@ import { __decorate, __metadata } from "tslib";
2
2
  import { inject, singleton } from 'mana-syringe';
3
3
  import { vec3 } from 'gl-matrix';
4
4
  import { CullingStrategyContribution } from './CullingPlugin';
5
- import { Mask } from '../shapes';
5
+ import { AABB, Mask } from '../shapes';
6
6
  import { DefaultCamera, Camera } from '../camera/Camera';
7
7
  import { Shape } from '..'; // group is not a 2d shape
8
8
 
9
9
  var shape2D = [Shape.CIRCLE, Shape.ELLIPSE, Shape.IMAGE, Shape.RECT, Shape.LINE, Shape.POLYLINE, Shape.POLYGON, Shape.TEXT, Shape.PATH, Shape.HTML];
10
10
 
11
- var FrustumCullingStrategy = function () {
11
+ var FrustumCullingStrategy =
12
+ /** @class */
13
+ function () {
12
14
  function FrustumCullingStrategy() {}
13
15
 
14
16
  FrustumCullingStrategy.prototype.isVisible = function (object) {
17
+ // return true;
15
18
  var _a, _b;
16
19
 
17
20
  var cullable = object.cullable;
@@ -22,7 +25,7 @@ var FrustumCullingStrategy = function () {
22
25
 
23
26
  var renderBounds = object.getRenderBounds();
24
27
 
25
- if (!renderBounds) {
28
+ if (AABB.isEmpty(renderBounds)) {
26
29
  return false;
27
30
  } // get VP matrix from camera
28
31
 
@@ -6,7 +6,9 @@ import { INHERIT_PROPERTIES } from '../global-module';
6
6
  import { computeInheritStyleProperty } from '../property-handlers';
7
7
  import { RenderingContext, RenderReason, RenderingPluginContribution, dirtifyToRoot } from '../services';
8
8
 
9
- var PrepareRendererPlugin = function () {
9
+ var PrepareRendererPlugin =
10
+ /** @class */
11
+ function () {
10
12
  function PrepareRendererPlugin() {}
11
13
 
12
14
  PrepareRendererPlugin_1 = PrepareRendererPlugin;
@@ -84,7 +84,7 @@ export function parseColor(colorStr) {
84
84
  return {
85
85
  type: PARSED_COLOR_TYPE.Constant,
86
86
  value: rgba,
87
- formatted: color && "rgba(" + color.r + "," + color.g + "," + color.b + "," + color.opacity + ")" || 'rgba(0,0,0,0)'
87
+ formatted: color && "rgba(".concat(color.r, ",").concat(color.g, ",").concat(color.b, ",").concat(color.opacity, ")") || 'rgba(0,0,0,0)'
88
88
  };
89
89
  }
90
90
  export function mergeColors(left, right) {
@@ -103,7 +103,7 @@ export function mergeColors(left, right) {
103
103
  }
104
104
 
105
105
  rgba[3] = clamp(rgba[3], 0, 1);
106
- return "rgba(" + rgba.join(',') + ")";
106
+ return "rgba(".concat(rgba.join(','), ")");
107
107
  }];
108
108
  }
109
109
 
@@ -13,7 +13,7 @@ function isAngleUnit(unit) {
13
13
  }
14
14
 
15
15
  export function parseDimension(unitRegExp, string, object, name) {
16
- string = ("" + string).trim().toLowerCase();
16
+ string = "".concat(string).trim().toLowerCase();
17
17
 
18
18
  if (string === 'inherit') {
19
19
  var computed = computeInheritStyleProperty(object, name);
@@ -1,4 +1,4 @@
1
1
  import type { PathCommand } from '../types';
2
2
  import type { ParsedPathStyleProps } from '../display-objects';
3
3
  export declare function parsePath(path: string): ParsedPathStyleProps;
4
- export declare function mergePaths(left: ParsedPathStyleProps, right: ParsedPathStyleProps): ((string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["m" | "M", number, number] | ["r" | "R", number, number, number, number] | ["Q" | "q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["u" | "U", number, number, number])[] | ((pathArray: PathCommand[]) => PathCommand[]))[];
4
+ export declare function mergePaths(left: ParsedPathStyleProps, right: ParsedPathStyleProps): ((string[] | ["a" | "A", number, number, number, number, number, number, number] | ["C" | "c", number, number, number, number, number, number] | ["o" | "O", number, number] | ["h" | "H", number] | ["l" | "L", number, number] | ["m" | "M", number, number] | ["r" | "R", number, number, number, number] | ["q" | "Q", number, number, number, number] | ["s" | "S", number, number, number, number, number, number, number] | ["t" | "T", number, number] | ["v" | "V", number] | ["u" | "U", number, number, number])[] | ((pathArray: PathCommand[]) => PathCommand[]))[];
@@ -1,3 +1,3 @@
1
1
  export function updateText(oldValue, newValue, object) {
2
- object.nodeValue = "" + newValue || '';
2
+ object.nodeValue = "".concat(newValue) || '';
3
3
  }
@@ -13,7 +13,9 @@ import { ContextService } from './ContextService';
13
13
  import { mat4, vec3 } from 'gl-matrix';
14
14
  var PROPAGATION_LIMIT = 2048;
15
15
 
16
- var EventService = function (_super) {
16
+ var EventService =
17
+ /** @class */
18
+ function (_super) {
17
19
  __extends(EventService, _super);
18
20
 
19
21
  function EventService() {
@@ -475,6 +477,12 @@ var EventService = function (_super) {
475
477
  }
476
478
 
477
479
  EventService.prototype.init = function () {
480
+ // this.onPointerDown = this.onPointerDown.bind(this);
481
+ // this.onPointerMove = this.onPointerUp.bind(this);
482
+ // this.onPointerMove = this.onPointerMove.bind(this);
483
+ // this.onPointerUp = this.onPointerUp.bind(this);
484
+ // this.onPointerOut = this.onPointerOut.bind(this);
485
+ // this.onWheel = this.onWheel.bind(this);
478
486
  this.rootTarget = this.renderingContext.root.parentNode; // document
479
487
 
480
488
  this.addEventMapping('pointerdown', this.onPointerDown);
@@ -559,7 +567,7 @@ var EventService = function (_super) {
559
567
  mappers[i].fn(e);
560
568
  }
561
569
  } else {
562
- console.warn("[EventService]: Event mapping not defined for " + e.type);
570
+ console.warn("[EventService]: Event mapping not defined for ".concat(e.type));
563
571
  }
564
572
  };
565
573
 
@@ -849,7 +857,7 @@ var EventService = function (_super) {
849
857
 
850
858
  EventService.prototype.notifyTarget = function (e, type) {
851
859
  type = type !== null && type !== void 0 ? type : e.type;
852
- var key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? type + "capture" : type;
860
+ var key = e.eventPhase === e.CAPTURING_PHASE || e.eventPhase === e.AT_TARGET ? "".concat(type, "capture") : type;
853
861
  this.notifyListeners(e, key);
854
862
 
855
863
  if (e.eventPhase === e.AT_TARGET) {
@@ -869,14 +877,14 @@ var EventService = function (_super) {
869
877
  emitter.removeListener(type, listeners.fn, undefined, true);
870
878
  }
871
879
 
872
- listeners.fn.call(listeners.context, e);
880
+ listeners.fn.call(e.currentTarget || listeners.context, e); // listeners.fn.call(listeners.context, e);
873
881
  } else {
874
882
  for (var i = 0; i < listeners.length && !e.propagationImmediatelyStopped; i++) {
875
883
  if (listeners[i].once) {
876
884
  emitter.removeListener(type, listeners[i].fn, undefined, true);
877
885
  }
878
886
 
879
- listeners[i].fn.call(listeners[i].context, e);
887
+ listeners[i].fn.call(e.currentTarget || listeners[i].context, e); // listeners[i].fn.call(listeners[i].context, e);
880
888
  }
881
889
  }
882
890
  };
@@ -1,6 +1,6 @@
1
1
  import { Syringe } from 'mana-syringe';
2
2
  import { SyncHook, SyncWaterfallHook, AsyncParallelHook, AsyncSeriesWaterfallHook } from 'tapable';
3
- import type { DisplayObject } from '..';
3
+ import type { CanvasConfig, DisplayObject } from '..';
4
4
  import type { EventPosition, InteractivePointerEvent } from '../types';
5
5
  export interface RenderingPlugin {
6
6
  apply: (renderer: RenderingService) => void;
@@ -48,10 +48,20 @@ export declare class RenderingService {
48
48
  };
49
49
  init(): Promise<void>;
50
50
  getStats(): {
51
+ /**
52
+ * total display objects in scenegraph
53
+ */
51
54
  total: number;
55
+ /**
56
+ * number of display objects need to render in current frame
57
+ */
52
58
  rendered: number;
59
+ /**
60
+ * number of display objects displayed on screen
61
+ */
62
+ renderedOnscreen: number;
53
63
  };
54
- render(): void;
64
+ render(canvasConfig: Partial<CanvasConfig>): void;
55
65
  private renderDisplayObject;
56
66
  destroy(): void;
57
67
  dirtify(): void;
@@ -15,12 +15,26 @@ export var RenderingPluginContribution = Syringe.defineToken('RenderingPluginCon
15
15
  * * end frame
16
16
  */
17
17
 
18
- var RenderingService = function () {
18
+ var RenderingService =
19
+ /** @class */
20
+ function () {
19
21
  function RenderingService() {
20
22
  this.inited = false;
21
23
  this.stats = {
24
+ /**
25
+ * total display objects in scenegraph
26
+ */
22
27
  total: 0,
23
- rendered: 0
28
+
29
+ /**
30
+ * number of display objects need to render in current frame
31
+ */
32
+ rendered: 0,
33
+
34
+ /**
35
+ * number of display objects displayed on screen
36
+ */
37
+ renderedOnscreen: 0
24
38
  };
25
39
  this.zIndexCounter = 0;
26
40
  this.hooks = {
@@ -79,7 +93,7 @@ var RenderingService = function () {
79
93
  return this.stats;
80
94
  };
81
95
 
82
- RenderingService.prototype.render = function () {
96
+ RenderingService.prototype.render = function (canvasConfig) {
83
97
  this.stats.total = 0;
84
98
  this.stats.rendered = 0;
85
99
  this.zIndexCounter = 0;
@@ -88,13 +102,18 @@ var RenderingService = function () {
88
102
  if (this.renderingContext.renderReasons.size && this.inited) {
89
103
  this.renderDisplayObject(this.renderingContext.root);
90
104
 
91
- if (this.renderingContext.dirty) {
105
+ if (this.renderingContext.dirty || canvasConfig.renderer.getConfig().enableDirtyRectangleRendering && this.stats.total === 1) {
106
+ if (!this.renderingContext.dirty) {
107
+ this.hooks.beginFrame.call();
108
+ }
109
+
110
+ this.stats.renderedOnscreen = this.stats.rendered;
92
111
  this.hooks.endFrame.call();
93
112
  this.renderingContext.dirty = false;
94
113
  }
95
114
 
96
115
  this.renderingContext.renderReasons.clear();
97
- } // console.log('render objects: ', this.stats.count);
116
+ } // console.log('stats', this.stats);
98
117
 
99
118
  };
100
119
 
@@ -12,7 +12,9 @@ export var SceneGraphSelector = Syringe.defineToken('SceneGraphSelector', {
12
12
  * * getElementsByTag
13
13
  */
14
14
 
15
- var DefaultSceneGraphSelector = function () {
15
+ var DefaultSceneGraphSelector =
16
+ /** @class */
17
+ function () {
16
18
  function DefaultSceneGraphSelector() {}
17
19
 
18
20
  DefaultSceneGraphSelector.prototype.selectOne = function (query, root) {
@@ -52,7 +52,9 @@ export var SceneGraphService = 'SceneGraphService';
52
52
  * @see https://community.khronos.org/t/scene-graphs/50542/7
53
53
  */
54
54
 
55
- var DefaultSceneGraphService = function () {
55
+ var DefaultSceneGraphService =
56
+ /** @class */
57
+ function () {
56
58
  function DefaultSceneGraphService() {
57
59
  var _this = this;
58
60
  /**
@@ -340,16 +342,14 @@ var DefaultSceneGraphService = function () {
340
342
 
341
343
  DefaultSceneGraphService.prototype.detach = function (child) {
342
344
  if (child.parentNode) {
343
- var transform = child.transformable;
344
-
345
- if (transform) {
346
- var worldTransform = this.getWorldTransform(child, transform);
347
- mat4.getScaling(transform.localScale, worldTransform);
348
- mat4.getTranslation(transform.localPosition, worldTransform);
349
- mat4.getRotation(transform.localRotation, worldTransform);
350
- transform.localDirtyFlag = true;
351
- } // parent needs re-sort
352
-
345
+ var transform = child.transformable; // if (transform) {
346
+ // const worldTransform = this.getWorldTransform(child, transform);
347
+ // mat4.getScaling(transform.localScale, worldTransform);
348
+ // mat4.getTranslation(transform.localPosition, worldTransform);
349
+ // mat4.getRotation(transform.localRotation, worldTransform);
350
+ // transform.localDirtyFlag = true;
351
+ // }
352
+ // parent needs re-sort
353
353
 
354
354
  var sortable = child.parentNode.sortable;
355
355
 
@@ -3,7 +3,9 @@ import { singleton } from 'mana-syringe';
3
3
  import { GeometryAABBUpdater } from './interfaces';
4
4
  import { Shape } from '../../types';
5
5
 
6
- var CircleUpdater = function () {
6
+ var CircleUpdater =
7
+ /** @class */
8
+ function () {
7
9
  function CircleUpdater() {}
8
10
 
9
11
  CircleUpdater.prototype.update = function (parsedStyle, object) {
@@ -3,7 +3,9 @@ import { singleton } from 'mana-syringe';
3
3
  import { GeometryAABBUpdater } from './interfaces';
4
4
  import { Shape } from '../../types';
5
5
 
6
- var EllipseUpdater = function () {
6
+ var EllipseUpdater =
7
+ /** @class */
8
+ function () {
7
9
  function EllipseUpdater() {}
8
10
 
9
11
  EllipseUpdater.prototype.update = function (parsedStyle, object) {
@@ -3,7 +3,9 @@ import { singleton } from 'mana-syringe';
3
3
  import { GeometryAABBUpdater } from './interfaces';
4
4
  import { Shape } from '../../types';
5
5
 
6
- var LineUpdater = function () {
6
+ var LineUpdater =
7
+ /** @class */
8
+ function () {
7
9
  function LineUpdater() {}
8
10
 
9
11
  LineUpdater.prototype.update = function (parsedStyle) {
@@ -3,7 +3,9 @@ import { singleton } from 'mana-syringe';
3
3
  import { GeometryAABBUpdater } from './interfaces';
4
4
  import { Shape } from '../../types';
5
5
 
6
- var PathUpdater = function () {
6
+ var PathUpdater =
7
+ /** @class */
8
+ function () {
7
9
  function PathUpdater() {}
8
10
 
9
11
  PathUpdater.prototype.update = function (parsedStyle) {
@@ -3,7 +3,9 @@ import { singleton } from 'mana-syringe';
3
3
  import { GeometryAABBUpdater } from './interfaces';
4
4
  import { Shape } from '../../types';
5
5
 
6
- var PolylineUpdater = function () {
6
+ var PolylineUpdater =
7
+ /** @class */
8
+ function () {
7
9
  function PolylineUpdater() {}
8
10
 
9
11
  PolylineUpdater.prototype.update = function (parsedStyle) {
@@ -4,7 +4,9 @@ import { isString } from '@antv/util';
4
4
  import { GeometryAABBUpdater } from './interfaces';
5
5
  import { Shape } from '../../types';
6
6
 
7
- var RectUpdater = function () {
7
+ var RectUpdater =
8
+ /** @class */
9
+ function () {
8
10
  function RectUpdater() {}
9
11
 
10
12
  RectUpdater.prototype.update = function (parsedStyle, object) {
@@ -5,7 +5,9 @@ import { GeometryAABBUpdater } from './interfaces';
5
5
  import { TextService } from '../text';
6
6
  import { Shape } from '../../types';
7
7
 
8
- var TextUpdater = function () {
8
+ var TextUpdater =
9
+ /** @class */
10
+ function () {
9
11
  function TextUpdater() {}
10
12
 
11
13
  TextUpdater.prototype.update = function (parsedStyle) {
@@ -22,6 +24,18 @@ var TextUpdater = function () {
22
24
  dy = parsedStyle.dy;
23
25
  var metrics = this.textService.measureText(text, parsedStyle);
24
26
  parsedStyle.metrics = metrics;
27
+
28
+ if (!text) {
29
+ return {
30
+ width: 0,
31
+ height: 0,
32
+ x: 0,
33
+ y: 0,
34
+ offsetX: 0,
35
+ offsetY: 0
36
+ };
37
+ }
38
+
25
39
  var width = metrics.width,
26
40
  height = metrics.height,
27
41
  lineHeight = metrics.lineHeight,
@@ -1,7 +1,9 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { singleton } from 'mana-syringe';
3
3
 
4
- var OffscreenCanvasCreator = function () {
4
+ var OffscreenCanvasCreator =
5
+ /** @class */
6
+ function () {
5
7
  function OffscreenCanvasCreator() {}
6
8
 
7
9
  OffscreenCanvasCreator.prototype.getOrCreateCanvas = function () {
@@ -24,10 +24,12 @@ var regexCannotStartJaJp = /[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾー
24
24
  var regexCannotEndJaJp = /[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/;
25
25
  var regexCannotStartKoKr = /[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/;
26
26
  var regexCannotEndKoKr = /[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/;
27
- var regexCannotStart = new RegExp(regexCannotStartZhCn.source + "|" + regexCannotStartZhTw.source + "|" + regexCannotStartJaJp.source + "|" + regexCannotStartKoKr.source);
28
- var regexCannotEnd = new RegExp(regexCannotEndZhCn.source + "|" + regexCannotEndZhTw.source + "|" + regexCannotEndJaJp.source + "|" + regexCannotEndKoKr.source);
27
+ var regexCannotStart = new RegExp("".concat(regexCannotStartZhCn.source, "|").concat(regexCannotStartZhTw.source, "|").concat(regexCannotStartJaJp.source, "|").concat(regexCannotStartKoKr.source));
28
+ var regexCannotEnd = new RegExp("".concat(regexCannotEndZhCn.source, "|").concat(regexCannotEndZhTw.source, "|").concat(regexCannotEndJaJp.source, "|").concat(regexCannotEndKoKr.source));
29
29
 
30
- var TextService = function () {
30
+ var TextService =
31
+ /** @class */
32
+ function () {
31
33
  function TextService() {
32
34
  var _this = this;
33
35
 
package/es/shapes/AABB.js CHANGED
@@ -5,7 +5,9 @@ import { vec3 } from 'gl-matrix';
5
5
  * @see https://github.com/antvis/GWebGPUEngine/issues/3
6
6
  */
7
7
 
8
- var AABB = function () {
8
+ var AABB =
9
+ /** @class */
10
+ function () {
9
11
  function AABB(center, halfExtents) {
10
12
  this.min = vec3.create();
11
13
  this.max = vec3.create();
@@ -45,6 +47,11 @@ var AABB = function () {
45
47
  return;
46
48
  }
47
49
 
50
+ if (AABB.isEmpty(this)) {
51
+ this.setMinMax(aabb.getMin(), aabb.getMax());
52
+ return;
53
+ }
54
+
48
55
  var tc = this.center;
49
56
  var tcx = tc[0];
50
57
  var tcy = tc[1];
@@ -1,7 +1,9 @@
1
1
  import { vec3 } from 'gl-matrix';
2
2
  var tmpVecA = vec3.create();
3
3
 
4
- var BoundingSphere = function () {
4
+ var BoundingSphere =
5
+ /** @class */
6
+ function () {
5
7
  function BoundingSphere(center, radius) {
6
8
  this.center = center || vec3.create();
7
9
  this.radius = radius || 0.5;
@@ -9,7 +9,9 @@ export var Mask;
9
9
  Mask[Mask["INDETERMINATE"] = 2147483647] = "INDETERMINATE";
10
10
  })(Mask || (Mask = {}));
11
11
 
12
- var Frustum = function () {
12
+ var Frustum =
13
+ /** @class */
14
+ function () {
13
15
  function Frustum(planes) {
14
16
  this.planes = [];
15
17
 
@@ -1,6 +1,8 @@
1
1
  import { vec3 } from 'gl-matrix';
2
2
 
3
- var Plane = function () {
3
+ var Plane =
4
+ /** @class */
5
+ function () {
4
6
  function Plane(distance, normal) {
5
7
  this.distance = distance || 0;
6
8
  this.normal = normal || vec3.fromValues(0, 1, 0);
@@ -1,4 +1,6 @@
1
- var Point = function () {
1
+ var Point =
2
+ /** @class */
3
+ function () {
2
4
  function Point(x, y) {
3
5
  if (x === void 0) {
4
6
  x = 0;
@@ -1,4 +1,6 @@
1
- var PolygonShape = function () {
1
+ var PolygonShape =
2
+ /** @class */
3
+ function () {
2
4
  function PolygonShape() {
3
5
  var points = [];
4
6
 
package/es/shapes/Ray.js CHANGED
@@ -11,7 +11,9 @@ var tmpVecE = vec3.create();
11
11
  * @see https://github.com/mrdoob/three.js/blob/dev/src/math/Ray.js
12
12
  */
13
13
 
14
- var Ray = function () {
14
+ var Ray =
15
+ /** @class */
16
+ function () {
15
17
  function Ray(origin, direction) {
16
18
  this.origin = origin || vec3.create();
17
19
  this.direction = direction || vec3.fromValues(0, 0, -1);
package/es/shapes/Rect.js CHANGED
@@ -1,4 +1,6 @@
1
- var Rect = function () {
1
+ var Rect =
2
+ /** @class */
3
+ function () {
2
4
  function Rect(x, y, width, height) {
3
5
  this.x = x;
4
6
  this.y = y;
@@ -1,4 +1,6 @@
1
- var Rectangle = function () {
1
+ var Rectangle =
2
+ /** @class */
3
+ function () {
2
4
  function Rectangle(x, y, width, height) {
3
5
  this.x = x;
4
6
  this.y = y;