@antv/g 1.0.0-alpha.23 → 1.0.0-alpha.24

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 (63) hide show
  1. package/es/Canvas.d.ts +4 -2
  2. package/es/Canvas.js +14 -4
  3. package/es/components/Renderable.d.ts +0 -4
  4. package/es/components/Renderable.js +0 -5
  5. package/es/components/Sortable.d.ts +4 -0
  6. package/es/display-objects/Line.js +6 -2
  7. package/es/display-objects/Path.js +6 -2
  8. package/es/display-objects/Polyline.js +6 -2
  9. package/es/display-objects/Text.js +6 -2
  10. package/es/display-objects/index.d.ts +0 -1
  11. package/es/display-objects/index.js +0 -1
  12. package/es/dom/interfaces.d.ts +2 -0
  13. package/es/plugins/CullingPlugin.d.ts +1 -1
  14. package/es/plugins/CullingPlugin.js +8 -7
  15. package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
  16. package/es/plugins/DirtyCheckPlugin.js +8 -7
  17. package/es/plugins/EventPlugin.js +17 -16
  18. package/es/plugins/FrustumCullingStrategy.js +1 -0
  19. package/es/plugins/PrepareRendererPlugin.js +4 -6
  20. package/es/services/EventService.d.ts +10 -10
  21. package/es/services/EventService.js +528 -383
  22. package/es/services/RenderingService.d.ts +21 -23
  23. package/es/services/RenderingService.js +63 -51
  24. package/es/services/SceneGraphService.js +16 -3
  25. package/es/shapes/Polygon.d.ts +9 -0
  26. package/es/shapes/Polygon.js +62 -0
  27. package/es/shapes/index.d.ts +1 -0
  28. package/es/shapes/index.js +2 -1
  29. package/es/types.d.ts +12 -2
  30. package/lib/Canvas.d.ts +4 -2
  31. package/lib/Canvas.js +14 -4
  32. package/lib/components/Renderable.d.ts +0 -4
  33. package/lib/components/Renderable.js +0 -5
  34. package/lib/components/Sortable.d.ts +4 -0
  35. package/lib/display-objects/Line.js +6 -2
  36. package/lib/display-objects/Path.js +6 -2
  37. package/lib/display-objects/Polyline.js +6 -2
  38. package/lib/display-objects/Text.js +6 -2
  39. package/lib/display-objects/index.d.ts +0 -1
  40. package/lib/display-objects/index.js +0 -13
  41. package/lib/dom/interfaces.d.ts +2 -0
  42. package/lib/plugins/CullingPlugin.d.ts +1 -1
  43. package/lib/plugins/CullingPlugin.js +9 -7
  44. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
  45. package/lib/plugins/DirtyCheckPlugin.js +9 -7
  46. package/lib/plugins/EventPlugin.js +16 -15
  47. package/lib/plugins/FrustumCullingStrategy.js +1 -0
  48. package/lib/plugins/PrepareRendererPlugin.js +5 -6
  49. package/lib/services/EventService.d.ts +10 -10
  50. package/lib/services/EventService.js +527 -382
  51. package/lib/services/RenderingService.d.ts +21 -23
  52. package/lib/services/RenderingService.js +67 -54
  53. package/lib/services/SceneGraphService.js +16 -3
  54. package/lib/shapes/Polygon.d.ts +9 -0
  55. package/lib/shapes/Polygon.js +69 -0
  56. package/lib/shapes/index.d.ts +1 -0
  57. package/lib/shapes/index.js +13 -0
  58. package/lib/types.d.ts +12 -2
  59. package/package.json +4 -4
  60. package/es/display-objects/Batch.d.ts +0 -24
  61. package/es/display-objects/Batch.js +0 -82
  62. package/lib/display-objects/Batch.d.ts +0 -24
  63. package/lib/display-objects/Batch.js +0 -91
@@ -1,6 +1,5 @@
1
- import { SyncHook, SyncWaterfallHook } from 'tapable';
2
1
  import { DisplayObject } from '..';
