@antv/g 1.0.0-alpha.36 → 1.0.0-alpha.37

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 (92) hide show
  1. package/dist/index.umd.js +2 -2
  2. package/es/Canvas.d.ts +2 -1
  3. package/es/Canvas.js +8 -3
  4. package/es/DisplayObjectPool.d.ts +3 -3
  5. package/es/DisplayObjectPool.js +6 -6
  6. package/es/camera/Camera.js +28 -16
  7. package/es/components/Cullable.d.ts +1 -2
  8. package/es/components/Cullable.js +6 -14
  9. package/es/components/Geometry.d.ts +1 -2
  10. package/es/components/Geometry.js +3 -10
  11. package/es/components/Renderable.d.ts +1 -2
  12. package/es/components/Renderable.js +5 -13
  13. package/es/components/Sortable.d.ts +1 -2
  14. package/es/components/Sortable.js +3 -12
  15. package/es/components/Transform.d.ts +1 -2
  16. package/es/components/Transform.js +15 -22
  17. package/es/display-objects/DisplayObject.js +6 -9
  18. package/es/display-objects/HTML.js +1 -4
  19. package/es/dom/Element.d.ts +7 -0
  20. package/es/dom/Element.js +10 -12
  21. package/es/dom/EventTarget.d.ts +0 -3
  22. package/es/dom/EventTarget.js +0 -6
  23. package/es/dom/KeyframeEffect.d.ts +0 -1
  24. package/es/dom/Node.js +1 -0
  25. package/es/dom/interfaces.d.ts +0 -2
  26. package/es/global-module.js +8 -6
  27. package/es/index.d.ts +1 -4
  28. package/es/index.js +2 -9
  29. package/es/plugins/CullingPlugin.js +2 -3
  30. package/es/plugins/DirtyCheckPlugin.js +1 -2
  31. package/es/plugins/FrustumCullingStrategy.js +2 -3
  32. package/es/plugins/PrepareRendererPlugin.js +13 -15
  33. package/es/property-handlers/aabb.js +4 -4
  34. package/es/property-handlers/anchor.js +3 -4
  35. package/es/property-handlers/clipPath.js +2 -2
  36. package/es/property-handlers/index.d.ts +1 -0
  37. package/es/property-handlers/index.js +2 -1
  38. package/es/property-handlers/lineDash.d.ts +2 -0
  39. package/es/property-handlers/lineDash.js +8 -0
  40. package/es/property-handlers/zIndex.js +3 -4
  41. package/es/services/RenderingService.js +3 -5
  42. package/es/services/SceneGraphService.d.ts +0 -2
  43. package/es/services/SceneGraphService.js +45 -82
  44. package/es/types.d.ts +1 -0
  45. package/es/utils/math.d.ts +1 -0
  46. package/es/utils/math.js +25 -0
  47. package/lib/Canvas.d.ts +2 -1
  48. package/lib/Canvas.js +8 -4
  49. package/lib/DisplayObjectPool.d.ts +3 -3
  50. package/lib/DisplayObjectPool.js +6 -6
  51. package/lib/camera/Camera.js +27 -15
  52. package/lib/components/Cullable.d.ts +1 -2
  53. package/lib/components/Cullable.js +6 -15
  54. package/lib/components/Geometry.d.ts +1 -2
  55. package/lib/components/Geometry.js +3 -11
  56. package/lib/components/Renderable.d.ts +1 -2
  57. package/lib/components/Renderable.js +5 -14
  58. package/lib/components/Sortable.d.ts +1 -2
  59. package/lib/components/Sortable.js +3 -13
  60. package/lib/components/Transform.d.ts +1 -2
  61. package/lib/components/Transform.js +15 -24
  62. package/lib/display-objects/DisplayObject.js +6 -11
  63. package/lib/display-objects/HTML.js +1 -5
  64. package/lib/dom/Element.d.ts +7 -0
  65. package/lib/dom/Element.js +11 -12
  66. package/lib/dom/EventTarget.d.ts +0 -3
  67. package/lib/dom/EventTarget.js +0 -10
  68. package/lib/dom/KeyframeEffect.d.ts +0 -1
  69. package/lib/dom/Node.js +1 -0
  70. package/lib/dom/interfaces.d.ts +0 -2
  71. package/lib/global-module.js +7 -4
  72. package/lib/index.d.ts +1 -4
  73. package/lib/index.js +10 -28
  74. package/lib/plugins/CullingPlugin.js +2 -4
  75. package/lib/plugins/DirtyCheckPlugin.js +1 -3
  76. package/lib/plugins/FrustumCullingStrategy.js +2 -4
  77. package/lib/plugins/PrepareRendererPlugin.js +12 -14
  78. package/lib/property-handlers/aabb.js +4 -4
  79. package/lib/property-handlers/anchor.js +3 -5
  80. package/lib/property-handlers/clipPath.js +2 -2
  81. package/lib/property-handlers/index.d.ts +1 -0
  82. package/lib/property-handlers/index.js +13 -0
  83. package/lib/property-handlers/lineDash.d.ts +2 -0
  84. package/lib/property-handlers/lineDash.js +15 -0
  85. package/lib/property-handlers/zIndex.js +3 -5
  86. package/lib/services/RenderingService.js +3 -6
  87. package/lib/services/SceneGraphService.d.ts +0 -2
  88. package/lib/services/SceneGraphService.js +45 -85
  89. package/lib/types.d.ts +1 -0
  90. package/lib/utils/math.d.ts +1 -0
  91. package/lib/utils/math.js +27 -0
  92. package/package.json +3 -4
