@antv/g 5.0.4 → 5.0.8

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 (57) hide show
  1. package/dist/index.umd.min.js +15 -0
  2. package/es/Canvas.d.ts +13 -2
  3. package/es/Canvas.js +20 -9
  4. package/es/camera/Camera.d.ts +2 -1
  5. package/es/camera/Camera.js +13 -5
  6. package/es/components/Sortable.d.ts +4 -0
  7. package/es/components/Sortable.js +5 -0
  8. package/es/display-objects/DisplayObject.d.ts +0 -3
  9. package/es/display-objects/DisplayObject.js +16 -9
  10. package/es/display-objects/Line.d.ts +6 -0
  11. package/es/display-objects/Line.js +7 -8
  12. package/es/display-objects/Path.js +3 -7
  13. package/es/display-objects/Polyline.js +3 -7
  14. package/es/display-objects/Text.js +3 -7
  15. package/es/dom/EventTarget.d.ts +1 -1
  16. package/es/dom/EventTarget.js +1 -1
  17. package/es/dom/interfaces.d.ts +5 -1
  18. package/es/dom/interfaces.js +5 -0
  19. package/es/global-module.d.ts +4 -0
  20. package/es/global-module.js +58 -71
  21. package/es/plugins/FrustumCullingStrategy.js +3 -1
  22. package/es/property-handlers/localPosition.js +4 -2
  23. package/es/services/RenderingService.d.ts +6 -0
  24. package/es/services/RenderingService.js +29 -1
  25. package/es/services/SceneGraphService.js +4 -4
  26. package/es/types.d.ts +10 -2
  27. package/es/types.js +16 -0
  28. package/es/utils/interpolation.js +10 -7
  29. package/lib/Canvas.d.ts +13 -2
  30. package/lib/Canvas.js +20 -9
  31. package/lib/camera/Camera.d.ts +2 -1
  32. package/lib/camera/Camera.js +14 -5
  33. package/lib/components/Sortable.d.ts +4 -0
  34. package/lib/components/Sortable.js +5 -0
  35. package/lib/display-objects/DisplayObject.d.ts +0 -3
  36. package/lib/display-objects/DisplayObject.js +13 -8
  37. package/lib/display-objects/Line.d.ts +6 -0
  38. package/lib/display-objects/Line.js +6 -7
  39. package/lib/display-objects/Path.js +2 -6
  40. package/lib/display-objects/Polyline.js +2 -6
  41. package/lib/display-objects/Text.js +2 -6
  42. package/lib/dom/EventTarget.d.ts +1 -1
  43. package/lib/dom/EventTarget.js +1 -1
  44. package/lib/dom/interfaces.d.ts +5 -1
  45. package/lib/dom/interfaces.js +5 -0
  46. package/lib/global-module.d.ts +4 -0
  47. package/lib/global-module.js +58 -71
  48. package/lib/plugins/FrustumCullingStrategy.js +2 -0
  49. package/lib/property-handlers/localPosition.js +4 -2
  50. package/lib/services/RenderingService.d.ts +6 -0
  51. package/lib/services/RenderingService.js +30 -1
  52. package/lib/services/SceneGraphService.js +4 -4
  53. package/lib/types.d.ts +10 -2
  54. package/lib/types.js +19 -1
  55. package/lib/utils/interpolation.js +7 -9
  56. package/package.json +4 -4
  57. package/dist/index.umd.js +0 -15
@@ -3,7 +3,9 @@ export function updateLocalPosition(oldValue, newValue, object) {
3
3
  _b = _a.x,
4
4
  x = _b === void 0 ? 0 : _b,
5
5
  _c = _a.y,
6
- y = _c === void 0 ? 0 : _c; // update local position when x/y changed
6
+ y = _c === void 0 ? 0 : _c,
7
+ _d = _a.z,
8
+ z = _d === void 0 ? 0 : _d; // update local position when x/y changed
7
9
 
8
- object.setLocalPosition(x, y);
10
+ object.setLocalPosition(x, y, z);
9
11
  }