3
- import { EventPosition, InteractivePointerEvent } from '../types';
2
+ import { EventPosition } from '../types';
4
3
  export interface RenderingPlugin {
5
4
  apply(renderer: RenderingService): void;
6
5
  }
@@ -9,6 +8,23 @@ export interface PickingResult {
9
8
  position: EventPosition;
10
9
  picked: DisplayObject | null;
11
10
  }
11
+ export declare enum RenderingServiceEvent {
12
+ PointerDown = "pointerdown",
13
+ PointerUp = "pointerup",
14
+ PointerMove = "pointermove",
15
+ PointerOut = "pointerout",
16
+ PointerOver = "pointerover",
17
+ PointerWheel = "pointerwheel",
18
+ BeginFrame = "beginframe",
19
+ EndFrame = "endframe",
20
+ Prepare = "prepare",
21
+ BeforeRender = "beforerender",
22
+ Render = "render",
23
+ AfterRender = "afterrender",
24
+ Init = "init",
25
+ Destroy = "destroy",
26
+ Picking = "picking"
27
+ }
12
28
  /**
13
29
  * Use frame renderer implemented by `g-canvas/svg/webgl`, in every frame we do followings:
14
30
  * * update & merge dirty rectangles
@@ -21,27 +37,9 @@ export interface PickingResult {
21
37
  export declare class RenderingService {
22
38
  private renderingPluginContribution;
23
39
  private renderingContext;
24
- hooks: {
25
- init: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
26
- prepare: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
27
- /**
28
- * called at beginning of each frame, won't get called if nothing to re-render
29
- */
30
- beginFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
31
- beforeRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
32
- render: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
33
- afterRender: SyncHook<[DisplayObject<any, any>], void, import("tapable").UnsetAdditionalOptions>;
34
- endFrame: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
35
- destroy: SyncHook<[], void, import("tapable").UnsetAdditionalOptions>;
36
- pick: SyncWaterfallHook<[PickingResult], import("tapable").UnsetAdditionalOptions>;
37
- pointerDown: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
38
- pointerUp: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
39
- pointerMove: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
40
- pointerOut: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
41
- pointerOver: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
42
- pointerWheel: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
43
- };
44
- init(): void;
40
+ private inited;
41
+ emitter: any;
42
+ init(): Promise<void>;
45
43
  render(): void;
46
44
  destroy(): void;
47
45
  dirtify(): void;
@@ -1,12 +1,30 @@
1
- import { __decorate, __metadata, __read, __spreadArray } from "tslib";
1
+ import { __awaiter, __decorate, __generator, __metadata, __read, __spreadArray } from "tslib";
2
2
  import { inject, injectable, named } from 'inversify';
3
- import { SyncHook, SyncWaterfallHook } from 'tapable';
4
3
  import { Renderable, Sortable } from '../components';
5
4
  import { ContributionProvider } from '../contribution-provider';
6
- import { Batch } from '..';
7
5
  import { RenderingContext, RENDER_REASON } from './RenderingContext';
8
6
  import { sortByZIndex } from './SceneGraphService';
7
+ import AsyncEventEmitter from 'async-eventemitter';
9
8
  export var RenderingPluginContribution = 'RenderingPluginContribution';
