@antv/g 5.0.24 → 5.1.0

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 (132) hide show
  1. package/dist/index.umd.min.js +2 -2
  2. package/es/Canvas.js +2 -0
  3. package/es/css/CSSProperty.d.ts +2 -1
  4. package/es/css/StyleValueRegistry.d.ts +2 -1
  5. package/es/css/StyleValueRegistry.js +68 -72
  6. package/es/css/parser/color.d.ts +1 -1
  7. package/es/css/parser/color.js +2 -2
  8. package/es/css/parser/dimension.js +5 -1
  9. package/es/css/parser/path.d.ts +2 -2
  10. package/es/css/parser/path.js +9 -2
  11. package/es/css/parser/points.d.ts +8 -1
  12. package/es/css/parser/points.js +33 -3
  13. package/es/css/parser/transform.js +1 -1
  14. package/es/css/properties/CSSPropertyClipPath.js +7 -1
  15. package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  16. package/es/css/properties/CSSPropertyLocalPosition.js +64 -20
  17. package/es/css/properties/CSSPropertyPath.d.ts +2 -2
  18. package/es/css/properties/CSSPropertyPath.js +7 -5
  19. package/es/css/properties/CSSPropertyPoints.js +3 -4
  20. package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
  21. package/es/css/properties/CSSPropertyTransform.js +76 -104
  22. package/es/display-objects/Circle.d.ts +4 -0
  23. package/es/display-objects/Circle.js +2 -0
  24. package/es/display-objects/DisplayObject.d.ts +1 -7
  25. package/es/display-objects/DisplayObject.js +6 -26
  26. package/es/display-objects/Ellipse.d.ts +4 -0
  27. package/es/display-objects/Ellipse.js +2 -0
  28. package/es/display-objects/Group.d.ts +4 -0
  29. package/es/display-objects/Group.js +2 -0
  30. package/es/display-objects/HTML.d.ts +4 -4
  31. package/es/display-objects/HTML.js +5 -3
  32. package/es/display-objects/Image.d.ts +4 -0
  33. package/es/display-objects/Image.js +2 -0
  34. package/es/display-objects/Line.js +2 -0
  35. package/es/display-objects/Path.d.ts +2 -2
  36. package/es/display-objects/Polygon.js +1 -1
  37. package/es/display-objects/Polyline.js +1 -1
  38. package/es/display-objects/Rect.d.ts +6 -2
  39. package/es/display-objects/Rect.js +2 -0
  40. package/es/display-objects/Text.d.ts +4 -0
  41. package/es/display-objects/Text.js +2 -0
  42. package/es/dom/Element.js +1 -0
  43. package/es/services/EventService.js +10 -2
  44. package/es/services/SceneGraphService.d.ts +2 -0
  45. package/es/services/SceneGraphService.js +9 -0
  46. package/es/services/aabb/CircleUpdater.d.ts +0 -2
  47. package/es/services/aabb/CircleUpdater.js +2 -6
  48. package/es/services/aabb/EllipseUpdater.d.ts +0 -2
  49. package/es/services/aabb/EllipseUpdater.js +2 -6
  50. package/es/services/aabb/LineUpdater.d.ts +0 -2
  51. package/es/services/aabb/LineUpdater.js +1 -3
  52. package/es/services/aabb/PathUpdater.d.ts +0 -2
  53. package/es/services/aabb/PathUpdater.js +1 -5
  54. package/es/services/aabb/PolylineUpdater.d.ts +0 -2
  55. package/es/services/aabb/PolylineUpdater.js +1 -3
  56. package/es/services/aabb/RectUpdater.d.ts +0 -2
  57. package/es/services/aabb/RectUpdater.js +1 -5
  58. package/es/services/aabb/TextUpdater.d.ts +7 -0
  59. package/es/services/aabb/TextUpdater.js +0 -4
  60. package/es/services/aabb/interfaces.d.ts +0 -3
  61. package/es/types.d.ts +6 -19
  62. package/es/types.js +1 -0
  63. package/es/utils/interpolation.js +2 -8
  64. package/es/utils/math.js +4 -3
  65. package/es/utils/path.d.ts +2 -2
  66. package/es/utils/path.js +61 -24
  67. package/lib/Canvas.js +2 -0
  68. package/lib/css/CSSProperty.d.ts +2 -1
  69. package/lib/css/StyleValueRegistry.d.ts +2 -1
  70. package/lib/css/StyleValueRegistry.js +67 -71
  71. package/lib/css/parser/color.d.ts +1 -1
  72. package/lib/css/parser/color.js +1 -1
  73. package/lib/css/parser/dimension.js +4 -0
  74. package/lib/css/parser/path.d.ts +2 -2
  75. package/lib/css/parser/path.js +9 -2
  76. package/lib/css/parser/points.d.ts +8 -1
  77. package/lib/css/parser/points.js +33 -3
  78. package/lib/css/parser/transform.js +1 -1
  79. package/lib/css/properties/CSSPropertyClipPath.js +8 -1
  80. package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
  81. package/lib/css/properties/CSSPropertyLocalPosition.js +65 -20
  82. package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
  83. package/lib/css/properties/CSSPropertyPath.js +7 -5
  84. package/lib/css/properties/CSSPropertyPoints.js +3 -4
  85. package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
  86. package/lib/css/properties/CSSPropertyTransform.js +75 -103
  87. package/lib/display-objects/Circle.d.ts +4 -0
  88. package/lib/display-objects/Circle.js +2 -0
  89. package/lib/display-objects/DisplayObject.d.ts +1 -7
  90. package/lib/display-objects/DisplayObject.js +6 -27
  91. package/lib/display-objects/Ellipse.d.ts +4 -0
  92. package/lib/display-objects/Ellipse.js +2 -0
  93. package/lib/display-objects/Group.d.ts +4 -0
  94. package/lib/display-objects/Group.js +2 -0
  95. package/lib/display-objects/HTML.d.ts +4 -4
  96. package/lib/display-objects/HTML.js +5 -3
  97. package/lib/display-objects/Image.d.ts +4 -0
  98. package/lib/display-objects/Image.js +2 -0
  99. package/lib/display-objects/Line.js +2 -0
  100. package/lib/display-objects/Path.d.ts +2 -2
  101. package/lib/display-objects/Polygon.js +1 -1
  102. package/lib/display-objects/Polyline.js +1 -1
  103. package/lib/display-objects/Rect.d.ts +6 -2
  104. package/lib/display-objects/Rect.js +2 -0
  105. package/lib/display-objects/Text.d.ts +4 -0
  106. package/lib/display-objects/Text.js +2 -0
  107. package/lib/dom/Element.js +1 -0
  108. package/lib/services/EventService.js +10 -2
  109. package/lib/services/SceneGraphService.d.ts +2 -0
  110. package/lib/services/SceneGraphService.js +12 -0
  111. package/lib/services/aabb/CircleUpdater.d.ts +0 -2
  112. package/lib/services/aabb/CircleUpdater.js +2 -6
  113. package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
  114. package/lib/services/aabb/EllipseUpdater.js +2 -6
  115. package/lib/services/aabb/LineUpdater.d.ts +0 -2
  116. package/lib/services/aabb/LineUpdater.js +1 -3
  117. package/lib/services/aabb/PathUpdater.d.ts +0 -2
  118. package/lib/services/aabb/PathUpdater.js +1 -5
  119. package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
  120. package/lib/services/aabb/PolylineUpdater.js +1 -3
  121. package/lib/services/aabb/RectUpdater.d.ts +0 -2
  122. package/lib/services/aabb/RectUpdater.js +1 -5
  123. package/lib/services/aabb/TextUpdater.d.ts +7 -0
  124. package/lib/services/aabb/TextUpdater.js +0 -4
  125. package/lib/services/aabb/interfaces.d.ts +0 -3
  126. package/lib/types.d.ts +6 -19
  127. package/lib/types.js +1 -0
  128. package/lib/utils/interpolation.js +2 -8
  129. package/lib/utils/math.js +4 -3
  130. package/lib/utils/path.d.ts +2 -2
  131. package/lib/utils/path.js +55 -24
  132. package/package.json +3 -3