package/es/Canvas.d.ts CHANGED
@@ -15,7 +15,8 @@ export declare enum CanvasEvent {
15
15
  BEFORE_RENDER = "beforerender",
16
16
  AFTER_RENDER = "afterrender",
17
17
  BEFORE_DESTROY = "beforedestroy",
18
- AFTER_DESTROY = "afterdestroy"
18
+ AFTER_DESTROY = "afterdestroy",
19
+ RESIZE = "resize"
19
20
  }
20
21
  /**
21
22
  * can be treated like Window in DOM
package/es/Canvas.js CHANGED
@@ -11,7 +11,6 @@ import { containerModule as commonContainerModule } from './canvas-module';
11
11
  import { cancelAnimationFrame } from './utils/raf';
12
12
  import { Document, EventTarget, ElementEvent } from './dom';
13
13
  import { CustomElementRegistry } from './dom/CustomElementRegistry';
14
- import { Renderable } from './components';
15
14
  import { globalContainer } from './global-module';
16
15
  export var CanvasEvent;
17
16
 
@@ -21,6 +20,7 @@ export var CanvasEvent;
21
20
  CanvasEvent["AFTER_RENDER"] = "afterrender";
22
21
  CanvasEvent["BEFORE_DESTROY"] = "beforedestroy";
23
22
  CanvasEvent["AFTER_DESTROY"] = "afterdestroy";
23
+ CanvasEvent["RESIZE"] = "resize";
24
24
  })(CanvasEvent || (CanvasEvent = {}));
25
25
  /**
26
26
  * can be treated like Window in DOM
@@ -205,10 +205,15 @@ function (_super) {
205
205
  var projectionMode = camera.getProjectionMode();
206
206
 
207
207
  if (projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
208
- camera.setOrthographic(width / -2, width / 2, height / -2, height / 2, camera.getNear(), camera.getFar());
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());
209
209
  } else {
210
210
  camera.setAspect(width / height);
211
211
  }
212
+
213
+ this.emit(CanvasEvent.RESIZE, {
214
+ width: width,
215
+ height: height
216
+ });
212
217
  }; // proxy to document.documentElement
213
218
 
214
219
 
@@ -281,7 +286,7 @@ function (_super) {
281
286
  }
282
287
 
283
288
  this.getRoot().forEach(function (node) {
284
- var renderable = node.entity.getComponent(Renderable);
289
+ var renderable = node.renderable;
285
290
 
286
291
  if (renderable) {
287
292
  renderable.renderBoundsDirty = true;
@@ -1,7 +1,7 @@
1
1
  import type { DisplayObject } from './display-objects';
2
2
  export declare class DisplayObjectPool {
3
3
  private pool;
4
- getByName(name: string): DisplayObject;
5
- add(name: string, groupOrShape: DisplayObject): void;
6
- remove(name: string): void;
4
+ getByEntity(entity: number): DisplayObject;
5
+ add(entity: number, groupOrShape: DisplayObject): void;
6
+ remove(entity: number): void;
7
7
  }
@@ -8,16 +8,16 @@ function () {
8
8
  this.pool = {};
9
9
  }
10
10
 
11
- DisplayObjectPool.prototype.getByName = function (name) {
12
- return this.pool[name];
11
+ DisplayObjectPool.prototype.getByEntity = function (entity) {
12
+ return this.pool[entity];
13
13
  };
14
14
 
15
- DisplayObjectPool.prototype.add = function (name, groupOrShape) {
16
- this.pool[name] = groupOrShape;
15
+ DisplayObjectPool.prototype.add = function (entity, groupOrShape) {
16
+ this.pool[entity] = groupOrShape;
17
17
  };
18
18
 
19
- DisplayObjectPool.prototype.remove = function (name) {
20
- delete this.pool[name];
19
+ DisplayObjectPool.prototype.remove = function (entity) {
20
+ delete this.pool[entity];
21
21
  };
22
22
 
23
23
  DisplayObjectPool = __decorate([singleton()], DisplayObjectPool);
@@ -3,7 +3,7 @@ import { EventEmitter } from 'eventemitter3';
3
3
  import { mat3, mat4, quat, vec3, vec4 } from 'gl-matrix';
4
4
  import { Landmark } from './Landmark';
5
5
  import { Frustum } from '../shapes';
6
- import { createVec3, getAngle } from '../utils/math';
6
+ import { createVec3, getAngle, makePerspective } from '../utils/math';
7
7
  import { requestAnimationFrame, cancelAnimationFrame } from '../utils/raf';
8
8
  export var DefaultCamera = 'DefaultCamera';
9
9
  export var CAMERA_TYPE;
@@ -379,6 +379,8 @@ function (_super) {
379
379
 
380
380
  if (this.projectionMode === CAMERA_PROJECTION_MODE.ORTHOGRAPHIC) {
381
381
  this.setOrthographic(this.left, this.rright, this.top, this.bottom, this.near, this.far);
382
+ } else if (this.projectionMode === CAMERA_PROJECTION_MODE.PERSPECTIVE) {
383
+ this.setPerspective(this.near, this.far, this.fov, this.aspect);
382
384
  }
383
385
 
384
386
  return this;
@@ -389,21 +391,23 @@ function (_super) {
389
391
  this.fov = fov;
390
392
  this.near = near;
391
393
  this.far = far;
392
- this.aspect = aspect; // let top = this.near * Math.tan(DEG_2_RAD * 0.5 * this.fov) / this.zoom;
393
- // let height = 2 * top;
394
- // let width = this.aspect * height;
395
- // let left = -0.5 * width;
396
- // if (this.view !== undefined && this.view.enabled) {
397
- // const fullWidth = this.view.fullWidth;
398
- // const fullHeight = this.view.fullHeight;
399
- // left += this.view.offsetX * width / fullWidth;
400
- // top -= this.view.offsetY * height / fullHeight;
401
- // width *= this.view.width / fullWidth;
402
- // height *= this.view.height / fullHeight;
403
- // }
404
- // flip Y
405
-
406
- mat4.perspective(this.projectionMatrix, -this.fov * DEG_2_RAD, -this.aspect, this.near, this.far);
394
+ this.aspect = aspect;
395
+ var top = this.near * Math.tan(DEG_2_RAD * 0.5 * this.fov) / this.zoom;
396
+ var height = 2 * top;
397
+ var width = this.aspect * height;
398
+ var left = -0.5 * width;
399
+
400
+ if (this.view !== undefined && this.view.enabled) {
401
+ var fullWidth = this.view.fullWidth;
402
+ var fullHeight = this.view.fullHeight;
403
+ left += this.view.offsetX * width / fullWidth;
404
+ top -= this.view.offsetY * height / fullHeight;
405
+ width *= this.view.width / fullWidth;
406
+ height *= this.view.height / fullHeight;
407
+ } // flip Y
408
+
409
+
410
+ makePerspective(this.projectionMatrix, left, left + width, top - height, top, near, this.far);
407
411
  mat4.invert(this.projectionMatrixInverse, this.projectionMatrix);
408
412
  this.emit(CAMERA_EVENT.Updated);
409
413
  return this;
@@ -449,6 +453,14 @@ function (_super) {
449
453
 
450
454
 
451
455
  Camera.prototype.setPosition = function (x, y, z) {
456
+ if (y === void 0) {
457
+ y = 0;
458
+ }
459
+
460
+ if (z === void 0) {
461
+ z = 0;
462
+ }
463
+
452
464
  this._setPosition(x, y, z);
453
465
 
454
466
  this.setFocalPoint(this.focalPoint);
@@ -1,11 +1,10 @@
1
- import { Component } from '@antv/g-ecs';
2
1
  /**
3
2
  * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
4
3
  */
