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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/es/Canvas.d.ts +40 -18
  2. package/es/Canvas.js +121 -65
  3. package/es/DisplayObjectPool.d.ts +2 -1
  4. package/es/DisplayObjectPool.js +4 -0
  5. package/{lib → es/camera}/Camera.d.ts +6 -3
  6. package/es/{Camera.js → camera/Camera.js} +22 -16
  7. package/es/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
  8. package/es/{Landmark.js → camera/Landmark.js} +1 -1
  9. package/es/camera/index.d.ts +2 -0
  10. package/es/camera/index.js +2 -0
  11. package/es/components/Cullable.js +1 -1
  12. package/es/components/Geometry.d.ts +8 -1
  13. package/es/components/Renderable.d.ts +9 -8
  14. package/es/components/Renderable.js +2 -6
  15. package/es/components/Sortable.d.ts +6 -2
  16. package/es/display-objects/Circle.d.ts +2 -3
  17. package/es/display-objects/Circle.js +2 -5
  18. package/es/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
  19. package/es/{CustomElement.js → display-objects/CustomElement.js} +22 -12
  20. package/{lib → es/display-objects}/DisplayObject.d.ts +136 -141
  21. package/es/{DisplayObject.js → display-objects/DisplayObject.js} +408 -292
  22. package/es/display-objects/Ellipse.d.ts +2 -3
  23. package/es/display-objects/Ellipse.js +2 -5
  24. package/es/display-objects/Group.d.ts +2 -1
  25. package/es/display-objects/Group.js +13 -5
  26. package/es/display-objects/HTML.d.ts +2 -2
  27. package/es/display-objects/HTML.js +4 -7
  28. package/es/display-objects/Image.d.ts +2 -2
  29. package/es/display-objects/Image.js +2 -6
  30. package/es/display-objects/Line.d.ts +2 -2
  31. package/es/display-objects/Line.js +8 -8
  32. package/es/display-objects/Path.d.ts +3 -2
  33. package/es/display-objects/Path.js +8 -8
  34. package/es/display-objects/Polygon.d.ts +2 -2
  35. package/es/display-objects/Polygon.js +2 -6
  36. package/es/display-objects/Polyline.d.ts +2 -2
  37. package/es/display-objects/Polyline.js +8 -8
  38. package/es/display-objects/Rect.d.ts +2 -2
  39. package/es/display-objects/Rect.js +2 -6
  40. package/es/display-objects/Text.d.ts +2 -3
  41. package/es/display-objects/Text.js +8 -7
  42. package/es/display-objects/index.d.ts +2 -0
  43. package/es/display-objects/index.js +2 -0
  44. package/es/{Animation.d.ts → dom/Animation.d.ts} +3 -3
  45. package/es/{Animation.js → dom/Animation.js} +2 -3
  46. package/{lib → es/dom}/AnimationEffectTiming.d.ts +2 -0
  47. package/es/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -2
  48. package/es/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
  49. package/es/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
  50. package/es/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
  51. package/es/{Timeline.js → dom/AnimationTimeline.js} +1 -1
  52. package/es/dom/CustomElementRegistry.d.ts +15 -0
  53. package/es/dom/CustomElementRegistry.js +40 -0
  54. package/{lib → es/dom}/CustomEvent.d.ts +1 -1
  55. package/es/{CustomEvent.js → dom/CustomEvent.js} +1 -1
  56. package/es/dom/Document.d.ts +36 -17
  57. package/es/dom/Document.js +98 -14
  58. package/es/dom/Element.d.ts +71 -92
  59. package/es/dom/Element.js +179 -195
  60. package/es/dom/EventTarget.d.ts +11 -6
  61. package/es/dom/EventTarget.js +12 -4
  62. package/es/dom/FederatedEvent.d.ts +15 -7
  63. package/es/dom/FederatedEvent.js +33 -0
  64. package/es/dom/FederatedMouseEvent.d.ts +1 -1
  65. package/es/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
  66. package/es/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
  67. package/es/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
  68. package/es/{KeyframeList.js → dom/KeyframeList.js} +0 -0
  69. package/es/dom/Node.d.ts +38 -23
  70. package/es/dom/Node.js +37 -33
  71. package/es/dom/index.d.ts +15 -2
  72. package/es/dom/index.js +16 -3
  73. package/es/dom/interfaces.d.ts +301 -0
  74. package/es/dom/interfaces.js +1 -0
  75. package/es/global-module.d.ts +0 -2
  76. package/es/global-module.js +31 -29
  77. package/es/index.d.ts +7 -14
  78. package/es/index.js +8 -15
  79. package/es/plugins/CullingPlugin.d.ts +2 -2
  80. package/es/plugins/CullingPlugin.js +13 -16
  81. package/es/plugins/DirtyCheckPlugin.d.ts +1 -1
  82. package/es/plugins/DirtyCheckPlugin.js +8 -7
  83. package/es/plugins/EventPlugin.js +52 -31
  84. package/es/plugins/FrustumCullingStrategy.d.ts +1 -1
  85. package/es/plugins/FrustumCullingStrategy.js +5 -4
  86. package/es/plugins/PrepareRendererPlugin.d.ts +0 -1
  87. package/es/plugins/PrepareRendererPlugin.js +42 -38
  88. package/es/property-handlers/aabb.d.ts +2 -3
  89. package/es/property-handlers/aabb.js +29 -21
  90. package/es/property-handlers/anchor.d.ts +3 -0
  91. package/es/property-handlers/anchor.js +21 -0
  92. package/es/property-handlers/clipPath.d.ts +1 -1
  93. package/es/property-handlers/clipPath.js +3 -4
  94. package/es/property-handlers/color.d.ts +1 -1
  95. package/es/property-handlers/dimension.d.ts +1 -1
  96. package/es/property-handlers/dimension.js +6 -9
  97. package/es/property-handlers/filter.d.ts +1 -1
  98. package/es/property-handlers/index.d.ts +5 -4
  99. package/es/property-handlers/index.js +1 -0
  100. package/es/property-handlers/localPosition.d.ts +1 -1
  101. package/es/property-handlers/localPosition.js +1 -6
  102. package/es/property-handlers/offsetDistance.d.ts +1 -1
  103. package/es/property-handlers/offsetPath.d.ts +1 -1
  104. package/es/property-handlers/origin.d.ts +1 -1
  105. package/es/property-handlers/origin.js +9 -2
  106. package/es/property-handlers/path.d.ts +2 -2
  107. package/es/property-handlers/path.js +8 -4
  108. package/es/property-handlers/points.d.ts +1 -1
  109. package/es/property-handlers/transform.d.ts +1 -1
  110. package/es/property-handlers/zIndex.d.ts +1 -1
  111. package/es/services/ContextService.d.ts +3 -2
  112. package/es/services/EventService.d.ts +18 -13
  113. package/es/services/EventService.js +604 -384
  114. package/es/services/RenderingContext.d.ts +1 -1
  115. package/es/services/RenderingService.d.ts +23 -29
  116. package/es/services/RenderingService.js +63 -54
  117. package/es/services/SceneGraphSelector.d.ts +7 -7
  118. package/es/services/SceneGraphSelector.js +10 -6
  119. package/es/services/SceneGraphService.d.ts +73 -78
  120. package/es/services/SceneGraphService.js +165 -78
  121. package/es/services/aabb/PathUpdater.d.ts +1 -1
  122. package/es/services/aabb/RectUpdater.d.ts +2 -2
  123. package/es/services/aabb/interfaces.d.ts +1 -1
  124. package/es/shapes/Point.d.ts +4 -0
  125. package/es/shapes/Polygon.d.ts +9 -0
  126. package/es/shapes/Polygon.js +62 -0
  127. package/es/shapes/index.d.ts +1 -0
  128. package/es/shapes/index.js +2 -1
  129. package/es/types.d.ts +18 -6
  130. package/es/utils/animation.d.ts +1 -2
  131. package/es/utils/animation.js +5 -10
  132. package/es/utils/canvas.d.ts +1 -1
  133. package/es/utils/custom-easing.d.ts +3 -2
  134. package/es/utils/custom-easing.js +12 -6
  135. package/es/utils/event.js +1 -1
  136. package/es/utils/index.d.ts +1 -0
  137. package/es/utils/index.js +2 -1
  138. package/es/utils/interpolation.d.ts +3 -4
  139. package/es/utils/interpolation.js +0 -16
  140. package/es/utils/path.d.ts +2 -2
  141. package/lib/Canvas.d.ts +40 -18
  142. package/lib/Canvas.js +131 -74
  143. package/lib/DisplayObjectPool.d.ts +2 -1
  144. package/lib/DisplayObjectPool.js +4 -0
  145. package/{es → lib/camera}/Camera.d.ts +6 -3
  146. package/lib/{Camera.js → camera/Camera.js} +25 -20
  147. package/lib/{Landmark.d.ts → camera/Landmark.d.ts} +2 -2
  148. package/lib/{Landmark.js → camera/Landmark.js} +2 -3
  149. package/lib/camera/index.d.ts +2 -0
  150. package/lib/camera/index.js +31 -0
  151. package/lib/components/Cullable.js +1 -1
  152. package/lib/components/Geometry.d.ts +8 -1
  153. package/lib/components/Renderable.d.ts +9 -8
  154. package/lib/components/Renderable.js +2 -6
  155. package/lib/components/Sortable.d.ts +6 -2
  156. package/lib/display-objects/Circle.d.ts +2 -3
  157. package/lib/display-objects/Circle.js +3 -6
  158. package/lib/{CustomElement.d.ts → display-objects/CustomElement.d.ts} +1 -1
  159. package/lib/{CustomElement.js → display-objects/CustomElement.js} +22 -12
  160. package/{es → lib/display-objects}/DisplayObject.d.ts +136 -141
  161. package/lib/{DisplayObject.js → display-objects/DisplayObject.js} +418 -299
  162. package/lib/display-objects/Ellipse.d.ts +2 -3
  163. package/lib/display-objects/Ellipse.js +3 -6
  164. package/lib/display-objects/Group.d.ts +2 -1
  165. package/lib/display-objects/Group.js +12 -4
  166. package/lib/display-objects/HTML.d.ts +2 -2
  167. package/lib/display-objects/HTML.js +4 -7
  168. package/lib/display-objects/Image.d.ts +2 -2
  169. package/lib/display-objects/Image.js +2 -6
  170. package/lib/display-objects/Line.d.ts +2 -2
  171. package/lib/display-objects/Line.js +8 -8
  172. package/lib/display-objects/Path.d.ts +3 -2
  173. package/lib/display-objects/Path.js +8 -8
  174. package/lib/display-objects/Polygon.d.ts +2 -2
  175. package/lib/display-objects/Polygon.js +2 -6
  176. package/lib/display-objects/Polyline.d.ts +2 -2
  177. package/lib/display-objects/Polyline.js +8 -8
  178. package/lib/display-objects/Rect.d.ts +2 -2
  179. package/lib/display-objects/Rect.js +2 -6
  180. package/lib/display-objects/Text.d.ts +2 -3
  181. package/lib/display-objects/Text.js +9 -8
  182. package/lib/display-objects/index.d.ts +2 -0
  183. package/lib/display-objects/index.js +26 -0
  184. package/lib/{Animation.d.ts → dom/Animation.d.ts} +3 -3
  185. package/lib/{Animation.js → dom/Animation.js} +2 -3
  186. package/{es → lib/dom}/AnimationEffectTiming.d.ts +2 -0
  187. package/lib/{AnimationEffectTiming.js → dom/AnimationEffectTiming.js} +3 -3
  188. package/lib/{AnimationEvent.d.ts → dom/AnimationEvent.d.ts} +3 -2
  189. package/lib/{AnimationEvent.js → dom/AnimationEvent.js} +1 -1
  190. package/lib/{Timeline.d.ts → dom/AnimationTimeline.d.ts} +1 -1
  191. package/lib/{Timeline.js → dom/AnimationTimeline.js} +1 -1
  192. package/lib/dom/CustomElementRegistry.d.ts +15 -0
  193. package/lib/dom/CustomElementRegistry.js +48 -0
  194. package/{es → lib/dom}/CustomEvent.d.ts +1 -1
  195. package/lib/{CustomEvent.js → dom/CustomEvent.js} +1 -1
  196. package/lib/dom/Document.d.ts +36 -17
  197. package/lib/dom/Document.js +99 -15
  198. package/lib/dom/Element.d.ts +71 -92
  199. package/lib/dom/Element.js +180 -198
  200. package/lib/dom/EventTarget.d.ts +11 -6
  201. package/lib/dom/EventTarget.js +20 -10
  202. package/lib/dom/FederatedEvent.d.ts +15 -7
  203. package/lib/dom/FederatedEvent.js +33 -0
  204. package/lib/dom/FederatedMouseEvent.d.ts +1 -1
  205. package/lib/{KeyframeEffect.d.ts → dom/KeyframeEffect.d.ts} +16 -5
  206. package/lib/{KeyframeEffect.js → dom/KeyframeEffect.js} +50 -4
  207. package/lib/{KeyframeList.d.ts → dom/KeyframeList.d.ts} +1 -1
  208. package/lib/{KeyframeList.js → dom/KeyframeList.js} +0 -0
  209. package/lib/dom/Node.d.ts +38 -23
  210. package/lib/dom/Node.js +37 -33
  211. package/lib/dom/index.d.ts +15 -2
  212. package/lib/dom/index.js +177 -8
  213. package/lib/dom/interfaces.d.ts +301 -0
  214. package/lib/dom/interfaces.js +5 -0
  215. package/lib/global-module.d.ts +0 -2
  216. package/lib/global-module.js +30 -30
  217. package/lib/index.d.ts +7 -14
  218. package/lib/index.js +44 -135
  219. package/lib/plugins/CullingPlugin.d.ts +2 -2
  220. package/lib/plugins/CullingPlugin.js +14 -16
  221. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -1
  222. package/lib/plugins/DirtyCheckPlugin.js +9 -7
  223. package/lib/plugins/EventPlugin.js +52 -30
  224. package/lib/plugins/FrustumCullingStrategy.d.ts +1 -1
  225. package/lib/plugins/FrustumCullingStrategy.js +5 -4
  226. package/lib/plugins/PrepareRendererPlugin.d.ts +0 -1
  227. package/lib/plugins/PrepareRendererPlugin.js +41 -37
  228. package/lib/property-handlers/aabb.d.ts +2 -3
  229. package/lib/property-handlers/aabb.js +28 -22
  230. package/lib/property-handlers/anchor.d.ts +3 -0
  231. package/lib/property-handlers/anchor.js +34 -0
  232. package/lib/property-handlers/clipPath.d.ts +1 -1
  233. package/lib/property-handlers/clipPath.js +3 -4
  234. package/lib/property-handlers/color.d.ts +1 -1
  235. package/lib/property-handlers/dimension.d.ts +1 -1
  236. package/lib/property-handlers/dimension.js +6 -9
  237. package/lib/property-handlers/filter.d.ts +1 -1
  238. package/lib/property-handlers/index.d.ts +5 -4
  239. package/lib/property-handlers/index.js +14 -0
  240. package/lib/property-handlers/localPosition.d.ts +1 -1
  241. package/lib/property-handlers/localPosition.js +1 -7
  242. package/lib/property-handlers/offsetDistance.d.ts +1 -1
  243. package/lib/property-handlers/offsetPath.d.ts +1 -1
  244. package/lib/property-handlers/origin.d.ts +1 -1
  245. package/lib/property-handlers/origin.js +10 -2
  246. package/lib/property-handlers/path.d.ts +2 -2
  247. package/lib/property-handlers/path.js +8 -4
  248. package/lib/property-handlers/points.d.ts +1 -1
  249. package/lib/property-handlers/transform.d.ts +1 -1
  250. package/lib/property-handlers/zIndex.d.ts +1 -1
  251. package/lib/services/ContextService.d.ts +3 -2
  252. package/lib/services/EventService.d.ts +18 -13
  253. package/lib/services/EventService.js +616 -385
  254. package/lib/services/RenderingContext.d.ts +1 -1
  255. package/lib/services/RenderingService.d.ts +23 -29
  256. package/lib/services/RenderingService.js +66 -56
  257. package/lib/services/SceneGraphSelector.d.ts +7 -7
  258. package/lib/services/SceneGraphSelector.js +10 -6
  259. package/lib/services/SceneGraphService.d.ts +73 -78
  260. package/lib/services/SceneGraphService.js +166 -79
  261. package/lib/services/aabb/PathUpdater.d.ts +1 -1
  262. package/lib/services/aabb/RectUpdater.d.ts +2 -2
  263. package/lib/services/aabb/interfaces.d.ts +1 -1
  264. package/lib/shapes/Point.d.ts +4 -0
  265. package/lib/shapes/Polygon.d.ts +9 -0
  266. package/lib/shapes/Polygon.js +69 -0
  267. package/lib/shapes/index.d.ts +1 -0
  268. package/lib/shapes/index.js +13 -0
  269. package/lib/types.d.ts +18 -6
  270. package/lib/utils/animation.d.ts +1 -2
  271. package/lib/utils/animation.js +8 -16
  272. package/lib/utils/canvas.d.ts +1 -1
  273. package/lib/utils/custom-easing.d.ts +3 -2
  274. package/lib/utils/custom-easing.js +16 -8
  275. package/lib/utils/event.js +1 -1
  276. package/lib/utils/index.d.ts +1 -0
  277. package/lib/utils/index.js +13 -0
  278. package/lib/utils/interpolation.d.ts +3 -4
  279. package/lib/utils/interpolation.js +0 -17
  280. package/lib/utils/path.d.ts +2 -2
  281. package/package.json +6 -6
  282. package/es/Batch.d.ts +0 -25
  283. package/es/Batch.js +0 -82
  284. package/es/shapes-type.d.ts +0 -175
  285. package/es/shapes-type.js +0 -18
  286. package/es/utils/matrix-decompose.d.ts +0 -3
  287. package/es/utils/matrix-decompose.js +0 -404
  288. package/lib/Batch.d.ts +0 -25
  289. package/lib/Batch.js +0 -91
  290. package/lib/shapes-type.d.ts +0 -175
  291. package/lib/shapes-type.js +0 -41
  292. package/lib/utils/matrix-decompose.d.ts +0 -3
  293. package/lib/utils/matrix-decompose.js +0 -414