9
+ export var RenderingServiceEvent;
10
+
11
+ (function (RenderingServiceEvent) {
12
+ RenderingServiceEvent["PointerDown"] = "pointerdown";
13
+ RenderingServiceEvent["PointerUp"] = "pointerup";
14
+ RenderingServiceEvent["PointerMove"] = "pointermove";
15
+ RenderingServiceEvent["PointerOut"] = "pointerout";
16
+ RenderingServiceEvent["PointerOver"] = "pointerover";
17
+ RenderingServiceEvent["PointerWheel"] = "pointerwheel";
18
+ RenderingServiceEvent["BeginFrame"] = "beginframe";
19
+ RenderingServiceEvent["EndFrame"] = "endframe";
20
+ RenderingServiceEvent["Prepare"] = "prepare";
21
+ RenderingServiceEvent["BeforeRender"] = "beforerender";
22
+ RenderingServiceEvent["Render"] = "render";
23
+ RenderingServiceEvent["AfterRender"] = "afterrender";
24
+ RenderingServiceEvent["Init"] = "init";
25
+ RenderingServiceEvent["Destroy"] = "destroy";
26
+ RenderingServiceEvent["Picking"] = "picking";
27
+ })(RenderingServiceEvent || (RenderingServiceEvent = {}));
10
28
  /**
11
29
  * Use frame renderer implemented by `g-canvas/svg/webgl`, in every frame we do followings:
12
30
  * * update & merge dirty rectangles
@@ -17,52 +35,44 @@ export var RenderingPluginContribution = 'RenderingPluginContribution';
17
35
  * * end frame
18
36
  */
19
37
 
