@antv/g 1.0.0-alpha.3 → 1.0.0-alpha.30

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