@@ -24,6 +24,8 @@ export declare class RenderingService {
24
24
  private renderingContext;
25
25
  private sceneGraphService;
26
26
  private inited;
27
+ private stats;
28
+ private zIndexCounter;
27
29
  hooks: {
28
30
  init: AsyncSeriesHook<[], import("tapable").UnsetAdditionalOptions>;
29
31
  prepare: SyncWaterfallHook<[DisplayObject<any, any>], import("tapable").UnsetAdditionalOptions>;
@@ -45,6 +47,10 @@ export declare class RenderingService {
45
47
  pointerWheel: SyncHook<[InteractivePointerEvent], void, import("tapable").UnsetAdditionalOptions>;
46
48
  };
47
49
  init(): Promise<void>;
50
+ getStats(): {
51
+ total: number;
52
+ rendered: number;
53
+ };
48
54
  render(): void;
49
55
  private renderDisplayObject;
50
56
  destroy(): void;
@@ -1,6 +1,7 @@
1
1
  import { __awaiter, __decorate, __generator, __metadata } from "tslib";
2
2
  import { inject, singleton, contrib, Syringe, Contribution } from 'mana-syringe';
3
3
  import { SyncHook, SyncWaterfallHook, AsyncSeriesHook, AsyncSeriesWaterfallHook } from 'tapable';
4
+ import { ElementEvent } from '../dom';
4
5
  import { RenderingContext, RENDER_REASON } from './RenderingContext';
5
6
  import { SceneGraphService, sortByZIndex } from './SceneGraphService';
6
7
  export var RenderingPluginContribution = Syringe.defineToken('RenderingPluginContribution');
@@ -19,6 +20,11 @@ var RenderingService =
19
20
  function () {
20
21
  function RenderingService() {
21
22
  this.inited = false;
23
+ this.stats = {
24
+ total: 0,
25
+ rendered: 0
26
+ };
27
+ this.zIndexCounter = 0;
22
28
  this.hooks = {
23
29
  init: new AsyncSeriesHook(),
24
30
  prepare: new SyncWaterfallHook(['object']),
@@ -71,7 +77,14 @@ function () {
71
77
  });
72
78
  };
73
79
 
80
+ RenderingService.prototype.getStats = function () {
81
+ return this.stats;
82
+ };
83
+
74
84
  RenderingService.prototype.render = function () {
85
+ this.stats.total = 0;
86
+ this.stats.rendered = 0;
87
+ this.zIndexCounter = 0;
75
88
  this.sceneGraphService.syncHierarchy(this.renderingContext.root);
76
89
 
77
90
  if (this.renderingContext.renderReasons.size && this.inited) {
@@ -88,7 +101,8 @@ function () {
88
101
  }
89
102
 
90
103
  this.renderingContext.renderReasons.clear();
91
- }
104
+ } // console.log('render objects: ', this.stats.count);
105
+
92
106
  };
93
107
 
94
108
  RenderingService.prototype.renderDisplayObject = function (displayObject) {
@@ -96,8 +110,12 @@ function () {
96
110
 
97
111
 
98
112
  var objectToRender = this.hooks.prepare.call(displayObject);
113
+ displayObject.sortable.renderOrder = this.zIndexCounter++;
114
+ this.stats.total++;
99
115
 
100
116
  if (objectToRender) {
117
+ this.stats.rendered++;
118
+
101
119
  if (!this.renderingContext.dirty) {
102
120
  this.renderingContext.dirty = true;
103
121
  this.hooks.beginFrame.call();
@@ -111,10 +129,12 @@ function () {
111
129
 
112
130
 
113
131
  var sortable = displayObject.sortable;
132
+ var renderOrderChanged = false;
114
133
 
115
134
  if (sortable.dirty) {
116
135
  // sortable.sorted = [...(displayObject.childNodes as IElement[])].sort(sortByZIndex);
117
136
  sortable.sorted = displayObject.childNodes.slice().sort(sortByZIndex);
137
+ renderOrderChanged = true;
118
138
  sortable.dirty = false;
119
139
  } // recursive rendering its children
120
140
 
@@ -122,6 +142,14 @@ function () {
122
142
  (sortable.sorted || displayObject.childNodes).forEach(function (child) {
123
143
  _this.renderDisplayObject(child);
124
144
  });
145
+
146
+ if (renderOrderChanged) {
147
+ displayObject.forEach(function (child) {
148
+ child.emit(ElementEvent.RENDER_ORDER_CHANGED, {
149
+ renderOrder: child.sortable.renderOrder
150
+ });
151
+ });
152
+ }
125
153
  };
126
154
 
127
155
  RenderingService.prototype.destroy = function () {
@@ -144,7 +144,7 @@ function () {
144
144
 
145
145
  var transform = element.transformable;
146
146
 
147
- if (element.parentNode === null) {
147
+ if (element.parentNode === null || !element.parentNode.transformable) {
148
148
  _this.rotateLocal(element, degrees);
149
149
  } else {
150
150
  var rotation = quat.create();
@@ -214,7 +214,7 @@ function () {
214
214
 
215
215
  var transform = element.transformable;
216
216
 
217
- if (element.parentNode === null) {
217
+ if (element.parentNode === null || !element.parentNode.transformable) {
218
218
  _this.setLocalEulerAngles(element, degrees);
219
219
  } else {
220
220
  quat.fromEuler(transform.localRotation, degrees[0], degrees[1], degrees[2]);
@@ -285,7 +285,7 @@ function () {
285
285
 
286
286
  transform.position = position;
287
287
 
288
- if (element.parentNode === null) {
288
+ if (element.parentNode === null || !element.parentNode.transformable) {
289
289
  vec3.copy(transform.localPosition, position);
290
290
  } else {
291
291
  var parentTransform = element.parentNode.transformable;
@@ -547,7 +547,7 @@ function () {
547
547
  return transform.worldTransform;
548
548
  }
549
549
 
550
- if (element.parentNode) {
550
+ if (element.parentNode && element.parentNode.transformable) {
551
551
  this.getWorldTransform(element.parentNode);
552
552
  }
553
553
 
package/es/types.d.ts CHANGED
@@ -25,12 +25,12 @@ export interface EventPosition {
25
25
  x: number;
26
26
  y: number;
27
27
  }
28
- export declare const enum LINE_CAP {
28
+ export declare enum LINE_CAP {
29
29
  Butt = "butt",
30
30
  Round = "round",
31
31
  Square = "square"
32
32
  }
33
- export declare const enum LINE_JOIN {
33
+ export declare enum LINE_JOIN {
34
34
  Bevel = "bevel",
35
35
  Round = "round",
36
36
  Miter = "miter"
@@ -44,6 +44,10 @@ export interface BaseStyleProps {
44
44
  * y in local space
45
45
  */
46
46
  y?: number;
47
+ /**
48
+ * z in local space
49
+ */
50
+ z?: number;
47
51
  /**
48
52
  * the origin of rotation and scaling, default to (0, 0)
49
53
  */
@@ -180,6 +184,10 @@ export interface CanvasConfig {
180
184
  * @type {number}
181
185
  */
182
186
  height: number;
187
+ /**
188
+ * 画布背景色
189
+ */
190
+ background?: ColorType;
183
191
  /**
184
192
  * 是否可监听
185
193
  * @type {boolean}
package/es/types.js CHANGED
@@ -14,4 +14,20 @@ export var SHAPE;
14
14
  SHAPE["HTML"] = "html";
15
15
  })(SHAPE || (SHAPE = {}));
16
16
 
17
+ export var LINE_CAP;
18
+
19
+ (function (LINE_CAP) {
20
+ LINE_CAP["Butt"] = "butt";
21
+ LINE_CAP["Round"] = "round";
22
+ LINE_CAP["Square"] = "square";
23
+ })(LINE_CAP || (LINE_CAP = {}));
24
+
25
+ export var LINE_JOIN;
26
+
27
+ (function (LINE_JOIN) {
28
+ LINE_JOIN["Bevel"] = "bevel";
29
+ LINE_JOIN["Round"] = "round";
30
+ LINE_JOIN["Miter"] = "miter";
31
+ })(LINE_JOIN || (LINE_JOIN = {}));
32
+
17
33
  export var CanvasConfig = 'CanvasConfig';
@@ -1,6 +1,9 @@
1
1
  import { __read, __spreadArray } from "tslib";
2
- import { globalContainer } from '../global-module';
3
- import { StylePropertyMergerFactory, StylePropertyParserFactory } from '../property-handlers/interfaces';
2
+ import { stylePropertyMergerFactory, stylePropertyParserFactory } from '../global-module'; // import {
3
+ // StylePropertyMergerFactory,
4
+ // StylePropertyParserFactory,
5
+ // } from '../property-handlers/interfaces';
6
+
4
7
  import { parseEasingFunction } from './animation';
5
8
  export function convertEffectInput(keyframes, timing, target) {
6
9
  var propertySpecificKeyframeGroups = makePropertySpecificKeyframeGroups(keyframes, timing);
@@ -104,11 +107,11 @@ function makeInterpolations(propertySpecificKeyframeGroups, target) {
104
107
 
105
108
  function propertyInterpolation(property, left, right, target) {
106
109
  var parsedLeft = left;
107
- var parsedRight = right;
108
- var parserFactory = globalContainer.get(StylePropertyParserFactory);
109
- var parser = parserFactory(property);
110
- var mergerFactory = globalContainer.get(StylePropertyMergerFactory);
111
- var merger = mergerFactory(property); // if (left == 'initial' || right == 'initial') {
110
+ var parsedRight = right; // const parserFactory = globalContainer.get<StylePropertyParserFactory>(StylePropertyParserFactory);
111
+
112
+ var parser = stylePropertyParserFactory[property]; // const mergerFactory = globalContainer.get<StylePropertyMergerFactory>(StylePropertyMergerFactory);
113
+
114
+ var merger = stylePropertyMergerFactory[property]; // if (left == 'initial' || right == 'initial') {
112
115
  // if (left == 'initial')
113
116
  // left = initialValues[ucProperty];
114
117
  // if (right == 'initial')
package/lib/Canvas.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { Cursor } from './types';
1
2
  import { CanvasConfig } from './types';
2
3
  import { DisplayObject } from './display-objects/DisplayObject';
3
4
  import { ContextService } from './services';
@@ -5,7 +6,7 @@ import { RenderingService } from './services/RenderingService';
5
6
  import { RenderingContext } from './services/RenderingContext';
6
7
  import { EventService } from './services/EventService';
7
8
  import { Camera } from './camera';
8
- import type { AbstractRenderer } from './AbstractRenderer';
9
+ import type { IRenderer } from './AbstractRenderer';
9
10
  import type { PointLike } from './shapes';
10
11
  import type { IChildNode } from './dom';
11
12
  import { Document, EventTarget } from './dom';
@@ -42,6 +43,11 @@ export declare class Canvas extends EventTarget implements ICanvas {
42
43
  * rAF in auto rendering
43
44
  */
44
45
  private frameId?;
46
+ /**
47
+ * cache here since inversify's resolving is very slow
48
+ */
49
+ private eventService;
50
+ private renderingService;
45
51
  constructor(config: CanvasConfig);
46
52
  private initRenderingContext;
47
53
  private initDefaultCamera;
@@ -60,6 +66,10 @@ export declare class Canvas extends EventTarget implements ICanvas {
60
66
  getEventService(): EventService;
61
67
  getRenderingService(): RenderingService;
62
68
  getRenderingContext(): RenderingContext;
69
+ getStats(): {
70
+ total: number;
71
+ rendered: number;
72
+ };
63
73
  getComputedStyle(node: DisplayObject): any;
64
74
  destroy(destroyScenegraph?: boolean): void;
65
75
  /**
@@ -78,7 +88,8 @@ export declare class Canvas extends EventTarget implements ICanvas {
78
88
  private initRenderer;
79
89
  private loadCommonContainerModule;
80
90
  private loadRendererContainerModule;
81
- setRenderer(renderer: AbstractRenderer): void;
91
+ setRenderer(renderer: IRenderer): void;
92
+ setCursor(cursor: Cursor): void;
82
93
  private unmountChildren;
83
94
  private mountChildren;
84
95
  client2Viewport(client: PointLike): PointLike;
package/lib/Canvas.js CHANGED
@@ -71,9 +71,11 @@ function (_super) {
71
71
 
72
72
  _this.customElements = new _CustomElementRegistry.CustomElementRegistry();
73
73
  (0, _canvas.cleanExistedCanvas)(config.container, _this);
74
- var mergedConfig = (0, _tslib.__assign)((0, _tslib.__assign)({}, config), {
74
+ var mergedConfig = (0, _tslib.__assign)({
75
+ width: 300,
76
+ height: 150,
75
77
  cursor: 'default'
76
- });
78
+ }, config);
77
79
 
78
80
  _this.initRenderingContext(mergedConfig);
79
81
 
@@ -119,8 +121,7 @@ function (_super) {
119
121
 
120
122
  Canvas.prototype.initDefaultCamera = function (width, height) {
121
123
  // set a default ortho camera
122
- var camera = new _camera.Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0) // origin to be in the top left
123
- .setOrthographic(width / -2, width / 2, height / -2, height / 2, 0.1, 1000); // redraw when camera changed
124
+ var camera = new _camera.Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0).setOrthographic(width / -2, width / 2, height / 2, height / -2, 0.1, 1000); // redraw when camera changed
124
125
 
125
126
  var context = this.container.get(_RenderingContext.RenderingContext);
126
127
  camera.on(_camera.CAMERA_EVENT.Updated, function () {
@@ -163,17 +164,21 @@ function (_super) {
163
164
  };
164
165
 
165
166
  Canvas.prototype.getEventService = function () {
166
- return this.container.get(_EventService.EventService);
167
+ return this.eventService;
167
168
  };
168
169
 
169
170
  Canvas.prototype.getRenderingService = function () {
170
- return this.container.get(_RenderingService.RenderingService);
171
+ return this.renderingService;
171
172
  };
172
173
 
173
174
  Canvas.prototype.getRenderingContext = function () {
174
175
  return this.container.get(_RenderingContext.RenderingContext);
175
176
  };
176
177
 
178
+ Canvas.prototype.getStats = function () {
179
+ return this.getRenderingService().getStats();
180
+ };
181
+
177
182
  Canvas.prototype.getComputedStyle = function (node) {
178
183
  return node.parsedStyle;
179
184
  };
@@ -224,9 +229,10 @@ function (_super) {
224
229
 
225
230
  var camera = this.container.get(_camera.DefaultCamera);
226
231
  var projectionMode = camera.getProjectionMode();
232
+ camera.setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0);
227
233
 
228
234
  if (projectionMode === _camera.CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
229
- camera.setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0).setOrthographic(width / -2, width / 2, height / -2, height / 2, camera.getNear(), camera.getFar());
235
+ camera.setOrthographic(width / -2, width / 2, height / 2, height / -2, camera.getNear(), camera.getFar());
230
236
  } else {
231
237
  camera.setAspect(width / height);
232
238
  }
@@ -296,9 +302,10 @@ function (_super) {
296
302
  this.loadRendererContainerModule(renderer); // init context
297
303
 
298
304
  var contextService = this.container.get(_services.ContextService);
299
- var renderingService = this.container.get(_RenderingService.RenderingService);
305
+ this.renderingService = this.container.get(_RenderingService.RenderingService);
306
+ this.eventService = this.container.get(_EventService.EventService);
300
307
  contextService.init();
301
- renderingService.init().then(function () {
308
+ this.renderingService.init().then(function () {
302
309
  _this.emit(CanvasEvent.READY, {});
303
310
  });
304
311
 
@@ -354,6 +361,10 @@ function (_super) {
354
361
  this.initRenderer(renderer);
355
362
  };
356
363
 
364
+ Canvas.prototype.setCursor = function (cursor) {
365
+ this.getContextService().applyCursorStyle(cursor);
366
+ };
367
+
357
368
  Canvas.prototype.unmountChildren = function (parent) {
358
369
  var path = [];
359
370
  parent.forEach(function (child) {
@@ -129,6 +129,7 @@ export declare class Camera extends EventEmitter {
129
129
  * ortho matrix for Canvas2D & SVG
130
130
  */
131
131
  private orthoMatrix;
132
+ isOrtho(): boolean;
132
133
  clone(): Camera;
133
134
  getProjectionMode(): CAMERA_PROJECTION_MODE;
134
135
  getPerspective(): mat4;
@@ -167,7 +168,7 @@ export declare class Camera extends EventEmitter {
167
168
  * 设置相机矩阵
168
169
  */
169
170
  setMatrix(matrix: mat4): this;
170
- setFov(fov: number): void;
171
+ setFov(fov: number): this;
171
172
  setAspect(aspect: number): this;
172
173
  setNear(near: number): this;
173
174
  setFar(far: number): this;
@@ -155,7 +155,7 @@ function (_super) {
155
155
 
156
156
  _this.fov = 30;
157
157
  _this.near = 0.1;
158
- _this.far = 10000;
158
+ _this.far = 1000;
159
159
  _this.aspect = 1;
160
160
  _this.projectionMatrix = _glMatrix.mat4.create();
161
161
  _this.projectionMatrixInverse = _glMatrix.mat4.create();
@@ -182,6 +182,10 @@ function (_super) {
182
182
  return _this;
183
183
  }
184
184
 
185
+ Camera.prototype.isOrtho = function () {
186
+ return this.projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC;
187
+ };
188
+
185
189
  Camera.prototype.clone = function () {
186
190
  var camera = new Camera();
187
191
  camera.setType(this.type, undefined); // camera.interactor = this.interactor;
@@ -317,6 +321,7 @@ function (_super) {
317
321
 
318
322
  Camera.prototype.setFov = function (fov) {
319
323
  this.setPerspective(this.near, this.far, fov, this.aspect);
324
+ return this;
320
325
  };
321
326
 
322
327
  Camera.prototype.setAspect = function (aspect) {
@@ -424,10 +429,11 @@ function (_super) {
424
429
  top -= this.view.offsetY * height / fullHeight;
425
430
  width *= this.view.width / fullWidth;
426
431
  height *= this.view.height / fullHeight;
427
- } // flip Y
432
+ }
428
433
 
434
+ (0, _math.makePerspective)(this.projectionMatrix, left, left + width, top, top - height, near, this.far); // flipY since the origin of OpenGL/WebGL is bottom-left compared with top-left in Canvas2D
429
435
 
430
- (0, _math.makePerspective)(this.projectionMatrix, left, left + width, top - height, top, near, this.far);
436
+ _glMatrix.mat4.scale(this.projectionMatrix, this.projectionMatrix, _glMatrix.vec3.fromValues(1, -1, 1));
431
437
 
432
438
  _glMatrix.mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
433
439
 
@@ -461,7 +467,10 @@ function (_super) {
461
467
  bottom = top - scaleH * this.view.height;
462
468
  }
463
469
 
464
- _glMatrix.mat4.ortho(this.projectionMatrix, left, right, bottom, top, near, far);
470
+ _glMatrix.mat4.ortho(this.projectionMatrix, left, right, bottom, top, near, far); // flipY since the origin of OpenGL/WebGL is bottom-left compared with top-left in Canvas2D
471
+
472
+
473
+ _glMatrix.mat4.scale(this.projectionMatrix, this.projectionMatrix, _glMatrix.vec3.fromValues(1, -1, 1));
465
474
 
466
475
  _glMatrix.mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
467
476
 
@@ -1033,7 +1042,7 @@ function (_super) {
1033
1042
 
1034
1043
  var rotZ = _glMatrix.quat.setAxisAngle(_glMatrix.quat.create(), [0, 0, 1], -this.roll * Math.PI / 180);
1035
1044
 
1036
- _glMatrix.mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, _glMatrix.vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.bottom - this.top) / 2 - position[1], 0), _glMatrix.vec3.fromValues(this.zoom, this.zoom, 1), position);
1045
+ _glMatrix.mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, _glMatrix.vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.top - this.bottom) / 2 - position[1], 0), _glMatrix.vec3.fromValues(this.zoom, this.zoom, 1), position);
1037
1046
  };
1038
1047
 
1039
1048
  Camera.ProjectionMode = {
@@ -13,4 +13,8 @@ export declare class Sortable {
13
13
  * index in parent's children
14
14
  */
15
15
  lastSortedIndex: number;
16
+ /**
17
+ * render order in whole scenegraph
18
+ */
19
+ renderOrder: number;
16
20
  }
@@ -13,6 +13,11 @@ function () {
13
13
  * need to re-sort
14
14
  */
15
15
  this.dirty = false;
16
+ /**
17
+ * render order in whole scenegraph
18
+ */
19
+
20
+ this.renderOrder = 0;
16
21
  }
17
22
 
18
23
  Sortable.tag = 'c-sortable';
@@ -4,7 +4,6 @@ import type { Animation } from '../dom/Animation';
4
4
  import { Element } from '../dom/Element';
5
5
  import type { DisplayObjectConfig, IChildNode } from '../dom/interfaces';
6
6
  import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
7
- import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
8
7
  /**
9
8
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
10
9
  *
@@ -32,8 +31,6 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
32
31
  * push to active animations after calling `animate()`
33
32
  */
34
33
  private activeAnimations;
35
- stylePropertyUpdaterFactory: <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[];
36
- stylePropertyParserFactory: <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>;
37
34
  constructor(config: DisplayObjectConfig<StyleProps>);
38
35
  destroy(): void;
39
36
  cloneNode(deep?: boolean): this;
@@ -23,12 +23,12 @@ var _types = require("../types");
23
23
 
24
24
  var _utils = require("../utils");
25
25
 
26
- var _propertyHandlers = require("../property-handlers");
27
-
28
26
  var _globalModule = require("../global-module");
29
27
 
30
28
  var _services = require("../services");
31
29
 
30
+ // import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
31
+ // import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
32
32
  var DEFAULT_STYLE_PROPS = {
33
33
  anchor: [0, 0, 0],
34
34
  origin: [0, 0, 0],
@@ -58,7 +58,12 @@ var DEFAULT_STYLE_PROPS = {
58
58
  var DisplayObject =
59
59
  /** @class */
60
60
  function (_super) {
61
- (0, _tslib.__extends)(DisplayObject, _super);
61
+ (0, _tslib.__extends)(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
62
+ // <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
63
+ // >(StylePropertyUpdaterFactory);
64
+ // stylePropertyParserFactory = globalContainer.get<
65
+ // <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
66
+ // >(StylePropertyParserFactory);
62
67
 
63
68
  function DisplayObject(config) {
64
69
  var _a, _b, _c;
@@ -69,9 +74,7 @@ function (_super) {
69
74
  */
70
75
 
71
76
 
72
- _this.activeAnimations = [];
73
- _this.stylePropertyUpdaterFactory = _globalModule.globalContainer.get(_propertyHandlers.StylePropertyUpdaterFactory);
74
- _this.stylePropertyParserFactory = _globalModule.globalContainer.get(_propertyHandlers.StylePropertyParserFactory); // assign name, id to config
77
+ _this.activeAnimations = []; // assign name, id to config
75
78
  // eg. group.get('name')
76
79
 
77
80
  _this.config = config; // compatible with G 3.0
@@ -199,7 +202,8 @@ function (_super) {
199
202
 
200
203
 
201
204
  DisplayObject.prototype.parseStyleProperty = function (name, value) {
202
- var stylePropertyParser = this.stylePropertyParserFactory(name);
205
+ // const stylePropertyParser = this.stylePropertyParserFactory(name);
206
+ var stylePropertyParser = _globalModule.stylePropertyParserFactory[name];
203
207
 
204
208
  if (stylePropertyParser) {
205
209
  // @ts-ignore
@@ -212,9 +216,10 @@ function (_super) {
212
216
  DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
213
217
  var _this = this; // update property, which may cause AABB re-calc
214
218
  // @ts-ignore
219
+ // const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
215
220
 
216
221
 
217
- var stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
222
+ var stylePropertyUpdaters = _globalModule.stylePropertyUpdaterFactory[name];
218
223
 
219
224
  if (stylePropertyUpdaters) {
220
225
  stylePropertyUpdaters.forEach(function (updater) {
@@ -7,14 +7,20 @@ export interface LineStyleProps extends BaseStyleProps {
7
7
  y1: number;
8
8
  x2: number;
9
9
  y2: number;
10
+ z1?: number;
11
+ z2?: number;
12
+ isBillboard?: boolean;
10
13
  }
11
14
  export interface ParsedLineStyleProps extends ParsedBaseStyleProps {
12
15
  x1: number;
13
16
  y1: number;
14
17
  x2: number;
15
18
  y2: number;
19
+ z1?: number;
20
+ z2?: number;
16
21
  defX: number;
17
22
  defY: number;
23
+ isBillboard?: boolean;
18
24
  }
19
25
  export declare class Line extends DisplayObject<LineStyleProps, ParsedLineStyleProps> {
20
26
  constructor({ style, ...rest }: DisplayObjectConfig<LineStyleProps>);
@@ -30,13 +30,12 @@ function (_super) {
30
30
  y1: 0,
31
31
  x2: 0,
32
32
  y2: 0,
33
- lineJoin: "miter"
34
- /* Miter */
35
- ,
36
- lineCap: "butt"
37
- /* Butt */
38
- ,
39
- lineWidth: 1
33
+ z1: 0,
34
+ z2: 0,
35
+ lineJoin: _types.LINE_JOIN.Miter,
36
+ lineCap: _types.LINE_CAP.Butt,
37
+ lineWidth: 1,
38
+ isBillboard: false
40
39
  }, style)
41
40
  }, rest)) || this;
42
41
  }
@@ -29,12 +29,8 @@ function (_super) {
29
29
  type: _types.SHAPE.Path,
30
30
  style: (0, _tslib.__assign)({
31
31
  path: '',
32
- lineJoin: "miter"
33
- /* Miter */
34
- ,
35
- lineCap: "butt"
36
- /* Butt */
37
- ,
32
+ lineJoin: _types.LINE_JOIN.Miter,
33
+ lineCap: _types.LINE_CAP.Butt,
38
34
  lineWidth: 1
39
35
  }, style)
40
36
  }, rest)) || this;
@@ -27,12 +27,8 @@ function (_super) {
27
27
  type: _types.SHAPE.Polyline,
28
28
  style: (0, _tslib.__assign)({
29
29
  points: [],
30
- lineJoin: "miter"
31
- /* Miter */
32
- ,
33
- lineCap: "butt"
34
- /* Butt */
35
- ,
30
+ lineJoin: _types.LINE_JOIN.Miter,
31
+ lineCap: _types.LINE_CAP.Butt,
36
32
  lineWidth: 1
37
33
  }, style)
38
34
  }, rest)) || this;
@@ -39,12 +39,8 @@ function (_super) {
39
39
  fill: '#000',
40
40
  letterSpacing: 0,
41
41
  lineHeight: 0,
42
- lineJoin: "miter"
43
- /* Miter */
44
- ,
45
- lineCap: "butt"
46
- /* Butt */
47
- ,
42
+ lineJoin: _types.LINE_JOIN.Miter,
43
+ lineCap: _types.LINE_CAP.Butt,
48
44
  lineWidth: 0,
49
45
  miterLimit: 10,
50
46
  padding: 0,
@@ -27,7 +27,7 @@ export declare class EventTarget implements IEventTarget {
27
27
  */
28
28
  off(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
29
29
  removeAllEventListeners(): void;
30
- removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
30
+ removeEventListener(type: string, listener?: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;
31
31
  /**
32
32
  * @deprecated
33
33
  * @alias dispatchEvent
@@ -124,7 +124,7 @@ function () {
124
124
  var capture = (0, _util.isBoolean)(options) && options || (0, _util.isObject)(options) && options.capture;
125
125
  var context = (0, _util.isFunction)(listener) ? undefined : listener;
126
126
  type = capture ? type + "capture" : type;
127
- listener = (0, _util.isFunction)(listener) ? listener : listener.handleEvent;
127
+ listener = (0, _util.isFunction)(listener) ? listener : listener === null || listener === void 0 ? void 0 : listener.handleEvent;
128
128
  this.emitter.off(type, listener, context);
129
129
  return this;
130
130
  };