@antv/g 1.0.0-alpha.28 → 1.0.0-alpha.29

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