@@ -11,23 +11,33 @@ var _util = require("@antv/util");
11
11
 
12
12
  var _glMatrix = require("gl-matrix");
13
13
 
14
- var _components = require("./components");
14
+ var _DisplayObjectPool = require("../DisplayObjectPool");
15
15
 
16
- var _math = require("./utils/math");
16
+ var _dom = require("../dom");
17
17
 
18
- var _types = require("./types");
18
+ var _2 = require("..");
19
19
 
20
- var _DisplayObjectPool = require("./DisplayObjectPool");
20
+ var _utils = require("../utils");
21
21
 
22
- var _inversify = require("./inversify.config");
22
+ var _components = require("../components");
23
23
 
24
- var _propertyHandlers = require("./property-handlers");
24
+ var _propertyHandlers = require("../property-handlers");
25
25
 
26
- var _Element = require("./dom/Element");
26
+ var _services = require("../services");
27
27
 
28
+ var DEFAULT_STYLE_PROPS = {
29
+ anchor: [0, 0, 0],
30
+ origin: [0, 0, 0],
31
+ opacity: 1,
32
+ fillOpacity: 1,
33
+ strokeOpacity: 1
34
+ };
28
35
  /**
29
36
  * prototype chains: DisplayObject -> Element -> Node -> EventTarget
30
37
  *
38
+ * mixins: Animatable, Transformable, Visible
39
+ * @see https://github.com/tannerntannern/ts-mixer/blob/master/README.md#mixing-generic-classes
40
+ *
31
41
  * Provide abilities in scene graph, such as:
32
42
  * * transform `translate/rotate/scale`
33
43
  * * add/remove child
@@ -40,33 +50,25 @@ var _Element = require("./dom/Element");
40
50
  * * destroy
41
51
  * * attributeChanged
42
52
  */