38
+
20
39
  var RenderingService = function () {
21
40
  function RenderingService() {
22
- this.hooks = {
23
- init: new SyncHook(),
24
- prepare: new SyncWaterfallHook(['object']),
25
-
26
- /**
27
- * called at beginning of each frame, won't get called if nothing to re-render
28
- */
29
- beginFrame: new SyncHook([]),
30
- beforeRender: new SyncHook(['objectToRender']),
31
- render: new SyncHook(['objectToRender']),
32
- afterRender: new SyncHook(['objectToRender']),
33
- endFrame: new SyncHook([]),
34
- destroy: new SyncHook(),
35
- pick: new SyncWaterfallHook(['result']),
36
- pointerDown: new SyncHook(['event']),
37
- pointerUp: new SyncHook(['event']),
38
- pointerMove: new SyncHook(['event']),
39
- pointerOut: new SyncHook(['event']),
40
- pointerOver: new SyncHook(['event']),
41
- pointerWheel: new SyncHook(['event'])
42
- };
41
+ this.inited = false;
42
+ this.emitter = new AsyncEventEmitter();
43
43
  }
44
44
 
45
45
  RenderingService.prototype.init = function () {
46
- var _this = this; // register rendering plugins
47
-
48
-
49
- this.renderingPluginContribution.getContributions(true).forEach(function (plugin) {
50
- plugin.apply(_this);
46
+ return __awaiter(this, void 0, void 0, function () {
47
+ var _this = this;
48
+
49
+ return __generator(this, function (_a) {
50
+ // register rendering plugins
51
+ this.renderingPluginContribution.getContributions(true).forEach(function (plugin) {
52
+ plugin.apply(_this);
53
+ });
54
+ this.emitter.emit(RenderingServiceEvent.Init, {}, function () {
55
+ // run after all of the event listeners are done
56
+ _this.inited = true;
57
+ });
58
+ return [2
59
+ /*return*/
60
+ ];
61
+ });
51
62
  });
52
- this.hooks.init.call();
53
63
  };
54
64
 
55
65
  RenderingService.prototype.render = function () {
56
- if (this.renderingContext.renderReasons.size) {
66
+ if (this.renderingContext.renderReasons.size && this.inited) {
57
67
  this.renderDisplayObject(this.renderingContext.root);
58
68
 
59
69
  if (this.renderingContext.dirty) {
60
- this.hooks.endFrame.call();
70
+ this.emitter.emit(RenderingServiceEvent.EndFrame);
61
71
  this.renderingContext.dirty = false;
62
72
  } else {
63
73
  if (this.renderingContext.renderReasons.has(RENDER_REASON.DisplayObjectRemoved)) {
64
- this.hooks.beginFrame.call();
65
- this.hooks.endFrame.call();
74
+ this.emitter.emit(RenderingServiceEvent.BeginFrame);
75
+ this.emitter.emit(RenderingServiceEvent.EndFrame);
66
76
  }
67
77
  }
68
78
 
@@ -71,7 +81,7 @@ var RenderingService = function () {
71
81
  };
72
82
 
73
83
  RenderingService.prototype.destroy = function () {
74
- this.hooks.destroy.call();
84
+ this.emitter.emit(RenderingServiceEvent.Destroy);
75
85
  };
76
86
 
77
87
  RenderingService.prototype.dirtify = function () {
@@ -82,28 +92,30 @@ var RenderingService = function () {
82
92
  RenderingService.prototype.renderDisplayObject = function (displayObject) {
83
93
  var _this = this;
84
94
 
85
- var entity = displayObject === null || displayObject === void 0 ? void 0 : displayObject.getEntity(); // render itself
95
+ var entity = displayObject.entity; // render itself
86
96
 
87
- var objectToRender = this.hooks.prepare.call(displayObject);
97
+ this.emitter.emit(RenderingServiceEvent.Prepare, displayObject, function (objectToRender) {
98
+ if (objectToRender) {
99
+ if (!_this.renderingContext.dirty) {
100
+ _this.renderingContext.dirty = true;
88
101
 
89
- if (objectToRender) {
90
- if (!this.renderingContext.dirty) {
91
- this.renderingContext.dirty = true;
92
- this.hooks.beginFrame.call();
93
- }
102
+ _this.emitter.emit(RenderingServiceEvent.BeginFrame);
103
+ }
104
+
105
+ _this.emitter.emit(RenderingServiceEvent.BeforeRender, objectToRender);
106
+
107
+ _this.emitter.emit(RenderingServiceEvent.Render, objectToRender);
108
+
109
+ _this.emitter.emit(RenderingServiceEvent.AfterRender, objectToRender);
110
+
111
+ entity.getComponent(Renderable).dirty = false;
112
+ } // sort is very expensive, use cached result if posible
94
113
 
95
- this.hooks.beforeRender.call(objectToRender);
96
- this.hooks.render.call(objectToRender);
97
- this.hooks.afterRender.call(objectToRender);
98
- entity.getComponent(Renderable).dirty = false;
99
- }
100
114
 
101
- if ((objectToRender === null || objectToRender === void 0 ? void 0 : objectToRender.nodeName) !== Batch.tag) {
102
- // sort is very expensive, use cached result if posible
103
115
  var sortable = entity.getComponent(Sortable);
104
116
 
105
117
  if (sortable.dirty) {
106
- sortable.sorted = __spreadArray([], __read(displayObject.childNodes)).sort(sortByZIndex);
118
+ sortable.sorted = __spreadArray([], __read(displayObject.childNodes), false).sort(sortByZIndex);
107
119
  sortable.dirty = false;
108
120
  } // recursive rendering its children
109
121
 
@@ -111,7 +123,7 @@ var RenderingService = function () {
111
123
  (sortable.sorted || displayObject.childNodes).forEach(function (child) {
112
124
  _this.renderDisplayObject(child);
113
125
  });
114
- }
126
+ });
115
127
  };
116
128
 
117
129
  __decorate([inject(ContributionProvider), named(RenderingPluginContribution), __metadata("design:type", Object)], RenderingService.prototype, "renderingPluginContribution", void 0);
@@ -13,6 +13,7 @@ export function sortByZIndex(o1, o2) {
13
13
  var zIndex2 = Number(o2.style.zIndex);
14
14
 
15
15
  if (zIndex1 === zIndex2) {
16
+ // return o1.entity.getComponent(Sortable).lastSortedIndex - o2.entity.getComponent(Sortable).lastSortedIndex;
16
17
  var parent_1 = o1.parentNode;
17
18
 
18
19
  if (parent_1) {
@@ -735,10 +736,9 @@ var DefaultSceneGraphService = function () {
735
736
 
736
737
  aabb.setFromTransformedAABB(bounds, this.getWorldTransform(element));
737
738
  } // calc context's offset
738
- // @ts-ignore
739
739
 
740
740
 
741
- var bbox = (_b = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getContextService().getBoundingClientRect();
741
+ var bbox = (_b = (_a = element.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView) === null || _b === void 0 ? void 0 : _b.getContextService().getBoundingClientRect();
742
742
 
743
743
  if (aabb) {
744
744
  var _c = __read(aabb.getMin(), 2),
@@ -765,7 +765,20 @@ var DefaultSceneGraphService = function () {
765
765
 
766
766
  if (!childTransform.dirtyFlag) {
767
767
  _this.dirtifyWorldInternal(child, childTransform);
768
- }
768
+ } // model matrix changed
769
+
770
+
771
+ child.emit(ElementEvent.ATTRIBUTE_CHANGED, {
772
+ attributeName: 'modelMatrix',
773
+ oldValue: null,
774
+ newValue: null
775
+ });
776
+ }); // model matrix changed
777
+
778
+ element.emit(ElementEvent.ATTRIBUTE_CHANGED, {
779
+ attributeName: 'modelMatrix',
780
+ oldValue: null,
781
+ newValue: null
769
782
  }); // emit on leaf node
770
783
 
771
784
  if (element.childNodes.length === 0) {
@@ -0,0 +1,9 @@
1
+ import { Point } from './Point';
2
+ export declare class PolygonShape {
3
+ points: number[];
4
+ closeStroke: boolean;
5
+ constructor(points: Point[] | number[]);
6
+ constructor(...points: Point[] | number[]);
7
+ clone(): PolygonShape;
8
+ contains(x: number, y: number): boolean;
9
+ }
@@ -0,0 +1,62 @@
1
+ var PolygonShape = function () {
2
+ function PolygonShape() {
3
+ var points = [];
4
+
5
+ for (var _i = 0; _i < arguments.length; _i++) {
6
+ points[_i] = arguments[_i];
7
+ }
8
+
9
+ var flat = Array.isArray(points[0]) ? points[0] : points; // if this is an array of points, convert it to a flat array of numbers
10
+
11
+ if (typeof flat[0] !== 'number') {
12
+ var p = [];
13
+
14
+ for (var i = 0, il = flat.length; i < il; i++) {
15
+ p.push(flat[i].x, flat[i].y);
16
+ }
17
+
18
+ flat = p;
19
+ }
20
+
21
+ this.points = flat;
22
+ /**
23
+ * `false` after moveTo, `true` after `closePath`. In all other cases it is `true`.
24
+ * @member {boolean}
25
+ * @default true
26
+ */
27
+
28
+ this.closeStroke = true;
29
+ }
30
+
31
+ PolygonShape.prototype.clone = function () {
32
+ var points = this.points.slice();
33
+ var polygon = new PolygonShape(points);
34
+ polygon.closeStroke = this.closeStroke;
35
+ return polygon;
36
+ };
37
+
38
+ PolygonShape.prototype.contains = function (x, y) {
39
+ var inside = false; // use some raycasting to test hits
40
+ // https://github.com/substack/point-in-polygon/blob/master/index.js
41
+
42
+ var length = this.points.length / 2;
43
+
44
+ for (var i = 0, j = length - 1; i < length; j = i++) {
45
+ var xi = this.points[i * 2];
46
+ var yi = this.points[i * 2 + 1];
47
+ var xj = this.points[j * 2];
48
+ var yj = this.points[j * 2 + 1];
49
+ var intersect = yi > y !== yj > y && x < (xj - xi) * ((y - yi) / (yj - yi)) + xi;
50
+
51
+ if (intersect) {
52
+ inside = !inside;
53
+ }
54
+ }
55
+
56
+ return inside;
57
+ };
58
+
59
+ return PolygonShape;
60
+ }();
61
+
62
+ export { PolygonShape };
@@ -5,3 +5,4 @@ export * from './Plane';
5
5
  export * from './Ray';
6
6
  export * from './Point';
7
7
  export * from './Rectangle';
8
+ export * from './Polygon';
@@ -4,4 +4,5 @@ export * from './Frustum';
4
4
  export * from './Plane';
5
5
  export * from './Ray';
6
6
  export * from './Point';
7
- export * from './Rectangle';
7
+ export * from './Rectangle';
8
+ export * from './Polygon';
package/es/types.d.ts CHANGED
@@ -25,6 +25,16 @@ export interface EventPosition {
25
25
  x: number;
26
26
  y: number;
27
27
  }
28
+ export declare const enum LINE_CAP {
29
+ Butt = "butt",
30
+ Round = "round",
31
+ Square = "square"
32
+ }
33
+ export declare const enum LINE_JOIN {
34
+ Bevel = "bevel",
35
+ Round = "round",
36
+ Miter = "miter"
37
+ }
28
38
  export interface BaseStyleProps {
29
39
  /**
30
40
  * x in local space
@@ -87,9 +97,9 @@ export interface BaseStyleProps {
87
97
  /** 线宽 */
88
98
  lineWidth?: number;
89
99
  /** 指定如何绘制每一条线段末端 */
90
- lineCap?: 'butt' | 'round' | 'square';
100
+ lineCap?: LINE_CAP;
91
101
  /** 用来设置2个长度不为0的相连部分(线段,圆弧,曲线)如何连接在一起的属性(长度为0的变形部分,其指定的末端和控制点在同一位置,会被忽略) */
92
- lineJoin?: 'bevel' | 'round' | 'miter';
102
+ lineJoin?: LINE_JOIN;
93
103
  /**
94
104
  * 设置线的虚线样式,可以指定一个数组。一组描述交替绘制线段和间距(坐标空间单位)长度的数字。 如果数组元素的数量是奇数, 数组的元素会被复制并重复。例如, [5, 15, 25] 会变成 [5, 15, 25, 5, 15, 25]。这个属性取决于浏览器是否支持 setLineDash() 函数。
95
105
  */
package/lib/Canvas.d.ts CHANGED
@@ -11,6 +11,7 @@ import { Document, EventTarget } from './dom';
11
11
  import type { IElement, INode, ICanvas } from './dom/interfaces';
12
12
  import { CustomElementRegistry } from './dom/CustomElementRegistry';
13
13
  export declare enum CanvasEvent {
14
+ READY = "ready",
14
15
  BEFORE_RENDER = "beforerender",
15
16
  AFTER_RENDER = "afterrender",
16
17
  BEFORE_DESTROY = "beforedestroy",
@@ -43,6 +44,7 @@ export declare class Canvas extends EventTarget implements ICanvas {
43
44
  private initRenderingContext;
44
45
  private initDefaultCamera;
45
46
  getConfig(): Partial<CanvasConfig>;
47
+ getContainer(): import("inversify/lib/container/container").Container;
46
48
  /**
47
49
  * get the root displayObject in scenegraph
48
50
  * @alias this.document.documentElement
@@ -83,12 +85,12 @@ export declare class Canvas extends EventTarget implements ICanvas {
83
85
  canvas2Viewport(canvas: PointLike): PointLike;
84
86
  /**
85
87
  * @deprecated
86
- * @alias client2Canvas
88
+ * @alias client2Viewport
87
89
  */
88
90
  getPointByClient(clientX: number, clientY: number): PointLike;
89
91
  /**
90
92
  * @deprecated
91
- * @alias canvas2Client
93
+ * @alias viewport2Client
92
94
  */
93
95
  getClientByPoint(x: number, y: number): PointLike;
94
96
  }
package/lib/Canvas.js CHANGED
@@ -39,6 +39,7 @@ var CanvasEvent;
39
39
  exports.CanvasEvent = CanvasEvent;
40
40
 
41
41
  (function (CanvasEvent) {
42
+ CanvasEvent["READY"] = "ready";
42
43
  CanvasEvent["BEFORE_RENDER"] = "beforerender";
43
44
  CanvasEvent["AFTER_RENDER"] = "afterrender";
44
45
  CanvasEvent["BEFORE_DESTROY"] = "beforedestroy";
@@ -123,6 +124,10 @@ var Canvas = function (_super) {
123
124
  Canvas.prototype.getConfig = function () {
124
125
  return this.container.get(_types.CanvasConfig);
125
126
  };
127
+
128
+ Canvas.prototype.getContainer = function () {
129
+ return this.container;
130
+ };
126
131
  /**
127
132
  * get the root displayObject in scenegraph
128
133
  * @alias this.document.documentElement
@@ -241,7 +246,7 @@ var Canvas = function (_super) {
241
246
  };
242
247
 
243
248
  Canvas.prototype.render = function () {
244
- this.emit(CanvasEvent.BEFORE_DESTROY, {});
249
+ this.emit(CanvasEvent.BEFORE_RENDER, {});
245
250
 
246
251
  if (this.container.isBound(_RenderingService.RenderingService)) {
247
252
  var renderingService = this.container.get(_RenderingService.RenderingService);
@@ -264,6 +269,8 @@ var Canvas = function (_super) {
264
269
  };
265
270
 
266
271
  Canvas.prototype.initRenderer = function (renderer) {
272
+ var _this = this;
273
+
267
274
  if (!renderer) {
268
275
  throw new Error('Renderer is required.');
269
276
  }
@@ -275,7 +282,9 @@ var Canvas = function (_super) {
275
282
  var contextService = this.container.get(_services.ContextService);
276
283
  var renderingService = this.container.get(_RenderingService.RenderingService);
277
284
  contextService.init();
278
- renderingService.init();
285
+ renderingService.init().then(function () {
286
+ _this.emit(CanvasEvent.READY, {});
287
+ });
279
288
 
280
289
  if (renderer.getConfig().enableAutoRendering) {
281
290
  this.run();
@@ -352,6 +361,7 @@ var Canvas = function (_super) {
352
361
  if (!child.isConnected) {
353
362
  child.ownerDocument = _this.document;
354
363
  child.isConnected = true;
364
+ debugger;
355
365
  child.emit(_dom.ElementEvent.MOUNTED, {});
356
366
  }
357
367
  });
@@ -374,7 +384,7 @@ var Canvas = function (_super) {
374
384
  };
375
385
  /**
376
386
  * @deprecated
377
- * @alias client2Canvas
387
+ * @alias client2Viewport
378
388
  */
379
389
 
380
390
 
@@ -386,7 +396,7 @@ var Canvas = function (_super) {
386
396
  };
387
397
  /**
388
398
  * @deprecated
389
- * @alias canvas2Client
399
+ * @alias viewport2Client
390
400
  */
391
401
 
392
402
 
@@ -22,8 +22,4 @@ export declare class Renderable extends Component {
22
22
  * dirty rectangle flag
23
23
  */
24
24
  dirty: boolean;
25
- /**
26
- * is instanced
27
- */
28
- instanced: boolean;
29
25
  }
@@ -22,11 +22,6 @@ var Renderable = function (_super) {
22
22
  */
23
23
 
24
24
  _this.dirty = false;
25
- /**
26
- * is instanced
27
- */
28
-
29
- _this.instanced = false;
30
25
  return _this;
31
26
  }
32
27
 
@@ -10,4 +10,8 @@ export declare class Sortable extends Component {
10
10
  * sorted child entities
11
11
  */
12
12
  sorted: INode[];
13
+ /**
14
+ * index in parent's children
15
+ */
16
+ lastSortedIndex: number;
13
17
  }
@@ -28,8 +28,12 @@ var Line = function (_super) {
28
28
  y1: 0,
29
29
  x2: 0,
30
30
  y2: 0,
31
- lineJoin: 'miter',
32
- lineCap: 'butt',
31
+ lineJoin: "miter"
32
+ /* Miter */
33
+ ,
34
+ lineCap: "butt"
35
+ /* Butt */
36
+ ,
33
37
  lineWidth: 1
34
38
  }, style)
35
39
  }, rest)) || this;
@@ -27,8 +27,12 @@ var Path = function (_super) {
27
27
  type: _types.SHAPE.Path,
28
28
  style: (0, _tslib.__assign)({
29
29
  path: '',
30
- lineJoin: 'miter',
31
- lineCap: 'butt',
30
+ lineJoin: "miter"
31
+ /* Miter */
32
+ ,
33
+ lineCap: "butt"
34
+ /* Butt */
35
+ ,
32
36
  lineWidth: 1
33
37
  }, style)
34
38
  }, rest)) || this;
@@ -25,8 +25,12 @@ var Polyline = function (_super) {
25
25
  type: _types.SHAPE.Polyline,
26
26
  style: (0, _tslib.__assign)({
27
27
  points: [],
28
- lineJoin: 'miter',
29
- lineCap: 'butt',
28
+ lineJoin: "miter"
29
+ /* Miter */
30
+ ,
31
+ lineCap: "butt"
32
+ /* Butt */
33
+ ,
30
34
  lineWidth: 1
31
35
  }, style)
32
36
  }, rest)) || this;
@@ -37,8 +37,12 @@ var Text = function (_super) {
37
37
  fill: '#000',
38
38
  letterSpacing: 0,
39
39
  lineHeight: 0,
40
- lineJoin: 'miter',
41
- lineCap: 'butt',
40
+ lineJoin: "miter"
41
+ /* Miter */
42
+ ,
43
+ lineCap: "butt"
44
+ /* Butt */
45
+ ,
42
46
  lineWidth: 0,
43
47
  miterLimit: 10,
44
48
  padding: 0,
@@ -1,6 +1,5 @@
1
1
  export * from './DisplayObject';
2
2
  export * from './CustomElement';
3
- export * from './Batch';
4
3
  export * from './Circle';
5
4
  export * from './Ellipse';
6
5
  export * from './Group';
@@ -30,19 +30,6 @@ Object.keys(_CustomElement).forEach(function (key) {
30
30
  });
31
31
  });
32
32
 
33
- var _Batch = require("./Batch");
34
-
35
- Object.keys(_Batch).forEach(function (key) {
36
- if (key === "default" || key === "__esModule") return;
37
- if (key in exports && exports[key] === _Batch[key]) return;
38
- Object.defineProperty(exports, key, {
39
- enumerable: true,
40
- get: function get() {
41
- return _Batch[key];
42
- }
43
- });
44
- });
45
-
46
33
  var _Circle = require("./Circle");
47
34
 
48
35
  Object.keys(_Circle).forEach(function (key) {
@@ -7,6 +7,7 @@ import { CustomElementRegistry } from './CustomElementRegistry';
7
7
  import { DisplayObject } from '..';
8
8
  import type { PointLike } from '../shapes';
9
9
  import type { Camera } from '../camera';
10
+ import { ContextService } from '../services';
10
11
  export interface IEventTarget {
11
12
  entity: Entity;
12
13
  getEntity(): Entity;
@@ -292,6 +293,7 @@ export interface ICanvas extends IEventTarget {
292
293
  destroy(destroyScenegraph?: boolean): void;
293
294
  resize(width: number, height: number): void;
294
295
  getCamera(): Camera;
296
+ getContextService(): ContextService<unknown>;
295
297
  client2Viewport(client: PointLike): PointLike;
296
298
  viewport2Client(viewport: PointLike): PointLike;
297
299
  canvas2Viewport(canvas: PointLike): PointLike;
@@ -14,5 +14,5 @@ export declare class CullingPlugin implements RenderingPlugin {
14
14
  private canvasConfig;
15
15
  private strategies;
16
16
  private renderingContext;
17
- apply(renderer: RenderingService): void;
17
+ apply(renderingService: RenderingService): void;
18
18
  }