5
4
  export declare enum Strategy {
6
5
  Standard = 0
7
6
  }
8
- export declare class Cullable extends Component {
7
+ export declare class Cullable {
9
8
  static tag: string;
10
9
  strategy: Strategy;
11
10
  visibilityPlaneMask: number;
@@ -1,9 +1,6 @@
1
- import { __extends } from "tslib";
2
- import { Component } from '@antv/g-ecs';
3
1
  /**
4
2
  * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#changing-mesh-culling-strategy
5
3
  */
6
-
7
4
  export var Strategy;
8
5
 
9
6
  (function (Strategy) {
@@ -12,17 +9,12 @@ export var Strategy;
12
9
 
13
10
  var Cullable =
14
11
  /** @class */
15
- function (_super) {
16
- __extends(Cullable, _super);
17
-
12
+ function () {
18
13
  function Cullable() {
19
- var _this = _super !== null && _super.apply(this, arguments) || this;
20
-
21
- _this.strategy = Strategy.Standard;
22
- _this.visibilityPlaneMask = -1;
23
- _this.visible = true;
24
- _this.enable = true;
25
- return _this;
14
+ this.strategy = Strategy.Standard;
15
+ this.visibilityPlaneMask = -1;
16
+ this.visible = true;
17
+ this.enable = true;
26
18
  }
27
19
 
28
20
  Cullable.prototype.isCulled = function () {
@@ -31,6 +23,6 @@ function (_super) {
31
23
 
32
24
  Cullable.tag = 'c-cullable';
33
25
  return Cullable;
34
- }(Component);
26
+ }();
35
27
 
36
28
  export { Cullable };
@@ -1,6 +1,5 @@
1
- import { Component } from '@antv/g-ecs';
2
1
  import { AABB } from '../shapes';
3
- export declare class Geometry extends Component {
2
+ export declare class Geometry {
4
3
  static tag: string;
5
4
  /**
6
5
  * excluding all children
@@ -1,17 +1,10 @@
1
- import { __extends } from "tslib";
2
- import { Component } from '@antv/g-ecs';
3
-
4
1
  var Geometry =
5
2
  /** @class */
6
- function (_super) {
7
- __extends(Geometry, _super);
8
-
9
- function Geometry() {
10
- return _super !== null && _super.apply(this, arguments) || this;
11
- }
3
+ function () {
4
+ function Geometry() {}
12
5
 
13
6
  Geometry.tag = 'c-geometry';
14
7
  return Geometry;
15
- }(Component);
8
+ }();
16
9
 
17
10
  export { Geometry };
@@ -1,6 +1,5 @@
1
- import { Component } from '@antv/g-ecs';
2
1
  import { AABB } from '../shapes';
3
- export declare class Renderable extends Component {
2
+ export declare class Renderable {
4
3
  static tag: string;
5
4
  /**
6
5
  * aabb 应该存在 Renderable 而非 Geometry 中,原因包括:
@@ -1,26 +1,18 @@
1
- import { __extends } from "tslib";
2
- import { Component } from '@antv/g-ecs';
3
-
4
1
  var Renderable =
5
2
  /** @class */
6
- function (_super) {
7
- __extends(Renderable, _super);
8
-
3
+ function () {
9
4
  function Renderable() {
10
- var _this = _super !== null && _super.apply(this, arguments) || this;
11
-
12
- _this.boundsDirty = true;
13
- _this.renderBoundsDirty = true;
5
+ this.boundsDirty = true;
6
+ this.renderBoundsDirty = true;
14
7
  /**
15
8
  * dirty rectangle flag
16
9
  */
17
10
 
18
- _this.dirty = false;
19
- return _this;
11
+ this.dirty = false;
20
12
  }
21
13
 
22
14
  Renderable.tag = 'c-renderable';
23
15
  return Renderable;
24
- }(Component);
16
+ }();
25
17
 
26
18
  export { Renderable };
@@ -1,6 +1,5 @@
1
- import { Component } from '@antv/g-ecs';
2
1
  import type { INode } from '../dom/interfaces';
3
- export declare class Sortable extends Component {
2
+ export declare class Sortable {
4
3
  static tag: string;
5
4
  /**
6
5
  * need to re-sort
@@ -1,24 +1,15 @@
1
- import { __extends } from "tslib";
2
- import { Component } from '@antv/g-ecs';
3
-
4
1
  var Sortable =
5
2
  /** @class */
6
- function (_super) {
7
- __extends(Sortable, _super);
8
-
3
+ function () {
9
4
  function Sortable() {
10
- var _this = _super !== null && _super.apply(this, arguments) || this;
11
5
  /**
12
6
  * need to re-sort
13
7
  */
14
-
15
-
16
- _this.dirty = false;
17
- return _this;
8
+ this.dirty = false;
18
9
  }
19
10
 
20
11
  Sortable.tag = 'c-sortable';
21
12
  return Sortable;
22
- }(Component);
13
+ }();
23
14
 
24
15
  export { Sortable };
@@ -1,9 +1,8 @@
1
1
  import { mat4, vec3 } from 'gl-matrix';
2
- import { Component } from '@antv/g-ecs';
3
2
  /**
4
3
  * do RTS transformation for 2D/3D
5
4
  */
6
- export declare class Transform extends Component {
5
+ export declare class Transform {
7
6
  static tag: string;
8
7
  dirtyFlag: boolean;
9
8
  localDirtyFlag: boolean;
@@ -1,44 +1,37 @@
1
- import { __extends } from "tslib";
2
1
  import { mat4, quat, vec3 } from 'gl-matrix';
3
- import { Component } from '@antv/g-ecs';
4
2
  /**
5
3
  * do RTS transformation for 2D/3D
6
4
  */
7
5
 
8
6
  var Transform =
9
7
  /** @class */
10
- function (_super) {
11
- __extends(Transform, _super);
12
-
8
+ function () {
13
9
  function Transform() {
14
- var _this = _super !== null && _super.apply(this, arguments) || this;
15
-
16
- _this.dirtyFlag = false;
17
- _this.localDirtyFlag = false;
18
- _this.frozen = false;
19
- _this.graphDepth = 0;
10
+ this.dirtyFlag = false;
11
+ this.localDirtyFlag = false;
12
+ this.frozen = false;
13
+ this.graphDepth = 0;
20
14
  /**
21
15
  * local space RTS
22
16
  */
23
17
 
24
- _this.localPosition = vec3.fromValues(0, 0, 0);
25
- _this.localRotation = quat.fromValues(0, 0, 0, 1);
26
- _this.localScale = vec3.fromValues(1, 1, 1);
27
- _this.localTransform = mat4.create();
18
+ this.localPosition = vec3.fromValues(0, 0, 0);
19
+ this.localRotation = quat.fromValues(0, 0, 0, 1);
20
+ this.localScale = vec3.fromValues(1, 1, 1);
21
+ this.localTransform = mat4.create();
28
22
  /**
29
23
  * world space RTS
30
24
  */
31
25
 
32
- _this.position = vec3.fromValues(0, 0, 0);
33
- _this.rotation = quat.fromValues(0, 0, 0, 1);
34
- _this.scaling = vec3.fromValues(1, 1, 1);
35
- _this.worldTransform = mat4.create();
26
+ this.position = vec3.fromValues(0, 0, 0);
27
+ this.rotation = quat.fromValues(0, 0, 0, 1);
28
+ this.scaling = vec3.fromValues(1, 1, 1);
29
+ this.worldTransform = mat4.create();
36
30
  /**
37
31
  * the origin of scaling and rotation
38
32
  */
39
33
 
40
- _this.origin = vec3.fromValues(0, 0, 0);
41
- return _this; // /**
34
+ this.origin = vec3.fromValues(0, 0, 0); // /**
42
35
  // * apply lerp to RTS, which can be used in camera animation
43
36
  // *
44
37
  // * @see https://xiaoiver.github.io/coding/2018/12/28/Camera-%E8%AE%BE%E8%AE%A1-%E4%B8%80.html
@@ -67,6 +60,6 @@ function (_super) {
67
60
 
68
61
  Transform.tag = 'c-transform';
69
62
  return Transform;
70
- }(Component);
63
+ }();
71
64
 
72
65
  export { Transform };
@@ -7,9 +7,7 @@ import { Element } from '../dom/Element';
7
7
  import { ElementEvent } from '../dom/interfaces';
8
8
  import { SHAPE } from '../types';
9
9
  import { createVec3, fromRotationTranslationScale, getEuler, rad2deg } from '../utils';
10
- import { Cullable, Renderable } from '../components';
11
10
  import { StylePropertyParserFactory, StylePropertyUpdaterFactory } from '../property-handlers';
12
- import { dirtifyRenderable } from '../services';
13
11
  import { globalContainer } from '../global-module';
14
12
  var DEFAULT_STYLE_PROPS = {
15
13
  anchor: [0, 0, 0],
@@ -84,7 +82,7 @@ function (_super) {
84
82
  _this.initAttributes(_this.config.style); // insert this group into pool
85
83
 
86
84
 
87
- globalContainer.get(DisplayObjectPool).add(_this.entity.getName(), _this);
85
+ globalContainer.get(DisplayObjectPool).add(_this.entity, _this);
88
86
  return _this;
89
87
  }
90
88
 
@@ -92,7 +90,7 @@ function (_super) {
92
90
  _super.prototype.destroy.call(this); // remove from into pool
93
91
 
94
92
 
95
- globalContainer.get(DisplayObjectPool).remove(this.entity.getName()); // stop all active animations
93
+ globalContainer.get(DisplayObjectPool).remove(this.entity); // stop all active animations
96
94
 
97
95
  this.getAnimations().forEach(function (animation) {
98
96
  animation.cancel();
@@ -127,7 +125,7 @@ function (_super) {
127
125
  attributes = {};
128
126
  }
129
127
 
130
- var renderable = this.entity.getComponent(Renderable); // parse attributes first
128
+ var renderable = this.renderable; // parse attributes first
131
129
 
132
130
  for (var attributeName in attributes) {
133
131
  var value = attributes[attributeName];
@@ -211,8 +209,7 @@ function (_super) {
211
209
  DisplayObject.prototype.changeAttribute = function (name, value) {
212
210
  var _this = this;
213
211
 
214
- var entity = this.entity;
215
- var renderable = entity.getComponent(Renderable);
212
+ var renderable = this.renderable;
216
213
  var oldValue = this.attributes[name]; // @ts-ignore
217
214
 
218
215
  var oldParsedValue = this.parsedStyle[name]; // update value
@@ -225,7 +222,7 @@ function (_super) {
225
222
 
226
223
  if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
227
224
  this.attributes.clipPathTargets.forEach(function (target) {
228
- dirtifyRenderable(target);
225
+ target.emit(ElementEvent.BOUNDS_CHANGED, {});
229
226
  target.emit(ElementEvent.ATTRIBUTE_CHANGED, {
230
227
  attributeName: 'clipPath',
231
228
  oldValue: _this,
@@ -553,7 +550,7 @@ function (_super) {
553
550
  };
554
551
 
555
552
  DisplayObject.prototype.isVisible = function () {
556
- var cullable = this.entity.getComponent(Cullable);
553
+ var cullable = this.cullable;
557
554
  return this.style.visibility === 'visible' && (!cullable || cullable && !cullable.isCulled());
558
555
  };
559
556
  /**
@@ -1,7 +1,6 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
2
  import { SHAPE } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
- import { Cullable } from '../components';
5
4
  import { AABB } from '../shapes';
6
5
  import { mat4, vec3 } from 'gl-matrix';
7
6
  /**
@@ -27,9 +26,7 @@ function (_super) {
27
26
  }, style)
28
27
  }, rest)) || this;
29
28
 
30
- var cullable = _this.entity.getComponent(Cullable);
31
-
32
- cullable.enable = false;
29
+ _this.cullable.enable = false;
33
30
  return _this;
34
31
  }
35
32
  /**
@@ -1,4 +1,5 @@
1
1
  import { SceneGraphService } from '../services/SceneGraphService';
2
+ import { Cullable, Geometry, Renderable, Transform, Sortable } from '../components';
2
3
  import { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
4
  import { Node } from './Node';
4
5
  import { AABB, Rectangle } from '../shapes';
@@ -12,6 +13,12 @@ import type { DisplayObjectConfig, IEventTarget, IChildNode, IElement, INode } f
12
13
  export declare class Element<StyleProps extends BaseStyleProps = any, ParsedStyleProps extends ParsedBaseStyleProps = any> extends Node implements IElement<StyleProps, ParsedStyleProps> {
13
14
  static isElement(target: IEventTarget | INode | IElement): target is IElement;
14
15
  sceneGraphService: SceneGraphService;
16
+ entity: number;
17
+ renderable: Renderable;
18
+ cullable: Cullable;
19
+ transformable: Transform;
20
+ sortable: Sortable;
21
+ geometry: Geometry;
15
22
  constructor(config: DisplayObjectConfig<StyleProps>);
16
23
  /**
17
24
  * used with `getElementById()`
package/es/dom/Element.js CHANGED
@@ -5,6 +5,7 @@ import { Cullable, Geometry, Renderable, Transform, Sortable } from '../componen
5
5
  import { Node } from './Node';
6
6
  import { ElementEvent } from './interfaces';
7
7
  import { globalContainer } from '../global-module';
8
+ var entityCounter = 0;
8
9
  /**
9
10
  * Has following capabilities:
10
11
  * * Node insert/remove, eg. appendChild, removeChild, remove...
@@ -21,6 +22,12 @@ function (_super) {
21
22
  var _this = _super.call(this) || this;
22
23
 
23
24
  _this.sceneGraphService = globalContainer.get(SceneGraphService);
25
+ _this.entity = entityCounter++;
26
+ _this.renderable = new Renderable();
27
+ _this.cullable = new Cullable();
28
+ _this.transformable = new Transform();
29
+ _this.sortable = new Sortable();
30
+ _this.geometry = new Geometry();
24
31
  _this.scrollLeft = 0;
25
32
  _this.scrollTop = 0;
26
33
  /**
@@ -39,14 +46,7 @@ function (_super) {
39
46
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
40
47
  */
41
48
 
42
- _this.attributes = {}; // create entity with shape's name, unique ID
43
-
44
- var entity = _this.entity;
45
- entity.addComponent(Renderable);
46
- entity.addComponent(Cullable);
47
- entity.addComponent(Transform);
48
- entity.addComponent(Sortable);
49
- entity.addComponent(Geometry);
49
+ _this.attributes = {};
50
50
  return _this;
51
51
  }
52
52
 
@@ -188,8 +188,7 @@ function (_super) {
188
188
 
189
189
  if (destroy) {
190
190
  // this.removeChildren();
191
- child.entity.destroy(); // remove event listeners
192
-
191
+ // remove event listeners
193
192
  child.emitter.removeAllListeners();
194
193
  }
195
194
 
@@ -406,8 +405,7 @@ function (_super) {
406
405
  // destroy itself before remove
407
406
  this.emit(ElementEvent.DESTROY, {}); // remove from scenegraph first
408
407
 
409
- this.remove(false);
410
- this.entity.destroy(); // remove event listeners
408
+ this.remove(false); // remove event listeners
411
409
 
412
410
  this.emitter.removeAllListeners();
413
411
  this.destroyed = true;
@@ -1,4 +1,3 @@
1
- import { Entity } from '@antv/g-ecs';
2
1
  import { FederatedEvent } from './FederatedEvent';
3
2
  import type { IEventTarget } from './interfaces';
4
3
  export declare const DELEGATION_SPLITTER = ":";
@@ -12,8 +11,6 @@ export declare class EventTarget implements IEventTarget {
12
11
  * event emitter
13
12
  */
14
13
  emitter: import("eventemitter3")<string | symbol, any>;
15
- entity: Entity;
16
- constructor();
17
14
  /**
18
15
  * @deprecated
19
16
  * @alias addEventListener
@@ -1,10 +1,8 @@
1
1
  import { __read, __spreadArray } from "tslib";
2
2
  import { isBoolean, isFunction, isObject } from '@antv/util';
3
3
  import { EventEmitter } from 'eventemitter3';
4
- import { World } from '@antv/g-ecs';
5
4
  import { CustomEvent } from './CustomEvent';
6
5
  import { FederatedEvent } from './FederatedEvent';
7
- import { globalContainer } from '../global-module';
8
6
  export var DELEGATION_SPLITTER = ':';
9
7
  /**
10
8
  * Objects that can receive events and may have listeners for them.
@@ -20,10 +18,6 @@ function () {
20
18
  * event emitter
21
19
  */
22
20
  this.emitter = new EventEmitter();
23
- var world = globalContainer.get(World); // create entity with shape's name, unique ID
24
-
25
- var entity = world.createEntity();
26
- this.entity = entity;
27
21
  }
28
22
  /**
29
23
  * @deprecated
@@ -20,7 +20,6 @@ export declare function numericTimingToObject(timingInput: KeyframeEffectOptions
20
20
  export declare class KeyframeEffect {
21
21
  composite: CompositeOperation;
22
22
  iterationComposite: IterationCompositeOperation;
23
- pseudoElement: string | null;
24
23
  target: IElement | null;
25
24
  animation: Animation | null;
26
25
  timing: AnimationEffectTiming;
package/es/dom/Node.js CHANGED
@@ -115,6 +115,7 @@ function (_super) {
115
115
 
116
116
 
117
117
  Node.prototype.isEqualNode = function (otherNode) {
118
+ // TODO: compare 2 nodes, not sameness
118
119
  return this === otherNode;
119
120
  };
120
121
 
@@ -1,4 +1,3 @@
1
- import { Entity } from '@antv/g-ecs';
2
1
  import EventEmitter from 'eventemitter3';
3
2
  import type { AnimationTimeline } from './AnimationTimeline';
4
3
  import { BaseStyleProps, ParsedBaseStyleProps, SHAPE } from '../types';
@@ -35,7 +34,6 @@ export declare enum ElementEvent {
35
34
  BOUNDS_CHANGED = "bounds-changed"
36
35
  }
37
36
  export interface IEventTarget {
38
- entity: Entity;
39
37
  emitter: EventEmitter;
40
38
  on(type: string, listener: EventListenerOrEventListenerObject | ((...args: any[]) => void), options?: boolean | AddEventListenerOptions): this;
41
39
  addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): this;