@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
package/es/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/es/Canvas.js CHANGED
@@ -50,9 +50,11 @@ function (_super) {
50
50
  _this.customElements = new CustomElementRegistry();
51
51
  cleanExistedCanvas(config.container, _this);
52
52
 
53
- var mergedConfig = __assign(__assign({}, config), {
53
+ var mergedConfig = __assign({
54
+ width: 300,
55
+ height: 150,
54
56
  cursor: 'default'
55
- });
57
+ }, config);
56
58
 
57
59
  _this.initRenderingContext(mergedConfig);
58
60
 
@@ -98,8 +100,7 @@ function (_super) {
98
100
 
99
101
  Canvas.prototype.initDefaultCamera = function (width, height) {
100
102
  // set a default ortho camera
101
- var camera = new Camera().setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0) // origin to be in the top left
102
- .setOrthographic(width / -2, width / 2, height / -2, height / 2, 0.1, 1000); // redraw when camera changed
103
+ var camera = new 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
103
104
 
104
105
  var context = this.container.get(RenderingContext);
105
106
  camera.on(CAMERA_EVENT.Updated, function () {
@@ -142,17 +143,21 @@ function (_super) {
142
143
  };
143
144
 
144
145
  Canvas.prototype.getEventService = function () {
145
- return this.container.get(EventService);
146
+ return this.eventService;
146
147
  };
147
148
 
148
149
  Canvas.prototype.getRenderingService = function () {
149
- return this.container.get(RenderingService);
150
+ return this.renderingService;
150
151
  };
151
152
 
152
153
  Canvas.prototype.getRenderingContext = function () {
153
154
  return this.container.get(RenderingContext);
154
155
  };
155
156
 
157
+ Canvas.prototype.getStats = function () {
158
+ return this.getRenderingService().getStats();
159
+ };
160
+
156
161
  Canvas.prototype.getComputedStyle = function (node) {
157
162
  return node.parsedStyle;
158
163
  };
@@ -203,9 +208,10 @@ function (_super) {
203
208
 
204
209
  var camera = this.container.get(DefaultCamera);
205
210
  var projectionMode = camera.getProjectionMode();
211
+ camera.setPosition(width / 2, height / 2, 500).setFocalPoint(width / 2, height / 2, 0);
206
212
 
207
213
  if (projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
208
- 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());
214
+ camera.setOrthographic(width / -2, width / 2, height / 2, height / -2, camera.getNear(), camera.getFar());
209
215
  } else {
210
216
  camera.setAspect(width / height);
211
217
  }
@@ -275,9 +281,10 @@ function (_super) {
275
281
  this.loadRendererContainerModule(renderer); // init context
276
282
 
277
283
  var contextService = this.container.get(ContextService);
278
- var renderingService = this.container.get(RenderingService);
284
+ this.renderingService = this.container.get(RenderingService);
285
+ this.eventService = this.container.get(EventService);
279
286
  contextService.init();
280
- renderingService.init().then(function () {
287
+ this.renderingService.init().then(function () {
281
288
  _this.emit(CanvasEvent.READY, {});
282
289
  });
283
290
 
@@ -333,6 +340,10 @@ function (_super) {
333
340
  this.initRenderer(renderer);
334
341
  };
335
342
 
343
+ Canvas.prototype.setCursor = function (cursor) {
344
+ this.getContextService().applyCursorStyle(cursor);
345
+ };
346
+
336
347
  Canvas.prototype.unmountChildren = function (parent) {
337
348
  var path = [];
338
349
  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;
@@ -136,7 +136,7 @@ function (_super) {
136
136
 
137
137
  _this.fov = 30;
138
138
  _this.near = 0.1;
139
- _this.far = 10000;
139
+ _this.far = 1000;
140
140
  _this.aspect = 1;
141
141
  _this.projectionMatrix = mat4.create();
142
142
  _this.projectionMatrixInverse = mat4.create();
@@ -163,6 +163,10 @@ function (_super) {
163
163
  return _this;
164
164
  }
165
165
 
166
+ Camera.prototype.isOrtho = function () {
167
+ return this.projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC;
168
+ };
169
+
166
170
  Camera.prototype.clone = function () {
167
171
  var camera = new Camera();
168
172
  camera.setType(this.type, undefined); // camera.interactor = this.interactor;
@@ -297,6 +301,7 @@ function (_super) {
297
301
 
298
302
  Camera.prototype.setFov = function (fov) {
299
303
  this.setPerspective(this.near, this.far, fov, this.aspect);
304
+ return this;
300
305
  };
301
306
 
302
307
  Camera.prototype.setAspect = function (aspect) {
@@ -404,10 +409,11 @@ function (_super) {
404
409
  top -= this.view.offsetY * height / fullHeight;
405
410
  width *= this.view.width / fullWidth;
406
411
  height *= this.view.height / fullHeight;
407
- } // flip Y
412
+ }
408
413
 
414
+ 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
409
415
 
410
- makePerspective(this.projectionMatrix, left, left + width, top - height, top, near, this.far);
416
+ mat4.scale(this.projectionMatrix, this.projectionMatrix, vec3.fromValues(1, -1, 1));
411
417
  mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
412
418
  this.emit(CAMERA_EVENT.Updated);
413
419
  return this;
@@ -439,7 +445,9 @@ function (_super) {
439
445
  bottom = top - scaleH * this.view.height;
440
446
  }
441
447
 
442
- mat4.ortho(this.projectionMatrix, left, right, bottom, top, near, far);
448
+ 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
449
+
450
+ mat4.scale(this.projectionMatrix, this.projectionMatrix, vec3.fromValues(1, -1, 1));
443
451
  mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
444
452
 
445
453
  this._getOrthoMatrix();
@@ -960,7 +968,7 @@ function (_super) {
960
968
 
961
969
  var position = this.position;
962
970
  var rotZ = quat.setAxisAngle(quat.create(), [0, 0, 1], -this.roll * Math.PI / 180);
963
- mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.bottom - this.top) / 2 - position[1], 0), vec3.fromValues(this.zoom, this.zoom, 1), position);
971
+ mat4.fromRotationTranslationScaleOrigin(this.orthoMatrix, rotZ, vec3.fromValues((this.rright - this.left) / 2 - position[0], (this.top - this.bottom) / 2 - position[1], 0), vec3.fromValues(this.zoom, this.zoom, 1), position);
964
972
  };
965
973
 
966
974
  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
  }
@@ -6,6 +6,11 @@ function () {
6
6
  * need to re-sort
7
7
  */
8
8
  this.dirty = false;
9
+ /**
10
+ * render order in whole scenegraph
11
+ */
12
+
13
+ this.renderOrder = 0;
9
14
  }
10
15
 
11
16
  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;
@@ -6,9 +6,10 @@ import { KeyframeEffect } from '../dom/KeyframeEffect';
6
6
  import { Element } from '../dom/Element';
7
7
  import { ElementEvent } from '../dom/interfaces';
8
8
  import { SHAPE } from '../types';
9
- import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils';
10
- import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
11
- import { globalContainer } from '../global-module';
9
+ import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils'; // import type { StylePropertyParser, StylePropertyUpdater } from '../property-handlers';
10
+ // import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
11
+
12
+ import { globalContainer, stylePropertyParserFactory, stylePropertyUpdaterFactory } from '../global-module';
12
13
  import { dirtifyToRoot } from '../services';
13
14
  var DEFAULT_STYLE_PROPS = {
14
15
  anchor: [0, 0, 0],
@@ -39,7 +40,13 @@ var DEFAULT_STYLE_PROPS = {
39
40
  var DisplayObject =
40
41
  /** @class */
41
42
  function (_super) {
42
- __extends(DisplayObject, _super);
43
+ __extends(DisplayObject, _super); // stylePropertyUpdaterFactory = globalContainer.get<
44
+ // <Key extends keyof StyleProps>(stylePropertyName: Key) => StylePropertyUpdater<any>[]
45
+ // >(StylePropertyUpdaterFactory);
46
+ // stylePropertyParserFactory = globalContainer.get<
47
+ // <Key extends keyof ParsedStyleProps>(stylePropertyName: Key) => StylePropertyParser<any, any>
48
+ // >(StylePropertyParserFactory);
49
+
43
50
 
44
51
  function DisplayObject(config) {
45
52
  var _a, _b, _c;
@@ -50,9 +57,7 @@ function (_super) {
50
57
  */
51
58
 
52
59
 
53
- _this.activeAnimations = [];
54
- _this.stylePropertyUpdaterFactory = globalContainer.get(StylePropertyUpdaterFactory);
55
- _this.stylePropertyParserFactory = globalContainer.get(StylePropertyParserFactory); // assign name, id to config
60
+ _this.activeAnimations = []; // assign name, id to config
56
61
  // eg. group.get('name')
57
62
 
58
63
  _this.config = config; // compatible with G 3.0
@@ -178,7 +183,8 @@ function (_super) {
178
183
 
179
184
 
180
185
  DisplayObject.prototype.parseStyleProperty = function (name, value) {
181
- var stylePropertyParser = this.stylePropertyParserFactory(name);
186
+ // const stylePropertyParser = this.stylePropertyParserFactory(name);
187
+ var stylePropertyParser = stylePropertyParserFactory[name];
182
188
 
183
189
  if (stylePropertyParser) {
184
190
  // @ts-ignore
@@ -191,9 +197,10 @@ function (_super) {
191
197
  DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
192
198
  var _this = this; // update property, which may cause AABB re-calc
193
199
  // @ts-ignore
200
+ // const stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
194
201
 
195
202
 
196
- var stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
203
+ var stylePropertyUpdaters = stylePropertyUpdaterFactory[name];
197
204
 
198
205
  if (stylePropertyUpdaters) {
199
206
  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>);
@@ -1,6 +1,6 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
2
  import { Line as LineUtil } from '@antv/g-math';
3
- import { SHAPE } from '../types';
3
+ import { SHAPE, LINE_CAP, LINE_JOIN } from '../types';
4
4
  import { DisplayObject } from './DisplayObject';
5
5
  import { Point } from '../shapes';
6
6
 
@@ -20,13 +20,12 @@ function (_super) {
20
20
  y1: 0,
21
21
  x2: 0,
22
22
  y2: 0,
23
- lineJoin: "miter"
24
- /* Miter */
25
- ,
26
- lineCap: "butt"
27
- /* Butt */
28
- ,
29
- lineWidth: 1
23
+ z1: 0,
24
+ z2: 0,
25
+ lineJoin: LINE_JOIN.Miter,
26
+ lineCap: LINE_CAP.Butt,
27
+ lineWidth: 1,
28
+ isBillboard: false
30
29
  }, style)
31
30
  }, rest)) || this;
32
31
  }
@@ -1,5 +1,5 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import { SHAPE } from '../types';
2
+ import { SHAPE, LINE_CAP, LINE_JOIN } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
  import { Point } from '../shapes';
5
5
  import { Cubic as CubicUtil } from '@antv/g-math';
@@ -18,12 +18,8 @@ function (_super) {
18
18
  type: SHAPE.Path,
19
19
  style: __assign({
20
20
  path: '',
21
- lineJoin: "miter"
22
- /* Miter */
23
- ,
24
- lineCap: "butt"
25
- /* Butt */
26
- ,
21
+ lineJoin: LINE_JOIN.Miter,
22
+ lineCap: LINE_CAP.Butt,
27
23
  lineWidth: 1
28
24
  }, style)
29
25
  }, rest)) || this;
@@ -1,6 +1,6 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
2
  import { Line as LineUtil } from '@antv/g-math';
3
- import { SHAPE } from '../types';
3
+ import { SHAPE, LINE_CAP, LINE_JOIN } from '../types';
4
4
  import { DisplayObject } from './DisplayObject';
5
5
  import { Point } from '../shapes';
6
6
 
@@ -17,12 +17,8 @@ function (_super) {
17
17
  type: SHAPE.Polyline,
18
18
  style: __assign({
19
19
  points: [],
20
- lineJoin: "miter"
21
- /* Miter */
22
- ,
23
- lineCap: "butt"
24
- /* Butt */
25
- ,
20
+ lineJoin: LINE_JOIN.Miter,
21
+ lineCap: LINE_CAP.Butt,
26
22
  lineWidth: 1
27
23
  }, style)
28
24
  }, rest)) || this;
@@ -1,5 +1,5 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import { SHAPE } from '../types';
2
+ import { SHAPE, LINE_JOIN, LINE_CAP } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
 
5
5
  var Text =
@@ -31,12 +31,8 @@ function (_super) {
31
31
  fill: '#000',
32
32
  letterSpacing: 0,
33
33
  lineHeight: 0,
34
- lineJoin: "miter"
35
- /* Miter */
36
- ,
37
- lineCap: "butt"
38
- /* Butt */
39
- ,
34
+ lineJoin: LINE_JOIN.Miter,
35
+ lineCap: LINE_CAP.Butt,
40
36
  lineWidth: 0,
41
37
  miterLimit: 10,
42
38
  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
@@ -110,7 +110,7 @@ function () {
110
110
  var capture = isBoolean(options) && options || isObject(options) && options.capture;
111
111
  var context = isFunction(listener) ? undefined : listener;
112
112
  type = capture ? type + "capture" : type;
113
- listener = isFunction(listener) ? listener : listener.handleEvent;
113
+ listener = isFunction(listener) ? listener : listener === null || listener === void 0 ? void 0 : listener.handleEvent;
114
114
  this.emitter.off(type, listener, context);
115
115
  return this;
116
116
  };
@@ -31,7 +31,11 @@ export declare enum ElementEvent {
31
31
  CHILD_REMOVED = "child-removed",
32
32
  MOUNTED = "mounted",
33
33
  UNMOUNTED = "unmounted",
34
- BOUNDS_CHANGED = "bounds-changed"
34
+ BOUNDS_CHANGED = "bounds-changed",
35
+ /**
36
+ * trigger when z-index changed
37
+ */
38
+ RENDER_ORDER_CHANGED = "render-order-changed"
35
39
  }
36
40
  export interface IEventTarget {
37
41
  emitter: EventEmitter;
@@ -29,4 +29,9 @@ export var ElementEvent;
29
29
  ElementEvent["MOUNTED"] = "mounted";
30
30
  ElementEvent["UNMOUNTED"] = "unmounted";
31
31
  ElementEvent["BOUNDS_CHANGED"] = "bounds-changed";
32
+ /**
33
+ * trigger when z-index changed
34
+ */
35
+
36
+ ElementEvent["RENDER_ORDER_CHANGED"] = "render-order-changed";
32
37
  })(ElementEvent || (ElementEvent = {}));
@@ -1,2 +1,6 @@
1
+ import type { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater } from './property-handlers';
1
2
  export declare const globalContainer: import("mana-syringe").Container;
3
+ export declare const stylePropertyParserFactory: Record<string, StylePropertyParser<any, any>>;
4
+ export declare const stylePropertyUpdaterFactory: Record<string, StylePropertyUpdater<any>[]>;
5
+ export declare const stylePropertyMergerFactory: Record<string, StylePropertyMerger<any, any>>;
2
6
  export declare const containerModule: import("mana-syringe").SyringeModule;
@@ -7,8 +7,14 @@ import { TextService } from './services/text';
7
7
  import { TextUpdater } from './services/aabb/TextUpdater';
8
8
  import { OffscreenCanvasCreator } from './services/text/OffscreenCanvasCreator';
9
9
  import { DefaultSceneGraphSelector, SceneGraphSelector, SceneGraphSelectorFactory } from './services/SceneGraphSelector';
10
- import { StylePropertyParser, StylePropertyMerger, StylePropertyUpdater, StylePropertyParserFactory, StylePropertyUpdaterFactory, StylePropertyMergerFactory, clampedMergeNumbers, parseNumber, mergeColors, parseColor, updateGeometry, updateLocalPosition, updateOffsetPath, updateClipPath, updateZIndex, updateOffsetDistance, updateOrigin, updateTransform, updateTransformOrigin, parseTransform, mergeTransforms, parsePath, parsePoints, mergePaths, mergeNumbers, mergeNumberLists, parseFilter, updateAnchor, parseLineDash } from './property-handlers';
10
+ import { // StylePropertyParserFactory,
11
+ // StylePropertyUpdaterFactory,
12
+ // StylePropertyMergerFactory,
13
+ clampedMergeNumbers, parseNumber, mergeColors, parseColor, updateGeometry, updateLocalPosition, updateOffsetPath, updateClipPath, updateZIndex, updateOffsetDistance, updateOrigin, updateTransform, updateTransformOrigin, parseTransform, mergeTransforms, parsePath, parsePoints, mergePaths, mergeNumbers, mergeNumberLists, parseFilter, updateAnchor, parseLineDash } from './property-handlers';
11
14
  export var globalContainer = GlobalContainer;
15
+ export var stylePropertyParserFactory = {};
16
+ export var stylePropertyUpdaterFactory = {};
17
+ export var stylePropertyMergerFactory = {};
12
18
  export var containerModule = Module(function (register) {
13
19
  decorate(injectable(), EventEmitter); // bind DisplayObject pool
14
20
 
@@ -56,83 +62,65 @@ export var containerModule = Module(function (register) {
56
62
  return cache[tagName];
57
63
  };
58
64
  }
59
- }); // bind style property handlers
60
-
61
- register({
62
- token: StylePropertyParserFactory,
63
- useFactory: function useFactory(context) {
64
- var cache = {};
65
- return function (propertyName) {
66
- if (!cache[propertyName]) {
67
- if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
68
- cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
69
- }
70
- }
71
-
72
- return cache[propertyName];
73
- };
74
- }
75
- });
76
- register({
77
- token: StylePropertyUpdaterFactory,
78
- useFactory: function useFactory(context) {
79
- var cache = {};
80
- return function (propertyName) {
81
- if (!cache[propertyName]) {
82
- if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
83
- cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
84
- }
85
- }
86
-
87
- return cache[propertyName];
88
- };
89
- }
90
- });
91
- register({
92
- token: StylePropertyMergerFactory,
93
- useFactory: function useFactory(context) {
94
- var cache = {};
95
- return function (propertyName) {
96
- if (!cache[propertyName]) {
97
- if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
98
- cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
99
- }
100
- }
101
-
102
- return cache[propertyName];
103
- };
104
- }
105
- });
65
+ }); // // bind style property handlers
66
+ // register({
67
+ // token: StylePropertyParserFactory,
68
+ // useFactory: (context) => {
69
+ // const cache = {};
70
+ // return (propertyName: string) => {
71
+ // if (!cache[propertyName]) {
72
+ // if (context.container.isBoundNamed(StylePropertyParser, propertyName)) {
73
+ // cache[propertyName] = context.container.getNamed(StylePropertyParser, propertyName);
74
+ // }
75
+ // }
76
+ // return cache[propertyName];
77
+ // };
78
+ // },
79
+ // });
80
+ // register({
81
+ // token: StylePropertyUpdaterFactory,
82
+ // useFactory: (context) => {
83
+ // const cache = {};
84
+ // return (propertyName: string) => {
85
+ // if (!cache[propertyName]) {
86
+ // if (context.container.isBoundNamed(StylePropertyUpdater, propertyName)) {
87
+ // cache[propertyName] = context.container.getAllNamed(StylePropertyUpdater, propertyName);
88
+ // }
89
+ // }
90
+ // return cache[propertyName];
91
+ // };
92
+ // },
93
+ // });
94
+ // register({
95
+ // token: StylePropertyMergerFactory,
96
+ // useFactory: (context) => {
97
+ // const cache = {};
98
+ // return (propertyName: string) => {
99
+ // if (!cache[propertyName]) {
100
+ // if (context.container.isBoundNamed(StylePropertyMerger, propertyName)) {
101
+ // cache[propertyName] = context.container.getNamed(StylePropertyMerger, propertyName);
102
+ // }
103
+ // }
104
+ // return cache[propertyName];
105
+ // };
106
+ // },
107
+ // });
106
108
 
107
109
  function addPropertyHandler(property, parser, merger, updater) {
108
110
  if (parser) {
109
- register({
110
- token: {
111
- token: StylePropertyParser,
112
- named: property
113
- },
114
- useValue: parser
115
- });
111
+ stylePropertyParserFactory[property] = parser; // register({ token: { token: StylePropertyParser, named: property }, useValue: parser });
116
112
  }
117
113
 
118
114
  if (merger) {
119
- register({
120
- token: {
121
- token: StylePropertyMerger,
122
- named: property
123
- },
124
- useValue: merger
125
- });
115
+ stylePropertyMergerFactory[property] = merger; // register({ token: { token: StylePropertyMerger, named: property }, useValue: merger });
126
116
  }
127
117
 
128
118
  if (updater) {
129
- register({
130
- token: {
131
- token: StylePropertyUpdater,
132
- named: property
133
- },
134
- useValue: updater
135
- });
119
+ if (!stylePropertyUpdaterFactory[property]) {
120
+ stylePropertyUpdaterFactory[property] = [];
121
+ }
122
+
123
+ stylePropertyUpdaterFactory[property].push(updater); // register({ token: { token: StylePropertyUpdater, named: property }, useValue: updater });
136
124
  }
137
125
  }
138
126
 
@@ -166,8 +154,7 @@ export var containerModule = Module(function (register) {
166
154
 
167
155
  addPropertyHandler('points', parsePoints, undefined, undefined); // update local position
168
156
 
169
- addPropertiesHandler(['x', 'y', 'points', 'path', 'x1', 'x2', 'y1', 'y2'], // ['x', 'y'],
170
- undefined, undefined, updateLocalPosition);
157
+ addPropertiesHandler(['x', 'y', 'z', 'points', 'path', 'x1', 'x2', 'y1', 'y2', 'z1', 'z2'], undefined, undefined, updateLocalPosition);
171
158
  addPropertyHandler('filter', parseFilter, undefined, undefined);
172
159
  addPropertyHandler('anchor', undefined, undefined, updateAnchor);
173
160
  });
@@ -1,4 +1,6 @@
1
- import { __decorate } from "tslib";
1
+ import { __decorate } from "tslib"; // import { vec3, mat4 } from 'gl-matrix';
2
+ // import { inject, singleton } from 'mana-syringe';
3
+
2
4
  import { vec3 } from 'gl-matrix';
3
5
  import { singleton } from 'mana-syringe';
4
6
  import { CullingStrategyContribution } from './CullingPlugin';