@@ -51,112 +51,84 @@ function () {
51
51
  this.mixer = _parser.mergeTransforms;
52
52
  }
53
53
 
54
- CSSPropertyTransform.prototype.calculator = function (name, oldValue, newValue, object) {
55
- if (newValue instanceof _cssom.CSSKeywordValue) {
56
- newValue = [];
57
- } // const uniqTypes = uniq([
58
- // ...(oldValue || []).map(({ t }) => t),
59
- // ...(newValue || []).map(({ t }) => t),
60
- // ]);
54
+ CSSPropertyTransform.prototype.postProcessor = function (object) {
55
+ var _a = object.parsedStyle,
56
+ transform = _a.transform,
57
+ defX = _a.defX,
58
+ defY = _a.defY;
61
59
 
60
+ if (transform && transform.length) {
61
+ // reset transform
62
+ object.resetLocalTransform();
63
+ object.setLocalPosition(defX, defY);
64
+ transform.forEach(function (_a) {
65
+ var t = _a.t,
66
+ d = _a.d;
62
67
 
63
- newValue.forEach(function (transform) {
64
- var t = transform.t;
65
- var value = (newValue || []).find(function (o) {
66
- return o.t === t;
68
+ if (t === 'scale') {
69
+ // scale(1) scale(1, 1)
70
+ var newScale = d.map(function (s) {
71
+ return s.value;
72
+ }) || [1, 1];
73
+ object.scaleLocal(newScale[0], newScale[1], 1);
74
+ } else if (t === 'scalex') {
75
+ var newScale = d.map(function (s) {
76
+ return s.value;
77
+ }) || [1];
78
+ object.scaleLocal(newScale[0], 1, 1);
79
+ } else if (t === 'scaley') {
80
+ var newScale = d.map(function (s) {
81
+ return s.value;
82
+ }) || [1];
83
+ object.scaleLocal(1, newScale[0], 1);
84
+ } else if (t === 'scalez') {
85
+ var newScale = d.map(function (s) {
86
+ return s.value;
87
+ }) || [1];
88
+ object.scaleLocal(1, 1, newScale[0]);
89
+ } else if (t === 'scale3d') {
90
+ var newScale = d.map(function (s) {
91
+ return s.value;
92
+ }) || [1, 1, 1];
93
+ object.scaleLocal(newScale[0], newScale[1], newScale[2]);
94
+ } else if (t === 'translate') {
95
+ var newTranslation = d || [_cssom.Opx, _cssom.Opx];
96
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, 0);
97
+ } else if (t === 'translatex') {
98
+ var newTranslation = d || [_cssom.Opx];
99
+ object.translateLocal(newTranslation[0].value, 0, 0);
100
+ } else if (t === 'translatey') {
101
+ var newTranslation = d || [_cssom.Opx];
102
+ object.translateLocal(0, newTranslation[0].value, 0);
103
+ } else if (t === 'translatez') {
104
+ var newTranslation = d || [_cssom.Opx];
105
+ object.translateLocal(0, 0, newTranslation[0].value);
106
+ } else if (t === 'translate3d') {
107
+ var newTranslation = d || [_cssom.Opx, _cssom.Opx, _cssom.Opx];
108
+ object.translateLocal(newTranslation[0].value, newTranslation[1].value, newTranslation[2].value);
109
+ } else if (t === 'rotate') {
110
+ var newAngles = d || [_cssom.Odeg];
111
+ object.rotateLocal(0, 0, newAngles[0].value);
112
+ } else if (t === 'rotatex') {
113
+ var newAngles = d || [_cssom.Odeg];
114
+ object.rotateLocal(newAngles[0].value, 0, 0);
115
+ } else if (t === 'rotatey') {
116
+ var newAngles = d || [_cssom.Odeg];
117
+ object.rotateLocal(0, newAngles[0].value, 0);
118
+ } else if (t === 'rotatez') {
119
+ var newAngles = d || [_cssom.Odeg];
120
+ object.rotateLocal(0, 0, newAngles[0].value);
121
+ } else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
122
+ // const newAngles = value && value.d || [Odeg, Odeg, Odeg];
123
+ // const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
124
+ // object.rotateLocal(
125
+ // newAngles[0].value - oldAngles[0].value,
126
+ // newAngles[1].value - oldAngles[1].value,
127
+ // newAngles[2].value - oldAngles[2].value,
128
+ // );
129
+ }
67
130
  });
68
- var old = (oldValue || []).find(function (o) {
69
- return o.t === t;
70
- });
71
-
72
- if (t === 'scale') {
73
- // scale(1) scale(1, 1)
74
- var newScale = value && value.d && value.d.map(function (s) {
75
- return s.value;
76
- }) || [1, 1];
77
- var oldScale = old && old.d && old.d.map(function (s) {
78
- return s.value;
79
- }) || [1, 1];
80
- object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], 1);
81
- } else if (t === 'scalex') {
82
- var newScale = value && value.d && value.d.map(function (s) {
83
- return s.value;
84
- }) || [1];
85
- var oldScale = old && old.d && old.d.map(function (s) {
86
- return s.value;
87
- }) || [1];
88
- object.scaleLocal(newScale[0] / oldScale[0], 1, 1);
89
- } else if (t === 'scaley') {
90
- var newScale = value && value.d && value.d.map(function (s) {
91
- return s.value;
92
- }) || [1];
93
- var oldScale = old && old.d && old.d.map(function (s) {
94
- return s.value;
95
- }) || [1];
96
- object.scaleLocal(1, newScale[0] / oldScale[0], 1);
97
- } else if (t === 'scalez') {
98
- var newScale = value && value.d && value.d.map(function (s) {
99
- return s.value;
100
- }) || [1];
101
- var oldScale = old && old.d && old.d.map(function (s) {
102
- return s.value;
103
- }) || [1];
104
- object.scaleLocal(1, 1, newScale[0] / oldScale[0]);
105
- } else if (t === 'scale3d') {
106
- var newScale = value && value.d && value.d.map(function (s) {
107
- return s.value;
108
- }) || [1, 1, 1];
109
- var oldScale = old && old.d && old.d.map(function (s) {
110
- return s.value;
111
- }) || [1, 1, 1];
112
- object.scaleLocal(newScale[0] / oldScale[0], newScale[1] / oldScale[1], newScale[2] / oldScale[2]);
113
- } else if (t === 'translate') {
114
- var newTranslation = value && value.d || [_cssom.Opx, _cssom.Opx];
115
- var oldTranslation = old && old.d || [_cssom.Opx, _cssom.Opx];
116
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, 0);
117
- } else if (t === 'translatex') {
118
- var newTranslation = value && value.d || [_cssom.Opx];
119
- var oldTranslation = old && old.d || [_cssom.Opx];
120
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, 0, 0);
121
- } else if (t === 'translatey') {
122
- var newTranslation = value && value.d || [_cssom.Opx];
123
- var oldTranslation = old && old.d || [_cssom.Opx];
124
- object.translateLocal(0, newTranslation[0].value - oldTranslation[0].value, 0);
125
- } else if (t === 'translatez') {
126
- var newTranslation = value && value.d || [_cssom.Opx];
127
- var oldTranslation = old && old.d || [_cssom.Opx];
128
- object.translateLocal(0, 0, newTranslation[0].value - oldTranslation[0].value);
129
- } else if (t === 'translate3d') {
130
- var newTranslation = value && value.d || [_cssom.Opx, _cssom.Opx, _cssom.Opx];
131
- var oldTranslation = old && old.d || [_cssom.Opx, _cssom.Opx, _cssom.Opx];
132
- object.translateLocal(newTranslation[0].value - oldTranslation[0].value, newTranslation[1].value - oldTranslation[1].value, newTranslation[2].value - oldTranslation[2].value);
133
- } else if (t === 'rotate') {
134
- var newAngles = value && value.d || [_cssom.Odeg];
135
- var oldAngles = old && old.d || [_cssom.Odeg];
136
- object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
137
- } else if (t === 'rotatex') {
138
- var newAngles = value && value.d || [_cssom.Odeg];
139
- var oldAngles = old && old.d || [_cssom.Odeg];
140
- object.rotateLocal(newAngles[0].value - oldAngles[0].value, 0, 0);
141
- } else if (t === 'rotatey') {
142
- var newAngles = value && value.d || [_cssom.Odeg];
143
- var oldAngles = old && old.d || [_cssom.Odeg];
144
- object.rotateLocal(0, newAngles[0].value - oldAngles[0].value, 0);
145
- } else if (t === 'rotatez') {
146
- var newAngles = value && value.d || [_cssom.Odeg];
147
- var oldAngles = old && old.d || [_cssom.Odeg];
148
- object.rotateLocal(0, 0, newAngles[0].value - oldAngles[0].value);
149
- } else if (t === 'rotate3d') {// 暂不支持绕指定轴旋转
150
- // const newAngles = value && value.d || [Odeg, Odeg, Odeg];
151
- // const oldAngles = old && old.d || [Odeg, Odeg, Odeg];
152
- // object.rotateLocal(
153
- // newAngles[0].value - oldAngles[0].value,
154
- // newAngles[1].value - oldAngles[1].value,
155
- // newAngles[2].value - oldAngles[2].value,
156
- // );
157
- }
158
- });
159
- return newValue;
131
+ }
160
132
  };