53
+
43
54
  var DisplayObject = function (_super) {
44
55
  (0, _tslib.__extends)(DisplayObject, _super);
45
56
 
46
57
  function DisplayObject(config) {
47
58
  var _a, _b, _c;
48
59
 
49
- var _this = _super.call(this) || this;
50
-
51
- _this.shadow = false;
52
- _this.displayObjectPool = _inversify.container.get(_DisplayObjectPool.DisplayObjectPool);
53
- _this.stylePropertyUpdaterFactory = _inversify.container.get(_propertyHandlers.StylePropertyUpdaterFactory);
54
- _this.stylePropertyParserFactory = _inversify.container.get(_propertyHandlers.StylePropertyParserFactory);
55
- /** scene graph operations */
56
-
57
- _this.scrollLeft = 0;
58
- _this.scrollTop = 0;
60
+ var _this = _super.call(this, config) || this;
59
61
  /**
60
- * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/dataset
62
+ * push to active animations after calling `animate()`
61
63
  */
62
64
 
63
- _this.dataset = {}; // assign name, id to config
64
- // eg. group.get('name')
65
-
66
- _this.config = config; // insert this group into pool
67
65
 
68
- _this.displayObjectPool.add(_this.entity.getName(), _this); // compatible with G 3.0
66
+ _this.activeAnimations = [];
67
+ _this.stylePropertyUpdaterFactory = _2.container.get(_propertyHandlers.StylePropertyUpdaterFactory);
68
+ _this.stylePropertyParserFactory = _2.container.get(_propertyHandlers.StylePropertyParserFactory); // assign name, id to config
69
+ // eg. group.get('name')
69
70
 
71
+ _this.config = config; // compatible with G 3.0
70
72
 
71
73
  _this.config.interactive = (_a = _this.config.capture) !== null && _a !== void 0 ? _a : _this.config.interactive; // init scene graph node
72
74
 
@@ -74,14 +76,12 @@ var DisplayObject = function (_super) {
74
76
  _this.name = _this.config.name || '';
75
77
  _this.className = _this.config.className || '';
76
78
  _this.interactive = (_b = _this.config.interactive) !== null && _b !== void 0 ? _b : true;
77
- _this.nodeName = _this.config.type || _types.SHAPE.Group;
78
- _this.attributes; // compatible with G 3.0
79
- // @ts-ignore
79
+ _this.nodeName = _this.config.type || _2.SHAPE.Group; // compatible with G 3.0
80
80
 
81
- _this.config.style = (0, _tslib.__assign)((0, _tslib.__assign)({
81
+ _this.config.style = (0, _tslib.__assign)((0, _tslib.__assign)((0, _tslib.__assign)((0, _tslib.__assign)({}, DEFAULT_STYLE_PROPS), {
82
82
  zIndex: (_c = _this.config.zIndex) !== null && _c !== void 0 ? _c : 0,
83
83
  visibility: _this.config.visible === false ? 'hidden' : 'visible'
84
- }, _this.config.style), _this.config.attrs);
84
+ }), _this.config.style), _this.config.attrs);
85
85
  _this.style = new Proxy(_this.attributes, {
86
86
  get: function get(_, prop) {
87
87
  return _this.getAttribute(prop);
@@ -93,179 +93,172 @@ var DisplayObject = function (_super) {
93
93
  }
94
94
  });
95
95
 
96
- _this.initAttributes(_this.config.style);
96
+ _this.initAttributes(_this.config.style); // insert this group into pool
97
97
 
98
- _this.on(_Element.DISPLAY_OBJECT_EVENT.ChildInserted, function (child) {
99
- // when appending to document
100
- if (_this.ownerDocument && _this.ownerDocument.documentElement === _this && _this.ownerDocument.defaultView) {
101
- _this.ownerDocument.defaultView.decorate(child, _this.ownerDocument.defaultView.getRenderingService(), _this);
102
- }
103
- });
98
+
99
+ _2.container.get(_DisplayObjectPool.DisplayObjectPool).add(_this.entity.getName(), _this);
104
100
 
105
101
  return _this;
106
102
  }
107
- /**
108
- * compatible with G 3.0
109
- * @deprecated
110
- */
111
103
 
104
+ DisplayObject.prototype.destroy = function () {
105
+ _super.prototype.destroy.call(this); // remove from into pool
112
106
 
113
- DisplayObject.prototype.set = function (name, value) {
114
- this.config[name] = value;
115
- };
116
107
 
117
- DisplayObject.prototype.get = function (name) {
118
- return this.config[name];
119
- };
108
+ _2.container.get(_DisplayObjectPool.DisplayObjectPool).remove(this.entity.getName()); // stop all active animations
120
109
 
121
- DisplayObject.prototype.getConfig = function () {
122
- return this.config;
123
- };
124
110
 
125
- DisplayObject.prototype.attr = function () {
126
- var _this = this;
111
+ this.getAnimations().forEach(function (animation) {
112
+ animation.cancel();
113
+ });
114
+ };
127
115
 
128
- var args = [];
116
+ DisplayObject.prototype.cloneNode = function (deep) {
117
+ var cloned = new this.constructor({
118
+ // copy id & name
119
+ // @see https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
120
+ id: this.id,
121
+ name: this.name,
122
+ className: this.name,
123
+ interactive: this.interactive,
124
+ style: (0, _tslib.__assign)({}, this.style)
125
+ });
129
126
 
130
- for (var _i = 0; _i < arguments.length; _i++) {
131
- args[_i] = arguments[_i];
127
+ if (deep) {
128
+ this.children.forEach(function (child) {
129
+ var clonedChild = child.cloneNode(deep);
130
+ cloned.appendChild(clonedChild);
131
+ });
132
132
  }
133
133
 
134
- var _a = (0, _tslib.__read)(args, 2),
135
- name = _a[0],
136
- value = _a[1];
134
+ return cloned;
135
+ };
137
136
 
138
- if (!name) {
139
- return this.attributes;
140
- }
137
+ DisplayObject.prototype.initAttributes = function (attributes) {
138
+ var _this = this;
141
139
 
142
- if ((0, _util.isObject)(name)) {
143
- Object.keys(name).forEach(function (key) {
144
- _this.setAttribute(key, name[key]);
145
- });
146
- return this;
140
+ if (attributes === void 0) {
141
+ attributes = {};
147
142
  }
148
143
 
149
- if (args.length === 2) {
150
- this.setAttribute(name, value);
151
- return this;
152
- }
144
+ var renderable = this.entity.getComponent(_components.Renderable); // parse attributes first
153
145
 
154
- return this.attributes[name];
155
- };
156
- /**
157
- * @deprecated
158
- * compatible with G 3.0
159
- * @deprecated
160
- */
146
+ for (var attributeName in attributes) {
147
+ var value = attributes[attributeName];
148
+ this.attributes[attributeName] = value; // @ts-ignore
161
149
 
150
+ this.parseStyleProperty(attributeName, value);
151
+ }
162
152
 
163
- DisplayObject.prototype.getCount = function () {
164
- return this.childElementCount;
165
- };
166
- /**
167
- * @deprecated
168
- * compatible with G 3.0
169
- * @deprecated
170
- */
153
+ var priorities = {
154
+ x: 1000,
155
+ y: 1000
156
+ }; // update x, y at last
171
157
 
158
+ var sortedNames = Object.keys(attributes).sort(function (a, b) {
159
+ return (priorities[a] || 0) - (priorities[b] || 0);
160
+ });
161
+ sortedNames.forEach(function (attributeName) {
162
+ // @ts-ignore
163
+ _this.updateStyleProperty(attributeName, undefined, _this.parsedStyle[attributeName]);
164
+ }); // redraw at next frame
172
165
 
173
- DisplayObject.prototype.getParent = function () {
174
- return this.parentNode;
166
+ renderable.dirty = true;
175
167
  };
176
- /**
177
- * @deprecated
178
- * compatible with G 3.0
179
- * @deprecated
180
- */
181
168
 
169
+ DisplayObject.prototype.setAttribute = function (attributeName, value, force) {
170
+ if (force === void 0) {
171
+ force = false;
172
+ }
182
173
 
183
- DisplayObject.prototype.getChildren = function () {
184
- return this.children;
174
+ if (force || !(0, _util.isEqual)(value, this.attributes[attributeName]) || attributeName === 'transformOrigin' || attributeName === 'visibility' // will affect children
175
+ ) {
176
+ if (attributeName === 'visibility') {
177
+ // set value cascade
178
+ this.forEach(function (object) {
179
+ object.changeAttribute(attributeName, value);
180
+ });
181
+ } else {
182
+ this.changeAttribute(attributeName, value);
183
+ }
184
+
185
+ _super.prototype.setAttribute.call(this, attributeName, value);
186
+ }
185
187
  };
186
188
  /**
187
- * @deprecated
188
- * compatible with G 3.0
189
- * @deprecated
189
+ * parse property, eg.
190
+ * * fill: 'red' => [1, 0, 0, 1]
191
+ * * translateX: '10px' => { unit: 'px', value: 10 }
190
192
  */
191
193
 
192
194
 
193
- DisplayObject.prototype.getFirst = function () {
194
- return this.firstChild;
195
+ DisplayObject.prototype.parseStyleProperty = function (name, value) {
196
+ var stylePropertyParser = this.stylePropertyParserFactory(name);
197
+
198
+ if (stylePropertyParser) {
199
+ // @ts-ignore
200
+ this.parsedStyle[name] = stylePropertyParser(value, this);
201
+ } else {
202
+ this.parsedStyle[name] = value;
203
+ }
195
204
  };
196
- /**
197
- * @deprecated
198
- * compatible with G 3.0
199
- * @deprecated
200
- * get last child group/shape
201
- */
202
205
 
206
+ DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
207
+ var _this = this; // update property, which may cause AABB re-calc
208
+ // @ts-ignore
203
209
 
204
- DisplayObject.prototype.getLast = function () {
205
- return this.lastChild;
206
- };
207
- /**
208
- * @deprecated
209
- * compatible with G 3.0
210
- * @deprecated
211
- * get child group/shape by index
212
- */
213
210
 
211
+ var stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
214
212
 
215
- DisplayObject.prototype.getChildByIndex = function (index) {
216
- return this.children[index] || null;
213
+ if (stylePropertyUpdaters) {
214
+ stylePropertyUpdaters.forEach(function (updater) {
215
+ // @ts-ignore
216
+ updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService);
217
+ });
218
+ }
217
219
  };
218
220
  /**
219
- * compatible with G 3.0
220
- * @deprecated
221
+ * called when attributes get changed or initialized
221
222
  */
222
223
 
223
224
 
224
- DisplayObject.prototype.add = function (child, index) {
225
- this.appendChild(child, index);
226
- };
227
- /** transform operations */
228
-
225
+ DisplayObject.prototype.changeAttribute = function (name, value) {
226
+ var _this = this;
229
227
 
230
- DisplayObject.prototype.setOrigin = function (position, y, z) {
231
- if (y === void 0) {
232
- y = 0;
233
- }
228
+ var entity = this.getEntity();
229
+ var renderable = entity.getComponent(_components.Renderable);
230
+ var oldValue = this.attributes[name]; // @ts-ignore
234
231
 
235
- if (z === void 0) {
236
- z = 0;
237
- }
232
+ var oldParsedValue = this.parsedStyle[name]; // update value
238
233
 
239
- this.sceneGraphService.setOrigin(this, (0, _math.createVec3)(position, y, z));
240
- return this;
241
- };
234
+ this.attributes[name] = value; // @ts-ignore
242
235
 
243
- DisplayObject.prototype.getOrigin = function () {
244
- return this.sceneGraphService.getOrigin(this);
245
- };
246
- /**
247
- * alias setPosition
248
- */
236
+ this.parseStyleProperty(name, value); // @ts-ignore
249
237
 
238
+ this.updateStyleProperty(name, oldParsedValue, this.parsedStyle[name]); // inform clip path targets
250
239
 
251
- DisplayObject.prototype.moveTo = function (position, y, z) {
252
- if (y === void 0) {
253
- y = 0;
254
- }
240
+ if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
241
+ this.attributes.clipPathTargets.forEach(function (target) {
242
+ (0, _services.dirtifyRenderable)(target);
243
+ target.emit(_dom.ElementEvent.ATTRIBUTE_CHANGED, {
244
+ attributeName: 'clipPath',
245
+ oldValue: _this,
246
+ newValue: _this
247
+ });
248
+ });
249
+ } // redraw at next frame
255
250
 
256
- if (z === void 0) {
257
- z = 0;
258
- }
259
251
 
260
- this.setPosition(position, y, z);
261
- return this;
262
- };
263
- /**
264
- * alias setPosition
265
- */
252
+ renderable.dirty = true;
253
+ this.emit(_dom.ElementEvent.ATTRIBUTE_CHANGED, {
254
+ attributeName: name,
255
+ oldValue: oldValue,
256
+ newValue: value
257
+ });
258
+ }; // #region transformable
266
259
 
267
260
 
268
- DisplayObject.prototype.move = function (position, y, z) {
261
+ DisplayObject.prototype.setOrigin = function (position, y, z) {
269
262
  if (y === void 0) {
270
263
  y = 0;
271
264
  }
@@ -274,12 +267,15 @@ var DisplayObject = function (_super) {
274
267
  z = 0;
275
268
  }
276
269
 
277
- this.setPosition(position, y, z);
270
+ this.sceneGraphService.setOrigin(this, (0, _utils.createVec3)(position, y, z));
271
+ this.attributes.origin = this.getOrigin();
278
272
  return this;
279
273
  };
274
+
275
+ DisplayObject.prototype.getOrigin = function () {
276
+ return this.sceneGraphService.getOrigin(this);
277
+ };
280
278
  /**
281
- * compatible with G 3.0
282
- *
283
279
  * set position in world space
284
280
  */
285
281
 
@@ -293,7 +289,7 @@ var DisplayObject = function (_super) {
293
289
  z = 0;
294
290
  }
295
291
 
296
- this.sceneGraphService.setPosition(this, (0, _math.createVec3)(position, y, z));
292
+ this.sceneGraphService.setPosition(this, (0, _utils.createVec3)(position, y, z));
297
293
  this.syncLocalPosition();
298
294
  return this;
299
295
  };
@@ -311,7 +307,7 @@ var DisplayObject = function (_super) {
311
307
  z = 0;
312
308
  }
313
309
 
314
- this.sceneGraphService.setLocalPosition(this, (0, _math.createVec3)(position, y, z));
310
+ this.sceneGraphService.setLocalPosition(this, (0, _utils.createVec3)(position, y, z));
315
311
  this.syncLocalPosition();
316
312
  return this;
317
313
  };
@@ -329,7 +325,7 @@ var DisplayObject = function (_super) {
329
325
  z = 0;
330
326
  }
331
327
 
332
- this.sceneGraphService.translate(this, (0, _math.createVec3)(position, y, z));
328
+ this.sceneGraphService.translate(this, (0, _utils.createVec3)(position, y, z));
333
329
  this.syncLocalPosition();
334
330
  return this;
335
331
  };
@@ -347,7 +343,7 @@ var DisplayObject = function (_super) {
347
343
  z = 0;
348
344
  }
349
345
 
350
- this.sceneGraphService.translateLocal(this, (0, _math.createVec3)(position, y, z));
346
+ this.sceneGraphService.translateLocal(this, (0, _utils.createVec3)(position, y, z));
351
347
  this.syncLocalPosition();
352
348
  return this;
353
349
  };
@@ -377,7 +373,7 @@ var DisplayObject = function (_super) {
377
373
  if (typeof scaling === 'number') {
378
374
  y = y || scaling;
379
375
  z = z || scaling;
380
- scaling = (0, _math.createVec3)(scaling, y, z);
376
+ scaling = (0, _utils.createVec3)(scaling, y, z);
381
377
  }
382
378
 
383
379
  this.sceneGraphService.scaleLocal(this, scaling);
@@ -392,7 +388,7 @@ var DisplayObject = function (_super) {
392
388
  if (typeof scaling === 'number') {
393
389
  y = y || scaling;
394
390
  z = z || scaling;
395
- scaling = (0, _math.createVec3)(scaling, y, z);
391
+ scaling = (0, _utils.createVec3)(scaling, y, z);
396
392
  }
397
393
 
398
394
  this.sceneGraphService.setLocalScale(this, scaling);
@@ -420,14 +416,13 @@ var DisplayObject = function (_super) {
420
416
 
421
417
 
422
418
  DisplayObject.prototype.getEulerAngles = function () {
423
- var transform = this.entity.getComponent(_components.Transform); // eslint-disable-next-line @typescript-eslint/no-unused-vars
424
-
425
- var _a = (0, _tslib.__read)((0, _math.getEuler)(_glMatrix.vec3.create(), this.sceneGraphService.getWorldTransform(this, transform)), 3),
419
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
420
+ var _a = (0, _tslib.__read)((0, _utils.getEuler)(_glMatrix.vec3.create(), this.sceneGraphService.getWorldTransform(this)), 3),
426
421
  ex = _a[0],
427
422
  ey = _a[1],
428
423
  ez = _a[2];
429
424
 
430
- return (0, _math.rad2deg)(ez);
425
+ return (0, _utils.rad2deg)(ez);
431
426
  };
432
427
  /**
433
428
  * only return degrees of Z axis in local space
@@ -436,12 +431,12 @@ var DisplayObject = function (_super) {
436
431
 
437
432
  DisplayObject.prototype.getLocalEulerAngles = function () {
438
433
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
439
- var _a = (0, _tslib.__read)((0, _math.getEuler)(_glMatrix.vec3.create(), this.sceneGraphService.getLocalRotation(this)), 3),
434
+ var _a = (0, _tslib.__read)((0, _utils.getEuler)(_glMatrix.vec3.create(), this.sceneGraphService.getLocalRotation(this)), 3),
440
435
  ex = _a[0],
441
436
  ey = _a[1],
442
437
  ez = _a[2];
443
438
 
444
- return (0, _math.rad2deg)(ez);
439
+ return (0, _utils.rad2deg)(ez);
445
440
  };
446
441
  /**
447
442
  * set euler angles(degrees) in world space
@@ -497,80 +492,83 @@ var DisplayObject = function (_super) {
497
492
  DisplayObject.prototype.getWorldTransform = function () {
498
493
  return this.sceneGraphService.getWorldTransform(this);
499
494
  };
495
+
496
+ DisplayObject.prototype.resetLocalTransform = function () {
497
+ this.sceneGraphService.resetLocalTransform(this);
498
+ };
500
499
  /**
501
- * return 3x3 matrix in world space
502
- * @deprecated
500
+ * sync style.x/y when local position changed
501
+ *
502
+ * Mixins may not declare private/protected properties
503
+ * however, you can use ES2020 private fields
503
504
  */
504
505
 
505
506
 
506
- DisplayObject.prototype.getMatrix = function () {
507
- var transform = this.getWorldTransform();
508
-
509
- var _a = (0, _tslib.__read)(_glMatrix.mat4.getTranslation(_glMatrix.vec3.create(), transform), 2),
510
- tx = _a[0],
511
- ty = _a[1];
512
-
513
- var _b = (0, _tslib.__read)(_glMatrix.mat4.getScaling(_glMatrix.vec3.create(), transform), 2),
514
- sx = _b[0],
515
- sy = _b[1];
516
-
517
- var rotation = _glMatrix.mat4.getRotation(_glMatrix.quat.create(), transform);
507
+ DisplayObject.prototype.syncLocalPosition = function () {
508
+ var localPosition = this.getLocalPosition();
509
+ this.attributes.x = localPosition[0];
510
+ this.attributes.y = localPosition[1];
511
+ }; // #endregion transformable
512
+ // #region animatable
518
513
 
519
- var _c = (0, _tslib.__read)((0, _math.getEuler)(_glMatrix.vec3.create(), rotation), 3),
520
- eux = _c[0],
521
- euy = _c[1],
522
- euz = _c[2]; // gimbal lock at 90 degrees
514
+ /**
515
+ * returns an array of all Animation objects affecting this element
516
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Element/getAnimations
517
+ */
523
518
 
524
519
 
525
- return (0, _math.fromRotationTranslationScale)(eux || euz, tx, ty, sx, sy);
520
+ DisplayObject.prototype.getAnimations = function () {
521
+ return this.activeAnimations;
526
522
  };
527
523
  /**
528
- * set 3x3 matrix in world space
529
- * @deprecated
524
+ * create an animation with WAAPI
525
+ * @see https://developer.mozilla.org/zh-CN/docs/Web/API/Element/animate
530
526
  */
531
527
 
532
528
 
533
- DisplayObject.prototype.setMatrix = function (mat) {
534
- var row0x = mat[0];
535
- var row0y = mat[3];
536
- var row1x = mat[1];
537
- var row1y = mat[4]; // decompose 3x3 matrix
538
- // @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
529
+ DisplayObject.prototype.animate = function (keyframes, options) {
530
+ var _a, _b;
539
531
 
540
- var scalingX = Math.sqrt(row0x * row0x + row0y * row0y);
541
- var scalingY = Math.sqrt(row1x * row1x + row1y * row1y); // If determinant is negative, one axis was flipped.
532
+ var timeline = (_a = this.ownerDocument) === null || _a === void 0 ? void 0 : _a.timeline; // accounte for clip path, use target's timeline
542
533
 
543
- var determinant = row0x * row1y - row0y * row1x;
534
+ if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
535
+ var target = this.attributes.clipPathTargets[0];
536
+ timeline = (_b = target.ownerDocument) === null || _b === void 0 ? void 0 : _b.timeline;
537
+ } // clear old parsed transform
544
538
 
545
- if (determinant < 0) {
546
- // Flip axis with minimum unit vector dot product.
547
- if (row0x < row1y) {
548
- scalingX = -scalingX;
549
- } else {
550
- scalingY = -scalingY;
551
- }
552
- } // Renormalize matrix to remove scale.
553
539
 
540
+ this.parsedStyle.transform = undefined;
554
541
 
555
- if (scalingX) {
556
- row0x *= 1 / scalingX;
557
- row0y *= 1 / scalingX;
542
+ if (timeline) {
543
+ return timeline.play(new _dom.KeyframeEffect(this, keyframes, options));
558
544
  }
559
545
 
560
- if (scalingY) {
561
- row1x *= 1 / scalingY;
562
- row1y *= 1 / scalingY;
563
- } // Compute rotation and renormalize matrix.
546
+ return null;
547
+ }; // #endregion animatable
548
+ // #region visible
564
549
 
550
+ /**
551
+ * show group, which will also change visibility of its children in sceneGraphNode
552
+ *
553
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility
554
+ */
565
555
 
566
- var angle = Math.atan2(row0y, row0x);
567
- this.setEulerAngles(angle).setPosition(mat[6], mat[7]).setLocalScale(scalingX, scalingY);
556
+
557
+ DisplayObject.prototype.show = function () {
558
+ this.style.visibility = 'visible';
568
559
  };
569
- /* z-index & visibility */
560
+ /**
561
+ * hide group, which will also change visibility of its children in sceneGraphNode
562
+ */
570
563
 
571
564
 
572
- DisplayObject.prototype.setZIndex = function (zIndex) {
573
- this.style.zIndex = zIndex;
565
+ DisplayObject.prototype.hide = function () {
566
+ this.style.visibility = 'hidden';
567
+ };
568
+
569
+ DisplayObject.prototype.isVisible = function () {
570
+ var cullable = this.entity.getComponent(_components.Cullable);
571
+ return this.style.visibility === 'visible' && (!cullable || cullable && !cullable.isCulled());
574
572
  };
575
573
  /**
576
574
  * bring to front in current group
@@ -579,11 +577,12 @@ var DisplayObject = function (_super) {
579
577
 
580
578
  DisplayObject.prototype.toFront = function () {
581
579
  if (this.parentNode) {
582
- var zIndex = Math.max.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(this.parentNode.children.map(function (child) {
580
+ this.style.zIndex = Math.max.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(this.parentNode.children.map(function (child) {
583
581
  return Number(child.style.zIndex);
584
582
  })))) + 1;
585
- this.setZIndex(zIndex);
586
583
  }
584
+
585
+ return this;
587
586
  };
588
587
  /**
589
588
  * send to back in current group
@@ -592,34 +591,85 @@ var DisplayObject = function (_super) {
592
591
 
593
592
  DisplayObject.prototype.toBack = function () {
594
593
  if (this.parentNode) {
595
- var zIndex = Math.min.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(this.parentNode.children.map(function (child) {
594
+ this.style.zIndex = Math.min.apply(Math, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(this.parentNode.children.map(function (child) {
596
595
  return Number(child.style.zIndex);
597
596
  })))) - 1;
598
- this.setZIndex(zIndex);
599
597
  }
598
+
599
+ return this;
600
+ }; // #endregion visible
601
+ // #region deprecated
602
+
603
+ /**
604
+ * @deprecated
605
+ * compatible with G 3.0
606
+ * @deprecated
607
+ */
608
+
609
+
610
+ DisplayObject.prototype.getCount = function () {
611
+ return this.childElementCount;
600
612
  };
601
613
  /**
602
- * show group, which will also change visibility of its children in sceneGraphNode
603
- *
604
- * @see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility
614
+ * @deprecated
615
+ * compatible with G 3.0
616
+ * @deprecated
605
617
  */
606
618
 
607
619
 
608
- DisplayObject.prototype.show = function () {
609
- this.style.visibility = 'visible';
620
+ DisplayObject.prototype.getParent = function () {
621
+ return this.parentElement;
610
622
  };
611
623
  /**
612
- * hide group, which will also change visibility of its children in sceneGraphNode
624
+ * @deprecated
625
+ * compatible with G 3.0
626
+ * @deprecated
613
627
  */
614
628
 
615
629
 
616
- DisplayObject.prototype.hide = function () {
617
- this.style.visibility = 'hidden';
630
+ DisplayObject.prototype.getChildren = function () {
631
+ return this.children;
632
+ };
633
+ /**
634
+ * @deprecated
635
+ * compatible with G 3.0
636
+ * @deprecated
637
+ */
638
+
639
+
640
+ DisplayObject.prototype.getFirst = function () {
641
+ return this.firstElementChild;
618
642
  };
643
+ /**
644
+ * @deprecated
645
+ * compatible with G 3.0
646
+ * @deprecated
647
+ * get last child group/shape
648
+ */
619
649
 
620
- DisplayObject.prototype.isVisible = function () {
621
- var cullable = this.getEntity().getComponent(_components.Cullable);
622
- return this.style.visibility === 'visible' && (!cullable || cullable && !cullable.isCulled());
650
+
651
+ DisplayObject.prototype.getLast = function () {
652
+ return this.lastElementChild;
653
+ };
654
+ /**
655
+ * @deprecated
656
+ * compatible with G 3.0
657
+ * @deprecated
658
+ * get child group/shape by index
659
+ */
660
+
661
+
662
+ DisplayObject.prototype.getChildByIndex = function (index) {
663
+ return this.children[index] || null;
664
+ };
665
+ /**
666
+ * compatible with G 3.0
667
+ * @deprecated
668
+ */
669
+
670
+
671
+ DisplayObject.prototype.add = function (child, index) {
672
+ return this.appendChild(child, index);
623
673
  };
624
674
  /**
625
675
  * @alias style.clipPath
@@ -637,116 +687,185 @@ var DisplayObject = function (_super) {
637
687
 
638
688
 
639
689
  DisplayObject.prototype.getClip = function () {
640
- return this.style.clipPath;
690
+ return this.style.clipPath || null;
641
691
  };
642
692
  /**
643
- * parse property, eg.
644
- * * fill: 'red' => [1, 0, 0, 1]
645
- * * translateX: '10px' => { unit: 'px', value: 10 }
693
+ * compatible with G 3.0
694
+ * @deprecated
646
695
  */
647
696
 
648
697
 
649
- DisplayObject.prototype.parseStyleProperty = function (name, value) {
650
- var stylePropertyParser = this.stylePropertyParserFactory(name);
698
+ DisplayObject.prototype.set = function (name, value) {
699
+ this.config[name] = value;
700
+ };
701
+ /**
702
+ * compatible with G 3.0
703
+ * @deprecated
704
+ */
651
705
 
652
- if (stylePropertyParser) {
653
- this.parsedStyle[name] = stylePropertyParser(value, this);
654
- } else {
655
- this.parsedStyle[name] = value;
656
- }
706
+
707
+ DisplayObject.prototype.get = function (name) {
708
+ return this.config[name];
657
709
  };
710
+ /**
711
+ * compatible with G 3.0
712
+ * @alias object.config
713
+ * @deprecated
714
+ */
658
715
 
659
- DisplayObject.prototype.updateStyleProperty = function (name, oldParsedValue, newParsedValue) {
660
- var _this = this; // update property, which may cause AABB re-calc
661
- // @ts-ignore
662
716
 
717
+ DisplayObject.prototype.getConfig = function () {
718
+ return this.config;
719
+ };
663
720
 
664
- var stylePropertyUpdaters = this.stylePropertyUpdaterFactory(name);
721
+ DisplayObject.prototype.attr = function () {
722
+ var _this = this;
665
723
 
666
- if (stylePropertyUpdaters) {
667
- stylePropertyUpdaters.forEach(function (updater) {
668
- updater(oldParsedValue, newParsedValue, _this, _this.sceneGraphService);
724
+ var args = [];
725
+
726
+ for (var _i = 0; _i < arguments.length; _i++) {
727
+ args[_i] = arguments[_i];
728
+ }
729
+
730
+ var _a = (0, _tslib.__read)(args, 2),
731
+ name = _a[0],
732
+ value = _a[1];
733
+
734
+ if (!name) {
735
+ return this.attributes;
736
+ }
737
+
738
+ if ((0, _util.isObject)(name)) {
739
+ Object.keys(name).forEach(function (key) {
740
+ _this.setAttribute(key, name[key]);
669
741
  });
742
+ return this;
743
+ }
744
+
745
+ if (args.length === 2) {
746
+ this.setAttribute(name, value);
747
+ return this;
670
748
  }
749
+
750
+ return this.attributes[name];
671
751
  };
672
752
  /**
673
- * called when attributes get changed or initialized
753
+ * @alias setPosition
754
+ * @deprecated
674
755
  */
675
756
 
676
757
 
677
- DisplayObject.prototype.changeAttribute = function (name, value) {
678
- var _this = this;
758
+ DisplayObject.prototype.moveTo = function (position, y, z) {
759
+ if (y === void 0) {
760
+ y = 0;
761
+ }
679
762
 
680
- var entity = this.getEntity();
681
- var renderable = entity.getComponent(_components.Renderable);
682
- var oldValue = this.attributes[name]; // @ts-ignore
763
+ if (z === void 0) {
764
+ z = 0;
765
+ }
683
766
 
684
- var oldParsedValue = this.parsedStyle[name]; // update value
767
+ this.setPosition(position, y, z);
768
+ return this;
769
+ };
770
+ /**
771
+ * @alias setPosition
772
+ * @deprecated
773
+ */
685
774
 
686
- this.attributes[name] = value; // @ts-ignore
687
775
 
688
- this.parseStyleProperty(name, value); // @ts-ignore
776
+ DisplayObject.prototype.move = function (position, y, z) {
777
+ if (y === void 0) {
778
+ y = 0;
779
+ }
689
780
 
690
- this.updateStyleProperty(name, oldParsedValue, this.parsedStyle[name]); // inform clip path targets
781
+ if (z === void 0) {
782
+ z = 0;
783
+ }
691
784
 
692
- if (this.attributes.clipPathTargets && this.attributes.clipPathTargets.length) {
693
- this.attributes.clipPathTargets.forEach(function (target) {
694
- var targetRenderable = target.getEntity().getComponent(_components.Renderable);
695
- targetRenderable.dirty = true;
696
- targetRenderable.aabbDirty = true;
697
- target.emitter.emit(_Element.DISPLAY_OBJECT_EVENT.AttributeChanged, 'clipPath', _this, _this, target);
698
- });
699
- } // redraw at next frame
785
+ this.setPosition(position, y, z);
786
+ return this;
787
+ };
788
+ /**
789
+ * @alias style.zIndex
790
+ * @deprecated
791
+ */
700
792
 
701
793
 
702
- renderable.dirty = true;
703
- this.emitter.emit(_Element.DISPLAY_OBJECT_EVENT.AttributeChanged, name, oldValue, value, this);
794
+ DisplayObject.prototype.setZIndex = function (zIndex) {
795
+ this.style.zIndex = zIndex;
796
+ return this;
704
797
  };
798
+ /**
799
+ * return 3x3 matrix in world space
800
+ * @deprecated
801
+ */
705
802
 
706
- DisplayObject.prototype.initAttributes = function (attributes) {
707
- var _this = this;
708
803
 
709
- if (attributes === void 0) {
710
- attributes = {};
711
- }
804
+ DisplayObject.prototype.getMatrix = function () {
805
+ var transform = this.getWorldTransform();
712
806
 
713
- var entity = this.getEntity();
714
- var renderable = entity.getComponent(_components.Renderable); // parse attributes first
807
+ var _a = (0, _tslib.__read)(_glMatrix.mat4.getTranslation(_glMatrix.vec3.create(), transform), 2),
808
+ tx = _a[0],
809
+ ty = _a[1];
715
810
 
716
- for (var attributeName in attributes) {
717
- var value = attributes[attributeName];
718
- this.attributes[attributeName] = value; // @ts-ignore
811
+ var _b = (0, _tslib.__read)(_glMatrix.mat4.getScaling(_glMatrix.vec3.create(), transform), 2),
812
+ sx = _b[0],
813
+ sy = _b[1];
719
814
 
720
- this.parseStyleProperty(attributeName, value);
721
- }
815
+ var rotation = _glMatrix.mat4.getRotation(_glMatrix.quat.create(), transform);
722
816
 
723
- var priorities = {
724
- x: 1000,
725
- y: 1000
726
- }; // update x, y at last
817
+ var _c = (0, _tslib.__read)((0, _utils.getEuler)(_glMatrix.vec3.create(), rotation), 3),
818
+ eux = _c[0],
819
+ euy = _c[1],
820
+ euz = _c[2]; // gimbal lock at 90 degrees
727
821
 
728
- var sortedNames = Object.keys(attributes).sort(function (a, b) {
729
- return (priorities[a] || 0) - (priorities[b] || 0);
730
- });
731
- sortedNames.forEach(function (attributeName) {
732
- // @ts-ignore
733
- _this.updateStyleProperty(attributeName, undefined, _this.parsedStyle[attributeName]);
734
- }); // redraw at next frame
735
822
 
736
- renderable.dirty = true;
823
+ return (0, _utils.fromRotationTranslationScale)(eux || euz, tx, ty, sx, sy);
737
824
  };
738
825
  /**
739
- * sync style.x/y when local position changed
826
+ * set 3x3 matrix in world space
827
+ * @deprecated
740
828
  */
741
829
 
742
830
 
743
- DisplayObject.prototype.syncLocalPosition = function () {
744
- var localPosition = this.getLocalPosition();
745
- this.attributes.x = localPosition[0];
746
- this.attributes.y = localPosition[1];
831
+ DisplayObject.prototype.setMatrix = function (mat) {
832
+ var row0x = mat[0];
833
+ var row0y = mat[3];
834
+ var row1x = mat[1];
835
+ var row1y = mat[4]; // decompose 3x3 matrix
836
+ // @see https://www.w3.org/TR/css-transforms-1/#decomposing-a-2d-matrix
837
+
838
+ var scalingX = Math.sqrt(row0x * row0x + row0y * row0y);
839
+ var scalingY = Math.sqrt(row1x * row1x + row1y * row1y); // If determinant is negative, one axis was flipped.
840
+
841
+ var determinant = row0x * row1y - row0y * row1x;
842
+
843
+ if (determinant < 0) {
844
+ // Flip axis with minimum unit vector dot product.
845
+ if (row0x < row1y) {
846
+ scalingX = -scalingX;
847
+ } else {
848
+ scalingY = -scalingY;
849
+ }
850
+ } // Renormalize matrix to remove scale.
851
+
852
+
853
+ if (scalingX) {
854
+ row0x *= 1 / scalingX;
855
+ row0y *= 1 / scalingX;
856
+ }
857
+
858
+ if (scalingY) {
859
+ row1x *= 1 / scalingY;
860
+ row1y *= 1 / scalingY;
861
+ } // Compute rotation and renormalize matrix.
862
+
863
+
864
+ var angle = Math.atan2(row0y, row0x);
865
+ this.setEulerAngles(angle).setPosition(mat[6], mat[7]).setLocalScale(scalingX, scalingY);
747
866
  };
748
867
 
749
868
  return DisplayObject;
750
- }(_Element.Element);
869
+ }(_dom.Element);
751
870
 
752
871
  exports.DisplayObject = DisplayObject;