161
133
 
162
134
  CSSPropertyTransform = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], CSSPropertyTransform);
@@ -3,9 +3,13 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface CircleStyleProps extends BaseStyleProps {
6
+ cx?: number | string;
7
+ cy?: number | string;
6
8
  r: number | string;
7
9
  }
8
10
  export interface ParsedCircleStyleProps extends ParsedBaseStyleProps {
11
+ cx: CSSUnitValue;
12
+ cy: CSSUnitValue;
9
13
  r: CSSUnitValue;
10
14
  }
11
15
  export declare class Circle extends DisplayObject<CircleStyleProps, ParsedCircleStyleProps> {
@@ -26,6 +26,8 @@ function (_super) {
26
26
  return _super.call(this, (0, _tslib.__assign)({
27
27
  type: _types.Shape.CIRCLE,
28
28
  style: (0, _tslib.__assign)({
29
+ cx: '',
30
+ cy: '',
29
31
  r: '',
30
32
  anchor: [0.5, 0.5],
31
33
  transformOrigin: 'center',
@@ -116,14 +116,8 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
116
116
  getLocalRotation(): quat;
117
117
  getLocalTransform(): mat4;
118
118
  getWorldTransform(): mat4;
119
+ setLocalTransform(transform: mat4): this;
119
120
  resetLocalTransform(): void;
120
- /**
121
- * sync style.x/y when local position changed
122
- *
123
- * Mixins may not declare private/protected properties
124
- * however, you can use ES2020 private fields
125
- */
126
- private syncLocalPosition;
127
121
  /**
128
122
  * returns an array of all Animation objects affecting this element
129
123
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
@@ -31,18 +31,14 @@ var _shapes = require("../shapes");
31
31
 
32
32
  var _interfaces2 = require("../css/interfaces");
33
33
 
34
- var _css = require("../css");
35
-
36
34
  var DEFAULT_STYLE_PROPS = {
37
- x: '',
38
- y: '',
39
- z: '',
40
35
  anchor: [0, 0],
41
36
  opacity: '',
42
37
  fillOpacity: '',
43
38
  strokeOpacity: '',
44
39
  fill: '',
45
40
  stroke: '',
41
+ transform: '',
46
42
  transformOrigin: '',
47
43
  visibility: '',
48
44
  pointerEvents: '',
@@ -307,7 +303,6 @@ function (_super) {
307
303
  }
308
304
 
309
305
  this.sceneGraphService.setPosition(this, (0, _utils.createVec3)(position, y, z));
310
- this.syncLocalPosition();
311
306
  return this;
312
307
  };
313
308
  /**
@@ -325,7 +320,6 @@ function (_super) {
325
320
  }
326
321
 
327
322
  this.sceneGraphService.setLocalPosition(this, (0, _utils.createVec3)(position, y, z));
328
- this.syncLocalPosition();
329
323
  return this;
330
324
  };
331
325
  /**
@@ -343,7 +337,6 @@ function (_super) {
343
337
  }
344
338
 
345
339
  this.sceneGraphService.translate(this, (0, _utils.createVec3)(position, y, z));
346
- this.syncLocalPosition();
347
340
  return this;
348
341
  };
349
342
  /**
@@ -361,7 +354,6 @@ function (_super) {
361
354
  }
362
355
 
363
356
  this.sceneGraphService.translateLocal(this, (0, _utils.createVec3)(position, y, z));
364
- this.syncLocalPosition();
365
357
  return this;
366
358
  };
367
359
 
@@ -520,26 +512,13 @@ function (_super) {
520
512
  return this.sceneGraphService.getWorldTransform(this);
521
513
  };
522
514
 
523
- DisplayObject.prototype.resetLocalTransform = function () {
524
- this.sceneGraphService.resetLocalTransform(this);
515
+ DisplayObject.prototype.setLocalTransform = function (transform) {
516
+ this.sceneGraphService.setLocalTransform(this, transform);
517
+ return this;
525
518
  };
526
- /**
527
- * sync style.x/y when local position changed
528
- *
529
- * Mixins may not declare private/protected properties
530
- * however, you can use ES2020 private fields
531
- */
532
-
533
-
534
- DisplayObject.prototype.syncLocalPosition = function () {
535
- var localPosition = this.getLocalPosition();
536
- this.attributes.x = localPosition[0];
537
- this.attributes.y = localPosition[1];
538
- this.attributes.z = localPosition[2]; // should not affect computed style
539
519
 
540
- this.parsedStyle.x = new _css.CSSUnitValue(this.attributes.x, 'px');
541
- this.parsedStyle.y = new _css.CSSUnitValue(this.attributes.y, 'px');
542
- this.parsedStyle.z = new _css.CSSUnitValue(this.attributes.z, 'px');
520
+ DisplayObject.prototype.resetLocalTransform = function () {
521
+ this.sceneGraphService.resetLocalTransform(this);
543
522
  }; // #endregion transformable
544
523
  // #region animatable
545
524
 
@@ -3,10 +3,14 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
3
3
  import { DisplayObject } from './DisplayObject';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface EllipseStyleProps extends BaseStyleProps {
6
+ cx?: number | string;
7
+ cy?: number | string;
6
8
  rx: number | string;
7
9
  ry: number | string;
8
10
  }
9
11
  export interface ParsedEllipseStyleProps extends ParsedBaseStyleProps {
12
+ cx: CSSUnitValue;
13
+ cy: CSSUnitValue;
10
14
  rx: CSSUnitValue;
11
15
  ry: CSSUnitValue;
12
16
  }
@@ -26,6 +26,8 @@ function (_super) {
26
26
  return _super.call(this, (0, _tslib.__assign)({
27
27
  type: _types.Shape.ELLIPSE,
28
28
  style: (0, _tslib.__assign)({
29
+ cx: '',
30
+ cy: '',
29
31
  rx: '',
30
32
  ry: '',
31
33
  anchor: [0.5, 0.5],
@@ -3,10 +3,14 @@ import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface GroupStyleProps extends BaseStyleProps {
6
+ x?: number | string;
7
+ y?: number | string;
6
8
  width?: number | string;
7
9
  height?: number | string;
8
10
  }
9
11
  export interface ParsedGroupStyleProps extends ParsedBaseStyleProps {
12
+ x: CSSUnitValue;
13
+ y: CSSUnitValue;
10
14
  width?: CSSUnitValue;
11
15
  height?: CSSUnitValue;
12
16
  }
@@ -36,6 +36,8 @@ function (_super) {
36
36
  return _super.call(this, (0, _tslib.__assign)({
37
37
  type: _types.Shape.GROUP,
38
38
  style: (0, _tslib.__assign)({
39
+ x: '',
40
+ y: '',
39
41
  width: '',
40
42
  height: ''
41
43
  }, style)
@@ -4,19 +4,19 @@ import type { DisplayObjectConfig } from '../dom';
4
4
  import { AABB } from '../shapes';
5
5
  import type { CSSUnitValue } from '../css';
6
6
  export interface HTMLStyleProps extends BaseStyleProps {
7
+ x?: number | string;
8
+ y?: number | string;
7
9
  innerHTML: string | HTMLElement;
8
10
  width: number;
9
11
  height: number;
10
- className?: string | string[];
11
- style?: string;
12
12
  }
13
13
  export interface ParsedHTMLStyleProps extends ParsedBaseStyleProps {
14
+ x: CSSUnitValue;
15
+ y: CSSUnitValue;
14
16
  $el: HTMLElement;
15
17
  innerHTML: string | HTMLElement;
16
18
  width: CSSUnitValue;
17
19
  height: CSSUnitValue;
18
- className?: string | string[];
19
- style?: string;
20
20
  }
21
21
  /**
22
22
  * HTML container
@@ -36,9 +36,11 @@ function (_super) {
36
36
  _this = _super.call(this, (0, _tslib.__assign)({
37
37
  type: _types.Shape.HTML,
38
38
  style: (0, _tslib.__assign)({
39
- innerHTML: '',
40
- className: '',
41
- style: ''
39
+ x: '',
40
+ y: '',
41
+ width: '',
42
+ height: '',
43
+ innerHTML: ''
42
44
  }, style)
43
45
  }, rest)) || this;
44
46
  _this.cullable.enable = false;
@@ -3,12 +3,16 @@ import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface ImageStyleProps extends BaseStyleProps {
6
+ x?: number | string;
7
+ y?: number | string;
6
8
  img?: string | HTMLImageElement;
7
9
  src?: string | HTMLImageElement;
8
10
  width?: number | string;
9
11
  height?: number | string;
10
12
  }
11
13
  export interface ParsedImageStyleProps extends ParsedBaseStyleProps {
14
+ x: CSSUnitValue;
15
+ y: CSSUnitValue;
12
16
  img?: string | HTMLImageElement;
13
17
  src?: string | HTMLImageElement;
14
18
  width?: CSSUnitValue;
@@ -26,6 +26,8 @@ function (_super) {
26
26
  return _super.call(this, (0, _tslib.__assign)({
27
27
  type: _types.Shape.IMAGE,
28
28
  style: (0, _tslib.__assign)({
29
+ x: '',
30
+ y: '',
29
31
  img: '',
30
32
  width: '',
31
33
  height: '',
@@ -47,6 +47,7 @@ function (_super) {
47
47
  }
48
48
 
49
49
  Line.prototype.getPoint = function (ratio) {
50
+ // TODO: account for z1/z2 in 3D line
50
51
  var _a = this.parsedStyle,
51
52
  x1 = _a.x1,
52
53
  y1 = _a.y1,
@@ -59,6 +60,7 @@ function (_super) {
59
60
  };
60
61
 
61
62
  Line.prototype.getTotalLength = function () {
63
+ // TODO: account for z1/z2 in 3D line
62
64
  var _a = this.parsedStyle,
63
65
  x1 = _a.x1,
64
66
  y1 = _a.y1,
@@ -4,8 +4,8 @@ import type { DisplayObjectConfig } from '../dom';
4
4
  import { Point } from '../shapes';
5
5
  import type { Rectangle } from '../shapes/Rectangle';
6
6
  export interface PathStyleProps extends BaseStyleProps {
7
- path?: string | PathCommand[];
8
- d?: string | PathCommand[];
7
+ path?: string | PathCommand[] | DisplayObject;
8
+ d?: string | PathCommand[] | DisplayObject;
9
9
  }
10
10
  export interface PathSegment {
11
11
  command: PathCommand[0];
@@ -26,7 +26,7 @@ function (_super) {
26
26
  return _super.call(this, (0, _tslib.__assign)({
27
27
  type: _types.Shape.POLYGON,
28
28
  style: (0, _tslib.__assign)({
29
- points: [],
29
+ points: '',
30
30
  miterLimit: 4,
31
31
  lineWidth: 1
32
32
  }, style)
@@ -30,7 +30,7 @@ function (_super) {
30
30
  return _super.call(this, (0, _tslib.__assign)({
31
31
  type: _types.Shape.POLYLINE,
32
32
  style: (0, _tslib.__assign)({
33
- points: [],
33
+ points: '',
34
34
  lineWidth: 1,
35
35
  miterLimit: 4
36
36
  }, style)
@@ -3,13 +3,17 @@ import { DisplayObject } from './DisplayObject';
3
3
  import type { DisplayObjectConfig } from '../dom';
4
4
  import type { CSSUnitValue } from '../css';
5
5
  export interface RectStyleProps extends BaseStyleProps {
6
+ x?: number | string;
7
+ y?: number | string;
6
8
  width: number | string;
7
9
  height: number | string;
8
10
  radius?: number | string;
9
11
  }
10
12
  export interface ParsedRectStyleProps extends ParsedBaseStyleProps {
11
- width?: CSSUnitValue;
12
- height?: CSSUnitValue;
13
+ x: CSSUnitValue;
14
+ y: CSSUnitValue;
15
+ width: CSSUnitValue;
16
+ height: CSSUnitValue;
13
17
  radius?: CSSUnitValue;
14
18
  }
15
19
  export declare class Rect extends DisplayObject<RectStyleProps, ParsedRectStyleProps> {
@@ -26,6 +26,8 @@ function (_super) {
26
26
  return _super.call(this, (0, _tslib.__assign)({
27
27
  type: _types.Shape.RECT,
28
28
  style: (0, _tslib.__assign)({
29
+ x: '',
30
+ y: '',
29
31
  width: '',
30
32
  height: '',
31
33
  radius: '',
@@ -4,6 +4,8 @@ import type { BaseStyleProps, ParsedBaseStyleProps } from '../types';
4
4
  import { DisplayObject } from './DisplayObject';
5
5
  import type { CSSUnitValue, CSSGlobalKeywords, CSSKeywordValue } from '../css';
6
6
  export interface TextStyleProps extends BaseStyleProps {
7
+ x?: number | string;
8
+ y?: number | string;
7
9
  text: string;
8
10
  /** 设置文本内容的当前对齐方式 */
9
11
  textAlign?: CSSGlobalKeywords | 'start' | 'center' | 'end' | 'left' | 'right';
@@ -31,6 +33,8 @@ export interface TextStyleProps extends BaseStyleProps {
31
33
  dy?: number | string;
32
34
  }
33
35
  export interface ParsedTextStyleProps extends ParsedBaseStyleProps {
36
+ x: CSSUnitValue;
37
+ y: CSSUnitValue;
34
38
  text: string;
35
39
  /** 设置文本内容的当前对齐方式 */
36
40
  textAlign?: CSSKeywordValue;
@@ -31,6 +31,8 @@ function (_super) {
31
31
  _this = _super.call(this, (0, _tslib.__assign)({
32
32
  type: _types.Shape.TEXT,
33
33
  style: (0, _tslib.__assign)({
34
+ x: '',
35
+ y: '',
34
36
  text: '',
35
37
  fontSize: '',
36
38
  fontFamily: '',
@@ -556,6 +556,7 @@ function (_super) {
556
556
 
557
557
 
558
558
  Element.prototype.removeAttribute = function (attributeName) {
559
+ this.setAttribute(attributeName, null);
559
560
  delete this.attributes[attributeName];
560
561
  };
561
562
  /**
@@ -376,7 +376,11 @@ function (_super) {
376
376
  while (leaveEvent.target && !e.composedPath().includes(leaveEvent.target)) {
377
377
  leaveEvent.currentTarget = leaveEvent.target;
378
378
  this.notifyTarget(leaveEvent);
379
- if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
379
+
380
+ if (isMouse) {
381
+ // console.error(leaveEvent.target);
382
+ this.notifyTarget(leaveEvent, 'mouseleave');
383
+ }
380
384
 
381
385
  if (_Node.Node.isNode(leaveEvent.target)) {
382
386
  leaveEvent.target = leaveEvent.target.parentNode;
@@ -481,7 +485,11 @@ function (_super) {
481
485
  while (leaveEvent.target && leaveEvent.target !== (_Node.Node.isNode(this.rootTarget) && this.rootTarget.parentNode)) {
482
486
  leaveEvent.currentTarget = leaveEvent.target;
483
487
  this.notifyTarget(leaveEvent);
484
- if (isMouse) this.notifyTarget(leaveEvent, 'mouseleave');
488
+
489
+ if (isMouse) {
490
+ // console.error(leaveEvent.target, 'out');
491
+ this.notifyTarget(leaveEvent, 'mouseleave');
492
+ }
485
493
 
486
494
  if (_Node.Node.isNode(leaveEvent.target)) {
487
495
  leaveEvent.target = leaveEvent.target.parentNode;
@@ -35,6 +35,7 @@ export interface SceneGraphService {
35
35
  getLocalRotation: (element: INode) => quat;
36
36
  getWorldTransform: (element: INode, transform?: Transform) => mat4;
37
37
  getLocalTransform: (element: INode, transform?: Transform) => mat4;
38
+ setLocalTransform: (element: INode, transform: mat4) => void;
38
39
  resetLocalTransform: (element: INode) => void;
39
40
  getBounds: (element: INode, render?: boolean) => AABB;
40
41
  getLocalBounds: (element: INode, render?: boolean) => AABB;
@@ -129,6 +130,7 @@ export declare class DefaultSceneGraphService implements SceneGraphService {
129
130
  getLocalRotation(element: INode): import("gl-matrix").vec4;
130
131
  getLocalScale(element: INode): vec3;
131
132
  getLocalTransform(element: INode): mat4;
133
+ setLocalTransform(element: INode, transform: mat4): void;
132
134
  resetLocalTransform(element: INode): void;
133
135
  private getTransformedGeometryBounds;
134
136
  /**
@@ -607,6 +607,18 @@ function () {
607
607
  return transform.localTransform;
608
608
  };
609
609
 
610
+ DefaultSceneGraphService.prototype.setLocalTransform = function (element, transform) {
611
+ var t = _glMatrix.mat4.getTranslation(_glMatrix.vec3.create(), transform);
612
+
613
+ var r = _glMatrix.mat4.getRotation(_glMatrix.quat.create(), transform);
614
+
615
+ var s = _glMatrix.mat4.getScaling(_glMatrix.vec3.create(), transform);
616
+
617
+ this.setLocalScale(element, s);
618
+ this.setLocalPosition(element, t);
619
+ this.setLocalRotation(element, r);
620
+ };
621
+
610
622
  DefaultSceneGraphService.prototype.resetLocalTransform = function (element) {
611
623
  this.setLocalScale(element, [1, 1, 1]);
612
624
  this.setLocalPosition(element, [0, 0, 0]);
@@ -4,7 +4,5 @@ export declare class CircleUpdater implements GeometryAABBUpdater<ParsedCircleSt
4
4
  update(parsedStyle: ParsedCircleStyleProps, object: Circle): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }
@@ -19,16 +19,12 @@ function () {
19
19
  function CircleUpdater() {}
20
20
 
21
21
  CircleUpdater.prototype.update = function (parsedStyle, object) {
22
- var r = parsedStyle.r,
23
- x = parsedStyle.x,
24
- y = parsedStyle.y;
22
+ var r = parsedStyle.r;
25
23
  var width = r.value * 2;
26
24
  var height = r.value * 2;
27
25
  return {
28
26
  width: width,
29
- height: height,
30
- x: x.value || 0,
31
- y: y.value || 0
27
+ height: height
32
28
  };
33
29
  };
34
30
 
@@ -4,7 +4,5 @@ export declare class EllipseUpdater implements GeometryAABBUpdater<ParsedEllipse
4
4
  update(parsedStyle: ParsedEllipseStyleProps, object: Ellipse): {
5
5
  width: number;
6
6
  height: number;
7
- x: number;
8
- y: number;
9
7
  };
10
8
  }